@whyshu/argent 0.2.6 → 0.2.7
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/package.json +1 -1
- package/src/index.js +38 -33
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -227,39 +227,44 @@ export function apply(ctx) {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
230
|
+
// ⛔ 2026-11-07 实测:启动阶段 ctx.plugin(dsh-mcp-client) 会挂起 dsh 启动(端口 bound 但 HTTP 不响应),
|
|
231
|
+
// 用户侧表现为「dsh 启动失败」;只有删插件才能启动。故:默认延后注册,且可用 ARGENT_MCP_DISABLE=1 关闭。
|
|
232
|
+
if (process.env.ARGENT_MCP_DISABLE === '1') {
|
|
233
|
+
console.log('[argent] MCP 网关已禁用(ARGENT_MCP_DISABLE=1)')
|
|
234
|
+
} else setTimeout(() => { void (async () => {
|
|
235
|
+
try {
|
|
236
|
+
const mcpClient = await hostImport('@deepseek-ai/dsh-mcp-client')
|
|
237
|
+
const mcpReady = ctx.plugin(mcpClient, {
|
|
238
|
+
transport: 'stdio',
|
|
239
|
+
serverName: 'argent',
|
|
240
|
+
command: process.execPath,
|
|
241
|
+
args: [join(PKG_ROOT, 'mcp', 'gateway.mjs')],
|
|
242
|
+
cwd: PKG_ROOT,
|
|
243
|
+
env: {
|
|
244
|
+
ARGENT_DATA_DIR: dataDir,
|
|
245
|
+
ARGENT_TENANT: TENANT,
|
|
246
|
+
ARGENT_ENGINE_DIR: engineDir,
|
|
247
|
+
ARGENT_GATEWAY_ML: process.env.ARGENT_GATEWAY_ML || '',
|
|
248
|
+
},
|
|
249
|
+
toolCallTimeoutMs: 180000,
|
|
250
|
+
failOnStartupError: false,
|
|
251
|
+
})
|
|
252
|
+
// 启动等待上限:网关子进程已起但 mcp-client 握手可能很慢(2026-11-07 本机实测挂起)
|
|
253
|
+
// ⇒ 超时只告警、不阻塞后续(隧道/ERP 连接器已在前面启动)。
|
|
254
|
+
const MCP_START_TIMEOUT_MS = 20_000
|
|
255
|
+
const raced = await Promise.race([
|
|
256
|
+
mcpReady.then(() => 'ok'),
|
|
257
|
+
new Promise((resolve) => {
|
|
258
|
+
const t = setTimeout(() => resolve('timeout'), MCP_START_TIMEOUT_MS)
|
|
259
|
+
t.unref?.()
|
|
260
|
+
}),
|
|
261
|
+
])
|
|
262
|
+
if (raced === 'ok') console.log(`[argent] MCP 网关已注册(engineDir=${engineDir || '(无引擎)'})`)
|
|
263
|
+
else console.warn(`[argent] MCP 网关握手超时(${MCP_START_TIMEOUT_MS}ms,后台继续;不影响隧道/ERP 连接器)`)
|
|
264
|
+
} catch (e) {
|
|
265
|
+
console.error('[argent] MCP 网关注册失败(其余功能不受影响):', e?.message || e)
|
|
266
|
+
}
|
|
267
|
+
})(); }, 5000)
|
|
263
268
|
|
|
264
269
|
// ERP 连接器:只有 poller 才启动(UI 端不抢队列)
|
|
265
270
|
if (role === 'poller') {
|