Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(browser): retire export modes before adapter execution
Dash710968ee19c7
diff --git a/packages/lizi-mcps/src/browser/opencli-recipes.test.ts b/packages/lizi-mcps/src/browser/opencli-recipes.test.tsindex c68994e295..8240c973cf 100644--- a/packages/lizi-mcps/src/browser/opencli-recipes.test.ts+++ b/packages/lizi-mcps/src/browser/opencli-recipes.test.ts@@ -58,6 +58,73 @@ afterEach(() => {});describe("bundled OpenCLI recipes", () => {+ // #6826 export-mode recurrence, unit tier. Earlier tests only exercised+ // link flags and web/stdout, missing optional archive/browser-download modes.+ // Every retired argument must disappear and fail before execution begins.+ it('rejects retired export arguments before any browser or network effect', async () => {+ const cases: Array<[string, Record<string, unknown>, string, unknown]> = [+ ['twitter/bookmarks', { all: true }, 'resume-file', 'resume.json'],+ ['twitter/bookmarks', { all: true }, 'output-file', 'archive.jsonl'],+ ['twitter/likes', { username: 'fixture', all: true }, 'resume-file', 'resume.json'],+ ['twitter/likes', { username: 'fixture', all: true }, 'output-file', 'archive.jsonl'],+ ['band/post', { band_no: '1', post_no: '2' }, 'output', 'photos'],+ ['doubao/meeting-transcript', { id: '123' }, 'download', true],+ ['doubao/meeting-transcript', { id: '123' }, 'download', 'true'],+ ['web/read', { url: 'https://example.test' }, 'output', 'articles'],+ ['web/read', { url: 'https://example.test' }, 'download-images', true],+ ['midjourney/generate', { prompt: 'fixture' }, 'output', 'images'],+ ...['background', 'edit', 'face-swap', 'generate', 'object-remover', 'remove-bg', 'restore', 'try-on', 'upscale', 'video']+ .map(name => [`yollomi/${name}`, {}, 'output', 'images'] as [string, Record<string, unknown>, string, unknown]),+ ];+ const effect = vi.fn(async () => { throw new Error('unexpected page effect'); });+ const page = new Proxy({}, { get: () => effect }) as IPage;+ 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');+ expect(loadRecipes().get(`opencli:${id}`)!.inputs).not.toHaveProperty(key);+ }+ expect(start).not.toHaveBeenCalled();+ expect(effect).not.toHaveBeenCalled();+ });++ it('keeps Band photo links and Doubao transcript text available without exports', async () => {+ const band = { goto: async () => {}, getCookies: async () => [{ name: 'band_session', value: 'invalid-fixture' }],+ evaluate: async () => ({ text: 'Fixture post', photos: ['https://example.test/photo.png'] }),+ } as unknown as IPage;+ expect(await executeAdapter('band/post', { band_no: '1', post_no: '2' }, band))+ .toMatchObject([{ type: 'post', text: expect.stringContaining('https://example.test/photo.png') }]);+ const evaluate = vi.fn(async (_js: string) => 'Fixture transcript');+ const doubao = { goto: async () => {}, wait: async () => {}, evaluate } as unknown as IPage;+ expect(await executeAdapter('doubao/meeting-transcript', { id: '123' }, doubao))+ .toEqual([{ Section: 'Transcript', Content: 'Fixture transcript' }]);+ expect(evaluate.mock.calls.every(args => !String(args[0]).includes('minutes-download-text-btn'))).toBe(true);+ expect(loadRecipes().get('opencli:mubu/doc')!.inputs).toHaveProperty('output');+ });++ // Unsupported adapter API regression: real adapter + real OpenCliPage,+ // fake transport and timers. Old page.waitForTimeout always throws after goto.+ it('runs Maimai talent search using the supported five-second delay', async () => {+ vi.useFakeTimers();+ const calls: BrowserControlRequest[] = [];+ const page = new OpenCliPage({ targetId: 'fixture', call: async request => {+ calls.push(request);+ const method = request.recipeCommand?.method;+ return { ok: true, action: request.action, data: method === 'Cindy.begin' ? { sessionId: 'fixture-session' }+ : method === 'Network.getCookies' ? { cookies: [] }+ : { result: request.request?.fn?.includes('api/ent/discover/search')+ ? { code: 0, data: { list: [{ name: 'Fixture candidate', company: 'Fixture company' }] } } : true } };+ } });+ try {+ const result = executeAdapter('maimai/search-talents', { query: 'fixture' }, page);+ const checked = expect(result).resolves.toMatchObject([{ name: 'Fixture candidate', company: 'Fixture company' }]);+ await vi.advanceTimersByTimeAsync(4999);+ expect(calls.some(call => call.request?.fn?.includes('api/ent/discover/search'))).toBe(false);+ await vi.advanceTimersByTimeAsync(1);+ await checked;+ } finally { await page.dispose(); }+ });+// #6826 download recurrence, unit tier. Generic downloader tests missed the// X composer consumer; real DNS/redirect policy with an in-memory dispatcher.it.each(['http://127.0.0.1/private', 'https://private.example/image', 'https://public.example/redirect'])(diff --git a/packages/opencli-vendor/README.md b/packages/opencli-vendor/README.mdindex e9503803c2..e0b3c87223 100644--- a/packages/opencli-vendor/README.md+++ b/packages/opencli-vendor/README.md@@ -64,6 +64,11 @@这些入口新增跨平台写入机制。17 条直接落盘命令暂缓,生成配方沿用已有链接分支,通用网页读取默认返回正文;发现与执行共用这些默认值,显式关闭上述模式在页面动作前拒绝。需要保存结果时使用已有宿主文件工具。调用内诊断、上传副本和转换结果继续可用,结束后清理。+- 同一 selection 还收回 16 条命令的 19 个导出参数:X 收藏/喜欢的断点与归档文件、Band+ 图片目录、豆包转录下载,以及生成/通用读取的输出目录和图片下载选项。发现入口不再展示,+ 旧调用即使显式传入也在参数预检时拒绝,早于执行开始和页面/网络动作;命令本身的正文、+ 列表、媒体链接仍可用,幕布的 `output` 格式参数不受影响。不增加下载捕获或文件归档机制。+- 脉脉人才搜索使用已有 `sleep(5)` 秒接口;全部来源仅这一处使用不支持的 `waitForTimeout`。- Instagram 图片转换、视频元数据、封面及 story 裁剪只读取批准字节的调用内副本,不重新打开原始源路径;临时输入及转换结果沿用同一调用目录,在成功或失败后清理。- 抖音分片上传先批准并打开源文件,再创建远端上传;上传 ID 和进度只存于本次调用,diff --git a/packages/opencli-vendor/UPSTREAM.json b/packages/opencli-vendor/UPSTREAM.jsonindex bcfbe53cea..957071fa98 100644--- a/packages/opencli-vendor/UPSTREAM.json+++ b/packages/opencli-vendor/UPSTREAM.json@@ -228,6 +228,9 @@},"clis/pubmed/utils.js": {"upstreamSha256": "ad4e9eff1347b667ec04aaa43bc55a4b65adedac685c55daf11965aec15fe436"+ },+ "clis/maimai/search-talents.js": {+ "upstreamSha256": "f4ebfd01ea433cec410a14a1cccea6928d51b7d5ea43af2ca8ab450fa58c4e19"}},"files": {@@ -869,7 +872,7 @@"clis/lobsters/read.js": "e25827148fadc1811f5c77c9559d8a717d670177e24a6d7cc39bc4fbe47d2809","clis/lobsters/tag.js": "314dfe59ad10de0f7a0766b71a771b0f33a31bc137915ef50b51d1b2f58c68b9","clis/maimai/auth.js": "a9982cf023ce13d34b23014ecee735687bcd21487c61febb8bc80888e9d43f74",- "clis/maimai/search-talents.js": "f4ebfd01ea433cec410a14a1cccea6928d51b7d5ea43af2ca8ab450fa58c4e19",+ "clis/maimai/search-talents.js": "18fc50cd19c3fe5be69785bb3b2466435fbd0e8ccc77f55a156feebe8f64eaba","clis/manus/_utils.js": "d5d8c7ae6f4bc77cd367192d128844372cd2cbe0bdf737752fbfd78a38cdb142","clis/manus/auth.js": "ad526ed7abcbbef890537b0d445e99bc763787f7f3d30420758a14af92d75018","clis/manus/connectors.js": "3114bac64cc4506187598cc42c9cce1bac82c7d46d284930d1689fb297c1bfbe",diff --git a/packages/opencli-vendor/cindy/catalog.ts b/packages/opencli-vendor/cindy/catalog.tsindex e5e2d3c3a7..eca3d4ff3d 100644--- a/packages/opencli-vendor/cindy/catalog.ts+++ b/packages/opencli-vendor/cindy/catalog.ts@@ -13,21 +13,33 @@ export interface CatalogEntry {args: Arg[];aliases?: string[];modulePath: string;+ /** Retired modes remain rejected even when supplied by an older caller. */+ excludedArgs?: string[];}// Do not propagate the 1,223-entry JSON's inferred union through host types.export const upstreamCatalog = manifestJson as CatalogEntry[];export const excludedSites: Readonly<Record<string, string>> = selection.excludedSites;export const excludedCommands = new Set<string>(selection.excludedCommands);+const excludedArguments: Readonly<Record<string, string[]>> = selection.excludedArguments;// Local exports are outside the selected capability. Generation keeps its// existing link-only branch; generic reading returns content in the tool result.export const canonicalCatalog = upstreamCatalog.filter(entry => !(entry.site in excludedSites)- && !excludedCommands.has(`${entry.site}/${entry.name}`)).map(entry => ({- ...entry,- args: entry.args.map(arg => ['sd', 'skip-download', 'no-download'].includes(arg.name)- || (entry.site === 'web' && entry.name === 'read' && arg.name === 'stdout')- ? { ...arg, default: true } : arg),- }));+ && !excludedCommands.has(`${entry.site}/${entry.name}`)).map(entry => {+ const excludedArgs = excludedArguments[`${entry.site}/${entry.name}`] ?? [];+ return {+ ...entry, excludedArgs,+ description: entry.site === 'doubao' && entry.name === 'meeting-transcript'+ ? 'Read the meeting transcript from a Doubao conversation' : 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.', '') };+ return ['sd', 'skip-download', 'no-download'].includes(arg.name)+ || (entry.site === 'web' && entry.name === 'read' && arg.name === 'stdout')+ ? { ...selected, default: true } : selected;+ }),+ };+ });/** Keep upstream aliases executable as well as canonical command names. */const catalog: CatalogEntry[] = canonicalCatalog.flatMap(entry => [diff --git a/packages/opencli-vendor/cindy/index.ts b/packages/opencli-vendor/cindy/index.tsindex 56728d28c9..b9ee5955ce 100644--- a/packages/opencli-vendor/cindy/index.ts+++ b/packages/opencli-vendor/cindy/index.ts@@ -100,10 +100,13 @@ export async function executeAdapter(): Promise<unknown> {return withRecipeHost(secrets, async () => {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`);// Discovery and execution use the same selected argument defaults.- const args = prepareInputs(entries.get(id)!.args, inputs);+ const args = prepareInputs(entry.args, inputs);if (!files?.output) {- const skip = entries.get(id)!.args.find(arg => ['sd', 'skip-download', 'no-download'].includes(arg.name));+ const skip = entry.args.find(arg => ['sd', 'skip-download', 'no-download'].includes(arg.name));if ((skip && args[skip.name] !== true) || (id === 'web/read' && args.stdout !== true)) {throw new Error('Local recipe file export is unavailable; keep the link-only or content-only mode');}diff --git a/packages/opencli-vendor/cindy/patches.json b/packages/opencli-vendor/cindy/patches.jsonindex d9bcc3e438..15653fe222 100644--- a/packages/opencli-vendor/cindy/patches.json+++ b/packages/opencli-vendor/cindy/patches.json@@ -3701,5 +3701,10 @@"file": "clis/pubmed/utils.js","before": "const delayMs = process.env.NCBI_API_KEY ? 110 : 360;","after": "const delayMs = 360;"+ },+ {+ "file": "clis/maimai/search-talents.js",+ "before": "await page.waitForTimeout(5000);",+ "after": "await page.sleep(5);"}]diff --git a/packages/opencli-vendor/cindy/selection.json b/packages/opencli-vendor/cindy/selection.jsonindex 30cae2aad6..e5485e2cc9 100644--- a/packages/opencli-vendor/cindy/selection.json+++ b/packages/opencli-vendor/cindy/selection.json@@ -7,6 +7,24 @@"weixin/download", "xiaohongshu/download", "zhihu/download"],"excludedCommandsReason": "Local file exports are deferred: a checked path string is not an atomic write capability. Full sources are retained; use existing host file tools to save browser results.",+ "excludedArguments": {+ "band/post": ["output"],+ "doubao/meeting-transcript": ["download"],+ "midjourney/generate": ["output"],+ "twitter/bookmarks": ["resume-file", "output-file"],+ "twitter/likes": ["resume-file", "output-file"],+ "web/read": ["output", "download-images"],+ "yollomi/background": ["output"],+ "yollomi/edit": ["output"],+ "yollomi/face-swap": ["output"],+ "yollomi/generate": ["output"],+ "yollomi/object-remover": ["output"],+ "yollomi/remove-bg": ["output"],+ "yollomi/restore": ["output"],+ "yollomi/try-on": ["output"],+ "yollomi/upscale": ["output"],+ "yollomi/video": ["output"]+ },"excludedSites": {"zlibrary": "Not in Cindy's default catalog: copyright enforcement history and unverified mirror ownership (reviewed 2026-10-23).","slock": "Deferred: app.slock.ai redirects to app.raft.build; the adapter still assumes the old origin and token storage. Revalidate before inclusion.",diff --git a/packages/opencli-vendor/clis/maimai/search-talents.js b/packages/opencli-vendor/clis/maimai/search-talents.jsindex 9079246bcd..85756b81d1 100644--- a/packages/opencli-vendor/clis/maimai/search-talents.js+++ b/packages/opencli-vendor/clis/maimai/search-talents.js@@ -52,7 +52,7 @@ cli({// Navigate to the search pageawait page.goto('https://maimai.cn/ent/talents/discover/search_v2', { waitUntil: 'networkidle' });- await page.waitForTimeout(5000);+ await page.sleep(5);// Generate random session IDsconst sessionid = 'b92d0fb5-f3fd-1f4b-fcdc-' + Math.random().toString(16).slice(2, 14);