Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
test: fix Windows link fixtures and MCP test typing
DavidShen3a935568d567
diff --git a/apps/desktop/src/main/cindy-make/__tests__/taskWorkspace.test.ts b/apps/desktop/src/main/cindy-make/__tests__/taskWorkspace.test.tsindex 5d1d4770f6..859f05c375 100644--- a/apps/desktop/src/main/cindy-make/__tests__/taskWorkspace.test.ts+++ b/apps/desktop/src/main/cindy-make/__tests__/taskWorkspace.test.ts@@ -68,10 +68,10 @@ describe('prepareCindyMakeWorkspace', () => {expect(phases).toEqual(['checking', 'creating', 'installing']);});- /** Windows without Developer Mode cannot create symlinks; Git stores plain files there. */+ /** Directory junctions exercise real links on Windows without requiring Developer Mode. */const linkIfPossible = async (target: string, link: string): Promise<boolean> => {try {- await symlink(target, link, 'dir');+ await symlink(target, link, process.platform === 'win32' ? 'junction' : 'dir');return true;} catch (error) {const code = (error as NodeJS.ErrnoException).code;diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/telegramBotMcpServer.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/telegramBotMcpServer.test.tsindex e606a0a4ba..a984ba7ccd 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/telegramBotMcpServer.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/telegramBotMcpServer.test.ts@@ -202,12 +202,21 @@ describe('cindy_telegram_bot sends into the current lane', () => {it('send_media goes through the transport; guests may only upload files inside the task directory', async () => {const t = fakeTransport();- const workingDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tg-mcp-'));- const inside = path.join(workingDir, 'chart.png');- fs.writeFileSync(inside, 'png');- const escapeLink = path.join(workingDir, 'hosts-link');- fs.symlinkSync('/etc/hosts', escapeLink);+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'tg-mcp-'));try {+ const workingDir = path.join(root, 'work');+ const outsideDir = path.join(root, 'outside');+ fs.mkdirSync(workingDir);+ fs.mkdirSync(outsideDir);+ const inside = path.join(workingDir, 'chart.png');+ const outside = path.join(outsideDir, 'private.txt');+ fs.writeFileSync(inside, 'png');+ fs.writeFileSync(outside, 'fixture');+ const escapeDir = path.join(workingDir, 'outside-link');+ // A file reached through a directory link still escapes realpath containment;+ // Windows junctions keep this regression runnable without symlink privileges.+ fs.symlinkSync(outsideDir, escapeDir, process.platform === 'win32' ? 'junction' : 'dir');+ const escapeLink = path.join(escapeDir, 'private.txt');await withServer(groupScope(t),async (call) => {@@ -217,7 +226,7 @@ describe('cindy_telegram_bot sends into the current lane', () => {file: 'chart.png',});expect(t.sendMedia).toHaveBeenLastCalledWith('g/-100/7', { kind: 'photo', absPath: fs.realpathSync.native(inside), caption: 'c' });- expect(await call('send_media', { kind: 'document', path: '/etc/passwd' })).toMatchObject({+ expect(await call('send_media', { kind: 'document', path: outside })).toMatchObject({ok: false,errorCode: 'PERMISSION_DENIED',});@@ -226,6 +235,7 @@ describe('cindy_telegram_bot sends into the current lane', () => {ok: false,errorCode: 'PERMISSION_DENIED',});+ expect(t.sendMedia).toHaveBeenCalledTimes(1);expect(await call('send_media', { kind: 'document', path: 'relative.bin' })).toMatchObject({ errorCode: 'PATH_NOT_ABSOLUTE' });expect(await call('send_media', { kind: 'sticker', file_id: 'CAAC1' })).toMatchObject({ ok: true });expect(await call('send_media', { kind: 'photo' })).toMatchObject({ ok: false, errorCode: 'NO_SOURCE' });@@ -234,10 +244,10 @@ describe('cindy_telegram_bot sends into the current lane', () => {);// The owner may send any absolute path (same as the Feishu send_file_to_user tool).await withServer(ownerDmScope(t), async (call) => {- expect(await call('send_media', { kind: 'document', path: '/etc/hosts' })).toMatchObject({ ok: true });+ expect(await call('send_media', { kind: 'document', path: outside })).toMatchObject({ ok: true });});} finally {- fs.rmSync(workingDir, { recursive: true, force: true });+ fs.rmSync(root, { recursive: true, force: true });}});diff --git a/packages/lizi-mcps/src/__tests__/feishuBotLaneTools.test.ts b/packages/lizi-mcps/src/__tests__/feishuBotLaneTools.test.tsindex 5f1503a826..ce11ed316f 100644--- a/packages/lizi-mcps/src/__tests__/feishuBotLaneTools.test.ts+++ b/packages/lizi-mcps/src/__tests__/feishuBotLaneTools.test.ts@@ -246,11 +246,13 @@ describe('cindy_feishu_bot 轮次内直通工具', () => {const outside = join(outsideDir, 'secret.txt');writeFileSync(inside, 'ok');writeFileSync(outside, 'secret');- symlinkSync(outside, join(workingDir, 'link.txt'));+ const linkDir = join(workingDir, 'outside-link');+ // Resolve a real file through a directory link; Windows junctions need no symlink privilege.+ symlinkSync(outsideDir, linkDir, process.platform === 'win32' ? 'junction' : 'dir');const im = fakeTransport();const guest = await harness(() => scopeOf(im, { requesterIsOwner: false, workingDir }));- for (const p of [outside, join(workingDir, 'link.txt'), join(workingDir, 'missing.txt')]) {+ for (const p of [outside, join(linkDir, 'secret.txt'), join(workingDir, 'missing.txt')]) {expect((await guest.call('send_file', { path: p })).payload.errorCode).toBe('PERMISSION_DENIED');}expect((await guest.call('send_file', { path: 'report.txt' })).payload.errorCode).toBe('PATH_NOT_ABSOLUTE');diff --git a/packages/lizi-mcps/src/__tests__/sessionControlTools.test.ts b/packages/lizi-mcps/src/__tests__/sessionControlTools.test.tsindex 85e00817d0..15ae5ee4c5 100644--- a/packages/lizi-mcps/src/__tests__/sessionControlTools.test.ts+++ b/packages/lizi-mcps/src/__tests__/sessionControlTools.test.ts@@ -165,9 +165,10 @@ describe('cindy_helper session control tools', () => {// 校验明细,调用方一轮自纠。const { registry } = setup();const result = parse(await registry.call('set_session_runtime', { effort: 'high' }));+ const data = result.data as Record<string, unknown> | undefined;expect(result).toMatchObject({ ok: false, errorCode: 'INVALID_ARGS' });- expect(JSON.stringify(result.data?.validation_errors ?? result)).toContain('expected_generation');- expect(result.data?.schema).toBeTruthy();+ expect(JSON.stringify(data?.validation_errors ?? result)).toContain('expected_generation');+ expect(data?.schema).toBeTruthy();});it('updates and cancels only through the caller-bound ownership context', async () => {diff --git a/packages/lizi-mcps/src/__tests__/submitGithubIssueTool.test.ts b/packages/lizi-mcps/src/__tests__/submitGithubIssueTool.test.tsindex 6ab5087f65..712fb0ab1f 100644--- a/packages/lizi-mcps/src/__tests__/submitGithubIssueTool.test.ts+++ b/packages/lizi-mcps/src/__tests__/submitGithubIssueTool.test.ts@@ -4,6 +4,7 @@*/import { describe, expect, it, vi } from 'vitest';+import type { z } from 'zod';import { XdtHelperToolRegistry } from '../lizi_xdtHelperToolRegistry.js';import type { XdtHelperToolResult } from '../lizi_xdtHelperToolRegistry.js';@@ -66,6 +67,7 @@ describe('submit_github_issue tool', () => {it('澄清流程交给 agent 判断,并与自动附加的当前任务环境区分', () => {const { registry } = setup();const tool = registry.get('submit_github_issue');+ const bodySchema = tool?.inputShape.body as z.ZodType | undefined;expect(tool?.description).toContain('缺什么问什么');expect(tool?.description).toContain('不要套固定问卷或章节清单');expect(tool?.description).toContain('普通建议不必按缺陷来问');@@ -76,15 +78,15 @@ describe('submit_github_issue tool', () => {expect(tool?.description).toContain('本工具不能把对话里的图片传到 GitHub');expect(tool?.description).toContain('禁止写「已提供截图」');expect(tool?.description).toContain('不要写仓库路径、实现方案、验收清单');- expect(tool?.inputShape.body.description).toContain('按这条反馈本身组织');- expect(tool?.inputShape.body.description).not.toContain('bug 优先用');- expect(tool?.inputShape.body.description).toContain('禁止声称截图已附');- expect(tool?.inputShape.body.description).toContain('提交时的任务环境');- expect(tool?.inputShape.body.description).toContain('实际故障');- expect(tool?.inputShape.body.description).toContain(+ expect(bodySchema?.description).toContain('按这条反馈本身组织');+ expect(bodySchema?.description).not.toContain('bug 优先用');+ expect(bodySchema?.description).toContain('禁止声称截图已附');+ expect(bodySchema?.description).toContain('提交时的任务环境');+ expect(bodySchema?.description).toContain('实际故障');+ expect(bodySchema?.description).toContain('不要复制系统自动附加的当前任务快照',);- expect(tool?.inputShape.body.description).not.toMatch(+ expect(bodySchema?.description).not.toMatch(/不要写环境信息\(客户端版本 \/ 版本区域 \/ OS \/ Harness \/ 模型 ID/,);});diff --git a/packages/lizi-mcps/src/computer/computerMcpServer.test.ts b/packages/lizi-mcps/src/computer/computerMcpServer.test.tsindex 24813c8078..53a3333b7c 100644--- a/packages/lizi-mcps/src/computer/computerMcpServer.test.ts+++ b/packages/lizi-mcps/src/computer/computerMcpServer.test.ts@@ -1251,7 +1251,7 @@ describe('createComputerMcpServer', () => {const authorizer = vi.fn(async (request: { path: string; toolName?: string }) => {expect(request.path).toBe(screenshot);expect(request.toolName).toBe('cindy-computer:get_window_state');- return { allowed: true, isCurrent: () => true };+ return { allowed: true as const, isCurrent: () => true };});setSessionPathAuthorizer(authorizer);const h = await makeHarness(deps, {