海流 是 AI Skill Hub 本期精选n8n工作流之一。综合评分 8.0 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
海流 是一款基于 TypeScript 开发的开源工具,专注于 n8n、ai、agent 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
海流 是一款基于 TypeScript 开发的开源工具,专注于 n8n、ai、agent 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一:npm 全局安装 npm install -g haiflow # 方式二:npx 直接运行(无需安装) npx haiflow --help # 方式三:项目依赖安装 npm install haiflow # 方式四:从源码运行 git clone https://github.com/andersonaguiar/haiflow cd haiflow npm install npm start
# 命令行使用
haiflow --help
# 基本用法
haiflow [options] <input>
# Node.js 代码中使用
const haiflow = require('haiflow');
const result = await haiflow.run(options);
console.log(result);
// n8n 工作流配置步骤 // 1. 在 n8n 中点击 "Import Workflow" // 2. 粘贴 JSON 文件内容或上传文件 // 3. 配置必要的 Credentials: // - Settings → Credentials → New // - 选择对应服务类型填写 API Key // 4. 激活工作流 (Toggle ON) // 5. 通过 Webhook 或定时触发器运行
hooks · ai · flow
Run Claude Code as a headless AI agent over HTTP — no API key costs, no SDK, just your existing Claude Code subscription.
Haiflow wraps Claude Code in tmux sessions and exposes a REST API to trigger prompts, queue work, and capture responses. Automate anything you can do in Claude Code — code generation, refactoring, bug triage, daily reports — from any HTTP client.
Why not the Claude API? Claude Code includes tool use, file access, git integration, and your custom skills out of the box. Haiflow lets you automate all of that via HTTP without paying per-token API costs. Use n8n, cron, webhooks, or any automation tool to drive it.

POST /trigger ───┐
│ ┌────────────────┐
┌───▼───┐ │ tmux session │
│ Queue ├───>│ (claude) │
│ (FIFO)│ └───────┬────────┘
└───────┘ │
hooks fire on
session events
│
┌───────▼────────┐
│ Responses │
└───────┬────────┘
│
GET /responses/:id <──────────────┤
│
GET /responses/:id/stream <───────┘ (SSE)
docker run -d -p 6379:6379 redis.bun install
Haiflow uses Claude Code hooks to track session state. The setup command merges hook config into ~/.claude/settings.json:
bun run setup
The hooks are thin HTTP forwarders — they POST Claude Code events to the haiflow server. If the server isn't running, they silently no-op. They won't interfere with non-orchestrated Claude sessions (the server ignores unknown session IDs).
pipeline.json in your HAIFLOW_DATA_DIR (default /tmp/haiflow):{
"topics": {
"design.ready": {
"description": "Design agent completed its analysis",
"subscribers": [
{
"session": "developer",
"promptTemplate": "Implement this design:\n\n{{message}}"
}
]
},
"code.ready": {
"subscribers": [
{
"session": "code-reviewer",
"promptTemplate": "Review these changes:\n\n{{message}}"
}
]
}
},
"emitters": {
"design-agent": ["design.ready"],
"developer": ["code.ready"]
}
}
```bash
Haiflow works with any tool that can make HTTP requests. Here are a few examples:
Import the chained calc workflow from examples/chained-calc/: - chained-calc-step1.json — Step 1: calculate 2+2 - chained-calc-step2.json — Step 2: multiply result by 5 - chained-calc-step3.json — Step 3: multiply result by 10 - pipeline-calc-chain.json — Pipeline configuration that wires them together
bun run dev # starts server with hot reload ```
cp .env.example .env
| Variable | Default | Description |
|---|---|---|
PORT | 3333 | HTTP server port |
HAIFLOW_ENV | development | Deployment environment (development/production; falls back to NODE_ENV). In production, haiflow fails closed at boot on an insecure exposure and rejects a weak/placeholder key. Dev is permissive (no tunnel required). |
HAIFLOW_HOST | 127.0.0.1 | Bind address. Loopback by default so the origin is only reachable through a front proxy/tunnel — an identity layer can't be bypassed by hitting the port directly. A public bind in production needs HAIFLOW_ALLOW_PUBLIC_BIND=true. See [DEPLOYMENT.md](DEPLOYMENT.md). |
HAIFLOW_ALLOW_PUBLIC_BIND | false | Acknowledge a public bind (0.0.0.0/LAN/public IP) in production — you firewall the port and run your own identity layer. Without it, production refuses to start when bound publicly. |
HAIFLOW_DATA_DIR | /tmp/haiflow | Directory for session state, queues, and responses |
HAIFLOW_PORT | 3333 | Port used by hook scripts (set if different from PORT) |
HAIFLOW_API_KEY | — | **Required.** Any string you choose — this is your own secret, not a paid key. In production it must be ≥24 chars and not a placeholder. |
HAIFLOW_CWD | — | When set, every session is forced to use this cwd. The cwd field in /session/start request bodies is ignored (a warning is logged if it differs). |
HAIFLOW_ALLOW_REQUEST_CWD | true | When false, /session/start rejects requests that try to set their own cwd — HAIFLOW_CWD must be set on the server instead. |
HAIFLOW_GUARDRAILS | true | Installs ~/.claude/skills/haiflow-guardrails/SKILL.md on server boot and injects /haiflow-guardrails into each new tmux session. The skill instructs Claude to refuse paths outside cwd, refuse to read secrets, and refuse network exfiltration. |
REDIS_URL | redis://localhost:6379 | **Required.** Redis URL for event persistence and delivery tracking |
HAIFLOW_START_READY_TIMEOUT_MS | 15000 | How long /session/start waits for the SessionStart hook to link a Claude session id before failing (a session that never links would silently drop every response — usually means hooks aren't wired) |
HAIFLOW_ALLOW_TRIGGER_CALLBACK | false | Enables the per-/trigger callbackUrl completion webhook. Off by default because an arbitrary callback URL is an SSRF surface |
HAIFLOW_CALLBACK_ALLOW_HOSTS | — | Optional comma-separated host allowlist for callbackUrl. With it set, callbacks to any other host are rejected with 400 |
N8N_API_KEY | — | n8n API key for workflow integration |
HAIFLOW_USAGE_ALERT_TOKENS | — | When set, GET /usage/window flags alert: true once the rolling 5h token total crosses it (alert-only, never throttles) |
HAIFLOW_TASK_TIMEOUT_SEC | 0 | Optional hard per-task timeout. 0 disables it. The watchdog flags tasks that exceed it |
HAIFLOW_WAITING_GRACE_SEC | 120 | How long a session flagged waiting by Claude's Notification hook may stay blocked before the watchdog acts |
HAIFLOW_WATCHDOG_RECOVER | false | When true, the watchdog auto-recovers a wedged session (Escape, mark timed_out, drain). Default alert-only |
HAIFLOW_MAP_MAX_ITEMS | 200 | Max items one POST /map call may fan across a pool |
HAIFLOW_MAP_TIMEOUT_SEC | 1800 | How long a map run waits for stragglers before the reducer fires with partial results |
curl -s -H "Authorization: Bearer $HAIFLOW_API_KEY" \ http://localhost:3333/pipeline | jq .
See API.md for the full API reference: all endpoints, parameters, and examples. The same surface is also published as an interactive reference in the docs site.
Chain agents together with event-driven pub/sub. Each agent subscribes to topics it cares about and emits events when done — no hardcoded dependencies between agents.
Design Agent ──emit──▶ design.ready ──subscribe──▶ Developer Agent
Developer ──emit──▶ code.ready ──subscribe──▶ Code Reviewer
Reviewer ──emit──▶ review.done ──subscribe──▶ QA Agent
See Pipeline for setup.
The pipeline system lets you chain agents together using pub/sub topics. When an agent finishes a task, haiflow automatically emits its output to configured topics. Other agents subscribed to those topics receive the output as their next prompt.
curl -X POST http://localhost:3333/trigger \ -H "Authorization: Bearer $HAIFLOW_API_KEY" \ -H "Content-Type: application/json" \ -d '{"prompt": "Analyse the Figma design at ...", "session": "design-agent"}' ```
haiflow 是一个基于 Hooks、AI 与 Flow 构建的自动化编排框架。它通过监听 Claude Code 的会话状态,实现 AI Agent 之间的事件驱动协作,让开发者能够构建复杂的 AI 工作流。
运行 haiflow 需要安装 Bun (v1.2.3+)、tmux 和 jq。此外,必须安装 Claude Code CLI 以支持 Hook 功能。如果需要实现事件持久化和更高级的数据处理,建议配置 Redis 作为可选组件。
首先通过 `bun install` 安装项目依赖。随后,运行 `bun run setup` 命令来安装 Claude Code hooks。该命令会自动将 Hook 配置合并到您的 `~/.claude/settings.json` 中。这些 Hooks 作为轻量级的 HTTP 转发器,会将 Claude Code 的事件 POST 到 haiflow 服务器,且在服务器未运行时会自动静默处理,不会干扰常规的 Claude 会话。
通过在 `HAIFLOW_DATA_DIR`(默认 `/tmp/haiflow`)中创建 `pipeline.json` 来定义工作流。您可以利用 pub/sub 机制将不同的 Agent 连接起来。例如,当 Design Agent 完成任务并发布 `design.ready` 事件时,订阅了该主题的 Developer Agent 会自动接收输出并作为其下一步的 Prompt。此外,haiflow 也支持通过 HTTP 请求与 n8n 等外部工具进行集成。
项目通过 `.env` 文件进行环境配置。您可以根据需要修改 `PORT`(HTTP 服务端口)、`HAIFLOW_DATA_DIR`(会话状态、队列和响应的存储目录)以及 `HAIFLOW_API_KEY`(用于 API 鉴权的密钥)。在开发模式下,可以使用 `bun run dev` 启动支持热重载的服务端。
haiflow 提供了一套完整的 RESTful API 接口。开发者可以通过携带 `HAIFLOW_API_KEY` 的 HTTP 请求来触发 Pipeline(例如使用 `/trigger` 端点启动 Agent 链),或者通过 `/pipeline` 端点查看当前的 Pipeline 配置、Redis 状态及近期发生的事件流。详细的参数说明请参考 API.md。
haiflow 的核心是基于事件驱动的 Agent Pipeline 系统。它通过发布/订阅(pub/sub)模式将多个 Agent 串联。每个 Agent 只需订阅感兴趣的 Topic,并在完成任务后发出相应的事件,从而实现 Agent 之间的解耦协作,无需在代码中硬编码 Agent 之间的依赖关系。
高质量的开源n8n工作流项目
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,海流 在n8n工作流赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | haiflow |
| 原始描述 | 开源n8n工作流:Run Claude Code as a headless AI agent over HTTP — hooks + ai + flow. Automate c。⭐8 · TypeScript |
| Topics | n8naiagentai-automation |
| GitHub | https://github.com/andersonaguiar/haiflow |
| License | MIT |
| 语言 | TypeScript |
收录时间:2026-06-24 · 更新时间:2026-06-26 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端