@whyshu/argent 0.2.5 → 0.2.6

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 +28 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyshu/argent",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
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,10 +212,25 @@ export function apply(ctx) {
212
212
  role = 'ui'
213
213
  }
214
214
 
215
+ // ⑥ App 真流式隧道(默认关:ARGENT_TUNNEL=1 才启动;Mac 出站到 relay,契约 §2)
216
+ // 放在内核解析之后(用最终 dataDir 读 agent-report.json#machineId);未登录/缺 machineId 只记日志不抛。
217
+ if (isTunnelEnabled()) {
218
+ try {
219
+ const { startTunnel } = await import('./tunnel.mjs')
220
+ const tunnel = startTunnel({ dataDir, version: PKG_VERSION })
221
+ if (tunnel) {
222
+ ctx.on?.('dispose', () => { try { tunnel.stop() } catch { /* 退出清理失败不影响宿主 */ } })
223
+ console.log(`[argent] App 隧道已启动(${tunnel.endpoint},machineId=${tunnel.machineId})`)
224
+ }
225
+ } catch (e) {
226
+ console.error('[argent] 隧道启动失败(不影响其余功能):', e?.message || e)
227
+ }
228
+ }
229
+
215
230
  // MCP 网关(engine.* / erp.* / ml.*)
216
231
  try {
217
232
  const mcpClient = await hostImport('@deepseek-ai/dsh-mcp-client')
218
- await ctx.plugin(mcpClient, {
233
+ const mcpReady = ctx.plugin(mcpClient, {
219
234
  transport: 'stdio',
220
235
  serverName: 'argent',
221
236
  command: process.execPath,
@@ -230,7 +245,18 @@ export function apply(ctx) {
230
245
  toolCallTimeoutMs: 180000,
231
246
  failOnStartupError: false,
232
247
  })
233
- console.log(`[argent] MCP 网关已注册(engineDir=${engineDir || '(无引擎)'})`)
248
+ // 启动等待上限:网关子进程已起但 mcp-client 握手可能很慢(2026-11-07 本机实测挂起)
249
+ // ⇒ 超时只告警、不阻塞后续(隧道/ERP 连接器已在前面启动)。
250
+ const MCP_START_TIMEOUT_MS = 20_000
251
+ const raced = await Promise.race([
252
+ mcpReady.then(() => 'ok'),
253
+ new Promise((resolve) => {
254
+ const t = setTimeout(() => resolve('timeout'), MCP_START_TIMEOUT_MS)
255
+ t.unref?.()
256
+ }),
257
+ ])
258
+ if (raced === 'ok') console.log(`[argent] MCP 网关已注册(engineDir=${engineDir || '(无引擎)'})`)
259
+ else console.warn(`[argent] MCP 网关握手超时(${MCP_START_TIMEOUT_MS}ms,后台继续;不影响隧道/ERP 连接器)`)
234
260
  } catch (e) {
235
261
  console.error('[argent] MCP 网关注册失败(其余功能不受影响):', e?.message || e)
236
262
  }
@@ -245,19 +271,5 @@ export function apply(ctx) {
245
271
  }
246
272
  }
247
273
 
248
- // ⑥ App 真流式隧道(默认关:ARGENT_TUNNEL=1 才启动;Mac 出站到 relay,契约 §2)
249
- // 放在内核解析之后(用最终 dataDir 读 agent-report.json#machineId);未登录/缺 machineId 只记日志不抛。
250
- if (isTunnelEnabled()) {
251
- try {
252
- const { startTunnel } = await import('./tunnel.mjs')
253
- const tunnel = startTunnel({ dataDir, version: PKG_VERSION })
254
- if (tunnel) {
255
- ctx.on?.('dispose', () => { try { tunnel.stop() } catch { /* 退出清理失败不影响宿主 */ } })
256
- console.log(`[argent] App 隧道已启动(${tunnel.endpoint},machineId=${tunnel.machineId})`)
257
- }
258
- } catch (e) {
259
- console.error('[argent] 隧道启动失败(不影响其余功能):', e?.message || e)
260
- }
261
- }
262
274
  })()
263
275
  }