让 AI Agent 和人互传文件
编程 Agent 跑在你的下载文件夹够不着的地方:沙箱、容器、CI、远程机器。freedrop 给 Agent 一条命令把文件交给你——你在任意设备上打开一个链接就能收;再给它一条命令,接收你在浏览器里选好的文件。中间不上传到任何地方:数据在两端之间直接传输,端到端加密。
告诉你的 Agent
把下面这段粘贴到 Agent 会读的指令里(AGENTS.md、CLAUDE.md 或系统提示词):
要给我发文件时,在后台运行 `npx -y freedrop --json --timeout 10m <文件>`,
把它第一行输出里的 `link` 给我。要接收我的文件时,向我要 https://freedrop.dev/
页面上显示的链接,然后运行 `npx -y freedrop --json -y -o <目录> '<链接>'`。
详见 https://freedrop.dev/llms.txt
任何能执行 shell 命令的 Agent 都能用:Claude Code、Codex CLI、Gemini CLI、Cursor、Aider 等等。Agent 那一端需要 Node.js 22 及以上;你这边只要一个浏览器。
流程
- Agent → 你。 Agent 在后台启动发送端,stdout 的第一行是带
link的ready事件;Agent 把链接转给你,你在手机或电脑上打开、保存文件。你那边每个字节校验通过后,发送端以 0 退出。 - 你 → Agent。 你打开 freedrop.dev,选好文件,把页面给出的链接贴进对话。Agent 运行接收端,每个校验通过的文件都会产生一个带绝对路径的
saved事件。传完之前请保持页面打开。
为什么它适合在 Agent 的 shell 里跑
- 没有终端也不卡住。 没有 TTY 时只输出纯文本行——不打二维码、不原地刷新进度条;接收端没加
-y会直接退出,而不是等一个没人能回答的确认。 - 输出可解析。 加
--json后 stdout 上只有逐行的 JSON 事件,给人看的文字改走 stderr。 - 退出码说明下一步。 连接中途断开(8)就重跑同一条命令续传;连不上(4)就加 TURN 中继重试;超时(7)说明没人来接。
- 等待有上限。
--timeout只计算没有传输进行时的时间,慢速传输不会被误杀。 - 链接和代码都认。 接收端接受浏览器链接(带不带
https://都行),也接受裸代码。
参考
下面是 /llms.txt 中的同一份参考——写给 Agent 本身读的说明,原文为英文,与 llms.txt 保持同步。
Send a file to a person
npx -y freedrop --json --timeout 10m report.pdf data.csv
Run it in the background. The first stdout line is the ready event: give the person its link (they open it in any browser, on any device — no install) or, if they have a terminal, npx freedrop <code>. The process exits 0 once the receiver has verified every byte. Without --timeout the sender waits for a receiver indefinitely; --timeout counts only time with no transfer under way. Arguments must be regular files — tar a directory first.
Receive a file from a person
Ask them to open https://freedrop.dev/, pick the files, and send you the link (or the npx freedrop <code> line) it shows. Then:
npx -y freedrop --json -y -o <dir> '<link or code>'
-y is required without a terminal (exit 2 otherwise). Each verified file produces a saved event with its absolute path; a name already taken in <dir> lands as name(1).ext. Keep the person's page open until the transfer finishes.
Events (--json)
ready(send):code,link,files[{name, size}],totalincoming(receive):files,total,resumed(bytes already on disk)progress:bytes,total— at most every 10 s, and at 100 %saved(receive):name,path,sizestatus:message— human-readable, wording may changedone:total,seconds— then exit 0error:error,code(= exit status),message— then exit. Aconnecterror addsnat{here,peer}: each end's {type,ipv6} or null,typeone ofopen,cone,symmetric,blocked(no STUN server answered),unknown.symmetricon both ends, orblockedon either, means only a TURN relay will connect them
Exit statuses
- 0 done, every file verified
- 1
failed— anything else; read the message - 2
usage— bad arguments, or a receiver without-yand no terminal - 3
broker— no rendezvous broker reachable (network, or--broker) - 4
connect— peers met but WebRTC could not connect: retry with--turn cloudflare(needs CF_TURN_KEY_ID, CF_TURN_API_TOKEN) or--turn turn:host:3478 --turn-auth user:passon the sending side - 5
verify— a file failed verification or changed while sending; a re-run transfers it fresh - 6
declined— the receiver said no - 7
timeout—--timeoutpassed, or a receiver found no sender (wrong code, or the sender is gone) - 8
lost— connection lost mid-transfer; re-run the same command to resume - 130 / 143
interrupted— SIGINT / SIGTERM; re-run to resume
Interrupted and lost transfers print the exact command that resumes them: the receiver re-runs freedrop -y -o <dir> <code>, the sender freedrop --code <code> <files>.