@agentproto/secrets

中文文档
2.2.0发布于 2026/10/27Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 6228

@agentproto/secrets — AIP-19 SECRETS.md reference implementation. A workspace-level manifest format for declaring secret slugs, their purpose, access grants, and audit metadata — without ever storing the values themselves. Hosts resolve slugs against a re

原始使用文档
文档目录5 节
  1. Usage
  2. capture — vault a CLI's own OAuth login locally
  3. Exposure surface ( @agentproto/secrets/exposure )
  4. mcp-header — brokered MCP auth
  5. License

@agentproto/secrets

AIP-19 SECRETS.md reference implementation. A workspace-level manifest format for declaring secret slugs, their purpose, access grants, and audit metadata — without ever storing the values themselves. Hosts resolve slugs against a real vault at reveal time.

Status: 0.1.0-alpha. Generated by scripts/scaffold-aip.mjs — build() and validate() bodies are TODOs.

Spec: https://agentproto.sh/docs/aip-19

Usage

import { defineSecrets } from "@agentproto/secrets"

const x = defineSecrets({
  id: "my-secrets",
  description: "Short purpose.",
  // ...
})

capture — vault a CLI's own OAuth login locally

agentproto-secrets capture [--provider <recipe>] [--vault-dir <dir>] reads a coding CLI's subscription OAuth login through its builtin recipe's oauth field map (the full AIP-19 oauth shape {accessToken, refreshToken, expiresAt}), seals it to the vault's own local keypair (<dir>/key.json, 0600, minted on first run), and writes entries/<provider>.json (0600). It prints a capability pointer (agentproto-secrets://vault/<provider>?method=…&key=…) — the token values are never printed, logged, or written in the clear. If the CLI has no local login yet (claude login / codex login not run), the command exits 1 and says to run the CLI's own login first; it never spawns a second login client.

Trust boundary: the vault keypair lives in plaintext at <dir>/key.json (0600) next to the sealed entries, so at-rest confidentiality rests on filesystem permissions — any read of the vault dir (backup, sync, a compromised local account) yields key and ciphertext together. This is a LOCAL vault only: for sending the credential to a server without exposing the plaintext, use provision (seal to the target's own key first).

Exposure surface (@agentproto/secrets/exposure)

The manifest says which secrets exist; an exposure says how a resolved secret reaches a runtime. SecretExposure is a discriminated union — one kind per delivery mechanism, so consumers filter with the isExposureKind guard and handle each with one switch case:

kindDelivers the secret as…
envan environment variable on the agent process
filea file written into the workspace
egress-substitutea $$SECRET[NAME]$$ placeholder substituted on egress
mcp-headeran HTTP auth header on an MCP server's transport
import { isExposureKind, type SecretExposure } from "@agentproto/secrets/exposure"

const headerExposures = exposures.filter(e => isExposureKind(e, "mcp-header"))

mcp-header — brokered MCP auth

interface McpHeaderExposure {
  kind: "mcp-header"
  credentialPath: string   // broker path: "<providerId>" or "<providerId>/<account>"
  server?: string          // optional upstream override, forwarded to the broker
}

resolveMcpHeaderExposure(exposure, resolver, { signal }) turns that path into a ready-to-use header map. The resolver is a structural McpHeaderResolver (resolveHeaders({ path, server?, signal? })) — the CredentialBroker from @agentproto/auth satisfies it with no adapter, so this package stays dependency-free of auth while still driving it.

Every resolved header value is run through assertSafeSecretValue before return — a value containing CR/LF/NUL is rejected, closing off header-injection (a smuggled newline can't append extra header lines onto the transport).

import { resolveMcpHeaderExposure } from "@agentproto/secrets/exposure"
import { CredentialBroker } from "@agentproto/auth"

const headers = await resolveMcpHeaderExposure(exposure, broker, { signal })
// → { Authorization: "Bearer …" }, guarded

The same guard (assertSafeSecretValue) and the $$SECRET[NAME]$$ engine (substituteSecrets, SECRET_PLACEHOLDER_PATTERN, formatPlaceholder) are exported from this subpath for the egress-substitute path.

License

MIT — see LICENSE.

版本与发布记录

@agentproto/secrets 共发布 20 个版本,首次发布于 2026/06/21;过去 12 个月发布了 20 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.2.0latest2026/10/279 天前
2.1.12026/10/1918 天前
2.1.02026/10/1621 天前
2.0.22026/10/1422 天前
2.0.12026/10/1026 天前
2.0.02026/10/0729 天前

关于 @agentproto/secrets 的常见问题

@agentproto/secrets 是什么?

@agentproto/secrets — AIP-19 SECRETS.md reference implementation. A workspace-level manifest format for declaring secret slugs, their purpose, access grants, and audit metadata — without ever storing the values themselves. Hosts resolve slugs against a re

如何安装 @agentproto/secrets?

在项目目录运行 npm install @agentproto/secrets,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 agentproto-secrets,可以用 npx agentproto-secrets 直接运行。

@agentproto/secrets 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agentproto/secrets 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@agentproto/secrets 可以商用吗?

@agentproto/secrets 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@agentproto/secrets 的下载量有多少?

根据 npm 官方下载统计,@agentproto/secrets 在 2026/10/05 – 2026/11/03 这 30 天内被下载 6,228 次,日均约 208 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agentproto/secrets 还在维护吗?

最新版本 2.2.0 发布于 2026/10/27(9 天前);至今共发布 20 个版本,其中过去 12 个月发布了 20 个;首次发布于 2026/06/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。