Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(orca): 跨设备 Worker 带图派发显式拒绝,不再静默丢图

Zhang Yunjinf9e0d03e7ec4
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts
index e6f610aa54..89392da315 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkers.test.ts
@@ -408,6 +408,26 @@ describe('wrapTeamDeps', () => {
} finally { workers.stop(); }
});
+ it('rejects image attachments for cross-device workers instead of silently dropping them', async () => {
+ // 图片是 Lead 本机文件, 运行设备上的 Agent 读不到; 必须显式拒错, 不能只发文本返回 ok。
+ const { workers, remoteInvoke } = setup();
+ const base = baseDeps();
+ const wrapped = workers.wrapTeamDeps(base);
+ store.listActiveRemoteWorkers.mockResolvedValueOnce([restoredRow] as never);
+ try {
+ await workers.start();
+ const result = await wrapped.dispatchWorkerMessage({
+ targetSessionId: 'proxy-1', message: 'look at this', workerId: 'w-1',
+ imagePaths: ['C:/tmp/a.png'],
+ dispatchMeta: { source: 'mcp', context: 'send_to_worker' },
+ } as never);
+ expect(result.ok).toBe(false);
+ expect(result.dispatchOutcome).toMatchObject({ code: 'SEND_FAILED', accepted: false });
+ expect(String(result.dispatchOutcome?.message)).toContain('image attachments');
+ expect(remoteInvoke.mock.calls.some(([, channel]) => channel === 'maker:input:enqueue')).toBe(false);
+ } finally { workers.stop(); }
+ });
+
it('does not fall back locally when restoring routes fails', async () => {
store.listActiveRemoteWorkers.mockRejectedValueOnce(new Error('database unavailable'));
const { workers } = setup();
diff --git a/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts
index e184d06c9e..ad9c2f5a40 100644
--- a/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts
+++ b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts
@@ -664,6 +664,20 @@ export function createOrcaRemoteWorkers(deps: OrcaRemoteWorkersDeps) {
},
dispatchWorkerMessage: async (params) => {
if (!(await isRemoteWorker(params.targetSessionId))) return base.dispatchWorkerMessage(params);
+ // 图片是 Lead 本机文件, 运行设备上的 Agent 读不到; 跨设备通道只传文本, 必须显式拒绝而不是静默丢图。
+ if (params.imagePaths?.length) {
+ return {
+ ok: false,
+ dispatchOutcome: {
+ ...createHostSendFailure(
+ 'SEND_FAILED',
+ 'image attachments are only supported for local sessions; cross-device workers cannot read files stored on the Lead machine',
+ ),
+ source: params.dispatchMeta.source,
+ context: params.dispatchMeta.context,
+ },
+ };
+ }
// 与本机派发复用同一会话锁,保持 enqueue 与 accepted/commit 身份的顺序一致。
return base.withSessionSendLock(params.targetSessionId, async () => {
const clientId = createId();