@lightcone-ai/daemon 0.15.14 → 0.15.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -53,7 +53,8 @@ export class KuaishouAdapter {
|
|
|
53
53
|
if (!redirectUrl.includes('cp.kuaishou.com/article/publish')) {
|
|
54
54
|
throw new Error(`LOGIN_EXPIRED: 快手登录已过期,请重新扫码连接 (redirected to: ${redirectUrl})`);
|
|
55
55
|
}
|
|
56
|
-
await this.
|
|
56
|
+
try { await this._cdp.send('Runtime.evaluate', { expression: 'window.scrollTo(0, 300)', returnByValue: false }); } catch {}
|
|
57
|
+
await this._waitForSelector('input[type="file"], [class*="upload"], [class*="Upload"]', 45000);
|
|
57
58
|
|
|
58
59
|
const { loggedIn } = await this.checkLoginStatus();
|
|
59
60
|
if (!loggedIn) throw new Error('LOGIN_EXPIRED: 快手登录已过期,请重新扫码连接');
|
|
@@ -88,15 +89,18 @@ export class KuaishouAdapter {
|
|
|
88
89
|
if (!redirectUrl.includes('cp.kuaishou.com/article/publish')) {
|
|
89
90
|
throw new Error(`LOGIN_EXPIRED: 快手登录已过期,请重新扫码连接 (redirected to: ${redirectUrl})`);
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
// Scroll once to trigger any lazy-rendered upload widgets, then wait
|
|
93
|
+
try { await this._cdp.send('Runtime.evaluate', { expression: 'window.scrollTo(0, 300)', returnByValue: false }); } catch {}
|
|
94
|
+
await this._waitForSelector('input[type="file"], [class*="upload"], [class*="Upload"]', 45000);
|
|
92
95
|
|
|
93
96
|
const { loggedIn } = await this.checkLoginStatus();
|
|
94
97
|
if (!loggedIn) throw new Error('LOGIN_EXPIRED: 快手登录已过期,请重新扫码连接');
|
|
95
98
|
|
|
96
99
|
await this._uploadFiles([video], 'video');
|
|
97
|
-
// Wait for
|
|
98
|
-
await this._waitForSelector('[placeholder*="
|
|
100
|
+
// Wait for publish form: Kuaishou video page shows description area (not a separate title field)
|
|
101
|
+
await this._waitForSelector('[placeholder*="描述"], [contenteditable="true"]', 120000);
|
|
99
102
|
|
|
103
|
+
// Kuaishou video publish has no dedicated title input; skip if field not found
|
|
100
104
|
if (title) {
|
|
101
105
|
await this._fillField('[placeholder*="标题"]', title);
|
|
102
106
|
}
|
|
@@ -124,6 +128,24 @@ export class KuaishouAdapter {
|
|
|
124
128
|
if (result.result?.value) return;
|
|
125
129
|
await sleep(500);
|
|
126
130
|
}
|
|
131
|
+
// Dump diagnostic info to help debug page state on timeout
|
|
132
|
+
try {
|
|
133
|
+
const [urlR, titleR, bodyR, inputR, uploadR] = await Promise.all([
|
|
134
|
+
this._cdp.send('Runtime.evaluate', { expression: 'location.href', returnByValue: true }),
|
|
135
|
+
this._cdp.send('Runtime.evaluate', { expression: 'document.title', returnByValue: true }),
|
|
136
|
+
this._cdp.send('Runtime.evaluate', { expression: 'document.body?.innerText?.slice(0,400)', returnByValue: true }),
|
|
137
|
+
this._cdp.send('Runtime.evaluate', { expression: `!!document.querySelector('input[type="file"]')`, returnByValue: true }),
|
|
138
|
+
this._cdp.send('Runtime.evaluate', { expression: `document.querySelectorAll('[class*="upload"],[class*="Upload"]').length`, returnByValue: true }),
|
|
139
|
+
]);
|
|
140
|
+
console.error(`[KuaishouAdapter] selector timeout diagnostics:`);
|
|
141
|
+
console.error(` url=${urlR.result?.value}`);
|
|
142
|
+
console.error(` title=${titleR.result?.value}`);
|
|
143
|
+
console.error(` input[type=file] present=${inputR.result?.value}`);
|
|
144
|
+
console.error(` upload-class elements=${uploadR.result?.value}`);
|
|
145
|
+
console.error(` body text: ${bodyR.result?.value}`);
|
|
146
|
+
} catch (diagErr) {
|
|
147
|
+
console.error(`[KuaishouAdapter] diagnostic failed: ${diagErr.message}`);
|
|
148
|
+
}
|
|
127
149
|
throw new Error(`Timeout waiting for selector: ${selector}`);
|
|
128
150
|
}
|
|
129
151
|
|
package/package.json
CHANGED
package/src/browser-login.js
CHANGED
|
@@ -11,6 +11,7 @@ import path from 'path';
|
|
|
11
11
|
import http from 'http';
|
|
12
12
|
import { WebSocket } from 'ws';
|
|
13
13
|
import { acquireProfileLock } from './profile-lock.js';
|
|
14
|
+
import { closeSession as closePublisherSession } from '../mcp-servers/publisher/chrome-pool.js';
|
|
14
15
|
|
|
15
16
|
// ── Platform configs ──────────────────────────────────────────────────────────
|
|
16
17
|
|
|
@@ -419,6 +420,11 @@ export class BrowserLoginSession {
|
|
|
419
420
|
} catch (err) {
|
|
420
421
|
console.error(`[BrowserLogin][${this._platform}] Failed to save cookies: ${err.message}`);
|
|
421
422
|
}
|
|
423
|
+
// Kill any stale chrome-pool session so the next publish job starts fresh with new cookies
|
|
424
|
+
try {
|
|
425
|
+
closePublisherSession(this._platform);
|
|
426
|
+
console.log(`[BrowserLogin][${this._platform}] Closed stale publisher Chrome session after re-login`);
|
|
427
|
+
} catch {}
|
|
422
428
|
connection.send({ type: 'browser:login_complete', platform: this._platform, profileDir: this._profileDir });
|
|
423
429
|
await this.close();
|
|
424
430
|
}
|