@whyshu/argent 0.2.5 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +50 -33
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyshu/argent",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "type": "module",
5
5
  "description": "Argent 单 bundle(dsh web / DSH Desktop 同一插件):ERP 连接器 + 问述代理 + 登录/续期 + MCP 网关 + 伞伞桌宠(含积分)",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -212,39 +212,6 @@ export function apply(ctx) {
212
212
  role = 'ui'
213
213
  }
214
214
 
215
- // MCP 网关(engine.* / erp.* / ml.*)
216
- try {
217
- const mcpClient = await hostImport('@deepseek-ai/dsh-mcp-client')
218
- await ctx.plugin(mcpClient, {
219
- transport: 'stdio',
220
- serverName: 'argent',
221
- command: process.execPath,
222
- args: [join(PKG_ROOT, 'mcp', 'gateway.mjs')],
223
- cwd: PKG_ROOT,
224
- env: {
225
- ARGENT_DATA_DIR: dataDir,
226
- ARGENT_TENANT: TENANT,
227
- ARGENT_ENGINE_DIR: engineDir,
228
- ARGENT_GATEWAY_ML: process.env.ARGENT_GATEWAY_ML || '',
229
- },
230
- toolCallTimeoutMs: 180000,
231
- failOnStartupError: false,
232
- })
233
- console.log(`[argent] MCP 网关已注册(engineDir=${engineDir || '(无引擎)'})`)
234
- } catch (e) {
235
- console.error('[argent] MCP 网关注册失败(其余功能不受影响):', e?.message || e)
236
- }
237
-
238
- // ERP 连接器:只有 poller 才启动(UI 端不抢队列)
239
- if (role === 'poller') {
240
- try {
241
- startOfficeRuntime(ctx, { dataDir })
242
- console.log(`[argent] ERP 连接器已启动,数据目录: ${dataDir}`)
243
- } catch (e) {
244
- console.error('[argent] ERP 连接器启动失败(不影响 dsh):', e?.message || e)
245
- }
246
- }
247
-
248
215
  // ⑥ App 真流式隧道(默认关:ARGENT_TUNNEL=1 才启动;Mac 出站到 relay,契约 §2)
249
216
  // 放在内核解析之后(用最终 dataDir 读 agent-report.json#machineId);未登录/缺 machineId 只记日志不抛。
250
217
  if (isTunnelEnabled()) {
@@ -259,5 +226,55 @@ export function apply(ctx) {
259
226
  console.error('[argent] 隧道启动失败(不影响其余功能):', e?.message || e)
260
227
  }
261
228
  }
229
+
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)
268
+
269
+ // ERP 连接器:只有 poller 才启动(UI 端不抢队列)
270
+ if (role === 'poller') {
271
+ try {
272
+ startOfficeRuntime(ctx, { dataDir })
273
+ console.log(`[argent] ERP 连接器已启动,数据目录: ${dataDir}`)
274
+ } catch (e) {
275
+ console.error('[argent] ERP 连接器启动失败(不影响 dsh):', e?.message || e)
276
+ }
277
+ }
278
+
262
279
  })()
263
280
  }