myagent-ai 1.27.0 → 1.27.1
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 +1 -1
- package/web/api_server.py +11 -5
- package/web/ui/admin/admin-sessions.js +13 -15
- package/web/ui/chat/chat_main.js +27 -5
- package/worklog.md +0 -23
- package/.phoneide_tmp.py +0 -8
package/package.json
CHANGED
package/web/api_server.py
CHANGED
|
@@ -4305,7 +4305,8 @@ window.addEventListener('beforeunload', function() {{
|
|
|
4305
4305
|
if agent == "default":
|
|
4306
4306
|
# default agent: agent_id='' 或 agent_id='default' 或 旧格式 web_default/sess_*
|
|
4307
4307
|
rows = self.core.memory._get_conn().execute(
|
|
4308
|
-
"""SELECT DISTINCT session_id, COUNT(*) as cnt, MAX(created_at) as last
|
|
4308
|
+
"""SELECT DISTINCT session_id, COUNT(*) as cnt, MAX(created_at) as last,
|
|
4309
|
+
MAX(CASE WHEN agent_id != '' AND agent_id != 'default' THEN agent_id ELSE NULL END) as agent_id FROM memories
|
|
4309
4310
|
WHERE category = 'session' AND role != ''
|
|
4310
4311
|
AND key NOT IN ('llm_output', 'llm_input', 'tool_result_raw', 'conversation_insight')
|
|
4311
4312
|
AND (agent_id = '' OR agent_id = 'default' OR session_id = 'web_default' OR session_id LIKE 'sess_%')
|
|
@@ -4313,19 +4314,24 @@ window.addEventListener('beforeunload', function() {{
|
|
|
4313
4314
|
else:
|
|
4314
4315
|
# 其他 agent: agent_id=agent 或 session_id 前缀匹配(旧数据)
|
|
4315
4316
|
rows = self.core.memory._get_conn().execute(
|
|
4316
|
-
"""SELECT DISTINCT session_id, COUNT(*) as cnt, MAX(created_at) as last
|
|
4317
|
+
"""SELECT DISTINCT session_id, COUNT(*) as cnt, MAX(created_at) as last,
|
|
4318
|
+
MAX(CASE WHEN agent_id != '' AND agent_id != ? THEN agent_id ELSE NULL END) as agent_id FROM memories
|
|
4317
4319
|
WHERE category = 'session' AND role != ''
|
|
4318
4320
|
AND key NOT IN ('llm_output', 'llm_input', 'tool_result_raw', 'conversation_insight')
|
|
4319
4321
|
AND (agent_id = ? OR session_id LIKE ?)
|
|
4320
4322
|
GROUP BY session_id ORDER BY last DESC LIMIT 100""",
|
|
4321
|
-
(agent, f"{agent}_%")).fetchall()
|
|
4323
|
+
(agent, agent, f"{agent}_%")).fetchall()
|
|
4322
4324
|
else:
|
|
4325
|
+
# [v1.25.7] 无 agent 过滤时也返回 agent_id,供后台管理页面使用
|
|
4323
4326
|
rows = self.core.memory._get_conn().execute(
|
|
4324
|
-
"SELECT DISTINCT session_id, COUNT(*) as cnt, MAX(created_at) as last
|
|
4327
|
+
"SELECT DISTINCT session_id, COUNT(*) as cnt, MAX(created_at) as last, "
|
|
4328
|
+
"MAX(CASE WHEN agent_id != '' THEN agent_id ELSE NULL END) as agent_id FROM memories "
|
|
4325
4329
|
"WHERE category = 'session' AND role != '' "
|
|
4326
4330
|
"AND key NOT IN ('llm_output', 'llm_input', 'tool_result_raw', 'conversation_insight') "
|
|
4327
4331
|
"GROUP BY session_id ORDER BY last DESC LIMIT 100").fetchall()
|
|
4328
|
-
sessions = [{"id": r["session_id"], "messages": r["cnt"], "last": r["last"]
|
|
4332
|
+
sessions = [{"id": r["session_id"], "messages": r["cnt"], "last": r["last"],
|
|
4333
|
+
"agent_id": (r["agent_id"] or ""),
|
|
4334
|
+
"display_name": "", "preview": ""} for r in rows]
|
|
4329
4335
|
# 批量获取自定义会话名称
|
|
4330
4336
|
sids = [s["id"] for s in sessions]
|
|
4331
4337
|
name_map = self.core.memory.list_session_names(sids) if sids else {}
|
|
@@ -7,25 +7,23 @@ async function renderSessions(){
|
|
|
7
7
|
}
|
|
8
8
|
let html='<div class="table-wrap"><table><tr><th>会话</th><th>Agent</th><th>消息数</th><th>最后活动</th><th>操作</th></tr>';
|
|
9
9
|
for(const s of (ss||[])){
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}else{
|
|
22
|
-
agentName='default';
|
|
10
|
+
// [v1.25.7] 优先使用后端返回的 agent_id,不再从 session_id 猜测
|
|
11
|
+
let agentName=s.agent_id||'';
|
|
12
|
+
if(!agentName){
|
|
13
|
+
// 回退:从 session_id 前缀提取(兼容旧格式)
|
|
14
|
+
if((s.id||'').indexOf('_web_')>=0){
|
|
15
|
+
agentName=(s.id||'').split('_web_')[0]||'default';
|
|
16
|
+
}else if((s.id||'').indexOf('_cli_')>=0){
|
|
17
|
+
agentName=(s.id||'').split('_cli_')[0]||'default';
|
|
18
|
+
}else{
|
|
19
|
+
agentName='default';
|
|
20
|
+
}
|
|
23
21
|
}
|
|
24
22
|
const displayName=s.display_name||s.id;
|
|
25
23
|
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>
|
|
26
24
|
<td><button class="btn btn-sm" style="background:var(--success);color:#fff" onclick="enterSession('${escHtml(s.id)}','${escHtml(agentName)}')">切入</button>
|
|
27
|
-
<button class="btn btn-sm btn-ghost" onclick="viewSession('${s.id}')">查看</button>
|
|
28
|
-
<button class="btn btn-sm btn-danger" onclick="clearSession('${s.id}')">清除</button></td></tr>`;}
|
|
25
|
+
<button class="btn btn-sm btn-ghost" onclick="viewSession('${escHtml(s.id)}')">查看</button>
|
|
26
|
+
<button class="btn btn-sm btn-danger" onclick="clearSession('${escHtml(s.id)}')">清除</button></td></tr>`;}
|
|
29
27
|
html+='</table></div>';
|
|
30
28
|
$('content').innerHTML=html;
|
|
31
29
|
}
|
package/web/ui/chat/chat_main.js
CHANGED
|
@@ -2181,8 +2181,8 @@ async function selectAgent(agentPath) {
|
|
|
2181
2181
|
try { state.abortController.abort(); } catch (_) {}
|
|
2182
2182
|
state.abortController = null;
|
|
2183
2183
|
}
|
|
2184
|
-
hideTypingIndicator();
|
|
2185
|
-
stopExecTimerPolling();
|
|
2184
|
+
if (typeof hideTypingIndicator === 'function') hideTypingIndicator();
|
|
2185
|
+
if (typeof stopExecTimerPolling === 'function') stopExecTimerPolling();
|
|
2186
2186
|
// 立即清空聊天区域DOM,防止切换agent时旧消息残留
|
|
2187
2187
|
var _mi = document.getElementById('messagesInner');
|
|
2188
2188
|
if (_mi) _mi.innerHTML = '';
|
|
@@ -2899,6 +2899,27 @@ state._msgLoadOffset = 0;
|
|
|
2899
2899
|
state._msgLoadTotal = 0;
|
|
2900
2900
|
|
|
2901
2901
|
async function selectSession(id) {
|
|
2902
|
+
// [v1.25.6] 确保从群聊视图切回个人聊天视图(与 selectAgent/exitGroupChat 保持一致)
|
|
2903
|
+
if (currentView === 'group') {
|
|
2904
|
+
currentView = 'chat';
|
|
2905
|
+
currentGroupId = null;
|
|
2906
|
+
groupMessages = [];
|
|
2907
|
+
// 恢复头部 UI
|
|
2908
|
+
var _gbb = document.getElementById('groupBackBtn'); if (_gbb) _gbb.style.display = 'none';
|
|
2909
|
+
var _gsb = document.getElementById('groupSettingsBtn'); if (_gsb) _gsb.style.display = 'none';
|
|
2910
|
+
var _ccb2 = document.getElementById('clearChatBtn'); if (_ccb2) _ccb2.style.display = '';
|
|
2911
|
+
var _dot = document.querySelector('.main-title .dot');
|
|
2912
|
+
if (_dot) _dot.style.display = '';
|
|
2913
|
+
document.getElementById('userInput').placeholder = '输入消息... (Enter 发送, Shift+Enter 换行)';
|
|
2914
|
+
// 恢复侧边栏 UI
|
|
2915
|
+
var _newChatBtn2 = document.querySelector('.new-chat-btn');
|
|
2916
|
+
if (_newChatBtn2) _newChatBtn2.style.display = '';
|
|
2917
|
+
var _searchInput2 = document.getElementById('searchInput');
|
|
2918
|
+
if (_searchInput2) { _searchInput2.placeholder = '搜索对话...'; }
|
|
2919
|
+
StatePersistence.remove('currentView');
|
|
2920
|
+
StatePersistence.remove('currentGroupId');
|
|
2921
|
+
}
|
|
2922
|
+
|
|
2902
2923
|
if (id === '__new__') {
|
|
2903
2924
|
newChat();
|
|
2904
2925
|
if (isMobile()) closeMobileSidebar();
|
|
@@ -2915,8 +2936,8 @@ async function selectSession(id) {
|
|
|
2915
2936
|
try { state.abortController.abort(); } catch (_) {}
|
|
2916
2937
|
state.abortController = null;
|
|
2917
2938
|
}
|
|
2918
|
-
hideTypingIndicator();
|
|
2919
|
-
stopExecTimerPolling();
|
|
2939
|
+
if (typeof hideTypingIndicator === 'function') hideTypingIndicator();
|
|
2940
|
+
if (typeof stopExecTimerPolling === 'function') stopExecTimerPolling();
|
|
2920
2941
|
document.getElementById('sendBtn').style.display = '';
|
|
2921
2942
|
document.getElementById('sendBtn').disabled = true;
|
|
2922
2943
|
document.getElementById('stopBtn').style.display = 'none';
|
|
@@ -3783,7 +3804,8 @@ function renderMessages() {
|
|
|
3783
3804
|
}
|
|
3784
3805
|
|
|
3785
3806
|
function _renderMessagesInner() {
|
|
3786
|
-
|
|
3807
|
+
// [v1.25.6] 与 renderSessions 保持一致:同时检查 groups.length > 0
|
|
3808
|
+
if (currentView === 'group' && typeof groups !== 'undefined' && groups.length > 0) {
|
|
3787
3809
|
renderGroupMessages();
|
|
3788
3810
|
return;
|
|
3789
3811
|
}
|
package/worklog.md
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
Task ID: [20260420-05]
|
|
3
|
-
Agent: Main Agent
|
|
4
|
-
Task: 发布 v1.27.0 到 GitHub 和 npm(完成)
|
|
5
|
-
|
|
6
|
-
Work Log:
|
|
7
|
-
- 升级版本号:v1.26.0 → v1.27.0(重大架构升级)
|
|
8
|
-
- Git 推送:推送至 GitHub origin/main
|
|
9
|
-
- npm 发布:发布 myagent-ai@1.27.0 到 npmjs.com
|
|
10
|
-
- 同步更新:package.json、worklog.md、core/version.py
|
|
11
|
-
|
|
12
|
-
版本说明:
|
|
13
|
-
- 数字 agent_id 系统(agents 表 + agent_id INTEGER)
|
|
14
|
-
- session_id 完全独立(不再包含 agent 前缀)
|
|
15
|
-
- goodbye CLI 工具(清空数据 + 卸载项目)
|
|
16
|
-
- 移除所有迁移逻辑,使用全新数据库结构
|
|
17
|
-
|
|
18
|
-
Stage Summary:
|
|
19
|
-
- ✅ GitHub: https://github.com/ctz168/myagent
|
|
20
|
-
- ✅ npm: https://www.npmjs.com/package/myagent-ai
|
|
21
|
-
- ✅ 版本:v1.27.0
|
|
22
|
-
- ✅ 所有功能测试通过
|
|
23
|
-
|
|
24
1
|
---
|
|
25
2
|
Task ID: [20260420-04]
|
|
26
3
|
Agent: Main Agent
|
package/.phoneide_tmp.py
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import subprocess, sys
|
|
2
|
-
proc = subprocess.Popen([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1)
|
|
3
|
-
for line in proc.stdout:
|
|
4
|
-
print(line, end='')
|
|
5
|
-
sys.stdout.flush()
|
|
6
|
-
proc.wait()
|
|
7
|
-
if proc.returncode != 0:
|
|
8
|
-
print(f'\nExit code: {proc.returncode}')
|