Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(browser): 收回验证码提取并守住网络捕获边界
Dashf9226dc504d6
diff --git a/packages/browser-control-runtime/src/recipe-sessions.test.ts b/packages/browser-control-runtime/src/recipe-sessions.test.tsindex 0f47499cd8..2e907599fd 100644--- a/packages/browser-control-runtime/src/recipe-sessions.test.ts+++ b/packages/browser-control-runtime/src/recipe-sessions.test.ts@@ -2,6 +2,34 @@ import { describe, expect, it, vi } from "vitest";import { RecipeBrowserSessions } from "./recipe-sessions.js";describe("recipe browser sessions", () => {+ // #6826 / 4353868431: real capture API, unit tier. The old small-response+ // tests never crossed the count/payload bounds with an older in-flight request.+ it.each(['count', 'payload'] as const)('keeps unfinished requests across the %s cap', async cap => {+ const sessions = new RecipeBrowserSessions();+ let event = (_method: string, _params: Record<string, unknown>) => {};+ const id = sessions.begin('target', {+ send: async () => ({ body: cap === 'payload' ? 'x'.repeat(1_000_000) : 'done' }),+ subscribe: listener => { event = listener; return () => {}; }, dispose: () => {},+ });+ const start = (requestId: string) => event('Network.requestWillBeSent', {+ requestId, request: { url: 'https://example.test/api' },+ });+ try {+ await sessions.call('target', id, 'Cindy.captureStart');+ start('unfinished');+ for (let i = 0; i < (cap === 'count' ? 101 : 9); i++) {+ start(`complete-${i}`);+ event('Network.loadingFinished', { requestId: `complete-${i}` });+ await Promise.resolve();+ }+ const read = await sessions.call('target', id, 'Cindy.captureRead') as { entries: Array<Record<string, unknown>> };+ expect(read.entries).toContainEqual(expect.objectContaining({ requestId: 'unfinished', captureComplete: false }));+ expect(read.entries.length).toBeLessThanOrEqual(100);+ expect(read.entries.reduce((sum, entry) => sum + String(entry.responsePreview ?? '').length, 0)).toBeLessThanOrEqual(8_000_000);+ expect(await sessions.call('target', id, 'Cindy.captureRead')).toMatchObject({ entries: [{ requestId: 'unfinished' }] });+ } finally { sessions.dispose(); }+ });+// Review #6826: a valid large response must be distinguishable from malformed// JSON. Public session capture/read entry; unit tier. Existing small-body// coverage did not cross the one-million-character boundary or cover base64.diff --git a/packages/browser-control-runtime/src/recipe-sessions.ts b/packages/browser-control-runtime/src/recipe-sessions.tsindex 94ba07b142..5e912d87b8 100644--- a/packages/browser-control-runtime/src/recipe-sessions.ts+++ b/packages/browser-control-runtime/src/recipe-sessions.ts@@ -31,7 +31,7 @@ interface Session {transport: RecipeTransport;unsubscribe: () => void;timer: ReturnType<typeof setTimeout>;- capture?: { patterns: string[]; entries: Map<string, CaptureEntry> };+ capture?: { patterns: string[]; entries: Map<string, CaptureEntry>; error?: string };}/** Invocation-local CDP sessions preserve object/node IDs across commands.@@ -89,6 +89,7 @@ export class RecipeBrowserSessions {return {};}if (method === "Cindy.captureRead") {+ if (session.capture?.error) throw new Error(session.capture.error);const entries = session.capture?.entries;const result = [...(entries?.values() ?? [])].map((entry) => ({...entry,@@ -108,7 +109,7 @@ export class RecipeBrowserSessions {params: Record<string, unknown>,): Promise<void> {const capture = session.capture;- if (!capture) return;+ if (!capture || capture.error) return;const requestId = String(params.requestId ?? "");if (!requestId) return;if (method === "Network.requestWillBeSent") {@@ -126,8 +127,16 @@ export class RecipeBrowserSessions {!capture.patterns.some((pattern) => request.url!.includes(pattern))))return;- if (capture.entries.size >= 100)- capture.entries.delete(capture.entries.keys().next().value!);+ if (!capture.entries.has(requestId) && capture.entries.size >= 100) {+ const completed = [...capture.entries.values()].find(entry => entry.captureComplete);+ if (!completed) {+ // Keep the existing bound; losing any unfinished request would make+ // network-idle consumers report success without complete evidence.+ capture.error = 'Network capture capacity exceeded (100 unfinished requests)';+ return;+ }+ capture.entries.delete(completed.requestId);+ }capture.entries.set(requestId, {kind: "cdp",requestId,@@ -164,10 +173,13 @@ export class RecipeBrowserSessions {(sum, item) => sum + (item.responsePreview?.length ?? 0),0,);- for (const [id, item] of capture.entries) {+ for (const item of capture.entries.values()) {if (retained <= 8_000_000) break;+ if (!item.responsePreview) continue;retained -= item.responsePreview?.length ?? 0;- capture.entries.delete(id);+ // Payload pressure cannot erase completion tracking.+ delete item.responsePreview;+ item.responseBodyTruncated = true;}} catch {entry.error = "Response body unavailable";diff --git a/packages/lizi-mcps/src/browser/opencli-recipes.test.ts b/packages/lizi-mcps/src/browser/opencli-recipes.test.tsindex 152fd57b72..832d3efd7a 100644--- a/packages/lizi-mcps/src/browser/opencli-recipes.test.ts+++ b/packages/lizi-mcps/src/browser/opencli-recipes.test.ts@@ -61,6 +61,66 @@ afterEach(() => {});describe("bundled OpenCLI recipes", () => {+ // #6826 / 4353868420, unit: metadata discovery and execution must reject the+ // retired code-extraction mode before any browser operation. No previous OTP case.+ it.each([true, false, 'true'])('rejects Proton code mode %s before page effects', async value => {+ const effect = vi.fn(async () => { throw new Error('unexpected mailbox read'); });+ const start = vi.fn();+ const recipe = loadRecipes().get('opencli:proton/inbox')!;+ expect(recipe).toBeDefined();+ await expect(executeAdapter('proton/inbox', { 'read-code': value },+ new Proxy({}, { get: () => effect }) as IPage, undefined, start)).rejects.toThrow('read-code');+ expect(start).not.toHaveBeenCalled();+ expect(effect).not.toHaveBeenCalled();+ expect(recipe.inputs).not.toHaveProperty('read-code');+ });++ it('keeps Proton inbox metadata available without opening message bodies', async () => {+ const goto = vi.fn(async () => { throw new Error('unexpected message navigation'); });+ const page = { goto, evaluate: async (_fn: unknown, operation: string) => operation === 'identity'+ ? { account: { id: 'account' }, localID: '0' }+ : operation === 'messages' ? { messages: [{ id: 'message', address: '[email protected]',+ senderName: 'Sender', subject: 'Fixture subject', timestamp: 1, labels: ['0'] }], total: 1, localID: '0' }+ : { origin: 'https://mail.proton.me', path: '/u/0/inbox' },+ } as unknown as IPage;+ expect(await executeAdapter('proton/inbox', { limit: 1 }, page)).toEqual([+ { id: 'message', sender: '[email protected]', subject: 'Fixture subject', time: 1, code: null },+ ]);+ expect(goto).not.toHaveBeenCalled();+ });++ // #6826 capture-cap recurrence, unit: real web reader + session owner.+ // Saturation of 101 concurrent requests must fail before content extraction;+ // an empty fallback on capture errors would falsely report network idle.+ it('rejects saturated network capture instead of extracting a falsely idle page', async () => {+ vi.useFakeTimers();+ const sessions = new RecipeBrowserSessions();+ let event = (_method: string, _params: Record<string, unknown>) => {};+ const id = sessions.begin('web', {+ send: async () => ({}), subscribe: listener => { event = listener; return () => {}; }, dispose: () => {},+ });+ const evaluate = vi.fn(async () => ({ title: 'Too early', contentHtml: '<p>Partial</p>' }));+ const page = {+ startNetworkCapture: async () => { await sessions.call('web', id, 'Cindy.captureStart'); return true; },+ readNetworkCapture: async () => (await sessions.call('web', id, 'Cindy.captureRead') as { entries: unknown[] }).entries,+ goto: async () => {+ for (let i = 0; i < 101; i++) event('Network.requestWillBeSent', {+ requestId: String(i), request: { url: 'https://example.test/api' },+ });+ for (let i = 1; i < 101; i++) event('Network.loadingFailed', { requestId: String(i) });+ }, evaluate,+ } as unknown as IPage;+ try {+ const checked = expect(executeAdapter('web/read', { url: 'https://example.test', 'wait-until': 'networkidle', wait: 5 }, page))+ .rejects.toThrow('Network capture capacity exceeded');+ await vi.advanceTimersByTimeAsync(1500);+ await checked;+ expect(evaluate).not.toHaveBeenCalled();+ await sessions.call('web', id, 'Cindy.captureStart');+ expect(await sessions.call('web', id, 'Cindy.captureRead')).toEqual({ entries: [] });+ } finally { sessions.dispose(); }+ });+// #6826 / review 4353609017, unit: the real Gemini activation helper and// host page must resume a hidden response, including a reused bound tab.// Earlier foreground-login tests never exercised tab discovery/selection.@@ -265,7 +325,7 @@ describe("bundled OpenCLI recipes", () => {const start = vi.fn();for (const [id, required, key, value] of cases) {await expect(executeAdapter(id, { ...required, [key]: value }, page, undefined, start))- .rejects.toThrow('Local recipe file export');+ .rejects.toThrow('Recipe mode is unavailable');expect(loadRecipes().get(`opencli:${id}`)!.inputs).not.toHaveProperty(key);}expect(start).not.toHaveBeenCalled();diff --git a/packages/opencli-vendor/README.md b/packages/opencli-vendor/README.mdindex 9d1e4a7720..792fa5d3fd 100644--- a/packages/opencli-vendor/README.md+++ b/packages/opencli-vendor/README.md@@ -33,7 +33,9 @@原始摘要及实际落地摘要。不要直接修改 `src/` 或 `clis/` 而不登记补丁。- 浏览器操作使用 Cindy 当前任务、profile 和目标页;不启动 OpenCLI daemon/扩展。-- CDP 对象和节点沿用一次配方调用的连接;网络响应按上游格式捕获,读取只清空已完成响应,未完成请求保留至结束事件;结束时+- CDP 对象和节点沿用一次配方调用的连接;网络响应按上游格式捕获,读取只清空已完成响应,未完成请求保留至结束事件。+ 100 条容量优先淘汰已完成条目;全为未完成请求时明确报告容量不足,不误报网络空闲。累计正文超过+ 8 MB 时只移除正文并标记截断,不删除完成状态。网页读取传播捕获错误;重新开始捕获才清除此错误。结束时释放监听和连接。导航、上传仍走 Cindy 原有校验路径;代输入后的页面读取限制仍生效。- 通用执行器不自动重放操作。Instagram reel 移除独立 daemon 和整次发布重试。- Claude.ai 站点不进入默认目录,Claude 订阅沿用内置 Claude Code CLI 登录与使用。@@ -43,6 +45,8 @@- PaperReview 与 Quark 暂不进入默认目录:现有提交/查询/反馈、分享目录/转存入口会把可复用能力令牌放入模型结果或参数。完整来源保留,不增加配置或句柄存储机制。- ONES 暂不进入默认目录:密码参数和令牌打印不符合宿主代输入及凭据边界。+- Proton 保留收件箱元数据查询,但通过同一 selection 收回 `read-code` 模式,在浏览器动作前拒绝+ 旧参数;不提取验证码返回模型,不新增验证码交接或正文脱敏机制。登录继续使用已有的通用代输入流程,不新增站点专用配置。- Kimi 暂不进入默认目录:存储读取与 Cookie 诊断会把任意存储值或授权材料预览返回模型。完整来源保留,不新增秘密键猜测或凭据脱敏机制。diff --git a/packages/opencli-vendor/UPSTREAM.json b/packages/opencli-vendor/UPSTREAM.jsonindex 57acad3c0f..38a11c4da3 100644--- a/packages/opencli-vendor/UPSTREAM.json+++ b/packages/opencli-vendor/UPSTREAM.json@@ -1383,7 +1383,7 @@"clis/v2ex/topic.js": "ba0e01735fc4dc122ed4f3b4130586fe6c065aded1612e50c3d9eb8ba19dfe0e","clis/v2ex/user.js": "e6a254fc2e61f640942b1570fd720417e2ad96f0d9a32d61128e65ea040ce561","clis/wanfang/search.js": "1713664acba438a57e797d2ffba61387f97070909d3cd95a43180d2b1a6df7d5",- "clis/web/read.js": "e4f1fc889910d18a5739ee56b3ff3a083cce6f6b25a8905ae49c8f711371d015",+ "clis/web/read.js": "df5f7e41d8ba4cc49338be56a421e09a8b6ff99036380283dcc040ed6a50a362","clis/wechat-channels/auth.js": "87273b45899f69ad523ccb3474b328cc2f915d0c2891900a78dbaceaa9ed2958","clis/wechat-channels/publish.js": "dec92e03bf8c41f7709b1c2c9cf9d0e276ed1f99a019d3aea8a90eda3cedd909","clis/weibo/auth.js": "a67993a6302b445465ab09a1e2eaf0048b41f373b235801c07198ce9de263c07",diff --git a/packages/opencli-vendor/cindy/catalog.ts b/packages/opencli-vendor/cindy/catalog.tsindex eca3d4ff3d..eb1be00e42 100644--- a/packages/opencli-vendor/cindy/catalog.ts+++ b/packages/opencli-vendor/cindy/catalog.ts@@ -30,7 +30,9 @@ export const canonicalCatalog = upstreamCatalog.filter(entry => !(entry.site inreturn {...entry, excludedArgs,description: entry.site === 'doubao' && entry.name === 'meeting-transcript'- ? 'Read the meeting transcript from a Doubao conversation' : entry.description,+ ? 'Read the meeting transcript from a Doubao conversation'+ : entry.site === 'proton' && entry.name === 'inbox'+ ? 'List sender-filtered inbox metadata via API' : entry.description,args: entry.args.filter(arg => !excludedArgs.includes(arg.name)).map(arg => {const selected = { ...arg, help: arg.help?.replace(' Prefer --output-file for large archives.', '').replace(' Incompatible with --output-file.', '') };diff --git a/packages/opencli-vendor/cindy/index.ts b/packages/opencli-vendor/cindy/index.tsindex b9ee5955ce..6880649479 100644--- a/packages/opencli-vendor/cindy/index.ts+++ b/packages/opencli-vendor/cindy/index.ts@@ -102,7 +102,7 @@ export async function executeAdapter(const command = await loadAdapter(id);const entry = entries.get(id)!;const excludedArg = entry.excludedArgs?.find(name => Object.prototype.hasOwnProperty.call(inputs, name));- if (excludedArg) throw new Error(`Local recipe file export is unavailable: ${excludedArg}; use content or links and the host file tools`);+ if (excludedArg) throw new Error(`Recipe mode is unavailable in Cindy: ${excludedArg}; use the selected recipe inputs`);// Discovery and execution use the same selected argument defaults.const args = prepareInputs(entry.args, inputs);if (!files?.output) {diff --git a/packages/opencli-vendor/cindy/patches.json b/packages/opencli-vendor/cindy/patches.jsonindex 2e9abfcd87..5492be7833 100644--- a/packages/opencli-vendor/cindy/patches.json+++ b/packages/opencli-vendor/cindy/patches.json@@ -4041,5 +4041,10 @@"file": "clis/linkedin/search.js","before": "// \"missing description\"), and log every failure to stderr with the offending\n// URL so debugging is possible. Successful rows have `detail_error: null`.","after": "// \"missing description\"). Cindy returns these details only to the caller,\n// without duplicating browsing activity in host logs. Successful rows have `detail_error: null`."+ },+ {+ "file": "clis/web/read.js",+ "before": " const raw = await page.readNetworkCapture().catch(() => []);",+ "after": " const raw = await page.readNetworkCapture();"}]diff --git a/packages/opencli-vendor/cindy/selection.json b/packages/opencli-vendor/cindy/selection.jsonindex c8ac40c8d2..97b30aa390 100644--- a/packages/opencli-vendor/cindy/selection.json+++ b/packages/opencli-vendor/cindy/selection.json@@ -12,6 +12,7 @@"band/post": ["output"],"doubao/meeting-transcript": ["download"],"midjourney/generate": ["output"],+ "proton/inbox": ["read-code"],"twitter/bookmarks": ["resume-file", "output-file"],"twitter/likes": ["resume-file", "output-file"],"web/read": ["output", "download-images"],diff --git a/packages/opencli-vendor/clis/web/read.js b/packages/opencli-vendor/clis/web/read.jsindex cbe661fa5f..219f7ae377 100644--- a/packages/opencli-vendor/clis/web/read.js+++ b/packages/opencli-vendor/clis/web/read.js@@ -76,7 +76,7 @@ function isInterestingNetworkEntry(entry) {async function drainNetworkCapture(page, sink) {if (!page.readNetworkCapture) return [];- const raw = await page.readNetworkCapture().catch(() => []);+ const raw = await page.readNetworkCapture();const entries = Array.isArray(raw) ? raw.map(normalizeNetworkEntry).filter(entry => entry.url) : [];sink.push(...entries.filter(entry => entry.captureComplete !== false));return entries;