@axiom-lattice/gateway 4.9.2 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embed/{embed-page-AgentDetailSideApp-WQAMMDXN.js → embed-page-AgentDetailSideApp-GH3XNS5A.js} +1 -1
- package/dist/embed/{embed-page-AgentGovernanceWorkbench-VKD4IZIO.js → embed-page-AgentGovernanceWorkbench-AXHLZTUG.js} +1 -1
- package/dist/embed/{embed-page-MessageGraph-C4EJWY3E.js → embed-page-MessageGraph-HLLPBTLQ.js} +1 -1
- package/dist/embed/{embed-page-ReactChart-TNT4TT4C.js → embed-page-ReactChart-46EYPRQ7.js} +1 -1
- package/dist/embed/{embed-page-SkillFlow-WWRDU6GS.js → embed-page-SkillFlow-NMUDTNTY.js} +1 -1
- package/dist/embed/{embed-page-TasksSideApp-73SJLGRY.js → embed-page-TasksSideApp-DOCKHJCF.js} +1 -1
- package/dist/embed/{embed-page-TeamWorkspace-6E4HAH7L.js → embed-page-TeamWorkspace-LXOIMYRW.js} +1 -1
- package/dist/embed/{embed-page-TopologyRuntimeView-SXUNRFT4.js → embed-page-TopologyRuntimeView-DT7XXEK2.js} +1 -1
- package/dist/embed/{embed-page-WorkflowAutomationView-I4VN6YY2.js → embed-page-WorkflowAutomationView-ONAY4RTM.js} +1 -1
- package/dist/embed/{embed-page-chunk-G5NEOKZK.js → embed-page-chunk-F7G2DME5.js} +1 -1
- package/dist/embed/{embed-page-chunk-WUOHF2QZ.js → embed-page-chunk-H4W4NDIY.js} +1 -1
- package/dist/embed/{embed-page-chunk-YZMHK63X.js → embed-page-chunk-JQSBSZMP.js} +1 -1
- package/dist/embed/{embed-page-chunk-IM57IYUL.js → embed-page-chunk-LGZUYB7B.js} +1 -1
- package/dist/embed/{embed-page-chunk-RQXI6NQX.js → embed-page-chunk-NR2PTMJ6.js} +1 -1
- package/dist/embed/{embed-page-chunk-TEIHYMTL.js → embed-page-chunk-OY4CDWED.js} +7 -7
- package/dist/embed/{embed-page-chunk-L7HKGCDN.js → embed-page-chunk-RA35MUYW.js} +1 -1
- package/dist/embed/{embed-page-en-GE4GI4D3.js → embed-page-en-ICVL5QAC.js} +1 -1
- package/dist/embed/{embed-page-zh-KC2E7UVY.js → embed-page-zh-FPYCTKQK.js} +1 -1
- package/dist/embed/embed-page.js +1 -1
- package/dist/index.js +326 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +274 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
package/dist/index.js
CHANGED
|
@@ -1731,25 +1731,25 @@ function extractText(msg) {
|
|
|
1731
1731
|
}
|
|
1732
1732
|
return null;
|
|
1733
1733
|
}
|
|
1734
|
-
var
|
|
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
|
-
|
|
1738
|
+
import_zod19 = require("zod");
|
|
1739
1739
|
init_wechat_client();
|
|
1740
1740
|
init_context_store();
|
|
1741
1741
|
init_Logger();
|
|
1742
|
-
|
|
1743
|
-
wechatConfigSchema =
|
|
1744
|
-
botToken:
|
|
1745
|
-
uin:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1811
|
+
logger7.warn("WeChat installation missing botToken, skipping", { installationId });
|
|
1812
1812
|
return;
|
|
1813
1813
|
}
|
|
1814
|
-
if (
|
|
1815
|
-
|
|
1814
|
+
if (activeConnections3.has(installationId)) {
|
|
1815
|
+
logger7.warn("WeChat polling already running for installation, skipping", { installationId });
|
|
1816
1816
|
return;
|
|
1817
1817
|
}
|
|
1818
|
-
|
|
1818
|
+
logger7.info("WeChat polling starting", { installationId, tenantId });
|
|
1819
1819
|
const abortController = new AbortController();
|
|
1820
1820
|
const heartbeatTimer = setInterval(() => {
|
|
1821
|
-
const state2 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
1858
|
+
const currentState = activeConnections3.get(installationId);
|
|
1859
1859
|
if (!currentState || currentState.abortController.signal.aborted) {
|
|
1860
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1899
|
+
logger7.info("WeChat poll aborted by signal", { installationId });
|
|
1900
1900
|
return;
|
|
1901
1901
|
}
|
|
1902
|
-
|
|
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
|
-
|
|
1912
|
+
logger7.info("WeChat polling started", { installationId });
|
|
1913
1913
|
},
|
|
1914
1914
|
async disconnect(installationId) {
|
|
1915
|
-
const state =
|
|
1915
|
+
const state = activeConnections3.get(installationId);
|
|
1916
1916
|
if (!state) {
|
|
1917
|
-
|
|
1917
|
+
logger7.warn("WeChat polling not running, nothing to disconnect", { installationId });
|
|
1918
1918
|
return;
|
|
1919
1919
|
}
|
|
1920
|
-
|
|
1920
|
+
logger7.info("WeChat polling disconnecting", { installationId });
|
|
1921
1921
|
state.abortController.abort();
|
|
1922
1922
|
clearInterval(state.heartbeatTimer);
|
|
1923
|
-
|
|
1924
|
-
|
|
1923
|
+
activeConnections3.delete(installationId);
|
|
1924
|
+
logger7.info("WeChat polling disconnected", { installationId });
|
|
1925
1925
|
}
|
|
1926
1926
|
};
|
|
1927
1927
|
}
|
|
@@ -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
|
|
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
|
-
|
|
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) :
|
|
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 ??
|
|
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
|
|
3929
|
+
var import_zod21;
|
|
3930
3930
|
var init_pluginExposeAdapter = __esm({
|
|
3931
3931
|
"src/services/open/pluginExposeAdapter.ts"() {
|
|
3932
3932
|
"use strict";
|
|
3933
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
4597
|
-
exec_dir:
|
|
4598
|
-
timeout:
|
|
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
|
|
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
|
-
|
|
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:
|
|
4956
|
-
query:
|
|
4957
|
-
limit:
|
|
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
|
|
4985
|
+
var import_zod23;
|
|
4986
4986
|
var init_kbProvider = __esm({
|
|
4987
4987
|
"src/services/open/providers/kbProvider.ts"() {
|
|
4988
4988
|
"use strict";
|
|
4989
|
-
|
|
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:
|
|
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
|
|
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
|
-
|
|
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,192 @@ 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_zod17 = require("zod");
|
|
30991
|
+
var WecomAiBot = __toESM(require("@wecom/aibot-node-sdk"));
|
|
30992
|
+
|
|
30993
|
+
// src/channels/wecom/parser.ts
|
|
30994
|
+
function parseWecomTextFrame(frame) {
|
|
30995
|
+
if (!frame || typeof frame !== "object") return null;
|
|
30996
|
+
const { headers, body } = frame;
|
|
30997
|
+
const reqId = headers?.req_id;
|
|
30998
|
+
if (typeof reqId !== "string" || !body) return null;
|
|
30999
|
+
if (body.msgtype !== "text") return null;
|
|
31000
|
+
const fromUserId = body.from?.userid;
|
|
31001
|
+
const content = body.text?.content;
|
|
31002
|
+
if (typeof fromUserId !== "string" || typeof content !== "string") {
|
|
31003
|
+
return null;
|
|
31004
|
+
}
|
|
31005
|
+
return {
|
|
31006
|
+
reqId,
|
|
31007
|
+
msgId: typeof body.msgid === "string" ? body.msgid : "",
|
|
31008
|
+
fromUserId,
|
|
31009
|
+
chatId: typeof body.chatid === "string" ? body.chatid : void 0,
|
|
31010
|
+
chatType: body.chattype === "group" ? "group" : "direct",
|
|
31011
|
+
text: content
|
|
31012
|
+
};
|
|
31013
|
+
}
|
|
31014
|
+
|
|
31015
|
+
// src/channels/wecom/WecomChannelAdapter.ts
|
|
31016
|
+
init_Logger();
|
|
31017
|
+
var logger6 = new Logger({ serviceName: "lattice/gateway/wecom" });
|
|
31018
|
+
var wecomConfigSchema = import_zod17.z.object({
|
|
31019
|
+
botId: import_zod17.z.string(),
|
|
31020
|
+
secret: import_zod17.z.string()
|
|
31021
|
+
});
|
|
31022
|
+
var RECONNECT_BASE_MS = 5e3;
|
|
31023
|
+
var RECONNECT_MAX_MS = 6e4;
|
|
31024
|
+
var activeConnections2 = /* @__PURE__ */ new Map();
|
|
31025
|
+
var wecomChannelAdapter = {
|
|
31026
|
+
channel: "wecom",
|
|
31027
|
+
configSchema: wecomConfigSchema,
|
|
31028
|
+
async receive(rawPayload, installation) {
|
|
31029
|
+
const parsed = parseWecomTextFrame(rawPayload);
|
|
31030
|
+
if (!parsed) return null;
|
|
31031
|
+
return {
|
|
31032
|
+
channel: "wecom",
|
|
31033
|
+
channelInstallationId: installation.id,
|
|
31034
|
+
tenantId: installation.tenantId,
|
|
31035
|
+
sender: { id: parsed.fromUserId },
|
|
31036
|
+
content: {
|
|
31037
|
+
text: parsed.text,
|
|
31038
|
+
// `messageId` 供去重中间件使用(企业微信可能重投同一 msgid)。
|
|
31039
|
+
metadata: {
|
|
31040
|
+
messageId: parsed.msgId,
|
|
31041
|
+
chatId: parsed.chatId,
|
|
31042
|
+
chatType: parsed.chatType
|
|
31043
|
+
}
|
|
31044
|
+
},
|
|
31045
|
+
conversation: {
|
|
31046
|
+
id: parsed.chatId ?? parsed.fromUserId,
|
|
31047
|
+
type: parsed.chatType
|
|
31048
|
+
},
|
|
31049
|
+
replyTarget: {
|
|
31050
|
+
adapterChannel: "wecom",
|
|
31051
|
+
channelInstallationId: installation.id,
|
|
31052
|
+
// 回复需原样带回入站帧(含 `headers.req_id`)。frame 是纯 JSON,
|
|
31053
|
+
// replyTarget 仅在内存流转,不落库。
|
|
31054
|
+
rawTarget: { frame: rawPayload }
|
|
31055
|
+
}
|
|
31056
|
+
};
|
|
31057
|
+
},
|
|
31058
|
+
async sendReply(replyTarget, message, installation) {
|
|
31059
|
+
const connection = activeConnections2.get(installation.id);
|
|
31060
|
+
if (!connection) {
|
|
31061
|
+
logger6.warn("WeCom bot not connected, cannot reply", {
|
|
31062
|
+
installationId: installation.id
|
|
31063
|
+
});
|
|
31064
|
+
return;
|
|
31065
|
+
}
|
|
31066
|
+
connection.client.reply(replyTarget.rawTarget.frame, {
|
|
31067
|
+
msgtype: "text",
|
|
31068
|
+
text: { content: message.text }
|
|
31069
|
+
});
|
|
31070
|
+
},
|
|
31071
|
+
resolveThreadId(message, binding) {
|
|
31072
|
+
const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
31073
|
+
const agentId = binding.agentId;
|
|
31074
|
+
if (message.conversation?.type === "group") {
|
|
31075
|
+
return `wecom:group:${message.conversation.id}:${agentId}:${date}`;
|
|
31076
|
+
}
|
|
31077
|
+
return `wecom:dm:${message.sender.id}:${agentId}:${date}`;
|
|
31078
|
+
},
|
|
31079
|
+
async connect(installation, deps) {
|
|
31080
|
+
const { id: installationId, tenantId, config } = installation;
|
|
31081
|
+
if (!config.botId || !config.secret) {
|
|
31082
|
+
logger6.warn("WeCom installation missing botId/secret, skipping", { installationId });
|
|
31083
|
+
return;
|
|
31084
|
+
}
|
|
31085
|
+
if (activeConnections2.has(installationId)) {
|
|
31086
|
+
logger6.warn("WeCom long connection already running, skipping", { installationId });
|
|
31087
|
+
return;
|
|
31088
|
+
}
|
|
31089
|
+
const { router, wsClientFactory } = deps ?? {};
|
|
31090
|
+
const client = (wsClientFactory ?? createDefaultWecomClient)(config);
|
|
31091
|
+
const connection = { client, intentional: false, attempts: 0 };
|
|
31092
|
+
client.on("message.text", (frame) => {
|
|
31093
|
+
wecomChannelAdapter.receive(frame, installation).then((inbound) => {
|
|
31094
|
+
if (!inbound || !router) return void 0;
|
|
31095
|
+
return router.dispatch(inbound);
|
|
31096
|
+
}).catch((error) => {
|
|
31097
|
+
logger6.error("WeCom message dispatch error", {
|
|
31098
|
+
installationId,
|
|
31099
|
+
error: error instanceof Error ? error.message : String(error)
|
|
31100
|
+
});
|
|
31101
|
+
});
|
|
31102
|
+
});
|
|
31103
|
+
client.on("authenticated", () => {
|
|
31104
|
+
connection.attempts = 0;
|
|
31105
|
+
});
|
|
31106
|
+
client.on("event.disconnected_event", () => {
|
|
31107
|
+
logger6.warn("WeCom connection kicked by a newer connection; will reconnect", {
|
|
31108
|
+
installationId
|
|
31109
|
+
});
|
|
31110
|
+
scheduleReconnect(installationId, connection);
|
|
31111
|
+
});
|
|
31112
|
+
activeConnections2.set(installationId, connection);
|
|
31113
|
+
client.connect();
|
|
31114
|
+
logger6.info("WeCom long connection starting", { installationId, tenantId });
|
|
31115
|
+
},
|
|
31116
|
+
async disconnect(installationId) {
|
|
31117
|
+
const connection = activeConnections2.get(installationId);
|
|
31118
|
+
if (!connection) {
|
|
31119
|
+
logger6.warn("WeCom long connection not running, nothing to disconnect", { installationId });
|
|
31120
|
+
return;
|
|
31121
|
+
}
|
|
31122
|
+
connection.intentional = true;
|
|
31123
|
+
if (connection.timer) {
|
|
31124
|
+
clearTimeout(connection.timer);
|
|
31125
|
+
connection.timer = void 0;
|
|
31126
|
+
}
|
|
31127
|
+
try {
|
|
31128
|
+
connection.client.disconnect();
|
|
31129
|
+
} catch (error) {
|
|
31130
|
+
logger6.error("WeCom long connection stop error", {
|
|
31131
|
+
installationId,
|
|
31132
|
+
error: error instanceof Error ? error.message : String(error)
|
|
31133
|
+
});
|
|
31134
|
+
}
|
|
31135
|
+
activeConnections2.delete(installationId);
|
|
31136
|
+
logger6.info("WeCom long connection disconnected", { installationId });
|
|
31137
|
+
}
|
|
31138
|
+
};
|
|
31139
|
+
function scheduleReconnect(installationId, connection) {
|
|
31140
|
+
if (connection.intentional || connection.timer) return;
|
|
31141
|
+
const delay2 = Math.min(RECONNECT_BASE_MS * 2 ** connection.attempts, RECONNECT_MAX_MS);
|
|
31142
|
+
connection.attempts += 1;
|
|
31143
|
+
logger6.info("WeCom reconnect scheduled", {
|
|
31144
|
+
installationId,
|
|
31145
|
+
delayMs: delay2,
|
|
31146
|
+
attempt: connection.attempts
|
|
31147
|
+
});
|
|
31148
|
+
const timer = setTimeout(() => {
|
|
31149
|
+
connection.timer = void 0;
|
|
31150
|
+
if (connection.intentional || activeConnections2.get(installationId) !== connection) {
|
|
31151
|
+
return;
|
|
31152
|
+
}
|
|
31153
|
+
try {
|
|
31154
|
+
connection.client.connect();
|
|
31155
|
+
} catch (error) {
|
|
31156
|
+
logger6.error("WeCom reconnect failed", {
|
|
31157
|
+
installationId,
|
|
31158
|
+
error: error instanceof Error ? error.message : String(error)
|
|
31159
|
+
});
|
|
31160
|
+
scheduleReconnect(installationId, connection);
|
|
31161
|
+
}
|
|
31162
|
+
}, delay2);
|
|
31163
|
+
timer.unref?.();
|
|
31164
|
+
connection.timer = timer;
|
|
31165
|
+
}
|
|
31166
|
+
function createDefaultWecomClient(config) {
|
|
31167
|
+
return new WecomAiBot.WSClient({
|
|
31168
|
+
botId: config.botId,
|
|
31169
|
+
secret: config.secret,
|
|
31170
|
+
// 断网无限重连;被踢(disconnected_event)由 scheduleReconnect 兜底。
|
|
31171
|
+
maxReconnectAttempts: -1
|
|
31172
|
+
});
|
|
31173
|
+
}
|
|
31174
|
+
|
|
30979
31175
|
// src/swagger.ts
|
|
30980
31176
|
var import_swagger = __toESM(require("@fastify/swagger"));
|
|
30981
31177
|
var import_swagger_ui = __toESM(require("@fastify/swagger-ui"));
|
|
@@ -31930,9 +32126,9 @@ var MessageRouter = class {
|
|
|
31930
32126
|
};
|
|
31931
32127
|
|
|
31932
32128
|
// src/channels/room/RoomChannelAdapter.ts
|
|
31933
|
-
var
|
|
32129
|
+
var import_zod18 = require("zod");
|
|
31934
32130
|
var import_protocols34 = require("@axiom-lattice/protocols");
|
|
31935
|
-
var roomConfigSchema =
|
|
32131
|
+
var roomConfigSchema = import_zod18.z.object({}).strict();
|
|
31936
32132
|
function createRoomChannelAdapter(writer) {
|
|
31937
32133
|
return {
|
|
31938
32134
|
channel: "room",
|
|
@@ -32818,11 +33014,11 @@ function readPluginDeploymentLimits(env = process.env) {
|
|
|
32818
33014
|
};
|
|
32819
33015
|
}
|
|
32820
33016
|
function startPluginDeploymentRuntime(options) {
|
|
32821
|
-
const { lease, holder, logger:
|
|
33017
|
+
const { lease, holder, logger: logger9 } = options;
|
|
32822
33018
|
const forcedOn = process.env[PLUGIN_DEPLOYMENT_RUNTIME_FLAG] === "true" || process.env[PLUGIN_DEPLOYMENT_RUNTIME_FLAG] === "1";
|
|
32823
33019
|
const effectiveServiceBaseUrl = options.wiring.serviceBaseUrl ?? process.env.MICROSANDBOX_SERVICE_BASE_URL;
|
|
32824
33020
|
if (forcedOn && !effectiveServiceBaseUrl) {
|
|
32825
|
-
|
|
33021
|
+
logger9.warn(
|
|
32826
33022
|
`${PLUGIN_DEPLOYMENT_RUNTIME_FLAG} is enabled but MICROSANDBOX_SERVICE_BASE_URL is empty; skipping plugin deployment runtime`,
|
|
32827
33023
|
{ holder }
|
|
32828
33024
|
);
|
|
@@ -32841,8 +33037,8 @@ function startPluginDeploymentRuntime(options) {
|
|
|
32841
33037
|
};
|
|
32842
33038
|
const service2 = createService(deps);
|
|
32843
33039
|
register(service2);
|
|
32844
|
-
|
|
32845
|
-
const reconcile = runStartupReconcile(service2, reconcileDeadlineMs,
|
|
33040
|
+
logger9.info("plugin deployment runtime started", { holder });
|
|
33041
|
+
const reconcile = runStartupReconcile(service2, reconcileDeadlineMs, logger9, holder);
|
|
32846
33042
|
let held = false;
|
|
32847
33043
|
let inFlight = false;
|
|
32848
33044
|
const tick = async () => {
|
|
@@ -32850,18 +33046,18 @@ function startPluginDeploymentRuntime(options) {
|
|
|
32850
33046
|
inFlight = true;
|
|
32851
33047
|
try {
|
|
32852
33048
|
if (held) {
|
|
32853
|
-
held = await renewLease(lease, holder,
|
|
33049
|
+
held = await renewLease(lease, holder, logger9);
|
|
32854
33050
|
if (!held) {
|
|
32855
|
-
|
|
33051
|
+
logger9.warn("plugin deployment lease lost; watchdog paused", { holder });
|
|
32856
33052
|
}
|
|
32857
33053
|
} else {
|
|
32858
|
-
held = await acquireLease(lease, holder,
|
|
33054
|
+
held = await acquireLease(lease, holder, logger9);
|
|
32859
33055
|
if (held) {
|
|
32860
|
-
|
|
33056
|
+
logger9.info("plugin deployment lease acquired", { holder });
|
|
32861
33057
|
}
|
|
32862
33058
|
}
|
|
32863
33059
|
if (!held) return;
|
|
32864
|
-
await runWatchdog(service2, holder,
|
|
33060
|
+
await runWatchdog(service2, holder, logger9);
|
|
32865
33061
|
} finally {
|
|
32866
33062
|
inFlight = false;
|
|
32867
33063
|
}
|
|
@@ -32877,7 +33073,7 @@ function startPluginDeploymentRuntime(options) {
|
|
|
32877
33073
|
try {
|
|
32878
33074
|
await lease.release(PLUGIN_DEPLOYMENT_LEASE_KEY, holder);
|
|
32879
33075
|
} catch (error) {
|
|
32880
|
-
|
|
33076
|
+
logger9.warn("plugin deployment lease release failed", {
|
|
32881
33077
|
holder,
|
|
32882
33078
|
error: errorMessage5(error)
|
|
32883
33079
|
});
|
|
@@ -32885,16 +33081,16 @@ function startPluginDeploymentRuntime(options) {
|
|
|
32885
33081
|
held = false;
|
|
32886
33082
|
}
|
|
32887
33083
|
register(void 0);
|
|
32888
|
-
|
|
33084
|
+
logger9.info("plugin deployment runtime stopped", { holder });
|
|
32889
33085
|
}
|
|
32890
33086
|
};
|
|
32891
33087
|
}
|
|
32892
|
-
async function runStartupReconcile(service2, deadlineMs,
|
|
33088
|
+
async function runStartupReconcile(service2, deadlineMs, logger9, holder) {
|
|
32893
33089
|
try {
|
|
32894
33090
|
await withDeadline(service2.startupReconcile(), deadlineMs);
|
|
32895
|
-
|
|
33091
|
+
logger9.info("plugin deployment startup reconcile complete", { holder });
|
|
32896
33092
|
} catch (error) {
|
|
32897
|
-
|
|
33093
|
+
logger9.warn("plugin deployment startup reconcile failed", {
|
|
32898
33094
|
holder,
|
|
32899
33095
|
error: errorMessage5(error)
|
|
32900
33096
|
});
|
|
@@ -32917,7 +33113,7 @@ async function withDeadline(work, deadlineMs) {
|
|
|
32917
33113
|
if (timer !== void 0) clearTimeout(timer);
|
|
32918
33114
|
}
|
|
32919
33115
|
}
|
|
32920
|
-
async function acquireLease(lease, holder,
|
|
33116
|
+
async function acquireLease(lease, holder, logger9) {
|
|
32921
33117
|
try {
|
|
32922
33118
|
return await lease.tryAcquire(
|
|
32923
33119
|
PLUGIN_DEPLOYMENT_LEASE_KEY,
|
|
@@ -32925,14 +33121,14 @@ async function acquireLease(lease, holder, logger8) {
|
|
|
32925
33121
|
PLUGIN_DEPLOYMENT_LEASE_TTL_MS
|
|
32926
33122
|
);
|
|
32927
33123
|
} catch (error) {
|
|
32928
|
-
|
|
33124
|
+
logger9.warn("plugin deployment lease acquire failed", {
|
|
32929
33125
|
holder,
|
|
32930
33126
|
error: errorMessage5(error)
|
|
32931
33127
|
});
|
|
32932
33128
|
return false;
|
|
32933
33129
|
}
|
|
32934
33130
|
}
|
|
32935
|
-
async function renewLease(lease, holder,
|
|
33131
|
+
async function renewLease(lease, holder, logger9) {
|
|
32936
33132
|
try {
|
|
32937
33133
|
return await lease.renew(
|
|
32938
33134
|
PLUGIN_DEPLOYMENT_LEASE_KEY,
|
|
@@ -32940,18 +33136,18 @@ async function renewLease(lease, holder, logger8) {
|
|
|
32940
33136
|
PLUGIN_DEPLOYMENT_LEASE_TTL_MS
|
|
32941
33137
|
);
|
|
32942
33138
|
} catch (error) {
|
|
32943
|
-
|
|
33139
|
+
logger9.warn("plugin deployment lease renew failed", {
|
|
32944
33140
|
holder,
|
|
32945
33141
|
error: errorMessage5(error)
|
|
32946
33142
|
});
|
|
32947
33143
|
return false;
|
|
32948
33144
|
}
|
|
32949
33145
|
}
|
|
32950
|
-
async function runWatchdog(service2, holder,
|
|
33146
|
+
async function runWatchdog(service2, holder, logger9) {
|
|
32951
33147
|
try {
|
|
32952
33148
|
await service2.healthWatchdog();
|
|
32953
33149
|
} catch (error) {
|
|
32954
|
-
|
|
33150
|
+
logger9.warn("plugin deployment health watchdog failed", {
|
|
32955
33151
|
holder,
|
|
32956
33152
|
error: errorMessage5(error)
|
|
32957
33153
|
});
|
|
@@ -32989,29 +33185,29 @@ function storeClassName(kind) {
|
|
|
32989
33185
|
return void 0;
|
|
32990
33186
|
}
|
|
32991
33187
|
}
|
|
32992
|
-
function warnMultiReplicaReadiness(
|
|
33188
|
+
function warnMultiReplicaReadiness(logger9) {
|
|
32993
33189
|
if (typeof process.env.AXIOM_REPLICA_ID !== "string" || process.env.AXIOM_REPLICA_ID.trim() === "") return;
|
|
32994
33190
|
for (const kind of SHARED_STORE_KINDS) {
|
|
32995
33191
|
const name = storeClassName(kind);
|
|
32996
33192
|
if (name === void 0 || !name.startsWith("InMemory")) continue;
|
|
32997
|
-
|
|
33193
|
+
logger9.warn(`Multi-replica: store '${kind}' is ${name} (not shared); configure a shared store`, {
|
|
32998
33194
|
phase: "multi_replica_readiness",
|
|
32999
33195
|
store: kind
|
|
33000
33196
|
});
|
|
33001
33197
|
}
|
|
33002
33198
|
if (!process.env.AUTH_TOKEN_SECRET?.trim() && !process.env.JWT_SECRET?.trim()) {
|
|
33003
|
-
|
|
33199
|
+
logger9.warn(
|
|
33004
33200
|
"Multi-replica: AUTH_TOKEN_SECRET/JWT_SECRET unset; console sessions are signed per-process and will not verify across replicas",
|
|
33005
33201
|
{ phase: "multi_replica_readiness", env: "AUTH_TOKEN_SECRET" }
|
|
33006
33202
|
);
|
|
33007
33203
|
}
|
|
33008
33204
|
if (!process.env.LATTICE_ENCRYPTION_KEY?.trim()) {
|
|
33009
|
-
|
|
33205
|
+
logger9.warn(
|
|
33010
33206
|
"Multi-replica: LATTICE_ENCRYPTION_KEY unset; stored credentials use the shared dev default and may not decrypt across differing keys",
|
|
33011
33207
|
{ phase: "multi_replica_readiness", env: "LATTICE_ENCRYPTION_KEY" }
|
|
33012
33208
|
);
|
|
33013
33209
|
}
|
|
33014
|
-
|
|
33210
|
+
logger9.warn(
|
|
33015
33211
|
"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
33212
|
{ phase: "multi_replica_readiness", feature: "agent-run-sse" }
|
|
33017
33213
|
);
|
|
@@ -33154,7 +33350,7 @@ var DEFAULT_LOGGER_CONFIG = {
|
|
|
33154
33350
|
loggerName: "lattice/gateway"
|
|
33155
33351
|
};
|
|
33156
33352
|
var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
|
|
33157
|
-
var
|
|
33353
|
+
var logger8 = loggerLattice.client;
|
|
33158
33354
|
function initializeLogger(config) {
|
|
33159
33355
|
if (import_core98.loggerLatticeManager.hasLattice("default")) {
|
|
33160
33356
|
import_core98.loggerLatticeManager.removeLattice("default");
|
|
@@ -33241,7 +33437,7 @@ app.setErrorHandler((error, request, reply) => {
|
|
|
33241
33437
|
"x-request-id": getHeaderValue(request.headers["x-request-id"]),
|
|
33242
33438
|
"x-user-id": getHeaderValue(request.headers["x-user-id"])
|
|
33243
33439
|
};
|
|
33244
|
-
|
|
33440
|
+
logger8.error(
|
|
33245
33441
|
`\u8BF7\u6C42\u9519\u8BEF: ${request.method} ${request.url} error:${error.message}`,
|
|
33246
33442
|
{
|
|
33247
33443
|
...context,
|
|
@@ -33277,14 +33473,14 @@ async function restoreMcpConnections() {
|
|
|
33277
33473
|
const storeLattice = (0, import_core98.getStoreLattice)("default", "mcp");
|
|
33278
33474
|
const store2 = storeLattice.store;
|
|
33279
33475
|
if (!store2) {
|
|
33280
|
-
|
|
33476
|
+
logger8.info("MCP store not configured, skipping connection restoration");
|
|
33281
33477
|
return;
|
|
33282
33478
|
}
|
|
33283
33479
|
const configs = (await store2.getAllConfigsWithoutTenant()).filter(
|
|
33284
33480
|
(c2) => c2.status === "connected"
|
|
33285
33481
|
);
|
|
33286
33482
|
if (configs.length === 0) return;
|
|
33287
|
-
|
|
33483
|
+
logger8.info(`Restoring ${configs.length} MCP server connections...`);
|
|
33288
33484
|
const deps = {
|
|
33289
33485
|
store: store2,
|
|
33290
33486
|
manager: import_core98.mcpManager,
|
|
@@ -33301,15 +33497,15 @@ async function restoreMcpConnections() {
|
|
|
33301
33497
|
results.forEach((result, index) => {
|
|
33302
33498
|
if (result.status === "rejected") {
|
|
33303
33499
|
const config = configs[index];
|
|
33304
|
-
|
|
33500
|
+
logger8.warn(
|
|
33305
33501
|
`Failed to restore MCP server "${config.tenantId}/${config.key}"`,
|
|
33306
33502
|
{ error: result.reason }
|
|
33307
33503
|
);
|
|
33308
33504
|
}
|
|
33309
33505
|
});
|
|
33310
|
-
|
|
33506
|
+
logger8.info(`MCP connection restoration complete: ${configs.length} servers`);
|
|
33311
33507
|
} catch (err) {
|
|
33312
|
-
|
|
33508
|
+
logger8.error("MCP connection restoration failed", { error: err });
|
|
33313
33509
|
}
|
|
33314
33510
|
}
|
|
33315
33511
|
var start = async (config) => {
|
|
@@ -33322,7 +33518,7 @@ var start = async (config) => {
|
|
|
33322
33518
|
file: config.loggerConfig.file || DEFAULT_LOGGER_CONFIG.file
|
|
33323
33519
|
};
|
|
33324
33520
|
loggerLattice = initializeLogger(loggerConfig);
|
|
33325
|
-
|
|
33521
|
+
logger8 = loggerLattice.client;
|
|
33326
33522
|
}
|
|
33327
33523
|
app.decorate("loggerLattice", loggerLattice);
|
|
33328
33524
|
const projectRoomRealtimeMode = resolveProjectRoomRealtimeMode();
|
|
@@ -33332,12 +33528,13 @@ var start = async (config) => {
|
|
|
33332
33528
|
tasks: (0, import_core98.getStoreLattice)("default", "task").store,
|
|
33333
33529
|
rooms: (0, import_core98.getStoreLattice)("default", "projectRoom").store,
|
|
33334
33530
|
memberships: (0, import_core98.getStoreLattice)("default", "projectBotMembership").store,
|
|
33335
|
-
log: { warn: (message, context) =>
|
|
33531
|
+
log: { warn: (message, context) => logger8.warn(message, context) }
|
|
33336
33532
|
});
|
|
33337
33533
|
}
|
|
33338
33534
|
let channelDeps;
|
|
33339
33535
|
const adapterRegistry = new ChannelAdapterRegistry();
|
|
33340
33536
|
adapterRegistry.register(larkChannelAdapter);
|
|
33537
|
+
adapterRegistry.register(wecomChannelAdapter);
|
|
33341
33538
|
const { wechatChannelAdapter: wechatChannelAdapter2 } = await Promise.resolve().then(() => (init_WechatChannelAdapter(), WechatChannelAdapter_exports));
|
|
33342
33539
|
adapterRegistry.register(wechatChannelAdapter2);
|
|
33343
33540
|
try {
|
|
@@ -33350,7 +33547,7 @@ var start = async (config) => {
|
|
|
33350
33547
|
createRateLimitMiddleware(),
|
|
33351
33548
|
createAuditLoggerMiddleware()
|
|
33352
33549
|
],
|
|
33353
|
-
warn: (message, context) =>
|
|
33550
|
+
warn: (message, context) => logger8.warn(message, context),
|
|
33354
33551
|
realtime: projectRoomRealtimeRuntime?.publisher
|
|
33355
33552
|
});
|
|
33356
33553
|
const bindingStore = infrastructure.bindingRegistry;
|
|
@@ -33364,10 +33561,10 @@ var start = async (config) => {
|
|
|
33364
33561
|
installationStore,
|
|
33365
33562
|
bindingRegistry: bindingStore,
|
|
33366
33563
|
realtime: projectRoomRealtimeRuntime?.publisher,
|
|
33367
|
-
warn: (message, context) =>
|
|
33564
|
+
warn: (message, context) => logger8.warn(message, context)
|
|
33368
33565
|
};
|
|
33369
33566
|
} catch (err) {
|
|
33370
|
-
|
|
33567
|
+
logger8.warn("Channel infrastructure unavailable", {
|
|
33371
33568
|
error: err instanceof Error ? err.message : String(err)
|
|
33372
33569
|
});
|
|
33373
33570
|
}
|
|
@@ -33375,7 +33572,7 @@ var start = async (config) => {
|
|
|
33375
33572
|
try {
|
|
33376
33573
|
const menuStore = (0, import_core98.getStoreLattice)("default", "menu").store;
|
|
33377
33574
|
(0, import_core97.setMenuRegistry)(menuStore);
|
|
33378
|
-
|
|
33575
|
+
logger8.info("Menu registry initialized");
|
|
33379
33576
|
} catch {
|
|
33380
33577
|
}
|
|
33381
33578
|
registerAllBuiltinEntities();
|
|
@@ -33384,7 +33581,7 @@ var start = async (config) => {
|
|
|
33384
33581
|
}
|
|
33385
33582
|
const routes = registerLatticeRoutes(app, channelDeps, {
|
|
33386
33583
|
projectTaskEnabled: process.env.AXIOM_PROJECT_TASK_EXECUTION_ENABLED !== "false",
|
|
33387
|
-
projectTaskLog: { warn: (message, context) =>
|
|
33584
|
+
projectTaskLog: { warn: (message, context) => logger8.warn(message, context) },
|
|
33388
33585
|
projectRoomRealtimeRuntime
|
|
33389
33586
|
});
|
|
33390
33587
|
try {
|
|
@@ -33412,9 +33609,9 @@ var start = async (config) => {
|
|
|
33412
33609
|
getProjectStore: () => projectStore
|
|
33413
33610
|
});
|
|
33414
33611
|
a2a.registerA2ARoutes(app);
|
|
33415
|
-
|
|
33612
|
+
logger8.info("A2A standard routes registered");
|
|
33416
33613
|
} catch (err) {
|
|
33417
|
-
|
|
33614
|
+
logger8.warn("A2A standard routes unavailable", {
|
|
33418
33615
|
error: err instanceof Error ? err.message : String(err)
|
|
33419
33616
|
});
|
|
33420
33617
|
}
|
|
@@ -33451,26 +33648,26 @@ var start = async (config) => {
|
|
|
33451
33648
|
registerOpenFilesRoutes2(app);
|
|
33452
33649
|
registerOpenAuditRoutes2(app);
|
|
33453
33650
|
registerOpenExposureRoutes2(app);
|
|
33454
|
-
|
|
33651
|
+
logger8.info("Open API routes registered (kb + sandbox providers, session exchange)");
|
|
33455
33652
|
} catch (err) {
|
|
33456
|
-
|
|
33653
|
+
logger8.warn("Open API routes unavailable", {
|
|
33457
33654
|
error: err instanceof Error ? err.message : String(err)
|
|
33458
33655
|
});
|
|
33459
33656
|
}
|
|
33460
33657
|
try {
|
|
33461
33658
|
const { registerGatewaySandboxOpenCredentialProvider: registerGatewaySandboxOpenCredentialProvider2 } = await Promise.resolve().then(() => (init_sandboxOpenCredentialProvider(), sandboxOpenCredentialProvider_exports));
|
|
33462
33659
|
registerGatewaySandboxOpenCredentialProvider2((error) => {
|
|
33463
|
-
|
|
33660
|
+
logger8.warn("sandbox open-credential provider failed", { error });
|
|
33464
33661
|
});
|
|
33465
|
-
|
|
33662
|
+
logger8.info("Sandbox open-credential provider registered");
|
|
33466
33663
|
} catch (err) {
|
|
33467
|
-
|
|
33664
|
+
logger8.warn("Sandbox open-credential provider unavailable", {
|
|
33468
33665
|
error: err instanceof Error ? err.message : String(err)
|
|
33469
33666
|
});
|
|
33470
33667
|
}
|
|
33471
33668
|
if (!import_core98.sandboxLatticeManager.hasLattice("default")) {
|
|
33472
33669
|
import_core98.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
|
|
33473
|
-
|
|
33670
|
+
logger8.info("Registered sandbox manager from env configuration");
|
|
33474
33671
|
}
|
|
33475
33672
|
if (isPluginDeploymentRuntimeEnabled()) {
|
|
33476
33673
|
try {
|
|
@@ -33497,21 +33694,21 @@ var start = async (config) => {
|
|
|
33497
33694
|
listAllDeployments,
|
|
33498
33695
|
// The service logs fields-first; the gateway logger is message-first.
|
|
33499
33696
|
logger: {
|
|
33500
|
-
info: (fields, message) =>
|
|
33501
|
-
warn: (fields, message) =>
|
|
33502
|
-
error: (fields, message) =>
|
|
33697
|
+
info: (fields, message) => logger8.info(message ?? "plugin deployment", fields),
|
|
33698
|
+
warn: (fields, message) => logger8.warn(message ?? "plugin deployment", fields),
|
|
33699
|
+
error: (fields, message) => logger8.error(message ?? "plugin deployment", fields)
|
|
33503
33700
|
}
|
|
33504
33701
|
},
|
|
33505
33702
|
lease: leaseStore2,
|
|
33506
33703
|
holder: (0, import_core98.getReplicaId)(),
|
|
33507
|
-
logger:
|
|
33704
|
+
logger: logger8
|
|
33508
33705
|
});
|
|
33509
33706
|
app.addHook("onClose", async () => {
|
|
33510
33707
|
await pluginDeploymentRuntime.dispose();
|
|
33511
33708
|
});
|
|
33512
|
-
|
|
33709
|
+
logger8.info("Plugin deployment runtime started");
|
|
33513
33710
|
} catch (err) {
|
|
33514
|
-
|
|
33711
|
+
logger8.warn("Plugin deployment runtime unavailable", {
|
|
33515
33712
|
error: err instanceof Error ? err.message : String(err)
|
|
33516
33713
|
});
|
|
33517
33714
|
}
|
|
@@ -33524,12 +33721,12 @@ var start = async (config) => {
|
|
|
33524
33721
|
store: sharedResourceStore,
|
|
33525
33722
|
sandboxManager: import_core98.sandboxLatticeManager,
|
|
33526
33723
|
cache: cache2,
|
|
33527
|
-
logger:
|
|
33724
|
+
logger: logger8
|
|
33528
33725
|
});
|
|
33529
33726
|
registerResourceRoutes(app, resourceController);
|
|
33530
|
-
|
|
33727
|
+
logger8.info("Resource share routes registered");
|
|
33531
33728
|
} catch (err) {
|
|
33532
|
-
|
|
33729
|
+
logger8.warn("Resource share infrastructure unavailable", {
|
|
33533
33730
|
error: err instanceof Error ? err.message : String(err)
|
|
33534
33731
|
});
|
|
33535
33732
|
}
|
|
@@ -33542,14 +33739,14 @@ var start = async (config) => {
|
|
|
33542
33739
|
deps: { router: channelDeps.router }
|
|
33543
33740
|
}),
|
|
33544
33741
|
disconnect: () => (0, import_core98.disconnectAllChannels)((channel) => adapterRegistry.get(channel)),
|
|
33545
|
-
log: { warn: (message, context) =>
|
|
33742
|
+
log: { warn: (message, context) => logger8.warn(message, context) }
|
|
33546
33743
|
});
|
|
33547
33744
|
app.addHook("onClose", async () => {
|
|
33548
33745
|
await channelLeader.stop();
|
|
33549
33746
|
});
|
|
33550
33747
|
channelLeader.start();
|
|
33551
33748
|
} catch (err) {
|
|
33552
|
-
|
|
33749
|
+
logger8.error("Failed to start channel connections", {
|
|
33553
33750
|
error: err instanceof Error ? err.message : String(err)
|
|
33554
33751
|
});
|
|
33555
33752
|
}
|
|
@@ -33596,24 +33793,24 @@ var start = async (config) => {
|
|
|
33596
33793
|
await handleModelProviderChanged(payload, (tenantId, providerId2) => controller.reconcileProvider(tenantId, providerId2));
|
|
33597
33794
|
}
|
|
33598
33795
|
},
|
|
33599
|
-
log:
|
|
33796
|
+
log: logger8
|
|
33600
33797
|
});
|
|
33601
33798
|
try {
|
|
33602
33799
|
await outboxPoller.start();
|
|
33603
33800
|
} catch (err) {
|
|
33604
|
-
|
|
33801
|
+
logger8.warn("Outbox poller failed to start", { error: err instanceof Error ? err.message : String(err) });
|
|
33605
33802
|
}
|
|
33606
33803
|
const leaseStore = (0, import_core98.getStoreLattice)("default", "lease").store;
|
|
33607
33804
|
if (leaseStore.constructor?.name === "InMemoryLeaseStore") {
|
|
33608
|
-
|
|
33805
|
+
logger8.warn(
|
|
33609
33806
|
"Startup recovery leader gate uses a non-distributed lease store (per-process only); configure a shared 'lease' store for multi-replica deployments",
|
|
33610
33807
|
{ phase: "startup_recovery" }
|
|
33611
33808
|
);
|
|
33612
33809
|
}
|
|
33613
|
-
warnMultiReplicaReadiness(
|
|
33810
|
+
warnMultiReplicaReadiness(logger8);
|
|
33614
33811
|
const startup = await (0, import_core98.runAsLeader)(leaseStore, "startup-recovery", async () => {
|
|
33615
33812
|
if (routes.projectTaskRuntime) {
|
|
33616
|
-
await prepareProjectTaskRuntime(routes.projectTaskRuntime,
|
|
33813
|
+
await prepareProjectTaskRuntime(routes.projectTaskRuntime, logger8);
|
|
33617
33814
|
}
|
|
33618
33815
|
if (process.env.AXIOM_TASK_ORPHAN_RECOVERY === "true") {
|
|
33619
33816
|
try {
|
|
@@ -33624,19 +33821,19 @@ var start = async (config) => {
|
|
|
33624
33821
|
workItemStore: (0, import_core98.getStoreLattice)("default", "taskWorkItem").store,
|
|
33625
33822
|
tenantStore: (0, import_core98.getStoreLattice)("default", "tenant").store,
|
|
33626
33823
|
...createRecoveryCallerDeps2(),
|
|
33627
|
-
log:
|
|
33824
|
+
log: logger8
|
|
33628
33825
|
});
|
|
33629
33826
|
await runtime.recoverAll();
|
|
33630
33827
|
} catch (err) {
|
|
33631
|
-
|
|
33828
|
+
logger8.warn("Task orphan recovery failed", { error: err instanceof Error ? err.message : String(err) });
|
|
33632
33829
|
}
|
|
33633
33830
|
}
|
|
33634
33831
|
if (import_core98.scheduleLatticeManager.hasLattice("default")) {
|
|
33635
33832
|
try {
|
|
33636
33833
|
const restored = await import_core98.scheduleLatticeManager.getScheduleLattice("default").restore();
|
|
33637
|
-
|
|
33834
|
+
logger8.info("Scheduled tasks restored", { phase: "startup_recovery", restored });
|
|
33638
33835
|
} catch (err) {
|
|
33639
|
-
|
|
33836
|
+
logger8.warn("Scheduled task restore failed", {
|
|
33640
33837
|
phase: "startup_recovery",
|
|
33641
33838
|
error: err instanceof Error ? err.message : String(err)
|
|
33642
33839
|
});
|
|
@@ -33644,13 +33841,13 @@ var start = async (config) => {
|
|
|
33644
33841
|
}
|
|
33645
33842
|
}, { hold: true, ttlMs: 5 * 6e4 });
|
|
33646
33843
|
if (!startup.ran) {
|
|
33647
|
-
|
|
33844
|
+
logger8.info("Startup recovery skipped (another replica leads)", { phase: "startup_recovery" });
|
|
33648
33845
|
}
|
|
33649
33846
|
await app.listen({ port: target_port, host: "0.0.0.0" });
|
|
33650
|
-
|
|
33847
|
+
logger8.info(`Lattice Gateway is running on port: ${target_port}`);
|
|
33651
33848
|
const outboxRetention = createOutboxRetentionJob({
|
|
33652
33849
|
outbox: outboxStore,
|
|
33653
|
-
log:
|
|
33850
|
+
log: logger8
|
|
33654
33851
|
});
|
|
33655
33852
|
outboxRetention.start();
|
|
33656
33853
|
let agentTaskConsumer;
|
|
@@ -33663,15 +33860,15 @@ var start = async (config) => {
|
|
|
33663
33860
|
}
|
|
33664
33861
|
}
|
|
33665
33862
|
restoreMcpConnections().catch((error) => {
|
|
33666
|
-
|
|
33863
|
+
logger8.error("MCP connection restoration failed", { error });
|
|
33667
33864
|
});
|
|
33668
33865
|
if (config?.gracefulShutdown !== false && !shutdownHandlersInstalled) {
|
|
33669
33866
|
shutdownHandlersInstalled = true;
|
|
33670
33867
|
const gracefulShutdown = createGracefulShutdown({
|
|
33671
33868
|
timeoutMs: config?.gracefulShutdownTimeoutMs ?? 1e4,
|
|
33672
33869
|
log: {
|
|
33673
|
-
info: (message, context) =>
|
|
33674
|
-
warn: (message, context) =>
|
|
33870
|
+
info: (message, context) => logger8.info(message, context),
|
|
33871
|
+
warn: (message, context) => logger8.warn(message, context)
|
|
33675
33872
|
},
|
|
33676
33873
|
steps: [
|
|
33677
33874
|
async () => {
|
|
@@ -33689,7 +33886,7 @@ var start = async (config) => {
|
|
|
33689
33886
|
process.once("SIGINT", () => void gracefulShutdown("SIGINT"));
|
|
33690
33887
|
}
|
|
33691
33888
|
} catch (err) {
|
|
33692
|
-
|
|
33889
|
+
logger8.error("Server start failed", { error: err });
|
|
33693
33890
|
process.exit(1);
|
|
33694
33891
|
}
|
|
33695
33892
|
};
|