Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(browser): 复用会话审批并补齐文本输入兼容
Dash7d7e6a499cba
diff --git a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.tsindex 957abcb252..0b57ae36c8 100644--- a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts@@ -89,6 +89,38 @@ describe('desktop Claude read-only allowlist', () => {});describe('desktop MCP approval policy', () => {+ // #6826 security review 4354459321, unit: the shared policy must route each+ // recipe invocation through normal session approval, including read-labelled+ // recipes overridden by the user layer. Existing tests trusted the whole server.+ it('reviews recipe calls without trusting caller-supplied access or reusable grants', () => {+ for (const recipeId of ['opencli:weibo/delete', 'opencli:linkedin/safe-send', 'opencli:web/read', 'custom-recipe']) {+ const args = { action: 'recipe', recipeId, access: 'read', inputs: { send: true } };+ for (const toolName of ['call_tool', undefined]) {+ for (const encoded of [args, JSON.stringify(args)]) {+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_browser', toolName,+ toolParams: { name: 'browser', args: encoded },+ })).toBe('prompt-each-time');+ }+ }+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_browser', toolName: 'browser', toolParams: args }))+ .toBe('prompt-each-time');+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_browser', toolParams: args }))+ .toBe('prompt-each-time');+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_browser',+ toolParams: { ...args, name: 'browser', args: { action: 'snapshot' } },+ })).toBe('prompt-each-time');+ }+ for (const toolParams of [undefined, { name: 'browser' }, { name: 'browser', args: 'broken' }]) {+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_browser', toolName: 'call_tool', toolParams }))+ .toBe('prompt-each-time');+ }+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_browser', toolName: 'list_tools' })).toBe('auto-approve');+ for (const action of ['siteguide', 'snapshot', 'tabs']) {+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_browser', toolName: 'call_tool',+ toolParams: { name: 'browser', args: { action } },+ })).toBe('auto-approve');+ }+ });it('never lets import discovery grant reusable approval to start a migration', () => {for (const operation of ['sources', 'preview', 'status', 'start', undefined]) {for (const toolName of ['import_agent', undefined]) {@@ -177,7 +209,6 @@ describe('desktop MCP approval policy', () => {it('auto-approves only explicitly reviewed builtin servers', () => {for (const serverName of ['cindy_android',- 'cindy_browser','cindy_computer',// cindy_feishu_bot / cindy_telegram_bot 也在 trusted 表里, 但省略 toolName 时按次审批// (都带 call_api; 见下方专项用例)。diff --git a/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts b/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.tsindex 342800d808..86197c23a2 100644--- a/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts+++ b/apps/desktop/src/main/maker-host/mcp-tool-approval-policy.ts@@ -14,8 +14,9 @@* 1. READ_ONLY_MCP_TOOLS —— 精确到工具的只读发现入口,server 未整体可信也放行* 2. cindy_contacts —— 按内层 action 细粒度判定(见 contacts/approval.ts)* 3. cindy-art ghost_call —— 第一方作图/视频内层工具静默;其它插件继续走会话审批- * 4. TRUSTED_MCP_SERVERS —— 已 review 的第一方 server,整体静默- * 5. 其余 —— 进入会话审批(第三方 server、cindy_ssh、其它 ghost_call…)+ * 4. 敏感聚合调用(含 browser recipe)—— 每次进入现有会话审批+ * 5. TRUSTED_MCP_SERVERS —— 已 review 的第一方 server,其余调用静默+ * 6. 其余 —— 进入会话审批(第三方 server、cindy_ssh、其它 ghost_call…)* 风险分类不覆盖会话档位:Full Access 免操作审批,Auto 走统一审阅,Ask 才交用户确认。*/@@ -203,6 +204,23 @@ export function getDesktopMcpToolApprovalPolicy(if (toolName && READ_ONLY_MCP_TOOLS.has(`${serverName}::${toolName}`)) {return 'auto-approve';}+ // Recipes can write through an authenticated profile or be overridden by L2.+ // Route the exact invocation through the existing session flow, never trust+ // caller-supplied access metadata or reuse a server grant. Full Access/Auto/Ask+ // retain their existing semantics; discovery and ordinary browser actions stay trusted.+ if (serverName === 'cindy_browser') {+ const params = readJsonObject(toolParams);+ // Without an outer name, only an exact progressive envelope is unambiguous.+ // A direct browser call can itself carry name/args plus action=recipe.+ if (!toolName && (!params || Object.keys(params).some(key => key !== 'name' && key !== 'args'))) {+ return 'prompt-each-time';+ }+ const progressive = toolName === 'call_tool' || !toolName;+ const name = progressive ? (typeof params?.name === 'string' ? params.name.trim() : '') : toolName;+ const args = progressive ? readJsonObject(params?.args) : params;+ if ((name === 'browser' && args?.action === 'recipe')+ || (progressive && (!name || !args))) return 'prompt-each-time';+ }if (serverName === 'cindy' && toolName === 'ghost_market_install') return 'prompt-each-time';// This bridge multiplexes independent imported connections and commands with// their credentials. A server-wide grant for one tool must not authorize otherdiff --git a/docs/dev-rules/maker-core-and-agent-behavior.md b/docs/dev-rules/maker-core-and-agent-behavior.mdindex dbe0bdccbc..52c058ec7f 100644--- a/docs/dev-rules/maker-core-and-agent-behavior.md+++ b/docs/dev-rules/maker-core-and-agent-behavior.md@@ -505,6 +505,12 @@ Auto 优先效率,定位是防止严重后果,不是第二次任务规划或Claude MCP/额外目录等现有回退路径仍由 Cindy 审批,不因有订阅而免审。原生明确拒绝不触发第二次模型判断。独立 Host 操作继续使用自身审批入口。+Browser 的 `action=recipe` 调用复用现有逐次会话审批,不继承整个第一方 server 的静默放行;+Full Access、Auto、Ask 的含义保持不变。不以配方自报的 read/write 分类免审,用户覆盖层+也可能改变其实际动作。渐进参数(含 JSON 字符串)、直接工具调用及省略工具名共用+`maker-host/mcp-tool-approval-policy.ts`,发现和普通浏览器操作沿用原策略;+不新增配方确认 token 或独立授权状态。回归见 `mcpToolApprovalPolicy.test.ts`。+由 Cindy 负责的 Auto 审核先按固定顺序尝试 `cindy/auto-review`、内置 OpenAI 订阅的`gpt-5.4-nano`、`gpt-6-luna`。只有这些候选全部不可用、请求失败或输出无效时,才使用系统设置中用户明确自定义的辅助模型链,按已选顺序尝试最多 3 个模型;自动辅助链和diff --git a/packages/lizi-mcps/src/browser/opencli-page.ts b/packages/lizi-mcps/src/browser/opencli-page.tsindex 00f956d67c..eaa1b97141 100644--- a/packages/lizi-mcps/src/browser/opencli-page.ts+++ b/packages/lizi-mcps/src/browser/opencli-page.ts@@ -111,6 +111,11 @@ export class OpenCliPage extends CDPBasePage {return this.evaluate<T>(js);}+ /** Adapter compatibility name for the existing guarded CDP input path. */+ async insertText(text: string): Promise<void> {+ await this.nativeType(text);+ }+async cdp(method: string,params?: Record<string, unknown>,diff --git a/packages/lizi-mcps/src/browser/opencli-recipes.test.ts b/packages/lizi-mcps/src/browser/opencli-recipes.test.tsindex a068aede6c..393d121e85 100644--- a/packages/lizi-mcps/src/browser/opencli-recipes.test.ts+++ b/packages/lizi-mcps/src/browser/opencli-recipes.test.ts@@ -75,6 +75,50 @@ afterEach(() => {});describe("bundled OpenCLI recipes", () => {+ // #6826 / 4354393901, unit: real LinkedIn sender + real host page with+ // in-memory transport and fake clock. Previous tests never reached insertText.+ // Text insertion must reach CDP; a transport error must stop before Send.+ it.each(['ok', 'input-error', 'composer-mismatch'])('runs the verified sender through native text input (%s)', async mode => {+ vi.useFakeTimers();+ const calls: BrowserControlRequest[] = [];+ const thread = 'https://www.linkedin.com/messaging/thread/fixture/';+ const message = 'Fixture 中文 message';+ let inserted = '';+ let sent = false;+ const page = new OpenCliPage({ targetId: 'fixture', call: async request => {+ calls.push(request);+ const method = request.recipeCommand?.method;+ if (method === 'Cindy.begin') return { ok: true, action: request.action, data: { sessionId: 'fixture-session' } };+ if (method === 'Input.insertText') {+ if (mode === 'input-error') return { ok: false, action: request.action, message: 'fixture input failed' };+ inserted = String(request.recipeCommand?.params?.text);+ }+ const fn = request.request?.fn || '';+ const result = fn.includes('__OPENCLI_LINKEDIN_PROBE__')+ ? { url: thread, headerNames: ['Fixture Person'], bodyText: 'Last fixture message', composerFound: true,+ latestMessageText: 'Last fixture message' }+ : fn.includes('__OPENCLI_LINKEDIN_FOCUS_COMPOSER__') ? { ok: true }+ : fn.includes('__OPENCLI_LINKEDIN_READ_COMPOSER__') ? { ok: true, composerText: mode === 'composer-mismatch' ? 'Other text' : inserted }+ : fn.includes('__OPENCLI_LINKEDIN_CLICK_SEND__') ? (sent = true, { ok: true, sent: true }) : true;+ return { ok: true, action: request.action, data: { result } };+ } });+ try {+ const pending = executeAdapter('linkedin/safe-send', { 'thread-url': thread, 'expected-name': 'Fixture Person',+ 'expected-last-text': 'Last fixture message', message, send: true }, page);+ const checked = pending.then(value => ({ value, error: undefined }), error => ({ value: undefined, error }));+ await vi.runAllTimersAsync();+ const outcome = await checked;+ if (mode === 'ok') {+ expect(outcome.error).toBeUndefined();+ expect(outcome.value).toMatchObject([{ status: 'sent', recipient: 'Fixture Person' }]);+ } else {+ expect(outcome.error?.message).toContain(mode === 'input-error' ? 'fixture input failed' : 'composer_text_mismatch');+ }+ expect(calls.filter(call => call.recipeCommand?.method === 'Input.insertText')).toHaveLength(1);+ expect(sent).toBe(mode === 'ok');+ if (mode === 'ok') expect(inserted).toBe(message);+ } finally { await page.dispose(); }+ });// #6826 CodeQL URL family, unit: real adapter helpers must distinguish// a site's host from attacker-controlled prefixes, suffixes and query text.// Existing navigation tests used only legitimate origins.diff --git a/packages/opencli-vendor/README.md b/packages/opencli-vendor/README.mdindex 5a40ffcea2..85fb9bc4e5 100644--- a/packages/opencli-vendor/README.md+++ b/packages/opencli-vendor/README.md@@ -33,6 +33,12 @@原始摘要及实际落地摘要。不要直接修改 `src/` 或 `clis/` 而不登记补丁。- 浏览器操作使用 Cindy 当前任务、profile 和目标页;不启动 OpenCLI daemon/扩展。+- 宿主页的 `insertText` 兼容名委托已有 `nativeType`/CDP 输入路径,供 LinkedIn 等适配器+ 使用;输入失败直接传回,LinkedIn 继续在填写后核对正文和收件人,未通过时不点击发送。+- Desktop 的配方执行逐次进入已有会话权限流程,Full Access 免操作审批,Auto 走统一审核,+ Ask 由用户确认。发现和普通浏览器操作保留既有策略;read/write 分类不充当免审凭据,+ 因为用户覆盖层也可改变配方。渐进调用、JSON 字符串参数、直接调用和省略工具名共用+ 同一审批策略,不新增二阶段 token、授权存储或配方专用确认流程。- CDP 对象和节点沿用一次配方调用的连接;网络响应按上游格式捕获,读取只清空已完成响应,未完成请求保留至结束事件。100 条容量优先淘汰已完成条目;全为未完成请求时明确报告容量不足,不误报网络空闲。累计正文超过8 MB 时只移除正文并标记截断,不删除完成状态。网页读取传播捕获错误;重新开始捕获才清除此错误。结束时