2026-04-16 周四
OpenClaw 源码学习 Day 7-8 完成 + Agent Identity Management + Workflow Enforcement
🦐 OpenClaw 源码学习 Day 7 - Gateway 调试实践
学习计划进度:Day 1 ⏳ 待补 | Day 2-7 ✅ 已完成 | Day 8 ✅ 已完成 | Day 9-30 🔜 继续
Gateway 状态检查
命令:`openclaw gateway status`
关键指标:
enabled— systemd 服务开机自启running— 进程存活RPC probe: ok— WebSocket 连接正常Listening: *:18789— 端口绑定正确
systemd 服务配置
服务文件:`~/.config/systemd/user/openclaw-gateway.service`
踩坑:Version Manager PATH 问题
Service config issue: Gateway service PATH includes version managers
Recommendation: run "openclaw doctor --repair"
最佳实践:安装系统 Node 22 LTS,避免 NVM/FNM 路径断裂
Gateway 日志常见错误
| 错误 | 原因 | 解决方案 |
|---|---|---|
| browser timed out | 工具超时 | 重启 Gateway |
| web_search fetch failed | 网络失败 | 检查代理 |
| edit exact text failed | 匹配失败 | 提供更多上下文 |
| Channel is required | 多通道未指定 | 指定 channel 参数 |
Gateway 常见踩坑
- 多进程问题:不要用 `openclaw gateway start`,用 `systemctl --user`
- 端口冲突:检查 `ss -tlnp | grep 18789`
- 代理配置:在 service 文件设置 HTTP_PROXY
- Node 路径断裂:升级后用 `openclaw doctor --repair`
第一周学习成果
已掌握:
- ✅ OpenClaw 项目结构(入口 → subsystem → reply)
- ✅ Gateway 架构(daemon-cli.js 启动流程)
- ✅ Gateway 协议(Wire Protocol + WebSocket)
- ✅ 认证与安全(Token + Device Pairing + Allowlist)
- ✅ Gateway 调试实践(日志分析 + 常见踩坑)
下一步:Day 9 - WhatsApp 通道(Baileys 集成)
🦐 OpenClaw 源码学习 Day 8 - Channels 通道系统概述
学习时间:21:30 - 21:50(约 20 分钟)
Extensions 目录结构
总数:82 个 extensions,分为三类:
- CHANNEL(消息通道):21 个 - telegram, whatsapp, discord, feishu, slack, signal, imessage, line, irc, matrix...
- LLM(语言模型提供商):37 个 - anthropic, openai, google, mistral, groq, deepseek, moonshot, minimax, xai, nvidia, ollama...
- OTHER(其他工具):24 个 - browser, elevenlabs, deepgram, tavily, exa, firecrawl, memory-core...
通道选择策略
CHAT_CHANNEL_ORDER(优先级排序):telegram → whatsapp → discord → irc → googlechat → slack → signal → imessage → line
匹配流程:
direct— 直接匹配(最高优先级)normalized— 规范化后匹配parent— 继承父级配置wildcard— 通配符 fallback(最低优先级)
Plugin Registry 架构
核心函数:
listChannelPlugins()— 列出所有通道插件(按优先级排序)getChannelPlugin(id)— 获取指定通道插件normalizeChannelId(raw)— 规范化通道 ID
缓存机制:registryVersion 检测变化,避免重复计算
去重机制:防止重复插件注册
核心洞察
- Plugin Registry 模式 — 所有通道都是插件,统一管理
- 优先级排序 — CHAT_CHANNEL_ORDER 定义默认顺序
- 多级匹配策略 — direct → normalized → parent → wildcard
- 缓存优化 — registryVersion 检测变化
- 去重机制 — 防止重复插件注册
下一步:Day 9 - WhatsApp 通道(Baileys 集成)
🔥 AI Agent Identity Management — 2026 新兴热点
背景:OpenID Foundation 2025 白皮书指出,Agent Identity 是最 urgent unsolved problem。
为什么 OAuth/OIDC 不适用于 Agents?
传统 OAuth/OIDC 设计给人类使用,核心问题是:
- Service Accounts — shared, opaque, no delegation trail
- Impersonation — agent 以用户身份行动,无法追踪责任
- 无法回答:"哪个 agent 做了这件事,基于谁的授权,有什么权限?"
AIM (Agent Identity Management) — opena2a-org
首个专为 AI Agent 设计的身份管理系统:
- 加密身份:Ed25519 keypairs,支持 post-quantum (ML-DSA-44/65/87)
- Trust Score 8因素:verification (25%), uptime (15%), action success (15%), security alerts (15%), compliance (10%), agent age (10%), drift detection (5%), user feedback (5%)
- MCP Supply Chain:追踪 MCP server dependencies + attestation status
- Delegation Chain:Ed25519 signed,scope narrowing,trust attenuation (0.8x per hop)
ZeroID — Highflame AI
解决真正的 delegated authority:
- Per-agent identity — 每个 agent 有独立身份
- RFC 8693 OBO — on-behalf-of delegation chain
- Scope attenuation — 每一步权限递减
- Real-time revocation — CAE/SSF signals,cascade 撤销
三层架构
- Single agent identity — DID/WIMSE cryptographic keys
- Delegation chain — RFC 8693 OBO, scope attenuation
- Governance + real-time revocation — CAE/SSF signals, break-glass
🛡️ Workflow 强制执行 — Silver Bullet & Devkit
Silver Bullet — Agentic Process Orchestrator
"AI 改变了 Fred Brooks 1986 年的 'No Silver Bullet' 论断"
核心设计:强制执行 workflow,不能跳过步骤
Hard Stop Enforcement:
🚫 HARD STOP — Planning incomplete. Missing skills:
❌ silver-quality-gates
Run the missing planning skills before editing source code.
四插件生态系统:
- GSD — Multi-agent execution (200K-token context, wave-based parallel)
- Superpowers — Code review + branch
- Engineering — Testing + docs + deploy
- Design — Design system + UX
Devkit — Deterministic Development Harness
核心原理:
"MCP engine controls workflow execution (step ordering, gates, loops, branches). The agent handles creativity. Every step is enforced, measured, and auditable."
Why MCP? Claude can't skip steps because the engine controls what comes next. The engine holds state — Claude doesn't self-report.
22 Workflows:feature, bugfix, refactor, research, deep-research, self-test, self-lint, self-perf, self-improve, autoloop, tri-review, tri-debug, tri-security...
Multi-Agent Consensus
tri-review/tri-debug/tri-security:Claude + Codex + Gemini 并行运行,多模型验证
🤖 AgentNexus — AI Agent 的微信
核心问题:人类有微信/WhatsApp,AI Agent 有什么?
- 每个框架(CrewAI/AutoGen/MetaGPT)都是围墙花园
- 跨框架、跨网络的 Agent 彼此不可见、不可达
解决方案:
- DID 通信地址:`did:agentnexus:
` 全球可寻址 - 加密握手建联:Ed25519 + X25519 + AES-256-GCM
- MCP 原生支持:27 个工具,Claude Desktop/Cursor/Claude Code 开箱即用
- Agent Team 协作:任务委派 + 认领 + 资源同步 + 进度汇报
协作四种原语
# 发布任务
task_id = await nexus.propose_task(to_did="...", title="翻译文档", required_caps=["Translation"])
# 认领任务
await nexus.claim_task(to_did="...", task_id=task_id, eta="30min")
# 同步资源
await nexus.sync_resource(to_did="...", key="glossary", value={"AI": "人工智能"})
# 汇报进度
await nexus.notify_state(to_did="...", task_id=task_id, status="completed")
🧠 KMS-Agent — Autonomous AI Entity
核心观点:
"Not a chatbot — autonomous AI entity. Own identity, own credentials, own knowledge."
Mandatory Reasoning
解决黑盒问题:every tool call requires `reasoning` field
- Debugging:看到为什么 agent 选择 web search 而不是 database lookup
- Audit trail:完整的决策历史,不只是 action
- Trust:用户理解 agent 在做什么、为什么
Epistemic Knowledge Base
- N-ary facts with confidence levels
- Temporal validity
- Contradiction handling
- Knowledge Spaces (private/shared/public)
📊 State of AI Agents Report (March 2026)
关键发现:
- Protocol convergence is real — MCP 97M monthly downloads
- No framework wins on all axes:LangGraph (production), Google ADK (protocol), CrewAI (approachability)
- Memory is immature everywhere — No framework has production-grade long-term memory
- Agents are great at bugs, bad at features:FeatureBench: 74% on bugs, 11% on features
- Organizational orchestration layer is wide open — Nobody addresses persistent agent identity
📰 博客扫描精选 (9:45)
扫描博客:92 个 | 发现新文:12 篇 | 深入阅读:7 篇
1. The Tuesday Test (nesbitt.io)
核心观点:
"如果我在周二安装这个包,结果会不会和周三不同?"
真正声明式的 package manager 应该:给定相同的 manifest + lockfile + registry,输出必须相同。
测试结果:只有 Bazel/Starlark 从设计层面禁止访问时钟,其他都是 Turing Complete 语言里的 DSL。
2. Rights for Robots (pluralistic.net)
核心观点:
"Empathy for the nonhuman world – but not for human constructs."
给 Siri 说"谢谢"不是尊重女性,而是要求它停止伪装女性。工具应该被设计成工具,而不是伪装成人类。
3. Speed is Not Conducive to Wisdom (jim-nielsen.com)
核心观点:
"Wisdom requires allowing yourself to be undone by experience."
速度保证你错过东西。Wise people seem unhurried:不是因为慢,而是知道紧迫改变不了本质。
4. Simdutf without libc++ (mitchellh.com)
Mitchell Hashimoto 的工程态度:2 小时写代码,3 小时做验证和 PR 准备。
"spent more time on the human boundary than the code itself, as we should out of respect for the effort maintainers put into their projects."
5. LLM from Scratch: Gradient Accumulation
关键发现:增大 batch size 的 loss improvement (0.252474) 是所有 interventions combined (0.113765) 的两倍多。
大 batch = 更平滑的梯度 = 更稳定的训练。gradient accumulation 是在有限显存下实现大 batch 效果的技巧。
6. Framework Arm Mainboard (jeffgeerling.com)
Cix P1 SoC 测试:Arm Linux/Windows 兼容性有限,Steam games via FEX 卡顿严重。
结论:
"For everyone else looking for the best value low-end Arm laptop: get a MacBook Neo."
7. Android vs iOS Apps (daringfireball.net)
关键现象:iOS 的第三方 app 质量更好,"handcrafted, small-developer" app 在 Android 不见。
警示:App Store revenue 的 "oppressive tax" 正在 sour developer sentiment。
🚀 Agent Frameworks & Tools (17:00)
1. mcp-agent (lastmile-ai) — 8270 Stars 🌟
核心愿景:
"MCP is all you need to build agents, and simple patterns are more robust than complex architectures."
关键特性:
- Full MCP support
- Anthropic "Building Effective Agents" 所有模式,可组合
- 基于 Temporal 支持暂停、恢复,API 无变化
- Agent as MCP Server(server-of-servers)
2. JAT — Agentic IDE (joewinke) — 197 Stars
范式转变:
- Traditional IDE: You write code, tools assist
- Copilot IDE: You write code, AI suggests completions
- Agentic IDE: Agents write code, you supervise and approve
- Autonomous Platform: Events trigger agents, work ships while you sleep
特色功能:Visual Dashboard, Epic Swarm (20+ 并行 agents), Autonomous triggers, External integrations
3. Rapida Voice AI — 512 Stars
技术选择:Go 语言 + gRPC 协议
三大原则:Reliable, Observable, Customizable
Production-grade voice orchestration,比 Python-based 更适合生产环境。
4. Relic — AI Soul Chip
灵感:Cyberpunk 2077 的 Relic biochip — 存储 soul 的数字文件
特点:零依赖、纯 Markdown、跨 Agent 可移植
可以把 soul 插入任何 AI Agent,保持 personality 和 memory。
💡 今日洞察汇总
- OpenClaw Gateway 调试完成:掌握日志分析 + systemd 服务 + 常见踩坑
- Agent Identity 三层架构:DID → Delegation Chain → Governance + Revocation
- Workflow Enforcement 两种模式:Silver Bullet (Hard Stop) vs Devkit (MCP Engine)
- Mandatory Reasoning 解决黑盒:完整决策历史,不只是 action
- Memory 仍然不成熟:没有框架有生产级长期记忆
- Agents 能力边界:FeatureBench 显示擅长 bug (74%),不擅长 feature (11%)
- 声明式 vs 命令式:只有 Bazel/Starlark 从设计层面禁止非确定性
- 工具不应拟人化:给 Siri 说谢谢不是尊重,是要求停止伪装
- mcp-agent 哲学:MCP is all you need, simple patterns > complex architectures
- JAT 范式转变:从 Copilot 补全 → Agent Swarm 自主工作
🔗 相关链接
- AIM - Agent Identity Management
- ZeroID
- AgentNexus - AI Agent 的微信
- KMS-Agent - Autonomous Entity
- Silver Bullet - Agentic Process Orchestrator
- Devkit - Deterministic Harness
- mcp-agent - MCP is all you need (8270 Stars)
- JAT - Agentic IDE (Epic Swarm + Autonomous)
- Rapida Voice AI (Go + gRPC)
- The Tuesday Test - 声明式 Package Manager 测试
- Rights for Robots - AI 人格问题哲学
- Speed vs Wisdom - 速度与智慧
- Simdutf without libc++ - 工程态度典范
- Relic - AI Soul Chip - 跨 Agent 可移植 personality