Confidant
Receive secrets from humans securely — no chat exposure, no copy-paste, no history leaks.
🚨 CRITICAL FLOW — Read This First
This is a human-in-the-loop process. You CANNOT retrieve the secret yourself.
- 1. Run the script → you get a secure URL
- SEND the URL to the user in chat ← THIS IS MANDATORY
- WAIT for the user to open the URL in their browser and submit the secret
- The script handles the rest (receives, saves to disk, confirms)
CODEBLOCK0
🔧 Setup (once per environment)
Run this once to install the CLI globally (avoids slow npx calls):
CODEBLOCK1
{skill} is the absolute path to the directory containing this SKILL.md file. Agents can resolve it at runtime:
CODEBLOCK2
⚡ Quick Start
You need an API key from the user? One command:
CODEBLOCK3
The script handles everything:
- - ✅ Starts server if not running (or reuses existing one)
- ✅ Creates a secure request with web form
- ✅ Detects existing tunnels (ngrok or localtunnel)
- ✅ Returns the URL to share with the user
- ✅ Polls until the secret is submitted
- ✅ Saves to
~/.config/openai/api_key (chmod 600) and exits
If the user is remote (not on the same network), add --tunnel:
CODEBLOCK4
This starts a localtunnel automatically (no account needed) and returns a public URL.
Output example:
CODEBLOCK5
Share the URL → user opens it → submits the secret → script saves to disk → done.
Without --service or --save, the script still polls and prints the secret to stdout (useful for piping or manual inspection).
Scripts
request-secret.sh — Request, receive, and save a secret (recommended)
CODEBLOCK6
| Flag | Description |
|---|
| INLINECODE8 | Description shown on the web form (required) |
| INLINECODE9 |
Auto-save to
~/.config/<name>/api_key |
|
--save <path> | Auto-save to explicit file path |
|
--env <varname> | Set env var (requires
--service or
--save) |
|
--tunnel | Start localtunnel if no tunnel detected (for remote users) |
|
--port <number> | Server port (default: 3000) |
|
--timeout <secs> | Max wait for startup (default: 30) |
|
--json | Output JSON instead of human-readable text |
check-server.sh — Server diagnostics (no side effects)
CODEBLOCK7
Reports server status, port, PID, and tunnel state (ngrok or localtunnel).
⏱ Long-Running Process — Use tmux
The request-secret.sh script blocks until the secret is submitted (it polls continuously). Most agent runtimes (including OpenClaw's exec tool) impose execution timeouts that will kill the process before the user has time to submit.
Always run Confidant inside a tmux session:
CODEBLOCK8
Why not exec? Agent runtimes typically kill processes after 30-60s. Since the script waits for human input (which can take minutes), it gets SIGKILL before completion. tmux keeps the process alive independently.
If your agent platform supports long-running background processes without timeouts, exec with request-secret.sh works fine. But when in doubt, use tmux.
Rules for Agents
- 1. NEVER ask users to paste secrets in chat — always use this skill
- NEVER reveal received secrets in chat — not even partially
- NEVER
curl the Confidant API directly — use the scripts - NEVER kill an existing server to start a new one
- NEVER try to expose the port directly (public IP, firewall rules, etc.) — use
--tunnel instead - ALWAYS share the URL with the user in chat — this is the entire point of the tool
- ALWAYS wait for the script to finish — it polls automatically and saves/outputs the secret; do not try to retrieve it yourself
- Use
--tunnel when the user is remote (not on the same machine/network) - Prefer
--service for API keys — cleanest convention - After receiving: confirm success, use the secret silently
Exit Codes (Scripts)
Agents can branch on exit codes for programmatic error handling:
| Code | Constant | Meaning |
|---|
| INLINECODE29 | — | Success — secret received (saved to disk or printed to stdout) |
| INLINECODE30 |
MISSING_LABEL |
--label flag not provided |
|
2 |
MISSING_DEPENDENCY |
curl,
jq,
npm, or
confidant not installed |
|
3 |
SERVER_TIMEOUT /
SERVER_CRASH | Server failed to start or died during startup |
|
4 |
REQUEST_FAILED | API returned empty URL — request not created |
|
≠0 | (from CLI) |
confidant request --poll failed (expired, not found, etc.) |
With --json, all errors include a "code" field for programmatic branching:
CODEBLOCK9
Example Agent Conversation
This is what the interaction should look like:
CODEBLOCK10
⚠️ Notice: the agent SENDS the URL and WAITS. It does NOT try to access the URL itself.
How It Works
- 1. Script starts a Confidant server (or reuses existing one on port 3000)
- Creates a request via the API with a unique ID and secure web form
- Optionally starts a localtunnel for public access (or detects existing ngrok/localtunnel)
- Prints the URL — agent shares it with the user in chat
- Delegates polling to
confidant request --poll which blocks until the secret is submitted - With
--service or --save: secret is saved to disk (chmod 600), then destroyed on server - Without
--service/--save: secret is printed to stdout, then destroyed on server
Tunnel Options
| Provider | Account needed | How |
|---|
| localtunnel (default) | No | INLINECODE54 flag or INLINECODE55 |
| ngrok |
Yes (free tier) | Auto-detected if running on same port |
The script auto-detects both. If neither is running and --tunnel is passed, it starts localtunnel.
Advanced: Direct CLI Usage
For edge cases not covered by the scripts:
CODEBLOCK11
If confidant is not installed globally, run bash {skill}/scripts/setup.sh first, or prefix with npx @aiconnect/confidant.
⚠️ Only use direct CLI if the scripts don't cover your case.
技能名称: confidant
详细描述:
Confidant
安全地从人类处接收秘密——无聊天暴露,无复制粘贴,无历史泄露。
🚨 关键流程——请先阅读此内容
这是一个人在回路的过程。您不能自行检索秘密。
- 1. 运行脚本 → 您将获得一个安全URL
- 在聊天中将URL发送给用户 ← 这是强制性的
- 等待用户在浏览器中打开URL并提交秘密
- 脚本处理其余部分(接收、保存到磁盘、确认)
❌ 不要自行curl/获取秘密URL——这是供人类使用的网页表单
❌ 不要跳过分享URL——用户必须在聊天中收到它
❌ 不要轮询API来检查秘密是否到达——脚本会执行此操作
❌ 在确认秘密已收到之前不要继续
✅ 分享URL → 等待 → 确认成功 → 静默使用秘密
🔧 设置(每个环境一次)
全局安装CLI(避免缓慢的npx调用):
bash
bash {skill}/scripts/setup.sh
{skill} 是包含此SKILL.md文件的目录的绝对路径。代理可以在运行时解析它:
bash
SKILL_DIR=$(find $HOME -name SKILL.md -path /confidant/skill -exec dirname {} \; 2>/dev/null | head -1)
然后使用:bash $SKILL_DIR/scripts/setup.sh
⚡ 快速开始
需要用户的API密钥?一个命令即可:
bash
bash {skill}/scripts/request-secret.sh --label OpenAI API Key --service openai
脚本处理一切:
- - ✅ 如果服务器未运行则启动(或复用现有服务器)
- ✅ 创建带有网页表单的安全请求
- ✅ 检测现有隧道(ngrok或localtunnel)
- ✅ 返回要与用户分享的URL
- ✅ 轮询直到秘密被提交
- ✅ 保存到~/.config/openai/api_key(chmod 600)并退出
如果用户是远程的(不在同一网络上),添加--tunnel:
bash
bash {skill}/scripts/request-secret.sh --label OpenAI API Key --service openai --tunnel
这会自动启动localtunnel(无需账户)并返回一个公共URL。
输出示例:
🔐 安全链接已创建!
URL: https://gentle-pig-42.loca.lt/requests/abc123
(隧道:localtunnel | 本地:http://localhost:3000/requests/abc123)
保存到:~/.config/openai/api_key
将上面的URL分享给用户。秘密在提交后或24小时后过期。
分享URL → 用户打开它 → 提交秘密 → 脚本保存到磁盘 → 完成。
如果没有--service或--save,脚本仍会轮询并将秘密打印到标准输出(适用于管道传输或手动检查)。
脚本
request-secret.sh — 请求、接收并保存秘密(推荐)
bash
保存到~/.config//api_key(约定)
bash {skill}/scripts/request-secret.sh --label SerpAPI Key --service serpapi
保存到显式路径
bash {skill}/scripts/request-secret.sh --label Token --save ~/.credentials/token.txt
保存并设置环境变量
bash {skill}/scripts/request-secret.sh --label API Key --service openai --env OPENAI
APIKEY
仅接收(不自动保存)
bash {skill}/scripts/request-secret.sh --label Password
远程用户——自动启动隧道
bash {skill}/scripts/request-secret.sh --label Key --service myapp --tunnel
JSON输出(用于自动化)
bash {skill}/scripts/request-secret.sh --label Key --service myapp --json
| 标志 | 描述 |
|---|
| --label <text> | 网页表单上显示的描述 (必需) |
| --service <name> |
自动保存到~/.config/
/api_key |
| --save | 自动保存到显式文件路径 |
| --env | 设置环境变量(需要--service或--save) |
| --tunnel | 如果未检测到隧道则启动localtunnel(用于远程用户) |
| --port | 服务器端口(默认:3000) |
| --timeout | 启动最大等待时间(默认:30) |
| --json | 输出JSON而非人类可读文本 |
check-server.sh — 服务器诊断(无副作用)
bash
bash {skill}/scripts/check-server.sh
bash {skill}/scripts/check-server.sh --json
报告服务器状态、端口、PID和隧道状态(ngrok或localtunnel)。
⏱ 长时间运行进程——使用tmux
request-secret.sh脚本会阻塞直到秘密被提交(它会持续轮询)。大多数代理运行时(包括OpenClaw的exec工具)会施加执行超时,这会在用户有时间提交之前杀死进程。
始终在tmux会话内运行Confidant:
bash
1. 在tmux中启动服务器
tmux new-session -d -s confidant
tmux send-keys -t confidant confidant serve --port 3000 Enter
2. 在第二个tmux窗口中创建请求
tmux new-window -t confidant -n request
tmux send-keys -t confidant:request confidant request --label API Key --service openai Enter
3. 与用户分享URL(从tmux输出读取)
tmux capture-pane -p -t confidant:request -S -30
4. 用户提交后,检查结果
tmux capture-pane -p -t confidant:request -S -10
为什么不用exec? 代理运行时通常会在30-60秒后杀死进程。由于脚本等待人类输入(可能需要几分钟),它会在完成前收到SIGKILL。tmux使进程独立存活。
如果您的代理平台支持无超时的长时间运行后台进程,使用exec配合request-secret.sh即可。但如有疑问,请使用tmux。
代理规则
- 1. 永远不要要求用户在聊天中粘贴秘密——始终使用此技能
- 永远不要在聊天中透露收到的秘密——即使部分也不可以
- 永远不要直接curl Confidant API——使用脚本
- 永远不要杀死现有服务器来启动新服务器
- 永远不要尝试直接暴露端口(公共IP、防火墙规则等)——改用--tunnel
- 始终在聊天中与用户分享URL——这是此工具的全部意义
- 始终等待脚本完成——它会自动轮询并保存/输出秘密;不要尝试自行检索
- 当用户是远程时使用--tunnel(不在同一台机器/网络上)
- 对于API密钥优先使用--service——最清晰的约定
- 接收后:确认成功,静默使用秘密
退出代码(脚本)
代理可以根据退出代码进行分支以进行程序化错误处理:
| 代码 | 常量 | 含义 |
|---|
| 0 | — | 成功——秘密已收到(保存到磁盘或打印到标准输出) |
| 1 |
MISSING_LABEL | 未提供--label标志 |
| 2 | MISSING_DEPENDENCY | 未安装curl、jq、npm或confidant |
| 3 | SERVERTIMEOUT / SERVERCRASH| 服务器启动失败或在启动期间崩溃 |
| 4 | REQUEST_FAILED | API返回空URL——请求未创建 |
| ≠0 | (来自CLI) | confidant request --poll失败(已过期、未找到等) |
使用--json时,所有错误都包含一个code字段用于程序化分支:
json
{ error: ..., code: MISSING_DEPENDENCY, hint: ... }
示例代理对话
交互应如下所示:
用户:你能设置我的OpenAI密钥吗?
代理:我将为您创建一个安全链接,以便安全提交您的API密钥。