Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(browser): remove expired publishing diagnostic paths

Dashaef84bba4ef4
diff --git a/packages/lizi-mcps/src/browser/opencli-recipes.test.ts b/packages/lizi-mcps/src/browser/opencli-recipes.test.ts
index 393d121e85..70d91889d1 100644
--- a/packages/lizi-mcps/src/browser/opencli-recipes.test.ts
+++ b/packages/lizi-mcps/src/browser/opencli-recipes.test.ts
@@ -38,6 +38,8 @@ import { validateLocalReferences } from '../../../opencli-vendor/clis/midjourney
import { tosUpload } from '../../../opencli-vendor/clis/douyin/_shared/tos-upload.js';
// @ts-expect-error Pinned upstream JavaScript media helpers have no declarations.
import * as instagramMedia from '../../../opencli-vendor/clis/instagram/_shared/private-publish.js';
+// @ts-expect-error Pinned upstream JavaScript page probes have no declarations.
+import { buildInspectUploadStageJs } from '../../../opencli-vendor/clis/instagram/post.js';
// @ts-expect-error Pinned upstream JavaScript helpers have no declarations.
import { downloadRemoteImage, MAX_IMAGE_SIZE_BYTES } from '../../../opencli-vendor/clis/twitter/utils.js';
// @ts-expect-error Pinned upstream JavaScript helpers have no declarations.
@@ -75,6 +77,46 @@ afterEach(() => {
});
describe("bundled OpenCLI recipes", () => {
+ // #6826 / 4354589825, unit: the real publishing entries must retain the
+ // original failure without advertising an already-cleaned diagnostic file.
+ // Existing temporary-file tests covered cleanup, but never adapter errors.
+ // Minimal states: pending Instagram preview, missing XHS entry, failed video injection.
+ it.each(['instagram', 'xiaohongshu', 'wechat-channels'])('reports %s publishing failures without temporary screenshot paths', async site => {
+ const dir = await mkdtemp(path.join(tmpdir(), 'cindy-publish-error-'));
+ const file = path.join(dir, site === 'wechat-channels' ? 'clip.mp4' : 'image.jpg');
+ await writeFile(file, 'fixture');
+ const screenshot = vi.fn(async () => { throw new Error('fixture screenshot unavailable'); });
+ vi.stubEnv('OPENCLI_INSTAGRAM_CAPTURE', '0');
+ vi.spyOn(instagramMedia, 'resolveInstagramPrivatePublishConfig')
+ .mockRejectedValue(new CommandExecutionError('Instagram private route fixture unavailable'));
+ const page = {
+ goto: async () => {}, wait: async () => {}, getCookies: async () => [],
+ ...(site === 'instagram' ? { setFileInput: async () => {} } : {}),
+ screenshot,
+ evaluate: async (js: string) => {
+ if (js === '() => location.href') return site === 'xiaohongshu'
+ ? 'https://creator.xiaohongshu.com/publish/publish' : 'https://channels.weixin.qq.com/platform/post/create';
+ if (site === 'instagram') {
+ if (js === buildInspectUploadStageJs()) return { state: 'pending' };
+ return { ok: true, selectors: ['input[type="file"]'] };
+ }
+ return site === 'xiaohongshu' ? { ok: false, state: 'image_surface' }
+ : { ok: false, error: 'fixture upload rejection' };
+ },
+ } as unknown as IPage;
+ const inputs = site === 'instagram' ? { media: file } : site === 'xiaohongshu'
+ ? { title: 'Fixture', content: 'Fixture', 'card-text': 'Fixture' } : { video: file };
+ const expected = site === 'instagram' ? 'Instagram image preview did not appear after upload'
+ : site === 'xiaohongshu' ? '文字配图: could not click' : '视频文件注入失败: fixture upload rejection';
+ try {
+ await expect(executeAdapter(`${site}/${site === 'instagram' ? 'post' : 'publish'}`, inputs, page,
+ undefined, undefined, { read: readFileSync, open: file => openSync(file, 'r'), temporaryRoot: dir }))
+ .rejects.toThrow(expected);
+ expect(screenshot).not.toHaveBeenCalled();
+ expect(await readdir(dir)).toEqual([path.basename(file)]);
+ } finally { await rm(dir, { recursive: true, force: true }); }
+ });
+
// #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.
diff --git a/packages/opencli-vendor/README.md b/packages/opencli-vendor/README.md
index 85fb9bc4e5..059541c001 100644
--- a/packages/opencli-vendor/README.md
+++ b/packages/opencli-vendor/README.md
@@ -74,6 +74,8 @@
这些入口新增跨平台写入机制。19 条直接落盘命令暂缓,生成配方沿用已有链接分支,
通用网页读取默认返回正文;发现与执行共用这些默认值,显式关闭上述模式在页面动作前拒绝。
需要保存结果时使用已有宿主文件工具。调用内诊断、上传副本和转换结果继续可用,结束后清理。
+ Instagram、小红书与视频号的发布失败保留具体原因,移除临时诊断截图及其失效路径提示;
+ 不为此新增截图留存或产物交接。需要查看页面时沿用宿主已有浏览器工具。
临时根由宿主提供,每次调用用 `mkdtemp` 创建不可预测的私有目录(POSIX 为 0700);
这遵循现有宿主临时存储边界,不提供对同一操作系统账号下恶意并发进程的沙箱隔离。
任意本机命令执行者已经拥有该账号的文件权限,本次目录刷新不引入新的进程隔离机制。
diff --git a/packages/opencli-vendor/UPSTREAM.json b/packages/opencli-vendor/UPSTREAM.json
index fbc8b4964d..b3a8b8a5c7 100644
--- a/packages/opencli-vendor/UPSTREAM.json
+++ b/packages/opencli-vendor/UPSTREAM.json
@@ -809,9 +809,9 @@
"clis/instagram/following.js": "f42334a31aca1a727a11874836e814584b8cbac7e51a876c80b8d0d4d38775c9",
"clis/instagram/like.js": "40eca5c72564f704c40cf27b6c4da1bc38ee4d875224415cd88292a74e1b7bb0",
"clis/instagram/note.js": "5c409f7e6d2da0ab2c875729154b1af04c4ec00c6a2d51e4807bc3c3ea50abf8",
- "clis/instagram/post.js": "2e03fb73450023fcee74f8aea66595e0dd523b333bb94e62bc73496cea06a373",
+ "clis/instagram/post.js": "fa4760f05deee2d2807d54fa42fdf2cdee3b5e609c11fc328f0b50afa6f13ee5",
"clis/instagram/profile.js": "40f400cdabdcfcc216c5e7fa4bb321f1b70e00a5a5b83bac3c2ee1c276fca312",
- "clis/instagram/reel.js": "041de023591ed3a3f1d39c7b1fb8cb2f6d0f8f7f75ac7b8f6695ee55adf0f99c",
+ "clis/instagram/reel.js": "b51b9d52d80cf6858a06ede618ddb47bacc8579162cee227cfde02e21d6d6009",
"clis/instagram/save.js": "fc5105071edad389d6004247a1113473ade4b8da3e174ed6c06ef151d5a468ec",
"clis/instagram/saved.js": "95fbb7d994bd68e502b0b6a7fce70f24c3cf58083d5aefb1af54dfdd288781ec",
"clis/instagram/search.js": "a38879e761271d167bef752359442b0be84611cca727b2b323467772d2d45239",
@@ -1412,7 +1412,7 @@
"clis/wanfang/search.js": "1713664acba438a57e797d2ffba61387f97070909d3cd95a43180d2b1a6df7d5",
"clis/web/read.js": "df5f7e41d8ba4cc49338be56a421e09a8b6ff99036380283dcc040ed6a50a362",
"clis/wechat-channels/auth.js": "87273b45899f69ad523ccb3474b328cc2f915d0c2891900a78dbaceaa9ed2958",
- "clis/wechat-channels/publish.js": "dec92e03bf8c41f7709b1c2c9cf9d0e276ed1f99a019d3aea8a90eda3cedd909",
+ "clis/wechat-channels/publish.js": "9cf7ed168f5f246c6748958dfcae89836abfb0daf871702ede573fd5c501e0e3",
"clis/weibo/auth.js": "a67993a6302b445465ab09a1e2eaf0048b41f373b235801c07198ce9de263c07",
"clis/weibo/comments.js": "f2b9bb520ace7e3f530e0af09fb45ad251795ff1d61be93e96ecc4a8330f709c",
"clis/weibo/delete.js": "866a54ed27988df25d0d0499a58820246915f05af3d2c613ac9df7f022ca0113",
@@ -1504,7 +1504,7 @@
"clis/xiaohongshu/note.js": "09c08e2b8c69ee3a16daafc6fdcebf63fb016b99640adb8a157b80b3287f0833",
"clis/xiaohongshu/notifications.js": "1262c0172fabc45aa21ae65643d19e242856062e73caf0377a95cf94914000a3",
"clis/xiaohongshu/pinia-helpers.js": "c2b7639c4ddc2cd078a01eb62c66c0c37548b7b3fd5aac3c631ac53a36c68686",
- "clis/xiaohongshu/publish.js": "26b30ff721231bc84e8e0319964a9966fcf23b94f8ef2dc5f8cf24f4c1694a90",
+ "clis/xiaohongshu/publish.js": "216cad1c5f4cbefd70120f8e528b426e6f46090129dfec3d1e8d165d9f2c09d7",
"clis/xiaohongshu/risk-control.js": "6e7c15a8a27de78a45fbe01d206bbbd43fab23bd9aa4cf39c900bf6c838c7242",
"clis/xiaohongshu/saved.js": "c69f484e82b016a07ac699d3622236b8e0d2440826ff497f1ddbabb97137a2c7",
"clis/xiaohongshu/search.js": "333f5db3d62dfb3227bb59f47b5ce8e509901d6438b42e3038ec61624ea0d329",
diff --git a/packages/opencli-vendor/cindy/patches.json b/packages/opencli-vendor/cindy/patches.json
index 283e312001..2d51fccb66 100644
--- a/packages/opencli-vendor/cindy/patches.json
+++ b/packages/opencli-vendor/cindy/patches.json
@@ -4131,5 +4131,160 @@
"file": "src/pipeline/template.ts",
"before": "export function render(template: unknown, ctx: RenderContext): unknown {\n if (typeof template !== 'string') return template;\n const trimmed = template.trim();\n // Full expression: entire string is a single ${{ ... }}\n // Use [^}] to prevent matching across }} boundaries (e.g. \"${{ a }}-${{ b }}\")\n const fullMatch = trimmed.match(/^\\$\\{\\{\\s*([^}]*(?:\\}[^}][^}]*)*)\\s*\\}\\}$/);\n if (fullMatch && !trimmed.includes('}}-') && !trimmed.includes('}}${{')) return evalExpr(fullMatch[1].trim(), ctx);\n // Check if the entire string is a single expression (no other text around it)\n const singleExpr = trimmed.match(/^\\$\\{\\{\\s*([\\s\\S]*?)\\s*\\}\\}$/);\n if (singleExpr) {\n // Verify it's truly a single expression (no other ${{ inside)\n const inner = singleExpr[1];\n if (!inner.includes('${{')) return evalExpr(inner.trim(), ctx);\n }\n return template.replace(/\\$\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_m, expr) => String(evalExpr(expr.trim(), ctx)));\n}\n\nexport function evalExpr(expr: string, ctx: RenderContext): unknown {\n",
"after": "export function render(template: unknown, ctx: RenderContext): unknown {\n if (typeof template !== 'string') return template;\n const trimmed = template.trim();\n if (trimmed.startsWith('${{') && trimmed.endsWith('}}')) {\n const inner = trimmed.slice(3, -2);\n const singleClosingBraces = !inner.includes('}}') && !inner.endsWith('}');\n if (singleClosingBraces || !inner.includes('${{')) return evalExpr(inner.trim(), ctx);\n }\n // Scan delimiters once rather than retrying a backtracking regexp at each\n // opener. Keep malformed/unclosed templates as text, as before.\n const parts: string[] = [];\n let cursor = 0;\n while (cursor < template.length) {\n const start = template.indexOf('${{', cursor);\n if (start < 0) break;\n const end = template.indexOf('}}', start + 3);\n if (end < 0) break;\n const expr = template.slice(start + 3, end);\n parts.push(template.slice(cursor, start));\n parts.push(/[\\r\\n\\u2028\\u2029]/.test(expr)\n ? template.slice(start, end + 2) : String(evalExpr(expr.trim(), ctx)));\n cursor = end + 2;\n }\n parts.push(template.slice(cursor));\n return parts.join('');\n}\n\nexport function evalExpr(expr: string, ctx: RenderContext): unknown {\n"
+ },
+ {
+ "file": "clis/instagram/post.js",
+ "before": " if (state.state === 'failed') {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"instagram_post_preview_debug.png\")}` });\n throw makeUploadFailure(`Inspect ${recipeDiagnosticPath(\"instagram_post_preview_debug.png\")}. ` + (state.detail || ''));\n }\n",
+ "after": " if (state.state === 'failed') {\n throw makeUploadFailure(state.detail);\n }\n"
+ },
+ {
+ "file": "clis/instagram/post.js",
+ "before": " }\n await page.screenshot({ path: `${recipeDiagnosticPath(\"instagram_post_preview_debug.png\")}` });\n throw new CommandExecutionError('Instagram image preview did not appear after upload', `The selected file input may not match the active composer; inspect ${recipeDiagnosticPath(\"instagram_post_preview_debug.png\")}`);\n}\n",
+ "after": " }\n throw new CommandExecutionError('Instagram image preview did not appear after upload', 'The selected file input may not match the active composer');\n}\n"
+ },
+ {
+ "file": "clis/instagram/post.js",
+ "before": " }\n await page.screenshot({ path: `${recipeDiagnosticPath(\"instagram_post_caption_debug.png\")}` });\n throw new CommandExecutionError('Instagram caption editor did not appear', `Instagram may have changed the publish flow; inspect ${recipeDiagnosticPath(\"instagram_post_caption_debug.png\")}`);\n}\n",
+ "after": " }\n throw new CommandExecutionError('Instagram caption editor did not appear', 'Instagram may have changed the publish flow');\n}\n"
+ },
+ {
+ "file": "clis/instagram/post.js",
+ "before": " if (!(await hasCaptionEditor(page))) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"instagram_post_caption_debug.png\")}` });\n throw new CommandExecutionError('Instagram caption editor did not appear', `Instagram may have changed the publish flow; inspect ${recipeDiagnosticPath(\"instagram_post_caption_debug.png\")}`);\n }\n",
+ "after": " if (!(await hasCaptionEditor(page))) {\n throw new CommandExecutionError('Instagram caption editor did not appear', 'Instagram may have changed the publish flow');\n }\n"
+ },
+ {
+ "file": "clis/instagram/post.js",
+ "before": " }\n await page.screenshot({ path: `${recipeDiagnosticPath(\"instagram_post_caption_fill_debug.png\")}` });\n throw new CommandExecutionError('Instagram caption did not stick before sharing', `Inspect ${recipeDiagnosticPath(\"instagram_post_caption_fill_debug.png\")} for the caption editor state`);\n}\n",
+ "after": " }\n throw new CommandExecutionError('Instagram caption did not stick before sharing', 'The caption did not match before sharing; posting stopped');\n}\n"
+ },
+ {
+ "file": "clis/instagram/post.js",
+ "before": " if (result?.failed) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"instagram_post_share_debug.png\")}` });\n throw new CommandExecutionError('Instagram post share failed', `Inspect ${recipeDiagnosticPath(\"instagram_post_share_debug.png\")} for the share failure state`);\n }\n",
+ "after": " if (result?.failed) {\n throw new CommandExecutionError('Instagram post share failed', 'Instagram reported a share failure; check the current page before another attempt');\n }\n"
+ },
+ {
+ "file": "clis/instagram/post.js",
+ "before": " }\n await page.screenshot({ path: `${recipeDiagnosticPath(\"instagram_post_share_debug.png\")}` });\n throw new CommandExecutionError('Instagram post share confirmation did not appear', `Inspect ${recipeDiagnosticPath(\"instagram_post_share_debug.png\")} for the final publish state`);\n}\n",
+ "after": " }\n throw new CommandExecutionError('Instagram post share confirmation did not appear', 'The share outcome is unconfirmed; check the current page before another attempt');\n}\n"
+ },
+ {
+ "file": "clis/instagram/reel.js",
+ "before": "import { recipeFileExistsSync, recipeCopySource, recipeOutputPath, recipeTemporaryDirectory, resolveRecipePath } from '@jackwener/opencli/cindy/host';\nimport { recipeDiagnosticPath } from '@jackwener/opencli/cindy/host';\nimport * as fs from 'node:fs';\n",
+ "after": "import { recipeFileExistsSync, recipeCopySource, recipeOutputPath, recipeTemporaryDirectory, resolveRecipePath } from '@jackwener/opencli/cindy/host';\nimport * as fs from 'node:fs';\n"
+ },
+ {
+ "file": "clis/instagram/reel.js",
+ "before": " }\n await page.screenshot({ path: `${recipeDiagnosticPath(\"instagram_reel_preview_debug.png\")}` });\n throw new CommandExecutionError('Instagram reel preview did not appear after upload', lastDetail\n ? `Inspect ${recipeDiagnosticPath(\"instagram_reel_preview_debug.png\")}. Last visible dialog text: ${lastDetail}`\n : `Inspect ${recipeDiagnosticPath(\"instagram_reel_preview_debug.png\")} for the upload state`);\n}\n",
+ "after": " }\n throw new CommandExecutionError('Instagram reel preview did not appear after upload', lastDetail\n ? `Last visible dialog text: ${lastDetail}`\n : 'The upload did not reach the preview stage');\n}\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": "import { resolveRecipePath } from '@jackwener/opencli/cindy/host';\nimport { readRecipeFileSync, recipeDiagnosticPath } from '@jackwener/opencli/cindy/host';\n/**\n",
+ "after": "import { resolveRecipePath } from '@jackwener/opencli/cindy/host';\nimport { readRecipeFileSync } from '@jackwener/opencli/cindy/host';\n/**\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!located.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}` });\n throw new Error(`Could not find ${fieldName} input. Debug screenshot: ${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}`);\n }\n",
+ "after": " if (!located.ok) {\n throw new Error(`Could not find ${fieldName} input.`);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!prepared?.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}` });\n throw new Error(`Could not prepare ${fieldName} input. Debug screenshot: ${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}`);\n }\n",
+ "after": " if (!prepared?.ok) {\n throw new Error(`Could not prepare ${fieldName} input.`);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!result?.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}` });\n const actual = typeof result?.actual === 'string' ? result.actual : '';\n throw new Error(`Failed to set ${fieldName}. Expected \"${text}\", got \"${actual}\". Debug screenshot: ${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}`);\n }\n",
+ "after": " if (!result?.ok) {\n const actual = typeof result?.actual === 'string' ? result.actual : '';\n throw new Error(`Failed to set ${fieldName}. Expected \"${text}\", got \"${actual}\".`);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (state.count < expectedCount) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_media_debug.png\")}` });\n throw new CommandExecutionError(`${label}: expected at least ${expectedCount} visible media item(s), got ${state.count}. ` +\n `Debug screenshot: ${recipeDiagnosticPath(\"xhs_publish_media_debug.png\")}`);\n }\n",
+ "after": " if (state.count < expectedCount) {\n throw new CommandExecutionError(`${label}: expected at least ${expectedCount} visible media item(s), got ${state.count}. `);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!entry?.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_textimage_debug.png\")}` });\n throw new CommandExecutionError(`文字配图: could not click \"${TEXT_IMAGE_ENTRY_LABEL}\" entry. ` +\n `Debug: ${recipeDiagnosticPath(\"xhs_publish_textimage_debug.png\")}`);\n }\n if (!(await waitForFirstCard(page))) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_textimage_debug.png\")}` });\n throw new CommandExecutionError(`文字配图: 写文字 card editor did not appear after clicking \"${TEXT_IMAGE_ENTRY_LABEL}\". ` +\n `Debug: ${recipeDiagnosticPath(\"xhs_publish_textimage_debug.png\")}`);\n }\n",
+ "after": " if (!entry?.ok) {\n throw new CommandExecutionError(`文字配图: could not click \"${TEXT_IMAGE_ENTRY_LABEL}\" entry. `);\n }\n if (!(await waitForFirstCard(page))) {\n throw new CommandExecutionError(`文字配图: 写文字 card editor did not appear after clicking \"${TEXT_IMAGE_ENTRY_LABEL}\". `);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!added) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_addcard_debug.png\")}` });\n throw new CommandExecutionError(`文字配图: new card editor #${i + 1} did not render after \"${ADD_CARD_LABEL}\". ` +\n `Debug: ${recipeDiagnosticPath(\"xhs_publish_addcard_debug.png\")}`);\n }\n",
+ "after": " if (!added) {\n throw new CommandExecutionError(`文字配图: new card editor #${i + 1} did not render after \"${ADD_CARD_LABEL}\". `);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!generated) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_generate_debug.png\")}` });\n throw new CommandExecutionError(`文字配图: \"${GENERATE_LABEL}\" did not advance to the 预览图片 step. ` +\n `Debug: ${recipeDiagnosticPath(\"xhs_publish_generate_debug.png\")}`);\n }\n",
+ "after": " if (!generated) {\n throw new CommandExecutionError(`文字配图: \"${GENERATE_LABEL}\" did not advance to the 预览图片 step. `);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!next?.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_next_debug.png\")}` });\n throw new CommandExecutionError(`文字配图: could not click \"${PREVIEW_NEXT_LABEL}\". ` +\n `Debug: ${recipeDiagnosticPath(\"xhs_publish_next_debug.png\")}`);\n }\n",
+ "after": " if (!next?.ok) {\n throw new CommandExecutionError(`文字配图: could not click \"${PREVIEW_NEXT_LABEL}\". `);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (surface.state === 'video_surface') {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_tab_debug.png\")}` });\n const detail = tabResult?.ok\n",
+ "after": " if (surface.state === 'video_surface') {\n const detail = tabResult?.ok\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " throw new Error('Still on the video publish page after trying to select 图文. ' +\n `Details: ${detail}. Debug screenshot: ${recipeDiagnosticPath(\"xhs_publish_tab_debug.png\")}`);\n }\n",
+ "after": " throw new Error('Still on the video publish page after trying to select 图文. ' +\n `Details: ${detail}.`);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!upload.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_upload_debug.png\")}` });\n throw new CommandExecutionError(`Image injection failed: ${upload.error ?? 'unknown'}. ` +\n `Debug screenshot: ${recipeDiagnosticPath(\"xhs_publish_upload_debug.png\")}`);\n }\n",
+ "after": " if (!upload.ok) {\n throw new CommandExecutionError(`Image injection failed: ${upload.error ?? 'unknown'}. `);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!formReady) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_form_debug.png\")}` });\n throw new CommandExecutionError('Editing form did not appear after image acquisition. The page layout may have changed. ' +\n `Debug screenshot: ${recipeDiagnosticPath(\"xhs_publish_form_debug.png\")}`);\n }\n",
+ "after": " if (!formReady) {\n throw new CommandExecutionError('Editing form did not appear after image acquisition. The page layout may have changed. ');\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!upload.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_append_debug.png\")}` });\n throw new CommandExecutionError(`Appending images failed: ${upload.error ?? 'unknown'}. ` +\n `Debug screenshot: ${recipeDiagnosticPath(\"xhs_publish_append_debug.png\")}`);\n }\n",
+ "after": " if (!upload.ok) {\n throw new CommandExecutionError(`Appending images failed: ${upload.error ?? 'unknown'}. `);\n }\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " if (!invokeResult?.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"xhs_publish_submit_debug.png\")}` });\n const viaClause = invokeResult?.via ? ` (via=${invokeResult.via})` : '';\n",
+ "after": " if (!invokeResult?.ok) {\n const viaClause = invokeResult?.via ? ` (via=${invokeResult.via})` : '';\n"
+ },
+ {
+ "file": "clis/xiaohongshu/publish.js",
+ "before": " const lastMethodClause = invokeResult?.lastMethodError ? `, lastMethodError=${invokeResult.lastMethodError}` : '';\n throw new Error(`Could not trigger \"${actionLabels[0]}\" action${viaClause}${errorClause}${lastMethodClause}. ` +\n `Debug screenshot: ${recipeDiagnosticPath(\"xhs_publish_submit_debug.png\")}`);\n }\n",
+ "after": " const lastMethodClause = invokeResult?.lastMethodError ? `, lastMethodError=${invokeResult.lastMethodError}` : '';\n throw new Error(`Could not trigger \"${actionLabels[0]}\" action${viaClause}${errorClause}${lastMethodClause}. `);\n }\n"
+ },
+ {
+ "file": "clis/wechat-channels/publish.js",
+ "before": "import { resolveRecipePath, statRecipeFileSync } from '@jackwener/opencli/cindy/host';\nimport { readRecipeFileSync, recipeDiagnosticPath } from '@jackwener/opencli/cindy/host';\n/**\n",
+ "after": "import { resolveRecipePath, statRecipeFileSync } from '@jackwener/opencli/cindy/host';\nimport { readRecipeFileSync } from '@jackwener/opencli/cindy/host';\n/**\n"
+ },
+ {
+ "file": "clis/wechat-channels/publish.js",
+ "before": " if (!result?.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"wechat-channels_publish_upload_debug.png\")}` });\n throw new CommandExecutionError(`视频文件注入失败: ${result?.error ?? 'unknown'}\\n截图已保存到 ${recipeDiagnosticPath(\"wechat-channels_publish_upload_debug.png\")}`);\n }\n",
+ "after": " if (!result?.ok) {\n throw new CommandExecutionError(`视频文件注入失败: ${result?.error ?? 'unknown'}`);\n }\n"
+ },
+ {
+ "file": "clis/wechat-channels/publish.js",
+ "before": " if (!result?.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(`wechat-channels_publish_${fieldName}_debug.png`)}` });\n throw new CommandExecutionError(\n `找不到 ${fieldName} 输入框,截图已保存到 ${recipeDiagnosticPath(`wechat-channels_publish_${fieldName}_debug.png`)}`\n );\n",
+ "after": " if (!result?.ok) {\n throw new CommandExecutionError(\n `找不到 ${fieldName} 输入框`\n );\n"
+ },
+ {
+ "file": "clis/wechat-channels/publish.js",
+ "before": " if (!result?.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"wechat-channels_schedule_debug.png\")}` });\n const reason = result?.reason ? String(result.reason) : 'empty picker result';\n throw new CommandExecutionError(\n `定时设置失败 (${reason}),截图: ${recipeDiagnosticPath(\"wechat-channels_schedule_debug.png\")}`,\n );\n",
+ "after": " if (!result?.ok) {\n const reason = result?.reason ? String(result.reason) : 'empty picker result';\n throw new CommandExecutionError(\n `定时设置失败 (${reason})`,\n );\n"
+ },
+ {
+ "file": "clis/wechat-channels/publish.js",
+ "before": " if (!clicked?.ok) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"wechat-channels_publish_submit_debug.png\")}` });\n throw new CommandExecutionError(\n `找不到\"${labels[0]}\"按钮(按钮可能被禁用或表单未完成),` +\n `截图已保存到 ${recipeDiagnosticPath(\"wechat-channels_publish_submit_debug.png\")}`\n );\n",
+ "after": " if (!clicked?.ok) {\n throw new CommandExecutionError(\n `找不到\"${labels[0]}\"按钮(按钮可能被禁用或表单未完成)`\n );\n"
+ },
+ {
+ "file": "clis/wechat-channels/publish.js",
+ "before": " if (!isSuccess) {\n await page.screenshot({ path: `${recipeDiagnosticPath(\"wechat-channels_publish_result_debug.png\")}` });\n throw new CommandExecutionError(\n `未能验证${isDraft ? '草稿保存' : '发布'}成功,截图已保存到 ${recipeDiagnosticPath(\"wechat-channels_publish_result_debug.png\")}`,\n `url=${finalUrl || ''} message=${successMsg || ''}`,\n",
+ "after": " if (!isSuccess) {\n throw new CommandExecutionError(\n `未能验证${isDraft ? '草稿保存' : '发布'}成功`,\n `url=${finalUrl || ''} message=${successMsg || ''}`,\n"
}
]
diff --git a/packages/opencli-vendor/clis/instagram/post.js b/packages/opencli-vendor/clis/instagram/post.js
index 2363acd339..b54475c41e 100644
--- a/packages/opencli-vendor/clis/instagram/post.js
+++ b/packages/opencli-vendor/clis/instagram/post.js
@@ -774,14 +774,12 @@ async function waitForPreview(page, maxWaitSeconds = 12) {
if (state.state === 'preview')
return;
if (state.state === 'failed') {
- await page.screenshot({ path: `${recipeDiagnosticPath("instagram_post_preview_debug.png")}` });
- throw makeUploadFailure(`Inspect ${recipeDiagnosticPath("instagram_post_preview_debug.png")}. ` + (state.detail || ''));
+ throw makeUploadFailure(state.detail);
}
if (attempt < attempts - 1)
await page.wait({ time: 1 });
}
- await page.screenshot({ path: `${recipeDiagnosticPath("instagram_post_preview_debug.png")}` });
- throw new CommandExecutionError('Instagram image preview did not appear after upload', `The selected file input may not match the active composer; inspect ${recipeDiagnosticPath("instagram_post_preview_debug.png")}`);
+ throw new CommandExecutionError('Instagram image preview did not appear after upload', 'The selected file input may not match the active composer');
}
async function waitForPreviewMaybe(page, maxWaitSeconds = 4) {
const attempts = Math.max(1, Math.ceil(maxWaitSeconds * 2));
@@ -961,13 +959,11 @@ async function advanceToCaptionEditor(page) {
throw makeUploadFailure(uploadState.detail);
}
}
- await page.screenshot({ path: `${recipeDiagnosticPath("instagram_post_caption_debug.png")}` });
- throw new CommandExecutionError('Instagram caption editor did not appear', `Instagram may have changed the publish flow; inspect ${recipeDiagnosticPath("instagram_post_caption_debug.png")}`);
+ throw new CommandExecutionError('Instagram caption editor did not appear', 'Instagram may have changed the publish flow');
}
async function waitForCaptionEditor(page) {
if (!(await hasCaptionEditor(page))) {
- await page.screenshot({ path: `${recipeDiagnosticPath("instagram_post_caption_debug.png")}` });
- throw new CommandExecutionError('Instagram caption editor did not appear', `Instagram may have changed the publish flow; inspect ${recipeDiagnosticPath("instagram_post_caption_debug.png")}`);
+ throw new CommandExecutionError('Instagram caption editor did not appear', 'Instagram may have changed the publish flow');
}
}
async function rethrowUploadFailureIfPresent(page, originalError) {
@@ -1237,16 +1233,14 @@ async function ensureCaptionFilled(page, content) {
await page.wait({ time: 0.5 });
}
}
- await page.screenshot({ path: `${recipeDiagnosticPath("instagram_post_caption_fill_debug.png")}` });
- throw new CommandExecutionError('Instagram caption did not stick before sharing', `Inspect ${recipeDiagnosticPath("instagram_post_caption_fill_debug.png")} for the caption editor state`);
+ throw new CommandExecutionError('Instagram caption did not stick before sharing', 'The caption did not match before sharing; posting stopped');
}
async function waitForPublishSuccess(page) {
let settledStreak = 0;
for (let attempt = 0; attempt < 90; attempt++) {
const result = await page.evaluate(buildPublishStatusProbeJs());
if (result?.failed) {
- await page.screenshot({ path: `${recipeDiagnosticPath("instagram_post_share_debug.png")}` });
- throw new CommandExecutionError('Instagram post share failed', `Inspect ${recipeDiagnosticPath("instagram_post_share_debug.png")} for the share failure state`);
+ throw new CommandExecutionError('Instagram post share failed', 'Instagram reported a share failure; check the current page before another attempt');
}
if (result?.ok) {
return result.url || '';
@@ -1263,8 +1257,7 @@ async function waitForPublishSuccess(page) {
await page.wait({ time: 1 });
}
}
- await page.screenshot({ path: `${recipeDiagnosticPath("instagram_post_share_debug.png")}` });
- throw new CommandExecutionError('Instagram post share confirmation did not appear', `Inspect ${recipeDiagnosticPath("instagram_post_share_debug.png")} for the final publish state`);
+ throw new CommandExecutionError('Instagram post share confirmation did not appear', 'The share outcome is unconfirmed; check the current page before another attempt');
}
async function resolveProfileUrl(page, currentUserId = '') {
if (currentUserId) {
diff --git a/packages/opencli-vendor/clis/instagram/reel.js b/packages/opencli-vendor/clis/instagram/reel.js
index 66fbf0d87f..915bc15da8 100644
--- a/packages/opencli-vendor/clis/instagram/reel.js
+++ b/packages/opencli-vendor/clis/instagram/reel.js
@@ -1,5 +1,4 @@
import { recipeFileExistsSync, recipeCopySource, recipeOutputPath, recipeTemporaryDirectory, resolveRecipePath } from '@jackwener/opencli/cindy/host';
-import { recipeDiagnosticPath } from '@jackwener/opencli/cindy/host';
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
@@ -217,10 +216,9 @@ async function waitForVideoPreview(page, maxWaitSeconds = 20) {
if (attempt < maxWaitSeconds * 2 - 1)
await page.wait({ time: 0.5 });
}
- await page.screenshot({ path: `${recipeDiagnosticPath("instagram_reel_preview_debug.png")}` });
throw new CommandExecutionError('Instagram reel preview did not appear after upload', lastDetail
- ? `Inspect ${recipeDiagnosticPath("instagram_reel_preview_debug.png")}. Last visible dialog text: ${lastDetail}`
- : `Inspect ${recipeDiagnosticPath("instagram_reel_preview_debug.png")} for the upload state`);
+ ? `Last visible dialog text: ${lastDetail}`
+ : 'The upload did not reach the preview stage');
}
async function clickAction(page, labels, scope = 'any') {
const result = await page.evaluate(buildClickActionJs(labels, scope));
diff --git a/packages/opencli-vendor/clis/wechat-channels/publish.js b/packages/opencli-vendor/clis/wechat-channels/publish.js
index 9bb98f5416..4e42133b3b 100644
--- a/packages/opencli-vendor/clis/wechat-channels/publish.js
+++ b/packages/opencli-vendor/clis/wechat-channels/publish.js
@@ -1,5 +1,5 @@
import { resolveRecipePath, statRecipeFileSync } from '@jackwener/opencli/cindy/host';
-import { readRecipeFileSync, recipeDiagnosticPath } from '@jackwener/opencli/cindy/host';
+import { readRecipeFileSync } from '@jackwener/opencli/cindy/host';
/**
* WeChat Channels (视频号) publish — UI automation for WeChat Video Channels creator center.
*
@@ -257,8 +257,7 @@ async function uploadFile(page, absPath) {
`);
if (!result?.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath("wechat-channels_publish_upload_debug.png")}` });
- throw new CommandExecutionError(`视频文件注入失败: ${result?.error ?? 'unknown'}\n截图已保存到 ${recipeDiagnosticPath("wechat-channels_publish_upload_debug.png")}`);
+ throw new CommandExecutionError(`视频文件注入失败: ${result?.error ?? 'unknown'}`);
}
}
@@ -368,9 +367,8 @@ async function fillField(page, selectors, text, fieldName) {
`);
if (!result?.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath(`wechat-channels_publish_${fieldName}_debug.png`)}` });
throw new CommandExecutionError(
- `找不到 ${fieldName} 输入框,截图已保存到 ${recipeDiagnosticPath(`wechat-channels_publish_${fieldName}_debug.png`)}`
+ `找不到 ${fieldName} 输入框`
);
}
}
@@ -503,10 +501,9 @@ async function setScheduleTime(page, dt) {
`);
if (!result?.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath("wechat-channels_schedule_debug.png")}` });
const reason = result?.reason ? String(result.reason) : 'empty picker result';
throw new CommandExecutionError(
- `定时设置失败 (${reason}),截图: ${recipeDiagnosticPath("wechat-channels_schedule_debug.png")}`,
+ `定时设置失败 (${reason})`,
);
}
@@ -546,10 +543,8 @@ async function clickPublish(page, isDraft) {
`);
if (!clicked?.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath("wechat-channels_publish_submit_debug.png")}` });
throw new CommandExecutionError(
- `找不到"${labels[0]}"按钮(按钮可能被禁用或表单未完成),` +
- `截图已保存到 ${recipeDiagnosticPath("wechat-channels_publish_submit_debug.png")}`
+ `找不到"${labels[0]}"按钮(按钮可能被禁用或表单未完成)`
);
}
return clicked;
@@ -696,9 +691,8 @@ cli({
const isSuccess = submitSucceeded({ isDraft, finalUrl, successMsg });
if (!isSuccess) {
- await page.screenshot({ path: `${recipeDiagnosticPath("wechat-channels_publish_result_debug.png")}` });
throw new CommandExecutionError(
- `未能验证${isDraft ? '草稿保存' : '发布'}成功,截图已保存到 ${recipeDiagnosticPath("wechat-channels_publish_result_debug.png")}`,
+ `未能验证${isDraft ? '草稿保存' : '发布'}成功`,
`url=${finalUrl || ''} message=${successMsg || ''}`,
);
}
diff --git a/packages/opencli-vendor/clis/xiaohongshu/publish.js b/packages/opencli-vendor/clis/xiaohongshu/publish.js
index 1ae4deb9e1..9bad3b3cf8 100644
--- a/packages/opencli-vendor/clis/xiaohongshu/publish.js
+++ b/packages/opencli-vendor/clis/xiaohongshu/publish.js
@@ -1,6 +1,6 @@
import { recipeFileExistsSync, recipeOutputPath } from '@jackwener/opencli/cindy/host';
import { resolveRecipePath } from '@jackwener/opencli/cindy/host';
-import { readRecipeFileSync, recipeDiagnosticPath } from '@jackwener/opencli/cindy/host';
+import { readRecipeFileSync } from '@jackwener/opencli/cindy/host';
/**
* Xiaohongshu 图文笔记 publisher — creator center UI automation.
*
@@ -272,8 +272,7 @@ async function fillField(page, selectors, text, fieldName) {
})(${JSON.stringify(selectors)})
`);
if (!located.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}` });
- throw new Error(`Could not find ${fieldName} input. Debug screenshot: ${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}`);
+ throw new Error(`Could not find ${fieldName} input.`);
}
const applyInPage = () => page.evaluate(`
((selector, expectedText) => {
@@ -364,8 +363,7 @@ async function fillField(page, selectors, text, fieldName) {
})(${JSON.stringify(located.sel)}, ${JSON.stringify(text)})
`);
if (!prepared?.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}` });
- throw new Error(`Could not prepare ${fieldName} input. Debug screenshot: ${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}`);
+ throw new Error(`Could not prepare ${fieldName} input.`);
}
try {
await page.insertText(text);
@@ -402,9 +400,8 @@ async function fillField(page, selectors, text, fieldName) {
result = await applyInPage();
}
if (!result?.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}` });
const actual = typeof result?.actual === 'string' ? result.actual : '';
- throw new Error(`Failed to set ${fieldName}. Expected "${text}", got "${actual}". Debug screenshot: ${recipeDiagnosticPath(`xhs_publish_${fieldName}_debug.png`)}`);
+ throw new Error(`Failed to set ${fieldName}. Expected "${text}", got "${actual}".`);
}
}
/**
@@ -1039,9 +1036,7 @@ async function assertComposerMediaCount(page, expectedCount, label) {
throw new CommandExecutionError(`${label}: could not verify current composer media count`);
}
if (state.count < expectedCount) {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_media_debug.png")}` });
- throw new CommandExecutionError(`${label}: expected at least ${expectedCount} visible media item(s), got ${state.count}. ` +
- `Debug screenshot: ${recipeDiagnosticPath("xhs_publish_media_debug.png")}`);
+ throw new CommandExecutionError(`${label}: expected at least ${expectedCount} visible media item(s), got ${state.count}. `);
}
}
/**
@@ -1051,38 +1046,28 @@ async function assertComposerMediaCount(page, expectedCount, label) {
async function runTextImageFlow(page, cards, cardStyle) {
const entry = await clickByText(page, TEXT_IMAGE_ENTRY_LABEL);
if (!entry?.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_textimage_debug.png")}` });
- throw new CommandExecutionError(`文字配图: could not click "${TEXT_IMAGE_ENTRY_LABEL}" entry. ` +
- `Debug: ${recipeDiagnosticPath("xhs_publish_textimage_debug.png")}`);
+ throw new CommandExecutionError(`文字配图: could not click "${TEXT_IMAGE_ENTRY_LABEL}" entry. `);
}
if (!(await waitForFirstCard(page))) {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_textimage_debug.png")}` });
- throw new CommandExecutionError(`文字配图: 写文字 card editor did not appear after clicking "${TEXT_IMAGE_ENTRY_LABEL}". ` +
- `Debug: ${recipeDiagnosticPath("xhs_publish_textimage_debug.png")}`);
+ throw new CommandExecutionError(`文字配图: 写文字 card editor did not appear after clicking "${TEXT_IMAGE_ENTRY_LABEL}". `);
}
for (let i = 0; i < cards.length; i++) {
if (i > 0) {
const added = await addCard(page, i + 1);
if (!added) {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_addcard_debug.png")}` });
- throw new CommandExecutionError(`文字配图: new card editor #${i + 1} did not render after "${ADD_CARD_LABEL}". ` +
- `Debug: ${recipeDiagnosticPath("xhs_publish_addcard_debug.png")}`);
+ throw new CommandExecutionError(`文字配图: new card editor #${i + 1} did not render after "${ADD_CARD_LABEL}". `);
}
}
await fillCard(page, cards[i], i);
}
const generated = await clickGenerate(page);
if (!generated) {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_generate_debug.png")}` });
- throw new CommandExecutionError(`文字配图: "${GENERATE_LABEL}" did not advance to the 预览图片 step. ` +
- `Debug: ${recipeDiagnosticPath("xhs_publish_generate_debug.png")}`);
+ throw new CommandExecutionError(`文字配图: "${GENERATE_LABEL}" did not advance to the 预览图片 step. `);
}
const appliedStyle = await selectCardStyle(page, cardStyle);
const next = await clickByText(page, PREVIEW_NEXT_LABEL);
if (!next?.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_next_debug.png")}` });
- throw new CommandExecutionError(`文字配图: could not click "${PREVIEW_NEXT_LABEL}". ` +
- `Debug: ${recipeDiagnosticPath("xhs_publish_next_debug.png")}`);
+ throw new CommandExecutionError(`文字配图: could not click "${PREVIEW_NEXT_LABEL}". `);
}
await page.wait({ time: 2 }); // editor render
return appliedStyle;
@@ -1230,12 +1215,11 @@ cli({
const tabResult = await selectImageTextTab(page);
const surface = await waitForPublishSurfaceState(page, tabResult?.ok ? 5_000 : 2_000);
if (surface.state === 'video_surface') {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_tab_debug.png")}` });
const detail = tabResult?.ok
? `clicked "${tabResult.text}"`
: `visible candidates: ${(tabResult?.visibleTexts || []).join(' | ') || 'none'}`;
throw new Error('Still on the video publish page after trying to select 图文. ' +
- `Details: ${detail}. Debug screenshot: ${recipeDiagnosticPath("xhs_publish_tab_debug.png")}`);
+ `Details: ${detail}.`);
}
// ── Step 3: Acquire images — text-image generation and/or upload ──────────
let appliedCardStyle = cardStyle;
@@ -1246,9 +1230,7 @@ cli({
else {
const upload = await uploadImages(page, absImagePaths);
if (!upload.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_upload_debug.png")}` });
- throw new CommandExecutionError(`Image injection failed: ${upload.error ?? 'unknown'}. ` +
- `Debug screenshot: ${recipeDiagnosticPath("xhs_publish_upload_debug.png")}`);
+ throw new CommandExecutionError(`Image injection failed: ${upload.error ?? 'unknown'}. `);
}
await page.wait({ time: UPLOAD_SETTLE_MS / 1_000 });
await waitForUploads(page);
@@ -1256,9 +1238,7 @@ cli({
// ── Step 3b: Wait for editor form to render ───────────────────────────────
const formReady = await waitForEditForm(page);
if (!formReady) {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_form_debug.png")}` });
- throw new CommandExecutionError('Editing form did not appear after image acquisition. The page layout may have changed. ' +
- `Debug screenshot: ${recipeDiagnosticPath("xhs_publish_form_debug.png")}`);
+ throw new CommandExecutionError('Editing form did not appear after image acquisition. The page layout may have changed. ');
}
if (isTextImage) {
await assertComposerMediaCount(page, cards.length, '文字配图 generated images');
@@ -1267,9 +1247,7 @@ cli({
if (isTextImage && absImagePaths.length > 0) {
const upload = await uploadImages(page, absImagePaths);
if (!upload.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_append_debug.png")}` });
- throw new CommandExecutionError(`Appending images failed: ${upload.error ?? 'unknown'}. ` +
- `Debug screenshot: ${recipeDiagnosticPath("xhs_publish_append_debug.png")}`);
+ throw new CommandExecutionError(`Appending images failed: ${upload.error ?? 'unknown'}. `);
}
await page.wait({ time: UPLOAD_SETTLE_MS / 1_000 });
await waitForUploads(page);
@@ -1405,12 +1383,10 @@ cli({
}
}
if (!invokeResult?.ok) {
- await page.screenshot({ path: `${recipeDiagnosticPath("xhs_publish_submit_debug.png")}` });
const viaClause = invokeResult?.via ? ` (via=${invokeResult.via})` : '';
const errorClause = invokeResult?.error ? `, error=${invokeResult.error}` : '';
const lastMethodClause = invokeResult?.lastMethodError ? `, lastMethodError=${invokeResult.lastMethodError}` : '';
- throw new Error(`Could not trigger "${actionLabels[0]}" action${viaClause}${errorClause}${lastMethodClause}. ` +
- `Debug screenshot: ${recipeDiagnosticPath("xhs_publish_submit_debug.png")}`);
+ throw new Error(`Could not trigger "${actionLabels[0]}" action${viaClause}${errorClause}${lastMethodClause}. `);
}
// ── Step 8: Verify success ─────────────────────────────────────────────────
await page.wait({ time: 4 });