@gobing-ai/knowledge-kit 0.1.17 → 0.1.20
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/daily-voice/index.js +40 -7
- package/dist/index.js +8428 -4448
- package/package.json +1 -1
- 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/kk/config.example.yaml +7 -2
- package/plugins/kk/decisions/extract/ai-news.yaml +5 -2
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/chinese-article.json +8 -2
- package/plugins/kk/publish-presets/daily-ai-voice-migration.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +57 -16
- package/plugins/kk/publish-presets/itc-main.json +36 -9
- package/plugins/kk/publish-presets/technical-article.json +8 -2
- package/plugins/kk/schedules/kk-daily-ai-voice3.cron.tmpl +8 -9
- package/plugins/kk/schedules/kk-daily-publish3-cn-peak.cron.tmpl +13 -19
- package/plugins/kk/schedules/kk-daily-publish3-overseas.cron.tmpl +11 -9
- package/plugins/kk/scripts/daily-stages.ts +238 -14
- package/plugins/kk/scripts/daily-triage-core.ts +43 -25
- package/plugins/kk/scripts/daily-triage.ts +1 -1
- 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/publish/SKILL.md +15 -2
- package/plugins/kk/skills/web-automation/SKILL.md +31 -1
- package/plugins/kk/workflows/kk-article-generate.yaml +485 -0
- package/plugins/kk/workflows/kk-collect.yaml +8 -4
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +2 -1
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +4 -2
- package/plugins/kk/workflows/kk-daily-safety.yaml +5 -7
- package/plugins/kk/workflows/kk-news-generate.yaml +410 -0
- package/plugins/kk/workflows/kk-publish.yaml +236 -0
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +49 -10
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/csdn-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/infoq-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/jike-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/juejin-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/linkedin-pub/dist/index.js +43 -6
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +92 -15
- package/plugins/publishings/linkedin-pub/src/index.ts +52 -6
- package/plugins/publishings/shipinhao-pub/dist/index.js +391 -32
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +52 -11
- package/plugins/publishings/shipinhao-pub/plugin.json +1 -1
- package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +393 -0
- package/plugins/publishings/shipinhao-pub/src/flow.ts +243 -14
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -0
- package/plugins/publishings/sspai-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/substack-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/surfdash-pub/dist/index.js +50 -8
- package/plugins/publishings/surfdash-pub/src/index.ts +59 -8
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +34 -3
- package/plugins/publishings/threads-pub/dist/index.js +9196 -296
- package/plugins/publishings/threads-pub/dist/profile-check.js +21139 -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 +454 -81
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +401 -102
- package/plugins/publishings/wechatmp-pub/src/flow.ts +42 -4
- package/plugins/publishings/wechatmp-pub/src/index.ts +142 -102
- package/plugins/publishings/wechatmp-pub/src/profile-check.ts +36 -58
- package/plugins/publishings/weibo-pub/dist/index.js +136 -22
- package/plugins/publishings/weibo-pub/dist/profile-check.js +61 -11
- package/plugins/publishings/weibo-pub/src/index.ts +208 -22
- package/plugins/publishings/x-pub/dist/index.js +263 -43
- package/plugins/publishings/x-pub/dist/profile-check.js +63 -11
- 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 +193 -201
- package/plugins/publishings/xhs-pub/dist/profile-check.js +380 -85
- package/plugins/publishings/xhs-pub/src/automation-guard.ts +2 -3
- package/plugins/publishings/xhs-pub/src/flow.ts +177 -205
- package/plugins/publishings/xhs-pub/src/index.ts +65 -59
- package/plugins/publishings/xhs-pub/src/modes.ts +1 -1
- package/plugins/publishings/xhs-pub/src/page.ts +2 -2
- package/plugins/publishings/xhs-pub/src/profile-check.ts +86 -150
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +60 -10
- package/plugins/kk/scripts/daily-scheduled-run.ts +0 -581
- package/plugins/kk/scripts/voice3-publish-window.ts +0 -206
- package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +0 -903
- package/plugins/kk/workflows/kk-daily-publish3.yaml +0 -353
- package/plugins/kk/workflows/kk-itc-author.yaml +0 -484
- package/plugins/kk/workflows/kk-itc-publish-tail.yaml +0 -112
- package/plugins/kk/workflows/kk-itc.yaml +0 -291
|
@@ -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.
|
|
@@ -86,19 +100,31 @@ export function fail(target: string, error: string): Result {
|
|
|
86
100
|
return ResultSchema.parse({ ok: false, target, error: boundedDetail(error) });
|
|
87
101
|
}
|
|
88
102
|
|
|
89
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* A browser-stage failure: `ok: false` with `stage` (and optional evidence) in the Result metadata.
|
|
105
|
+
*
|
|
106
|
+
* `effect` defaults to `none`: every stage before the submit click only fills an editor, so nothing
|
|
107
|
+
* was accepted by the channel and a bounded retry is safe. The receipt stages (after the click) pass
|
|
108
|
+
* `unknown` explicitly — a clicked 发表 that produced no receipt may still have published.
|
|
109
|
+
*/
|
|
90
110
|
export function stageFail(
|
|
91
111
|
target: string,
|
|
92
112
|
error: string,
|
|
93
113
|
stage: string,
|
|
94
114
|
metadata: Record<string, unknown>,
|
|
95
115
|
evidence?: string,
|
|
116
|
+
effect: 'none' | 'unknown' = 'none',
|
|
96
117
|
): Result {
|
|
97
118
|
return ResultSchema.parse({
|
|
98
119
|
ok: false,
|
|
99
120
|
target,
|
|
100
121
|
error: boundedDetail(error),
|
|
101
|
-
metadata: {
|
|
122
|
+
metadata: {
|
|
123
|
+
...metadata,
|
|
124
|
+
stage,
|
|
125
|
+
...(evidence === undefined ? {} : { evidence: boundedDetail(evidence) }),
|
|
126
|
+
...(effect === 'none' ? { itcDelivery: { schemaVersion: 1, effect: 'none' } } : {}),
|
|
127
|
+
},
|
|
102
128
|
});
|
|
103
129
|
}
|
|
104
130
|
|
|
@@ -555,6 +581,22 @@ function resolveOriginal(
|
|
|
555
581
|
return { original: raw };
|
|
556
582
|
}
|
|
557
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
|
+
|
|
558
600
|
/**
|
|
559
601
|
* Unsupported requested fields, per operation: fields that mean nothing to the requested flow —
|
|
560
602
|
* images/videoPath outside their own operation, coverPath for 图文 — are typed unsupported-field
|
|
@@ -563,11 +605,14 @@ function resolveOriginal(
|
|
|
563
605
|
* `coverPath` (except on image) are implemented and validated in their resolvers.
|
|
564
606
|
*/
|
|
565
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.
|
|
566
611
|
const perOperation: Record<ShipinhaoOperationName, readonly string[]> = {
|
|
567
|
-
shortVideo: ['images', 'categories', 'publishTime', 'scheduling'],
|
|
612
|
+
shortVideo: ['images', 'categories', 'publishTime', 'scheduling', 'collection'],
|
|
568
613
|
audio: ['videoPath', 'images', 'categories', 'publishTime', 'scheduling'],
|
|
569
|
-
music: ['videoPath', 'images', 'categories', 'publishTime', 'scheduling'],
|
|
570
|
-
image: ['videoPath', 'coverPath', 'categories', 'publishTime', 'scheduling'],
|
|
614
|
+
music: ['videoPath', 'images', 'categories', 'publishTime', 'scheduling', 'collection'],
|
|
615
|
+
image: ['videoPath', 'coverPath', 'categories', 'publishTime', 'scheduling', 'collection'],
|
|
571
616
|
};
|
|
572
617
|
const refused: string[] = [];
|
|
573
618
|
for (const [container, source] of [
|
|
@@ -608,6 +653,55 @@ function editingFormReadyScript(mode: 'wujie' | 'direct', titleSelector: string,
|
|
|
608
653
|
})()`;
|
|
609
654
|
}
|
|
610
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
|
+
|
|
611
705
|
/**
|
|
612
706
|
* 声明原创 entry checkbox locator, vendor scoring ported verbatim (shipinhao.js:2233-2261):
|
|
613
707
|
* 原创/original attribute evidence, an associated 原创 label, or a short 原创 ancestor text;
|
|
@@ -818,15 +912,17 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
818
912
|
private readonly operation: ShipinhaoOperationName;
|
|
819
913
|
private readonly launcher: BrowserLauncher;
|
|
820
914
|
private readonly stepTimeoutMs: number;
|
|
915
|
+
private readonly preflightTimeoutMs: number;
|
|
821
916
|
constructor(
|
|
822
917
|
operation: ShipinhaoOperationName = 'shortVideo',
|
|
823
918
|
driver: BrowserDriver = 'script',
|
|
824
|
-
deps: { launcher?: BrowserLauncher; stepTimeoutMs?: number } = {},
|
|
919
|
+
deps: { launcher?: BrowserLauncher; stepTimeoutMs?: number; preflightTimeoutMs?: number } = {},
|
|
825
920
|
) {
|
|
826
921
|
this.operation = operation;
|
|
827
922
|
this.driver = driver;
|
|
828
923
|
this.launcher = deps.launcher ?? kkBrowserLauncher;
|
|
829
924
|
this.stepTimeoutMs = deps.stepTimeoutMs ?? STEP_TIMEOUT_MS;
|
|
925
|
+
this.preflightTimeoutMs = deps.preflightTimeoutMs ?? PREFLIGHT_TIMEOUT_MS;
|
|
830
926
|
}
|
|
831
927
|
|
|
832
928
|
/**
|
|
@@ -890,7 +986,14 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
890
986
|
const audio = await resolveAudioPath(metadataRecord.audio ?? metadataRecord.audioFile);
|
|
891
987
|
if (audio.error !== undefined) return fail(SHP_TARGET, audio.error);
|
|
892
988
|
media = [audio.path as string];
|
|
893
|
-
|
|
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
|
+
);
|
|
894
997
|
if (cover.error !== undefined) return fail(SHP_TARGET, cover.error);
|
|
895
998
|
coverPath = cover.path;
|
|
896
999
|
} else {
|
|
@@ -902,6 +1005,8 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
902
1005
|
if (tags.error !== undefined) return fail(SHP_TARGET, tags.error);
|
|
903
1006
|
const original = resolveOriginal(payload.content.metadata?.original);
|
|
904
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);
|
|
905
1010
|
const unsupported = unsupportedFields(payload, this.operation);
|
|
906
1011
|
if (unsupported.length > 0) {
|
|
907
1012
|
return fail(
|
|
@@ -918,15 +1023,24 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
918
1023
|
const session = await checkChannelSession(SHP_CONFIG, {
|
|
919
1024
|
profileDir,
|
|
920
1025
|
launcher: this.launcher,
|
|
921
|
-
|
|
922
|
-
|
|
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,
|
|
923
1032
|
});
|
|
924
1033
|
if (session.status !== 'verified') {
|
|
925
1034
|
// The recovery command leads the message: `fail()` bounds the line, and the operator's
|
|
926
|
-
// next action must never be the part that gets truncated.
|
|
927
|
-
|
|
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(
|
|
928
1038
|
SHP_TARGET,
|
|
929
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',
|
|
930
1044
|
);
|
|
931
1045
|
}
|
|
932
1046
|
|
|
@@ -944,19 +1058,39 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
944
1058
|
// bounded step like every other one, not the 180s interactive login wait.
|
|
945
1059
|
timeoutMs: this.stepTimeoutMs,
|
|
946
1060
|
},
|
|
947
|
-
async ({ page }) =>
|
|
948
|
-
|
|
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(
|
|
949
1081
|
page,
|
|
950
1082
|
POST_FLOW_SPECS[this.operation],
|
|
951
1083
|
title,
|
|
952
1084
|
body,
|
|
953
1085
|
tags.tags as readonly string[],
|
|
954
1086
|
original.original === true,
|
|
1087
|
+
collection.collection,
|
|
955
1088
|
media,
|
|
956
1089
|
coverPath,
|
|
957
1090
|
requested === 'public',
|
|
958
1091
|
profileDir,
|
|
959
|
-
)
|
|
1092
|
+
);
|
|
1093
|
+
},
|
|
960
1094
|
);
|
|
961
1095
|
} catch (error) {
|
|
962
1096
|
// Same ordering rule as the preflight refusal: the recovery command is never the tail
|
|
@@ -987,6 +1121,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
987
1121
|
body: string,
|
|
988
1122
|
tags: readonly string[],
|
|
989
1123
|
declareOriginal: boolean,
|
|
1124
|
+
collection: string | undefined,
|
|
990
1125
|
media: readonly string[],
|
|
991
1126
|
coverPath: string | undefined,
|
|
992
1127
|
publishPublic: boolean,
|
|
@@ -999,6 +1134,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
999
1134
|
publishStatus,
|
|
1000
1135
|
profileDir,
|
|
1001
1136
|
...(declareOriginal ? { original: true } : {}),
|
|
1137
|
+
...(collection !== undefined ? { collection } : {}),
|
|
1002
1138
|
};
|
|
1003
1139
|
|
|
1004
1140
|
// Dashboard click-through: the entry button opens the unified /platform/post/create
|
|
@@ -1216,6 +1352,15 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
1216
1352
|
);
|
|
1217
1353
|
}
|
|
1218
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
|
+
|
|
1219
1364
|
// 声明原创: ONLY on the explicit operator assertion (metadata.original === true); the
|
|
1220
1365
|
// vendor's unconditional run and log-only degradation (shipinhao.js:10-14, 2270-2310) are
|
|
1221
1366
|
// deliberately not mirrored. Ordering matches the vendor: after description, before cover
|
|
@@ -1329,6 +1474,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
1329
1474
|
receiptStage,
|
|
1330
1475
|
metadata,
|
|
1331
1476
|
`still on ${page.url()}; ${beforeReceipts.size} pre-existing receipt-shaped url(s)`,
|
|
1477
|
+
'unknown',
|
|
1332
1478
|
);
|
|
1333
1479
|
}
|
|
1334
1480
|
if (confirmed.evidence.startsWith('stale-state: ') || confirmed.evidence.startsWith('ambiguous-receipt: ')) {
|
|
@@ -1340,6 +1486,7 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
1340
1486
|
receiptStage,
|
|
1341
1487
|
metadata,
|
|
1342
1488
|
confirmed.evidence,
|
|
1489
|
+
'unknown',
|
|
1343
1490
|
);
|
|
1344
1491
|
}
|
|
1345
1492
|
const url = confirmed.evidence;
|
|
@@ -1353,6 +1500,88 @@ export class ShipinhaoBrowserTransport implements PublishTransport {
|
|
|
1353
1500
|
});
|
|
1354
1501
|
}
|
|
1355
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
|
+
|
|
1356
1585
|
/**
|
|
1357
1586
|
* The requested-only 声明原创 sequence; returns a typed-failure `Result`, or `undefined` when
|
|
1358
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. */
|
|
@@ -20210,6 +20210,7 @@ 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 DEFAULT_POLL_MS = 500;
|
|
20213
20214
|
function isInstantBrowserDeath(message) {
|
|
20214
20215
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
20215
20216
|
}
|
|
@@ -20375,6 +20376,16 @@ async function openChannelSession(config, request, deps = {}, stdout = echo) {
|
|
|
20375
20376
|
return 1;
|
|
20376
20377
|
}
|
|
20377
20378
|
const page = context.pages()[0] ?? await context.newPage();
|
|
20379
|
+
const onOpen = config.sessionState?.onOpen;
|
|
20380
|
+
if (onOpen !== undefined) {
|
|
20381
|
+
try {
|
|
20382
|
+
await onOpen({ context, page, profileDir: request.profileDir });
|
|
20383
|
+
} catch (error) {
|
|
20384
|
+
await context.close().catch(() => {});
|
|
20385
|
+
stdout(`${config.channel} profile open failed: ${errorMessage2(error)}`);
|
|
20386
|
+
return 1;
|
|
20387
|
+
}
|
|
20388
|
+
}
|
|
20378
20389
|
try {
|
|
20379
20390
|
await page.goto(request.url, { waitUntil: "commit", timeout: DEFAULT_OPEN_NAV_TIMEOUT_MS });
|
|
20380
20391
|
} catch (error) {
|
|
@@ -20386,6 +20397,36 @@ async function openChannelSession(config, request, deps = {}, stdout = echo) {
|
|
|
20386
20397
|
stdout(`${config.channel} profile open closed: ${request.profileDir}`);
|
|
20387
20398
|
return 0;
|
|
20388
20399
|
}
|
|
20400
|
+
async function loginWithAuthenticatedPage(config, opts) {
|
|
20401
|
+
const context = await opts.launcher.launch({ profileDir: opts.profileDir, headless: false });
|
|
20402
|
+
const sessionCaptured = config.sessionState?.onAuthenticated !== undefined;
|
|
20403
|
+
let captured = false;
|
|
20404
|
+
let facts = {};
|
|
20405
|
+
try {
|
|
20406
|
+
const page = context.pages()[0] ?? await context.newPage();
|
|
20407
|
+
await page.goto(opts.url);
|
|
20408
|
+
if (!await waitUntil(() => Promise.resolve(config.isAuthenticated(page)), opts.timeoutMs)) {
|
|
20409
|
+
throw new Error(`Authentication was not confirmed within ${opts.timeoutMs}ms \u2014 the profile's site session has likely ` + "expired or the sign-in was not completed: run the login command again to sign in again.");
|
|
20410
|
+
}
|
|
20411
|
+
await config.sessionState?.onAuthenticated?.({ context, page, profileDir: opts.profileDir });
|
|
20412
|
+
captured = sessionCaptured;
|
|
20413
|
+
if (opts.captureFacts) {
|
|
20414
|
+
facts = {
|
|
20415
|
+
...await captureSessionFacts(context, config.homeUrl),
|
|
20416
|
+
...config.readIdentity === undefined ? {} : { identity: await readIdentityOrUndefined(config.readIdentity, page) }
|
|
20417
|
+
};
|
|
20418
|
+
}
|
|
20419
|
+
} finally {
|
|
20420
|
+
try {
|
|
20421
|
+
await context.close();
|
|
20422
|
+
} catch {
|
|
20423
|
+
if (captured) {
|
|
20424
|
+
echoError(`${config.channel} browser context close failed after the authenticated session capture; saved state preserved`);
|
|
20425
|
+
}
|
|
20426
|
+
}
|
|
20427
|
+
}
|
|
20428
|
+
return facts;
|
|
20429
|
+
}
|
|
20389
20430
|
async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
20390
20431
|
const stdout = deps.stdout ?? ((line) => {
|
|
20391
20432
|
echo(line);
|
|
@@ -20436,7 +20477,8 @@ async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
|
20436
20477
|
const launcher = deps.launcher ?? kkBrowserLauncher;
|
|
20437
20478
|
stdout(`${config.channel} profile login: a browser window is opening \u2014 sign in there; waiting up to ${Math.round(loginTimeoutMs / 1000)}s for the signed-in state`);
|
|
20438
20479
|
try {
|
|
20439
|
-
|
|
20480
|
+
const captureFacts = url !== undefined;
|
|
20481
|
+
if (!captureFacts && config.sessionState?.onAuthenticated === undefined) {
|
|
20440
20482
|
await loginWithProfile({
|
|
20441
20483
|
profileDir,
|
|
20442
20484
|
url: config.homeUrl,
|
|
@@ -20447,18 +20489,16 @@ async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
|
20447
20489
|
stdout(`${config.channel} profile login verified: ${profileDir}`);
|
|
20448
20490
|
return 0;
|
|
20449
20491
|
}
|
|
20450
|
-
const facts = await
|
|
20492
|
+
const facts = await loginWithAuthenticatedPage(config, {
|
|
20451
20493
|
profileDir,
|
|
20452
|
-
|
|
20453
|
-
url,
|
|
20454
|
-
isAuthenticated: config.isAuthenticated,
|
|
20494
|
+
url: url ?? config.homeUrl,
|
|
20455
20495
|
timeoutMs: loginTimeoutMs,
|
|
20456
|
-
launcher
|
|
20457
|
-
|
|
20458
|
-
|
|
20459
|
-
...config.readIdentity === undefined ? {} : { identity: await readIdentityOrUndefined(config.readIdentity, page) }
|
|
20460
|
-
}));
|
|
20496
|
+
launcher,
|
|
20497
|
+
captureFacts
|
|
20498
|
+
});
|
|
20461
20499
|
stdout(`${config.channel} profile login verified: ${profileDir}`);
|
|
20500
|
+
if (url === undefined)
|
|
20501
|
+
return 0;
|
|
20462
20502
|
stdout(JSON.stringify({
|
|
20463
20503
|
status: "verified",
|
|
20464
20504
|
profileDir,
|
|
@@ -20481,6 +20521,16 @@ async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
|
20481
20521
|
stdout(JSON.stringify(result));
|
|
20482
20522
|
return result.status === "verified" ? 0 : 1;
|
|
20483
20523
|
}
|
|
20524
|
+
async function waitUntil(predicate, timeoutMs, pollMs = DEFAULT_POLL_MS) {
|
|
20525
|
+
const deadline = Date.now() + timeoutMs;
|
|
20526
|
+
while (Date.now() < deadline) {
|
|
20527
|
+
if (await predicate()) {
|
|
20528
|
+
return true;
|
|
20529
|
+
}
|
|
20530
|
+
await new Promise((resolve) => setTimeout(resolve, pollMs));
|
|
20531
|
+
}
|
|
20532
|
+
return predicate();
|
|
20533
|
+
}
|
|
20484
20534
|
async function captureSessionFacts(context, url) {
|
|
20485
20535
|
let cookies;
|
|
20486
20536
|
try {
|
|
@@ -20482,6 +20482,7 @@ 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 DEFAULT_POLL_MS = 500;
|
|
20485
20486
|
function isInstantBrowserDeath(message) {
|
|
20486
20487
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
20487
20488
|
}
|
|
@@ -20647,6 +20648,16 @@ async function openChannelSession(config, request, deps = {}, stdout = echo) {
|
|
|
20647
20648
|
return 1;
|
|
20648
20649
|
}
|
|
20649
20650
|
const page = context.pages()[0] ?? await context.newPage();
|
|
20651
|
+
const onOpen = config.sessionState?.onOpen;
|
|
20652
|
+
if (onOpen !== undefined) {
|
|
20653
|
+
try {
|
|
20654
|
+
await onOpen({ context, page, profileDir: request.profileDir });
|
|
20655
|
+
} catch (error) {
|
|
20656
|
+
await context.close().catch(() => {});
|
|
20657
|
+
stdout(`${config.channel} profile open failed: ${errorMessage2(error)}`);
|
|
20658
|
+
return 1;
|
|
20659
|
+
}
|
|
20660
|
+
}
|
|
20650
20661
|
try {
|
|
20651
20662
|
await page.goto(request.url, { waitUntil: "commit", timeout: DEFAULT_OPEN_NAV_TIMEOUT_MS });
|
|
20652
20663
|
} catch (error) {
|
|
@@ -20658,6 +20669,36 @@ async function openChannelSession(config, request, deps = {}, stdout = echo) {
|
|
|
20658
20669
|
stdout(`${config.channel} profile open closed: ${request.profileDir}`);
|
|
20659
20670
|
return 0;
|
|
20660
20671
|
}
|
|
20672
|
+
async function loginWithAuthenticatedPage(config, opts) {
|
|
20673
|
+
const context = await opts.launcher.launch({ profileDir: opts.profileDir, headless: false });
|
|
20674
|
+
const sessionCaptured = config.sessionState?.onAuthenticated !== undefined;
|
|
20675
|
+
let captured = false;
|
|
20676
|
+
let facts = {};
|
|
20677
|
+
try {
|
|
20678
|
+
const page = context.pages()[0] ?? await context.newPage();
|
|
20679
|
+
await page.goto(opts.url);
|
|
20680
|
+
if (!await waitUntil(() => Promise.resolve(config.isAuthenticated(page)), opts.timeoutMs)) {
|
|
20681
|
+
throw new Error(`Authentication was not confirmed within ${opts.timeoutMs}ms \u2014 the profile's site session has likely ` + "expired or the sign-in was not completed: run the login command again to sign in again.");
|
|
20682
|
+
}
|
|
20683
|
+
await config.sessionState?.onAuthenticated?.({ context, page, profileDir: opts.profileDir });
|
|
20684
|
+
captured = sessionCaptured;
|
|
20685
|
+
if (opts.captureFacts) {
|
|
20686
|
+
facts = {
|
|
20687
|
+
...await captureSessionFacts(context, config.homeUrl),
|
|
20688
|
+
...config.readIdentity === undefined ? {} : { identity: await readIdentityOrUndefined(config.readIdentity, page) }
|
|
20689
|
+
};
|
|
20690
|
+
}
|
|
20691
|
+
} finally {
|
|
20692
|
+
try {
|
|
20693
|
+
await context.close();
|
|
20694
|
+
} catch {
|
|
20695
|
+
if (captured) {
|
|
20696
|
+
echoError(`${config.channel} browser context close failed after the authenticated session capture; saved state preserved`);
|
|
20697
|
+
}
|
|
20698
|
+
}
|
|
20699
|
+
}
|
|
20700
|
+
return facts;
|
|
20701
|
+
}
|
|
20661
20702
|
async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
20662
20703
|
const stdout = deps.stdout ?? ((line) => {
|
|
20663
20704
|
echo(line);
|
|
@@ -20708,7 +20749,8 @@ async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
|
20708
20749
|
const launcher = deps.launcher ?? kkBrowserLauncher;
|
|
20709
20750
|
stdout(`${config.channel} profile login: a browser window is opening \u2014 sign in there; waiting up to ${Math.round(loginTimeoutMs / 1000)}s for the signed-in state`);
|
|
20710
20751
|
try {
|
|
20711
|
-
|
|
20752
|
+
const captureFacts = url !== undefined;
|
|
20753
|
+
if (!captureFacts && config.sessionState?.onAuthenticated === undefined) {
|
|
20712
20754
|
await loginWithProfile({
|
|
20713
20755
|
profileDir,
|
|
20714
20756
|
url: config.homeUrl,
|
|
@@ -20719,18 +20761,16 @@ async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
|
20719
20761
|
stdout(`${config.channel} profile login verified: ${profileDir}`);
|
|
20720
20762
|
return 0;
|
|
20721
20763
|
}
|
|
20722
|
-
const facts = await
|
|
20764
|
+
const facts = await loginWithAuthenticatedPage(config, {
|
|
20723
20765
|
profileDir,
|
|
20724
|
-
|
|
20725
|
-
url,
|
|
20726
|
-
isAuthenticated: config.isAuthenticated,
|
|
20766
|
+
url: url ?? config.homeUrl,
|
|
20727
20767
|
timeoutMs: loginTimeoutMs,
|
|
20728
|
-
launcher
|
|
20729
|
-
|
|
20730
|
-
|
|
20731
|
-
...config.readIdentity === undefined ? {} : { identity: await readIdentityOrUndefined(config.readIdentity, page) }
|
|
20732
|
-
}));
|
|
20768
|
+
launcher,
|
|
20769
|
+
captureFacts
|
|
20770
|
+
});
|
|
20733
20771
|
stdout(`${config.channel} profile login verified: ${profileDir}`);
|
|
20772
|
+
if (url === undefined)
|
|
20773
|
+
return 0;
|
|
20734
20774
|
stdout(JSON.stringify({
|
|
20735
20775
|
status: "verified",
|
|
20736
20776
|
profileDir,
|
|
@@ -20753,6 +20793,16 @@ async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
|
20753
20793
|
stdout(JSON.stringify(result));
|
|
20754
20794
|
return result.status === "verified" ? 0 : 1;
|
|
20755
20795
|
}
|
|
20796
|
+
async function waitUntil(predicate, timeoutMs, pollMs = DEFAULT_POLL_MS) {
|
|
20797
|
+
const deadline = Date.now() + timeoutMs;
|
|
20798
|
+
while (Date.now() < deadline) {
|
|
20799
|
+
if (await predicate()) {
|
|
20800
|
+
return true;
|
|
20801
|
+
}
|
|
20802
|
+
await new Promise((resolve) => setTimeout(resolve, pollMs));
|
|
20803
|
+
}
|
|
20804
|
+
return predicate();
|
|
20805
|
+
}
|
|
20756
20806
|
async function captureSessionFacts(context, url) {
|
|
20757
20807
|
let cookies;
|
|
20758
20808
|
try {
|