Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(provider-share): open the background link before reading a share
MagicLizie9ffa7485ac4
diff --git a/apps/desktop/src/main/device-link/__tests__/mirrorCacheIpcBoundary.test.ts b/apps/desktop/src/main/device-link/__tests__/mirrorCacheIpcBoundary.test.tsindex f87c93488f..1752f29400 100644--- a/apps/desktop/src/main/device-link/__tests__/mirrorCacheIpcBoundary.test.ts+++ b/apps/desktop/src/main/device-link/__tests__/mirrorCacheIpcBoundary.test.ts@@ -103,6 +103,7 @@ vi.mock('../index', () => ({openRemoteLink: vi.fn(),closeRemoteLink: vi.fn(),remoteInvoke: vi.fn(),+ providerShareHostInvoke: vi.fn(),remoteSubscribe: vi.fn(),remoteUnsubscribe: vi.fn(),disconnectAllControllers: vi.fn(),diff --git a/apps/desktop/src/main/device-link/__tests__/providerShareInvokeIpc.test.ts b/apps/desktop/src/main/device-link/__tests__/providerShareInvokeIpc.test.tsindex fbec273ceb..3332a2b4c9 100644--- a/apps/desktop/src/main/device-link/__tests__/providerShareInvokeIpc.test.ts+++ b/apps/desktop/src/main/device-link/__tests__/providerShareInvokeIpc.test.ts@@ -54,6 +54,15 @@ describe('provider share renderer reads', () => {await expect(handleProviderShareInvoke(deps, 'share:s1', 'maker:agent:status', ['codex'])).resolves.toEqual({ binaryReady: true });});+ it('reads through the background link to the owner computer when it is wired in', async () => {+ // relay 只在建链时登记受邀者这台电脑:直接发 invoke 会被拒成 providerShare peer unavailable。+ const hostInvoke = vi.fn(async () => ({ ok: true as const, result: { providers: [] } }));+ await expect(handleProviderShareInvoke({ invoke, invokeProviderShareHost: hostInvoke }, 'share:s1', 'maker:provider:list', [{ capabilities: [] }]))+ .resolves.toEqual({ providers: [] });+ expect(hostInvoke).toHaveBeenCalledWith('host-peer', 'maker:provider:list', [{ capabilities: [] }]);+ expect(invoke).not.toHaveBeenCalled();+ });+it('logs why a read failed, once a minute per error', async () => {warn.mockClear();invoke.mockResolvedValue({ ok: false, error: { code: 'DEVICE_OFFLINE', message: 'peer offline' } });diff --git a/apps/desktop/src/main/device-link/index.ts b/apps/desktop/src/main/device-link/index.tsindex f060b8ebc8..e5591cf7d7 100644--- a/apps/desktop/src/main/device-link/index.ts+++ b/apps/desktop/src/main/device-link/index.ts@@ -1881,6 +1881,15 @@ export async function remoteBackgroundInvoke(}}+/**+ * 分享者那台电脑(已解析成本地 peer key)的只读请求:relay 只在建链时登记受邀者这台电脑,没建过链的+ * 电脑直接发 invoke 会被当成不在分享名单里(`providerShare peer unavailable`)。与远程 Agent、手机代读+ * 分享同一条路:先建后台链路,再请求。+ */+export function providerShareHostInvoke(target: string, channel: string, args: unknown[]): Promise<InvokeResultPayload> {+ return backgroundInvokeDevice(target, channel, args);+}+async function backgroundInvokeDevice(deviceId: string, channel: string, args: unknown[]): Promise<InvokeResultPayload> {if (!client?.isLinkReady(deviceId)) {assertBackgroundLinkAccepted(await openRemoteLink(deviceId), {diff --git a/apps/desktop/src/main/device-link/ipc.ts b/apps/desktop/src/main/device-link/ipc.tsindex e3a2b01ec8..5dade749ee 100644--- a/apps/desktop/src/main/device-link/ipc.ts+++ b/apps/desktop/src/main/device-link/ipc.ts@@ -45,6 +45,7 @@ import {openRemoteLink,closeRemoteLink,remoteInvoke,+ providerShareHostInvoke,remoteSubscribe,remoteUnsubscribe,disconnectAllControllers,@@ -132,6 +133,8 @@ export interface DeviceLinkIpcDeps {openLink(deviceId: string): Promise<LinkAcceptPayload>;closeLink(deviceId: string): void;invoke(deviceId: string, channel: string, args: unknown[]): Promise<InvokeResultPayload>;+ /** 分享者电脑的只读请求:先建后台链路再发(relay 只在建链时登记受邀者的电脑)。缺省时用 invoke。 */+ invokeProviderShareHost?(target: string, channel: string, args: unknown[]): Promise<InvokeResultPayload>;subscribe(deviceId: string, topics: string[]): Promise<InvokeResultPayload>;unsubscribe(deviceId: string, topics: string[]): Promise<InvokeResultPayload>;disconnectAll(): void;@@ -195,6 +198,7 @@ export function defaultDeps(): DeviceLinkIpcDeps {requireDeviceLinkCapability();return remoteInvoke(...args);},+ invokeProviderShareHost: providerShareHostInvoke,subscribe: remoteSubscribe,unsubscribe: remoteUnsubscribe,disconnectAll: disconnectAllControllers,@@ -775,7 +779,7 @@ function logProviderShareReadFailure(agentDeviceId: string, channel: string, cod}export async function handleProviderShareInvoke(- deps: Pick<DeviceLinkIpcDeps, 'invoke'>,+ deps: Pick<DeviceLinkIpcDeps, 'invoke' | 'invokeProviderShareHost'>,agentDeviceId: string,channel: unknown,args: unknown,@@ -796,7 +800,7 @@ export async function handleProviderShareInvoke(try {result = isCrossRegionProviderShareTarget(target)? await crossRegionInvoke(target, channel, callArgs)- : await deps.invoke(target, channel, callArgs);+ : await (deps.invokeProviderShareHost ?? deps.invoke)(target, channel, callArgs);} catch (err) {logProviderShareReadFailure(agentDeviceId,diff --git a/docs/provider-sharing-implementation-plan.md b/docs/provider-sharing-implementation-plan.mdindex 6ca257b291..e770748dd3 100644--- a/docs/provider-sharing-implementation-plan.md+++ b/docs/provider-sharing-implementation-plan.md@@ -61,6 +61,9 @@没有分享时「分享给我的供应商」整组不显示;自己其他电脑上能用的远程供应商也列进左栏(远程角标,悬停提示写所在电脑;只读详情)。分享者电脑版本太旧、答不了 Agent 能力时,受邀者的模型列表直接提示「请让对方更新 Cindy」,不再只报读取失败。加入页「唤起失败」的指引文案(服务端)需改成新入口名。+- **受邀者读分享的模型目录(真机反馈三补)**:设置页详情与模型选择器读分享者电脑时,先建到那台的后台链路再请求,与远程 Agent、+ 手机代读同一条路。relay 只在 link-open 时把受邀者的这台电脑登记进成员,没建过链的电脑(新装、换了设备 id 的开发版)直接+ invoke 会被回 `DEVICE_OFFLINE` / `providerShare peer unavailable`,此前表现为「状态正常却一个模型都读不到」。- **待产品决定**:受邀者能看到分享者电脑的设备名(macOS 默认是「<全名>的 MacBook」,可能含真实姓名)。任务运行中途被拒绝、或轮询放弃时,个别错误仍是同账号文案(「到那台电脑上打开…」)。- **P3 客户端**:凭证只在内存,不落盘;本机只记不含凭证的区域标记,没有标记的账号从不联系对方区域;对方区域请求