@buoy-gg/sync-broker

中文文档
7.0.87发布于 2026/11/07TypeScriptESM + CJS近 30 天下载 4513

Headless Socket.IO broker for the Buoy devtool sync protocol (v1) — routes messages between devices and dashboard/MCP clients

原始使用文档
文档目录5 节
  1. Install
  2. Host a broker
  3. Existing HTTP server
  4. Message flow
  5. Network and verification

@buoy-gg/sync-broker

Host the Socket.IO message router used by Buoy Desktop and MCP. It routes device capabilities, watched snapshots, and remote actions between device and dashboard clients. Most users should run Desktop or MCP instead of hosting this package directly.

Install

npm install @buoy-gg/sync-broker

This is a Node host package. Use the exported createBroker, socketHandle, and protocol types when implementing a custom host.

Host a broker

The host must independently validate its Buoy account and supply admission through canUseDesktop. The default denies access. This integration sketch expects your host's existing account object; hasAccess() must reflect current verified admission, not merely the presence of a key:

import { createBroker, DEFAULT_BROKER_PORT } from "@buoy-gg/sync-broker";

const broker = createBroker({
  port: DEFAULT_BROKER_PORT,
  canUseDesktop: () => account.hasAccess(),
  onListening: (port) => console.log(`Broker listening on ${port}`),
  onError: (error) => console.error(error),
});

// Call when your account lifecycle changes admission:
broker.refreshAccess();

// Call during host shutdown:
await broker.close();

Keep account revalidation and expiry handling active for the host's lifetime. Refresh routing when access changes. Device and client admission is separate from the host callback. A listening HTTP endpoint does not prove that a device has been admitted.

Try connecting to an existing broker before starting another. If startup reports EADDRINUSE, connect to the broker already using that port or resolve the conflict. The default port is 42831.

Existing HTTP server

For an existing Socket.IO server, use socketHandle({ io, canUseDesktop }) and retain its returned refreshAccess function. Your host owns the HTTP server, Socket.IO options, account lifecycle, and shutdown. Do not attach routing twice to the same server.

Message flow

Devices announce capabilities. Dashboard watch requests control adapter subscriptions; the broker consolidates those requests. Device snapshots flow to watching clients, while named actions and their results travel in the opposite directions. Broker logs help diagnose admission, connection, and protocol problems. Offline device history is in memory and can be forgotten or age out.

Network and verification

The standalone server listens without a loopback-only host restriction. Default CORS allows any origin; CORS is not client authentication. Use a trusted development network and review access controls before exposing a custom host beyond it. Account admission does not establish app-specific authorization for every remote action.

Test with a verified host and device account: connect, watch a known tool, and confirm its snapshot. Then revoke host admission and verify that access closes. Reconnect after restoring valid access and check that watch state resumes. See the Desktop guide and MCP guide for supported end-user hosts.

版本与发布记录

@buoy-gg/sync-broker 共发布 92 个版本,首次发布于 2026/06/30;过去 12 个月发布了 92 个版本。

版本发布日期距今
7.0.87latest2026/11/071 天前
7.0.862026/11/062 天前
7.0.852026/11/053 天前
7.0.842026/11/035 天前
7.0.832026/11/035 天前
7.0.822026/11/036 天前

关于 @buoy-gg/sync-broker 的常见问题

@buoy-gg/sync-broker 是什么?

Headless Socket.IO broker for the Buoy devtool sync protocol (v1) — routes messages between devices and dashboard/MCP clients

如何安装 @buoy-gg/sync-broker?

在项目目录运行 npm install @buoy-gg/sync-broker,或使用 pnpm add / yarn add / bun add。

@buoy-gg/sync-broker 支持 TypeScript 吗?

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

@buoy-gg/sync-broker 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@buoy-gg/sync-broker 需要什么版本的 Node.js?

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

@buoy-gg/sync-broker 可以商用吗?

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

@buoy-gg/sync-broker 的下载量有多少?

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

@buoy-gg/sync-broker 还在维护吗?

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