@agenticprimitives/agent-relationships

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

Agent relationships SDK: trust-fabric edge store (subject, object, relationshipType) with role taxonomy. Phase 1 ships edge-ID derivation + relationship-type constants + client skeleton; AgentRelationship.sol + RelationshipTypeRegistry.sol ports land in P

原始使用文档
文档目录10 节
  1. Install
  2. Usage
  3. Edge-ID derivation (pure)
  4. Relationship type + role taxonomy
  5. Relationships client (Phase 2+)
  6. How it's different
  7. Subpath exports
  8. Security invariants
  9. Status
  10. License

@agenticprimitives/agent-relationships

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

EXPERIMENTAL — do NOT use for confidential edges.

This package writes the trust-fabric edge graph publicly on-chain. Every edge — its endpoints, type, role set, and status — is visible to anyone reading the chain, forever. There is no on-chain confidentiality for the fact that an edge exists.

That means this package is structurally incompatible with use-cases that bring a confidentiality requirement: financial counterparty graphs, medical referral networks, B2B partnership relationships under NDA, family/household membership, or any "who is connected to whom" graph where the connection itself is the secret. The metadata-hash field anchors off-chain JSON but cannot hide the existence of the edge or the identity of its endpoints.

Concrete public exposure per edge: subject address, object address, relationshipType (e.g. HAS_MEMBER, HAS_GOVERNANCE_OVER), role set on each side, EdgeStatus lifecycle (proposed/confirmed/active/revoked), and the actor address that submitted each state transition.

Private links — including every person↔org link — belong in related-agents (holder-resident vault credentials, ADR-0025). A future v2 private-edge variant (commitment-based, with selective-disclosure proofs) will live alongside this package. Until it ships, adopters requiring confidentiality should not use this package and should hold their relationship graph in an off-chain store with explicit access control.

Tracked as the Privacy Fork (audit PKG-agent-relationships-001 / EXT-019). capability.manifest.json sets "stability": "experimental".

A trust graph between addresses, not accounts in someone's database. As agents take on real work, the question moves from "who is this agent?" to "who stands behind it — which org is it a member of, who governs it, who vouches for it?" Most systems answer with rows in a vendor database that vanish when the vendor does. This package answers with on-chain edges between canonical Smart Agent addresses: an Edge is a (subject, object, relationshipType) triple with a role set on each side, a status lifecycle (PROPOSED → CONFIRMED → ACTIVE → REVOKED), and optional off-chain metadata anchored by a deterministic content hash. Because the endpoints are the canonical identities themselves (ADR-0010), edges survive credential rotation, name changes, and every other facet swap.

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.

Where agent-naming resolves names → addresses and agent-profile owns the profile layer, this package owns the relationship layer: the public graph of org membership, governance assertions, partnerships, and validation trust that other layers compose against.

Layer: Discover — the trust graph (not canonical identity — that is agent-account). Canonical key: Smart Agent addresses. An edge connects anchors; an edge is not a delegation.

Install

Workspace-internal in the agenticprimitives monorepo; not yet published.

Usage

Edge-ID derivation (pure)

import {
  computeEdgeId,
  RELATIONSHIP_TYPE,
} from '@agenticprimitives/agent-relationships';

const id = computeEdgeId(
  '0x1111…1111',                              // subject
  '0x2222…2222',                              // object
  RELATIONSHIP_TYPE.HAS_MEMBER,               // type (bytes32 hash)
);
//   0x… — keccak256 of packed (subject || object || typeId)

Same triple → same edge ID; idempotent propose comes for free. Direction matters for non-symmetric types (HAS_MEMBER(A→B) ≠ HAS_MEMBER(B→A)), and self-edges are refused.

Relationship type + role taxonomy

import {
  RELATIONSHIP_TYPE,
  ROLE,
  TYPE_SEMANTICS,
} from '@agenticprimitives/agent-relationships/taxonomy';

RELATIONSHIP_TYPE.HAS_MEMBER;        // bytes32 — keccak256("HAS_MEMBER")
RELATIONSHIP_TYPE.PARTNERSHIP;       // bytes32 — symmetric
RELATIONSHIP_TYPE.HAS_GOVERNANCE_OVER; // bytes32 — hierarchical

ROLE.BOARD_MEMBER;                   // bytes32 — keccak256("BOARD_MEMBER")
ROLE.TREASURER;                      // bytes32

TYPE_SEMANTICS[RELATIONSHIP_TYPE.PARTNERSHIP].symmetric;     // true
TYPE_SEMANTICS[RELATIONSHIP_TYPE.HAS_GOVERNANCE_OVER].hierarchical; // true

NAMESPACE_CONTAINS is intentionally absent — naming hierarchy lives in agent-naming via parent-pointer per ADR-0006, so no parallel authority can drift.

Relationships client (Phase 2+)

import {
  AgentRelationshipsClient,
  RELATIONSHIP_TYPE,
  ROLE,
} from '@agenticprimitives/agent-relationships';

const rel = new AgentRelationshipsClient({
  rpcUrl: 'https://base-sepolia.g.alchemy.com/v2/…',
  chainId: 84532,
});

// Read (Phase 2+)
const edges = await rel.listEdgesFor('0x…', { relationshipType: RELATIONSHIP_TYPE.HAS_MEMBER });

// Write (Phase 4+)
await rel.proposeEdge({
  subject: '0xAlice…',
  object:  '0xAcme…',
  relationshipType: RELATIONSHIP_TYPE.HAS_MEMBER,
  subjectRoles: [ROLE.BOARD_MEMBER],
});
await rel.confirmEdge({ edgeId: '0x…', selfRoles: [] });

Each write is authorized via the actor's Smart Agent ERC-1271 → its CustodyPolicy module. The relationships package itself stays custody-agnostic (no @agenticprimitives/account-custody import).

How it's different

The competing category is social/trust-graph products and registry "endorsement" features — follower edges, attestation lists, org charts held in an app database:

  • Bilateral by construction. A non-symmetric edge requires confirmation from both sides before it can influence anything (Phase 3+ contract enforcement); a PROPOSED edge is a claim, not a fact. Either party can revoke unilaterally, permissionlessly.
  • Edges connect identities, not handles. Both endpoints are canonical Smart Agent addresses, so the graph cannot be orphaned by a renamed handle or a rotated key.
  • An edge is not authority. HAS_GOVERNANCE_OVER asserts a relationship; it grants nothing. Authority is always a delegation or a custody-policy operation — separate primitives, separate packages. Graph products routinely blur this line; the package boundary here makes the blur impossible.

Subpath exports

  • @agenticprimitives/agent-relationships/taxonomy — relationship-type + role constants + semantics map.

Security invariants

  • Edge ID is deterministic — keccak256(subject || object || relationshipType); off-chain and on-chain derivations always match.
  • computeEdgeId refuses self-edges (subject === object).
  • Relationship-type + role IDs are keccak256(name) (matches Solidity keccak256(bytes(name))) — bytes32 hashes, not raw strings, preventing cross-namespace collisions.
  • Two-side confirmation for non-symmetric types (Phase 3+ contract enforcement).
  • Permissionless revocation from either side (Phase 3+).
  • Custody-agnostic — authority always routes through the actor's Smart Agent ERC-1271.
  • NAMESPACE_CONTAINS is intentionally absent (ADR-0006).

See AUDIT.md for the package audit + open findings.

Status

Experimental, and Phase 1 — pure SDK + spec + API skeleton. The pure layer (computeEdgeId, taxonomy, semantics map) is real and tested; client read methods throw R Phase 2 and write methods throw R Phase 4 — stubs by design. Contracts (AgentRelationship.sol + RelationshipTypeRegistry.sol) land in Phase 3. AgentAssertion (signed-claim layer) and AgentRelationshipResolver (policy layer) are deferred to v2 per ADR-0007. Full design + phase plan: specs/216-agent-relationships.md.

Beyond the package phases: testnet/pilot-ready posture only; production launch is gated on the public checklist in the root README.md. Track every security finding live in docs/audits/findings.yaml — and re-read the confidentiality warning at the top before adopting.

License

UNLICENSED (internal monorepo, not published).

版本与发布记录

@agenticprimitives/agent-relationships 共发布 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/agent-relationships 的常见问题

@agenticprimitives/agent-relationships 是什么?

Agent relationships SDK: trust-fabric edge store (subject, object, relationshipType) with role taxonomy. Phase 1 ships edge-ID derivation + relationship-type constants + client skeleton; AgentRelationship.sol + RelationshipTypeRegistry.sol ports land in P

如何安装 @agenticprimitives/agent-relationships?

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

@agenticprimitives/agent-relationships 支持 TypeScript 吗?

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

@agenticprimitives/agent-relationships 支持 ESM 还是 CommonJS?

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

@agenticprimitives/agent-relationships 可以商用吗?

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

@agenticprimitives/agent-relationships 的下载量有多少?

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

@agenticprimitives/agent-relationships 还在维护吗?

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