Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(agent-island): 校验完成动作来源并统一归档用语
Dash29b35aab6269
diff --git a/apps/desktop/src/main/agent-island/__tests__/service.test.ts b/apps/desktop/src/main/agent-island/__tests__/service.test.tsindex 23592dc075..b31dfb4401 100644--- a/apps/desktop/src/main/agent-island/__tests__/service.test.ts+++ b/apps/desktop/src/main/agent-island/__tests__/service.test.ts@@ -32,6 +32,7 @@ import { markAppContentWindow } from '../../windowFocusClassifier.js';import type { AgentIslandService } from '../service.js';import type { AgentIslandCompanionIdentity } from '../companionIdentity.js';import { setDeepLinkMainWindow, takePendingDeepLink } from '../../deepLink.js';+import { runDeviceLinkInvokeContext } from '../../device-link/invoke-context.js';const REMOTE_DAEMON_CLOSED_REASON = 'remote_daemon_closed';@@ -694,6 +695,36 @@ describe('AgentIslandService native publishing', () => {service.resetRuntimeState();});+ // IPC security §5: a valid completion token cannot authorize a foreign frame.+ // The same owner mutation remains available through authenticated device-link.+ it.each(['mark-read', 'archive'] as const)('rejects an untrusted %s sender before side effects and accepts its tunneled equivalent', async action => {+ const { AgentIslandService } = await import('../service.js');+ const service = new AgentIslandService({ getMainWindow: () => null });+ service.setEnabled(false);+ service.registerDeviceSessionIpc();+ const meta = { sessionId: 'sender-guard', agentKind: 'codex' as const };+ service.handleUserPrompt(meta, 'run');+ service.handleAgentEvent(meta, doneEvent());+ const token = (service.getSessionActivitySnapshot(meta.sessionId) as AgentIslandSessionActivity).completionToken!;+ const handler = registeredIpcHandler('agent-island:completion-action');+ const event = { senderFrame: null };+ mocks.assertTrustedAppRendererEvent.mockImplementation(() => { throw new Error('[FORBIDDEN] Untrusted renderer'); });+ try {+ expect(() => handler(event, meta.sessionId, action, token)).toThrow('[FORBIDDEN]');+ expect(mocks.assertTrustedAppRendererEvent).toHaveBeenCalledWith(event);+ expect(mocks.patchSessionMetaInDb).not.toHaveBeenCalled();+ expect(service.getSessionActivitySnapshot(meta.sessionId)).toMatchObject({ attention: true });+ mocks.assertTrustedAppRendererEvent.mockClear();+ expect(await runDeviceLinkInvokeContext({ controllerDeviceId: 'paired', channel: 'agent-island:completion-action' },+ () => handler(null, meta.sessionId, action, token))).toBe(true);+ expect(mocks.assertTrustedAppRendererEvent).not.toHaveBeenCalled();+ expect(mocks.patchSessionMetaInDb).toHaveBeenCalledTimes(action === 'archive' ? 1 : 0);+ expect(service.getSessionActivitySnapshot(meta.sessionId)?.attention ?? false).toBe(false);+ } finally {+ service.resetRuntimeState();+ }+ });+// Owner handler + existing send lock: stale network/queue deliveries must not// archive or acknowledge the next completion, even in the same millisecond.it.each(['mark-read', 'archive'] as const)('rejects an old %s on the owning device after its route wait', async action => {@@ -710,7 +741,8 @@ describe('AgentIslandService native publishing', () => {const blocked = new Promise<void>(resolve => { release = resolve; });setSessionRouteLockImplementation(async (_id, task) => { await blocked; return task(); });try {- const actionPromise = registeredIpcHandler('agent-island:completion-action')(null, meta.sessionId, action, token);+ const actionPromise = runDeviceLinkInvokeContext({ controllerDeviceId: 'paired', channel: 'agent-island:completion-action' },+ () => registeredIpcHandler('agent-island:completion-action')(null, meta.sessionId, action, token));complete();release();expect(await actionPromise).toBe(false);diff --git a/apps/desktop/src/main/agent-island/service.ts b/apps/desktop/src/main/agent-island/service.tsindex 2df4e2101a..092940b447 100644--- a/apps/desktop/src/main/agent-island/service.ts+++ b/apps/desktop/src/main/agent-island/service.ts@@ -151,6 +151,7 @@ import {} from './layoutPreferenceStore.js';import { throwIpcError } from '../utils/ipcValidate.js';import { assertTrustedAppRendererEvent } from '../security/trustedAppRenderer.js';+import { isDeviceLinkInvoke } from '../device-link/invoke-context.js';import { tapWindowBroadcast } from '../device-link/broadcast-tap.js';import {beginProtectedFolderCheck,@@ -548,7 +549,8 @@ export class AgentIslandService {/** 各平台都注册(含无原生岛的 headless):灵动岛关闭时远程任务靠它发桌面通知。 */registerDeviceSessionIpc(): void {- ipcMain.handle('agent-island:completion-action', (_event, sessionId: unknown, action: unknown, token: unknown) => {+ ipcMain.handle('agent-island:completion-action', (event, sessionId: unknown, action: unknown, token: unknown) => {+ if (!isDeviceLinkInvoke()) assertTrustedAppRendererEvent(event);if (typeof sessionId !== 'string' || !sessionId || (action !== 'archive' && action !== 'mark-read')|| typeof token !== 'string' || !token || token.length > 128) {throwIpcError('INVALID_PARAMS', 'Invalid completion action');diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 1892a60cba..653f3fe53a 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -1074,7 +1074,7 @@"agentIsland": {"native": {"markRead": "标为已读",- "archive": "存档",+ "archive": "归档","actionFailed": "操作未完成,提醒已保留,请重试。","newConversationTitle": "新建任务","newConversationHint": "开始一个新的任务",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex daf32744a4..b90656e001 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -1074,7 +1074,7 @@"agentIsland": {"native": {"markRead": "標為已讀",- "archive": "封存",+ "archive": "歸檔","actionFailed": "操作未完成,提醒已保留,請重試。","newConversationTitle": "新建任務","newConversationHint": "開始一個新的任務",diff --git a/i18n/GLOSSARY.md b/i18n/GLOSSARY.mdindex db3b7b523d..9c26cd8f62 100644--- a/i18n/GLOSSARY.md+++ b/i18n/GLOSSARY.md@@ -171,6 +171,10 @@ Anthropic Messages API / wire protocol 的用户可见名称。四语统一保用户为自有 API、OAuth 或订阅通道维护的本地 token 单价估算;只影响 Cindy 的用量价值估算,不代表供应商实际账单,也不覆盖 Cindy AI Gateway 的服务端实售价。先登记为 proposed,待产品术语评审后固化。+### Archive++任务归档动作。灵动岛完成卡按钮沿用既有任务归档确认框的译法,避免同一操作链路混用存档/归档或封存/歸檔;不在此条目裁决或批量修改其它语境。+### Global region企业认证与业务服务所在区域的用户可见名称,用于组织登录检测到 Global 服务区域时的确认文案;它描述连接的服务区域,不是对当前安装版本的标签,也不同于项目配置里的 generic global scope。先按现有四语文案登记为 proposed。diff --git a/i18n/glossary.json b/i18n/glossary.jsonindex d36cae6a8f..2df10870fa 100644--- a/i18n/glossary.json+++ b/i18n/glossary.json@@ -5,6 +5,7 @@"sourceLocale": "en","punctuationExempt": ["desktop:settings.help.qnaFeedbackBodyTemplate"],"terms": [+ {"id": "archive-task", "status": "proposed", "en": "Archive", "translations": {"zh-CN": "归档", "zh-TW": "歸檔", "ja": "アーカイブ", "ko": "보관"}, "checkCase": false, "note": "任务归档动作。灵动岛完成卡按钮沿用既有任务归档确认框的译法,避免同一操作链路混用存档/归档或封存/歸檔;不在此条目裁决或批量修改其它语境。"},{"id": "speech-speed", "status": "proposed", "en": "Speech speed", "translations": {"zh-CN": "语速", "zh-TW": "語速", "ja": "読み上げ速度", "ko": "읽기 속도"}, "checkCase": false, "note": "伙伴语音设置的合成语速;按伙伴保存,通话朗读、消息朗读和试听共用。区别于播放器倍速和语音输入停顿时间。"},{"id": "read-by-sentence", "status": "proposed", "en": "Read by sentence", "translations": {"zh-CN": "按句朗读", "zh-TW": "逐句朗讀", "ja": "文ごとに読み上げ", "ko": "문장별로 읽기"}, "checkCase": false, "note": "伙伴语音设置:默认在最终答复生成过程中按完整句子提前朗读;关闭后等待完整回复。需要回复后处理或无法识别最终答复阶段时延后。"},{"id": "voice-mode", "status": "proposed", "en": "Voice Mode", "translations": {"zh-CN": "语音模式", "zh-TW": "語音模式", "ja": "音声モード", "ko": "음성 모드"}, "checkCase": false, "note": "桌面伙伴一对一的连续语音交互方式;停顿发送、最终回复朗读和插话,沿用伙伴主任务。"},