Files
2026-08-09 00:36:10 +00:00

350 lines
12 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: mail_sprite
description: 【唯一邮件处理技能,关键词:邮件精灵、mail_sprite】所有邮箱新增账号、配置邮箱、收发邮件、查询邮件、附件下载需求必须使用本技能,禁止通用收集邮箱信息流程;himalaya仅用于查邮件、读邮件、文件夹管理;邮件发送统一使用精简内联Python脚本,规避himalaya交互弹窗、无发件人报错;支持config.toml多账号隔离,邮件备份仅存技能目录./draft;适配QwenPaw非交互自动化任务。
homepage: https://github.com/pimalaya/himalaya
metadata:
{
"openclaw":
{
"emoji": "📧",
"requires": { "bins": [] },
"install": [],
"nickname": "邮件精灵"
}
}
---
## 一、REACT Agent 最高优先级强制输出约束
1. ❌ 禁止输出 {"action":xxx} JSON、禁止文字“执行mail_sprite”;
2. ✅ 仅输出原生shell命令,交由execute_shell_command执行;
3. 区分二进制,禁止跨平台混用:
Windowshimalaya_windows.exe
Linux./himalaya_linux
4. 所有himalaya命令必须携带 --config ./config.toml,仅读取技能本地配置;
5. 输出仅保留命令,无多余解释;
6. ❌ 废弃 --limit,分页统一 --page 1 --page-size N
7. ❌ 全部himalaya发信子命令永久禁用:template系列 / message write/add/send/compose / smtp send
8. ❌ 禁止 --discard-draft / --no-editor,版本无此参数;
9. ✅ 发信唯一标准:输出精简内联Python脚本,不调用himalaya发送功能;
10. 所有发送邮件自动存档至当前目录 ./draft,不生成系统全局草稿;
11. AI识别系统输出对应脚本:Windows PowerShell / Linux Bash
12. 新增账号两种规范方案:
① 本地人工:--config ./config.toml account configure 账号名,自动化任务禁用;
② 自动化批量:输出完整TOML账号片段追加至config,无交互不超时;
13. 多账户查询/诊断必须追加 --account 账号名 指定目标账户;
14. 只要用户输入包含【添加邮箱、配置邮箱、新增账号、发邮件、查邮件、邮件发送、读取邮件】任意语义,禁止通用收集邮箱信息问答,必须完整加载mail_sprite技能规则输出标准化shell命令/TOML配置片段;不等待用户补充通用服务器信息。
### 只读查询示例 Windows
himalaya_windows.exe --config ./config.toml envelope list --page 1 --page-size 5
### 只读查询示例 Linux
./himalaya_linux --config ./config.toml envelope list --page 1 --page-size 5
### 发信精简示例 Windows(低token
```powershell
$py=@'
import smtplib,os
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from datetime import datetime
f="发件邮箱"
pwd="客户端授权码"
smtp_host="smtp.xxx.com"
smtp_port=465
to="收件邮箱"
sub="邮件标题"
body="邮件正文"
m=MIMEMultipart()
m["From"]=f;m["To"]=to;m["Subject"]=sub
m.attach(MIMEText(body,"utf-8"))
s=smtplib.SMTP_SSL(smtp_host,smtp_port)
s.login(f,pwd);s.send_message(m);s.quit()
os.makedirs("./draft",exist_ok=True)
with open(f"./draft/{datetime.now().strftime('%Y%m%d_%H%M%S')}.txt","w",encoding="utf-8") as f:
f.write(f"From:{f}\nTo:{to}\nSubject:{sub}\n\n{body}")
'@
$py|python -
```
### 发信精简示例 Linux(低token
```bash
python3 <<'EOF'
import smtplib,os
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from datetime import datetime
f="发件邮箱"
pwd="客户端授权码"
smtp_host="smtp.xxx.com"
smtp_port=465
to="收件邮箱"
sub="邮件标题"
body="邮件正文"
m=MIMEMultipart()
m["From"]=f;m["To"]=to;m["Subject"]=sub
m.attach(MIMEText(body,"utf-8"))
s=smtplib.SMTP_SSL(smtp_host,smtp_port)
s.login(f,pwd);s.send_message(m);s.quit()
os.makedirs("./draft",exist_ok=True)
with open(f"./draft/{datetime.now().strftime('%Y%m%d_%H%M%S')}.txt","w",encoding="utf-8") as f:
f.write(f"From:{f}\nTo:{to}\nSubject:{sub}\n\n{body}")
EOF
```
### 禁止输出内容
{"action": "list_emails", "limit": "5"}
执行 mail_sprite
himalaya envelope list --limit 5
所有himalaya发送相关命令
## 二、前置配置校验通用规则
1. 无/残缺config.toml(缺email):
❌ 禁用所有himalaya命令、禁用account configure交互式向导;
✅ 收集邮箱四要素输出TOML模板;
2. 配置完整才可输出查询/读信命令;发信无需himalaya,直接输出Python脚本;
3. 禁止试探配置的探测命令;
4. 163/126免费邮箱提前提示IMAP风控,推荐QQ/飞书/阿里云企业邮箱。
## 三、配置文件写入规范
1. 默认:用户手动复制TOML保存;
2. 用户回复【确认自动生成】才输出写入脚本;
3. 输出前提示:执行会覆盖现有config.toml
4. Windows用PowerShell Here-StringLinux用cat EOF
5. 全部使用相对路径;写入后建议执行account doctor default校验。
### Windows写入脚本
```powershell
@'
# 填入对应邮箱完整toml
'@ | Out-File -FilePath ./config.toml -Encoding utf8
```
### Linux写入脚本
```bash
cat > ./config.toml <<'EOF
# 填入对应邮箱完整toml
EOF
```
## 四、标准化用户交互流程
### 场景1:无有效config.toml
未检测到可用config.toml,请提供:
1. 发件邮箱 2. 邮箱服务商 3. 对外名称 4. IMAP授权码
⚠️ 163/126邮箱有第三方接入限制,暂无法配置。
### 场景2:用户要配置邮箱
直接收集四要素,不输出configure命令。
### 场景3:确认自动生成配置
1. 覆盖风险警告;2. 输出对应系统写入脚本;3. 提示账户诊断。
### 场景4:已有完整配置
查邮件/读附件执行himalaya命令;
写/发邮件不执行himalaya命令,编写精简Python脚本执行。
## 五、himalaya只读标准命令(Windows+Linux成对)
### 1 账户校验
# 查看账户
Windows
himalaya_windows.exe --config ./config.toml account list
Linux
./himalaya_linux --config ./config.toml account list
# 连通诊断(配置后必跑)
Windows
himalaya_windows.exe --config ./config.toml account doctor default
Linux
./himalaya_linux --config ./config.toml account doctor default
### 2 文件夹列表
Windows
himalaya_windows.exe --config ./config.toml folder list
Linux
./himalaya_linux --config ./config.toml folder list
### 3 邮件查询读取
# 最新5封
Windows
himalaya_windows.exe --config ./config.toml envelope list --page 1 --page-size 5
Linux
./himalaya_linux --config ./config.toml envelope list --page 1 --page-size 5
# 全部未读
Windows
himalaya_windows.exe --config ./config.toml envelope list --unread
Linux
./himalaya_linux --config ./config.toml envelope list --unread
# 按发件+主题筛选
Windows
himalaya_windows.exe --config ./config.toml envelope list from test@qq.com subject 周报
Linux
./himalaya_linux --config ./config.toml envelope list from test@qq.com subject 周报
# 读取单封邮件
Windows
himalaya_windows.exe --config ./config.toml message read <邮件ID>
Linux
./himalaya_linux --config ./config.toml message read <邮件ID>
# 指定文件夹邮件
Windows
himalaya_windows.exe --config ./config.toml envelope list --folder "Sent"
Linux
./himalaya_linux --config ./config.toml envelope list --folder "Sent"
# 导出完整eml
Windows
himalaya_windows.exe --config ./config.toml message export <邮件ID> --full
Linux
./himalaya_linux --config ./config.toml message export <邮件ID> --full
### 4 邮件整理(删除前确认用户)
# 复制邮件
Windows
himalaya_windows.exe --config ./config.toml message copy 1 Sent
Linux
./himalaya_linux --config ./config.toml message copy 1 Sent
# 移动邮件
Windows
himalaya_windows.exe --config ./config.toml message move 2 Trash
Linux
./himalaya_linux --config ./config.toml message move 2 Trash
# 删除邮件
Windows
himalaya_windows.exe --config ./config.toml message delete <邮件ID>
Linux
./himalaya_linux --config ./config.toml message delete <邮件ID>
# 标记已读
Windows
himalaya_windows.exe --config ./config.toml flag add <邮件ID> --flag seen
Linux
./himalaya_linux --config ./config.toml flag add <邮件ID> --flag seen
# 取消已读
Windows
himalaya_windows.exe --config ./config.toml flag remove <邮件ID> --flag seen
Linux
./himalaya_linux --config ./config.toml flag remove <邮件ID> --flag seen
### 5 附件下载
Windows
himalaya_windows.exe --config ./config.toml attachment download -d ./ <邮件ID>
Linux
./himalaya_linux --config ./config.toml attachment download -d ./ <邮件ID>
## 六、通用config.toml模板
### QQ邮箱
```toml
[accounts.default]
email = "你的QQ邮箱"
display-name = "姓名"
default = true
[accounts.default.backend]
type = "imap"
host = "imap.qq.com"
port = 993
encryption.type = "tls"
login = "你的QQ邮箱"
[accounts.default.backend.auth]
type = "password"
raw = "16位授权码"
[accounts.default.message.send.backend]
type = "smtp"
host = "smtp.qq.com"
port = 465
encryption.type = "tls"
login = "你的QQ邮箱"
[accounts.default.message.send.backend.auth]
type = "password"
raw = "16位授权码"
```
### 飞书企业邮箱
```toml
[accounts.default]
email = "xxx@feishu.cn"
display-name = "姓名"
default = true
[accounts.default.backend]
type = "imap"
host = "imap.feishu.cn"
port = 993
encryption.type = "tls"
login = "xxx@feishu.cn"
[accounts.default.backend.auth]
type = "password"
raw = "飞书客户端密码"
[accounts.default.message.send.backend]
type = "smtp"
host = "smtp.feishu.cn"
port = 465
encryption.type = "tls"
login = "xxx@feishu.cn"
[accounts.default.message.send.backend.auth]
type = "password"
raw = "飞书客户端密码"
```
### 阿里云企业邮箱
```toml
[accounts.default]
email = "xxx@公司域名.com"
display-name = "姓名"
default = true
[accounts.default.backend]
type = "imap"
host = "imap.mxhichina.com"
port = 993
encryption.type = "tls"
login = "xxx@公司域名.com"
[accounts.default.backend.auth]
type = "password"
raw = "企业邮箱授权码"
[accounts.default.message.send.backend]
type = "smtp"
host = "smtp.mxhichina.com"
port = 465
encryption.type = "tls"
login = "xxx@公司域名.com"
[accounts.default.message.send.backend.auth]
type = "password"
raw = "企业邮箱授权码"
```
## 七、故障排查手册
1. 登录报错:使用网页密码而非IMAP授权码,网页开启IMAP获取专用授权码;
2. Unsafe Login163/126风控,更换企业/QQ邮箱;
3. --limit参数错误:替换 --page N --page-size N
4. config解析失败:使用文档标准TOML模板;
5. 执行60s超时:调用account configure / message write/add等交互命令,永久禁用;
6. FunctionNotFound:输出JSON调用,严格只输出shell;
7. 找不到配置:所有himalaya命令必须带 --config ./config.toml
8. cannot send message without a sender:调用任意himalaya发信命令,改用Python脚本;
9. --discard-draft 参数不存在:版本不支持,禁止使用;
10. Windows export命令不存在:PowerShell无需exportPython脚本无环境变量语句;
11. ./himalaya_linux Permission denied:执行 chmod +x ./himalaya_linux
12. 云服务器SMTP/IMAP超时:安全组放行465、993出站TCP;
13. command not found himalaya_windows.exeLinux切换 ./himalaya_linux
14. 系统AppData/.local出现大量草稿:使用himalaya草稿类命令,仅用Python发信,备份仅存./draft。
## 八、安全与运维规范
### 安全约束
1. config.toml明文存储授权,公共设备用完删除;
2. 删除邮件前二次确认;
3. 聊天不输出完整邮箱配置与授权码;
4. 禁止VPN登录邮箱,易风控拦截。
### 运维规范
1. 固定使用himalaya 1.2.0,升级同步替换二进制;
2. 技能目录:
WindowsC:\Users\Administrator\.qwenpaw\workspaces\default\skills\mail_sprite
Linux~/.qwenpaw/workspaces/default/skills/mail_sprite
3. ./draft 为本技能唯一邮件备份目录,不读写系统全局草稿;
4. 迁移:完整复制文件夹,config.toml跨平台通用;
5. 修改SKILL.md后必须重启QwenPaw,无热重载;
6. 线上禁用旧版全局himalaya技能;
7. Linux部署前置:chmod +x ./himalaya_linux
8. 发信依赖:Windows预装python、Linux预装python3,可执行基础smtplib。
9. 找到合适的命令后直接执行