@agenticprimitives/a2a

中文文档
0.0.0-alpha.48发布于 2026/10/26MITTypeScriptES Module近 30 天下载 6788

Async, delegation-authorized Agent-to-Agent (A2A) task transport: Task/Message/Artifact runtime over a TaskStore port, JSON-RPC method handlers, SkillHandler dispatch, the A2aWireAdapter client, and scoped-grant caveat builders. Transport-agnostic core (s

原始使用文档
文档目录8 节
  1. What ships
  2. Boundary
  3. How it's different
  4. Validation
  5. Status
  6. License
  7. The pairwise asker
  8. Reference

@agenticprimitives/a2a

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

Agent-to-agent calls gated by the same delegations as everything else. Agent discovery and identity are being settled right now — ERC-8004 went to mainnet, agent naming services launched, agent cards are becoming the lingua franca of discovery. What none of that settles is authority: when agent A sends agent B a task, what proves A was allowed to ask, for exactly that skill, within exactly those limits? This package answers with the agenticprimitives delegation primitive — the same EIP-712, caveat-constrained, on-chain-revocable grant that authorizes a web session, an MCP tool, and an on-chain spend. One delegation model, everywhere; A2A is not the exception.

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.

Concretely: an async, delegation-authorized Agent-to-Agent task transport. Any claimed agent sends any other an asynchronous, delegation-scoped task and collects the result by poll, push, or stream. Built on the @agenticprimitives/fulfillment Task substrate; specified in spec 269.

What ships

All five implementation waves have landed:

  • Task runtime core — newTaskRecord, applyTransition (fail-closed via canTaskTransition), dispatchTask, the TaskStore port + an in-memory reference implementation, and the SkillHandler contract. Unknown skill → rejected, never silently dropped.
  • Delegation-auth gate — authorizeA2aMessage: delegate === requester, timestamp window, target + skill scoping via caveats, on-chain isRevoked + ERC-1271 injected fail-closed, signed message, single-use message-id. Plus buildA2aGrantCaveats and hashA2aMessage.
  • Agent surface — createA2aAgent (message/send → authorize + persist; tasks/get + tasks/cancel with party auth; alarm-driven processDue; agent card) + JSON-RPC 2.0 handlers (dispatchA2aRpc / handleA2aRpcBody) + the A2aWireAdapter client over an injected transport.
  • Vault body residency + signed push — message and artifact bodies live in the assignee's vault; only hashes/refs appear in task state. Terminal results are delivered as signed push envelopes (deliverPush / verifyPushEnvelope) with bounded retry, or streamed via SSE framing, or polled via tasks/get.
  • Two-agent acceptance harness — the happy path, delegation-gate denials at the agent surface, a cross-vault entitlement deposit, and the auth-required round-trip via resubmit, all exercised in test/harness.test.ts.
import { newTaskRecord, dispatchTask, buildSkillRegistry, createInMemoryTaskStore } from '@agenticprimitives/a2a';

Boundary

The core is transport-agnostic — no Cloudflare coupling in src/. The Durable Object-backed TaskStore adapter (createDurableObjectTaskStore) ships as the ./cloudflare subpath. See ADR-0034. mcp-runtime is a consumer of this package, not the owner — no back-edges.

How it's different

The competing pattern is A2A protocol SDKs and agent-framework messaging — transports that move tasks but treat authorization as someone else's problem (a bearer token, a shared secret, an allow-list). Three things this package does that they structurally cannot:

  • No task without a verifiable grant. A task record is only created when the delegation gate verifies the grant; task.permissionGrantRef pins the delegation hash, and an on-chain revocation fails the task in flight, closed.
  • Authorization is not identity. The caveats and assignee decide what may happen; the signed token proves who asked. A delegator never reaches another principal's namespace, and no claimed agent holds a long-lived signing key — KMS/session signers only.
  • Bodies stay in the vault. Task state carries hashes and refs; payloads live in the assignee's vault with its own access control. The transport never becomes the data store.

Because the gate is the same delegation primitive used across the substrate, "this agent may invoke that agent's summarize skill until Friday, revocable instantly" is one grant — verifiable on chain, auditable end to end.

Validation

pnpm --filter @agenticprimitives/a2a typecheck
pnpm --filter @agenticprimitives/a2a test

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 runtime runs end to end in the demo apps against Base Sepolia (ERC-1271 + isRevoked checks bound to chain).

License

UNLICENSED (internal monorepo, not published).

The pairwise asker

A service that wants to know a returning person without learning who she is declares the card extension AP_PAIRWISE_ASKER_EXTENSION_URI (pairwiseAskerCardExtension(audience)). The card decides the asker's form: when sendSubjectAskOverWire finds the extension it sends { pairwise, audience } — a per-service pseudonym from the pairwiseSubjectFor port — and no credential, no session, no address. A card that declares the extension and a sender with no pseudonym to give is refused, never answered with the credentialed form. validatePairwiseSubjectAsk refuses an asker that carries anything beyond its subject and audience; routedAskOf reads either form.

Reference

Boundary (ADR-0034). This package is the transport-agnostic core: the task runtime over a TaskStore port, the SkillHandler contract and dispatcher, the A2aWireAdapter client, the delegation-auth gate and the scoped-grant caveat builders. The Cloudflare TaskStoreDO (a Durable Object TaskStore with alarm()) ships as the ./cloudflare subpath. It diverges from spec 245's placement under mcp-runtime on purpose: mcp-runtime is a consumer (the receiving gate and the a2a→mcp delivery leg), not the owner. Spec 269 W1–W5 are the record (runtime, gate, createA2aAgent, the Cloudflare store, vault body residency, signed push and SSE, the two-agent acceptance harness test/harness.test.ts).

The wire (spec 372). src/standard/ (imported as @agenticprimitives/a2a/standard) is A2A 1.0 as the official TCK tests it: PascalCase methods, proto-JSON shapes, A2A-Version, ErrorInfo on every A2A error, SSE, push. There is no second set of method names. createStandardA2aServer({card, executor, principal?, canSeeTask?, beforeSend?, onCancel?}) is fetch-shaped; the executor emits events through ctx. Authority rides as an extension: a SendMessage carrying AP_DELEGATED_TASK_EXTENSION is a delegation-authorized task (standard/delegated.ts), and createAgentBackedServer puts the runtime behind it with every gate it always had. The Authorization header says who is CALLING (caller.ts); the envelope's signature says who AUTHORED the message; a relay may carry a message it did not write, so the two are never collapsed. canSeeTask answers a non-party TaskNotFound. tck/sut.mjs + scripts/run-a2a-tck.sh run the TCK in CI; ./conform (ap conform a2a <url>) probes a live agent's card and binding.

Promoted from the runtime (spec 399 §4). standard/mount.ts: withStandardCardFields, isRuntimeTaskId, runtimeBackedTaskStore, principalBySchemes (Bearer = person, A2A-Session = agent, never each other's fallback), delegatedDispatch, settlementForReplyKind, settleTask. subject-hop.ts: sendSubjectAskOverWire (resolves through the card, digest pin), subjectAskOf, subjectAnswerOf, handoffOf, SUBJECT_ANSWER_ARTIFACT; spec 433's subjectAnswerEnvelope / subjectAnswerArtifact; standard/app-delegation.ts (appDelegationAsk). wire-verify.ts: verifyDelegationWire, the delegate-key tail every A2A service repeats (identity, caveats, revocation, signature).

Agent-card audiences (spec 338 §8). agentCard(forAudience?) projects by SkillHandler.exposure (public, authenticated, private, service-only; omitted means public). Passing an audience is not authenticating one: createCardAudienceResolver verifies a signed challenge (nonce consumed before the signature is read, x-ap-* headers) and degrades to public on any failure; privateViewPolicy is a separate injected decision. Visibility is disclosure, not authorization.

版本与发布记录

@agenticprimitives/a2a 共发布 48 个版本,首次发布于 2026/06/11;过去 12 个月发布了 48 个版本。

版本发布日期距今
0.0.0-alpha.48latest2026/10/2610 天前
0.0.0-alpha.472026/10/2610 天前
0.0.0-alpha.462026/10/1720 天前
0.0.0-alpha.452026/10/1720 天前
0.0.0-alpha.442026/10/1720 天前
0.0.0-alpha.432026/10/1620 天前

其他发布通道:alpha → 0.0.0-alpha.3。

关于 @agenticprimitives/a2a 的常见问题

@agenticprimitives/a2a 是什么?

Async, delegation-authorized Agent-to-Agent (A2A) task transport: Task/Message/Artifact runtime over a TaskStore port, JSON-RPC method handlers, SkillHandler dispatch, the A2aWireAdapter client, and scoped-grant caveat builders. Transport-agnostic core (s

如何安装 @agenticprimitives/a2a?

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

@agenticprimitives/a2a 支持 TypeScript 吗?

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

@agenticprimitives/a2a 支持 ESM 还是 CommonJS?

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

@agenticprimitives/a2a 可以商用吗?

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

@agenticprimitives/a2a 的下载量有多少?

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

@agenticprimitives/a2a 还在维护吗?

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