myagent-ai 1.15.80 → 1.15.82
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 +2 -2
- package/start.js +8 -3
- package/web/ui/chat/flow_engine.js +36 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myagent-ai",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.82",
|
|
4
4
|
"description": "本地桌面端执行型AI助手 - Open Interpreter 风格 | Local Desktop Execution-Oriented AI Assistant",
|
|
5
5
|
"main": "main.py",
|
|
6
6
|
"bin": {
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
"departments/",
|
|
66
66
|
"web/"
|
|
67
67
|
]
|
|
68
|
-
}
|
|
68
|
+
}
|
package/start.js
CHANGED
|
@@ -432,14 +432,19 @@ function cmdUpdate(pkgDir) {
|
|
|
432
432
|
|
|
433
433
|
console.log("");
|
|
434
434
|
if (newVer) {
|
|
435
|
-
console.log(` [32m
|
|
435
|
+
console.log(` [32m✓[0m 已是最新版 v${newVer}`);
|
|
436
436
|
} else {
|
|
437
|
-
console.log(` [32m
|
|
437
|
+
console.log(` [32m✓[0m 更新完成`);
|
|
438
438
|
}
|
|
439
|
-
console.log(`
|
|
439
|
+
console.log(` 正在启动...`);
|
|
440
440
|
console.log("");
|
|
441
|
+
|
|
442
|
+
// 更新完成后自动启动 web 服务
|
|
443
|
+
cmdRun(newPkgDir, ["web"]);
|
|
441
444
|
}
|
|
442
445
|
|
|
446
|
+
|
|
447
|
+
|
|
443
448
|
function cmdUninstall() {
|
|
444
449
|
const venvDir = getVenvDir();
|
|
445
450
|
const dataDir = getDataDir();
|
|
@@ -1294,20 +1294,27 @@ async function sendMessage(opts) {
|
|
|
1294
1294
|
// Create session if needed (incorporate agent name)
|
|
1295
1295
|
let sessionId = state.activeSessionId;
|
|
1296
1296
|
if (!sessionId || sessionId === '__new__') {
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1297
|
+
// 防御:如果当前已有消息(说明有活跃会话但 ID 丢失),尝试复用已有会话
|
|
1298
|
+
if (state.messages.length > 0 && state.sessions && state.sessions.length > 0) {
|
|
1299
|
+
sessionId = state.sessions[0].id;
|
|
1300
|
+
state.activeSessionId = sessionId;
|
|
1301
|
+
console.warn('[sendMessage] activeSessionId was empty but messages exist, reusing session:', sessionId);
|
|
1302
|
+
} else {
|
|
1303
|
+
const ts = new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14);
|
|
1304
|
+
sessionId = `${state.activeAgent}_web_${ts}`;
|
|
1305
|
+
state.activeSessionId = sessionId;
|
|
1306
|
+
document.getElementById('headerTitle').textContent = formatSessionName(sessionId);
|
|
1307
|
+
// ── 立即在左侧边栏添加新会话条目(不等后端返回) ──
|
|
1308
|
+
state.sessions.unshift({
|
|
1309
|
+
id: sessionId,
|
|
1310
|
+
name: formatSessionName(sessionId),
|
|
1311
|
+
messages: 0,
|
|
1312
|
+
last: new Date().toISOString(),
|
|
1313
|
+
preview: '',
|
|
1314
|
+
});
|
|
1315
|
+
state.agentSessions[state.activeAgent] = [...state.sessions];
|
|
1316
|
+
renderSessions();
|
|
1317
|
+
}
|
|
1311
1318
|
// ── 更新 URL 参数,携带会话 ID(刷新页面可恢复) ──
|
|
1312
1319
|
try {
|
|
1313
1320
|
const url = new URL(window.location.href);
|
|
@@ -1849,7 +1856,21 @@ async function sendMessage(opts) {
|
|
|
1849
1856
|
state.sessions.splice(idx, 1);
|
|
1850
1857
|
state.sessions.unshift(existing);
|
|
1851
1858
|
} else {
|
|
1852
|
-
|
|
1859
|
+
// 防御:后端返回的 sessionIdReceived 和前端的不一致时,
|
|
1860
|
+
// 找到当前 activeSessionId 的条目,更新其 ID 而非创建新条目
|
|
1861
|
+
var localIdx = state.sessions.findIndex(s => s.id === state.activeSessionId);
|
|
1862
|
+
if (localIdx >= 0) {
|
|
1863
|
+
var localEntry = state.sessions[localIdx];
|
|
1864
|
+
localEntry.id = sessionIdReceived;
|
|
1865
|
+
localEntry.messages = (localEntry.messages || 0) + 2;
|
|
1866
|
+
localEntry.last = new Date().toISOString();
|
|
1867
|
+
state.activeSessionId = sessionIdReceived;
|
|
1868
|
+
state.sessions.splice(localIdx, 1);
|
|
1869
|
+
state.sessions.unshift(localEntry);
|
|
1870
|
+
console.warn('[sendMessage] Session ID mismatch, updated local entry:', sessionIdReceived);
|
|
1871
|
+
} else {
|
|
1872
|
+
state.sessions.unshift({ id: sessionIdReceived, name: formatSessionName(sessionIdReceived), messages: 2, last: new Date().toISOString() });
|
|
1873
|
+
}
|
|
1853
1874
|
}
|
|
1854
1875
|
state.agentSessions[state.activeAgent] = [...state.sessions];
|
|
1855
1876
|
renderSessions();
|