@datalayer/personal-agent-protocol

中文文档
0.32.0发布于 2026/11/08BSD-3-ClauseTypeScriptES Module构建来源已验证近 30 天下载 1.3万

TypeScript SDK for Personal Agent Protocol 0.4 (2026-11-06) and its Operations extension v2

原始使用文档
文档目录15 节
  1. Understand PAP in one minute
  2. Install and discover a company
  3. Python
  4. TypeScript
  5. Reactor is the extension foundation
  6. What is implemented
  7. What is not implemented yet
  8. Security boundary
  9. Command line
  10. Examples and first consumer
  11. Develop the SDKs
  12. Python
  13. TypeScript
  14. Learn more
  15. License

Datalayer

🤖 🌸 Personal Agent Protocol

Python and TypeScript SDKs for the Personal Agent Protocol: both implement version 0.4 (2026-11-06), the draft as of upstream 46beb21, and its Operations extension v2. See Compatibility, Migration, the conformance report, and Support.

Personal Agent Protocol demo

PAP lets a personal agent discover and talk to a company's agent on behalf of a person. The company remains responsible for its identity, authorization, data, and actions; the personal agent does not need the person's company password or a copy of their account data.

Understand PAP in one minute

A typical interaction has five parts:

  1. Discover — the personal agent reads the company's public /.well-known/poppy.json document.
  2. Start a Session — the personal agent names a new Session itself, signed out, and signs a Session JWT for each request.
  3. Converse — the personal agent can ask questions without disclosing the person's company identity.
  4. Sign in when required — the company opens its own authorization page. Credentials remain between the person and the company.
  5. Continue safely — the same conversation resumes with an access token for the scopes the person approved, beside the signed Session header.
sequenceDiagram
    actor Person
    participant PA as Personal agent
    participant Company as Company agent
    participant Auth as Company authorization server

    PA->>Company: Discover /.well-known/poppy.json
    Company-->>PA: Agent, API, and authorization endpoints
    PA->>PA: Start a signed-out Session, no request sent
    PA->>Company: Start a conversation, with a signed Session header
    Company-->>PA: Sign-in required for account data
    PA-->>Person: Open the company's sign-in page
    Person->>Auth: Sign in and approve scopes
    Auth-->>PA: Refresh token and access token
    PA->>Company: Continue the same conversation, with the access token
    Company-->>PA: Account-aware response

The SDKs implement these protocol and security mechanics. They do not decide what an agent should say, which model it should use, or whether a proposed action is appropriate for a person.

Install and discover a company

Python

python -m pip install personal-agent-protocol
import asyncio

from personal_agent_protocol import DiscoveryClient


async def main() -> None:
    async with DiscoveryClient() as client:
        company = await client.discover("example.com")
        print(company.document.organization.name)
        print(company.document.agent.protocols)


asyncio.run(main())

TypeScript

npm install @datalayer/personal-agent-protocol
import { discoverCompany } from '@datalayer/personal-agent-protocol';

const company = await discoverCompany('example.com');
console.log(company.document.organization.name);
console.log(company.document.agent.protocols);

Discovery is deliberately a small first example. Production Session, sign-in, and conversation flows also require host-owned signing keys, delegated key custody, token storage, and browser handoff. Those capabilities are provided through Reactor rather than hidden global state.

Reactor is the extension foundation

Both SDKs are built on Datalayer Reactor, a typed plugin and contribution system. An application assembles a PAP host from explicit contributions for:

  • discovery transport and URL-safety policy;
  • protocol profiles and extension handlers;
  • clocks and cryptographic randomness;
  • signing, delegated keys, and Session JWTs;
  • pairwise identity, token storage, and caching;
  • browser handoff and authorization-state storage;
  • CLI commands supplied by PAP or third-party extensions.

This architecture keeps the protocol core portable while allowing a desktop application, browser application, server, or test harness to provide the security and platform behavior appropriate to its environment. Missing or ambiguous security contributions fail closed.

Python accepts a host-assembled Reactor PluginPlatform:

from reactor import PluginManifest

from personal_agent_protocol import DiscoveryClient, build_pap_reactor


async def discover_with_host() -> None:
    platform, owned_http = build_pap_reactor(
        plugins=[
            (PluginManifest(name="my-security", version="1"), my_security_plugin)
        ]
    )
    try:
        async with DiscoveryClient(reactor=platform) as client:
            company = await client.discover("example.com")
            print(company.document.organization.name)
    finally:
        platform.stop()
        if owned_http is not None:
            await owned_http.aclose()

TypeScript can build a host or receive an existing ReactorPlatformView:

import {
  buildPapReactor,
  discoverCompany,
} from '@datalayer/personal-agent-protocol';

const reactor = buildPapReactor({}, [mySecurityPlugin]);
const company = await discoverCompany('example.com', { reactor });

See the Reactor repository for the plugin model and contribution lifecycle.

What is implemented

Python and TypeScript share fixtures and cover the same principal protocol surface:

AreaCurrent support
ModelsForward-compatible discovery, OAuth metadata, client metadata, messages, events, and Operations v2 models
Discoverypoppy.json, company-domain and issuer validation, bounded responses, and redirect controls
SessionsPairwise user IDs, local Sessions named by a random sid, a Session JWT on every request, and redacted tokens
CryptographyES256/PS384 JOSE, delegated keys and delegations, Session JWT creation and verification, blind signing, and replay checks
Direct Sign-InState, S256 PKCE, callback validation, browser handoff, and one-use code exchange orchestration
Browser SessionOne-time code, the agent's authorization of it with the Session header, controlled form POST, and replay-safe verification
TransportHost-owned authorization and Session headers, a fresh Session JWT per attempt, one restart after invalid_session, no redirects
ConversationsStart and continue, random user-global message IDs, ordered long polling, cursor recovery, duplicate suppression, and safe errors
ExtensibilityReactor contribution points for platform, security, protocol, storage, and CLI behavior
CLINon-secret profiles, company verification, extension diagnostics, and versioned JSON output

Python additionally provides a SQLite pairwise-identity reference provider. The portable TypeScript entry rejects obvious local and private literal addresses. Its explicit server entry adds NodeUrlSafetyPolicy and createResolvingFetch (A/AAAA resolution, every address global, the vetted one dialled), JoseSigner, and the checks a company makes of a Session header:

import {
  JoseSigner,
  NodeUrlSafetyPolicy,
} from '@datalayer/personal-agent-protocol/server';

Duplicate JSON members are rejected at Python and TypeScript trust boundaries.

What is not implemented yet

Every flow of draft 0.4 and Operations v2 is implemented in both SDKs and both reference companies: discovery, Sessions, Direct, Device and Mediated Sign-In, refresh tokens, DPoP, OpenAPI and MCP, conversations with SSE, handoff and close, browser sessions, feedback, and Operations. What remains:

  • production backends the host contributes: the SDK ships no KMS/HSM signer or durable delegated key custody, no durable token store, and only in-memory company stores and replay caches (check_store checks a durable one);
  • helpers the Guides suggest but the host decides today: choosing among the sign-in methods, matching a task's scopes to a held refresh token, and revoking the previous refresh token after a wider sign-in;
  • rate limits and RateLimit headers in the reference companies (a host can contribute pap.company.rateLimit), and redaction hooks for logs and traces;
  • in Node, socket pinning for metadata fetches (an egress proxy closes the DNS-rebinding interval meanwhile).

Each open or partial requirement is listed with its reason in Protocol coverage.

Security boundary

PAP credentials belong to the host, not to an agent model or tool call.

  • Access tokens, refresh tokens, Session JWTs, authorization codes, and pairwise identifiers must not enter prompts or model-visible tool results.
  • Direct Sign-In requires host-provided state storage, browser handoff, and signing contributions.
  • Session requests fail closed until suitable pap.signer and pap.sessionSigner contributions are installed.
  • Every redirect from a protocol endpoint is refused; caller-supplied Authorization, DPoP, and Poppy-Session headers are rejected.
  • CLI profiles store configuration only—never tokens or private keys.

The guides explain these boundaries at each flow rather than treating them as application conventions.

Command line

The Python distribution installs an extensible pap command. Its command groups use Reactor's datalayer.reactor.cli entry-point contract.

pap config set domain example.com --profile work
pap config show --profile work --json
pap company verify --profile work --json
pap extensions list --profile work

See the CLI guide for configuration precedence, security boundaries, machine-readable output, and third-party extensions.

Examples and first consumer

The examples/pydantic-ai directory contains small, focused Python examples. Each example teaches one feature—discovery, identity, Sessions, Direct Sign-In, Browser Session, cryptography, conversations, or Session transport—without giving protocol secrets to the model.

Datalayer Agent Runtimes is the first consumer of these SDKs. Its Personal Agent Protocol gallery turns the same features into interactive Reactor/Loop applications, including a guided person-to-company journey rendered with the runtime's real message UI. The gallery's local company simulators are deterministic and clearly identified; the PAP clients, transports, validation, and parsed exchanges are real.

The entry @datalayer/personal-agent-protocol/decks ships the four cases as decks: PAP_DECKS, PAP_DECK_IDS and papDeck(id), each with its yaml and the same deck parsed as spec. It brings in yaml and nothing of the SDK.

Each implemented feature should have all three learning layers:

  1. a focused SDK example in this repository;
  2. a Docusaurus guide with an explanation and Mermaid sequence diagram;
  3. an interactive Agent Runtimes example when a UI materially clarifies the flow.

Develop the SDKs

Clone the repository, then install the dependencies for the SDK you are changing.

Python

python -m pip install -e '.[test,lint,typing,examples]'
python -m pytest personal_agent_protocol/__tests__

TypeScript

The TypeScript package is at the repository root. Sources and tests live under src/; published JavaScript and declarations are emitted to lib/.

npm install
npm test

The shared fixtures are in fixtures/. Documentation is a Docusaurus site in docs/.

Learn more

License

BSD 3-Clause. See LICENSE.

版本与发布记录

@datalayer/personal-agent-protocol 共发布 35 个版本,首次发布于 2026/10/10;过去 12 个月发布了 35 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.32.0latest2026/11/083 天前
0.31.02026/11/073 天前
0.30.02026/10/3111 天前
0.29.02026/10/3111 天前
0.28.02026/10/3012 天前
0.27.02026/10/2715 天前

关于 @datalayer/personal-agent-protocol 的常见问题

@datalayer/personal-agent-protocol 是什么?

TypeScript SDK for Personal Agent Protocol 0.4 (2026-11-06) and its Operations extension v2

如何安装 @datalayer/personal-agent-protocol?

在项目目录运行 npm install @datalayer/personal-agent-protocol,或使用 pnpm add / yarn add / bun add。

@datalayer/personal-agent-protocol 支持 TypeScript 吗?

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

@datalayer/personal-agent-protocol 支持 ESM 还是 CommonJS?

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

@datalayer/personal-agent-protocol 可以商用吗?

@datalayer/personal-agent-protocol 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@datalayer/personal-agent-protocol 的下载量有多少?

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

@datalayer/personal-agent-protocol 还在维护吗?

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