@axiom-lattice/gateway 2.1.63 → 2.1.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1709,6 +1709,296 @@ async function executeSqlQuery(client, body, reply) {
1709
1709
  };
1710
1710
  }
1711
1711
 
1712
+ // src/controllers/workflow-tracking.ts
1713
+ import { getStoreLattice as getStoreLattice4, agentInstanceManager as agentInstanceManager4 } from "@axiom-lattice/core";
1714
+ function getTenantId6(request) {
1715
+ const userTenantId = request.user?.tenantId;
1716
+ if (userTenantId) return userTenantId;
1717
+ return request.headers["x-tenant-id"] || "default";
1718
+ }
1719
+ function getTrackingStore() {
1720
+ try {
1721
+ const storeLattice = getStoreLattice4("default", "workflowTracking");
1722
+ return storeLattice.store;
1723
+ } catch {
1724
+ return null;
1725
+ }
1726
+ }
1727
+ async function getDefinitionsFromAssistants(tenantId) {
1728
+ try {
1729
+ const storeLattice = getStoreLattice4("default", "assistant");
1730
+ const assistantStore = storeLattice.store;
1731
+ const assistants = await assistantStore.getAllAssistants(tenantId);
1732
+ const results = [];
1733
+ for (const a of assistants) {
1734
+ const def = a.graphDefinition;
1735
+ if (!def || def.type !== "processing") continue;
1736
+ if (!def.middleware) continue;
1737
+ for (const mw of def.middleware) {
1738
+ if (mw.type === "topology" && mw.enabled && mw.config?.edges?.length > 0) {
1739
+ results.push({
1740
+ assistantId: a.id,
1741
+ assistantName: a.name,
1742
+ topologyEdges: mw.config.edges,
1743
+ totalEdges: mw.config.edges.length
1744
+ });
1745
+ }
1746
+ }
1747
+ }
1748
+ return results;
1749
+ } catch {
1750
+ return [];
1751
+ }
1752
+ }
1753
+ async function getAllWorkflowDefinitions(request, reply) {
1754
+ const tenantId = getTenantId6(request);
1755
+ try {
1756
+ const configDefs = await getDefinitionsFromAssistants(tenantId);
1757
+ if (configDefs.length === 0) {
1758
+ return {
1759
+ success: true,
1760
+ message: "No workflow definitions found",
1761
+ data: { records: [] }
1762
+ };
1763
+ }
1764
+ const runMap = /* @__PURE__ */ new Map();
1765
+ try {
1766
+ const store = getTrackingStore();
1767
+ if (store) {
1768
+ const runs = await store.getWorkflowRunsByTenantId(tenantId);
1769
+ for (const r of runs) {
1770
+ const entry = runMap.get(r.assistantId) || { runCount: 0 };
1771
+ entry.runCount++;
1772
+ if (!entry.lastRunAt || new Date(r.startedAt) > new Date(entry.lastRunAt)) {
1773
+ entry.lastRunAt = r.startedAt instanceof Date ? r.startedAt.toISOString() : String(r.startedAt);
1774
+ }
1775
+ runMap.set(r.assistantId, entry);
1776
+ }
1777
+ }
1778
+ } catch {
1779
+ }
1780
+ const definitions = configDefs.map((d) => {
1781
+ const runInfo = runMap.get(d.assistantId);
1782
+ return {
1783
+ ...d,
1784
+ lastRunAt: runInfo?.lastRunAt || null,
1785
+ runCount: runInfo?.runCount || 0
1786
+ };
1787
+ });
1788
+ return {
1789
+ success: true,
1790
+ message: "Successfully retrieved workflow definitions",
1791
+ data: { records: definitions }
1792
+ };
1793
+ } catch (error) {
1794
+ request.log.error(error, "Failed to get workflow definitions");
1795
+ return reply.status(500).send({ success: false, message: "Failed to retrieve workflow definitions" });
1796
+ }
1797
+ }
1798
+ async function getAllWorkflowRuns(request, reply) {
1799
+ const tenantId = getTenantId6(request);
1800
+ const { assistantId, status } = request.query;
1801
+ try {
1802
+ const store = getTrackingStore();
1803
+ if (!store) {
1804
+ return reply.status(404).send({ success: false, message: "No workflow tracking store configured" });
1805
+ }
1806
+ let runs;
1807
+ if (assistantId) {
1808
+ runs = await store.getWorkflowRunsByAssistantId(tenantId, assistantId);
1809
+ } else {
1810
+ runs = await store.getWorkflowRunsByTenantId(tenantId);
1811
+ }
1812
+ if (status) {
1813
+ runs = runs.filter((r) => r.status === status);
1814
+ }
1815
+ return {
1816
+ success: true,
1817
+ message: "Successfully retrieved workflow runs",
1818
+ data: { records: runs, total: runs.length }
1819
+ };
1820
+ } catch (error) {
1821
+ request.log.error(error, "Failed to get workflow runs");
1822
+ return reply.status(500).send({ success: false, message: "Failed to retrieve workflow runs" });
1823
+ }
1824
+ }
1825
+ async function getInboxItems(request, reply) {
1826
+ const tenantId = getTenantId6(request);
1827
+ try {
1828
+ const store = getTrackingStore();
1829
+ if (!store) {
1830
+ return { success: true, message: "No tracking store configured", data: { records: [] } };
1831
+ }
1832
+ const nameMap = {};
1833
+ try {
1834
+ const asStoreLattice = getStoreLattice4("default", "assistant");
1835
+ const assistantStore = asStoreLattice.store;
1836
+ const assistants = await assistantStore.getAllAssistants(tenantId);
1837
+ for (const a of assistants) {
1838
+ nameMap[a.id] = a.name;
1839
+ }
1840
+ } catch {
1841
+ }
1842
+ const runs = await store.getWorkflowRunsByTenantId(tenantId);
1843
+ const runningRuns = runs.filter((r) => r.status === "running");
1844
+ if (runningRuns.length === 0) {
1845
+ return { success: true, message: "No running workflows", data: { records: [] } };
1846
+ }
1847
+ const inboxItems = [];
1848
+ for (const r of runningRuns) {
1849
+ try {
1850
+ const agent = agentInstanceManager4.getAgent({
1851
+ assistant_id: r.assistantId,
1852
+ thread_id: r.threadId,
1853
+ tenant_id: r.tenantId
1854
+ });
1855
+ const runStatus = await agent.getRunStatus();
1856
+ if (runStatus !== "interrupted") continue;
1857
+ const state = await agent.getCurrentState();
1858
+ const interrupts = state.tasks?.flatMap((t) => t.interrupts || []) || [];
1859
+ for (const i of interrupts) {
1860
+ inboxItems.push({
1861
+ runId: r.id,
1862
+ assistantId: r.assistantId,
1863
+ assistantName: nameMap[r.assistantId] || r.assistantId,
1864
+ threadId: r.threadId,
1865
+ tenantId: r.tenantId,
1866
+ interruptId: i.id,
1867
+ interruptValue: i.value,
1868
+ startedAt: r.startedAt,
1869
+ totalEdges: r.totalEdges,
1870
+ completedEdges: r.completedEdges
1871
+ });
1872
+ }
1873
+ } catch {
1874
+ }
1875
+ }
1876
+ inboxItems.sort(
1877
+ (a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()
1878
+ );
1879
+ return {
1880
+ success: true,
1881
+ message: "Successfully retrieved inbox items",
1882
+ data: { records: inboxItems }
1883
+ };
1884
+ } catch (error) {
1885
+ request.log.error(error, "Failed to get inbox items");
1886
+ return reply.status(500).send({ success: false, message: "Failed to retrieve inbox items" });
1887
+ }
1888
+ }
1889
+ async function getWorkflowDefinitions(request, reply) {
1890
+ const { assistantId } = request.params;
1891
+ const tenantId = getTenantId6(request);
1892
+ try {
1893
+ const store = getTrackingStore();
1894
+ if (!store) {
1895
+ return reply.status(404).send({ success: false, message: "No workflow tracking store configured" });
1896
+ }
1897
+ const runs = await store.getWorkflowRunsByAssistantId(tenantId, assistantId);
1898
+ const seen = /* @__PURE__ */ new Set();
1899
+ const definitions = runs.filter((r) => {
1900
+ const key = JSON.stringify(r.topologyEdges);
1901
+ if (seen.has(key)) return false;
1902
+ seen.add(key);
1903
+ return true;
1904
+ }).map((r) => ({
1905
+ assistantId: r.assistantId,
1906
+ topologyEdges: r.topologyEdges,
1907
+ totalEdges: r.totalEdges,
1908
+ lastRunAt: r.startedAt
1909
+ }));
1910
+ return {
1911
+ success: true,
1912
+ message: "Successfully retrieved workflow definitions",
1913
+ data: { records: definitions }
1914
+ };
1915
+ } catch (error) {
1916
+ request.log.error(error, "Failed to get workflow definitions");
1917
+ return reply.status(500).send({ success: false, message: "Failed to retrieve workflow definitions" });
1918
+ }
1919
+ }
1920
+ async function getWorkflowRuns(request, reply) {
1921
+ const { threadId } = request.params;
1922
+ const tenantId = getTenantId6(request);
1923
+ try {
1924
+ const store = getTrackingStore();
1925
+ if (!store) {
1926
+ return reply.status(404).send({ success: false, message: "No workflow tracking store configured" });
1927
+ }
1928
+ const runs = await store.getWorkflowRunsByThreadId(tenantId, threadId);
1929
+ return {
1930
+ success: true,
1931
+ message: "Successfully retrieved workflow runs",
1932
+ data: { records: runs, total: runs.length }
1933
+ };
1934
+ } catch (error) {
1935
+ request.log.error(error, "Failed to get workflow runs");
1936
+ return reply.status(500).send({ success: false, message: "Failed to retrieve workflow runs" });
1937
+ }
1938
+ }
1939
+ async function getWorkflowRun(request, reply) {
1940
+ const { runId } = request.params;
1941
+ try {
1942
+ const store = getTrackingStore();
1943
+ if (!store) {
1944
+ return reply.status(404).send({ success: false, message: "No workflow tracking store configured" });
1945
+ }
1946
+ const run = await store.getWorkflowRun(runId);
1947
+ if (!run) {
1948
+ return reply.status(404).send({ success: false, message: "Workflow run not found" });
1949
+ }
1950
+ return { success: true, message: "Successfully retrieved workflow run", data: run };
1951
+ } catch (error) {
1952
+ request.log.error(error, "Failed to get workflow run");
1953
+ return reply.status(500).send({ success: false, message: "Failed to retrieve workflow run" });
1954
+ }
1955
+ }
1956
+ async function getRunSteps(request, reply) {
1957
+ const { runId } = request.params;
1958
+ const { step_type, status: stepStatus } = request.query;
1959
+ try {
1960
+ const store = getTrackingStore();
1961
+ if (!store) {
1962
+ return reply.status(404).send({ success: false, message: "No workflow tracking store configured" });
1963
+ }
1964
+ let steps;
1965
+ if (step_type) {
1966
+ steps = await store.getRunStepsByType(runId, step_type);
1967
+ } else {
1968
+ steps = await store.getRunSteps(runId);
1969
+ }
1970
+ if (stepStatus) {
1971
+ steps = steps.filter((s) => s.status === stepStatus);
1972
+ }
1973
+ return {
1974
+ success: true,
1975
+ message: "Successfully retrieved run steps",
1976
+ data: { records: steps, total: steps.length }
1977
+ };
1978
+ } catch (error) {
1979
+ request.log.error(error, "Failed to get run steps");
1980
+ return reply.status(500).send({ success: false, message: "Failed to retrieve run steps" });
1981
+ }
1982
+ }
1983
+ async function getRunTasks(request, reply) {
1984
+ const { runId } = request.params;
1985
+ try {
1986
+ const store = getTrackingStore();
1987
+ if (!store) {
1988
+ return reply.status(404).send({ success: false, message: "No workflow tracking store configured" });
1989
+ }
1990
+ const steps = await store.getInterruptedSteps(runId);
1991
+ return {
1992
+ success: true,
1993
+ message: "Successfully retrieved user tasks",
1994
+ data: { records: steps, total: steps.length }
1995
+ };
1996
+ } catch (error) {
1997
+ request.log.error(error, "Failed to get run tasks");
1998
+ return reply.status(500).send({ success: false, message: "Failed to retrieve user tasks" });
1999
+ }
2000
+ }
2001
+
1712
2002
  // src/schemas/data-query.ts
1713
2003
  var dataQuerySchema = {
1714
2004
  description: "Execute data query (semantic or SQL)",
@@ -2050,7 +2340,7 @@ var getHealthSchema = {
2050
2340
  };
2051
2341
 
2052
2342
  // src/controllers/thread_status.ts
2053
- import { agentInstanceManager as agentInstanceManager4 } from "@axiom-lattice/core";
2343
+ import { agentInstanceManager as agentInstanceManager5 } from "@axiom-lattice/core";
2054
2344
  async function removePendingMessageHandler(request, reply) {
2055
2345
  try {
2056
2346
  const { assistant_id, thread_id, message_id } = request.params;
@@ -2063,7 +2353,7 @@ async function removePendingMessageHandler(request, reply) {
2063
2353
  if (!assistant_id) {
2064
2354
  return reply.code(400).send({ error: "Missing assistant_id parameter" });
2065
2355
  }
2066
- const agent = agentInstanceManager4.getAgent({
2356
+ const agent = agentInstanceManager5.getAgent({
2067
2357
  assistant_id,
2068
2358
  thread_id,
2069
2359
  tenant_id,
@@ -2393,14 +2683,14 @@ function registerSandboxProxyRoutes(app2) {
2393
2683
  // src/controllers/workspace.ts
2394
2684
  import * as fs from "fs/promises";
2395
2685
  import * as path from "path";
2396
- import { getStoreLattice as getStoreLattice4 } from "@axiom-lattice/core";
2686
+ import { getStoreLattice as getStoreLattice5 } from "@axiom-lattice/core";
2397
2687
  import { SandboxFilesystem, FilesystemBackend } from "@axiom-lattice/core";
2398
2688
  import { getSandBoxManager as getSandBoxManager3 } from "@axiom-lattice/core";
2399
2689
  import { v4 as uuidv4 } from "uuid";
2400
2690
  var WorkspaceController = class {
2401
2691
  constructor() {
2402
- this.workspaceStore = getStoreLattice4("default", "workspace").store;
2403
- this.projectStore = getStoreLattice4("default", "project").store;
2692
+ this.workspaceStore = getStoreLattice5("default", "workspace").store;
2693
+ this.projectStore = getStoreLattice5("default", "project").store;
2404
2694
  }
2405
2695
  getTenantId(request) {
2406
2696
  const userTenantId = request.user?.tenantId;
@@ -2925,11 +3215,11 @@ function registerWorkspaceRoutes(app2) {
2925
3215
 
2926
3216
  // src/controllers/database-configs.ts
2927
3217
  import {
2928
- getStoreLattice as getStoreLattice5,
3218
+ getStoreLattice as getStoreLattice6,
2929
3219
  sqlDatabaseManager
2930
3220
  } from "@axiom-lattice/core";
2931
3221
  import { randomUUID as randomUUID3 } from "crypto";
2932
- function getTenantId6(request) {
3222
+ function getTenantId7(request) {
2933
3223
  const userTenantId = request.user?.tenantId;
2934
3224
  if (userTenantId) {
2935
3225
  return userTenantId;
@@ -2937,9 +3227,9 @@ function getTenantId6(request) {
2937
3227
  return request.headers["x-tenant-id"] || "default";
2938
3228
  }
2939
3229
  async function getDatabaseConfigList(request, reply) {
2940
- const tenantId = getTenantId6(request);
3230
+ const tenantId = getTenantId7(request);
2941
3231
  try {
2942
- const storeLattice = getStoreLattice5("default", "database");
3232
+ const storeLattice = getStoreLattice6("default", "database");
2943
3233
  const store = storeLattice.store;
2944
3234
  const configs = await store.getAllConfigs(tenantId);
2945
3235
  console.log("Backend: getAllConfigs returned:", configs);
@@ -2967,10 +3257,10 @@ async function getDatabaseConfigList(request, reply) {
2967
3257
  }
2968
3258
  }
2969
3259
  async function getDatabaseConfig(request, reply) {
2970
- const tenantId = getTenantId6(request);
3260
+ const tenantId = getTenantId7(request);
2971
3261
  const { key } = request.params;
2972
3262
  try {
2973
- const storeLattice = getStoreLattice5("default", "database");
3263
+ const storeLattice = getStoreLattice6("default", "database");
2974
3264
  const store = storeLattice.store;
2975
3265
  const config = await store.getConfigByKey(tenantId, key);
2976
3266
  if (!config) {
@@ -2993,10 +3283,10 @@ async function getDatabaseConfig(request, reply) {
2993
3283
  }
2994
3284
  }
2995
3285
  async function createDatabaseConfig(request, reply) {
2996
- const tenantId = getTenantId6(request);
3286
+ const tenantId = getTenantId7(request);
2997
3287
  const body = request.body;
2998
3288
  try {
2999
- const storeLattice = getStoreLattice5("default", "database");
3289
+ const storeLattice = getStoreLattice6("default", "database");
3000
3290
  const store = storeLattice.store;
3001
3291
  const existing = await store.getConfigByKey(tenantId, body.key);
3002
3292
  if (existing) {
@@ -3028,11 +3318,11 @@ async function createDatabaseConfig(request, reply) {
3028
3318
  }
3029
3319
  }
3030
3320
  async function updateDatabaseConfig(request, reply) {
3031
- const tenantId = getTenantId6(request);
3321
+ const tenantId = getTenantId7(request);
3032
3322
  const { key } = request.params;
3033
3323
  const updates = request.body;
3034
3324
  try {
3035
- const storeLattice = getStoreLattice5("default", "database");
3325
+ const storeLattice = getStoreLattice6("default", "database");
3036
3326
  const store = storeLattice.store;
3037
3327
  const existing = await store.getConfigByKey(tenantId, key);
3038
3328
  if (!existing) {
@@ -3070,10 +3360,10 @@ async function updateDatabaseConfig(request, reply) {
3070
3360
  }
3071
3361
  }
3072
3362
  async function deleteDatabaseConfig(request, reply) {
3073
- const tenantId = getTenantId6(request);
3363
+ const tenantId = getTenantId7(request);
3074
3364
  const { keyOrId } = request.params;
3075
3365
  try {
3076
- const storeLattice = getStoreLattice5("default", "database");
3366
+ const storeLattice = getStoreLattice6("default", "database");
3077
3367
  const store = storeLattice.store;
3078
3368
  console.log("Delete request - keyOrId:", keyOrId);
3079
3369
  let config = await store.getConfigByKey(tenantId, keyOrId);
@@ -3119,10 +3409,10 @@ async function deleteDatabaseConfig(request, reply) {
3119
3409
  }
3120
3410
  }
3121
3411
  async function testDatabaseConnection(request, reply) {
3122
- const tenantId = getTenantId6(request);
3412
+ const tenantId = getTenantId7(request);
3123
3413
  const { key } = request.params;
3124
3414
  try {
3125
- const storeLattice = getStoreLattice5("default", "database");
3415
+ const storeLattice = getStoreLattice6("default", "database");
3126
3416
  const store = storeLattice.store;
3127
3417
  const config = await store.getConfigByKey(tenantId, key);
3128
3418
  if (!config) {
@@ -3207,12 +3497,12 @@ function registerDatabaseConfigRoutes(app2) {
3207
3497
 
3208
3498
  // src/controllers/metrics-configs.ts
3209
3499
  import {
3210
- getStoreLattice as getStoreLattice6,
3500
+ getStoreLattice as getStoreLattice7,
3211
3501
  metricsServerManager as metricsServerManager2,
3212
3502
  SemanticMetricsClient as SemanticMetricsClient2
3213
3503
  } from "@axiom-lattice/core";
3214
3504
  import { randomUUID as randomUUID4 } from "crypto";
3215
- function getTenantId7(request) {
3505
+ function getTenantId8(request) {
3216
3506
  const userTenantId = request.user?.tenantId;
3217
3507
  if (userTenantId) {
3218
3508
  return userTenantId;
@@ -3220,9 +3510,9 @@ function getTenantId7(request) {
3220
3510
  return request.headers["x-tenant-id"] || "default";
3221
3511
  }
3222
3512
  async function getMetricsServerConfigList(request, reply) {
3223
- const tenantId = getTenantId7(request);
3513
+ const tenantId = getTenantId8(request);
3224
3514
  try {
3225
- const storeLattice = getStoreLattice6("default", "metrics");
3515
+ const storeLattice = getStoreLattice7("default", "metrics");
3226
3516
  const store = storeLattice.store;
3227
3517
  const configs = await store.getAllConfigs(tenantId);
3228
3518
  return {
@@ -3246,10 +3536,10 @@ async function getMetricsServerConfigList(request, reply) {
3246
3536
  }
3247
3537
  }
3248
3538
  async function getMetricsServerConfig(request, reply) {
3249
- const tenantId = getTenantId7(request);
3539
+ const tenantId = getTenantId8(request);
3250
3540
  const { key } = request.params;
3251
3541
  try {
3252
- const storeLattice = getStoreLattice6("default", "metrics");
3542
+ const storeLattice = getStoreLattice7("default", "metrics");
3253
3543
  const store = storeLattice.store;
3254
3544
  const config = await store.getConfigByKey(tenantId, key);
3255
3545
  if (!config) {
@@ -3272,10 +3562,10 @@ async function getMetricsServerConfig(request, reply) {
3272
3562
  }
3273
3563
  }
3274
3564
  async function createMetricsServerConfig(request, reply) {
3275
- const tenantId = getTenantId7(request);
3565
+ const tenantId = getTenantId8(request);
3276
3566
  const body = request.body;
3277
3567
  try {
3278
- const storeLattice = getStoreLattice6("default", "metrics");
3568
+ const storeLattice = getStoreLattice7("default", "metrics");
3279
3569
  const store = storeLattice.store;
3280
3570
  const existing = await store.getConfigByKey(tenantId, body.key);
3281
3571
  if (existing) {
@@ -3323,11 +3613,11 @@ async function createMetricsServerConfig(request, reply) {
3323
3613
  }
3324
3614
  }
3325
3615
  async function updateMetricsServerConfig(request, reply) {
3326
- const tenantId = getTenantId7(request);
3616
+ const tenantId = getTenantId8(request);
3327
3617
  const { key } = request.params;
3328
3618
  const updates = request.body;
3329
3619
  try {
3330
- const storeLattice = getStoreLattice6("default", "metrics");
3620
+ const storeLattice = getStoreLattice7("default", "metrics");
3331
3621
  const store = storeLattice.store;
3332
3622
  const existing = await store.getConfigByKey(tenantId, key);
3333
3623
  if (!existing) {
@@ -3374,10 +3664,10 @@ async function updateMetricsServerConfig(request, reply) {
3374
3664
  }
3375
3665
  }
3376
3666
  async function deleteMetricsServerConfig(request, reply) {
3377
- const tenantId = getTenantId7(request);
3667
+ const tenantId = getTenantId8(request);
3378
3668
  const { keyOrId } = request.params;
3379
3669
  try {
3380
- const storeLattice = getStoreLattice6("default", "metrics");
3670
+ const storeLattice = getStoreLattice7("default", "metrics");
3381
3671
  const store = storeLattice.store;
3382
3672
  let config = await store.getConfigByKey(tenantId, keyOrId);
3383
3673
  let configKey = keyOrId;
@@ -3421,10 +3711,10 @@ async function deleteMetricsServerConfig(request, reply) {
3421
3711
  }
3422
3712
  }
3423
3713
  async function testMetricsServerConnection(request, reply) {
3424
- const tenantId = getTenantId7(request);
3714
+ const tenantId = getTenantId8(request);
3425
3715
  const { key } = request.params;
3426
3716
  try {
3427
- const storeLattice = getStoreLattice6("default", "metrics");
3717
+ const storeLattice = getStoreLattice7("default", "metrics");
3428
3718
  const store = storeLattice.store;
3429
3719
  const config = await store.getConfigByKey(tenantId, key);
3430
3720
  if (!config) {
@@ -3472,10 +3762,10 @@ async function testMetricsServerConnection(request, reply) {
3472
3762
  }
3473
3763
  }
3474
3764
  async function listAvailableMetrics(request, reply) {
3475
- const tenantId = getTenantId7(request);
3765
+ const tenantId = getTenantId8(request);
3476
3766
  const { key } = request.params;
3477
3767
  try {
3478
- const storeLattice = getStoreLattice6("default", "metrics");
3768
+ const storeLattice = getStoreLattice7("default", "metrics");
3479
3769
  const store = storeLattice.store;
3480
3770
  const config = await store.getConfigByKey(tenantId, key);
3481
3771
  if (!config) {
@@ -3510,11 +3800,11 @@ async function listAvailableMetrics(request, reply) {
3510
3800
  }
3511
3801
  }
3512
3802
  async function queryMetricsData(request, reply) {
3513
- const tenantId = getTenantId7(request);
3803
+ const tenantId = getTenantId8(request);
3514
3804
  const { key } = request.params;
3515
3805
  const { metricName, startTime, endTime, step, labels } = request.body;
3516
3806
  try {
3517
- const storeLattice = getStoreLattice6("default", "metrics");
3807
+ const storeLattice = getStoreLattice7("default", "metrics");
3518
3808
  const store = storeLattice.store;
3519
3809
  const config = await store.getConfigByKey(tenantId, key);
3520
3810
  if (!config) {
@@ -3558,10 +3848,10 @@ async function queryMetricsData(request, reply) {
3558
3848
  }
3559
3849
  }
3560
3850
  async function getDataSources(request, reply) {
3561
- const tenantId = getTenantId7(request);
3851
+ const tenantId = getTenantId8(request);
3562
3852
  const { key } = request.params;
3563
3853
  try {
3564
- const storeLattice = getStoreLattice6("default", "metrics");
3854
+ const storeLattice = getStoreLattice7("default", "metrics");
3565
3855
  const store = storeLattice.store;
3566
3856
  const config = await store.getConfigByKey(tenantId, key);
3567
3857
  if (!config) {
@@ -3599,10 +3889,10 @@ async function getDataSources(request, reply) {
3599
3889
  }
3600
3890
  }
3601
3891
  async function getDatasourceMetrics(request, reply) {
3602
- const tenantId = getTenantId7(request);
3892
+ const tenantId = getTenantId8(request);
3603
3893
  const { key, datasourceId } = request.params;
3604
3894
  try {
3605
- const storeLattice = getStoreLattice6("default", "metrics");
3895
+ const storeLattice = getStoreLattice7("default", "metrics");
3606
3896
  const store = storeLattice.store;
3607
3897
  const config = await store.getConfigByKey(tenantId, key);
3608
3898
  if (!config) {
@@ -3636,11 +3926,11 @@ async function getDatasourceMetrics(request, reply) {
3636
3926
  }
3637
3927
  }
3638
3928
  async function querySemanticMetrics(request, reply) {
3639
- const tenantId = getTenantId7(request);
3929
+ const tenantId = getTenantId8(request);
3640
3930
  const { key } = request.params;
3641
3931
  const body = request.body;
3642
3932
  try {
3643
- const storeLattice = getStoreLattice6("default", "metrics");
3933
+ const storeLattice = getStoreLattice7("default", "metrics");
3644
3934
  const store = storeLattice.store;
3645
3935
  const config = await store.getConfigByKey(tenantId, key);
3646
3936
  if (!config) {
@@ -3794,12 +4084,12 @@ function registerMetricsServerConfigRoutes(app2) {
3794
4084
 
3795
4085
  // src/controllers/mcp-configs.ts
3796
4086
  import {
3797
- getStoreLattice as getStoreLattice7,
4087
+ getStoreLattice as getStoreLattice8,
3798
4088
  mcpManager,
3799
4089
  toolLatticeManager as toolLatticeManager2
3800
4090
  } from "@axiom-lattice/core";
3801
4091
  import { randomUUID as randomUUID5 } from "crypto";
3802
- function getTenantId8(request) {
4092
+ function getTenantId9(request) {
3803
4093
  const userTenantId = request.user?.tenantId;
3804
4094
  if (userTenantId) {
3805
4095
  return userTenantId;
@@ -3807,9 +4097,9 @@ function getTenantId8(request) {
3807
4097
  return request.headers["x-tenant-id"] || "default";
3808
4098
  }
3809
4099
  async function getMcpServerConfigList(request, reply) {
3810
- const tenantId = getTenantId8(request);
4100
+ const tenantId = getTenantId9(request);
3811
4101
  try {
3812
- const storeLattice = getStoreLattice7("default", "mcp");
4102
+ const storeLattice = getStoreLattice8("default", "mcp");
3813
4103
  const store = storeLattice.store;
3814
4104
  const configs = await store.getAllConfigs(tenantId);
3815
4105
  return {
@@ -3833,10 +4123,10 @@ async function getMcpServerConfigList(request, reply) {
3833
4123
  }
3834
4124
  }
3835
4125
  async function getMcpServerConfig(request, reply) {
3836
- const tenantId = getTenantId8(request);
4126
+ const tenantId = getTenantId9(request);
3837
4127
  const { key } = request.params;
3838
4128
  try {
3839
- const storeLattice = getStoreLattice7("default", "mcp");
4129
+ const storeLattice = getStoreLattice8("default", "mcp");
3840
4130
  const store = storeLattice.store;
3841
4131
  const config = await store.getConfigByKey(tenantId, key);
3842
4132
  if (!config) {
@@ -3859,10 +4149,10 @@ async function getMcpServerConfig(request, reply) {
3859
4149
  }
3860
4150
  }
3861
4151
  async function createMcpServerConfig(request, reply) {
3862
- const tenantId = getTenantId8(request);
4152
+ const tenantId = getTenantId9(request);
3863
4153
  const body = request.body;
3864
4154
  try {
3865
- const storeLattice = getStoreLattice7("default", "mcp");
4155
+ const storeLattice = getStoreLattice8("default", "mcp");
3866
4156
  const store = storeLattice.store;
3867
4157
  const existing = await store.getConfigByKey(tenantId, body.key);
3868
4158
  if (existing) {
@@ -3898,11 +4188,11 @@ async function createMcpServerConfig(request, reply) {
3898
4188
  }
3899
4189
  }
3900
4190
  async function updateMcpServerConfig(request, reply) {
3901
- const tenantId = getTenantId8(request);
4191
+ const tenantId = getTenantId9(request);
3902
4192
  const { key } = request.params;
3903
4193
  const updates = request.body;
3904
4194
  try {
3905
- const storeLattice = getStoreLattice7("default", "mcp");
4195
+ const storeLattice = getStoreLattice8("default", "mcp");
3906
4196
  const store = storeLattice.store;
3907
4197
  const existing = await store.getConfigByKey(tenantId, key);
3908
4198
  if (!existing) {
@@ -3948,10 +4238,10 @@ async function updateMcpServerConfig(request, reply) {
3948
4238
  }
3949
4239
  }
3950
4240
  async function deleteMcpServerConfig(request, reply) {
3951
- const tenantId = getTenantId8(request);
4241
+ const tenantId = getTenantId9(request);
3952
4242
  const { keyOrId } = request.params;
3953
4243
  try {
3954
- const storeLattice = getStoreLattice7("default", "mcp");
4244
+ const storeLattice = getStoreLattice8("default", "mcp");
3955
4245
  const store = storeLattice.store;
3956
4246
  let config = await store.getConfigByKey(tenantId, keyOrId);
3957
4247
  let configKey = keyOrId;
@@ -3995,10 +4285,10 @@ async function deleteMcpServerConfig(request, reply) {
3995
4285
  }
3996
4286
  }
3997
4287
  async function testMcpServerConnection(request, reply) {
3998
- const tenantId = getTenantId8(request);
4288
+ const tenantId = getTenantId9(request);
3999
4289
  const { key } = request.params;
4000
4290
  try {
4001
- const storeLattice = getStoreLattice7("default", "mcp");
4291
+ const storeLattice = getStoreLattice8("default", "mcp");
4002
4292
  const store = storeLattice.store;
4003
4293
  const config = await store.getConfigByKey(tenantId, key);
4004
4294
  if (!config) {
@@ -4048,10 +4338,10 @@ async function testMcpServerConnection(request, reply) {
4048
4338
  }
4049
4339
  }
4050
4340
  async function listMcpServerTools(request, reply) {
4051
- const tenantId = getTenantId8(request);
4341
+ const tenantId = getTenantId9(request);
4052
4342
  const { key } = request.params;
4053
4343
  try {
4054
- const storeLattice = getStoreLattice7("default", "mcp");
4344
+ const storeLattice = getStoreLattice8("default", "mcp");
4055
4345
  const store = storeLattice.store;
4056
4346
  const config = await store.getConfigByKey(tenantId, key);
4057
4347
  if (!config) {
@@ -4081,10 +4371,10 @@ async function listMcpServerTools(request, reply) {
4081
4371
  }
4082
4372
  }
4083
4373
  async function connectMcpServer(request, reply) {
4084
- const tenantId = getTenantId8(request);
4374
+ const tenantId = getTenantId9(request);
4085
4375
  const { key } = request.params;
4086
4376
  try {
4087
- const storeLattice = getStoreLattice7("default", "mcp");
4377
+ const storeLattice = getStoreLattice8("default", "mcp");
4088
4378
  const store = storeLattice.store;
4089
4379
  const config = await store.getConfigByKey(tenantId, key);
4090
4380
  if (!config) {
@@ -4105,7 +4395,7 @@ async function connectMcpServer(request, reply) {
4105
4395
  };
4106
4396
  } catch (error) {
4107
4397
  console.error("Failed to connect MCP server:", error);
4108
- const storeLattice = getStoreLattice7("default", "mcp");
4398
+ const storeLattice = getStoreLattice8("default", "mcp");
4109
4399
  const store = storeLattice.store;
4110
4400
  const config = await store.getConfigByKey(tenantId, key);
4111
4401
  if (config) {
@@ -4118,10 +4408,10 @@ async function connectMcpServer(request, reply) {
4118
4408
  }
4119
4409
  }
4120
4410
  async function disconnectMcpServer(request, reply) {
4121
- const tenantId = getTenantId8(request);
4411
+ const tenantId = getTenantId9(request);
4122
4412
  const { key } = request.params;
4123
4413
  try {
4124
- const storeLattice = getStoreLattice7("default", "mcp");
4414
+ const storeLattice = getStoreLattice8("default", "mcp");
4125
4415
  const store = storeLattice.store;
4126
4416
  const config = await store.getConfigByKey(tenantId, key);
4127
4417
  if (!config) {
@@ -4226,11 +4516,11 @@ function registerMcpServerConfigRoutes(app2) {
4226
4516
  }
4227
4517
 
4228
4518
  // src/controllers/users.ts
4229
- import { getStoreLattice as getStoreLattice8 } from "@axiom-lattice/core";
4519
+ import { getStoreLattice as getStoreLattice9 } from "@axiom-lattice/core";
4230
4520
  import { v4 as uuidv42 } from "uuid";
4231
4521
  var UsersController = class {
4232
4522
  constructor() {
4233
- this.userStore = getStoreLattice8("default", "user").store;
4523
+ this.userStore = getStoreLattice9("default", "user").store;
4234
4524
  }
4235
4525
  async listUsers(request, reply) {
4236
4526
  const { email } = request.query;
@@ -4308,11 +4598,11 @@ function registerUserRoutes(app2) {
4308
4598
  }
4309
4599
 
4310
4600
  // src/controllers/tenants.ts
4311
- import { getStoreLattice as getStoreLattice9 } from "@axiom-lattice/core";
4601
+ import { getStoreLattice as getStoreLattice10 } from "@axiom-lattice/core";
4312
4602
  import { v4 as uuidv43 } from "uuid";
4313
4603
  var TenantsController = class {
4314
4604
  constructor() {
4315
- this.tenantStore = getStoreLattice9("default", "tenant").store;
4605
+ this.tenantStore = getStoreLattice10("default", "tenant").store;
4316
4606
  }
4317
4607
  // ==================== Tenant CRUD ====================
4318
4608
  async listTenants(request, reply) {
@@ -4376,7 +4666,7 @@ function registerTenantRoutes(app2) {
4376
4666
  }
4377
4667
 
4378
4668
  // src/controllers/auth.ts
4379
- import { getStoreLattice as getStoreLattice10 } from "@axiom-lattice/core";
4669
+ import { getStoreLattice as getStoreLattice11 } from "@axiom-lattice/core";
4380
4670
  import { v4 as uuidv44 } from "uuid";
4381
4671
  var defaultAuthConfig = {
4382
4672
  autoApproveUsers: true,
@@ -4385,9 +4675,9 @@ var defaultAuthConfig = {
4385
4675
  };
4386
4676
  var AuthController = class {
4387
4677
  constructor(config = {}) {
4388
- this.userStore = getStoreLattice10("default", "user").store;
4389
- this.tenantStore = getStoreLattice10("default", "tenant").store;
4390
- this.userTenantLinkStore = getStoreLattice10("default", "userTenantLink").store;
4678
+ this.userStore = getStoreLattice11("default", "user").store;
4679
+ this.tenantStore = getStoreLattice11("default", "tenant").store;
4680
+ this.userTenantLinkStore = getStoreLattice11("default", "userTenantLink").store;
4391
4681
  this.config = { ...defaultAuthConfig, ...config };
4392
4682
  }
4393
4683
  async register(request, reply) {
@@ -4759,7 +5049,7 @@ function registerAuthRoutes(app2, config) {
4759
5049
  }
4760
5050
 
4761
5051
  // src/channels/lark/routes.ts
4762
- import { getStoreLattice as getStoreLattice11 } from "@axiom-lattice/core";
5052
+ import { getStoreLattice as getStoreLattice12 } from "@axiom-lattice/core";
4763
5053
  import {
4764
5054
  ChannelIdentityMappingStore,
4765
5055
  PostgreSQLChannelInstallationStore
@@ -5010,7 +5300,7 @@ function resolveSubjectType(mappingMode, chatType) {
5010
5300
  }
5011
5301
 
5012
5302
  // src/channels/lark/runner.ts
5013
- import { agentInstanceManager as agentInstanceManager5 } from "@axiom-lattice/core";
5303
+ import { agentInstanceManager as agentInstanceManager6 } from "@axiom-lattice/core";
5014
5304
  import { MessageChunkTypes as MessageChunkTypes3 } from "@axiom-lattice/protocols";
5015
5305
 
5016
5306
  // src/channels/lark/aggregator.ts
@@ -5023,7 +5313,7 @@ function aggregateLarkReply(messageId, chunks) {
5023
5313
 
5024
5314
  // src/channels/lark/runner.ts
5025
5315
  async function runAgentAndCollectLarkReply(input) {
5026
- const agent = agentInstanceManager5.getAgent({
5316
+ const agent = agentInstanceManager6.getAgent({
5027
5317
  tenant_id: input.tenantId,
5028
5318
  assistant_id: input.assistantId,
5029
5319
  thread_id: input.threadId,
@@ -5135,7 +5425,7 @@ function createDefaultLarkDependencies() {
5135
5425
  const installationStore = new PostgreSQLChannelInstallationStore({
5136
5426
  poolConfig: getDatabaseUrl()
5137
5427
  });
5138
- const threadStore = getStoreLattice11("default", "thread").store;
5428
+ const threadStore = getStoreLattice12("default", "thread").store;
5139
5429
  const mappingStore = new ChannelIdentityMappingStore({
5140
5430
  poolConfig: getDatabaseUrl()
5141
5431
  });
@@ -5216,7 +5506,7 @@ function registerChannelRoutes(app2, dependencies = {}) {
5216
5506
 
5217
5507
  // src/controllers/channel-installations.ts
5218
5508
  import { randomUUID as randomUUID7 } from "crypto";
5219
- function getTenantId9(request) {
5509
+ function getTenantId10(request) {
5220
5510
  const userTenantId = request.user?.tenantId;
5221
5511
  if (userTenantId) {
5222
5512
  return userTenantId;
@@ -5234,7 +5524,7 @@ async function getInstallationStore() {
5234
5524
  });
5235
5525
  }
5236
5526
  async function getChannelInstallationList(request, reply) {
5237
- const tenantId = getTenantId9(request);
5527
+ const tenantId = getTenantId10(request);
5238
5528
  const { channel } = request.query;
5239
5529
  try {
5240
5530
  const store = await getInstallationStore();
@@ -5260,7 +5550,7 @@ async function getChannelInstallationList(request, reply) {
5260
5550
  }
5261
5551
  }
5262
5552
  async function getChannelInstallation(request, reply) {
5263
- const tenantId = getTenantId9(request);
5553
+ const tenantId = getTenantId10(request);
5264
5554
  const { installationId } = request.params;
5265
5555
  try {
5266
5556
  const store = await getInstallationStore();
@@ -5293,7 +5583,7 @@ async function getChannelInstallation(request, reply) {
5293
5583
  }
5294
5584
  }
5295
5585
  async function createChannelInstallation(request, reply) {
5296
- const tenantId = getTenantId9(request);
5586
+ const tenantId = getTenantId10(request);
5297
5587
  const body = request.body;
5298
5588
  try {
5299
5589
  if (!body.channel) {
@@ -5356,7 +5646,7 @@ async function createChannelInstallation(request, reply) {
5356
5646
  }
5357
5647
  }
5358
5648
  async function updateChannelInstallation(request, reply) {
5359
- const tenantId = getTenantId9(request);
5649
+ const tenantId = getTenantId10(request);
5360
5650
  const { installationId } = request.params;
5361
5651
  const body = request.body;
5362
5652
  try {
@@ -5402,7 +5692,7 @@ async function updateChannelInstallation(request, reply) {
5402
5692
  }
5403
5693
  }
5404
5694
  async function deleteChannelInstallation(request, reply) {
5405
- const tenantId = getTenantId9(request);
5695
+ const tenantId = getTenantId10(request);
5406
5696
  const { installationId } = request.params;
5407
5697
  try {
5408
5698
  const store = await getInstallationStore();
@@ -5588,6 +5878,29 @@ var registerLatticeRoutes = (app2) => {
5588
5878
  });
5589
5879
  registerChannelRoutes(app2);
5590
5880
  registerChannelInstallationRoutes(app2);
5881
+ app2.get(
5882
+ "/api/workflows/definitions",
5883
+ getAllWorkflowDefinitions
5884
+ );
5885
+ app2.get(
5886
+ "/api/workflows/runs",
5887
+ getAllWorkflowRuns
5888
+ );
5889
+ app2.get(
5890
+ "/api/workflows/inbox",
5891
+ getInboxItems
5892
+ );
5893
+ app2.get(
5894
+ "/api/assistants/:assistantId/workflows/definitions",
5895
+ getWorkflowDefinitions
5896
+ );
5897
+ app2.get(
5898
+ "/api/assistants/:assistantId/threads/:threadId/workflows/runs",
5899
+ getWorkflowRuns
5900
+ );
5901
+ app2.get("/api/workflows/runs/:runId", getWorkflowRun);
5902
+ app2.get("/api/workflows/runs/:runId/steps", getRunSteps);
5903
+ app2.get("/api/workflows/runs/:runId/tasks", getRunTasks);
5591
5904
  app2.delete(
5592
5905
  "/api/assistants/:assistant_id/threads/:thread_id/pending-messages/:message_id",
5593
5906
  removePendingMessageHandler
@@ -5657,7 +5970,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
5657
5970
  };
5658
5971
 
5659
5972
  // src/services/agent_task_consumer.ts
5660
- import { eventBus as eventBus2, AGENT_TASK_EVENT, agentInstanceManager as agentInstanceManager6, QueueMode as QueueMode2 } from "@axiom-lattice/core";
5973
+ import { eventBus as eventBus2, AGENT_TASK_EVENT, agentInstanceManager as agentInstanceManager7, QueueMode as QueueMode2 } from "@axiom-lattice/core";
5661
5974
  var handleAgentTask = async (taskRequest, retryCount = 0) => {
5662
5975
  const {
5663
5976
  assistant_id,
@@ -5666,13 +5979,16 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
5666
5979
  "x-tenant-id": tenant_id,
5667
5980
  command,
5668
5981
  callback_event,
5669
- runConfig
5982
+ runConfig,
5983
+ main_thread_id,
5984
+ main_tenant_id,
5985
+ main_assistant_id
5670
5986
  } = taskRequest;
5671
5987
  try {
5672
5988
  console.log(
5673
5989
  `\u5F00\u59CB\u5904\u7406\u4EFB\u52A1 [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
5674
5990
  );
5675
- const agent = agentInstanceManager6.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: runConfig?.workspaceId, project_id: runConfig?.projectId, custom_run_config: runConfig });
5991
+ const agent = agentInstanceManager7.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: runConfig?.workspaceId, project_id: runConfig?.projectId, custom_run_config: runConfig });
5676
5992
  await agent.addMessage({ input, command, custom_run_config: runConfig }, QueueMode2.STEER);
5677
5993
  if (callback_event) {
5678
5994
  agent.subscribeOnce("message:completed", (evt) => {
@@ -5681,6 +5997,34 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
5681
5997
  state: evt.state,
5682
5998
  config: { assistant_id, thread_id, tenant_id }
5683
5999
  });
6000
+ if (main_thread_id && main_tenant_id) {
6001
+ try {
6002
+ const mainAgent = agentInstanceManager7.getAgent({
6003
+ assistant_id: main_assistant_id ?? assistant_id,
6004
+ thread_id: main_thread_id,
6005
+ tenant_id: main_tenant_id
6006
+ });
6007
+ if (mainAgent) {
6008
+ const messages = evt.state?.values?.messages;
6009
+ const lastAIMessage = messages?.filter((m) => m.type === "ai" || m.getType?.() === "ai").pop();
6010
+ const summary = lastAIMessage?.content?.substring(0, 500) ?? "(no output)";
6011
+ mainAgent.addMessage(
6012
+ {
6013
+ input: {
6014
+ message: `[Async task completed]
6015
+ task_id: ${thread_id}
6016
+ ${summary}`
6017
+ }
6018
+ }
6019
+ ).catch((err) => {
6020
+ console.error("Failed to notify main thread:", err);
6021
+ });
6022
+ mainAgent.updateAsyncTaskStatus(thread_id, "completed");
6023
+ }
6024
+ } catch (err) {
6025
+ console.error("Failed to notify main thread:", err);
6026
+ }
6027
+ }
5684
6028
  });
5685
6029
  agent.subscribeOnce("message:interrupted", (evt) => {
5686
6030
  eventBus2.publish(callback_event, {
@@ -5890,8 +6234,9 @@ import {
5890
6234
  loggerLatticeManager,
5891
6235
  sandboxLatticeManager as sandboxLatticeManager2,
5892
6236
  sqlDatabaseManager as sqlDatabaseManager2,
5893
- getStoreLattice as getStoreLattice12,
5894
- agentInstanceManager as agentInstanceManager7,
6237
+ getStoreLattice as getStoreLattice13,
6238
+ storeLatticeManager,
6239
+ agentInstanceManager as agentInstanceManager8,
5895
6240
  createSandboxProvider
5896
6241
  } from "@axiom-lattice/core";
5897
6242
  import {
@@ -6039,7 +6384,7 @@ var start = async (config) => {
6039
6384
  app.decorate("loggerLattice", loggerLattice);
6040
6385
  registerLatticeRoutes(app);
6041
6386
  try {
6042
- const storeLattice = getStoreLattice12("default", "database");
6387
+ const storeLattice = getStoreLattice13("default", "database");
6043
6388
  const store = storeLattice.store;
6044
6389
  sqlDatabaseManager2.setConfigStore(store);
6045
6390
  logger.info("Database config store set for SqlDatabaseManager");
@@ -6050,6 +6395,21 @@ var start = async (config) => {
6050
6395
  sandboxLatticeManager2.registerLattice("default", getConfiguredSandboxProvider());
6051
6396
  logger.info("Registered sandbox manager from env configuration");
6052
6397
  }
6398
+ if (process.env.DATABASE_URL) {
6399
+ try {
6400
+ const { PostgreSQLWorkflowTrackingStore } = await import("@axiom-lattice/pg-stores");
6401
+ const pgStore = new PostgreSQLWorkflowTrackingStore({
6402
+ poolConfig: process.env.DATABASE_URL
6403
+ });
6404
+ if (storeLatticeManager.hasLattice("default", "workflowTracking")) {
6405
+ storeLatticeManager.removeLattice("default", "workflowTracking");
6406
+ }
6407
+ storeLatticeManager.registerLattice("default", "workflowTracking", pgStore);
6408
+ logger.info("Workflow tracking store switched to PostgreSQL");
6409
+ } catch (error) {
6410
+ logger.warn("Failed to switch workflow tracking to PostgreSQL, keeping in-memory: " + (error instanceof Error ? error.message : String(error)));
6411
+ }
6412
+ }
6053
6413
  const target_port = config?.port || Number(process.env.PORT) || 4001;
6054
6414
  await app.listen({ port: target_port, host: "0.0.0.0" });
6055
6415
  logger.info(`Lattice Gateway is running on port: ${target_port}`);
@@ -6068,7 +6428,7 @@ var start = async (config) => {
6068
6428
  }
6069
6429
  try {
6070
6430
  logger.info("Starting agent instance recovery...");
6071
- const restoreStats = await agentInstanceManager7.restore();
6431
+ const restoreStats = await agentInstanceManager8.restore();
6072
6432
  logger.info(`Agent recovery complete: ${restoreStats.restored} threads restored, ${restoreStats.errors} errors`);
6073
6433
  } catch (error) {
6074
6434
  logger.error("Agent recovery failed", { error });