@gobing-ai/knowledge-kit 0.1.14 → 0.1.16
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 +2399 -177
- package/package.json +1 -1
- package/plugins/generations/content-gen/dist/index.js +60 -54
- package/plugins/generations/content-gen/src/storm.ts +94 -61
- package/plugins/generations/core-facts-gen/dist/index.js +3 -3
- package/plugins/generations/daily-article-gen/dist/index.js +3 -3
- package/plugins/generations/dailynews-gen/dist/index.js +73 -10
- package/plugins/generations/dailynews-gen/src/index.ts +23 -1
- package/plugins/generations/dailynews-gen/src/script-plan.ts +103 -5
- package/plugins/generations/episode-plan-gen/dist/index.js +3 -3
- package/plugins/generations/gemini-tts/dist/index.js +3 -3
- package/plugins/generations/image-gen/README.md +31 -10
- package/plugins/generations/image-gen/assets/sample/cover__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-cover__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__clean-webapp-ui.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__cute.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__daily-news.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__editorial.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__fresh.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__minimalist.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__photorealistic.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__sketch.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__technical-diagram.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__vibrant.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__warm.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__xhs-knowledge.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/free__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/illustration__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/xhs-card__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/dist/index.js +3 -3
- package/plugins/generations/image-gen/presets/formats/daily-news-podcast-cover.yaml +18 -0
- package/plugins/generations/image-gen/presets/styles/quasi-news-podcast.yaml +9 -0
- package/plugins/generations/news-report-gen/dist/index.js +3 -3
- package/plugins/generations/voice-gen/dist/index.js +3 -3
- package/plugins/generations/voxcpm-tts/dist/index.js +3 -3
- package/plugins/ingestions/aihot-ingest/dist/index.js +3 -3
- package/plugins/ingestions/horizon-ingest/dist/index.js +3 -3
- package/plugins/ingestions/last30days-ingest/dist/index.js +3 -3
- package/plugins/ingestions/web-search/dist/index.js +3 -3
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice-migration.json +12 -3
- package/plugins/kk/publish-presets/daily-ai-voice.json +11 -3
- package/plugins/kk/scripts/cover-compositor.ts +152 -0
- package/plugins/kk/scripts/daily-cover-mock.ts +164 -0
- package/plugins/kk/scripts/daily-scheduled-run.ts +192 -3
- package/plugins/kk/scripts/daily-stages.ts +599 -27
- package/plugins/kk/scripts/daily-triage-core.ts +451 -0
- package/plugins/kk/scripts/daily-triage.ts +74 -0
- package/plugins/kk/scripts/kk-workflow-stages.ts +51 -6
- package/plugins/kk/skills/content-judge/SKILL.md +5 -4
- package/plugins/kk/skills/content-judge/references/rubrics.md +14 -0
- package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +16 -10
- package/plugins/kk/skills/news-editorial/SKILL.md +122 -0
- package/plugins/kk/skills/news-editorial/references/selection.md +47 -0
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +100 -0
- package/plugins/kk/skills/publish/SKILL.md +4 -4
- package/plugins/kk/skills/web-automation/SKILL.md +229 -77
- package/plugins/kk/skills/web-automation/references/browser-launch.md +127 -36
- package/plugins/kk/skills/wiki-authoring/SKILL.md +53 -0
- package/plugins/kk/skills/wiki-authoring/references/page-shapes.md +44 -0
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +4 -6
- package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +185 -224
- package/plugins/kk/workflows/kk-daily-publish3.yaml +16 -8
- package/plugins/kk/workflows/kk-daily-safety.yaml +32 -7
- package/plugins/publishings/bilibili-pub/dist/index.js +6 -4
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +3 -1
- package/plugins/publishings/cnblogs-pub/dist/index.js +6 -4
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +3 -1
- package/plugins/publishings/csdn-pub/dist/index.js +6 -4
- package/plugins/publishings/csdn-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/emdash-pub/dist/index.js +3 -3
- package/plugins/publishings/infoq-pub/dist/index.js +6 -4
- package/plugins/publishings/infoq-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/jike-pub/dist/index.js +6 -4
- package/plugins/publishings/jike-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/juejin-pub/dist/index.js +6 -4
- package/plugins/publishings/juejin-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/linkedin-pub/dist/index.js +6 -4
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/medium-pub/dist/index.js +3 -3
- package/plugins/publishings/podcast-pub/dist/index.js +148 -5
- package/plugins/publishings/podcast-pub/src/index.ts +71 -2
- package/plugins/publishings/podcast-pub/src/map.ts +3 -0
- package/plugins/publishings/podcast-pub/src/transcript.ts +195 -0
- package/plugins/publishings/qiita-pub/dist/index.js +3 -3
- package/plugins/publishings/shipinhao-pub/dist/index.js +227 -53
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +51 -2
- package/plugins/publishings/shipinhao-pub/plugin.json +2 -2
- package/plugins/publishings/shipinhao-pub/src/flow.ts +335 -79
- package/plugins/publishings/shipinhao-pub/src/index.ts +16 -8
- package/plugins/publishings/shipinhao-pub/src/profile-check.ts +1 -1
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +103 -5
- package/plugins/publishings/sspai-pub/dist/index.js +6 -4
- package/plugins/publishings/sspai-pub/dist/profile-check.js +3 -1
- package/plugins/publishings/substack-pub/dist/index.js +6 -4
- package/plugins/publishings/substack-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/surfdash-pub/dist/index.js +237 -14
- package/plugins/publishings/surfdash-pub/src/index.ts +127 -6
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +189 -0
- package/plugins/publishings/threads-pub/dist/index.js +3 -3
- package/plugins/publishings/wechatmp-pub/dist/index.js +62 -40
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +10 -3
- package/plugins/publishings/wechatmp-pub/src/flow.ts +73 -37
- package/plugins/publishings/wechatmp-pub/src/page.ts +14 -0
- package/plugins/publishings/weibo-pub/dist/index.js +6 -4
- package/plugins/publishings/weibo-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/x-pub/dist/index.js +6 -4
- package/plugins/publishings/x-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/xhs-pub/dist/index.js +562 -34
- package/plugins/publishings/xhs-pub/dist/profile-check.js +25 -4
- package/plugins/publishings/xhs-pub/src/errors.ts +45 -0
- package/plugins/publishings/xhs-pub/src/flow.ts +773 -45
- package/plugins/publishings/xhs-pub/src/page.ts +33 -0
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +6 -4
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +3 -1
- package/plugins/publishings/zenn-pub/dist/index.js +3 -3
- package/plugins/kk/scripts/daily-voice-style.zh.md +0 -70
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* shipinhao-pub transport + flow (task 0296).
|
|
2
|
+
* shipinhao-pub transport + flow (task 0296; four post kinds since 2026-11-10).
|
|
3
3
|
*
|
|
4
|
-
* The live
|
|
5
|
-
*
|
|
4
|
+
* The live post flow in `runPostFlow`, stage-typed on every `Result.metadata.stage`, shared by the
|
|
5
|
+
* four declared operations (视频 shortVideo, 音频 audio, 音乐 music, 图文 image): root-resolve
|
|
6
|
+
* (the wujie policy) → media-upload → media-processing → title-fill →
|
|
6
7
|
* description-paste-readback → original-declare (only when `metadata.original === true`) →
|
|
7
|
-
* cover-attach (when requested) → draft-save | publish-click → draft-receipt |
|
|
8
|
+
* cover-attach (when requested; never for 图文) → draft-save | publish-click → draft-receipt |
|
|
9
|
+
* publish-receipt. Per-operation differences are data, not code: the file-input selector ladder,
|
|
10
|
+
* the creation-page URL and the media payload gates (videoPath | audio(audioFile) | images).
|
|
11
|
+
* The audio/image/music selectors are **Provisional** until the first logged-in live recon —
|
|
12
|
+
* every one of them fails closed to a typed stage failure, never a wrong send.
|
|
8
13
|
*
|
|
9
14
|
* Root policy (shipinhao.js:3-5, 514-545, frozen by the task 0296 Design): if `wujie-app` is
|
|
10
15
|
* present, wait at most `SHP_ROOT_WAIT_MS` (vendor ROOT_WAIT_MS 30000, shipinhao.js:38) for its
|
|
@@ -49,21 +54,28 @@ import type { Locator, Page } from 'playwright';
|
|
|
49
54
|
import {
|
|
50
55
|
isShipinhaoAuthenticated,
|
|
51
56
|
readRootSnapshot,
|
|
57
|
+
SHP_AUDIO_SELECTORS,
|
|
52
58
|
SHP_CONFIG,
|
|
53
59
|
SHP_COVER_SAVE_WAIT_MS,
|
|
54
|
-
|
|
60
|
+
SHP_DESCRIPTION_MAX_CHARS,
|
|
61
|
+
SHP_DRAFT_CONFIRM_DIALOG_TEXT,
|
|
62
|
+
SHP_DRAFT_CONFIRM_PROCEED_LABEL,
|
|
63
|
+
SHP_HOME_URL_BY_OPERATION,
|
|
64
|
+
SHP_IMAGE_SELECTORS,
|
|
65
|
+
SHP_MUSIC_SELECTORS,
|
|
55
66
|
SHP_RECEIPT_URL_RES,
|
|
56
67
|
SHP_ROOT_WAIT_MS,
|
|
57
68
|
SHP_TARGET,
|
|
58
69
|
SHP_UPLOAD_TIMEOUT_MS,
|
|
59
70
|
SHP_VIDEO_SELECTORS,
|
|
71
|
+
type ShipinhaoOperationName,
|
|
60
72
|
type ShipinhaoRootSnapshot,
|
|
61
73
|
} from './selectors';
|
|
62
74
|
|
|
63
75
|
const STEP_TIMEOUT_MS = 30_000;
|
|
64
76
|
/**
|
|
65
|
-
* KK v1 local-
|
|
66
|
-
* not a platform limit — Channels' own ceiling is unpinned.
|
|
77
|
+
* KK v1 local-media size bound (task 0296 Design freeze): 2 GiB, applied to every media kind. A
|
|
78
|
+
* project-scoped product bound, not a platform limit — Channels' own ceiling is unpinned.
|
|
67
79
|
*/
|
|
68
80
|
const MAX_VIDEO_BYTES = 2 * 1024 * 1024 * 1024;
|
|
69
81
|
/** Operator recovery command every session failure names — never a cookie, DOM dump or stack. */
|
|
@@ -115,6 +127,39 @@ function normalizeText(value: string): string {
|
|
|
115
127
|
return value.replace(/\s+/g, '');
|
|
116
128
|
}
|
|
117
129
|
|
|
130
|
+
/** Plain text of sanitized HTML: block tags → newlines, then strip tags and decode entities. */
|
|
131
|
+
function htmlToPlainText(html: string): string {
|
|
132
|
+
return html
|
|
133
|
+
.replace(/<\/(p|h[1-6]|li|blockquote|div)>/gi, '\n')
|
|
134
|
+
.replace(/<br\s*\/?>/gi, '\n')
|
|
135
|
+
.replace(/<[^>]+>/g, '')
|
|
136
|
+
.replace(/ /g, ' ')
|
|
137
|
+
.replace(/&/g, '&')
|
|
138
|
+
.replace(/</g, '<')
|
|
139
|
+
.replace(/>/g, '>')
|
|
140
|
+
.replace(/"/g, '"')
|
|
141
|
+
.replace(/'/g, "'")
|
|
142
|
+
.trim();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Build the description the 添加描述 editor can actually retain: plain text (the editor keeps
|
|
147
|
+
* innerText, not markdown — headings lose `#`, links keep only their text) clipped to the 100-char
|
|
148
|
+
* platform cap with the topic tags kept whole, then re-rendered to the HTML we paste. Exported for
|
|
149
|
+
* the test contract (same pipeline the flow pastes).
|
|
150
|
+
*/
|
|
151
|
+
export function buildShipinhaoDescription(
|
|
152
|
+
body: string,
|
|
153
|
+
tags: readonly string[],
|
|
154
|
+
): { description: string; html: string } {
|
|
155
|
+
const bodyPlain = htmlToPlainText(sanitizeShipinhaoHtml(markdownToHtml(body)));
|
|
156
|
+
const topicLine = tags.map((tag) => `#${tag.replace(/^#/, '')}`).join(' ');
|
|
157
|
+
const budget = SHP_DESCRIPTION_MAX_CHARS - (tags.length > 0 ? Array.from(topicLine).length + 1 : 0);
|
|
158
|
+
const clipped = Array.from(bodyPlain).slice(0, Math.max(budget, 0)).join('').trim();
|
|
159
|
+
const description = tags.length > 0 ? `${clipped}\n${topicLine}` : clipped;
|
|
160
|
+
return { description, html: sanitizeShipinhaoHtml(markdownToHtml(description)) };
|
|
161
|
+
}
|
|
162
|
+
|
|
118
163
|
/**
|
|
119
164
|
* Plugin-local HTML sanitizer (task 0296 Design freeze — no new dependency): strips
|
|
120
165
|
* script/style/iframe/embed/object containers, `on*` event attributes and `javascript:`/`data:`
|
|
@@ -274,6 +319,44 @@ function editorTextScript(mode: 'wujie' | 'direct', selector: string): string {
|
|
|
274
319
|
})()`;
|
|
275
320
|
}
|
|
276
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Draft-save confirm dialog (Grounded live probe 2026-11-11): with 定时发表 active, clicking
|
|
324
|
+
* 保存草稿 renders the confirm dialog whose exact text is SHP_DRAFT_CONFIRM_DIALOG_TEXT with
|
|
325
|
+
* visible 不保存/保存 buttons — the save only proceeds after clicking the visible 保存. The same
|
|
326
|
+
* dialog also exists as a hidden 0×0 template, so the click requires a rendered box; absent
|
|
327
|
+
* dialog = normal no-op. **Audio known-gap**: the audio form's auto-cover slot stays
|
|
328
|
+
* primary-loading ≥8 min (headless AND headed) and the vendor never posts the save — draft-save
|
|
329
|
+
* for audio is a typed ceiling failure until a viable audio intake is pinned.
|
|
330
|
+
*/
|
|
331
|
+
function draftConfirmClickScript(mode: 'wujie' | 'direct'): string {
|
|
332
|
+
return `${rootScriptPrefix(mode)} // kk-shp-draft-confirm
|
|
333
|
+
const mark = ${JSON.stringify(SHP_DRAFT_CONFIRM_DIALOG_TEXT)};
|
|
334
|
+
const proceed = ${JSON.stringify(SHP_DRAFT_CONFIRM_PROCEED_LABEL)};
|
|
335
|
+
for (const scope of [document, root]) {
|
|
336
|
+
if (!scope) continue;
|
|
337
|
+
// Anchor from the button side: the dialog text repeats across nested toast/dialog spans and
|
|
338
|
+
// the last text-bearing element is a leaf without buttons (Grounded live probe 2026-11-11).
|
|
339
|
+
for (const button of scope.querySelectorAll('button')) {
|
|
340
|
+
if (String(button.textContent || '').trim() !== proceed || button.disabled) continue;
|
|
341
|
+
// Only click a genuinely rendered dialog button: the vendor ships this dialog as a
|
|
342
|
+
// permanently hidden 0×0 template inside the form (Grounded live probe 2026-11-11) —
|
|
343
|
+
// clicking the hidden copy is a silent no-op that would otherwise satisfy the rail.
|
|
344
|
+
const rect = button.getBoundingClientRect();
|
|
345
|
+
if (!(rect.width > 0 && rect.height > 0)) continue;
|
|
346
|
+
let ancestor = button;
|
|
347
|
+
for (let depth = 0; depth < 6 && ancestor; depth++) {
|
|
348
|
+
if (String(ancestor.textContent || '').includes(mark)) {
|
|
349
|
+
button.click();
|
|
350
|
+
return JSON.stringify({ ok: true });
|
|
351
|
+
}
|
|
352
|
+
ancestor = ancestor.parentElement;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return JSON.stringify({ ok: false, reason: 'absent' });
|
|
357
|
+
})()`;
|
|
358
|
+
}
|
|
359
|
+
|
|
277
360
|
/**
|
|
278
361
|
* Receipt-shaped URLs on screen (location + anchors across the vendor roots) — baseline and fresh
|
|
279
362
|
* read for the receipt stage.
|
|
@@ -300,42 +383,116 @@ async function readReceiptUrls(page: Page): Promise<readonly string[]> {
|
|
|
300
383
|
}
|
|
301
384
|
}
|
|
302
385
|
|
|
303
|
-
/** Works/record id from an observed receipt URL (shapes: `/record/detail/<id>`, `/post
|
|
386
|
+
/** Works/record id from an observed receipt URL (shapes: `/record/detail/<id>`, `/post/<kind>/<id>`; provisional). */
|
|
304
387
|
function receiptIdFrom(url: string): string | undefined {
|
|
305
|
-
return /\/(?:detail|video)\/([0-9a-zA-Z_-]+)/.exec(url)?.[1];
|
|
388
|
+
return /\/(?:detail|video|audio|image|music)\/([0-9a-zA-Z_-]+)/.exec(url)?.[1];
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
interface MediaPathSpec {
|
|
392
|
+
/** Metadata key named in every refusal (never the caller's raw value). */
|
|
393
|
+
field: string;
|
|
394
|
+
/** Kind word in the non-file/missing messages ('video', 'audio', 'image'). */
|
|
395
|
+
kindLabel: string;
|
|
396
|
+
/** Extension word in the unsupported-extension message ('MP4/MOV', 'MP3/M4A/...'). */
|
|
397
|
+
extLabel: string;
|
|
398
|
+
extRe: RegExp;
|
|
306
399
|
}
|
|
307
400
|
|
|
308
401
|
/**
|
|
309
|
-
* Pre-browser
|
|
310
|
-
*
|
|
311
|
-
* limit). Probed through the Bun file API (repo rule no-direct-fs-io) — never node:fs.
|
|
402
|
+
* Pre-browser media gate: the raw value must name an existing, regular, readable, nonempty local
|
|
403
|
+
* file of the accepted extensions under the KK v1 2 GiB local cap (labeled local bound — not a
|
|
404
|
+
* platform limit). Probed through the Bun file API (repo rule no-direct-fs-io) — never node:fs.
|
|
312
405
|
*/
|
|
313
|
-
async function
|
|
406
|
+
async function resolveMediaPath(
|
|
314
407
|
raw: unknown,
|
|
408
|
+
spec: MediaPathSpec,
|
|
315
409
|
): Promise<{ path?: string; error?: undefined } | { path?: undefined; error: string }> {
|
|
316
410
|
if (typeof raw !== 'string' || raw.trim().length === 0) {
|
|
317
|
-
return {
|
|
411
|
+
return {
|
|
412
|
+
error: `metadata.${spec.field} must be a non-empty local ${spec.kindLabel} file path, got '${bounded(raw)}'`,
|
|
413
|
+
};
|
|
318
414
|
}
|
|
319
415
|
const path = raw.trim();
|
|
320
|
-
if (
|
|
416
|
+
if (!spec.extRe.test(path)) {
|
|
321
417
|
return {
|
|
322
|
-
error: `metadata.
|
|
418
|
+
error: `metadata.${spec.field} must be a local ${spec.extLabel} file, got unsupported extension in '${bounded(path)}'`,
|
|
323
419
|
};
|
|
324
420
|
}
|
|
325
421
|
// no-direct-fs-io: probe the file through the Bun API instead of node:fs.
|
|
326
422
|
const file = Bun.file(path);
|
|
327
423
|
const readable = await file.exists().catch(() => false);
|
|
328
424
|
if (!readable || file.size === 0) {
|
|
329
|
-
return {
|
|
425
|
+
return {
|
|
426
|
+
error: `metadata.${spec.field} does not resolve to a readable nonempty local ${spec.kindLabel} file`,
|
|
427
|
+
};
|
|
330
428
|
}
|
|
331
429
|
if (file.size > MAX_VIDEO_BYTES) {
|
|
332
430
|
return {
|
|
333
|
-
error: `metadata.
|
|
431
|
+
error: `metadata.${spec.field} exceeds the KK v1 local ${spec.kindLabel} cap of 2 GiB (${file.size} bytes; a local product bound, not a platform limit)`,
|
|
334
432
|
};
|
|
335
433
|
}
|
|
336
434
|
return { path };
|
|
337
435
|
}
|
|
338
436
|
|
|
437
|
+
/** Video gate over the generic media gate (task 0296 messages preserved verbatim). */
|
|
438
|
+
function resolveVideoPath(
|
|
439
|
+
raw: unknown,
|
|
440
|
+
): Promise<{ path?: string; error?: undefined } | { path?: undefined; error: string }> {
|
|
441
|
+
return resolveMediaPath(raw, {
|
|
442
|
+
field: 'videoPath',
|
|
443
|
+
kindLabel: 'video',
|
|
444
|
+
extLabel: 'MP4/MOV',
|
|
445
|
+
extRe: /\.(mp4|mov)$/i,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Audio gate (音频/音乐): the daily episode mp3 rides `metadata.audioFile` (publish-prep's
|
|
451
|
+
* spelling); the variant builders also restate it as `metadata.audio` — the transport accepts
|
|
452
|
+
* either, so the field name in refusals names both.
|
|
453
|
+
*/
|
|
454
|
+
function resolveAudioPath(
|
|
455
|
+
raw: unknown,
|
|
456
|
+
): Promise<{ path?: string; error?: undefined } | { path?: undefined; error: string }> {
|
|
457
|
+
return resolveMediaPath(raw, {
|
|
458
|
+
field: 'audio (or audioFile)',
|
|
459
|
+
kindLabel: 'audio',
|
|
460
|
+
extLabel: 'MP3/M4A/WAV/AAC/FLAC',
|
|
461
|
+
extRe: /\.(mp3|m4a|wav|aac|flac)$/i,
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Image gate (图文): `metadata.images` is a non-empty array of local PNG/JPEG/WebP paths (plain
|
|
467
|
+
* strings or `{ path }` objects, the cards-variant spelling), each probed like a single media
|
|
468
|
+
* file. shortcut: no array-length cap — the platform's 图文 count limit is unpinned until live
|
|
469
|
+
* recon.
|
|
470
|
+
*/
|
|
471
|
+
async function resolveImagesPath(
|
|
472
|
+
raw: unknown,
|
|
473
|
+
): Promise<{ paths?: readonly string[]; error?: undefined } | { paths?: undefined; error: string }> {
|
|
474
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
475
|
+
return {
|
|
476
|
+
error: `metadata.images must be a non-empty array of local image file paths, got '${bounded(raw)}'`,
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
const paths: string[] = [];
|
|
480
|
+
for (const entry of raw) {
|
|
481
|
+
// The shared cards variant ships `images: [{ path }]`; the transport flattens to paths.
|
|
482
|
+
const candidate =
|
|
483
|
+
typeof entry === 'object' && entry !== null && 'path' in entry ? (entry as { path?: unknown }).path : entry;
|
|
484
|
+
const one = await resolveMediaPath(candidate, {
|
|
485
|
+
field: 'images[]',
|
|
486
|
+
kindLabel: 'image',
|
|
487
|
+
extLabel: 'PNG/JPEG/WebP',
|
|
488
|
+
extRe: /\.(png|jpe?g|webp)$/i,
|
|
489
|
+
});
|
|
490
|
+
if (one.error !== undefined) return { error: one.error };
|
|
491
|
+
paths.push(one.path as string);
|
|
492
|
+
}
|
|
493
|
+
return { paths };
|
|
494
|
+
}
|
|
495
|
+
|
|
339
496
|
/**
|
|
340
497
|
* Pre-browser requested-cover gate: an optional local PNG/JPEG/WebP that must exist as a regular,
|
|
341
498
|
* readable, nonempty file. Requested-but-absent or wrong-typed refuses here — a requested cover is
|
|
@@ -399,27 +556,49 @@ function resolveOriginal(
|
|
|
399
556
|
}
|
|
400
557
|
|
|
401
558
|
/**
|
|
402
|
-
* Unsupported requested fields
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
559
|
+
* Unsupported requested fields, per operation: fields that mean nothing to the requested flow —
|
|
560
|
+
* images/videoPath outside their own operation, coverPath for 图文 — are typed unsupported-field
|
|
561
|
+
* refusals, never silently ignored. categories and publishTime/scheduling are refused for every
|
|
562
|
+
* operation (定时 is an unported vendor enhancement, shipinhao.js:7-9). `tags`/`original`/
|
|
563
|
+
* `coverPath` (except on image) are implemented and validated in their resolvers.
|
|
406
564
|
*/
|
|
407
|
-
function unsupportedFields(payload: PublishTransportPayload): readonly string[] {
|
|
565
|
+
function unsupportedFields(payload: PublishTransportPayload, operation: ShipinhaoOperationName): readonly string[] {
|
|
566
|
+
const perOperation: Record<ShipinhaoOperationName, readonly string[]> = {
|
|
567
|
+
shortVideo: ['images', 'categories', 'publishTime', 'scheduling'],
|
|
568
|
+
audio: ['videoPath', 'images', 'categories', 'publishTime', 'scheduling'],
|
|
569
|
+
music: ['videoPath', 'images', 'categories', 'publishTime', 'scheduling'],
|
|
570
|
+
image: ['videoPath', 'coverPath', 'categories', 'publishTime', 'scheduling'],
|
|
571
|
+
};
|
|
408
572
|
const refused: string[] = [];
|
|
409
|
-
for (const [container,
|
|
410
|
-
['options',
|
|
411
|
-
['metadata',
|
|
412
|
-
]
|
|
413
|
-
|
|
414
|
-
for (const key of
|
|
415
|
-
if (
|
|
416
|
-
refused.push(`${container}.${key}`);
|
|
417
|
-
}
|
|
573
|
+
for (const [container, source] of [
|
|
574
|
+
['options', payload.options] as const,
|
|
575
|
+
['metadata', payload.content.metadata] as const,
|
|
576
|
+
]) {
|
|
577
|
+
if (source === undefined || source === null || typeof source !== 'object') continue;
|
|
578
|
+
for (const key of perOperation[operation]) {
|
|
579
|
+
if (key in source) refused.push(`${container}.${key}`);
|
|
418
580
|
}
|
|
419
581
|
}
|
|
420
582
|
return refused;
|
|
421
583
|
}
|
|
422
584
|
|
|
585
|
+
/**
|
|
586
|
+
* Per-operation flow data: the shared rails' selector table, the media file-input ladder, and the
|
|
587
|
+
* message label used by every upload/media-processing stage failure.
|
|
588
|
+
*/
|
|
589
|
+
interface PostFlowSpec {
|
|
590
|
+
selectors: typeof SHP_VIDEO_SELECTORS;
|
|
591
|
+
fileSelectors: readonly string[];
|
|
592
|
+
mediaLabel: string;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
const POST_FLOW_SPECS: Record<ShipinhaoOperationName, PostFlowSpec> = {
|
|
596
|
+
shortVideo: { selectors: SHP_VIDEO_SELECTORS, fileSelectors: SHP_VIDEO_SELECTORS.videoInput, mediaLabel: 'video' },
|
|
597
|
+
audio: { selectors: SHP_AUDIO_SELECTORS, fileSelectors: SHP_AUDIO_SELECTORS.audioInput, mediaLabel: 'audio' },
|
|
598
|
+
music: { selectors: SHP_MUSIC_SELECTORS, fileSelectors: SHP_MUSIC_SELECTORS.audioInput, mediaLabel: 'music' },
|
|
599
|
+
image: { selectors: SHP_IMAGE_SELECTORS, fileSelectors: SHP_IMAGE_SELECTORS.imagesInput, mediaLabel: 'image' },
|
|
600
|
+
};
|
|
601
|
+
|
|
423
602
|
/** Post-upload media-processing probe: the editing form (title input + description editor) must appear in the active root — the assignment itself is never success (shipinhao.js:623-625, 2676-2683). */
|
|
424
603
|
function editingFormReadyScript(mode: 'wujie' | 'direct', titleSelector: string, editorSelector: string): string {
|
|
425
604
|
return `${rootScriptPrefix(mode)}
|
|
@@ -636,11 +815,11 @@ function persistedStateScript(
|
|
|
636
815
|
export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
637
816
|
public readonly kind = 'browser';
|
|
638
817
|
public readonly driver: BrowserDriver;
|
|
639
|
-
private readonly operation:
|
|
818
|
+
private readonly operation: ShipinhaoOperationName;
|
|
640
819
|
private readonly launcher: BrowserLauncher;
|
|
641
820
|
private readonly stepTimeoutMs: number;
|
|
642
821
|
constructor(
|
|
643
|
-
operation:
|
|
822
|
+
operation: ShipinhaoOperationName = 'shortVideo',
|
|
644
823
|
driver: BrowserDriver = 'script',
|
|
645
824
|
deps: { launcher?: BrowserLauncher; stepTimeoutMs?: number } = {},
|
|
646
825
|
) {
|
|
@@ -651,7 +830,8 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
651
830
|
}
|
|
652
831
|
|
|
653
832
|
/**
|
|
654
|
-
* Publishes one Content as a shipinhao
|
|
833
|
+
* Publishes one Content as a shipinhao post (per the resolved operation) — a draft (default)
|
|
834
|
+
* or public work.
|
|
655
835
|
* @param payload - Target content plus per-call options.
|
|
656
836
|
* @returns The publish `Result`, `ok: true` only from an observed fresh persisted receipt.
|
|
657
837
|
*/
|
|
@@ -672,7 +852,9 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
672
852
|
`unknown publishStatus '${bounded(requested)}' for ${SHP_TARGET}: expected 'draft', 'public' or absent (absent defaults to draft)`,
|
|
673
853
|
);
|
|
674
854
|
}
|
|
675
|
-
|
|
855
|
+
// Only the shortVideo flow pins Content.format; the other flows accept the episode/article
|
|
856
|
+
// Content as-is (the daily episode payload is format markdown).
|
|
857
|
+
if (this.operation === 'shortVideo' && payload.content.format !== 'video') {
|
|
676
858
|
return fail(
|
|
677
859
|
SHP_TARGET,
|
|
678
860
|
`shipinhao shortVideo requires Content.format 'video', got '${bounded(payload.content.format)}'`,
|
|
@@ -682,29 +864,49 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
682
864
|
if (title.length === 0) {
|
|
683
865
|
return fail(
|
|
684
866
|
SHP_TARGET,
|
|
685
|
-
|
|
867
|
+
`shipinhao ${this.operation} requires a non-empty Content.title (the 短标题 input, shipinhao.js:638-654)`,
|
|
686
868
|
);
|
|
687
869
|
}
|
|
688
870
|
const body = payload.content.body.trim();
|
|
689
871
|
if (body.length === 0) {
|
|
690
872
|
return fail(
|
|
691
873
|
SHP_TARGET,
|
|
692
|
-
|
|
874
|
+
`shipinhao ${this.operation} requires non-empty Content.body Markdown (the 添加描述 description is pasted as sanitized text/html, shipinhao.js:669-674)`,
|
|
693
875
|
);
|
|
694
876
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
const
|
|
698
|
-
|
|
877
|
+
// Per-operation media payload: shortVideo videoPath, audio/music audio(audioFile), image
|
|
878
|
+
// images[]; the cover is requested-only and never read for image (图文 has no cover rails).
|
|
879
|
+
const metadataRecord = (payload.content.metadata ?? {}) as Record<string, unknown>;
|
|
880
|
+
let media: readonly string[];
|
|
881
|
+
let coverPath: string | undefined;
|
|
882
|
+
if (this.operation === 'shortVideo') {
|
|
883
|
+
const video = await resolveVideoPath(metadataRecord.videoPath);
|
|
884
|
+
if (video.error !== undefined) return fail(SHP_TARGET, video.error);
|
|
885
|
+
media = [video.path as string];
|
|
886
|
+
const cover = await resolveCoverPath(payload.content.metadata?.coverPath ?? payload.options?.coverPath);
|
|
887
|
+
if (cover.error !== undefined) return fail(SHP_TARGET, cover.error);
|
|
888
|
+
coverPath = cover.path;
|
|
889
|
+
} else if (this.operation === 'audio' || this.operation === 'music') {
|
|
890
|
+
const audio = await resolveAudioPath(metadataRecord.audio ?? metadataRecord.audioFile);
|
|
891
|
+
if (audio.error !== undefined) return fail(SHP_TARGET, audio.error);
|
|
892
|
+
media = [audio.path as string];
|
|
893
|
+
const cover = await resolveCoverPath(payload.content.metadata?.coverPath ?? payload.options?.coverPath);
|
|
894
|
+
if (cover.error !== undefined) return fail(SHP_TARGET, cover.error);
|
|
895
|
+
coverPath = cover.path;
|
|
896
|
+
} else {
|
|
897
|
+
const images = await resolveImagesPath(metadataRecord.images);
|
|
898
|
+
if (images.error !== undefined) return fail(SHP_TARGET, images.error);
|
|
899
|
+
media = images.paths as readonly string[];
|
|
900
|
+
}
|
|
699
901
|
const tags = resolveTags(payload.content.metadata?.tags ?? payload.options?.tags);
|
|
700
902
|
if (tags.error !== undefined) return fail(SHP_TARGET, tags.error);
|
|
701
903
|
const original = resolveOriginal(payload.content.metadata?.original);
|
|
702
904
|
if (original.error !== undefined) return fail(SHP_TARGET, original.error);
|
|
703
|
-
const unsupported = unsupportedFields(payload);
|
|
905
|
+
const unsupported = unsupportedFields(payload, this.operation);
|
|
704
906
|
if (unsupported.length > 0) {
|
|
705
907
|
return fail(
|
|
706
908
|
SHP_TARGET,
|
|
707
|
-
`unsupported field(s) ${unsupported.join(', ')} for shipinhao
|
|
909
|
+
`unsupported field(s) ${unsupported.join(', ')} for shipinhao ${this.operation}: implemented fields are title/description/tags/media/cover/original declaration only, and scheduling/publishTime is an unported vendor enhancement (shipinhao.js:7-9)`,
|
|
708
910
|
);
|
|
709
911
|
}
|
|
710
912
|
|
|
@@ -732,7 +934,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
732
934
|
return await withProfilePage(
|
|
733
935
|
{
|
|
734
936
|
profileDir,
|
|
735
|
-
url:
|
|
937
|
+
url: SHP_HOME_URL_BY_OPERATION[this.operation],
|
|
736
938
|
isAuthenticated: isShipinhaoAuthenticated,
|
|
737
939
|
// Headed by default; the headless preflight above is the unattended pass and
|
|
738
940
|
// `options.headless === true` the opt-in.
|
|
@@ -743,14 +945,15 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
743
945
|
timeoutMs: this.stepTimeoutMs,
|
|
744
946
|
},
|
|
745
947
|
async ({ page }) =>
|
|
746
|
-
this.
|
|
948
|
+
this.runPostFlow(
|
|
747
949
|
page,
|
|
950
|
+
POST_FLOW_SPECS[this.operation],
|
|
748
951
|
title,
|
|
749
952
|
body,
|
|
750
953
|
tags.tags as readonly string[],
|
|
751
954
|
original.original === true,
|
|
752
|
-
|
|
753
|
-
|
|
955
|
+
media,
|
|
956
|
+
coverPath,
|
|
754
957
|
requested === 'public',
|
|
755
958
|
profileDir,
|
|
756
959
|
),
|
|
@@ -769,19 +972,22 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
769
972
|
}
|
|
770
973
|
|
|
771
974
|
/**
|
|
772
|
-
* The live
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
975
|
+
* The live post flow on the already-navigated dashboard (recon-Grounded 2026-11-11: ALL
|
|
976
|
+
* operations enter through the dashboard — direct per-kind URLs redirect there): dashboard
|
|
977
|
+
* create-entry click-through (发表视频 → /platform/post/create) → the bounded wujie root
|
|
978
|
+
* policy (never a wrong root) → media attach with editing-form verification → title fill with
|
|
979
|
+
* readback → sanitized description/topics paste with readback → requested-only 声明原创 →
|
|
980
|
+
* optional committed cover → the draft save or the explicit-public 发表 → fresh-receipt
|
|
981
|
+
* confirmation.
|
|
777
982
|
*/
|
|
778
|
-
private async
|
|
983
|
+
private async runPostFlow(
|
|
779
984
|
page: Page,
|
|
985
|
+
spec: PostFlowSpec,
|
|
780
986
|
title: string,
|
|
781
987
|
body: string,
|
|
782
988
|
tags: readonly string[],
|
|
783
989
|
declareOriginal: boolean,
|
|
784
|
-
|
|
990
|
+
media: readonly string[],
|
|
785
991
|
coverPath: string | undefined,
|
|
786
992
|
publishPublic: boolean,
|
|
787
993
|
profileDir: string,
|
|
@@ -795,6 +1001,49 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
795
1001
|
...(declareOriginal ? { original: true } : {}),
|
|
796
1002
|
};
|
|
797
1003
|
|
|
1004
|
+
// Dashboard click-through: the entry button opens the unified /platform/post/create
|
|
1005
|
+
// surface (recon-Grounded 2026-11-11); the create page is confirmed by a media file input
|
|
1006
|
+
// appearing in the active root. Already-open create pages (defensive re-entry) skip the
|
|
1007
|
+
// click.
|
|
1008
|
+
const entrySnapshot = await readRootSnapshot(page);
|
|
1009
|
+
if (entrySnapshot.shadowFileInputs + entrySnapshot.directFileInputs === 0) {
|
|
1010
|
+
const entryRoot = await resolveCreatorRoot(page);
|
|
1011
|
+
if (entryRoot.error !== undefined) return stageFail(SHP_TARGET, entryRoot.error, 'root-resolve', metadata);
|
|
1012
|
+
try {
|
|
1013
|
+
const entry = (
|
|
1014
|
+
await resolveRootLocator(
|
|
1015
|
+
page,
|
|
1016
|
+
entryRoot.mode as 'wujie' | 'direct',
|
|
1017
|
+
spec.selectors.createEntry,
|
|
1018
|
+
'shipinhao create entry',
|
|
1019
|
+
this.stepTimeoutMs,
|
|
1020
|
+
)
|
|
1021
|
+
).locator;
|
|
1022
|
+
await entry.click();
|
|
1023
|
+
} catch (error) {
|
|
1024
|
+
return stageFail(
|
|
1025
|
+
SHP_TARGET,
|
|
1026
|
+
`shipinhao create entry click failed — ${errorMessage(error)}`,
|
|
1027
|
+
'entry-open',
|
|
1028
|
+
metadata,
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
1031
|
+
const opened = await expectOutcome(
|
|
1032
|
+
async () => {
|
|
1033
|
+
const snapshot = await readRootSnapshot(page);
|
|
1034
|
+
return snapshot.shadowFileInputs + snapshot.directFileInputs > 0 ? 'create surface open' : null;
|
|
1035
|
+
},
|
|
1036
|
+
{ timeoutMs: this.stepTimeoutMs, label: 'shipinhao create surface' },
|
|
1037
|
+
);
|
|
1038
|
+
if (!opened.ok)
|
|
1039
|
+
return stageFail(
|
|
1040
|
+
SHP_TARGET,
|
|
1041
|
+
`shipinhao create surface never opened after the entry click — no media file input appeared in the active root — ${opened.error}`,
|
|
1042
|
+
'entry-open',
|
|
1043
|
+
metadata,
|
|
1044
|
+
);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
798
1047
|
// Root-resolve BEFORE any upload: the bounded wujie policy — wujie shadowRoot only, or the
|
|
799
1048
|
// unique direct creator form; ambiguity/absence refuses here (see `resolveCreatorRoot`).
|
|
800
1049
|
const root = await resolveCreatorRoot(page);
|
|
@@ -809,23 +1058,25 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
809
1058
|
const resolved = await resolveRootLocator(
|
|
810
1059
|
page,
|
|
811
1060
|
mode,
|
|
812
|
-
|
|
813
|
-
|
|
1061
|
+
spec.fileSelectors,
|
|
1062
|
+
`shipinhao ${spec.mediaLabel} file input`,
|
|
814
1063
|
this.stepTimeoutMs,
|
|
815
1064
|
);
|
|
816
1065
|
if (resolved.selector === 'input[type="file"]' && (await resolved.locator.count()) !== 1) {
|
|
817
1066
|
return stageFail(
|
|
818
1067
|
SHP_TARGET,
|
|
819
|
-
`shipinhao
|
|
1068
|
+
`shipinhao ${spec.mediaLabel} file input ambiguous: the untyped input[type=file] candidate matched more than one input in the ${mode === 'wujie' ? 'wujie shadowRoot' : 'document'} root — the vendor resolves a unique untyped input or nothing (shipinhao.js:580-583)`,
|
|
820
1069
|
'root-resolve',
|
|
821
1070
|
metadata,
|
|
822
1071
|
);
|
|
823
1072
|
}
|
|
824
|
-
await resolved.locator.setInputFiles(
|
|
1073
|
+
await resolved.locator.setInputFiles(media.length === 1 ? (media[0] as string) : media, {
|
|
1074
|
+
timeout: this.stepTimeoutMs,
|
|
1075
|
+
});
|
|
825
1076
|
} catch (error) {
|
|
826
1077
|
return stageFail(
|
|
827
1078
|
SHP_TARGET,
|
|
828
|
-
`shipinhao
|
|
1079
|
+
`shipinhao ${spec.mediaLabel} file input/attach failed on ${page.url()}: ${errorMessage(error)}`,
|
|
829
1080
|
'upload-timeout',
|
|
830
1081
|
metadata,
|
|
831
1082
|
);
|
|
@@ -843,7 +1094,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
843
1094
|
await resolveRootLocator(
|
|
844
1095
|
page,
|
|
845
1096
|
mode,
|
|
846
|
-
|
|
1097
|
+
spec.selectors.titleInput,
|
|
847
1098
|
'shipinhao title input',
|
|
848
1099
|
this.stepTimeoutMs,
|
|
849
1100
|
)
|
|
@@ -852,7 +1103,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
852
1103
|
await resolveRootLocator(
|
|
853
1104
|
page,
|
|
854
1105
|
mode,
|
|
855
|
-
|
|
1106
|
+
spec.selectors.descriptionEditor,
|
|
856
1107
|
'shipinhao description editor',
|
|
857
1108
|
this.stepTimeoutMs,
|
|
858
1109
|
)
|
|
@@ -860,7 +1111,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
860
1111
|
} catch (error) {
|
|
861
1112
|
return stageFail(
|
|
862
1113
|
SHP_TARGET,
|
|
863
|
-
`shipinhao media processing not confirmed: the file was assigned but the post-upload editing form never appeared — ${errorMessage(error)}; refusing to claim an uploaded
|
|
1114
|
+
`shipinhao media processing not confirmed: the file was assigned but the post-upload editing form never appeared — ${errorMessage(error)}; refusing to claim an uploaded ${spec.mediaLabel}`,
|
|
864
1115
|
'upload-processing',
|
|
865
1116
|
metadata,
|
|
866
1117
|
);
|
|
@@ -875,7 +1126,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
875
1126
|
if (!formReady.ok) {
|
|
876
1127
|
return stageFail(
|
|
877
1128
|
SHP_TARGET,
|
|
878
|
-
`shipinhao media processing not confirmed within the ${SHP_UPLOAD_TIMEOUT_MS}ms ceiling — the file was assigned but no editing form appeared; refusing to claim an uploaded
|
|
1129
|
+
`shipinhao media processing not confirmed within the ${SHP_UPLOAD_TIMEOUT_MS}ms ceiling — the file was assigned but no editing form appeared; refusing to claim an uploaded ${spec.mediaLabel}`,
|
|
879
1130
|
'upload-processing',
|
|
880
1131
|
metadata,
|
|
881
1132
|
);
|
|
@@ -889,7 +1140,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
889
1140
|
await resolveRootLocator(
|
|
890
1141
|
page,
|
|
891
1142
|
mode,
|
|
892
|
-
|
|
1143
|
+
spec.selectors.titleInput,
|
|
893
1144
|
'shipinhao title input',
|
|
894
1145
|
this.stepTimeoutMs,
|
|
895
1146
|
)
|
|
@@ -919,22 +1170,20 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
919
1170
|
);
|
|
920
1171
|
}
|
|
921
1172
|
|
|
922
|
-
// Description + topics:
|
|
923
|
-
//
|
|
924
|
-
//
|
|
925
|
-
//
|
|
926
|
-
// the readback
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
),
|
|
931
|
-
);
|
|
1173
|
+
// Description + topics: the editor retains plain text only (headings lose `#`, links
|
|
1174
|
+
// keep just their text) and hard-truncates any paste to 100 chars (Grounded live probe
|
|
1175
|
+
// 2026-11-11), so the pasted content IS the clipped plain description (topics appended as
|
|
1176
|
+
// `#tag`, the vendor strips `#`/trims the same way before writing, shipinhao.js:2689-2692),
|
|
1177
|
+
// and the readback asserts that same string. Topic-token conversion (the vendor's
|
|
1178
|
+
// per-topic paste + Enter, shipinhao.js:1414) is not asserted — the readback is
|
|
1179
|
+
// text-level, and the receipt stage re-verifies persistence.
|
|
1180
|
+
const { description, html } = buildShipinhaoDescription(body, tags);
|
|
932
1181
|
try {
|
|
933
1182
|
const editorSelector = (
|
|
934
1183
|
await resolveRootLocator(
|
|
935
1184
|
page,
|
|
936
1185
|
mode,
|
|
937
|
-
|
|
1186
|
+
spec.selectors.descriptionEditor,
|
|
938
1187
|
'shipinhao description editor',
|
|
939
1188
|
this.stepTimeoutMs,
|
|
940
1189
|
)
|
|
@@ -944,7 +1193,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
944
1193
|
async () => {
|
|
945
1194
|
const editorText = String(await page.evaluate(editorTextScript(mode, editorSelector)));
|
|
946
1195
|
return editorText.length > 0 &&
|
|
947
|
-
normalizeText(editorText).includes(normalizeText(
|
|
1196
|
+
normalizeText(editorText).includes(normalizeText(description)) &&
|
|
948
1197
|
tags.every((tag) => editorText.includes(`#${tag.replace(/^#/, '')}`))
|
|
949
1198
|
? 'description and topics read back'
|
|
950
1199
|
: null;
|
|
@@ -988,7 +1237,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
988
1237
|
// (shipinhao.js:2312-2316). Missing current control = typed failure, never a manufactured
|
|
989
1238
|
// draft and never a publish fallback for a requested draft.
|
|
990
1239
|
const stage = publishPublic ? 'publish-click' : 'draft-save';
|
|
991
|
-
const submitSelectors = publishPublic ?
|
|
1240
|
+
const submitSelectors = publishPublic ? spec.selectors.publishButton : spec.selectors.saveButton;
|
|
992
1241
|
let submitLocator: Locator;
|
|
993
1242
|
try {
|
|
994
1243
|
const resolved = await resolveRootLocator(
|
|
@@ -1039,6 +1288,13 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
1039
1288
|
await submitLocator.click();
|
|
1040
1289
|
const confirmed = await expectOutcome(
|
|
1041
1290
|
async () => {
|
|
1291
|
+
if (!publishPublic) {
|
|
1292
|
+
// 定时发表 guard (Grounded 2026-11-11): a draft save opens the confirm dialog;
|
|
1293
|
+
// absent dialog = no-op. Fail-closed stays with the receipt ceiling below.
|
|
1294
|
+
const confirmRaw = String(await page.evaluate(draftConfirmClickScript(mode)));
|
|
1295
|
+
const confirm = JSON.parse(confirmRaw) as { ok: boolean; reason?: string };
|
|
1296
|
+
if (confirm.ok) return null; // 保存 clicked — receipts land on a later poll
|
|
1297
|
+
}
|
|
1042
1298
|
const fresh = (await readReceiptUrls(page)).filter((candidate) => !beforeReceipts.has(candidate));
|
|
1043
1299
|
if (fresh.length === 0) return null;
|
|
1044
1300
|
const ids = new Set(fresh.map(receiptIdFrom).filter((id): id is string => id !== undefined));
|
|
@@ -1092,7 +1348,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
1092
1348
|
target: SHP_TARGET,
|
|
1093
1349
|
id: receiptIdFrom(url),
|
|
1094
1350
|
url,
|
|
1095
|
-
message: `shipinhao
|
|
1351
|
+
message: `shipinhao ${this.operation} ${publishStatus} confirmed in profile ${profileDir}`,
|
|
1096
1352
|
metadata: { ...metadata, confirmedBy: receiptStage },
|
|
1097
1353
|
});
|
|
1098
1354
|
}
|