@axiom-lattice/gateway 4.9.2 → 4.10.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 (25) hide show
  1. package/dist/embed/{embed-page-AgentDetailSideApp-WQAMMDXN.js → embed-page-AgentDetailSideApp-2M4MLVQQ.js} +1 -1
  2. package/dist/embed/{embed-page-AgentGovernanceWorkbench-VKD4IZIO.js → embed-page-AgentGovernanceWorkbench-KEVBIQP6.js} +1 -1
  3. package/dist/embed/{embed-page-MessageGraph-C4EJWY3E.js → embed-page-MessageGraph-PRBUQINR.js} +1 -1
  4. package/dist/embed/{embed-page-ReactChart-TNT4TT4C.js → embed-page-ReactChart-V6JJXCEV.js} +1 -1
  5. package/dist/embed/{embed-page-SkillFlow-WWRDU6GS.js → embed-page-SkillFlow-6LPE2VG3.js} +1 -1
  6. package/dist/embed/{embed-page-TasksSideApp-73SJLGRY.js → embed-page-TasksSideApp-OFZI54MF.js} +1 -1
  7. package/dist/embed/{embed-page-TeamWorkspace-6E4HAH7L.js → embed-page-TeamWorkspace-QSSAF3AA.js} +1 -1
  8. package/dist/embed/{embed-page-TopologyRuntimeView-SXUNRFT4.js → embed-page-TopologyRuntimeView-PHULW2NG.js} +1 -1
  9. package/dist/embed/{embed-page-WorkflowAutomationView-I4VN6YY2.js → embed-page-WorkflowAutomationView-LQS6H7X6.js} +1 -1
  10. package/dist/embed/{embed-page-chunk-TEIHYMTL.js → embed-page-chunk-7PNQFZMK.js} +7 -7
  11. package/dist/embed/{embed-page-chunk-G5NEOKZK.js → embed-page-chunk-D5EY6ASK.js} +1 -1
  12. package/dist/embed/{embed-page-chunk-YZMHK63X.js → embed-page-chunk-IJ2YWGKU.js} +1 -1
  13. package/dist/embed/{embed-page-chunk-WUOHF2QZ.js → embed-page-chunk-O44JEYLD.js} +7 -7
  14. package/dist/embed/embed-page-chunk-PFCR6CFL.js +2 -0
  15. package/dist/embed/{embed-page-chunk-L7HKGCDN.js → embed-page-chunk-SSWDAKQU.js} +1 -1
  16. package/dist/embed/{embed-page-chunk-IM57IYUL.js → embed-page-chunk-YNHKD2CY.js} +1 -1
  17. package/dist/embed/{embed-page-en-GE4GI4D3.js → embed-page-en-ICVL5QAC.js} +1 -1
  18. package/dist/embed/{embed-page-zh-KC2E7UVY.js → embed-page-zh-FPYCTKQK.js} +1 -1
  19. package/dist/embed/embed-page.js +1 -1
  20. package/dist/index.js +342 -140
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +287 -86
  23. package/dist/index.mjs.map +1 -1
  24. package/package.json +8 -7
  25. package/dist/embed/embed-page-chunk-RQXI6NQX.js +0 -2
package/dist/index.js CHANGED
@@ -1731,25 +1731,25 @@ function extractText(msg) {
1731
1731
  }
1732
1732
  return null;
1733
1733
  }
1734
- var import_zod18, logger6, wechatConfigSchema, MAX_RECONNECT_DELAY_MS, BASE_RECONNECT_DELAY_MS, HEARTBEAT_INTERVAL_MS, MSG_TYPE_USER, MSG_ITEM_TEXT, activeConnections2, seenClientIds, wechatChannelAdapter;
1734
+ var import_zod19, logger7, wechatConfigSchema, MAX_RECONNECT_DELAY_MS, BASE_RECONNECT_DELAY_MS, HEARTBEAT_INTERVAL_MS, MSG_TYPE_USER, MSG_ITEM_TEXT, activeConnections3, seenClientIds, wechatChannelAdapter;
1735
1735
  var init_WechatChannelAdapter = __esm({
1736
1736
  "src/channels/wechat/WechatChannelAdapter.ts"() {
1737
1737
  "use strict";
1738
- import_zod18 = require("zod");
1738
+ import_zod19 = require("zod");
1739
1739
  init_wechat_client();
1740
1740
  init_context_store();
1741
1741
  init_Logger();
1742
- logger6 = new Logger({ serviceName: "lattice/gateway/wechat" });
1743
- wechatConfigSchema = import_zod18.z.object({
1744
- botToken: import_zod18.z.string(),
1745
- uin: import_zod18.z.string().optional()
1742
+ logger7 = new Logger({ serviceName: "lattice/gateway/wechat" });
1743
+ wechatConfigSchema = import_zod19.z.object({
1744
+ botToken: import_zod19.z.string(),
1745
+ uin: import_zod19.z.string().optional()
1746
1746
  });
1747
1747
  MAX_RECONNECT_DELAY_MS = 3e4;
1748
1748
  BASE_RECONNECT_DELAY_MS = 1e3;
1749
1749
  HEARTBEAT_INTERVAL_MS = 6e4;
1750
1750
  MSG_TYPE_USER = 1;
1751
1751
  MSG_ITEM_TEXT = 1;
1752
- activeConnections2 = /* @__PURE__ */ new Map();
1752
+ activeConnections3 = /* @__PURE__ */ new Map();
1753
1753
  seenClientIds = /* @__PURE__ */ new Set();
1754
1754
  wechatChannelAdapter = {
1755
1755
  channel: "wechat",
@@ -1790,7 +1790,7 @@ var init_WechatChannelAdapter = __esm({
1790
1790
  const senderId = replyTarget.rawTarget.senderId;
1791
1791
  const contextToken = getContextToken(installation.id, senderId);
1792
1792
  if (!contextToken) {
1793
- logger6.warn("WeChat context token expired, cannot send reply", {
1793
+ logger7.warn("WeChat context token expired, cannot send reply", {
1794
1794
  installationId: installation.id,
1795
1795
  senderId
1796
1796
  });
@@ -1808,24 +1808,24 @@ var init_WechatChannelAdapter = __esm({
1808
1808
  async connect(installation, deps) {
1809
1809
  const { id: installationId, tenantId, config } = installation;
1810
1810
  if (!config.botToken) {
1811
- logger6.warn("WeChat installation missing botToken, skipping", { installationId });
1811
+ logger7.warn("WeChat installation missing botToken, skipping", { installationId });
1812
1812
  return;
1813
1813
  }
1814
- if (activeConnections2.has(installationId)) {
1815
- logger6.warn("WeChat polling already running for installation, skipping", { installationId });
1814
+ if (activeConnections3.has(installationId)) {
1815
+ logger7.warn("WeChat polling already running for installation, skipping", { installationId });
1816
1816
  return;
1817
1817
  }
1818
- logger6.info("WeChat polling starting", { installationId, tenantId });
1818
+ logger7.info("WeChat polling starting", { installationId, tenantId });
1819
1819
  const abortController = new AbortController();
1820
1820
  const heartbeatTimer = setInterval(() => {
1821
- const state2 = activeConnections2.get(installationId);
1821
+ const state2 = activeConnections3.get(installationId);
1822
1822
  if (!state2) {
1823
1823
  clearInterval(heartbeatTimer);
1824
1824
  return;
1825
1825
  }
1826
1826
  const elapsed = Date.now() - state2.lastActivity;
1827
1827
  if (elapsed > HEARTBEAT_INTERVAL_MS * 2) {
1828
- logger6.error("WeChat polling heartbeat lost \u2014 no activity", {
1828
+ logger7.error("WeChat polling heartbeat lost \u2014 no activity", {
1829
1829
  installationId,
1830
1830
  elapsedMs: elapsed
1831
1831
  });
@@ -1838,26 +1838,26 @@ var init_WechatChannelAdapter = __esm({
1838
1838
  lastActivity: Date.now(),
1839
1839
  heartbeatTimer
1840
1840
  };
1841
- activeConnections2.set(installationId, state);
1841
+ activeConnections3.set(installationId, state);
1842
1842
  const router = deps?.router;
1843
1843
  let syncBuffer = "";
1844
1844
  let reconnectDelay = BASE_RECONNECT_DELAY_MS;
1845
1845
  const scheduleNextPoll = () => {
1846
1846
  poll().catch((err) => {
1847
- logger6.error("WeChat poll iteration crashed", {
1847
+ logger7.error("WeChat poll iteration crashed", {
1848
1848
  installationId,
1849
1849
  error: err instanceof Error ? err.message : String(err)
1850
1850
  });
1851
- const currentState = activeConnections2.get(installationId);
1851
+ const currentState = activeConnections3.get(installationId);
1852
1852
  if (currentState && !currentState.abortController.signal.aborted) {
1853
1853
  setTimeout(scheduleNextPoll, reconnectDelay);
1854
1854
  }
1855
1855
  });
1856
1856
  };
1857
1857
  const poll = async () => {
1858
- const currentState = activeConnections2.get(installationId);
1858
+ const currentState = activeConnections3.get(installationId);
1859
1859
  if (!currentState || currentState.abortController.signal.aborted) {
1860
- logger6.info("WeChat polling aborted", { installationId });
1860
+ logger7.info("WeChat polling aborted", { installationId });
1861
1861
  return;
1862
1862
  }
1863
1863
  try {
@@ -1870,7 +1870,7 @@ var init_WechatChannelAdapter = __esm({
1870
1870
  reconnectDelay = BASE_RECONNECT_DELAY_MS;
1871
1871
  currentState.lastActivity = Date.now();
1872
1872
  if (result.msgs.length > 0) {
1873
- logger6.info("WeChat poll received messages", {
1873
+ logger7.info("WeChat poll received messages", {
1874
1874
  installationId,
1875
1875
  count: result.msgs.length
1876
1876
  });
@@ -1887,7 +1887,7 @@ var init_WechatChannelAdapter = __esm({
1887
1887
  if (inbound && router) {
1888
1888
  const dispatchResult = await router.dispatch(inbound);
1889
1889
  if (!dispatchResult.success) {
1890
- logger6.warn("WeChat dispatch failed", {
1890
+ logger7.warn("WeChat dispatch failed", {
1891
1891
  installationId,
1892
1892
  error: dispatchResult.error?.message
1893
1893
  });
@@ -1896,10 +1896,10 @@ var init_WechatChannelAdapter = __esm({
1896
1896
  }
1897
1897
  } catch (err) {
1898
1898
  if (err instanceof Error && err.name === "AbortError") {
1899
- logger6.info("WeChat poll aborted by signal", { installationId });
1899
+ logger7.info("WeChat poll aborted by signal", { installationId });
1900
1900
  return;
1901
1901
  }
1902
- logger6.error("WeChat poll error", {
1902
+ logger7.error("WeChat poll error", {
1903
1903
  installationId,
1904
1904
  error: err instanceof Error ? err.message : String(err)
1905
1905
  });
@@ -1909,19 +1909,19 @@ var init_WechatChannelAdapter = __esm({
1909
1909
  scheduleNextPoll();
1910
1910
  };
1911
1911
  scheduleNextPoll();
1912
- logger6.info("WeChat polling started", { installationId });
1912
+ logger7.info("WeChat polling started", { installationId });
1913
1913
  },
1914
1914
  async disconnect(installationId) {
1915
- const state = activeConnections2.get(installationId);
1915
+ const state = activeConnections3.get(installationId);
1916
1916
  if (!state) {
1917
- logger6.warn("WeChat polling not running, nothing to disconnect", { installationId });
1917
+ logger7.warn("WeChat polling not running, nothing to disconnect", { installationId });
1918
1918
  return;
1919
1919
  }
1920
- logger6.info("WeChat polling disconnecting", { installationId });
1920
+ logger7.info("WeChat polling disconnecting", { installationId });
1921
1921
  state.abortController.abort();
1922
1922
  clearInterval(state.heartbeatTimer);
1923
- activeConnections2.delete(installationId);
1924
- logger6.info("WeChat polling disconnected", { installationId });
1923
+ activeConnections3.delete(installationId);
1924
+ logger7.info("WeChat polling disconnected", { installationId });
1925
1925
  }
1926
1926
  };
1927
1927
  }
@@ -2057,7 +2057,7 @@ function extractFailureReason(task) {
2057
2057
  return extractText2(task.status.message.parts);
2058
2058
  }
2059
2059
  function observationEventKey(task, result, failureReason) {
2060
- const digest = (0, import_node_crypto30.createHash)("sha256").update(JSON.stringify({
2060
+ const digest = (0, import_node_crypto31.createHash)("sha256").update(JSON.stringify({
2061
2061
  state: task.status.state,
2062
2062
  timestamp: task.status.timestamp,
2063
2063
  message: task.status.message,
@@ -2067,7 +2067,7 @@ function observationEventKey(task, result, failureReason) {
2067
2067
  return `a2a-status-observation:${task.id}:${digest}`;
2068
2068
  }
2069
2069
  function snapshotEventKey(task) {
2070
- const digest = (0, import_node_crypto30.createHash)("sha256").update(JSON.stringify(task)).digest("hex");
2070
+ const digest = (0, import_node_crypto31.createHash)("sha256").update(JSON.stringify(task)).digest("hex");
2071
2071
  return `a2a-task-snapshot:${task.id}:${digest}`;
2072
2072
  }
2073
2073
  function isGovernedObservation(state) {
@@ -2079,11 +2079,11 @@ function isA2ATaskSnapshot(value) {
2079
2079
  function snapshotSequence(value) {
2080
2080
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
2081
2081
  }
2082
- var import_node_crypto30, import_node_util, import_core80, TASK_STATUS_TO_A2A_STATE, TITLE_MAX_LENGTH, A2ATaskScopeConflictError, A2ATaskStoreAdapter;
2082
+ var import_node_crypto31, import_node_util, import_core80, TASK_STATUS_TO_A2A_STATE, TITLE_MAX_LENGTH, A2ATaskScopeConflictError, A2ATaskStoreAdapter;
2083
2083
  var init_A2ATaskStoreAdapter = __esm({
2084
2084
  "src/services/a2a/A2ATaskStoreAdapter.ts"() {
2085
2085
  "use strict";
2086
- import_node_crypto30 = require("crypto");
2086
+ import_node_crypto31 = require("crypto");
2087
2087
  import_node_util = require("util");
2088
2088
  import_core80 = require("@axiom-lattice/core");
2089
2089
  TASK_STATUS_TO_A2A_STATE = {
@@ -3601,11 +3601,11 @@ function grantCovers(grants, domain, action) {
3601
3601
  (g) => g.domain === domain && (!g.items || g.items.length === 0 || g.items.includes(action))
3602
3602
  );
3603
3603
  }
3604
- var import_zod19, GrantDeniedError, ValidationError, ActionNotFoundError, OpenLattice, openLattice;
3604
+ var import_zod20, GrantDeniedError, ValidationError, ActionNotFoundError, OpenLattice, openLattice;
3605
3605
  var init_openLattice = __esm({
3606
3606
  "src/services/open/openLattice.ts"() {
3607
3607
  "use strict";
3608
- import_zod19 = require("zod");
3608
+ import_zod20 = require("zod");
3609
3609
  GrantDeniedError = class extends Error {
3610
3610
  constructor(toolName) {
3611
3611
  super(`GRANT_DENIED: no grant covers ${toolName}`);
@@ -3745,7 +3745,7 @@ var init_openLattice = __esm({
3745
3745
  throw new GrantDeniedError(toolName);
3746
3746
  }
3747
3747
  const resolvedSchema = resolved.action.schema;
3748
- const parsed = "safeParse" in resolvedSchema ? resolvedSchema.safeParse(args) : import_zod19.z.object(resolvedSchema).safeParse(args);
3748
+ const parsed = "safeParse" in resolvedSchema ? resolvedSchema.safeParse(args) : import_zod20.z.object(resolvedSchema).safeParse(args);
3749
3749
  if (!parsed.success) {
3750
3750
  throw new ValidationError(parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; "));
3751
3751
  }
@@ -3878,7 +3878,7 @@ var init_openMcpServer = __esm({
3878
3878
 
3879
3879
  // src/services/open/pluginExposeAdapter.ts
3880
3880
  function schemaOf(tool) {
3881
- return tool.lc_kwargs?.schema ?? tool.schema ?? import_zod20.z.object({}).passthrough();
3881
+ return tool.lc_kwargs?.schema ?? tool.schema ?? import_zod21.z.object({}).passthrough();
3882
3882
  }
3883
3883
  function createPluginProvider(domain, tools, options = {}) {
3884
3884
  function toAction(info) {
@@ -3926,11 +3926,11 @@ function createPluginProvider(domain, tools, options = {}) {
3926
3926
  }
3927
3927
  };
3928
3928
  }
3929
- var import_zod20;
3929
+ var import_zod21;
3930
3930
  var init_pluginExposeAdapter = __esm({
3931
3931
  "src/services/open/pluginExposeAdapter.ts"() {
3932
3932
  "use strict";
3933
- import_zod20 = require("zod");
3933
+ import_zod21 = require("zod");
3934
3934
  }
3935
3935
  });
3936
3936
 
@@ -4571,21 +4571,21 @@ function createOpenSandboxProvider() {
4571
4571
  name: "files_read",
4572
4572
  label: "Read files",
4573
4573
  description: "Read a file from the project sandbox.",
4574
- schema: { path: import_zod21.z.string().min(1) },
4574
+ schema: { path: import_zod22.z.string().min(1) },
4575
4575
  annotations: { readOnlyHint: true, destructiveHint: false }
4576
4576
  },
4577
4577
  {
4578
4578
  name: "files_list",
4579
4579
  label: "List files",
4580
4580
  description: "List files under a directory in the project sandbox.",
4581
- schema: { path: import_zod21.z.string(), recursive: import_zod21.z.boolean().optional() },
4581
+ schema: { path: import_zod22.z.string(), recursive: import_zod22.z.boolean().optional() },
4582
4582
  annotations: { readOnlyHint: true, destructiveHint: false }
4583
4583
  },
4584
4584
  {
4585
4585
  name: "files_write",
4586
4586
  label: "Write files",
4587
4587
  description: "Write content to a file in the project sandbox.",
4588
- schema: { path: import_zod21.z.string().min(1), content: import_zod21.z.string() },
4588
+ schema: { path: import_zod22.z.string().min(1), content: import_zod22.z.string() },
4589
4589
  annotations: { readOnlyHint: false, destructiveHint: true }
4590
4590
  },
4591
4591
  {
@@ -4593,9 +4593,9 @@ function createOpenSandboxProvider() {
4593
4593
  label: "Run shell commands",
4594
4594
  description: "Execute a shell command in the project sandbox. Returns stdout (up to 64KB) and exit code.",
4595
4595
  schema: {
4596
- command: import_zod21.z.string().min(1),
4597
- exec_dir: import_zod21.z.string().optional(),
4598
- timeout: import_zod21.z.number().int().min(1e3).optional()
4596
+ command: import_zod22.z.string().min(1),
4597
+ exec_dir: import_zod22.z.string().optional(),
4598
+ timeout: import_zod22.z.number().int().min(1e3).optional()
4599
4599
  },
4600
4600
  annotations: { readOnlyHint: false, destructiveHint: true }
4601
4601
  }
@@ -4650,11 +4650,11 @@ ${truncated}`
4650
4650
  }
4651
4651
  };
4652
4652
  }
4653
- var import_zod21, import_core89, MAX_OUTPUT_BYTES;
4653
+ var import_zod22, import_core89, MAX_OUTPUT_BYTES;
4654
4654
  var init_sandboxProvider = __esm({
4655
4655
  "src/services/open/providers/sandboxProvider.ts"() {
4656
4656
  "use strict";
4657
- import_zod21 = require("zod");
4657
+ import_zod22 = require("zod");
4658
4658
  import_core89 = require("@axiom-lattice/core");
4659
4659
  MAX_OUTPUT_BYTES = 64e3;
4660
4660
  }
@@ -4952,9 +4952,9 @@ function createKbProvider(collectionService3) {
4952
4952
  label: "Search collections",
4953
4953
  description: "Search a knowledge base collection. Returns matched entries with content, metadata and similarity score.",
4954
4954
  schema: {
4955
- collection: import_zod22.z.string().min(1),
4956
- query: import_zod22.z.string().min(1),
4957
- limit: import_zod22.z.number().int().min(1).max(50).optional()
4955
+ collection: import_zod23.z.string().min(1),
4956
+ query: import_zod23.z.string().min(1),
4957
+ limit: import_zod23.z.number().int().min(1).max(50).optional()
4958
4958
  },
4959
4959
  annotations: { readOnlyHint: true, destructiveHint: false }
4960
4960
  }
@@ -4982,11 +4982,11 @@ function createKbProvider(collectionService3) {
4982
4982
  }
4983
4983
  };
4984
4984
  }
4985
- var import_zod22;
4985
+ var import_zod23;
4986
4986
  var init_kbProvider = __esm({
4987
4987
  "src/services/open/providers/kbProvider.ts"() {
4988
4988
  "use strict";
4989
- import_zod22 = require("zod");
4989
+ import_zod23 = require("zod");
4990
4990
  }
4991
4991
  });
4992
4992
 
@@ -5024,7 +5024,7 @@ function createAgentProvider(deps = {}) {
5024
5024
  toolName: `invoke_${assistantId}`,
5025
5025
  label: name,
5026
5026
  description: `Invoke the "${name}" agent${description ? ` \u2014 ${description}` : ""}. Returns its final reply.`,
5027
- schema: { message: import_zod23.z.string().min(1) },
5027
+ schema: { message: import_zod24.z.string().min(1) },
5028
5028
  annotations: { readOnlyHint: false, destructiveHint: false }
5029
5029
  };
5030
5030
  })
@@ -5072,11 +5072,11 @@ function createAgentProvider(deps = {}) {
5072
5072
  }
5073
5073
  };
5074
5074
  }
5075
- var import_zod23, import_core93, import_protocols39, STOP_TYPES;
5075
+ var import_zod24, import_core93, import_protocols39, STOP_TYPES;
5076
5076
  var init_agentProvider = __esm({
5077
5077
  "src/services/open/providers/agentProvider.ts"() {
5078
5078
  "use strict";
5079
- import_zod23 = require("zod");
5079
+ import_zod24 = require("zod");
5080
5080
  import_core93 = require("@axiom-lattice/core");
5081
5081
  import_protocols39 = require("@axiom-lattice/protocols");
5082
5082
  STOP_TYPES = [import_protocols39.MessageChunkTypes.MESSAGE_COMPLETED];
@@ -16375,6 +16375,9 @@ function isLarkConfig(config) {
16375
16375
  function isWechatConfig(config) {
16376
16376
  return isString(config.botToken) && isOptionalString(config.uin);
16377
16377
  }
16378
+ function isWecomConfig(config) {
16379
+ return isString(config.botId) && isString(config.secret) && isOptionalString(config.assistantId);
16380
+ }
16378
16381
  function snapshotPublicCreateRequest(value) {
16379
16382
  const body = snapshotPlainObject(value);
16380
16383
  const allowedKeys = /* @__PURE__ */ new Set([
@@ -16401,6 +16404,9 @@ function snapshotPublicCreateRequest(value) {
16401
16404
  if (body.channel === "wechat" && isWechatConfig(config)) {
16402
16405
  return { ...base, channel: "wechat", config };
16403
16406
  }
16407
+ if (body.channel === "wecom" && isWecomConfig(config)) {
16408
+ return { ...base, channel: "wecom", config };
16409
+ }
16404
16410
  if (body.channel === "email" || body.channel === "slack") return { ...base, channel: body.channel, config };
16405
16411
  return null;
16406
16412
  }
@@ -16421,6 +16427,7 @@ function snapshotPublicUpdateRequest(value, channel) {
16421
16427
  if (!config) return null;
16422
16428
  if (channel === "lark" && !isLarkConfig(config)) return null;
16423
16429
  if (channel === "wechat" && !isWechatConfig(config)) return null;
16430
+ if (channel === "wecom" && !isWecomConfig(config)) return null;
16424
16431
  }
16425
16432
  return {
16426
16433
  name: body.name,
@@ -16773,7 +16780,7 @@ function registerChannelInstallationRoutes(app2) {
16773
16780
  type: "object",
16774
16781
  additionalProperties: false,
16775
16782
  properties: {
16776
- channel: { type: "string", enum: ["lark", "email", "slack", "wechat"] }
16783
+ channel: { type: "string", enum: ["lark", "email", "slack", "wechat", "wecom"] }
16777
16784
  }
16778
16785
  }
16779
16786
  }
@@ -30270,7 +30277,7 @@ var collectionRegistration = {
30270
30277
  var import_core66 = require("@axiom-lattice/core");
30271
30278
  var import_crypto11 = require("crypto");
30272
30279
  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;
30273
- var PUBLIC_CHANNELS = /* @__PURE__ */ new Set(["lark", "email", "slack", "wechat"]);
30280
+ var PUBLIC_CHANNELS = /* @__PURE__ */ new Set(["lark", "email", "slack", "wechat", "wecom"]);
30274
30281
  function isPublicChannel(channel) {
30275
30282
  return typeof channel === "string" && PUBLIC_CHANNELS.has(channel);
30276
30283
  }
@@ -30291,6 +30298,9 @@ function validateImportData(data) {
30291
30298
  if (channel === "wechat" && typeof configRecord.botToken !== "string") {
30292
30299
  throw new Error("WeChat channel installation config requires botToken");
30293
30300
  }
30301
+ if (channel === "wecom" && (typeof configRecord.botId !== "string" || typeof configRecord.secret !== "string")) {
30302
+ throw new Error("WeCom channel installation config requires botId and secret");
30303
+ }
30294
30304
  return {
30295
30305
  channel,
30296
30306
  name: typeof data.name === "string" ? data.name : void 0,
@@ -30976,6 +30986,197 @@ function createAuditLoggerMiddleware() {
30976
30986
  // src/index.ts
30977
30987
  var import_core97 = require("@axiom-lattice/core");
30978
30988
 
30989
+ // src/channels/wecom/WecomChannelAdapter.ts
30990
+ var import_node_crypto27 = require("crypto");
30991
+ var import_zod17 = require("zod");
30992
+ var WecomAiBot = __toESM(require("@wecom/aibot-node-sdk"));
30993
+
30994
+ // src/channels/wecom/parser.ts
30995
+ function parseWecomTextFrame(frame) {
30996
+ if (!frame || typeof frame !== "object") return null;
30997
+ const { headers, body } = frame;
30998
+ const reqId = headers?.req_id;
30999
+ if (typeof reqId !== "string" || !body) return null;
31000
+ if (body.msgtype !== "text") return null;
31001
+ const fromUserId = body.from?.userid;
31002
+ const content = body.text?.content;
31003
+ if (typeof fromUserId !== "string" || typeof content !== "string") {
31004
+ return null;
31005
+ }
31006
+ return {
31007
+ reqId,
31008
+ msgId: typeof body.msgid === "string" ? body.msgid : "",
31009
+ fromUserId,
31010
+ chatId: typeof body.chatid === "string" ? body.chatid : void 0,
31011
+ chatType: body.chattype === "group" ? "group" : "direct",
31012
+ text: content
31013
+ };
31014
+ }
31015
+
31016
+ // src/channels/wecom/WecomChannelAdapter.ts
31017
+ init_Logger();
31018
+ var logger6 = new Logger({ serviceName: "lattice/gateway/wecom" });
31019
+ var wecomConfigSchema = import_zod17.z.object({
31020
+ botId: import_zod17.z.string(),
31021
+ secret: import_zod17.z.string()
31022
+ });
31023
+ var RECONNECT_BASE_MS = 5e3;
31024
+ var RECONNECT_MAX_MS = 6e4;
31025
+ var activeConnections2 = /* @__PURE__ */ new Map();
31026
+ var wecomChannelAdapter = {
31027
+ channel: "wecom",
31028
+ configSchema: wecomConfigSchema,
31029
+ async receive(rawPayload, installation) {
31030
+ const parsed = parseWecomTextFrame(rawPayload);
31031
+ if (!parsed) return null;
31032
+ return {
31033
+ channel: "wecom",
31034
+ channelInstallationId: installation.id,
31035
+ tenantId: installation.tenantId,
31036
+ sender: { id: parsed.fromUserId },
31037
+ content: {
31038
+ text: parsed.text,
31039
+ // `messageId` 供去重中间件使用(企业微信可能重投同一 msgid)。
31040
+ metadata: {
31041
+ messageId: parsed.msgId,
31042
+ chatId: parsed.chatId,
31043
+ chatType: parsed.chatType
31044
+ }
31045
+ },
31046
+ conversation: {
31047
+ id: parsed.chatId ?? parsed.fromUserId,
31048
+ type: parsed.chatType
31049
+ },
31050
+ replyTarget: {
31051
+ adapterChannel: "wecom",
31052
+ channelInstallationId: installation.id,
31053
+ // 回复需原样带回入站帧(含 `headers.req_id`)。frame 是纯 JSON,
31054
+ // replyTarget 仅在内存流转,不落库。
31055
+ rawTarget: { frame: rawPayload }
31056
+ }
31057
+ };
31058
+ },
31059
+ async sendReply(replyTarget, message, installation) {
31060
+ const connection = activeConnections2.get(installation.id);
31061
+ if (!connection) {
31062
+ logger6.warn("WeCom bot not connected, cannot reply", {
31063
+ installationId: installation.id
31064
+ });
31065
+ return;
31066
+ }
31067
+ connection.client.reply(replyTarget.rawTarget.frame, {
31068
+ msgtype: "stream",
31069
+ stream: {
31070
+ id: (0, import_node_crypto27.randomUUID)(),
31071
+ finish: true,
31072
+ content: message.text
31073
+ }
31074
+ });
31075
+ },
31076
+ resolveThreadId(message, binding) {
31077
+ const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
31078
+ const agentId = binding.agentId;
31079
+ if (message.conversation?.type === "group") {
31080
+ return `wecom:group:${message.conversation.id}:${agentId}:${date}`;
31081
+ }
31082
+ return `wecom:dm:${message.sender.id}:${agentId}:${date}`;
31083
+ },
31084
+ async connect(installation, deps) {
31085
+ const { id: installationId, tenantId, config } = installation;
31086
+ if (!config.botId || !config.secret) {
31087
+ logger6.warn("WeCom installation missing botId/secret, skipping", { installationId });
31088
+ return;
31089
+ }
31090
+ if (activeConnections2.has(installationId)) {
31091
+ logger6.warn("WeCom long connection already running, skipping", { installationId });
31092
+ return;
31093
+ }
31094
+ const { router, wsClientFactory } = deps ?? {};
31095
+ const client = (wsClientFactory ?? createDefaultWecomClient)(config);
31096
+ const connection = { client, intentional: false, attempts: 0 };
31097
+ client.on("message.text", (frame) => {
31098
+ wecomChannelAdapter.receive(frame, installation).then((inbound) => {
31099
+ if (!inbound || !router) return void 0;
31100
+ return router.dispatch(inbound);
31101
+ }).catch((error) => {
31102
+ logger6.error("WeCom message dispatch error", {
31103
+ installationId,
31104
+ error: error instanceof Error ? error.message : String(error)
31105
+ });
31106
+ });
31107
+ });
31108
+ client.on("authenticated", () => {
31109
+ connection.attempts = 0;
31110
+ });
31111
+ client.on("event.disconnected_event", () => {
31112
+ logger6.warn("WeCom connection kicked by a newer connection; will reconnect", {
31113
+ installationId
31114
+ });
31115
+ scheduleReconnect(installationId, connection);
31116
+ });
31117
+ activeConnections2.set(installationId, connection);
31118
+ client.connect();
31119
+ logger6.info("WeCom long connection starting", { installationId, tenantId });
31120
+ },
31121
+ async disconnect(installationId) {
31122
+ const connection = activeConnections2.get(installationId);
31123
+ if (!connection) {
31124
+ logger6.warn("WeCom long connection not running, nothing to disconnect", { installationId });
31125
+ return;
31126
+ }
31127
+ connection.intentional = true;
31128
+ if (connection.timer) {
31129
+ clearTimeout(connection.timer);
31130
+ connection.timer = void 0;
31131
+ }
31132
+ try {
31133
+ connection.client.disconnect();
31134
+ } catch (error) {
31135
+ logger6.error("WeCom long connection stop error", {
31136
+ installationId,
31137
+ error: error instanceof Error ? error.message : String(error)
31138
+ });
31139
+ }
31140
+ activeConnections2.delete(installationId);
31141
+ logger6.info("WeCom long connection disconnected", { installationId });
31142
+ }
31143
+ };
31144
+ function scheduleReconnect(installationId, connection) {
31145
+ if (connection.intentional || connection.timer) return;
31146
+ const delay2 = Math.min(RECONNECT_BASE_MS * 2 ** connection.attempts, RECONNECT_MAX_MS);
31147
+ connection.attempts += 1;
31148
+ logger6.info("WeCom reconnect scheduled", {
31149
+ installationId,
31150
+ delayMs: delay2,
31151
+ attempt: connection.attempts
31152
+ });
31153
+ const timer = setTimeout(() => {
31154
+ connection.timer = void 0;
31155
+ if (connection.intentional || activeConnections2.get(installationId) !== connection) {
31156
+ return;
31157
+ }
31158
+ try {
31159
+ connection.client.connect();
31160
+ } catch (error) {
31161
+ logger6.error("WeCom reconnect failed", {
31162
+ installationId,
31163
+ error: error instanceof Error ? error.message : String(error)
31164
+ });
31165
+ scheduleReconnect(installationId, connection);
31166
+ }
31167
+ }, delay2);
31168
+ timer.unref?.();
31169
+ connection.timer = timer;
31170
+ }
31171
+ function createDefaultWecomClient(config) {
31172
+ return new WecomAiBot.WSClient({
31173
+ botId: config.botId,
31174
+ secret: config.secret,
31175
+ // 断网无限重连;被踢(disconnected_event)由 scheduleReconnect 兜底。
31176
+ maxReconnectAttempts: -1
31177
+ });
31178
+ }
31179
+
30979
31180
  // src/swagger.ts
30980
31181
  var import_swagger = __toESM(require("@fastify/swagger"));
30981
31182
  var import_swagger_ui = __toESM(require("@fastify/swagger-ui"));
@@ -31039,7 +31240,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
31039
31240
  };
31040
31241
 
31041
31242
  // src/services/agent_task_consumer.ts
31042
- var import_node_crypto27 = require("crypto");
31243
+ var import_node_crypto28 = require("crypto");
31043
31244
  var import_core70 = require("@axiom-lattice/core");
31044
31245
  var import_protocols32 = require("@axiom-lattice/protocols");
31045
31246
  var handleAgentTask = async (taskRequest, retryCount = 0) => {
@@ -31063,7 +31264,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
31063
31264
  const agent = import_core70.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: scope.workspaceId, project_id: scope.projectId, custom_run_config: runConfig });
31064
31265
  if (callback_event) {
31065
31266
  const callbackEvent = callback_event;
31066
- const messageId = typeof input?.id === "string" && input.id !== "" ? input.id : (0, import_node_crypto27.randomUUID)();
31267
+ const messageId = typeof input?.id === "string" && input.id !== "" ? input.id : (0, import_node_crypto28.randomUUID)();
31067
31268
  let settled = false;
31068
31269
  const subscriptions = [];
31069
31270
  const dispose = () => {
@@ -31930,9 +32131,9 @@ var MessageRouter = class {
31930
32131
  };
31931
32132
 
31932
32133
  // src/channels/room/RoomChannelAdapter.ts
31933
- var import_zod17 = require("zod");
32134
+ var import_zod18 = require("zod");
31934
32135
  var import_protocols34 = require("@axiom-lattice/protocols");
31935
- var roomConfigSchema = import_zod17.z.object({}).strict();
32136
+ var roomConfigSchema = import_zod18.z.object({}).strict();
31936
32137
  function createRoomChannelAdapter(writer) {
31937
32138
  return {
31938
32139
  channel: "room",
@@ -32053,11 +32254,11 @@ async function prepareProjectTaskRuntime(runtime, log2) {
32053
32254
  var import_core74 = require("@axiom-lattice/core");
32054
32255
 
32055
32256
  // src/services/plugins/PluginDeploymentService.ts
32056
- var import_node_crypto29 = require("crypto");
32257
+ var import_node_crypto30 = require("crypto");
32057
32258
  var import_core73 = require("@axiom-lattice/core");
32058
32259
 
32059
32260
  // src/services/plugins/pluginDeploymentNaming.ts
32060
- var import_node_crypto28 = require("crypto");
32261
+ var import_node_crypto29 = require("crypto");
32061
32262
  var PLUGIN_GUEST_PORT = 8080;
32062
32263
  var SANDBOX_NAME_HASH_LENGTH = 16;
32063
32264
  function pluginSandboxName(tenantId, pluginType) {
@@ -32067,7 +32268,7 @@ function pluginSandboxName(tenantId, pluginType) {
32067
32268
  if (!pluginType || typeof pluginType !== "string") {
32068
32269
  throw new Error("pluginSandboxName: pluginType must be a non-empty string");
32069
32270
  }
32070
- const hash = (0, import_node_crypto28.createHash)("sha256").update(`${tenantId}\0${pluginType}`).digest("hex").slice(0, SANDBOX_NAME_HASH_LENGTH);
32271
+ const hash = (0, import_node_crypto29.createHash)("sha256").update(`${tenantId}\0${pluginType}`).digest("hex").slice(0, SANDBOX_NAME_HASH_LENGTH);
32071
32272
  return `plugin-${hash}`;
32072
32273
  }
32073
32274
 
@@ -32194,7 +32395,7 @@ var PluginDeploymentService = class {
32194
32395
  const failedAt = this.nowIso();
32195
32396
  await this.store.upsert(
32196
32397
  this.buildRecord({
32197
- id: existing?.id ?? (0, import_node_crypto29.randomUUID)(),
32398
+ id: existing?.id ?? (0, import_node_crypto30.randomUUID)(),
32198
32399
  tenantId,
32199
32400
  pluginType,
32200
32401
  pluginVersion: manifest.version,
@@ -32216,7 +32417,7 @@ var PluginDeploymentService = class {
32216
32417
  );
32217
32418
  }
32218
32419
  const record = this.buildRecord({
32219
- id: existing?.id ?? (0, import_node_crypto29.randomUUID)(),
32420
+ id: existing?.id ?? (0, import_node_crypto30.randomUUID)(),
32220
32421
  tenantId,
32221
32422
  pluginType,
32222
32423
  pluginVersion: manifest.version,
@@ -32818,11 +33019,11 @@ function readPluginDeploymentLimits(env = process.env) {
32818
33019
  };
32819
33020
  }
32820
33021
  function startPluginDeploymentRuntime(options) {
32821
- const { lease, holder, logger: logger8 } = options;
33022
+ const { lease, holder, logger: logger9 } = options;
32822
33023
  const forcedOn = process.env[PLUGIN_DEPLOYMENT_RUNTIME_FLAG] === "true" || process.env[PLUGIN_DEPLOYMENT_RUNTIME_FLAG] === "1";
32823
33024
  const effectiveServiceBaseUrl = options.wiring.serviceBaseUrl ?? process.env.MICROSANDBOX_SERVICE_BASE_URL;
32824
33025
  if (forcedOn && !effectiveServiceBaseUrl) {
32825
- logger8.warn(
33026
+ logger9.warn(
32826
33027
  `${PLUGIN_DEPLOYMENT_RUNTIME_FLAG} is enabled but MICROSANDBOX_SERVICE_BASE_URL is empty; skipping plugin deployment runtime`,
32827
33028
  { holder }
32828
33029
  );
@@ -32841,8 +33042,8 @@ function startPluginDeploymentRuntime(options) {
32841
33042
  };
32842
33043
  const service2 = createService(deps);
32843
33044
  register(service2);
32844
- logger8.info("plugin deployment runtime started", { holder });
32845
- const reconcile = runStartupReconcile(service2, reconcileDeadlineMs, logger8, holder);
33045
+ logger9.info("plugin deployment runtime started", { holder });
33046
+ const reconcile = runStartupReconcile(service2, reconcileDeadlineMs, logger9, holder);
32846
33047
  let held = false;
32847
33048
  let inFlight = false;
32848
33049
  const tick = async () => {
@@ -32850,18 +33051,18 @@ function startPluginDeploymentRuntime(options) {
32850
33051
  inFlight = true;
32851
33052
  try {
32852
33053
  if (held) {
32853
- held = await renewLease(lease, holder, logger8);
33054
+ held = await renewLease(lease, holder, logger9);
32854
33055
  if (!held) {
32855
- logger8.warn("plugin deployment lease lost; watchdog paused", { holder });
33056
+ logger9.warn("plugin deployment lease lost; watchdog paused", { holder });
32856
33057
  }
32857
33058
  } else {
32858
- held = await acquireLease(lease, holder, logger8);
33059
+ held = await acquireLease(lease, holder, logger9);
32859
33060
  if (held) {
32860
- logger8.info("plugin deployment lease acquired", { holder });
33061
+ logger9.info("plugin deployment lease acquired", { holder });
32861
33062
  }
32862
33063
  }
32863
33064
  if (!held) return;
32864
- await runWatchdog(service2, holder, logger8);
33065
+ await runWatchdog(service2, holder, logger9);
32865
33066
  } finally {
32866
33067
  inFlight = false;
32867
33068
  }
@@ -32877,7 +33078,7 @@ function startPluginDeploymentRuntime(options) {
32877
33078
  try {
32878
33079
  await lease.release(PLUGIN_DEPLOYMENT_LEASE_KEY, holder);
32879
33080
  } catch (error) {
32880
- logger8.warn("plugin deployment lease release failed", {
33081
+ logger9.warn("plugin deployment lease release failed", {
32881
33082
  holder,
32882
33083
  error: errorMessage5(error)
32883
33084
  });
@@ -32885,16 +33086,16 @@ function startPluginDeploymentRuntime(options) {
32885
33086
  held = false;
32886
33087
  }
32887
33088
  register(void 0);
32888
- logger8.info("plugin deployment runtime stopped", { holder });
33089
+ logger9.info("plugin deployment runtime stopped", { holder });
32889
33090
  }
32890
33091
  };
32891
33092
  }
32892
- async function runStartupReconcile(service2, deadlineMs, logger8, holder) {
33093
+ async function runStartupReconcile(service2, deadlineMs, logger9, holder) {
32893
33094
  try {
32894
33095
  await withDeadline(service2.startupReconcile(), deadlineMs);
32895
- logger8.info("plugin deployment startup reconcile complete", { holder });
33096
+ logger9.info("plugin deployment startup reconcile complete", { holder });
32896
33097
  } catch (error) {
32897
- logger8.warn("plugin deployment startup reconcile failed", {
33098
+ logger9.warn("plugin deployment startup reconcile failed", {
32898
33099
  holder,
32899
33100
  error: errorMessage5(error)
32900
33101
  });
@@ -32917,7 +33118,7 @@ async function withDeadline(work, deadlineMs) {
32917
33118
  if (timer !== void 0) clearTimeout(timer);
32918
33119
  }
32919
33120
  }
32920
- async function acquireLease(lease, holder, logger8) {
33121
+ async function acquireLease(lease, holder, logger9) {
32921
33122
  try {
32922
33123
  return await lease.tryAcquire(
32923
33124
  PLUGIN_DEPLOYMENT_LEASE_KEY,
@@ -32925,14 +33126,14 @@ async function acquireLease(lease, holder, logger8) {
32925
33126
  PLUGIN_DEPLOYMENT_LEASE_TTL_MS
32926
33127
  );
32927
33128
  } catch (error) {
32928
- logger8.warn("plugin deployment lease acquire failed", {
33129
+ logger9.warn("plugin deployment lease acquire failed", {
32929
33130
  holder,
32930
33131
  error: errorMessage5(error)
32931
33132
  });
32932
33133
  return false;
32933
33134
  }
32934
33135
  }
32935
- async function renewLease(lease, holder, logger8) {
33136
+ async function renewLease(lease, holder, logger9) {
32936
33137
  try {
32937
33138
  return await lease.renew(
32938
33139
  PLUGIN_DEPLOYMENT_LEASE_KEY,
@@ -32940,18 +33141,18 @@ async function renewLease(lease, holder, logger8) {
32940
33141
  PLUGIN_DEPLOYMENT_LEASE_TTL_MS
32941
33142
  );
32942
33143
  } catch (error) {
32943
- logger8.warn("plugin deployment lease renew failed", {
33144
+ logger9.warn("plugin deployment lease renew failed", {
32944
33145
  holder,
32945
33146
  error: errorMessage5(error)
32946
33147
  });
32947
33148
  return false;
32948
33149
  }
32949
33150
  }
32950
- async function runWatchdog(service2, holder, logger8) {
33151
+ async function runWatchdog(service2, holder, logger9) {
32951
33152
  try {
32952
33153
  await service2.healthWatchdog();
32953
33154
  } catch (error) {
32954
- logger8.warn("plugin deployment health watchdog failed", {
33155
+ logger9.warn("plugin deployment health watchdog failed", {
32955
33156
  holder,
32956
33157
  error: errorMessage5(error)
32957
33158
  });
@@ -32989,29 +33190,29 @@ function storeClassName(kind) {
32989
33190
  return void 0;
32990
33191
  }
32991
33192
  }
32992
- function warnMultiReplicaReadiness(logger8) {
33193
+ function warnMultiReplicaReadiness(logger9) {
32993
33194
  if (typeof process.env.AXIOM_REPLICA_ID !== "string" || process.env.AXIOM_REPLICA_ID.trim() === "") return;
32994
33195
  for (const kind of SHARED_STORE_KINDS) {
32995
33196
  const name = storeClassName(kind);
32996
33197
  if (name === void 0 || !name.startsWith("InMemory")) continue;
32997
- logger8.warn(`Multi-replica: store '${kind}' is ${name} (not shared); configure a shared store`, {
33198
+ logger9.warn(`Multi-replica: store '${kind}' is ${name} (not shared); configure a shared store`, {
32998
33199
  phase: "multi_replica_readiness",
32999
33200
  store: kind
33000
33201
  });
33001
33202
  }
33002
33203
  if (!process.env.AUTH_TOKEN_SECRET?.trim() && !process.env.JWT_SECRET?.trim()) {
33003
- logger8.warn(
33204
+ logger9.warn(
33004
33205
  "Multi-replica: AUTH_TOKEN_SECRET/JWT_SECRET unset; console sessions are signed per-process and will not verify across replicas",
33005
33206
  { phase: "multi_replica_readiness", env: "AUTH_TOKEN_SECRET" }
33006
33207
  );
33007
33208
  }
33008
33209
  if (!process.env.LATTICE_ENCRYPTION_KEY?.trim()) {
33009
- logger8.warn(
33210
+ logger9.warn(
33010
33211
  "Multi-replica: LATTICE_ENCRYPTION_KEY unset; stored credentials use the shared dev default and may not decrypt across differing keys",
33011
33212
  { phase: "multi_replica_readiness", env: "LATTICE_ENCRYPTION_KEY" }
33012
33213
  );
33013
33214
  }
33014
- logger8.warn(
33215
+ logger9.warn(
33015
33216
  "Multi-replica: agent run SSE and resume_stream are process-local; route a thread's follow-up runs to the replica streaming it (sticky routing) or share the stream/queue state",
33016
33217
  { phase: "multi_replica_readiness", feature: "agent-run-sse" }
33017
33218
  );
@@ -33154,7 +33355,7 @@ var DEFAULT_LOGGER_CONFIG = {
33154
33355
  loggerName: "lattice/gateway"
33155
33356
  };
33156
33357
  var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
33157
- var logger7 = loggerLattice.client;
33358
+ var logger8 = loggerLattice.client;
33158
33359
  function initializeLogger(config) {
33159
33360
  if (import_core98.loggerLatticeManager.hasLattice("default")) {
33160
33361
  import_core98.loggerLatticeManager.removeLattice("default");
@@ -33241,7 +33442,7 @@ app.setErrorHandler((error, request, reply) => {
33241
33442
  "x-request-id": getHeaderValue(request.headers["x-request-id"]),
33242
33443
  "x-user-id": getHeaderValue(request.headers["x-user-id"])
33243
33444
  };
33244
- logger7.error(
33445
+ logger8.error(
33245
33446
  `\u8BF7\u6C42\u9519\u8BEF: ${request.method} ${request.url} error:${error.message}`,
33246
33447
  {
33247
33448
  ...context,
@@ -33277,14 +33478,14 @@ async function restoreMcpConnections() {
33277
33478
  const storeLattice = (0, import_core98.getStoreLattice)("default", "mcp");
33278
33479
  const store2 = storeLattice.store;
33279
33480
  if (!store2) {
33280
- logger7.info("MCP store not configured, skipping connection restoration");
33481
+ logger8.info("MCP store not configured, skipping connection restoration");
33281
33482
  return;
33282
33483
  }
33283
33484
  const configs = (await store2.getAllConfigsWithoutTenant()).filter(
33284
33485
  (c2) => c2.status === "connected"
33285
33486
  );
33286
33487
  if (configs.length === 0) return;
33287
- logger7.info(`Restoring ${configs.length} MCP server connections...`);
33488
+ logger8.info(`Restoring ${configs.length} MCP server connections...`);
33288
33489
  const deps = {
33289
33490
  store: store2,
33290
33491
  manager: import_core98.mcpManager,
@@ -33301,15 +33502,15 @@ async function restoreMcpConnections() {
33301
33502
  results.forEach((result, index) => {
33302
33503
  if (result.status === "rejected") {
33303
33504
  const config = configs[index];
33304
- logger7.warn(
33505
+ logger8.warn(
33305
33506
  `Failed to restore MCP server "${config.tenantId}/${config.key}"`,
33306
33507
  { error: result.reason }
33307
33508
  );
33308
33509
  }
33309
33510
  });
33310
- logger7.info(`MCP connection restoration complete: ${configs.length} servers`);
33511
+ logger8.info(`MCP connection restoration complete: ${configs.length} servers`);
33311
33512
  } catch (err) {
33312
- logger7.error("MCP connection restoration failed", { error: err });
33513
+ logger8.error("MCP connection restoration failed", { error: err });
33313
33514
  }
33314
33515
  }
33315
33516
  var start = async (config) => {
@@ -33322,7 +33523,7 @@ var start = async (config) => {
33322
33523
  file: config.loggerConfig.file || DEFAULT_LOGGER_CONFIG.file
33323
33524
  };
33324
33525
  loggerLattice = initializeLogger(loggerConfig);
33325
- logger7 = loggerLattice.client;
33526
+ logger8 = loggerLattice.client;
33326
33527
  }
33327
33528
  app.decorate("loggerLattice", loggerLattice);
33328
33529
  const projectRoomRealtimeMode = resolveProjectRoomRealtimeMode();
@@ -33332,12 +33533,13 @@ var start = async (config) => {
33332
33533
  tasks: (0, import_core98.getStoreLattice)("default", "task").store,
33333
33534
  rooms: (0, import_core98.getStoreLattice)("default", "projectRoom").store,
33334
33535
  memberships: (0, import_core98.getStoreLattice)("default", "projectBotMembership").store,
33335
- log: { warn: (message, context) => logger7.warn(message, context) }
33536
+ log: { warn: (message, context) => logger8.warn(message, context) }
33336
33537
  });
33337
33538
  }
33338
33539
  let channelDeps;
33339
33540
  const adapterRegistry = new ChannelAdapterRegistry();
33340
33541
  adapterRegistry.register(larkChannelAdapter);
33542
+ adapterRegistry.register(wecomChannelAdapter);
33341
33543
  const { wechatChannelAdapter: wechatChannelAdapter2 } = await Promise.resolve().then(() => (init_WechatChannelAdapter(), WechatChannelAdapter_exports));
33342
33544
  adapterRegistry.register(wechatChannelAdapter2);
33343
33545
  try {
@@ -33350,7 +33552,7 @@ var start = async (config) => {
33350
33552
  createRateLimitMiddleware(),
33351
33553
  createAuditLoggerMiddleware()
33352
33554
  ],
33353
- warn: (message, context) => logger7.warn(message, context),
33555
+ warn: (message, context) => logger8.warn(message, context),
33354
33556
  realtime: projectRoomRealtimeRuntime?.publisher
33355
33557
  });
33356
33558
  const bindingStore = infrastructure.bindingRegistry;
@@ -33364,10 +33566,10 @@ var start = async (config) => {
33364
33566
  installationStore,
33365
33567
  bindingRegistry: bindingStore,
33366
33568
  realtime: projectRoomRealtimeRuntime?.publisher,
33367
- warn: (message, context) => logger7.warn(message, context)
33569
+ warn: (message, context) => logger8.warn(message, context)
33368
33570
  };
33369
33571
  } catch (err) {
33370
- logger7.warn("Channel infrastructure unavailable", {
33572
+ logger8.warn("Channel infrastructure unavailable", {
33371
33573
  error: err instanceof Error ? err.message : String(err)
33372
33574
  });
33373
33575
  }
@@ -33375,7 +33577,7 @@ var start = async (config) => {
33375
33577
  try {
33376
33578
  const menuStore = (0, import_core98.getStoreLattice)("default", "menu").store;
33377
33579
  (0, import_core97.setMenuRegistry)(menuStore);
33378
- logger7.info("Menu registry initialized");
33580
+ logger8.info("Menu registry initialized");
33379
33581
  } catch {
33380
33582
  }
33381
33583
  registerAllBuiltinEntities();
@@ -33384,7 +33586,7 @@ var start = async (config) => {
33384
33586
  }
33385
33587
  const routes = registerLatticeRoutes(app, channelDeps, {
33386
33588
  projectTaskEnabled: process.env.AXIOM_PROJECT_TASK_EXECUTION_ENABLED !== "false",
33387
- projectTaskLog: { warn: (message, context) => logger7.warn(message, context) },
33589
+ projectTaskLog: { warn: (message, context) => logger8.warn(message, context) },
33388
33590
  projectRoomRealtimeRuntime
33389
33591
  });
33390
33592
  try {
@@ -33412,9 +33614,9 @@ var start = async (config) => {
33412
33614
  getProjectStore: () => projectStore
33413
33615
  });
33414
33616
  a2a.registerA2ARoutes(app);
33415
- logger7.info("A2A standard routes registered");
33617
+ logger8.info("A2A standard routes registered");
33416
33618
  } catch (err) {
33417
- logger7.warn("A2A standard routes unavailable", {
33619
+ logger8.warn("A2A standard routes unavailable", {
33418
33620
  error: err instanceof Error ? err.message : String(err)
33419
33621
  });
33420
33622
  }
@@ -33451,26 +33653,26 @@ var start = async (config) => {
33451
33653
  registerOpenFilesRoutes2(app);
33452
33654
  registerOpenAuditRoutes2(app);
33453
33655
  registerOpenExposureRoutes2(app);
33454
- logger7.info("Open API routes registered (kb + sandbox providers, session exchange)");
33656
+ logger8.info("Open API routes registered (kb + sandbox providers, session exchange)");
33455
33657
  } catch (err) {
33456
- logger7.warn("Open API routes unavailable", {
33658
+ logger8.warn("Open API routes unavailable", {
33457
33659
  error: err instanceof Error ? err.message : String(err)
33458
33660
  });
33459
33661
  }
33460
33662
  try {
33461
33663
  const { registerGatewaySandboxOpenCredentialProvider: registerGatewaySandboxOpenCredentialProvider2 } = await Promise.resolve().then(() => (init_sandboxOpenCredentialProvider(), sandboxOpenCredentialProvider_exports));
33462
33664
  registerGatewaySandboxOpenCredentialProvider2((error) => {
33463
- logger7.warn("sandbox open-credential provider failed", { error });
33665
+ logger8.warn("sandbox open-credential provider failed", { error });
33464
33666
  });
33465
- logger7.info("Sandbox open-credential provider registered");
33667
+ logger8.info("Sandbox open-credential provider registered");
33466
33668
  } catch (err) {
33467
- logger7.warn("Sandbox open-credential provider unavailable", {
33669
+ logger8.warn("Sandbox open-credential provider unavailable", {
33468
33670
  error: err instanceof Error ? err.message : String(err)
33469
33671
  });
33470
33672
  }
33471
33673
  if (!import_core98.sandboxLatticeManager.hasLattice("default")) {
33472
33674
  import_core98.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
33473
- logger7.info("Registered sandbox manager from env configuration");
33675
+ logger8.info("Registered sandbox manager from env configuration");
33474
33676
  }
33475
33677
  if (isPluginDeploymentRuntimeEnabled()) {
33476
33678
  try {
@@ -33497,21 +33699,21 @@ var start = async (config) => {
33497
33699
  listAllDeployments,
33498
33700
  // The service logs fields-first; the gateway logger is message-first.
33499
33701
  logger: {
33500
- info: (fields, message) => logger7.info(message ?? "plugin deployment", fields),
33501
- warn: (fields, message) => logger7.warn(message ?? "plugin deployment", fields),
33502
- error: (fields, message) => logger7.error(message ?? "plugin deployment", fields)
33702
+ info: (fields, message) => logger8.info(message ?? "plugin deployment", fields),
33703
+ warn: (fields, message) => logger8.warn(message ?? "plugin deployment", fields),
33704
+ error: (fields, message) => logger8.error(message ?? "plugin deployment", fields)
33503
33705
  }
33504
33706
  },
33505
33707
  lease: leaseStore2,
33506
33708
  holder: (0, import_core98.getReplicaId)(),
33507
- logger: logger7
33709
+ logger: logger8
33508
33710
  });
33509
33711
  app.addHook("onClose", async () => {
33510
33712
  await pluginDeploymentRuntime.dispose();
33511
33713
  });
33512
- logger7.info("Plugin deployment runtime started");
33714
+ logger8.info("Plugin deployment runtime started");
33513
33715
  } catch (err) {
33514
- logger7.warn("Plugin deployment runtime unavailable", {
33716
+ logger8.warn("Plugin deployment runtime unavailable", {
33515
33717
  error: err instanceof Error ? err.message : String(err)
33516
33718
  });
33517
33719
  }
@@ -33524,12 +33726,12 @@ var start = async (config) => {
33524
33726
  store: sharedResourceStore,
33525
33727
  sandboxManager: import_core98.sandboxLatticeManager,
33526
33728
  cache: cache2,
33527
- logger: logger7
33729
+ logger: logger8
33528
33730
  });
33529
33731
  registerResourceRoutes(app, resourceController);
33530
- logger7.info("Resource share routes registered");
33732
+ logger8.info("Resource share routes registered");
33531
33733
  } catch (err) {
33532
- logger7.warn("Resource share infrastructure unavailable", {
33734
+ logger8.warn("Resource share infrastructure unavailable", {
33533
33735
  error: err instanceof Error ? err.message : String(err)
33534
33736
  });
33535
33737
  }
@@ -33542,14 +33744,14 @@ var start = async (config) => {
33542
33744
  deps: { router: channelDeps.router }
33543
33745
  }),
33544
33746
  disconnect: () => (0, import_core98.disconnectAllChannels)((channel) => adapterRegistry.get(channel)),
33545
- log: { warn: (message, context) => logger7.warn(message, context) }
33747
+ log: { warn: (message, context) => logger8.warn(message, context) }
33546
33748
  });
33547
33749
  app.addHook("onClose", async () => {
33548
33750
  await channelLeader.stop();
33549
33751
  });
33550
33752
  channelLeader.start();
33551
33753
  } catch (err) {
33552
- logger7.error("Failed to start channel connections", {
33754
+ logger8.error("Failed to start channel connections", {
33553
33755
  error: err instanceof Error ? err.message : String(err)
33554
33756
  });
33555
33757
  }
@@ -33596,24 +33798,24 @@ var start = async (config) => {
33596
33798
  await handleModelProviderChanged(payload, (tenantId, providerId2) => controller.reconcileProvider(tenantId, providerId2));
33597
33799
  }
33598
33800
  },
33599
- log: logger7
33801
+ log: logger8
33600
33802
  });
33601
33803
  try {
33602
33804
  await outboxPoller.start();
33603
33805
  } catch (err) {
33604
- logger7.warn("Outbox poller failed to start", { error: err instanceof Error ? err.message : String(err) });
33806
+ logger8.warn("Outbox poller failed to start", { error: err instanceof Error ? err.message : String(err) });
33605
33807
  }
33606
33808
  const leaseStore = (0, import_core98.getStoreLattice)("default", "lease").store;
33607
33809
  if (leaseStore.constructor?.name === "InMemoryLeaseStore") {
33608
- logger7.warn(
33810
+ logger8.warn(
33609
33811
  "Startup recovery leader gate uses a non-distributed lease store (per-process only); configure a shared 'lease' store for multi-replica deployments",
33610
33812
  { phase: "startup_recovery" }
33611
33813
  );
33612
33814
  }
33613
- warnMultiReplicaReadiness(logger7);
33815
+ warnMultiReplicaReadiness(logger8);
33614
33816
  const startup = await (0, import_core98.runAsLeader)(leaseStore, "startup-recovery", async () => {
33615
33817
  if (routes.projectTaskRuntime) {
33616
- await prepareProjectTaskRuntime(routes.projectTaskRuntime, logger7);
33818
+ await prepareProjectTaskRuntime(routes.projectTaskRuntime, logger8);
33617
33819
  }
33618
33820
  if (process.env.AXIOM_TASK_ORPHAN_RECOVERY === "true") {
33619
33821
  try {
@@ -33624,19 +33826,19 @@ var start = async (config) => {
33624
33826
  workItemStore: (0, import_core98.getStoreLattice)("default", "taskWorkItem").store,
33625
33827
  tenantStore: (0, import_core98.getStoreLattice)("default", "tenant").store,
33626
33828
  ...createRecoveryCallerDeps2(),
33627
- log: logger7
33829
+ log: logger8
33628
33830
  });
33629
33831
  await runtime.recoverAll();
33630
33832
  } catch (err) {
33631
- logger7.warn("Task orphan recovery failed", { error: err instanceof Error ? err.message : String(err) });
33833
+ logger8.warn("Task orphan recovery failed", { error: err instanceof Error ? err.message : String(err) });
33632
33834
  }
33633
33835
  }
33634
33836
  if (import_core98.scheduleLatticeManager.hasLattice("default")) {
33635
33837
  try {
33636
33838
  const restored = await import_core98.scheduleLatticeManager.getScheduleLattice("default").restore();
33637
- logger7.info("Scheduled tasks restored", { phase: "startup_recovery", restored });
33839
+ logger8.info("Scheduled tasks restored", { phase: "startup_recovery", restored });
33638
33840
  } catch (err) {
33639
- logger7.warn("Scheduled task restore failed", {
33841
+ logger8.warn("Scheduled task restore failed", {
33640
33842
  phase: "startup_recovery",
33641
33843
  error: err instanceof Error ? err.message : String(err)
33642
33844
  });
@@ -33644,13 +33846,13 @@ var start = async (config) => {
33644
33846
  }
33645
33847
  }, { hold: true, ttlMs: 5 * 6e4 });
33646
33848
  if (!startup.ran) {
33647
- logger7.info("Startup recovery skipped (another replica leads)", { phase: "startup_recovery" });
33849
+ logger8.info("Startup recovery skipped (another replica leads)", { phase: "startup_recovery" });
33648
33850
  }
33649
33851
  await app.listen({ port: target_port, host: "0.0.0.0" });
33650
- logger7.info(`Lattice Gateway is running on port: ${target_port}`);
33852
+ logger8.info(`Lattice Gateway is running on port: ${target_port}`);
33651
33853
  const outboxRetention = createOutboxRetentionJob({
33652
33854
  outbox: outboxStore,
33653
- log: logger7
33855
+ log: logger8
33654
33856
  });
33655
33857
  outboxRetention.start();
33656
33858
  let agentTaskConsumer;
@@ -33663,15 +33865,15 @@ var start = async (config) => {
33663
33865
  }
33664
33866
  }
33665
33867
  restoreMcpConnections().catch((error) => {
33666
- logger7.error("MCP connection restoration failed", { error });
33868
+ logger8.error("MCP connection restoration failed", { error });
33667
33869
  });
33668
33870
  if (config?.gracefulShutdown !== false && !shutdownHandlersInstalled) {
33669
33871
  shutdownHandlersInstalled = true;
33670
33872
  const gracefulShutdown = createGracefulShutdown({
33671
33873
  timeoutMs: config?.gracefulShutdownTimeoutMs ?? 1e4,
33672
33874
  log: {
33673
- info: (message, context) => logger7.info(message, context),
33674
- warn: (message, context) => logger7.warn(message, context)
33875
+ info: (message, context) => logger8.info(message, context),
33876
+ warn: (message, context) => logger8.warn(message, context)
33675
33877
  },
33676
33878
  steps: [
33677
33879
  async () => {
@@ -33689,7 +33891,7 @@ var start = async (config) => {
33689
33891
  process.once("SIGINT", () => void gracefulShutdown("SIGINT"));
33690
33892
  }
33691
33893
  } catch (err) {
33692
- logger7.error("Server start failed", { error: err });
33894
+ logger8.error("Server start failed", { error: err });
33693
33895
  process.exit(1);
33694
33896
  }
33695
33897
  };