Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ AGENTHUB_TOKENDANCE_ID_REDIRECT_URI=http://localhost:8080/client/auth/oidc/callb
# https://<agenthub-web-origin>/auth/tokendance/callback
AGENTHUB_TOKENDANCE_ID_ALLOWED_REDIRECT_URIS=http://127.0.0.1/callback,http://localhost:5174/auth/tokendance/callback,http://127.0.0.1:5174/auth/tokendance/callback

# ── TokenDance ID no-secret login readiness ─
# These values are script metadata for scripts/verify/verify-token-dance-id-login-readiness.py.
# They are not Hub runtime secrets and do not replace AGENTHUB_TOKENDANCE_ID_*.
AGENTHUB_TDID_LOGIN_ISSUER_URL=https://id.tokendancelab.com
AGENTHUB_TDID_LOGIN_CLIENT_ID=
AGENTHUB_TDID_LOGIN_TEST_ACCOUNT_REF=
# Optional local OIDC discovery JSON fixture for script contract tests only.
AGENTHUB_TDID_LOGIN_DISCOVERY_DOCUMENT=

# ── Pprof 管理端 (Basic Auth) ───────────────
# AGENTHUB_PPROF_USER=admin
# AGENTHUB_PPROF_PASS=
Expand Down
13 changes: 4 additions & 9 deletions docs/architecture/11-protocol-capability-mapping.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# 协议能力映射:自有契约 / MCP / A2A / AG-UI(宏观 §3 P1)

> 主索引:[architecture.md](../architecture.md)。本文件是 AgentHub 自有 REST/WS
> 契约与三个外部协议(MCP / A2A / AG-UI)的能力对照、引入红线与评估结论 SSOT。
> 上游基线:`docs/architecture/10-macro-engineering-design.md`(#2065 待合入;合入后改为相对链接) §3
> 协议分层表 + §9 差距路线 P1「MCP/A2A/AG-UI capability mapping — 未成文」。
> 主索引:[architecture.md](../architecture.md)。本文件是 AgentHub 自有 REST/WS 契约与三个外部协议(MCP / A2A / AG-UI)的能力对照、引入红线与评估结论 SSOT。上游基线:`docs/architecture/10-macro-engineering-design.md`(#2065,已合入)§3 协议分层表 + §9 差距路线 P1「MCP/A2A/AG-UI capability mapping — 未成文」。

## 0. 阅读约定

Expand Down Expand Up @@ -76,8 +73,7 @@ Deprecated unprefixed aliases(`list_projects` 等)仅在 discovery 中标记

### 2.5 外部来源

- MCP spec(Streamable HTTP `2025-06-18`):<https://modelcontextprotocol.io/specification/2025-06-18>
- MCP spec(旧 session-based `2024-11-05`,已废弃):<https://modelcontextprotocol.io/specification/2024-11-05>
- MCP spec:Streamable HTTP `2025-06-18` <https://modelcontextprotocol.io/specification/2025-06-18>;旧 session-based `2024-11-05`(已废弃)<https://modelcontextprotocol.io/specification/2024-11-05>

## 3. A2A:远程/跨设备协作场景界定

Expand Down Expand Up @@ -128,8 +124,7 @@ Deprecated unprefixed aliases(`list_projects` 等)仅在 discovery 中标记

### 3.6 外部来源

- A2A v1.0 spec:<https://google.github.io/A2A/>
- A2A GitHub:<https://github.com/google/A2A>
- A2A v1.0 spec <https://google.github.io/A2A/>;GitHub <https://github.com/google/A2A>

## 4. AG-UI:capability mapping 兼容评估

Expand Down Expand Up @@ -202,4 +197,4 @@ Deprecated unprefixed aliases(`list_projects` 等)仅在 discovery 中标记

- 本文件是协议能力映射 SSOT;新增外部协议或变更引入判定须更新本文件。
- 协议实现的源码 owner 在各模块 README;本文件只记录能力对照与红线。
- 与本文件冲突时以本文件为准;若宏观基线更新,先更新 `docs/architecture/10-macro-engineering-design.md`(#2065 待合入;合入后改为相对链接) 再同步本文件。
- 与本文件冲突时以本文件为准;若宏观基线更新,先更新 `docs/architecture/10-macro-engineering-design.md`(#2065,已合入) 再同步本文件。
15 changes: 14 additions & 1 deletion edge-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ go run ./edge-server/cmd/agenthub-edge --addr 127.0.0.1:3210 --runner-profile op
| `--store-backend` / `AGENTHUB_STORE_BACKEND` | `memory`, `file`, or `sqlite` |
| `--store-db` / `AGENTHUB_STORE_DB` | SQLite path when backend is `sqlite` |
| `--store-file` / `AGENTHUB_STORE_FILE` | Legacy JSON file store path |
| `--store-readiness`(无 env) | 打印 store readiness JSON 后退出(当前支持 `--store-backend sqlite`) |
| `--runner-command` / `AGENTHUB_RUNNER_COMMAND` | 本地进程执行器二进制(空=内置 mock executor) |
| `--runner-arg` / `--runner-env`(可重复,无 env) | 传给 `--runner-command` 的参数 / 环境变量 `KEY=VALUE` |
| `--runner-workdir` / `AGENTHUB_RUNNER_WORKDIR` | 工作目录(空=继承 Edge 进程 cwd) |
| `--agent-default` / `AGENTHUB_AGENT_DEFAULT` | Default Runtime adapter ID(`claude-acp`/`codex-acp`/`opencode-acp`/`claude-code`) |
| `--agent-model` / `AGENTHUB_AGENT_MODEL` | 默认 agent 的模型覆盖 |
| `--runtime-manifest` / `AGENTHUB_RUNTIME_MANIFESTS` | fixture-only 自定义 runtime manifest JSON 路径(可重复;env 用路径列表分隔) |
| `--skills-dir` / `AGENTHUB_SKILLS_DIRS` | 含 SKILL.md 子目录的技能目录(可重复;默认 `.agents/skills` 与 `.codex/skills`) |
| `--runner-profile` / `AGENTHUB_RUNNER_PROFILE` | Runtime preset(`agenthub-runner-mock`/`claude-code`/`codex`/`opencode`,均 cutover 到 ACP) |
| `--claude-acp-path` / `AGENTHUB_CLAUDE_ACP_PATH` | claude-agent-acp ACP launcher(空=平台原生 `npx`) |
| `--codex-acp-path` / `AGENTHUB_CODEX_ACP_PATH` | codex-acp ACP launcher(空=平台原生 `npx`) |
Expand All @@ -67,20 +74,26 @@ go run ./edge-server/cmd/agenthub-edge --addr 127.0.0.1:3210 --runner-profile op
| `--edge-device-id` / `AGENTHUB_EDGE_DEVICE_ID` | Device binding for Hub JWT |
| `--dev` / `AGENTHUB_DEV` | Dev mode:禁用自动本地 token,所有端点开放(仅本地开发) |
| `--remote-mode` / `AGENTHUB_REMOTE_MODE` | 允许非 loopback bind + 远程 origin(需配 `--local-auth-token` 或 `--hub-jwt-secret`) |
| `--tailscale` / `AGENTHUB_TAILSCALE` + `--tailscale-ip` / `AGENTHUB_TAILSCALE_IP` | tailscale 模式(隐含 remote-mode,以 tailscale 身份向 Hub 注册)+ 注册用 tailscale IP |
| `--allowed-origin` / `AGENTHUB_ALLOWED_ORIGINS` | remote-mode CORS 允许的 browser origin(可重复;env 用逗号分隔) |
| `--event-log-path` / `AGENTHUB_EVENT_LOG_PATH` | append-only JSON-lines 事件日志路径(崩溃恢复/回放;空=不持久化) |
| `--event-log-max-size` / `AGENTHUB_EVENT_LOG_MAX_SIZE` | 事件日志截断阈值(字节,0=默认 50 MiB) |
| `--hub-url` / `AGENTHUB_HUB_URL` + `--hub-token` / `AGENTHUB_HUB_TOKEN` | Edge→Hub 直连回调上报地址 + JWT bearer 鉴权 |
| `--hub-refresh-token` / `AGENTHUB_HUB_REFRESH_TOKEN` | Hub 会话 refresh token;设置后过期前经 `/client/auth/refresh` 自动轮换 `--hub-token` |
| `--hub-callback-timeout` / `AGENTHUB_HUB_CALLBACK_TIMEOUT` | 单次 Edge→Hub 回调超时(Go duration,默认 30s) |
| `--hub-callback-retry-budget` / `AGENTHUB_HUB_CALLBACK_RETRY_BUDGET` | 回调总 wall-clock 重试预算(Go duration,默认 10s) |
| `--hub-callback-max-attempts` / `AGENTHUB_HUB_CALLBACK_MAX_ATTEMPTS` | 单次回调总尝试数(默认 3) |
| `AGENTHUB_MEMORY_LIMIT_MB` | Soft memory-limit(env-only,默认 512 MiB,0=禁用;防长跑堆膨胀) |
| `--hub-mcp-sync-url` / `AGENTHUB_HUB_MCP_SYNC_URL` + `--hub-mcp-sync-interval` / `AGENTHUB_HUB_MCP_SYNC_INTERVAL` | 周期拉取 Hub MCP server 配置(URL 空=不同步;interval 默认 5m) |
| `AGENTHUB_LOG_LEVEL`(env-only) | 日志级别 `debug`/`info`/`warn`/`error`(默认 `info`) |
| `AGENTHUB_LOG_FORMAT`(env-only) | 日志格式 `text`/`json`(默认 `text`) |
| `AGENTHUB_DEMO_SEED`(env-only) | 任意非空值注入 demo 种子数据(仅开发演示) |

## Auto token and debug endpoint auth behavior

非 dev 模式且未显式配 `--local-auth-token` 与 `--hub-jwt-secret` 时,Edge 启动自动生成随机 `aght_` 本地 token(32 字节),是浏览器与本地 runtime 之间的主防线:无 token 的进程无法调状态变更端点或订阅 `/v1/events`。`--dev`/`AGENTHUB_DEV=1` 关闭此保护(仅本地开发)。

debug 端点(pprof、`/debug/config`、`/debug/state`)由 `debugAuthFunc` 分层鉴权(`server_auth.go`):(1) Dev 模式 → nil(公开);(2) 已配 `LocalAuthToken` → Bearer 校验;(3) 已配 `HubJWTSecret` 但无 `LocalAuthToken` → Hub-JWT 校验回退(复用 REST 路由同一 `jwtutil.ValidateHubToken` 信任链,防 operator 只配 HubJWTSecret 时 debug 端点裸奔);(4) 均未配 → nil(等价 dev 开放)。TokenDance `td_` bearer 不被 debug 端点接受。
debug 端点(pprof、`/debug/config`、`/debug/state`)由 `debugAuthFunc` 分层鉴权(`server_auth.go`):(1) Dev 模式 → nil(公开);(2) 已配 `LocalAuthToken` → Bearer 校验;(3) 已配 `HubJWTSecret` 但无 `LocalAuthToken` → Hub-JWT 校验回退(复用 REST 路由同一 `jwtutil.ValidateHubToken` 信任链,防 operator 只配 HubJWTSecret 时 debug 端点裸奔);(4) 均未配 → deny-all(fail-closed,401)。该分支在正常 `Run()` 流程中不可达:非 dev 且未显式配 token 时,启动会先自动生成本地 token,使 (2) 成立。TokenDance `td_` bearer 不被 debug 端点接受。

## Verification

Expand Down
155 changes: 0 additions & 155 deletions edge-server/internal/diff/diff.go

This file was deleted.

105 changes: 0 additions & 105 deletions edge-server/internal/diff/diff_test.go

This file was deleted.

4 changes: 3 additions & 1 deletion edge-server/internal/httpserver/server_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ func constantTimeEqual(got, want string) bool {
// middleware but leaves LocalAuthToken empty: previously debugAuthFunc
// returned nil, which exposed pprof/config/state to any caller even
// though Hub-JWT mode is a production-grade deployment.
// 4. Neither configured → nil (dev-equivalent open mode).
// 4. Neither configured → deny-all (fail-closed). In the normal Run()
// flow this branch is unreachable: when neither token is configured,
// startup auto-generates a local token, which satisfies layer 2.
//
// The Hub-JWT fallback reuses the same jwtutil.ValidateHubToken trust chain
// as localAuthMiddleware, so a Hub-issued Edge-scoped HS256 JWT accepted on
Expand Down
9 changes: 6 additions & 3 deletions hub-server/internal/cache/client_noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (

// Residual pure-helper peel #1123: NoOpCache interface stubs.

// NoOpCache is a safe no-op implementation of all cache interfaces used by
// services. Tests and offline paths can use this explicitly. Production
// constructors MUST receive a real *Client — passing nil will panic.
// NoOpCache is a fail-closed cache stub: mutation/read methods return
// ErrCacheUnavailable and the offline-queue methods surface that error to
// callers instead of silently succeeding. Bookkeeping methods (Invalidate,
// seq mirror setters, IsOnline) succeed as no-ops. Tests and offline paths
// can use this explicitly. Production constructors MUST receive a real
// *Client — passing nil will panic.
type NoOpCache struct{}

func (NoOpCache) Invalidate(ctx context.Context, keys ...string) error { return nil }
Expand Down
Loading
Loading