@axiom-lattice/gateway 4.8.0 → 4.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/dist/embed/{embed-page-AgentDetailSideApp-NTLAFO5C.js → embed-page-AgentDetailSideApp-MVSXAG5S.js} +1 -1
  2. package/dist/embed/{embed-page-AgentGovernanceWorkbench-QPVBOMLH.js → embed-page-AgentGovernanceWorkbench-ZEVAVRIQ.js} +1 -1
  3. package/dist/embed/{embed-page-MessageGraph-JAJGMYKH.js → embed-page-MessageGraph-CPZJIKOD.js} +1 -1
  4. package/dist/embed/{embed-page-ReactChart-WUG6TEAZ.js → embed-page-ReactChart-7NQMTFJE.js} +1 -1
  5. package/dist/embed/{embed-page-TasksSideApp-TJI22YGD.js → embed-page-TasksSideApp-CY6NI4DD.js} +1 -1
  6. package/dist/embed/{embed-page-TeamWorkspace-OJJLN5VI.js → embed-page-TeamWorkspace-7GQCMJWF.js} +1 -1
  7. package/dist/embed/{embed-page-TopologyRuntimeView-ZFU4N6TV.js → embed-page-TopologyRuntimeView-5DJPLCLQ.js} +1 -1
  8. package/dist/embed/{embed-page-WorkflowAutomationView-ALXV7VQQ.js → embed-page-WorkflowAutomationView-PDVXZXEF.js} +1 -1
  9. package/dist/embed/embed-page-chunk-3SV3E6X5.js +6986 -0
  10. package/dist/embed/{embed-page-chunk-O72XBKQH.js → embed-page-chunk-BKCIU75D.js} +1 -1
  11. package/dist/embed/{embed-page-chunk-DZQBVJ7Z.js → embed-page-chunk-PZCET7LJ.js} +1 -1
  12. package/dist/embed/{embed-page-chunk-IPIJ2SG6.js → embed-page-chunk-SFHRRNYQ.js} +1 -1
  13. package/dist/embed/{embed-page-chunk-N22EGQAJ.js → embed-page-chunk-ULBEL4OA.js} +1 -1
  14. package/dist/embed/{embed-page-chunk-UT3WYBZH.js → embed-page-chunk-UWL37DAK.js} +1 -1
  15. package/dist/embed/embed-page.js +1 -1
  16. package/dist/index.js +424 -427
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +22 -25
  19. package/dist/index.mjs.map +1 -1
  20. package/package.json +7 -7
  21. package/dist/embed/embed-page-chunk-QMVIL4BJ.js +0 -6991
package/dist/index.js CHANGED
@@ -966,7 +966,7 @@ function outcome(task) {
966
966
  });
967
967
  }
968
968
  async function backfillTopCallerGroup(tasks, top, deps) {
969
- const registry = deps.registry ?? import_core70.taskRunRegistry;
969
+ const registry = deps.registry ?? import_core71.taskRunRegistry;
970
970
  const results = [];
971
971
  const eligible = [];
972
972
  for (const task of tasks) {
@@ -1020,11 +1020,11 @@ async function recoverTask(task, deps) {
1020
1020
  if (task.status !== "in_progress") {
1021
1021
  return { kind: "skipped", reason: "not_in_progress" };
1022
1022
  }
1023
- const registry = deps.registry ?? import_core70.taskRunRegistry;
1023
+ const registry = deps.registry ?? import_core71.taskRunRegistry;
1024
1024
  if (registry.isLive(task.id) || deps.isTaskLive && await deps.isTaskLive(task)) {
1025
1025
  return { kind: "skipped", reason: "live" };
1026
1026
  }
1027
- const { convergedTasks } = await (0, import_core70.reconcileStaleTaskRuns)({
1027
+ const { convergedTasks } = await (0, import_core71.reconcileStaleTaskRuns)({
1028
1028
  tasks: [task],
1029
1029
  actor: "system:on-demand-recovery",
1030
1030
  lifecycle: deps.lifecycle,
@@ -1120,29 +1120,29 @@ async function runOrphanRecovery(deps) {
1120
1120
  deps.log.info("Task orphan recovery complete", { recovered, skipped });
1121
1121
  return { recovered, skipped };
1122
1122
  }
1123
- var import_messages, import_core70;
1123
+ var import_messages, import_core71;
1124
1124
  var init_TopCallerRecovery = __esm({
1125
1125
  "src/services/collaboration/TopCallerRecovery.ts"() {
1126
1126
  "use strict";
1127
1127
  import_messages = require("@langchain/core/messages");
1128
- import_core70 = require("@axiom-lattice/core");
1128
+ import_core71 = require("@axiom-lattice/core");
1129
1129
  }
1130
1130
  });
1131
1131
 
1132
1132
  // src/services/collaboration/taskRunLiveness.ts
1133
1133
  function createTaskRunLiveness() {
1134
1134
  try {
1135
- import_core71.storeLatticeManager.getStoreLattice("default", "lease");
1135
+ import_core72.storeLatticeManager.getStoreLattice("default", "lease");
1136
1136
  } catch {
1137
1137
  return void 0;
1138
1138
  }
1139
1139
  return async (task) => {
1140
1140
  try {
1141
- const store2 = import_core71.storeLatticeManager.getStoreLattice("default", "lease").store;
1142
- if (await store2.get((0, import_core71.taskRunLeaseKey)(task.id))) return true;
1141
+ const store2 = import_core72.storeLatticeManager.getStoreLattice("default", "lease").store;
1142
+ if (await store2.get((0, import_core72.taskRunLeaseKey)(task.id))) return true;
1143
1143
  const threadId = typeof task.context?.thread_id === "string" ? task.context.thread_id : void 0;
1144
1144
  if (threadId && task.ownerId) {
1145
- if (await store2.get((0, import_core71.threadRunLeaseKey)(task.tenantId, task.ownerId, threadId))) return true;
1145
+ if (await store2.get((0, import_core72.threadRunLeaseKey)(task.tenantId, task.ownerId, threadId))) return true;
1146
1146
  }
1147
1147
  return false;
1148
1148
  } catch {
@@ -1150,11 +1150,11 @@ function createTaskRunLiveness() {
1150
1150
  }
1151
1151
  };
1152
1152
  }
1153
- var import_core71;
1153
+ var import_core72;
1154
1154
  var init_taskRunLiveness = __esm({
1155
1155
  "src/services/collaboration/taskRunLiveness.ts"() {
1156
1156
  "use strict";
1157
- import_core71 = require("@axiom-lattice/core");
1157
+ import_core72 = require("@axiom-lattice/core");
1158
1158
  }
1159
1159
  });
1160
1160
 
@@ -1164,7 +1164,7 @@ __export(OrphanRecoveryRuntime_exports, {
1164
1164
  createOrphanRecoveryRuntime: () => createOrphanRecoveryRuntime
1165
1165
  });
1166
1166
  function createOrphanRecoveryRuntime(deps) {
1167
- const lifecycle = deps.lifecycle ?? (0, import_core72.createTaskLifecycleService)({
1167
+ const lifecycle = deps.lifecycle ?? (0, import_core73.createTaskLifecycleService)({
1168
1168
  taskStore: deps.taskStore,
1169
1169
  workItemStore: deps.workItemStore
1170
1170
  });
@@ -1172,7 +1172,7 @@ function createOrphanRecoveryRuntime(deps) {
1172
1172
  async recoverAll() {
1173
1173
  const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();
1174
1174
  return runOrphanRecovery({
1175
- reconcile: () => (0, import_core72.reconcileAllTenantTaskRuns)({
1175
+ reconcile: () => (0, import_core73.reconcileAllTenantTaskRuns)({
1176
1176
  actor: "system:orphan-recovery",
1177
1177
  tenantStore: {
1178
1178
  listTenants: async () => (await deps.tenantStore.getAllTenants()).map((tenant2) => ({ id: tenant2.id }))
@@ -1198,7 +1198,7 @@ function createOrphanRecoveryRuntime(deps) {
1198
1198
  const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();
1199
1199
  return recoverTask(task, {
1200
1200
  lifecycle,
1201
- registry: import_core72.taskRunRegistry,
1201
+ registry: import_core73.taskRunRegistry,
1202
1202
  orphans,
1203
1203
  callerFor: deps.callerFor,
1204
1204
  resume: deps.resume,
@@ -1207,11 +1207,11 @@ function createOrphanRecoveryRuntime(deps) {
1207
1207
  }
1208
1208
  };
1209
1209
  }
1210
- var import_core72;
1210
+ var import_core73;
1211
1211
  var init_OrphanRecoveryRuntime = __esm({
1212
1212
  "src/services/collaboration/OrphanRecoveryRuntime.ts"() {
1213
1213
  "use strict";
1214
- import_core72 = require("@axiom-lattice/core");
1214
+ import_core73 = require("@axiom-lattice/core");
1215
1215
  init_TopCallerRecovery();
1216
1216
  init_projectTaskScope();
1217
1217
  init_taskRunLiveness();
@@ -1227,12 +1227,12 @@ function createRecoveryCallerDeps() {
1227
1227
  return {
1228
1228
  callerFor: async (top, tenantId) => {
1229
1229
  if (!top.assistantId) return void 0;
1230
- const load = import_core73.getAgentClientAsync ?? import_core73.getAgentClient;
1230
+ const load = import_core74.getAgentClientAsync ?? import_core74.getAgentClient;
1231
1231
  const client = await load(tenantId, top.assistantId);
1232
1232
  const config = { configurable: { thread_id: top.threadId, runConfig: { tenantId, assistant_id: top.assistantId } } };
1233
1233
  let agent;
1234
1234
  try {
1235
- agent = import_core73.agentInstanceManager.getAgent({ assistant_id: top.assistantId, thread_id: top.threadId, tenant_id: tenantId });
1235
+ agent = import_core74.agentInstanceManager.getAgent({ assistant_id: top.assistantId, thread_id: top.threadId, tenant_id: tenantId });
1236
1236
  } catch {
1237
1237
  }
1238
1238
  return agent ? { client, config, agent } : { client, config };
@@ -1249,11 +1249,11 @@ function createRecoveryCallerDeps() {
1249
1249
  }
1250
1250
  };
1251
1251
  }
1252
- var import_core73;
1252
+ var import_core74;
1253
1253
  var init_RecoveryCallerDeps = __esm({
1254
1254
  "src/services/collaboration/RecoveryCallerDeps.ts"() {
1255
1255
  "use strict";
1256
- import_core73 = require("@axiom-lattice/core");
1256
+ import_core74 = require("@axiom-lattice/core");
1257
1257
  }
1258
1258
  });
1259
1259
 
@@ -1843,13 +1843,13 @@ function isA2ATaskSnapshot(value) {
1843
1843
  function snapshotSequence(value) {
1844
1844
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
1845
1845
  }
1846
- var import_node_crypto28, import_node_util, import_core74, TASK_STATUS_TO_A2A_STATE, TITLE_MAX_LENGTH, A2ATaskScopeConflictError, A2ATaskStoreAdapter;
1846
+ var import_node_crypto28, import_node_util, import_core75, TASK_STATUS_TO_A2A_STATE, TITLE_MAX_LENGTH, A2ATaskScopeConflictError, A2ATaskStoreAdapter;
1847
1847
  var init_A2ATaskStoreAdapter = __esm({
1848
1848
  "src/services/a2a/A2ATaskStoreAdapter.ts"() {
1849
1849
  "use strict";
1850
1850
  import_node_crypto28 = require("crypto");
1851
1851
  import_node_util = require("util");
1852
- import_core74 = require("@axiom-lattice/core");
1852
+ import_core75 = require("@axiom-lattice/core");
1853
1853
  TASK_STATUS_TO_A2A_STATE = {
1854
1854
  pending: "submitted",
1855
1855
  in_progress: "working",
@@ -1875,7 +1875,7 @@ var init_A2ATaskStoreAdapter = __esm({
1875
1875
  this.workItemStore = options.workItemStore;
1876
1876
  this.lifecycle = options.lifecycle;
1877
1877
  this.scope = options.scope;
1878
- this.runBridge = (0, import_core74.createTaskRunBridge)({
1878
+ this.runBridge = (0, import_core75.createTaskRunBridge)({
1879
1879
  lifecycle: this.lifecycle,
1880
1880
  taskStore: this.taskStore,
1881
1881
  workItemStore: this.workItemStore
@@ -2226,12 +2226,12 @@ function assistantHasGovernedTask(assistant) {
2226
2226
  const allowedTools = taskMiddleware?.allowedTools;
2227
2227
  return !!taskMiddleware && (allowedTools === void 0 || Array.isArray(allowedTools) && (allowedTools.length === 0 || allowedTools.includes("manage_task")));
2228
2228
  }
2229
- var import_uuid11, import_core75, import_protocols35, _AxiomAgentExecutor, AxiomAgentExecutor;
2229
+ var import_uuid11, import_core76, import_protocols35, _AxiomAgentExecutor, AxiomAgentExecutor;
2230
2230
  var init_AxiomAgentExecutor = __esm({
2231
2231
  "src/services/a2a/AxiomAgentExecutor.ts"() {
2232
2232
  "use strict";
2233
2233
  import_uuid11 = require("uuid");
2234
- import_core75 = require("@axiom-lattice/core");
2234
+ import_core76 = require("@axiom-lattice/core");
2235
2235
  import_protocols35 = require("@axiom-lattice/protocols");
2236
2236
  init_a2aFileRefs();
2237
2237
  init_task_file_refs();
@@ -2328,7 +2328,7 @@ var init_AxiomAgentExecutor = __esm({
2328
2328
  await this.taskStore.save(initialTask);
2329
2329
  bus.publish(initialTask);
2330
2330
  try {
2331
- const agent = import_core75.agentInstanceManager.getAgent(this.agentParams(threadId));
2331
+ const agent = import_core76.agentInstanceManager.getAgent(this.agentParams(threadId));
2332
2332
  const requestText = inputFiles.length > 0 ? `${text}
2333
2333
 
2334
2334
  ${formatFileRefsSection(inputFiles)}` : text;
@@ -2516,7 +2516,7 @@ ${formatFileRefsSection(inputFiles)}` : text;
2516
2516
  const threadId = task ? asString2(task.metadata?.threadId) : void 0;
2517
2517
  if (threadId) {
2518
2518
  try {
2519
- const agent = import_core75.agentInstanceManager.getAgent(this.agentParams(threadId));
2519
+ const agent = import_core76.agentInstanceManager.getAgent(this.agentParams(threadId));
2520
2520
  await agent.abort();
2521
2521
  } catch (err) {
2522
2522
  console.warn({
@@ -2890,10 +2890,10 @@ function isAsyncGenerator(value) {
2890
2890
  }
2891
2891
  function registerA2AStandardRoutes(app2, deps) {
2892
2892
  const authService = deps.authService;
2893
- const resolveTasks = deps.getTaskStoreLattice ?? (() => (0, import_core76.getStoreLattice)("default", "task").store);
2894
- const resolveTaskWorkItems = deps.getTaskWorkItemStore ?? (() => (0, import_core76.getStoreLattice)("default", "taskWorkItem").store);
2895
- const getAssistantStore2 = deps.getAssistantStore ?? (() => (0, import_core76.getStoreLattice)("default", "assistant").store);
2896
- const getProjectStore2 = deps.getProjectStore ?? (() => (0, import_core76.getStoreLattice)("default", "project").store);
2893
+ const resolveTasks = deps.getTaskStoreLattice ?? (() => (0, import_core77.getStoreLattice)("default", "task").store);
2894
+ const resolveTaskWorkItems = deps.getTaskWorkItemStore ?? (() => (0, import_core77.getStoreLattice)("default", "taskWorkItem").store);
2895
+ const getAssistantStore2 = deps.getAssistantStore ?? (() => (0, import_core77.getStoreLattice)("default", "assistant").store);
2896
+ const getProjectStore2 = deps.getProjectStore ?? (() => (0, import_core77.getStoreLattice)("default", "project").store);
2897
2897
  const runtimeRegistry = deps.runtimeRegistry ?? new A2ARuntimeRegistry();
2898
2898
  app2.addHook("onClose", async () => {
2899
2899
  runtimeRegistry.close();
@@ -2976,7 +2976,7 @@ function registerA2AStandardRoutes(app2, deps) {
2976
2976
  const taskStore = assistantHasGovernedTask(assistant) ? new A2ATaskStoreAdapter({
2977
2977
  taskStore: internalTasks,
2978
2978
  workItemStore: workItems,
2979
- lifecycle: (0, import_core76.createTaskLifecycleService)({
2979
+ lifecycle: (0, import_core77.createTaskLifecycleService)({
2980
2980
  taskStore: internalTasks,
2981
2981
  workItemStore: workItems
2982
2982
  }),
@@ -3095,7 +3095,7 @@ data: ${JSON.stringify(errorResponse)}
3095
3095
  const taskStore = assistantHasGovernedTask(assistant) ? new A2ATaskStoreAdapter({
3096
3096
  taskStore: internalTasks,
3097
3097
  workItemStore: workItems,
3098
- lifecycle: (0, import_core76.createTaskLifecycleService)({
3098
+ lifecycle: (0, import_core77.createTaskLifecycleService)({
3099
3099
  taskStore: internalTasks,
3100
3100
  workItemStore: workItems
3101
3101
  }),
@@ -3150,13 +3150,13 @@ data: ${JSON.stringify(data)}
3150
3150
  }
3151
3151
  );
3152
3152
  }
3153
- var import_uuid12, import_server2, import_core76, SSE_HEADERS;
3153
+ var import_uuid12, import_server2, import_core77, SSE_HEADERS;
3154
3154
  var init_a2a_standard = __esm({
3155
3155
  "src/routes/a2a-standard.ts"() {
3156
3156
  "use strict";
3157
3157
  import_uuid12 = require("uuid");
3158
3158
  import_server2 = require("@a2a-js/sdk/server");
3159
- import_core76 = require("@axiom-lattice/core");
3159
+ import_core77 = require("@axiom-lattice/core");
3160
3160
  init_A2AAuthService();
3161
3161
  init_A2AAgentCardBuilder();
3162
3162
  init_A2ATaskStoreAdapter();
@@ -3908,8 +3908,8 @@ function exposedDeclarations(plugin) {
3908
3908
  return (plugin.meta.tools ?? []).filter((t2) => t2.expose);
3909
3909
  }
3910
3910
  async function registerExposedPluginTools() {
3911
- for (const key of import_core77.PluginRegistry.list()) {
3912
- const plugin = import_core77.PluginRegistry.get(key);
3911
+ for (const key of import_core78.PluginRegistry.list()) {
3912
+ const plugin = import_core78.PluginRegistry.get(key);
3913
3913
  if (!plugin?.middleware) continue;
3914
3914
  const exposed = exposedDeclarations(plugin);
3915
3915
  if (exposed.length === 0) continue;
@@ -3944,8 +3944,8 @@ async function registerExposedPluginTools() {
3944
3944
  }
3945
3945
  function collectExposedPluginUiResources(grants) {
3946
3946
  const resources = /* @__PURE__ */ new Map();
3947
- for (const type of import_core77.PluginRegistry.list()) {
3948
- const plugin = import_core77.PluginRegistry.get(type);
3947
+ for (const type of import_core78.PluginRegistry.list()) {
3948
+ const plugin = import_core78.PluginRegistry.get(type);
3949
3949
  if (!plugin?.middleware) continue;
3950
3950
  const exposedNames = new Set(exposedDeclarations(plugin).map((d) => d.name));
3951
3951
  if (exposedNames.size === 0) continue;
@@ -3969,11 +3969,11 @@ function collectExposedPluginUiResources(grants) {
3969
3969
  }
3970
3970
  return resources;
3971
3971
  }
3972
- var import_core77;
3972
+ var import_core78;
3973
3973
  var init_registerExposedPlugins = __esm({
3974
3974
  "src/services/open/registerExposedPlugins.ts"() {
3975
3975
  "use strict";
3976
- import_core77 = require("@axiom-lattice/core");
3976
+ import_core78 = require("@axiom-lattice/core");
3977
3977
  init_openLattice();
3978
3978
  init_pluginExposeAdapter();
3979
3979
  }
@@ -3988,14 +3988,14 @@ function toText(result) {
3988
3988
  }
3989
3989
  function defaultCatalog() {
3990
3990
  return {
3991
- getValidatedManifest: (tenantId, type) => (0, import_core78.getSandboxPluginCatalog)().getValidatedManifest(tenantId, type),
3992
- getExecutor: () => (0, import_core78.getSandboxPluginCatalog)().getExecutor(),
3993
- readPluginFile: (tenantId, type, relPath) => (0, import_core78.getSandboxPluginCatalog)().readPluginFile(tenantId, type, relPath)
3991
+ getValidatedManifest: (tenantId, type) => (0, import_core79.getSandboxPluginCatalog)().getValidatedManifest(tenantId, type),
3992
+ getExecutor: () => (0, import_core79.getSandboxPluginCatalog)().getExecutor(),
3993
+ readPluginFile: (tenantId, type, relPath) => (0, import_core79.getSandboxPluginCatalog)().readPluginFile(tenantId, type, relPath)
3994
3994
  };
3995
3995
  }
3996
3996
  async function defaultResolveConnections(pluginType, ctx) {
3997
3997
  try {
3998
- return await (0, import_core78.resolveSandboxPluginConnections)(
3998
+ return await (0, import_core79.resolveSandboxPluginConnections)(
3999
3999
  pluginType,
4000
4000
  { connectAll: true },
4001
4001
  {
@@ -4024,7 +4024,7 @@ function mergeOpenCatalog(globalCatalog, tenantTools) {
4024
4024
  async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
4025
4025
  const catalog = deps.catalog ?? defaultCatalog();
4026
4026
  const listPlugins = deps.listPlugins ?? (async (tenant2) => {
4027
- const snapshot = await (0, import_core78.getSandboxPluginCatalog)().ensureLoaded(tenant2);
4027
+ const snapshot = await (0, import_core79.getSandboxPluginCatalog)().ensureLoaded(tenant2);
4028
4028
  return { plugins: snapshot.plugins, diagnostics: snapshot.diagnostics };
4029
4029
  });
4030
4030
  const resolveConnections = deps.resolveConnections ?? defaultResolveConnections;
@@ -4066,7 +4066,7 @@ async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
4066
4066
  domain,
4067
4067
  action: tool.name,
4068
4068
  description: tool.description,
4069
- schema: (0, import_core78.jsonSchemaToZod)(tool.schema),
4069
+ schema: (0, import_core79.jsonSchemaToZod)(tool.schema),
4070
4070
  annotations: {
4071
4071
  readOnlyHint: tool.readOnly ?? false,
4072
4072
  destructiveHint: tool.destructive ?? false
@@ -4117,11 +4117,11 @@ async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
4117
4117
  }
4118
4118
  };
4119
4119
  }
4120
- var import_core78;
4120
+ var import_core79;
4121
4121
  var init_tenantOpenPlugins = __esm({
4122
4122
  "src/services/open/tenantOpenPlugins.ts"() {
4123
4123
  "use strict";
4124
- import_core78 = require("@axiom-lattice/core");
4124
+ import_core79 = require("@axiom-lattice/core");
4125
4125
  init_openLattice();
4126
4126
  init_pluginToolExecution();
4127
4127
  }
@@ -4158,13 +4158,13 @@ function emptyTenantPlugins() {
4158
4158
  }
4159
4159
  function registerOpenRoutes(app2, deps = {}) {
4160
4160
  const openAuth = deps.openAuth ?? new OpenCredentialService(
4161
- (0, import_core79.getStoreLattice)("default", "a2aApiKey").store,
4162
- (0, import_core79.getStoreLattice)("default", "project").store
4161
+ (0, import_core80.getStoreLattice)("default", "a2aApiKey").store,
4162
+ (0, import_core80.getStoreLattice)("default", "project").store
4163
4163
  );
4164
4164
  const grantsSource = deps.grantsSource ?? ((ctx) => ctx.grants);
4165
4165
  const audit = deps.audit ?? (() => {
4166
4166
  try {
4167
- const store2 = (0, import_core79.getStoreLattice)("default", "openAudit").store;
4167
+ const store2 = (0, import_core80.getStoreLattice)("default", "openAudit").store;
4168
4168
  return new OpenAuditService(store2);
4169
4169
  } catch {
4170
4170
  return void 0;
@@ -4319,12 +4319,12 @@ function registerOpenRoutes(app2, deps = {}) {
4319
4319
  }
4320
4320
  );
4321
4321
  }
4322
- var import_types, import_core79, RPC_ERROR;
4322
+ var import_types, import_core80, RPC_ERROR;
4323
4323
  var init_open = __esm({
4324
4324
  "src/routes/open.ts"() {
4325
4325
  "use strict";
4326
4326
  import_types = require("@modelcontextprotocol/sdk/types.js");
4327
- import_core79 = require("@axiom-lattice/core");
4327
+ import_core80 = require("@axiom-lattice/core");
4328
4328
  init_openCredentialService();
4329
4329
  init_openAuditService();
4330
4330
  init_openRateLimiter();
@@ -4357,7 +4357,7 @@ function registerOpenSessionRoutes(app2) {
4357
4357
  if (typeof shareToken !== "string" || shareToken.length === 0) {
4358
4358
  return reply.status(400).send({ error: "SHARE_TOKEN_REQUIRED" });
4359
4359
  }
4360
- const store2 = (0, import_core80.getStoreLattice)("default", "sharedResource").store;
4360
+ const store2 = (0, import_core81.getStoreLattice)("default", "sharedResource").store;
4361
4361
  const record = await store2.findByToken(shareToken);
4362
4362
  if (!record || record.revoked) {
4363
4363
  return reply.status(404).send({ error: "SHARE_NOT_FOUND" });
@@ -4382,11 +4382,11 @@ function registerOpenSessionRoutes(app2) {
4382
4382
  }
4383
4383
  );
4384
4384
  }
4385
- var import_core80;
4385
+ var import_core81;
4386
4386
  var init_open_session = __esm({
4387
4387
  "src/routes/open-session.ts"() {
4388
4388
  "use strict";
4389
- import_core80 = require("@axiom-lattice/core");
4389
+ import_core81 = require("@axiom-lattice/core");
4390
4390
  init_openToken();
4391
4391
  init_previewToken();
4392
4392
  init_openLattice();
@@ -4395,13 +4395,13 @@ var init_open_session = __esm({
4395
4395
 
4396
4396
  // src/services/open/openCatalogService.ts
4397
4397
  async function defaultListTenantPlugins(tenantId) {
4398
- return (await (0, import_core81.getSandboxPluginCatalog)().ensureLoaded(tenantId)).plugins;
4398
+ return (await (0, import_core82.getSandboxPluginCatalog)().ensureLoaded(tenantId)).plugins;
4399
4399
  }
4400
- var import_core81, OpenCatalogService;
4400
+ var import_core82, OpenCatalogService;
4401
4401
  var init_openCatalogService = __esm({
4402
4402
  "src/services/open/openCatalogService.ts"() {
4403
4403
  "use strict";
4404
- import_core81 = require("@axiom-lattice/core");
4404
+ import_core82 = require("@axiom-lattice/core");
4405
4405
  init_openLattice();
4406
4406
  OpenCatalogService = class {
4407
4407
  constructor(assistantStore, lattice = openLattice, listTenantPlugins2 = defaultListTenantPlugins) {
@@ -4476,17 +4476,17 @@ function registerOpenCatalogRoutes(app2) {
4476
4476
  if (!tenantId) {
4477
4477
  return reply.status(401).send({ success: false, error: "Unauthorized" });
4478
4478
  }
4479
- const assistantStore = (0, import_core82.getStoreLattice)("default", "assistant").store;
4479
+ const assistantStore = (0, import_core83.getStoreLattice)("default", "assistant").store;
4480
4480
  const service2 = new OpenCatalogService(assistantStore);
4481
4481
  const catalog = await service2.buildForTenant(tenantId);
4482
4482
  return reply.status(200).send({ success: true, data: catalog });
4483
4483
  });
4484
4484
  }
4485
- var import_core82;
4485
+ var import_core83;
4486
4486
  var init_open_catalog = __esm({
4487
4487
  "src/routes/open-catalog.ts"() {
4488
4488
  "use strict";
4489
- import_core82 = require("@axiom-lattice/core");
4489
+ import_core83 = require("@axiom-lattice/core");
4490
4490
  init_openCatalogService();
4491
4491
  }
4492
4492
  });
@@ -4501,11 +4501,11 @@ async function resolveContextSandbox(ctx) {
4501
4501
  const sandboxName = ctx.runConfig?.sandboxName;
4502
4502
  if (typeof sandboxName === "string" && sandboxName.length > 0) {
4503
4503
  try {
4504
- return await import_core83.sandboxLatticeManager.getSandbox(sandboxName);
4504
+ return await import_core84.sandboxLatticeManager.getSandbox(sandboxName);
4505
4505
  } catch {
4506
4506
  }
4507
4507
  }
4508
- return import_core83.sandboxLatticeManager.getSandboxFromConfig({
4508
+ return import_core84.sandboxLatticeManager.getSandboxFromConfig({
4509
4509
  assistant_id: "",
4510
4510
  thread_id: "",
4511
4511
  tenantId: ctx.tenantId,
@@ -4603,12 +4603,12 @@ ${truncated}`
4603
4603
  }
4604
4604
  };
4605
4605
  }
4606
- var import_zod21, import_core83, MAX_OUTPUT_BYTES;
4606
+ var import_zod21, import_core84, MAX_OUTPUT_BYTES;
4607
4607
  var init_sandboxProvider = __esm({
4608
4608
  "src/services/open/providers/sandboxProvider.ts"() {
4609
4609
  "use strict";
4610
4610
  import_zod21 = require("zod");
4611
- import_core83 = require("@axiom-lattice/core");
4611
+ import_core84 = require("@axiom-lattice/core");
4612
4612
  MAX_OUTPUT_BYTES = 64e3;
4613
4613
  }
4614
4614
  });
@@ -4630,12 +4630,12 @@ function safePath(raw) {
4630
4630
  }
4631
4631
  function registerOpenFilesRoutes(app2, deps = {}) {
4632
4632
  const openAuth = deps.openAuth ?? new OpenCredentialService(
4633
- (0, import_core84.getStoreLattice)("default", "a2aApiKey").store,
4634
- (0, import_core84.getStoreLattice)("default", "project").store
4633
+ (0, import_core85.getStoreLattice)("default", "a2aApiKey").store,
4634
+ (0, import_core85.getStoreLattice)("default", "project").store
4635
4635
  );
4636
4636
  const audit = deps.audit ?? (() => {
4637
4637
  try {
4638
- const store2 = (0, import_core84.getStoreLattice)("default", "openAudit").store;
4638
+ const store2 = (0, import_core85.getStoreLattice)("default", "openAudit").store;
4639
4639
  return new OpenAuditService(store2);
4640
4640
  } catch {
4641
4641
  return void 0;
@@ -4745,11 +4745,11 @@ function registerOpenFilesRoutes(app2, deps = {}) {
4745
4745
  }
4746
4746
  });
4747
4747
  }
4748
- var import_core84;
4748
+ var import_core85;
4749
4749
  var init_open_files = __esm({
4750
4750
  "src/routes/open-files.ts"() {
4751
4751
  "use strict";
4752
- import_core84 = require("@axiom-lattice/core");
4752
+ import_core85 = require("@axiom-lattice/core");
4753
4753
  init_openCredentialService();
4754
4754
  init_openLattice();
4755
4755
  init_sandboxProvider();
@@ -4771,7 +4771,7 @@ function registerOpenAuditRoutes(app2) {
4771
4771
  return reply.status(401).send({ success: false, error: "Unauthorized" });
4772
4772
  }
4773
4773
  const status = request.query.status === "ok" || request.query.status === "error" ? request.query.status : void 0;
4774
- const store2 = (0, import_core85.getStoreLattice)("default", "openAudit").store;
4774
+ const store2 = (0, import_core86.getStoreLattice)("default", "openAudit").store;
4775
4775
  const records = await store2.query({
4776
4776
  tenantId,
4777
4777
  credentialId: request.query.credentialId,
@@ -4786,11 +4786,11 @@ function registerOpenAuditRoutes(app2) {
4786
4786
  }
4787
4787
  );
4788
4788
  }
4789
- var import_core85;
4789
+ var import_core86;
4790
4790
  var init_open_audit = __esm({
4791
4791
  "src/routes/open-audit.ts"() {
4792
4792
  "use strict";
4793
- import_core85 = require("@axiom-lattice/core");
4793
+ import_core86 = require("@axiom-lattice/core");
4794
4794
  }
4795
4795
  });
4796
4796
 
@@ -4807,7 +4807,7 @@ function registerOpenExposureRoutes(app2, deps = {}) {
4807
4807
  if (!tenantId) {
4808
4808
  return reply.status(401).send({ success: false, error: "Unauthorized" });
4809
4809
  }
4810
- const keyStore = (0, import_core86.getStoreLattice)("default", "a2aApiKey").store;
4810
+ const keyStore = (0, import_core87.getStoreLattice)("default", "a2aApiKey").store;
4811
4811
  const record = await keyStore.findById(request.params.id);
4812
4812
  if (!record || record.tenantId !== tenantId) {
4813
4813
  return reply.status(404).send({ success: false, error: "Key not found" });
@@ -4841,7 +4841,7 @@ function registerOpenExposureRoutes(app2, deps = {}) {
4841
4841
  hasUi: Boolean(t2.ui)
4842
4842
  }));
4843
4843
  const agentGrant = grants.find((g) => g.domain === "agent");
4844
- const assistantStore = (0, import_core86.getStoreLattice)("default", "assistant").store;
4844
+ const assistantStore = (0, import_core87.getStoreLattice)("default", "assistant").store;
4845
4845
  const agents = [];
4846
4846
  for (const assistantId of agentGrant?.items ?? []) {
4847
4847
  const assistant = await assistantStore.getAssistantById(
@@ -4876,11 +4876,11 @@ function registerOpenExposureRoutes(app2, deps = {}) {
4876
4876
  }
4877
4877
  );
4878
4878
  }
4879
- var import_core86, import_protocols38;
4879
+ var import_core87, import_protocols38;
4880
4880
  var init_open_exposure = __esm({
4881
4881
  "src/routes/open-exposure.ts"() {
4882
4882
  "use strict";
4883
- import_core86 = require("@axiom-lattice/core");
4883
+ import_core87 = require("@axiom-lattice/core");
4884
4884
  import_protocols38 = require("@axiom-lattice/protocols");
4885
4885
  init_openLattice();
4886
4886
  init_tenantOpenPlugins();
@@ -5000,7 +5000,7 @@ function createAgentProvider(deps = {}) {
5000
5000
  } catch {
5001
5001
  }
5002
5002
  }
5003
- const agent = import_core87.agentInstanceManager.getAgent({
5003
+ const agent = import_core88.agentInstanceManager.getAgent({
5004
5004
  tenant_id: ctx.tenantId,
5005
5005
  assistant_id: assistantId,
5006
5006
  thread_id: threadId,
@@ -5025,12 +5025,12 @@ function createAgentProvider(deps = {}) {
5025
5025
  }
5026
5026
  };
5027
5027
  }
5028
- var import_zod23, import_core87, import_protocols39, STOP_TYPES;
5028
+ var import_zod23, import_core88, import_protocols39, STOP_TYPES;
5029
5029
  var init_agentProvider = __esm({
5030
5030
  "src/services/open/providers/agentProvider.ts"() {
5031
5031
  "use strict";
5032
5032
  import_zod23 = require("zod");
5033
- import_core87 = require("@axiom-lattice/core");
5033
+ import_core88 = require("@axiom-lattice/core");
5034
5034
  import_protocols39 = require("@axiom-lattice/protocols");
5035
5035
  STOP_TYPES = [import_protocols39.MessageChunkTypes.MESSAGE_COMPLETED];
5036
5036
  }
@@ -5133,11 +5133,11 @@ async function resolveAgentOpenGrants(tenantId, assistantId, deps) {
5133
5133
  }
5134
5134
  }
5135
5135
  function createDefaultAgentReflectionDeps(tenantId) {
5136
- (0, import_core88.ensureBuiltinAgentsForTenant)(tenantId);
5136
+ (0, import_core89.ensureBuiltinAgentsForTenant)(tenantId);
5137
5137
  return {
5138
- ensure: (t2) => import_core88.agentLatticeManager.initializeStoredAssistantsForTenant(t2),
5138
+ ensure: (t2) => import_core89.agentLatticeManager.initializeStoredAssistantsForTenant(t2),
5139
5139
  getAgentConfig: (t2, assistantId) => {
5140
- const config = import_core88.agentLatticeManager.getAgentConfigWithTenant(t2, assistantId);
5140
+ const config = import_core89.agentLatticeManager.getAgentConfigWithTenant(t2, assistantId);
5141
5141
  if (!config) return void 0;
5142
5142
  return {
5143
5143
  middleware: extractMiddleware(config),
@@ -5145,16 +5145,16 @@ function createDefaultAgentReflectionDeps(tenantId) {
5145
5145
  };
5146
5146
  },
5147
5147
  getAssistantMiddleware: async (t2, assistantId) => {
5148
- const store2 = (0, import_core88.getStoreLattice)("default", "assistant").store;
5148
+ const store2 = (0, import_core89.getStoreLattice)("default", "assistant").store;
5149
5149
  const assistant = await store2.getAssistantById(t2, assistantId);
5150
5150
  return extractMiddleware(assistant?.graphDefinition);
5151
5151
  },
5152
5152
  exposedActionsByType: (type) => {
5153
- const plugin = import_core88.PluginRegistry.get(type);
5153
+ const plugin = import_core89.PluginRegistry.get(type);
5154
5154
  return plugin ? normalizeOpenExpose(plugin.meta.openExpose) : [];
5155
5155
  },
5156
5156
  resolvableAssistants: async (t2) => new Set(
5157
- import_core88.agentLatticeManager.getAllAgentLatticesByTenant(t2).map((lattice) => lattice.config.key)
5157
+ import_core89.agentLatticeManager.getAllAgentLatticesByTenant(t2).map((lattice) => lattice.config.key)
5158
5158
  )
5159
5159
  };
5160
5160
  }
@@ -5219,30 +5219,30 @@ function buildTenantExposedGrants(manifests) {
5219
5219
  }
5220
5220
  function createDefaultPluginReflectionDeps() {
5221
5221
  return {
5222
- ensure: (tenantId) => import_core88.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
5222
+ ensure: (tenantId) => import_core89.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
5223
5223
  globalExposedDomains: () => {
5224
5224
  const grants = [];
5225
- for (const type of import_core88.PluginRegistry.list()) {
5226
- const plugin = import_core88.PluginRegistry.get(type);
5225
+ for (const type of import_core89.PluginRegistry.list()) {
5226
+ const plugin = import_core89.PluginRegistry.get(type);
5227
5227
  const items = normalizeOpenExpose(plugin?.meta.openExpose);
5228
5228
  if (items.length > 0) grants.push({ domain: type, items });
5229
5229
  }
5230
5230
  return grants;
5231
5231
  },
5232
5232
  tenantExposedDomains: async (tenantId) => {
5233
- const { manifests } = await (0, import_core88.getSandboxPluginCatalog)().ensureLoaded(tenantId);
5233
+ const { manifests } = await (0, import_core89.getSandboxPluginCatalog)().ensureLoaded(tenantId);
5234
5234
  return buildTenantExposedGrants(Object.values(manifests));
5235
5235
  },
5236
5236
  resolvableAssistants: async (tenantId) => new Set(
5237
- import_core88.agentLatticeManager.getAllAgentLatticesByTenant(tenantId).map((lattice) => lattice.config.key)
5237
+ import_core89.agentLatticeManager.getAllAgentLatticesByTenant(tenantId).map((lattice) => lattice.config.key)
5238
5238
  )
5239
5239
  };
5240
5240
  }
5241
- var import_core88, AGENT_REFLECTION_CACHE_TTL_MS, cache, PLUGIN_REFLECTION_CACHE_TTL_MS, pluginCache;
5241
+ var import_core89, AGENT_REFLECTION_CACHE_TTL_MS, cache, PLUGIN_REFLECTION_CACHE_TTL_MS, pluginCache;
5242
5242
  var init_sandboxOpenReflection = __esm({
5243
5243
  "src/services/open/sandboxOpenReflection.ts"() {
5244
5244
  "use strict";
5245
- import_core88 = require("@axiom-lattice/core");
5245
+ import_core89 = require("@axiom-lattice/core");
5246
5246
  AGENT_REFLECTION_CACHE_TTL_MS = 6e4;
5247
5247
  cache = /* @__PURE__ */ new Map();
5248
5248
  PLUGIN_REFLECTION_CACHE_TTL_MS = 6e4;
@@ -5288,7 +5288,7 @@ function createSandboxOpenCredentialProvider(options) {
5288
5288
  };
5289
5289
  }
5290
5290
  function registerGatewaySandboxOpenCredentialProvider(onError) {
5291
- return (0, import_core89.registerSandboxOpenCredentialProvider)(
5291
+ return (0, import_core90.registerSandboxOpenCredentialProvider)(
5292
5292
  createSandboxOpenCredentialProvider({
5293
5293
  gatewayUrl: process.env.PUBLIC_GATEWAY_URL?.trim() || void 0,
5294
5294
  onError
@@ -5296,11 +5296,11 @@ function registerGatewaySandboxOpenCredentialProvider(onError) {
5296
5296
  { onError }
5297
5297
  );
5298
5298
  }
5299
- var import_core89, DEFAULT_SANDBOX_OPEN_GRANTS, MAX_SANDBOX_OPEN_DEPTH;
5299
+ var import_core90, DEFAULT_SANDBOX_OPEN_GRANTS, MAX_SANDBOX_OPEN_DEPTH;
5300
5300
  var init_sandboxOpenCredentialProvider = __esm({
5301
5301
  "src/services/open/sandboxOpenCredentialProvider.ts"() {
5302
5302
  "use strict";
5303
- import_core89 = require("@axiom-lattice/core");
5303
+ import_core90 = require("@axiom-lattice/core");
5304
5304
  init_openToken();
5305
5305
  init_sandboxOpenReflection();
5306
5306
  DEFAULT_SANDBOX_OPEN_GRANTS = [
@@ -5337,12 +5337,12 @@ var resources_exports = {};
5337
5337
  __export(resources_exports, {
5338
5338
  ResourceController: () => ResourceController
5339
5339
  });
5340
- var import_bcryptjs, import_core90, ResourceController;
5340
+ var import_bcryptjs, import_core91, ResourceController;
5341
5341
  var init_resources = __esm({
5342
5342
  "src/controllers/resources.ts"() {
5343
5343
  "use strict";
5344
5344
  import_bcryptjs = __toESM(require("bcryptjs"));
5345
- import_core90 = require("@axiom-lattice/core");
5345
+ import_core91 = require("@axiom-lattice/core");
5346
5346
  init_mime();
5347
5347
  init_http_range();
5348
5348
  init_sandboxGrants();
@@ -5359,14 +5359,14 @@ var init_resources = __esm({
5359
5359
  if (!workspaceId || !projectId) {
5360
5360
  return reply.status(400).send({ error: "x-workspace-id and x-project-id headers required" });
5361
5361
  }
5362
- const payload = (0, import_core90.createSharePayload)(
5362
+ const payload = (0, import_core91.createSharePayload)(
5363
5363
  tenantId,
5364
5364
  workspaceId,
5365
5365
  projectId,
5366
5366
  userId,
5367
5367
  body
5368
5368
  );
5369
- const token = (0, import_core90.generateToken)();
5369
+ const token = (0, import_core91.generateToken)();
5370
5370
  try {
5371
5371
  await this.deps.store.create({ ...payload, token });
5372
5372
  this.deps.logger.info(
@@ -5518,7 +5518,7 @@ var init_resources = __esm({
5518
5518
  resourcePath: subPath
5519
5519
  }, subPath, ext, request, reply);
5520
5520
  }
5521
- const volume = (0, import_core90.buildNamedVolumeName)("p", "project", tenantId, workspaceId, projectId);
5521
+ const volume = (0, import_core91.buildNamedVolumeName)("p", "project", tenantId, workspaceId, projectId);
5522
5522
  return this._resolveAndServe(
5523
5523
  volume,
5524
5524
  subPath,
@@ -13329,8 +13329,17 @@ function registerMetricsServerConfigRoutes(app2) {
13329
13329
  }
13330
13330
 
13331
13331
  // src/controllers/connections.ts
13332
- var import_core32 = require("@axiom-lattice/core");
13332
+ var import_core33 = require("@axiom-lattice/core");
13333
13333
  var import_zod2 = require("zod");
13334
+
13335
+ // src/services/plugins/connectionSecretFields.ts
13336
+ var import_core32 = require("@axiom-lattice/core");
13337
+ function secretFieldsForConnection(plugin) {
13338
+ const keys2 = (0, import_core32.connectionSecretFields)(plugin);
13339
+ return keys2.length > 0 ? keys2 : void 0;
13340
+ }
13341
+
13342
+ // src/controllers/connections.ts
13334
13343
  var createBody = import_zod2.z.object({
13335
13344
  type: import_zod2.z.string().min(1),
13336
13345
  key: import_zod2.z.string().min(1),
@@ -13352,28 +13361,9 @@ function getTenant(request) {
13352
13361
  async function getTenantPlugin(request, type) {
13353
13362
  return resolveTenantPluginByType(getTenant(request), type);
13354
13363
  }
13355
- function maskSecrets(config) {
13356
- const sensitive = /* @__PURE__ */ new Set([
13357
- "password",
13358
- "secret",
13359
- "token",
13360
- "apikey",
13361
- "api_key",
13362
- "session",
13363
- "privatekey",
13364
- "private_key",
13365
- "accesskey",
13366
- "access_key"
13367
- ]);
13368
- const out = {};
13369
- for (const [k, v] of Object.entries(config)) {
13370
- out[k] = sensitive.has(k.toLowerCase()) ? "********" : v;
13371
- }
13372
- return out;
13373
- }
13374
13364
  async function resolveConfig(type, body, tenantId) {
13375
13365
  if (body.key) {
13376
- const entry = await import_core32.ConnectionRegistry.get(type, body.key, tenantId);
13366
+ const entry = await import_core33.ConnectionRegistry.get(type, body.key, tenantId);
13377
13367
  if (!entry) throw { status: 404, error: `Connection "${body.key}" not found` };
13378
13368
  return entry.config;
13379
13369
  }
@@ -13384,25 +13374,27 @@ function connectionRoutes(fastify2) {
13384
13374
  fastify2.get("/api/connections", async (request, reply) => {
13385
13375
  const { type } = request.query;
13386
13376
  if (!type) return reply.status(400).send({ error: "query 'type' required" });
13387
- const entries = await import_core32.ConnectionRegistry.list(type, getTenant(request));
13377
+ const entries = await import_core33.ConnectionRegistry.list(type, getTenant(request));
13388
13378
  return reply.send({
13389
13379
  success: true,
13390
- data: { records: entries.map((e) => ({ ...e, config: maskSecrets(e.config) })), total: entries.length }
13380
+ data: { records: entries, total: entries.length }
13391
13381
  });
13392
13382
  });
13393
13383
  fastify2.post("/api/connections", async (request, reply) => {
13394
13384
  const parsed = createBody.parse(request.body);
13395
- const entry = await import_core32.ConnectionRegistry.create({
13385
+ const plugin = await getTenantPlugin(request, parsed.type);
13386
+ const entry = await import_core33.ConnectionRegistry.create({
13396
13387
  tenantId: getTenant(request),
13397
13388
  type: parsed.type,
13398
13389
  key: parsed.key,
13399
13390
  name: parsed.name,
13400
13391
  description: parsed.description,
13401
- config: parsed.config
13392
+ config: parsed.config,
13393
+ secretFields: secretFieldsForConnection(plugin)
13402
13394
  });
13403
13395
  return reply.status(201).send({
13404
13396
  success: true,
13405
- data: { ...entry, config: maskSecrets(entry.config) }
13397
+ data: entry
13406
13398
  });
13407
13399
  });
13408
13400
  fastify2.put("/api/connections/:key", async (request, reply) => {
@@ -13411,25 +13403,27 @@ function connectionRoutes(fastify2) {
13411
13403
  const { key } = request.params;
13412
13404
  const body = request.body;
13413
13405
  const tenantId = getTenant(request);
13414
- const existing = await import_core32.ConnectionRegistry.get(type, key, tenantId);
13406
+ const existing = await import_core33.ConnectionRegistry.get(type, key, tenantId);
13415
13407
  if (!existing) return reply.status(404).send({ error: "not found" });
13408
+ const plugin = await getTenantPlugin(request, type);
13416
13409
  const updates = {};
13417
13410
  if (body.name !== void 0) updates.name = body.name;
13418
13411
  if (body.description !== void 0) updates.description = body.description;
13419
13412
  if (body.config) {
13420
13413
  updates.config = { ...existing.config, ...body.config };
13414
+ updates.secretFields = secretFieldsForConnection(plugin);
13421
13415
  }
13422
- const entry = await import_core32.ConnectionRegistry.update(tenantId, type, key, updates);
13416
+ const entry = await import_core33.ConnectionRegistry.update(tenantId, type, key, updates);
13423
13417
  return reply.send({
13424
13418
  success: true,
13425
- data: { ...entry, config: maskSecrets(entry?.config ?? {}) }
13419
+ data: entry
13426
13420
  });
13427
13421
  });
13428
13422
  fastify2.delete("/api/connections/:key", async (request, reply) => {
13429
13423
  const { type } = request.query;
13430
13424
  if (!type) return reply.status(400).send({ error: "query 'type' required" });
13431
13425
  const { key } = request.params;
13432
- const ok = await import_core32.ConnectionRegistry.delete(getTenant(request), type, key);
13426
+ const ok = await import_core33.ConnectionRegistry.delete(getTenant(request), type, key);
13433
13427
  return reply.send({ success: ok });
13434
13428
  });
13435
13429
  fastify2.post("/api/connections/test", async (request, reply) => {
@@ -13490,7 +13484,7 @@ function connectionRoutes(fastify2) {
13490
13484
  }
13491
13485
 
13492
13486
  // src/controllers/mcp-configs.ts
13493
- var import_core33 = require("@axiom-lattice/core");
13487
+ var import_core34 = require("@axiom-lattice/core");
13494
13488
  var import_crypto8 = require("crypto");
13495
13489
 
13496
13490
  // src/services/mcpConfigSync.ts
@@ -13539,15 +13533,15 @@ function getTenantId11(request) {
13539
13533
  function broadcastMcpConfigChanged(tenantId, serverKey) {
13540
13534
  if (!tenantId || !serverKey) return;
13541
13535
  try {
13542
- const outbox = (0, import_core33.getStoreLattice)("default", "outbox").store;
13543
- void publishMcpConfigChanged(outbox, (0, import_core33.getReplicaId)(), tenantId, serverKey);
13536
+ const outbox = (0, import_core34.getStoreLattice)("default", "outbox").store;
13537
+ void publishMcpConfigChanged(outbox, (0, import_core34.getReplicaId)(), tenantId, serverKey);
13544
13538
  } catch {
13545
13539
  }
13546
13540
  }
13547
13541
  async function getMcpServerConfigList(request, reply) {
13548
13542
  const tenantId = getTenantId11(request);
13549
13543
  try {
13550
- const storeLattice = (0, import_core33.getStoreLattice)("default", "mcp");
13544
+ const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13551
13545
  const store2 = storeLattice.store;
13552
13546
  const configs = await store2.getAllConfigs(tenantId);
13553
13547
  return {
@@ -13574,7 +13568,7 @@ async function getMcpServerConfig(request, reply) {
13574
13568
  const tenantId = getTenantId11(request);
13575
13569
  const { key } = request.params;
13576
13570
  try {
13577
- const storeLattice = (0, import_core33.getStoreLattice)("default", "mcp");
13571
+ const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13578
13572
  const store2 = storeLattice.store;
13579
13573
  const config = await store2.getConfigByKey(tenantId, key);
13580
13574
  if (!config) {
@@ -13600,7 +13594,7 @@ async function createMcpServerConfig(request, reply) {
13600
13594
  const tenantId = getTenantId11(request);
13601
13595
  const body = request.body;
13602
13596
  try {
13603
- const storeLattice = (0, import_core33.getStoreLattice)("default", "mcp");
13597
+ const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13604
13598
  const store2 = storeLattice.store;
13605
13599
  const existing = await store2.getConfigByKey(tenantId, body.key);
13606
13600
  if (existing) {
@@ -13641,7 +13635,7 @@ async function updateMcpServerConfig(request, reply) {
13641
13635
  const { key } = request.params;
13642
13636
  const updates = request.body;
13643
13637
  try {
13644
- const storeLattice = (0, import_core33.getStoreLattice)("default", "mcp");
13638
+ const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13645
13639
  const store2 = storeLattice.store;
13646
13640
  const existing = await store2.getConfigByKey(tenantId, key);
13647
13641
  if (!existing) {
@@ -13663,13 +13657,13 @@ async function updateMcpServerConfig(request, reply) {
13663
13657
  }
13664
13658
  if (configChanged) {
13665
13659
  try {
13666
- const connection = (0, import_core33.convertToConnection)(updated.config);
13667
- import_core33.mcpManager.registerServer(tenantId, key, connection, {
13660
+ const connection = (0, import_core34.convertToConnection)(updated.config);
13661
+ import_core34.mcpManager.registerServer(tenantId, key, connection, {
13668
13662
  timeoutMs: updated.config.timeout,
13669
13663
  maxAttempts: updated.config.retryAttempts
13670
13664
  });
13671
- await import_core33.mcpManager.ensureConnected(tenantId, key);
13672
- await import_core33.mcpManager.registerToolsToToolLattice(tenantId, key, updated.selectedTools);
13665
+ await import_core34.mcpManager.ensureConnected(tenantId, key);
13666
+ await import_core34.mcpManager.registerToolsToToolLattice(tenantId, key, updated.selectedTools);
13673
13667
  await store2.updateConfig(tenantId, existing.id, { status: "connected" });
13674
13668
  updated.status = "connected";
13675
13669
  } catch (error) {
@@ -13677,16 +13671,16 @@ async function updateMcpServerConfig(request, reply) {
13677
13671
  await store2.updateConfig(tenantId, existing.id, { status: "error" });
13678
13672
  updated.status = "error";
13679
13673
  }
13680
- } else if (toolsChanged && import_core33.mcpManager.hasServer(tenantId, key)) {
13674
+ } else if (toolsChanged && import_core34.mcpManager.hasServer(tenantId, key)) {
13681
13675
  try {
13682
- await import_core33.mcpManager.registerToolsToToolLattice(tenantId, key, updated.selectedTools);
13676
+ await import_core34.mcpManager.registerToolsToToolLattice(tenantId, key, updated.selectedTools);
13683
13677
  } catch (error) {
13684
13678
  console.warn("Failed to re-register MCP tools:", error);
13685
13679
  }
13686
13680
  }
13687
- if (statusChanged && updated.status !== "connected" && import_core33.mcpManager.hasServer(tenantId, key)) {
13681
+ if (statusChanged && updated.status !== "connected" && import_core34.mcpManager.hasServer(tenantId, key)) {
13688
13682
  try {
13689
- await import_core33.mcpManager.removeServer(tenantId, key);
13683
+ await import_core34.mcpManager.removeServer(tenantId, key);
13690
13684
  } catch (error) {
13691
13685
  console.warn("Failed to remove MCP server:", error);
13692
13686
  }
@@ -13711,7 +13705,7 @@ async function deleteMcpServerConfig(request, reply) {
13711
13705
  const tenantId = getTenantId11(request);
13712
13706
  const { keyOrId } = request.params;
13713
13707
  try {
13714
- const storeLattice = (0, import_core33.getStoreLattice)("default", "mcp");
13708
+ const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13715
13709
  const store2 = storeLattice.store;
13716
13710
  let config = await store2.getConfigByKey(tenantId, keyOrId);
13717
13711
  let configKey = keyOrId;
@@ -13729,8 +13723,8 @@ async function deleteMcpServerConfig(request, reply) {
13729
13723
  };
13730
13724
  }
13731
13725
  try {
13732
- if (import_core33.mcpManager.hasServer(tenantId, configKey)) {
13733
- await import_core33.mcpManager.removeServer(tenantId, configKey);
13726
+ if (import_core34.mcpManager.hasServer(tenantId, configKey)) {
13727
+ await import_core34.mcpManager.removeServer(tenantId, configKey);
13734
13728
  }
13735
13729
  } catch (error) {
13736
13730
  console.warn("Failed to remove from MCP manager:", error);
@@ -13759,7 +13753,7 @@ async function testMcpServerConnection(request, reply) {
13759
13753
  const tenantId = getTenantId11(request);
13760
13754
  const { key } = request.params;
13761
13755
  try {
13762
- const storeLattice = (0, import_core33.getStoreLattice)("default", "mcp");
13756
+ const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13763
13757
  const store2 = storeLattice.store;
13764
13758
  const config = await store2.getConfigByKey(tenantId, key);
13765
13759
  if (!config) {
@@ -13771,8 +13765,8 @@ async function testMcpServerConnection(request, reply) {
13771
13765
  }
13772
13766
  try {
13773
13767
  const testKey = `__test_${key}_${Date.now()}`;
13774
- const connection = (0, import_core33.convertToConnection)(config.config);
13775
- const { latency } = await import_core33.McpLatticeManager.testConnection(testKey, connection);
13768
+ const connection = (0, import_core34.convertToConnection)(config.config);
13769
+ const { latency } = await import_core34.McpLatticeManager.testConnection(testKey, connection);
13776
13770
  return {
13777
13771
  success: true,
13778
13772
  message: "Connection test successful",
@@ -13807,7 +13801,7 @@ async function listMcpServerTools(request, reply) {
13807
13801
  const tenantId = getTenantId11(request);
13808
13802
  const { key } = request.params;
13809
13803
  try {
13810
- const storeLattice = (0, import_core33.getStoreLattice)("default", "mcp");
13804
+ const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13811
13805
  const store2 = storeLattice.store;
13812
13806
  const config = await store2.getConfigByKey(tenantId, key);
13813
13807
  if (!config) {
@@ -13817,7 +13811,7 @@ async function listMcpServerTools(request, reply) {
13817
13811
  message: "MCP server configuration not found"
13818
13812
  };
13819
13813
  }
13820
- const wasConnected = import_core33.mcpManager.isServerConnected(tenantId, key);
13814
+ const wasConnected = import_core34.mcpManager.isServerConnected(tenantId, key);
13821
13815
  if (!wasConnected) {
13822
13816
  await connectAndRegisterTools(config);
13823
13817
  }
@@ -13828,7 +13822,7 @@ async function listMcpServerTools(request, reply) {
13828
13822
  if (!wasConnected || statusStale) {
13829
13823
  broadcastMcpConfigChanged(tenantId, key);
13830
13824
  }
13831
- const tools = await import_core33.mcpManager.getServerTools(tenantId, key);
13825
+ const tools = await import_core34.mcpManager.getServerTools(tenantId, key);
13832
13826
  return {
13833
13827
  success: true,
13834
13828
  message: "Tools retrieved successfully",
@@ -13848,7 +13842,7 @@ async function connectMcpServer(request, reply) {
13848
13842
  const tenantId = getTenantId11(request);
13849
13843
  const { key } = request.params;
13850
13844
  try {
13851
- const storeLattice = (0, import_core33.getStoreLattice)("default", "mcp");
13845
+ const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13852
13846
  const store2 = storeLattice.store;
13853
13847
  const config = await store2.getConfigByKey(tenantId, key);
13854
13848
  if (!config) {
@@ -13870,7 +13864,7 @@ async function connectMcpServer(request, reply) {
13870
13864
  };
13871
13865
  } catch (error) {
13872
13866
  console.error("Failed to connect MCP server:", error);
13873
- const storeLattice = (0, import_core33.getStoreLattice)("default", "mcp");
13867
+ const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13874
13868
  const store2 = storeLattice.store;
13875
13869
  const config = await store2.getConfigByKey(tenantId, key);
13876
13870
  if (config) {
@@ -13887,7 +13881,7 @@ async function disconnectMcpServer(request, reply) {
13887
13881
  const tenantId = getTenantId11(request);
13888
13882
  const { key } = request.params;
13889
13883
  try {
13890
- const storeLattice = (0, import_core33.getStoreLattice)("default", "mcp");
13884
+ const storeLattice = (0, import_core34.getStoreLattice)("default", "mcp");
13891
13885
  const store2 = storeLattice.store;
13892
13886
  const config = await store2.getConfigByKey(tenantId, key);
13893
13887
  if (!config) {
@@ -13897,8 +13891,8 @@ async function disconnectMcpServer(request, reply) {
13897
13891
  message: "MCP server configuration not found"
13898
13892
  };
13899
13893
  }
13900
- if (import_core33.mcpManager.hasServer(tenantId, key)) {
13901
- await import_core33.mcpManager.removeServer(tenantId, key);
13894
+ if (import_core34.mcpManager.hasServer(tenantId, key)) {
13895
+ await import_core34.mcpManager.removeServer(tenantId, key);
13902
13896
  }
13903
13897
  const updated = await store2.updateConfig(tenantId, config.id, {
13904
13898
  status: "disconnected"
@@ -13928,8 +13922,8 @@ async function testMcpServerTools(request, reply) {
13928
13922
  };
13929
13923
  }
13930
13924
  const testKey = `__test_${Date.now()}`;
13931
- const connection = (0, import_core33.convertToConnection)(body.config);
13932
- const { tools } = await import_core33.McpLatticeManager.testConnection(testKey, connection);
13925
+ const connection = (0, import_core34.convertToConnection)(body.config);
13926
+ const { tools } = await import_core34.McpLatticeManager.testConnection(testKey, connection);
13933
13927
  return {
13934
13928
  success: true,
13935
13929
  message: "Tools retrieved successfully",
@@ -13946,14 +13940,14 @@ async function testMcpServerTools(request, reply) {
13946
13940
  }
13947
13941
  }
13948
13942
  async function connectAndRegisterTools(config) {
13949
- const connection = (0, import_core33.convertToConnection)(config.config);
13950
- import_core33.mcpManager.registerServer(config.tenantId, config.key, connection, {
13943
+ const connection = (0, import_core34.convertToConnection)(config.config);
13944
+ import_core34.mcpManager.registerServer(config.tenantId, config.key, connection, {
13951
13945
  timeoutMs: config.config.timeout,
13952
13946
  maxAttempts: config.config.retryAttempts,
13953
13947
  selectedTools: config.selectedTools
13954
13948
  });
13955
- await import_core33.mcpManager.ensureConnected(config.tenantId, config.key);
13956
- await import_core33.mcpManager.registerToolsToToolLattice(
13949
+ await import_core34.mcpManager.ensureConnected(config.tenantId, config.key);
13950
+ await import_core34.mcpManager.registerToolsToToolLattice(
13957
13951
  config.tenantId,
13958
13952
  config.key,
13959
13953
  config.selectedTools
@@ -13974,7 +13968,7 @@ function registerMcpServerConfigRoutes(app2) {
13974
13968
 
13975
13969
  // src/routes/mcp-apps.ts
13976
13970
  var import_protocols6 = require("@axiom-lattice/protocols");
13977
- var import_core34 = require("@axiom-lattice/core");
13971
+ var import_core35 = require("@axiom-lattice/core");
13978
13972
 
13979
13973
  // src/services/mcp-ui/UiResourceResolver.ts
13980
13974
  var import_node_crypto5 = require("crypto");
@@ -14339,26 +14333,26 @@ function createDefaultPluginBackend() {
14339
14333
  return {
14340
14334
  resolvePlugin: (tenantId, type) => resolveTenantPluginByType(tenantId, type),
14341
14335
  catalog: {
14342
- readPluginFile: (tenantId, pluginType, relPath) => (0, import_core34.getSandboxPluginCatalog)().readPluginFile(tenantId, pluginType, relPath),
14343
- getValidatedManifest: (tenantId, pluginType) => (0, import_core34.getSandboxPluginCatalog)().getValidatedManifest(tenantId, pluginType),
14344
- getExecutor: () => (0, import_core34.getSandboxPluginCatalog)().getExecutor()
14336
+ readPluginFile: (tenantId, pluginType, relPath) => (0, import_core35.getSandboxPluginCatalog)().readPluginFile(tenantId, pluginType, relPath),
14337
+ getValidatedManifest: (tenantId, pluginType) => (0, import_core35.getSandboxPluginCatalog)().getValidatedManifest(tenantId, pluginType),
14338
+ getExecutor: () => (0, import_core35.getSandboxPluginCatalog)().getExecutor()
14345
14339
  }
14346
14340
  };
14347
14341
  }
14348
14342
  function resolveMcpAppDeps(pluginBackend = createDefaultPluginBackend()) {
14349
14343
  const uiResourceResolver = new UiResourceResolver({
14350
14344
  store: new InMemoryMcpUiResourceCacheStore(),
14351
- fetchMcp: (tenantId, serverKey, resourceUri) => import_core34.mcpManager.readUiResource(tenantId, serverKey, resourceUri),
14345
+ fetchMcp: (tenantId, serverKey, resourceUri) => import_core35.mcpManager.readUiResource(tenantId, serverKey, resourceUri),
14352
14346
  fetchPlugin: (tenantId, pluginType, resource) => fetchPluginUiResource(pluginBackend, tenantId, pluginType, resource)
14353
14347
  });
14354
14348
  return {
14355
14349
  resolveUiResource: (tenantId, ref) => uiResourceResolver.resolve(tenantId, ref),
14356
- callTool: (tenantId, ref, name, args, context) => ref.kind === "mcp" ? import_core34.mcpManager.callServerTool(tenantId, ref.serverKey, name, args) : callPluginTool(pluginBackend, tenantId, ref, name, args, context),
14350
+ callTool: (tenantId, ref, name, args, context) => ref.kind === "mcp" ? import_core35.mcpManager.callServerTool(tenantId, ref.serverKey, name, args) : callPluginTool(pluginBackend, tenantId, ref, name, args, context),
14357
14351
  // Plugin refs reach these only after `tools/call`; the handler treats the
14358
14352
  // rejection as an unsupported method (403). The branches are live because
14359
14353
  // the pure handler deliberately delegates method policy to the deps.
14360
- readResource: (tenantId, ref, uri) => ref.kind === "mcp" ? import_core34.mcpManager.readServerResource(tenantId, ref.serverKey, uri) : Promise.reject(new PluginMethodNotSupportedError("resources/read")),
14361
- listTools: (tenantId, ref) => ref.kind === "mcp" ? import_core34.mcpManager.getAvailableTools(tenantId, ref.serverKey) : Promise.reject(new PluginMethodNotSupportedError("tools/list"))
14354
+ readResource: (tenantId, ref, uri) => ref.kind === "mcp" ? import_core35.mcpManager.readServerResource(tenantId, ref.serverKey, uri) : Promise.reject(new PluginMethodNotSupportedError("resources/read")),
14355
+ listTools: (tenantId, ref) => ref.kind === "mcp" ? import_core35.mcpManager.getAvailableTools(tenantId, ref.serverKey) : Promise.reject(new PluginMethodNotSupportedError("tools/list"))
14362
14356
  };
14363
14357
  }
14364
14358
  function firstHeader(request, name) {
@@ -14402,12 +14396,12 @@ function registerMcpAppRoutes(fastify2) {
14402
14396
  }
14403
14397
 
14404
14398
  // src/controllers/eval.ts
14405
- var import_core36 = require("@axiom-lattice/core");
14399
+ var import_core37 = require("@axiom-lattice/core");
14406
14400
  var import_uuid5 = require("uuid");
14407
14401
 
14408
14402
  // src/services/eval-runner.ts
14409
14403
  var import_events = require("events");
14410
- var import_core35 = require("@axiom-lattice/core");
14404
+ var import_core36 = require("@axiom-lattice/core");
14411
14405
  var import_uuid4 = require("uuid");
14412
14406
  var TERMINAL_PERSIST_ATTEMPTS = 2;
14413
14407
  function mapLogs(logs) {
@@ -14517,12 +14511,12 @@ var EvalRunner = class {
14517
14511
  const judgeModelKey = judgeCfg.modelKey || "";
14518
14512
  let resolvedJudgeModelKey;
14519
14513
  if (judgeModelKey) {
14520
- if (!import_core35.modelLatticeManager.hasLattice(judgeModelKey)) {
14514
+ if (!import_core36.modelLatticeManager.hasLattice(judgeModelKey)) {
14521
14515
  throw new Error(`Judge model "${judgeModelKey}" is not registered`);
14522
14516
  }
14523
14517
  resolvedJudgeModelKey = judgeModelKey;
14524
14518
  } else {
14525
- const models = import_core35.modelLatticeManager.getAllLattices();
14519
+ const models = import_core36.modelLatticeManager.getAllLattices();
14526
14520
  const defaultModel = models.find((m) => m.key === "default");
14527
14521
  resolvedJudgeModelKey = defaultModel?.key ?? models[0]?.key ?? "";
14528
14522
  if (!resolvedJudgeModelKey) {
@@ -14630,7 +14624,7 @@ var EvalRunner = class {
14630
14624
  };
14631
14625
  const runPromise = (async () => {
14632
14626
  try {
14633
- const evalProject = new import_core35.LatticeEvalProject(projectConfig, onCaseComplete);
14627
+ const evalProject = new import_core36.LatticeEvalProject(projectConfig, onCaseComplete);
14634
14628
  const calibration = await evalProject.calibrateJudge();
14635
14629
  if (!calibration.ok && !calibration.bypassed) {
14636
14630
  throw new Error(`Judge calibration failed: ${calibration.reason}`);
@@ -14734,7 +14728,7 @@ var EvalRunner = class {
14734
14728
  return ctx !== void 0 && !ctx.terminal.workerSettled && (tenantId === void 0 || ctx.tenantId === tenantId);
14735
14729
  }
14736
14730
  getEvalStore() {
14737
- return (0, import_core35.getStoreLattice)("default", "eval").store;
14731
+ return (0, import_core36.getStoreLattice)("default", "eval").store;
14738
14732
  }
14739
14733
  releaseProjectLease(leaseKey, leaseToken) {
14740
14734
  if (this.projectLeases.get(leaseKey) === leaseToken) this.projectLeases.delete(leaseKey);
@@ -14751,7 +14745,7 @@ function getTenantId12(request) {
14751
14745
  return request.headers["x-tenant-id"] || "default";
14752
14746
  }
14753
14747
  function getEvalStore() {
14754
- return (0, import_core36.getStoreLattice)("default", "eval").store;
14748
+ return (0, import_core37.getStoreLattice)("default", "eval").store;
14755
14749
  }
14756
14750
  async function getOwnedSuite(store2, tenantId, projectId, suiteId) {
14757
14751
  const project = await store2.getProjectById(tenantId, projectId);
@@ -15281,11 +15275,11 @@ data: ${JSON.stringify(event.data)}
15281
15275
  }
15282
15276
 
15283
15277
  // src/controllers/users.ts
15284
- var import_core37 = require("@axiom-lattice/core");
15278
+ var import_core38 = require("@axiom-lattice/core");
15285
15279
  var import_uuid6 = require("uuid");
15286
15280
  var UsersController = class {
15287
15281
  constructor() {
15288
- this.userStore = (0, import_core37.getStoreLattice)("default", "user").store;
15282
+ this.userStore = (0, import_core38.getStoreLattice)("default", "user").store;
15289
15283
  }
15290
15284
  async listUsers(request, reply) {
15291
15285
  const { email } = request.query;
@@ -15363,11 +15357,11 @@ function registerUserRoutes(app2) {
15363
15357
  }
15364
15358
 
15365
15359
  // src/controllers/tenants.ts
15366
- var import_core38 = require("@axiom-lattice/core");
15360
+ var import_core39 = require("@axiom-lattice/core");
15367
15361
  var import_uuid7 = require("uuid");
15368
15362
  var TenantsController = class {
15369
15363
  constructor() {
15370
- this.tenantStore = (0, import_core38.getStoreLattice)("default", "tenant").store;
15364
+ this.tenantStore = (0, import_core39.getStoreLattice)("default", "tenant").store;
15371
15365
  }
15372
15366
  // ==================== Tenant CRUD ====================
15373
15367
  async listTenants(request, reply) {
@@ -15431,7 +15425,7 @@ function registerTenantRoutes(app2) {
15431
15425
  }
15432
15426
 
15433
15427
  // src/controllers/auth.ts
15434
- var import_core39 = require("@axiom-lattice/core");
15428
+ var import_core40 = require("@axiom-lattice/core");
15435
15429
  var import_uuid8 = require("uuid");
15436
15430
  var import_node_crypto6 = require("crypto");
15437
15431
  var defaultAuthConfig = {
@@ -15441,9 +15435,9 @@ var defaultAuthConfig = {
15441
15435
  };
15442
15436
  var AuthController = class {
15443
15437
  constructor(config = {}) {
15444
- this.userStore = (0, import_core39.getStoreLattice)("default", "user").store;
15445
- this.tenantStore = (0, import_core39.getStoreLattice)("default", "tenant").store;
15446
- this.userTenantLinkStore = (0, import_core39.getStoreLattice)("default", "userTenantLink").store;
15438
+ this.userStore = (0, import_core40.getStoreLattice)("default", "user").store;
15439
+ this.tenantStore = (0, import_core40.getStoreLattice)("default", "tenant").store;
15440
+ this.userTenantLinkStore = (0, import_core40.getStoreLattice)("default", "userTenantLink").store;
15447
15441
  this.config = { ...defaultAuthConfig, ...config };
15448
15442
  }
15449
15443
  async register(request, reply) {
@@ -15602,7 +15596,7 @@ var AuthController = class {
15602
15596
  const linkMeta = link?.metadata || {};
15603
15597
  let personalAssistant = null;
15604
15598
  if (linkMeta.personalAssistantId) {
15605
- const assistantStore = (0, import_core39.getStoreLattice)("default", "assistant").store;
15599
+ const assistantStore = (0, import_core40.getStoreLattice)("default", "assistant").store;
15606
15600
  const exists = await assistantStore.hasAssistant(tenantId, linkMeta.personalAssistantId);
15607
15601
  if (exists) {
15608
15602
  personalAssistant = {
@@ -16739,7 +16733,7 @@ function registerChannelInstallationRoutes(app2) {
16739
16733
 
16740
16734
  // src/controllers/channel-bindings.ts
16741
16735
  var import_protocols8 = require("@axiom-lattice/protocols");
16742
- var import_core40 = require("@axiom-lattice/core");
16736
+ var import_core41 = require("@axiom-lattice/core");
16743
16737
  function getTenantId14(request) {
16744
16738
  const userTenantId = request.user?.tenantId;
16745
16739
  if (typeof userTenantId === "string" && userTenantId) return userTenantId;
@@ -16797,7 +16791,7 @@ function snapshotPublicUpdate(value) {
16797
16791
  return body;
16798
16792
  }
16799
16793
  function getInstallationStore2() {
16800
- return (0, import_core40.getStoreLattice)("default", "channelInstallation").store;
16794
+ return (0, import_core41.getStoreLattice)("default", "channelInstallation").store;
16801
16795
  }
16802
16796
  async function isValidPublicInstallation(tenantId, channelInstallationId, channel) {
16803
16797
  const installation = await getInstallationStore2().getInstallationById(channelInstallationId);
@@ -16816,7 +16810,7 @@ async function getBindingList(request, _reply) {
16816
16810
  const tenantId = getTenantId14(request);
16817
16811
  const { channel, agentId, channelInstallationId, limit, offset } = request.query;
16818
16812
  try {
16819
- const registry = (0, import_core40.getBindingRegistry)();
16813
+ const registry = (0, import_core41.getBindingRegistry)();
16820
16814
  const bindings = await registry.list({
16821
16815
  channel,
16822
16816
  agentId,
@@ -16835,7 +16829,7 @@ async function getBindingList(request, _reply) {
16835
16829
  async function getBinding(request, reply) {
16836
16830
  const tenantId = getTenantId14(request);
16837
16831
  try {
16838
- const registry = (0, import_core40.getBindingRegistry)();
16832
+ const registry = (0, import_core41.getBindingRegistry)();
16839
16833
  const binding = await registry.findById(tenantId, request.params.id);
16840
16834
  if (!binding || isInternalBinding(binding)) {
16841
16835
  reply.status(404);
@@ -16857,7 +16851,7 @@ async function createBinding(request, reply) {
16857
16851
  input.channelInstallationId,
16858
16852
  input.channel
16859
16853
  )) return invalidPublicInstallation(reply);
16860
- const registry = (0, import_core40.getBindingRegistry)();
16854
+ const registry = (0, import_core41.getBindingRegistry)();
16861
16855
  const binding = await registry.create({ ...input, tenantId });
16862
16856
  reply.status(201);
16863
16857
  return { success: true, message: "Binding created", data: binding };
@@ -16874,7 +16868,7 @@ async function createBinding(request, reply) {
16874
16868
  async function updateBinding(request, reply) {
16875
16869
  try {
16876
16870
  const tenantId = getTenantId14(request);
16877
- const registry = (0, import_core40.getBindingRegistry)();
16871
+ const registry = (0, import_core41.getBindingRegistry)();
16878
16872
  const existing = await registry.findById(tenantId, request.params.id);
16879
16873
  if (!existing || isInternalBinding(existing)) {
16880
16874
  reply.status(404);
@@ -16901,7 +16895,7 @@ async function updateBinding(request, reply) {
16901
16895
  async function deleteBinding(request, reply) {
16902
16896
  try {
16903
16897
  const tenantId = getTenantId14(request);
16904
- const registry = (0, import_core40.getBindingRegistry)();
16898
+ const registry = (0, import_core41.getBindingRegistry)();
16905
16899
  const existing = await registry.findById(tenantId, request.params.id);
16906
16900
  if (!existing || isInternalBinding(existing)) {
16907
16901
  reply.status(404);
@@ -16923,7 +16917,7 @@ async function resolveBinding(request, _reply) {
16923
16917
  return { success: false, message: "No binding found", data: null };
16924
16918
  }
16925
16919
  try {
16926
- const registry = (0, import_core40.getBindingRegistry)();
16920
+ const registry = (0, import_core41.getBindingRegistry)();
16927
16921
  const binding = await registry.resolve({ channel, senderId, channelInstallationId, tenantId });
16928
16922
  if (!binding) {
16929
16923
  return { success: false, message: "No binding found", data: null };
@@ -16946,7 +16940,7 @@ function registerChannelBindingRoutes(app2) {
16946
16940
  }
16947
16941
 
16948
16942
  // src/controllers/menu-items.ts
16949
- var import_core41 = require("@axiom-lattice/core");
16943
+ var import_core42 = require("@axiom-lattice/core");
16950
16944
  function getTenantId15(request) {
16951
16945
  const userTenantId = request.user?.tenantId;
16952
16946
  if (userTenantId) return userTenantId;
@@ -16958,7 +16952,7 @@ function errorMessage(err) {
16958
16952
  async function getMenuItemList(request, _reply) {
16959
16953
  const tenantId = getTenantId15(request);
16960
16954
  try {
16961
- const registry = (0, import_core41.getMenuRegistry)();
16955
+ const registry = (0, import_core42.getMenuRegistry)();
16962
16956
  const items = await registry.list({ tenantId, menuTarget: request.query.menuTarget });
16963
16957
  return { success: true, message: "Menu items retrieved", data: { records: items, total: items.length } };
16964
16958
  } catch (error) {
@@ -16970,7 +16964,7 @@ async function getMenuItemList(request, _reply) {
16970
16964
  async function getMenuItem(request, reply) {
16971
16965
  const tenantId = getTenantId15(request);
16972
16966
  try {
16973
- const registry = (0, import_core41.getMenuRegistry)();
16967
+ const registry = (0, import_core42.getMenuRegistry)();
16974
16968
  const item = await registry.getById(request.params.id);
16975
16969
  if (!item || item.tenantId !== tenantId) {
16976
16970
  reply.status(404);
@@ -16987,7 +16981,7 @@ async function getMenuItem(request, reply) {
16987
16981
  async function createMenuItem(request, reply) {
16988
16982
  const tenantId = getTenantId15(request);
16989
16983
  try {
16990
- const registry = (0, import_core41.getMenuRegistry)();
16984
+ const registry = (0, import_core42.getMenuRegistry)();
16991
16985
  const item = await registry.create({ ...request.body, tenantId });
16992
16986
  reply.status(201);
16993
16987
  return { success: true, message: "Menu item created", data: item };
@@ -17001,7 +16995,7 @@ async function createMenuItem(request, reply) {
17001
16995
  async function updateMenuItem(request, reply) {
17002
16996
  try {
17003
16997
  const tenantId = getTenantId15(request);
17004
- const registry = (0, import_core41.getMenuRegistry)();
16998
+ const registry = (0, import_core42.getMenuRegistry)();
17005
16999
  const existing = await registry.getById(request.params.id);
17006
17000
  if (!existing || existing.tenantId !== tenantId) {
17007
17001
  reply.status(404);
@@ -17019,7 +17013,7 @@ async function updateMenuItem(request, reply) {
17019
17013
  async function deleteMenuItem(request, reply) {
17020
17014
  try {
17021
17015
  const tenantId = getTenantId15(request);
17022
- const registry = (0, import_core41.getMenuRegistry)();
17016
+ const registry = (0, import_core42.getMenuRegistry)();
17023
17017
  const existing = await registry.getById(request.params.id);
17024
17018
  if (!existing || existing.tenantId !== tenantId) {
17025
17019
  reply.status(404);
@@ -17219,7 +17213,7 @@ function registerA2ABridgeRoutes(app2) {
17219
17213
  }
17220
17214
 
17221
17215
  // src/routes/stt.ts
17222
- var import_core42 = require("@axiom-lattice/core");
17216
+ var import_core43 = require("@axiom-lattice/core");
17223
17217
  var ALLOWED_AUDIO_FORMATS = /* @__PURE__ */ new Set([
17224
17218
  "webm",
17225
17219
  "wav",
@@ -17232,7 +17226,7 @@ var ALLOWED_AUDIO_FORMATS = /* @__PURE__ */ new Set([
17232
17226
  var MAX_AUDIO_FILE_SIZE = 25 * 1024 * 1024;
17233
17227
  var registerSTTRoutes = (app2) => {
17234
17228
  app2.get("/api/stt/models", async (_request, reply) => {
17235
- const models = import_core42.sttModelLatticeManager.getAllSTTModelInfo();
17229
+ const models = import_core43.sttModelLatticeManager.getAllSTTModelInfo();
17236
17230
  return reply.send({ models });
17237
17231
  });
17238
17232
  app2.post(
@@ -17275,7 +17269,7 @@ var registerSTTRoutes = (app2) => {
17275
17269
  try {
17276
17270
  let client;
17277
17271
  try {
17278
- client = (0, import_core42.getSTTClient)(modelKey2);
17272
+ client = (0, import_core43.getSTTClient)(modelKey2);
17279
17273
  } catch {
17280
17274
  return reply.status(404).send({ error: `STT model "${modelKey2}" not found` });
17281
17275
  }
@@ -17297,7 +17291,7 @@ var registerSTTRoutes = (app2) => {
17297
17291
  };
17298
17292
 
17299
17293
  // src/controllers/local-a2a.ts
17300
- var import_core43 = require("@axiom-lattice/core");
17294
+ var import_core44 = require("@axiom-lattice/core");
17301
17295
  var import_protocols9 = require("@axiom-lattice/protocols");
17302
17296
  function getTenantId16(request) {
17303
17297
  const userTenantId = request.user?.tenantId;
@@ -17311,7 +17305,7 @@ function getLocalRuntime(assistant) {
17311
17305
  return graphDefinition.localRuntime;
17312
17306
  }
17313
17307
  async function getLocalA2AAssistants(tenantId) {
17314
- const storeLattice = (0, import_core43.getStoreLattice)("default", "assistant");
17308
+ const storeLattice = (0, import_core44.getStoreLattice)("default", "assistant");
17315
17309
  const assistants = await storeLattice.store.getAllAssistants(tenantId);
17316
17310
  const results = [];
17317
17311
  for (const assistant of assistants) {
@@ -17323,7 +17317,7 @@ async function getLocalA2AAssistants(tenantId) {
17323
17317
  return results;
17324
17318
  }
17325
17319
  async function getLocalA2AAssistant(tenantId, assistantId) {
17326
- const storeLattice = (0, import_core43.getStoreLattice)("default", "assistant");
17320
+ const storeLattice = (0, import_core44.getStoreLattice)("default", "assistant");
17327
17321
  const assistant = await storeLattice.store.getAssistantById(tenantId, assistantId);
17328
17322
  if (!assistant) return null;
17329
17323
  const runtime = getLocalRuntime(assistant);
@@ -17565,11 +17559,11 @@ function registerTaskRoutes(app2, controller) {
17565
17559
  }
17566
17560
 
17567
17561
  // src/routes/index.ts
17568
- var import_core54 = require("@axiom-lattice/core");
17562
+ var import_core55 = require("@axiom-lattice/core");
17569
17563
 
17570
17564
  // src/controllers/tasks.ts
17571
17565
  var import_protocols13 = require("@axiom-lattice/protocols");
17572
- var import_core45 = require("@axiom-lattice/core");
17566
+ var import_core46 = require("@axiom-lattice/core");
17573
17567
 
17574
17568
  // src/services/collaboration/ProjectTaskThreadService.ts
17575
17569
  var import_protocols11 = require("@axiom-lattice/protocols");
@@ -17889,7 +17883,7 @@ var import_node_crypto9 = require("crypto");
17889
17883
 
17890
17884
  // src/services/collaboration/ProjectTaskExecutionService.ts
17891
17885
  var import_node_crypto8 = require("crypto");
17892
- var import_core44 = require("@axiom-lattice/core");
17886
+ var import_core45 = require("@axiom-lattice/core");
17893
17887
  var import_protocols12 = require("@axiom-lattice/protocols");
17894
17888
  init_projectTaskScope();
17895
17889
 
@@ -17953,7 +17947,7 @@ var ProjectTaskExecutionService = class {
17953
17947
  if (!Number.isFinite(options.lifecycleSettlementTimeoutMs) || options.lifecycleSettlementTimeoutMs <= 0) {
17954
17948
  throw new Error("Project task lifecycle settlement timeout must be positive");
17955
17949
  }
17956
- this.runBridge = (0, import_core44.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
17950
+ this.runBridge = (0, import_core45.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
17957
17951
  }
17958
17952
  /** Validates, atomically starts, dispatches, and settles a pending Project Task. */
17959
17953
  async start(input, signal) {
@@ -18148,15 +18142,15 @@ var ProjectTaskExecutionService = class {
18148
18142
  settlement.cleanup();
18149
18143
  return { kind: "deferred", task: input.task, thread: input.thread, messageId: input.inputMessageId };
18150
18144
  }
18151
- if (resumed.status === import_core44.ThreadStatus.INTERRUPTED && settlement.tryClaim()) {
18145
+ if (resumed.status === import_core45.ThreadStatus.INTERRUPTED && settlement.tryClaim()) {
18152
18146
  settlement.cleanup();
18153
18147
  const outcome2 = await this.settleInterruptedEvent(input.task, input.thread, input.inputMessageId);
18154
18148
  settlement.resolve(outcome2);
18155
18149
  return outcome2;
18156
18150
  }
18157
- if ((resumed.status === import_core44.ThreadStatus.IDLE || resumed.status === import_core44.ThreadStatus.ERROR) && settlement.tryClaim()) {
18151
+ if ((resumed.status === import_core45.ThreadStatus.IDLE || resumed.status === import_core45.ThreadStatus.ERROR) && settlement.tryClaim()) {
18158
18152
  settlement.cleanup();
18159
- const reason = resumed.status === import_core44.ThreadStatus.IDLE ? "Project task execution ended without lifecycle transition" : "Recovered Agent execution is in error state";
18153
+ const reason = resumed.status === import_core45.ThreadStatus.IDLE ? "Project task execution ended without lifecycle transition" : "Recovered Agent execution is in error state";
18160
18154
  const outcome2 = await this.settleEndedRecovery(input, reason);
18161
18155
  settlement.resolve(outcome2);
18162
18156
  return outcome2;
@@ -19199,7 +19193,7 @@ function withErrors(handler) {
19199
19193
  if (error instanceof HttpTaskError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
19200
19194
  if (error instanceof TaskCommandError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
19201
19195
  if (error instanceof ProjectCollaborationError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
19202
- if (error instanceof import_core45.ProjectTaskOwnerPolicyError) return reply.code(403).send({ success: false, code: error.code, error: error.message });
19196
+ if (error instanceof import_core46.ProjectTaskOwnerPolicyError) return reply.code(403).send({ success: false, code: error.code, error: error.message });
19203
19197
  if (error instanceof ProjectTaskThreadError) return reply.code(409).send({ success: false, code: error.code, error: error.message });
19204
19198
  request.log.error({ error }, "Task route failed");
19205
19199
  return reply.code(500).send({ success: false, code: "TASK_INTERNAL_ERROR", error: "Task operation failed" });
@@ -19836,7 +19830,7 @@ var import_zod6 = require("zod");
19836
19830
  // src/services/agent-web-app/AgentWebAppRuntimeService.ts
19837
19831
  var import_node_crypto10 = require("crypto");
19838
19832
  var import_protocols14 = require("@axiom-lattice/protocols");
19839
- var import_core46 = require("@axiom-lattice/core");
19833
+ var import_core47 = require("@axiom-lattice/core");
19840
19834
  init_task_file_refs();
19841
19835
  function isRecord2(value) {
19842
19836
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -20000,12 +19994,12 @@ var AgentWebAppRuntimeService = class {
20000
19994
  const runtime = await this.resolveRuntime(webAppId, selection);
20001
19995
  await this.requireOwnedThread(runtime, userId, threadId);
20002
19996
  if (process.env.AXIOM_REPLICA_ID) {
20003
- const owner = await (0, import_core46.getThreadRunOwner)({
19997
+ const owner = await (0, import_core47.getThreadRunOwner)({
20004
19998
  tenantId: runtime.webApp.tenantId,
20005
19999
  assistantId: runtime.webApp.assistantId,
20006
20000
  threadId
20007
20001
  });
20008
- if (owner && owner !== (0, import_core46.getReplicaId)()) {
20002
+ if (owner && owner !== (0, import_core47.getReplicaId)()) {
20009
20003
  return {
20010
20004
  stream: (async function* () {
20011
20005
  yield (0, import_protocols14.buildAffinityMissChunk)(owner, threadId);
@@ -20358,7 +20352,7 @@ async function verifyWebAppToken(token, issuer, options = {}) {
20358
20352
 
20359
20353
  // src/routes/agent-web-app-runtime.ts
20360
20354
  var import_protocols15 = require("@axiom-lattice/protocols");
20361
- var import_core47 = require("@axiom-lattice/core");
20355
+ var import_core48 = require("@axiom-lattice/core");
20362
20356
  var idSchema = import_zod6.z.string().min(1).max(128);
20363
20357
  var paramsSchema = import_zod6.z.object({ webAppId: idSchema }).strict();
20364
20358
  var threadParamsSchema = import_zod6.z.object({ webAppId: idSchema, threadId: idSchema }).strict();
@@ -20792,7 +20786,7 @@ function registerAgentWebAppRuntimeRoutes(app2, deps) {
20792
20786
  if (!threadId) throw new AgentWebAppRuntimeError("INVALID_REQUEST", 400, "thread_id is required");
20793
20787
  const content = body.messages.map((message) => message.content).join("\n");
20794
20788
  const { messageId } = await deps.service.enqueueMessage(webAppId, identity.userId, threadId, content, { projectId: body.projectId, modelKey: body.modelKey });
20795
- reply.header(import_protocols15.REPLICA_HEADER, (0, import_core47.getReplicaId)());
20789
+ reply.header(import_protocols15.REPLICA_HEADER, (0, import_core48.getReplicaId)());
20796
20790
  for (const [name, value] of Object.entries((0, import_protocols15.affinityEchoHeaders)(request.headers[import_protocols15.AGENT_AFFINITY_HEADER]))) {
20797
20791
  reply.header(name, value);
20798
20792
  }
@@ -20878,7 +20872,7 @@ function beginSse(reply, request) {
20878
20872
  "X-Accel-Buffering": "no",
20879
20873
  "Access-Control-Allow-Origin": "*",
20880
20874
  "Access-Control-Expose-Headers": `${import_protocols15.REPLICA_HEADER}, ${import_protocols15.AFFINITY_ECHO_HEADER}`,
20881
- [import_protocols15.REPLICA_HEADER]: (0, import_core47.getReplicaId)(),
20875
+ [import_protocols15.REPLICA_HEADER]: (0, import_core48.getReplicaId)(),
20882
20876
  ...(0, import_protocols15.affinityEchoHeaders)(request.headers[import_protocols15.AGENT_AFFINITY_HEADER])
20883
20877
  });
20884
20878
  }
@@ -21115,7 +21109,7 @@ var import_zod9 = require("zod");
21115
21109
 
21116
21110
  // src/services/capability/CapabilityBundleService.ts
21117
21111
  var import_zod8 = require("zod");
21118
- var import_core48 = require("@axiom-lattice/core");
21112
+ var import_core49 = require("@axiom-lattice/core");
21119
21113
  var CapabilityBundleServiceError = class extends Error {
21120
21114
  constructor(code, message, statusCode) {
21121
21115
  super(message);
@@ -21156,7 +21150,7 @@ function projectBundleIds(config) {
21156
21150
  return [...value];
21157
21151
  }
21158
21152
  function issue(error) {
21159
- if (error instanceof import_core48.CapabilityBundleMergeError || error instanceof import_core48.CapabilityBundleValidationError) return { code: error instanceof import_core48.CapabilityBundleValidationError && error.code === "CAPABILITY_BUNDLE_INVALID_CONFIG" ? "INVALID_BUNDLE_CONFIG" : error.code, message: error.message, bundleId: error instanceof import_core48.CapabilityBundleMergeError ? error.bundleId : void 0, capabilityType: error.capabilityType, fieldPath: error.fieldPath };
21153
+ if (error instanceof import_core49.CapabilityBundleMergeError || error instanceof import_core49.CapabilityBundleValidationError) return { code: error instanceof import_core49.CapabilityBundleValidationError && error.code === "CAPABILITY_BUNDLE_INVALID_CONFIG" ? "INVALID_BUNDLE_CONFIG" : error.code, message: error.message, bundleId: error instanceof import_core49.CapabilityBundleMergeError ? error.bundleId : void 0, capabilityType: error.capabilityType, fieldPath: error.fieldPath };
21160
21154
  return { code: "CAPABILITY_BUNDLE_CONFIGURATION_ERROR", message: error instanceof Error ? error.message : "Invalid capability bundle configuration" };
21161
21155
  }
21162
21156
  var CapabilityBundleService = class {
@@ -21169,7 +21163,7 @@ var CapabilityBundleService = class {
21169
21163
  const errors = [];
21170
21164
  for (const value of values) {
21171
21165
  try {
21172
- (0, import_core48.validateCapabilityBundleInput)(value);
21166
+ (0, import_core49.validateCapabilityBundleInput)(value);
21173
21167
  bundles.push(value);
21174
21168
  } catch {
21175
21169
  errors.push({ bundleId: value.id, code: "INVALID_BUNDLE_CONFIG", message: "Capability bundle record is invalid" });
@@ -21181,7 +21175,7 @@ var CapabilityBundleService = class {
21181
21175
  const value = await this.deps.bundleStore.getById(tenantId, id3);
21182
21176
  if (!value) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
21183
21177
  try {
21184
- (0, import_core48.validateCapabilityBundleInput)(value);
21178
+ (0, import_core49.validateCapabilityBundleInput)(value);
21185
21179
  } catch {
21186
21180
  throw new CapabilityBundleServiceError("INVALID_BUNDLE_CONFIG", "Capability bundle record is invalid", 422);
21187
21181
  }
@@ -21189,7 +21183,7 @@ var CapabilityBundleService = class {
21189
21183
  }
21190
21184
  async create(tenantId, input) {
21191
21185
  rejectStableKey(input);
21192
- (0, import_core48.validateCapabilityBundleInput)(input);
21186
+ (0, import_core49.validateCapabilityBundleInput)(input);
21193
21187
  const value = input;
21194
21188
  const name = value.name.trim();
21195
21189
  const base = slugify(name);
@@ -21200,10 +21194,10 @@ var CapabilityBundleService = class {
21200
21194
  let suffix = 2;
21201
21195
  while (keys2.has(key)) key = `${base}-${suffix++}`;
21202
21196
  const normalized = { ...value, key, name };
21203
- (0, import_core48.validateCapabilityBundleInput)(normalized);
21197
+ (0, import_core49.validateCapabilityBundleInput)(normalized);
21204
21198
  try {
21205
21199
  const result = await this.deps.bundleStore.create(tenantId, normalized);
21206
- (0, import_core48.validateCapabilityBundleInput)(result);
21200
+ (0, import_core49.validateCapabilityBundleInput)(result);
21207
21201
  return result;
21208
21202
  } catch (error) {
21209
21203
  if (!isDuplicate(error)) throw error;
@@ -21214,16 +21208,16 @@ var CapabilityBundleService = class {
21214
21208
  }
21215
21209
  async update(tenantId, id3, input) {
21216
21210
  rejectStableKey(input);
21217
- (0, import_core48.validateCapabilityBundleInput)(input, { partial: true });
21211
+ (0, import_core49.validateCapabilityBundleInput)(input, { partial: true });
21218
21212
  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);
21219
21213
  const value = input;
21220
21214
  const normalized = { ...value, ...value.name === void 0 ? {} : { name: value.name.trim() }, ...Object.prototype.hasOwnProperty.call(value, "description") ? { description: value.description?.trim() || void 0 } : {} };
21221
- (0, import_core48.validateCapabilityBundleInput)(normalized, { partial: true });
21215
+ (0, import_core49.validateCapabilityBundleInput)(normalized, { partial: true });
21222
21216
  try {
21223
21217
  const result = await this.deps.bundleStore.update(tenantId, id3, normalized);
21224
21218
  if (!result) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
21225
21219
  if ("status" in result && result.status === "conflict") throw new CapabilityBundleServiceError("BUNDLE_CONFLICT", "Capability bundle changed after it was loaded; reload before saving", 409);
21226
- (0, import_core48.validateCapabilityBundleInput)(result);
21220
+ (0, import_core49.validateCapabilityBundleInput)(result);
21227
21221
  return result;
21228
21222
  } catch (error) {
21229
21223
  if (error instanceof CapabilityBundleServiceError) throw error;
@@ -21258,8 +21252,8 @@ var CapabilityBundleService = class {
21258
21252
  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: "" };
21259
21253
  try {
21260
21254
  const ordered = ids.map((id3) => byId.get(id3));
21261
- ordered.forEach((bundle) => (0, import_core48.validateCapabilityBundleInput)(bundle));
21262
- return (0, import_core48.mergeCapabilityBundles)(ordered);
21255
+ ordered.forEach((bundle) => (0, import_core49.validateCapabilityBundleInput)(bundle));
21256
+ return (0, import_core49.mergeCapabilityBundles)(ordered);
21263
21257
  } catch (error) {
21264
21258
  return { bundleIds: ids, capabilities: [], overrides: [], sources: [], warnings: [], errors: [issue(error)], revision: "" };
21265
21259
  }
@@ -21292,7 +21286,7 @@ var CapabilityBundleService = class {
21292
21286
  return ids.map((id3) => {
21293
21287
  const value = byId.get(id3);
21294
21288
  if (!value) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
21295
- (0, import_core48.validateCapabilityBundleInput)(value);
21289
+ (0, import_core49.validateCapabilityBundleInput)(value);
21296
21290
  return value;
21297
21291
  });
21298
21292
  }
@@ -21307,7 +21301,7 @@ var CapabilityBundleService = class {
21307
21301
  continue;
21308
21302
  }
21309
21303
  try {
21310
- (0, import_core48.validateCapabilityBundleInput)(bundle);
21304
+ (0, import_core49.validateCapabilityBundleInput)(bundle);
21311
21305
  valid.push(bundle);
21312
21306
  } catch (error) {
21313
21307
  errors.push({ ...issue(error), bundleId: id3 });
@@ -21315,7 +21309,7 @@ var CapabilityBundleService = class {
21315
21309
  }
21316
21310
  let preview;
21317
21311
  try {
21318
- preview = (0, import_core48.mergeCapabilityBundles)(valid);
21312
+ preview = (0, import_core49.mergeCapabilityBundles)(valid);
21319
21313
  } catch (error) {
21320
21314
  preview = { bundleIds: ids, capabilities: [], overrides: [], sources: [], warnings: [], errors: [issue(error)], revision: "" };
21321
21315
  }
@@ -21467,7 +21461,7 @@ var import_zod11 = require("zod");
21467
21461
  // src/services/model-provider/ModelProviderService.ts
21468
21462
  var import_node_crypto14 = require("crypto");
21469
21463
  var import_protocols16 = require("@axiom-lattice/protocols");
21470
- var import_core49 = require("@axiom-lattice/core");
21464
+ var import_core50 = require("@axiom-lattice/core");
21471
21465
 
21472
21466
  // src/services/model-provider/errors.ts
21473
21467
  var ModelProviderServiceError = class extends Error {
@@ -22271,9 +22265,9 @@ var ModelProviderService = class {
22271
22265
  */
22272
22266
  async assertSafeUrl(baseURL) {
22273
22267
  try {
22274
- await (0, import_core49.assertSafeUpstreamUrl)(baseURL);
22268
+ await (0, import_core50.assertSafeUpstreamUrl)(baseURL);
22275
22269
  } catch (error) {
22276
- if (error instanceof import_core49.UnsafeUpstreamUrlError) {
22270
+ if (error instanceof import_core50.UnsafeUpstreamUrlError) {
22277
22271
  throw new ModelProviderServiceError(
22278
22272
  unsafeReasonToErrorCode[error.reason],
22279
22273
  400,
@@ -23739,7 +23733,7 @@ async function execute(reply, operation) {
23739
23733
  // src/routes/cospace.ts
23740
23734
  var import_node_crypto20 = require("crypto");
23741
23735
  var import_zod15 = require("zod");
23742
- var import_core50 = require("@axiom-lattice/core");
23736
+ var import_core51 = require("@axiom-lattice/core");
23743
23737
  var import_protocols19 = require("@axiom-lattice/protocols");
23744
23738
  var CoSpaceAuthError = class extends Error {
23745
23739
  constructor() {
@@ -23924,14 +23918,14 @@ function registerCoSpaceRoutes(app2, deps) {
23924
23918
  }
23925
23919
  let projectId;
23926
23920
  if (body.type === "human") {
23927
- projectId = (0, import_core50.generateDirectHumanProjectId)(
23921
+ projectId = (0, import_core51.generateDirectHumanProjectId)(
23928
23922
  actor3.tenantId,
23929
23923
  params.workspaceId,
23930
23924
  actor3.userId,
23931
23925
  body.targetUserId
23932
23926
  );
23933
23927
  } else {
23934
- projectId = (0, import_core50.generateDirectBotProjectId)(
23928
+ projectId = (0, import_core51.generateDirectBotProjectId)(
23935
23929
  actor3.tenantId,
23936
23930
  params.workspaceId,
23937
23931
  actor3.userId,
@@ -24138,7 +24132,7 @@ function registerCoSpaceRoutes(app2, deps) {
24138
24132
  );
24139
24133
  const bots = [];
24140
24134
  for (const assistant of assistants) {
24141
- const directProjectId = (0, import_core50.generateDirectBotProjectId)(
24135
+ const directProjectId = (0, import_core51.generateDirectBotProjectId)(
24142
24136
  actor3.tenantId,
24143
24137
  params.workspaceId,
24144
24138
  actor3.userId,
@@ -24200,7 +24194,7 @@ function registerCoSpaceRoutes(app2, deps) {
24200
24194
  if (link.userId === actor3.userId) continue;
24201
24195
  const user = await deps.userStore.getUserById(link.userId);
24202
24196
  if (!user) continue;
24203
- const directProjectId = (0, import_core50.generateDirectHumanProjectId)(
24197
+ const directProjectId = (0, import_core51.generateDirectHumanProjectId)(
24204
24198
  actor3.tenantId,
24205
24199
  params.workspaceId,
24206
24200
  actor3.userId,
@@ -25017,7 +25011,7 @@ function createRoomMessageRetentionJob(input) {
25017
25011
 
25018
25012
  // src/services/collaboration/ProjectTaskExecutionMutex.ts
25019
25013
  var import_protocols22 = require("@axiom-lattice/protocols");
25020
- var import_core51 = require("@axiom-lattice/core");
25014
+ var import_core52 = require("@axiom-lattice/core");
25021
25015
  var MACHINE_LEASE_OPTIONS = { ttlMs: 6e4, acquireTimeoutMs: 9e4, retryDelayMs: 100 };
25022
25016
  function machineKey(scope) {
25023
25017
  const snapshot = (0, import_protocols22.snapshotExactRecord)(scope, ["tenantId", "assistantId", "projectId"]);
@@ -25045,9 +25039,9 @@ var ProjectTaskExecutionMutex = class {
25045
25039
  const leaseKey = `project-task-machine:${encodeURIComponent(scope.tenantId)}:${encodeURIComponent(scope.assistantId)}:${encodeURIComponent(scope.projectId)}`;
25046
25040
  await this.acquire(key, signal);
25047
25041
  try {
25048
- const store2 = (0, import_core51.getCoordinationLeaseStore)();
25042
+ const store2 = (0, import_core52.getCoordinationLeaseStore)();
25049
25043
  if (!store2) return await operation();
25050
- return await (0, import_core51.withLease)(store2, leaseKey, (0, import_core51.getReplicaId)(), operation, MACHINE_LEASE_OPTIONS);
25044
+ return await (0, import_core52.withLease)(store2, leaseKey, (0, import_core52.getReplicaId)(), operation, MACHINE_LEASE_OPTIONS);
25051
25045
  } finally {
25052
25046
  this.release(key);
25053
25047
  }
@@ -25100,7 +25094,7 @@ var ProjectTaskExecutionMutex = class {
25100
25094
 
25101
25095
  // src/services/collaboration/ProjectTaskObserver.ts
25102
25096
  var import_node_crypto22 = require("crypto");
25103
- var import_core52 = require("@axiom-lattice/core");
25097
+ var import_core53 = require("@axiom-lattice/core");
25104
25098
  var import_protocols23 = require("@axiom-lattice/protocols");
25105
25099
 
25106
25100
  // src/services/collaboration/projectTaskDispatchMarker.ts
@@ -25137,7 +25131,7 @@ var ProjectTaskObserver = class {
25137
25131
  throw new Error(`Invalid Project task observer bound: ${name}`);
25138
25132
  }
25139
25133
  }
25140
- this.runBridge = (0, import_core52.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
25134
+ this.runBridge = (0, import_core53.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
25141
25135
  }
25142
25136
  /** Fire-and-forget notifier adapter that never waits for observer work or machine acquisition. */
25143
25137
  async listener(event) {
@@ -26353,7 +26347,7 @@ function isRecord3(value) {
26353
26347
  init_projectTaskScope();
26354
26348
 
26355
26349
  // src/services/collaboration/ProjectRoomRealtimeRuntime.ts
26356
- var import_core53 = require("@axiom-lattice/core");
26350
+ var import_core54 = require("@axiom-lattice/core");
26357
26351
 
26358
26352
  // src/services/collaboration/ProjectRoomEventBroker.ts
26359
26353
  var import_node_crypto24 = require("crypto");
@@ -27128,7 +27122,7 @@ function createProjectRoomRealtimeRuntime(deps) {
27128
27122
  broker,
27129
27123
  publisher,
27130
27124
  subscriber,
27131
- subscribe: (listener) => import_core53.taskLifecycleNotifier.subscribe(listener),
27125
+ subscribe: (listener) => import_core54.taskLifecycleNotifier.subscribe(listener),
27132
27126
  log: deps.log,
27133
27127
  shutdownTimeoutMs: deps.shutdownTimeoutMs
27134
27128
  });
@@ -27866,35 +27860,35 @@ function hookErrorMessage(error) {
27866
27860
  function wrapReassignmentThreadError(error) {
27867
27861
  if (error instanceof ProjectTaskThreadError) {
27868
27862
  if (error.code === "PROJECT_TASK_THREAD_SCOPE_INVALID") {
27869
- return new import_core54.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", error.message, {
27863
+ return new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", error.message, {
27870
27864
  hint: "Project task, room, or roster scope changed; re-read the task and retry."
27871
27865
  });
27872
27866
  }
27873
27867
  if (error.code === "PROJECT_TASK_THREAD_OWNER_INVALID") {
27874
- return new import_core54.ManagedTaskStartError("TASK_REASSIGN_NO_CHANGE", error.message, {
27868
+ return new import_core55.ManagedTaskStartError("TASK_REASSIGN_NO_CHANGE", error.message, {
27875
27869
  hint: "The target already owns this task; re-read before dispatching."
27876
27870
  });
27877
27871
  }
27878
- return new import_core54.ManagedTaskStartError("TASK_THREAD_CONFLICT", error.message, {
27872
+ return new import_core55.ManagedTaskStartError("TASK_THREAD_CONFLICT", error.message, {
27879
27873
  hint: "Task Thread changed concurrently; re-read the task and retry."
27880
27874
  });
27881
27875
  }
27882
- return new import_core54.ManagedTaskStartError("TASK_EXECUTION_ENQUEUE_FAILED", hookErrorMessage(error), {
27876
+ return new import_core55.ManagedTaskStartError("TASK_EXECUTION_ENQUEUE_FAILED", hookErrorMessage(error), {
27883
27877
  hint: "Re-read the task and retry the dispatch."
27884
27878
  });
27885
27879
  }
27886
27880
  function wrapReassignmentAuthorizationError(error) {
27887
- if (error instanceof import_core54.ProjectTaskOwnerPolicyError) {
27881
+ if (error instanceof import_core55.ProjectTaskOwnerPolicyError) {
27888
27882
  if (error.code === "PROJECT_TASK_CALLER_INACTIVE") {
27889
- return new import_core54.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", error.message, {
27883
+ return new import_core55.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", error.message, {
27890
27884
  hint: "Dispatch from an active Project Room member bot."
27891
27885
  });
27892
27886
  }
27893
- return new import_core54.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", error.message, {
27887
+ return new import_core55.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", error.message, {
27894
27888
  hint: "Dispatch to an active bot in this Project's roster."
27895
27889
  });
27896
27890
  }
27897
- return new import_core54.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", hookErrorMessage(error), {
27891
+ return new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", hookErrorMessage(error), {
27898
27892
  hint: "Re-read the task and roster, then retry the dispatch."
27899
27893
  });
27900
27894
  }
@@ -27923,43 +27917,43 @@ async function transferGovernedDispatchOwner(task, options, deps) {
27923
27917
  const agentId = options?.agentId;
27924
27918
  if (!agentId || agentId === task.ownerId) return void 0;
27925
27919
  if (!task.workspaceId || !task.projectId) {
27926
- throw new import_core54.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is not governed by a Project lifecycle.", {
27920
+ throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is not governed by a Project lifecycle.", {
27927
27921
  hint: "Dispatch governed tasks from a trusted Project run; ordinary tasks execute immediately."
27928
27922
  });
27929
27923
  }
27930
27924
  return deps.mutex.runExclusive({ tenantId: task.tenantId, projectId: task.projectId }, async () => {
27931
27925
  const current = await deps.tasks.getById(task.tenantId, task.id);
27932
27926
  if (!current || !isProjectLifecycleTask(current) || current.workspaceId !== task.workspaceId || current.projectId !== task.projectId) {
27933
- throw new import_core54.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is no longer a Project lifecycle task.", {
27927
+ throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is no longer a Project lifecycle task.", {
27934
27928
  hint: "Re-read the task and confirm it still belongs to this Project before dispatching."
27935
27929
  });
27936
27930
  }
27937
27931
  if (current.ownerType !== "agent") {
27938
- throw new import_core54.ManagedTaskStartError("AGENT_TASK_REQUIRED", "Project task owner must be an Agent.", {
27932
+ throw new import_core55.ManagedTaskStartError("AGENT_TASK_REQUIRED", "Project task owner must be an Agent.", {
27939
27933
  hint: "Assign the task to an Agent before dispatching."
27940
27934
  });
27941
27935
  }
27942
27936
  if (current.status !== "pending") {
27943
- throw new import_core54.ManagedTaskStartError("TASK_NOT_DISPATCHABLE", "Only a `pending` Project task can be dispatched.", {
27937
+ throw new import_core55.ManagedTaskStartError("TASK_NOT_DISPATCHABLE", "Only a `pending` Project task can be dispatched.", {
27944
27938
  hint: `This task is '${current.status}'. Resolve it or create a new task before dispatching.`
27945
27939
  });
27946
27940
  }
27947
27941
  if (agentId === current.ownerId) return current;
27948
27942
  const room = await deps.rooms.getMainRoom(current.tenantId, current.projectId);
27949
27943
  if (!room || room.tenantId !== current.tenantId || room.workspaceId !== current.workspaceId || room.projectId !== current.projectId || room.type !== "main") {
27950
- throw new import_core54.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Project main room is unavailable.", {
27944
+ throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Project main room is unavailable.", {
27951
27945
  hint: "Open or repair the Project Room before dispatching."
27952
27946
  });
27953
27947
  }
27954
27948
  const target = await deps.botMemberships.findByAssistant(current.tenantId, current.projectId, agentId);
27955
27949
  if (!target || target.status !== "active" || target.tenantId !== current.tenantId || target.workspaceId !== current.workspaceId || target.projectId !== current.projectId || target.assistantId !== agentId || target.roomId !== room.id) {
27956
- throw new import_core54.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", "Target Project task owner is not active in the exact roster.", {
27950
+ throw new import_core55.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", "Target Project task owner is not active in the exact roster.", {
27957
27951
  hint: "Dispatch to an active bot in this Project's roster."
27958
27952
  });
27959
27953
  }
27960
27954
  const caller = options?.callerMembershipId ? await deps.botMemberships.findById(current.tenantId, options.callerMembershipId) : null;
27961
27955
  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) {
27962
- throw new import_core54.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", "Current Project task caller is not active in the exact roster.", {
27956
+ throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", "Current Project task caller is not active in the exact roster.", {
27963
27957
  hint: "Dispatch from an active Project Room member bot."
27964
27958
  });
27965
27959
  }
@@ -27994,7 +27988,7 @@ async function transferGovernedDispatchOwner(task, options, deps) {
27994
27988
  actor: `agent:${caller.assistantId}`
27995
27989
  });
27996
27990
  if (!result.success) {
27997
- throw new import_core54.ManagedTaskStartError(result.code, result.error, {
27991
+ throw new import_core55.ManagedTaskStartError(result.code, result.error, {
27998
27992
  hint: result.hint ?? reassignmentFailureHint(result.code),
27999
27993
  ...result.retryable !== void 0 ? { retryable: result.retryable } : {}
28000
27994
  });
@@ -28003,19 +27997,19 @@ async function transferGovernedDispatchOwner(task, options, deps) {
28003
27997
  });
28004
27998
  }
28005
27999
  var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28006
- const webAppStore = (0, import_core54.getStoreLattice)("default", "agentWebApp").store;
28007
- const assistantStore = (0, import_core54.getStoreLattice)("default", "assistant").store;
28008
- const projectStore = (0, import_core54.getStoreLattice)("default", "project").store;
28009
- const projectMembershipStore = (0, import_core54.getStoreLattice)("default", "projectMembership").store;
28010
- const userTenantLinkStore = (0, import_core54.getStoreLattice)("default", "userTenantLink").store;
28011
- const projectRoomStore = (0, import_core54.getStoreLattice)("default", "projectRoom").store;
28012
- const projectBotMembershipStore = (0, import_core54.getStoreLattice)("default", "projectBotMembership").store;
28013
- const projectRoomMessageStore = (0, import_core54.getStoreLattice)("default", "projectRoomMessage").store;
28014
- const projectRoomReadStateStore = (0, import_core54.getStoreLattice)("default", "projectRoomReadState").store;
28015
- const userPushSubscriptionStore = (0, import_core54.getStoreLattice)("default", "userPushSubscription").store;
28016
- const threadStore = (0, import_core54.getStoreLattice)("default", "thread").store;
28017
- const taskStore = (0, import_core54.getStoreLattice)("default", "task").store;
28018
- const taskWorkItemStore = (0, import_core54.getStoreLattice)("default", "taskWorkItem").store;
28000
+ const webAppStore = (0, import_core55.getStoreLattice)("default", "agentWebApp").store;
28001
+ const assistantStore = (0, import_core55.getStoreLattice)("default", "assistant").store;
28002
+ const projectStore = (0, import_core55.getStoreLattice)("default", "project").store;
28003
+ const projectMembershipStore = (0, import_core55.getStoreLattice)("default", "projectMembership").store;
28004
+ const userTenantLinkStore = (0, import_core55.getStoreLattice)("default", "userTenantLink").store;
28005
+ const projectRoomStore = (0, import_core55.getStoreLattice)("default", "projectRoom").store;
28006
+ const projectBotMembershipStore = (0, import_core55.getStoreLattice)("default", "projectBotMembership").store;
28007
+ const projectRoomMessageStore = (0, import_core55.getStoreLattice)("default", "projectRoomMessage").store;
28008
+ const projectRoomReadStateStore = (0, import_core55.getStoreLattice)("default", "projectRoomReadState").store;
28009
+ const userPushSubscriptionStore = (0, import_core55.getStoreLattice)("default", "userPushSubscription").store;
28010
+ const threadStore = (0, import_core55.getStoreLattice)("default", "thread").store;
28011
+ const taskStore = (0, import_core55.getStoreLattice)("default", "task").store;
28012
+ const taskWorkItemStore = (0, import_core55.getStoreLattice)("default", "taskWorkItem").store;
28019
28013
  const projectTaskEnabled = options.projectTaskEnabled ?? process.env.AXIOM_PROJECT_TASK_EXECUTION_ENABLED !== "false";
28020
28014
  const accessService = new ProjectAccessService({ projectStore, membershipStore: projectMembershipStore, userTenantLinkStore });
28021
28015
  const realtimeMode = resolveProjectRoomRealtimeMode();
@@ -28081,7 +28075,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28081
28075
  updateAssistant: assistantStore.updateAssistant.bind(assistantStore)
28082
28076
  });
28083
28077
  const resolveCoordinatorMentionName = async (tenantId) => {
28084
- const tenant2 = await (0, import_core54.getStoreLattice)("default", "tenant").store.getTenantById(tenantId);
28078
+ const tenant2 = await (0, import_core55.getStoreLattice)("default", "tenant").store.getTenantById(tenantId);
28085
28079
  const value = tenant2?.metadata?.coordinatorMentionName;
28086
28080
  return typeof value === "string" && value.length > 0 ? value : void 0;
28087
28081
  };
@@ -28108,7 +28102,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28108
28102
  return membership !== null && membership.projectId === projectId ? membership : null;
28109
28103
  },
28110
28104
  getThreadStatus: async ({ tenantId, assistantId, threadId, workspaceId, projectId }) => {
28111
- const agent = import_core54.agentInstanceManager.getAgent({
28105
+ const agent = import_core55.agentInstanceManager.getAgent({
28112
28106
  tenant_id: tenantId,
28113
28107
  assistant_id: assistantId,
28114
28108
  thread_id: threadId,
@@ -28117,9 +28111,9 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28117
28111
  });
28118
28112
  return String(await agent.getRunStatus());
28119
28113
  },
28120
- dispatcher: (0, import_core54.createTrustedAgentMessageDispatcher)((scope) => import_core54.agentInstanceManager.getAgent(scope))
28114
+ dispatcher: (0, import_core55.createTrustedAgentMessageDispatcher)((scope) => import_core55.agentInstanceManager.getAgent(scope))
28121
28115
  });
28122
- const membershipService = new ProjectMembershipService({ membershipStore: projectMembershipStore, userTenantLinkStore, accessService, projectMutationMutex: import_core54.projectMutationMutex, roomStore: projectRoomStore, realtime, onRealtimeFailure: realtime && channelDeps?.warn ? ({ code, membershipId }) => channelDeps.warn?.("project-room:membership-realtime-failed", { code, membershipId }) : void 0 });
28116
+ const membershipService = new ProjectMembershipService({ membershipStore: projectMembershipStore, userTenantLinkStore, accessService, projectMutationMutex: import_core55.projectMutationMutex, roomStore: projectRoomStore, realtime, onRealtimeFailure: realtime && channelDeps?.warn ? ({ code, membershipId }) => channelDeps.warn?.("project-room:membership-realtime-failed", { code, membershipId }) : void 0 });
28123
28117
  const rosterService = new ProjectRosterService({
28124
28118
  accessService,
28125
28119
  roomService,
@@ -28130,7 +28124,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28130
28124
  assistantStore,
28131
28125
  taskStore,
28132
28126
  bindingLifecycle,
28133
- projectMutationMutex: import_core54.projectMutationMutex,
28127
+ projectMutationMutex: import_core55.projectMutationMutex,
28134
28128
  realtime,
28135
28129
  onRealtimeFailure: realtime && channelDeps?.warn ? ({ code, membershipId }) => channelDeps.warn?.("project-room:roster-realtime-failed", { code, membershipId }) : void 0
28136
28130
  });
@@ -28186,9 +28180,9 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28186
28180
  }
28187
28181
  if (projectTaskComposition) app2.addHook("onClose", async () => projectTaskComposition.lease.release());
28188
28182
  const taskThreadService = projectTaskComposition?.lease.runtime.threads ?? new ProjectTaskThreadService({ threads: threadStore, idFactory: import_node_crypto26.randomUUID });
28189
- const taskLifecycle = projectTaskComposition?.lease.runtime.lifecycle ?? (0, import_core54.createTaskLifecycleService)({ taskStore, workItemStore: taskWorkItemStore });
28190
- const reassignmentAuthorizer = (0, import_core54.createProjectTaskReassignmentAuthorizer)(
28191
- new import_core54.ProjectTaskOwnerPolicy(projectBotMembershipStore),
28183
+ const taskLifecycle = projectTaskComposition?.lease.runtime.lifecycle ?? (0, import_core55.createTaskLifecycleService)({ taskStore, workItemStore: taskWorkItemStore });
28184
+ const reassignmentAuthorizer = (0, import_core55.createProjectTaskReassignmentAuthorizer)(
28185
+ new import_core55.ProjectTaskOwnerPolicy(projectBotMembershipStore),
28192
28186
  (input) => validateReassignmentThread(threadStore, input)
28193
28187
  );
28194
28188
  const taskCommandService = new TaskCommandService({
@@ -28197,7 +28191,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28197
28191
  lifecycle: taskLifecycle,
28198
28192
  execution: projectTaskComposition?.lease.runtime.execution,
28199
28193
  threads: taskThreadService,
28200
- agents: { getAgent: (params) => import_core54.agentInstanceManager.getAgent(params) },
28194
+ agents: { getAgent: (params) => import_core55.agentInstanceManager.getAgent(params) },
28201
28195
  taskScope: (task) => resolveCommandTaskScope(task, {
28202
28196
  rooms: projectRoomStore,
28203
28197
  bots: projectBotMembershipStore,
@@ -28235,7 +28229,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28235
28229
  readStateService,
28236
28230
  interruptService: roomInterruptService,
28237
28231
  userDirectory: {
28238
- getUserById: (id3) => (0, import_core54.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { name: u.name } : null)
28232
+ getUserById: (id3) => (0, import_core55.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { name: u.name } : null)
28239
28233
  }
28240
28234
  });
28241
28235
  registerProjectRosterRoutes(app2, { service: rosterService });
@@ -28246,7 +28240,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28246
28240
  createProject: projectStore.createProject.bind(projectStore)
28247
28241
  },
28248
28242
  workspaceStore: {
28249
- getWorkspaceById: (tenantId, id3) => (0, import_core54.getStoreLattice)("default", "workspace").store.getWorkspaceById(tenantId, id3)
28243
+ getWorkspaceById: (tenantId, id3) => (0, import_core55.getStoreLattice)("default", "workspace").store.getWorkspaceById(tenantId, id3)
28250
28244
  },
28251
28245
  membershipStore: {
28252
28246
  list: projectMembershipStore.list.bind(projectMembershipStore),
@@ -28269,7 +28263,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28269
28263
  getUsersByTenant: userTenantLinkStore.getUsersByTenant.bind(userTenantLinkStore)
28270
28264
  },
28271
28265
  userStore: {
28272
- getUserById: (id3) => (0, import_core54.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { id: u.id, name: u.name, email: u.email } : null)
28266
+ getUserById: (id3) => (0, import_core55.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { id: u.id, name: u.name, email: u.email } : null)
28273
28267
  },
28274
28268
  assistantStore: {
28275
28269
  getAssistantById: assistantStore.getAssistantById.bind(assistantStore),
@@ -28291,17 +28285,17 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28291
28285
  }
28292
28286
  });
28293
28287
  registerCapabilityBundleRoutes(app2, new CapabilityBundleController({
28294
- bundleStore: (0, import_core54.getStoreLattice)("default", "capabilityBundle").store,
28288
+ bundleStore: (0, import_core55.getStoreLattice)("default", "capabilityBundle").store,
28295
28289
  projectStore
28296
28290
  }, { authRequired: process.env.AUTH_REQUIRED === "true" }));
28297
28291
  const modelProviderController = new ModelProviderController({
28298
- providerStore: (0, import_core54.getStoreLattice)("default", "modelProvider").store,
28292
+ providerStore: (0, import_core55.getStoreLattice)("default", "modelProvider").store,
28299
28293
  userTenantLinkStore,
28300
28294
  registry: {
28301
- register: (tenantId, modelKey2, config) => import_core54.modelLatticeManager.registerLatticeWithTenant(tenantId, modelKey2, config),
28302
- has: (tenantId, modelKey2) => import_core54.modelLatticeManager.hasLatticeWithTenant(tenantId, modelKey2),
28303
- remove: (tenantId, modelKey2) => import_core54.modelLatticeManager.removeLatticeWithTenant(tenantId, modelKey2),
28304
- listRegistered: (tenantId) => import_core54.modelLatticeManager.getLatticeKeysByTenant(tenantId)
28295
+ register: (tenantId, modelKey2, config) => import_core55.modelLatticeManager.registerLatticeWithTenant(tenantId, modelKey2, config),
28296
+ has: (tenantId, modelKey2) => import_core55.modelLatticeManager.hasLatticeWithTenant(tenantId, modelKey2),
28297
+ remove: (tenantId, modelKey2) => import_core55.modelLatticeManager.removeLatticeWithTenant(tenantId, modelKey2),
28298
+ listRegistered: (tenantId) => import_core55.modelLatticeManager.getLatticeKeysByTenant(tenantId)
28305
28299
  }
28306
28300
  }, { authRequired: process.env.AUTH_REQUIRED === "true" });
28307
28301
  registerModelProviderRoutes(app2, modelProviderController);
@@ -28311,10 +28305,10 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28311
28305
  webAppStore,
28312
28306
  assistantStore,
28313
28307
  projectStore,
28314
- modelRegistry: { has: (key) => import_core54.modelLatticeManager.hasLattice(key) },
28308
+ modelRegistry: { has: (key) => import_core55.modelLatticeManager.hasLattice(key) },
28315
28309
  configuredAgentResolver: createConfiguredAgentResolver({
28316
- hydrate: (tenantId) => import_core54.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
28317
- has: (tenantId, assistantId) => import_core54.agentLatticeManager.hasAgentLatticeWithTenant(tenantId, assistantId)
28310
+ hydrate: (tenantId) => import_core55.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
28311
+ has: (tenantId, assistantId) => import_core55.agentLatticeManager.hasAgentLatticeWithTenant(tenantId, assistantId)
28318
28312
  })
28319
28313
  })
28320
28314
  });
@@ -28351,28 +28345,28 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28351
28345
  },
28352
28346
  tasks: taskStore,
28353
28347
  workItems: taskWorkItemStore,
28354
- projectMutationMutex: import_core54.projectMutationMutex,
28348
+ projectMutationMutex: import_core55.projectMutationMutex,
28355
28349
  ...projectTaskComposition ? { commands: taskCommandService } : {}
28356
28350
  }),
28357
28351
  service: new AgentWebAppRuntimeService({
28358
28352
  webAppStore,
28359
- threadStore: (0, import_core54.getStoreLattice)("default", "thread").store,
28353
+ threadStore: (0, import_core55.getStoreLattice)("default", "thread").store,
28360
28354
  projectStore,
28361
28355
  assistantResolver: {
28362
28356
  resolve: async (tenantId, assistantId) => {
28363
28357
  const stored = await assistantStore.getAssistantById(tenantId, assistantId);
28364
28358
  if (stored) return { id: stored.id, name: stored.name, description: stored.description };
28365
- await import_core54.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId);
28366
- const config = import_core54.agentLatticeManager.getAgentConfigWithTenant(tenantId, assistantId);
28359
+ await import_core55.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId);
28360
+ const config = import_core55.agentLatticeManager.getAgentConfigWithTenant(tenantId, assistantId);
28367
28361
  return config ? { id: assistantId, name: config.name, description: config.description } : null;
28368
28362
  }
28369
28363
  },
28370
28364
  modelRegistry: {
28371
- has: (key) => import_core54.modelLatticeManager.hasLattice(key),
28365
+ has: (key) => import_core55.modelLatticeManager.hasLattice(key),
28372
28366
  label: (key) => key
28373
28367
  },
28374
28368
  messageReader: {
28375
- getCurrentMessages: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core54.agentInstanceManager.getAgentForRead({
28369
+ getCurrentMessages: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core55.agentInstanceManager.getAgentForRead({
28376
28370
  tenant_id: tenantId,
28377
28371
  assistant_id: assistantId,
28378
28372
  thread_id: threadId,
@@ -28381,7 +28375,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28381
28375
  }).getCurrentMessages()
28382
28376
  },
28383
28377
  agentResolver: {
28384
- getAgent: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core54.agentInstanceManager.getAgent({
28378
+ getAgent: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core55.agentInstanceManager.getAgent({
28385
28379
  tenant_id: tenantId,
28386
28380
  assistant_id: assistantId,
28387
28381
  thread_id: threadId,
@@ -28399,8 +28393,8 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28399
28393
  if (webApp.tenantId !== preview.tenantId) return false;
28400
28394
  const assistant = await assistantStore.getAssistantById(preview.tenantId, webApp.assistantId);
28401
28395
  if (assistant) return !assistant.ownerUserId || assistant.ownerUserId === preview.userId;
28402
- await import_core54.agentLatticeManager.initializeStoredAssistantsForTenant(preview.tenantId);
28403
- return import_core54.agentLatticeManager.hasAgentLatticeWithTenant(preview.tenantId, webApp.assistantId);
28396
+ await import_core55.agentLatticeManager.initializeStoredAssistantsForTenant(preview.tenantId);
28397
+ return import_core55.agentLatticeManager.hasAgentLatticeWithTenant(preview.tenantId, webApp.assistantId);
28404
28398
  }
28405
28399
  })
28406
28400
  });
@@ -28457,14 +28451,14 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28457
28451
  app2.post("/api/personal-assistant", createPersonalAssistant);
28458
28452
  app2.get("/api/personal-assistant", getPersonalAssistant);
28459
28453
  app2.delete("/api/personal-assistant", deletePersonalAssistant);
28460
- import_core54.executionAuthorityRegistry.register({
28454
+ import_core55.executionAuthorityRegistry.register({
28461
28455
  id: "project-lifecycle",
28462
28456
  matches: isProjectLifecycleTask,
28463
28457
  code: "PROJECT_TASK_EXECUTION_MANAGED",
28464
28458
  message: "Project tasks are executed by the durable Project queue runtime",
28465
28459
  onManagedStart: async (task, options2) => {
28466
28460
  if (!projectTaskComposition && options2?.agentId && options2.agentId !== task.ownerId) {
28467
- throw new import_core54.ManagedTaskStartError(
28461
+ throw new import_core55.ManagedTaskStartError(
28468
28462
  "PROJECT_TASK_RUNTIME_UNAVAILABLE",
28469
28463
  "Project task ownership transfer requires the Project task runtime.",
28470
28464
  { hint: "Project task execution is disabled; enable the Project task runtime or dispatch to the current owner." }
@@ -28477,7 +28471,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28477
28471
  threads: taskThreadService,
28478
28472
  reassignmentAuthorizer,
28479
28473
  lifecycle: taskLifecycle,
28480
- mutex: import_core54.projectMutationMutex
28474
+ mutex: import_core55.projectMutationMutex
28481
28475
  }) : void 0;
28482
28476
  const admitted = transferred ?? task;
28483
28477
  if (!admitted.workspaceId || !admitted.projectId) return;
@@ -28485,7 +28479,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28485
28479
  context: withExecutionRequest(admitted.context, (/* @__PURE__ */ new Date()).toISOString())
28486
28480
  }).catch(() => null);
28487
28481
  const eventTask = markerUpdated ?? admitted;
28488
- void import_core54.projectTaskAdmissionNotifier.publish({
28482
+ void import_core55.projectTaskAdmissionNotifier.publish({
28489
28483
  tenantId: eventTask.tenantId,
28490
28484
  workspaceId: eventTask.workspaceId,
28491
28485
  projectId: eventTask.projectId,
@@ -28499,7 +28493,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28499
28493
  access: accessService,
28500
28494
  tasks: taskStore,
28501
28495
  workItems: taskWorkItemStore,
28502
- projectMutationMutex: import_core54.projectMutationMutex,
28496
+ projectMutationMutex: import_core55.projectMutationMutex,
28503
28497
  commands: taskCommandService,
28504
28498
  readableProjects: async ({ tenantId, userId, workspaceId }) => {
28505
28499
  const projects = await projectStore.getProjectsByWorkspace(tenantId, workspaceId);
@@ -28781,9 +28775,9 @@ function tryCreateProjectTaskRuntime(input) {
28781
28775
  let stores;
28782
28776
  try {
28783
28777
  stores = {
28784
- tenants: (0, import_core54.getStoreLattice)("default", "tenant").store,
28785
- workspaces: (0, import_core54.getStoreLattice)("default", "workspace").store,
28786
- queue: (0, import_core54.getStoreLattice)("default", "threadMessageQueue").store
28778
+ tenants: (0, import_core55.getStoreLattice)("default", "tenant").store,
28779
+ workspaces: (0, import_core55.getStoreLattice)("default", "workspace").store,
28780
+ queue: (0, import_core55.getStoreLattice)("default", "threadMessageQueue").store
28787
28781
  };
28788
28782
  const missing = missingRuntimeMethod(input, stores);
28789
28783
  if (missing) return { reason: missing };
@@ -28815,7 +28809,7 @@ function createRuntime(input, stores, log2) {
28815
28809
  const controller = new AbortController();
28816
28810
  const mutex = new ProjectTaskExecutionMutex();
28817
28811
  const threads = new ProjectTaskThreadService({ threads: input.threadStore, idFactory: import_node_crypto26.randomUUID });
28818
- const lifecycle = (0, import_core54.createTaskLifecycleService)({ taskStore: input.taskStore, workItemStore: input.taskWorkItemStore });
28812
+ const lifecycle = (0, import_core55.createTaskLifecycleService)({ taskStore: input.taskStore, workItemStore: input.taskWorkItemStore });
28819
28813
  const projection = new RoomProjectionService({
28820
28814
  messages: input.projectRoomMessageStore,
28821
28815
  events: input.taskWorkItemStore,
@@ -28825,7 +28819,7 @@ function createRuntime(input, stores, log2) {
28825
28819
  realtime: input.realtime,
28826
28820
  idFactory: import_node_crypto26.randomUUID
28827
28821
  });
28828
- const agentFor = (task, thread) => import_core54.agentInstanceManager.getAgent({
28822
+ const agentFor = (task, thread) => import_core55.agentInstanceManager.getAgent({
28829
28823
  tenant_id: task.tenantId,
28830
28824
  assistant_id: task.ownerId,
28831
28825
  thread_id: thread.id,
@@ -28839,7 +28833,7 @@ function createRuntime(input, stores, log2) {
28839
28833
  bots: input.projectBotMembershipStore,
28840
28834
  threads,
28841
28835
  lifecycle,
28842
- dispatcher: (0, import_core54.createTrustedAgentMessageDispatcher)((scope) => import_core54.agentInstanceManager.getAgent(scope)),
28836
+ dispatcher: (0, import_core55.createTrustedAgentMessageDispatcher)((scope) => import_core55.agentInstanceManager.getAgent(scope)),
28843
28837
  queue: stores.queue,
28844
28838
  agentFor
28845
28839
  }, {
@@ -28866,8 +28860,8 @@ function createRuntime(input, stores, log2) {
28866
28860
  const taskLifecycleListener = ((event) => {
28867
28861
  void observer.listener(event);
28868
28862
  });
28869
- const unsubscribe = import_core54.taskLifecycleNotifier.subscribe(taskLifecycleListener);
28870
- const unsubscribeAdmission = import_core54.projectTaskAdmissionNotifier.subscribe((event, signal) => {
28863
+ const unsubscribe = import_core55.taskLifecycleNotifier.subscribe(taskLifecycleListener);
28864
+ const unsubscribeAdmission = import_core55.projectTaskAdmissionNotifier.subscribe((event, signal) => {
28871
28865
  observer.admit(event, signal);
28872
28866
  });
28873
28867
  let reconciliationWork;
@@ -29014,12 +29008,12 @@ function registerResourceRoutes(app2, controller) {
29014
29008
  }
29015
29009
 
29016
29010
  // src/export_registrations/index.ts
29017
- var import_core65 = require("@axiom-lattice/core");
29011
+ var import_core66 = require("@axiom-lattice/core");
29018
29012
 
29019
29013
  // src/export_registrations/skill.registration.ts
29020
- var import_core55 = require("@axiom-lattice/core");
29014
+ var import_core56 = require("@axiom-lattice/core");
29021
29015
  function getStore(context) {
29022
- return new import_core55.SandboxSkillStore({
29016
+ return new import_core56.SandboxSkillStore({
29023
29017
  workspaceId: context?.workspaceId,
29024
29018
  projectId: context?.projectId
29025
29019
  });
@@ -29037,7 +29031,7 @@ var skillRegistration = {
29037
29031
  async listForExport(tenantId, context) {
29038
29032
  const store2 = getStore(context);
29039
29033
  const skills = await store2.getAllSkills(tenantId, toStoreContext(context));
29040
- return skills.filter((s) => !(0, import_core55.isBuiltInSkill)(s.id)).map((s) => ({
29034
+ return skills.filter((s) => !(0, import_core56.isBuiltInSkill)(s.id)).map((s) => ({
29041
29035
  _exportId: "",
29042
29036
  data: {
29043
29037
  id: s.id,
@@ -29102,7 +29096,7 @@ var skillRegistration = {
29102
29096
  const insertions = [];
29103
29097
  for (const entity of entities) {
29104
29098
  const id3 = entity.data.id;
29105
- if ((0, import_core55.isBuiltInSkill)(id3)) continue;
29099
+ if ((0, import_core56.isBuiltInSkill)(id3)) continue;
29106
29100
  if (existingIds.has(id3)) {
29107
29101
  conflicts.push({
29108
29102
  _exportId: entity._exportId,
@@ -29161,9 +29155,9 @@ var skillRegistration = {
29161
29155
  };
29162
29156
 
29163
29157
  // src/export_registrations/agent.registration.ts
29164
- var import_core56 = require("@axiom-lattice/core");
29158
+ var import_core57 = require("@axiom-lattice/core");
29165
29159
  function getStore2() {
29166
- return (0, import_core56.getStoreLattice)("default", "assistant").store;
29160
+ return (0, import_core57.getStoreLattice)("default", "assistant").store;
29167
29161
  }
29168
29162
  var agentRegistration = {
29169
29163
  entityType: "agent",
@@ -29243,9 +29237,9 @@ var agentRegistration = {
29243
29237
  };
29244
29238
 
29245
29239
  // src/export_registrations/database-config.registration.ts
29246
- var import_core57 = require("@axiom-lattice/core");
29240
+ var import_core58 = require("@axiom-lattice/core");
29247
29241
  function getStore3() {
29248
- return (0, import_core57.getStoreLattice)("default", "database").store;
29242
+ return (0, import_core58.getStoreLattice)("default", "database").store;
29249
29243
  }
29250
29244
  var databaseConfigRegistration = {
29251
29245
  entityType: "database_config",
@@ -29325,9 +29319,9 @@ var databaseConfigRegistration = {
29325
29319
  };
29326
29320
 
29327
29321
  // src/export_registrations/metrics-config.registration.ts
29328
- var import_core58 = require("@axiom-lattice/core");
29322
+ var import_core59 = require("@axiom-lattice/core");
29329
29323
  function getStore4() {
29330
- return (0, import_core58.getStoreLattice)("default", "metrics").store;
29324
+ return (0, import_core59.getStoreLattice)("default", "metrics").store;
29331
29325
  }
29332
29326
  var metricsConfigRegistration = {
29333
29327
  entityType: "metrics_config",
@@ -29407,9 +29401,9 @@ var metricsConfigRegistration = {
29407
29401
  };
29408
29402
 
29409
29403
  // src/export_registrations/mcp-config.registration.ts
29410
- var import_core59 = require("@axiom-lattice/core");
29404
+ var import_core60 = require("@axiom-lattice/core");
29411
29405
  function getStore5() {
29412
- return (0, import_core59.getStoreLattice)("default", "mcp").store;
29406
+ return (0, import_core60.getStoreLattice)("default", "mcp").store;
29413
29407
  }
29414
29408
  var mcpConfigRegistration = {
29415
29409
  entityType: "mcp_config",
@@ -29492,9 +29486,9 @@ var mcpConfigRegistration = {
29492
29486
  };
29493
29487
 
29494
29488
  // src/export_registrations/connection.registration.ts
29495
- var import_core60 = require("@axiom-lattice/core");
29489
+ var import_core61 = require("@axiom-lattice/core");
29496
29490
  function getStore6() {
29497
- return (0, import_core60.getStoreLattice)("default", "connection").store;
29491
+ return (0, import_core61.getStoreLattice)("default", "connection").store;
29498
29492
  }
29499
29493
  async function listAllConnections(tenantId) {
29500
29494
  const store2 = getStore6();
@@ -29519,7 +29513,8 @@ var connectionRegistration = {
29519
29513
  key: c2.key,
29520
29514
  name: c2.name,
29521
29515
  description: c2.description,
29522
- config: c2.config
29516
+ config: c2.config,
29517
+ secretFields: c2.secretFields
29523
29518
  }
29524
29519
  }));
29525
29520
  },
@@ -29563,22 +29558,24 @@ var connectionRegistration = {
29563
29558
  } catch {
29564
29559
  }
29565
29560
  }
29561
+ const secretFields = Array.isArray(d.secretFields) ? d.secretFields : secretFieldsForConnection(await resolveTenantPluginByType(tenantId, type));
29566
29562
  await store2.create({
29567
29563
  tenantId,
29568
29564
  type,
29569
29565
  key,
29570
29566
  name: d.name,
29571
29567
  description: d.description,
29572
- config: d.config
29568
+ config: d.config,
29569
+ secretFields
29573
29570
  });
29574
29571
  return { newId: void 0 };
29575
29572
  }
29576
29573
  };
29577
29574
 
29578
29575
  // src/export_registrations/collection.registration.ts
29579
- var import_core61 = require("@axiom-lattice/core");
29576
+ var import_core62 = require("@axiom-lattice/core");
29580
29577
  function getStore7() {
29581
- return (0, import_core61.getStoreLattice)("default", "collection").store;
29578
+ return (0, import_core62.getStoreLattice)("default", "collection").store;
29582
29579
  }
29583
29580
  var collectionRegistration = {
29584
29581
  entityType: "collection",
@@ -29649,7 +29646,7 @@ var collectionRegistration = {
29649
29646
  };
29650
29647
 
29651
29648
  // src/export_registrations/channel-installation.registration.ts
29652
- var import_core62 = require("@axiom-lattice/core");
29649
+ var import_core63 = require("@axiom-lattice/core");
29653
29650
  var import_crypto11 = require("crypto");
29654
29651
  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;
29655
29652
  var PUBLIC_CHANNELS = /* @__PURE__ */ new Set(["lark", "email", "slack", "wechat"]);
@@ -29683,7 +29680,7 @@ function validateImportData(data) {
29683
29680
  };
29684
29681
  }
29685
29682
  function getStore8() {
29686
- return (0, import_core62.getStoreLattice)("default", "channelInstallation").store;
29683
+ return (0, import_core63.getStoreLattice)("default", "channelInstallation").store;
29687
29684
  }
29688
29685
  function getOverwriteError(tenantId, incomingChannel, existing) {
29689
29686
  if (!existing) return "Channel installation overwrite target must exist";
@@ -29817,9 +29814,9 @@ var channelInstallationRegistration = {
29817
29814
  };
29818
29815
 
29819
29816
  // src/export_registrations/menu.registration.ts
29820
- var import_core63 = require("@axiom-lattice/core");
29817
+ var import_core64 = require("@axiom-lattice/core");
29821
29818
  function getStore9() {
29822
- return (0, import_core63.getStoreLattice)("default", "menu").store;
29819
+ return (0, import_core64.getStoreLattice)("default", "menu").store;
29823
29820
  }
29824
29821
  var menuRegistration = {
29825
29822
  entityType: "menu",
@@ -29897,9 +29894,9 @@ var menuRegistration = {
29897
29894
  };
29898
29895
 
29899
29896
  // src/export_registrations/eval.registration.ts
29900
- var import_core64 = require("@axiom-lattice/core");
29897
+ var import_core65 = require("@axiom-lattice/core");
29901
29898
  function getStore10() {
29902
- return (0, import_core64.getStoreLattice)("default", "eval").store;
29899
+ return (0, import_core65.getStoreLattice)("default", "eval").store;
29903
29900
  }
29904
29901
  var evalRegistration = {
29905
29902
  entityType: "eval",
@@ -30225,7 +30222,7 @@ var evalRegistration = {
30225
30222
 
30226
30223
  // src/export_registrations/index.ts
30227
30224
  function registerAllBuiltinEntities() {
30228
- const registry = import_core65.ExportableEntityRegistry.getInstance();
30225
+ const registry = import_core66.ExportableEntityRegistry.getInstance();
30229
30226
  registry.register(skillRegistration);
30230
30227
  registry.register(agentRegistration);
30231
30228
  registry.register(databaseConfigRegistration);
@@ -30356,7 +30353,7 @@ function createAuditLoggerMiddleware() {
30356
30353
  }
30357
30354
 
30358
30355
  // src/index.ts
30359
- var import_core91 = require("@axiom-lattice/core");
30356
+ var import_core92 = require("@axiom-lattice/core");
30360
30357
 
30361
30358
  // src/swagger.ts
30362
30359
  var import_swagger = __toESM(require("@fastify/swagger"));
@@ -30422,7 +30419,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
30422
30419
 
30423
30420
  // src/services/agent_task_consumer.ts
30424
30421
  var import_node_crypto27 = require("crypto");
30425
- var import_core66 = require("@axiom-lattice/core");
30422
+ var import_core67 = require("@axiom-lattice/core");
30426
30423
  var import_protocols31 = require("@axiom-lattice/protocols");
30427
30424
  var handleAgentTask = async (taskRequest, retryCount = 0) => {
30428
30425
  const {
@@ -30442,7 +30439,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
30442
30439
  `\u5F00\u59CB\u5904\u7406\u4EFB\u52A1 [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
30443
30440
  );
30444
30441
  const scope = (0, import_protocols31.resolveRunScope)(runConfig);
30445
- const agent = import_core66.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: scope.workspaceId, project_id: scope.projectId, custom_run_config: runConfig });
30442
+ const agent = import_core67.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: scope.workspaceId, project_id: scope.projectId, custom_run_config: runConfig });
30446
30443
  if (callback_event) {
30447
30444
  const callbackEvent = callback_event;
30448
30445
  const messageId = typeof input?.id === "string" && input.id !== "" ? input.id : (0, import_node_crypto27.randomUUID)();
@@ -30463,13 +30460,13 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
30463
30460
  const onCompleted = (evt) => {
30464
30461
  if (!belongsToMessage(evt)) return;
30465
30462
  settle(() => {
30466
- import_core66.eventBus.publish(callbackEvent, {
30463
+ import_core67.eventBus.publish(callbackEvent, {
30467
30464
  success: true,
30468
30465
  state: evt.state
30469
30466
  });
30470
30467
  if (main_thread_id && main_tenant_id) {
30471
30468
  try {
30472
- const mainAgent = import_core66.agentInstanceManager.getAgent({
30469
+ const mainAgent = import_core67.agentInstanceManager.getAgent({
30473
30470
  assistant_id: main_assistant_id ?? assistant_id,
30474
30471
  thread_id: main_thread_id,
30475
30472
  tenant_id: main_tenant_id,
@@ -30502,7 +30499,7 @@ ${summary}`
30502
30499
  const onInterrupted = (evt) => {
30503
30500
  if (!belongsToMessage(evt)) return;
30504
30501
  settle(() => {
30505
- import_core66.eventBus.publish(callbackEvent, {
30502
+ import_core67.eventBus.publish(callbackEvent, {
30506
30503
  success: true,
30507
30504
  state: evt.state
30508
30505
  });
@@ -30511,7 +30508,7 @@ ${summary}`
30511
30508
  const onFailed = (evt) => {
30512
30509
  if (!belongsToMessage(evt)) return;
30513
30510
  settle(() => {
30514
- import_core66.eventBus.publish(callbackEvent, {
30511
+ import_core67.eventBus.publish(callbackEvent, {
30515
30512
  success: false,
30516
30513
  error: evt?.error instanceof Error ? evt.error.message : typeof evt?.error === "string" ? evt.error : "Agent execution failed"
30517
30514
  });
@@ -30526,13 +30523,13 @@ ${summary}`
30526
30523
  agent.subscribe("message:interrupted", onInterrupted);
30527
30524
  agent.subscribe("message:failed", onFailed);
30528
30525
  try {
30529
- await agent.addMessage({ input: { ...input, id: messageId }, command, custom_run_config: runConfig }, import_core66.QueueMode.STEER);
30526
+ await agent.addMessage({ input: { ...input, id: messageId }, command, custom_run_config: runConfig }, import_core67.QueueMode.STEER);
30530
30527
  } catch (error) {
30531
30528
  dispose();
30532
30529
  throw error;
30533
30530
  }
30534
30531
  } else {
30535
- await agent.addMessage({ input, command, custom_run_config: runConfig }, import_core66.QueueMode.STEER);
30532
+ await agent.addMessage({ input, command, custom_run_config: runConfig }, import_core67.QueueMode.STEER);
30536
30533
  }
30537
30534
  return true;
30538
30535
  } catch (error) {
@@ -30551,7 +30548,7 @@ ${summary}`
30551
30548
  return handleAgentTask(taskRequest, nextRetryCount);
30552
30549
  }
30553
30550
  if (callback_event) {
30554
- import_core66.eventBus.publish(callback_event, {
30551
+ import_core67.eventBus.publish(callback_event, {
30555
30552
  success: false,
30556
30553
  error: error instanceof Error ? error.message : String(error)
30557
30554
  });
@@ -30588,7 +30585,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
30588
30585
  * 初始化事件监听和队列轮询
30589
30586
  */
30590
30587
  initialize() {
30591
- import_core66.eventBus.subscribe(import_core66.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
30588
+ import_core67.eventBus.subscribe(import_core67.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
30592
30589
  this.startPollingQueue();
30593
30590
  console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
30594
30591
  }
@@ -30707,7 +30704,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
30707
30704
  handleAgentTask(taskRequest).catch((error) => {
30708
30705
  console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
30709
30706
  if (taskRequest.callback_event) {
30710
- import_core66.eventBus.publish(taskRequest.callback_event, {
30707
+ import_core67.eventBus.publish(taskRequest.callback_event, {
30711
30708
  success: false,
30712
30709
  error: error instanceof Error ? error.message : String(error)
30713
30710
  });
@@ -30722,13 +30719,13 @@ _AgentTaskConsumer.agent_run_endpoint = "http://localhost:4001/api/runs";
30722
30719
  var AgentTaskConsumer = _AgentTaskConsumer;
30723
30720
 
30724
30721
  // src/index.ts
30725
- var import_core92 = require("@axiom-lattice/core");
30722
+ var import_core93 = require("@axiom-lattice/core");
30726
30723
 
30727
30724
  // src/channels/ChannelInfrastructure.ts
30728
- var import_core68 = require("@axiom-lattice/core");
30725
+ var import_core69 = require("@axiom-lattice/core");
30729
30726
 
30730
30727
  // src/router/MessageRouter.ts
30731
- var import_core67 = require("@axiom-lattice/core");
30728
+ var import_core68 = require("@axiom-lattice/core");
30732
30729
  var import_protocols32 = require("@axiom-lattice/protocols");
30733
30730
  var import_crypto12 = require("crypto");
30734
30731
  var BindingNotFoundError = class extends Error {
@@ -31014,7 +31011,7 @@ var MessageRouter = class {
31014
31011
  channel: message.channel,
31015
31012
  adapterChannel: adapter.channel
31016
31013
  }, "Thread resolved by adapter strategy");
31017
- const threadStore = (0, import_core67.getStoreLattice)("default", "thread").store;
31014
+ const threadStore = (0, import_core68.getStoreLattice)("default", "thread").store;
31018
31015
  try {
31019
31016
  await threadStore.createThread(
31020
31017
  tenantId,
@@ -31051,7 +31048,7 @@ var MessageRouter = class {
31051
31048
  }
31052
31049
  }
31053
31050
  if (!threadId) {
31054
- const threadStore = (0, import_core67.getStoreLattice)("default", "thread").store;
31051
+ const threadStore = (0, import_core68.getStoreLattice)("default", "thread").store;
31055
31052
  const newThreadId = (0, import_crypto12.randomUUID)();
31056
31053
  console.log({
31057
31054
  event: "dispatch:thread:create",
@@ -31091,7 +31088,7 @@ var MessageRouter = class {
31091
31088
  senderId: message.sender.id,
31092
31089
  contentLength: message.content.text.length
31093
31090
  }, "Dispatching to agent");
31094
- const agent = import_core67.agentInstanceManager.getAgent({
31091
+ const agent = import_core68.agentInstanceManager.getAgent({
31095
31092
  tenant_id: tenantId,
31096
31093
  assistant_id: agentId,
31097
31094
  thread_id: threadId,
@@ -31364,7 +31361,7 @@ function createChannelInfrastructure(deps) {
31364
31361
  onMessageCommitted: deps.onMessageCommitted ?? (deps.realtime ? (message) => deps.realtime?.messageCreated(message) : void 0),
31365
31362
  onCallbackFailure: (event) => deps.warn("project-room:message-commit-callback-failed", event)
31366
31363
  };
31367
- deps.adapterRegistry.register(createRoomChannelAdapter(new import_core68.RoomAgentMessageService(writerDeps)));
31364
+ deps.adapterRegistry.register(createRoomChannelAdapter(new import_core69.RoomAgentMessageService(writerDeps)));
31368
31365
  } catch (error) {
31369
31366
  deps.warn("Room channel unavailable", { error: error instanceof Error ? error.message : String(error) });
31370
31367
  }
@@ -31385,11 +31382,11 @@ async function prepareProjectTaskRuntime(runtime, log2) {
31385
31382
  }
31386
31383
 
31387
31384
  // src/services/multiReplicaReadiness.ts
31388
- var import_core69 = require("@axiom-lattice/core");
31385
+ var import_core70 = require("@axiom-lattice/core");
31389
31386
  var SHARED_STORE_KINDS = ["lease", "outbox", "threadMessageQueue", "task", "taskWorkItem"];
31390
31387
  function storeClassName(kind) {
31391
31388
  try {
31392
- return (0, import_core69.getStoreLattice)("default", kind).store.constructor?.name;
31389
+ return (0, import_core70.getStoreLattice)("default", kind).store.constructor?.name;
31393
31390
  } catch {
31394
31391
  return void 0;
31395
31392
  }
@@ -31559,11 +31556,11 @@ var DEFAULT_LOGGER_CONFIG = {
31559
31556
  var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
31560
31557
  var logger7 = loggerLattice.client;
31561
31558
  function initializeLogger(config) {
31562
- if (import_core92.loggerLatticeManager.hasLattice("default")) {
31563
- import_core92.loggerLatticeManager.removeLattice("default");
31559
+ if (import_core93.loggerLatticeManager.hasLattice("default")) {
31560
+ import_core93.loggerLatticeManager.removeLattice("default");
31564
31561
  }
31565
- (0, import_core92.registerLoggerLattice)("default", config);
31566
- return (0, import_core92.getLoggerLattice)("default");
31562
+ (0, import_core93.registerLoggerLattice)("default", config);
31563
+ return (0, import_core93.getLoggerLattice)("default");
31567
31564
  }
31568
31565
  var app = (0, import_fastify.default)({
31569
31566
  logger: false,
@@ -31660,7 +31657,7 @@ app.setErrorHandler((error, request, reply) => {
31660
31657
  });
31661
31658
  function getConfiguredSandboxProvider() {
31662
31659
  const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || "microsandbox-remote";
31663
- return (0, import_core92.createSandboxProvider)({
31660
+ return (0, import_core93.createSandboxProvider)({
31664
31661
  type: sandboxProviderType,
31665
31662
  remoteBaseURL: process.env.SANDBOX_BASE_URL,
31666
31663
  microsandboxServiceBaseURL: process.env.MICROSANDBOX_SERVICE_BASE_URL,
@@ -31676,7 +31673,7 @@ function getConfiguredSandboxProvider() {
31676
31673
  }
31677
31674
  async function restoreMcpConnections() {
31678
31675
  try {
31679
- const storeLattice = (0, import_core92.getStoreLattice)("default", "mcp");
31676
+ const storeLattice = (0, import_core93.getStoreLattice)("default", "mcp");
31680
31677
  const store2 = storeLattice.store;
31681
31678
  if (!store2) {
31682
31679
  logger7.info("MCP store not configured, skipping connection restoration");
@@ -31689,8 +31686,8 @@ async function restoreMcpConnections() {
31689
31686
  logger7.info(`Restoring ${configs.length} MCP server connections...`);
31690
31687
  const deps = {
31691
31688
  store: store2,
31692
- manager: import_core92.mcpManager,
31693
- convertToConnection: import_core92.convertToConnection
31689
+ manager: import_core93.mcpManager,
31690
+ convertToConnection: import_core93.convertToConnection
31694
31691
  };
31695
31692
  const results = await Promise.allSettled(
31696
31693
  configs.map(
@@ -31731,9 +31728,9 @@ var start = async (config) => {
31731
31728
  let projectRoomRealtimeRuntime;
31732
31729
  if (projectRoomRealtimeMode === "single-gateway") {
31733
31730
  projectRoomRealtimeRuntime = createProjectRoomRealtimeRuntime({
31734
- tasks: (0, import_core92.getStoreLattice)("default", "task").store,
31735
- rooms: (0, import_core92.getStoreLattice)("default", "projectRoom").store,
31736
- memberships: (0, import_core92.getStoreLattice)("default", "projectBotMembership").store,
31731
+ tasks: (0, import_core93.getStoreLattice)("default", "task").store,
31732
+ rooms: (0, import_core93.getStoreLattice)("default", "projectRoom").store,
31733
+ memberships: (0, import_core93.getStoreLattice)("default", "projectBotMembership").store,
31737
31734
  log: { warn: (message, context) => logger7.warn(message, context) }
31738
31735
  });
31739
31736
  }
@@ -31747,7 +31744,7 @@ var start = async (config) => {
31747
31744
  const infrastructure = createChannelInfrastructure({
31748
31745
  adapterRegistry,
31749
31746
  getStore: ((kind) => getStore11("default", kind).store),
31750
- trustedDispatcher: (0, import_core92.createTrustedAgentMessageDispatcher)((scope) => import_core92.agentInstanceManager.getAgent(scope)),
31747
+ trustedDispatcher: (0, import_core93.createTrustedAgentMessageDispatcher)((scope) => import_core93.agentInstanceManager.getAgent(scope)),
31751
31748
  middlewares: [
31752
31749
  createDeduplicationMiddleware(),
31753
31750
  createRateLimitMiddleware(),
@@ -31758,7 +31755,7 @@ var start = async (config) => {
31758
31755
  });
31759
31756
  const bindingStore = infrastructure.bindingRegistry;
31760
31757
  const installationStore = infrastructure.installationStore;
31761
- (0, import_core91.setBindingRegistry)(bindingStore);
31758
+ (0, import_core92.setBindingRegistry)(bindingStore);
31762
31759
  const router = infrastructure.router;
31763
31760
  app.addHook("onClose", async () => router.dispose());
31764
31761
  channelDeps = {
@@ -31774,10 +31771,10 @@ var start = async (config) => {
31774
31771
  error: err instanceof Error ? err.message : String(err)
31775
31772
  });
31776
31773
  }
31777
- (0, import_core91.setEvalRunService)(evalRunner);
31774
+ (0, import_core92.setEvalRunService)(evalRunner);
31778
31775
  try {
31779
- const menuStore = (0, import_core92.getStoreLattice)("default", "menu").store;
31780
- (0, import_core91.setMenuRegistry)(menuStore);
31776
+ const menuStore = (0, import_core93.getStoreLattice)("default", "menu").store;
31777
+ (0, import_core92.setMenuRegistry)(menuStore);
31781
31778
  logger7.info("Menu registry initialized");
31782
31779
  } catch {
31783
31780
  }
@@ -31794,10 +31791,10 @@ var start = async (config) => {
31794
31791
  const { A2AAuthService: A2AAuthService2, parseEnvKeys: parseEnvKeys2 } = await Promise.resolve().then(() => (init_A2AAuthService(), A2AAuthService_exports));
31795
31792
  const { registerA2AStandardRoutes: registerA2AStandardRoutes2 } = await Promise.resolve().then(() => (init_a2a_standard(), a2a_standard_exports));
31796
31793
  const a2a = await Promise.resolve().then(() => (init_a2a(), a2a_exports));
31797
- const a2aKeyStore = (0, import_core92.getStoreLattice)("default", "a2aApiKey").store;
31798
- const assistantStore = (0, import_core92.getStoreLattice)("default", "assistant").store;
31799
- const projectStore = (0, import_core92.getStoreLattice)("default", "project").store;
31800
- const taskStore = (0, import_core92.getStoreLattice)("default", "task").store;
31794
+ const a2aKeyStore = (0, import_core93.getStoreLattice)("default", "a2aApiKey").store;
31795
+ const assistantStore = (0, import_core93.getStoreLattice)("default", "assistant").store;
31796
+ const projectStore = (0, import_core93.getStoreLattice)("default", "project").store;
31797
+ const taskStore = (0, import_core93.getStoreLattice)("default", "task").store;
31801
31798
  const authService = new A2AAuthService2({
31802
31799
  keyStore: a2aKeyStore,
31803
31800
  assistantStore,
@@ -31836,8 +31833,8 @@ var start = async (config) => {
31836
31833
  const { CollectionService: CollectionService2 } = await Promise.resolve().then(() => (init_collection_service(), collection_service_exports));
31837
31834
  openLattice2.register(createKbProvider2(new CollectionService2()));
31838
31835
  openLattice2.register(createOpenSandboxProvider2());
31839
- const threadStore = (0, import_core92.getStoreLattice)("default", "thread").store;
31840
- const assistantStore = (0, import_core92.getStoreLattice)("default", "assistant").store;
31836
+ const threadStore = (0, import_core93.getStoreLattice)("default", "thread").store;
31837
+ const assistantStore = (0, import_core93.getStoreLattice)("default", "assistant").store;
31841
31838
  openLattice2.register(
31842
31839
  createAgentProvider2({
31843
31840
  threadStore,
@@ -31871,17 +31868,17 @@ var start = async (config) => {
31871
31868
  error: err instanceof Error ? err.message : String(err)
31872
31869
  });
31873
31870
  }
31874
- if (!import_core92.sandboxLatticeManager.hasLattice("default")) {
31875
- import_core92.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
31871
+ if (!import_core93.sandboxLatticeManager.hasLattice("default")) {
31872
+ import_core93.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
31876
31873
  logger7.info("Registered sandbox manager from env configuration");
31877
31874
  }
31878
31875
  try {
31879
31876
  const { ResourceController: ResourceController2 } = await Promise.resolve().then(() => (init_resources(), resources_exports));
31880
- const sharedResourceStore = (0, import_core92.getStoreLattice)("default", "sharedResource").store;
31881
- const cache2 = new import_core92.TokenCache();
31877
+ const sharedResourceStore = (0, import_core93.getStoreLattice)("default", "sharedResource").store;
31878
+ const cache2 = new import_core93.TokenCache();
31882
31879
  const resourceController = new ResourceController2({
31883
31880
  store: sharedResourceStore,
31884
- sandboxManager: import_core92.sandboxLatticeManager,
31881
+ sandboxManager: import_core93.sandboxLatticeManager,
31885
31882
  cache: cache2,
31886
31883
  logger: logger7
31887
31884
  });
@@ -31906,39 +31903,39 @@ var start = async (config) => {
31906
31903
  }
31907
31904
  }
31908
31905
  const target_port = config?.port || Number(process.env.PORT) || 4001;
31909
- (0, import_core92.configureCoordinationLeaseStore)((0, import_core92.getStoreLattice)("default", "lease").store);
31910
- const outboxStore = (0, import_core92.getStoreLattice)("default", "outbox").store;
31911
- import_core92.taskLifecycleNotifier.setOutbox(outboxStore);
31912
- import_core92.projectTaskAdmissionNotifier.setOutbox(outboxStore);
31913
- (0, import_core92.configurePluginCatalogSync)({ outbox: outboxStore, owner: (0, import_core92.getReplicaId)() });
31906
+ (0, import_core93.configureCoordinationLeaseStore)((0, import_core93.getStoreLattice)("default", "lease").store);
31907
+ const outboxStore = (0, import_core93.getStoreLattice)("default", "outbox").store;
31908
+ import_core93.taskLifecycleNotifier.setOutbox(outboxStore);
31909
+ import_core93.projectTaskAdmissionNotifier.setOutbox(outboxStore);
31910
+ (0, import_core93.configurePluginCatalogSync)({ outbox: outboxStore, owner: (0, import_core93.getReplicaId)() });
31914
31911
  bridgeAssistantEvents(
31915
- (event, cb) => import_core92.eventBus.subscribe(event, cb),
31912
+ (event, cb) => import_core93.eventBus.subscribe(event, cb),
31916
31913
  outboxStore,
31917
- (0, import_core92.getReplicaId)()
31914
+ (0, import_core93.getReplicaId)()
31918
31915
  );
31919
31916
  if (projectRoomRealtimeRuntime) {
31920
31917
  projectRoomRealtimeRuntime.broker.setBroadcastHook((scope, serialized, sourceKey) => {
31921
- void publishRoomEvent(outboxStore, (0, import_core92.getReplicaId)(), scope, serialized, sourceKey);
31918
+ void publishRoomEvent(outboxStore, (0, import_core93.getReplicaId)(), scope, serialized, sourceKey);
31922
31919
  });
31923
31920
  }
31924
- const outboxPoller = new import_core92.OutboxPoller({
31921
+ const outboxPoller = new import_core93.OutboxPoller({
31925
31922
  store: outboxStore,
31926
- owner: (0, import_core92.getReplicaId)(),
31923
+ owner: (0, import_core93.getReplicaId)(),
31927
31924
  handlers: {
31928
- "task-lifecycle": (payload) => import_core92.taskLifecycleNotifier.deliverFromOutbox(payload),
31929
- "project-task-admission": (payload) => import_core92.projectTaskAdmissionNotifier.deliverFromOutbox(payload),
31925
+ "task-lifecycle": (payload) => import_core93.taskLifecycleNotifier.deliverFromOutbox(payload),
31926
+ "project-task-admission": (payload) => import_core93.projectTaskAdmissionNotifier.deliverFromOutbox(payload),
31930
31927
  [ROOM_EVENT_TOPIC]: async (payload) => {
31931
31928
  if (projectRoomRealtimeRuntime) ingestRoomEvent(payload, projectRoomRealtimeRuntime.broker);
31932
31929
  },
31933
- "assistant-changed": (payload) => handleAssistantChanged(payload, (tenantId) => import_core92.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId)),
31930
+ "assistant-changed": (payload) => handleAssistantChanged(payload, (tenantId) => import_core93.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId)),
31934
31931
  [MCP_CONFIG_CHANGED_TOPIC]: (payload) => reconcileMcpConfigChange(payload, {
31935
- store: (0, import_core92.getStoreLattice)("default", "mcp").store,
31936
- manager: import_core92.mcpManager,
31937
- convertToConnection: import_core92.convertToConnection
31932
+ store: (0, import_core93.getStoreLattice)("default", "mcp").store,
31933
+ manager: import_core93.mcpManager,
31934
+ convertToConnection: import_core93.convertToConnection
31938
31935
  }),
31939
- [import_core92.PLUGIN_CATALOG_CHANGED_TOPIC]: async (payload) => {
31936
+ [import_core93.PLUGIN_CATALOG_CHANGED_TOPIC]: async (payload) => {
31940
31937
  const tenantId = payload?.tenantId;
31941
- if (typeof tenantId === "string" && tenantId.length > 0) (0, import_core92.getSandboxPluginCatalog)().invalidate(tenantId);
31938
+ if (typeof tenantId === "string" && tenantId.length > 0) (0, import_core93.getSandboxPluginCatalog)().invalidate(tenantId);
31942
31939
  }
31943
31940
  },
31944
31941
  log: logger7
@@ -31948,7 +31945,7 @@ var start = async (config) => {
31948
31945
  } catch (err) {
31949
31946
  logger7.warn("Outbox poller failed to start", { error: err instanceof Error ? err.message : String(err) });
31950
31947
  }
31951
- const leaseStore = (0, import_core92.getStoreLattice)("default", "lease").store;
31948
+ const leaseStore = (0, import_core93.getStoreLattice)("default", "lease").store;
31952
31949
  if (leaseStore.constructor?.name === "InMemoryLeaseStore") {
31953
31950
  logger7.warn(
31954
31951
  "Startup recovery leader gate uses a non-distributed lease store (per-process only); configure a shared 'lease' store for multi-replica deployments",
@@ -31956,7 +31953,7 @@ var start = async (config) => {
31956
31953
  );
31957
31954
  }
31958
31955
  warnMultiReplicaReadiness(logger7);
31959
- const startup = await (0, import_core92.runAsLeader)(leaseStore, "startup-recovery", async () => {
31956
+ const startup = await (0, import_core93.runAsLeader)(leaseStore, "startup-recovery", async () => {
31960
31957
  if (routes.projectTaskRuntime) {
31961
31958
  await prepareProjectTaskRuntime(routes.projectTaskRuntime, logger7);
31962
31959
  }
@@ -31965,9 +31962,9 @@ var start = async (config) => {
31965
31962
  const { createOrphanRecoveryRuntime: createOrphanRecoveryRuntime2 } = await Promise.resolve().then(() => (init_OrphanRecoveryRuntime(), OrphanRecoveryRuntime_exports));
31966
31963
  const { createRecoveryCallerDeps: createRecoveryCallerDeps2 } = await Promise.resolve().then(() => (init_RecoveryCallerDeps(), RecoveryCallerDeps_exports));
31967
31964
  const runtime = createOrphanRecoveryRuntime2({
31968
- taskStore: (0, import_core92.getStoreLattice)("default", "task").store,
31969
- workItemStore: (0, import_core92.getStoreLattice)("default", "taskWorkItem").store,
31970
- tenantStore: (0, import_core92.getStoreLattice)("default", "tenant").store,
31965
+ taskStore: (0, import_core93.getStoreLattice)("default", "task").store,
31966
+ workItemStore: (0, import_core93.getStoreLattice)("default", "taskWorkItem").store,
31967
+ tenantStore: (0, import_core93.getStoreLattice)("default", "tenant").store,
31971
31968
  ...createRecoveryCallerDeps2(),
31972
31969
  log: logger7
31973
31970
  });
@@ -31976,9 +31973,9 @@ var start = async (config) => {
31976
31973
  logger7.warn("Task orphan recovery failed", { error: err instanceof Error ? err.message : String(err) });
31977
31974
  }
31978
31975
  }
31979
- if (import_core92.scheduleLatticeManager.hasLattice("default")) {
31976
+ if (import_core93.scheduleLatticeManager.hasLattice("default")) {
31980
31977
  try {
31981
- const restored = await import_core92.scheduleLatticeManager.getScheduleLattice("default").restore();
31978
+ const restored = await import_core93.scheduleLatticeManager.getScheduleLattice("default").restore();
31982
31979
  logger7.info("Scheduled tasks restored", { phase: "startup_recovery", restored });
31983
31980
  } catch (err) {
31984
31981
  logger7.warn("Scheduled task restore failed", {