@gobing-ai/knowledge-kit 0.1.22 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/index.js +282 -147
- package/package.json +5 -5
- package/plugins/generations/content-gen/dist/index.js +9 -9
- package/plugins/generations/core-facts-gen/dist/index.js +12 -12
- package/plugins/generations/daily-article-gen/dist/index.js +12 -12
- package/plugins/generations/dailynews-gen/dist/index.js +11 -11
- package/plugins/generations/dailynews-gen/src/script-plan.ts +2 -2
- package/plugins/generations/episode-plan-gen/dist/index.js +12 -12
- package/plugins/generations/gemini-tts/dist/index.js +56 -16
- package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
- package/plugins/generations/image-gen/dist/index.js +9 -9
- package/plugins/generations/music-gen/README.md +2 -2
- package/plugins/generations/music-gen/dist/index.js +62 -26
- package/plugins/generations/music-gen/presets/formats/song.yaml +6 -1
- package/plugins/generations/music-gen/presets/themes/synthwave.yaml +6 -1
- package/plugins/generations/music-gen/src/adapter/instance.ts +34 -11
- package/plugins/generations/music-gen/src/presets.ts +36 -3
- package/plugins/generations/news-report-gen/dist/index.js +12 -12
- package/plugins/generations/omni-voice-gen/uv.toml +5 -0
- package/plugins/generations/vibe-voice-tts/README.md +64 -0
- package/plugins/generations/vibe-voice-tts/dist/index.js +14259 -0
- package/plugins/generations/vibe-voice-tts/package.json +16 -0
- package/plugins/generations/vibe-voice-tts/plugin.json +6 -0
- package/plugins/generations/vibe-voice-tts/profiles.json +10 -0
- package/plugins/generations/vibe-voice-tts/pyproject.toml +9 -0
- package/plugins/generations/vibe-voice-tts/python/worker.py +566 -0
- package/plugins/generations/vibe-voice-tts/src/index.ts +88 -0
- package/plugins/generations/vibe-voice-tts/src/vibevoice-client.ts +828 -0
- package/plugins/generations/vibe-voice-tts/tsconfig.json +8 -0
- package/plugins/generations/vibe-voice-tts/uv.lock +1767 -0
- package/plugins/generations/vibe-voice-tts/uv.toml +4 -0
- package/plugins/generations/voice-gen/dist/index.js +40 -10
- package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
- package/plugins/generations/voxcpm-tts/dist/index.js +90 -18
- package/plugins/generations/voxcpm-tts/python/worker.py +9 -0
- package/plugins/generations/voxcpm-tts/src/index.ts +41 -0
- package/plugins/generations/voxcpm-tts/src/voxcpm-client.ts +32 -11
- package/plugins/generations/voxcpm-tts/uv.toml +5 -0
- package/plugins/ingestions/aihot-ingest/dist/index.js +12 -12
- package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
- package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
- package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
- package/plugins/ingestions/web-search/dist/index.js +10 -10
- package/plugins/kk/README.md +21 -0
- package/plugins/kk/decisions/kk-safety.yaml +5 -2
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +16 -16
- package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +12 -1
- package/plugins/kk/scripts/cover-compositor.ts +104 -26
- package/plugins/kk/scripts/daily-stages.ts +481 -63
- package/plugins/kk/scripts/kk-workflow-stages.ts +218 -17
- package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
- package/plugins/kk/scripts/series-names.ts +16 -3
- package/plugins/kk/skills/news-editorial/SKILL.md +1 -1
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +4 -3
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -5
- package/plugins/kk/workflows/kk-daily-safety.yaml +12 -10
- package/plugins/kk/workflows/kk-music.yaml +20 -16
- package/plugins/kk/workflows/kk-news-generate.yaml +26 -3
- package/plugins/kk/workflows/kk-publish.yaml +4 -1
- package/plugins/publishings/bilibili-pub/dist/index.js +22 -22
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/cnblogs-pub/dist/index.js +22 -22
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/csdn-pub/dist/index.js +22 -22
- package/plugins/publishings/csdn-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/emdash-pub/dist/index.js +9 -9
- package/plugins/publishings/infoq-pub/dist/index.js +22 -22
- package/plugins/publishings/infoq-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/jike-pub/dist/index.js +22 -22
- package/plugins/publishings/jike-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/juejin-pub/dist/index.js +22 -22
- package/plugins/publishings/juejin-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/linkedin-pub/dist/index.js +133 -33
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +27 -22
- package/plugins/publishings/linkedin-pub/src/index.ts +192 -18
- package/plugins/publishings/medium-pub/dist/index.js +9 -9
- package/plugins/publishings/podcast-pub/dist/index.js +240 -37
- package/plugins/publishings/podcast-pub/src/index.ts +154 -3
- package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
- package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
- package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
- package/plugins/publishings/qiita-pub/dist/index.js +9 -9
- package/plugins/publishings/shipinhao-pub/dist/index.js +23 -23
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +23 -23
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +2 -1
- package/plugins/publishings/sspai-pub/dist/index.js +22 -22
- package/plugins/publishings/sspai-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/substack-pub/dist/index.js +22 -22
- package/plugins/publishings/substack-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/surfdash-pub/dist/index.js +207 -95
- package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
- package/plugins/publishings/surfdash-pub/src/index.ts +101 -76
- package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
- package/plugins/publishings/surfdash-pub/src/patch.ts +49 -26
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
- package/plugins/publishings/threads-pub/dist/index.js +83 -27
- package/plugins/publishings/threads-pub/dist/profile-check.js +34 -23
- package/plugins/publishings/threads-pub/src/post-rail.ts +121 -4
- package/plugins/publishings/wechatmp-pub/dist/index.js +274 -98
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +27 -23
- package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +117 -13
- package/plugins/publishings/wechatmp-pub/src/flow.ts +183 -43
- package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
- package/plugins/publishings/weibo-pub/dist/index.js +22 -22
- package/plugins/publishings/weibo-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/x-pub/dist/index.js +113 -32
- package/plugins/publishings/x-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/x-pub/src/post-rail.ts +155 -20
- package/plugins/publishings/xhs-pub/dist/index.js +22 -22
- package/plugins/publishings/xhs-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +22 -22
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/zenn-pub/dist/index.js +9 -9
|
@@ -4845,7 +4845,7 @@ var init_zod = __esm(() => {
|
|
|
4845
4845
|
init_external();
|
|
4846
4846
|
});
|
|
4847
4847
|
|
|
4848
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4848
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
|
|
4849
4849
|
var ErrorCode;
|
|
4850
4850
|
var init_errors3 = __esm(() => {
|
|
4851
4851
|
ErrorCode = {
|
|
@@ -4856,7 +4856,7 @@ var init_errors3 = __esm(() => {
|
|
|
4856
4856
|
};
|
|
4857
4857
|
});
|
|
4858
4858
|
|
|
4859
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4859
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
|
|
4860
4860
|
var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
|
|
4861
4861
|
var init_api_response = __esm(() => {
|
|
4862
4862
|
init_errors3();
|
|
@@ -4879,10 +4879,10 @@ var init_api_response = __esm(() => {
|
|
|
4879
4879
|
CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
|
|
4880
4880
|
});
|
|
4881
4881
|
|
|
4882
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4882
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
|
|
4883
4883
|
var init_cursor = () => {};
|
|
4884
4884
|
|
|
4885
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4885
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/env.js
|
|
4886
4886
|
function getEnvVar(name, fallback) {
|
|
4887
4887
|
const raw = process.env[name];
|
|
4888
4888
|
return raw === undefined ? fallback : raw;
|
|
@@ -4891,10 +4891,10 @@ function getEnvVars() {
|
|
|
4891
4891
|
return process.env;
|
|
4892
4892
|
}
|
|
4893
4893
|
|
|
4894
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4894
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
|
|
4895
4895
|
var init_event_severity = () => {};
|
|
4896
4896
|
|
|
4897
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4897
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/object.js
|
|
4898
4898
|
function isPlainObject2(value) {
|
|
4899
4899
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4900
4900
|
}
|
|
@@ -4912,7 +4912,7 @@ function deepMerge(target, source) {
|
|
|
4912
4912
|
return result;
|
|
4913
4913
|
}
|
|
4914
4914
|
|
|
4915
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4915
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
|
|
4916
4916
|
function processStream(name) {
|
|
4917
4917
|
const proc = globalThis.process;
|
|
4918
4918
|
const stream = proc?.[name];
|
|
@@ -4933,7 +4933,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
|
|
|
4933
4933
|
}
|
|
4934
4934
|
var defaultStdoutTarget, defaultStderrTarget;
|
|
4935
4935
|
|
|
4936
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4936
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
|
|
4937
4937
|
var init_dist = __esm(() => {
|
|
4938
4938
|
init_api_response();
|
|
4939
4939
|
init_cursor();
|
|
@@ -11931,7 +11931,7 @@ var init_dist2 = __esm(() => {
|
|
|
11931
11931
|
$visitAsync = visit.visitAsync;
|
|
11932
11932
|
});
|
|
11933
11933
|
|
|
11934
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11934
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
|
|
11935
11935
|
function getProcessEnv() {
|
|
11936
11936
|
return getEnvVars();
|
|
11937
11937
|
}
|
|
@@ -12009,7 +12009,7 @@ var init_config = __esm(() => {
|
|
|
12009
12009
|
};
|
|
12010
12010
|
});
|
|
12011
12011
|
|
|
12012
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12012
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
|
|
12013
12013
|
import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
12014
12014
|
import { dirname, resolve as resolvePath } from "path";
|
|
12015
12015
|
function createNodeFileSystem(root, paths) {
|
|
@@ -12096,7 +12096,7 @@ function findProjectRoot(startDir) {
|
|
|
12096
12096
|
}
|
|
12097
12097
|
var init_file_system_node = () => {};
|
|
12098
12098
|
|
|
12099
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12099
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
|
|
12100
12100
|
var DbModuleNotInstalledError;
|
|
12101
12101
|
var init_db_errors = __esm(() => {
|
|
12102
12102
|
DbModuleNotInstalledError = class DbModuleNotInstalledError extends Error {
|
|
@@ -19307,7 +19307,7 @@ var init_execa = __esm(() => {
|
|
|
19307
19307
|
} = getIpcExport());
|
|
19308
19308
|
});
|
|
19309
19309
|
|
|
19310
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
19310
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
|
|
19311
19311
|
function resolveDeadline(optionTimeout, defaultTimeout) {
|
|
19312
19312
|
if (optionTimeout === null)
|
|
19313
19313
|
return null;
|
|
@@ -19399,7 +19399,7 @@ function ownProcessGroupLifecycle(ownership) {
|
|
|
19399
19399
|
}
|
|
19400
19400
|
var MAX_TIMEOUT_MS = 2147483647, DEFAULT_KILL_GRACE_MS = 5000, GROUP_POLL_INTERVAL_MS = 25, GROUP_KILL_PATIENCE_MS = 2000;
|
|
19401
19401
|
|
|
19402
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
19402
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
|
|
19403
19403
|
import { isatty } from "tty";
|
|
19404
19404
|
function processEventSeverity(reason, exitCode) {
|
|
19405
19405
|
if (reason === "error")
|
|
@@ -19771,7 +19771,7 @@ var init_process_executor = __esm(() => {
|
|
|
19771
19771
|
init_config();
|
|
19772
19772
|
});
|
|
19773
19773
|
|
|
19774
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
19774
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
|
|
19775
19775
|
function getNodeFileSystem() {
|
|
19776
19776
|
if (!_nodeFileSystem)
|
|
19777
19777
|
_nodeFileSystem = createNodeFileSystem();
|
|
@@ -20099,11 +20099,11 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
|
|
|
20099
20099
|
});
|
|
20100
20100
|
}
|
|
20101
20101
|
});
|
|
20102
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
20102
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
|
|
20103
20103
|
init_file_system_node();
|
|
20104
20104
|
init_config();
|
|
20105
20105
|
|
|
20106
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
20106
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
|
|
20107
20107
|
function normalizeSeparators(path) {
|
|
20108
20108
|
return path.replaceAll("\\", "/");
|
|
20109
20109
|
}
|
|
@@ -20161,7 +20161,7 @@ function getProcessCwd() {
|
|
|
20161
20161
|
return globalThis.process?.cwd?.() ?? "/";
|
|
20162
20162
|
}
|
|
20163
20163
|
|
|
20164
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
20164
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
|
|
20165
20165
|
init_runtime_node_bun();
|
|
20166
20166
|
|
|
20167
20167
|
// ../../packages/kk-core/src/render-md.ts
|
|
@@ -20254,7 +20254,7 @@ async function trySelectors(page, selectors, options = {}) {
|
|
|
20254
20254
|
import { join as join5, resolve as resolve5 } from "path";
|
|
20255
20255
|
import { parseArgs } from "util";
|
|
20256
20256
|
|
|
20257
|
-
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.
|
|
20257
|
+
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
|
|
20258
20258
|
class BrowserAutomationError extends Error {
|
|
20259
20259
|
constructor(message, options) {
|
|
20260
20260
|
super(message, options);
|
|
@@ -20303,10 +20303,10 @@ class OperationAbortedError extends BrowserAutomationError {
|
|
|
20303
20303
|
this.name = "OperationAbortedError";
|
|
20304
20304
|
}
|
|
20305
20305
|
}
|
|
20306
|
-
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.
|
|
20306
|
+
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
|
|
20307
20307
|
import { mkdir } from "fs/promises";
|
|
20308
20308
|
|
|
20309
|
-
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.
|
|
20309
|
+
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
|
|
20310
20310
|
function resolveProfileDir(profileDir) {
|
|
20311
20311
|
if (profileDir.trim() === "") {
|
|
20312
20312
|
throw new InvalidProfileDirError;
|
|
@@ -20318,7 +20318,7 @@ function resolveProfileDir(profileDir) {
|
|
|
20318
20318
|
return resolved;
|
|
20319
20319
|
}
|
|
20320
20320
|
|
|
20321
|
-
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.
|
|
20321
|
+
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
|
|
20322
20322
|
var PROFILE_DIR_MODE = 448;
|
|
20323
20323
|
var BUSY_PROFILE_PATTERN = /singleton|already in use|in use by another/i;
|
|
20324
20324
|
var CHROMIUM_MISSING_PATTERN = /playwright install|executable doesn't exist/i;
|
|
@@ -20369,7 +20369,7 @@ function createPersistentLauncher(options = {}) {
|
|
|
20369
20369
|
};
|
|
20370
20370
|
}
|
|
20371
20371
|
|
|
20372
|
-
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.
|
|
20372
|
+
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
|
|
20373
20373
|
var DEFAULT_TIMEOUT_MS = 30000;
|
|
20374
20374
|
var POLL_INTERVAL_MS = 250;
|
|
20375
20375
|
var defaultLauncher;
|
|
@@ -21697,6 +21697,10 @@ async function resolveMediaPath(content, spec) {
|
|
|
21697
21697
|
}
|
|
21698
21698
|
return { path };
|
|
21699
21699
|
}
|
|
21700
|
+
function isLibraryCover(content) {
|
|
21701
|
+
const wechatmp = content.metadata?.wechatmp;
|
|
21702
|
+
return typeof wechatmp === "object" && wechatmp !== null && !Array.isArray(wechatmp) && wechatmp.coverSource === "library";
|
|
21703
|
+
}
|
|
21700
21704
|
async function resolveBodyImages(content) {
|
|
21701
21705
|
const ordered = content.metadata?.images;
|
|
21702
21706
|
if (ordered !== undefined && !Array.isArray(ordered)) {
|
|
@@ -21706,20 +21710,22 @@ async function resolveBodyImages(content) {
|
|
|
21706
21710
|
const cover = typeof content.metadata?.wechatmp === "object" && content.metadata.wechatmp !== null ? content.metadata.wechatmp.coverPath : undefined;
|
|
21707
21711
|
const candidates = [];
|
|
21708
21712
|
if (typeof cover === "string" && cover.length > 0)
|
|
21709
|
-
candidates.push({ path: cover, what: "metadata.wechatmp.coverPath" });
|
|
21713
|
+
candidates.push({ path: cover, what: "metadata.wechatmp.coverPath", coverOnly: true });
|
|
21710
21714
|
const genericCover = content.metadata?.coverImage;
|
|
21711
21715
|
const genericCoverPath = typeof genericCover === "string" ? genericCover : typeof genericCover?.path === "string" ? genericCover.path : undefined;
|
|
21712
21716
|
if (genericCoverPath !== undefined && genericCoverPath.length > 0)
|
|
21713
|
-
candidates.push({ path: genericCoverPath, what: "metadata.coverImage" });
|
|
21717
|
+
candidates.push({ path: genericCoverPath, what: "metadata.coverImage", coverOnly: true });
|
|
21714
21718
|
for (const [index, image] of descriptors.entries()) {
|
|
21715
21719
|
const path = typeof image === "string" ? image : image?.path;
|
|
21716
21720
|
if (typeof path !== "string" || path.length === 0) {
|
|
21717
21721
|
return { error: `images validation: images[${index}] carries no path` };
|
|
21718
21722
|
}
|
|
21719
|
-
candidates.push({ path, what: `metadata.images[${index}]
|
|
21723
|
+
candidates.push({ path, what: `metadata.images[${index}]`, coverOnly: false });
|
|
21720
21724
|
}
|
|
21725
|
+
const skipCoverInBody = isLibraryCover(content);
|
|
21721
21726
|
const paths = [];
|
|
21722
|
-
|
|
21727
|
+
let hasValidatedCover = false;
|
|
21728
|
+
for (const { path, what, coverOnly } of candidates) {
|
|
21723
21729
|
if (!isAbsolute2(path)) {
|
|
21724
21730
|
return { error: `images validation: ${what} must be absolute, got '${path}'` };
|
|
21725
21731
|
}
|
|
@@ -21731,9 +21737,12 @@ async function resolveBodyImages(content) {
|
|
|
21731
21737
|
if (!await createNodeFileSystem().exists(path)) {
|
|
21732
21738
|
return { error: `images validation: ${what} does not exist: '${path}'` };
|
|
21733
21739
|
}
|
|
21734
|
-
|
|
21740
|
+
if (coverOnly)
|
|
21741
|
+
hasValidatedCover = true;
|
|
21742
|
+
if (!(skipCoverInBody && coverOnly))
|
|
21743
|
+
paths.push(path);
|
|
21735
21744
|
}
|
|
21736
|
-
return { paths };
|
|
21745
|
+
return { paths, hasValidatedCover };
|
|
21737
21746
|
}
|
|
21738
21747
|
function deriveDigest(content) {
|
|
21739
21748
|
const explicit = content.metadata?.digest;
|
|
@@ -21811,7 +21820,7 @@ async function validateModeInput(operation, content) {
|
|
|
21811
21820
|
const images = await resolveBodyImages(content);
|
|
21812
21821
|
if (images.error)
|
|
21813
21822
|
return { error: images.error };
|
|
21814
|
-
if ((images.paths ?? []).length === 0) {
|
|
21823
|
+
if ((images.paths ?? []).length === 0 && !(isLibraryCover(content) && images.hasValidatedCover === true)) {
|
|
21815
21824
|
return {
|
|
21816
21825
|
error: "cover validation: \u6587\u7AE0 takes its cover from a body image (\u9ED8\u8BA4\u9996\u56FE\u4E3A\u5C01\u9762) but none was supplied \u2014 set metadata.wechatmp.coverPath, metadata.coverImage or metadata.images[]"
|
|
21817
21826
|
};
|
|
@@ -22140,9 +22149,49 @@ async function evaluateCgiVerdict(page, expression) {
|
|
|
22140
22149
|
function ambiguousSubmission(stage, detail) {
|
|
22141
22150
|
return new WechatCgiDraftError("ambiguous-submission", stage, detail, { ambiguousSubmission: true });
|
|
22142
22151
|
}
|
|
22152
|
+
async function readDraftList(page, session, stage) {
|
|
22153
|
+
const listUrl = buildUrl2(APPMSG_URL, {
|
|
22154
|
+
action: "list_ex",
|
|
22155
|
+
begin: "0",
|
|
22156
|
+
count: "5",
|
|
22157
|
+
token: session.token,
|
|
22158
|
+
lang: "zh_CN",
|
|
22159
|
+
f: "json"
|
|
22160
|
+
});
|
|
22161
|
+
let listVerdict;
|
|
22162
|
+
try {
|
|
22163
|
+
listVerdict = await evaluateCgiVerdict(page, cgiFetchExpression2({
|
|
22164
|
+
url: listUrl,
|
|
22165
|
+
method: "GET",
|
|
22166
|
+
fields: {},
|
|
22167
|
+
maxBytes: MAX_RESPONSE_BYTES2,
|
|
22168
|
+
timeoutMs: REQUEST_TIMEOUT_MS2
|
|
22169
|
+
}));
|
|
22170
|
+
} catch (error) {
|
|
22171
|
+
throw new WechatCgiDraftError("readback-failed", stage, `draft list readback ended before a receipt returned: ${stripQuery2(String(error))}`);
|
|
22172
|
+
}
|
|
22173
|
+
if (listVerdict?.kind !== "ok") {
|
|
22174
|
+
const detail = listVerdict?.kind === "http-status" ? `HTTP ${listVerdict.status}` : listVerdict?.kind === "too-large" ? `${MAX_RESPONSE_BYTES2}-byte bound exceeded` : listVerdict?.kind === "error" ? stripQuery2(listVerdict.detail) : "page returned no usable verdict";
|
|
22175
|
+
throw new WechatCgiDraftError("readback-failed", stage, `draft list readback failed: ${detail}`);
|
|
22176
|
+
}
|
|
22177
|
+
let list;
|
|
22178
|
+
try {
|
|
22179
|
+
list = JSON.parse(listVerdict.text);
|
|
22180
|
+
} catch {
|
|
22181
|
+
throw new WechatCgiDraftError("readback-failed", stage, "draft list receipt is not JSON");
|
|
22182
|
+
}
|
|
22183
|
+
return isRecord2(list) && Array.isArray(list.app_msg_list) ? list.app_msg_list.filter((item) => isRecord2(item)) : [];
|
|
22184
|
+
}
|
|
22185
|
+
function duplicateDraft(existing, title) {
|
|
22186
|
+
const id = existing.app_id !== undefined ? existing.app_id : existing.appmsgid;
|
|
22187
|
+
return new WechatCgiDraftError("duplicate-draft", "pre-create-lookup", `duplicate-draft: appmsgid ${String(id)} already holds "${title}" \u2014 delete it or finish it in the console`);
|
|
22188
|
+
}
|
|
22143
22189
|
async function createWechatArticleDraft(page, session, content, media) {
|
|
22144
|
-
|
|
22190
|
+
const certified = certifyCgiDraft(content);
|
|
22145
22191
|
assertMpOrigin2(page);
|
|
22192
|
+
const existing = (await readDraftList(page, session, "pre-create-lookup")).find((item) => item.title === certified.title);
|
|
22193
|
+
if (existing !== undefined)
|
|
22194
|
+
throw duplicateDraft(existing, certified.title);
|
|
22146
22195
|
const payload = buildCreateArticlePayload(session, content, media);
|
|
22147
22196
|
let createVerdict;
|
|
22148
22197
|
try {
|
|
@@ -22184,38 +22233,8 @@ async function createWechatArticleDraft(page, session, content, media) {
|
|
|
22184
22233
|
if (appMsgId === undefined || !/^-?\d{1,12}$/.test(appMsgId)) {
|
|
22185
22234
|
throw ambiguousSubmission("create-receipt", "create receipt did not return a safe numeric appMsgId");
|
|
22186
22235
|
}
|
|
22187
|
-
const
|
|
22188
|
-
|
|
22189
|
-
begin: "0",
|
|
22190
|
-
count: "5",
|
|
22191
|
-
token: session.token,
|
|
22192
|
-
lang: "zh_CN",
|
|
22193
|
-
f: "json"
|
|
22194
|
-
});
|
|
22195
|
-
let listVerdict;
|
|
22196
|
-
try {
|
|
22197
|
-
listVerdict = await evaluateCgiVerdict(page, cgiFetchExpression2({
|
|
22198
|
-
url: listUrl,
|
|
22199
|
-
method: "GET",
|
|
22200
|
-
fields: {},
|
|
22201
|
-
maxBytes: MAX_RESPONSE_BYTES2,
|
|
22202
|
-
timeoutMs: REQUEST_TIMEOUT_MS2
|
|
22203
|
-
}));
|
|
22204
|
-
} catch (error) {
|
|
22205
|
-
throw new WechatCgiDraftError("readback-failed", "readback", `draft list readback ended before a receipt returned: ${stripQuery2(String(error))}`);
|
|
22206
|
-
}
|
|
22207
|
-
if (listVerdict?.kind !== "ok") {
|
|
22208
|
-
const detail = listVerdict?.kind === "http-status" ? `HTTP ${listVerdict.status}` : listVerdict?.kind === "too-large" ? `${MAX_RESPONSE_BYTES2}-byte bound exceeded` : listVerdict?.kind === "error" ? stripQuery2(listVerdict.detail) : "page returned no usable verdict";
|
|
22209
|
-
throw new WechatCgiDraftError("readback-failed", "readback", `draft list readback failed: ${detail}`);
|
|
22210
|
-
}
|
|
22211
|
-
let list;
|
|
22212
|
-
try {
|
|
22213
|
-
list = JSON.parse(listVerdict.text);
|
|
22214
|
-
} catch {
|
|
22215
|
-
throw new WechatCgiDraftError("readback-failed", "readback", "draft list receipt is not JSON");
|
|
22216
|
-
}
|
|
22217
|
-
const items = isRecord2(list) && Array.isArray(list.app_msg_list) ? list.app_msg_list : [];
|
|
22218
|
-
const confirmed = items.some((item) => isRecord2(item) && item.title === content.title && (String(item.app_id) === appMsgId || String(item.appmsgid) === appMsgId));
|
|
22236
|
+
const items = await readDraftList(page, session, "readback");
|
|
22237
|
+
const confirmed = items.some((item) => item.title === content.title && (String(item.app_id) === appMsgId || String(item.appmsgid) === appMsgId));
|
|
22219
22238
|
if (!confirmed) {
|
|
22220
22239
|
throw new WechatCgiDraftError("readback-failed", "readback", "draft list did not confirm an item matching the created appMsgId and title");
|
|
22221
22240
|
}
|
|
@@ -22723,7 +22742,11 @@ var URL_COMMITTED = `(() => {
|
|
|
22723
22742
|
return checkbox?.checked === true ? area.querySelector('.article_url_setting')?.textContent ?? null : null;
|
|
22724
22743
|
})()`;
|
|
22725
22744
|
var ORIGINAL_DECLARATION = `${DIALOG} label:has(.js_original_type_radio):has-text("\u6587\u5B57\u539F\u521B")`;
|
|
22726
|
-
var ORIGINAL_AGREEMENT =
|
|
22745
|
+
var ORIGINAL_AGREEMENT = [
|
|
22746
|
+
`${DIALOG} label.original_agreement:has(input[type="checkbox"]:not(:checked))`,
|
|
22747
|
+
`${DIALOG} label:has(input[type="checkbox"]:not(:checked)):has-text("\u6211\u5DF2\u9605\u8BFB\u5E76\u540C\u610F") i.weui-desktop-icon-checkbox`,
|
|
22748
|
+
`${DIALOG} label:has(input[type="checkbox"]:not(:checked)):has-text("\u6211\u5DF2\u9605\u8BFB\u5E76\u540C\u610F")`
|
|
22749
|
+
];
|
|
22727
22750
|
var COLLECTION_SETTLE_MS = 1200;
|
|
22728
22751
|
var STEP_RETRY_SETTLE_MS = 1000;
|
|
22729
22752
|
var SWEEP_SETTLE_MS = 400;
|
|
@@ -22735,6 +22758,12 @@ function norm(value) {
|
|
|
22735
22758
|
}
|
|
22736
22759
|
var COMMITTED = {
|
|
22737
22760
|
original: `(() => {
|
|
22761
|
+
const open = document.querySelector('#js_original_open');
|
|
22762
|
+
if (open) {
|
|
22763
|
+
if (open.getClientRects().length === 0) return false;
|
|
22764
|
+
const sw = open.querySelector('input.weui-desktop-switch__input, input[type="checkbox"]');
|
|
22765
|
+
return sw ? sw.checked === true : true;
|
|
22766
|
+
}
|
|
22738
22767
|
const el = [...document.querySelectorAll('#js_original input.weui-desktop-switch__input')]
|
|
22739
22768
|
.find(input => input.parentElement?.getClientRects().length > 0);
|
|
22740
22769
|
return el ? el.checked === true : null;
|
|
@@ -22754,6 +22783,40 @@ var CLAIM_COMMITTED = `(() => {
|
|
|
22754
22783
|
const enabled = checkbox ? checkbox.checked === true : null;
|
|
22755
22784
|
return { enabled, text };
|
|
22756
22785
|
})()`;
|
|
22786
|
+
var REWARD_STATE = `(() => {
|
|
22787
|
+
const rows = [
|
|
22788
|
+
document.querySelector('.js_reward_allow_click'),
|
|
22789
|
+
document.querySelector('.js_reward_open'),
|
|
22790
|
+
document.querySelector('.setting-group__switch.js_reward_open'),
|
|
22791
|
+
].filter((el) => el !== null);
|
|
22792
|
+
if (rows.length === 0) return null;
|
|
22793
|
+
const blockedText = /\u65E0\u6CD5\u5F00\u542F\u8D5E\u8D4F|\u8FD8\u6CA1\u6709\u8D5E\u8D4F\u8D26\u6237|\u524D\u5F80\u5F00\u901A|\u672A\u5F00\u901A/;
|
|
22794
|
+
for (const el of rows) {
|
|
22795
|
+
const text = (el.textContent ?? '').replace(/\\s+/g, ' ').trim();
|
|
22796
|
+
const box = el.getBoundingClientRect();
|
|
22797
|
+
if (blockedText.test(text) || (box.width === 0 && box.height === 0)) {
|
|
22798
|
+
return { clickable: false, blocked: true, text: text.slice(0, 200) };
|
|
22799
|
+
}
|
|
22800
|
+
}
|
|
22801
|
+
return { clickable: true, blocked: false, text: '' };
|
|
22802
|
+
})()`;
|
|
22803
|
+
async function readRewardState(page) {
|
|
22804
|
+
try {
|
|
22805
|
+
const raw = await page.evaluate(REWARD_STATE);
|
|
22806
|
+
if (typeof raw !== "object" || raw === null)
|
|
22807
|
+
return null;
|
|
22808
|
+
const value = raw;
|
|
22809
|
+
if (typeof value.clickable !== "boolean" || typeof value.blocked !== "boolean")
|
|
22810
|
+
return null;
|
|
22811
|
+
return {
|
|
22812
|
+
clickable: value.clickable,
|
|
22813
|
+
blocked: value.blocked,
|
|
22814
|
+
text: typeof value.text === "string" ? value.text : ""
|
|
22815
|
+
};
|
|
22816
|
+
} catch {
|
|
22817
|
+
return null;
|
|
22818
|
+
}
|
|
22819
|
+
}
|
|
22757
22820
|
async function readChecked(page, expression) {
|
|
22758
22821
|
try {
|
|
22759
22822
|
const raw = await page.evaluate(expression);
|
|
@@ -22762,8 +22825,9 @@ async function readChecked(page, expression) {
|
|
|
22762
22825
|
return null;
|
|
22763
22826
|
}
|
|
22764
22827
|
}
|
|
22765
|
-
async function
|
|
22828
|
+
async function enrichArticleDetailed(page, meta) {
|
|
22766
22829
|
const warnings = [];
|
|
22830
|
+
const capabilityWarnings = [];
|
|
22767
22831
|
const str = (key) => typeof meta[key] === "string" ? meta[key] : "";
|
|
22768
22832
|
const on = (key) => meta[key] === true;
|
|
22769
22833
|
const sweep = async () => {
|
|
@@ -22805,7 +22869,9 @@ async function enrichArticle(page, meta) {
|
|
|
22805
22869
|
return "ok";
|
|
22806
22870
|
} catch (error) {
|
|
22807
22871
|
if (error instanceof CapabilityError) {
|
|
22808
|
-
|
|
22872
|
+
const msg = `${name}: ${error.message}`;
|
|
22873
|
+
warnings.push(msg);
|
|
22874
|
+
capabilityWarnings.push(msg);
|
|
22809
22875
|
return "capability";
|
|
22810
22876
|
}
|
|
22811
22877
|
}
|
|
@@ -22833,11 +22899,14 @@ async function enrichArticle(page, meta) {
|
|
|
22833
22899
|
const outcome = await step(name, async () => {
|
|
22834
22900
|
await openRow(ROW_ORIGINAL, "\u539F\u521B\u58F0\u660E");
|
|
22835
22901
|
await clickSelector(page, ORIGINAL_DECLARATION, 5000);
|
|
22836
|
-
const agreement = await trySelectors(page,
|
|
22837
|
-
if (agreement.found) {
|
|
22838
|
-
await clickSelector(page,
|
|
22902
|
+
const agreement = await trySelectors(page, ORIGINAL_AGREEMENT);
|
|
22903
|
+
if (agreement.found && agreement.selector != null) {
|
|
22904
|
+
await clickSelector(page, agreement.selector, 3000);
|
|
22839
22905
|
}
|
|
22840
22906
|
await clickSelector(page, ORIGINAL_CONFIRM, 8000);
|
|
22907
|
+
await page.locator(DIALOG).first().waitFor?.({ state: "hidden", timeout: 1500 }).catch(() => {
|
|
22908
|
+
return;
|
|
22909
|
+
});
|
|
22841
22910
|
});
|
|
22842
22911
|
if (outcome !== "capability" && await readChecked(page, COMMITTED.original) !== true && !await residual(name)) {
|
|
22843
22912
|
warnings.push(`${name}: \u539F\u521B\u58F0\u660E\u672A\u751F\u6548\uFF0C\u8BF7\u624B\u52A8\u8BBE\u7F6E`);
|
|
@@ -22848,6 +22917,10 @@ async function enrichArticle(page, meta) {
|
|
|
22848
22917
|
const name = "\u8D5E\u8D4F";
|
|
22849
22918
|
if (await readChecked(page, COMMITTED.reward) !== true) {
|
|
22850
22919
|
const outcome = await step(name, async () => {
|
|
22920
|
+
const state = await readRewardState(page);
|
|
22921
|
+
if (state?.blocked === true) {
|
|
22922
|
+
throw new CapabilityError(`\u9700\u8981\u8D5E\u8D4F\u8D26\u6237\uFF08\u672C\u516C\u4F17\u53F7\u672A\u88AB\u6388\u6743\uFF0C\u5E73\u53F0\u539F\u6587\uFF1A${state.text === "" ? "\u65E0\u6CD5\u5F00\u542F\u8D5E\u8D4F" : state.text}\uFF09\u2014 \u8FD0\u8425\u8005\u5728\u5E73\u53F0\u5F00\u901A\u540E\u91CD\u8DD1\uFF0C\u672C\u6B21\u4E0D\u8BF7\u6C42\u8BE5\u5B57\u6BB5`);
|
|
22923
|
+
}
|
|
22851
22924
|
await openRow(ROW_REWARD, "\u8D5E\u8D4F");
|
|
22852
22925
|
const blocked = await tryFindSelector(page, [`${DIALOG} :has-text("\u524D\u5F80\u5F00\u901A")`, `${DIALOG} :has-text("\u65E0\u6CD5\u5F00\u542F")`], 1500);
|
|
22853
22926
|
if (blocked !== undefined)
|
|
@@ -22899,7 +22972,9 @@ async function enrichArticle(page, meta) {
|
|
|
22899
22972
|
};
|
|
22900
22973
|
const urlRow = await readUrl() === norm(originalUrl) ? "committed" : await tryFindSelector(page, ROW_URL, 2000);
|
|
22901
22974
|
if (urlRow === undefined) {
|
|
22902
|
-
|
|
22975
|
+
const msg = `${name}: \u884C\u4E0D\u5B58\u5728\uFF08\u5F53\u524D\u516C\u4F17\u53F7\u4E0D\u652F\u6301\uFF09\uFF0C\u8BF7\u624B\u52A8\u5904\u7406\u6216\u79FB\u9664 originalUrl`;
|
|
22976
|
+
warnings.push(msg);
|
|
22977
|
+
capabilityWarnings.push(msg);
|
|
22903
22978
|
} else if (urlRow !== "committed") {
|
|
22904
22979
|
await step(name, async () => {
|
|
22905
22980
|
if (await readUrl() === norm(originalUrl))
|
|
@@ -22951,7 +23026,14 @@ async function enrichArticle(page, meta) {
|
|
|
22951
23026
|
}
|
|
22952
23027
|
}
|
|
22953
23028
|
await sweep();
|
|
22954
|
-
|
|
23029
|
+
const ranAfterOriginal = on("reward") || collection !== "" || originalUrl !== "" || claimSource !== "";
|
|
23030
|
+
const hadOriginalWarning = warnings.some((w) => w.startsWith("\u539F\u521B\u58F0\u660E:"));
|
|
23031
|
+
if (on("original") && ranAfterOriginal && !hadOriginalWarning) {
|
|
23032
|
+
if (await readChecked(page, COMMITTED.original) === false) {
|
|
23033
|
+
warnings.push("\u539F\u521B\u58F0\u660E: \u540E\u7EED\u8BBE\u7F6E\u540E\u539F\u521B\u58F0\u660E\u88AB\u91CD\u7F6E\uFF0C\u8BF7\u6838\u5BF9");
|
|
23034
|
+
}
|
|
23035
|
+
}
|
|
23036
|
+
return { warnings, capabilityWarnings };
|
|
22955
23037
|
}
|
|
22956
23038
|
|
|
22957
23039
|
// ../../plugins/publishings/wechatmp-pub/src/flow.ts
|
|
@@ -23701,6 +23783,20 @@ async function setCover(page, source, deps, identity) {
|
|
|
23701
23783
|
return await warn(`cover: ${error instanceof Error ? error.message : String(error)}`);
|
|
23702
23784
|
}
|
|
23703
23785
|
}
|
|
23786
|
+
function genericCoverPathOf(content) {
|
|
23787
|
+
const generic = content.metadata?.coverImage;
|
|
23788
|
+
const genericPath = typeof generic === "string" ? generic : typeof generic?.path === "string" ? generic.path : undefined;
|
|
23789
|
+
return genericPath !== undefined && genericPath.length > 0 ? genericPath : undefined;
|
|
23790
|
+
}
|
|
23791
|
+
function libraryCoverFallback(content) {
|
|
23792
|
+
const meta = content.metadata?.wechatmp;
|
|
23793
|
+
if (meta !== null && typeof meta === "object" && !Array.isArray(meta)) {
|
|
23794
|
+
const coverPath = meta.coverPath;
|
|
23795
|
+
if (typeof coverPath === "string" && coverPath.trim().length > 0)
|
|
23796
|
+
return coverPath.trim();
|
|
23797
|
+
}
|
|
23798
|
+
return genericCoverPathOf(content);
|
|
23799
|
+
}
|
|
23704
23800
|
function coverSourceOf(content) {
|
|
23705
23801
|
const meta = content.metadata?.wechatmp;
|
|
23706
23802
|
if (meta !== null && typeof meta === "object" && !Array.isArray(meta)) {
|
|
@@ -23708,9 +23804,7 @@ function coverSourceOf(content) {
|
|
|
23708
23804
|
if (declared === "body" || declared === "library")
|
|
23709
23805
|
return declared;
|
|
23710
23806
|
}
|
|
23711
|
-
|
|
23712
|
-
const genericPath = typeof generic === "string" ? generic : typeof generic?.path === "string" ? generic.path : undefined;
|
|
23713
|
-
return genericPath !== undefined && genericPath.length > 0 ? "body" : "library";
|
|
23807
|
+
return genericCoverPathOf(content) !== undefined ? "body" : "library";
|
|
23714
23808
|
}
|
|
23715
23809
|
function audioBlockOf(content) {
|
|
23716
23810
|
const meta = content.metadata?.wechatmp;
|
|
@@ -23728,9 +23822,11 @@ function audioBlockOf(content) {
|
|
|
23728
23822
|
async function enrichArticleDraft(page, content, stepTimeoutMs) {
|
|
23729
23823
|
const enrichMeta = content.metadata?.wechatmp;
|
|
23730
23824
|
if (enrichMeta === undefined || typeof enrichMeta !== "object" || Array.isArray(enrichMeta))
|
|
23731
|
-
return { enrichWarnings: [], coverWarnings: [] };
|
|
23825
|
+
return { enrichWarnings: [], capabilityWarnings: [], coverWarnings: [] };
|
|
23732
23826
|
const meta = enrichMeta;
|
|
23733
|
-
const
|
|
23827
|
+
const detailed = await enrichArticleDetailed(page, meta);
|
|
23828
|
+
const enrichWarnings = [...detailed.warnings];
|
|
23829
|
+
const capabilityWarnings = [...detailed.capabilityWarnings];
|
|
23734
23830
|
const audio = audioBlockOf(content);
|
|
23735
23831
|
let audioFailed = false;
|
|
23736
23832
|
let coverSeeded = false;
|
|
@@ -23752,14 +23848,15 @@ async function enrichArticleDraft(page, content, stepTimeoutMs) {
|
|
|
23752
23848
|
coverWarnings.push(cover);
|
|
23753
23849
|
}
|
|
23754
23850
|
}
|
|
23755
|
-
return { enrichWarnings, coverWarnings };
|
|
23851
|
+
return { enrichWarnings, capabilityWarnings, coverWarnings };
|
|
23756
23852
|
}
|
|
23757
23853
|
async function composeArticle(input, deps, entry) {
|
|
23758
23854
|
const page = entry.editor;
|
|
23759
23855
|
const warnings = [];
|
|
23760
23856
|
const titlePath = await typeTitle(page, deps);
|
|
23761
23857
|
await insertBody(page, deps);
|
|
23762
|
-
|
|
23858
|
+
if (input.images.length > 0)
|
|
23859
|
+
await attachImages(page, input.images, deps);
|
|
23763
23860
|
for (const warning of [
|
|
23764
23861
|
await fillOptional(page, DIGEST_INPUT, input.digest ?? "", "\u6458\u8981", deps),
|
|
23765
23862
|
await fillOptional(page, AUTHOR_INPUT, authorOf(deps.content), "\u4F5C\u8005", deps)
|
|
@@ -23772,17 +23869,17 @@ async function composeArticle(input, deps, entry) {
|
|
|
23772
23869
|
const audioRuns = audioBlockOf(deps.content) !== null;
|
|
23773
23870
|
if (!(coverSource === "library" && audioRuns)) {
|
|
23774
23871
|
const cover = await setCover(page, coverSource, deps, {
|
|
23775
|
-
requested: input.images[0]
|
|
23872
|
+
requested: input.images[0] ?? libraryCoverFallback(deps.content)
|
|
23776
23873
|
});
|
|
23777
23874
|
if (cover !== null)
|
|
23778
23875
|
warnings.push(cover);
|
|
23779
23876
|
}
|
|
23780
|
-
const { enrichWarnings, coverWarnings } = await enrichArticleDraft(page, deps.content, deps.stepTimeoutMs);
|
|
23877
|
+
const { enrichWarnings, capabilityWarnings, coverWarnings } = await enrichArticleDraft(page, deps.content, deps.stepTimeoutMs);
|
|
23781
23878
|
warnings.push(...coverWarnings);
|
|
23782
23879
|
const layout = await applyLayout(page, deps);
|
|
23783
23880
|
if (layout !== null)
|
|
23784
23881
|
warnings.push(layout);
|
|
23785
|
-
return { warnings, titlePath, enrichWarnings };
|
|
23882
|
+
return { warnings, titlePath, enrichWarnings, capabilityWarnings };
|
|
23786
23883
|
}
|
|
23787
23884
|
async function composeSticker(input, deps, entry) {
|
|
23788
23885
|
const page = entry.editor;
|
|
@@ -24541,7 +24638,8 @@ async function runCgiDraft(input, deps) {
|
|
|
24541
24638
|
operation: input.operation,
|
|
24542
24639
|
publishStatus: deps.publishStatus,
|
|
24543
24640
|
stage: error.stage,
|
|
24544
|
-
...error.metadata.ambiguousSubmission === true ? { ambiguousSubmission: true } : {}
|
|
24641
|
+
...error.metadata.ambiguousSubmission === true ? { ambiguousSubmission: true } : {},
|
|
24642
|
+
...error.code === "duplicate-draft" ? { itcDelivery: { schemaVersion: 1, effect: "none" } } : {}
|
|
24545
24643
|
}
|
|
24546
24644
|
});
|
|
24547
24645
|
}
|
|
@@ -24566,11 +24664,16 @@ async function runMode(input, deps) {
|
|
|
24566
24664
|
if (!result.ok && diagnostics.length > 0) {
|
|
24567
24665
|
return { ...result, error: `${result.error} \u2014 compose diagnostics: ${diagnostics.join(" | ")}` };
|
|
24568
24666
|
}
|
|
24569
|
-
|
|
24667
|
+
const capabilitySet = new Set(composed.capabilityWarnings ?? []);
|
|
24668
|
+
const blockingEnrichWarnings = composed.enrichWarnings.filter((warning) => !capabilitySet.has(warning));
|
|
24669
|
+
const partialAllowed = process.env.WECHATMP_ALLOW_PARTIAL_ENRICH === "1";
|
|
24670
|
+
const fatalEnrichWarnings = partialAllowed ? blockingEnrichWarnings : composed.enrichWarnings;
|
|
24671
|
+
if (result.ok && fatalEnrichWarnings.length > 0) {
|
|
24672
|
+
const capabilityOnly = blockingEnrichWarnings.length === 0;
|
|
24570
24673
|
return {
|
|
24571
24674
|
...result,
|
|
24572
24675
|
ok: false,
|
|
24573
|
-
error: `draft saved but enrichment did not apply \u2014 ${
|
|
24676
|
+
error: `draft saved but enrichment did not apply \u2014 ${fatalEnrichWarnings.join(" | ")}${capabilityOnly ? " (set WECHATMP_ALLOW_PARTIAL_ENRICH=1 to accept a partial draft)" : ""}`
|
|
24574
24677
|
};
|
|
24575
24678
|
}
|
|
24576
24679
|
return result;
|
|
@@ -24659,7 +24762,18 @@ function markdownToWechatHtml(markdown) {
|
|
|
24659
24762
|
function escapeHtml(text) {
|
|
24660
24763
|
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
24661
24764
|
}
|
|
24662
|
-
async function
|
|
24765
|
+
async function evalOrFallback(page, script, fallback) {
|
|
24766
|
+
try {
|
|
24767
|
+
return String(await page.evaluate(script) ?? fallback);
|
|
24768
|
+
} catch {
|
|
24769
|
+
return fallback;
|
|
24770
|
+
}
|
|
24771
|
+
}
|
|
24772
|
+
async function insertAudioMaterial(page, input, timing = {}) {
|
|
24773
|
+
const uploadWaitMs = timing.uploadWaitMs ?? 120000;
|
|
24774
|
+
const saveCloseWaitMs = timing.saveCloseWaitMs ?? 30000;
|
|
24775
|
+
const saveDispatchWaitMs = timing.saveDispatchWaitMs ?? 1e4;
|
|
24776
|
+
const postUploadRowRetries = timing.rowRetries ?? 15;
|
|
24663
24777
|
const { title, audioPath, coverPath } = input;
|
|
24664
24778
|
let libraryHasCover = false;
|
|
24665
24779
|
const result = (warning) => ({
|
|
@@ -24733,16 +24847,35 @@ async function insertAudioMaterial(page, input) {
|
|
|
24733
24847
|
return JSON.stringify({ state: 'top', identity });
|
|
24734
24848
|
})()`;
|
|
24735
24849
|
const upload = async () => {
|
|
24850
|
+
let sawLiveUpload = false;
|
|
24851
|
+
const failUpload = (warning) => ({ ...result(warning), sawLiveUpload });
|
|
24852
|
+
const uploadDialog = '.weui-desktop-dialog:visible:has(h3.weui-desktop-dialog__title:text-is("\u4E0A\u4F20\u97F3\u9891"))';
|
|
24853
|
+
const isLiveUploadForm = async () => {
|
|
24854
|
+
if (await page.locator(uploadDialog).count() === 0)
|
|
24855
|
+
return false;
|
|
24856
|
+
try {
|
|
24857
|
+
const titleText = await page.locator(`${uploadDialog} h3.weui-desktop-dialog__title`).first().textContent?.() ?? "";
|
|
24858
|
+
return titleText.trim() === "\u4E0A\u4F20\u97F3\u9891";
|
|
24859
|
+
} catch {
|
|
24860
|
+
return false;
|
|
24861
|
+
}
|
|
24862
|
+
};
|
|
24736
24863
|
const uploadControl = await trySelectors(page, UPLOAD_AUDIO);
|
|
24737
24864
|
if (!uploadControl.found)
|
|
24738
|
-
return
|
|
24865
|
+
return failUpload("\u97F3\u9891: \u4E0A\u4F20\u97F3\u9891 control not found in the audio dialog");
|
|
24739
24866
|
await clickSelector(page, uploadControl.selector ?? UPLOAD_AUDIO[0] ?? "text=\u4E0A\u4F20\u97F3\u9891", 8000);
|
|
24740
24867
|
const audioInput = await trySelectors(page, AUDIO_UPLOAD_INPUT, { visible: false });
|
|
24741
24868
|
if (!audioInput.found)
|
|
24742
|
-
return
|
|
24869
|
+
return failUpload("\u97F3\u9891: no audio file input appeared");
|
|
24743
24870
|
await uploadFile(asPlaywrightPage(page), audioInput.selector ?? AUDIO_UPLOAD_INPUT.join(", "), audioPath, {
|
|
24744
|
-
timeoutMs:
|
|
24871
|
+
timeoutMs: 120000
|
|
24745
24872
|
});
|
|
24873
|
+
sawLiveUpload = await isLiveUploadForm();
|
|
24874
|
+
if (sawLiveUpload) {
|
|
24875
|
+
const uploaded = await waitUntil(async () => await page.locator(`${uploadDialog} button:has-text("\u91CD\u65B0\u4E0A\u4F20")`).count() > 0 && /100%/.test(await evalOrFallback(page, `(() => { const d = [...document.querySelectorAll('.weui-desktop-dialog')].find((el) => el.offsetWidth > 0 && el.querySelector('input[name=audio_id]')); return d ? (d.textContent ?? '') : ''; })()`, "")), uploadWaitMs);
|
|
24876
|
+
if (!uploaded)
|
|
24877
|
+
return failUpload("\u97F3\u9891: \u97F3\u9891\u6587\u4EF6\u4E0A\u4F20\u672A\u5B8C\u6210\uFF08\u672A\u8FBE\u5230 100%\uFF09\uFF0C\u672A\u4FDD\u5B58\u97F3\u9891");
|
|
24878
|
+
}
|
|
24746
24879
|
const coverControl = await trySelectors(page, UPLOAD_COVER);
|
|
24747
24880
|
if (coverControl.found) {
|
|
24748
24881
|
await clickSelector(page, coverControl.selector ?? UPLOAD_COVER[0] ?? "text=\u4E0A\u4F20\u5C01\u9762", 8000);
|
|
@@ -24755,10 +24888,10 @@ async function insertAudioMaterial(page, input) {
|
|
|
24755
24888
|
if (hasChooser) {
|
|
24756
24889
|
const libraryReady = await waitUntil(async () => Boolean(await page.evaluate(`!document.querySelector('#js_image_dialog_list_wrp .weui-desktop-loading')`)), 5000);
|
|
24757
24890
|
if (!libraryReady)
|
|
24758
|
-
return
|
|
24891
|
+
return failUpload("\u97F3\u9891: \u5C01\u9762\u7D20\u6750\u5E93\u52A0\u8F7D\u672A\u5B8C\u6210\uFF0C\u672A\u4E0A\u4F20\u91CD\u590D\u5C01\u9762");
|
|
24759
24892
|
existing = Number(await page.evaluate(`([...document.querySelectorAll('.weui-desktop-img-picker__item')].filter(row => row.offsetWidth > 0 && row.querySelector('.weui-desktop-img-picker__img-title')?.textContent?.trim() === ${JSON.stringify(coverName)})).length`));
|
|
24760
24893
|
if (existing > 1)
|
|
24761
|
-
return
|
|
24894
|
+
return failUpload("\u97F3\u9891: \u5185\u5BB9\u7ED1\u5B9A\u5C01\u9762\u5B58\u5728\u591A\u4E2A\u540C\u540D\u7D20\u6750\uFF0C\u672A\u731C\u6D4B\u9009\u62E9");
|
|
24762
24895
|
}
|
|
24763
24896
|
let uploadPath = coverPath;
|
|
24764
24897
|
let temporaryDir;
|
|
@@ -24787,10 +24920,13 @@ async function insertAudioMaterial(page, input) {
|
|
|
24787
24920
|
return row.classList.contains('selected');
|
|
24788
24921
|
})()`)), 30000);
|
|
24789
24922
|
if (!selected)
|
|
24790
|
-
return
|
|
24923
|
+
return failUpload("\u97F3\u9891: \u4E0A\u4F20\u5C01\u9762\u672A\u51FA\u73B0\u552F\u4E00\u5DF2\u9009\u4E2D\u7684\u540C\u540D\u56FE\u7247\uFF0C\u672A\u63D0\u4EA4\u5C01\u9762");
|
|
24791
24924
|
libraryHasCover = true;
|
|
24792
24925
|
const next = await findSelector(page, [`${chooser} button:has-text("\u4E0B\u4E00\u6B65"):not(.weui-desktop-btn_disabled)`], "\u97F3\u9891\u5C01\u9762 \u4E0B\u4E00\u6B65", 30000);
|
|
24793
24926
|
await clickSelector(page, next, 8000);
|
|
24927
|
+
if (sawLiveUpload && await page.locator(`${chooser} button:has-text("\u4E0A\u4E00\u6B65")`).count() > 0) {
|
|
24928
|
+
await page.waitForTimeout?.(2000);
|
|
24929
|
+
}
|
|
24794
24930
|
const finish = await findSelector(page, [`${chooser} button:has-text("\u5B8C\u6210"):not(.weui-desktop-btn_disabled)`], "\u97F3\u9891\u5C01\u9762 \u5B8C\u6210", 30000);
|
|
24795
24931
|
await clickSelector(page, finish, 8000);
|
|
24796
24932
|
let closed = await waitUntil(async () => !await page.locator(chooser).first().isVisible(), 25000);
|
|
@@ -24801,9 +24937,20 @@ async function insertAudioMaterial(page, input) {
|
|
|
24801
24937
|
closed = await waitUntil(async () => !await page.locator(chooser).first().isVisible(), 1e4);
|
|
24802
24938
|
}
|
|
24803
24939
|
}
|
|
24940
|
+
if (!closed) {
|
|
24941
|
+
const pickerClose = await tryFindSelector(page, [
|
|
24942
|
+
`${chooser} .weui-desktop-dialog__close-btn`,
|
|
24943
|
+
`${chooser} .weui-desktop-dialog__close`,
|
|
24944
|
+
`${chooser} button:has-text("\u53D6\u6D88")`
|
|
24945
|
+
], 3000);
|
|
24946
|
+
if (pickerClose !== undefined) {
|
|
24947
|
+
await clickSelector(page, pickerClose, 3000);
|
|
24948
|
+
closed = await waitUntil(async () => !await page.locator(chooser).first().isVisible(), 1e4);
|
|
24949
|
+
}
|
|
24950
|
+
}
|
|
24804
24951
|
if (!closed) {
|
|
24805
24952
|
const inventory = await openDialogInventory(page);
|
|
24806
|
-
return
|
|
24953
|
+
return failUpload(`\u97F3\u9891: \u5C01\u9762\u9009\u62E9\u5668\u5B8C\u6210\u540E\u672A\u5173\u95ED\uFF0C\u672A\u4FDD\u5B58\u97F3\u9891${inventory ? ` (dialogs: ${inventory})` : ""}`);
|
|
24807
24954
|
}
|
|
24808
24955
|
}
|
|
24809
24956
|
} finally {
|
|
@@ -24819,10 +24966,29 @@ async function insertAudioMaterial(page, input) {
|
|
|
24819
24966
|
await fillSelector(page, titleInput.selector ?? AUDIO_TITLE_INPUT.join(", "), title);
|
|
24820
24967
|
const agreed = String(await page.evaluate(AGREE));
|
|
24821
24968
|
if (agreed !== "checked")
|
|
24822
|
-
return
|
|
24969
|
+
return failUpload(`\u97F3\u9891: \u670D\u52A1\u89C4\u5219\u52FE\u9009\u5931\u8D25 (${agreed})`);
|
|
24823
24970
|
const save = await findSelector(page, UPLOAD_SAVE.map((selector) => `${selector}:not(.weui-desktop-btn_disabled):not([disabled])`), "\u97F3\u9891\u4E0A\u4F20\u5B8C\u6210\u4E14\u5C01\u9762\u5DF2\u63D0\u4EA4\u540E\u7684\u4FDD\u5B58\u6309\u94AE", 90000);
|
|
24971
|
+
if (sawLiveUpload) {
|
|
24972
|
+
await evalOrFallback(page, '(() => { window.__kkToasts = []; new MutationObserver(() => { const t = document.querySelector(".weui-desktop-toast"); if (t && t.textContent) window.__kkToasts.push(t.textContent.trim().slice(0, 200)); }).observe(document.body, { subtree: true, childList: true, characterData: true }); })()', "");
|
|
24973
|
+
}
|
|
24824
24974
|
await clickSelector(page, save, 8000);
|
|
24825
|
-
|
|
24975
|
+
if (sawLiveUpload) {
|
|
24976
|
+
let formClosed = await waitUntil(async () => !await isLiveUploadForm(), saveCloseWaitMs);
|
|
24977
|
+
if (!formClosed) {
|
|
24978
|
+
const dispatched = await evalOrFallback(page, '(() => { const form = [...document.querySelectorAll(".weui-desktop-dialog")].find((d) => d.querySelector(".title_form_wrp")); const btn = form && [...form.querySelectorAll("button")].find((b) => (b.textContent ?? "").trim() === "\u4FDD\u5B58"); if (!btn) return "no-btn"; btn.click(); return btn.disabled ? "was-disabled" : "clicked"; })()', "null");
|
|
24979
|
+
formClosed = await waitUntil(async () => !await isLiveUploadForm(), saveDispatchWaitMs);
|
|
24980
|
+
if (!formClosed) {
|
|
24981
|
+
const saveDiagnostics = `(() => {
|
|
24982
|
+
const form = [...document.querySelectorAll(".weui-desktop-dialog")].find((d) => d.querySelector(".title_form_wrp"));
|
|
24983
|
+
const btn = form && [...form.querySelectorAll("button")].find((b) => (b.textContent ?? "").trim() === "\u4FDD\u5B58");
|
|
24984
|
+
return JSON.stringify({ btn: btn ? { disabled: btn.disabled, offW: btn.offsetWidth } : null, toasts: (window.__kkToasts ?? []).slice(-3) });
|
|
24985
|
+
})()`;
|
|
24986
|
+
const diag = (await evalOrFallback(page, saveDiagnostics, "")).slice(0, 400);
|
|
24987
|
+
return failUpload(`\u97F3\u9891: \u4FDD\u5B58\u5931\u8D25\uFF0C\u4E0A\u4F20\u5F39\u7A97\u672A\u5173\u95ED\uFF08dispatch=${dispatched} ${diag}\uFF09`);
|
|
24988
|
+
}
|
|
24989
|
+
}
|
|
24990
|
+
}
|
|
24991
|
+
return failUpload("");
|
|
24826
24992
|
};
|
|
24827
24993
|
const matchOnce = async () => {
|
|
24828
24994
|
try {
|
|
@@ -24831,9 +24997,9 @@ async function insertAudioMaterial(page, input) {
|
|
|
24831
24997
|
return "error";
|
|
24832
24998
|
}
|
|
24833
24999
|
};
|
|
24834
|
-
const awaitMatch = async () => {
|
|
25000
|
+
const awaitMatch = async (retries = AUDIO_ROW_RETRIES) => {
|
|
24835
25001
|
let match = await matchOnce();
|
|
24836
|
-
for (let i = 0;match === "missing" && i <
|
|
25002
|
+
for (let i = 0;match === "missing" && i < retries; i += 1) {
|
|
24837
25003
|
await page.waitForTimeout?.(AUDIO_ROW_SETTLE_MS);
|
|
24838
25004
|
match = await matchOnce();
|
|
24839
25005
|
}
|
|
@@ -24847,14 +25013,17 @@ async function insertAudioMaterial(page, input) {
|
|
|
24847
25013
|
await page.evaluate(`document.querySelector(${JSON.stringify(AUDIO_MENU)})?.click()`);
|
|
24848
25014
|
await waitForVisible(page, AUDIO_DIALOG, AUDIO_DIALOG_TIMEOUT_MS);
|
|
24849
25015
|
let match = await awaitMatch();
|
|
25016
|
+
let postSavePoll = false;
|
|
24850
25017
|
if (match === "missing") {
|
|
24851
25018
|
const uploadResult = await upload();
|
|
25019
|
+
postSavePoll = uploadResult.sawLiveUpload;
|
|
24852
25020
|
if (uploadResult.warning !== "") {
|
|
24853
|
-
|
|
25021
|
+
if (!uploadResult.sawLiveUpload)
|
|
25022
|
+
await page.evaluate(CANCEL);
|
|
24854
25023
|
return result(uploadResult.warning);
|
|
24855
25024
|
}
|
|
24856
25025
|
await waitForVisible(page, AUDIO_DIALOG, AUDIO_DIALOG_TIMEOUT_MS);
|
|
24857
|
-
match = await awaitMatch();
|
|
25026
|
+
match = await awaitMatch(postSavePoll ? postUploadRowRetries : AUDIO_ROW_RETRIES);
|
|
24858
25027
|
if (match === "missing") {
|
|
24859
25028
|
await page.evaluate(CANCEL);
|
|
24860
25029
|
return result(`\u97F3\u9891: \u4FDD\u5B58\u540E\u7D20\u6750\u5217\u8868\u672A\u51FA\u73B0\u300C${title}\u300D\uFF0C\u672A\u63D2\u5165\u97F3\u9891`);
|
|
@@ -24879,7 +25048,14 @@ async function insertAudioMaterial(page, input) {
|
|
|
24879
25048
|
await page.evaluate(CANCEL);
|
|
24880
25049
|
return result("\u97F3\u9891: \u7D20\u6750\u5339\u914D\u63A2\u6D4B\u8FD4\u56DE\u672A\u77E5\u7ED3\u679C\uFF0C\u672A\u63D2\u5165\u97F3\u9891");
|
|
24881
25050
|
}
|
|
24882
|
-
|
|
25051
|
+
let inserted = await page.evaluate(INSERT) === true;
|
|
25052
|
+
if (!inserted && postSavePoll) {
|
|
25053
|
+
for (let i = 0;!inserted && i < 5; i += 1) {
|
|
25054
|
+
await page.waitForTimeout?.(500);
|
|
25055
|
+
inserted = await page.evaluate(INSERT) === true;
|
|
25056
|
+
}
|
|
25057
|
+
}
|
|
25058
|
+
if (!inserted) {
|
|
24883
25059
|
await page.evaluate(CANCEL);
|
|
24884
25060
|
return result("\u97F3\u9891: \u63D2\u5165\u6309\u94AE\u672A\u627E\u5230\uFF0C\u8BF7\u624B\u52A8\u63D2\u5165");
|
|
24885
25061
|
}
|