Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mcp): 保留 Bot 所属任务的固定工作区
Dash65ee6e852798
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/moveSession.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/moveSession.test.tsindex 4bbfe26f74..3350832c15 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/moveSession.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/moveSession.test.ts@@ -6,6 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';const h = vi.hoisted(() => ({owner: { dataOwnerId: 'owner-a', ownerGeneration: 1 },query: vi.fn(),+ botLinks: [] as Array<{ botId: string }>,workers: [] as Array<{ sessionId: string }>,running: new Set<string>(),attached: false,@@ -18,12 +19,13 @@ vi.mock('../../appSessionState.js', () => ({getActiveDataOwnerPushStamp: () => ({ ...h.owner }),isAppSessionBoundaryPending: () => false,}));-vi.mock('../../localDb/client/current.js', () => {+vi.mock('../../localDb/client/current.js', async () => {+ const { botSessionLinks } = await import('../../localDb/schema.js');const client = {drizzle: {select: () => ({- from: () => ({- where: () => ({ limit: h.query }),+ from: (table: unknown) => ({+ where: () => ({ limit: table === botSessionLinks ? async () => h.botLinks : h.query }),innerJoin: () => ({ where: async () => h.workers }),}),}),@@ -55,6 +57,7 @@ describe('moveSession host', () => {h.owner = { dataOwnerId: 'owner-a', ownerGeneration: 1 };h.running = new Set();h.workers = [];+ h.botLinks = [];h.attached = false;h.enterLock.mockImplementation(() => undefined);h.query.mockResolvedValue([@@ -144,6 +147,26 @@ describe('moveSession host', () => {expect(await run(null)).toMatchObject({ errorCode: 'PRECONDITION_FAILED' });expect(h.saved).not.toHaveBeenCalled();});+ it.each([false, true])(+ 'keeps Bot-owned tasks in their managed workspace (project=%s)',+ async (project) => {+ const workingDir = project ? directory : null;+ // Source-only records and legacy linked records share the same restriction.+ h.query+ .mockResolvedValueOnce([{ id: 'caller' }])+ .mockResolvedValueOnce([{ id: 'target', status: 'active', source: 'bot' }]);+ expect(await run(workingDir)).toMatchObject({ errorCode: 'UNSUPPORTED_CAPABILITY' });+ h.enterLock.mockImplementationOnce(() => {+ h.botLinks = [{ botId: 'bot' }];+ });+ expect(await run(workingDir)).toMatchObject({ errorCode: 'UNSUPPORTED_CAPABILITY' });+ expect(h.saved).not.toHaveBeenCalled();+ // A normal delegated task is not a Bot-owned task; parent linkage does not restrict moving it.+ h.botLinks = [];+ h.query.mockResolvedValue([{ id: 'target', status: 'active', parentSessionId: 'bot-task' }]);+ expect(await run(workingDir)).toMatchObject({ ok: true });+ },+ );it('rejects missing directories, files, and relative paths without writing', async () => {expect(await run(path.join(directory, 'missing'))).toMatchObject({ errorCode: 'NOT_FOUND' });await writeFile(path.join(directory, 'file'), 'keep');diff --git a/apps/desktop/src/main/mcp-integrations/moveSession.ts b/apps/desktop/src/main/mcp-integrations/moveSession.tsindex d89c6d70d9..638fe5aac2 100644--- a/apps/desktop/src/main/mcp-integrations/moveSession.ts+++ b/apps/desktop/src/main/mcp-integrations/moveSession.ts@@ -1,6 +1,6 @@import { and, eq } from 'drizzle-orm';import type { XdtHelperMcpDeps } from '@cindy/mcps';-import { sessions, orcaTeams, orcaWorkers } from '../localDb/schema.js';+import { sessions, orcaTeams, orcaWorkers, botSessionLinks } from '../localDb/schema.js';import { updateSessionInDb } from '../localDb/ipc/sessions.js';import { bindingStore } from '../im/binding.js';import { throwIpcError } from '../utils/ipcValidate.js';@@ -59,6 +59,15 @@ export function createMoveSession('UNSUPPORTED_CAPABILITY','Review task settings are fixed to the source task.',);+ // Bot runtime resolves its workspace from the ownership link, including legacy tasks.+ const [botLink] = await context.client.drizzle+ .select({ botId: botSessionLinks.botId })+ .from(botSessionLinks)+ .where(eq(botSessionLinks.sessionId, sessionId))+ .limit(1);+ context.assertCurrent();+ if (target.source === 'bot' || botLink)+ throwIpcError('UNSUPPORTED_CAPABILITY', 'Bot tasks use their own managed workspace.');workers =target.orcaRole === 'lead'? await context.client.drizzlediff --git a/packages/lizi-mcps/src/xdt-helper/move_session.ts b/packages/lizi-mcps/src/xdt-helper/move_session.tsindex 9e8431d6f6..db098990ff 100644--- a/packages/lizi-mcps/src/xdt-helper/move_session.ts+++ b/packages/lizi-mcps/src/xdt-helper/move_session.ts@@ -29,7 +29,7 @@ export function registerMoveSessionTool(name: "move_session",category: "control",description:- "Move an existing local Cindy task into a project or between projects. Pass an existing absolute directory as working_dir. Pass null to remove the project grouping while retaining the task’s working directory, matching the UI. Reuses Cindy’s task move path, including transcript relocation and idle runtime refresh; does not move project files or create a task. Running tasks (including a lead with running workers), IM-controlled tasks, archived/deleted tasks and Review tasks cannot move. SSH tasks are unsupported. Cannot move the calling task while it is executing this tool. Use list_sessions to find session_id and list_projects to find directories; create_project restores a hidden project.",+ "Move an existing local Cindy task into a project or between projects. Pass an existing absolute directory as working_dir. Pass null to remove the project grouping while retaining the task’s working directory, matching the UI. Reuses Cindy’s task move path, including transcript relocation and idle runtime refresh; does not move project files or create a task. Running tasks (including a lead with running workers), IM-controlled tasks, archived/deleted tasks, Bot-owned tasks and Review tasks cannot move. SSH tasks are unsupported. Cannot move the calling task while it is executing this tool. Use list_sessions to find session_id and list_projects to find directories; create_project restores a hidden project.",inputShape: {session_id: z.string().trim().min(1).max(256),working_dir: z.string().trim().min(1).max(4096).nullable(),