@appport/protocol

中文文档
1.4.1发布于 2026/11/06Apache-2.0TypeScriptES Module零依赖近 30 天下载 3364

AppPort wire protocol types, envelopes, error codes and manifest contracts.

原始使用文档

@appport/protocol

The AppPort wire contract: envelope types, error codes, naming rules, manifest shapes, structural validation and compatibility analysis.

This package is pure. It has no runtime dependencies and knows nothing about transports, servers or clients — which is what makes it safe to depend on from a browser bundle, an Electron preload script or a CLI.

import { createRequest, parseClientEnvelope, PROTOCOL_ID } from "@appport/protocol";

const request = createRequest({
  requestId: "req_01J...",
  capability: { name: "documents.save", version: 1 },
  input: { documentId: "doc_1", content: "hello" }
});

parseClientEnvelope(request); // throws AppPortError on a malformed envelope

What is here

ModuleContents
versionappport/1, conformance levels
envelopesrequest, response, event, subscribe, stream envelopes and guards
validateprotocol-level structural validation, decode and encode
errorsthe standard error codes and AppPortError
namescapability, event, permission and application-id grammar
idsULID-based identifier helpers
manifestmanifest, discovery and transport descriptor types
jsonschemathe JSON Schema subset published in manifests
sessionPrincipal and Session
operationslong-running operation records
blobbinary references
compatibilitybreaking vs non-breaking manifest diffing; compareSchemas for one schema pair
fulfillmentcanonical contracts (isCanonicalContract), fulfillment claims (claimFor, claimsFor, lintFulfillment) and their evaluation (evaluateFulfillment) (spec/fulfillment-1.md), since 1.2.0
integrationintegration metadata and lintIntegration; dependencies, including canonical targets (CanonicalDependencyTarget, isCanonicalDependencyTarget, since 1.2.0)

Names are checked, not merely typed: electron.documents.save and ipc.saveDocument are rejected, because a capability name that encodes a transport breaks the protocol's central invariant.

Public discovery (1.1.0)

buildPublicDescription, validatePublicDescription, capabilityDigest, contractDigest, PUBLIC_DESCRIPTION_PATH and the appport.public-description/1 schema (spec/schemas/public-description.schema.json in the repository). Publication is the application owner's explicit, fail-closed decision; a description is a pointer to, and a digest of, the authoritative manifest and is untrusted data. Discovery is not authorization, approval or publisher trust.

版本与发布记录

@appport/protocol 共发布 10 个版本,首次发布于 2026/09/21;过去 12 个月发布了 10 个版本。

版本发布日期距今
1.4.1latest2026/11/062 天前
1.4.02026/11/052 天前
1.3.02026/10/2810 天前
1.2.12026/10/2217 天前
1.2.02026/10/1919 天前
1.1.02026/10/1524 天前

关于 @appport/protocol 的常见问题

@appport/protocol 是什么?

AppPort wire protocol types, envelopes, error codes and manifest contracts.

如何安装 @appport/protocol?

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

@appport/protocol 支持 TypeScript 吗?

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

@appport/protocol 支持 ESM 还是 CommonJS?

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

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

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

@appport/protocol 可以商用吗?

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

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

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

@appport/protocol 还在维护吗?

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