@appport/sdk

中文文档
1.6.0发布于 2026/11/06Apache-2.0TypeScriptES Module近 30 天下载 2067

AppPort developer SDK: implement a universal application boundary across runtimes and transports.

原始使用文档
文档目录5 节
  1. Secure discovery (1.2.0)
  2. Behavior change in 1.2.0: redirects and origins are refused…
  3. Canonical capabilities (1.3.0)
  4. Node-only TypeScript
  5. Agent Skill

@appport/sdk

The curated TypeScript API for the AppPort protocol.

It exposes application contracts, capability handlers, manifests, clients, servers, authorization primitives, and supported transports without coupling application code to a URL, process, transport, storage engine, or platform.

import { createClient, createHttpTransport } from "@appport/sdk";

const app = createClient({
  transport: createHttpTransport({ url: "/appport" })
});

Node-only hosting helpers are exported from @appport/sdk/node.

@appport/sdk is the convenience façade: it aggregates lower-level protocol, client, server, and transport packages, and it keeps AppPort.discover() wired to the built-in HTTP and WebSocket transports. It is not the foundational architecture layer; lower-level packages do not depend on the SDK.

Secure discovery (1.2.0)

import { AppPort } from "@appport/sdk";

// Inspect what an application publishes and verify its references. Connects to nothing, sends no credentials, invokes nothing.
const found = await AppPort.discoverApplication({ origin: "https://app.example.com", pins: recordedPins, timeoutMs: 10_000 });
found.state;        // "not-published" | "unavailable" | "malformed" | "unresolved" | "reference-verified"
found.established;  // { publisherTrust: false, authorization: false, approval: false, invoked: false }  always

// Connect a client to a host you chose.
const client = await AppPort.discover({ origin: "https://app.example.com", sessionId });

reference-verified means the published references are consistent with the authoritative manifest. It does not mean the publisher is trusted, that you are authorized, that an approval was obtained, or that an operation is safe. AppPort defines no signature for application manifests, and it neither collects nor checks approvals. Mapping-signature trust (@appport/integration) is not production-ready.

Behavior change in 1.2.0: redirects and origins are refused by default

AppPort.discover and the HTTP transport used to follow redirects and to use any transport endpoint a discovery document advertised, so a 307 or a document naming another origin sent the session id and request body there. They now refuse both:

You needDo
The old redirect-following behavior, for an origin you operateredirects: "follow"
A transport endpoint on another originallowOrigins: ["https://api.example.com"]
A larger discovery document than 1 MiBmaxDocumentBytes
A deadline or cancellationtimeoutMs, signal

An http to https redirect is a different origin: connect to the https origin directly.

Canonical capabilities (1.3.0)

defineCapability({ fulfills: [claimFor(contract, "order.hold", 1)] }) declares that a capability fulfils a canonical capability, and an application's requirements may name one with canonical: { contract }. A claim is evaluated before it is used and grants no authority. Registering canonical contracts, discovering providers, resolving canonical requirements and binding them are @appport/core APIs; see its README and spec/fulfillment-1.md.

Node-only TypeScript

The root @appport/sdk and @appport/sdk/node type-check in a Node-only project (lib: ["ES2023"], no DOM, skipLibCheck: false). The MCP bridge exports (createMcpBridge, toMcpTools, ...) stay available from the root. The MCP server is not part of the SDK; import it from @appport/mcp, and note that the MCP SDK it uses needs the DOM HeadersInit type (see that package's README).

Agent Skill

This package carries the official AppPort Agent Skill at skills/appport, matching this SDK version. The skill is optional, so the SDK does not install what only the skill needs: the skill imports @appport/protocol and @appport/integration directly, and your project must depend on them itself (a package manager that does not hoist, such as pnpm, will not expose a transitive copy). To install it for Claude Code:

npm install @appport/sdk @appport/protocol @appport/integration
mkdir -p .claude/skills && cp -R node_modules/@appport/sdk/skills/appport .claude/skills/appport   # one project
mkdir -p ~/.claude/skills && cp -R node_modules/@appport/sdk/skills/appport ~/.claude/skills/appport # your user
node .claude/skills/appport/scripts/check-requirements.mjs

If the check reports a package as (not installed), its output includes an install command that fixes it.

Only Claude Code is verified. The skill is guidance, not enforcement. It needs @appport/sdk 1.2.0+, @appport/protocol 1.1.0+ and @appport/integration 1.1.0+ (the first releases containing secure discovery).

版本与发布记录

@appport/sdk 共发布 35 个版本,首次发布于 2026/09/03;过去 12 个月发布了 35 个版本。

版本发布日期距今
1.6.0latest2026/11/062 天前
1.5.02026/11/052 天前
1.4.12026/11/034 天前
1.4.02026/10/2810 天前
1.3.12026/10/2217 天前
1.3.02026/10/1919 天前

关于 @appport/sdk 的常见问题

@appport/sdk 是什么?

AppPort developer SDK: implement a universal application boundary across runtimes and transports.

如何安装 @appport/sdk?

在项目目录运行 npm install @appport/sdk,或使用 pnpm add / yarn add / bun add。

@appport/sdk 支持 TypeScript 吗?

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

@appport/sdk 支持 ESM 还是 CommonJS?

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

@appport/sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@appport/sdk 可以商用吗?

@appport/sdk 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@appport/sdk 的下载量有多少?

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

@appport/sdk 还在维护吗?

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