Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
chore: 合并上游 main,解决冲突
Zhang Yunjinbfe1aaf73090
diff --cc apps/desktop/src/main/maker-ipc/__tests__/orcaTeamService.test.tsindex c17e8eb4b3,f660c5cd4a..200bfd7b5d--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaTeamService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaTeamService.test.ts@@@ -545,26 -558,9 +558,26 @@@ describe('OrcaTeamService', () =>finalText: '完成了',});- expect(leadMessages).toEqual(['[Auto-bridged: worker 完成但未调 send_to_lead]\n\n完成了']);+ expect(leadMessages).toEqual(['[Auto-bridged: worker 已完成,系统自动回传结果]\n\n完成了']);});+ it('forwards imagePaths through dispatchWorkerTask to the shared primitive', async () => {+ const { deps, service } = createDeps();++ await expect(+ service.dispatchWorkerTask({+ targetSessionId: 'worker-session-1',+ message: '看截图',+ imagePaths: ['C:/tmp/a.png'],+ dispatchMeta: { source: 'test-source', context: 'images' },+ }),+ ).resolves.toMatchObject({ dispatched: true });++ expect(deps.dispatchWorkerMessage).toHaveBeenCalledWith(+ expect.objectContaining({ imagePaths: ['C:/tmp/a.png'] }),+ );+ });+it('resumes a stale running worker before dispatching the next task', async () => {const { deps, service, setWorker } = createDeps();setWorker(diff --cc apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.tsindex ad9c2f5a40,1b700cbb88..c1d6c05b39--- a/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts+++ b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkers.ts@@@ -664,22 -674,9 +674,23 @@@ export function createOrcaRemoteWorkers},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 dispatchOwner = ownerToken();const clientId = createId();const meta = { source: params.dispatchMeta.source, context: params.dispatchMeta.context };let acceptedDidRun = false;diff --cc apps/desktop/src/main/maker-ipc/register.tsindex 6e040440f1,932269b85f..f6698d4821--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@@ -879,8 -915,8 +915,9 @@@ importtype OrcaInterAgentDispatcher,type OrcaInterAgentMessageSource,} from './orcaInterAgentDispatcher.js';+import { resolveOrcaImageAttachmentInput } from './orcaImageAttachments.js';import { OrcaWorkerPermissionConfirmBridge } from './orcaWorkerPermissionConfirmBridge.js';+ import { assertTaskActionCurrent, captureTaskActionGuard, bindTaskActionInput, hasTaskActionAuthorization, taskActionInputGuard, settleTaskActionInput, TaskActionAuthorizationError, type TaskActionDeliveryGuard } from './taskActionAuthorization.js';import {getOrcaWorkspaceInfoReadOnly,getOrcaWorkerDiagnosticStatusReadOnly,@@@ -2437,8 -2693,8 +2694,9 @@@ interface OrcaCollabServiceworkerPermissionMode?: OrcaWorkerPermissionMode;label: string;workingDir?: string;+ worktree?: { sourceBranch?: string };initialTask?: string;+ initialTaskImages?: string[];executionDeviceId?: string;/** Worker 的 Agent 所在位置;语义见 OrcaWorkerCreateParams.agentDeviceId。 */agentDeviceId?: string | null;diff --cc apps/desktop/src/main/mcp-integrations/__tests__/collabSendOutcome.test.tsindex be9cd9054c,c7cc3e8eae..2e5c43a520--- a/apps/desktop/src/main/mcp-integrations/__tests__/collabSendOutcome.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/collabSendOutcome.test.ts@@@ -206,51 -229,97 +229,142 @@@ describe('collab send outcome semantics});+ it('maps send_to_worker images to the host imagePaths field at the collab boundary', async () => {+ const sendToWorker = vi.fn(async () => ({+ ok: true as const,+ agentKind: 'codex' as const,+ wakeKind: 'already-active' as const,+ targetTitle: null,+ targetLastUserSendAt: null,+ }));+ mockState.collabService = createCollabService({ sendToWorker });+ createDesktopMcpProviders({+ botCapabilities,+ getMakerMemoryManager: vi.fn(),+ lspPool: {} as never,+ pluginRegistry: { isEnabled: () => false, getPlugins: () => [] } as never,+ invokeRemote: vi.fn(),+ });+ const orca = mockState.capturedProvidersConfig?.orca as {+ sendToWorker: (params: Record<string, unknown>) => Promise<unknown>;+ };++ await orca.sendToWorker({+ callerLeadSessionId: 'lead-1',+ targetSessionId: 'worker-session-1',+ message: 'look',+ images: ['C:/tmp/a.png'],+ });+ expect(sendToWorker).toHaveBeenCalledWith({+ callerLeadSessionId: 'lead-1',+ targetSessionId: 'worker-session-1',+ message: 'look',+ imagePaths: ['C:/tmp/a.png'],+ });++ await orca.sendToWorker({+ callerLeadSessionId: 'lead-1',+ targetSessionId: 'worker-session-1',+ message: 'text only',+ });+ expect(sendToWorker).toHaveBeenLastCalledWith({+ callerLeadSessionId: 'lead-1',+ targetSessionId: 'worker-session-1',+ message: 'text only',+ });+ });++ // #6439: real Desktop host callbacks + worker DB, only the external IM service+ // is replaced. Covers missing awaits at host call sites, beyond resolver tests.+ it('sends canonical background text and files through companion host callbacks with a worker DB', async () => {+ const client = await createDbClient({ transport: 'worker-thread', useInlineWorker: true });+ try {+ commitVolatileAppSession('cloud', 'feishu-test-owner');+ await client.exec('CREATE TABLE sessions (id TEXT PRIMARY KEY, source TEXT)');+ await client.exec('CREATE TABLE bot_session_links (session_id TEXT, bot_id TEXT, role TEXT)');+ await client.exec('CREATE TABLE bot_profiles (id TEXT PRIMARY KEY, status TEXT)');+ await client.exec("INSERT INTO bot_profiles VALUES ('bot-feishu', 'active')");+ await client.exec("INSERT INTO sessions VALUES ('background-receipt', 'bot')");+ await client.exec("INSERT INTO bot_session_links VALUES ('background-receipt', 'bot-feishu', 'canonical')");+ setCurrentDbClient(client, 'feishu-test-owner');+ createDesktopMcpProviders({+ botCapabilities,+ getMakerMemoryManager: vi.fn(),+ lspPool: {} as never,+ pluginRegistry: { isEnabled: () => true, getPlugins: () => [] } as never,+ invokeRemote: vi.fn(),+ });+ const feishu = mockState.capturedProvidersConfig!.feishuBot as FeishuBotMcpHostDeps;+ const session = { sessionId: 'background-receipt', sessionInstanceId: 'runtime' };+ const owner = await feishu.getOwnerOpenId(session);+ expect(owner).toBe('ou_companion');+ expect(await feishu.sendMessage(owner!, 'task complete', session.sessionId, session))+ .toMatchObject({ ok: true, messageId: 'om_companion_text' });+ expect(await feishu.sendFile(owner!, '/tmp/report.txt', 'report.txt', session))+ .toMatchObject({ ok: true, messageId: 'om_companion_file' });+ expect(mockState.companionFeishu.sendMarkdownText).toHaveBeenCalledWith('ou_companion', 'task complete');+ expect(mockState.companionFeishu.sendFile).toHaveBeenCalledWith('ou_companion', '/tmp/report.txt', 'report.txt');++ // A boundary may start after the resolver fulfills but before its caller+ // resumes. Both production send callbacks must recheck before dispatch.+ for (const transition of ['pending', 'generation'] as const) {+ for (const send of [+ () => feishu.sendMessage(owner!, 'must not send', session.sessionId, session),+ () => feishu.sendFile(owner!, '/tmp/report.txt', 'report.txt', session),+ ]) {+ let release: (() => void) | undefined;+ mockState.companionFeishu.sendMarkdownText.mockClear();+ mockState.companionFeishu.sendFile.mockClear();+ mockState.afterSelectCompanion = () => {+ if (transition === 'pending') release = beginAppSessionBoundary();+ else commitVolatileAppSession('cloud', 'feishu-test-owner', true);+ };+ try {+ expect(await send()).toMatchObject({ ok: false, reason: 'SEND_FAIL' });+ expect(mockState.companionFeishu.sendMarkdownText).not.toHaveBeenCalled();+ expect(mockState.companionFeishu.sendFile).not.toHaveBeenCalled();+ } finally {+ mockState.afterSelectCompanion = null;+ release?.();+ }+ }+ }++ // A paused profile may still have a live tool call and connected transport.+ // The persisted pause must block both sends even though its link survives.+ await client.exec("UPDATE bot_profiles SET status = 'paused' WHERE id = 'bot-feishu'");+ try {+ await expect(feishu.getOwnerOpenId(session)).rejects.toThrow('Companion is not active');+ expect(await feishu.sendMessage(owner!, 'paused', session.sessionId, session))+ .toMatchObject({ ok: false, reason: 'SEND_FAIL' });+ expect(await feishu.sendFile(owner!, '/tmp/report.txt', 'report.txt', session))+ .toMatchObject({ ok: false, reason: 'SEND_FAIL' });+ expect(mockState.companionFeishu.sendMarkdownText).not.toHaveBeenCalled();+ expect(mockState.companionFeishu.sendFile).not.toHaveBeenCalled();+ expect(mockState.personalFeishu.sendMarkdownText).not.toHaveBeenCalled();+ expect(mockState.personalFeishu.sendFile).not.toHaveBeenCalled();+ } finally {+ await client.exec("UPDATE bot_profiles SET status = 'active' WHERE id = 'bot-feishu'");+ }++ // Same-account archive removes canonical membership without changing the+ // DB snapshot. An app-scoped recipient must not cross to personal credentials.+ await client.exec("UPDATE bot_session_links SET role = 'history' WHERE session_id = 'background-receipt'");+ for (const send of [+ () => feishu.sendMessage(owner!, 'must not switch bots', session.sessionId, session),+ () => feishu.sendFile(owner!, '/tmp/report.txt', 'report.txt', session),+ ]) {+ expect(await send()).toMatchObject({ ok: false, reason: 'SEND_FAIL' });+ }+ expect(mockState.personalFeishu.sendMarkdownText).not.toHaveBeenCalled();+ expect(mockState.personalFeishu.sendFile).not.toHaveBeenCalled();+ } finally {+ commitVolatileAppSession('signed-out');+ clearCurrentDbClient(client);+ await client.dispose();+ }+ });+it('rejects start_skill_learning after the built-in Learn Skill is disabled', async () => {mockState.learnEnabled = false;createDesktopMcpProviders({diff --cc packages/lizi-mcps/src/orca/server.tsindex 4947c4944f,aaa7c5a482..5b296e2cf9--- a/packages/lizi-mcps/src/orca/server.ts+++ b/packages/lizi-mcps/src/orca/server.ts@@@ -109,10 -112,9 +112,10 @@@ export interface OrcaMcpDeps/** Worker 的 Agent 所在位置:null = 任务所在电脑;省略 = 跟 Lead。 */agentDeviceId?: string | null;initialTask?: string;+ initialTaskImages?: string[];}) => Promise<ControlResult<- { workerId: string; workerSessionId: string; softLimitExceeded?: boolean; dispatched?: boolean; dispatchOutcome?: import('../lizi_xdtHelperMcpServer.js').ControlDispatchOutcome; queuedMessageId?: string },+ { workerId: string; workerSessionId: string; workingDir?: string; worktree?: { path: string; branch: string }; softLimitExceeded?: boolean; dispatched?: boolean; dispatchOutcome?: import('../lizi_xdtHelperMcpServer.js').ControlDispatchOutcome; queuedMessageId?: string },'INVALID_PARAMS' | 'NOT_FOUND' | 'WORKER_LIMIT_HARD_EXCEEDED' | 'DUPLICATE_LABEL' | 'WORKER_CREATION_IN_PROGRESS' | 'BUDGET_MODEL_REQUIRES_API_MODE' | 'NO_PROVIDER_FOR_AGENT' | 'PROVIDER_ROUTE_UNAVAILABLE' | 'REMOTE_AGENT_DEVICE_UNREACHABLE' | 'REMOTE_AGENT_SHARE_PAUSED' | 'REMOTE_AGENT_SHARE_REMOVED' | 'REMOTE_AGENT_SHARE_UNAVAILABLE' | 'UNSUPPORTED_CAPABILITY'>>;diff --cc packages/lizi-mcps/src/xdt-helper/create_worker.tsindex 868c16b13c,93bb605877..0a4fab9b6d--- a/packages/lizi-mcps/src/xdt-helper/create_worker.ts+++ b/packages/lizi-mcps/src/xdt-helper/create_worker.ts@@@ -147,11 -123,15 +150,18 @@@ export const createWorkerSpecSchema = z.min(1).optional().describe('可选, 创建后立即派给 worker 的第一条消息'),+ images: imagesListSchema+ .optional()+ .describe('可选, 随 initial_task 发给 worker 的图片(png/jpeg/gif/webp, 最多 8 张); 必须是扁平字符串数组, 每张图一个字符串, 如 ["cindy-media://...png"]; 仅本机 worker 支持, SSH 远端 worker 会拒绝; 不传 initial_task 时忽略。地址两类: (a) 用户在对话里贴的图 — 把上下文 <cindy-host-image-references> 里的 uri 原样传入; (b) Lead 自己落盘的本机绝对路径'),working_dir: z.string().min(1).max(4096).refine((value) => value.trim().length > 0).optional()- .describe('可选,Worker 所在主机上已存在的绝对工作目录;省略则继承 Lead。创建前校验并绑定,失败不回退;不创建目录或 Git worktree。指定 execution_device_id 时是那台电脑上的目录,省略则由那台分配任务目录。'),+ .describe('可选,Worker 所在主机上已存在的绝对目录。省略时继承 Lead 任务记录的工作目录(启动时的目录),不会跟随之后 cd 进入的 worktree。希望共用你当前的 worktree(含 git worktree add 自建的)时,请显式传其绝对路径;需要独立的新 worktree 时用 new_worktree。显式 working_dir / new_worktree 按会话权限审批。指定 execution_device_id 时目录属于那台电脑,省略由那台分配;校验失败不回退。'),+ new_worktree: z.object({+ source_branch: z.string().min(1).max(1024)+ .refine((value) => value.trim().length > 0 && !value.startsWith('-') && !Array.from(value).some((character) => character.charCodeAt(0) < 32))+ .optional()+ .describe('可选,源分支或提交;省略使用目标目录的当前分支,分离 HEAD 时使用当前提交。'),+ }).strict().optional()+ .describe('可选,为 Worker 新建自有 Git worktree,传 {} 使用默认源分支。仅支持本机有提交的 Git 项目;不支持 SSH 或 execution_device_id。working_dir 指定源项目,返回 working_dir 才是 Worker 实际目录。此选项按会话权限审批。归档 Worker 时按普通任务规则回收该 worktree,未提交改动先快照。'),execution_device_id: z.string().trim().min(1).max(128).optional().describe('可选,运行设备:同账号另一台电脑的设备 id,只能取 get_workspace_info 返回的 execution_devices 中 supported=true 的 device_id。指定后 Worker 的任务、目录、命令与文件都在那台电脑;省略则与 Lead 同一台。那台离线、未开启远程控制或版本过旧时创建失败,不会回退到本机。'),agent_device_id: z.string().trim().min(1).max(128).optional()@@@ -212,7 -192,7 +223,7 @@@ export function registerCreateWorkerToocategory: 'control',description: DESCRIPTION,inputShape: createWorkerSpecSchema.shape,- handler: async ({ role, agent, model, provider_id, effort, fast, label, initial_task, images, working_dir, execution_device_id, agent_device_id }) => {- handler: async ({ role, agent, model, provider_id, effort, fast, label, initial_task, working_dir, new_worktree, execution_device_id, agent_device_id }) => {++ handler: async ({ role, agent, model, provider_id, effort, fast, label, initial_task, images, working_dir, new_worktree, execution_device_id, agent_device_id }) => {const ctx = deps.getSessionContext?.() ?? deps;if (!ctx.sessionId) {return errorPayload('LEAD_NOT_SUPPORTED', '当前 session 类型不支持作为 Lead。');@@@ -233,7 -213,7 +244,8 @@@fast,label,...(working_dir !== undefined ? { workingDir: working_dir } : {}),+ ...(images ? { initialTaskImages: images } : {}),+ ...(new_worktree !== undefined ? { worktree: new_worktree.source_branch === undefined ? {} : { sourceBranch: new_worktree.source_branch } } : {}),...(execution_device_id !== undefined ? { executionDeviceId: execution_device_id } : {}),...toHostAgentDeviceId(agent_device_id),initialTask: initial_task,diff --cc packages/lizi-mcps/src/xdt-helper/create_workers.tsindex 93d2069a3d,31106cad31..7a5d4e2c5d--- a/packages/lizi-mcps/src/xdt-helper/create_workers.ts+++ b/packages/lizi-mcps/src/xdt-helper/create_workers.ts@@@ -154,7 -158,7 +158,8 @@@ export function registerCreateWorkersTofast: worker.fast,label: worker.label,...(worker.working_dir !== undefined ? { workingDir: worker.working_dir } : {}),+ ...(worker.images ? { initialTaskImages: worker.images } : {}),+ ...(worker.new_worktree !== undefined ? { worktree: worker.new_worktree.source_branch === undefined ? {} : { sourceBranch: worker.new_worktree.source_branch } } : {}),...(worker.execution_device_id !== undefined ? { executionDeviceId: worker.execution_device_id } : {}),...toHostAgentDeviceId(worker.agent_device_id),initialTask: worker.initial_task,