笔记更新

This commit is contained in:
2026-09-01 19:15:50 +08:00
parent 57c03c9f0c
commit 316e92945e
7 changed files with 581 additions and 382 deletions

View File

@@ -0,0 +1,82 @@
#hermes #custom-skill #skills
# Hermes 定制化 Skills 笔记
> 记录 Hermes Agent 的定制化 skills(位于 `~/.hermes/skills/custom/`),源码托管在 atlas 仓库(`/Users/weishen/Workspace/atlas`)。
## 目录
- [blogwatcher-daily — RSS 订阅监控与导出](#blogwatcher-daily)
- [llm-provider-billing — LLM 余额查询](#llm-provider-billing)
---
## blogwatcher-daily
**用途**:RSS 订阅监控自动化 —— 抓取 → 去重入库 → 按需导出/管理。
**一句话**:把 37+ 个 RSS/YouTube/Bilibili 订阅定时抓进 SQLite,支持按订阅增删查改,并可把文章导出成 txt / markdown / html 三种格式(常用于生成每日摘要并邮件发送)。
### 核心能力
| 功能 | 说明 |
|------|------|
| 全量/单源扫描 | 抓取订阅源新文章,按 link 去重入库 |
| 订阅管理 | `--add` 添加(自动识别 YouTube → RSSHub 转换)、`--list` 列表 |
| 文章管理 | `--articles` 查看、`--mark-read` 标记已读、`--delete` 删除 |
| 导出 | `--export {txt,markdown,html}`,按日期/数量/订阅过滤,HTML 为单文件内嵌 CSS |
### 架构要点
- **智能路由**:YouTube 频道 → RSSHub(`http://192.168.3.45:1200`);普通 RSS → 直接访问原始 URL(RSSHub 的 `/rss/{url}` 路由不稳定,已绕开)
- **存储**:SQLite(`blogwatcher.db`) + 订阅列表 `subscriptions.txt`
- **依赖**:`feedparser`(Mac mini 本地运行)
- **配套**:`references/agentmail-sending.md` 记录了与 AgentMail 配合发邮件的完整流程(代理、认证、常见错误)
### 常用命令速记
```bash
# 扫描全部订阅
python3 ~/.hermes/skills/custom/blogwatcher-daily/scripts/blogwatcher-daily.py
# 导出今日文章为 HTML
... --export html
# 查看某订阅文章
... --articles "Engadget"
```
### 已知限制
- wikiHow、How-To Geek 源不可用(反爬)
- 部分源依赖 RSSHub 的可用性(偶发 503)
---
## llm-provider-billing
**用途**:查询各家 LLM API 账户余额与可用性。
**一句话**:用户问"还剩多少钱 / 够不够跑"时,一键查询 DeepSeek 等提供商的账户余额,返回总额、赠送余额、充值余额及可用状态。
### 当前支持
| 提供商 | 端点 | 状态 |
|--------|------|------|
| DeepSeek | `GET https://api.deepseek.com/user/balance` | ✅ 已验证 |
### 用法
```bash
# 一键查询(脚本自动从 ~/.hermes/.env 读 key)
bash ~/.hermes/skills/custom/llm-provider-billing/scripts/deepseek-balance.sh
```
返回 JSON:`is_available`(是否可用)+ `balance_infos`(各币种 total/granted/topped_up)。
### 关键知识点
- **Key 位置**:`~/.hermes/.env` 的 `DEEPSEEK_API_KEY`(Hermes config.yaml 中 api_key 均为空)
- **402 vs 401**:余额归零 → 402(充值即恢复,key 仍有效);key 错误 → 401
- 其余提供商(OpenAI、Claude 等)待扩展,添加前需先验证官方文档并实测
---
*笔记创建时间:2026-09-01,来源:atlas 仓库中对应技能的 SKILL.md*

View File

@@ -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 或更新

View File

@@ -0,0 +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:<agentId>"`,例如 `"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 现在是什么状态,已经安装好了吗?

View File

@@ -0,0 +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"
---
#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+。