@axiom-lattice/gateway 4.9.0 → 4.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{chunk-NPHK4SZ6.mjs → chunk-FGSFOXIX.mjs} +2 -2
  2. package/dist/{chunk-73QZQQOT.mjs → chunk-MWWLJMYN.mjs} +3 -2
  3. package/dist/chunk-MWWLJMYN.mjs.map +1 -0
  4. package/dist/embed/{embed-page-AgentDetailSideApp-BVJK7WIS.js → embed-page-AgentDetailSideApp-UMITWVYQ.js} +1 -1
  5. package/dist/embed/{embed-page-AgentGovernanceWorkbench-L2YHPRNE.js → embed-page-AgentGovernanceWorkbench-UD7RE7PT.js} +1 -1
  6. package/dist/embed/{embed-page-MessageGraph-JOQ46UE2.js → embed-page-MessageGraph-XQWKYDUB.js} +1 -1
  7. package/dist/embed/{embed-page-ReactChart-I5AYTSII.js → embed-page-ReactChart-LW3GWMY2.js} +1 -1
  8. package/dist/embed/{embed-page-SkillFlow-YLB5XPFH.js → embed-page-SkillFlow-X3D346DE.js} +1 -1
  9. package/dist/embed/{embed-page-TasksSideApp-QLJVB7UK.js → embed-page-TasksSideApp-SUMX2GJF.js} +1 -1
  10. package/dist/embed/{embed-page-TeamWorkspace-BZZEAYSB.js → embed-page-TeamWorkspace-QMIX2TP2.js} +1 -1
  11. package/dist/embed/{embed-page-TopologyRuntimeView-FRA3AXQQ.js → embed-page-TopologyRuntimeView-ZP6NWNS7.js} +1 -1
  12. package/dist/embed/{embed-page-WorkflowAutomationView-D745PK3W.js → embed-page-WorkflowAutomationView-4HD3ISK6.js} +1 -1
  13. package/dist/embed/{embed-page-chunk-FVMSMU4J.js → embed-page-chunk-3VIEL6KL.js} +1 -1
  14. package/dist/embed/{embed-page-chunk-4WBAN7QL.js → embed-page-chunk-MFFCCHGW.js} +158 -158
  15. package/dist/embed/{embed-page-chunk-M2PV36MX.js → embed-page-chunk-QCKYIPFY.js} +1 -1
  16. package/dist/embed/{embed-page-chunk-P5PFV3N7.js → embed-page-chunk-QGAGZMX2.js} +1 -1
  17. package/dist/embed/{embed-page-chunk-FWGNJMXD.js → embed-page-chunk-SX7YO5JA.js} +1 -1
  18. package/dist/embed/{embed-page-chunk-WMLR2GQK.js → embed-page-chunk-T7XXE35M.js} +1 -1
  19. package/dist/embed/{embed-page-chunk-K5YYUAPL.js → embed-page-chunk-YAJUWBF2.js} +1 -1
  20. package/dist/embed/embed-page.js +1 -1
  21. package/dist/index.d.mts +48 -3
  22. package/dist/index.d.ts +48 -3
  23. package/dist/index.js +621 -442
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +327 -146
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/{open-UVKMONVE.mjs → open-FJ3BY3CL.mjs} +3 -3
  28. package/dist/{open-exposure-27ESFWTB.mjs → open-exposure-OX5NKWDG.mjs} +3 -3
  29. package/package.json +3 -3
  30. package/dist/chunk-73QZQQOT.mjs.map +0 -1
  31. /package/dist/{chunk-NPHK4SZ6.mjs.map → chunk-FGSFOXIX.mjs.map} +0 -0
  32. /package/dist/{open-UVKMONVE.mjs.map → open-FJ3BY3CL.mjs.map} +0 -0
  33. /package/dist/{open-exposure-27ESFWTB.mjs.map → open-exposure-OX5NKWDG.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -573,12 +573,13 @@ async function invokePluginTool(deps, tenantId, pluginType, name, args, runConte
573
573
  maxResultBytes: tool.maxResultBytes
574
574
  });
575
575
  if (!result.ok) throw new Error(result.error ?? "sandbox plugin execution failed");
576
- return result.result;
576
+ return result.result === void 0 ? (0, import_core35.handlerResultText)(result) : result.result;
577
577
  }
578
- var PluginToolScopeError;
578
+ var import_core35, PluginToolScopeError;
579
579
  var init_pluginToolExecution = __esm({
580
580
  "src/services/plugins/pluginToolExecution.ts"() {
581
581
  "use strict";
582
+ import_core35 = require("@axiom-lattice/core");
582
583
  PluginToolScopeError = class extends Error {
583
584
  /**
584
585
  * @param name - Rejected tool name.
@@ -1144,8 +1145,8 @@ async function refreshStoreKeyMap() {
1144
1145
  function broadcastA2AKeyChanged(tenantId) {
1145
1146
  if (!tenantId) return;
1146
1147
  try {
1147
- const outbox = (0, import_core56.getStoreLattice)("default", "outbox").store;
1148
- void publishA2AKeyChanged(outbox, (0, import_core56.getReplicaId)(), tenantId);
1148
+ const outbox = (0, import_core58.getStoreLattice)("default", "outbox").store;
1149
+ void publishA2AKeyChanged(outbox, (0, import_core58.getReplicaId)(), tenantId);
1149
1150
  } catch {
1150
1151
  }
1151
1152
  }
@@ -1321,11 +1322,11 @@ function registerA2ARoutes(app2) {
1321
1322
  );
1322
1323
  }
1323
1324
  }
1324
- var import_core56, _a2aKeyStore, _a2aAuthService;
1325
+ var import_core58, _a2aKeyStore, _a2aAuthService;
1325
1326
  var init_a2a = __esm({
1326
1327
  "src/routes/a2a.ts"() {
1327
1328
  "use strict";
1328
- import_core56 = require("@axiom-lattice/core");
1329
+ import_core58 = require("@axiom-lattice/core");
1329
1330
  init_A2AAuthService();
1330
1331
  init_a2aKeySync();
1331
1332
  _a2aKeyStore = null;
@@ -1372,7 +1373,7 @@ function outcome(task) {
1372
1373
  });
1373
1374
  }
1374
1375
  async function backfillTopCallerGroup(tasks, top, deps) {
1375
- const registry = deps.registry ?? import_core74.taskRunRegistry;
1376
+ const registry = deps.registry ?? import_core76.taskRunRegistry;
1376
1377
  const results = [];
1377
1378
  const eligible = [];
1378
1379
  for (const task of tasks) {
@@ -1426,11 +1427,11 @@ async function recoverTask(task, deps) {
1426
1427
  if (task.status !== "in_progress") {
1427
1428
  return { kind: "skipped", reason: "not_in_progress" };
1428
1429
  }
1429
- const registry = deps.registry ?? import_core74.taskRunRegistry;
1430
+ const registry = deps.registry ?? import_core76.taskRunRegistry;
1430
1431
  if (registry.isLive(task.id) || deps.isTaskLive && await deps.isTaskLive(task)) {
1431
1432
  return { kind: "skipped", reason: "live" };
1432
1433
  }
1433
- const { convergedTasks } = await (0, import_core74.reconcileStaleTaskRuns)({
1434
+ const { convergedTasks } = await (0, import_core76.reconcileStaleTaskRuns)({
1434
1435
  tasks: [task],
1435
1436
  actor: "system:on-demand-recovery",
1436
1437
  lifecycle: deps.lifecycle,
@@ -1526,29 +1527,29 @@ async function runOrphanRecovery(deps) {
1526
1527
  deps.log.info("Task orphan recovery complete", { recovered, skipped });
1527
1528
  return { recovered, skipped };
1528
1529
  }
1529
- var import_messages, import_core74;
1530
+ var import_messages, import_core76;
1530
1531
  var init_TopCallerRecovery = __esm({
1531
1532
  "src/services/collaboration/TopCallerRecovery.ts"() {
1532
1533
  "use strict";
1533
1534
  import_messages = require("@langchain/core/messages");
1534
- import_core74 = require("@axiom-lattice/core");
1535
+ import_core76 = require("@axiom-lattice/core");
1535
1536
  }
1536
1537
  });
1537
1538
 
1538
1539
  // src/services/collaboration/taskRunLiveness.ts
1539
1540
  function createTaskRunLiveness() {
1540
1541
  try {
1541
- import_core75.storeLatticeManager.getStoreLattice("default", "lease");
1542
+ import_core77.storeLatticeManager.getStoreLattice("default", "lease");
1542
1543
  } catch {
1543
1544
  return void 0;
1544
1545
  }
1545
1546
  return async (task) => {
1546
1547
  try {
1547
- const store2 = import_core75.storeLatticeManager.getStoreLattice("default", "lease").store;
1548
- if (await store2.get((0, import_core75.taskRunLeaseKey)(task.id))) return true;
1548
+ const store2 = import_core77.storeLatticeManager.getStoreLattice("default", "lease").store;
1549
+ if (await store2.get((0, import_core77.taskRunLeaseKey)(task.id))) return true;
1549
1550
  const threadId = typeof task.context?.thread_id === "string" ? task.context.thread_id : void 0;
1550
1551
  if (threadId && task.ownerId) {
1551
- if (await store2.get((0, import_core75.threadRunLeaseKey)(task.tenantId, task.ownerId, threadId))) return true;
1552
+ if (await store2.get((0, import_core77.threadRunLeaseKey)(task.tenantId, task.ownerId, threadId))) return true;
1552
1553
  }
1553
1554
  return false;
1554
1555
  } catch {
@@ -1556,11 +1557,11 @@ function createTaskRunLiveness() {
1556
1557
  }
1557
1558
  };
1558
1559
  }
1559
- var import_core75;
1560
+ var import_core77;
1560
1561
  var init_taskRunLiveness = __esm({
1561
1562
  "src/services/collaboration/taskRunLiveness.ts"() {
1562
1563
  "use strict";
1563
- import_core75 = require("@axiom-lattice/core");
1564
+ import_core77 = require("@axiom-lattice/core");
1564
1565
  }
1565
1566
  });
1566
1567
 
@@ -1570,7 +1571,7 @@ __export(OrphanRecoveryRuntime_exports, {
1570
1571
  createOrphanRecoveryRuntime: () => createOrphanRecoveryRuntime
1571
1572
  });
1572
1573
  function createOrphanRecoveryRuntime(deps) {
1573
- const lifecycle = deps.lifecycle ?? (0, import_core76.createTaskLifecycleService)({
1574
+ const lifecycle = deps.lifecycle ?? (0, import_core78.createTaskLifecycleService)({
1574
1575
  taskStore: deps.taskStore,
1575
1576
  workItemStore: deps.workItemStore
1576
1577
  });
@@ -1578,7 +1579,7 @@ function createOrphanRecoveryRuntime(deps) {
1578
1579
  async recoverAll() {
1579
1580
  const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();
1580
1581
  return runOrphanRecovery({
1581
- reconcile: () => (0, import_core76.reconcileAllTenantTaskRuns)({
1582
+ reconcile: () => (0, import_core78.reconcileAllTenantTaskRuns)({
1582
1583
  actor: "system:orphan-recovery",
1583
1584
  tenantStore: {
1584
1585
  listTenants: async () => (await deps.tenantStore.getAllTenants()).map((tenant2) => ({ id: tenant2.id }))
@@ -1604,7 +1605,7 @@ function createOrphanRecoveryRuntime(deps) {
1604
1605
  const isTaskLive = deps.isTaskLive ?? createTaskRunLiveness();
1605
1606
  return recoverTask(task, {
1606
1607
  lifecycle,
1607
- registry: import_core76.taskRunRegistry,
1608
+ registry: import_core78.taskRunRegistry,
1608
1609
  orphans,
1609
1610
  callerFor: deps.callerFor,
1610
1611
  resume: deps.resume,
@@ -1613,11 +1614,11 @@ function createOrphanRecoveryRuntime(deps) {
1613
1614
  }
1614
1615
  };
1615
1616
  }
1616
- var import_core76;
1617
+ var import_core78;
1617
1618
  var init_OrphanRecoveryRuntime = __esm({
1618
1619
  "src/services/collaboration/OrphanRecoveryRuntime.ts"() {
1619
1620
  "use strict";
1620
- import_core76 = require("@axiom-lattice/core");
1621
+ import_core78 = require("@axiom-lattice/core");
1621
1622
  init_TopCallerRecovery();
1622
1623
  init_projectTaskScope();
1623
1624
  init_taskRunLiveness();
@@ -1633,12 +1634,12 @@ function createRecoveryCallerDeps() {
1633
1634
  return {
1634
1635
  callerFor: async (top, tenantId) => {
1635
1636
  if (!top.assistantId) return void 0;
1636
- const load = import_core77.getAgentClientAsync ?? import_core77.getAgentClient;
1637
+ const load = import_core79.getAgentClientAsync ?? import_core79.getAgentClient;
1637
1638
  const client = await load(tenantId, top.assistantId);
1638
1639
  const config = { configurable: { thread_id: top.threadId, runConfig: { tenantId, assistant_id: top.assistantId } } };
1639
1640
  let agent;
1640
1641
  try {
1641
- agent = import_core77.agentInstanceManager.getAgent({ assistant_id: top.assistantId, thread_id: top.threadId, tenant_id: tenantId });
1642
+ agent = import_core79.agentInstanceManager.getAgent({ assistant_id: top.assistantId, thread_id: top.threadId, tenant_id: tenantId });
1642
1643
  } catch {
1643
1644
  }
1644
1645
  return agent ? { client, config, agent } : { client, config };
@@ -1655,11 +1656,11 @@ function createRecoveryCallerDeps() {
1655
1656
  }
1656
1657
  };
1657
1658
  }
1658
- var import_core77;
1659
+ var import_core79;
1659
1660
  var init_RecoveryCallerDeps = __esm({
1660
1661
  "src/services/collaboration/RecoveryCallerDeps.ts"() {
1661
1662
  "use strict";
1662
- import_core77 = require("@axiom-lattice/core");
1663
+ import_core79 = require("@axiom-lattice/core");
1663
1664
  }
1664
1665
  });
1665
1666
 
@@ -2078,13 +2079,13 @@ function isA2ATaskSnapshot(value) {
2078
2079
  function snapshotSequence(value) {
2079
2080
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
2080
2081
  }
2081
- var import_node_crypto30, import_node_util, import_core78, TASK_STATUS_TO_A2A_STATE, TITLE_MAX_LENGTH, A2ATaskScopeConflictError, A2ATaskStoreAdapter;
2082
+ var import_node_crypto30, import_node_util, import_core80, TASK_STATUS_TO_A2A_STATE, TITLE_MAX_LENGTH, A2ATaskScopeConflictError, A2ATaskStoreAdapter;
2082
2083
  var init_A2ATaskStoreAdapter = __esm({
2083
2084
  "src/services/a2a/A2ATaskStoreAdapter.ts"() {
2084
2085
  "use strict";
2085
2086
  import_node_crypto30 = require("crypto");
2086
2087
  import_node_util = require("util");
2087
- import_core78 = require("@axiom-lattice/core");
2088
+ import_core80 = require("@axiom-lattice/core");
2088
2089
  TASK_STATUS_TO_A2A_STATE = {
2089
2090
  pending: "submitted",
2090
2091
  in_progress: "working",
@@ -2110,7 +2111,7 @@ var init_A2ATaskStoreAdapter = __esm({
2110
2111
  this.workItemStore = options.workItemStore;
2111
2112
  this.lifecycle = options.lifecycle;
2112
2113
  this.scope = options.scope;
2113
- this.runBridge = (0, import_core78.createTaskRunBridge)({
2114
+ this.runBridge = (0, import_core80.createTaskRunBridge)({
2114
2115
  lifecycle: this.lifecycle,
2115
2116
  taskStore: this.taskStore,
2116
2117
  workItemStore: this.workItemStore
@@ -2461,12 +2462,12 @@ function assistantHasGovernedTask(assistant) {
2461
2462
  const allowedTools = taskMiddleware?.allowedTools;
2462
2463
  return !!taskMiddleware && (allowedTools === void 0 || Array.isArray(allowedTools) && (allowedTools.length === 0 || allowedTools.includes("manage_task")));
2463
2464
  }
2464
- var import_uuid11, import_core79, import_protocols35, _AxiomAgentExecutor, AxiomAgentExecutor;
2465
+ var import_uuid11, import_core81, import_protocols35, _AxiomAgentExecutor, AxiomAgentExecutor;
2465
2466
  var init_AxiomAgentExecutor = __esm({
2466
2467
  "src/services/a2a/AxiomAgentExecutor.ts"() {
2467
2468
  "use strict";
2468
2469
  import_uuid11 = require("uuid");
2469
- import_core79 = require("@axiom-lattice/core");
2470
+ import_core81 = require("@axiom-lattice/core");
2470
2471
  import_protocols35 = require("@axiom-lattice/protocols");
2471
2472
  init_a2aFileRefs();
2472
2473
  init_task_file_refs();
@@ -2563,7 +2564,7 @@ var init_AxiomAgentExecutor = __esm({
2563
2564
  await this.taskStore.save(initialTask);
2564
2565
  bus.publish(initialTask);
2565
2566
  try {
2566
- const agent = import_core79.agentInstanceManager.getAgent(this.agentParams(threadId));
2567
+ const agent = import_core81.agentInstanceManager.getAgent(this.agentParams(threadId));
2567
2568
  const requestText = inputFiles.length > 0 ? `${text}
2568
2569
 
2569
2570
  ${formatFileRefsSection(inputFiles)}` : text;
@@ -2751,7 +2752,7 @@ ${formatFileRefsSection(inputFiles)}` : text;
2751
2752
  const threadId = task ? asString2(task.metadata?.threadId) : void 0;
2752
2753
  if (threadId) {
2753
2754
  try {
2754
- const agent = import_core79.agentInstanceManager.getAgent(this.agentParams(threadId));
2755
+ const agent = import_core81.agentInstanceManager.getAgent(this.agentParams(threadId));
2755
2756
  await agent.abort();
2756
2757
  } catch (err) {
2757
2758
  console.warn({
@@ -3125,10 +3126,10 @@ function isAsyncGenerator(value) {
3125
3126
  }
3126
3127
  function registerA2AStandardRoutes(app2, deps) {
3127
3128
  const authService = deps.authService;
3128
- const resolveTasks = deps.getTaskStoreLattice ?? (() => (0, import_core80.getStoreLattice)("default", "task").store);
3129
- const resolveTaskWorkItems = deps.getTaskWorkItemStore ?? (() => (0, import_core80.getStoreLattice)("default", "taskWorkItem").store);
3130
- const getAssistantStore2 = deps.getAssistantStore ?? (() => (0, import_core80.getStoreLattice)("default", "assistant").store);
3131
- const getProjectStore2 = deps.getProjectStore ?? (() => (0, import_core80.getStoreLattice)("default", "project").store);
3129
+ const resolveTasks = deps.getTaskStoreLattice ?? (() => (0, import_core82.getStoreLattice)("default", "task").store);
3130
+ const resolveTaskWorkItems = deps.getTaskWorkItemStore ?? (() => (0, import_core82.getStoreLattice)("default", "taskWorkItem").store);
3131
+ const getAssistantStore2 = deps.getAssistantStore ?? (() => (0, import_core82.getStoreLattice)("default", "assistant").store);
3132
+ const getProjectStore2 = deps.getProjectStore ?? (() => (0, import_core82.getStoreLattice)("default", "project").store);
3132
3133
  const runtimeRegistry = deps.runtimeRegistry ?? new A2ARuntimeRegistry();
3133
3134
  app2.addHook("onClose", async () => {
3134
3135
  runtimeRegistry.close();
@@ -3211,7 +3212,7 @@ function registerA2AStandardRoutes(app2, deps) {
3211
3212
  const taskStore = assistantHasGovernedTask(assistant) ? new A2ATaskStoreAdapter({
3212
3213
  taskStore: internalTasks,
3213
3214
  workItemStore: workItems,
3214
- lifecycle: (0, import_core80.createTaskLifecycleService)({
3215
+ lifecycle: (0, import_core82.createTaskLifecycleService)({
3215
3216
  taskStore: internalTasks,
3216
3217
  workItemStore: workItems
3217
3218
  }),
@@ -3330,7 +3331,7 @@ data: ${JSON.stringify(errorResponse)}
3330
3331
  const taskStore = assistantHasGovernedTask(assistant) ? new A2ATaskStoreAdapter({
3331
3332
  taskStore: internalTasks,
3332
3333
  workItemStore: workItems,
3333
- lifecycle: (0, import_core80.createTaskLifecycleService)({
3334
+ lifecycle: (0, import_core82.createTaskLifecycleService)({
3334
3335
  taskStore: internalTasks,
3335
3336
  workItemStore: workItems
3336
3337
  }),
@@ -3385,13 +3386,13 @@ data: ${JSON.stringify(data)}
3385
3386
  }
3386
3387
  );
3387
3388
  }
3388
- var import_uuid12, import_server2, import_core80, SSE_HEADERS;
3389
+ var import_uuid12, import_server2, import_core82, SSE_HEADERS;
3389
3390
  var init_a2a_standard = __esm({
3390
3391
  "src/routes/a2a-standard.ts"() {
3391
3392
  "use strict";
3392
3393
  import_uuid12 = require("uuid");
3393
3394
  import_server2 = require("@a2a-js/sdk/server");
3394
- import_core80 = require("@axiom-lattice/core");
3395
+ import_core82 = require("@axiom-lattice/core");
3395
3396
  init_A2AAuthService();
3396
3397
  init_A2AAgentCardBuilder();
3397
3398
  init_A2ATaskStoreAdapter();
@@ -3954,8 +3955,8 @@ function exposedDeclarations(plugin) {
3954
3955
  return (plugin.meta.tools ?? []).filter((t2) => t2.expose);
3955
3956
  }
3956
3957
  async function registerExposedPluginTools() {
3957
- for (const key of import_core81.PluginRegistry.list()) {
3958
- const plugin = import_core81.PluginRegistry.get(key);
3958
+ for (const key of import_core83.PluginRegistry.list()) {
3959
+ const plugin = import_core83.PluginRegistry.get(key);
3959
3960
  if (!plugin?.middleware) continue;
3960
3961
  const exposed = exposedDeclarations(plugin);
3961
3962
  if (exposed.length === 0) continue;
@@ -3990,8 +3991,8 @@ async function registerExposedPluginTools() {
3990
3991
  }
3991
3992
  function collectExposedPluginUiResources(grants) {
3992
3993
  const resources = /* @__PURE__ */ new Map();
3993
- for (const type of import_core81.PluginRegistry.list()) {
3994
- const plugin = import_core81.PluginRegistry.get(type);
3994
+ for (const type of import_core83.PluginRegistry.list()) {
3995
+ const plugin = import_core83.PluginRegistry.get(type);
3995
3996
  if (!plugin?.middleware) continue;
3996
3997
  const exposedNames = new Set(exposedDeclarations(plugin).map((d) => d.name));
3997
3998
  if (exposedNames.size === 0) continue;
@@ -4015,11 +4016,11 @@ function collectExposedPluginUiResources(grants) {
4015
4016
  }
4016
4017
  return resources;
4017
4018
  }
4018
- var import_core81;
4019
+ var import_core83;
4019
4020
  var init_registerExposedPlugins = __esm({
4020
4021
  "src/services/open/registerExposedPlugins.ts"() {
4021
4022
  "use strict";
4022
- import_core81 = require("@axiom-lattice/core");
4023
+ import_core83 = require("@axiom-lattice/core");
4023
4024
  init_openLattice();
4024
4025
  init_pluginExposeAdapter();
4025
4026
  }
@@ -4034,14 +4035,14 @@ function toText(result) {
4034
4035
  }
4035
4036
  function defaultCatalog() {
4036
4037
  return {
4037
- getValidatedManifest: (tenantId, type) => (0, import_core82.getSandboxPluginCatalog)().getValidatedManifest(tenantId, type),
4038
- getExecutor: () => (0, import_core82.getSandboxPluginCatalog)().getExecutor(),
4039
- readPluginFile: (tenantId, type, relPath) => (0, import_core82.getSandboxPluginCatalog)().readPluginFile(tenantId, type, relPath)
4038
+ getValidatedManifest: (tenantId, type) => (0, import_core84.getSandboxPluginCatalog)().getValidatedManifest(tenantId, type),
4039
+ getExecutor: () => (0, import_core84.getSandboxPluginCatalog)().getExecutor(),
4040
+ readPluginFile: (tenantId, type, relPath) => (0, import_core84.getSandboxPluginCatalog)().readPluginFile(tenantId, type, relPath)
4040
4041
  };
4041
4042
  }
4042
4043
  async function defaultResolveConnections(pluginType, ctx) {
4043
4044
  try {
4044
- return await (0, import_core82.resolveSandboxPluginConnections)(
4045
+ return await (0, import_core84.resolveSandboxPluginConnections)(
4045
4046
  pluginType,
4046
4047
  { connectAll: true },
4047
4048
  {
@@ -4070,7 +4071,7 @@ function mergeOpenCatalog(globalCatalog, tenantTools) {
4070
4071
  async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
4071
4072
  const catalog = deps.catalog ?? defaultCatalog();
4072
4073
  const listPlugins = deps.listPlugins ?? (async (tenant2) => {
4073
- const snapshot = await (0, import_core82.getSandboxPluginCatalog)().ensureLoaded(tenant2);
4074
+ const snapshot = await (0, import_core84.getSandboxPluginCatalog)().ensureLoaded(tenant2);
4074
4075
  return { plugins: snapshot.plugins, diagnostics: snapshot.diagnostics };
4075
4076
  });
4076
4077
  const resolveConnections = deps.resolveConnections ?? defaultResolveConnections;
@@ -4112,7 +4113,7 @@ async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
4112
4113
  domain,
4113
4114
  action: tool.name,
4114
4115
  description: tool.description,
4115
- schema: (0, import_core82.jsonSchemaToZod)(tool.schema),
4116
+ schema: (0, import_core84.jsonSchemaToZod)(tool.schema),
4116
4117
  annotations: {
4117
4118
  readOnlyHint: tool.readOnly ?? false,
4118
4119
  destructiveHint: tool.destructive ?? false
@@ -4163,11 +4164,11 @@ async function buildTenantOpenPlugins(tenantId, grants, deps = {}) {
4163
4164
  }
4164
4165
  };
4165
4166
  }
4166
- var import_core82;
4167
+ var import_core84;
4167
4168
  var init_tenantOpenPlugins = __esm({
4168
4169
  "src/services/open/tenantOpenPlugins.ts"() {
4169
4170
  "use strict";
4170
- import_core82 = require("@axiom-lattice/core");
4171
+ import_core84 = require("@axiom-lattice/core");
4171
4172
  init_openLattice();
4172
4173
  init_pluginToolExecution();
4173
4174
  }
@@ -4204,13 +4205,13 @@ function emptyTenantPlugins() {
4204
4205
  }
4205
4206
  function registerOpenRoutes(app2, deps = {}) {
4206
4207
  const openAuth = deps.openAuth ?? new OpenCredentialService(
4207
- (0, import_core83.getStoreLattice)("default", "a2aApiKey").store,
4208
- (0, import_core83.getStoreLattice)("default", "project").store
4208
+ (0, import_core85.getStoreLattice)("default", "a2aApiKey").store,
4209
+ (0, import_core85.getStoreLattice)("default", "project").store
4209
4210
  );
4210
4211
  const grantsSource = deps.grantsSource ?? ((ctx) => ctx.grants);
4211
4212
  const audit = deps.audit ?? (() => {
4212
4213
  try {
4213
- const store2 = (0, import_core83.getStoreLattice)("default", "openAudit").store;
4214
+ const store2 = (0, import_core85.getStoreLattice)("default", "openAudit").store;
4214
4215
  return new OpenAuditService(store2);
4215
4216
  } catch {
4216
4217
  return void 0;
@@ -4365,12 +4366,12 @@ function registerOpenRoutes(app2, deps = {}) {
4365
4366
  }
4366
4367
  );
4367
4368
  }
4368
- var import_types, import_core83, RPC_ERROR;
4369
+ var import_types, import_core85, RPC_ERROR;
4369
4370
  var init_open = __esm({
4370
4371
  "src/routes/open.ts"() {
4371
4372
  "use strict";
4372
4373
  import_types = require("@modelcontextprotocol/sdk/types.js");
4373
- import_core83 = require("@axiom-lattice/core");
4374
+ import_core85 = require("@axiom-lattice/core");
4374
4375
  init_openCredentialService();
4375
4376
  init_openAuditService();
4376
4377
  init_openRateLimiter();
@@ -4403,7 +4404,7 @@ function registerOpenSessionRoutes(app2) {
4403
4404
  if (typeof shareToken !== "string" || shareToken.length === 0) {
4404
4405
  return reply.status(400).send({ error: "SHARE_TOKEN_REQUIRED" });
4405
4406
  }
4406
- const store2 = (0, import_core84.getStoreLattice)("default", "sharedResource").store;
4407
+ const store2 = (0, import_core86.getStoreLattice)("default", "sharedResource").store;
4407
4408
  const record = await store2.findByToken(shareToken);
4408
4409
  if (!record || record.revoked) {
4409
4410
  return reply.status(404).send({ error: "SHARE_NOT_FOUND" });
@@ -4428,11 +4429,11 @@ function registerOpenSessionRoutes(app2) {
4428
4429
  }
4429
4430
  );
4430
4431
  }
4431
- var import_core84;
4432
+ var import_core86;
4432
4433
  var init_open_session = __esm({
4433
4434
  "src/routes/open-session.ts"() {
4434
4435
  "use strict";
4435
- import_core84 = require("@axiom-lattice/core");
4436
+ import_core86 = require("@axiom-lattice/core");
4436
4437
  init_openToken();
4437
4438
  init_previewToken();
4438
4439
  init_openLattice();
@@ -4441,13 +4442,13 @@ var init_open_session = __esm({
4441
4442
 
4442
4443
  // src/services/open/openCatalogService.ts
4443
4444
  async function defaultListTenantPlugins(tenantId) {
4444
- return (await (0, import_core85.getSandboxPluginCatalog)().ensureLoaded(tenantId)).plugins;
4445
+ return (await (0, import_core87.getSandboxPluginCatalog)().ensureLoaded(tenantId)).plugins;
4445
4446
  }
4446
- var import_core85, OpenCatalogService;
4447
+ var import_core87, OpenCatalogService;
4447
4448
  var init_openCatalogService = __esm({
4448
4449
  "src/services/open/openCatalogService.ts"() {
4449
4450
  "use strict";
4450
- import_core85 = require("@axiom-lattice/core");
4451
+ import_core87 = require("@axiom-lattice/core");
4451
4452
  init_openLattice();
4452
4453
  OpenCatalogService = class {
4453
4454
  constructor(assistantStore, lattice = openLattice, listTenantPlugins2 = defaultListTenantPlugins) {
@@ -4522,17 +4523,17 @@ function registerOpenCatalogRoutes(app2) {
4522
4523
  if (!tenantId) {
4523
4524
  return reply.status(401).send({ success: false, error: "Unauthorized" });
4524
4525
  }
4525
- const assistantStore = (0, import_core86.getStoreLattice)("default", "assistant").store;
4526
+ const assistantStore = (0, import_core88.getStoreLattice)("default", "assistant").store;
4526
4527
  const service2 = new OpenCatalogService(assistantStore);
4527
4528
  const catalog = await service2.buildForTenant(tenantId);
4528
4529
  return reply.status(200).send({ success: true, data: catalog });
4529
4530
  });
4530
4531
  }
4531
- var import_core86;
4532
+ var import_core88;
4532
4533
  var init_open_catalog = __esm({
4533
4534
  "src/routes/open-catalog.ts"() {
4534
4535
  "use strict";
4535
- import_core86 = require("@axiom-lattice/core");
4536
+ import_core88 = require("@axiom-lattice/core");
4536
4537
  init_openCatalogService();
4537
4538
  }
4538
4539
  });
@@ -4547,11 +4548,11 @@ async function resolveContextSandbox(ctx) {
4547
4548
  const sandboxName = ctx.runConfig?.sandboxName;
4548
4549
  if (typeof sandboxName === "string" && sandboxName.length > 0) {
4549
4550
  try {
4550
- return await import_core87.sandboxLatticeManager.getSandbox(sandboxName);
4551
+ return await import_core89.sandboxLatticeManager.getSandbox(sandboxName);
4551
4552
  } catch {
4552
4553
  }
4553
4554
  }
4554
- return import_core87.sandboxLatticeManager.getSandboxFromConfig({
4555
+ return import_core89.sandboxLatticeManager.getSandboxFromConfig({
4555
4556
  assistant_id: "",
4556
4557
  thread_id: "",
4557
4558
  tenantId: ctx.tenantId,
@@ -4649,12 +4650,12 @@ ${truncated}`
4649
4650
  }
4650
4651
  };
4651
4652
  }
4652
- var import_zod21, import_core87, MAX_OUTPUT_BYTES;
4653
+ var import_zod21, import_core89, MAX_OUTPUT_BYTES;
4653
4654
  var init_sandboxProvider = __esm({
4654
4655
  "src/services/open/providers/sandboxProvider.ts"() {
4655
4656
  "use strict";
4656
4657
  import_zod21 = require("zod");
4657
- import_core87 = require("@axiom-lattice/core");
4658
+ import_core89 = require("@axiom-lattice/core");
4658
4659
  MAX_OUTPUT_BYTES = 64e3;
4659
4660
  }
4660
4661
  });
@@ -4676,12 +4677,12 @@ function safePath(raw) {
4676
4677
  }
4677
4678
  function registerOpenFilesRoutes(app2, deps = {}) {
4678
4679
  const openAuth = deps.openAuth ?? new OpenCredentialService(
4679
- (0, import_core88.getStoreLattice)("default", "a2aApiKey").store,
4680
- (0, import_core88.getStoreLattice)("default", "project").store
4680
+ (0, import_core90.getStoreLattice)("default", "a2aApiKey").store,
4681
+ (0, import_core90.getStoreLattice)("default", "project").store
4681
4682
  );
4682
4683
  const audit = deps.audit ?? (() => {
4683
4684
  try {
4684
- const store2 = (0, import_core88.getStoreLattice)("default", "openAudit").store;
4685
+ const store2 = (0, import_core90.getStoreLattice)("default", "openAudit").store;
4685
4686
  return new OpenAuditService(store2);
4686
4687
  } catch {
4687
4688
  return void 0;
@@ -4791,11 +4792,11 @@ function registerOpenFilesRoutes(app2, deps = {}) {
4791
4792
  }
4792
4793
  });
4793
4794
  }
4794
- var import_core88;
4795
+ var import_core90;
4795
4796
  var init_open_files = __esm({
4796
4797
  "src/routes/open-files.ts"() {
4797
4798
  "use strict";
4798
- import_core88 = require("@axiom-lattice/core");
4799
+ import_core90 = require("@axiom-lattice/core");
4799
4800
  init_openCredentialService();
4800
4801
  init_openLattice();
4801
4802
  init_sandboxProvider();
@@ -4817,7 +4818,7 @@ function registerOpenAuditRoutes(app2) {
4817
4818
  return reply.status(401).send({ success: false, error: "Unauthorized" });
4818
4819
  }
4819
4820
  const status = request.query.status === "ok" || request.query.status === "error" ? request.query.status : void 0;
4820
- const store2 = (0, import_core89.getStoreLattice)("default", "openAudit").store;
4821
+ const store2 = (0, import_core91.getStoreLattice)("default", "openAudit").store;
4821
4822
  const records = await store2.query({
4822
4823
  tenantId,
4823
4824
  credentialId: request.query.credentialId,
@@ -4832,11 +4833,11 @@ function registerOpenAuditRoutes(app2) {
4832
4833
  }
4833
4834
  );
4834
4835
  }
4835
- var import_core89;
4836
+ var import_core91;
4836
4837
  var init_open_audit = __esm({
4837
4838
  "src/routes/open-audit.ts"() {
4838
4839
  "use strict";
4839
- import_core89 = require("@axiom-lattice/core");
4840
+ import_core91 = require("@axiom-lattice/core");
4840
4841
  }
4841
4842
  });
4842
4843
 
@@ -4853,7 +4854,7 @@ function registerOpenExposureRoutes(app2, deps = {}) {
4853
4854
  if (!tenantId) {
4854
4855
  return reply.status(401).send({ success: false, error: "Unauthorized" });
4855
4856
  }
4856
- const keyStore = (0, import_core90.getStoreLattice)("default", "a2aApiKey").store;
4857
+ const keyStore = (0, import_core92.getStoreLattice)("default", "a2aApiKey").store;
4857
4858
  const record = await keyStore.findById(request.params.id);
4858
4859
  if (!record || record.tenantId !== tenantId) {
4859
4860
  return reply.status(404).send({ success: false, error: "Key not found" });
@@ -4887,7 +4888,7 @@ function registerOpenExposureRoutes(app2, deps = {}) {
4887
4888
  hasUi: Boolean(t2.ui)
4888
4889
  }));
4889
4890
  const agentGrant = grants.find((g) => g.domain === "agent");
4890
- const assistantStore = (0, import_core90.getStoreLattice)("default", "assistant").store;
4891
+ const assistantStore = (0, import_core92.getStoreLattice)("default", "assistant").store;
4891
4892
  const agents = [];
4892
4893
  for (const assistantId of agentGrant?.items ?? []) {
4893
4894
  const assistant = await assistantStore.getAssistantById(
@@ -4922,11 +4923,11 @@ function registerOpenExposureRoutes(app2, deps = {}) {
4922
4923
  }
4923
4924
  );
4924
4925
  }
4925
- var import_core90, import_protocols38;
4926
+ var import_core92, import_protocols38;
4926
4927
  var init_open_exposure = __esm({
4927
4928
  "src/routes/open-exposure.ts"() {
4928
4929
  "use strict";
4929
- import_core90 = require("@axiom-lattice/core");
4930
+ import_core92 = require("@axiom-lattice/core");
4930
4931
  import_protocols38 = require("@axiom-lattice/protocols");
4931
4932
  init_openLattice();
4932
4933
  init_tenantOpenPlugins();
@@ -5046,7 +5047,7 @@ function createAgentProvider(deps = {}) {
5046
5047
  } catch {
5047
5048
  }
5048
5049
  }
5049
- const agent = import_core91.agentInstanceManager.getAgent({
5050
+ const agent = import_core93.agentInstanceManager.getAgent({
5050
5051
  tenant_id: ctx.tenantId,
5051
5052
  assistant_id: assistantId,
5052
5053
  thread_id: threadId,
@@ -5071,12 +5072,12 @@ function createAgentProvider(deps = {}) {
5071
5072
  }
5072
5073
  };
5073
5074
  }
5074
- var import_zod23, import_core91, import_protocols39, STOP_TYPES;
5075
+ var import_zod23, import_core93, import_protocols39, STOP_TYPES;
5075
5076
  var init_agentProvider = __esm({
5076
5077
  "src/services/open/providers/agentProvider.ts"() {
5077
5078
  "use strict";
5078
5079
  import_zod23 = require("zod");
5079
- import_core91 = require("@axiom-lattice/core");
5080
+ import_core93 = require("@axiom-lattice/core");
5080
5081
  import_protocols39 = require("@axiom-lattice/protocols");
5081
5082
  STOP_TYPES = [import_protocols39.MessageChunkTypes.MESSAGE_COMPLETED];
5082
5083
  }
@@ -5179,11 +5180,11 @@ async function resolveAgentOpenGrants(tenantId, assistantId, deps) {
5179
5180
  }
5180
5181
  }
5181
5182
  function createDefaultAgentReflectionDeps(tenantId) {
5182
- (0, import_core92.ensureBuiltinAgentsForTenant)(tenantId);
5183
+ (0, import_core94.ensureBuiltinAgentsForTenant)(tenantId);
5183
5184
  return {
5184
- ensure: (t2) => import_core92.agentLatticeManager.initializeStoredAssistantsForTenant(t2),
5185
+ ensure: (t2) => import_core94.agentLatticeManager.initializeStoredAssistantsForTenant(t2),
5185
5186
  getAgentConfig: (t2, assistantId) => {
5186
- const config = import_core92.agentLatticeManager.getAgentConfigWithTenant(t2, assistantId);
5187
+ const config = import_core94.agentLatticeManager.getAgentConfigWithTenant(t2, assistantId);
5187
5188
  if (!config) return void 0;
5188
5189
  return {
5189
5190
  middleware: extractMiddleware(config),
@@ -5191,16 +5192,16 @@ function createDefaultAgentReflectionDeps(tenantId) {
5191
5192
  };
5192
5193
  },
5193
5194
  getAssistantMiddleware: async (t2, assistantId) => {
5194
- const store2 = (0, import_core92.getStoreLattice)("default", "assistant").store;
5195
+ const store2 = (0, import_core94.getStoreLattice)("default", "assistant").store;
5195
5196
  const assistant = await store2.getAssistantById(t2, assistantId);
5196
5197
  return extractMiddleware(assistant?.graphDefinition);
5197
5198
  },
5198
5199
  exposedActionsByType: (type) => {
5199
- const plugin = import_core92.PluginRegistry.get(type);
5200
+ const plugin = import_core94.PluginRegistry.get(type);
5200
5201
  return plugin ? normalizeOpenExpose(plugin.meta.openExpose) : [];
5201
5202
  },
5202
5203
  resolvableAssistants: async (t2) => new Set(
5203
- import_core92.agentLatticeManager.getAllAgentLatticesByTenant(t2).map((lattice) => lattice.config.key)
5204
+ import_core94.agentLatticeManager.getAllAgentLatticesByTenant(t2).map((lattice) => lattice.config.key)
5204
5205
  )
5205
5206
  };
5206
5207
  }
@@ -5265,30 +5266,30 @@ function buildTenantExposedGrants(manifests) {
5265
5266
  }
5266
5267
  function createDefaultPluginReflectionDeps() {
5267
5268
  return {
5268
- ensure: (tenantId) => import_core92.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
5269
+ ensure: (tenantId) => import_core94.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
5269
5270
  globalExposedDomains: () => {
5270
5271
  const grants = [];
5271
- for (const type of import_core92.PluginRegistry.list()) {
5272
- const plugin = import_core92.PluginRegistry.get(type);
5272
+ for (const type of import_core94.PluginRegistry.list()) {
5273
+ const plugin = import_core94.PluginRegistry.get(type);
5273
5274
  const items = normalizeOpenExpose(plugin?.meta.openExpose);
5274
5275
  if (items.length > 0) grants.push({ domain: type, items });
5275
5276
  }
5276
5277
  return grants;
5277
5278
  },
5278
5279
  tenantExposedDomains: async (tenantId) => {
5279
- const { manifests } = await (0, import_core92.getSandboxPluginCatalog)().ensureLoaded(tenantId);
5280
+ const { manifests } = await (0, import_core94.getSandboxPluginCatalog)().ensureLoaded(tenantId);
5280
5281
  return buildTenantExposedGrants(Object.values(manifests));
5281
5282
  },
5282
5283
  resolvableAssistants: async (tenantId) => new Set(
5283
- import_core92.agentLatticeManager.getAllAgentLatticesByTenant(tenantId).map((lattice) => lattice.config.key)
5284
+ import_core94.agentLatticeManager.getAllAgentLatticesByTenant(tenantId).map((lattice) => lattice.config.key)
5284
5285
  )
5285
5286
  };
5286
5287
  }
5287
- var import_core92, AGENT_REFLECTION_CACHE_TTL_MS, cache, PLUGIN_REFLECTION_CACHE_TTL_MS, pluginCache;
5288
+ var import_core94, AGENT_REFLECTION_CACHE_TTL_MS, cache, PLUGIN_REFLECTION_CACHE_TTL_MS, pluginCache;
5288
5289
  var init_sandboxOpenReflection = __esm({
5289
5290
  "src/services/open/sandboxOpenReflection.ts"() {
5290
5291
  "use strict";
5291
- import_core92 = require("@axiom-lattice/core");
5292
+ import_core94 = require("@axiom-lattice/core");
5292
5293
  AGENT_REFLECTION_CACHE_TTL_MS = 6e4;
5293
5294
  cache = /* @__PURE__ */ new Map();
5294
5295
  PLUGIN_REFLECTION_CACHE_TTL_MS = 6e4;
@@ -5334,7 +5335,7 @@ function createSandboxOpenCredentialProvider(options) {
5334
5335
  };
5335
5336
  }
5336
5337
  function registerGatewaySandboxOpenCredentialProvider(onError) {
5337
- return (0, import_core93.registerSandboxOpenCredentialProvider)(
5338
+ return (0, import_core95.registerSandboxOpenCredentialProvider)(
5338
5339
  createSandboxOpenCredentialProvider({
5339
5340
  gatewayUrl: process.env.PUBLIC_GATEWAY_URL?.trim() || void 0,
5340
5341
  onError
@@ -5342,11 +5343,11 @@ function registerGatewaySandboxOpenCredentialProvider(onError) {
5342
5343
  { onError }
5343
5344
  );
5344
5345
  }
5345
- var import_core93, DEFAULT_SANDBOX_OPEN_GRANTS, MAX_SANDBOX_OPEN_DEPTH;
5346
+ var import_core95, DEFAULT_SANDBOX_OPEN_GRANTS, MAX_SANDBOX_OPEN_DEPTH;
5346
5347
  var init_sandboxOpenCredentialProvider = __esm({
5347
5348
  "src/services/open/sandboxOpenCredentialProvider.ts"() {
5348
5349
  "use strict";
5349
- import_core93 = require("@axiom-lattice/core");
5350
+ import_core95 = require("@axiom-lattice/core");
5350
5351
  init_openToken();
5351
5352
  init_sandboxOpenReflection();
5352
5353
  DEFAULT_SANDBOX_OPEN_GRANTS = [
@@ -5383,12 +5384,12 @@ var resources_exports = {};
5383
5384
  __export(resources_exports, {
5384
5385
  ResourceController: () => ResourceController
5385
5386
  });
5386
- var import_bcryptjs, import_core94, ResourceController;
5387
+ var import_bcryptjs, import_core96, ResourceController;
5387
5388
  var init_resources = __esm({
5388
5389
  "src/controllers/resources.ts"() {
5389
5390
  "use strict";
5390
5391
  import_bcryptjs = __toESM(require("bcryptjs"));
5391
- import_core94 = require("@axiom-lattice/core");
5392
+ import_core96 = require("@axiom-lattice/core");
5392
5393
  init_mime();
5393
5394
  init_http_range();
5394
5395
  init_sandboxGrants();
@@ -5405,14 +5406,14 @@ var init_resources = __esm({
5405
5406
  if (!workspaceId || !projectId) {
5406
5407
  return reply.status(400).send({ error: "x-workspace-id and x-project-id headers required" });
5407
5408
  }
5408
- const payload = (0, import_core94.createSharePayload)(
5409
+ const payload = (0, import_core96.createSharePayload)(
5409
5410
  tenantId,
5410
5411
  workspaceId,
5411
5412
  projectId,
5412
5413
  userId,
5413
5414
  body
5414
5415
  );
5415
- const token = (0, import_core94.generateToken)();
5416
+ const token = (0, import_core96.generateToken)();
5416
5417
  try {
5417
5418
  await this.deps.store.create({ ...payload, token });
5418
5419
  this.deps.logger.info(
@@ -5564,7 +5565,7 @@ var init_resources = __esm({
5564
5565
  resourcePath: subPath
5565
5566
  }, subPath, ext, request, reply);
5566
5567
  }
5567
- const volume = (0, import_core94.buildNamedVolumeName)("p", "project", tenantId, workspaceId, projectId);
5568
+ const volume = (0, import_core96.buildNamedVolumeName)("p", "project", tenantId, workspaceId, projectId);
5568
5569
  return this._resolveAndServe(
5569
5570
  volume,
5570
5571
  subPath,
@@ -14013,7 +14014,7 @@ function registerMcpServerConfigRoutes(app2) {
14013
14014
 
14014
14015
  // src/routes/mcp-apps.ts
14015
14016
  var import_protocols6 = require("@axiom-lattice/protocols");
14016
- var import_core35 = require("@axiom-lattice/core");
14017
+ var import_core36 = require("@axiom-lattice/core");
14017
14018
 
14018
14019
  // src/services/mcp-ui/UiResourceResolver.ts
14019
14020
  var import_node_crypto5 = require("crypto");
@@ -14388,26 +14389,26 @@ function createDefaultPluginBackend() {
14388
14389
  return {
14389
14390
  resolvePlugin: (tenantId, type) => resolveTenantPluginByType(tenantId, type),
14390
14391
  catalog: {
14391
- readPluginFile: (tenantId, pluginType, relPath) => (0, import_core35.getSandboxPluginCatalog)().readPluginFile(tenantId, pluginType, relPath),
14392
- getValidatedManifest: (tenantId, pluginType) => (0, import_core35.getSandboxPluginCatalog)().getValidatedManifest(tenantId, pluginType),
14393
- getExecutor: () => (0, import_core35.getSandboxPluginCatalog)().getExecutor()
14392
+ readPluginFile: (tenantId, pluginType, relPath) => (0, import_core36.getSandboxPluginCatalog)().readPluginFile(tenantId, pluginType, relPath),
14393
+ getValidatedManifest: (tenantId, pluginType) => (0, import_core36.getSandboxPluginCatalog)().getValidatedManifest(tenantId, pluginType),
14394
+ getExecutor: () => (0, import_core36.getSandboxPluginCatalog)().getExecutor()
14394
14395
  }
14395
14396
  };
14396
14397
  }
14397
14398
  function resolveMcpAppDeps(pluginBackend = createDefaultPluginBackend()) {
14398
14399
  const uiResourceResolver = new UiResourceResolver({
14399
14400
  store: new InMemoryMcpUiResourceCacheStore(),
14400
- fetchMcp: (tenantId, serverKey, resourceUri) => import_core35.mcpManager.readUiResource(tenantId, serverKey, resourceUri),
14401
+ fetchMcp: (tenantId, serverKey, resourceUri) => import_core36.mcpManager.readUiResource(tenantId, serverKey, resourceUri),
14401
14402
  fetchPlugin: (tenantId, pluginType, resource) => fetchPluginUiResource(pluginBackend, tenantId, pluginType, resource)
14402
14403
  });
14403
14404
  return {
14404
14405
  resolveUiResource: (tenantId, ref) => uiResourceResolver.resolve(tenantId, ref),
14405
- 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),
14406
+ callTool: (tenantId, ref, name, args, context) => ref.kind === "mcp" ? import_core36.mcpManager.callServerTool(tenantId, ref.serverKey, name, args) : callPluginTool(pluginBackend, tenantId, ref, name, args, context),
14406
14407
  // Plugin refs reach these only after `tools/call`; the handler treats the
14407
14408
  // rejection as an unsupported method (403). The branches are live because
14408
14409
  // the pure handler deliberately delegates method policy to the deps.
14409
- readResource: (tenantId, ref, uri) => ref.kind === "mcp" ? import_core35.mcpManager.readServerResource(tenantId, ref.serverKey, uri) : Promise.reject(new PluginMethodNotSupportedError("resources/read")),
14410
- listTools: (tenantId, ref) => ref.kind === "mcp" ? import_core35.mcpManager.getAvailableTools(tenantId, ref.serverKey) : Promise.reject(new PluginMethodNotSupportedError("tools/list"))
14410
+ readResource: (tenantId, ref, uri) => ref.kind === "mcp" ? import_core36.mcpManager.readServerResource(tenantId, ref.serverKey, uri) : Promise.reject(new PluginMethodNotSupportedError("resources/read")),
14411
+ listTools: (tenantId, ref) => ref.kind === "mcp" ? import_core36.mcpManager.getAvailableTools(tenantId, ref.serverKey) : Promise.reject(new PluginMethodNotSupportedError("tools/list"))
14411
14412
  };
14412
14413
  }
14413
14414
  function firstHeader(request, name) {
@@ -14451,12 +14452,12 @@ function registerMcpAppRoutes(fastify2) {
14451
14452
  }
14452
14453
 
14453
14454
  // src/controllers/eval.ts
14454
- var import_core37 = require("@axiom-lattice/core");
14455
+ var import_core38 = require("@axiom-lattice/core");
14455
14456
  var import_uuid5 = require("uuid");
14456
14457
 
14457
14458
  // src/services/eval-runner.ts
14458
14459
  var import_events = require("events");
14459
- var import_core36 = require("@axiom-lattice/core");
14460
+ var import_core37 = require("@axiom-lattice/core");
14460
14461
  var import_uuid4 = require("uuid");
14461
14462
  var TERMINAL_PERSIST_ATTEMPTS = 2;
14462
14463
  function mapLogs(logs) {
@@ -14566,12 +14567,12 @@ var EvalRunner = class {
14566
14567
  const judgeModelKey = judgeCfg.modelKey || "";
14567
14568
  let resolvedJudgeModelKey;
14568
14569
  if (judgeModelKey) {
14569
- if (!import_core36.modelLatticeManager.hasLattice(judgeModelKey)) {
14570
+ if (!import_core37.modelLatticeManager.hasLattice(judgeModelKey)) {
14570
14571
  throw new Error(`Judge model "${judgeModelKey}" is not registered`);
14571
14572
  }
14572
14573
  resolvedJudgeModelKey = judgeModelKey;
14573
14574
  } else {
14574
- const models = import_core36.modelLatticeManager.getAllLattices();
14575
+ const models = import_core37.modelLatticeManager.getAllLattices();
14575
14576
  const defaultModel = models.find((m) => m.key === "default");
14576
14577
  resolvedJudgeModelKey = defaultModel?.key ?? models[0]?.key ?? "";
14577
14578
  if (!resolvedJudgeModelKey) {
@@ -14679,7 +14680,7 @@ var EvalRunner = class {
14679
14680
  };
14680
14681
  const runPromise = (async () => {
14681
14682
  try {
14682
- const evalProject = new import_core36.LatticeEvalProject(projectConfig, onCaseComplete);
14683
+ const evalProject = new import_core37.LatticeEvalProject(projectConfig, onCaseComplete);
14683
14684
  const calibration = await evalProject.calibrateJudge();
14684
14685
  if (!calibration.ok && !calibration.bypassed) {
14685
14686
  throw new Error(`Judge calibration failed: ${calibration.reason}`);
@@ -14783,7 +14784,7 @@ var EvalRunner = class {
14783
14784
  return ctx !== void 0 && !ctx.terminal.workerSettled && (tenantId === void 0 || ctx.tenantId === tenantId);
14784
14785
  }
14785
14786
  getEvalStore() {
14786
- return (0, import_core36.getStoreLattice)("default", "eval").store;
14787
+ return (0, import_core37.getStoreLattice)("default", "eval").store;
14787
14788
  }
14788
14789
  releaseProjectLease(leaseKey, leaseToken) {
14789
14790
  if (this.projectLeases.get(leaseKey) === leaseToken) this.projectLeases.delete(leaseKey);
@@ -14800,7 +14801,7 @@ function getTenantId12(request) {
14800
14801
  return request.headers["x-tenant-id"] || "default";
14801
14802
  }
14802
14803
  function getEvalStore() {
14803
- return (0, import_core37.getStoreLattice)("default", "eval").store;
14804
+ return (0, import_core38.getStoreLattice)("default", "eval").store;
14804
14805
  }
14805
14806
  async function getOwnedSuite(store2, tenantId, projectId, suiteId) {
14806
14807
  const project = await store2.getProjectById(tenantId, projectId);
@@ -14831,8 +14832,7 @@ async function createProject(request, reply) {
14831
14832
  const judgeCfg = data.judgeModelConfig || {};
14832
14833
  const modelKey2 = judgeCfg.modelKey || "";
14833
14834
  if (modelKey2) {
14834
- const { modelLatticeManager: modelLatticeManager4 } = await import("@axiom-lattice/core");
14835
- if (!modelLatticeManager4.hasLattice(modelKey2)) {
14835
+ if (!import_core38.modelLatticeManager.hasLattice(modelKey2)) {
14836
14836
  return reply.status(400).send({ success: false, message: `Judge model "${modelKey2}" is not registered` });
14837
14837
  }
14838
14838
  }
@@ -14878,8 +14878,7 @@ async function listProjects(request, reply) {
14878
14878
  let projects = await store2.getProjectsByTenant(tenantId);
14879
14879
  if (projects.length === 0) {
14880
14880
  try {
14881
- const { modelLatticeManager: modelLatticeManager4 } = await import("@axiom-lattice/core");
14882
- const models = modelLatticeManager4.getAllLattices();
14881
+ const models = import_core38.modelLatticeManager.getAllLattices();
14883
14882
  const first = models[0];
14884
14883
  const judgeModel = first ? { modelKey: first.key } : {};
14885
14884
  const host = request.hostname || "localhost";
@@ -14947,8 +14946,7 @@ async function updateProject(request, reply) {
14947
14946
  const judgeCfg = body.judgeModelConfig || {};
14948
14947
  const modelKey2 = judgeCfg.modelKey || "";
14949
14948
  if (modelKey2) {
14950
- const { modelLatticeManager: modelLatticeManager4 } = await import("@axiom-lattice/core");
14951
- if (!modelLatticeManager4.hasLattice(modelKey2)) {
14949
+ if (!import_core38.modelLatticeManager.hasLattice(modelKey2)) {
14952
14950
  return reply.status(400).send({ success: false, message: `Judge model "${modelKey2}" is not registered` });
14953
14951
  }
14954
14952
  }
@@ -15330,11 +15328,11 @@ data: ${JSON.stringify(event.data)}
15330
15328
  }
15331
15329
 
15332
15330
  // src/controllers/users.ts
15333
- var import_core38 = require("@axiom-lattice/core");
15331
+ var import_core39 = require("@axiom-lattice/core");
15334
15332
  var import_uuid6 = require("uuid");
15335
15333
  var UsersController = class {
15336
15334
  constructor() {
15337
- this.userStore = (0, import_core38.getStoreLattice)("default", "user").store;
15335
+ this.userStore = (0, import_core39.getStoreLattice)("default", "user").store;
15338
15336
  }
15339
15337
  async listUsers(request, reply) {
15340
15338
  const { email } = request.query;
@@ -15412,11 +15410,11 @@ function registerUserRoutes(app2) {
15412
15410
  }
15413
15411
 
15414
15412
  // src/controllers/tenants.ts
15415
- var import_core39 = require("@axiom-lattice/core");
15413
+ var import_core40 = require("@axiom-lattice/core");
15416
15414
  var import_uuid7 = require("uuid");
15417
15415
  var TenantsController = class {
15418
15416
  constructor() {
15419
- this.tenantStore = (0, import_core39.getStoreLattice)("default", "tenant").store;
15417
+ this.tenantStore = (0, import_core40.getStoreLattice)("default", "tenant").store;
15420
15418
  }
15421
15419
  // ==================== Tenant CRUD ====================
15422
15420
  async listTenants(request, reply) {
@@ -15480,7 +15478,7 @@ function registerTenantRoutes(app2) {
15480
15478
  }
15481
15479
 
15482
15480
  // src/controllers/auth.ts
15483
- var import_core40 = require("@axiom-lattice/core");
15481
+ var import_core41 = require("@axiom-lattice/core");
15484
15482
  var import_uuid8 = require("uuid");
15485
15483
  var import_node_crypto6 = require("crypto");
15486
15484
  var defaultAuthConfig = {
@@ -15490,9 +15488,9 @@ var defaultAuthConfig = {
15490
15488
  };
15491
15489
  var AuthController = class {
15492
15490
  constructor(config = {}) {
15493
- this.userStore = (0, import_core40.getStoreLattice)("default", "user").store;
15494
- this.tenantStore = (0, import_core40.getStoreLattice)("default", "tenant").store;
15495
- this.userTenantLinkStore = (0, import_core40.getStoreLattice)("default", "userTenantLink").store;
15491
+ this.userStore = (0, import_core41.getStoreLattice)("default", "user").store;
15492
+ this.tenantStore = (0, import_core41.getStoreLattice)("default", "tenant").store;
15493
+ this.userTenantLinkStore = (0, import_core41.getStoreLattice)("default", "userTenantLink").store;
15496
15494
  this.config = { ...defaultAuthConfig, ...config };
15497
15495
  }
15498
15496
  async register(request, reply) {
@@ -15651,7 +15649,7 @@ var AuthController = class {
15651
15649
  const linkMeta = link?.metadata || {};
15652
15650
  let personalAssistant = null;
15653
15651
  if (linkMeta.personalAssistantId) {
15654
- const assistantStore = (0, import_core40.getStoreLattice)("default", "assistant").store;
15652
+ const assistantStore = (0, import_core41.getStoreLattice)("default", "assistant").store;
15655
15653
  const exists = await assistantStore.hasAssistant(tenantId, linkMeta.personalAssistantId);
15656
15654
  if (exists) {
15657
15655
  personalAssistant = {
@@ -16348,6 +16346,7 @@ function registerChannelRoutes(app2, dependencies) {
16348
16346
  // src/controllers/channel-installations.ts
16349
16347
  var import_crypto10 = require("crypto");
16350
16348
  var import_protocols7 = require("@axiom-lattice/protocols");
16349
+ var import_core42 = require("@axiom-lattice/core");
16351
16350
  var _adapterRegistry;
16352
16351
  var _router;
16353
16352
  function setChannelControllerDeps(deps) {
@@ -16471,8 +16470,7 @@ function snapshotPlainObject(value) {
16471
16470
  }
16472
16471
  }
16473
16472
  async function getInstallationStore() {
16474
- const { getStoreLattice: getStoreLattice40 } = await import("@axiom-lattice/core");
16475
- const store2 = getStoreLattice40("default", "channelInstallation").store;
16473
+ const store2 = (0, import_core42.getStoreLattice)("default", "channelInstallation").store;
16476
16474
  if (store2) return store2;
16477
16475
  const { PostgreSQLChannelInstallationStore } = await import("@axiom-lattice/pg-stores");
16478
16476
  const databaseUrl = process.env.DATABASE_URL;
@@ -16788,7 +16786,7 @@ function registerChannelInstallationRoutes(app2) {
16788
16786
 
16789
16787
  // src/controllers/channel-bindings.ts
16790
16788
  var import_protocols8 = require("@axiom-lattice/protocols");
16791
- var import_core41 = require("@axiom-lattice/core");
16789
+ var import_core43 = require("@axiom-lattice/core");
16792
16790
  function getTenantId14(request) {
16793
16791
  const userTenantId = request.user?.tenantId;
16794
16792
  if (typeof userTenantId === "string" && userTenantId) return userTenantId;
@@ -16846,7 +16844,7 @@ function snapshotPublicUpdate(value) {
16846
16844
  return body;
16847
16845
  }
16848
16846
  function getInstallationStore2() {
16849
- return (0, import_core41.getStoreLattice)("default", "channelInstallation").store;
16847
+ return (0, import_core43.getStoreLattice)("default", "channelInstallation").store;
16850
16848
  }
16851
16849
  async function isValidPublicInstallation(tenantId, channelInstallationId, channel) {
16852
16850
  const installation = await getInstallationStore2().getInstallationById(channelInstallationId);
@@ -16865,7 +16863,7 @@ async function getBindingList(request, _reply) {
16865
16863
  const tenantId = getTenantId14(request);
16866
16864
  const { channel, agentId, channelInstallationId, limit, offset } = request.query;
16867
16865
  try {
16868
- const registry = (0, import_core41.getBindingRegistry)();
16866
+ const registry = (0, import_core43.getBindingRegistry)();
16869
16867
  const bindings = await registry.list({
16870
16868
  channel,
16871
16869
  agentId,
@@ -16884,7 +16882,7 @@ async function getBindingList(request, _reply) {
16884
16882
  async function getBinding(request, reply) {
16885
16883
  const tenantId = getTenantId14(request);
16886
16884
  try {
16887
- const registry = (0, import_core41.getBindingRegistry)();
16885
+ const registry = (0, import_core43.getBindingRegistry)();
16888
16886
  const binding = await registry.findById(tenantId, request.params.id);
16889
16887
  if (!binding || isInternalBinding(binding)) {
16890
16888
  reply.status(404);
@@ -16906,7 +16904,7 @@ async function createBinding(request, reply) {
16906
16904
  input.channelInstallationId,
16907
16905
  input.channel
16908
16906
  )) return invalidPublicInstallation(reply);
16909
- const registry = (0, import_core41.getBindingRegistry)();
16907
+ const registry = (0, import_core43.getBindingRegistry)();
16910
16908
  const binding = await registry.create({ ...input, tenantId });
16911
16909
  reply.status(201);
16912
16910
  return { success: true, message: "Binding created", data: binding };
@@ -16923,7 +16921,7 @@ async function createBinding(request, reply) {
16923
16921
  async function updateBinding(request, reply) {
16924
16922
  try {
16925
16923
  const tenantId = getTenantId14(request);
16926
- const registry = (0, import_core41.getBindingRegistry)();
16924
+ const registry = (0, import_core43.getBindingRegistry)();
16927
16925
  const existing = await registry.findById(tenantId, request.params.id);
16928
16926
  if (!existing || isInternalBinding(existing)) {
16929
16927
  reply.status(404);
@@ -16950,7 +16948,7 @@ async function updateBinding(request, reply) {
16950
16948
  async function deleteBinding(request, reply) {
16951
16949
  try {
16952
16950
  const tenantId = getTenantId14(request);
16953
- const registry = (0, import_core41.getBindingRegistry)();
16951
+ const registry = (0, import_core43.getBindingRegistry)();
16954
16952
  const existing = await registry.findById(tenantId, request.params.id);
16955
16953
  if (!existing || isInternalBinding(existing)) {
16956
16954
  reply.status(404);
@@ -16972,7 +16970,7 @@ async function resolveBinding(request, _reply) {
16972
16970
  return { success: false, message: "No binding found", data: null };
16973
16971
  }
16974
16972
  try {
16975
- const registry = (0, import_core41.getBindingRegistry)();
16973
+ const registry = (0, import_core43.getBindingRegistry)();
16976
16974
  const binding = await registry.resolve({ channel, senderId, channelInstallationId, tenantId });
16977
16975
  if (!binding) {
16978
16976
  return { success: false, message: "No binding found", data: null };
@@ -16995,7 +16993,7 @@ function registerChannelBindingRoutes(app2) {
16995
16993
  }
16996
16994
 
16997
16995
  // src/controllers/menu-items.ts
16998
- var import_core42 = require("@axiom-lattice/core");
16996
+ var import_core44 = require("@axiom-lattice/core");
16999
16997
  function getTenantId15(request) {
17000
16998
  const userTenantId = request.user?.tenantId;
17001
16999
  if (userTenantId) return userTenantId;
@@ -17007,7 +17005,7 @@ function errorMessage(err) {
17007
17005
  async function getMenuItemList(request, _reply) {
17008
17006
  const tenantId = getTenantId15(request);
17009
17007
  try {
17010
- const registry = (0, import_core42.getMenuRegistry)();
17008
+ const registry = (0, import_core44.getMenuRegistry)();
17011
17009
  const items = await registry.list({ tenantId, menuTarget: request.query.menuTarget });
17012
17010
  return { success: true, message: "Menu items retrieved", data: { records: items, total: items.length } };
17013
17011
  } catch (error) {
@@ -17019,7 +17017,7 @@ async function getMenuItemList(request, _reply) {
17019
17017
  async function getMenuItem(request, reply) {
17020
17018
  const tenantId = getTenantId15(request);
17021
17019
  try {
17022
- const registry = (0, import_core42.getMenuRegistry)();
17020
+ const registry = (0, import_core44.getMenuRegistry)();
17023
17021
  const item = await registry.getById(request.params.id);
17024
17022
  if (!item || item.tenantId !== tenantId) {
17025
17023
  reply.status(404);
@@ -17036,7 +17034,7 @@ async function getMenuItem(request, reply) {
17036
17034
  async function createMenuItem(request, reply) {
17037
17035
  const tenantId = getTenantId15(request);
17038
17036
  try {
17039
- const registry = (0, import_core42.getMenuRegistry)();
17037
+ const registry = (0, import_core44.getMenuRegistry)();
17040
17038
  const item = await registry.create({ ...request.body, tenantId });
17041
17039
  reply.status(201);
17042
17040
  return { success: true, message: "Menu item created", data: item };
@@ -17050,7 +17048,7 @@ async function createMenuItem(request, reply) {
17050
17048
  async function updateMenuItem(request, reply) {
17051
17049
  try {
17052
17050
  const tenantId = getTenantId15(request);
17053
- const registry = (0, import_core42.getMenuRegistry)();
17051
+ const registry = (0, import_core44.getMenuRegistry)();
17054
17052
  const existing = await registry.getById(request.params.id);
17055
17053
  if (!existing || existing.tenantId !== tenantId) {
17056
17054
  reply.status(404);
@@ -17068,7 +17066,7 @@ async function updateMenuItem(request, reply) {
17068
17066
  async function deleteMenuItem(request, reply) {
17069
17067
  try {
17070
17068
  const tenantId = getTenantId15(request);
17071
- const registry = (0, import_core42.getMenuRegistry)();
17069
+ const registry = (0, import_core44.getMenuRegistry)();
17072
17070
  const existing = await registry.getById(request.params.id);
17073
17071
  if (!existing || existing.tenantId !== tenantId) {
17074
17072
  reply.status(404);
@@ -17268,7 +17266,7 @@ function registerA2ABridgeRoutes(app2) {
17268
17266
  }
17269
17267
 
17270
17268
  // src/routes/stt.ts
17271
- var import_core43 = require("@axiom-lattice/core");
17269
+ var import_core45 = require("@axiom-lattice/core");
17272
17270
  var ALLOWED_AUDIO_FORMATS = /* @__PURE__ */ new Set([
17273
17271
  "webm",
17274
17272
  "wav",
@@ -17281,7 +17279,7 @@ var ALLOWED_AUDIO_FORMATS = /* @__PURE__ */ new Set([
17281
17279
  var MAX_AUDIO_FILE_SIZE = 25 * 1024 * 1024;
17282
17280
  var registerSTTRoutes = (app2) => {
17283
17281
  app2.get("/api/stt/models", async (_request, reply) => {
17284
- const models = import_core43.sttModelLatticeManager.getAllSTTModelInfo();
17282
+ const models = import_core45.sttModelLatticeManager.getAllSTTModelInfo();
17285
17283
  return reply.send({ models });
17286
17284
  });
17287
17285
  app2.post(
@@ -17324,7 +17322,7 @@ var registerSTTRoutes = (app2) => {
17324
17322
  try {
17325
17323
  let client;
17326
17324
  try {
17327
- client = (0, import_core43.getSTTClient)(modelKey2);
17325
+ client = (0, import_core45.getSTTClient)(modelKey2);
17328
17326
  } catch {
17329
17327
  return reply.status(404).send({ error: `STT model "${modelKey2}" not found` });
17330
17328
  }
@@ -17346,7 +17344,7 @@ var registerSTTRoutes = (app2) => {
17346
17344
  };
17347
17345
 
17348
17346
  // src/controllers/local-a2a.ts
17349
- var import_core44 = require("@axiom-lattice/core");
17347
+ var import_core46 = require("@axiom-lattice/core");
17350
17348
  var import_protocols9 = require("@axiom-lattice/protocols");
17351
17349
  function getTenantId16(request) {
17352
17350
  const userTenantId = request.user?.tenantId;
@@ -17360,7 +17358,7 @@ function getLocalRuntime(assistant) {
17360
17358
  return graphDefinition.localRuntime;
17361
17359
  }
17362
17360
  async function getLocalA2AAssistants(tenantId) {
17363
- const storeLattice = (0, import_core44.getStoreLattice)("default", "assistant");
17361
+ const storeLattice = (0, import_core46.getStoreLattice)("default", "assistant");
17364
17362
  const assistants = await storeLattice.store.getAllAssistants(tenantId);
17365
17363
  const results = [];
17366
17364
  for (const assistant of assistants) {
@@ -17372,7 +17370,7 @@ async function getLocalA2AAssistants(tenantId) {
17372
17370
  return results;
17373
17371
  }
17374
17372
  async function getLocalA2AAssistant(tenantId, assistantId) {
17375
- const storeLattice = (0, import_core44.getStoreLattice)("default", "assistant");
17373
+ const storeLattice = (0, import_core46.getStoreLattice)("default", "assistant");
17376
17374
  const assistant = await storeLattice.store.getAssistantById(tenantId, assistantId);
17377
17375
  if (!assistant) return null;
17378
17376
  const runtime = getLocalRuntime(assistant);
@@ -17614,11 +17612,11 @@ function registerTaskRoutes(app2, controller) {
17614
17612
  }
17615
17613
 
17616
17614
  // src/routes/index.ts
17617
- var import_core55 = require("@axiom-lattice/core");
17615
+ var import_core57 = require("@axiom-lattice/core");
17618
17616
 
17619
17617
  // src/controllers/tasks.ts
17620
17618
  var import_protocols13 = require("@axiom-lattice/protocols");
17621
- var import_core46 = require("@axiom-lattice/core");
17619
+ var import_core48 = require("@axiom-lattice/core");
17622
17620
 
17623
17621
  // src/services/collaboration/ProjectTaskThreadService.ts
17624
17622
  var import_protocols11 = require("@axiom-lattice/protocols");
@@ -17938,7 +17936,7 @@ var import_node_crypto9 = require("crypto");
17938
17936
 
17939
17937
  // src/services/collaboration/ProjectTaskExecutionService.ts
17940
17938
  var import_node_crypto8 = require("crypto");
17941
- var import_core45 = require("@axiom-lattice/core");
17939
+ var import_core47 = require("@axiom-lattice/core");
17942
17940
  var import_protocols12 = require("@axiom-lattice/protocols");
17943
17941
  init_projectTaskScope();
17944
17942
 
@@ -18002,7 +18000,7 @@ var ProjectTaskExecutionService = class {
18002
18000
  if (!Number.isFinite(options.lifecycleSettlementTimeoutMs) || options.lifecycleSettlementTimeoutMs <= 0) {
18003
18001
  throw new Error("Project task lifecycle settlement timeout must be positive");
18004
18002
  }
18005
- this.runBridge = (0, import_core45.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
18003
+ this.runBridge = (0, import_core47.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
18006
18004
  }
18007
18005
  /** Validates, atomically starts, dispatches, and settles a pending Project Task. */
18008
18006
  async start(input, signal) {
@@ -18052,10 +18050,10 @@ var ProjectTaskExecutionService = class {
18052
18050
  return { kind: "ready", task: current, thread: ensured.thread, rosterExempt: validated.rosterExempt };
18053
18051
  }
18054
18052
  /** Resumes an interrupted Project Task on its canonical existing Thread. */
18055
- async resume(input, signal) {
18053
+ async resume(input, signal, options) {
18056
18054
  const prepared = await this.prepareResume(input, signal);
18057
18055
  if (prepared.kind === "aborted") return prepared.outcome;
18058
- return this.dispatchRun(prepared.task, prepared.thread, "resume", prepared.rosterExempt, signal);
18056
+ return this.dispatchRun(prepared.task, prepared.thread, "resume", prepared.rosterExempt, signal, options);
18059
18057
  }
18060
18058
  /** Clears the durable interruption and loads the exact resumed task. */
18061
18059
  async prepareResume(input, signal) {
@@ -18088,6 +18086,7 @@ var ProjectTaskExecutionService = class {
18088
18086
  *
18089
18087
  * @param input Tenant, task identity, and optional command actor.
18090
18088
  * @param signal Optional cancellation signal for the armed settlement.
18089
+ * @param options Optional resume command carried into the queued run message.
18091
18090
  * @returns The settled run outcome.
18092
18091
  * @remarks `start` semantics: make this task run. `pending` starts,
18093
18092
  * `interrupted` resumes, `failed` retries, and `completed`/`cancelled`
@@ -18095,14 +18094,15 @@ var ProjectTaskExecutionService = class {
18095
18094
  * conflict. This is a record transition plus an application-layer side
18096
18095
  * effect; the kernel only records the status change. `actor` attributes the
18097
18096
  * start/resume/retry/reopen transition and defaults to the system actor.
18097
+ * `options.command` is only carried on an interrupted-task resume.
18098
18098
  */
18099
- async dispatch(input, signal) {
18099
+ async dispatch(input, signal, options) {
18100
18100
  const task = await this.requireTask(input);
18101
18101
  if (task.ownerType !== "agent") {
18102
18102
  throw new ProjectTaskExecutionError("PROJECT_TASK_NOT_READY", "Project task is not agent-owned");
18103
18103
  }
18104
18104
  if (task.status === "pending") return this.start(input, signal);
18105
- if (task.status === "interrupted") return this.resume(input, signal);
18105
+ if (task.status === "interrupted") return this.resume(input, signal, options);
18106
18106
  if (task.status === "failed" || task.status === "completed" || task.status === "cancelled") {
18107
18107
  return this.dispatchRestartable(task, input.actor ?? SYSTEM_ACTOR, signal);
18108
18108
  }
@@ -18113,6 +18113,7 @@ var ProjectTaskExecutionService = class {
18113
18113
  *
18114
18114
  * @param input Tenant, task identity, and optional command actor.
18115
18115
  * @param signal Optional cancellation signal for the pre-run transition.
18116
+ * @param options Optional resume command carried into the queued run message.
18116
18117
  * @returns The `in_progress` task snapshot and whether the run was queued.
18117
18118
  * @remarks Intended for command HTTP handlers that must release the Project
18118
18119
  * mutation mutex immediately: the armed settlement keeps running in the
@@ -18120,20 +18121,25 @@ var ProjectTaskExecutionService = class {
18120
18121
  * awaits it. Enqueue failure converges the task exactly like the awaited
18121
18122
  * path before throwing, so no phantom run is left behind.
18122
18123
  */
18123
- async dispatchDetached(input, signal) {
18124
+ async dispatchDetached(input, signal, options) {
18124
18125
  const task = await this.requireTask(input);
18126
+ if (options?.expectedStatus !== void 0 && task.status !== options.expectedStatus) {
18127
+ throw new ProjectTaskExecutionError("PROJECT_TASK_NOT_RESUMABLE", "Project task is not in the expected status");
18128
+ }
18125
18129
  if (task.ownerType !== "agent") {
18126
18130
  throw new ProjectTaskExecutionError("PROJECT_TASK_NOT_READY", "Project task is not agent-owned");
18127
18131
  }
18128
18132
  const actor3 = input.actor ?? SYSTEM_ACTOR;
18129
18133
  let prepared;
18130
18134
  let mode;
18135
+ let resumeOptions;
18131
18136
  if (task.status === "pending") {
18132
18137
  prepared = await this.prepareStart(input, signal);
18133
18138
  mode = "start";
18134
18139
  } else if (task.status === "interrupted") {
18135
18140
  prepared = await this.prepareResume(input, signal);
18136
18141
  mode = "resume";
18142
+ resumeOptions = options;
18137
18143
  } else if (task.status === "failed" || task.status === "completed" || task.status === "cancelled") {
18138
18144
  prepared = await this.prepareRestartable(task, actor3, signal);
18139
18145
  mode = "resume";
@@ -18141,7 +18147,7 @@ var ProjectTaskExecutionService = class {
18141
18147
  throw new ProjectTaskExecutionError("PROJECT_TASK_NOT_READY", `Project task is '${task.status}'`);
18142
18148
  }
18143
18149
  if (prepared.kind === "aborted") return { task: prepared.outcome.task, queued: false };
18144
- return this.enqueueDetached(prepared.task, prepared.thread, mode, prepared.rosterExempt);
18150
+ return this.enqueueDetached(prepared.task, prepared.thread, mode, prepared.rosterExempt, resumeOptions);
18145
18151
  }
18146
18152
  /** Recovers one exact pending or processing queue row without dispatching a duplicate input. */
18147
18153
  async recover(input, signal) {
@@ -18197,15 +18203,15 @@ var ProjectTaskExecutionService = class {
18197
18203
  settlement.cleanup();
18198
18204
  return { kind: "deferred", task: input.task, thread: input.thread, messageId: input.inputMessageId };
18199
18205
  }
18200
- if (resumed.status === import_core45.ThreadStatus.INTERRUPTED && settlement.tryClaim()) {
18206
+ if (resumed.status === import_core47.ThreadStatus.INTERRUPTED && settlement.tryClaim()) {
18201
18207
  settlement.cleanup();
18202
18208
  const outcome2 = await this.settleInterruptedEvent(input.task, input.thread, input.inputMessageId);
18203
18209
  settlement.resolve(outcome2);
18204
18210
  return outcome2;
18205
18211
  }
18206
- if ((resumed.status === import_core45.ThreadStatus.IDLE || resumed.status === import_core45.ThreadStatus.ERROR) && settlement.tryClaim()) {
18212
+ if ((resumed.status === import_core47.ThreadStatus.IDLE || resumed.status === import_core47.ThreadStatus.ERROR) && settlement.tryClaim()) {
18207
18213
  settlement.cleanup();
18208
- const reason = resumed.status === import_core45.ThreadStatus.IDLE ? "Project task execution ended without lifecycle transition" : "Recovered Agent execution is in error state";
18214
+ const reason = resumed.status === import_core47.ThreadStatus.IDLE ? "Project task execution ended without lifecycle transition" : "Recovered Agent execution is in error state";
18209
18215
  const outcome2 = await this.settleEndedRecovery(input, reason);
18210
18216
  settlement.resolve(outcome2);
18211
18217
  return outcome2;
@@ -18386,10 +18392,10 @@ var ProjectTaskExecutionService = class {
18386
18392
  }
18387
18393
  return current;
18388
18394
  }
18389
- async dispatchRun(task, thread, mode, rosterExempt, signal) {
18395
+ async dispatchRun(task, thread, mode, rosterExempt, signal, options) {
18390
18396
  const messageId = (this.options.idFactory ?? import_node_crypto8.randomUUID)();
18391
18397
  if (signal?.aborted) return this.compensateCancellation(task, thread, messageId, false);
18392
- const armed = await this.armAndEnqueue(task, thread, mode, messageId, rosterExempt, signal);
18398
+ const armed = await this.armAndEnqueue(task, thread, mode, messageId, rosterExempt, signal, options);
18393
18399
  if (armed.cancelled) return this.cancelSettlement(armed.settlement, task, thread, messageId, false);
18394
18400
  if (signal?.aborted) return this.cancelSettlement(armed.settlement, task, thread, messageId, armed.queued);
18395
18401
  if (!armed.queued) {
@@ -18404,7 +18410,7 @@ var ProjectTaskExecutionService = class {
18404
18410
  * enqueue yields `queued: false` with a stable reason; the caller decides
18405
18411
  * whether to converge only (awaited path) or converge and throw (detached).
18406
18412
  */
18407
- async armAndEnqueue(task, thread, mode, messageId, rosterExempt, signal) {
18413
+ async armAndEnqueue(task, thread, mode, messageId, rosterExempt, signal, options) {
18408
18414
  const settlement = this.armSettlement(task, thread, messageId);
18409
18415
  if (signal?.aborted) return { settlement, queued: false, error: "", cancelled: true };
18410
18416
  try {
@@ -18414,7 +18420,10 @@ var ProjectTaskExecutionService = class {
18414
18420
  project_id: task.projectId,
18415
18421
  assistant_id: task.ownerId,
18416
18422
  thread_id: thread.id
18417
- }, { input: { id: messageId, message: buildTaskPrompt(task, mode) } }, {
18423
+ }, {
18424
+ input: { id: messageId, message: buildTaskPrompt(task, mode) },
18425
+ ...mode === "resume" && options?.command ? { command: options.command } : {}
18426
+ }, {
18418
18427
  executionMode: "followup",
18419
18428
  trustedRunContext: { projectTask: buildTrustedTaskContext(task, thread, messageId, rosterExempt) }
18420
18429
  });
@@ -18440,9 +18449,9 @@ var ProjectTaskExecutionService = class {
18440
18449
  * task is converged exactly like the awaited path before throwing, so no
18441
18450
  * phantom in-progress run is left behind.
18442
18451
  */
18443
- async enqueueDetached(task, thread, mode, rosterExempt) {
18452
+ async enqueueDetached(task, thread, mode, rosterExempt, options) {
18444
18453
  const messageId = (this.options.idFactory ?? import_node_crypto8.randomUUID)();
18445
- const armed = await this.armAndEnqueue(task, thread, mode, messageId, rosterExempt);
18454
+ const armed = await this.armAndEnqueue(task, thread, mode, messageId, rosterExempt, void 0, options);
18446
18455
  void armed.settlement.promise.catch(() => void 0);
18447
18456
  if (!armed.queued) {
18448
18457
  await this.claimDispatchFailure(armed.settlement, task, thread, messageId, armed.error);
@@ -18573,12 +18582,14 @@ var ProjectTaskExecutionService = class {
18573
18582
  async settleInterruptedEvent(task, thread, messageId, state) {
18574
18583
  const current = await this.withLifecycleTimeout(this.reloadTask(task), void 0);
18575
18584
  if (current?.status === "interrupted" && this.matchesExecution(current, task, thread)) {
18585
+ this.emitInterrupted(current, thread, messageId, state);
18576
18586
  return { kind: "interrupted", task: current, thread, messageId };
18577
18587
  }
18578
18588
  const clarify = readClarifyInterrupt(state ?? await this.readInterruptedThreadState(task, thread));
18579
18589
  if (clarify !== void 0) {
18580
18590
  const interrupted = await this.interruptForClarify(current ?? task, thread, clarify);
18581
18591
  if (interrupted?.status === "interrupted" && this.matchesExecution(interrupted, task, thread)) {
18592
+ this.emitInterrupted(interrupted, thread, messageId, state);
18582
18593
  return { kind: "interrupted", task: interrupted, thread, messageId };
18583
18594
  }
18584
18595
  }
@@ -18590,6 +18601,22 @@ var ProjectTaskExecutionService = class {
18590
18601
  "interruption_not_durable"
18591
18602
  );
18592
18603
  }
18604
+ /**
18605
+ * Fire-and-forget best-effort projection of a durable interruption.
18606
+ *
18607
+ * @remarks Never awaited and never allowed to affect settlement. The state is
18608
+ * resolved lazily so a missing/undefined event state only triggers a thread
18609
+ * read when the hook is actually wired.
18610
+ */
18611
+ emitInterrupted(task, thread, messageId, state) {
18612
+ const hook = this.deps.onTaskInterrupted;
18613
+ if (!hook) return;
18614
+ void Promise.resolve().then(async () => {
18615
+ const resolved = state ?? await this.readInterruptedThreadState(task, thread);
18616
+ await hook({ task, thread, messageId, state: resolved });
18617
+ }).catch(() => {
18618
+ });
18619
+ }
18593
18620
  /** Reads the paused thread snapshot when no interrupt event payload is available (recovery). */
18594
18621
  async readInterruptedThreadState(task, thread) {
18595
18622
  try {
@@ -19254,7 +19281,7 @@ function withErrors(handler) {
19254
19281
  if (error instanceof HttpTaskError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
19255
19282
  if (error instanceof TaskCommandError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
19256
19283
  if (error instanceof ProjectCollaborationError) return reply.code(error.statusCode).send({ success: false, code: error.code, error: error.message });
19257
- if (error instanceof import_core46.ProjectTaskOwnerPolicyError) return reply.code(403).send({ success: false, code: error.code, error: error.message });
19284
+ if (error instanceof import_core48.ProjectTaskOwnerPolicyError) return reply.code(403).send({ success: false, code: error.code, error: error.message });
19258
19285
  if (error instanceof ProjectTaskThreadError) return reply.code(409).send({ success: false, code: error.code, error: error.message });
19259
19286
  request.log.error({ error }, "Task route failed");
19260
19287
  return reply.code(500).send({ success: false, code: "TASK_INTERNAL_ERROR", error: "Task operation failed" });
@@ -19891,7 +19918,7 @@ var import_zod6 = require("zod");
19891
19918
  // src/services/agent-web-app/AgentWebAppRuntimeService.ts
19892
19919
  var import_node_crypto10 = require("crypto");
19893
19920
  var import_protocols14 = require("@axiom-lattice/protocols");
19894
- var import_core47 = require("@axiom-lattice/core");
19921
+ var import_core49 = require("@axiom-lattice/core");
19895
19922
  init_task_file_refs();
19896
19923
  function isRecord2(value) {
19897
19924
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -20055,12 +20082,12 @@ var AgentWebAppRuntimeService = class {
20055
20082
  const runtime = await this.resolveRuntime(webAppId, selection);
20056
20083
  await this.requireOwnedThread(runtime, userId, threadId);
20057
20084
  if (process.env.AXIOM_REPLICA_ID) {
20058
- const owner = await (0, import_core47.getThreadRunOwner)({
20085
+ const owner = await (0, import_core49.getThreadRunOwner)({
20059
20086
  tenantId: runtime.webApp.tenantId,
20060
20087
  assistantId: runtime.webApp.assistantId,
20061
20088
  threadId
20062
20089
  });
20063
- if (owner && owner !== (0, import_core47.getReplicaId)()) {
20090
+ if (owner && owner !== (0, import_core49.getReplicaId)()) {
20064
20091
  return {
20065
20092
  stream: (async function* () {
20066
20093
  yield (0, import_protocols14.buildAffinityMissChunk)(owner, threadId);
@@ -20413,7 +20440,7 @@ async function verifyWebAppToken(token, issuer, options = {}) {
20413
20440
 
20414
20441
  // src/routes/agent-web-app-runtime.ts
20415
20442
  var import_protocols15 = require("@axiom-lattice/protocols");
20416
- var import_core48 = require("@axiom-lattice/core");
20443
+ var import_core50 = require("@axiom-lattice/core");
20417
20444
  var idSchema = import_zod6.z.string().min(1).max(128);
20418
20445
  var paramsSchema = import_zod6.z.object({ webAppId: idSchema }).strict();
20419
20446
  var threadParamsSchema = import_zod6.z.object({ webAppId: idSchema, threadId: idSchema }).strict();
@@ -20847,7 +20874,7 @@ function registerAgentWebAppRuntimeRoutes(app2, deps) {
20847
20874
  if (!threadId) throw new AgentWebAppRuntimeError("INVALID_REQUEST", 400, "thread_id is required");
20848
20875
  const content = body.messages.map((message) => message.content).join("\n");
20849
20876
  const { messageId } = await deps.service.enqueueMessage(webAppId, identity.userId, threadId, content, { projectId: body.projectId, modelKey: body.modelKey });
20850
- reply.header(import_protocols15.REPLICA_HEADER, (0, import_core48.getReplicaId)());
20877
+ reply.header(import_protocols15.REPLICA_HEADER, (0, import_core50.getReplicaId)());
20851
20878
  for (const [name, value] of Object.entries((0, import_protocols15.affinityEchoHeaders)(request.headers[import_protocols15.AGENT_AFFINITY_HEADER]))) {
20852
20879
  reply.header(name, value);
20853
20880
  }
@@ -20933,7 +20960,7 @@ function beginSse(reply, request) {
20933
20960
  "X-Accel-Buffering": "no",
20934
20961
  "Access-Control-Allow-Origin": "*",
20935
20962
  "Access-Control-Expose-Headers": `${import_protocols15.REPLICA_HEADER}, ${import_protocols15.AFFINITY_ECHO_HEADER}`,
20936
- [import_protocols15.REPLICA_HEADER]: (0, import_core48.getReplicaId)(),
20963
+ [import_protocols15.REPLICA_HEADER]: (0, import_core50.getReplicaId)(),
20937
20964
  ...(0, import_protocols15.affinityEchoHeaders)(request.headers[import_protocols15.AGENT_AFFINITY_HEADER])
20938
20965
  });
20939
20966
  }
@@ -21170,7 +21197,7 @@ var import_zod9 = require("zod");
21170
21197
 
21171
21198
  // src/services/capability/CapabilityBundleService.ts
21172
21199
  var import_zod8 = require("zod");
21173
- var import_core49 = require("@axiom-lattice/core");
21200
+ var import_core51 = require("@axiom-lattice/core");
21174
21201
  var CapabilityBundleServiceError = class extends Error {
21175
21202
  constructor(code, message, statusCode) {
21176
21203
  super(message);
@@ -21211,7 +21238,7 @@ function projectBundleIds(config) {
21211
21238
  return [...value];
21212
21239
  }
21213
21240
  function issue(error) {
21214
- 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 };
21241
+ if (error instanceof import_core51.CapabilityBundleMergeError || error instanceof import_core51.CapabilityBundleValidationError) return { code: error instanceof import_core51.CapabilityBundleValidationError && error.code === "CAPABILITY_BUNDLE_INVALID_CONFIG" ? "INVALID_BUNDLE_CONFIG" : error.code, message: error.message, bundleId: error instanceof import_core51.CapabilityBundleMergeError ? error.bundleId : void 0, capabilityType: error.capabilityType, fieldPath: error.fieldPath };
21215
21242
  return { code: "CAPABILITY_BUNDLE_CONFIGURATION_ERROR", message: error instanceof Error ? error.message : "Invalid capability bundle configuration" };
21216
21243
  }
21217
21244
  var CapabilityBundleService = class {
@@ -21224,7 +21251,7 @@ var CapabilityBundleService = class {
21224
21251
  const errors = [];
21225
21252
  for (const value of values) {
21226
21253
  try {
21227
- (0, import_core49.validateCapabilityBundleInput)(value);
21254
+ (0, import_core51.validateCapabilityBundleInput)(value);
21228
21255
  bundles.push(value);
21229
21256
  } catch {
21230
21257
  errors.push({ bundleId: value.id, code: "INVALID_BUNDLE_CONFIG", message: "Capability bundle record is invalid" });
@@ -21236,7 +21263,7 @@ var CapabilityBundleService = class {
21236
21263
  const value = await this.deps.bundleStore.getById(tenantId, id3);
21237
21264
  if (!value) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
21238
21265
  try {
21239
- (0, import_core49.validateCapabilityBundleInput)(value);
21266
+ (0, import_core51.validateCapabilityBundleInput)(value);
21240
21267
  } catch {
21241
21268
  throw new CapabilityBundleServiceError("INVALID_BUNDLE_CONFIG", "Capability bundle record is invalid", 422);
21242
21269
  }
@@ -21244,7 +21271,7 @@ var CapabilityBundleService = class {
21244
21271
  }
21245
21272
  async create(tenantId, input) {
21246
21273
  rejectStableKey(input);
21247
- (0, import_core49.validateCapabilityBundleInput)(input);
21274
+ (0, import_core51.validateCapabilityBundleInput)(input);
21248
21275
  const value = input;
21249
21276
  const name = value.name.trim();
21250
21277
  const base = slugify(name);
@@ -21255,10 +21282,10 @@ var CapabilityBundleService = class {
21255
21282
  let suffix = 2;
21256
21283
  while (keys2.has(key)) key = `${base}-${suffix++}`;
21257
21284
  const normalized = { ...value, key, name };
21258
- (0, import_core49.validateCapabilityBundleInput)(normalized);
21285
+ (0, import_core51.validateCapabilityBundleInput)(normalized);
21259
21286
  try {
21260
21287
  const result = await this.deps.bundleStore.create(tenantId, normalized);
21261
- (0, import_core49.validateCapabilityBundleInput)(result);
21288
+ (0, import_core51.validateCapabilityBundleInput)(result);
21262
21289
  return result;
21263
21290
  } catch (error) {
21264
21291
  if (!isDuplicate(error)) throw error;
@@ -21269,16 +21296,16 @@ var CapabilityBundleService = class {
21269
21296
  }
21270
21297
  async update(tenantId, id3, input) {
21271
21298
  rejectStableKey(input);
21272
- (0, import_core49.validateCapabilityBundleInput)(input, { partial: true });
21299
+ (0, import_core51.validateCapabilityBundleInput)(input, { partial: true });
21273
21300
  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);
21274
21301
  const value = input;
21275
21302
  const normalized = { ...value, ...value.name === void 0 ? {} : { name: value.name.trim() }, ...Object.prototype.hasOwnProperty.call(value, "description") ? { description: value.description?.trim() || void 0 } : {} };
21276
- (0, import_core49.validateCapabilityBundleInput)(normalized, { partial: true });
21303
+ (0, import_core51.validateCapabilityBundleInput)(normalized, { partial: true });
21277
21304
  try {
21278
21305
  const result = await this.deps.bundleStore.update(tenantId, id3, normalized);
21279
21306
  if (!result) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
21280
21307
  if ("status" in result && result.status === "conflict") throw new CapabilityBundleServiceError("BUNDLE_CONFLICT", "Capability bundle changed after it was loaded; reload before saving", 409);
21281
- (0, import_core49.validateCapabilityBundleInput)(result);
21308
+ (0, import_core51.validateCapabilityBundleInput)(result);
21282
21309
  return result;
21283
21310
  } catch (error) {
21284
21311
  if (error instanceof CapabilityBundleServiceError) throw error;
@@ -21313,8 +21340,8 @@ var CapabilityBundleService = class {
21313
21340
  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: "" };
21314
21341
  try {
21315
21342
  const ordered = ids.map((id3) => byId.get(id3));
21316
- ordered.forEach((bundle) => (0, import_core49.validateCapabilityBundleInput)(bundle));
21317
- return (0, import_core49.mergeCapabilityBundles)(ordered);
21343
+ ordered.forEach((bundle) => (0, import_core51.validateCapabilityBundleInput)(bundle));
21344
+ return (0, import_core51.mergeCapabilityBundles)(ordered);
21318
21345
  } catch (error) {
21319
21346
  return { bundleIds: ids, capabilities: [], overrides: [], sources: [], warnings: [], errors: [issue(error)], revision: "" };
21320
21347
  }
@@ -21347,7 +21374,7 @@ var CapabilityBundleService = class {
21347
21374
  return ids.map((id3) => {
21348
21375
  const value = byId.get(id3);
21349
21376
  if (!value) throw new CapabilityBundleServiceError("BUNDLE_NOT_FOUND", "Capability bundle not found", 404);
21350
- (0, import_core49.validateCapabilityBundleInput)(value);
21377
+ (0, import_core51.validateCapabilityBundleInput)(value);
21351
21378
  return value;
21352
21379
  });
21353
21380
  }
@@ -21362,7 +21389,7 @@ var CapabilityBundleService = class {
21362
21389
  continue;
21363
21390
  }
21364
21391
  try {
21365
- (0, import_core49.validateCapabilityBundleInput)(bundle);
21392
+ (0, import_core51.validateCapabilityBundleInput)(bundle);
21366
21393
  valid.push(bundle);
21367
21394
  } catch (error) {
21368
21395
  errors.push({ ...issue(error), bundleId: id3 });
@@ -21370,7 +21397,7 @@ var CapabilityBundleService = class {
21370
21397
  }
21371
21398
  let preview;
21372
21399
  try {
21373
- preview = (0, import_core49.mergeCapabilityBundles)(valid);
21400
+ preview = (0, import_core51.mergeCapabilityBundles)(valid);
21374
21401
  } catch (error) {
21375
21402
  preview = { bundleIds: ids, capabilities: [], overrides: [], sources: [], warnings: [], errors: [issue(error)], revision: "" };
21376
21403
  }
@@ -21522,7 +21549,7 @@ var import_zod11 = require("zod");
21522
21549
  // src/services/model-provider/ModelProviderService.ts
21523
21550
  var import_node_crypto14 = require("crypto");
21524
21551
  var import_protocols16 = require("@axiom-lattice/protocols");
21525
- var import_core50 = require("@axiom-lattice/core");
21552
+ var import_core52 = require("@axiom-lattice/core");
21526
21553
 
21527
21554
  // src/services/model-provider/errors.ts
21528
21555
  var ModelProviderServiceError = class extends Error {
@@ -22376,9 +22403,9 @@ var ModelProviderService = class {
22376
22403
  */
22377
22404
  async assertSafeUrl(baseURL) {
22378
22405
  try {
22379
- await (0, import_core50.assertSafeUpstreamUrl)(baseURL);
22406
+ await (0, import_core52.assertSafeUpstreamUrl)(baseURL);
22380
22407
  } catch (error) {
22381
- if (error instanceof import_core50.UnsafeUpstreamUrlError) {
22408
+ if (error instanceof import_core52.UnsafeUpstreamUrlError) {
22382
22409
  throw new ModelProviderServiceError(
22383
22410
  unsafeReasonToErrorCode[error.reason],
22384
22411
  400,
@@ -23095,7 +23122,13 @@ var ProjectRosterService = class {
23095
23122
  }
23096
23123
  const agent = (await this.deps.agents.list(actor3.tenantId, actor3.userId)).find((item) => item.assistantId === assistantId);
23097
23124
  if (!agent || agent.ownerUserId !== void 0) throw new ProjectRosterServiceError("ASSISTANT_NOT_FOUND", 404, "Agent not found");
23098
- const room = await this.deps.roomService.ensureMainRoom(actor3);
23125
+ const room = await this.deps.roomStore.ensureMainRoom({
23126
+ id: (0, import_node_crypto17.randomUUID)(),
23127
+ tenantId: actor3.tenantId,
23128
+ workspaceId: project.workspaceId,
23129
+ projectId: actor3.projectId,
23130
+ name: project.name
23131
+ });
23099
23132
  const taken = new Set((await this.deps.membershipStore.list(actor3.tenantId, actor3.projectId)).map((item) => item.mentionName));
23100
23133
  const mentionName = uniqueMentionName(agent.name, taken);
23101
23134
  let ids = await this.findSafePresence(actor3, room, assistantId);
@@ -23811,6 +23844,13 @@ var import_protocols18 = require("@axiom-lattice/protocols");
23811
23844
  // src/services/collaboration/RoomInterruptService.ts
23812
23845
  var import_node_crypto19 = require("crypto");
23813
23846
  init_projectTaskScope();
23847
+ var RESUMABLE_TASK_INTERRUPT_CODES = /* @__PURE__ */ new Set([
23848
+ "PROJECT_TASK_NOT_RESUMABLE",
23849
+ "PROJECT_TASK_NOT_READY",
23850
+ "PROJECT_TASK_START_CONFLICT",
23851
+ "TASK_STATUS_CONFLICT",
23852
+ "REVIEW_APPROVAL_REQUIRED"
23853
+ ]);
23814
23854
  var RoomInterruptServiceError = class extends Error {
23815
23855
  /** Creates a stable room interrupt error. */
23816
23856
  constructor(code, statusCode, message) {
@@ -23833,7 +23873,16 @@ var RoomInterruptService = class {
23833
23873
  /** Resolves a pending interrupt with an explicit resume command. */
23834
23874
  async resume(input, command) {
23835
23875
  await this.deps.requireAccess({ tenantId: input.tenantId, userId: input.userId, projectId: input.projectId });
23836
- const membership = await this.deps.resolveMembership(input);
23876
+ if (input.ref.kind === "task") {
23877
+ await this.resumeTask(input, command);
23878
+ return;
23879
+ }
23880
+ await this.resumePresence(input, command);
23881
+ }
23882
+ /** Resolves a bot presence-thread interrupt by dispatching a follow-up resume. */
23883
+ async resumePresence(input, command) {
23884
+ const membershipId = input.ref.kind === "presence" ? input.ref.membershipId : "";
23885
+ const membership = await this.deps.resolveMembership({ tenantId: input.tenantId, projectId: input.projectId, membershipId });
23837
23886
  if (!membership || membership.status !== "active" || !membership.roomThreadId || membership.projectId !== input.projectId) {
23838
23887
  throw new RoomInterruptServiceError("ROOM_INTERRUPT_TARGET_UNAVAILABLE", 404, "Room interrupt target is unavailable");
23839
23888
  }
@@ -23886,6 +23935,47 @@ var RoomInterruptService = class {
23886
23935
  }
23887
23936
  );
23888
23937
  }
23938
+ /** Resolves a Project Task interrupt by re-reading the task thread and resuming its durable run. */
23939
+ async resumeTask(input, command) {
23940
+ if (!this.deps.tasks || !this.deps.execution) throw new RoomInterruptServiceError("ROOM_INTERRUPT_TARGET_UNAVAILABLE", 404, "Project task runtime is unavailable");
23941
+ const taskId = input.ref.kind === "task" ? input.ref.taskId : "";
23942
+ const task = await this.deps.tasks.getById(input.tenantId, taskId);
23943
+ if (!task || task.tenantId !== input.tenantId || task.projectId !== input.projectId || task.status !== "interrupted" || typeof task.context?.thread_id !== "string") {
23944
+ throw new RoomInterruptServiceError("ROOM_INTERRUPT_NOT_PENDING", 409, "Room interrupt is no longer pending");
23945
+ }
23946
+ const status = await this.deps.getThreadStatus({
23947
+ tenantId: task.tenantId,
23948
+ assistantId: task.ownerId,
23949
+ threadId: task.context.thread_id,
23950
+ workspaceId: task.workspaceId ?? "",
23951
+ projectId: task.projectId ?? ""
23952
+ });
23953
+ if (String(status) !== "interrupted") throw new RoomInterruptServiceError("ROOM_INTERRUPT_NOT_PENDING", 409, "Room interrupt is no longer pending");
23954
+ if (this.deps.getThreadState) {
23955
+ const state = await this.deps.getThreadState({
23956
+ tenantId: task.tenantId,
23957
+ assistantId: task.ownerId,
23958
+ threadId: task.context.thread_id,
23959
+ workspaceId: task.workspaceId ?? "",
23960
+ projectId: task.projectId ?? ""
23961
+ });
23962
+ if (readClarifyInterrupt(state) === void 0) {
23963
+ throw new RoomInterruptServiceError("ROOM_INTERRUPT_NOT_PENDING", 409, "Room interrupt is no longer pending");
23964
+ }
23965
+ }
23966
+ try {
23967
+ await this.deps.execution.dispatchDetached(
23968
+ { tenantId: task.tenantId, taskId: task.id, actor: `user:${input.userId}` },
23969
+ void 0,
23970
+ { command, expectedStatus: "interrupted" }
23971
+ );
23972
+ } catch (error) {
23973
+ if (error instanceof ProjectTaskExecutionError && RESUMABLE_TASK_INTERRUPT_CODES.has(error.code)) {
23974
+ throw new RoomInterruptServiceError("ROOM_INTERRUPT_NOT_PENDING", 409, error.message);
23975
+ }
23976
+ throw error;
23977
+ }
23978
+ }
23889
23979
  };
23890
23980
 
23891
23981
  // src/schemas/project-room.ts
@@ -23929,14 +24019,18 @@ var updateProjectBotSchema = import_zod12.z.object({
23929
24019
  expectedUpdatedAt: isoDate
23930
24020
  }).strict().refine((value) => value.role !== void 0 || value.title !== void 0 || value.responsibility !== void 0 || value.mentionName !== void 0, { message: "At least one mutable field is required" });
23931
24021
  var resumeInterruptSchema = import_zod12.z.object({
23932
- membershipId: id2,
24022
+ ref: import_zod12.z.discriminatedUnion("kind", [
24023
+ import_zod12.z.object({ kind: import_zod12.z.literal("presence"), membershipId: id2 }).strict(),
24024
+ import_zod12.z.object({ kind: import_zod12.z.literal("task"), taskId: id2 }).strict()
24025
+ ]).optional(),
24026
+ membershipId: id2.optional(),
23933
24027
  answers: import_zod12.z.array(import_zod12.z.object({
23934
24028
  questionIndex: import_zod12.z.number().int().nonnegative(),
23935
24029
  otherText: import_zod12.z.string().optional(),
23936
24030
  selectedOptions: import_zod12.z.array(import_zod12.z.string()).optional(),
23937
24031
  filePath: import_zod12.z.string().optional()
23938
24032
  }).strict()).optional()
23939
- }).strict();
24033
+ }).strict().refine((v) => v.ref !== void 0 || v.membershipId !== void 0, { message: "ref or membershipId is required" });
23940
24034
 
23941
24035
  // src/routes/project-rooms.ts
23942
24036
  var ProjectRoomAuthError = class extends Error {
@@ -23987,8 +24081,9 @@ function registerProjectRoomRoutes(app2, deps) {
23987
24081
  const params = projectRoomParamsSchema.parse(request.params);
23988
24082
  const requestActor = actor(request, params.projectId);
23989
24083
  const body = resumeInterruptSchema.parse(request.body ?? {});
24084
+ const ref = body.ref ?? { kind: "presence", membershipId: body.membershipId };
23990
24085
  await deps.interruptService.resume(
23991
- { tenantId: requestActor.tenantId, projectId: requestActor.projectId, userId: requestActor.userId, membershipId: body.membershipId },
24086
+ { tenantId: requestActor.tenantId, projectId: requestActor.projectId, userId: requestActor.userId, ref },
23992
24087
  { resume: { data: { answers: body.answers ?? [] } } }
23993
24088
  );
23994
24089
  return { data: { resolved: true } };
@@ -24095,7 +24190,7 @@ async function execute(reply, operation) {
24095
24190
  // src/routes/cospace.ts
24096
24191
  var import_node_crypto20 = require("crypto");
24097
24192
  var import_zod15 = require("zod");
24098
- var import_core51 = require("@axiom-lattice/core");
24193
+ var import_core53 = require("@axiom-lattice/core");
24099
24194
  var import_protocols19 = require("@axiom-lattice/protocols");
24100
24195
  var CoSpaceAuthError = class extends Error {
24101
24196
  constructor() {
@@ -24280,14 +24375,14 @@ function registerCoSpaceRoutes(app2, deps) {
24280
24375
  }
24281
24376
  let projectId;
24282
24377
  if (body.type === "human") {
24283
- projectId = (0, import_core51.generateDirectHumanProjectId)(
24378
+ projectId = (0, import_core53.generateDirectHumanProjectId)(
24284
24379
  actor3.tenantId,
24285
24380
  params.workspaceId,
24286
24381
  actor3.userId,
24287
24382
  body.targetUserId
24288
24383
  );
24289
24384
  } else {
24290
- projectId = (0, import_core51.generateDirectBotProjectId)(
24385
+ projectId = (0, import_core53.generateDirectBotProjectId)(
24291
24386
  actor3.tenantId,
24292
24387
  params.workspaceId,
24293
24388
  actor3.userId,
@@ -24494,7 +24589,7 @@ function registerCoSpaceRoutes(app2, deps) {
24494
24589
  );
24495
24590
  const bots = [];
24496
24591
  for (const assistant of assistants) {
24497
- const directProjectId = (0, import_core51.generateDirectBotProjectId)(
24592
+ const directProjectId = (0, import_core53.generateDirectBotProjectId)(
24498
24593
  actor3.tenantId,
24499
24594
  params.workspaceId,
24500
24595
  actor3.userId,
@@ -24556,7 +24651,7 @@ function registerCoSpaceRoutes(app2, deps) {
24556
24651
  if (link.userId === actor3.userId) continue;
24557
24652
  const user = await deps.userStore.getUserById(link.userId);
24558
24653
  if (!user) continue;
24559
- const directProjectId = (0, import_core51.generateDirectHumanProjectId)(
24654
+ const directProjectId = (0, import_core53.generateDirectHumanProjectId)(
24560
24655
  actor3.tenantId,
24561
24656
  params.workspaceId,
24562
24657
  actor3.userId,
@@ -25385,7 +25480,7 @@ function createRoomMessageRetentionJob(input) {
25385
25480
 
25386
25481
  // src/services/collaboration/ProjectTaskExecutionMutex.ts
25387
25482
  var import_protocols22 = require("@axiom-lattice/protocols");
25388
- var import_core52 = require("@axiom-lattice/core");
25483
+ var import_core54 = require("@axiom-lattice/core");
25389
25484
  var MACHINE_LEASE_OPTIONS = { ttlMs: 6e4, acquireTimeoutMs: 9e4, retryDelayMs: 100 };
25390
25485
  function machineKey(scope) {
25391
25486
  const snapshot = (0, import_protocols22.snapshotExactRecord)(scope, ["tenantId", "assistantId", "projectId"]);
@@ -25413,9 +25508,9 @@ var ProjectTaskExecutionMutex = class {
25413
25508
  const leaseKey = `project-task-machine:${encodeURIComponent(scope.tenantId)}:${encodeURIComponent(scope.assistantId)}:${encodeURIComponent(scope.projectId)}`;
25414
25509
  await this.acquire(key, signal);
25415
25510
  try {
25416
- const store2 = (0, import_core52.getCoordinationLeaseStore)();
25511
+ const store2 = (0, import_core54.getCoordinationLeaseStore)();
25417
25512
  if (!store2) return await operation();
25418
- return await (0, import_core52.withLease)(store2, leaseKey, (0, import_core52.getReplicaId)(), operation, MACHINE_LEASE_OPTIONS);
25513
+ return await (0, import_core54.withLease)(store2, leaseKey, (0, import_core54.getReplicaId)(), operation, MACHINE_LEASE_OPTIONS);
25419
25514
  } finally {
25420
25515
  this.release(key);
25421
25516
  }
@@ -25466,9 +25561,57 @@ var ProjectTaskExecutionMutex = class {
25466
25561
  }
25467
25562
  };
25468
25563
 
25564
+ // src/services/collaboration/TaskInterruptCardProjector.ts
25565
+ function clarifyFence(data) {
25566
+ return ["```clarify", JSON.stringify(data), "```"].join("\n");
25567
+ }
25568
+ var TaskInterruptCardProjector = class {
25569
+ constructor(deps) {
25570
+ this.deps = deps;
25571
+ }
25572
+ /** Projects the interruption as a correlated room card when it is a clarify. */
25573
+ async project(input) {
25574
+ const clarify = readClarifyInterrupt(input.state);
25575
+ if (!clarify) return;
25576
+ const { task, messageId } = input;
25577
+ const workspaceId = task.workspaceId;
25578
+ const projectId = task.projectId;
25579
+ if (!workspaceId || !projectId) return;
25580
+ const adapter = this.deps.adapter;
25581
+ const sendInterrupt = adapter.sendInterrupt;
25582
+ if (!sendInterrupt) {
25583
+ this.safeWarn("project-room:task-interrupt-card-unsupported", { taskId: task.id });
25584
+ return;
25585
+ }
25586
+ try {
25587
+ const room = snapshotProjectRoom(await this.deps.rooms.getMainRoom(task.tenantId, projectId));
25588
+ if (!room || !room.id || room.tenantId !== task.tenantId || room.workspaceId !== workspaceId || room.projectId !== projectId) return;
25589
+ const membership = snapshotBotMembership(await this.deps.bots.findByAssistant(task.tenantId, projectId, task.ownerId));
25590
+ if (!membership || membership.tenantId !== task.tenantId || membership.workspaceId !== workspaceId || membership.projectId !== projectId || membership.roomId !== room.id || membership.assistantId !== task.ownerId || membership.status !== "active") return;
25591
+ const installation = await this.deps.installation.ensure(task.tenantId);
25592
+ const text = clarifyFence({ taskId: task.id, questions: clarify.questions });
25593
+ await sendInterrupt.call(
25594
+ adapter,
25595
+ { adapterChannel: "room", channelInstallationId: installation.id, rawTarget: { targetMembershipId: membership.id } },
25596
+ { text, metadata: { correlationKey: `task:${task.id}:${messageId}` } },
25597
+ installation
25598
+ );
25599
+ } catch (error) {
25600
+ this.safeWarn("project-room:task-interrupt-card-failed", { taskId: task.id, error: error instanceof Error ? error.message : String(error) });
25601
+ }
25602
+ }
25603
+ /** Logs without ever letting a failing logger reject `project()`. */
25604
+ safeWarn(message, context) {
25605
+ try {
25606
+ this.deps.log.warn(message, context);
25607
+ } catch {
25608
+ }
25609
+ }
25610
+ };
25611
+
25469
25612
  // src/services/collaboration/ProjectTaskObserver.ts
25470
25613
  var import_node_crypto22 = require("crypto");
25471
- var import_core53 = require("@axiom-lattice/core");
25614
+ var import_core55 = require("@axiom-lattice/core");
25472
25615
  var import_protocols23 = require("@axiom-lattice/protocols");
25473
25616
 
25474
25617
  // src/services/collaboration/projectTaskDispatchMarker.ts
@@ -25505,7 +25648,7 @@ var ProjectTaskObserver = class {
25505
25648
  throw new Error(`Invalid Project task observer bound: ${name}`);
25506
25649
  }
25507
25650
  }
25508
- this.runBridge = (0, import_core53.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
25651
+ this.runBridge = (0, import_core55.createTaskRunBridge)({ lifecycle: this.deps.lifecycle });
25509
25652
  }
25510
25653
  /** Fire-and-forget notifier adapter that never waits for observer work or machine acquisition. */
25511
25654
  async listener(event) {
@@ -26721,7 +26864,7 @@ function isRecord3(value) {
26721
26864
  init_projectTaskScope();
26722
26865
 
26723
26866
  // src/services/collaboration/ProjectRoomRealtimeRuntime.ts
26724
- var import_core54 = require("@axiom-lattice/core");
26867
+ var import_core56 = require("@axiom-lattice/core");
26725
26868
 
26726
26869
  // src/services/collaboration/ProjectRoomEventBroker.ts
26727
26870
  var import_node_crypto24 = require("crypto");
@@ -27496,7 +27639,7 @@ function createProjectRoomRealtimeRuntime(deps) {
27496
27639
  broker,
27497
27640
  publisher,
27498
27641
  subscriber,
27499
- subscribe: (listener) => import_core54.taskLifecycleNotifier.subscribe(listener),
27642
+ subscribe: (listener) => import_core56.taskLifecycleNotifier.subscribe(listener),
27500
27643
  log: deps.log,
27501
27644
  shutdownTimeoutMs: deps.shutdownTimeoutMs
27502
27645
  });
@@ -28233,35 +28376,35 @@ function hookErrorMessage(error) {
28233
28376
  function wrapReassignmentThreadError(error) {
28234
28377
  if (error instanceof ProjectTaskThreadError) {
28235
28378
  if (error.code === "PROJECT_TASK_THREAD_SCOPE_INVALID") {
28236
- return new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", error.message, {
28379
+ return new import_core57.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", error.message, {
28237
28380
  hint: "Project task, room, or roster scope changed; re-read the task and retry."
28238
28381
  });
28239
28382
  }
28240
28383
  if (error.code === "PROJECT_TASK_THREAD_OWNER_INVALID") {
28241
- return new import_core55.ManagedTaskStartError("TASK_REASSIGN_NO_CHANGE", error.message, {
28384
+ return new import_core57.ManagedTaskStartError("TASK_REASSIGN_NO_CHANGE", error.message, {
28242
28385
  hint: "The target already owns this task; re-read before dispatching."
28243
28386
  });
28244
28387
  }
28245
- return new import_core55.ManagedTaskStartError("TASK_THREAD_CONFLICT", error.message, {
28388
+ return new import_core57.ManagedTaskStartError("TASK_THREAD_CONFLICT", error.message, {
28246
28389
  hint: "Task Thread changed concurrently; re-read the task and retry."
28247
28390
  });
28248
28391
  }
28249
- return new import_core55.ManagedTaskStartError("TASK_EXECUTION_ENQUEUE_FAILED", hookErrorMessage(error), {
28392
+ return new import_core57.ManagedTaskStartError("TASK_EXECUTION_ENQUEUE_FAILED", hookErrorMessage(error), {
28250
28393
  hint: "Re-read the task and retry the dispatch."
28251
28394
  });
28252
28395
  }
28253
28396
  function wrapReassignmentAuthorizationError(error) {
28254
- if (error instanceof import_core55.ProjectTaskOwnerPolicyError) {
28397
+ if (error instanceof import_core57.ProjectTaskOwnerPolicyError) {
28255
28398
  if (error.code === "PROJECT_TASK_CALLER_INACTIVE") {
28256
- return new import_core55.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", error.message, {
28399
+ return new import_core57.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", error.message, {
28257
28400
  hint: "Dispatch from an active Project Room member bot."
28258
28401
  });
28259
28402
  }
28260
- return new import_core55.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", error.message, {
28403
+ return new import_core57.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", error.message, {
28261
28404
  hint: "Dispatch to an active bot in this Project's roster."
28262
28405
  });
28263
28406
  }
28264
- return new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", hookErrorMessage(error), {
28407
+ return new import_core57.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", hookErrorMessage(error), {
28265
28408
  hint: "Re-read the task and roster, then retry the dispatch."
28266
28409
  });
28267
28410
  }
@@ -28290,43 +28433,43 @@ async function transferGovernedDispatchOwner(task, options, deps) {
28290
28433
  const agentId = options?.agentId;
28291
28434
  if (!agentId || agentId === task.ownerId) return void 0;
28292
28435
  if (!task.workspaceId || !task.projectId) {
28293
- throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is not governed by a Project lifecycle.", {
28436
+ throw new import_core57.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is not governed by a Project lifecycle.", {
28294
28437
  hint: "Dispatch governed tasks from a trusted Project run; ordinary tasks execute immediately."
28295
28438
  });
28296
28439
  }
28297
28440
  return deps.mutex.runExclusive({ tenantId: task.tenantId, projectId: task.projectId }, async () => {
28298
28441
  const current = await deps.tasks.getById(task.tenantId, task.id);
28299
28442
  if (!current || !isProjectLifecycleTask(current) || current.workspaceId !== task.workspaceId || current.projectId !== task.projectId) {
28300
- throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is no longer a Project lifecycle task.", {
28443
+ throw new import_core57.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Task is no longer a Project lifecycle task.", {
28301
28444
  hint: "Re-read the task and confirm it still belongs to this Project before dispatching."
28302
28445
  });
28303
28446
  }
28304
28447
  if (current.ownerType !== "agent") {
28305
- throw new import_core55.ManagedTaskStartError("AGENT_TASK_REQUIRED", "Project task owner must be an Agent.", {
28448
+ throw new import_core57.ManagedTaskStartError("AGENT_TASK_REQUIRED", "Project task owner must be an Agent.", {
28306
28449
  hint: "Assign the task to an Agent before dispatching."
28307
28450
  });
28308
28451
  }
28309
28452
  if (current.status !== "pending") {
28310
- throw new import_core55.ManagedTaskStartError("TASK_NOT_DISPATCHABLE", "Only a `pending` Project task can be dispatched.", {
28453
+ throw new import_core57.ManagedTaskStartError("TASK_NOT_DISPATCHABLE", "Only a `pending` Project task can be dispatched.", {
28311
28454
  hint: `This task is '${current.status}'. Resolve it or create a new task before dispatching.`
28312
28455
  });
28313
28456
  }
28314
28457
  if (agentId === current.ownerId) return current;
28315
28458
  const room = await deps.rooms.getMainRoom(current.tenantId, current.projectId);
28316
28459
  if (!room || room.tenantId !== current.tenantId || room.workspaceId !== current.workspaceId || room.projectId !== current.projectId || room.type !== "main") {
28317
- throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Project main room is unavailable.", {
28460
+ throw new import_core57.ManagedTaskStartError("PROJECT_TASK_CONTEXT_INVALID", "Project main room is unavailable.", {
28318
28461
  hint: "Open or repair the Project Room before dispatching."
28319
28462
  });
28320
28463
  }
28321
28464
  const target = await deps.botMemberships.findByAssistant(current.tenantId, current.projectId, agentId);
28322
28465
  if (!target || target.status !== "active" || target.tenantId !== current.tenantId || target.workspaceId !== current.workspaceId || target.projectId !== current.projectId || target.assistantId !== agentId || target.roomId !== room.id) {
28323
- throw new import_core55.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", "Target Project task owner is not active in the exact roster.", {
28466
+ throw new import_core57.ManagedTaskStartError("PROJECT_TASK_OWNER_INACTIVE", "Target Project task owner is not active in the exact roster.", {
28324
28467
  hint: "Dispatch to an active bot in this Project's roster."
28325
28468
  });
28326
28469
  }
28327
28470
  const caller = options?.callerMembershipId ? await deps.botMemberships.findById(current.tenantId, options.callerMembershipId) : null;
28328
28471
  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) {
28329
- throw new import_core55.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", "Current Project task caller is not active in the exact roster.", {
28472
+ throw new import_core57.ManagedTaskStartError("PROJECT_TASK_CALLER_INACTIVE", "Current Project task caller is not active in the exact roster.", {
28330
28473
  hint: "Dispatch from an active Project Room member bot."
28331
28474
  });
28332
28475
  }
@@ -28361,7 +28504,7 @@ async function transferGovernedDispatchOwner(task, options, deps) {
28361
28504
  actor: `agent:${caller.assistantId}`
28362
28505
  });
28363
28506
  if (!result.success) {
28364
- throw new import_core55.ManagedTaskStartError(result.code, result.error, {
28507
+ throw new import_core57.ManagedTaskStartError(result.code, result.error, {
28365
28508
  hint: result.hint ?? reassignmentFailureHint(result.code),
28366
28509
  ...result.retryable !== void 0 ? { retryable: result.retryable } : {}
28367
28510
  });
@@ -28372,25 +28515,25 @@ async function transferGovernedDispatchOwner(task, options, deps) {
28372
28515
  function broadcastModelProviderChanged(tenantId, providerId2) {
28373
28516
  if (!tenantId) return;
28374
28517
  try {
28375
- const outbox = (0, import_core55.getStoreLattice)("default", "outbox").store;
28376
- void publishModelProviderChanged(outbox, (0, import_core55.getReplicaId)(), tenantId, providerId2);
28518
+ const outbox = (0, import_core57.getStoreLattice)("default", "outbox").store;
28519
+ void publishModelProviderChanged(outbox, (0, import_core57.getReplicaId)(), tenantId, providerId2);
28377
28520
  } catch {
28378
28521
  }
28379
28522
  }
28380
28523
  var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28381
- const webAppStore = (0, import_core55.getStoreLattice)("default", "agentWebApp").store;
28382
- const assistantStore = (0, import_core55.getStoreLattice)("default", "assistant").store;
28383
- const projectStore = (0, import_core55.getStoreLattice)("default", "project").store;
28384
- const projectMembershipStore = (0, import_core55.getStoreLattice)("default", "projectMembership").store;
28385
- const userTenantLinkStore = (0, import_core55.getStoreLattice)("default", "userTenantLink").store;
28386
- const projectRoomStore = (0, import_core55.getStoreLattice)("default", "projectRoom").store;
28387
- const projectBotMembershipStore = (0, import_core55.getStoreLattice)("default", "projectBotMembership").store;
28388
- const projectRoomMessageStore = (0, import_core55.getStoreLattice)("default", "projectRoomMessage").store;
28389
- const projectRoomReadStateStore = (0, import_core55.getStoreLattice)("default", "projectRoomReadState").store;
28390
- const userPushSubscriptionStore = (0, import_core55.getStoreLattice)("default", "userPushSubscription").store;
28391
- const threadStore = (0, import_core55.getStoreLattice)("default", "thread").store;
28392
- const taskStore = (0, import_core55.getStoreLattice)("default", "task").store;
28393
- const taskWorkItemStore = (0, import_core55.getStoreLattice)("default", "taskWorkItem").store;
28524
+ const webAppStore = (0, import_core57.getStoreLattice)("default", "agentWebApp").store;
28525
+ const assistantStore = (0, import_core57.getStoreLattice)("default", "assistant").store;
28526
+ const projectStore = (0, import_core57.getStoreLattice)("default", "project").store;
28527
+ const projectMembershipStore = (0, import_core57.getStoreLattice)("default", "projectMembership").store;
28528
+ const userTenantLinkStore = (0, import_core57.getStoreLattice)("default", "userTenantLink").store;
28529
+ const projectRoomStore = (0, import_core57.getStoreLattice)("default", "projectRoom").store;
28530
+ const projectBotMembershipStore = (0, import_core57.getStoreLattice)("default", "projectBotMembership").store;
28531
+ const projectRoomMessageStore = (0, import_core57.getStoreLattice)("default", "projectRoomMessage").store;
28532
+ const projectRoomReadStateStore = (0, import_core57.getStoreLattice)("default", "projectRoomReadState").store;
28533
+ const userPushSubscriptionStore = (0, import_core57.getStoreLattice)("default", "userPushSubscription").store;
28534
+ const threadStore = (0, import_core57.getStoreLattice)("default", "thread").store;
28535
+ const taskStore = (0, import_core57.getStoreLattice)("default", "task").store;
28536
+ const taskWorkItemStore = (0, import_core57.getStoreLattice)("default", "taskWorkItem").store;
28394
28537
  const projectTaskEnabled = options.projectTaskEnabled ?? process.env.AXIOM_PROJECT_TASK_EXECUTION_ENABLED !== "false";
28395
28538
  const accessService = new ProjectAccessService({ projectStore, membershipStore: projectMembershipStore, userTenantLinkStore });
28396
28539
  const realtimeMode = resolveProjectRoomRealtimeMode();
@@ -28456,7 +28599,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28456
28599
  updateAssistant: assistantStore.updateAssistant.bind(assistantStore)
28457
28600
  });
28458
28601
  const resolveCoordinatorMentionName = async (tenantId) => {
28459
- const tenant2 = await (0, import_core55.getStoreLattice)("default", "tenant").store.getTenantById(tenantId);
28602
+ const tenant2 = await (0, import_core57.getStoreLattice)("default", "tenant").store.getTenantById(tenantId);
28460
28603
  const value = tenant2?.metadata?.coordinatorMentionName;
28461
28604
  return typeof value === "string" && value.length > 0 ? value : void 0;
28462
28605
  };
@@ -28474,31 +28617,11 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28474
28617
  ensureCoordinator: (scope) => coordinatorEnsurer.ensure(scope),
28475
28618
  log: realtimeLog
28476
28619
  });
28477
- const roomInterruptService = new RoomInterruptService({
28478
- requireAccess: async ({ tenantId, userId, projectId }) => {
28479
- await accessService.requireProjectAccess({ tenantId, userId, projectId, capability: "send" });
28480
- },
28481
- resolveMembership: async ({ tenantId, projectId, membershipId }) => {
28482
- const membership = await projectBotMembershipStore.findById(tenantId, membershipId);
28483
- return membership !== null && membership.projectId === projectId ? membership : null;
28484
- },
28485
- getThreadStatus: async ({ tenantId, assistantId, threadId, workspaceId, projectId }) => {
28486
- const agent = import_core55.agentInstanceManager.getAgent({
28487
- tenant_id: tenantId,
28488
- assistant_id: assistantId,
28489
- thread_id: threadId,
28490
- workspace_id: workspaceId,
28491
- project_id: projectId
28492
- });
28493
- return String(await agent.getRunStatus());
28494
- },
28495
- dispatcher: (0, import_core55.createTrustedAgentMessageDispatcher)((scope) => import_core55.agentInstanceManager.getAgent(scope)),
28496
- projects: projectStore
28497
- });
28498
- 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 });
28620
+ const membershipService = new ProjectMembershipService({ membershipStore: projectMembershipStore, userTenantLinkStore, accessService, projectMutationMutex: import_core57.projectMutationMutex, roomStore: projectRoomStore, realtime, onRealtimeFailure: realtime && channelDeps?.warn ? ({ code, membershipId }) => channelDeps.warn?.("project-room:membership-realtime-failed", { code, membershipId }) : void 0 });
28499
28621
  const rosterService = new ProjectRosterService({
28500
28622
  accessService,
28501
28623
  roomService,
28624
+ roomStore: projectRoomStore,
28502
28625
  membershipStore: projectBotMembershipStore,
28503
28626
  projects: projectStore,
28504
28627
  agents: { list: async (tenantId, userId) => (await collectTenantAssistants(tenantId, userId)).map((assistant) => ({ assistantId: assistant.id, name: assistant.name, ...assistant.ownerUserId === void 0 ? {} : { ownerUserId: assistant.ownerUserId } })) },
@@ -28506,7 +28629,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28506
28629
  assistantStore,
28507
28630
  taskStore,
28508
28631
  bindingLifecycle,
28509
- projectMutationMutex: import_core55.projectMutationMutex,
28632
+ projectMutationMutex: import_core57.projectMutationMutex,
28510
28633
  realtime,
28511
28634
  onRealtimeFailure: realtime && channelDeps?.warn ? ({ code, membershipId }) => channelDeps.warn?.("project-room:roster-realtime-failed", { code, membershipId }) : void 0
28512
28635
  });
@@ -28548,6 +28671,14 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28548
28671
  messageId: event.messageId
28549
28672
  }) : void 0
28550
28673
  });
28674
+ const roomAdapter = channelDeps?.adapterRegistry.get("room");
28675
+ const taskInterruptProjector = installation && roomAdapter ? new TaskInterruptCardProjector({
28676
+ rooms: projectRoomStore,
28677
+ bots: projectBotMembershipStore,
28678
+ installation,
28679
+ adapter: roomAdapter,
28680
+ log: realtimeLog
28681
+ }) : void 0;
28551
28682
  const projectTaskRuntime = projectTaskEnabled ? tryCreateProjectTaskRuntime({
28552
28683
  taskStore,
28553
28684
  taskWorkItemStore,
@@ -28559,7 +28690,10 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28559
28690
  realtime,
28560
28691
  log: options.projectTaskLog,
28561
28692
  ensurePublicOwner: (scope) => rosterService.ensurePublicProjectAgent(scope),
28562
- ...coordinatorWakeNotifier === void 0 ? {} : { coordinatorWake: coordinatorWakeNotifier }
28693
+ ...coordinatorWakeNotifier === void 0 ? {} : { coordinatorWake: coordinatorWakeNotifier },
28694
+ ...taskInterruptProjector === void 0 ? {} : {
28695
+ onTaskInterrupted: (input) => taskInterruptProjector.project(input)
28696
+ }
28563
28697
  }) : { reason: void 0 };
28564
28698
  const projectTaskComposition = "composition" in projectTaskRuntime ? projectTaskRuntime.composition : void 0;
28565
28699
  const projectTaskUnavailableReason = "reason" in projectTaskRuntime ? projectTaskRuntime.reason : void 0;
@@ -28570,9 +28704,9 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28570
28704
  }
28571
28705
  if (projectTaskComposition) app2.addHook("onClose", async () => projectTaskComposition.lease.release());
28572
28706
  const taskThreadService = projectTaskComposition?.lease.runtime.threads ?? new ProjectTaskThreadService({ threads: threadStore, idFactory: import_node_crypto26.randomUUID });
28573
- const taskLifecycle = projectTaskComposition?.lease.runtime.lifecycle ?? (0, import_core55.createTaskLifecycleService)({ taskStore, workItemStore: taskWorkItemStore });
28574
- const reassignmentAuthorizer = (0, import_core55.createProjectTaskReassignmentAuthorizer)(
28575
- new import_core55.ProjectTaskOwnerPolicy(projectBotMembershipStore),
28707
+ const taskLifecycle = projectTaskComposition?.lease.runtime.lifecycle ?? (0, import_core57.createTaskLifecycleService)({ taskStore, workItemStore: taskWorkItemStore });
28708
+ const reassignmentAuthorizer = (0, import_core57.createProjectTaskReassignmentAuthorizer)(
28709
+ new import_core57.ProjectTaskOwnerPolicy(projectBotMembershipStore),
28576
28710
  (input) => validateReassignmentThread(threadStore, input)
28577
28711
  );
28578
28712
  const taskCommandService = new TaskCommandService({
@@ -28581,7 +28715,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28581
28715
  lifecycle: taskLifecycle,
28582
28716
  execution: projectTaskComposition?.lease.runtime.execution,
28583
28717
  threads: taskThreadService,
28584
- agents: { getAgent: (params) => import_core55.agentInstanceManager.getAgent(params) },
28718
+ agents: { getAgent: (params) => import_core57.agentInstanceManager.getAgent(params) },
28585
28719
  taskScope: (task) => resolveCommandTaskScope(task, {
28586
28720
  rooms: projectRoomStore,
28587
28721
  bots: projectBotMembershipStore,
@@ -28589,6 +28723,39 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28589
28723
  }),
28590
28724
  reassign: unsupportedHumanReassign
28591
28725
  });
28726
+ const roomInterruptService = new RoomInterruptService({
28727
+ requireAccess: async ({ tenantId, userId, projectId }) => {
28728
+ await accessService.requireProjectAccess({ tenantId, userId, projectId, capability: "send" });
28729
+ },
28730
+ resolveMembership: async ({ tenantId, projectId, membershipId }) => {
28731
+ const membership = await projectBotMembershipStore.findById(tenantId, membershipId);
28732
+ return membership !== null && membership.projectId === projectId ? membership : null;
28733
+ },
28734
+ getThreadStatus: async ({ tenantId, assistantId, threadId, workspaceId, projectId }) => {
28735
+ const agent = import_core57.agentInstanceManager.getAgent({
28736
+ tenant_id: tenantId,
28737
+ assistant_id: assistantId,
28738
+ thread_id: threadId,
28739
+ workspace_id: workspaceId,
28740
+ project_id: projectId
28741
+ });
28742
+ return String(await agent.getRunStatus());
28743
+ },
28744
+ getThreadState: async ({ tenantId, assistantId, threadId, workspaceId, projectId }) => {
28745
+ const agent = import_core57.agentInstanceManager.getAgent({
28746
+ tenant_id: tenantId,
28747
+ assistant_id: assistantId,
28748
+ thread_id: threadId,
28749
+ workspace_id: workspaceId,
28750
+ project_id: projectId
28751
+ });
28752
+ return agent.getCurrentState();
28753
+ },
28754
+ dispatcher: (0, import_core57.createTrustedAgentMessageDispatcher)((scope) => import_core57.agentInstanceManager.getAgent(scope)),
28755
+ projects: projectStore,
28756
+ tasks: taskStore,
28757
+ execution: projectTaskComposition?.lease.runtime.execution
28758
+ });
28592
28759
  const publicRoomService = new WorkspacePublicRoomService({
28593
28760
  getProjectById: projectStore.getProjectById.bind(projectStore),
28594
28761
  createProject: projectStore.createProject.bind(projectStore),
@@ -28619,7 +28786,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28619
28786
  readStateService,
28620
28787
  interruptService: roomInterruptService,
28621
28788
  userDirectory: {
28622
- getUserById: (id3) => (0, import_core55.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { name: u.name } : null)
28789
+ getUserById: (id3) => (0, import_core57.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { name: u.name } : null)
28623
28790
  }
28624
28791
  });
28625
28792
  registerProjectRosterRoutes(app2, { service: rosterService });
@@ -28630,7 +28797,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28630
28797
  createProject: projectStore.createProject.bind(projectStore)
28631
28798
  },
28632
28799
  workspaceStore: {
28633
- getWorkspaceById: (tenantId, id3) => (0, import_core55.getStoreLattice)("default", "workspace").store.getWorkspaceById(tenantId, id3)
28800
+ getWorkspaceById: (tenantId, id3) => (0, import_core57.getStoreLattice)("default", "workspace").store.getWorkspaceById(tenantId, id3)
28634
28801
  },
28635
28802
  membershipStore: {
28636
28803
  list: projectMembershipStore.list.bind(projectMembershipStore),
@@ -28653,7 +28820,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28653
28820
  getUsersByTenant: userTenantLinkStore.getUsersByTenant.bind(userTenantLinkStore)
28654
28821
  },
28655
28822
  userStore: {
28656
- getUserById: (id3) => (0, import_core55.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { id: u.id, name: u.name, email: u.email } : null)
28823
+ getUserById: (id3) => (0, import_core57.getStoreLattice)("default", "user").store.getUserById(id3).then((u) => u ? { id: u.id, name: u.name, email: u.email } : null)
28657
28824
  },
28658
28825
  assistantStore: {
28659
28826
  getAssistantById: assistantStore.getAssistantById.bind(assistantStore),
@@ -28675,17 +28842,17 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28675
28842
  }
28676
28843
  });
28677
28844
  registerCapabilityBundleRoutes(app2, new CapabilityBundleController({
28678
- bundleStore: (0, import_core55.getStoreLattice)("default", "capabilityBundle").store,
28845
+ bundleStore: (0, import_core57.getStoreLattice)("default", "capabilityBundle").store,
28679
28846
  projectStore
28680
28847
  }, { authRequired: process.env.AUTH_REQUIRED === "true" }));
28681
28848
  const modelProviderController = new ModelProviderController({
28682
- providerStore: (0, import_core55.getStoreLattice)("default", "modelProvider").store,
28849
+ providerStore: (0, import_core57.getStoreLattice)("default", "modelProvider").store,
28683
28850
  userTenantLinkStore,
28684
28851
  registry: {
28685
- register: (tenantId, modelKey2, config) => import_core55.modelLatticeManager.registerLatticeWithTenant(tenantId, modelKey2, config),
28686
- has: (tenantId, modelKey2) => import_core55.modelLatticeManager.hasLatticeWithTenant(tenantId, modelKey2),
28687
- remove: (tenantId, modelKey2) => import_core55.modelLatticeManager.removeLatticeWithTenant(tenantId, modelKey2),
28688
- listRegistered: (tenantId) => import_core55.modelLatticeManager.getLatticeKeysByTenant(tenantId)
28852
+ register: (tenantId, modelKey2, config) => import_core57.modelLatticeManager.registerLatticeWithTenant(tenantId, modelKey2, config),
28853
+ has: (tenantId, modelKey2) => import_core57.modelLatticeManager.hasLatticeWithTenant(tenantId, modelKey2),
28854
+ remove: (tenantId, modelKey2) => import_core57.modelLatticeManager.removeLatticeWithTenant(tenantId, modelKey2),
28855
+ listRegistered: (tenantId) => import_core57.modelLatticeManager.getLatticeKeysByTenant(tenantId)
28689
28856
  },
28690
28857
  onChanged: (tenantId, providerId2) => broadcastModelProviderChanged(tenantId, providerId2)
28691
28858
  }, { authRequired: process.env.AUTH_REQUIRED === "true" });
@@ -28696,10 +28863,10 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28696
28863
  webAppStore,
28697
28864
  assistantStore,
28698
28865
  projectStore,
28699
- modelRegistry: { has: (key) => import_core55.modelLatticeManager.hasLattice(key) },
28866
+ modelRegistry: { has: (key) => import_core57.modelLatticeManager.hasLattice(key) },
28700
28867
  configuredAgentResolver: createConfiguredAgentResolver({
28701
- hydrate: (tenantId) => import_core55.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
28702
- has: (tenantId, assistantId) => import_core55.agentLatticeManager.hasAgentLatticeWithTenant(tenantId, assistantId)
28868
+ hydrate: (tenantId) => import_core57.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId),
28869
+ has: (tenantId, assistantId) => import_core57.agentLatticeManager.hasAgentLatticeWithTenant(tenantId, assistantId)
28703
28870
  })
28704
28871
  })
28705
28872
  });
@@ -28736,28 +28903,28 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28736
28903
  },
28737
28904
  tasks: taskStore,
28738
28905
  workItems: taskWorkItemStore,
28739
- projectMutationMutex: import_core55.projectMutationMutex,
28906
+ projectMutationMutex: import_core57.projectMutationMutex,
28740
28907
  ...projectTaskComposition ? { commands: taskCommandService } : {}
28741
28908
  }),
28742
28909
  service: new AgentWebAppRuntimeService({
28743
28910
  webAppStore,
28744
- threadStore: (0, import_core55.getStoreLattice)("default", "thread").store,
28911
+ threadStore: (0, import_core57.getStoreLattice)("default", "thread").store,
28745
28912
  projectStore,
28746
28913
  assistantResolver: {
28747
28914
  resolve: async (tenantId, assistantId) => {
28748
28915
  const stored = await assistantStore.getAssistantById(tenantId, assistantId);
28749
28916
  if (stored) return { id: stored.id, name: stored.name, description: stored.description };
28750
- await import_core55.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId);
28751
- const config = import_core55.agentLatticeManager.getAgentConfigWithTenant(tenantId, assistantId);
28917
+ await import_core57.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId);
28918
+ const config = import_core57.agentLatticeManager.getAgentConfigWithTenant(tenantId, assistantId);
28752
28919
  return config ? { id: assistantId, name: config.name, description: config.description } : null;
28753
28920
  }
28754
28921
  },
28755
28922
  modelRegistry: {
28756
- has: (key) => import_core55.modelLatticeManager.hasLattice(key),
28923
+ has: (key) => import_core57.modelLatticeManager.hasLattice(key),
28757
28924
  label: (key) => key
28758
28925
  },
28759
28926
  messageReader: {
28760
- getCurrentMessages: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core55.agentInstanceManager.getAgentForRead({
28927
+ getCurrentMessages: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core57.agentInstanceManager.getAgentForRead({
28761
28928
  tenant_id: tenantId,
28762
28929
  assistant_id: assistantId,
28763
28930
  thread_id: threadId,
@@ -28766,7 +28933,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28766
28933
  }).getCurrentMessages()
28767
28934
  },
28768
28935
  agentResolver: {
28769
- getAgent: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core55.agentInstanceManager.getAgent({
28936
+ getAgent: ({ tenantId, assistantId, threadId, workspaceId, projectId }) => import_core57.agentInstanceManager.getAgent({
28770
28937
  tenant_id: tenantId,
28771
28938
  assistant_id: assistantId,
28772
28939
  thread_id: threadId,
@@ -28784,8 +28951,8 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28784
28951
  if (webApp.tenantId !== preview.tenantId) return false;
28785
28952
  const assistant = await assistantStore.getAssistantById(preview.tenantId, webApp.assistantId);
28786
28953
  if (assistant) return !assistant.ownerUserId || assistant.ownerUserId === preview.userId;
28787
- await import_core55.agentLatticeManager.initializeStoredAssistantsForTenant(preview.tenantId);
28788
- return import_core55.agentLatticeManager.hasAgentLatticeWithTenant(preview.tenantId, webApp.assistantId);
28954
+ await import_core57.agentLatticeManager.initializeStoredAssistantsForTenant(preview.tenantId);
28955
+ return import_core57.agentLatticeManager.hasAgentLatticeWithTenant(preview.tenantId, webApp.assistantId);
28789
28956
  }
28790
28957
  })
28791
28958
  });
@@ -28842,14 +29009,14 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28842
29009
  app2.post("/api/personal-assistant", createPersonalAssistant);
28843
29010
  app2.get("/api/personal-assistant", getPersonalAssistant);
28844
29011
  app2.delete("/api/personal-assistant", deletePersonalAssistant);
28845
- import_core55.executionAuthorityRegistry.register({
29012
+ import_core57.executionAuthorityRegistry.register({
28846
29013
  id: "project-lifecycle",
28847
29014
  matches: isProjectLifecycleTask,
28848
29015
  code: "PROJECT_TASK_EXECUTION_MANAGED",
28849
29016
  message: "Project tasks are executed by the durable Project queue runtime",
28850
29017
  onManagedStart: async (task, options2) => {
28851
29018
  if (!projectTaskComposition && options2?.agentId && options2.agentId !== task.ownerId) {
28852
- throw new import_core55.ManagedTaskStartError(
29019
+ throw new import_core57.ManagedTaskStartError(
28853
29020
  "PROJECT_TASK_RUNTIME_UNAVAILABLE",
28854
29021
  "Project task ownership transfer requires the Project task runtime.",
28855
29022
  { hint: "Project task execution is disabled; enable the Project task runtime or dispatch to the current owner." }
@@ -28862,7 +29029,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28862
29029
  threads: taskThreadService,
28863
29030
  reassignmentAuthorizer,
28864
29031
  lifecycle: taskLifecycle,
28865
- mutex: import_core55.projectMutationMutex
29032
+ mutex: import_core57.projectMutationMutex
28866
29033
  }) : void 0;
28867
29034
  const admitted = transferred ?? task;
28868
29035
  if (!admitted.workspaceId || !admitted.projectId) return;
@@ -28870,7 +29037,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28870
29037
  context: withExecutionRequest(admitted.context, (/* @__PURE__ */ new Date()).toISOString())
28871
29038
  }).catch(() => null);
28872
29039
  const eventTask = markerUpdated ?? admitted;
28873
- void import_core55.projectTaskAdmissionNotifier.publish({
29040
+ void import_core57.projectTaskAdmissionNotifier.publish({
28874
29041
  tenantId: eventTask.tenantId,
28875
29042
  workspaceId: eventTask.workspaceId,
28876
29043
  projectId: eventTask.projectId,
@@ -28884,7 +29051,7 @@ var registerLatticeRoutes = (app2, channelDeps, options = {}) => {
28884
29051
  access: accessService,
28885
29052
  tasks: taskStore,
28886
29053
  workItems: taskWorkItemStore,
28887
- projectMutationMutex: import_core55.projectMutationMutex,
29054
+ projectMutationMutex: import_core57.projectMutationMutex,
28888
29055
  commands: taskCommandService,
28889
29056
  readableProjects: async ({ tenantId, userId, workspaceId }) => {
28890
29057
  const projects = await projectStore.getProjectsByWorkspace(tenantId, workspaceId);
@@ -29167,9 +29334,9 @@ function tryCreateProjectTaskRuntime(input) {
29167
29334
  let stores;
29168
29335
  try {
29169
29336
  stores = {
29170
- tenants: (0, import_core55.getStoreLattice)("default", "tenant").store,
29171
- workspaces: (0, import_core55.getStoreLattice)("default", "workspace").store,
29172
- queue: (0, import_core55.getStoreLattice)("default", "threadMessageQueue").store
29337
+ tenants: (0, import_core57.getStoreLattice)("default", "tenant").store,
29338
+ workspaces: (0, import_core57.getStoreLattice)("default", "workspace").store,
29339
+ queue: (0, import_core57.getStoreLattice)("default", "threadMessageQueue").store
29173
29340
  };
29174
29341
  const missing = missingRuntimeMethod(input, stores);
29175
29342
  if (missing) return { reason: missing };
@@ -29201,7 +29368,7 @@ function createRuntime(input, stores, log2) {
29201
29368
  const controller = new AbortController();
29202
29369
  const mutex = new ProjectTaskExecutionMutex();
29203
29370
  const threads = new ProjectTaskThreadService({ threads: input.threadStore, idFactory: import_node_crypto26.randomUUID });
29204
- const lifecycle = (0, import_core55.createTaskLifecycleService)({ taskStore: input.taskStore, workItemStore: input.taskWorkItemStore });
29371
+ const lifecycle = (0, import_core57.createTaskLifecycleService)({ taskStore: input.taskStore, workItemStore: input.taskWorkItemStore });
29205
29372
  const projection = new RoomProjectionService({
29206
29373
  messages: input.projectRoomMessageStore,
29207
29374
  events: input.taskWorkItemStore,
@@ -29211,7 +29378,7 @@ function createRuntime(input, stores, log2) {
29211
29378
  realtime: input.realtime,
29212
29379
  idFactory: import_node_crypto26.randomUUID
29213
29380
  });
29214
- const agentFor = (task, thread) => import_core55.agentInstanceManager.getAgent({
29381
+ const agentFor = (task, thread) => import_core57.agentInstanceManager.getAgent({
29215
29382
  tenant_id: task.tenantId,
29216
29383
  assistant_id: task.ownerId,
29217
29384
  thread_id: thread.id,
@@ -29226,10 +29393,11 @@ function createRuntime(input, stores, log2) {
29226
29393
  bots: input.projectBotMembershipStore,
29227
29394
  threads,
29228
29395
  lifecycle,
29229
- dispatcher: (0, import_core55.createTrustedAgentMessageDispatcher)((scope) => import_core55.agentInstanceManager.getAgent(scope)),
29396
+ dispatcher: (0, import_core57.createTrustedAgentMessageDispatcher)((scope) => import_core57.agentInstanceManager.getAgent(scope)),
29230
29397
  queue: stores.queue,
29231
29398
  agentFor,
29232
- ...input.ensurePublicOwner === void 0 ? {} : { ensurePublicOwner: input.ensurePublicOwner }
29399
+ ...input.ensurePublicOwner === void 0 ? {} : { ensurePublicOwner: input.ensurePublicOwner },
29400
+ ...input.onTaskInterrupted === void 0 ? {} : { onTaskInterrupted: input.onTaskInterrupted }
29233
29401
  },
29234
29402
  {
29235
29403
  settlementTimeoutMs: PROJECT_TASK_SETTLEMENT_TIMEOUT_MS,
@@ -29256,8 +29424,8 @@ function createRuntime(input, stores, log2) {
29256
29424
  const taskLifecycleListener = ((event) => {
29257
29425
  void observer.listener(event);
29258
29426
  });
29259
- const unsubscribe = import_core55.taskLifecycleNotifier.subscribe(taskLifecycleListener);
29260
- const unsubscribeAdmission = import_core55.projectTaskAdmissionNotifier.subscribe((event, signal) => {
29427
+ const unsubscribe = import_core57.taskLifecycleNotifier.subscribe(taskLifecycleListener);
29428
+ const unsubscribeAdmission = import_core57.projectTaskAdmissionNotifier.subscribe((event, signal) => {
29261
29429
  observer.admit(event, signal);
29262
29430
  });
29263
29431
  let reconciliationWork;
@@ -29408,12 +29576,12 @@ function registerResourceRoutes(app2, controller) {
29408
29576
  }
29409
29577
 
29410
29578
  // src/export_registrations/index.ts
29411
- var import_core67 = require("@axiom-lattice/core");
29579
+ var import_core69 = require("@axiom-lattice/core");
29412
29580
 
29413
29581
  // src/export_registrations/skill.registration.ts
29414
- var import_core57 = require("@axiom-lattice/core");
29582
+ var import_core59 = require("@axiom-lattice/core");
29415
29583
  function getStore(context) {
29416
- return new import_core57.SandboxSkillStore({
29584
+ return new import_core59.SandboxSkillStore({
29417
29585
  workspaceId: context?.workspaceId,
29418
29586
  projectId: context?.projectId
29419
29587
  });
@@ -29431,7 +29599,7 @@ var skillRegistration = {
29431
29599
  async listForExport(tenantId, context) {
29432
29600
  const store2 = getStore(context);
29433
29601
  const skills = await store2.getAllSkills(tenantId, toStoreContext(context));
29434
- return skills.filter((s) => !(0, import_core57.isBuiltInSkill)(s.id)).map((s) => ({
29602
+ return skills.filter((s) => !(0, import_core59.isBuiltInSkill)(s.id)).map((s) => ({
29435
29603
  _exportId: "",
29436
29604
  data: {
29437
29605
  id: s.id,
@@ -29496,7 +29664,7 @@ var skillRegistration = {
29496
29664
  const insertions = [];
29497
29665
  for (const entity of entities) {
29498
29666
  const id3 = entity.data.id;
29499
- if ((0, import_core57.isBuiltInSkill)(id3)) continue;
29667
+ if ((0, import_core59.isBuiltInSkill)(id3)) continue;
29500
29668
  if (existingIds.has(id3)) {
29501
29669
  conflicts.push({
29502
29670
  _exportId: entity._exportId,
@@ -29555,9 +29723,9 @@ var skillRegistration = {
29555
29723
  };
29556
29724
 
29557
29725
  // src/export_registrations/agent.registration.ts
29558
- var import_core58 = require("@axiom-lattice/core");
29726
+ var import_core60 = require("@axiom-lattice/core");
29559
29727
  function getStore2() {
29560
- return (0, import_core58.getStoreLattice)("default", "assistant").store;
29728
+ return (0, import_core60.getStoreLattice)("default", "assistant").store;
29561
29729
  }
29562
29730
  var agentRegistration = {
29563
29731
  entityType: "agent",
@@ -29637,9 +29805,9 @@ var agentRegistration = {
29637
29805
  };
29638
29806
 
29639
29807
  // src/export_registrations/database-config.registration.ts
29640
- var import_core59 = require("@axiom-lattice/core");
29808
+ var import_core61 = require("@axiom-lattice/core");
29641
29809
  function getStore3() {
29642
- return (0, import_core59.getStoreLattice)("default", "database").store;
29810
+ return (0, import_core61.getStoreLattice)("default", "database").store;
29643
29811
  }
29644
29812
  var databaseConfigRegistration = {
29645
29813
  entityType: "database_config",
@@ -29719,9 +29887,9 @@ var databaseConfigRegistration = {
29719
29887
  };
29720
29888
 
29721
29889
  // src/export_registrations/metrics-config.registration.ts
29722
- var import_core60 = require("@axiom-lattice/core");
29890
+ var import_core62 = require("@axiom-lattice/core");
29723
29891
  function getStore4() {
29724
- return (0, import_core60.getStoreLattice)("default", "metrics").store;
29892
+ return (0, import_core62.getStoreLattice)("default", "metrics").store;
29725
29893
  }
29726
29894
  var metricsConfigRegistration = {
29727
29895
  entityType: "metrics_config",
@@ -29801,9 +29969,9 @@ var metricsConfigRegistration = {
29801
29969
  };
29802
29970
 
29803
29971
  // src/export_registrations/mcp-config.registration.ts
29804
- var import_core61 = require("@axiom-lattice/core");
29972
+ var import_core63 = require("@axiom-lattice/core");
29805
29973
  function getStore5() {
29806
- return (0, import_core61.getStoreLattice)("default", "mcp").store;
29974
+ return (0, import_core63.getStoreLattice)("default", "mcp").store;
29807
29975
  }
29808
29976
  var mcpConfigRegistration = {
29809
29977
  entityType: "mcp_config",
@@ -29886,9 +30054,9 @@ var mcpConfigRegistration = {
29886
30054
  };
29887
30055
 
29888
30056
  // src/export_registrations/connection.registration.ts
29889
- var import_core62 = require("@axiom-lattice/core");
30057
+ var import_core64 = require("@axiom-lattice/core");
29890
30058
  function getStore6() {
29891
- return (0, import_core62.getStoreLattice)("default", "connection").store;
30059
+ return (0, import_core64.getStoreLattice)("default", "connection").store;
29892
30060
  }
29893
30061
  async function listAllConnections(tenantId) {
29894
30062
  const store2 = getStore6();
@@ -29973,9 +30141,9 @@ var connectionRegistration = {
29973
30141
  };
29974
30142
 
29975
30143
  // src/export_registrations/collection.registration.ts
29976
- var import_core63 = require("@axiom-lattice/core");
30144
+ var import_core65 = require("@axiom-lattice/core");
29977
30145
  function getStore7() {
29978
- return (0, import_core63.getStoreLattice)("default", "collection").store;
30146
+ return (0, import_core65.getStoreLattice)("default", "collection").store;
29979
30147
  }
29980
30148
  var collectionRegistration = {
29981
30149
  entityType: "collection",
@@ -30046,7 +30214,7 @@ var collectionRegistration = {
30046
30214
  };
30047
30215
 
30048
30216
  // src/export_registrations/channel-installation.registration.ts
30049
- var import_core64 = require("@axiom-lattice/core");
30217
+ var import_core66 = require("@axiom-lattice/core");
30050
30218
  var import_crypto11 = require("crypto");
30051
30219
  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;
30052
30220
  var PUBLIC_CHANNELS = /* @__PURE__ */ new Set(["lark", "email", "slack", "wechat"]);
@@ -30080,7 +30248,7 @@ function validateImportData(data) {
30080
30248
  };
30081
30249
  }
30082
30250
  function getStore8() {
30083
- return (0, import_core64.getStoreLattice)("default", "channelInstallation").store;
30251
+ return (0, import_core66.getStoreLattice)("default", "channelInstallation").store;
30084
30252
  }
30085
30253
  function getOverwriteError(tenantId, incomingChannel, existing) {
30086
30254
  if (!existing) return "Channel installation overwrite target must exist";
@@ -30214,9 +30382,9 @@ var channelInstallationRegistration = {
30214
30382
  };
30215
30383
 
30216
30384
  // src/export_registrations/menu.registration.ts
30217
- var import_core65 = require("@axiom-lattice/core");
30385
+ var import_core67 = require("@axiom-lattice/core");
30218
30386
  function getStore9() {
30219
- return (0, import_core65.getStoreLattice)("default", "menu").store;
30387
+ return (0, import_core67.getStoreLattice)("default", "menu").store;
30220
30388
  }
30221
30389
  var menuRegistration = {
30222
30390
  entityType: "menu",
@@ -30294,9 +30462,9 @@ var menuRegistration = {
30294
30462
  };
30295
30463
 
30296
30464
  // src/export_registrations/eval.registration.ts
30297
- var import_core66 = require("@axiom-lattice/core");
30465
+ var import_core68 = require("@axiom-lattice/core");
30298
30466
  function getStore10() {
30299
- return (0, import_core66.getStoreLattice)("default", "eval").store;
30467
+ return (0, import_core68.getStoreLattice)("default", "eval").store;
30300
30468
  }
30301
30469
  var evalRegistration = {
30302
30470
  entityType: "eval",
@@ -30622,7 +30790,7 @@ var evalRegistration = {
30622
30790
 
30623
30791
  // src/export_registrations/index.ts
30624
30792
  function registerAllBuiltinEntities() {
30625
- const registry = import_core67.ExportableEntityRegistry.getInstance();
30793
+ const registry = import_core69.ExportableEntityRegistry.getInstance();
30626
30794
  registry.register(skillRegistration);
30627
30795
  registry.register(agentRegistration);
30628
30796
  registry.register(databaseConfigRegistration);
@@ -30753,7 +30921,7 @@ function createAuditLoggerMiddleware() {
30753
30921
  }
30754
30922
 
30755
30923
  // src/index.ts
30756
- var import_core95 = require("@axiom-lattice/core");
30924
+ var import_core97 = require("@axiom-lattice/core");
30757
30925
 
30758
30926
  // src/swagger.ts
30759
30927
  var import_swagger = __toESM(require("@fastify/swagger"));
@@ -30819,7 +30987,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
30819
30987
 
30820
30988
  // src/services/agent_task_consumer.ts
30821
30989
  var import_node_crypto27 = require("crypto");
30822
- var import_core68 = require("@axiom-lattice/core");
30990
+ var import_core70 = require("@axiom-lattice/core");
30823
30991
  var import_protocols32 = require("@axiom-lattice/protocols");
30824
30992
  var handleAgentTask = async (taskRequest, retryCount = 0) => {
30825
30993
  const {
@@ -30839,7 +31007,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
30839
31007
  `\u5F00\u59CB\u5904\u7406\u4EFB\u52A1 [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
30840
31008
  );
30841
31009
  const scope = (0, import_protocols32.resolveRunScope)(runConfig);
30842
- const agent = import_core68.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: scope.workspaceId, project_id: scope.projectId, custom_run_config: runConfig });
31010
+ const agent = import_core70.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: scope.workspaceId, project_id: scope.projectId, custom_run_config: runConfig });
30843
31011
  if (callback_event) {
30844
31012
  const callbackEvent = callback_event;
30845
31013
  const messageId = typeof input?.id === "string" && input.id !== "" ? input.id : (0, import_node_crypto27.randomUUID)();
@@ -30860,13 +31028,13 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
30860
31028
  const onCompleted = (evt) => {
30861
31029
  if (!belongsToMessage(evt)) return;
30862
31030
  settle(() => {
30863
- import_core68.eventBus.publish(callbackEvent, {
31031
+ import_core70.eventBus.publish(callbackEvent, {
30864
31032
  success: true,
30865
31033
  state: evt.state
30866
31034
  });
30867
31035
  if (main_thread_id && main_tenant_id) {
30868
31036
  try {
30869
- const mainAgent = import_core68.agentInstanceManager.getAgent({
31037
+ const mainAgent = import_core70.agentInstanceManager.getAgent({
30870
31038
  assistant_id: main_assistant_id ?? assistant_id,
30871
31039
  thread_id: main_thread_id,
30872
31040
  tenant_id: main_tenant_id,
@@ -30899,7 +31067,7 @@ ${summary}`
30899
31067
  const onInterrupted = (evt) => {
30900
31068
  if (!belongsToMessage(evt)) return;
30901
31069
  settle(() => {
30902
- import_core68.eventBus.publish(callbackEvent, {
31070
+ import_core70.eventBus.publish(callbackEvent, {
30903
31071
  success: true,
30904
31072
  state: evt.state
30905
31073
  });
@@ -30908,7 +31076,7 @@ ${summary}`
30908
31076
  const onFailed = (evt) => {
30909
31077
  if (!belongsToMessage(evt)) return;
30910
31078
  settle(() => {
30911
- import_core68.eventBus.publish(callbackEvent, {
31079
+ import_core70.eventBus.publish(callbackEvent, {
30912
31080
  success: false,
30913
31081
  error: evt?.error instanceof Error ? evt.error.message : typeof evt?.error === "string" ? evt.error : "Agent execution failed"
30914
31082
  });
@@ -30923,13 +31091,13 @@ ${summary}`
30923
31091
  agent.subscribe("message:interrupted", onInterrupted);
30924
31092
  agent.subscribe("message:failed", onFailed);
30925
31093
  try {
30926
- await agent.addMessage({ input: { ...input, id: messageId }, command, custom_run_config: runConfig }, import_core68.QueueMode.STEER);
31094
+ await agent.addMessage({ input: { ...input, id: messageId }, command, custom_run_config: runConfig }, import_core70.QueueMode.STEER);
30927
31095
  } catch (error) {
30928
31096
  dispose();
30929
31097
  throw error;
30930
31098
  }
30931
31099
  } else {
30932
- await agent.addMessage({ input, command, custom_run_config: runConfig }, import_core68.QueueMode.STEER);
31100
+ await agent.addMessage({ input, command, custom_run_config: runConfig }, import_core70.QueueMode.STEER);
30933
31101
  }
30934
31102
  return true;
30935
31103
  } catch (error) {
@@ -30948,7 +31116,7 @@ ${summary}`
30948
31116
  return handleAgentTask(taskRequest, nextRetryCount);
30949
31117
  }
30950
31118
  if (callback_event) {
30951
- import_core68.eventBus.publish(callback_event, {
31119
+ import_core70.eventBus.publish(callback_event, {
30952
31120
  success: false,
30953
31121
  error: error instanceof Error ? error.message : String(error)
30954
31122
  });
@@ -30985,7 +31153,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
30985
31153
  * 初始化事件监听和队列轮询
30986
31154
  */
30987
31155
  initialize() {
30988
- import_core68.eventBus.subscribe(import_core68.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
31156
+ import_core70.eventBus.subscribe(import_core70.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
30989
31157
  this.startPollingQueue();
30990
31158
  console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
30991
31159
  }
@@ -31104,7 +31272,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
31104
31272
  handleAgentTask(taskRequest).catch((error) => {
31105
31273
  console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
31106
31274
  if (taskRequest.callback_event) {
31107
- import_core68.eventBus.publish(taskRequest.callback_event, {
31275
+ import_core70.eventBus.publish(taskRequest.callback_event, {
31108
31276
  success: false,
31109
31277
  error: error instanceof Error ? error.message : String(error)
31110
31278
  });
@@ -31153,13 +31321,13 @@ function createGracefulShutdown(options) {
31153
31321
  }
31154
31322
 
31155
31323
  // src/index.ts
31156
- var import_core96 = require("@axiom-lattice/core");
31324
+ var import_core98 = require("@axiom-lattice/core");
31157
31325
 
31158
31326
  // src/channels/ChannelInfrastructure.ts
31159
- var import_core70 = require("@axiom-lattice/core");
31327
+ var import_core72 = require("@axiom-lattice/core");
31160
31328
 
31161
31329
  // src/router/MessageRouter.ts
31162
- var import_core69 = require("@axiom-lattice/core");
31330
+ var import_core71 = require("@axiom-lattice/core");
31163
31331
  var import_protocols33 = require("@axiom-lattice/protocols");
31164
31332
  var import_crypto12 = require("crypto");
31165
31333
  var BindingNotFoundError = class extends Error {
@@ -31445,7 +31613,7 @@ var MessageRouter = class {
31445
31613
  channel: message.channel,
31446
31614
  adapterChannel: adapter.channel
31447
31615
  }, "Thread resolved by adapter strategy");
31448
- const threadStore = (0, import_core69.getStoreLattice)("default", "thread").store;
31616
+ const threadStore = (0, import_core71.getStoreLattice)("default", "thread").store;
31449
31617
  try {
31450
31618
  await threadStore.createThread(
31451
31619
  tenantId,
@@ -31482,7 +31650,7 @@ var MessageRouter = class {
31482
31650
  }
31483
31651
  }
31484
31652
  if (!threadId) {
31485
- const threadStore = (0, import_core69.getStoreLattice)("default", "thread").store;
31653
+ const threadStore = (0, import_core71.getStoreLattice)("default", "thread").store;
31486
31654
  const newThreadId = (0, import_crypto12.randomUUID)();
31487
31655
  console.log({
31488
31656
  event: "dispatch:thread:create",
@@ -31522,7 +31690,7 @@ var MessageRouter = class {
31522
31690
  senderId: message.sender.id,
31523
31691
  contentLength: message.content.text.length
31524
31692
  }, "Dispatching to agent");
31525
- const agent = import_core69.agentInstanceManager.getAgent({
31693
+ const agent = import_core71.agentInstanceManager.getAgent({
31526
31694
  tenant_id: tenantId,
31527
31695
  assistant_id: agentId,
31528
31696
  thread_id: threadId,
@@ -31744,10 +31912,23 @@ function createRoomChannelAdapter(writer) {
31744
31912
  const installed = installationValues(installation);
31745
31913
  if (!installed) throw new Error("Invalid room installation");
31746
31914
  const targetEnvelope = exactValues2(replyTarget, ["adapterChannel", "channelInstallationId", "rawTarget"]);
31747
- const target = exactStrings(targetEnvelope?.rawTarget, ["sourceRoomMessageId", "targetMembershipId", "inputMessageId"]);
31748
31915
  const envelope = exactValues2(message, ["text", "metadata"]);
31749
- const metadata = exactStrings(envelope?.metadata, ["inputMessageId"]);
31750
- if (!targetEnvelope || targetEnvelope.adapterChannel !== "room" || targetEnvelope.channelInstallationId !== installation.id || !target || !metadata || typeof envelope?.text !== "string") throw new Error("Invalid room interrupt");
31916
+ if (!targetEnvelope || targetEnvelope.adapterChannel !== "room" || targetEnvelope.channelInstallationId !== installation.id || typeof envelope?.text !== "string") throw new Error("Invalid room interrupt");
31917
+ const correlationKey = exactStrings(envelope.metadata, ["correlationKey"])?.correlationKey;
31918
+ if (correlationKey) {
31919
+ const correlatedTarget = exactStrings(targetEnvelope.rawTarget, ["targetMembershipId"]);
31920
+ if (!correlatedTarget) throw new Error("Invalid room interrupt correlation");
31921
+ await writer.postCorrelatedInterrupt({
31922
+ tenantId: installed.tenantId,
31923
+ membershipId: correlatedTarget.targetMembershipId,
31924
+ correlationKey,
31925
+ text: envelope.text
31926
+ });
31927
+ return;
31928
+ }
31929
+ const target = exactStrings(targetEnvelope.rawTarget, ["sourceRoomMessageId", "targetMembershipId", "inputMessageId"]);
31930
+ const metadata = exactStrings(envelope.metadata, ["inputMessageId"]);
31931
+ if (!target || !metadata) throw new Error("Invalid room interrupt");
31751
31932
  if (target.inputMessageId !== metadata.inputMessageId) throw new Error("Invalid room interrupt correlation");
31752
31933
  await writer.postInterrupt({
31753
31934
  tenantId: installed.tenantId,
@@ -31795,7 +31976,7 @@ function createChannelInfrastructure(deps) {
31795
31976
  onMessageCommitted: deps.onMessageCommitted ?? (deps.realtime ? (message) => deps.realtime?.messageCreated(message) : void 0),
31796
31977
  onCallbackFailure: (event) => deps.warn("project-room:message-commit-callback-failed", event)
31797
31978
  };
31798
- deps.adapterRegistry.register(createRoomChannelAdapter(new import_core70.RoomAgentMessageService(writerDeps)));
31979
+ deps.adapterRegistry.register(createRoomChannelAdapter(new import_core72.RoomAgentMessageService(writerDeps)));
31799
31980
  } catch (error) {
31800
31981
  deps.warn("Room channel unavailable", { error: error instanceof Error ? error.message : String(error) });
31801
31982
  }
@@ -31816,11 +31997,11 @@ async function prepareProjectTaskRuntime(runtime, log2) {
31816
31997
  }
31817
31998
 
31818
31999
  // src/services/plugins/PluginDeploymentRuntimeStartup.ts
31819
- var import_core72 = require("@axiom-lattice/core");
32000
+ var import_core74 = require("@axiom-lattice/core");
31820
32001
 
31821
32002
  // src/services/plugins/PluginDeploymentService.ts
31822
32003
  var import_node_crypto29 = require("crypto");
31823
- var import_core71 = require("@axiom-lattice/core");
32004
+ var import_core73 = require("@axiom-lattice/core");
31824
32005
 
31825
32006
  // src/services/plugins/pluginDeploymentNaming.ts
31826
32007
  var import_node_crypto28 = require("crypto");
@@ -31838,7 +32019,7 @@ function pluginSandboxName(tenantId, pluginType) {
31838
32019
  }
31839
32020
 
31840
32021
  // src/services/plugins/PluginDeploymentService.ts
31841
- var PLUGIN_HOST_SERVER_PATH = `${import_core71.PLUGIN_HOST_DIR}/server.js`;
32022
+ var PLUGIN_HOST_SERVER_PATH = `${import_core73.PLUGIN_HOST_DIR}/server.js`;
31842
32023
  var DEFAULT_PLUGIN_IDLE_TIMEOUT_MS = 15 * 60 * 1e3;
31843
32024
  var DEFAULT_PLUGIN_HEALTH_TIMEOUT_MS = 3e4;
31844
32025
  var DEFAULT_PLUGIN_HEALTH_POLL_INTERVAL_MS = 500;
@@ -31877,11 +32058,11 @@ var PluginDeploymentService = class {
31877
32058
  this.catalog = deps.catalog;
31878
32059
  this.installPluginHost = deps.installPluginHost;
31879
32060
  this.lease = deps.lease;
31880
- this.registry = deps.registry ?? new import_core71.PluginDeploymentRuntimeRegistry({ now: deps.clock ?? Date.now });
32061
+ this.registry = deps.registry ?? new import_core73.PluginDeploymentRuntimeRegistry({ now: deps.clock ?? Date.now });
31881
32062
  this.now = deps.clock ?? Date.now;
31882
32063
  this.logger = deps.logger ?? { info: () => void 0 };
31883
32064
  this.limits = deps.limits ?? {};
31884
- this.serviceBaseUrl = (deps.serviceBaseUrl ?? process.env.MICROSANDBOX_SERVICE_URL ?? "").replace(
32065
+ this.serviceBaseUrl = (deps.serviceBaseUrl ?? process.env.MICROSANDBOX_SERVICE_BASE_URL ?? "").replace(
31885
32066
  /\/$/,
31886
32067
  ""
31887
32068
  );
@@ -32569,7 +32750,7 @@ function isPluginDeploymentRuntimeEnabled(env = process.env) {
32569
32750
  const flag = env[PLUGIN_DEPLOYMENT_RUNTIME_FLAG];
32570
32751
  if (flag === "false" || flag === "0") return false;
32571
32752
  if (flag === "true" || flag === "1") return true;
32572
- return Boolean(env.MICROSANDBOX_SERVICE_URL);
32753
+ return Boolean(env.MICROSANDBOX_SERVICE_BASE_URL);
32573
32754
  }
32574
32755
  function readPluginDeploymentLimits(env = process.env) {
32575
32756
  return {
@@ -32586,15 +32767,15 @@ function readPluginDeploymentLimits(env = process.env) {
32586
32767
  function startPluginDeploymentRuntime(options) {
32587
32768
  const { lease, holder, logger: logger8 } = options;
32588
32769
  const forcedOn = process.env[PLUGIN_DEPLOYMENT_RUNTIME_FLAG] === "true" || process.env[PLUGIN_DEPLOYMENT_RUNTIME_FLAG] === "1";
32589
- const effectiveServiceBaseUrl = options.wiring.serviceBaseUrl ?? process.env.MICROSANDBOX_SERVICE_URL;
32770
+ const effectiveServiceBaseUrl = options.wiring.serviceBaseUrl ?? process.env.MICROSANDBOX_SERVICE_BASE_URL;
32590
32771
  if (forcedOn && !effectiveServiceBaseUrl) {
32591
32772
  logger8.warn(
32592
- `${PLUGIN_DEPLOYMENT_RUNTIME_FLAG} is enabled but MICROSANDBOX_SERVICE_URL is empty; skipping plugin deployment runtime`,
32773
+ `${PLUGIN_DEPLOYMENT_RUNTIME_FLAG} is enabled but MICROSANDBOX_SERVICE_BASE_URL is empty; skipping plugin deployment runtime`,
32593
32774
  { holder }
32594
32775
  );
32595
32776
  return { reconcile: Promise.resolve(), dispose: async () => void 0 };
32596
32777
  }
32597
- const register = options.register ?? ((service3) => (0, import_core72.setPluginDeploymentService)(service3));
32778
+ const register = options.register ?? ((service3) => (0, import_core74.setPluginDeploymentService)(service3));
32598
32779
  const setIntervalFn = options.setIntervalFn ?? setInterval;
32599
32780
  const clearIntervalFn = options.clearIntervalFn ?? clearInterval;
32600
32781
  const watchdogIntervalMs = options.watchdogIntervalMs ?? DEFAULT_PLUGIN_WATCHDOG_INTERVAL_MS;
@@ -32739,7 +32920,7 @@ function errorMessage5(error) {
32739
32920
  }
32740
32921
 
32741
32922
  // src/services/multiReplicaReadiness.ts
32742
- var import_core73 = require("@axiom-lattice/core");
32923
+ var import_core75 = require("@axiom-lattice/core");
32743
32924
  var SHARED_STORE_KINDS = [
32744
32925
  "lease",
32745
32926
  "outbox",
@@ -32750,7 +32931,7 @@ var SHARED_STORE_KINDS = [
32750
32931
  ];
32751
32932
  function storeClassName(kind) {
32752
32933
  try {
32753
- return (0, import_core73.getStoreLattice)("default", kind).store.constructor?.name;
32934
+ return (0, import_core75.getStoreLattice)("default", kind).store.constructor?.name;
32754
32935
  } catch {
32755
32936
  return void 0;
32756
32937
  }
@@ -32922,11 +33103,11 @@ var DEFAULT_LOGGER_CONFIG = {
32922
33103
  var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
32923
33104
  var logger7 = loggerLattice.client;
32924
33105
  function initializeLogger(config) {
32925
- if (import_core96.loggerLatticeManager.hasLattice("default")) {
32926
- import_core96.loggerLatticeManager.removeLattice("default");
33106
+ if (import_core98.loggerLatticeManager.hasLattice("default")) {
33107
+ import_core98.loggerLatticeManager.removeLattice("default");
32927
33108
  }
32928
- (0, import_core96.registerLoggerLattice)("default", config);
32929
- return (0, import_core96.getLoggerLattice)("default");
33109
+ (0, import_core98.registerLoggerLattice)("default", config);
33110
+ return (0, import_core98.getLoggerLattice)("default");
32930
33111
  }
32931
33112
  var app = (0, import_fastify.default)({
32932
33113
  logger: false,
@@ -33024,7 +33205,7 @@ app.setErrorHandler((error, request, reply) => {
33024
33205
  var shutdownHandlersInstalled = false;
33025
33206
  function getConfiguredSandboxProvider() {
33026
33207
  const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || "microsandbox-remote";
33027
- return (0, import_core96.createSandboxProvider)({
33208
+ return (0, import_core98.createSandboxProvider)({
33028
33209
  type: sandboxProviderType,
33029
33210
  remoteBaseURL: process.env.SANDBOX_BASE_URL,
33030
33211
  microsandboxServiceBaseURL: process.env.MICROSANDBOX_SERVICE_BASE_URL,
@@ -33040,7 +33221,7 @@ function getConfiguredSandboxProvider() {
33040
33221
  }
33041
33222
  async function restoreMcpConnections() {
33042
33223
  try {
33043
- const storeLattice = (0, import_core96.getStoreLattice)("default", "mcp");
33224
+ const storeLattice = (0, import_core98.getStoreLattice)("default", "mcp");
33044
33225
  const store2 = storeLattice.store;
33045
33226
  if (!store2) {
33046
33227
  logger7.info("MCP store not configured, skipping connection restoration");
@@ -33053,8 +33234,8 @@ async function restoreMcpConnections() {
33053
33234
  logger7.info(`Restoring ${configs.length} MCP server connections...`);
33054
33235
  const deps = {
33055
33236
  store: store2,
33056
- manager: import_core96.mcpManager,
33057
- convertToConnection: import_core96.convertToConnection
33237
+ manager: import_core98.mcpManager,
33238
+ convertToConnection: import_core98.convertToConnection
33058
33239
  };
33059
33240
  const results = await Promise.allSettled(
33060
33241
  configs.map(
@@ -33095,9 +33276,9 @@ var start = async (config) => {
33095
33276
  let projectRoomRealtimeRuntime;
33096
33277
  if (projectRoomRealtimeMode === "single-gateway") {
33097
33278
  projectRoomRealtimeRuntime = createProjectRoomRealtimeRuntime({
33098
- tasks: (0, import_core96.getStoreLattice)("default", "task").store,
33099
- rooms: (0, import_core96.getStoreLattice)("default", "projectRoom").store,
33100
- memberships: (0, import_core96.getStoreLattice)("default", "projectBotMembership").store,
33279
+ tasks: (0, import_core98.getStoreLattice)("default", "task").store,
33280
+ rooms: (0, import_core98.getStoreLattice)("default", "projectRoom").store,
33281
+ memberships: (0, import_core98.getStoreLattice)("default", "projectBotMembership").store,
33101
33282
  log: { warn: (message, context) => logger7.warn(message, context) }
33102
33283
  });
33103
33284
  }
@@ -33107,11 +33288,10 @@ var start = async (config) => {
33107
33288
  const { wechatChannelAdapter: wechatChannelAdapter2 } = await Promise.resolve().then(() => (init_WechatChannelAdapter(), WechatChannelAdapter_exports));
33108
33289
  adapterRegistry.register(wechatChannelAdapter2);
33109
33290
  try {
33110
- const { getStoreLattice: getStore11 } = await import("@axiom-lattice/core");
33111
33291
  const infrastructure = createChannelInfrastructure({
33112
33292
  adapterRegistry,
33113
- getStore: ((kind) => getStore11("default", kind).store),
33114
- trustedDispatcher: (0, import_core96.createTrustedAgentMessageDispatcher)((scope) => import_core96.agentInstanceManager.getAgent(scope)),
33293
+ getStore: ((kind) => (0, import_core98.getStoreLattice)("default", kind).store),
33294
+ trustedDispatcher: (0, import_core98.createTrustedAgentMessageDispatcher)((scope) => import_core98.agentInstanceManager.getAgent(scope)),
33115
33295
  middlewares: [
33116
33296
  createDeduplicationMiddleware(),
33117
33297
  createRateLimitMiddleware(),
@@ -33122,7 +33302,7 @@ var start = async (config) => {
33122
33302
  });
33123
33303
  const bindingStore = infrastructure.bindingRegistry;
33124
33304
  const installationStore = infrastructure.installationStore;
33125
- (0, import_core95.setBindingRegistry)(bindingStore);
33305
+ (0, import_core97.setBindingRegistry)(bindingStore);
33126
33306
  const router = infrastructure.router;
33127
33307
  app.addHook("onClose", async () => router.dispose());
33128
33308
  channelDeps = {
@@ -33138,10 +33318,10 @@ var start = async (config) => {
33138
33318
  error: err instanceof Error ? err.message : String(err)
33139
33319
  });
33140
33320
  }
33141
- (0, import_core95.setEvalRunService)(evalRunner);
33321
+ (0, import_core97.setEvalRunService)(evalRunner);
33142
33322
  try {
33143
- const menuStore = (0, import_core96.getStoreLattice)("default", "menu").store;
33144
- (0, import_core95.setMenuRegistry)(menuStore);
33323
+ const menuStore = (0, import_core98.getStoreLattice)("default", "menu").store;
33324
+ (0, import_core97.setMenuRegistry)(menuStore);
33145
33325
  logger7.info("Menu registry initialized");
33146
33326
  } catch {
33147
33327
  }
@@ -33158,10 +33338,10 @@ var start = async (config) => {
33158
33338
  const { A2AAuthService: A2AAuthService2, parseEnvKeys: parseEnvKeys2 } = await Promise.resolve().then(() => (init_A2AAuthService(), A2AAuthService_exports));
33159
33339
  const { registerA2AStandardRoutes: registerA2AStandardRoutes2 } = await Promise.resolve().then(() => (init_a2a_standard(), a2a_standard_exports));
33160
33340
  const a2a = await Promise.resolve().then(() => (init_a2a(), a2a_exports));
33161
- const a2aKeyStore = (0, import_core96.getStoreLattice)("default", "a2aApiKey").store;
33162
- const assistantStore = (0, import_core96.getStoreLattice)("default", "assistant").store;
33163
- const projectStore = (0, import_core96.getStoreLattice)("default", "project").store;
33164
- const taskStore = (0, import_core96.getStoreLattice)("default", "task").store;
33341
+ const a2aKeyStore = (0, import_core98.getStoreLattice)("default", "a2aApiKey").store;
33342
+ const assistantStore = (0, import_core98.getStoreLattice)("default", "assistant").store;
33343
+ const projectStore = (0, import_core98.getStoreLattice)("default", "project").store;
33344
+ const taskStore = (0, import_core98.getStoreLattice)("default", "task").store;
33165
33345
  const authService = new A2AAuthService2({
33166
33346
  keyStore: a2aKeyStore,
33167
33347
  assistantStore,
@@ -33200,8 +33380,8 @@ var start = async (config) => {
33200
33380
  const { CollectionService: CollectionService2 } = await Promise.resolve().then(() => (init_collection_service(), collection_service_exports));
33201
33381
  openLattice2.register(createKbProvider2(new CollectionService2()));
33202
33382
  openLattice2.register(createOpenSandboxProvider2());
33203
- const threadStore = (0, import_core96.getStoreLattice)("default", "thread").store;
33204
- const assistantStore = (0, import_core96.getStoreLattice)("default", "assistant").store;
33383
+ const threadStore = (0, import_core98.getStoreLattice)("default", "thread").store;
33384
+ const assistantStore = (0, import_core98.getStoreLattice)("default", "assistant").store;
33205
33385
  openLattice2.register(
33206
33386
  createAgentProvider2({
33207
33387
  threadStore,
@@ -33235,15 +33415,15 @@ var start = async (config) => {
33235
33415
  error: err instanceof Error ? err.message : String(err)
33236
33416
  });
33237
33417
  }
33238
- if (!import_core96.sandboxLatticeManager.hasLattice("default")) {
33239
- import_core96.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
33418
+ if (!import_core98.sandboxLatticeManager.hasLattice("default")) {
33419
+ import_core98.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
33240
33420
  logger7.info("Registered sandbox manager from env configuration");
33241
33421
  }
33242
33422
  if (isPluginDeploymentRuntimeEnabled()) {
33243
33423
  try {
33244
- const pluginDeploymentStore = (0, import_core96.getStoreLattice)("default", "pluginDeployment").store;
33245
- const tenantStore = (0, import_core96.getStoreLattice)("default", "tenant").store;
33246
- const leaseStore2 = (0, import_core96.getStoreLattice)("default", "lease").store;
33424
+ const pluginDeploymentStore = (0, import_core98.getStoreLattice)("default", "pluginDeployment").store;
33425
+ const tenantStore = (0, import_core98.getStoreLattice)("default", "tenant").store;
33426
+ const leaseStore2 = (0, import_core98.getStoreLattice)("default", "lease").store;
33247
33427
  const listAllDeployments = async () => {
33248
33428
  const tenants = await tenantStore.getAllTenants();
33249
33429
  const lists = await Promise.all(
@@ -33256,9 +33436,9 @@ var start = async (config) => {
33256
33436
  const pluginDeploymentRuntime = startPluginDeploymentRuntime({
33257
33437
  wiring: {
33258
33438
  store: pluginDeploymentStore,
33259
- sandboxManager: (0, import_core96.getSandBoxManager)(),
33260
- catalog: (0, import_core96.getSandboxPluginCatalog)(),
33261
- installPluginHost: import_core96.installPluginHost,
33439
+ sandboxManager: (0, import_core98.getSandBoxManager)(),
33440
+ catalog: (0, import_core98.getSandboxPluginCatalog)(),
33441
+ installPluginHost: import_core98.installPluginHost,
33262
33442
  limits: readPluginDeploymentLimits(),
33263
33443
  serviceKey: process.env.MICROSANDBOX_API_KEY,
33264
33444
  listAllDeployments,
@@ -33270,7 +33450,7 @@ var start = async (config) => {
33270
33450
  }
33271
33451
  },
33272
33452
  lease: leaseStore2,
33273
- holder: (0, import_core96.getReplicaId)(),
33453
+ holder: (0, import_core98.getReplicaId)(),
33274
33454
  logger: logger7
33275
33455
  });
33276
33456
  app.addHook("onClose", async () => {
@@ -33285,11 +33465,11 @@ var start = async (config) => {
33285
33465
  }
33286
33466
  try {
33287
33467
  const { ResourceController: ResourceController2 } = await Promise.resolve().then(() => (init_resources(), resources_exports));
33288
- const sharedResourceStore = (0, import_core96.getStoreLattice)("default", "sharedResource").store;
33289
- const cache2 = new import_core96.TokenCache();
33468
+ const sharedResourceStore = (0, import_core98.getStoreLattice)("default", "sharedResource").store;
33469
+ const cache2 = new import_core98.TokenCache();
33290
33470
  const resourceController = new ResourceController2({
33291
33471
  store: sharedResourceStore,
33292
- sandboxManager: import_core96.sandboxLatticeManager,
33472
+ sandboxManager: import_core98.sandboxLatticeManager,
33293
33473
  cache: cache2,
33294
33474
  logger: logger7
33295
33475
  });
@@ -33301,15 +33481,14 @@ var start = async (config) => {
33301
33481
  });
33302
33482
  }
33303
33483
  if (channelDeps && process.env.CHANNELS_ENABLED !== "false") {
33304
- const { connectAllChannels, disconnectAllChannels, ChannelConnectionLeader } = await import("@axiom-lattice/core");
33305
33484
  try {
33306
- const channelLeader = new ChannelConnectionLeader({
33307
- leaseStore: (0, import_core96.getStoreLattice)("default", "lease").store,
33308
- owner: (0, import_core96.getReplicaId)(),
33309
- connect: () => connectAllChannels((channel) => adapterRegistry.get(channel), {
33485
+ const channelLeader = new import_core98.ChannelConnectionLeader({
33486
+ leaseStore: (0, import_core98.getStoreLattice)("default", "lease").store,
33487
+ owner: (0, import_core98.getReplicaId)(),
33488
+ connect: () => (0, import_core98.connectAllChannels)((channel) => adapterRegistry.get(channel), {
33310
33489
  deps: { router: channelDeps.router }
33311
33490
  }),
33312
- disconnect: () => disconnectAllChannels((channel) => adapterRegistry.get(channel)),
33491
+ disconnect: () => (0, import_core98.disconnectAllChannels)((channel) => adapterRegistry.get(channel)),
33313
33492
  log: { warn: (message, context) => logger7.warn(message, context) }
33314
33493
  });
33315
33494
  app.addHook("onClose", async () => {
@@ -33323,40 +33502,40 @@ var start = async (config) => {
33323
33502
  }
33324
33503
  }
33325
33504
  const target_port = config?.port || Number(process.env.PORT) || 4001;
33326
- (0, import_core96.configureCoordinationLeaseStore)((0, import_core96.getStoreLattice)("default", "lease").store);
33327
- const outboxStore = (0, import_core96.getStoreLattice)("default", "outbox").store;
33328
- import_core96.taskLifecycleNotifier.setOutbox(outboxStore);
33329
- import_core96.projectTaskAdmissionNotifier.setOutbox(outboxStore);
33330
- (0, import_core96.configurePluginCatalogSync)({ outbox: outboxStore, owner: (0, import_core96.getReplicaId)() });
33505
+ (0, import_core98.configureCoordinationLeaseStore)((0, import_core98.getStoreLattice)("default", "lease").store);
33506
+ const outboxStore = (0, import_core98.getStoreLattice)("default", "outbox").store;
33507
+ import_core98.taskLifecycleNotifier.setOutbox(outboxStore);
33508
+ import_core98.projectTaskAdmissionNotifier.setOutbox(outboxStore);
33509
+ (0, import_core98.configurePluginCatalogSync)({ outbox: outboxStore, owner: (0, import_core98.getReplicaId)() });
33331
33510
  bridgeAssistantEvents(
33332
- (event, cb) => import_core96.eventBus.subscribe(event, cb),
33511
+ (event, cb) => import_core98.eventBus.subscribe(event, cb),
33333
33512
  outboxStore,
33334
- (0, import_core96.getReplicaId)()
33513
+ (0, import_core98.getReplicaId)()
33335
33514
  );
33336
33515
  if (projectRoomRealtimeRuntime) {
33337
33516
  projectRoomRealtimeRuntime.broker.setBroadcastHook((scope, serialized, sourceKey) => {
33338
- void publishRoomEvent(outboxStore, (0, import_core96.getReplicaId)(), scope, serialized, sourceKey);
33517
+ void publishRoomEvent(outboxStore, (0, import_core98.getReplicaId)(), scope, serialized, sourceKey);
33339
33518
  });
33340
33519
  }
33341
- const outboxPoller = new import_core96.OutboxPoller({
33520
+ const outboxPoller = new import_core98.OutboxPoller({
33342
33521
  store: outboxStore,
33343
- owner: (0, import_core96.getReplicaId)(),
33522
+ owner: (0, import_core98.getReplicaId)(),
33344
33523
  handlers: {
33345
- "task-lifecycle": (payload) => import_core96.taskLifecycleNotifier.deliverFromOutbox(payload),
33346
- "project-task-admission": (payload) => import_core96.projectTaskAdmissionNotifier.deliverFromOutbox(payload),
33524
+ "task-lifecycle": (payload) => import_core98.taskLifecycleNotifier.deliverFromOutbox(payload),
33525
+ "project-task-admission": (payload) => import_core98.projectTaskAdmissionNotifier.deliverFromOutbox(payload),
33347
33526
  [ROOM_EVENT_TOPIC]: async (payload) => {
33348
33527
  if (projectRoomRealtimeRuntime) ingestRoomEvent(payload, projectRoomRealtimeRuntime.broker);
33349
33528
  },
33350
- "assistant-changed": (payload) => handleAssistantChanged(payload, (tenantId) => import_core96.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId)),
33529
+ "assistant-changed": (payload) => handleAssistantChanged(payload, (tenantId) => import_core98.agentLatticeManager.initializeStoredAssistantsForTenant(tenantId)),
33351
33530
  [A2A_KEY_CHANGED_TOPIC]: (payload) => handleA2AKeyChanged(payload, () => refreshStoreKeyMap()),
33352
33531
  [MCP_CONFIG_CHANGED_TOPIC]: (payload) => reconcileMcpConfigChange(payload, {
33353
- store: (0, import_core96.getStoreLattice)("default", "mcp").store,
33354
- manager: import_core96.mcpManager,
33355
- convertToConnection: import_core96.convertToConnection
33532
+ store: (0, import_core98.getStoreLattice)("default", "mcp").store,
33533
+ manager: import_core98.mcpManager,
33534
+ convertToConnection: import_core98.convertToConnection
33356
33535
  }),
33357
- [import_core96.PLUGIN_CATALOG_CHANGED_TOPIC]: async (payload) => {
33536
+ [import_core98.PLUGIN_CATALOG_CHANGED_TOPIC]: async (payload) => {
33358
33537
  const tenantId = payload?.tenantId;
33359
- if (typeof tenantId === "string" && tenantId.length > 0) (0, import_core96.getSandboxPluginCatalog)().invalidate(tenantId);
33538
+ if (typeof tenantId === "string" && tenantId.length > 0) (0, import_core98.getSandboxPluginCatalog)().invalidate(tenantId);
33360
33539
  },
33361
33540
  [MODEL_PROVIDER_CHANGED_TOPIC]: async (payload) => {
33362
33541
  const controller = routes.modelProviderController;
@@ -33371,7 +33550,7 @@ var start = async (config) => {
33371
33550
  } catch (err) {
33372
33551
  logger7.warn("Outbox poller failed to start", { error: err instanceof Error ? err.message : String(err) });
33373
33552
  }
33374
- const leaseStore = (0, import_core96.getStoreLattice)("default", "lease").store;
33553
+ const leaseStore = (0, import_core98.getStoreLattice)("default", "lease").store;
33375
33554
  if (leaseStore.constructor?.name === "InMemoryLeaseStore") {
33376
33555
  logger7.warn(
33377
33556
  "Startup recovery leader gate uses a non-distributed lease store (per-process only); configure a shared 'lease' store for multi-replica deployments",
@@ -33379,7 +33558,7 @@ var start = async (config) => {
33379
33558
  );
33380
33559
  }
33381
33560
  warnMultiReplicaReadiness(logger7);
33382
- const startup = await (0, import_core96.runAsLeader)(leaseStore, "startup-recovery", async () => {
33561
+ const startup = await (0, import_core98.runAsLeader)(leaseStore, "startup-recovery", async () => {
33383
33562
  if (routes.projectTaskRuntime) {
33384
33563
  await prepareProjectTaskRuntime(routes.projectTaskRuntime, logger7);
33385
33564
  }
@@ -33388,9 +33567,9 @@ var start = async (config) => {
33388
33567
  const { createOrphanRecoveryRuntime: createOrphanRecoveryRuntime2 } = await Promise.resolve().then(() => (init_OrphanRecoveryRuntime(), OrphanRecoveryRuntime_exports));
33389
33568
  const { createRecoveryCallerDeps: createRecoveryCallerDeps2 } = await Promise.resolve().then(() => (init_RecoveryCallerDeps(), RecoveryCallerDeps_exports));
33390
33569
  const runtime = createOrphanRecoveryRuntime2({
33391
- taskStore: (0, import_core96.getStoreLattice)("default", "task").store,
33392
- workItemStore: (0, import_core96.getStoreLattice)("default", "taskWorkItem").store,
33393
- tenantStore: (0, import_core96.getStoreLattice)("default", "tenant").store,
33570
+ taskStore: (0, import_core98.getStoreLattice)("default", "task").store,
33571
+ workItemStore: (0, import_core98.getStoreLattice)("default", "taskWorkItem").store,
33572
+ tenantStore: (0, import_core98.getStoreLattice)("default", "tenant").store,
33394
33573
  ...createRecoveryCallerDeps2(),
33395
33574
  log: logger7
33396
33575
  });
@@ -33399,9 +33578,9 @@ var start = async (config) => {
33399
33578
  logger7.warn("Task orphan recovery failed", { error: err instanceof Error ? err.message : String(err) });
33400
33579
  }
33401
33580
  }
33402
- if (import_core96.scheduleLatticeManager.hasLattice("default")) {
33581
+ if (import_core98.scheduleLatticeManager.hasLattice("default")) {
33403
33582
  try {
33404
- const restored = await import_core96.scheduleLatticeManager.getScheduleLattice("default").restore();
33583
+ const restored = await import_core98.scheduleLatticeManager.getScheduleLattice("default").restore();
33405
33584
  logger7.info("Scheduled tasks restored", { phase: "startup_recovery", restored });
33406
33585
  } catch (err) {
33407
33586
  logger7.warn("Scheduled task restore failed", {
@@ -33444,7 +33623,7 @@ var start = async (config) => {
33444
33623
  steps: [
33445
33624
  async () => {
33446
33625
  await Promise.all(
33447
- import_core96.agentInstanceManager.getAllAgents().map((agent) => agent.abort().catch(() => void 0))
33626
+ import_core98.agentInstanceManager.getAllAgents().map((agent) => agent.abort().catch(() => void 0))
33448
33627
  );
33449
33628
  },
33450
33629
  () => agentTaskConsumer?.stopPollingQueue(),