@agenticprimitives/ap-kms

中文文档
0.0.0-alpha.31发布于 2026/10/26MITTypeScriptES Module零依赖近 30 天下载 2083

Manifest-driven managed-KMS orchestrator: provision per-identity Cloud-KMS HSM signing keys + per-key IAM, resolve each agent's Smart Agent (agent-naming), derive + verify the EVM delegate address, and push the minimal runtime secrets to deploy targets wi

原始使用文档

@agenticprimitives/ap-kms

Part of Agentic Primitives — the open-source trust substrate for agentic applications: identity that can sign, authority checked at act time, evidence the owner carries. Developer kit · All packages

Manifest-driven managed-KMS orchestrator. One declarative kms.manifest.json is the single source of truth for an app's signing identities; ap-kms apply then does every step to get Cloud-KMS signing working:

  1. Provision the keyring + a per-identity HSM secp256k1 signing key + per-key IAM (gcloud-free REST, via @agenticprimitives/key-custody/provision-gcp). Idempotent.
  2. Derive + report each key's EVM address (verify it before wiring).
  3. Resolve each agent-naming name → its Smart Agent address (@agenticprimitives/agent-naming).
  4. Wire the minimal runtime secrets to each deploy target via an app-supplied secret writer with no terminal echo — --write. The orchestrator is provider-agnostic; concrete deploy-platform code (Cloudflare/Vercel/…) lives in the app and is injected as writeSecret (ADR-0020).

The one human step it never does is the owner-signed delegation leaf (Smart Agent → KMS key), produced by the content-signer ceremony. ap-kms apply reports per-identity whether it's bound; ap-kms verify confirms each agent's live KMS delegate (derived from the key) still equals the owner-authorized delegate stored in the deployment's bindings, and that the stored SA matches the name's on-chain resolution.

Design

The core (@agenticprimitives/ap-kms) is pure — the provisioner, name resolver, address derivation, stored-bindings reader, and secret writer are all injected (KmsOrchestratorDeps). This keeps key-custody a leaf and the orchestration testable. The node wiring (@agenticprimitives/ap-kms/node) assembles the provider-agnostic implementations (provisioner / derivation / resolver / bindings reader) and the fs manifest loader; the deploy-platform secret writer stays in the app and is injected:

import { applyKmsManifest } from '@agenticprimitives/ap-kms';
import { loadManifest, makeNodeDeps } from '@agenticprimitives/ap-kms/node';
import { writeSecret } from './my-app-secret-writers.js'; // app-owned: switches on deployment.platform

const manifest = loadManifest('kms.manifest.json');
await applyKmsManifest(manifest, makeNodeDeps(manifest, { writeSecret }), { write: true });

deployment.platform is an opaque tag; the app's writeSecret(deployment, name, value) decides how to push the secret (e.g. a worker secret CLI, a hosting-provider REST API). No provider hostnames or provider-specific code live in this package.

CLI

ap-kms apply                          # provision + IAM + derive + resolve SA + REPORT (no secret writes)
ap-kms apply --write --writers ./w.js  # also push runtime secrets via the app-supplied writer module
ap-kms apply --dry-run                # print the plan only (no GCP mutations)
ap-kms verify                         # read-only drift check vs. stored owner-authorized delegations
ap-kms <cmd> --manifest path/to/kms.manifest.json

--writers <module> is dynamically imported and must export writeSecret(deployment, name, value) (or default-export it). The naming RPC URL comes from the env var named by manifest.naming.rpcUrlEnv (kept out of the manifest because it carries an API key).

版本与发布记录

@agenticprimitives/ap-kms 共发布 27 个版本,首次发布于 2026/06/18;过去 12 个月发布了 27 个版本。

版本发布日期距今
0.0.0-alpha.31latest2026/10/2612 天前
0.0.0-alpha.302026/10/1722 天前
0.0.0-alpha.292026/10/1622 天前
0.0.0-alpha.282026/10/1622 天前
0.0.0-alpha.272026/10/1622 天前
0.0.0-alpha.262026/10/1622 天前

关于 @agenticprimitives/ap-kms 的常见问题

@agenticprimitives/ap-kms 是什么?

Manifest-driven managed-KMS orchestrator: provision per-identity Cloud-KMS HSM signing keys + per-key IAM, resolve each agent's Smart Agent (agent-naming), derive + verify the EVM delegate address, and push the minimal runtime secrets to deploy targets wi

如何安装 @agenticprimitives/ap-kms?

在项目目录运行 npm install @agenticprimitives/ap-kms,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:viem(^2.52.2)、@agenticprimitives/types(^1.0.0-alpha.45)、@agenticprimitives/key-custody(^1.0.0-alpha.45)、@agenticprimitives/agent-naming(^1.0.0-alpha.45)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 ap-kms,可以用 npx ap-kms 直接运行。

@agenticprimitives/ap-kms 支持 TypeScript 吗?

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

@agenticprimitives/ap-kms 支持 ESM 还是 CommonJS?

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

@agenticprimitives/ap-kms 可以商用吗?

@agenticprimitives/ap-kms 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@agenticprimitives/ap-kms 的下载量有多少?

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

@agenticprimitives/ap-kms 还在维护吗?

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