From 316e92945eae775fe6244746e1ad7a39894a9cf6 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 1 Sep 2026 19:15:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=94=E8=AE=B0=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hermes/xingzhi/Hermes自定义技能说明.md | 114 ------- Project/blogwatcher-daily/项目需求.md | 10 + .../Hermes定制化Skills笔记.md | 1 + knowledgebase/n8n Docker 更新指南.md | 287 ++++++++++++++++ .../n8n 调用openclaw agents的工作流架构.md | 232 ++++++------- .../n8n调用hermes agents的工作流架构.md | 312 +++++++++--------- openclaw/🟠API Key.md | 7 +- 7 files changed, 581 insertions(+), 382 deletions(-) delete mode 100644 Hermes/xingzhi/Hermes自定义技能说明.md create mode 100644 Project/blogwatcher-daily/项目需求.md rename {Hermes/xingzhi => knowledgebase}/Hermes定制化Skills笔记.md (98%) create mode 100644 knowledgebase/n8n Docker 更新指南.md rename {raw/Agent => knowledgebase}/n8n 调用openclaw agents的工作流架构.md (95%) rename {raw/Agent => knowledgebase}/n8n调用hermes agents的工作流架构.md (73%) diff --git a/Hermes/xingzhi/Hermes自定义技能说明.md b/Hermes/xingzhi/Hermes自定义技能说明.md deleted file mode 100644 index 3f3baf00..00000000 --- a/Hermes/xingzhi/Hermes自定义技能说明.md +++ /dev/null @@ -1,114 +0,0 @@ -# Hermes 自定义技能说明 - -> 创建日期:2026-04-20 -> 更新日期:2026-04-20 - ---- - -## 技能总览 - -| 技能名 | 用途 | 调用方式 | -| --------------------------------- | --------------------------------------------- | ------------- | -| `blogwatcher-daily` | RSS 订阅监控 + 每日笔记生成 | cronjob | -| `claude-code-executor` | 用 TMUX 启动 Claude Code 并委托任务 | delegate_task | -| `claude-code-infographic-prompts` | 调用 Claude Code 的 baoyu-infographic 生成信息图提示词 | 手动调用 | -| `marker-pdf-to-markdown` | PDF 转 Markdown(marker_single 单文件 / marker 批量) | terminal | -| `whisper-audio-to-text` | 音频/视频转文字(Whisper) | terminal | - ---- - -## 1. claude-code-executor - -**路径**:`~/.hermes/skills/custom/claude-code-executor/SKILL.md` - -**用途**:通过 TMUX 启动 Claude Code(bypassPermissions 模式),发送任务指令,监控完成状态。 - -**触发关键词**:用户说"请用 Claude Code 做 xxx"、"用 Claude Code 执行 xxx" - -**核心流程**: -1. 启动 TMUX session `claude-task` -2. 等 8 秒后发送 Enter(bypassPermissions 确认) -3. 发送完整任务指令 -4. 监控 `done:` 输出 -5. 清理 tmux session - -**SSH 到 ubuntu2 命令**:`ssh ubuntu2` - ---- - -## 2. claude-code-infographic-build - -**路径**:`~/.hermes/skills/custom/claude-code-infographic-build/SKILL.md` - -**用途**:调用 Claude Code 的 `baoyu-infographic` 技能,为笔记内容生成信息图提示词,并进一步生成图片添加到原始笔记。 - -**完整三步流程**: -1. **步骤①**:baoyu-infographic 生成三部分提示词 → 保存到 Hermes/xingzhi/ -2. **步骤②**:在同一 Claude Code session 中,baoyu-imagine 生成图片 → 保存到 Hermes/xingzhi/ -3. **步骤③**:obsidian skill 将图片引用添加到原始笔记 - -**三部分提示词格式**: -1. **系统提示词** — Image Specifications + Core Principles -2. **风格锁定提示词** — Layout Guidelines + Style Guidelines -3. **内容结构提示词** — Text Requirements + 具体内容 - -**布局参考**(`~/.claude/skills/baoyu-infographic/references/layouts/`): -- `hub-spoke` — 适合 mind-map(标注了 "Best For: Mind maps") -- `circular-flow` — 适合循环流程 -- `venn` — 适合交集关系 - -**风格参考**(`~/.claude/skills/baoyu-infographic/references/styles/`): -- `corporate-memphis` — 商务孟菲斯风格 -- `chalkboard` — 粉笔黑板风格 -- `cyberpunk-neon` — 赛博霓虹风格 -- `warm` / `notion` / `minimal` / `blueprint` / `watercolor` / `elegant` - -**文件命名**:`[主题]-infographic-prompts-YYYY-MM-DD.md` - ---- - -## 3. blogwatcher-daily - -**路径**:`~/.hermes/skills/custom/blogwatcher-daily/SKILL.md` - -**用途**:RSS 订阅监控 + 每日笔记生成。使用 RSSHub + feedparser 抓取 31 个订阅,自动去重并存入 SQLite,新文章追加写入 Markdown 笔记。 - ---- - -## 4. marker-pdf-to-markdown - -**路径**:`~/.hermes/skills/custom/marker-pdf-to-markdown/SKILL.md` - -**用途**:PDF 转 Markdown/HTML/JSON 高精度工具,支持 OCR、表格、公式识别。 - -**安装位置**:ubuntu2 服务器(`ssh ubuntu2`) - -| 命令 | 用途 | 输入 | -|------|------|------| -| `marker_single` | 单文件转换,默认输出到 PDF 同目录 | 单个 PDF 文件 | -| `marker` | 批量转换,需文件夹输入 | 文件夹路径 | - -常用选项:`--output_dir`、`--output_format json/markdown/html`、`--no-images`、`--use_llm`、`--page_range` - ---- - -## 5. whisper-audio-to-text - -**路径**:`~/.hermes/skills/custom/whisper-audio-to-text/SKILL.md` - -**用途**:使用 OpenAI Whisper 将音频/视频转换为文字(转录或翻译)。 - -**安装位置**:Mac mini(GPU 加速)、ubuntu1、ubuntu2(CPU 模式),均直接可用。 - ---- - -## 相关 Claude Code 技能(`~/.claude/skills/`) - -| 技能名 | 用途 | -|--------|------| -| `baoyu-article-illustrator` | 文章配图(分析文章结构 + 生成配图) | -| `baoyu-infographic` | 信息图生成 | -| `baoyu-cover-image` | 封面图生成 | -| `fireworks-tech-graph` | 技术图生成 | - -这些 Claude Code 技能通过 `claude-code-executor` 启动 Claude Code CLI 后调用。 diff --git a/Project/blogwatcher-daily/项目需求.md b/Project/blogwatcher-daily/项目需求.md new file mode 100644 index 00000000..e19d3812 --- /dev/null +++ b/Project/blogwatcher-daily/项目需求.md @@ -0,0 +1,10 @@ + +## 2026-09-01 +1. 在subscription.txt里的订阅增加一个分类的栏位: + 比如: + AI技术|Tech With Tim|http://192.168.3.45:1200/youtube/channel/UC4JX40jDee_tINbkjycV4Sg + AI技术|灵姐说AI|http://192.168.3.45:1200/youtube/channel/UCMenHpvUet8myDntrTh7Ckw + 电子书|SaltTiger|https://salttiger.com/feed/ + 新闻热点|BBC中文网|http://192.168.3.45:1200/youtube/channel/UCb3TZ4SD_Ys3j4z0-8o6auA + +2. 导出文章时可根据分类导出,比如导出所有AI技术频道今日的文章 diff --git a/Hermes/xingzhi/Hermes定制化Skills笔记.md b/knowledgebase/Hermes定制化Skills笔记.md similarity index 98% rename from Hermes/xingzhi/Hermes定制化Skills笔记.md rename to knowledgebase/Hermes定制化Skills笔记.md index b962dd73..5b6d6602 100644 --- a/Hermes/xingzhi/Hermes定制化Skills笔记.md +++ b/knowledgebase/Hermes定制化Skills笔记.md @@ -1,3 +1,4 @@ +#hermes #custom-skill #skills # Hermes 定制化 Skills 笔记 > 记录 Hermes Agent 的定制化 skills(位于 `~/.hermes/skills/custom/`),源码托管在 atlas 仓库(`/Users/weishen/Workspace/atlas`)。 diff --git a/knowledgebase/n8n Docker 更新指南.md b/knowledgebase/n8n Docker 更新指南.md new file mode 100644 index 00000000..9548b129 --- /dev/null +++ b/knowledgebase/n8n Docker 更新指南.md @@ -0,0 +1,287 @@ +#n8n #docker #update +## 概述 + +本笔记记录 n8n 容器化部署的版本管理和更新方法,基于自定义 Dockerfile 多阶段构建(Python 3.13 任务运行器 + n8n 基础镜像)的场景。 + +--- + +## 问题分析 + +### 当前 Dockerfile 的版本不匹配问题 + +在原有配置中存在以下问题: + +```dockerfile +# 阶段 1:克隆特定版本的源码 +RUN git clone --depth 1 --branch n8n@2.13.4 \ + https://github.com/n8n-io/n8n.git /tmp/n8n-src + +# 阶段 2:使用最新的基础镜像 +FROM n8nio/n8n:latest # ← 潜在的版本不兼容 +``` + +**风险:** 源码版本(2.13.4)与运行时基础镜像版本不一致,可能导致: + +- Python 任务运行器与 n8n 核心不兼容 +- 环境变量和 API 变化 +- 功能异常或启动失败 + +### docker compose pull 的行为 + +```bash +$ docker compose pull +✔ postgres:16-alpine Pulled # ← 成功拉取(直接使用 image:) +✔ n8n Skipped # ← 跳过(使用 build: 需要重新构建) +``` + +**原因:** `docker compose pull` 仅处理 `image:` 字段的镜像,对于 `build:` 字段需要使用 `docker compose build`。 + +--- + +## 更新方法 + +### 方案 1:明确版本号(推荐) + +**优点:** + +- 版本控制清晰,可复现 +- 避免 `latest` 标签的不确定性 +- 便于回滚 + +**实施步骤:** + +1. **查询最新版本** + + ```bash + # 访问 GitHub Releases 页面 + # https://github.com/n8n-io/n8n/releases + # 或使用 git 查询 + git ls-remote --tags https://github.com/n8n-io/n8n.git | grep -oP 'n8n@\K[\d.]+' | tail -10 + ``` + +2. **更新 Dockerfile** + + ```dockerfile + FROM python:3.13-alpine AS python-builder + ENV HTTP_PROXY=http://127.0.0.1:10808 + ENV HTTPS_PROXY=http://127.0.0.1:10808 + RUN apk add --no-cache git + + # 更新版本号 + RUN git clone --depth 1 --branch n8n@2.14.2 \ + https://github.com/n8n-io/n8n.git /tmp/n8n-src + + # ... 阶段 1 其余部分 ... + + # 确保基础镜像版本匹配 + FROM n8nio/n8n:2.14.2 + USER root + # ... 阶段 2 其余部分 ... + ``` + +3. **重新构建和启动** + + ```bash + # 清除缓存重建 + proxychains docker compose build --no-cache n8n + + # 停止旧容器 + docker compose down + + # 启动新容器 + docker compose up -d + + # 查看日志 + docker compose logs -f n8n + ``` + + +### 方案 2:使用 latest 标签(快速更新,不推荐用于生产) + +**优点:** + +- 快速获取最新功能 +- 简化维护 + +**缺点:** + +- 版本不可控 +- 可能的功能破坏性变化 +- 难以追踪问题 + +**实施步骤:** + +```dockerfile +FROM python:3.13-alpine AS python-builder +ENV HTTP_PROXY=http://127.0.0.1:10808 +ENV HTTPS_PROXY=http://127.0.0.1:10808 +RUN apk add --no-cache git + +# 移除 --branch 参数,使用最新源码 +RUN git clone --depth 1 https://github.com/n8n-io/n8n.git /tmp/n8n-src + +# ... 阶段 1 其余部分 ... + +FROM n8nio/n8n:latest # ← 保持 latest +USER root +# ... 阶段 2 其余部分 ... +``` + +然后执行: + +```bash +proxychains docker compose build --no-cache n8n +docker compose down && docker compose up -d +``` + +--- + +## 最佳实践 + +### 1. 版本管理 + +|环境|建议|说明| +|---|---|---| +|生产|明确版本号|便于故障追踪和回滚| +|测试|测试多个版本|在升级前验证兼容性| +|开发|可使用 latest|快速迭代原型| + +### 2. 构建优化 + +```dockerfile +# 代理配置一致性 +# 阶段 1 和 docker-compose.yml 应保持一致 +# Dockerfile 中:127.0.0.1:10808(本地) +# docker-compose.yml 中:host.docker.internal:10808(容器内) + +# 原因: +# - Dockerfile 在本地构建时,127.0.0.1 指向本机 +# - 容器运行时,host.docker.internal 指向宿主机 +``` + +### 3. 版本检查 + +更新后验证版本: + +```bash +# 进入容器 +docker compose exec n8n sh + +# 查看 n8n 版本 +npm list n8n + +# 查看 Python 版本 +python3 --version + +# 查看任务运行器状态 +ls -la /usr/local/lib/node_modules/@n8n/task-runner-python/ +``` + +--- + +## 常见问题 + +### Q1: docker compose pull 没有更新 n8n + +**A:** 因为你使用了 `build:` 而不是 `image:`。需要用: + +```bash +docker compose build --no-cache n8n +``` + +### Q2: 更新后 n8n 启动失败 + +**A:** 检查以下几点: + +```bash +# 查看错误日志 +docker compose logs n8n + +# 常见原因: +# 1. 版本不兼配 → 确保 Dockerfile 两阶段版本一致 +# 2. 环境变量过期 → 查阅新版本的 CHANGELOG +# 3. 数据库迁移失败 → 检查 PostgreSQL 连接和权限 +``` + +### Q3: 如何回滚到前一个版本 + +**A:** + +```bash +# 1. 修改 Dockerfile 版本号 +# 2. 重新构建 +docker compose build --no-cache n8n + +# 3. 清理数据后重启(如需) +docker compose down +docker compose up -d +``` + +### Q4: 代理在构建时不生效 + +**A:** Docker 构建使用的是宿主机网络,`127.0.0.1` 应该指向代理服务。确保: + +```bash +# 1. 代理服务运行中 +# 2. 端口 10808 可访问 +# 3. 检查防火墙规则 + +# 测试连接 +curl -x http://127.0.0.1:10808 https://github.com -I +``` + +--- + +## 更新清单 + +更新前: + +- [ ] 备份 `.env` 和 `docker-compose.yml` +- [ ] 记录当前 n8n 版本 +- [ ] 查看新版本的 CHANGELOG(breaking changes) +- [ ] 确保代理正常工作 + +更新过程: + +- [ ] 更新 Dockerfile 版本号(两处) +- [ ] 执行 `docker compose build --no-cache n8n` +- [ ] 停止旧容器:`docker compose down` +- [ ] 启动新容器:`docker compose up -d` + +更新后: + +- [ ] 查看 n8n 日志:`docker compose logs n8n` +- [ ] 检查 Web UI 是否可访问(https://n8n.ishenwei.online) +- [ ] 验证现有工作流是否正常运行 +- [ ] 检查 Python 任务运行器功能 + +--- + +## 相关命令速查 + +```bash +# 查看构建日志(详细) +docker compose build --no-cache n8n --progress=plain + +# 清理所有 n8n 相关镜像和容器 +docker compose down -v +docker image rm n8n:* + +# 重新完整部署 +docker compose down -v && docker compose up -d --build + +# 进入 n8n 容器交互式 shell +docker compose exec n8n sh + +# 查看实时日志 +docker compose logs -f n8n + +# 仅查看最后 100 行日志 +docker compose logs n8n -n 100 +``` + +--- + +**最后更新:** 2026-09-01 +**当前配置版本:** n8n@2.13.4 +**推荐升级版本:** n8n@2.14.x 或更新 \ No newline at end of file diff --git a/raw/Agent/n8n 调用openclaw agents的工作流架构.md b/knowledgebase/n8n 调用openclaw agents的工作流架构.md similarity index 95% rename from raw/Agent/n8n 调用openclaw agents的工作流架构.md rename to knowledgebase/n8n 调用openclaw agents的工作流架构.md index 7c2cd48c..0854be6f 100644 --- a/raw/Agent/n8n 调用openclaw agents的工作流架构.md +++ b/knowledgebase/n8n 调用openclaw agents的工作流架构.md @@ -1,117 +1,117 @@ - -#n8n #openclaw #agents -## OpenClaw API Server 配置 - -OpenClaw 的 Gateway 可以提供 OpenAI 兼容的 [Fossies](https://fossies.org/linux/openclaw/docs/gateway/openai-http-api.md) Chat Completions 端点,**默认是关闭的**,需要在配置中手动开启。 - -### 第一步:开启端点 - -编辑 `~/.openclaw/openclaw.json`,添加: - -json - -```json -{ - "gateway": { - "port": 18789, - "mode": "local", - "bind": "lan", - "auth": { - "mode": "token", - "token": "fb97035a1b62a4f29e5cb2f9ac131bd37f021a10823f66b0" - }, - "tailscale": { - "mode": "off", - "resetOnExit": false - }, - "remote": { - "url": "ws://192.168.3.189:18789" - }, - "nodes": { - "denyCommands": [ - "camera.snap", - "camera.clip", - "screen.record", - "contacts.add", - "calendar.add", - "reminders.add", - "sms.send" - ] - }, - "controlUi": { - "allowInsecureAuth": true - }, - "http": { - "endpoints": { - "chatCompletions": { - "enabled": true - } - } - } - } -} -``` - -> `host: "0.0.0.0"` 是为了让 Docker 容器能访问,和 Hermes 同理。 - -然后重启 Gateway: - -bash - -```bash -openclaw gateway restart -``` - -验证: - -bash - -```bash -curl http://localhost:18789/v1/health -``` - ---- - -## 与 Hermes 的关键区别 - -|项目|Hermes|OpenClaw| -|---|---|---| -|默认端口|`8642`|**`18789`**| -|Agent 指定方式|`"model": "hermes-agent"`|**`"model": "openclaw:main"`**| -|默认是否开启|✅ 开启|❌ 需手动开启| - -OpenClaw 通过 `model` 字段来指定 Agent ID,格式为 `"openclaw:"`,例如 `"openclaw:main"` 或 `"openclaw:beta"`。 [OpenClaw AI](https://openclaw-ai.com/en/docs/gateway/openai-http-api/) - ---- - -## 在 n8n 中调用 OpenClaw - -json - -```json -{ - "model": "openclaw:main", - "messages": [ - {"role": "user", "content": "{{ $json.input }}"} - ] -} -``` - -| 字段 | 值 | -| ------------- | ------------------------------------------------ | -| URL | `http://192.168.3.189:18789/v1/chat/completions` | -| Authorization | `Bearer your-secret-key` | - ---- - -## 最终架构总结 - -``` -n8n (Docker) - │ - ├─ POST 192.168.3.189:8642 → Hermes Agent (port 8642) - │ - └─ POST 192.168.3.189:18789 → OpenClaw Agent (port 18789) -``` - + +#n8n #openclaw #agents +## OpenClaw API Server 配置 + +OpenClaw 的 Gateway 可以提供 OpenAI 兼容的 [Fossies](https://fossies.org/linux/openclaw/docs/gateway/openai-http-api.md) Chat Completions 端点,**默认是关闭的**,需要在配置中手动开启。 + +### 第一步:开启端点 + +编辑 `~/.openclaw/openclaw.json`,添加: + +json + +```json +{ + "gateway": { + "port": 18789, + "mode": "local", + "bind": "lan", + "auth": { + "mode": "token", + "token": "fb97035a1b62a4f29e5cb2f9ac131bd37f021a10823f66b0" + }, + "tailscale": { + "mode": "off", + "resetOnExit": false + }, + "remote": { + "url": "ws://192.168.3.189:18789" + }, + "nodes": { + "denyCommands": [ + "camera.snap", + "camera.clip", + "screen.record", + "contacts.add", + "calendar.add", + "reminders.add", + "sms.send" + ] + }, + "controlUi": { + "allowInsecureAuth": true + }, + "http": { + "endpoints": { + "chatCompletions": { + "enabled": true + } + } + } + } +} +``` + +> `host: "0.0.0.0"` 是为了让 Docker 容器能访问,和 Hermes 同理。 + +然后重启 Gateway: + +bash + +```bash +openclaw gateway restart +``` + +验证: + +bash + +```bash +curl http://localhost:18789/v1/health +``` + +--- + +## 与 Hermes 的关键区别 + +|项目|Hermes|OpenClaw| +|---|---|---| +|默认端口|`8642`|**`18789`**| +|Agent 指定方式|`"model": "hermes-agent"`|**`"model": "openclaw:main"`**| +|默认是否开启|✅ 开启|❌ 需手动开启| + +OpenClaw 通过 `model` 字段来指定 Agent ID,格式为 `"openclaw:"`,例如 `"openclaw:main"` 或 `"openclaw:beta"`。 [OpenClaw AI](https://openclaw-ai.com/en/docs/gateway/openai-http-api/) + +--- + +## 在 n8n 中调用 OpenClaw + +json + +```json +{ + "model": "openclaw:main", + "messages": [ + {"role": "user", "content": "{{ $json.input }}"} + ] +} +``` + +| 字段 | 值 | +| ------------- | ------------------------------------------------ | +| URL | `http://192.168.3.189:18789/v1/chat/completions` | +| Authorization | `Bearer your-secret-key` | + +--- + +## 最终架构总结 + +``` +n8n (Docker) + │ + ├─ POST 192.168.3.189:8642 → Hermes Agent (port 8642) + │ + └─ POST 192.168.3.189:18789 → OpenClaw Agent (port 18789) +``` + 两个都用同一个局域网 IP,只是端口不同,在 n8n 里分别建两个 HTTP Request 节点就可以了。你的 OpenClaw 现在是什么状态,已经安装好了吗? \ No newline at end of file diff --git a/raw/Agent/n8n调用hermes agents的工作流架构.md b/knowledgebase/n8n调用hermes agents的工作流架构.md similarity index 73% rename from raw/Agent/n8n调用hermes agents的工作流架构.md rename to knowledgebase/n8n调用hermes agents的工作流架构.md index 75080238..f1800c4d 100644 --- a/raw/Agent/n8n调用hermes agents的工作流架构.md +++ b/knowledgebase/n8n调用hermes agents的工作流架构.md @@ -1,152 +1,162 @@ ---- -title: "n8n调用openclaw/hermes agents的工作流架构" -source: "https://claude.ai/chat/a18d1fa2-7e98-4f86-bac0-1167281eb151" -author: -published: -created: 2026-04-20 -description: "Claude conversation with 8 messages" -tags: - - "clippings" ---- -好消息!**Hermes Agent 内置了 OpenAI 兼容的 API Server**,完全不需要额外写任何代码,直接配置开启就行。 - ---- - -## 第一步:开启 Hermes API Server - -Hermes 的 API Server 会将 hermes-agent 暴露为一个 OpenAI 兼容的 HTTP 端点,默认端口是 **8642**。 [GitHub](https://github.com/NousResearch/hermes-agent/blob/main/website/docs/user-guide/features/api-server.md) - -bash - -```bash -# 开启 API Server -hermes config set API_SERVER_ENABLED true - -# 设置一个访问密钥(必须) -hermes config set API_SERVER_KEY your-secret-key - -# 启动 Gateway(API Server 随之运行) -hermes gateway install # 安装为系统服务 -hermes gateway start # 启动 -``` - -验证是否正常运行: - -bash - -```bash -curl http://localhost:8642/v1/health -# 返回 {"status": "ok"} 即成功 -``` - -```bash -weishen@WeideMac-mini ~ % hermes config set API_SERVER_ENABLED true -✓ Set API_SERVER_ENABLED = True in /Users/weishen/.hermes/config.yaml -weishen@WeideMac-mini ~ % nano /Users/weishen/.hermes/config.yaml -weishen@WeideMac-mini ~ % hermes config set API_SERVER_KEY 01KPN2YYSEV56BZQSQX9XGW6VH -✓ Set API_SERVER_KEY = 01KPN2YYSEV56BZQSQX9XGW6VH in /Users/weishen/.hermes/config.yaml -weishen@WeideMac-mini ~ % nano /Users/weishen/.hermes/config.yaml -weishen@WeideMac-mini ~ % hermes gateway restart -✓ Service restarted -weishen@WeideMac-mini ~ % curl http://localhost:8642/v1/health -{"status": "ok", "platform": "hermes-agent"}% weishen@WeideMac-mini ~ % curl http://localhost:8642/v1/chat/completions \ - -H "Authorization: Bearer 01KPN2YYSEV56BZQSQX9XGW6VH" \ - -H "Content-Type: application/json" \ - -d '{"model": "hermes-agent", "messages": [{"role": "user", "content": "Hello!"}]}' -{"id": "chatcmpl-e1569aadb12b4e36aedd9198b29e1", "object": "chat.completion", "created": 1776677020, "model": "hermes-agent", "choices": [{"index": 0, "message": {"role": "assistant", "content": "Hello! How can I help today?"}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 11458, "completion_tokens": 63, "total_tokens": 11521}}% -``` ---- - -## 第二步:为每个 Agent 创建独立 Profile - -你可以用 Profile 的方式为每个用户/角色创建独立的 Hermes 实例,每个 profile 跑在不同端口,配置独立的 API key。 [GitHub](https://github.com/NousResearch/hermes-agent/blob/main/website/docs/user-guide/features/api-server.md) - -bash - -```bash -# 创建三个专用 Agent(以任务分工为例) -hermes profile create agent-researcher -hermes profile create agent-writer -hermes profile create agent-coder - -# 分别配置端口和 key -hermes -p agent-researcher config set API_SERVER_ENABLED true -hermes -p agent-researcher config set API_SERVER_PORT 8643 -hermes -p agent-researcher config set API_SERVER_KEY key-researcher - -hermes -p agent-writer config set API_SERVER_ENABLED true -hermes -p agent-writer config set API_SERVER_PORT 8644 -hermes -p agent-writer config set API_SERVER_KEY key-writer - -hermes -p agent-coder config set API_SERVER_ENABLED true -hermes -p agent-coder config set API_SERVER_PORT 8645 -hermes -p agent-coder config set API_SERVER_KEY key-coder - -# 分别启动三个 gateway -hermes -p agent-researcher gateway & -hermes -p agent-writer gateway & -hermes -p agent-coder gateway & -``` - ---- - -## 第三步:在 n8n 中调用 - -每个 Agent 都是标准的 OpenAI 格式接口,在 n8n 中用 **HTTP Request 节点**: - -|字段|填写内容| -|---|---| -|Method|POST| -|URL|`http://localhost:8643/v1/chat/completions`| -|Header: Authorization|`Bearer key-researcher`| -|Header: Content-Type|`application/json`| - -Body(JSON): - -json - -```json -{ - "model": "agent-researcher", - "messages": [ - { - "role": "system", - "content": "你是一个专门负责网络调研的Agent,请搜索并总结信息" - }, - { - "role": "user", - "content": "{{ $json.task }}" - } - ] -} -``` - ---- - -## 多轮对话保持上下文(重要) - -v0.7.0 起 API Server 支持通过 `X-Hermes-Session-Id` header 来保持会话连续性,让 chat-completions 客户端也能跨请求共享同一个 session。 [GitHub](https://github.com/mudrii/hermes-agent-docs) - -在 n8n 的 HTTP Request 节点 Header 中加一行: - -``` -X-Hermes-Session-Id: my-workflow-session-001 -``` - -这样同一个工作流里的多次调用会共享上下文,非常适合需要多步推理的任务链。 - ---- - -## 完整架构示意 - -``` -n8n Workflow - │ - ├─ [HTTP Request] → localhost:8643 (agent-researcher) → 搜索/调研 - │ - ├─ [HTTP Request] → localhost:8644 (agent-writer) → 内容生成 - │ - └─ [HTTP Request] → localhost:8645 (agent-coder) → 代码任务 -``` - +--- +title: "n8n调用openclaw/hermes agents的工作流架构" +source: "https://claude.ai/chat/a18d1fa2-7e98-4f86-bac0-1167281eb151" +author: +published: +created: 2026-04-20 +description: "Claude conversation with 8 messages" +tags: + - "clippings" +--- +#n8n #hermes #agents + +好消息!**Hermes Agent 内置了 OpenAI 兼容的 API Server**,完全不需要额外写任何代码,直接配置开启就行。 + +--- + +## 第一步:开启 Hermes API Server + +Hermes 的 API Server 会将 hermes-agent 暴露为一个 OpenAI 兼容的 HTTP 端点,默认端口是 **8642**。 [GitHub](https://github.com/NousResearch/hermes-agent/blob/main/website/docs/user-guide/features/api-server.md) + +bash + +```bash +# 开启 API Server +hermes config set API_SERVER_ENABLED true + +# 设置一个访问密钥(必须) +hermes config set API_SERVER_KEY your-secret-key + +# 启动 Gateway(API Server 随之运行) +hermes gateway install # 安装为系统服务 +hermes gateway start # 启动 +``` + +验证是否正常运行: + +bash + +```bash +curl http://192.168.3.189:8642/v1/health + +{"status": "ok", "platform": "hermes-agent", "version": "0.20.6"} +``` + +```bash +weishen@WeideMac-mini ~ % hermes config set API_SERVER_ENABLED true +✓ Set API_SERVER_ENABLED = True in /Users/weishen/.hermes/config.yaml +weishen@WeideMac-mini ~ % nano /Users/weishen/.hermes/config.yaml +weishen@WeideMac-mini ~ % hermes config set API_SERVER_KEY 01KPN2YYSEV56BZQSQX9XGW6VH +✓ Set API_SERVER_KEY = 01KPN2YYSEV56BZQSQX9XGW6VH in /Users/weishen/.hermes/config.yaml +weishen@WeideMac-mini ~ % nano /Users/weishen/.hermes/config.yaml + + +API_SERVER_ENABLED: true +API_SERVER_HOST: 0.0.0.0 +API_SERVER_KEY: 01KPN2YYSEV56BZQSQX9XGW6VH + + + +weishen@WeideMac-mini ~ % hermes gateway restart +✓ Service restarted +weishen@WeideMac-mini ~ % curl http://192.168.3.189:8642/v1/health +{"status": "ok", "platform": "hermes-agent", "version": "0.20.6"}% shenwei@WEI-THINKBOOK:/mnt/c/Users/ishen$ curl http://192.168.3.189:8642/v1/chat/completions -H "Authorization: Bearer 01KPN2YYSEV56BZQSQX9XGW6VH" -H "Content-Type: application/json" -d '{"model": "hermes-agent", "messages": [{"role": "user", "content": "Hello!"}]}' + + +{"id": "chatcmpl-15f9eabe682948149268b3bbb6f24", "object": "chat.completion", "created": 1788239643, "model": "hermes-agent", "choices": [{"index": 0, "message": {"role": "assistant", "content": "Hello! How can I help you today?"}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 15297, "completion_tokens": 67, "total_tokens": 15364}}(base) +``` +--- + +## 第二步:为每个 Agent 创建独立 Profile + +你可以用 Profile 的方式为每个用户/角色创建独立的 Hermes 实例,每个 profile 跑在不同端口,配置独立的 API key。 [GitHub](https://github.com/NousResearch/hermes-agent/blob/main/website/docs/user-guide/features/api-server.md) + +bash + +```bash +# 创建三个专用 Agent(以任务分工为例) +hermes profile create agent-researcher +hermes profile create agent-writer +hermes profile create agent-coder + +# 分别配置端口和 key +hermes -p agent-researcher config set API_SERVER_ENABLED true +hermes -p agent-researcher config set API_SERVER_PORT 8643 +hermes -p agent-researcher config set API_SERVER_KEY key-researcher + +hermes -p agent-writer config set API_SERVER_ENABLED true +hermes -p agent-writer config set API_SERVER_PORT 8644 +hermes -p agent-writer config set API_SERVER_KEY key-writer + +hermes -p agent-coder config set API_SERVER_ENABLED true +hermes -p agent-coder config set API_SERVER_PORT 8645 +hermes -p agent-coder config set API_SERVER_KEY key-coder + +# 分别启动三个 gateway +hermes -p agent-researcher gateway & +hermes -p agent-writer gateway & +hermes -p agent-coder gateway & +``` + +--- + +## 第三步:在 n8n 中调用 + +每个 Agent 都是标准的 OpenAI 格式接口,在 n8n 中用 **HTTP Request 节点**: + +| 字段 | 填写内容 | +| --------------------- | ------------------------------------------- | +| Method | POST | +| URL | `http://localhost:8643/v1/chat/completions` | +| Header: Authorization | `Bearer key-researcher` | +| Header: Content-Type | `application/json` | + +Body(JSON): + +json + +```json +{ + "model": "agent-researcher", + "messages": [ + { + "role": "system", + "content": "你是一个专门负责网络调研的Agent,请搜索并总结信息" + }, + { + "role": "user", + "content": "{{ $json.task }}" + } + ] +} +``` + +--- + +## 多轮对话保持上下文(重要) + +v0.7.0 起 API Server 支持通过 `X-Hermes-Session-Id` header 来保持会话连续性,让 chat-completions 客户端也能跨请求共享同一个 session。 [GitHub](https://github.com/mudrii/hermes-agent-docs) + +在 n8n 的 HTTP Request 节点 Header 中加一行: + +``` +X-Hermes-Session-Id: my-workflow-session-001 +``` + +这样同一个工作流里的多次调用会共享上下文,非常适合需要多步推理的任务链。 + +--- + +## 完整架构示意 + +``` +n8n Workflow + │ + ├─ [HTTP Request] → localhost:8643 (agent-researcher) → 搜索/调研 + │ + ├─ [HTTP Request] → localhost:8644 (agent-writer) → 内容生成 + │ + └─ [HTTP Request] → localhost:8645 (agent-coder) → 代码任务 +``` + 这套方案完全原生支持,不需要任何额外中间件。你现在的 Hermes 是哪个版本?可以用 `hermes version` 确认一下,部分特性需要 v0.4.0+。 \ No newline at end of file diff --git a/openclaw/🟠API Key.md b/openclaw/🟠API Key.md index 3170f1c7..0edcf9fc 100644 --- a/openclaw/🟠API Key.md +++ b/openclaw/🟠API Key.md @@ -1,4 +1,5 @@ -#api-key #deepseek #gemini #google #aws #x #notion #n8n #github #wavespeed #siliconflow #airtable #brightdata #telegram +#api-key #deepseek #gemini #google #aws #x #notion #n8n #github #wavespeed #siliconflow #airtable #brightdata #telegram #kimi + ```table-of-contents title: @@ -274,3 +275,7 @@ BJVys7j427n0xgLOX7AmCu2evMBbJzBVtcukQY6hKak | API key | e87634afb449ad908bc2274e2b91c49b | | Shared secret | ffe8f752d237269f00a5fc2db0489640 | | Registered to | ishenwei | +## Kimi +``` +sk-ADsNHdojiQ9Dzo72MSsP0AXAuqsWkHXGdRL9rn4jryIgA3GH +``` \ No newline at end of file