File Sender
Packages workspace files into a ZIP, generates a companion description file, and notifies the Manager to deliver them to the user. Files are persisted locally to .file-outbox/ first — even if notification fails, the files are safe.
All required environment variables are injected automatically by the Manager at instance creation. No manual configuration needed.
Core Workflow
Step 1: Compose a Description
Before running the script, write a concise description of what you generated. This description will be saved as a .txt file alongside the ZIP in .file-outbox/, serving as a human-readable summary for the user.
The description should include:
- - What files/project were generated
- The main purpose of the files
- How to use them (brief instructions)
Good example:
CODEBLOCK0
Bad example:
CODEBLOCK1
Step 2: Package and Send
Pass the source path and the description text to the script:
CODEBLOCK2
The script will:
- 1. Validate the path — Only allows files under
/home/node/workspace/, blocks symlink traversal - Create a ZIP — Single file
zip, directory zip -r, 500MB limit - Write description — Saves the description text as
{file_id}.txt in INLINECODE7 - Persist locally — Both ZIP and TXT are stored in
.file-outbox/ (safe on disk) - Notify Manager — Sends a lightweight POST with metadata only (no file body)
- Manager pulls — Manager's background task pulls the ZIP from the Agent and forwards it
Core design: After step 4, files are safely on disk. Steps 5-6 failing does NOT lose the files.
The Manager retries automatically — the user will always receive the files eventually.
Step 3: Confirm the Result
The script outputs the result. Even if notification fails, the files are safely persisted locally. The system will retry delivery automatically.
Quick Examples
CODEBLOCK3
Sending Multiple Non-Adjacent Files
Collect them into a temporary directory first:
CODEBLOCK4
What Gets Saved in .file-outbox/
For each delivery, two files are created:
CODEBLOCK5
The .txt file contains the exact description you provided, serving as a persistent record of what was sent and why.
When to Trigger
| Scenario | Trigger? |
|---|
| Created a complete project/application | ✅ Yes |
| Generated documents/reports/data files |
✅ Yes |
| User asks to "send files" | ✅ Yes |
| Only explaining code / answering questions | ❌ No |
| Modifying system config files | ❌ No |
| Tiny single-line changes | ❌ No |
Output Examples
Success:
CODEBLOCK6
Notification failure (files still safe):
CODEBLOCK7
Limits
| Limit | Value |
|---|
| Max file size | 500MB (after ZIP) |
| Source path scope |
/home/node/workspace/ only |
| Cannot send |
.file-outbox/ directory itself |
Environment Requirements
- -
OPENCLAW_INSTANCE_NAME — Instance name (auto-injected by Manager) - INLINECODE14 — File Push service URL (auto-injected by Manager)
- INLINECODE15 — Instance-specific push token (auto-injected by Manager)
- INLINECODE16 and
zip commands must be available in PATH
文件发送器
将工作区文件打包为ZIP,生成配套的描述文件,并通知管理器将其交付给用户。文件会首先持久化存储到本地.file-outbox/目录——即使通知失败,文件也是安全的。
所有必要的环境变量在实例创建时由管理器自动注入,无需手动配置。
核心工作流程
第一步:编写描述
在运行脚本之前,请简要描述您生成的内容。该描述将作为.txt文件与ZIP包一同保存在.file-outbox/目录中,作为供用户阅读的摘要说明。
描述应包含:
- - 生成了哪些文件/项目
- 文件的主要用途
- 如何使用(简要说明)
好的示例:
贪吃蛇游戏项目 (snake_game)
包含:index.html, style.css, game.js
使用方法:在浏览器中打开index.html即可玩游戏
不好的示例:
文件
第二步:打包并发送
将源路径和描述文本传递给脚本:
bash
bash scripts/send-files.sh \
/home/node/workspace/snake_game \
贪吃蛇游戏项目,包含index.html、style.css、game.js。在浏览器中打开index.html即可游玩。
脚本将执行以下操作:
- 1. 验证路径 — 仅允许/home/node/workspace/下的文件,阻止符号链接遍历
- 创建ZIP包 — 单个文件使用zip,目录使用zip -r,限制500MB
- 写入描述 — 将描述文本保存为.file-outbox/中的{file_id}.txt
- 本地持久化 — ZIP和TXT文件均存储在.file-outbox/中(安全保存在磁盘上)
- 通知管理器 — 发送仅包含元数据的轻量级POST请求(不包含文件体)
- 管理器拉取 — 管理器的后台任务从Agent拉取ZIP包并转发
核心设计:第4步完成后,文件已安全保存在磁盘上。第5-6步失败不会导致文件丢失。
管理器会自动重试——用户最终一定能收到文件。
第三步:确认结果
脚本会输出结果。即使通知失败,文件也已安全持久化到本地。系统会自动重试交付。
快速示例
bash
发送单个文件
bash scripts/send-files.sh \
/home/node/workspace/report.pdf \
2026年3月月度销售报告,包含图表和汇总表。
发送整个目录(自动递归压缩)
bash scripts/send-files.sh \
/home/node/workspace/my_project \
完整的Python项目,包含requirements.txt和README.md。运行:pip install -r requirements.txt && python main.py
发送多个不连续的文件
先将它们收集到一个临时目录中:
bash
mkdir -p /tmp/delivery
cp /home/node/workspace/report.pdf /tmp/delivery/
cp /home/node/workspace/data.csv /tmp/delivery/
bash scripts/send-files.sh /tmp/delivery 分析报告 + 原始数据CSV
保存在.file-outbox/中的内容
每次交付会创建两个文件:
.file-outbox/
├── 20260401120000_a1b2c3d4.zip # 打包的文件
└── 20260401120000_a1b2c3d4.txt # 描述文本(供阅读)
.txt文件包含您提供的完整描述,作为已发送内容及原因的持久化记录。
触发时机
| 场景 | 是否触发? |
|---|
| 创建了完整的项目/应用 | ✅ 是 |
| 生成了文档/报告/数据文件 |
✅ 是 |
| 用户要求发送文件 | ✅ 是 |
| 仅解释代码/回答问题 | ❌ 否 |
| 修改系统配置文件 | ❌ 否 |
| 微小的单行更改 | ❌ 否 |
输出示例
成功:
📦 正在打包文件...
文件ID:20260401120000_a1b2c3d4 | 大小:156KB
📤 正在通知管理器...
✅ 通知已发送!文件将自动交付给用户。
通知失败(文件仍然安全):
⚠️ 无法连接到管理器。文件已安全存储在本地。
系统将自动重试——用户最终会收到文件。
限制
| 限制项 | 值 |
|---|
| 最大文件大小 | 500MB(压缩后) |
| 源路径范围 |
仅限/home/node/workspace/ |
| 禁止发送 | .file-outbox/目录本身 |
环境要求
- - OPENCLAWINSTANCENAME — 实例名称(由管理器自动注入)
- OPENCLAWMANAGERURL — 文件推送服务URL(由管理器自动注入)
- OPENCLAWFILEPUSH_TOKEN — 实例专属推送令牌(由管理器自动注入)
- curl和zip命令必须在PATH中可用