myagent-ai 1.32.8 → 1.32.9
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
CHANGED
package/web/api_server.py
CHANGED
|
@@ -3515,7 +3515,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
3515
3515
|
"""GET /api/agents - 返回扁平 agent 列表(系统 agent 排在最前)"""
|
|
3516
3516
|
await self._ensure_agents_initialized()
|
|
3517
3517
|
agents = self._scan_agents_flat()
|
|
3518
|
-
# 统计会话数
|
|
3518
|
+
# 统计会话数 + 附加数字 agent_id
|
|
3519
3519
|
if self.core.memory:
|
|
3520
3520
|
rows = self.core.memory._get_conn().execute(
|
|
3521
3521
|
"SELECT session_id, COUNT(*) as cnt FROM memories "
|
|
@@ -3527,6 +3527,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
3527
3527
|
session_counts[ap] = session_counts.get(ap, 0) + r["cnt"]
|
|
3528
3528
|
for a in agents:
|
|
3529
3529
|
a["session_count"] = session_counts.get(a["path"], 0)
|
|
3530
|
+
a["aid"] = self.core.memory.get_agent_id(a["path"])
|
|
3530
3531
|
# 系统 agent 排在最前
|
|
3531
3532
|
agents.sort(key=lambda a: (0 if a.get("system") else 1, a.get("path", "")))
|
|
3532
3533
|
return web.json_response(agents)
|
|
@@ -405,12 +405,19 @@ async function deleteAgentKB(path,filename){
|
|
|
405
405
|
|
|
406
406
|
async function loadAgentSessions(){
|
|
407
407
|
const path=window._currentEditAgentPath;if(!path)return;
|
|
408
|
+
// 查找该 agent 的数字 ID(aid)
|
|
409
|
+
var _editAgentAid = 1;
|
|
410
|
+
if (typeof allAgentsCache !== 'undefined' && Array.isArray(allAgentsCache)) {
|
|
411
|
+
for (var i = 0; i < allAgentsCache.length; i++) {
|
|
412
|
+
if (allAgentsCache[i].path === path) { _editAgentAid = allAgentsCache[i].aid || 1; break; }
|
|
413
|
+
}
|
|
414
|
+
}
|
|
408
415
|
const data=await api(`/api/agents/${encodeURIComponent(path)}/sessions`);
|
|
409
416
|
const sessions=Array.isArray(data)?data:(data?.sessions||[]);
|
|
410
417
|
let html=`<div class="flex justify-between items-center mb-16"><h4 style="font-size:14px;color:var(--text2)">会话 (${sessions.length})</h4></div>`;
|
|
411
418
|
if(sessions.length===0){html+='<div class="empty">暂无会话</div>';}
|
|
412
419
|
else{html+='<div class="table-wrap"><table><tr><th>会话</th><th>消息数</th><th>最后活动</th><th></th></tr>';
|
|
413
|
-
for(const s of sessions){const dn=s.display_name||s.id;html+=`<tr><td style="max-width:200px;overflow:hidden;text-overflow:ellipsis" title="${escHtml(s.id)}">${escHtml(dn.length>25?dn.slice(0,25)+'...':dn)}</td><td>${s.messages||0}</td><td>${fmtTimeAgo(s.last)}</td><td><button class="btn btn-sm" style="background:var(--success);color:#fff" onclick="enterSession('${escHtml(s.id)}'
|
|
420
|
+
for(const s of sessions){const dn=s.display_name||s.id;html+=`<tr><td style="max-width:200px;overflow:hidden;text-overflow:ellipsis" title="${escHtml(s.id)}">${escHtml(dn.length>25?dn.slice(0,25)+'...':dn)}</td><td>${s.messages||0}</td><td>${fmtTimeAgo(s.last)}</td><td><button class="btn btn-sm" style="background:var(--success);color:#fff" onclick="enterSession('${escHtml(s.id)}',${_editAgentAid})">切入</button> <button class="btn btn-sm btn-ghost" onclick="viewSessionMsgs('${escHtml(s.id)}')">查看</button></td></tr>`}
|
|
414
421
|
html+='</table></div>';}
|
|
415
422
|
$('sessionsContent').innerHTML=html;
|
|
416
423
|
}
|
|
@@ -11,18 +11,8 @@ async function renderSessions(){
|
|
|
11
11
|
}
|
|
12
12
|
let html='<div class="table-wrap"><table><tr><th>会话</th><th>Agent</th><th>消息数</th><th>最后活动</th><th>操作</th></tr>';
|
|
13
13
|
for(const s of (ss||[])){
|
|
14
|
-
//
|
|
14
|
+
// 使用后端返回的 agent_id(agent 名称)
|
|
15
15
|
let agentName=s.agent_id||'';
|
|
16
|
-
if(!agentName){
|
|
17
|
-
// 回退:从 session_id 前缀提取(兼容旧格式)
|
|
18
|
-
if((s.id||'').indexOf('_web_')>=0){
|
|
19
|
-
agentName=(s.id||'').split('_web_')[0]||'default';
|
|
20
|
-
}else if((s.id||'').indexOf('_cli_')>=0){
|
|
21
|
-
agentName=(s.id||'').split('_cli_')[0]||'default';
|
|
22
|
-
}else{
|
|
23
|
-
agentName='default';
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
16
|
const displayName=s.display_name||s.id;
|
|
27
17
|
const dbId=s.agent_db_id||1;
|
|
28
18
|
html+=`<tr><td title="${escHtml(s.id)}">${escHtml(displayName.length>30?displayName.slice(0,30)+'...':displayName)}</td><td>${escHtml(agentName)}</td><td>${s.messages}</td><td>${s.last?.slice(0,19)||''}</td>
|
package/web/ui/chat/chat_main.js
CHANGED
|
@@ -2815,13 +2815,9 @@ function newChat() {
|
|
|
2815
2815
|
state.activeSessionId = '__new__';
|
|
2816
2816
|
state._selectedSessionLabel = null; // [v1.18.9] 清除选中的会话名称
|
|
2817
2817
|
// ── 更新 URL(新对话移除 session 参数) ──
|
|
2818
|
-
// [v1.27.2] 使用 aid 代替 a
|
|
2819
2818
|
try {
|
|
2820
2819
|
const url = new URL(window.location.href);
|
|
2821
2820
|
url.searchParams.delete('s');
|
|
2822
|
-
url.searchParams.delete('session');
|
|
2823
|
-
url.searchParams.delete('a');
|
|
2824
|
-
url.searchParams.delete('agent');
|
|
2825
2821
|
var _ncAgentObj = findAgentByPath(state.activeAgent);
|
|
2826
2822
|
if (_ncAgentObj && _ncAgentObj.aid) {
|
|
2827
2823
|
url.searchParams.set('aid', _ncAgentObj.aid);
|
|
@@ -1648,10 +1648,6 @@ async function sendMessage(opts) {
|
|
|
1648
1648
|
try {
|
|
1649
1649
|
const url = new URL(window.location.href);
|
|
1650
1650
|
url.searchParams.set('s', UrlCodec.encode(sessionId));
|
|
1651
|
-
// [v1.27.2] 使用 aid 代替 a
|
|
1652
|
-
url.searchParams.delete('a');
|
|
1653
|
-
url.searchParams.delete('agent');
|
|
1654
|
-
url.searchParams.delete('session');
|
|
1655
1651
|
var _feAgentObj = (typeof findAgentByPath === 'function') ? findAgentByPath(state.activeAgent) : null;
|
|
1656
1652
|
if (_feAgentObj && _feAgentObj.aid) url.searchParams.set('aid', _feAgentObj.aid);
|
|
1657
1653
|
window.history.replaceState({}, '', url.toString());
|
|
@@ -2879,10 +2875,6 @@ const StreamingRecovery = {
|
|
|
2879
2875
|
try {
|
|
2880
2876
|
const url = new URL(window.location.href);
|
|
2881
2877
|
url.searchParams.set('s', UrlCodec.encode(sessionId));
|
|
2882
|
-
// [v1.27.2] 使用 aid 代替 a
|
|
2883
|
-
url.searchParams.delete('a');
|
|
2884
|
-
url.searchParams.delete('agent');
|
|
2885
|
-
url.searchParams.delete('session');
|
|
2886
2878
|
var _rvAgentObj = (typeof findAgentByPath === 'function') ? findAgentByPath(state.activeAgent) : null;
|
|
2887
2879
|
if (_rvAgentObj && _rvAgentObj.aid) url.searchParams.set('aid', _rvAgentObj.aid);
|
|
2888
2880
|
window.history.replaceState({}, '', url.toString());
|