Codecast
Live-stream coding agent sessions to Discord. Zero AI tokens burned.
Setup
First-time setup: see references/setup.md for webhook creation, unbuffer install, bot token, and smoke test.
Invocation
Launch with exec background:true. Background exec sessions survive agent turns and OpenClaw fires notifyOnExit automatically when the process ends.
CODEBLOCK0
Note the session ID from the response — use it to monitor via process.
Options
| Flag | Description | Default |
|---|
| INLINECODE3 | Working directory | Current dir |
| INLINECODE4 |
Timeout | 1800 |
|
-h <sec> | Hang threshold | 120 |
|
-n <name> | Agent display name | Auto-detected |
|
-r <n> | Rate limit (posts/60s) | 25 |
|
--thread | Post into a Discord thread | Off |
|
--skip-reads | Hide Read tool events | Off |
|
--review <url> | PR review mode | — |
|
--parallel <file> | Parallel tasks mode | — |
|
--resume <dir> | Replay session | — |
For PR review, parallel tasks, Discord bridge, and Codex structured output: see references/advanced-modes.md.
Agent Launch Checklist
- 1. Start background session → note session ID and PID from response
- Post to dev channel → announce agent name, workdir, task
- Write breadcrumb for completion routing:
echo '{"channel":"<invoking-channel-id>","relayDir":"<relay-dir>","pid":<PID>}' > /tmp/codecast-pending-<PID>.json
- 4. Log to daily memory → session ID, relay dir, invoking channel
The breadcrumb file tells the heartbeat precheck where to post results when the session completes. It auto-detects completion by checking if the PID is still alive.
That's it. When the process ends, OpenClaw's notifyOnExit fires a system event + heartbeat request. The heartbeat handler reads the result from the relay dir's stream.jsonl and posts to the invoking channel.
Completion Detection
OpenClaw handles this natively:
- -
tools.exec.notifyOnExit: true (default) — system event + heartbeat on process exit - Heartbeat precheck script detects completed sessions via INLINECODE16
- No cron watcher needed
Backup: Append this to the inner agent's prompt for an additional signal:
CODEBLOCK2
Monitoring
CODEBLOCK3
Agent Support
| Agent | Output Mode | Status |
|---|
| Claude Code | stream-json | Full support |
| Codex |
--json JSONL | Full support |
| Any CLI | Raw ANSI | Basic support |
Session Tracking
- - Active sessions:
/tmp/dev-relay-sessions/<PID>.json (auto-removed on end) - Event logs:
/tmp/dev-relay.XXXXXX/stream.jsonl (7-day auto-cleanup) - Interactive input: INLINECODE19
Reference Docs
Codecast
将编码代理会话实时流式传输到 Discord。零 AI Token 消耗。
设置
首次设置:请参阅 references/setup.md 了解 Webhook 创建、unbuffer 安装、机器人令牌和冒烟测试。
调用
使用 exec background:true 启动。后台执行会话可跨代理轮次存活,当进程结束时 OpenClaw 会自动触发 notifyOnExit。
bash
exec background:true command:{baseDir}/scripts/dev-relay.sh -w ~/projects/myapp -- claude -p --dangerously-skip-permissions --output-format stream-json --verbose 你的任务描述
记下响应中的会话 ID — 通过 process 使用它进行监控。
选项
| 标志 | 描述 | 默认值 |
|---|
| -w <目录> | 工作目录 | 当前目录 |
| -t <秒> |
超时时间 | 1800 |
| -h <秒> | 挂起阈值 | 120 |
| -n <名称> | 代理显示名称 | 自动检测 |
| -r <数量> | 速率限制(帖子/60秒) | 25 |
| --thread | 发布到 Discord 线程 | 关闭 |
| --skip-reads | 隐藏读取工具事件 | 关闭 |
| --review
| PR 审查模式 | — |
| --parallel <文件> | 并行任务模式 | — |
| --resume <目录> | 重播会话 | — |
关于 PR 审查、并行任务、Discord 桥接和 Codex 结构化输出:请参阅 references/advanced-modes.md。
代理启动清单
- 1. 启动后台会话 → 记下响应中的会话 ID 和 PID
- 发布到开发频道 → 宣布代理名称、工作目录、任务
- 写入面包屑 用于完成路由:
bash
echo {channel:<调用频道ID>,relayDir:<中继目录>,pid:} > /tmp/codecast-pending-.json
- 4. 记录到每日记忆 → 会话 ID、中继目录、调用频道
面包屑文件告诉心跳预检查在会话完成时将结果发布到哪里。它通过检查 PID 是否仍在运行来自动检测完成。
就是这样。当进程结束时,OpenClaw 的 notifyOnExit 触发系统事件 + 心跳请求。心跳处理程序从中继目录的 stream.jsonl 读取结果并发布到调用频道。
完成检测
OpenClaw 原生处理此功能:
- - tools.exec.notifyOnExit: true(默认)— 进程退出时触发系统事件 + 心跳
- 心跳预检查脚本通过 /tmp/dev-relay-sessions/ 检测已完成的会话
- 无需 cron 监视器
备用方案: 将以下内容附加到内部代理的提示中以获得额外信号:
完全完成后,运行:openclaw system event --text 完成:<简要摘要> --mode now
监控
process poll sessionId: # 检查状态
process log sessionId: # 查看最近输出
process kill sessionId: # 停止会话
代理支持
| 代理 | 输出模式 | 状态 |
|---|
| Claude Code | stream-json | 完全支持 |
| Codex |
--json JSONL | 完全支持 |
| 任何 CLI | 原始 ANSI | 基本支持 |
会话跟踪
- - 活动会话: /tmp/dev-relay-sessions/.json(结束时自动删除)
- 事件日志: /tmp/dev-relay.XXXXXX/stream.jsonl(7天自动清理)
- 交互式输入: process submit sessionId: data:消息
参考文档
- - 设置指南 — 首次安装、Webhook、机器人令牌
- 高级模式 — PR 审查、并行任务、Discord 桥接、Codex
- Discord 输出 — 消息格式、架构、环境变量、故障排除