@gobing-ai/knowledge-kit 0.1.19 → 0.1.22
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/board/collect/index.js +1 -0
- package/dist/board/daily-voice/index.js +1315 -264
- package/dist/board/itc/index.js +1 -0
- package/dist/index.js +14674 -8775
- package/package.json +1 -1
- package/plugins/generations/dailynews-gen/dist/index.js +285 -16
- package/plugins/generations/dailynews-gen/src/editorial-claims.ts +215 -0
- package/plugins/generations/dailynews-gen/src/index.ts +23 -4
- package/plugins/generations/dailynews-gen/src/script-builder.ts +10 -3
- package/plugins/generations/dailynews-gen/src/script-plan.ts +74 -14
- package/plugins/generations/image-gen/README.md +31 -31
- package/plugins/generations/image-gen/assets/sample/provenance.json +314 -0
- package/plugins/generations/image-gen/config.example.yaml +3 -0
- package/plugins/generations/image-gen/dist/index.js +154 -14
- package/plugins/generations/image-gen/presets/SOURCE.md +65 -0
- package/plugins/generations/image-gen/scripts/eval-style-presets.ts +513 -0
- package/plugins/generations/image-gen/scripts/gen-samples.ts +57 -7
- package/plugins/generations/image-gen/src/presets.ts +6 -5
- package/plugins/generations/image-gen/src/providers/h3-local.ts +196 -0
- package/plugins/generations/image-gen/src/providers/types.ts +11 -1
- package/plugins/generations/music-gen/README.md +277 -0
- package/plugins/generations/music-gen/dist/index.js +23544 -0
- package/plugins/generations/music-gen/package.json +24 -0
- package/plugins/generations/music-gen/plugin.json +23 -0
- package/plugins/generations/music-gen/presets/SOURCE.md +39 -0
- package/plugins/generations/music-gen/presets/formats/clip.yaml +21 -0
- package/plugins/generations/music-gen/presets/formats/jingle.yaml +22 -0
- package/plugins/generations/music-gen/presets/formats/loop.yaml +21 -0
- package/plugins/generations/music-gen/presets/formats/song.yaml +31 -0
- package/plugins/generations/music-gen/presets/formats/underscore.yaml +22 -0
- package/plugins/generations/music-gen/presets/themes/ambient-tech.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/cinematic.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/lofi.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/synthwave.yaml +30 -0
- package/plugins/generations/music-gen/scripts/gen-preset-index.ts +181 -0
- package/plugins/generations/music-gen/scripts/resolve-preset.ts +64 -0
- package/plugins/generations/music-gen/src/adapter/index.ts +35 -0
- package/plugins/generations/music-gen/src/adapter/instance.ts +904 -0
- package/plugins/generations/music-gen/src/adapter/offline.ts +124 -0
- package/plugins/generations/music-gen/src/artifact.ts +223 -0
- package/plugins/generations/music-gen/src/audio/checks.ts +618 -0
- package/plugins/generations/music-gen/src/audio/master.ts +267 -0
- package/plugins/generations/music-gen/src/audio/measure.ts +507 -0
- package/plugins/generations/music-gen/src/audio/profile.ts +131 -0
- package/plugins/generations/music-gen/src/audio.ts +122 -0
- package/plugins/generations/music-gen/src/brief.ts +191 -0
- package/plugins/generations/music-gen/src/config.ts +451 -0
- package/plugins/generations/music-gen/src/content.ts +199 -0
- package/plugins/generations/music-gen/src/digest.ts +100 -0
- package/plugins/generations/music-gen/src/index.ts +147 -0
- package/plugins/generations/music-gen/src/job.ts +131 -0
- package/plugins/generations/music-gen/src/plugin.ts +371 -0
- package/plugins/generations/music-gen/src/presets.ts +918 -0
- package/plugins/generations/music-gen/src/render.ts +87 -0
- package/plugins/generations/music-gen/src/request.ts +102 -0
- package/plugins/generations/music-gen/src/spend.ts +495 -0
- package/plugins/generations/music-gen/tsconfig.json +8 -0
- package/plugins/kk/config.example.yaml +3 -0
- package/plugins/kk/decisions/extract/ai-news.yaml +5 -2
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +48 -7
- package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +2 -1
- package/plugins/kk/scripts/cover-compositor.ts +380 -32
- package/plugins/kk/scripts/daily-cover-mock.ts +40 -3
- package/plugins/kk/scripts/daily-stages.ts +897 -34
- package/plugins/kk/scripts/episode-identity.ts +180 -0
- package/plugins/kk/scripts/kk-workflow-stages.ts +37 -1
- package/plugins/kk/scripts/music-stages.ts +624 -0
- package/plugins/kk/scripts/news-editorial-ledger.ts +906 -0
- package/plugins/kk/scripts/source-citation.ts +187 -0
- package/plugins/kk/scripts/topic-selection-attempts.ts +446 -0
- package/plugins/kk/scripts/topic-selection-calibration.ts +161 -0
- package/plugins/kk/skills/content-judge/SKILL.md +11 -6
- package/plugins/kk/skills/content-judge/references/music-quality-rubric.md +147 -0
- package/plugins/kk/skills/content-judge/references/rubrics.md +15 -0
- package/plugins/kk/skills/content-safety/SKILL.md +12 -0
- package/plugins/kk/skills/image-authoring/SKILL.md +7 -3
- package/plugins/kk/skills/image-authoring/references/providers.md +27 -0
- package/plugins/kk/skills/image-authoring/references/style-extraction.md +1 -1
- package/plugins/kk/skills/music-authoring/SKILL.md +276 -0
- package/plugins/kk/skills/music-authoring/references/judge-input.md +117 -0
- package/plugins/kk/skills/news-editorial/SKILL.md +102 -15
- package/plugins/kk/skills/news-editorial/references/selection.md +4 -0
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +58 -11
- package/plugins/kk/skills/publish/SKILL.md +11 -0
- package/plugins/kk/skills/web-automation/SKILL.md +31 -1
- package/plugins/kk/workflows/kk-collect.yaml +8 -4
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +10 -9
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +11 -9
- package/plugins/kk/workflows/kk-music.yaml +328 -0
- package/plugins/kk/workflows/kk-news-generate.yaml +58 -3
- package/plugins/publishings/bilibili-pub/dist/index.js +11 -1
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/cnblogs-pub/dist/index.js +11 -1
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/csdn-pub/dist/index.js +11 -1
- package/plugins/publishings/csdn-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/infoq-pub/dist/index.js +11 -1
- package/plugins/publishings/infoq-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/jike-pub/dist/index.js +11 -1
- package/plugins/publishings/jike-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/juejin-pub/dist/index.js +11 -1
- package/plugins/publishings/juejin-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/linkedin-pub/dist/index.js +54 -7
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +43 -6
- package/plugins/publishings/linkedin-pub/src/index.ts +52 -6
- package/plugins/publishings/podcast-pub/dist/index.js +586 -20
- package/plugins/publishings/podcast-pub/src/corrections.ts +509 -0
- package/plugins/publishings/podcast-pub/src/index.ts +257 -5
- package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +240 -0
- package/plugins/publishings/podcast-pub/src/show-notes.ts +69 -13
- package/plugins/publishings/shipinhao-pub/dist/index.js +437 -32
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +14 -2
- package/plugins/publishings/shipinhao-pub/plugin.json +1 -1
- package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +492 -0
- package/plugins/publishings/shipinhao-pub/src/flow.ts +227 -12
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -0
- package/plugins/publishings/sspai-pub/dist/index.js +11 -1
- package/plugins/publishings/sspai-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/substack-pub/dist/index.js +11 -1
- package/plugins/publishings/substack-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/surfdash-pub/dist/index.js +122 -28
- package/plugins/publishings/surfdash-pub/src/digest-check.ts +7 -3
- package/plugins/publishings/surfdash-pub/src/index.ts +159 -25
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +37 -4
- package/plugins/publishings/threads-pub/dist/index.js +9206 -296
- package/plugins/publishings/threads-pub/dist/profile-check.js +21149 -0
- package/plugins/publishings/threads-pub/package.json +3 -1
- package/plugins/publishings/threads-pub/plugin.json +6 -1
- package/plugins/publishings/threads-pub/src/index.ts +8 -1
- package/plugins/publishings/threads-pub/src/post-rail.ts +357 -0
- package/plugins/publishings/threads-pub/src/profile-check.ts +17 -0
- package/plugins/publishings/wechatmp-pub/dist/index.js +18 -1
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/wechatmp-pub/src/flow.ts +13 -0
- package/plugins/publishings/weibo-pub/dist/index.js +57 -3
- package/plugins/publishings/weibo-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/weibo-pub/src/index.ts +74 -2
- package/plugins/publishings/x-pub/dist/index.js +274 -44
- package/plugins/publishings/x-pub/dist/profile-check.js +14 -2
- package/plugins/publishings/x-pub/src/index.ts +15 -1
- package/plugins/publishings/x-pub/src/post-rail.ts +334 -0
- package/plugins/publishings/xhs-pub/dist/index.js +11 -1
- package/plugins/publishings/xhs-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +11 -1
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +11 -1
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
withProfilePage,
|
|
52
52
|
} from '@gobing-ai/ts-browser-automation';
|
|
53
53
|
import type { Locator, Page } from 'playwright';
|
|
54
|
+
import { runAudioPostFlow } from './audio-flow';
|
|
54
55
|
import {
|
|
55
56
|
isShipinhaoAuthenticated,
|
|
56
57
|
readRootSnapshot,
|
|
@@ -72,7 +73,20 @@ import {
|
|
|
72
73
|
type ShipinhaoRootSnapshot,
|
|
73
74
|
} from './selectors';
|
|
74
75
|
|
|
76
|
+
/** Steps (fill, upload, dialog) keep the shared 30s rail. */
|
|
75
77
|
const STEP_TIMEOUT_MS = 30_000;
|
|
78
|
+
/**
|
|
79
|
+
* The read-only session preflight is a cold headless launch plus a readiness poll; the shipped
|
|
80
|
+
* probe verifies the same profile with a 120s budget (`profile-check check --timeout 120000`) while
|
|
81
|
+
* this call was capped at the 30s STEP budget, so a healthy session that takes 40-60s to paint read
|
|
82
|
+
* as `Authentication was not confirmed` (2026-11-13: check verified, publish refused).
|
|
83
|
+
*/
|
|
84
|
+
const PREFLIGHT_TIMEOUT_MS = 180_000;
|
|
85
|
+
/**
|
|
86
|
+
* Per-poll budget for the 合集 control probe inside the selection loop: the row either exists or
|
|
87
|
+
* does not, so a long wait per attempt only delays the typed refusal (2026-11-16).
|
|
88
|
+
*/
|
|
89
|
+
const COLLECTION_PROBE_MS = 2_000;
|
|
76
90
|
/**
|
|
77
91
|
* KK v1 local-media size bound (task 0296 Design freeze): 2 GiB, applied to every media kind. A
|
|
78
92
|
* project-scoped product bound, not a platform limit — Channels' own ceiling is unpinned.
|
|
@@ -567,6 +581,22 @@ function resolveOriginal(
|
|
|
567
581
|
return { original: raw };
|
|
568
582
|
}
|
|
569
583
|
|
|
584
|
+
/**
|
|
585
|
+
* Pre-browser 合集 gate (2026-11-16): an optional non-empty collection title, applied to the AUDIO
|
|
586
|
+
* post only. A collection that cannot be committed is a typed failure *before* the submit click —
|
|
587
|
+
* the operator asked for the episode to live in 合集 `每日AI乱炖`, so publishing without it is not
|
|
588
|
+
* a degraded success, it is the wrong result.
|
|
589
|
+
*/
|
|
590
|
+
function resolveCollection(
|
|
591
|
+
raw: unknown,
|
|
592
|
+
): { collection?: string; error?: undefined } | { collection?: undefined; error: string } {
|
|
593
|
+
if (raw === undefined) return {};
|
|
594
|
+
if (typeof raw !== 'string' || raw.trim().length === 0) {
|
|
595
|
+
return { error: `collection must be a nonempty string when present, got '${bounded(raw)}'` };
|
|
596
|
+
}
|
|
597
|
+
return { collection: raw.trim() };
|
|
598
|
+
}
|
|
599
|
+
|
|
570
600
|
/**
|
|
571
601
|
* Unsupported requested fields, per operation: fields that mean nothing to the requested flow —
|
|
572
602
|
* images/videoPath outside their own operation, coverPath for 图文 — are typed unsupported-field
|
|
@@ -575,11 +605,14 @@ function resolveOriginal(
|
|
|
575
605
|
* `coverPath` (except on image) are implemented and validated in their resolvers.
|
|
576
606
|
*/
|
|
577
607
|
function unsupportedFields(payload: PublishTransportPayload, operation: ShipinhaoOperationName): readonly string[] {
|
|
608
|
+
// `collection` is implemented for AUDIO only (2026-11-16): the other three kinds must keep
|
|
609
|
+
// their exact current behaviour, so a collection request on them is refused by name instead of
|
|
610
|
+
// silently ignored.
|
|
578
611
|
const perOperation: Record<ShipinhaoOperationName, readonly string[]> = {
|
|
579
|
-
shortVideo: ['images', 'categories', 'publishTime', 'scheduling'],
|
|
612
|
+
shortVideo: ['images', 'categories', 'publishTime', 'scheduling', 'collection'],
|
|
580
613
|
audio: ['videoPath', 'images', 'categories', 'publishTime', 'scheduling'],
|
|
581
|
-
music: ['videoPath', 'images', 'categories', 'publishTime', 'scheduling'],
|
|
582
|
-
image: ['videoPath', 'coverPath', 'categories', 'publishTime', 'scheduling'],
|
|
614
|
+
music: ['videoPath', 'images', 'categories', 'publishTime', 'scheduling', 'collection'],
|
|
615
|
+
image: ['videoPath', 'coverPath', 'categories', 'publishTime', 'scheduling', 'collection'],
|
|
583
616
|
};
|
|
584
617
|
const refused: string[] = [];
|
|
585
618
|
for (const [container, source] of [
|
|
@@ -620,6 +653,55 @@ function editingFormReadyScript(mode: 'wujie' | 'direct', titleSelector: string,
|
|
|
620
653
|
})()`;
|
|
621
654
|
}
|
|
622
655
|
|
|
656
|
+
/**
|
|
657
|
+
* 合集 (collection) control, one parameterised page script (2026-11-16).
|
|
658
|
+
*
|
|
659
|
+
* The audio form's collection row ships without a stable class, so this works from text alone:
|
|
660
|
+
* `click-entry` finds the rendered row whose own text starts with the 合集 label and clicks it,
|
|
661
|
+
* `click-option` picks the option whose own text equals the requested collection (exact, never by
|
|
662
|
+
* index) — a native `<select>` is served by assigning the matching option's value — and `read`
|
|
663
|
+
* re-reads the row afterwards so a click that did not commit is never mistaken for a selection.
|
|
664
|
+
*/
|
|
665
|
+
function collectionScript(
|
|
666
|
+
mode: 'wujie' | 'direct',
|
|
667
|
+
action: 'click-entry' | 'click-option' | 'read',
|
|
668
|
+
label: string,
|
|
669
|
+
name: string,
|
|
670
|
+
): string {
|
|
671
|
+
return `${rootScriptPrefix(mode)} // kk-shp-collection
|
|
672
|
+
const label = ${JSON.stringify(label)};
|
|
673
|
+
const name = ${JSON.stringify(name)};
|
|
674
|
+
const action = ${JSON.stringify(action)};
|
|
675
|
+
const roots = [document, root].filter(Boolean);
|
|
676
|
+
const ownText = (el) => Array.from(el.childNodes).filter((n) => n.nodeType === 3).map((n) => (n.textContent || '').trim()).join(' ').trim();
|
|
677
|
+
const rendered = (el) => { const r = el.getBoundingClientRect(); return r.width > 0 && r.height > 0; };
|
|
678
|
+
const all = [];
|
|
679
|
+
for (const scope of roots) {
|
|
680
|
+
if (!scope || !scope.querySelectorAll) continue;
|
|
681
|
+
for (const el of scope.querySelectorAll('*')) all.push(el);
|
|
682
|
+
}
|
|
683
|
+
const row = all.find((el) => rendered(el) && ownText(el).startsWith(label));
|
|
684
|
+
if (action === 'click-entry') {
|
|
685
|
+
if (!row) return JSON.stringify({ ok: false, reason: 'entry-absent' });
|
|
686
|
+
const target = row.closest('button, div, li, label') || row;
|
|
687
|
+
target.click();
|
|
688
|
+
return JSON.stringify({ ok: true, text: String(row.textContent || '').trim().slice(0, 80) });
|
|
689
|
+
}
|
|
690
|
+
if (action === 'click-option') {
|
|
691
|
+
const exact = all.filter((el) => rendered(el) && ownText(el) === name);
|
|
692
|
+
if (exact.length > 0) {
|
|
693
|
+
const option = exact[exact.length - 1];
|
|
694
|
+
(option.closest('li, div, label, button') || option).click();
|
|
695
|
+
return JSON.stringify({ ok: true, how: 'text' });
|
|
696
|
+
}
|
|
697
|
+
const near = all.filter((el) => rendered(el) && ownText(el).includes(name)).map((el) => ownText(el).slice(0, 40));
|
|
698
|
+
return JSON.stringify({ ok: false, reason: 'option-absent', seen: [...new Set(near)].slice(0, 8) });
|
|
699
|
+
}
|
|
700
|
+
const state = row === undefined ? '' : String(row.textContent || '').trim().slice(0, 120);
|
|
701
|
+
return JSON.stringify({ ok: state.includes(name), text: state });
|
|
702
|
+
})()`;
|
|
703
|
+
}
|
|
704
|
+
|
|
623
705
|
/**
|
|
624
706
|
* 声明原创 entry checkbox locator, vendor scoring ported verbatim (shipinhao.js:2233-2261):
|
|
625
707
|
* 原创/original attribute evidence, an associated 原创 label, or a short 原创 ancestor text;
|
|
@@ -830,15 +912,17 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
830
912
|
private readonly operation: ShipinhaoOperationName;
|
|
831
913
|
private readonly launcher: BrowserLauncher;
|
|
832
914
|
private readonly stepTimeoutMs: number;
|
|
915
|
+
private readonly preflightTimeoutMs: number;
|
|
833
916
|
constructor(
|
|
834
917
|
operation: ShipinhaoOperationName = 'shortVideo',
|
|
835
918
|
driver: BrowserDriver = 'script',
|
|
836
|
-
deps: { launcher?: BrowserLauncher; stepTimeoutMs?: number } = {},
|
|
919
|
+
deps: { launcher?: BrowserLauncher; stepTimeoutMs?: number; preflightTimeoutMs?: number } = {},
|
|
837
920
|
) {
|
|
838
921
|
this.operation = operation;
|
|
839
922
|
this.driver = driver;
|
|
840
923
|
this.launcher = deps.launcher ?? kkBrowserLauncher;
|
|
841
924
|
this.stepTimeoutMs = deps.stepTimeoutMs ?? STEP_TIMEOUT_MS;
|
|
925
|
+
this.preflightTimeoutMs = deps.preflightTimeoutMs ?? PREFLIGHT_TIMEOUT_MS;
|
|
842
926
|
}
|
|
843
927
|
|
|
844
928
|
/**
|
|
@@ -902,7 +986,14 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
902
986
|
const audio = await resolveAudioPath(metadataRecord.audio ?? metadataRecord.audioFile);
|
|
903
987
|
if (audio.error !== undefined) return fail(SHP_TARGET, audio.error);
|
|
904
988
|
media = [audio.path as string];
|
|
905
|
-
|
|
989
|
+
// 封面 source ladder: an explicit coverPath, else the bundle's own cover image. WHY the
|
|
990
|
+
// fallback (2026-11-16): the publish matrix builds the payload through ContentSchema,
|
|
991
|
+
// which strips the variant's top-level `options` block, so a daily episode arrives with
|
|
992
|
+
// `metadata.coverImage` only — and the 音频 form REFUSES to submit without a 封面
|
|
993
|
+
// (「请上传封面」), which is how every earlier audio publish ended `unknown`.
|
|
994
|
+
const cover = await resolveCoverPath(
|
|
995
|
+
payload.content.metadata?.coverPath ?? payload.options?.coverPath ?? metadataRecord.coverImage,
|
|
996
|
+
);
|
|
906
997
|
if (cover.error !== undefined) return fail(SHP_TARGET, cover.error);
|
|
907
998
|
coverPath = cover.path;
|
|
908
999
|
} else {
|
|
@@ -914,6 +1005,8 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
914
1005
|
if (tags.error !== undefined) return fail(SHP_TARGET, tags.error);
|
|
915
1006
|
const original = resolveOriginal(payload.content.metadata?.original);
|
|
916
1007
|
if (original.error !== undefined) return fail(SHP_TARGET, original.error);
|
|
1008
|
+
const collection = resolveCollection(payload.options?.collection ?? payload.content.metadata?.collection);
|
|
1009
|
+
if (collection.error !== undefined) return fail(SHP_TARGET, collection.error);
|
|
917
1010
|
const unsupported = unsupportedFields(payload, this.operation);
|
|
918
1011
|
if (unsupported.length > 0) {
|
|
919
1012
|
return fail(
|
|
@@ -930,15 +1023,24 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
930
1023
|
const session = await checkChannelSession(SHP_CONFIG, {
|
|
931
1024
|
profileDir,
|
|
932
1025
|
launcher: this.launcher,
|
|
933
|
-
|
|
934
|
-
|
|
1026
|
+
// Headless first, then one read-only headed pass (same rail as xhs-pub): shipinhao's
|
|
1027
|
+
// dashboard regularly paints past a 30-90s headless poll on a healthy session, and the
|
|
1028
|
+
// shipped probe (`profile-check check`) has always used this fallback — the publish
|
|
1029
|
+
// preflight was the only caller that disabled it, so `check` verified what `publish`
|
|
1030
|
+
// refused (2026-11-13).
|
|
1031
|
+
timeoutMs: this.preflightTimeoutMs,
|
|
935
1032
|
});
|
|
936
1033
|
if (session.status !== 'verified') {
|
|
937
1034
|
// The recovery command leads the message: `fail()` bounds the line, and the operator's
|
|
938
|
-
// next action must never be the part that gets truncated.
|
|
939
|
-
|
|
1035
|
+
// next action must never be the part that gets truncated. Effect none: no console visit
|
|
1036
|
+
// happened, so the bounded retry may resend it.
|
|
1037
|
+
return stageFail(
|
|
940
1038
|
SHP_TARGET,
|
|
941
1039
|
`${SHP_TARGET} session preflight refused — run: ${SHP_LOGIN_INSTRUCTION} — detail: ${session.detail}`,
|
|
1040
|
+
'session-preflight',
|
|
1041
|
+
{ operation: this.operation, publishStatus: 'draft' },
|
|
1042
|
+
undefined,
|
|
1043
|
+
'none',
|
|
942
1044
|
);
|
|
943
1045
|
}
|
|
944
1046
|
|
|
@@ -956,19 +1058,39 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
956
1058
|
// bounded step like every other one, not the 180s interactive login wait.
|
|
957
1059
|
timeoutMs: this.stepTimeoutMs,
|
|
958
1060
|
},
|
|
959
|
-
async ({ page }) =>
|
|
960
|
-
|
|
1061
|
+
async ({ page }) => {
|
|
1062
|
+
// 音频 has its own surface (`/platform/post/createAudio`); driving it through the
|
|
1063
|
+
// video rails is what made every audio publish end `uncertain` (2026-11-15).
|
|
1064
|
+
// shortVideo/image/music keep the flow below untouched.
|
|
1065
|
+
if (this.operation === 'audio') {
|
|
1066
|
+
return runAudioPostFlow({
|
|
1067
|
+
page,
|
|
1068
|
+
title,
|
|
1069
|
+
body,
|
|
1070
|
+
tags: tags.tags as readonly string[],
|
|
1071
|
+
media,
|
|
1072
|
+
coverPath,
|
|
1073
|
+
collection: collection.collection,
|
|
1074
|
+
publishPublic: requested === 'public',
|
|
1075
|
+
operation: this.operation,
|
|
1076
|
+
profileDir,
|
|
1077
|
+
stepTimeoutMs: this.stepTimeoutMs,
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
return this.runPostFlow(
|
|
961
1081
|
page,
|
|
962
1082
|
POST_FLOW_SPECS[this.operation],
|
|
963
1083
|
title,
|
|
964
1084
|
body,
|
|
965
1085
|
tags.tags as readonly string[],
|
|
966
1086
|
original.original === true,
|
|
1087
|
+
collection.collection,
|
|
967
1088
|
media,
|
|
968
1089
|
coverPath,
|
|
969
1090
|
requested === 'public',
|
|
970
1091
|
profileDir,
|
|
971
|
-
)
|
|
1092
|
+
);
|
|
1093
|
+
},
|
|
972
1094
|
);
|
|
973
1095
|
} catch (error) {
|
|
974
1096
|
// Same ordering rule as the preflight refusal: the recovery command is never the tail
|
|
@@ -999,6 +1121,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
999
1121
|
body: string,
|
|
1000
1122
|
tags: readonly string[],
|
|
1001
1123
|
declareOriginal: boolean,
|
|
1124
|
+
collection: string | undefined,
|
|
1002
1125
|
media: readonly string[],
|
|
1003
1126
|
coverPath: string | undefined,
|
|
1004
1127
|
publishPublic: boolean,
|
|
@@ -1011,6 +1134,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
1011
1134
|
publishStatus,
|
|
1012
1135
|
profileDir,
|
|
1013
1136
|
...(declareOriginal ? { original: true } : {}),
|
|
1137
|
+
...(collection !== undefined ? { collection } : {}),
|
|
1014
1138
|
};
|
|
1015
1139
|
|
|
1016
1140
|
// Dashboard click-through: the entry button opens the unified /platform/post/create
|
|
@@ -1228,6 +1352,15 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
1228
1352
|
);
|
|
1229
1353
|
}
|
|
1230
1354
|
|
|
1355
|
+
// 合集: AUDIO only, and only when requested (2026-11-16). Ordered after the description —
|
|
1356
|
+
// the row renders with the rest of the post-upload rails on that form — and before the
|
|
1357
|
+
// declaration/cover/submit so a collection that cannot be committed refuses while nothing
|
|
1358
|
+
// has been published yet.
|
|
1359
|
+
if (collection !== undefined) {
|
|
1360
|
+
const collected = await this.selectCollectionFlow(page, mode, spec, collection, metadata);
|
|
1361
|
+
if (collected !== undefined) return collected;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1231
1364
|
// 声明原创: ONLY on the explicit operator assertion (metadata.original === true); the
|
|
1232
1365
|
// vendor's unconditional run and log-only degradation (shipinhao.js:10-14, 2270-2310) are
|
|
1233
1366
|
// deliberately not mirrored. Ordering matches the vendor: after description, before cover
|
|
@@ -1367,6 +1500,88 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
1367
1500
|
});
|
|
1368
1501
|
}
|
|
1369
1502
|
|
|
1503
|
+
/**
|
|
1504
|
+
* 合集 selection for the AUDIO post (2026-11-16): open the row, click the option by exact text,
|
|
1505
|
+
* then require the row to read back the requested collection. Every step type-fails — a missing
|
|
1506
|
+
* row, an absent option or a click that did not commit — because the operator's requirement is
|
|
1507
|
+
* that the episode lives in that collection: publishing without it is the wrong result, not a
|
|
1508
|
+
* degraded one.
|
|
1509
|
+
*/
|
|
1510
|
+
private async selectCollectionFlow(
|
|
1511
|
+
page: Page,
|
|
1512
|
+
mode: 'wujie' | 'direct',
|
|
1513
|
+
spec: PostFlowSpec,
|
|
1514
|
+
collection: string,
|
|
1515
|
+
metadata: Record<string, unknown>,
|
|
1516
|
+
): Promise<Result | undefined> {
|
|
1517
|
+
const failCollection = (message: string, stage: string, evidence?: string): Result =>
|
|
1518
|
+
stageFail(SHP_TARGET, message, stage, metadata, evidence);
|
|
1519
|
+
const label = spec.selectors.collectionLabel;
|
|
1520
|
+
const read = (raw: string): { ok: boolean; reason?: string; text?: string; seen?: string[] } => {
|
|
1521
|
+
try {
|
|
1522
|
+
return JSON.parse(raw) as { ok: boolean; reason?: string; text?: string; seen?: string[] };
|
|
1523
|
+
} catch {
|
|
1524
|
+
return { ok: false, reason: 'unreadable-probe' };
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
const entry = read(String(await page.evaluate(collectionScript(mode, 'click-entry', label, collection))));
|
|
1528
|
+
if (!entry.ok) {
|
|
1529
|
+
return failCollection(
|
|
1530
|
+
`shipinhao 合集 (collection) row not found on the ${this.operation} form — refusing to publish outside the requested 合集 '${collection}'`,
|
|
1531
|
+
'collection-select',
|
|
1532
|
+
entry.reason,
|
|
1533
|
+
);
|
|
1534
|
+
}
|
|
1535
|
+
const option = await expectOutcome(
|
|
1536
|
+
async () => {
|
|
1537
|
+
const picked = read(
|
|
1538
|
+
String(await page.evaluate(collectionScript(mode, 'click-option', label, collection))),
|
|
1539
|
+
);
|
|
1540
|
+
if (picked.ok) return 'option clicked';
|
|
1541
|
+
// A native `<select>` renders no clickable option node: Playwright's own selectOption
|
|
1542
|
+
// is the write path for it (no page-script value assignment — the flow never writes
|
|
1543
|
+
// `.value`). It pierces open shadow roots, and a select without that label throws, so
|
|
1544
|
+
// a missing collection stays a typed refusal.
|
|
1545
|
+
const selects = page.locator('select');
|
|
1546
|
+
const count = await selects.count();
|
|
1547
|
+
for (let i = 0; i < count; i++) {
|
|
1548
|
+
try {
|
|
1549
|
+
await selects.nth(i).selectOption({ label: collection }, { timeout: COLLECTION_PROBE_MS });
|
|
1550
|
+
return 'option selected';
|
|
1551
|
+
} catch {
|
|
1552
|
+
// Not this select — keep looking; the refusal below still fires.
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
return null;
|
|
1556
|
+
},
|
|
1557
|
+
{ timeoutMs: this.stepTimeoutMs, label: 'shipinhao 合集 option' },
|
|
1558
|
+
);
|
|
1559
|
+
if (!option.ok) {
|
|
1560
|
+
const seen = read(String(await page.evaluate(collectionScript(mode, 'click-option', label, collection))));
|
|
1561
|
+
return failCollection(
|
|
1562
|
+
`shipinhao 合集 '${collection}' is not among the collections the account offers — refusing to publish outside it`,
|
|
1563
|
+
'collection-select',
|
|
1564
|
+
`${option.error}; seen: ${(seen.seen ?? []).join(' | ')}`,
|
|
1565
|
+
);
|
|
1566
|
+
}
|
|
1567
|
+
const commit = await expectOutcome(
|
|
1568
|
+
async () => {
|
|
1569
|
+
const state = read(String(await page.evaluate(collectionScript(mode, 'read', label, collection))));
|
|
1570
|
+
return state.ok ? 'collection read back' : null;
|
|
1571
|
+
},
|
|
1572
|
+
{ timeoutMs: this.stepTimeoutMs, label: 'shipinhao 合集 readback' },
|
|
1573
|
+
);
|
|
1574
|
+
if (!commit.ok) {
|
|
1575
|
+
const state = read(String(await page.evaluate(collectionScript(mode, 'read', label, collection))));
|
|
1576
|
+
return failCollection(
|
|
1577
|
+
`shipinhao 合集 '${collection}' was clicked but the form does not show it committed — refusing to submit`,
|
|
1578
|
+
'collection-readback',
|
|
1579
|
+
`row text: ${state.text ?? '<absent>'} — ${commit.error}`,
|
|
1580
|
+
);
|
|
1581
|
+
}
|
|
1582
|
+
return undefined;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1370
1585
|
/**
|
|
1371
1586
|
* The requested-only 声明原创 sequence; returns a typed-failure `Result`, or `undefined` when
|
|
1372
1587
|
* the declaration committed with verified state: entry checkbox clicked and read back checked
|
|
@@ -243,6 +243,19 @@ export const SHP_VIDEO_SELECTORS = {
|
|
|
243
243
|
* on an explicit `publishStatus: 'public'`.
|
|
244
244
|
*/
|
|
245
245
|
publishButton: ['button:text-is("发表")', '[role="button"]:text-is("发表")'],
|
|
246
|
+
/**
|
|
247
|
+
* The 合集 (collection) entry on the AUDIO post form (2026-11-16, operator requirement: the daily
|
|
248
|
+
* episode belongs to 合集 `每日AI乱炖`). Matched by its own visible text, because the row ships
|
|
249
|
+
* without a stable class in the creator form; the flow then opens it and picks the option by
|
|
250
|
+
* exact text (`collectionOptionText`), never by index.
|
|
251
|
+
*
|
|
252
|
+
* Audio-only by contract: `collection` is listed in `unsupportedFields` for the other three
|
|
253
|
+
* post kinds, so 视频/图文/音乐 keep their exact current behaviour and a collection request on
|
|
254
|
+
* them is refused before a browser opens.
|
|
255
|
+
*/
|
|
256
|
+
collectionEntry: ['button:has-text("合集")', 'div:has-text("合集")', 'span:has-text("合集")'],
|
|
257
|
+
/** Label the entry row is expected to carry once a collection is committed (readback gate). */
|
|
258
|
+
collectionLabel: '合集',
|
|
246
259
|
} as const;
|
|
247
260
|
|
|
248
261
|
/** Keys of the selector map, for typed probes. */
|
|
@@ -20782,6 +20782,9 @@ async function ensureProfileDir2(profileDir, headless) {
|
|
|
20782
20782
|
var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
20783
20783
|
// ../../packages/publish-harness/src/browser.ts
|
|
20784
20784
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20785
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20786
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20787
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20785
20788
|
var DEFAULT_STEP_TIMEOUT_MS = 30000;
|
|
20786
20789
|
var DEFAULT_POLL_MS = 500;
|
|
20787
20790
|
var ATTACH_POLL_MS = 100;
|
|
@@ -20906,14 +20909,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20906
20909
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20907
20910
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20908
20911
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20912
|
+
const deadline = Date.now() + timeoutMs;
|
|
20913
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20914
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20915
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20909
20916
|
for (const headless of passes) {
|
|
20917
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20918
|
+
if (remainingMs < minPassMs)
|
|
20919
|
+
break;
|
|
20910
20920
|
try {
|
|
20911
20921
|
await withProfilePage({
|
|
20912
20922
|
profileDir: opts.profileDir,
|
|
20913
20923
|
headless,
|
|
20914
20924
|
url: config.homeUrl,
|
|
20915
20925
|
isAuthenticated: config.isAuthenticated,
|
|
20916
|
-
timeoutMs,
|
|
20926
|
+
timeoutMs: remainingMs,
|
|
20917
20927
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20918
20928
|
}, async () => true);
|
|
20919
20929
|
return {
|
|
@@ -20210,6 +20210,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
|
20210
20210
|
var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
|
|
20211
20211
|
var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
|
|
20212
20212
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20213
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20214
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20215
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20213
20216
|
var DEFAULT_POLL_MS = 500;
|
|
20214
20217
|
function isInstantBrowserDeath(message) {
|
|
20215
20218
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
@@ -20332,14 +20335,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20332
20335
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20333
20336
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20334
20337
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20338
|
+
const deadline = Date.now() + timeoutMs;
|
|
20339
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20340
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20341
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20335
20342
|
for (const headless of passes) {
|
|
20343
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20344
|
+
if (remainingMs < minPassMs)
|
|
20345
|
+
break;
|
|
20336
20346
|
try {
|
|
20337
20347
|
await withProfilePage({
|
|
20338
20348
|
profileDir: opts.profileDir,
|
|
20339
20349
|
headless,
|
|
20340
20350
|
url: config.homeUrl,
|
|
20341
20351
|
isAuthenticated: config.isAuthenticated,
|
|
20342
|
-
timeoutMs,
|
|
20352
|
+
timeoutMs: remainingMs,
|
|
20343
20353
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20344
20354
|
}, async () => true);
|
|
20345
20355
|
return {
|
|
@@ -20776,6 +20776,9 @@ async function ensureProfileDir2(profileDir, headless) {
|
|
|
20776
20776
|
var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
20777
20777
|
// ../../packages/publish-harness/src/browser.ts
|
|
20778
20778
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20779
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20780
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20781
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20779
20782
|
var DEFAULT_STEP_TIMEOUT_MS = 30000;
|
|
20780
20783
|
var DEFAULT_POLL_MS = 500;
|
|
20781
20784
|
var ATTACH_POLL_MS = 100;
|
|
@@ -20900,14 +20903,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20900
20903
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20901
20904
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20902
20905
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20906
|
+
const deadline = Date.now() + timeoutMs;
|
|
20907
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20908
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20909
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20903
20910
|
for (const headless of passes) {
|
|
20911
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20912
|
+
if (remainingMs < minPassMs)
|
|
20913
|
+
break;
|
|
20904
20914
|
try {
|
|
20905
20915
|
await withProfilePage({
|
|
20906
20916
|
profileDir: opts.profileDir,
|
|
20907
20917
|
headless,
|
|
20908
20918
|
url: config.homeUrl,
|
|
20909
20919
|
isAuthenticated: config.isAuthenticated,
|
|
20910
|
-
timeoutMs,
|
|
20920
|
+
timeoutMs: remainingMs,
|
|
20911
20921
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20912
20922
|
}, async () => true);
|
|
20913
20923
|
return {
|
|
@@ -20482,6 +20482,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
|
20482
20482
|
var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
|
|
20483
20483
|
var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
|
|
20484
20484
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20485
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20486
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20487
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20485
20488
|
var DEFAULT_POLL_MS = 500;
|
|
20486
20489
|
function isInstantBrowserDeath(message) {
|
|
20487
20490
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
@@ -20604,14 +20607,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20604
20607
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20605
20608
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20606
20609
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20610
|
+
const deadline = Date.now() + timeoutMs;
|
|
20611
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20612
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20613
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20607
20614
|
for (const headless of passes) {
|
|
20615
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20616
|
+
if (remainingMs < minPassMs)
|
|
20617
|
+
break;
|
|
20608
20618
|
try {
|
|
20609
20619
|
await withProfilePage({
|
|
20610
20620
|
profileDir: opts.profileDir,
|
|
20611
20621
|
headless,
|
|
20612
20622
|
url: config.homeUrl,
|
|
20613
20623
|
isAuthenticated: config.isAuthenticated,
|
|
20614
|
-
timeoutMs,
|
|
20624
|
+
timeoutMs: remainingMs,
|
|
20615
20625
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20616
20626
|
}, async () => true);
|
|
20617
20627
|
return {
|