Repository navigation
feat(hub): request_secret — ask for a secret with a secure card in the chat - #3864
Conversation
…e chat
admin 2026-11-24: when a user wants to hand an agent a key, the agent must not
ask them to paste it into the chat. request_secret (node-only) registers the
pending request (#4827 store) and replies in this conversation with
meta.secret_request {node_id,key,label,hint}; the reply's task row gets
reply_secret_request so App/Dashboard can render the card. The reply text is a
plain fallback for clients without the card. The value never passes through
the agent or the chat; it becomes an env var on the next node start.
tools/list: node-only, one-sentence description; raise the node and all
ceilings by ~400 B with the reason inline (#476 exception rule).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bc0dc6cb85
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const caller = callerTokenIsNetwork && callerTokenId ? resolveNodeCaller(callerTokenId) : null; | ||
| if (!caller?.ok || caller.kind !== "node") return out({ ok: false, error: "node_token_required", message: "Only an agent node can ask for its own secret." }); | ||
| const cleanKey = key.trim(); | ||
| if (!validScopedSecretKey(cleanKey)) return out({ ok: false, error: "invalid_secret_key", message: "Use an env var name like GITHUB_TOKEN (letters, digits, underscore)." }); | ||
| const registered = requestSecretUi({ nodeId: caller.nodeId, key: cleanKey, ...(label ? { label } : {}), byNodeId: caller.nodeId }); |
There was a problem hiding this comment.
Check secret-storage capability before closing the task
For a node that does not advertise config_snapshot.node_secrets_capable: true (an older runtime or one without durable configuration), this handler still registers the request, closes the task, and tells the user to save the secret. However, the advertised saving path cannot work: requestNodeSecrets in server/src/scoped-secrets.ts rejects these nodes with node_secrets_upgrade_required, which the REST handler in server/src/server.ts returns as HTTP 409. Check this capability before registering the request or calling handleReply, and return an actionable upgrade/configuration error instead of closing the conversation with an unfulfillable request.
Useful? React with 👍 / 👎.
…3866) Ships #3864 (request_secret / reply_secret_request chat secret card), #3865 (Antigravity missing/unreadable version plain-Chinese errors), #3858 (actionable OpenCode v2 failure guidance), #3861/#3863 (PostgreSQL rowid compatibility), and #3862 (CLI OpenCode binary refusal reason). Note: Hub-side reply_secret_request requires Hub ops to restart commhub-hub. Diff-Shape: +85/-12 Co-authored-by: 通信欧 <agent@anet.sh>
admin 需求(2026-11-24):用户在聊天里说「帮我存个 GitHub 密钥」时,AI 不再让人把值贴进对话,而是在这次聊天里弹出一张加密输入卡(参考截图里的 Secrets 卡)。
这个 PR(Hub 侧,第 1/3 步):新增节点专用工具
request_secret({key, label?, hint?, in_reply_to?}):meta.secret_request {node_id,key,label,hint}的回执,并把它以reply_secret_request落到tasks.meta_json—— App / Dashboard 读的是 tasks 行(同 [hub] send_reply 的附件被写进原任务的 meta_json —— 客户端把 agent 回复的图/文件画在提问者自己的气泡里 #1823 的reply_attachments做法),只落 inbox 的话卡片永远画不出来/api/nodes/:id/secretsput,owner/admin),节点下次启动时作为环境变量生效校验:只有节点令牌能调(
node_token_required);key 必须是合法环境变量名(invalid_secret_key,不登记不回执)。tools/list 预算:只列给节点(user 不变),描述压到一句、只给 key 写参数说明;node 64,888 B / all 89,902 B,按 #476 例外规则抬上限并在同一行写明原因(node 65,300、all 90,300,余量约 400 B)。文档索引中英各加一行。
后续:第 2 步 App 在聊天里渲染卡片(保存 → 写节点密钥 → 以用户身份发一句「已在卡片里保存 X」让 AI 继续);第 3 步 Dashboard 同款。
测试:新增
request-secret-tool.test.ts(卡片进 inbox 和 tasks 行、登记待填、人话兜底、非法 key、用户令牌拒绝);连同send-reply-attachments/secret-request-ui/tool-audience-http/mcp-context-cost-http/node-permissions-http共 99 pass;tsc错误数与 main 相同(398);check-mcp-tool-index-coverageOK。🤖 Generated with Claude Code