10x-chat 0.10.13 → 0.11.2
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/LICENSE +21 -0
- package/README-zh.md +279 -0
- package/README.md +72 -2
- package/dist/bin/cli.js +1 -1
- package/dist/bin/cli.js.map +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +12 -2
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/login.d.ts.map +1 -1
- package/dist/cli/login.js +1 -1
- package/dist/cli/login.js.map +1 -1
- package/dist/cli/migrate.js +10 -1
- package/dist/cli/migrate.js.map +1 -1
- package/dist/cli/status.d.ts.map +1 -1
- package/dist/cli/status.js +4 -0
- package/dist/cli/status.js.map +1 -1
- package/dist/cli/video.d.ts.map +1 -1
- package/dist/cli/video.js +159 -75
- package/dist/cli/video.js.map +1 -1
- package/dist/core/bundle.d.ts.map +1 -1
- package/dist/core/bundle.js +14 -2
- package/dist/core/bundle.js.map +1 -1
- package/dist/core/dreamina-video-orchestrator.d.ts +19 -0
- package/dist/core/dreamina-video-orchestrator.d.ts.map +1 -0
- package/dist/core/dreamina-video-orchestrator.js +125 -0
- package/dist/core/dreamina-video-orchestrator.js.map +1 -0
- package/dist/core/image-orchestrator.d.ts.map +1 -1
- package/dist/core/image-orchestrator.js +10 -0
- package/dist/core/image-orchestrator.js.map +1 -1
- package/dist/core/orchestrator.d.ts.map +1 -1
- package/dist/core/orchestrator.js +4 -1
- package/dist/core/orchestrator.js.map +1 -1
- package/dist/core/video-download.d.ts +12 -0
- package/dist/core/video-download.d.ts.map +1 -0
- package/dist/core/video-download.js +102 -0
- package/dist/core/video-download.js.map +1 -0
- package/dist/core/video-orchestrator.d.ts.map +1 -1
- package/dist/core/video-orchestrator.js +1 -0
- package/dist/core/video-orchestrator.js.map +1 -1
- package/dist/providers/dreamina-video.d.ts +118 -0
- package/dist/providers/dreamina-video.d.ts.map +1 -0
- package/dist/providers/dreamina-video.js +450 -0
- package/dist/providers/dreamina-video.js.map +1 -0
- package/dist/providers/dreamina.d.ts +33 -0
- package/dist/providers/dreamina.d.ts.map +1 -0
- package/dist/providers/dreamina.js +125 -0
- package/dist/providers/dreamina.js.map +1 -0
- package/dist/providers/flow.d.ts +5 -0
- package/dist/providers/flow.d.ts.map +1 -1
- package/dist/providers/flow.js +25 -9
- package/dist/providers/flow.js.map +1 -1
- package/dist/providers/gemini.d.ts.map +1 -1
- package/dist/providers/gemini.js +116 -34
- package/dist/providers/gemini.js.map +1 -1
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +1 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/registry.d.ts.map +1 -1
- package/dist/providers/registry.js +2 -0
- package/dist/providers/registry.js.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +11 -5
- package/skills/10x-chat/SKILL.md +21 -9
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dreamina (CapCut) video-generation UI automation.
|
|
3
|
+
*
|
|
4
|
+
* The video toolbar is built with Arco Design (`lv-*`) components:
|
|
5
|
+
* - Type / Model / Reference-mode / Duration are `.lv-select[role="combobox"]`
|
|
6
|
+
* that open a portal `.lv-select-popup` containing `.lv-select-option`s.
|
|
7
|
+
* - Aspect ratio + resolution share one `lv-btn` that opens a popover of radio
|
|
8
|
+
* chips (`[class*="radio-content"]`) — ratios (21:9 … 9:16) and 720P/1080P.
|
|
9
|
+
* - References upload through `input[type="file"]` (multiple; images/video/audio).
|
|
10
|
+
*
|
|
11
|
+
* Hashed CSS-module suffixes (e.g. `toolbar-select-f8R3U4`) change per build, so
|
|
12
|
+
* everything here keys off the stable Arco classes + visible option text.
|
|
13
|
+
*/
|
|
14
|
+
export const DREAMINA_VIDEO_MODELS = [
|
|
15
|
+
'Seedance 2.0 Fast',
|
|
16
|
+
'Seedance 2.0',
|
|
17
|
+
'Seedance 1.5 Pro',
|
|
18
|
+
'Seedance 1.0',
|
|
19
|
+
'Seedance 1.0 Fast',
|
|
20
|
+
];
|
|
21
|
+
/** Cheapest model — "Faster and lower cost" — used as the test/default model. */
|
|
22
|
+
export const DREAMINA_DEFAULT_MODEL = 'Seedance 2.0 Fast';
|
|
23
|
+
export const DREAMINA_ASPECTS = ['21:9', '16:9', '4:3', '1:1', '3:4', '9:16'];
|
|
24
|
+
export const DREAMINA_RESOLUTIONS = ['720P', '1080P'];
|
|
25
|
+
export const DREAMINA_MIN_DURATION = 4;
|
|
26
|
+
export const DREAMINA_MAX_DURATION = 15;
|
|
27
|
+
/** Reference (input-image) modes, mapped to their UI labels. */
|
|
28
|
+
export const DREAMINA_REF_MODES = {
|
|
29
|
+
omni: 'Omni reference',
|
|
30
|
+
frames: 'First and last frames',
|
|
31
|
+
multiframes: 'Multiframes',
|
|
32
|
+
};
|
|
33
|
+
export const DREAMINA_VIDEO_SELECTORS = {
|
|
34
|
+
combobox: '.lv-select[role="combobox"]',
|
|
35
|
+
selectPopup: '.lv-select-popup',
|
|
36
|
+
selectOption: '.lv-select-option',
|
|
37
|
+
composer: '.tiptap.ProseMirror[role="textbox"]',
|
|
38
|
+
submit: 'button[class*="submit-button"]:not(.lv-btn-disabled)',
|
|
39
|
+
fileInput: 'input[type="file"]',
|
|
40
|
+
};
|
|
41
|
+
// ── Browser-context helpers (run inside page.evaluate) ──────────────
|
|
42
|
+
/** Click the first visible `.lv-select` combobox whose text matches `pattern`. */
|
|
43
|
+
async function openCombobox(page, pattern) {
|
|
44
|
+
return page.evaluate((pat) => {
|
|
45
|
+
const rx = new RegExp(pat, 'i');
|
|
46
|
+
const norm = (s) => (s ?? '').replace(/\s+/g, ' ').trim();
|
|
47
|
+
const vis = (el) => {
|
|
48
|
+
if (!(el instanceof HTMLElement))
|
|
49
|
+
return false;
|
|
50
|
+
const s = getComputedStyle(el);
|
|
51
|
+
return (el.offsetWidth > 0 &&
|
|
52
|
+
el.offsetHeight > 0 &&
|
|
53
|
+
s.visibility !== 'hidden' &&
|
|
54
|
+
s.display !== 'none');
|
|
55
|
+
};
|
|
56
|
+
const box = Array.from(document.querySelectorAll('.lv-select[role="combobox"]'))
|
|
57
|
+
.filter(vis)
|
|
58
|
+
.find((el) => rx.test(norm(el.textContent)));
|
|
59
|
+
if (box) {
|
|
60
|
+
box.click();
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}, pattern);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Click an option in the open `.lv-select-popup` whose own title text (or that
|
|
68
|
+
* of a descendant) exactly equals one of `labels`. Exact match disambiguates
|
|
69
|
+
* e.g. "Dreamina Seedance 2.0" from "Dreamina Seedance 2.0 Fast".
|
|
70
|
+
*
|
|
71
|
+
* Returns `'disabled'` (without clicking) when the matching option is locked
|
|
72
|
+
* — Arco marks it `lv-select-option-wrapper-disabled` / `aria-disabled`. Some
|
|
73
|
+
* Dreamina models (e.g. Seedance 1.x) are unavailable on certain accounts, and
|
|
74
|
+
* clicking them is a no-op that would silently leave the wrong model selected.
|
|
75
|
+
*/
|
|
76
|
+
async function clickSelectOption(page, labels) {
|
|
77
|
+
return page.evaluate((wanted) => {
|
|
78
|
+
const norm = (s) => (s ?? '').replace(/\s+/g, ' ').trim();
|
|
79
|
+
const vis = (el) => {
|
|
80
|
+
if (!(el instanceof HTMLElement))
|
|
81
|
+
return false;
|
|
82
|
+
const s = getComputedStyle(el);
|
|
83
|
+
return (el.offsetWidth > 0 &&
|
|
84
|
+
el.offsetHeight > 0 &&
|
|
85
|
+
s.visibility !== 'hidden' &&
|
|
86
|
+
s.display !== 'none');
|
|
87
|
+
};
|
|
88
|
+
const isDisabled = (el) => /disabled/i.test(el.getAttribute('class') ?? '') ||
|
|
89
|
+
el.getAttribute('aria-disabled') === 'true' ||
|
|
90
|
+
!!el.closest('[aria-disabled="true"], [class*="disabled"]');
|
|
91
|
+
const options = Array.from(document.querySelectorAll('.lv-select-popup .lv-select-option, .lv-select-popup [role="option"]')).filter(vis);
|
|
92
|
+
for (const opt of options) {
|
|
93
|
+
const nodes = [opt, ...Array.from(opt.querySelectorAll('*'))];
|
|
94
|
+
if (nodes.some((n) => wanted.includes(norm(n.textContent)))) {
|
|
95
|
+
if (isDisabled(opt))
|
|
96
|
+
return 'disabled';
|
|
97
|
+
opt.click();
|
|
98
|
+
return 'clicked';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return 'not-found';
|
|
102
|
+
}, labels);
|
|
103
|
+
}
|
|
104
|
+
// ── Public actions ──────────────────────────────────────────────────
|
|
105
|
+
export async function selectVideoModel(page, model) {
|
|
106
|
+
const opened = await openCombobox(page, 'Seedance|Seedream|Dreamina|Veo|Kling');
|
|
107
|
+
if (!opened) {
|
|
108
|
+
console.warn(`⚠ Dreamina model selector not found — keeping default (wanted "${model}")`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
await page.waitForTimeout(700);
|
|
112
|
+
const outcome = await clickSelectOption(page, [`Dreamina ${model}`, model]);
|
|
113
|
+
await page.keyboard.press('Escape').catch(() => { });
|
|
114
|
+
if (outcome === 'disabled') {
|
|
115
|
+
throw new Error(`Dreamina model "${model}" is locked on your account (greyed out in the picker). ` +
|
|
116
|
+
'Model availability depends on your plan/region — "Seedance 2.0 Fast" and ' +
|
|
117
|
+
'"Seedance 2.0" are the generally-available options.');
|
|
118
|
+
}
|
|
119
|
+
if (outcome === 'not-found') {
|
|
120
|
+
console.warn(`⚠ Dreamina model "${model}" not in picker — keeping current`);
|
|
121
|
+
}
|
|
122
|
+
await page.waitForTimeout(500);
|
|
123
|
+
}
|
|
124
|
+
export async function selectReferenceMode(page, refMode) {
|
|
125
|
+
const label = DREAMINA_REF_MODES[refMode];
|
|
126
|
+
const opened = await openCombobox(page, 'reference|frame|Multiframe|Omni');
|
|
127
|
+
if (!opened) {
|
|
128
|
+
console.warn(`⚠ Dreamina reference-mode selector not found (wanted "${label}")`);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
await page.waitForTimeout(600);
|
|
132
|
+
const outcome = await clickSelectOption(page, [label]);
|
|
133
|
+
if (outcome !== 'clicked') {
|
|
134
|
+
console.warn(`⚠ Dreamina reference mode "${label}" ${outcome} — keeping current`);
|
|
135
|
+
await page.keyboard.press('Escape').catch(() => { });
|
|
136
|
+
}
|
|
137
|
+
await page.waitForTimeout(500);
|
|
138
|
+
}
|
|
139
|
+
export async function selectDuration(page, durationSecs) {
|
|
140
|
+
const clamped = Math.min(DREAMINA_MAX_DURATION, Math.max(DREAMINA_MIN_DURATION, Math.round(durationSecs)));
|
|
141
|
+
const opened = await openCombobox(page, '^\\s*\\d+s\\s*$');
|
|
142
|
+
if (!opened) {
|
|
143
|
+
console.warn(`⚠ Dreamina duration selector not found (wanted ${clamped}s)`);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
await page.waitForTimeout(500);
|
|
147
|
+
const outcome = await clickSelectOption(page, [`${clamped}s`]);
|
|
148
|
+
if (outcome !== 'clicked') {
|
|
149
|
+
console.warn(`⚠ Dreamina duration "${clamped}s" ${outcome} — keeping current`);
|
|
150
|
+
await page.keyboard.press('Escape').catch(() => { });
|
|
151
|
+
}
|
|
152
|
+
await page.waitForTimeout(400);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* True if a toolbar button's text contains an aspect ratio like "16:9" — even
|
|
156
|
+
* when a resolution is concatenated, e.g. "16:9720P" (Seedance 2.0). The key
|
|
157
|
+
* detail: NO trailing word boundary. In "16:9720P" the ratio and resolution
|
|
158
|
+
* digits run together, so `\b\d{1,2}:\d{1,2}\b` fails to match and the
|
|
159
|
+
* aspect/resolution control is never found.
|
|
160
|
+
*
|
|
161
|
+
* NOTE: `selectAspectAndResolution` inlines this regex inside `page.evaluate`
|
|
162
|
+
* (can't close over Node scope). Keep in sync — unit tests guard the contract.
|
|
163
|
+
*/
|
|
164
|
+
export function buttonTextHasAspectRatio(text) {
|
|
165
|
+
return /\b\d{1,2}:\d{1,2}/.test(text);
|
|
166
|
+
}
|
|
167
|
+
/** Open the aspect/resolution popover and pick the requested ratio + resolution. */
|
|
168
|
+
export async function selectAspectAndResolution(page, aspect, resolution) {
|
|
169
|
+
if (!aspect && !resolution)
|
|
170
|
+
return;
|
|
171
|
+
const opened = await page.evaluate(() => {
|
|
172
|
+
const norm = (s) => (s ?? '').replace(/\s+/g, ' ').trim();
|
|
173
|
+
const vis = (el) => {
|
|
174
|
+
if (!(el instanceof HTMLElement))
|
|
175
|
+
return false;
|
|
176
|
+
const s = getComputedStyle(el);
|
|
177
|
+
return (el.offsetWidth > 0 &&
|
|
178
|
+
el.offsetHeight > 0 &&
|
|
179
|
+
s.visibility !== 'hidden' &&
|
|
180
|
+
s.display !== 'none');
|
|
181
|
+
};
|
|
182
|
+
// Inline copy of `buttonTextHasAspectRatio` (page.evaluate can't close over
|
|
183
|
+
// Node scope). Keep in sync — unit tests guard the contract. NO trailing
|
|
184
|
+
// word boundary: "16:9720P" (Seedance 2.0) runs the ratio + resolution
|
|
185
|
+
// digits together, so `\b\d{1,2}:\d{1,2}\b` would fail to match.
|
|
186
|
+
const btn = Array.from(document.querySelectorAll('button.lv-btn'))
|
|
187
|
+
.filter(vis)
|
|
188
|
+
.find((el) => /\b\d{1,2}:\d{1,2}/.test(norm(el.textContent)));
|
|
189
|
+
if (btn) {
|
|
190
|
+
btn.click();
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
});
|
|
195
|
+
if (!opened) {
|
|
196
|
+
console.warn('⚠ Dreamina aspect/resolution control not found — keeping defaults');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
await page.waitForTimeout(600);
|
|
200
|
+
const picked = await page.evaluate(({ wantAspect, wantRes }) => {
|
|
201
|
+
const norm = (s) => (s ?? '').replace(/\s+/g, ' ').trim();
|
|
202
|
+
const vis = (el) => {
|
|
203
|
+
if (!(el instanceof HTMLElement))
|
|
204
|
+
return false;
|
|
205
|
+
const s = getComputedStyle(el);
|
|
206
|
+
return (el.offsetWidth > 0 &&
|
|
207
|
+
el.offsetHeight > 0 &&
|
|
208
|
+
s.visibility !== 'hidden' &&
|
|
209
|
+
s.display !== 'none');
|
|
210
|
+
};
|
|
211
|
+
const clickExact = (text) => {
|
|
212
|
+
const el = Array.from(document.querySelectorAll('[class*="radio-content"], [class*="radio-"], button, [role="radio"]'))
|
|
213
|
+
.filter(vis)
|
|
214
|
+
.find((e) => norm(e.textContent) === text);
|
|
215
|
+
if (el) {
|
|
216
|
+
el.click();
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
return false;
|
|
220
|
+
};
|
|
221
|
+
return {
|
|
222
|
+
aspect: wantAspect ? clickExact(wantAspect) : true,
|
|
223
|
+
res: wantRes ? clickExact(wantRes) : true,
|
|
224
|
+
};
|
|
225
|
+
}, { wantAspect: aspect ?? null, wantRes: resolution ?? null });
|
|
226
|
+
if (aspect && !picked.aspect)
|
|
227
|
+
console.warn(`⚠ Dreamina aspect "${aspect}" not found`);
|
|
228
|
+
if (resolution && !picked.res)
|
|
229
|
+
console.warn(`⚠ Dreamina resolution "${resolution}" not found`);
|
|
230
|
+
await page.waitForTimeout(400);
|
|
231
|
+
await page.keyboard.press('Escape').catch(() => { });
|
|
232
|
+
await page.waitForTimeout(300);
|
|
233
|
+
}
|
|
234
|
+
/** Upload reference / input images into the references file input. */
|
|
235
|
+
export async function uploadReferenceImages(page, images) {
|
|
236
|
+
if (images.length === 0)
|
|
237
|
+
return;
|
|
238
|
+
const input = page.locator(DREAMINA_VIDEO_SELECTORS.fileInput).first();
|
|
239
|
+
await input.waitFor({ state: 'attached', timeout: 10_000 }).catch(() => { });
|
|
240
|
+
await input.setInputFiles(images.slice(0, 12));
|
|
241
|
+
// Give uploads time to register thumbnails before generating.
|
|
242
|
+
await page.waitForTimeout(Math.min(3000 + images.length * 1500, 15_000));
|
|
243
|
+
}
|
|
244
|
+
/** Type the prompt into the "Describe your video" composer (not the reference box). */
|
|
245
|
+
export async function typePrompt(page, prompt) {
|
|
246
|
+
const handle = await page.evaluateHandle((composerSel) => {
|
|
247
|
+
const norm = (s) => (s ?? '').replace(/\s+/g, ' ').trim();
|
|
248
|
+
const vis = (el) => {
|
|
249
|
+
if (!(el instanceof HTMLElement))
|
|
250
|
+
return false;
|
|
251
|
+
const s = getComputedStyle(el);
|
|
252
|
+
return (el.offsetWidth > 0 &&
|
|
253
|
+
el.offsetHeight > 0 &&
|
|
254
|
+
s.visibility !== 'hidden' &&
|
|
255
|
+
s.display !== 'none');
|
|
256
|
+
};
|
|
257
|
+
const editables = Array.from(document.querySelectorAll(composerSel)).filter(vis);
|
|
258
|
+
const placeholderOf = (el) => {
|
|
259
|
+
const ph = el.getAttribute('data-placeholder') || el.getAttribute('aria-placeholder') || '';
|
|
260
|
+
const inner = el.querySelector('[data-placeholder]')?.getAttribute('data-placeholder') ?? '';
|
|
261
|
+
return norm(`${ph} ${inner} ${el.textContent}`);
|
|
262
|
+
};
|
|
263
|
+
// Prefer the prompt composer; avoid the references box.
|
|
264
|
+
const prompt = editables.find((el) => /describe|prompt|video|mention/i.test(placeholderOf(el)));
|
|
265
|
+
const notReference = editables.find((el) => !/reference|upload/i.test(placeholderOf(el)));
|
|
266
|
+
return prompt ?? notReference ?? editables[editables.length - 1] ?? null;
|
|
267
|
+
}, DREAMINA_VIDEO_SELECTORS.composer);
|
|
268
|
+
const composer = handle.asElement();
|
|
269
|
+
if (!composer)
|
|
270
|
+
throw new Error('Dreamina prompt composer not found.');
|
|
271
|
+
await composer.click();
|
|
272
|
+
await page.keyboard.press('ControlOrMeta+a');
|
|
273
|
+
await page.keyboard.press('Backspace');
|
|
274
|
+
await page.keyboard.insertText(prompt);
|
|
275
|
+
await page.waitForTimeout(400);
|
|
276
|
+
}
|
|
277
|
+
/** Click the (now-enabled) generate/submit button. Returns false if not found. */
|
|
278
|
+
export async function clickGenerate(page) {
|
|
279
|
+
const submit = page.locator(DREAMINA_VIDEO_SELECTORS.submit).first();
|
|
280
|
+
if (await submit.isVisible({ timeout: 8_000 }).catch(() => false)) {
|
|
281
|
+
await submit.click().catch(() => { });
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
// Fallback: the primary circular icon button in the composer toolbar.
|
|
285
|
+
return page.evaluate(() => {
|
|
286
|
+
const vis = (el) => {
|
|
287
|
+
if (!(el instanceof HTMLElement))
|
|
288
|
+
return false;
|
|
289
|
+
const s = getComputedStyle(el);
|
|
290
|
+
return (el.offsetWidth > 0 &&
|
|
291
|
+
el.offsetHeight > 0 &&
|
|
292
|
+
s.visibility !== 'hidden' &&
|
|
293
|
+
s.display !== 'none');
|
|
294
|
+
};
|
|
295
|
+
const btn = Array.from(document.querySelectorAll('button.lv-btn-primary.lv-btn-shape-circle, button[class*="submit-button"]'))
|
|
296
|
+
.filter(vis)
|
|
297
|
+
.find((el) => !el.classList.contains('lv-btn-disabled') && !el.disabled);
|
|
298
|
+
if (btn) {
|
|
299
|
+
btn.click();
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
return false;
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Build a stable lookup key from a prompt: the generation result card on
|
|
307
|
+
* `/ai-tool/generate` echoes the prompt text, which uniquely identifies OUR
|
|
308
|
+
* generation among other (history / in-progress) cards on the page.
|
|
309
|
+
*/
|
|
310
|
+
export function promptKey(prompt) {
|
|
311
|
+
return prompt.replace(/\s+/g, ' ').trim().slice(0, 60).toLowerCase();
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* True if `src` is a *finished* generation clip rather than the in-progress
|
|
315
|
+
* loading placeholder. While generating, the result card embeds a 780×780
|
|
316
|
+
* spinner served from `capcutstatic.com/.../capcut-web-login-static`; the
|
|
317
|
+
* finished clip is a real CDN video whose path contains `/video/` (or a
|
|
318
|
+
* `blob:` URL). Polling must reject the former and wait for the latter, or it
|
|
319
|
+
* downloads the placeholder instead of the video.
|
|
320
|
+
*
|
|
321
|
+
* NOTE: `readResultForPrompt` runs this inside `page.evaluate`, where it cannot
|
|
322
|
+
* close over Node-scope functions, so it inlines an identical copy. Keep the
|
|
323
|
+
* two in sync — the unit tests guard this contract.
|
|
324
|
+
*/
|
|
325
|
+
export function isDreaminaResultSrc(src) {
|
|
326
|
+
if (!src)
|
|
327
|
+
return false;
|
|
328
|
+
if (/capcutstatic\.com/.test(src))
|
|
329
|
+
return false;
|
|
330
|
+
return src.startsWith('blob:') || /\/video\//.test(src);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Locate OUR generation's result card by its echoed prompt text, then read the
|
|
334
|
+
* `<video>` source(s) inside it. Scoping to the prompt's record avoids grabbing
|
|
335
|
+
* trending-feed clips or other generations that share the page.
|
|
336
|
+
*/
|
|
337
|
+
async function readResultForPrompt(page, key, baseline) {
|
|
338
|
+
return page.evaluate(({ wantedKey, baselineSrcs }) => {
|
|
339
|
+
const norm = (s) => (s ?? '').replace(/\s+/g, ' ').trim();
|
|
340
|
+
const srcOf = (v) => v.currentSrc || v.src || v.querySelector('source')?.src || '';
|
|
341
|
+
const GRID = '[class*="responsive-video-grid"]';
|
|
342
|
+
const EDITABLE = '[contenteditable], .tiptap, .ProseMirror, textarea, input';
|
|
343
|
+
const baseline = new Set(baselineSrcs);
|
|
344
|
+
// Inline copy of `isDreaminaResultSrc` (page.evaluate can't close over
|
|
345
|
+
// Node scope). Keep in sync — unit tests guard the contract. Rejects the
|
|
346
|
+
// in-progress 780×780 `capcutstatic.com` placeholder; accepts the finished
|
|
347
|
+
// CDN clip (`…/video/…`) or a blob URL.
|
|
348
|
+
const isResultSrc = (src) => {
|
|
349
|
+
if (!src)
|
|
350
|
+
return false;
|
|
351
|
+
if (/capcutstatic\.com/.test(src))
|
|
352
|
+
return false;
|
|
353
|
+
return src.startsWith('blob:') || /\/video\//.test(src);
|
|
354
|
+
};
|
|
355
|
+
// Text of `el` with any composer/editable text removed. The prompt
|
|
356
|
+
// composer echoes OUR prompt, so including it would let an unrelated
|
|
357
|
+
// card (or a home-page promo) match our key once `recordOf` walks up far
|
|
358
|
+
// enough to swallow the composer. Stripping editables means only a real
|
|
359
|
+
// result card's echoed prompt header can satisfy the match.
|
|
360
|
+
const recordText = (el) => {
|
|
361
|
+
const clone = el.cloneNode(true);
|
|
362
|
+
for (const ed of Array.from(clone.querySelectorAll(EDITABLE)))
|
|
363
|
+
ed.remove();
|
|
364
|
+
return norm(clone.textContent).toLowerCase();
|
|
365
|
+
};
|
|
366
|
+
// Each generation renders one `responsive-video-grid`; the prompt header is
|
|
367
|
+
// a sibling within the same record. The record is the largest ancestor that
|
|
368
|
+
// still contains exactly ONE grid (going higher reaches the list of all
|
|
369
|
+
// generations, whose combined text would mis-match). When only one grid is
|
|
370
|
+
// on the page the walk reaches near-`body` and can swallow the composer —
|
|
371
|
+
// `recordText` strips editables so that copy of our prompt can't match.
|
|
372
|
+
const recordOf = (grid) => {
|
|
373
|
+
let record = grid;
|
|
374
|
+
let node = grid.parentElement;
|
|
375
|
+
for (let i = 0; i < 10 && node; i++) {
|
|
376
|
+
if (node.querySelectorAll(GRID).length === 1) {
|
|
377
|
+
record = node;
|
|
378
|
+
node = node.parentElement;
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return record;
|
|
385
|
+
};
|
|
386
|
+
for (const grid of Array.from(document.querySelectorAll(GRID))) {
|
|
387
|
+
const text = recordText(recordOf(grid));
|
|
388
|
+
if (!text.includes(wantedKey))
|
|
389
|
+
continue;
|
|
390
|
+
const video = grid.querySelector('video');
|
|
391
|
+
const src = video instanceof HTMLVideoElement ? srcOf(video) : '';
|
|
392
|
+
// Accept only a finished, brand-new result clip — never the in-progress
|
|
393
|
+
// placeholder or a pre-existing (history / trending) video.
|
|
394
|
+
if (src && !baseline.has(src) && isResultSrc(src))
|
|
395
|
+
return { srcs: [src], failed: false };
|
|
396
|
+
if (/generation failed|failed to generate|something went wrong|content.*violat/i.test(text)) {
|
|
397
|
+
return { srcs: [], failed: true };
|
|
398
|
+
}
|
|
399
|
+
// Our record exists but the video is still rendering — keep polling.
|
|
400
|
+
}
|
|
401
|
+
// Fallback: explicit failure text tied to our prompt (no grid rendered).
|
|
402
|
+
for (const el of Array.from(document.querySelectorAll('div, p, span'))) {
|
|
403
|
+
const t = recordText(el);
|
|
404
|
+
if (t.includes(wantedKey) &&
|
|
405
|
+
/generation failed|failed to generate|something went wrong|content.*violat/i.test(t)) {
|
|
406
|
+
return { srcs: [], failed: true };
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return { srcs: [], failed: false };
|
|
410
|
+
}, { wantedKey: key, baselineSrcs: baseline });
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Snapshot the `src` of every `<video>` currently on the page. Captured just
|
|
414
|
+
* before generating so the poll can exclude pre-existing (history / promo)
|
|
415
|
+
* clips and only accept the brand-new generation result.
|
|
416
|
+
*/
|
|
417
|
+
export async function captureVideoSrcs(page) {
|
|
418
|
+
return page.evaluate(() => {
|
|
419
|
+
const srcOf = (v) => v.currentSrc || v.src || v.querySelector('source')?.src || '';
|
|
420
|
+
return Array.from(document.querySelectorAll('video'))
|
|
421
|
+
.map((v) => srcOf(v))
|
|
422
|
+
.filter((s) => s.length > 0);
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Poll the generate page until OUR prompt's result video has a src (or the
|
|
427
|
+
* generation fails / times out). Returns the result video URL(s).
|
|
428
|
+
*/
|
|
429
|
+
export async function waitForResultVideo(page, key, opts) {
|
|
430
|
+
const { timeoutMs, baseline = [], onTick } = opts;
|
|
431
|
+
const start = Date.now();
|
|
432
|
+
const POLL = 3000;
|
|
433
|
+
while (Date.now() - start < timeoutMs) {
|
|
434
|
+
const result = await readResultForPrompt(page, key, baseline);
|
|
435
|
+
if (onTick)
|
|
436
|
+
onTick(Math.round((Date.now() - start) / 1000));
|
|
437
|
+
if (result.failed) {
|
|
438
|
+
throw new Error('Dreamina reported the generation failed (check prompt / content policy).');
|
|
439
|
+
}
|
|
440
|
+
if (result.srcs.length > 0) {
|
|
441
|
+
// Let the src settle to its final CDN URL.
|
|
442
|
+
await page.waitForTimeout(2000);
|
|
443
|
+
const settled = await readResultForPrompt(page, key, baseline);
|
|
444
|
+
return settled.srcs.length > 0 ? settled.srcs : result.srcs;
|
|
445
|
+
}
|
|
446
|
+
await page.waitForTimeout(POLL);
|
|
447
|
+
}
|
|
448
|
+
return [];
|
|
449
|
+
}
|
|
450
|
+
//# sourceMappingURL=dreamina-video.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dreamina-video.js","sourceRoot":"","sources":["../../src/providers/dreamina-video.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,mBAAmB;IACnB,cAAc;IACd,kBAAkB;IAClB,cAAc;IACd,mBAAmB;CACX,CAAC;AAGX,iFAAiF;AACjF,MAAM,CAAC,MAAM,sBAAsB,GAAuB,mBAAmB,CAAC;AAE9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAU,CAAC;AAGvF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAU,CAAC;AAG/D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC,gEAAgE;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,gBAAgB;IACtB,MAAM,EAAE,uBAAuB;IAC/B,WAAW,EAAE,aAAa;CAClB,CAAC;AAoBX,MAAM,CAAC,MA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} from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Dreamina — ByteDance / CapCut's AI creation studio (https://dreamina.capcut.com).
|
|
4
|
+
*
|
|
5
|
+
* This provider currently implements the **login + auth-check** flow. Video
|
|
6
|
+
* generation (prompt submission, model/aspect/duration selection, polling and
|
|
7
|
+
* download) is wired in a follow-up; {@link dreaminaActions.submitPrompt} and
|
|
8
|
+
* {@link dreaminaActions.captureResponse} intentionally throw until then.
|
|
9
|
+
*
|
|
10
|
+
* Auth detection notes (verified against the live site, May 2026):
|
|
11
|
+
* - The studio renders for signed-out visitors too, so a visible composer is
|
|
12
|
+
* NOT evidence of being logged in.
|
|
13
|
+
* - The reliable signed-out signal is the sidebar "Sign in" affordance
|
|
14
|
+
* (`div[class*="login-button"]`).
|
|
15
|
+
* - Signed-in evidence: an account avatar, or a numeric credit balance in the
|
|
16
|
+
* sidebar credit menu (`#SiderMenuCredit`), which is empty when logged out.
|
|
17
|
+
* - CSS-module class suffixes are content-hashed (e.g. `login-button-cgKP_u`)
|
|
18
|
+
* and change between builds, so we match on stable class *prefixes* and the
|
|
19
|
+
* Arco Design component classes (`lv-*`), never the full hashed class.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DREAMINA_CONFIG: ProviderConfig;
|
|
22
|
+
export declare const DREAMINA_SELECTORS: {
|
|
23
|
+
/** Signed-out indicator: sidebar "Sign in" button (CSS-module class prefix). */
|
|
24
|
+
readonly loginButton: "[class*=\"login-button\"]";
|
|
25
|
+
/** Prompt composer — Tiptap/ProseMirror rich-text input. */
|
|
26
|
+
readonly composer: ".tiptap.ProseMirror[role=\"textbox\"]";
|
|
27
|
+
/** Generate/submit button (disabled until a prompt is entered). */
|
|
28
|
+
readonly submitButton: "button[class*=\"submit-button\"]";
|
|
29
|
+
/** Sidebar credit balance — stable id; empty text when signed out. */
|
|
30
|
+
readonly creditDisplay: "#SiderMenuCredit";
|
|
31
|
+
};
|
|
32
|
+
export declare const dreaminaActions: ProviderActions;
|
|
33
|
+
//# sourceMappingURL=dreamina.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dreamina.d.ts","sourceRoot":"","sources":["../../src/providers/dreamina.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAErF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,EAAE,cAQ7B,CAAC;AAEF,eAAO,MAAM,kBAAkB;IAC7B,gFAAgF;;IAEhF,4DAA4D;;IAE5D,mEAAmE;;IAEnE,sEAAsE;;CAE9D,CAAC;AAwBX,eAAO,MAAM,eAAe,EAAE,eAwF7B,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dreamina — ByteDance / CapCut's AI creation studio (https://dreamina.capcut.com).
|
|
3
|
+
*
|
|
4
|
+
* This provider currently implements the **login + auth-check** flow. Video
|
|
5
|
+
* generation (prompt submission, model/aspect/duration selection, polling and
|
|
6
|
+
* download) is wired in a follow-up; {@link dreaminaActions.submitPrompt} and
|
|
7
|
+
* {@link dreaminaActions.captureResponse} intentionally throw until then.
|
|
8
|
+
*
|
|
9
|
+
* Auth detection notes (verified against the live site, May 2026):
|
|
10
|
+
* - The studio renders for signed-out visitors too, so a visible composer is
|
|
11
|
+
* NOT evidence of being logged in.
|
|
12
|
+
* - The reliable signed-out signal is the sidebar "Sign in" affordance
|
|
13
|
+
* (`div[class*="login-button"]`).
|
|
14
|
+
* - Signed-in evidence: an account avatar, or a numeric credit balance in the
|
|
15
|
+
* sidebar credit menu (`#SiderMenuCredit`), which is empty when logged out.
|
|
16
|
+
* - CSS-module class suffixes are content-hashed (e.g. `login-button-cgKP_u`)
|
|
17
|
+
* and change between builds, so we match on stable class *prefixes* and the
|
|
18
|
+
* Arco Design component classes (`lv-*`), never the full hashed class.
|
|
19
|
+
*/
|
|
20
|
+
export const DREAMINA_CONFIG = {
|
|
21
|
+
name: 'dreamina',
|
|
22
|
+
displayName: 'Dreamina',
|
|
23
|
+
url: 'https://dreamina.capcut.com/ai-tool/home?type=video',
|
|
24
|
+
loginUrl: 'https://dreamina.capcut.com/ai-tool/home?type=video',
|
|
25
|
+
models: ['Seedance 2.0', 'Seedance 2.0 Fast'],
|
|
26
|
+
defaultModel: 'Seedance 2.0 Fast',
|
|
27
|
+
defaultTimeoutMs: 10 * 60 * 1000, // 10 mins — video gen is slow
|
|
28
|
+
};
|
|
29
|
+
export const DREAMINA_SELECTORS = {
|
|
30
|
+
/** Signed-out indicator: sidebar "Sign in" button (CSS-module class prefix). */
|
|
31
|
+
loginButton: '[class*="login-button"]',
|
|
32
|
+
/** Prompt composer — Tiptap/ProseMirror rich-text input. */
|
|
33
|
+
composer: '.tiptap.ProseMirror[role="textbox"]',
|
|
34
|
+
/** Generate/submit button (disabled until a prompt is entered). */
|
|
35
|
+
submitButton: 'button[class*="submit-button"]',
|
|
36
|
+
/** Sidebar credit balance — stable id; empty text when signed out. */
|
|
37
|
+
creditDisplay: '#SiderMenuCredit',
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* CapCut / ByteDance passport session cookies set on `.capcut.com` once signed
|
|
41
|
+
* in. Presence of any of these is treated as proof of an authenticated session.
|
|
42
|
+
* (`ttwid`, `msToken`, `_tea_web_id` are anti-bot/analytics, NOT auth, and are
|
|
43
|
+
* present even when signed out, so they are deliberately excluded.)
|
|
44
|
+
*/
|
|
45
|
+
const DREAMINA_AUTH_COOKIES = new Set([
|
|
46
|
+
'sessionid',
|
|
47
|
+
'sessionid_ss',
|
|
48
|
+
'sid_guard',
|
|
49
|
+
'sid_tt',
|
|
50
|
+
'uid_tt',
|
|
51
|
+
'uid_tt_ss',
|
|
52
|
+
'sid_ucp_v1',
|
|
53
|
+
'ssid_ucp_v1',
|
|
54
|
+
'passport_auth_status',
|
|
55
|
+
]);
|
|
56
|
+
/** URLs Dreamina/CapCut redirects to when authentication is required. */
|
|
57
|
+
const LOGIN_URL_RE = /(?:passport|accounts?|login|signin)\.(?:capcut|byteoversea|tiktok|bytedance)\.com|\/(?:login|sign[-_]?in)(?:[/?#]|$)/i;
|
|
58
|
+
export const dreaminaActions = {
|
|
59
|
+
async isLoggedIn(page) {
|
|
60
|
+
try {
|
|
61
|
+
// A redirect to a login/passport page means we're not authenticated.
|
|
62
|
+
if (LOGIN_URL_RE.test(page.url()))
|
|
63
|
+
return false;
|
|
64
|
+
// Settle the SPA. The signed-out studio reliably renders the sidebar
|
|
65
|
+
// "Sign in" button, so waiting for it resolves fast when logged out and
|
|
66
|
+
// avoids sampling the brief load window where it has not rendered yet
|
|
67
|
+
// (during which guest feed thumbnails would otherwise look like avatars).
|
|
68
|
+
await page
|
|
69
|
+
.locator(DREAMINA_SELECTORS.loginButton)
|
|
70
|
+
.first()
|
|
71
|
+
.waitFor({ state: 'visible', timeout: 12_000 })
|
|
72
|
+
.catch(() => { });
|
|
73
|
+
const hasAuthCookies = await page
|
|
74
|
+
.context()
|
|
75
|
+
.cookies(['https://dreamina.capcut.com', 'https://www.capcut.com', 'https://capcut.com'])
|
|
76
|
+
.then((cookies) => cookies.some((cookie) => DREAMINA_AUTH_COOKIES.has(cookie.name)))
|
|
77
|
+
.catch(() => false);
|
|
78
|
+
const dom = await page.evaluate(({ loginButtonSel, creditSel }) => {
|
|
79
|
+
const visible = (el) => {
|
|
80
|
+
if (!(el instanceof HTMLElement))
|
|
81
|
+
return false;
|
|
82
|
+
const style = window.getComputedStyle(el);
|
|
83
|
+
return (el.offsetWidth > 0 &&
|
|
84
|
+
el.offsetHeight > 0 &&
|
|
85
|
+
style.visibility !== 'hidden' &&
|
|
86
|
+
style.display !== 'none');
|
|
87
|
+
};
|
|
88
|
+
const norm = (value) => (value ?? '').replace(/\s+/g, ' ').trim();
|
|
89
|
+
// Signed-out: a visible "Sign in / Log in / Sign up" affordance.
|
|
90
|
+
const loginButtonVisible = Array.from(document.querySelectorAll(loginButtonSel)).some(visible);
|
|
91
|
+
const signInTextRe = /^(?:sign in|log ?in|sign up|登录|登入|注册)$/i;
|
|
92
|
+
const textAffordance = Array.from(document.querySelectorAll('button, a, [role="button"]')).some((el) => visible(el) && signInTextRe.test(norm(el.textContent)));
|
|
93
|
+
const signInVisible = loginButtonVisible || textAffordance;
|
|
94
|
+
// Signed-in: the sidebar credit menu shows a numeric balance (it is
|
|
95
|
+
// empty when signed out). Avatar-class elements are intentionally NOT
|
|
96
|
+
// used — the guest feed renders several `[class*="avatar"]` thumbnails.
|
|
97
|
+
const creditEl = document.querySelector(creditSel);
|
|
98
|
+
const hasCreditBalance = !!creditEl && /\d/.test(norm(creditEl.textContent));
|
|
99
|
+
return { signInVisible, hasCreditBalance };
|
|
100
|
+
}, {
|
|
101
|
+
loginButtonSel: DREAMINA_SELECTORS.loginButton,
|
|
102
|
+
creditSel: DREAMINA_SELECTORS.creditDisplay,
|
|
103
|
+
});
|
|
104
|
+
// A visible sign-in affordance is authoritative — the guest studio shows it.
|
|
105
|
+
if (dom.signInVisible)
|
|
106
|
+
return false;
|
|
107
|
+
// Require positive proof of a session: a CapCut passport cookie or a
|
|
108
|
+
// rendered credit balance. Absence of the login button alone is NOT
|
|
109
|
+
// enough — it is also briefly absent during initial page load.
|
|
110
|
+
return hasAuthCookies || dom.hasCreditBalance;
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
async submitPrompt(_page, _prompt) {
|
|
117
|
+
throw new Error('Dreamina video generation is not yet implemented. Login and auth-check are supported; ' +
|
|
118
|
+
'prompt submission + generation are coming in a follow-up.');
|
|
119
|
+
},
|
|
120
|
+
async captureResponse(_page, _opts) {
|
|
121
|
+
throw new Error('Dreamina video generation is not yet implemented. Login and auth-check are supported; ' +
|
|
122
|
+
'response capture is coming in a follow-up.');
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=dreamina.js.map
|
|
@@ -0,0 +1 @@
|
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