@agenticprimitives/identity-directory-adapters

中文文档
1.0.0-alpha.46发布于 2026/10/26MITTypeScriptES Module零依赖近 30 天下载 4038

Port implementations for @agenticprimitives/identity-directory: NamingPort (wraps agent-naming), OnChainReadPort (viem readContract), IndexerPort (in-memory; SPARQL/GraphDB later). The one composition layer allowed to import agent-naming (spec 100 §4 / AD

原始使用文档
文档目录7 节
  1. What's here
  2. Usage
  3. How it's different
  4. Boundaries
  5. Validation
  6. Status
  7. License

@agenticprimitives/identity-directory-adapters

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

The binding layer that keeps the directory honest. identity-directory can promise "indexer proposes, on-chain confirms" only because its core never touches a real data source — it declares ports, and this package implements them. That separation is enforced, not aspirational: this is the one package allowed to import agent-naming (spec 100 §4 / ADR-0015), so every naming read in the identity stack flows through one auditable seam. Adapters translate sources into ports and add no policy of their own.

Part of agenticprimitives — the trust substrate for the agent economy: one canonical Smart Agent identity with custody, delegation, naming, credentials, and audit evidence designed as one system.

What's here

makeNamingPort({ client, chainId })   wrap agent-naming + eip155 Address↔CanonicalAgentId lift
makeOnChainReadPort(readers)          assemble OnChainReadPort from { exists, confirmsCredential }
viemExists(client)                    a contract-agnostic exists (bytecode-at-address)
createInMemoryIndexer(entries)        an in-memory IndexerPort (demo + tests)
toCanonicalAgentId / addressOf        eip155 CAIP-10 glue

Usage

import { createDirectory } from '@agenticprimitives/identity-directory';
import {
  makeNamingPort, makeOnChainReadPort, viemExists, createInMemoryIndexer,
} from '@agenticprimitives/identity-directory-adapters';

const dir = createDirectory({
  naming: makeNamingPort({ client: namingClient, chainId: 8453 }),
  onChain: makeOnChainReadPort({
    exists: viemExists(publicClient),
    // app-wired to the real membership getter (isCustodian/isTrustee):
    confirmsCredential: async (id, p) => publicClient.readContract({ /* … */ }),
  }),
  indexer: createInMemoryIndexer(seedEntries),
});

How it's different

The competing pattern is the monolithic indexer/resolver SDK — one client that talks to every source and bakes resolution policy into the data access. The cost shows up later: you cannot swap a source, cannot audit which mechanism answered a query, and the index silently becomes authoritative. The ports-and-adapters split here means:

  • Sources are swappable. Naming, on-chain reads, and the indexer are independent factories; a new source for an existing port is one new factory, not a rewrite.
  • Authority placement is visible in the types. confirmsCredential is a live on-chain membership check, the indexer is a proposer — the interfaces make it impossible to confuse the two.
  • No adapter ever escalates. Each port is one mechanism; there is no try naming, catch → on-chain fallback anywhere (ADR-0013), and reads are readContract/getCode only — never eth_getLogs (ADR-0012).

Boundaries

  • confirmsCredential is app-wired — the on-chain membership getter is contract- and credential-kind-specific (an EOA address vs a passkey credentialIdDigest), so this package does not guess it. It MUST reflect the current set so a revoked credential returns false (the directory drops it). Never wire it to a cached or event-derived list that could revive a revoked credential.
  • The in-memory indexer is non-authoritative — it proposes candidates; the directory confirms them on-chain. The production indexer is a SPARQL/GraphDB adapter (spec 225 §7), landing later.
  • CAIP-10 here is eip155-only glue; the canonical multi-namespace builder is @agenticprimitives/agent-profile (/caip10), deliberately kept out of this adapter's dependency set.

Validation

pnpm --filter @agenticprimitives/identity-directory build   # core dist (vitest resolution)
pnpm --filter @agenticprimitives/identity-directory-adapters typecheck
pnpm --filter @agenticprimitives/identity-directory-adapters test
pnpm check:forbidden-terms

Status

Testnet/pilot-ready. Production launch is gated on the public checklist in the root README.md — including third-party contract audit and governance key rotation. Track every security finding live in docs/audits/findings.yaml. The shipped indexer is the in-memory reference (demo + tests); the production SPARQL/GraphDB adapter is roadmap.

License

UNLICENSED (internal monorepo, not published).

版本与发布记录

@agenticprimitives/identity-directory-adapters 共发布 45 个版本,首次发布于 2026/06/01;过去 12 个月发布了 45 个版本。

版本发布日期距今
1.0.0-alpha.46latest2026/10/2612 天前
1.0.0-alpha.452026/10/2612 天前
1.0.0-alpha.442026/10/1721 天前
1.0.0-alpha.432026/10/1722 天前
1.0.0-alpha.422026/10/1622 天前
1.0.0-alpha.412026/10/1622 天前

其他发布通道:alpha → 0.1.0-alpha.2。

关于 @agenticprimitives/identity-directory-adapters 的常见问题

@agenticprimitives/identity-directory-adapters 是什么?

Port implementations for @agenticprimitives/identity-directory: NamingPort (wraps agent-naming), OnChainReadPort (viem readContract), IndexerPort (in-memory; SPARQL/GraphDB later). The one composition layer allowed to import agent-naming (spec 100 §4 / AD

如何安装 @agenticprimitives/identity-directory-adapters?

在项目目录运行 npm install @agenticprimitives/identity-directory-adapters,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:viem(^2.52.2)、@agenticprimitives/types(^1.0.0-alpha.46)、@agenticprimitives/agent-naming(^1.0.0-alpha.46)、@agenticprimitives/identity-directory(^1.0.0-alpha.46)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@agenticprimitives/identity-directory-adapters 支持 TypeScript 吗?

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

@agenticprimitives/identity-directory-adapters 支持 ESM 还是 CommonJS?

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

@agenticprimitives/identity-directory-adapters 可以商用吗?

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

@agenticprimitives/identity-directory-adapters 的下载量有多少?

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

@agenticprimitives/identity-directory-adapters 还在维护吗?

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