Skip to content

feat(hub): request_secret — ask for a secret with a secure card in the chat - #3864

Merged
vansin merged 3 commits into
mainfrom
feat/request-secret-card
Nov 24, 2026
Merged

vansin merged 3 commits into
mainfrom
feat/request-secret-card

Conversation

@vansin

@vansin vansin commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

admin 需求(2026-11-24):用户在聊天里说「帮我存个 GitHub 密钥」时,AI 不再让人把值贴进对话,而是在这次聊天里弹出一张加密输入卡(参考截图里的 Secrets 卡)。

这个 PR(Hub 侧,第 1/3 步):新增节点专用工具 request_secret({key, label?, hint?, in_reply_to?}):

  1. 登记「待填」(复用 #4827 的 30 分钟内存登记,节点设置页原有的待填卡也能看到)
  2. 在这次对话里回一条带 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 的话卡片永远画不出来
  3. 回执正文是人话兜底:旧客户端看不到卡片时告诉人「到这个 AI 的设置 → 密钥 里添加 KEY」
  4. 值永远不经过 agent 和聊天:卡片直接写节点密钥(已有 /api/nodes/:id/secrets put,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-coverage OK。

🤖 Generated with Claude Code

…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>
@vansin vansin added the full-qa Run the full QA / Docker / E2E matrix on this PR label Nov 24, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T08:48:49.214710Z bc0dc6c PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread server/src/tools.ts
Comment on lines +3197 to +3201
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 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@vansin
vansin merged commit 786cce6 into main Nov 24, 2026
6 checks passed
vansin added a commit that referenced this pull request Nov 24, 2026
…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>
vansin added a commit that referenced this pull request Nov 24, 2026
…y_secret_request) (#3867)

Bump @sleep2agi/commhub-server to 0.9.0-preview.296 so #3864 (chat secret card) and recent Hub fixes can be published to npm and rolled out to production Hub.

Diff-Shape: +37/-3

Co-authored-by: 通信欧 <agent@anet.sh>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-qa Run the full QA / Docker / E2E matrix on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant