myagent-ai 1.26.0 → 1.26.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.
@@ -75,104 +75,58 @@ class MainAgent(BaseAgent):
75
75
  - <recall_memory>: 你在上一轮通过 <recall> 指定的记忆搜索结果。系统根据你提供的关键字和时间点搜索了 top5 相关记忆。
76
76
  - 两种记忆互补:automemory 是自动匹配的,recall_memory 是你主动指定搜索的。如果 automemory 不足,使用 <recall> 请求更多。
77
77
  3. 工具使用指南 — 只有两个工具: command 和 web_control
78
- 4. 文件自动发送与下载链接: docx-create、xlsx-create、ppt-create、pdf-create、write 等命令执行成功后会**自动**将文件发送给用户(无需手动调用 send-file)。系统会返回包含下载链接的文件卡片,LLM 不需要自行拼接文件链接。仅在需要发送其他独立文件(如已存在的文件)时,才使用 myagent-ai send-file <文件路径> [描述]。向用户展示下载链接时,务必使用 Markdown 超链接格式: [文件名](完整URL)。
78
+ 4. 文件自动发送与下载链接: docx-create、xlsx-create、ppt-create、pdf-create 等命令执行成功后会**自动**将文件发送给用户(无需手动调用 send-file)。系统会返回包含下载链接的文件卡片,LLM 不需要自行拼接文件链接。仅在需要发送其他独立文件(如已存在的文件)时,才使用 myagent-ai send-file <文件路径> [描述]。向用户展示下载链接时,务必使用 Markdown 超链接格式: [文件名](完整URL)。
79
79
 
80
80
  **command**(执行命令行,所有操作都通过它完成):
81
81
  <tool><toolname>command</toolname><parms>{"command": "要执行的命令"}</parms><timeout>超时秒数</timeout></tool>
82
82
 
83
- 所有 CLI 命令 (通过 command 工具调用 myagent-ai):
83
+ 【重要】命令执行规则:
84
+ - Shell 原生命令(ls/cat/grep/ps/df/uname/python3/pip/npm/git/curl/wget 等)直接执行,不要加任何前缀
85
+ - 文件读写直接用 cat/tee/python3 等,不要用 myagent-ai read/write
86
+ - 只有下面的 myagent 专有命令才需要 myagent-ai 前缀
87
+ - 多个命令可用 && 连接一次执行(减少回调次数)
84
88
 
85
- 【感知】
89
+ 【myagent 专有命令】(需要 myagent-ai 前缀):
90
+
91
+ 感知:
86
92
  - OCR 文字识别: myagent-ai ocr 图片路径 [ch|en]
87
- - 图片分析(VLM): myagent-ai analyze-image 图片路径 [分析提示词]
93
+ - 图片分析(VLM): myagent-ai analyze-image 图片路径 [提示词]
88
94
  - 语音转文字: myagent-ai transcribe 音频路径 [zh|en|ja]
89
95
 
90
- 【搜索】
96
+ 搜索:
91
97
  - 网络搜索: myagent-ai search 关键词 [-n 数量]
92
- - 读取网页: myagent-ai read-url URL [--raw]
93
- - 获取URL原始内容(API): myagent-ai fetch-url URL [-m METHOD] [-H 'Key:Val'] [-d DATA]
94
-
95
- 【文件操作】
96
- - 读文件: myagent-ai read 文件路径 [--offset N] [--limit N]
97
- - 写文件: myagent-ai write 文件路径 -c "内容" [--append]
98
- - 列出目录: myagent-ai ls 目录 [-p "*.py"] [-r] [--max N]
99
- - 删除: myagent-ai rm 路径 [-r]
100
- - 搜索文件内容: myagent-ai grep 关键词 目录 [-p "*.py"]
101
- - 移动/重命名: myagent-ai mv 源路径 目标路径
102
- - 发送文件给用户: myagent-ai send-file 文件路径 描述
98
+ - 读取网页: myagent-ai read-url URL
99
+ - 获取URL内容(API): myagent-ai fetch-url URL [-m METHOD] [-H 'Key:Val'] [-d DATA]
103
100
 
104
- 【文档生成】
105
- - 创建Word: myagent-ai docx-create -c '{JSON内容}' -t 标题 (自动发送文件)
101
+ 文档生成 (执行后自动发送文件给用户):
102
+ - 创建Word: myagent-ai docx-create -c '{JSON}' -t 标题
106
103
  - 读取Word: myagent-ai docx-read 文件.docx
107
- - 创建Excel: myagent-ai xlsx-create -s '{JSON工作表}' -t 标题 (自动发送文件)
104
+ - 创建Excel: myagent-ai xlsx-create -s '{JSON}' -t 标题
108
105
  - 读取Excel: myagent-ai xlsx-read 文件.xlsx [--sheet 名称]
109
106
  - 编辑Excel: myagent-ai xlsx-edit 文件.xlsx append-row -d '{JSON}'
110
- - 创建PPT: myagent-ai ppt-create -s '{JSON幻灯片}' (自动发送文件)
107
+ - 创建PPT: myagent-ai ppt-create -s '{JSON幻灯片}'
111
108
  - 读取PPT: myagent-ai ppt-read 文件.pptx
112
- - 创建PDF: myagent-ai pdf-create -c '{JSON内容}' (自动发送文件)
113
- - 读取PDF: myagent-ai pdf-read 文件.pdf [--start N] [--end N]
114
-
115
- 【系统】
116
- - 系统信息: myagent-ai sysinfo
117
- - 列出进程: myagent-ai ps [--filter 名称] [--limit N]
118
- - 环境变量: myagent-ai env [KEY]
119
- - 路径信息: myagent-ai pathinfo 路径
120
-
121
- 【浏览器】
122
- - 打开网页: myagent-ai browser-open URL
123
- - 浏览器截图: myagent-ai browser-screenshot
124
- - 点击元素: myagent-ai browser-click CSS选择器
125
- - 填写输入: myagent-ai browser-fill CSS选择器
126
- - 执行JS: myagent-ai browser-eval 'JS代码'
127
- - 标签页管理: myagent-ai browser-navigate list|select|new|close
128
- - 关闭浏览器: myagent-ai browser-close
129
-
130
- 【GUI桌面】(仅Windows/macOS桌面)
131
- - 屏幕截图: myagent-ai screenshot [区域] [-m 显示器]
132
- - 鼠标点击: myagent-ai mouse-click X Y [-b left] [-c 1]
133
- - 鼠标拖拽: myagent-ai mouse-drag X1 Y1 X2 Y2
134
- - 输入文本: myagent-ai type-text "文本" [--clear]
135
- - 快捷键: myagent-ai hotkey copy|paste|ctrl+c|alt+tab
136
- - 列出窗口: myagent-ai window-list [--filter 关键词]
137
- - 聚焦窗口: myagent-ai window-focus 标题 [--maximize]
138
- - 屏幕元素识别: myagent-ai screen-element 描述 [区域]
139
-
140
- 【记忆】
141
- - 搜索记忆: myagent-ai memory [--keyword 关键词] [--limit N]
142
-
143
- 【Agent间通信】
144
- - 向其他Agent发送消息: myagent-ai chat --agent <Agent路径> --message "消息内容"
145
- - 向其他Agent发送文件: myagent-ai chat --agent <Agent路径> --file "文件路径"
146
- - 同时发送消息和文件: myagent-ai chat --agent <路径> -m "消息" -f "文件路径"
147
- - 可同时发送多个文件: myagent-ai chat --agent <路径> -f "文件1|文件2|文件3" (用|分隔多个文件路径)
148
-
149
- 【压缩解压】
150
- - 压缩文件/文件夹: myagent-ai zip 路径1 [路径2] ... [-o 输出.zip] [--exclude __pycache__ *.pyc .git]
151
- - 解压zip文件: myagent-ai unzip 文件.zip [-o 输出目录]
152
-
153
- 【媒体播放】
154
- - 播放音频: myagent-ai playaudio --url 音频URL [--title 标题] 或 myagent-ai playaudio --file 本地路径
155
- - 播放视频: myagent-ai playvideo --url 视频URL [--title 标题] 或 myagent-ai playvideo --file 本地路径
156
-
157
- 【通用Shell命令】
158
- - 执行代码: python3 script.py 或 python3 -c "代码"
159
- - 文件列表: ls -la 目录
160
- - 系统信息: uname -a / df -h / free -h
109
+ - 创建PDF: myagent-ai pdf-create -c '{JSON}' [-o 输出路径]
110
+ - 读取PDF: myagent-ai pdf-read 文件.pdf
111
+
112
+ 浏览器 (Playwright):
113
+ - 打开/截图/点击/填写/执行JS/标签页管理/关闭:
114
+ myagent-ai browser-open|browser-screenshot|browser-click|browser-fill|browser-eval|browser-navigate|browser-close
115
+
116
+ GUI桌面 (仅Windows/macOS):
117
+ - screenshot, mouse-click, mouse-drag, type-text, hotkey, window-list, window-focus, screen-element
118
+
119
+ 记忆/通信/媒体:
120
+ - 搜索记忆: myagent-ai memory [--keyword 关键词]
121
+ - Agent间通信: myagent-ai chat --agent <路径> -m "消息" [-f "文件"]
122
+ - 发送文件给用户: myagent-ai send-file 文件路径 描述
123
+ - 播放音频/视频: myagent-ai playaudio/playvideo --url URL [--title 标题]
161
124
 
162
125
  调用示例:
126
+ <tool><toolname>command</toolname><parms>{"command": "ls -la /tmp && df -h && python3 --version"}</parms><timeout>10</timeout></tool>
163
127
  <tool><toolname>command</toolname><parms>{"command": "myagent-ai search 人工智能最新进展"}</parms><timeout>15</timeout></tool>
164
128
  <tool><toolname>command</toolname><parms>{"command": "myagent-ai docx-create -c '{\"title\": \"报告\", \"sections\": [{\"heading\": \"摘要\", \"body\": \"内容\"}]}' -t 周报"}</parms><timeout>30</timeout></tool>
165
- <tool><toolname>command</toolname><parms>{"command": "myagent-ai ppt-create -s '{JSON幻灯片}'"}</parms><timeout>30</timeout></tool>
166
- <tool><toolname>command</toolname><parms>{"command": "myagent-ai playaudio --url https://music.163.com/song?id=123 --title 歌曲名"}</parms><timeout>10</timeout></tool>
167
- <tool><toolname>command</toolname><parms>{"command": "myagent-ai playvideo --url https://www.bilibili.com/video/BV123 --title 视频名"}</parms><timeout>10</timeout></tool>
168
- <tool><toolname>command</toolname><parms>{"command": "myagent-ai chat --agent default/coder --message \"请帮我分析这段代码的时间复杂度\""}</parms><timeout>10</timeout></tool>
169
- <tool><toolname>command</toolname><parms>{"command": "myagent-ai chat --agent default/coder -f \"/path/to/report.pdf\" -m \"请审阅这份报告\""}</parms><timeout>10</timeout></tool>
170
- <tool><toolname>command</toolname><parms>{"command": "myagent-ai zip /path/to/project -o backup.zip --exclude __pycache__ .git"}</parms><timeout>30</timeout></tool>
171
- <tool><toolname>command</toolname><parms>{"command": "myagent-ai unzip /path/to/archive.zip -o ./output"}</parms><timeout>30</timeout></tool>
172
-
173
- 多个命令可用 && 连接一次执行(强烈推荐,减少LLM回调次数):
174
- <tool><toolname>command</toolname><parms>{"command": "myagent-ai search xxx && myagent-ai read-url https://..."}</parms><timeout>30</timeout></tool>
175
- <tool><toolname>command</toolname><parms>{"command": "myagent-ai sysinfo && myagent-ai ps --filter python"}</parms><timeout>15</timeout></tool>
129
+ <tool><toolname>command</toolname><parms>{"command": "cat /etc/os-release && uname -a && free -h"}</parms><timeout>10</timeout></tool>
176
130
 
177
131
  **file_send**(向用户发送文件,文件会以卡片形式显示在聊天中):
178
132
  <tool><toolname>file_send</toolname><parms>{"file_path": "文件的绝对路径", "description": "文件描述(可选)"}</parms><timeout>30</timeout></tool>
@@ -173,6 +173,7 @@ class ContextBuilder:
173
173
  self._build_task_plan(task_plan),
174
174
  self._build_tools(self.skill_registry),
175
175
  self._build_skill_prompts(self.skill_registry),
176
+ self._build_runtime_env(),
176
177
  self._build_exec_warnings(),
177
178
  ]
178
179
 
@@ -821,6 +822,64 @@ class ContextBuilder:
821
822
  """
822
823
  return ""
823
824
 
825
+ def _build_runtime_env(self) -> str:
826
+ """[v1.26.0] 构建运行环境信息段落 — 操作系统、Shell、可用工具链。"""
827
+ import os
828
+ import platform
829
+ import subprocess
830
+ import shutil
831
+
832
+ lines = ["<runtime_env>"]
833
+
834
+ # 操作系统
835
+ system = platform.system()
836
+ release = platform.release()
837
+ machine = platform.machine()
838
+ lines.append(f"操作系统: {system} {release} ({machine})")
839
+
840
+ # Shell 信息
841
+ shell_name = os.environ.get("SHELL", "")
842
+ if not shell_name and system == "Windows":
843
+ shell_name = os.environ.get("COMSPEC", "cmd.exe")
844
+ if shell_name:
845
+ lines.append(f"默认Shell: {shell_name}")
846
+
847
+ # 常用工具检测
848
+ useful_tools = []
849
+ for tool in ["python3", "python", "pip3", "pip", "node", "npm", "npx",
850
+ "git", "curl", "wget", "bash", "zsh", "sh",
851
+ "docker", "docker-compose", "ffmpeg", "jq", "tar", "zip", "unzip",
852
+ "grep", "sed", "awk", "find", "cat", "head", "tail", "wc"]:
853
+ path = shutil.which(tool)
854
+ if path:
855
+ useful_tools.append(tool)
856
+ lines.append(f"可用命令: {', '.join(useful_tools)}")
857
+
858
+ # Python 版本
859
+ try:
860
+ result = subprocess.run(
861
+ ["python3", "--version"], capture_output=True, text=True, timeout=5
862
+ )
863
+ if result.returncode == 0:
864
+ lines.append(f"Python: {result.stdout.strip()}")
865
+ except Exception:
866
+ pass
867
+
868
+ # Node 版本
869
+ node_path = shutil.which("node")
870
+ if node_path:
871
+ try:
872
+ result = subprocess.run(
873
+ ["node", "--version"], capture_output=True, text=True, timeout=5
874
+ )
875
+ if result.returncode == 0:
876
+ lines.append(f"Node.js: {result.stdout.strip()}")
877
+ except Exception:
878
+ pass
879
+
880
+ lines.append("</runtime_env>")
881
+ return "\n".join(lines)
882
+
824
883
  def _build_exec_warnings(self) -> str:
825
884
  """[v1.23.44] 构建执行环境警告段落,提醒 Agent 避免常见错误。"""
826
885
  import os
@@ -844,8 +903,7 @@ class ContextBuilder:
844
903
  "- 禁止执行: bash start.sh / ./start.sh (同上,启动脚本)",
845
904
  "- 禁止执行: myagent-ai start / myagent-ai run (重复启动服务)",
846
905
  "- 如需测试 myagent 模块,请直接 import: python -c 'from agents.main_agent import MainAgent; ...'",
847
- "- 如需搜索项目代码,请使用: myagent-ai grep &lt;关键词&gt; &lt;路径&gt; (注意: 不支持 -n/-i/-r 等系统 grep 参数)",
848
- "- 如需操作文件,请使用: myagent-ai file-read / file-write / file-search 等 CLI 命令",
906
+ "- 文件操作请使用原生命令: cat, head, tail, grep, find ",
849
907
  "</exec_warnings>",
850
908
  ]
851
909
  return "\n".join(lines)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myagent-ai",
3
- "version": "1.26.0",
3
+ "version": "1.26.1",
4
4
  "description": "本地桌面端执行型AI助手 - Open Interpreter 风格 | Local Desktop Execution-Oriented AI Assistant",
5
5
  "main": "main.py",
6
6
  "bin": {
package/start.js CHANGED
@@ -782,14 +782,15 @@ function main() {
782
782
  if (cmd === "reinstall") { cmdReinstall(pkgDir); return; }
783
783
  if (cmd === "install") { cmdInstall(pkgDir); return; }
784
784
 
785
- // [v1.22.0] CLI 子命令 — 轻量级,不需要完整启动 myagent
785
+ // [v1.26.0] CLI 子命令 — 仅保留 myagent 专有命令
786
+ // 原生命令 (ls/grep/cat/ps/cp/mv/rm/...) 直接透传 shell,不再包装
786
787
  const CLI_CMDS = [
787
788
  // 感知
788
789
  "ocr", "analyze-image", "transcribe",
789
790
  // 搜索
790
791
  "search", "read-url", "fetch-url",
791
- // 文件操作
792
- "read", "write", "ls", "rm", "grep", "mv", "send-file",
792
+ // 文件发送
793
+ "send-file",
793
794
  // 文档 - Word
794
795
  "docx-create", "docx-read",
795
796
  // 文档 - Excel
@@ -798,9 +799,6 @@ function main() {
798
799
  "ppt-create", "ppt-read",
799
800
  // 文档 - PDF
800
801
  "pdf-create", "pdf-read",
801
- // 系统
802
- "system-info", "sysinfo", "process-list", "ps",
803
- "env", "pathinfo",
804
802
  // 浏览器
805
803
  "browser-open", "browser-screenshot", "browser-close",
806
804
  "browser-click", "browser-fill", "browser-eval", "browser-navigate",
@@ -813,8 +811,6 @@ function main() {
813
811
  "playaudio", "playvideo",
814
812
  // Agent 通信
815
813
  "chat",
816
- // 压缩解压
817
- "zip", "unzip",
818
814
  // 帮助
819
815
  "help", "-h", "--help",
820
816
  ];