@auto-ai/agent 2.1.101 → 2.1.103

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/dist/ws-test.html +78 -27
  2. package/package.json +6 -6
package/dist/ws-test.html CHANGED
@@ -5000,6 +5000,43 @@
5000
5000
  return u.toString()
5001
5001
  }
5002
5002
 
5003
+ function buildSessionReplayUrl(sessionId) {
5004
+ const u = new URL('/api/sessions/replay', httpOriginForApi() + '/')
5005
+ u.searchParams.set('agent', currentAgentParam())
5006
+ u.searchParams.set('sessionId', sessionId)
5007
+ return u.toString()
5008
+ }
5009
+
5010
+ /**
5011
+ * 业务语义:历史 UI 回显走 HTTP 读 legacy jsonl 并转 v3,与 WS 实时事件解耦。
5012
+ */
5013
+ async function loadSessionReplayViaHttp(sessionId) {
5014
+ const sid = typeof sessionId === 'string' ? sessionId.trim() : ''
5015
+ if (!sid) return
5016
+ try {
5017
+ const r = await fetch(buildSessionReplayUrl(sid))
5018
+ const data = await r.json()
5019
+ if (!r.ok) {
5020
+ throw new Error(
5021
+ (data && data.message) || data.error || r.statusText || String(r.status),
5022
+ )
5023
+ }
5024
+ const envelopes = Array.isArray(data.envelopes) ? data.envelopes : []
5025
+ for (let i = 0; i < envelopes.length; i++) {
5026
+ applyWsEnvelopeV3(envelopes[i])
5027
+ }
5028
+ requestRenderChat()
5029
+ logLine('session-replay-http', {
5030
+ sessionId: sid,
5031
+ messageCount: data.messageCount,
5032
+ envelopeCount: envelopes.length,
5033
+ })
5034
+ } catch (e) {
5035
+ logLine('session-replay-http', String(e))
5036
+ setStatus('历史回放失败: ' + e, 'err')
5037
+ }
5038
+ }
5039
+
5003
5040
  function buildPendingPromptsUrl(sessionId) {
5004
5041
  const u = new URL('/api/sessions/pending-prompts', httpOriginForApi() + '/')
5005
5042
  u.searchParams.set('agent', currentAgentParam())
@@ -5363,27 +5400,27 @@
5363
5400
  }
5364
5401
 
5365
5402
  function buildRuntimeToolImportUrl() {
5366
- const u = new URL('/api/tools/runtime-import', httpOriginForApi() + '/')
5403
+ const u = new URL('/api/runtime/tools/import', httpOriginForApi() + '/')
5367
5404
  u.searchParams.set('agent', currentAgentParam())
5368
5405
  return u.toString()
5369
5406
  }
5370
5407
 
5371
5408
  function buildRuntimeToolExportUrl(fileName) {
5372
- const u = new URL('/api/tools/runtime-export', httpOriginForApi() + '/')
5409
+ const u = new URL('/api/runtime/tools/export', httpOriginForApi() + '/')
5373
5410
  u.searchParams.set('agent', currentAgentParam())
5374
5411
  u.searchParams.set('file', fileName)
5375
5412
  return u.toString()
5376
5413
  }
5377
5414
 
5378
5415
  function buildRuntimeToolDeleteUrl(fileName) {
5379
- const u = new URL('/api/tools/runtime-file', httpOriginForApi() + '/')
5416
+ const u = new URL('/api/runtime/tools/file', httpOriginForApi() + '/')
5380
5417
  u.searchParams.set('agent', currentAgentParam())
5381
5418
  u.searchParams.set('file', fileName)
5382
5419
  return u.toString()
5383
5420
  }
5384
5421
 
5385
5422
  function buildRuntimeMcpFilesUrl() {
5386
- const u = new URL('/api/mcp/runtime-files', httpOriginForApi() + '/')
5423
+ const u = new URL('/api/runtime/mcps/files', httpOriginForApi() + '/')
5387
5424
  u.searchParams.set('agent', currentAgentParam())
5388
5425
  return u.toString()
5389
5426
  }
@@ -5401,20 +5438,20 @@
5401
5438
  }
5402
5439
 
5403
5440
  function buildRuntimeMcpExportUrl(fileName) {
5404
- const u = new URL('/api/mcp/runtime-export', httpOriginForApi() + '/')
5441
+ const u = new URL('/api/runtime/mcps/export', httpOriginForApi() + '/')
5405
5442
  u.searchParams.set('agent', currentAgentParam())
5406
5443
  u.searchParams.set('file', fileName)
5407
5444
  return u.toString()
5408
5445
  }
5409
5446
 
5410
5447
  function buildRuntimeMcpImportUrl() {
5411
- const u = new URL('/api/mcp/runtime-import', httpOriginForApi() + '/')
5448
+ const u = new URL('/api/runtime/mcps/import', httpOriginForApi() + '/')
5412
5449
  u.searchParams.set('agent', currentAgentParam())
5413
5450
  return u.toString()
5414
5451
  }
5415
5452
 
5416
5453
  function buildRuntimeMcpDeleteUrl(fileName) {
5417
- const u = new URL('/api/mcp/runtime-file', httpOriginForApi() + '/')
5454
+ const u = new URL('/api/runtime/mcps/file', httpOriginForApi() + '/')
5418
5455
  u.searchParams.set('agent', currentAgentParam())
5419
5456
  u.searchParams.set('file', fileName)
5420
5457
  return u.toString()
@@ -5427,7 +5464,7 @@
5427
5464
  }
5428
5465
 
5429
5466
  function buildRuntimeSkillFilesUrl() {
5430
- const u = new URL('/api/skills/runtime-files', httpOriginForApi() + '/')
5467
+ const u = new URL('/api/runtime/skills/files', httpOriginForApi() + '/')
5431
5468
  u.searchParams.set('agent', currentAgentParam())
5432
5469
  return u.toString()
5433
5470
  }
@@ -5452,20 +5489,20 @@
5452
5489
  }
5453
5490
 
5454
5491
  function buildRuntimeSkillExportUrl(fileName) {
5455
- const u = new URL('/api/skills/runtime-export', httpOriginForApi() + '/')
5492
+ const u = new URL('/api/runtime/skills/export', httpOriginForApi() + '/')
5456
5493
  u.searchParams.set('agent', currentAgentParam())
5457
5494
  u.searchParams.set('file', fileName)
5458
5495
  return u.toString()
5459
5496
  }
5460
5497
 
5461
5498
  function buildRuntimeSkillImportUrl() {
5462
- const u = new URL('/api/skills/runtime-import', httpOriginForApi() + '/')
5499
+ const u = new URL('/api/runtime/skills/import', httpOriginForApi() + '/')
5463
5500
  u.searchParams.set('agent', currentAgentParam())
5464
5501
  return u.toString()
5465
5502
  }
5466
5503
 
5467
5504
  function buildRuntimeSkillDeleteUrl(fileName) {
5468
- const u = new URL('/api/skills/runtime-file', httpOriginForApi() + '/')
5505
+ const u = new URL('/api/runtime/skills/file', httpOriginForApi() + '/')
5469
5506
  u.searchParams.set('agent', currentAgentParam())
5470
5507
  u.searchParams.set('file', fileName)
5471
5508
  return u.toString()
@@ -5664,10 +5701,11 @@
5664
5701
  const frag = document.createDocumentFragment()
5665
5702
  for (let i = 0; i < items.length; i++) {
5666
5703
  const row = items[i]
5667
- if (!row || typeof row.id !== 'string') continue
5668
- const file = String(row.id).trim()
5704
+ if (!row || typeof row.packageId !== 'string') continue
5705
+ const file = String(row.packageId).trim()
5669
5706
  if (!file) continue
5670
- const hasJson = row.hasMcpJson === true
5707
+ const meta = row.meta && typeof row.meta === 'object' ? row.meta : {}
5708
+ const hasJson = meta.hasMcpJson === true
5671
5709
  const item = document.createElement('div')
5672
5710
  item.className = 'tool-files-item'
5673
5711
  const main = document.createElement('div')
@@ -5677,10 +5715,12 @@
5677
5715
  name.textContent = file
5678
5716
  const sub = document.createElement('div')
5679
5717
  sub.className = 'tool-files-sub'
5680
- const fc = Number(row.fileCount || 0)
5718
+ const fc = Number(meta.fileCount || 0)
5719
+ const serverNames = Array.isArray(meta.serverNames) ? meta.serverNames : []
5681
5720
  sub.textContent =
5682
5721
  'MCP 包目录' +
5683
- (hasJson ? ' · mcp.json' : ' · 缺少 mcp.json') +
5722
+ (serverNames.length ? ' · servers: ' + serverNames.join(', ') : '') +
5723
+ (hasJson ? ' · 含 .mcp.json' : ' · 缺少 .mcp.json') +
5684
5724
  ' · 可导出文件 ' +
5685
5725
  (Number.isFinite(fc) && fc > 0 ? fc : 0) +
5686
5726
  ' · zip 仅含编译产物(mcp.json / index.js)'
@@ -5751,8 +5791,8 @@
5751
5791
  throw new Error(x.body.message || x.body.error || x.r.statusText)
5752
5792
  }
5753
5793
  const dir =
5754
- x.body && typeof x.body.mcpRuntimeDir === 'string'
5755
- ? x.body.mcpRuntimeDir
5794
+ x.body && typeof x.body.runtimeDir === 'string'
5795
+ ? x.body.runtimeDir
5756
5796
  : '.ws-agents/mcps-runtime'
5757
5797
  const items = Array.isArray(x.body.items) ? x.body.items : []
5758
5798
  mcpPackageMeta.textContent = dir + ' · 共 ' + items.length + ' 个包'
@@ -5801,11 +5841,12 @@
5801
5841
  const frag = document.createDocumentFragment()
5802
5842
  for (let i = 0; i < items.length; i++) {
5803
5843
  const row = items[i]
5804
- if (!row || typeof row.id !== 'string') continue
5805
- const file = String(row.id).trim()
5844
+ if (!row || typeof row.packageId !== 'string') continue
5845
+ const file = String(row.packageId).trim()
5806
5846
  if (!file) continue
5807
- const fileCount = Number(row.fileCount || 0)
5808
- const skillCount = Number(row.skillCount || 0)
5847
+ const meta = row.meta && typeof row.meta === 'object' ? row.meta : {}
5848
+ const fileCount = Number(meta.fileCount || 0)
5849
+ const skillCount = Number(meta.skillCount || 0)
5809
5850
  const item = document.createElement('div')
5810
5851
  item.className = 'tool-files-item'
5811
5852
  const main = document.createElement('div')
@@ -5885,8 +5926,8 @@
5885
5926
  throw new Error(x.body.message || x.body.error || x.r.statusText)
5886
5927
  }
5887
5928
  const dir =
5888
- x.body && typeof x.body.skillsRuntimeDir === 'string'
5889
- ? x.body.skillsRuntimeDir
5929
+ x.body && typeof x.body.runtimeDir === 'string'
5930
+ ? x.body.runtimeDir
5890
5931
  : '.ws-agents/skills-runtime'
5891
5932
  const items = Array.isArray(x.body.items) ? x.body.items : []
5892
5933
  skillPackageMeta.textContent = dir + ' · 共 ' + items.length + ' 个包'
@@ -6231,6 +6272,9 @@
6231
6272
  if (socket && socket.readyState === WebSocket.OPEN) {
6232
6273
  serverReady = false
6233
6274
  resetChatUi()
6275
+ if (nextSid) {
6276
+ void loadSessionReplayViaHttp(nextSid)
6277
+ }
6234
6278
  pendingSessionOverrides = null
6235
6279
  if (nextSid) {
6236
6280
  /* 已在上方拉取 overrides;切换中勿清空 composer 模型 */
@@ -6297,6 +6341,13 @@
6297
6341
  }
6298
6342
  serverReady = false
6299
6343
  resetChatUi()
6344
+ const replaySid =
6345
+ sessionIdInput && typeof sessionIdInput.value === 'string'
6346
+ ? sessionIdInput.value.trim()
6347
+ : ''
6348
+ if (replaySid) {
6349
+ void loadSessionReplayViaHttp(replaySid)
6350
+ }
6300
6351
  const url = buildWsUrlWithQuery()
6301
6352
  logLine('connect', url)
6302
6353
  setStatus('正在连接…', '')
@@ -6349,9 +6400,9 @@
6349
6400
  })
6350
6401
  if (
6351
6402
  data.type === 'session.meta' &&
6352
- data.payload &&
6353
- typeof data.payload === 'object' &&
6354
- data.payload.sessionId
6403
+ data.data &&
6404
+ typeof data.data === 'object' &&
6405
+ data.data.sessionId
6355
6406
  ) {
6356
6407
  void loadSessions()
6357
6408
  if (pendingSessionOverrides) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auto-ai/agent",
3
- "version": "2.1.101",
3
+ "version": "2.1.103",
4
4
  "description": "Auto AI Agent 网关 CLI(WebSocket,独立二进制,无需 Bun)",
5
5
  "type": "module",
6
6
  "maintainers": [
@@ -27,11 +27,11 @@
27
27
  "node": ">=18"
28
28
  },
29
29
  "optionalDependencies": {
30
- "@auto-ai/agent-linux-x64": "2.1.101",
31
- "@auto-ai/agent-linux-arm64": "2.1.101",
32
- "@auto-ai/agent-darwin-x64": "2.1.101",
33
- "@auto-ai/agent-darwin-arm64": "2.1.101",
34
- "@auto-ai/agent-win-x64": "2.1.101"
30
+ "@auto-ai/agent-linux-x64": "2.1.103",
31
+ "@auto-ai/agent-linux-arm64": "2.1.103",
32
+ "@auto-ai/agent-darwin-x64": "2.1.103",
33
+ "@auto-ai/agent-darwin-arm64": "2.1.103",
34
+ "@auto-ai/agent-win-x64": "2.1.103"
35
35
  },
36
36
  "scripts": {
37
37
  "prepare": "node ../../scripts/sync-launcher-env.js",