@cherrystudio/remote-protocol

中文文档
0.7.0发布于 2026/10/22TypeScriptES Module近 30 天下载 1.4万

Cherry Studio remote access protocol schemas and Agent recovery contracts.

原始使用文档
文档目录7 节
  1. Connection addresses
  2. Failure outcomes
  3. Interaction and workspace additions
  4. Message usage
  5. Pairing addresses
  6. Paged message summaries
  7. Resumable Agent attachments

Remote protocol

Portable schemas and pure Agent recovery functions shared by Desktop and Mobile. The root owns JSON-RPC and connection contracts. Agent and configuration transfer have separate exports; neither owns sockets, keys, persistence or reconnection. The root also owns the shared discovery service type, TXT format and fixed WebSocket path. These are Cherry peer interoperability contracts, not listener or routing policy.

Published as @cherrystudio/remote-protocol through the repository's Changesets release workflow. Package versions follow semver independently of the negotiated wire protocol version. Building or passing package tests alone does not qualify Desktop, Expo or relay interoperability.

Run pnpm --filter @cherrystudio/remote-protocol test, typecheck and build. External consumers enter through the package exports, never src/ deep imports.

The event reducer caches streaming text byte lengths by part snapshot without adding wire fields. Appends encode only new text after an initial length calculation; restored or replaced parts calculate their own length. Producers read part.append offsets through the exported textByteLength, so emitting and validating an append share one cache entry. Completion still checks the full content digest and does not inherit the streaming snapshot's cache. Older snapshots remain independently usable for atomic recovery; their weakly held cache entries disappear with those objects.

Connection addresses

connection.hello.connectionEndpointsVersion: 1 advertises connection.endpoints. The request names an already approved domain; the desktop rechecks its current grant before and after preparing the response. The result contains the desktop identity and at most 32 direct endpoints, with no invitation or VPN credentials. Clients pin the identity, keep suggestions ephemeral, and persist only explicitly verified selections. Peers without this optional capability retain existing pairing and manual-address flows.

Failure outcomes

./failure owns the bounded execution failure snapshot shared by live execution and message history. Messages carry explicit pending/success/error/paused status. A failed execution requires a failure and a terminal message identity. Terminal persistence is either durable with message and history revisions, or non-durable with a separate persistence failure. RPC authorization errors and command receipts remain independent of execution outcomes.

connection.hello.agentFailureVersion: 1 advertises this contract. New clients require it for Agent access only; configuration and pairing retain their existing protocol. Old execution error fields remain a compatibility projection. Old cached projections missing required fields are rebuilt from a checkpoint. Unknown upstream causes are classified as unknown; wire snapshots validate the versioned reason vocabulary without rewriting bytes used by checkpoint digests.

Interaction and workspace additions

  • Interaction summaries may declare kind: question; full questions stay in the versioned input resource and use questionInputSchema. Responses are explicit approve, deny-with-optional-reason, or answer-with-question-keyed-values. Validate completeness against the current interaction at the host; the schema validates shape and bounds. Question text keys must be unique.
  • Workspace catalogs advertise systemWorkspace; creation accepts an explicit system or registered selection. The host owns directory resolution and returns the real workspace ID and kind.
  • Legacy plain decision and workspaceId mutations remain accepted, including journal recovery. A request must choose exactly one form. New clients use the legacy forms for those existing operations and explicit forms for the additions; old catalogs do not imply system support.
  • Command identity includes the full answer or workspace selection. Retrying with the same ID and different input is an idempotency conflict, never a replacement operation.

Agent catalogs optionally include emoji (nonempty Unicode text, at most 64 UTF-16 units). It is display metadata, not a file path or URL. Omission remains compatible with older hosts; clients keep their normal fallback. Image transfer is outside this field's contract.

Message usage

AgentMessage.usage is an optional materialized summary. It carries nonnegative token counts, cache/reasoning breakdowns, bounded per-currency costs and request counts, and completed runtime durations. Absence means unknown, not zero. It deliberately excludes per-request accounting rows and runtime span arrays. The message owns the snapshot, so history responses, message updates, and checkpoint/replay use one schema. Older peers may omit it; no pairing capability gate changes.

The optional public model summary (modelId, providerId, name) is shared by message snapshots and Agent catalog entries. A message records its producing model; the catalog records current configuration (null for unconfigured, omitted for older hosts). Neither carries provider secrets or requires the receiving device to have the model installed.

Pairing addresses

pairingQrSchema accepts legacy v2 IP/port invitations and v3 invitations with complete endpoints (host, port, security). fixtures/pairing-qr.json is also exercised by Mobile's lightweight startup schema. Keep the fixture copy aligned when changing the wire contract. parseDirectEndpoint accepts HTTP(S) input as an alias for WS(S), preserving TLS and explicit ports. The fixed route remains /v1/remote/connect; advertised endpoints use advertisedEndpointSchema to reject loopback and wildcard destinations.

Paged message summaries

connection.hello.agentMessageSummariesVersion: 1 advertises the optional agent.messages.list parameter partsMode: 'paged'. Only send this parameter after observing the capability. Without it, responses retain complete partIds.

Paged responses contain AgentMessageSummary items: message identity, revision, role, status and optional usage/model/failure metadata, with partsMode: 'paged' and no partIds. Enumerate every part through agent.parts.list using the message ID and revision, following nextCursor until null. An omitted index is not an empty message. History and part revision checks remain unchanged.

AgentMessageListItem is the full-message/summary union. Summaries are list-only; events, checkpoints and reducers still require complete AgentMessage snapshots. Peers without the capability keep the existing request and response shapes.

An indivisible list item over the response budget returns RESOURCE_EXHAUSTED with details: { kind: 'ITEM_TOO_LARGE', itemBytes, budgetBytes, retryable: false }. The same request and data cannot recover by waiting. Other resource-exhaustion errors retain their semantics; legacy clients may ignore the additional details.

Resumable Agent attachments

connection.hello.agentUploadsVersion: 1 advertises prepare/get/resume/complete/cancel and binary DATA/ACK records. Upload identity is scoped to device and Agent grant, independent of sockets and sessions. A durable committedOffset is the only resume position. resume uses an idempotent resume ID and expected writer epoch; old writers cannot advance a replaced upload. DATA carries raw bytes authenticated by Noise AEAD, with a durable ACK after each block. Desktop computes the full-file SHA-256 before publishing a ready managed reference. The optional agentUploadChecksum: 'sha256' hello capability supports independent source verification: prepare fixes checksumAlgorithm, complete supplies expectedSha256, and ready returns the actual sha256. A mismatch becomes durable failed state with CHECKSUM_MISMATCH; disk/publication errors use VERIFICATION_FAILED. Changing a recorded digest or mode is an idempotency conflict. Absent-mode uploads retain legacy behavior. New mobile hashes its retained immutable source natively in parallel with normal DATA transfer; recovery compares the saved digest before resumed writes.

Limits: 1 GiB/file, 2 GiB/message, eight files, 1 MiB blocks and two outstanding blocks. Staging expires after 24 hours idle or seven days total, with 4 GiB/device and 8 GiB/global reservations. Upload permission and expiry are rechecked independently of message receipts. Send accepts text, files, or both. Clients freeze the upload references in the durable send command before submission and query that command's receipt after uncertain outcomes. They must never replace expired upload references inside an already submitted command.

Uploaded file history uses a revision-bound content reference, never a desktop filesystem path. Content pages are read under the current Agent grant and checked against the complete digest.

版本与发布记录

@cherrystudio/remote-protocol 共发布 7 个版本,首次发布于 2026/09/24;过去 12 个月发布了 7 个版本。

版本发布日期距今
0.7.0latest2026/10/2218 天前
0.6.02026/10/2020 天前
0.5.02026/10/1327 天前
0.4.02026/10/1030 天前
0.3.02026/09/301 个月前
0.2.02026/09/291 个月前

关于 @cherrystudio/remote-protocol 的常见问题

@cherrystudio/remote-protocol 是什么?

Cherry Studio remote access protocol schemas and Agent recovery contracts.

如何安装 @cherrystudio/remote-protocol?

在项目目录运行 npm install @cherrystudio/remote-protocol,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:zod(^4.3.4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cherrystudio/remote-protocol 支持 TypeScript 吗?

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

@cherrystudio/remote-protocol 支持 ESM 还是 CommonJS?

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

@cherrystudio/remote-protocol 可以商用吗?

@cherrystudio/remote-protocol 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@cherrystudio/remote-protocol 的下载量有多少?

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

@cherrystudio/remote-protocol 还在维护吗?

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