Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(plugins): preserve device sync delivery across lifecycle races
zqchris78a3dc53ced5
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/deviceSyncSlot.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/deviceSyncSlot.test.tsindex 5f58dbb30d..a63c4b7127 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/deviceSyncSlot.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/deviceSyncSlot.test.ts@@ -42,25 +42,30 @@ function pair() {pins = new Map<string, string>(),delivered: any[] = [];const blocked = new Set<string>();+ const keys = {+ prepare: vi.fn(async () => {}),+ getIdentity: () => identity,+ getPeerPublicKey: (p: string) => pins.get(p) ?? null,+ pinPeerPublicKey: async (p: string, k: string) => {+ if (pins.has(p) && pins.get(p) !== k) throw Error('pin');+ const fresh = !pins.has(p);+ pins.set(p, k);+ return fresh;+ },+ };+ const deliver = vi.fn(async (_ghost: InstalledGhost, msg: unknown, valid: () => boolean) => {+ if (!valid()) return false;+ delivered.push(msg);+ return true;+ });+ const other = { ...g, manifest: { ...manifest, id: 'other-sync' }, instanceKey: 'other-sync' } as InstalledGhost;+ const ghosts = [g, other];const svc = new PluginDeviceSync({scope: () => scope,- keys: {- prepare: async () => {},- getIdentity: () => identity,- getPeerPublicKey: (p) => pins.get(p) ?? null,- pinPeerPublicKey: async (p, k) => {- if (pins.has(p) && pins.get(p) !== k) throw Error('pin');- const fresh = !pins.has(p);- pins.set(p, k);- return fresh;- },- },- getGhost: (key) => (key === 'example-sync' ? g : null),- listGhosts: () => [g],- deliver: async (_ghost, msg) => {- delivered.push(msg);- return true;- },+ keys,+ getGhost: (key) => ghosts.find(ghost => ghost.instanceKey === key) ?? null,+ listGhosts: () => ghosts,+ deliver,});svc.connect({self: () => id,@@ -77,6 +82,9 @@ function pair() {cleanups.push(() => svc.reset());return {svc,+ keys,+ deliver,+ addPlugin: (id: string) => ghosts.push({ ...g, manifest: { ...manifest, id }, instanceKey: id } as InstalledGhost),g,delivered,blocked,@@ -101,7 +109,7 @@ function pair() {).toMatchObject({ errorCode: 'SYNC_CONNECTING' });await flush();}- return { a, b, frames, flush, ready };+ return { a, b, frames, flush, ready, addPeer: (id: string) => { const peer = side(id); sides.set(id, peer); return peer; } };}it('declares the capability without changing legacy manifests and projects its permission', () => {for (const validate of [validateGhostManifest, validateProtocolManifest]) {@@ -211,3 +219,101 @@ it('expires in-flight work on stop even when the same install immediately restarexpect(await result).toMatchObject({ errorCode: 'SYNC_RESULT_UNKNOWN' });expect(await a.svc.handle('example-sync', { op: 'status' })).toMatchObject({ online: true });});++// PR #6569: the wire callback does not await receive. Sequential flush alone missed+// same-peer overlap and revocation while the runtime was starting (unit tier).+it('queues concurrent same-peer frames across plugins while key preparation is pending', async () => {+ const { a, b, frames, ready, flush } = pair();+ await ready();+ const requests = ['example-sync', 'example-sync', 'other-sync'].map((plugin, n) =>+ a.svc.handle(plugin, { op: 'request', peer: 'b', data: { n } }));+ await Promise.resolve(); await Promise.resolve();+ let release!: () => void;+ const blocked = new Promise<void>(resolve => { release = resolve; });+ b.keys.prepare.mockImplementationOnce(() => blocked);+ const receiving = frames.splice(0).map(f => b.svc.receive(f.from, f.data));+ expect(receiving).toHaveLength(3);+ expect(b.delivered).toHaveLength(0);+ release(); await Promise.all(receiving);+ expect(b.delivered.map(m => m.data.n)).toEqual([0, 1, 2]);+ for (const msg of b.delivered) await b.svc.handle(msg.data.n === 2 ? 'other-sync' : 'example-sync', {+ op: 'reply', requestId: msg.requestId, data: { persisted: msg.data.n },+ });+ await flush();+ expect(await Promise.all(requests)).toEqual([0, 1, 2].map(n => ({ ok: true, data: { persisted: n } })));+});++it('rechecks device revocation after waiting for plugin startup and before delivery', async () => {+ const { a, b, frames, ready } = pair(); await ready();+ let release!: () => void, entered!: () => void;+ const started = new Promise<void>(resolve => { entered = resolve; });+ const loading = new Promise<void>(resolve => { release = resolve; });+ b.deliver.mockImplementation(async (_ghost, msg, valid) => {+ entered(); await loading;+ if (!valid()) return false;+ b.delivered.push(msg); return true;+ });+ const result = a.svc.handle('example-sync', { op: 'request', peer: 'b', data: {} });+ await Promise.resolve(); await Promise.resolve();+ const frame = frames.shift()!;+ const receiving = b.svc.receive(frame.from, frame.data);+ await started; b.blocked.add('a'); release(); await receiving;+ expect(b.delivered).toHaveLength(0);+ a.svc.reset(); expect(await result).toMatchObject({ errorCode: 'SYNC_RESULT_UNKNOWN' });+});+++it('keeps another peer flowing while a receive queue waits and discards queued frames on reset', async () => {+ const { a, b, frames, ready, flush, addPeer } = pair(); await ready();+ const c = addPeer('c');+ expect(await c.svc.handle('example-sync', { op: 'request', peer: 'b', data: {} })).toMatchObject({ errorCode: 'SYNC_CONNECTING' });+ await flush();+ let release!: () => void, entered!: () => void;+ const started = new Promise<void>(resolve => { entered = resolve; });+ const loading = new Promise<void>(resolve => { release = resolve; });+ b.keys.prepare.mockImplementationOnce(() => { entered(); return loading; });+ const pending = [0, 1].map(n => a.svc.handle('example-sync', { op: 'request', peer: 'b', data: { n } }));+ await Promise.resolve(); await Promise.resolve();+ const receiving = frames.splice(0).map(f => b.svc.receive(f.from, f.data));+ await started;+ const other = c.svc.handle('example-sync', { op: 'request', peer: 'b', data: { other: true } });+ await Promise.resolve(); await Promise.resolve(); await flush();+ expect(b.delivered.map(m => m.data)).toEqual([{ other: true }]);+ await b.svc.handle('example-sync', { op: 'reply', requestId: b.delivered[0].requestId, data: { persisted: true } });+ await flush(); expect(await other).toEqual({ ok: true, data: { persisted: true } });+ b.svc.reset(); b.svc.setActive(true); release(); await Promise.all(receiving);+ expect(b.delivered).toHaveLength(1);+ a.svc.reset();+ expect(await Promise.all(pending)).toEqual([0, 1].map(() => ({ ok: false, errorCode: 'SYNC_RESULT_UNKNOWN' })));+});+++it('reactivates under the new owner when account commit follows teardown', async () => {+ const { b } = pair();+ b.svc.reset(); b.setScope('owner-b'); b.svc.setActive(true);+ expect(await b.svc.handle('example-sync', { op: 'status' })).toMatchObject({ online: true });+});++// The documented concurrency budget counts incoming and outgoing requests together.+it.each([2, 32])('counts incoming requests toward the combined %i request budget', async count => {+ const { a, b, ready, flush, addPeer } = pair(); await ready();+ const c = addPeer('c'); c.addPlugin('budget-0');+ expect(await c.svc.handle('budget-0', { op: 'request', peer: 'b', data: {} })).toMatchObject({ errorCode: 'SYNC_CONNECTING' });+ await flush();+ const requests: Array<Promise<unknown>> = [];+ for (let i = 0; i < count / 2; i++) {+ const id = `budget-${i}`; a.addPlugin(id); b.addPlugin(id);+ for (let n = 0; n < 2; n++) requests.push(a.svc.handle(id, { op: 'request', peer: 'b', data: { n } }));+ }+ await Promise.resolve(); await Promise.resolve(); await flush();+ expect(b.delivered).toHaveLength(count);+ const extra = c.svc.handle('budget-0', { op: 'request', peer: 'b', data: {} });+ await Promise.resolve(); await Promise.resolve(); await flush();+ expect(b.delivered).toHaveLength(count);+ // Per-plugin limit with spare global slots, or global limit for a different plugin.+ const outbound = b.svc.handle(count === 2 ? 'budget-0' : 'example-sync', { op: 'request', peer: 'a', data: {} });+ await vi.advanceTimersByTimeAsync(30001);+ expect(await outbound).toMatchObject({ errorCode: 'SYNC_BUSY' });+ expect(await extra).toMatchObject({ errorCode: 'SYNC_RESULT_UNKNOWN' });+ expect(await Promise.all(requests)).toEqual(Array.from({ length: count }, () => ({ ok: false, errorCode: 'SYNC_RESULT_UNKNOWN' })));+});diff --git a/apps/desktop/src/main/cindy-brain/deviceSyncSlot.ts b/apps/desktop/src/main/cindy-brain/deviceSyncSlot.tsindex b9ba34ce49..57b3ed3e7c 100644--- a/apps/desktop/src/main/cindy-brain/deviceSyncSlot.ts+++ b/apps/desktop/src/main/cindy-brain/deviceSyncSlot.ts@@ -80,7 +80,8 @@ export class PluginDeviceSync {private readonly pending = new Map<string, Pending>();private readonly incoming = new Map<string, Incoming>();private readonly keyReplies = new Map<string, number>();- private readonly receiving = new Set<string>();+ private readonly receiving = new Map<string, Promise<void>>();+ private receivingCount = 0;private readonly epochs = new Map<string, number>();constructor(private readonly deps: Deps) {}connect(transport: PluginSyncTransport): void {@@ -88,7 +89,7 @@ export class PluginDeviceSync {this.transport = transport;}setActive(active: boolean): void {- if (!active) this.reset();+ if (!active || this.scope !== this.deps.scope()) this.reset();this.active = active;}reset(): void {@@ -103,6 +104,7 @@ export class PluginDeviceSync {this.incoming.clear();this.keyReplies.clear();this.receiving.clear();+ this.receivingCount = 0;this.scope = this.deps.scope();}invalidate(instance: string): void {@@ -140,6 +142,10 @@ export class PluginDeviceSync {);};}+ private atCapacity(instance: string): boolean {+ return this.pending.size + this.incoming.size >= 32 ||+ [...this.pending.values(), ...this.incoming.values()].filter(p => p.instance === instance).length >= 2;+ }async handle(instance: string, raw: unknown): Promise<unknown> {if (this.scope !== this.deps.scope()) this.reset();const plugin = identity(this.deps.getGhost(instance));@@ -170,19 +176,11 @@ export class PluginDeviceSync {const current = this.capture(instance),peer = raw.peer;if (!current?.() || !this.transport?.allowed(peer)) return error('SYNC_OFFLINE');- if (- this.pending.size >= 32 ||- [...this.pending.values()].filter((p) => p.instance === instance).length >= 2- )- return error('SYNC_BUSY');+ if (this.atCapacity(instance)) return error('SYNC_BUSY');try {await this.deps.keys.prepare();if (!current() || !this.transport?.allowed(peer)) return error('SYNC_OFFLINE');- if (- this.pending.size >= 32 ||- [...this.pending.values()].filter((p) => p.instance === instance).length >= 2- )- return error('SYNC_BUSY');+ if (this.atCapacity(instance)) return error('SYNC_BUSY');if (!this.deps.keys.getPeerPublicKey(peer)) {this.transport.send(peer, {version: 1,@@ -244,16 +242,29 @@ export class PluginDeviceSync {raw.version !== 1)return;- if (this.receiving.has(peer) || this.receiving.size >= 32) return;+ // Keep concurrent requests (including different plugins) in arrival order.+ // At most 64 bounded frames across peers: request/response slots plus key exchange.+ if (this.receivingCount >= 64 ||+ (raw.kind !== 'key' && raw.kind !== 'data') ||+ (raw.kind === 'data' && (typeof raw.data !== 'string' || raw.data.length > Math.ceil(MAX_BYTES / 3) * 4)) ||+ (raw.kind === 'key' && !isValidContactsSyncPublicKey(raw.publicKey))) return;const generation = this.generation,- scope = this.deps.scope();+ scope = this.deps.scope(),+ receivedAt = Date.now();const current = () =>this.active &&generation === this.generation &&scope === this.deps.scope() &&- this.transport?.allowed(peer);- this.receiving.add(peer);+ Date.now() - receivedAt < TIMEOUT_MS &&+ this.transport?.allowed(peer) === true;+ const previous = this.receiving.get(peer);+ let release!: () => void;+ const turn = new Promise<void>((resolve) => { release = resolve; });+ this.receiving.set(peer, turn);+ this.receivingCount++;try {+ await previous;+ if (!current()) return;await this.deps.keys.prepare();if (!current()) return;if (raw.kind === 'key') {@@ -314,16 +325,19 @@ export class PluginDeviceSync {this.pending.delete(p.id);clearTimeout(pending.timer);pending.finish({ ok: true, data: p.data });- } else if (p.kind === 'request' && this.incoming.size < 32) {+ } else if (p.kind === 'request') {const ghost = this.deps.listGhosts().find((g) => {const i = identity(g);return i && same(i, packet.plugin);});if (!ghost) return;const instance = installedGhostStoragePart(ghost),- valid = this.capture(instance);- if (!valid?.()) return;+ pluginCurrent = this.capture(instance);+ if (!pluginCurrent?.() || this.atCapacity(instance)) return;const requestId = randomUUID();+ // A queued/startup-delayed request must still belong to this peer grant,+ // account, plugin revision and unexpired incoming request at actual delivery.+ const valid = () => current() && pluginCurrent();const timer = setTimeout(() => this.incoming.delete(requestId), TIMEOUT_MS);timer.unref?.();this.incoming.set(requestId, { peer, packet, instance, current: valid, timer });@@ -336,7 +350,7 @@ export class PluginDeviceSync {peer,data: p.data,},- valid,+ () => valid() && this.incoming.has(requestId),)) ||!valid()) {@@ -347,7 +361,11 @@ export class PluginDeviceSync {} catch {/* Invalid/unauthenticated frames never surface their contents or mutate plugin data. */} finally {- if (generation === this.generation) this.receiving.delete(peer);+ release();+ if (generation === this.generation) {+ this.receivingCount--;+ if (this.receiving.get(peer) === turn) this.receiving.delete(peer);+ }}}}diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.tsindex 503cc40efe..d8f33e48f7 100644--- a/apps/desktop/src/main/cindy-brain/index.ts+++ b/apps/desktop/src/main/cindy-brain/index.ts@@ -2030,7 +2030,9 @@ export const pluginDeviceSync = new PluginDeviceSync({if (!isCurrent()) return false;const scope = activeOwnerScopeKey();const id = installedGhostStoragePart(ghost);- const started = await getGhostRuntime().spawn(ghost);+ const runtime = getGhostRuntime();+ const started = await runtime.spawn(ghost);+ if (!started.ok || !await runtime.waitUntilRunning(id)) return false;return started.ok && isCurrent() && scope === activeOwnerScopeKey() &&ghostInstallApprovalToken(findGhostForInstanceId(id)?.approval) === ghostInstallApprovalToken(ghost.approval) && sendToGhostLogic(id, message);},diff --git a/apps/desktop/src/main/cindy-brain/runtime/GhostRuntime.ts b/apps/desktop/src/main/cindy-brain/runtime/GhostRuntime.tsindex 889ce61ce9..115cecf69c 100644--- a/apps/desktop/src/main/cindy-brain/runtime/GhostRuntime.ts+++ b/apps/desktop/src/main/cindy-brain/runtime/GhostRuntime.ts@@ -57,6 +57,7 @@ interface GhostRuntimeOptions {interface RuntimeEntry {state: GhostRuntimeState;handle: SandboxHandle | null;+ loading: Promise<void> | null;/** 熔断窗口内的崩溃时间戳(旧的滚动淘汰)。 */crashTimestamps: number[];}@@ -108,7 +109,8 @@ export class GhostRuntime {entry.handle = handle;handle.onGone((details) => this.handleGone(id, details.reason));try {- await handle.load();+ entry.loading = handle.load();+ await entry.loading;} catch (err) {// 入口都加载不出来按一次崩溃记账(坏 entry 反复 spawn 同样会熔断)。this.options.log?.warn('ghost sandbox load failed', { id, error: err instanceof Error ? err.message : String(err) });@@ -123,10 +125,19 @@ export class GhostRuntime {}// load 期间可能已被 stop/crash 改道;只有仍处 starting 才转 running。// (经 stateOf 重读:setState 走方法赋值,TS 的字面量收窄跟不上。)- if (this.stateOf(id) === 'starting') this.setState(id, entry, 'running');+ if (entry.handle === handle && this.stateOf(id) === 'starting') this.setState(id, entry, 'running');return { ok: true, state: this.stateOf(id) };}+ /** Await this sandbox's actual entry load, including an already-starting instance. */+ async waitUntilRunning(id: string): Promise<boolean> {+ const entry = this.entries.get(id);+ const handle = entry?.handle;+ if (!entry || !handle) return false;+ try { await entry.loading; } catch { return false; }+ return entry.handle === handle && entry.state === 'running';+ }+/** 熄灯(沉睡 / 抽离 / 闲置超时 / 退出前逐个关)。幂等。 */stop(id: string): void {const entry = this.entries.get(id);@@ -169,7 +180,7 @@ export class GhostRuntime {private getEntry(id: string): RuntimeEntry {let entry = this.entries.get(id);if (!entry) {- entry = { state: 'off', handle: null, crashTimestamps: [] };+ entry = { state: 'off', handle: null, loading: null, crashTimestamps: [] };this.entries.set(id, entry);}return entry;diff --git a/apps/desktop/src/main/cindy-brain/runtime/__tests__/GhostRuntime.test.ts b/apps/desktop/src/main/cindy-brain/runtime/__tests__/GhostRuntime.test.tsindex f5fb2c8f88..3fc44e140a 100644--- a/apps/desktop/src/main/cindy-brain/runtime/__tests__/GhostRuntime.test.ts+++ b/apps/desktop/src/main/cindy-brain/runtime/__tests__/GhostRuntime.test.ts@@ -198,3 +198,36 @@ describe('GhostRuntime · 状态机', () => {expect(runtime.stateOf('_ns__acme__helper')).toBe('running');});});++// PR #6569: a resident plugin can still be loading when sync calls spawn again.+// Existing tests used immediately-loaded sandboxes; these deferred loads exercise+// the production readiness boundary and stale-handle rejection without real waits (unit).+it.each(['ready', 'failed', 'replaced'] as const)('waits for the same sandbox load before delivery: %s', async (outcome) => {+ const loads: Array<{ resolve(): void; reject(error: Error): void }> = [];+ const runtime = new GhostRuntime({ adapter: { create: () => {+ const handle = new FakeHandle();+ handle.load = () => new Promise<void>((resolve, reject) => { loads.push({ resolve, reject }); });+ return handle;+ } } });+ const first = runtime.spawn(chipGhost());+ expect(await runtime.spawn(chipGhost())).toEqual({ ok: true, state: 'starting' });+ let delivered = false;+ const readiness = runtime.waitUntilRunning('demo').then(ready => { delivered = ready; return ready; });+ await Promise.resolve();+ expect(delivered).toBe(false);+ if (outcome === 'replaced') {+ runtime.stop('demo');+ const replacement = runtime.spawn(chipGhost());+ loads[0].resolve(); await first;+ expect(await readiness).toBe(false);+ expect(runtime.stateOf('demo')).toBe('starting');+ loads[1].resolve(); await replacement;+ expect(await runtime.waitUntilRunning('demo')).toBe(true);+ } else {+ if (outcome === 'failed') loads[0].reject(new Error('load failed'));+ else loads[0].resolve();+ await first;+ expect(await readiness).toBe(outcome === 'ready');+ }+ runtime.destroyAll();+});diff --git a/apps/desktop/src/main/device-link/index.ts b/apps/desktop/src/main/device-link/index.tsindex a8c53acda7..b7687a86c6 100644--- a/apps/desktop/src/main/device-link/index.ts+++ b/apps/desktop/src/main/device-link/index.ts@@ -1133,9 +1133,9 @@ export function initDeviceLinkService(options: DeviceLinkServiceOptions = {}): vpluginDeviceSync.connect({self: () => client?.getSelfDeviceId() ?? null,peers: () => [...presenceOnlineByDevice.entries()]- .filter(([deviceId, online]) => !isScopedPeer(deviceId) && deviceId !== client?.getSelfDeviceId() && shouldExchangeDictionaryWith({ online, platform: getControllerPlatform(deviceId), revoked: isDeviceRevoked(deviceId) }))+ .filter(([deviceId, online]) => !isScopedPeer(deviceId) && !revokedByRemote.has(deviceId) && deviceId !== client?.getSelfDeviceId() && shouldExchangeDictionaryWith({ online, platform: getControllerPlatform(deviceId), revoked: isDeviceRevoked(deviceId) })).map(([deviceId]) => ({ deviceId, deviceName: presenceNameByDevice.get(deviceId) ?? deviceId.slice(0, 8) })),- allowed: deviceId => !isScopedPeer(deviceId) && deviceId !== client?.getSelfDeviceId() &&+ allowed: deviceId => !isScopedPeer(deviceId) && !revokedByRemote.has(deviceId) && deviceId !== client?.getSelfDeviceId() &&shouldExchangeDictionaryWith({ online: presenceOnlineByDevice.get(deviceId) === true, platform: getControllerPlatform(deviceId), revoked: isDeviceRevoked(deviceId) }),send: (deviceId, frame) => { if (!client) throw new Error('device link unavailable'); client.sendPush(deviceId, PLUGIN_SYNC_CHANNEL, frame); },});diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex 51d4e8bd6d..9d6d560072 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -2753,6 +2753,9 @@ namespace + id 下同一插件的有界 JSON 请求;`deviceSync: true` 是独旧客户端忽略新通道,插件探测 API 后保留本地功能;超时不代表未执行,不自动重试非幂等动作。复用现有设备密钥库,AES-GCM AAD 使用 `plugin-sync:` transfer 标记与源/目标设备绑定。每请求 64 KiB、每插件 2 个/全机 32 个在途、30 秒超时;应用持久化后才回复。+接收按 peer 顺序排队,全机最多 64 帧;等待不会拦住其他 peer,账号重置后旧队列失效。+投递等待同一插件沙箱入口加载完成,并在实际发送前重查撤权与请求有效期。+显式断开远程控制后此通道可走 unlinked legacy;不重新打开控制链路,仍执行同账号与撤权检查。账号/owner、安装 revision、插件启停和撤权每次重新核验,旧请求失效只影响其调用,不重连共享 relay。恢复由插件持久状态对账,不恢复失效请求。实现与 unit 回归:`cindy-brain/deviceSyncSlot.ts` / `__tests__/deviceSyncSlot.test.ts`。diff --git a/packages/device-link/src/__tests__/client.test.ts b/packages/device-link/src/__tests__/client.test.tsindex 8896a7c845..ee5bedd098 100644--- a/packages/device-link/src/__tests__/client.test.ts+++ b/packages/device-link/src/__tests__/client.test.ts@@ -33,6 +33,7 @@ import {parseTransportAck,parseTransportPayload,} from '../transport.js';+import { PLUGIN_SYNC_CHANNEL } from '../pluginSyncProtocol.js';import { DL_CONTACTS_SYNC_CHANNEL } from '../contactsSyncProtocol.js';import { resolveRemoteInvokeTimeoutMs } from '../invokePolicy.js';import { SESSION_ACTIVITY_CHANNEL } from '../topics.js';@@ -3455,7 +3456,8 @@ describe('DeviceLinkClient', () => {h.client.stop();});- it('显式 close 后词典只读快照 push 仍走 unlinked legacy,不报 LINK_NOT_OPEN', async () => {+ // PR #6569: plugin data sync remains independent from the control link (unit wire fixture).+ it.each(['device-link:voice:dictionary:snapshot', PLUGIN_SYNC_CHANNEL])('显式 close 后 %s push 仍走 unlinked legacy,不报 LINK_NOT_OPEN', async (channel) => {const h = makeHarness({ timing: { pingIntervalMs: 1_000 } });h.client.start();await tick();@@ -3488,7 +3490,7 @@ describe('DeviceLinkClient', () => {const sentBefore = h.current().sent.length;expect(() => h.client.sendPush('dev-b',- 'device-link:voice:dictionary:snapshot',+ channel,{ ok: true, entries: [] },)).not.toThrow();const sent = h.current().sent.at(-1)!;@@ -3496,7 +3498,7 @@ describe('DeviceLinkClient', () => {expect(sent).toMatchObject({kind: 'push',dst: 'dev-b',- payload: { channel: 'device-link:voice:dictionary:snapshot' },+ payload: { channel },});expect(parseTransportPayload(sent.payload)).toBeNull();h.client.stop();diff --git a/packages/device-link/src/client.ts b/packages/device-link/src/client.tsindex e2a10bcd3a..49c99203a1 100644--- a/packages/device-link/src/client.ts+++ b/packages/device-link/src/client.ts@@ -67,6 +67,7 @@ import {byteLength,type RetransmitEstimate,} from './transport.js';+import { PLUGIN_SYNC_CHANNEL } from './pluginSyncProtocol.js';import { MAKER_EVENT_BATCH_CHANNEL } from './topics.js';/** Budget measurement: physical wire envelope size regardless of relay announcement. */@@ -5227,6 +5228,9 @@ const UNLINKED_LEGACY_INVOKE_CHANNELS = new Set(['maker:git-safety:get',]);const UNLINKED_LEGACY_PUSH_CHANNELS = new Set([+ // Same-account encrypted sync does not require an open remote-control link.+ // The Desktop plugin-sync receiver still checks owner, revocation and capability.+ PLUGIN_SYNC_CHANNEL,'device-link:voice:dictionary:snapshot',]);