Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(browser): no capability limits of our own in My browser; uploads go through review
Dash4b2b2d452f58
diff --git a/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-browser-extension.md b/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-browser-extension.mdindex a0f7c36180..c04ccb9368 100644--- a/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-browser-extension.md+++ b/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-browser-extension.md@@ -1,7 +1,7 @@## 4.23 随包浏览器扩展(browserExtension 能力)插件随包携带一个 Chrome / Edge 扩展(翻译、字幕、页面读取之类"住在用户浏览器里"的功能)时,-由 **Cindy 承接扩展的连接**:配对、身份绑定、作业分发、结果脱敏都在宿主,插件+由 **Cindy 承接扩展的连接**:配对、身份绑定、作业分发、结果按预算截断都在宿主,插件不再自带接线进程。在身份卡声明:```jsondiff --git a/apps/desktop/src/main/browser-extension/__tests__/bridge.test.ts b/apps/desktop/src/main/browser-extension/__tests__/bridge.test.tsindex dd9185f203..b3fa7b44e2 100644--- a/apps/desktop/src/main/browser-extension/__tests__/bridge.test.ts+++ b/apps/desktop/src/main/browser-extension/__tests__/bridge.test.ts@@ -188,8 +188,9 @@ describe('policy · 地址校验与 URL 脱敏', () => {).not.toThrow();});- it('提取属性是封闭集合;载荷校验保留空文本与空选项', () => {- for (const attr of ['href', 'src', 'datetime', 'title', 'alt', 'aria-label', 'role']) {+ // 2026-10-30: any attribute can be extracted, as in Cindy's own browser; only the name is checked.+ it('提取任意属性名;载荷校验保留空文本与空选项', () => {+ for (const attr of ['href', 'role', 'data-csrf-token', 'value', 'xlink:href']) {expect(() =>validateBrowserExtensionJob('extract', {url: 'https://example.test',@@ -197,7 +198,7 @@ describe('policy · 地址校验与 URL 脱敏', () => {}),).not.toThrow();}- for (const attr of ['data-csrf-token', 'nonce', 'value', 'outerHTML', 'onclick', 'HREF']) {+ for (const attr of ['', 'a b', '1x', '<x>']) {expect(() =>validateBrowserExtensionJob('extract', {url: 'https://example.test',@@ -446,8 +447,8 @@ describe('bridge · 作业生命周期', () => {});// 2026-10-30: site lists are gone. A plugin of the site-list era still pushes one; it is acknowledged- // and blocks nothing, while tab URLs keep their credential redaction.- it('旧插件推送的站点名单不再生效;标签页地址仍做凭证脱敏', async () => {+ // and blocks nothing. Addresses come back whole, as in Cindy's own browser.+ it('旧插件推送的站点名单不再生效;标签页地址原样返回', async () => {const { bridge, ready } = await fixture();const c = await ready();expect(@@ -468,7 +469,7 @@ describe('bridge · 作业生命周期', () => {});const tabs = (await p).tabs as Array<Record<string, unknown>>;expect(tabs[0].title).toBe('mail');- expect(tabs[0].url).not.toContain('11111111');+ expect(tabs[0].url).toContain('11111111');expect(tabs[1]).toEqual({ id: 2, redacted: true });const clicked = bridge.act('click', { url: 'https://example.test', selector: 'button' });await sleep(5);@@ -479,42 +480,12 @@ describe('bridge · 作业生命周期', () => {expect((await clicked).ok).toBe(true);});- // Review 2026-10-29 (Codex P1): network-result entries were forwarded to the model with their URLs- // untouched, including OAuth codes and embedded credentials.- it('网络请求结果里的地址也由宿主脱敏', async () => {- const { bridge, ready } = await fixture();- const c = await ready();- const p = bridge.act('requests', { url: 'https://example.test', tabId: 1 });- await sleep(5);- const { job } = await c.request('/poll');- await c.request('/ack', { id: job.id });- await c.request('/result', {- id: job.id,- result: {- ok: true,- requests: [- { url: 'https://example.test/cb?code=11111111-1111-4111-8111-111111111111', status: 200 },- { url: 'https://user:[email protected]/path', status: 200 },- { url: 'https://example.test/' + 'a'.repeat(9000), status: 200 },- ],- },- });- const result = await p;- const requests = result.requests as Array<{ url: string | null; status: number }>;- expect(requests[0].url).not.toContain('11111111');- expect(requests[1].url).not.toContain('secret');- expect(requests[2].url).toBeNull();- expect(requests.map((r) => r.status)).toEqual([200, 200, 200]);- });-- it('提取结果的最终预算覆盖脱敏后的增长;__proto__ 字段按自有属性保留', async () => {+ it('提取结果按最终预算截断,链接要么完整要么省略;__proto__ 字段按自有属性保留', async () => {const { bridge, ready } = await fixture({ jobTimeout: 3000 });const c = await ready();- const url =- 'https://example.test/?' + Array.from({ length: 15 }, (_, i) => 'token' + i + '=x').join('&');+ const url = 'https://example.test/?q=' + 'x'.repeat(280);const record = Object.fromEntries(Array.from({ length: 30 }, (_, i) => ['field' + i, url]));- expect(url.length * 30).toBeLessThan(6000);- expect(redactBrowserUrl(url).length * 30).toBeGreaterThan(6000);+ expect(url.length * 30).toBeGreaterThan(6000);const promise = bridge.act('extract', {url: 'https://example.test',fields: { link: 'a' },@@ -539,7 +510,7 @@ describe('bridge · 作业生命周期', () => {);expect(values.reduce((n, v) => n + (v?.length || 0), 0)).toBeLessThanOrEqual(6000);expect(result.truncated).toBe(true);- expect(values.every((v) => v === null || v === redactBrowserUrl(url))).toBe(true);+ expect(values.every((v) => v === null || v === url)).toBe(true);const single = bridge.act('extract', {url: 'https://example.test',fields: { text: 'p' },diff --git a/apps/desktop/src/main/browser-extension/bridge.ts b/apps/desktop/src/main/browser-extension/bridge.tsindex f2d67ece34..916f51f1df 100644--- a/apps/desktop/src/main/browser-extension/bridge.ts+++ b/apps/desktop/src/main/browser-extension/bridge.ts@@ -19,7 +19,8 @@* - 作业一次送达绝不重投;已确认未完成的作业只能是 unknown,不能按成功或未执行报告;* - 不设站点名单(2026-10-30 决定):安全交给任务的权限档位与自动审核;旧扩展与旧插件仍收发* 的 policy 字段只作兼容,恒为「全部允许」;- * - 每个 URL 交给模型前都经 redactBrowserUrl;读取结果标 untrusted_content。+ * - Agent 读到的地址与链接原样返回(2026-10-30);转交给插件的翻译请求来源地址仍经 redactBrowserUrl;+ * 读取结果标 untrusted_content。*/import http from 'node:http';@@ -358,55 +359,18 @@ export class BrowserExtensionBridge {// ── 结果脱敏 ────────────────────────────────────────────────────────────- private redactFields(record: Record<string, unknown>): {- record: Record<string, unknown>;- dropped: boolean;- } {- let out: Record<string, unknown> | null = null;- let dropped = false;- for (const [key, value] of Object.entries(record)) {- if (!isHttp(value)) continue;- let clean: string | null = redactBrowserUrl(value);- if (clean.length > FIELD_VALUE_MAX) {- clean = null;- dropped = true;- }- if (clean === value) continue;- out = out || { ...record };- out[key] = clean;- }- return { record: out || record, dropped };- }-- /** 交给模型前的最后一道门:页面 URL、标签页、链接与提取字段里的凭证全部抹掉,并按预算截断。 */- private redactResult(result: Record<string, unknown>, maxChars = 6000): Record<string, unknown> {+ /**+ * 交给模型前按预算截断。链接与地址原样返回(2026-10-30 决定:与专用浏览器一致,Agent 能用页面里的+ * 魔法链接、签名地址;安全交给任务的权限档位与自动审核)。+ */+ private boundResult(result: Record<string, unknown>, maxChars = 6000): Record<string, unknown> {const out: Record<string, unknown> = { ...result };- if (typeof out.url === 'string') out.url = redactBrowserUrl(out.url);- if (Array.isArray(out.tabs)) {- out.tabs = out.tabs.map((t: { redacted?: boolean; url?: unknown }) =>- t && !t.redacted && typeof t.url === 'string' ? { ...t, url: redactBrowserUrl(t.url) } : t,- );- }- if (Array.isArray(out.links)) {- out.links = out.links.map((l: { url?: unknown }) =>- l && typeof l.url === 'string' ? { ...l, url: redactBrowserUrl(l.url) } : l,- );- }- if (Array.isArray(out.requests)) {- // Network results carry page URLs too (OAuth codes, reset tokens, embedded credentials).- out.requests = out.requests.map((r: { url?: unknown }) =>- r && typeof r === 'object' && typeof r.url === 'string'- ? { ...r, url: r.url.length > 8192 ? null : redactBrowserUrl(r.url) }- : r,- );- }let remaining = maxChars;const boundRecord = (entry: unknown): unknown => {if (!entry || typeof entry !== 'object') return entry;- const r = this.redactFields(entry as Record<string, unknown>);- let truncated = r.dropped;+ let truncated = false;const bounded: Record<string, unknown> = {};- for (const [key, value] of Object.entries(r.record)) {+ for (const [key, value] of Object.entries(entry as Record<string, unknown>)) {let finalValue: unknown = value;if (typeof value === 'string') {const limit = Math.min(remaining, FIELD_VALUE_MAX);@@ -439,7 +403,7 @@ export class BrowserExtensionBridge {if (!this.jobs.has(job.id)) return;clearTimeout(job.timer);this.jobs.delete(job.id);- const safe = this.redactResult(result, job.payload.maxChars || 6000);+ const safe = this.boundResult(result, job.payload.maxChars || 6000);const timing = (safe.timing && typeof safe.timing === 'object' ? safe.timing : {}) as Record<string,unknowndiff --git a/apps/desktop/src/main/browser-extension/policy.ts b/apps/desktop/src/main/browser-extension/policy.tsindex db07e0afc9..d196ef2b94 100644--- a/apps/desktop/src/main/browser-extension/policy.ts+++ b/apps/desktop/src/main/browser-extension/policy.ts@@ -45,15 +45,8 @@ export const BROWSER_EXTENSION_INTERACT_ACTIONS = [] as const;/** Actions that address no page: listing tabs, and checking or granting the on-demand debugger. */const UNADDRESSED_ACTIONS: readonly unknown[] = ['tabs', 'debuggerAccess', 'unmark'];-export const BROWSER_EXTENSION_EXTRACT_ATTRIBUTES = [- 'href',- 'src',- 'datetime',- 'title',- 'alt',- 'aria-label',- 'role',-] as const;+/** Any attribute may be extracted, as in Cindy's own browser (2026-10-30); only the name is checked. */+const EXTRACT_ATTRIBUTE_NAME = /^[A-Za-z_:][-A-Za-z0-9_:.]{0,99}$/;export type BrowserExtensionReadAction = (typeof BROWSER_EXTENSION_READ_ACTIONS)[number];export type BrowserExtensionInteractAction = (typeof BROWSER_EXTENSION_INTERACT_ACTIONS)[number];@@ -362,11 +355,9 @@ export function validateBrowserExtensionJob(!spec.selector ||spec.selector.length > 2000 ||(spec.attr != null &&- !(BROWSER_EXTENSION_EXTRACT_ATTRIBUTES as readonly string[]).includes(spec.attr));+ (typeof spec.attr !== 'string' || !EXTRACT_ATTRIBUTE_NAME.test(spec.attr)));if (invalid) {- throw new Error(- 'Each field needs a CSS selector; attr may only be href, src, datetime, title, alt, aria-label or role.',- );+ throw new Error('Each field needs a CSS selector; attr must be an attribute name.');}}if (payload.after != null && !payload.multiple)diff --git a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.tsindex 7ab30454c9..019be04053 100644--- a/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/mcpToolApprovalPolicy.test.ts@@ -132,6 +132,10 @@ describe('desktop MCP approval policy', () => {}expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_browser', toolName: 'browser', toolParams: toUser })).toBe('prompt-each-time');+ // Each upload hands a local file to a website, so it is reviewed too (2026-10-30).+ expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_browser', toolName: 'call_tool',+ toolParams: { name: 'browser', args: { action: 'upload', paths: ['/tmp/a.pdf'] } },+ })).toBe('prompt-each-time');for (const backend of ['external', 'rsb-webview']) {expect(getDesktopMcpToolApprovalPolicy({ serverName: 'cindy_browser', toolName: 'call_tool',toolParams: { name: 'browser', args: { action: 'setBackend', backend } },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 194a2f1cd0..db5e2111e2 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@@ -225,6 +225,9 @@ export function getDesktopMcpToolApprovalPolicy(// choosing My browser in Settings needs no tool call and so no approval.if (name === 'browser' && args?.action === 'setBackend' && args.backend === 'user-browser')return 'prompt-each-time';+ // Uploading hands a local file to a website. Files are not filtered by name (2026-10-30), so each+ // upload goes through the task's approval: Ask confirms, Auto reviews, Full Access proceeds.+ if (name === 'browser' && args?.action === 'upload') return 'prompt-each-time';}if (serverName === 'cindy' && toolName === 'ghost_market_install') return 'prompt-each-time';// This bridge multiplexes independent imported connections and commands withdiff --git a/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/rsb-webview-upload-policy.test.ts b/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/rsb-webview-upload-policy.test.tsindex 8ec562681a..dbc621d3b8 100644--- a/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/rsb-webview-upload-policy.test.ts+++ b/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/rsb-webview-upload-policy.test.ts@@ -112,7 +112,8 @@ describe('resolveUploadFiles', () => {]);});- it('rejects files outside the session roots and sensitive names', async () => {+ // 2026-10-30: names inside the roots are not filtered; each upload goes through the task's approval.+ it('rejects files outside the session roots; names inside them are not filtered', async () => {const outside = path.join(outsideRoot, 'outside.txt');const secret = path.join(allowedRoot, '.env.local');await fs.writeFile(outside, 'outside');@@ -121,9 +122,7 @@ describe('resolveUploadFiles', () => {await expect(resolveUploadFiles([outside], [allowedRoot])).rejects.toThrow('inside the current session directory',);- await expect(resolveUploadFiles([secret], [allowedRoot])).rejects.toThrow(- 'blocked for sensitive file',- );+ await expect(resolveUploadFiles([secret], [allowedRoot])).resolves.toEqual([realpathSync(secret)]);});it('resolves links before checking containment', async () => {diff --git a/apps/desktop/src/main/mcp-integrations/browser-backend/rsb-webview-upload-policy.ts b/apps/desktop/src/main/mcp-integrations/browser-backend/rsb-webview-upload-policy.tsindex bf496b6dcb..677556ac54 100644--- a/apps/desktop/src/main/mcp-integrations/browser-backend/rsb-webview-upload-policy.ts+++ b/apps/desktop/src/main/mcp-integrations/browser-backend/rsb-webview-upload-policy.ts@@ -5,17 +5,6 @@ const MAX_FILE_COUNT = 20;const MAX_FILE_BYTES = 100 * 1024 * 1024;const MAX_TOTAL_BYTES = 500 * 1024 * 1024;-const BLOCKED_FILE_NAMES = new Set([- '.env',- '.npmrc',- '.netrc',- '.pypirc',- 'id_dsa',- 'id_ecdsa',- 'id_ed25519',- 'id_rsa',-]);-function isInside(parent: string, child: string): boolean {const fold = (value: string) =>process.platform === 'win32' ? value.toLowerCase() : value;@@ -23,21 +12,12 @@ function isInside(parent: string, child: string): boolean {return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));}-function isBlockedFile(filePath: string): boolean {- const name = path.basename(filePath).toLowerCase();- const sensitiveDirectory = filePath- .split(/[\\/]+/)- .some((segment) => ['.git', '.ssh'].includes(segment.toLowerCase()));- return BLOCKED_FILE_NAMES.has(name)- || name.startsWith('.env.')- || name.endsWith('.key')- || sensitiveDirectory;-}-/*** Resolves upload candidates to their filesystem identity and confines every* file to a host-provided root. Realpath checks prevent a workdir symlink or- * junction from granting access to a file outside that workdir.+ * junction from granting access to a file outside that workdir. Files inside+ * the roots are not filtered by name (2026-10-30: no capability limits of our+ * own); every browser upload goes through the task's approval instead.*/export async function resolveUploadFiles(candidates: unknown,@@ -139,9 +119,6 @@ export function resolveUploadFilesSync(candidates: unknown, allowedRoots: stringif (!roots.some((root) => isInside(root, resolved))) {throw new Error('upload files must stay inside the current session directory');}- if (isBlockedFile(resolved)) {- throw new Error(`upload blocked for sensitive file: ${path.basename(resolved)}`);- }if (stat.size > MAX_FILE_BYTES) {throw new Error(`upload file exceeds ${MAX_FILE_BYTES} bytes: ${path.basename(resolved)}`);}diff --git a/apps/desktop/src/main/mcp-integrations/browser-backend/user-browser-backend.ts b/apps/desktop/src/main/mcp-integrations/browser-backend/user-browser-backend.tsindex 0f6afc8afa..8530e6bc08 100644--- a/apps/desktop/src/main/mcp-integrations/browser-backend/user-browser-backend.ts+++ b/apps/desktop/src/main/mcp-integrations/browser-backend/user-browser-backend.ts@@ -103,6 +103,8 @@ export function extensionSupportsParity(version: string | null | undefined): boo/** Extensions from this version upload by path through Chrome's debugger, without the ~30 MB transfer bound. */export const USER_BROWSER_PATH_UPLOAD_VERSION = '0.4.56';+/** Extensions from this version read and fill password, payment and one-time-code fields like any field. */+export const USER_BROWSER_SENSITIVE_FIELDS_VERSION = '0.4.57';function extensionAtLeast(version: string | null | undefined, wanted: string): boolean {const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version ?? '');@@ -1436,16 +1438,37 @@ export class UserBrowserBackend implements BrowserBackend {});if (job.error !== 'EVAL_BLOCKED_BY_PAGE') return this.failureResult(req.action, job);}+ if (+ domRead.kind === 'login-wall' &&+ extensionAtLeast(+ this.connectedClients(control).find((c) => c.id === record.clientId)?.version,+ USER_BROWSER_SENSITIVE_FIELDS_VERSION,+ )+ ) {+ // The page forbids scripts: probe the same two fields with the extension's declarative extract+ // (password and one-time-code fields are readable like any field from this version on).+ const probe = await this.pageJob(control, record, 'extract', {+ fields: {+ password: { selector: 'input[type=password]', attr: 'type' },+ code: { selector: 'input[autocomplete="one-time-code"]', attr: 'autocomplete' },+ },+ });+ if (!probe.ok) return this.failureResult(req.action, probe);+ const found = (probe.record ?? {}) as { password?: unknown; code?: unknown };+ return actionOk(req.action, {+ backend: this.kind,+ targetId: record.targetId,+ result: { password: found.password != null, code: found.code != null },+ });+ }if (domRead.kind === 'login-wall') {- // The extension refuses to read password / one-time-code fields at all (they are sensitive- // fields), so a declarative probe cannot tell "absent" from "present but withheld". Report- // the check as unavailable instead of a false negative; the snapshot text still shows the- // sign-in page to the agent, and the user's own browser normally carries their sign-ins.+ // Older extensions refuse to read password / one-time-code fields, so a declarative probe cannot+ // tell "absent" from "present but withheld". Report the check as unavailable, not a false negative.return actionOk(req.action, {backend: this.kind,targetId: record.targetId,result: { password: false, code: false, unavailable: true },- note: '用户浏览器执行端不读取密码/验证码字段,无法做登录墙检测;以快照内容判断是否需要登录。',+ note: '这个版本的扩展不读取密码/验证码字段,无法做登录墙检测;以快照内容判断是否需要登录。',});}if (domRead.kind !== 'extract' || !domRead.extract)