Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): keep agent update checks metadata-only
Cindy885ee6895490
diff --git a/apps/desktop/src/main/__tests__/updateService.test.ts b/apps/desktop/src/main/__tests__/updateService.test.tsindex 89177da553..fe5a502902 100644--- a/apps/desktop/src/main/__tests__/updateService.test.ts+++ b/apps/desktop/src/main/__tests__/updateService.test.ts@@ -327,40 +327,33 @@ describe('installation version repair scope', () => {});describe('agent-facing managed app update check', () => {- it('reports a downloaded newer version without restarting the app', async () => {- readAutoUpdateSettings.mockReturnValue({ autoRelaunchOnIdle: false });- fetchManifest.mockResolvedValue(updateManifest());- download.mockImplementation(async ({ targetPath }: { targetPath: string }) => {- fs.mkdirSync(path.dirname(targetPath), { recursive: true });- fs.writeFileSync(targetPath, 'update');- return { path: targetPath, size: 123 };- });+ it('checks version metadata without staging a patch or arming auto-relaunch', async () => {+ // Auto-relaunch is enabled. The normal background check gets a same-version+ // manifest so this test isolates any patch staged by the Agent check.+ fetchManifest.mockResolvedValueOnce(updateManifest()).mockResolvedValue(updateManifest('0.0.64'));const service = await freshUpdateService('darwin');try {+ service.initUpdateService();expect(await service.checkAppUpdateForAgent()).toMatchObject({- status: 'ready', currentVersion: '0.0.64', targetVersion: '0.0.65',+ status: 'available', currentVersion: '0.0.64', targetVersion: '0.0.65',});- await vi.advanceTimersByTimeAsync(5_000);+ expect(download).not.toHaveBeenCalled();+ await vi.advanceTimersByTimeAsync(65_000);+ expect(download).not.toHaveBeenCalled();expect(spawnProcess).not.toHaveBeenCalled();+ expect(appQuit).not.toHaveBeenCalled();} finally {service.stopUpdateService();}});- it('rejects a staged patch after the macOS app moves into a translocated location', async () => {- readAutoUpdateSettings.mockReturnValue({ autoRelaunchOnIdle: false });+ it('rejects a translocated macOS app without staging a patch', async () => {fetchManifest.mockResolvedValue(updateManifest());- download.mockImplementation(async ({ targetPath }: { targetPath: string }) => {- fs.mkdirSync(path.dirname(targetPath), { recursive: true });- fs.writeFileSync(targetPath, 'update');- return { path: targetPath, size: 123 };- });const service = await freshUpdateService('darwin');- expect(await service.checkAppUpdateForAgent()).toMatchObject({ status: 'ready' });+ expect(await service.checkAppUpdateForAgent()).toMatchObject({ status: 'available' });appIsInApplicationsFolder.mockReturnValue(false);expect(await service.checkAppUpdateForAgent()).toMatchObject({ status: 'unsupported' });- await vi.advanceTimersByTimeAsync(5_000);- expect(spawnProcess).not.toHaveBeenCalled();+ expect(download).not.toHaveBeenCalled();service.stopUpdateService();});@@ -390,6 +383,16 @@ describe('agent-facing managed app update check', () => {expect(await service.checkAppUpdateForAgent()).toMatchObject({ status: 'no_installable_update' });expect(spawnProcess).not.toHaveBeenCalled();});++ it('does not advertise an invalid or asset-free manifest as an installable update', async () => {+ const service = await freshUpdateService('darwin');+ fetchManifest.mockResolvedValueOnce(updateManifest('not-semver'));+ expect(await service.checkAppUpdateForAgent()).toMatchObject({ status: 'manifest_failed' });+ fetchManifest.mockResolvedValueOnce({ app: { version: '0.0.65' } });+ expect(await service.checkAppUpdateForAgent()).toMatchObject({ status: 'no_installable_update' });+ expect(download).not.toHaveBeenCalled();+ service.stopUpdateService();+ });});describe('binary version checks after an applied update', () => {diff --git a/apps/desktop/src/main/maker-host/host-system-prompt.md b/apps/desktop/src/main/maker-host/host-system-prompt.mdindex e350573753..cc3337dc73 100644--- a/apps/desktop/src/main/maker-host/host-system-prompt.md+++ b/apps/desktop/src/main/maker-host/host-system-prompt.md@@ -1,4 +1,4 @@You are Cindy, an open-source AI assistant.Source: https://github.com/makecindy/cindy-When asked to update the Cindy application hosting this task, use cindy_helper check_app_update to check the current update channel. If an installable update is ready, direct the user to Cindy's built-in Check for Updates action for manual installation; do not install or restart the application yourself. Never replace the running Cindy application through shell commands or create a persistent restart job (including launchctl submit). If a release exists but the current update channel has no installable update, say so; do not sideload it. If the managed tool is unavailable, direct the user to the same built-in action; do not improvise an installer.+When asked to update the Cindy application hosting this task, use cindy_helper check_app_update to read the current update channel's version information. If an installable update is available, direct the user to Cindy's built-in Check for Updates action to download and install it; do not download, install or restart the application yourself. Never replace the running Cindy application through shell commands or create a persistent restart job (including launchctl submit). If a release exists but the current update channel has no installable update, say so; do not sideload it. If the managed tool is unavailable, direct the user to the same built-in action; do not improvise an installer.diff --git a/apps/desktop/src/main/updateService.ts b/apps/desktop/src/main/updateService.tsindex 042333a334..ffa0c3310d 100644--- a/apps/desktop/src/main/updateService.ts+++ b/apps/desktop/src/main/updateService.ts@@ -2114,15 +2114,22 @@ export async function checkAppUpdateForAgent(): Promise<{if (currentStatus === 'downloading' || currentStatus === 'superseding') {return { status: 'downloading', currentVersion, targetVersion: readyVersion };}- const result = await checkForUpdate();- if (currentStatus === 'ready' && readyVersion) {- return { status: 'ready', currentVersion, targetVersion: readyVersion };+ // An Agent check must not stage a patch: checkForUpdate() downloads it and+ // enables the existing auto-relaunch-on-idle path. Read only the manifest;+ // the user can download and install through the built-in update action.+ const manifest = await fetchManifest();+ if (!manifest) return { status: 'manifest_failed', currentVersion, reason: '无法读取当前渠道的更新信息。' };+ const relation = compareAppUpdateVersions(manifest.app?.version, currentVersion);+ if (relation === 'invalid') return {+ status: 'manifest_failed', currentVersion, reason: '当前渠道的更新版本信息无效。',+ };+ if (relation === 'newer' && resolveUpdateAsset(manifest)) {+ return { status: 'available', currentVersion, targetVersion: manifest.app.version };}- if (result === 'idle') return {+ return {status: 'no_installable_update', currentVersion,reason: '当前渠道没有适用于这台设备的可安装更新;也可能已是最新版本。',};- return { status: result, currentVersion, reason: `应用内更新检查结果:${result}` };}export function initUpdateService(): void {diff --git a/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts b/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.tsindex b8f7860800..06c1aa3626 100644--- a/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts+++ b/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts@@ -24,7 +24,7 @@ describe("cindy_helper MCP server", () => {sessionInstanceId: 'instance-1', remoteHostId: undefined as string | undefined,};let current = true;- const check = vi.fn(async () => ({ status: 'ready', currentVersion: '0.1.86', targetVersion: '0.1.90' }));+ const check = vi.fn(async () => ({ status: 'available', currentVersion: '0.1.86', targetVersion: '0.1.90' }));const server = createXdtHelperMcpServer({resolveSurface: async () => 'default',appUpdate: {@@ -45,7 +45,7 @@ describe("cindy_helper MCP server", () => {expect((tools.tools as Array<{ name: string }>).map((tool) => tool.name)).toEqual(['check_app_update',]);- expect(await call('check_app_update')).toMatchObject({ status: 'ready', targetVersion: '0.1.90' });+ expect(await call('check_app_update')).toMatchObject({ status: 'available', targetVersion: '0.1.90' });expect(await call('install_app_update')).toMatchObject({ ok: false, errorCode: 'UNKNOWN_TOOL' });expect(check).toHaveBeenCalledOnce();current = false;diff --git a/packages/lizi-mcps/src/xdt-helper/app_update.ts b/packages/lizi-mcps/src/xdt-helper/app_update.tsindex e285d12b99..0b350d60ae 100644--- a/packages/lizi-mcps/src/xdt-helper/app_update.ts+++ b/packages/lizi-mcps/src/xdt-helper/app_update.ts@@ -27,7 +27,7 @@ export function registerAppUpdateTools(registry.register({name: 'check_app_update',category: 'app_update',- description: `检查当前运行的 ${BRAND_NAME} 是否有可通过应用内更新器安装的新版本。本工具不能安装或重启应用;如需手动安装,请用户使用内置「检查更新」界面。不要用 GitHub Release 文件替换正在运行的应用。`,+ description: `仅读取当前渠道更新版本信息,检查当前运行的 ${BRAND_NAME} 是否有可通过应用内更新器安装的新版本。本工具不会下载、安装或重启应用;如需安装,请用户使用内置「检查更新」界面。不要用 GitHub Release 文件替换正在运行的应用。`,inputShape: {},handler: async () => {const error = callerError();