@auto-ai/agent 2.1.95 → 2.1.96
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/agent-office.html +40 -35
- package/dist/ws-test.html +369 -108
- package/mcps-runtime/claude-tuitui/.mcp.json +18 -0
- package/mcps-runtime/claude-tuitui/cli.mjs +78 -0
- package/mcps-runtime/claude-tuitui/package-lock.json +1167 -0
- package/mcps-runtime/claude-tuitui/server/boot.mjs +25 -0
- package/mcps-runtime/claude-tuitui/server/index.mjs +935 -0
- package/mcps-runtime/claude-tuitui/server/state.mjs +229 -0
- package/mcps-runtime/claude-tuitui/server/tuitui-api.mjs +358 -0
- package/package.json +7 -6
package/dist/agent-office.html
CHANGED
|
@@ -306,9 +306,6 @@
|
|
|
306
306
|
;(function () {
|
|
307
307
|
'use strict'
|
|
308
308
|
|
|
309
|
-
/** 列表/写操作 API 上下文:固定使用已存在的默认 agent */
|
|
310
|
-
const DEFAULT_CONTEXT_AGENT = 'qihoo'
|
|
311
|
-
|
|
312
309
|
/** 解析 API 基址:支持 ?apiBase= 或当前页面 origin(与 ws-test 一致) */
|
|
313
310
|
function httpOriginForApi() {
|
|
314
311
|
try {
|
|
@@ -322,21 +319,17 @@
|
|
|
322
319
|
return window.location.origin
|
|
323
320
|
}
|
|
324
321
|
|
|
325
|
-
/** 构建 GET/POST /api/agents
|
|
326
|
-
function buildAgentsListUrl(
|
|
327
|
-
|
|
328
|
-
u.searchParams.set('agent', contextAgent || DEFAULT_CONTEXT_AGENT)
|
|
329
|
-
return u.toString()
|
|
322
|
+
/** 构建 GET/POST /api/agents 列表地址(无需 agent 查询参数) */
|
|
323
|
+
function buildAgentsListUrl() {
|
|
324
|
+
return new URL('/api/agents', httpOriginForApi() + '/').toString()
|
|
330
325
|
}
|
|
331
326
|
|
|
332
|
-
/** 构建单个 agent 的 REST
|
|
333
|
-
function buildAgentItemUrl(id
|
|
334
|
-
|
|
327
|
+
/** 构建单个 agent 的 REST 地址(由 path 的 id 唯一标识目标) */
|
|
328
|
+
function buildAgentItemUrl(id) {
|
|
329
|
+
return new URL(
|
|
335
330
|
'/api/agents/' + encodeURIComponent(String(id || '').trim()),
|
|
336
331
|
httpOriginForApi() + '/',
|
|
337
|
-
)
|
|
338
|
-
u.searchParams.set('agent', contextAgent || DEFAULT_CONTEXT_AGENT)
|
|
339
|
-
return u.toString()
|
|
332
|
+
).toString()
|
|
340
333
|
}
|
|
341
334
|
|
|
342
335
|
/** 校验新建 agent id:字母数字下划线中划线,1~64 */
|
|
@@ -372,8 +365,8 @@
|
|
|
372
365
|
}
|
|
373
366
|
|
|
374
367
|
/** 拉取 agent 列表 */
|
|
375
|
-
async function fetchAgentsList(
|
|
376
|
-
const r = await fetch(buildAgentsListUrl(
|
|
368
|
+
async function fetchAgentsList() {
|
|
369
|
+
const r = await fetch(buildAgentsListUrl())
|
|
377
370
|
const body = await r.json().catch(() => ({}))
|
|
378
371
|
if (!r.ok) {
|
|
379
372
|
throw new Error(body.message || body.error || r.statusText)
|
|
@@ -382,8 +375,8 @@
|
|
|
382
375
|
}
|
|
383
376
|
|
|
384
377
|
/** 拉取单个 agent 详情(含 config、prompt) */
|
|
385
|
-
async function fetchAgentDetail(id
|
|
386
|
-
const r = await fetch(buildAgentItemUrl(id
|
|
378
|
+
async function fetchAgentDetail(id) {
|
|
379
|
+
const r = await fetch(buildAgentItemUrl(id))
|
|
387
380
|
const body = await r.json().catch(() => ({}))
|
|
388
381
|
if (!r.ok) {
|
|
389
382
|
throw new Error(body.message || body.error || r.statusText)
|
|
@@ -391,17 +384,29 @@
|
|
|
391
384
|
return body.agent || { id }
|
|
392
385
|
}
|
|
393
386
|
|
|
394
|
-
/** 删除 agent
|
|
395
|
-
async function deleteAgent(id
|
|
387
|
+
/** 删除 agent */
|
|
388
|
+
async function deleteAgent(id) {
|
|
396
389
|
const agentId = String(id || '').trim()
|
|
397
390
|
if (!agentId) throw new Error('缺少 agent id')
|
|
398
|
-
|
|
399
|
-
|
|
391
|
+
const tryDelete = async (withAgentQuery) => {
|
|
392
|
+
const u = new URL(buildAgentItemUrl(agentId))
|
|
393
|
+
if (withAgentQuery) {
|
|
394
|
+
u.searchParams.set('agent', agentId)
|
|
395
|
+
}
|
|
396
|
+
const r = await fetch(u.toString(), { method: 'DELETE' })
|
|
397
|
+
const body = await r.json().catch(() => ({}))
|
|
398
|
+
return { r, body }
|
|
400
399
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
400
|
+
let ret = await tryDelete(false)
|
|
401
|
+
if (!ret.r.ok) {
|
|
402
|
+
const msg = String(ret.body && (ret.body.message || ret.body.error || ''))
|
|
403
|
+
// 兼容仍要求 ?agent 的旧服务端;新服务端不会走该分支。
|
|
404
|
+
if (ret.r.status === 400 && msg.includes('missing required query parameter: agent')) {
|
|
405
|
+
ret = await tryDelete(true)
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (!ret.r.ok) {
|
|
409
|
+
throw new Error(ret.body.message || ret.body.error || ret.r.statusText)
|
|
405
410
|
}
|
|
406
411
|
}
|
|
407
412
|
|
|
@@ -411,7 +416,7 @@
|
|
|
411
416
|
async function saveAgent(params) {
|
|
412
417
|
const { id, whentouse, prompt, isEdit, baseConfig, contextAgent } = params
|
|
413
418
|
if (isEdit) {
|
|
414
|
-
const patchRes = await fetch(buildAgentItemUrl(id
|
|
419
|
+
const patchRes = await fetch(buildAgentItemUrl(id), {
|
|
415
420
|
method: 'PATCH',
|
|
416
421
|
headers: { 'content-type': 'application/json; charset=utf-8' },
|
|
417
422
|
body: JSON.stringify({
|
|
@@ -426,7 +431,7 @@
|
|
|
426
431
|
return id
|
|
427
432
|
}
|
|
428
433
|
|
|
429
|
-
const createRes = await fetch(buildAgentsListUrl(
|
|
434
|
+
const createRes = await fetch(buildAgentsListUrl(), {
|
|
430
435
|
method: 'POST',
|
|
431
436
|
headers: { 'content-type': 'application/json; charset=utf-8' },
|
|
432
437
|
body: JSON.stringify({ name: id, prompt }),
|
|
@@ -436,10 +441,10 @@
|
|
|
436
441
|
throw new Error(createBody.message || createBody.error || createRes.statusText)
|
|
437
442
|
}
|
|
438
443
|
|
|
439
|
-
const cfgBody = await fetchAgentDetail(id
|
|
444
|
+
const cfgBody = await fetchAgentDetail(id)
|
|
440
445
|
const baseCfg =
|
|
441
446
|
cfgBody.config && typeof cfgBody.config === 'object' ? cfgBody.config : null
|
|
442
|
-
const patchRes = await fetch(buildAgentItemUrl(id
|
|
447
|
+
const patchRes = await fetch(buildAgentItemUrl(id), {
|
|
443
448
|
method: 'PATCH',
|
|
444
449
|
headers: { 'content-type': 'application/json; charset=utf-8' },
|
|
445
450
|
body: JSON.stringify({
|
|
@@ -580,7 +585,7 @@
|
|
|
580
585
|
this.controller = controller
|
|
581
586
|
this.list = list
|
|
582
587
|
this.hooks = hooks || {}
|
|
583
|
-
this.contextAgent =
|
|
588
|
+
this.contextAgent = ''
|
|
584
589
|
this.agents = []
|
|
585
590
|
this.editingId = null
|
|
586
591
|
this.baseConfig = null
|
|
@@ -687,7 +692,7 @@
|
|
|
687
692
|
if (this.panelTitleEl) this.panelTitleEl.textContent = 'Agent · ' + agentId
|
|
688
693
|
if (this.panelMetaEl) this.panelMetaEl.textContent = '加载中…'
|
|
689
694
|
if (this.btnDelete) {
|
|
690
|
-
this.btnDelete.disabled =
|
|
695
|
+
this.btnDelete.disabled = false
|
|
691
696
|
}
|
|
692
697
|
if (this.btnWorkbench) this.btnWorkbench.disabled = false
|
|
693
698
|
try {
|
|
@@ -762,7 +767,7 @@
|
|
|
762
767
|
this.idInput.readOnly = true
|
|
763
768
|
}
|
|
764
769
|
if (this.btnDelete) {
|
|
765
|
-
this.btnDelete.disabled =
|
|
770
|
+
this.btnDelete.disabled = false
|
|
766
771
|
}
|
|
767
772
|
if (this.btnWorkbench) this.btnWorkbench.disabled = false
|
|
768
773
|
if (this.panelTitleEl) this.panelTitleEl.textContent = 'Agent · ' + id
|
|
@@ -776,12 +781,12 @@
|
|
|
776
781
|
|
|
777
782
|
async handleDelete() {
|
|
778
783
|
const id = this.editingId
|
|
779
|
-
if (!id
|
|
784
|
+
if (!id) return
|
|
780
785
|
if (!window.confirm('确定删除 Agent「' + id + '」?此操作不可恢复。')) {
|
|
781
786
|
return
|
|
782
787
|
}
|
|
783
788
|
try {
|
|
784
|
-
await deleteAgent(id
|
|
789
|
+
await deleteAgent(id)
|
|
785
790
|
await this.refreshAgents()
|
|
786
791
|
this.hidePanel()
|
|
787
792
|
this.clearUrlAgentParam()
|