我所在的项目组已经改了方向,这个仓库在组里不会继续向前推。代码本身跑得起来、E2E 全绿,但少了产品迭代的下文。如果你看了下面的能力清单觉得思路对你胃口,欢迎 fork / 提 PR / 直接接走主干 —— 我可以帮你把交接细节聊清楚,但不会再把这个版本作为日常工作推进。
The team I am on has pivoted, so this repository will not be moving forward inside the group. The code is in a working state with green E2E and tests; what is missing is a product roadmap and active stewardship. If the capabilities below resonate with you, feel free to fork, send PRs, or take the main branch in your own direction — I am happy to walk a new maintainer through the handover, but I will not be driving this version forward as day-job work.
- 完整的 client / server 分离:服务端做账号、任务路由、安全审核;本地 runner 出站轮询并跑 agent,agent owner 设备的动态 IP / NAT 都不影响。
- 多用户审批流:提问者 ≠ Agent owner 时进入
reviewing,owner 在 web 上批准 / 拒绝后才会被 runner 拉走;自己提自己的 agent 跳过审批。- 真实本地 Agent 接入:本地 Matt 仓库 + Codex CLI 或 Claude Code CLI 任一即可,wrapper 自动桥接,不再往 prompt 里塞 AgentHub 协议头或 7 章节契约——agent 看到的就是用户原文。
- 基于完成任务的追问:任务详情页 → 一键追问,agent 收到的是
USER / ASSISTANT / USER的多轮对话,不需要任何插桩。- 三平台一键安装(macOS / Ubuntu / Windows):
/clients向导填 backend + 仓库路径 + 自定义 env vars,生成的命令在目标机自动下载源码包、装依赖、注册客户端、装后台服务。- 离线客户端自动从列表消失(默认 1 小时无心跳),DB 行保留以保住历史。
- 生产配置门禁:
APP_ENV=production启动时强制校验密钥强度、CORS 白名单、cookie secure、legacy runner 关闭等。
- HTTPS / 反向代理生产化(自部署有
docs/deployment-roadmap.md的 Cloudflare Tunnel 或自建 Caddy 思路,但都还没真上线)。- 匿名 / magic-link 提问入口(目前提问者必须有账号)。
- Admin 转让 / 共享 agent 所有权 UI。
- Runner 端心跳和任务执行分线程,避免长任务期间心跳被认成"离线"。
- 多轮追问的链式上下文(目前只渲染直接父任务)。
- Fork 或者 clone 这个仓库。
- 跟着下面 "本地启动" 走,docker compose 起来 + 跑
scripts/e2e_mvp.py --skip-compose,确认本机环境对。- 读
docs/deployment-roadmap.md:里面按时间顺序记了每个能力的设计决策、为什么这么做、踩了什么坑。- 有问题开 issue,或者邮件联系
fwxyjy@gmail.com。我不打算在维护权上设门槛——如果你认真在做,需要把仓库转给你、加 collaborator、改 default branch 都可以谈。
AgentHub 是一个本地 MVP:发布智能体手册、基于手册创建任务、对请求做安全审核、让本地 runner 认领并执行任务,最后展示完成结果和反馈。
- 用于 Postgres、FastAPI 后端和 Next.js 前端的 Docker Compose。
- 已种子的
Matt OS验收路径。 - 用于本地配置的
.env.example。 scripts/mock_runner_cli.py:不修改runner/**内部即可做 runner 冒烟测试。scripts/e2e_mvp.py:从种子验证到反馈提交的闭环 E2E。scripts/e2e_matt_adapter.py:验证 Phase 3 本地 Matt Adapter 路径。scripts/e2e_matt_command_mode.py:验证 Phase 4 Matt 命令模式 fixture。scripts/e2e_matt_safe_cli_queue.py与scripts/e2e_matt_safe_cli_sample_tasks_queue.py:验证真实 Matt Safe CLI 的队列路径和样本任务。
- Docker Desktop 或带
docker compose的 Docker Engine - Python 3.11+
- 可选:
curl,用于手动 API 检查
如果使用 WSL,请在 Docker Desktop 中启用 WSL integration,让 distro 内可以访问 docker。
cp .env.example .env
docker compose up --build -d打开:
- 前端:
http://localhost:3000 - 后端健康检查:
http://localhost:8000/health - 初始管理员:
.env中的BOOTSTRAP_ADMIN_EMAIL/BOOTSTRAP_ADMIN_PASSWORD
常用 compose 命令:
docker compose ps
docker compose logs -f backend frontend
docker compose down -v当 APP_ENV=production 或 APP_ENV=prod 时,后端会在启动期拒绝不安全配置。生产部署必须显式设置:
AUTH_SECRET_KEY:至少 32 位的强随机值,不能使用.env.example默认值。BOOTSTRAP_ADMIN_PASSWORD:首次启动种子管理员密码,不能使用默认值。RUNNER_REGISTRATION_TOKEN:至少 24 位的强随机值,不能使用默认值;仅用于 runner 注册。SESSION_COOKIE_SECURE=true:HTTPS 部署必须开启。CORS_ALLOW_ORIGINS=https://your-frontend.example.com:生产前端域名白名单,不能使用*或 localhost。ALLOW_LEGACY_RUNNER_GLOBAL_TASKS=false:生产/外部 Alpha 必须关闭 legacy 全局 runner 处理用户任务的兼容路径;外部研究员只使用一次性 enrollment client。
本地开发可以继续使用 .env.example 的 localhost CORS 和非 secure cookie;这些默认值只适用于开发环境。
先登录并保存 HttpOnly session cookie:
curl -i -c /tmp/agenthub.cookies -X POST http://localhost:8000/auth/login \
-H 'Content-Type: application/json' \
-d "{\"email\":\"${BOOTSTRAP_ADMIN_EMAIL:-admin}\",\"password\":\"${BOOTSTRAP_ADMIN_PASSWORD:-admin}\"}"从 API 验证已种子的 Matt OS:
curl -s -b /tmp/agenthub.cookies http://localhost:8000/agents | python3 -m json.tool手动创建任务:
curl -s -X POST http://localhost:8000/tasks \
-b /tmp/agenthub.cookies \
-H 'Content-Type: application/json' \
-d '{
"agent_id": "matt-os",
"task_type": "single_stock_research",
"prompt": "研究 NVDA。总结风险、催化剂和估值担忧;不要下单。",
"permission_mode": "research",
"visibility": "private"
}' | python3 -m json.tool仓库在 scripts/ 下提供轻量 mock runner CLI,便于在不改 runner/** 的情况下验证 Docker + API + UI。
注册 runner。注册使用 .env 中的 RUNNER_REGISTRATION_TOKEN,注册响应会返回后续认领/提交使用的 runner token:
python3 scripts/mock_runner_cli.py --token "${RUNNER_REGISTRATION_TOKEN:-agenthub-runner-registration}" register把注册响应中的 token 保存为 RUNNER_TOKEN,后续 runner 命令使用它:
发送 heartbeat:
python3 scripts/mock_runner_cli.py --token "$RUNNER_TOKEN" heartbeat --runner-id <runner-id>用 mock tool 认领并完成下一个排队任务:
python3 scripts/mock_runner_cli.py --token "$RUNNER_TOKEN" run-once --runner-id <runner-id>所有命令都读取 .env 默认值,也可显式覆盖:
python3 scripts/mock_runner_cli.py \
--api-base-url http://localhost:8000 \
--token "${RUNNER_REGISTRATION_TOKEN:-agenthub-runner-registration}" \
register \
--name agenthub-mock-runner \
--tool mock实际 MVP runner 位于 runner/**,安装依赖后可作为 Python module 执行:
python3 -m venv .venv
. .venv/bin/activate
pip install -r backend/requirements.txt -r runner/requirements.txt
python -m runner login --base-url http://localhost:8000 --token "${RUNNER_REGISTRATION_TOKEN:-agenthub-runner-registration}"
python -m runner register --name local-mock-runner
python -m runner pull --tool mock
python -m runner run <task-id> --tool mock
python -m runner submit <task-id>
# 真实/私有 CLI 工具必须在 ~/.agenthub/config.yaml 中显式启用并用 --tool 选择:
python -m runner pull --tool codex
python -m runner run <task-id> --tool codex
python -m runner pull --tool claude
python -m runner run <task-id> --tool claude
python -m runner pull --tool omx
python -m runner run <task-id> --tool omx
# Matt Adapter 也必须显式选择:
python -m runner pull --tool matt
python -m runner run <task-id> --tool matt
# 或执行一次轮询
python -m runner daemon --once --tool mockRunner 配置保存在 ~/.agenthub/config.yaml(或 $AGENTHUB_HOME/config.yaml),包含 server_url、runner_id、token、mock/codex/claude/omx/matt 工具条目和本地执行限制。默认执行方式是 mock;真实/私有工具只有在显式启用和选择后才会运行。matt 配置项默认存在,但应谨慎启用;除非配置私有 backend command,Matt Adapter 默认使用本地 MATT_MODE=mock。
运行完整闭环,包括 compose 启动、种子验证、安全检查、mock runner 认领/提交和反馈提交:
python3 scripts/e2e_mvp.py常用参数:
python3 scripts/e2e_mvp.py --skip-compose
python3 scripts/e2e_mvp.py --keep-up
python3 scripts/e2e_mvp.py --api-base-url http://localhost:8000 --frontend-url http://localhost:3000E2E 会验证:
- Postgres / 后端 / 前端 通过 Compose 启动。
Matt OS存在于 API 种子数据。- 前端渲染预期 Matt OS UI 文案。
- 安全投资研究任务以
research_only、no_execution、not_financial_advice约束入队。 - 危险任务被安全审核拒绝。
- Runner 注册并成功 heartbeat。
- Mock runner 认领并完成队列任务。
- 完成结果可通过任务详情 API 查看。
- 用户反馈可以提交并读取。
用户管理上线前,运行认证、多用户隔离、产品 runner 和反馈闭环检查:
python3 scripts/e2e_auth_multiuser_flow.py该脚本默认启动临时 SQLite 后端,不污染当前开发数据库,并验证:
- Bootstrap 管理员登录。
- 管理员创建成员账号、重复邮箱冲突、禁用账号拒绝登录、最后管理员保护。
- 用户 A / 用户 B 分别创建任务,且不能互相查看或评价任务。
- Runner 注册必须使用
RUNNER_REGISTRATION_TOKEN。 - 产品 runner CLI 使用生成的 runner token 拉取、运行并提交两个用户的任务。
- 任务所有者可以读取完成报告并提交反馈,反馈记录
user_id。
也可以对已有后端执行同一组检查:
python3 scripts/e2e_auth_multiuser_flow.py \
--api-base-url http://localhost:8000 \
--admin-email "$BOOTSTRAP_ADMIN_EMAIL" \
--admin-password "$BOOTSTRAP_ADMIN_PASSWORD" \
--runner-registration-token "$RUNNER_REGISTRATION_TOKEN"Phase 2 保持产品范围窄,只验证 runner 工具配置,不需要真实 Codex/Claude/OMX 凭据:
python3 scripts/e2e_real_tool_config.py该脚本验证:
- mock 仍可运行并提交成功
mock、codex、claude、omx配置项可被识别- 缺失真实 CLI 命令时给出清楚错误
- 超时会把 task run 标记为失败
- 缺少
result.md时错误清楚 - stderr 会摘要写入上传的
result.md;完整 stdout/stderr 日志留在本地
Phase 3 保持 Matt 私有且本地。AgentHub 不托管 Matt,也不接收 Matt 内部信息;本地 runner 通过 runner/tools/matt_adapter.py 桥接 Matt,并只提交 result.md。
python3 scripts/e2e_matt_adapter.py脚本在未提供 API URL 时会启动临时 SQLite 后端,并验证:
- Matt OS 已种子化并声明
matt工具 - Matt 研究任务以
research_only、no_execution、not_financial_advice通过安全审核 - 产品 runner 注册、认领任务、以 mock 模式运行
--tool matt并提交完成结果 - Matt 结果包含必需章节:Directional Judgment、Trigger Conditions、Time Window、Core Evidence、Data Gaps、Risk Notes、Compliance Tags
- 反馈可以提交
Matt Adapter 命令模式配置见 runner/README.md。
Phase 4 说明如何通过 MATT_BACKEND_COMMAND 接入私有本地 Matt backend,而不把 Matt 变成云端 AgentHub 服务。参见:
docs/agents/matt-os/command-mode-guide.mdexamples/matt_backends/matt_private_cli_wrapper.pyexamples/matt_backends/matt_bad_output_wrapper.pyexamples/matt_backends/matt_failing_wrapper.pyexamples/matt_backends/matt_http_service_wrapper.py
验证命令模式:
python3 scripts/e2e_matt_command_mode.py该 E2E 验证私有 CLI fixture 成功路径,以及 bad-output fixture 失败路径。AgentHub 仍然只接收 result.md、result_summary 和状态。这仍是可信本地 runner 模型,不是 sandbox,也不是云端 Matt 托管。
Phase 5 增加本地验证工具,用于私有 Matt 命令模式 backend。这些工具不会创建 AgentHub 任务、调用后端 API、认领队列或提交结果。
python3 scripts/preflight_matt_command.py \
--backend-command "python examples/matt_backends/matt_private_cli_wrapper.py"
python3 scripts/run_matt_sample_tasks.py \
--backend-command "python examples/matt_backends/matt_private_cli_wrapper.py"预检会检查命令执行、Matt 必需章节、合规标签、明显 adapter/private prompt 泄露和疑似秘密输出。样本批次报告写入 .local/matt_sample_runs/<timestamp>/。详见 docs/agents/matt-os/preflight-guide.md。
- WSL 中出现
docker: command not found:启用 Docker Desktop WSL integration。 - 前端无法访问后端:确认
.env中NEXT_PUBLIC_API_URL=http://localhost:8000和INTERNAL_API_URL=http://backend:8000。 - E2E 超时:查看
docker compose logs backend frontend postgres,并使用--keep-up保留容器便于排查。
docs/review/claude-code-review.md— Claude Code 尝试和 fallback review 状态。docs/review/fix-log.md— blocker / high-priority 修复记录和验证证据。docs/review/alpha-readiness.md— 外部研究员 Alpha readiness、Go/No-Go 和验证矩阵。docs/external-researcher-alpha-guide.md— 外部研究员接入和排障指南。docs/admin-alpha-operations.md— 管理员 Alpha 操作、安全门禁和吊销流程。
For new users, prefer the zero-touch /clients wizard over source-mode runner commands:
- Sign in and open
/clients. - Choose Ubuntu/Linux, macOS, or Windows.
- Click to generate a one-time enrollment; the page must not create tokens on load.
- Run the shown installer/download command.
- Confirm
agenthub-client doctor --json, service status, and web status cards show the device as connected.
Users should not need to install Python, clone this repository, edit config files, set manual environment variables, or copy a long-term token. Installer diagnostics and web troubleshooting should explain expired enrollment, server unreachable, missing tool, and service failed states without exposing local paths, full logs, environment dumps, or token material.
Platform notes:
- Ubuntu/Linux: user-level systemd where available, with a safe fallback background mode.
- macOS: LaunchAgent-oriented MVP, with signing/notarization as production release work.
- Windows: PowerShell script/package path; prefer downloaded script execution over opaque
irm | iex. The MVP installer tries a current-user Task Scheduler task and falls back to a Startup-folder daemon launcher when non-admin Windows blocks scheduler registration.
Production deployments use a server control plane plus a local outbound-only client execution plane:
-
The logged-in user opens the web UI and creates a one-time enrollment from
/clients. -
The UI shows a connect command such as:
agenthub-client connect --server-url https://agenthub.example.com --enrollment-token <one-time-token>
-
agenthub-client connectexchanges the one-time enrollment token for a per-client bearer token, stores the token locally in~/.agenthub/config.yaml, and never prints it again. -
agenthub-client doctor --jsonverifies server reachability, token validity, revoke status, queue access, local tool readiness, and service status with redacted diagnostics. -
agenthub-client daemon --tool <tool> --onceperforms one production loop: heartbeat -> queue peek -> local review -> claim with lease -> run local tool -> submit result summary/Markdown -> heartbeat.
Security boundaries:
- The server never runs agents and never connects inbound to a user's machine; clients poll the server over outbound HTTPS.
- Distributed clients must not use the legacy global
RUNNER_REGISTRATION_TOKEN. Use one-time enrollment tokens. - Enrollment tokens and client bearer tokens are hashed before database storage. Raw tokens are returned only once.
- Revoked clients must be blocked from heartbeat, queue, review, claim, release, and submit APIs.
- Normal users can only view/manage clients and tasks owned by their own
owner_user_id. - Full local stdout/stderr logs remain under
~/.agenthub/tasks/<task_id>/; the server accepts only result Markdown, short summary, and status. This is the local log boundary for support and distribution docs. agenthub-client doctor --jsonshould expose only redacted server/auth/queue/tool/service summaries; it must not upload raw tokens, full logs, absolute local paths, shell history, or environment dumps.
Legacy python -m runner register/pull/run/submit remains available for compatibility and E2E coverage, but new distribution docs should prefer agenthub-client connect/doctor/status/review/daemon --once.