架构

┌─────────────────────────────────────────────────────────┐
│                   AI Agent (Hermes / LLM)                │
│  "run psql with DATABASE_URL"                            │
└────────────────────┬────────────────────────────────────┘
                     │ CLI / HTTP
                     ▼
┌─────────────────────────────────────────────────────────┐
│                   trustless CLI                          │
│                                                         │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐              │
│  │ secret   │  │ run      │  │ proxy    │              │
│  │ (list/   │  │ (subproc │  │ (HTTP    │              │
│  │  get/set)│  │  inject) │  │  proxy + │              │
│  └────┬─────┘  └────┬─────┘  │  MITM)   │              │
│       │             │        └─────┬─────┘              │
│       │             │              │                    │
│  ┌────┴─────────────┴──────────────┴─────┐              │
│  │            Backend Interface          │              │
│  │  (pass / env / bitwarden — swappable) │              │
│  └─────────────────────┬──────────────────┘             │
└────────────────────────┼────────────────────────────────┘
                          │
            ┌─────────────┴─────────────┐
            │                           │
            ▼                           ▼
     ┌──────────────┐          ┌──────────────┐
     │  pass store   │          │  Target API   │
     │  (GPG + pass) │          │  / Service    │
     └──────────────┘          └──────────────┘

后端抽象

凭据解析器被抽象为简单接口:

type Backend interface {
    Resolve(ctx context.Context, key string) (string, error)
    List(ctx context.Context) ([]Entry, error)
}

已实现的后端:

  • pass(默认)—— 封装 pass show <key>,读取第一行作为密钥
  • env —— 通过 os.Getenv() 从环境变量读取(用于 CI/CD、容器)
  • bitwarden —— 封装 bw CLI(bw list items),解析 secureNote fields[value] / 登录密码 / notes 首行。会话密钥通过 BW_SESSION 环境变量传递(绝不经过 argv)。通过 trustless bw-unlock 解锁(会话密钥保存到 ~/.config/trustless/bw-session,0600)。会话无效时 fail closed。详见 docs/bitwarden-backend-design.md

通过 trustless config set backend <name> 配置。