Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(browser-extension): retry a failed native install on status; bound every read result; refuse combined waits on older extensions
Dash154240a9bb1a
diff --git a/apps/desktop/src/main/browser-extension/__tests__/bridge.test.ts b/apps/desktop/src/main/browser-extension/__tests__/bridge.test.tsindex 2c7f3234b6..28d158b770 100644--- a/apps/desktop/src/main/browser-extension/__tests__/bridge.test.ts+++ b/apps/desktop/src/main/browser-extension/__tests__/bridge.test.ts@@ -493,6 +493,30 @@ describe('bridge · 作业生命周期', () => {expect((await clicked).ok).toBe(true);});+ // Review 2026-10-30 (Codex P2): every read result is bounded, not only extract records.+ it('requests / links / text 等读取结果也有数量与大小上限', async () => {+ const { bridge, ready } = await fixture();+ const c = await ready();+ const pending = 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: Array.from({ length: 1500 }, (_, i) => ({ url: 'https://example.test/' + i, note: 'n'.repeat(20000) })),+ text: 't'.repeat(900_000),+ },+ });+ const result = await pending;+ const requests = result.requests as Array<{ url: string; note: string }>;+ expect(requests).toHaveLength(1000);+ expect(requests[0].note.length).toBe(8192);+ expect((result.text as string).length).toBe(400_000);+ expect(result.truncated).toBe(true);+ });+it('提取结果按最终预算截断,链接要么完整要么省略;__proto__ 字段按自有属性保留', async () => {const { bridge, ready } = await fixture({ jobTimeout: 3000 });const c = await ready();diff --git a/apps/desktop/src/main/browser-extension/bridge.ts b/apps/desktop/src/main/browser-extension/bridge.tsindex fcf873910c..b628c6dce4 100644--- a/apps/desktop/src/main/browser-extension/bridge.ts+++ b/apps/desktop/src/main/browser-extension/bridge.ts@@ -200,6 +200,15 @@ const failure = (const isHttp = (value: unknown): value is string =>typeof value === 'string' && /^https?:\/\//i.test(value);const FIELD_VALUE_MAX = 4000;+/** Per-result backstops for list-shaped reads (see boundResult). */+const LIST_ENTRY_CAPS: ReadonlyArray<readonly [string, number]> = [+ ['requests', 1000],+ ['messages', 1000],+ ['links', 1000],+ ['events', 5000],+];+const ENTRY_STRING_MAX = 8192;+const TEXT_RESULT_MAX = 400_000;export class BrowserExtensionBridge {/** Wire compatibility only: extensions and plugins of the site-list era still read it. */@@ -394,6 +403,33 @@ export class BrowserExtensionBridge {};if (Array.isArray(out.records)) out.records = out.records.map(boundRecord);if (out.record) out.record = boundRecord(out.record);+ // Backstop for every other read result: a result is accepted up to ~32 MB and 16 jobs can be in+ // flight, so an extension (or a corrupted one) must not make Main hold and forward all of it. Entry+ // counts and string sizes are capped; a cut is reported in `truncated`.+ for (const [key, max] of LIST_ENTRY_CAPS) {+ const list = out[key];+ if (!Array.isArray(list)) continue;+ const capped = list.length > max ? list.slice(0, max) : list;+ if (capped !== list) out.truncated = true;+ out[key] = capped.map((entry) => {+ if (!entry || typeof entry !== 'object') return entry;+ const row: Record<string, unknown> = { ...(entry as Record<string, unknown>) };+ for (const [field, value] of Object.entries(row)) {+ if (typeof value === 'string' && value.length > ENTRY_STRING_MAX) {+ row[field] = /^https?:\/\//i.test(value) ? null : value.slice(0, ENTRY_STRING_MAX);+ out.truncated = true;+ }+ }+ return row;+ });+ }+ for (const key of ['text', 'html', 'markdown'] as const) {+ const value = out[key];+ if (typeof value === 'string' && value.length > TEXT_RESULT_MAX) {+ out[key] = value.slice(0, TEXT_RESULT_MAX);+ out.truncated = true;+ }+ }return out;}diff --git a/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.tsindex 55c4c60d4f..7ecdd398b7 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.ts@@ -369,6 +369,34 @@ describe('browserExtensionSlot · 管子上行', () => {expect(again.sent.some(([, payload]) => (payload as { name?: string }).name === 'browser-extension-policy-request')).toBe(false);});+ // Review 2026-10-30 (Codex P2): a native install that failed for a passing reason is retried on status.+ it('原生连接程序安装失败后,status 请求按 30 秒节流重试', async () => {+ let now = 1_000_000;+ let installs = 0;+ let state: 'ready' | 'unavailable' = 'unavailable';+ const { slot, bridges, settle, ghosts } = await makeSlot({+ now: () => now,+ createNativeBinding: () => ({+ token: 'f'.repeat(64),+ install: vi.fn(async () => {+ installs++;+ if (installs >= 2) state = 'ready';+ return state === 'ready' ? { ok: true as const } : { ok: false as const, error: 'NATIVE_BINDING_UNAVAILABLE' as const, reason: 'EBUSY' };+ }),+ close: vi.fn(async () => undefined),+ status: () => state,+ }),+ });+ slot.reconcile(ghosts);+ await settle();+ expect(installs).toBe(1);+ await slot.handleRequest('_root__my-browser', { kind: 'status' });+ expect(installs).toBe(2);+ expect(bridges).toHaveLength(1);+ await slot.handleRequest('_root__my-browser', { kind: 'status' });+ expect(installs).toBe(2);+ });+// Review 2026-10-30 (Codex P2): a failed startup is rebuilt by the next request instead of staying failed.it('启动失败后下一次请求重建整套启动流程', async () => {const { slot, bridges, natives, settle, ghosts } = await makeSlot();diff --git a/apps/desktop/src/main/cindy-brain/browserExtensionSlot.ts b/apps/desktop/src/main/cindy-brain/browserExtensionSlot.tsindex 961a9267ea..c6acea96c2 100644--- a/apps/desktop/src/main/cindy-brain/browserExtensionSlot.ts+++ b/apps/desktop/src/main/cindy-brain/browserExtensionSlot.ts@@ -116,6 +116,8 @@ interface Entry {closing: boolean;/** Paired clients as last persisted. */saved: SavedBrowserExtensionState;+ /** Earliest time the native binding may be retried after a failed or pending install. */+ nativeRetryAt?: number;/** The startup sequence failed (for example every compatible port was busy); the next request rebuilds it. */startFailed?: true;/** Where the installed package came from; pairings never carry over to a package from elsewhere. */@@ -383,6 +385,19 @@ export class GhostBrowserExtensionSlot {try {switch (req.kind) {case 'status': {+ // A native install that failed for a passing reason (a busy file, a registry timeout) would+ // otherwise stay failed until the plugin is toggled; try again on a status request, at most+ // every 30 seconds.+ if (entry.native && entry.native.status() === 'unavailable') {+ const now = (this.deps.now ?? Date.now)();+ if (now >= (entry.nativeRetryAt ?? 0)) {+ entry.nativeRetryAt = now + 30_000;+ await entry.native.install(+ entry.bridge.listeningPort,+ entry.ghost.manifest.browserExtension!.extensionIds,+ );+ }+ }const status = await entry.bridge.status();if (!status.ok) return { ...status, errorCode: 'HOST_NOT_READY' };return {diff --git a/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/user-browser-backend.test.ts b/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/user-browser-backend.test.tsindex e374645408..031ccf5d5c 100644--- a/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/user-browser-backend.test.ts+++ b/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/user-browser-backend.test.ts@@ -328,6 +328,10 @@ describe('UserBrowserBackend · 读取与动作', () => {expect(await call(b, { action: 'act', targetId: 't1', request: { kind: 'wait', timeMs: 1 } }),).toMatchObject({ ok: true, data: { kind: 'wait', waitedMs: 1 } });+ // Review 2026-10-30 (Codex P2): older extensions run one wait condition per call, so a combination is refused.+ expect(+ await call(b, { action: 'act', targetId: 't1', request: { kind: 'wait', selector: '.ready', timeMs: 500 } }),+ ).toMatchObject({ ok: false, message: expect.stringContaining('组合') });// Review 2026-10-30 (Codex P2): a loadState wait on an older extension must not navigate the tab.fake.responses.set('tabs', () => ({ ok: true, tabs: [{ id: 7, url: 'https://example.test/a', status: 'complete' }] }));const navigatesBefore = fake.jobs.filter(([name]) => name === 'navigate').length;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 1446b9aeab..29ab50d9ff 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@@ -1386,6 +1386,10 @@ export class UserBrowserBackend implements BrowserBackend {): Promise<BackendResult> {const request = req.request!;if (request.fn || request.textGone) return unsupported(req.action, 'wait.fn / wait.textGone');+ // Older extensions run one wait condition per call; a combination would silently drop all but the+ // first, so it is refused instead.+ const conditions = [request.selector, typeof request.timeMs === 'number', request.url, request.loadState].filter(Boolean);+ if (conditions.length > 1) return unsupported(req.action, '同时组合多个 wait 条件(selector / timeMs / url / loadState)');const timeoutMs = Math.min(30000, Math.max(100, request.timeoutMs ?? 15000));const started = (this.opts.now ?? Date.now)();if (request.selector) {