myagent-ai 1.23.13 → 1.23.15
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/agents/main_agent.py +16 -0
- package/package.json +1 -1
- package/skills/docx_skill.py +7 -1
- package/skills/pdf_skill.py +7 -1
- package/skills/ppt_skill.py +7 -1
- package/skills/xlsx_skill.py +5 -9
- package/start.js +6 -1
- package/web/ui/chat/chat_main.js +4 -2
- package/web/ui/chat/flow_engine.js +1 -1
package/agents/main_agent.py
CHANGED
|
@@ -1592,6 +1592,22 @@ class MainAgent(BaseAgent):
|
|
|
1592
1592
|
content=_fallback_text,
|
|
1593
1593
|
)
|
|
1594
1594
|
|
|
1595
|
+
# [v1.23.13] 持久化已发送文件到会话记忆,刷新后可恢复文件卡片
|
|
1596
|
+
if _sent_files and self.memory:
|
|
1597
|
+
import json as _json_files
|
|
1598
|
+
try:
|
|
1599
|
+
self.memory.add_session(
|
|
1600
|
+
session_id=context.session_id,
|
|
1601
|
+
role="assistant",
|
|
1602
|
+
content="", # 空内容,仅用于承载文件元数据
|
|
1603
|
+
key="file_send",
|
|
1604
|
+
importance=0.2,
|
|
1605
|
+
metadata={"files": _sent_files},
|
|
1606
|
+
)
|
|
1607
|
+
logger.info(f"[{task_id}] 已持久化 {len(_sent_files)} 个文件到会话记忆")
|
|
1608
|
+
except Exception as _fe:
|
|
1609
|
+
logger.warning(f"[{task_id}] 持久化文件信息失败: {_fe}")
|
|
1610
|
+
|
|
1595
1611
|
context.working_memory["iterations"] = self._iteration_count
|
|
1596
1612
|
if current_task_plan:
|
|
1597
1613
|
context.working_memory["task_plan"] = current_task_plan
|
package/package.json
CHANGED
package/skills/docx_skill.py
CHANGED
|
@@ -8,6 +8,7 @@ from __future__ import annotations
|
|
|
8
8
|
|
|
9
9
|
import json
|
|
10
10
|
import os
|
|
11
|
+
import time
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
from typing import Any, Dict, List, Optional
|
|
13
14
|
|
|
@@ -61,7 +62,12 @@ class DOCXCreateSkill(Skill):
|
|
|
61
62
|
return SkillResult(success=False, error=f"content JSON 解析失败: {e}")
|
|
62
63
|
|
|
63
64
|
try:
|
|
64
|
-
|
|
65
|
+
if not output_path.strip():
|
|
66
|
+
default_dir = Path.home() / ".myagent" / "data" / "workspace" / "userfiles"
|
|
67
|
+
default_dir.mkdir(parents=True, exist_ok=True)
|
|
68
|
+
out = default_dir / f"doc_{int(time.time())}.docx"
|
|
69
|
+
else:
|
|
70
|
+
out = Path(output_path).expanduser().resolve()
|
|
65
71
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
66
72
|
|
|
67
73
|
doc = Document()
|
package/skills/pdf_skill.py
CHANGED
|
@@ -9,6 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
import json
|
|
10
10
|
import os
|
|
11
11
|
import textwrap
|
|
12
|
+
import time
|
|
12
13
|
from pathlib import Path
|
|
13
14
|
from typing import Any, Dict, List, Optional
|
|
14
15
|
|
|
@@ -115,7 +116,12 @@ class PDFCreateSkill(Skill):
|
|
|
115
116
|
|
|
116
117
|
try:
|
|
117
118
|
# 输出路径
|
|
118
|
-
|
|
119
|
+
if not output_path.strip():
|
|
120
|
+
default_dir = Path.home() / ".myagent" / "data" / "workspace" / "userfiles"
|
|
121
|
+
default_dir.mkdir(parents=True, exist_ok=True)
|
|
122
|
+
out = default_dir / f"doc_{int(time.time())}.pdf"
|
|
123
|
+
else:
|
|
124
|
+
out = Path(output_path).expanduser().resolve()
|
|
119
125
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
120
126
|
|
|
121
127
|
# 配色
|
package/skills/ppt_skill.py
CHANGED
|
@@ -8,6 +8,7 @@ from __future__ import annotations
|
|
|
8
8
|
|
|
9
9
|
import json
|
|
10
10
|
import os
|
|
11
|
+
import time
|
|
11
12
|
from pathlib import Path
|
|
12
13
|
from typing import Any, Dict, List, Optional
|
|
13
14
|
|
|
@@ -87,7 +88,12 @@ class PPTCreateSkill(Skill):
|
|
|
87
88
|
return SkillResult(success=False, error=f"slides JSON 解析失败: {e}")
|
|
88
89
|
|
|
89
90
|
try:
|
|
90
|
-
|
|
91
|
+
if not output_path.strip():
|
|
92
|
+
default_dir = Path.home() / ".myagent" / "data" / "workspace" / "userfiles"
|
|
93
|
+
default_dir.mkdir(parents=True, exist_ok=True)
|
|
94
|
+
out = default_dir / f"ppt_{int(time.time())}.pptx"
|
|
95
|
+
else:
|
|
96
|
+
out = Path(output_path).expanduser().resolve()
|
|
91
97
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
92
98
|
|
|
93
99
|
t = THEMES.get(theme, THEMES["professional"])
|
package/skills/xlsx_skill.py
CHANGED
|
@@ -99,16 +99,12 @@ class XLSXCreateSkill(Skill):
|
|
|
99
99
|
return SkillResult(success=False, error=f"sheets JSON 解析失败: {e}")
|
|
100
100
|
|
|
101
101
|
try:
|
|
102
|
-
out = Path(output_path).expanduser().resolve()
|
|
103
102
|
if not output_path.strip():
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
except Exception:
|
|
110
|
-
work_dir = Path.cwd()
|
|
111
|
-
out = work_dir / f"report_{int(time.time())}.xlsx"
|
|
103
|
+
default_dir = Path.home() / ".myagent" / "data" / "workspace" / "userfiles"
|
|
104
|
+
default_dir.mkdir(parents=True, exist_ok=True)
|
|
105
|
+
out = default_dir / f"report_{int(time.time())}.xlsx"
|
|
106
|
+
else:
|
|
107
|
+
out = Path(output_path).expanduser().resolve()
|
|
112
108
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
113
109
|
|
|
114
110
|
wb = openpyxl.Workbook()
|
package/start.js
CHANGED
|
@@ -821,9 +821,14 @@ function main() {
|
|
|
821
821
|
}
|
|
822
822
|
env = process.env;
|
|
823
823
|
}
|
|
824
|
+
// [v1.23.14] CLI cwd 使用 workspace 目录而非 pkgDir,
|
|
825
|
+
// 避免 Path("").resolve() 指向 npm 安装目录导致 "Is a directory" 错误。
|
|
826
|
+
// cli.py 已通过 sys.path 处理模块导入,不依赖 cwd。
|
|
827
|
+
const cliWorkDir = path.join(getDataDir(), "data", "workspace");
|
|
828
|
+
try { fs.mkdirSync(cliWorkDir, { recursive: true }); } catch (_) {}
|
|
824
829
|
try {
|
|
825
830
|
execFileSync(pyExe, [cliScript, ...args], {
|
|
826
|
-
stdio: "inherit", cwd:
|
|
831
|
+
stdio: "inherit", cwd: cliWorkDir, env, timeout: 300000,
|
|
827
832
|
});
|
|
828
833
|
} catch (e) {
|
|
829
834
|
process.exit(e.status || 1);
|
package/web/ui/chat/chat_main.js
CHANGED
|
@@ -2248,6 +2248,8 @@ async function selectSession(id) {
|
|
|
2248
2248
|
}
|
|
2249
2249
|
if (m.files && m.files.length > 0) {
|
|
2250
2250
|
mapped.files = m.files;
|
|
2251
|
+
// [v1.23.13] 同时映射到 _files,使历史消息中的文件卡片可渲染
|
|
2252
|
+
mapped._files = m.files;
|
|
2251
2253
|
}
|
|
2252
2254
|
return mapped;
|
|
2253
2255
|
});
|
|
@@ -2944,7 +2946,7 @@ function _renderMessagesInner() {
|
|
|
2944
2946
|
(sizeStr ? '<span class="msg-file-size">' + sizeStr + '</span>' : '') +
|
|
2945
2947
|
'</span>' +
|
|
2946
2948
|
'<span class="msg-file-actions">' +
|
|
2947
|
-
'<a class="msg-file-download" href="/api/file/' + (fileId || '') + '
|
|
2949
|
+
'<a class="msg-file-download" href="/api/file/' + (fileId || '') + '?name=' + encodeURIComponent(f.name || 'file') + '" download="' + escapeHtml(f.name) + '" title="下载" onclick="event.stopPropagation()">⬇</a>' +
|
|
2948
2950
|
'</span>' +
|
|
2949
2951
|
'</div>');
|
|
2950
2952
|
}
|
|
@@ -2966,7 +2968,7 @@ function _renderMessagesInner() {
|
|
|
2966
2968
|
(sizeStr ? '<span class="msg-file-size">' + sizeStr + '</span>' : '') +
|
|
2967
2969
|
'</span>' +
|
|
2968
2970
|
'<span class="msg-file-actions">' +
|
|
2969
|
-
'<a class="msg-file-download" href="/api/file/' + (fileId || '') + '
|
|
2971
|
+
'<a class="msg-file-download" href="/api/file/' + (fileId || '') + '?name=' + encodeURIComponent(f.name || 'file') + '" download="' + escapeHtml(f.name) + '" title="下载" onclick="event.stopPropagation()">⬇</a>' +
|
|
2970
2972
|
'</span>' +
|
|
2971
2973
|
'</div>');
|
|
2972
2974
|
}
|
|
@@ -1752,7 +1752,7 @@ async function sendMessage(opts) {
|
|
|
1752
1752
|
data: {
|
|
1753
1753
|
id: 'v2tool_' + Date.now() + '_' + allExecEvents.length,
|
|
1754
1754
|
type: 'tool_start',
|
|
1755
|
-
title:
|
|
1755
|
+
title: '调用工具: ' + (evt.tool.toolname || ''),
|
|
1756
1756
|
tool_name: evt.tool.toolname,
|
|
1757
1757
|
params: evt.tool.parms,
|
|
1758
1758
|
timeout: evt.tool.timeout,
|