@lightcone-ai/daemon 0.9.37 → 0.9.39
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.
|
@@ -33,8 +33,15 @@ export class XhsAdapter {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async checkLoginStatus() {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
// Navigate to publish page — if redirected away, session is expired
|
|
37
|
+
await this._cdp.send('Page.navigate', { url: 'https://creator.xiaohongshu.com/publish/publish' });
|
|
38
|
+
await sleep(4000);
|
|
39
|
+
const result = await this._cdp.send('Runtime.evaluate', {
|
|
40
|
+
expression: 'window.location.href',
|
|
41
|
+
returnByValue: true,
|
|
42
|
+
});
|
|
43
|
+
const url = result.result?.value ?? '';
|
|
44
|
+
return url.includes('creator.xiaohongshu.com/publish');
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
async publishImageText({ title, text, tags = [], images = [] }) {
|
package/package.json
CHANGED
package/src/browser-login.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { spawn, execSync } from 'child_process';
|
|
8
8
|
import { homedir } from 'os';
|
|
9
|
-
import { accessSync, constants as fsConstants, rmSync, existsSync } from 'fs';
|
|
9
|
+
import { accessSync, constants as fsConstants, rmSync, existsSync, mkdirSync } from 'fs';
|
|
10
10
|
import path from 'path';
|
|
11
11
|
import http from 'http';
|
|
12
12
|
import { WebSocket } from 'ws';
|
|
@@ -94,6 +94,23 @@ export class BrowserLoginSession {
|
|
|
94
94
|
async start(connection, userId) {
|
|
95
95
|
this._profileDir = profileDir(this._platform, userId);
|
|
96
96
|
|
|
97
|
+
// Ensure profile dir exists
|
|
98
|
+
try { mkdirSync(this._profileDir, { recursive: true }); } catch {}
|
|
99
|
+
|
|
100
|
+
// Kill any process holding the CDP port
|
|
101
|
+
try {
|
|
102
|
+
if (process.platform !== 'win32') {
|
|
103
|
+
execSync(`lsof -ti:${CDP_PORT} | xargs kill -9`, { stdio: 'ignore' });
|
|
104
|
+
}
|
|
105
|
+
} catch {}
|
|
106
|
+
await sleep(300);
|
|
107
|
+
|
|
108
|
+
// Clean up stale Chrome lock files
|
|
109
|
+
for (const lockFile of ['SingletonLock', 'SingletonCookie', 'SingletonSocket']) {
|
|
110
|
+
const p = path.join(this._profileDir, lockFile);
|
|
111
|
+
try { if (existsSync(p)) rmSync(p, { force: true }); } catch {}
|
|
112
|
+
}
|
|
113
|
+
|
|
97
114
|
this._proc = spawn(CHROME_BIN, [
|
|
98
115
|
`--remote-debugging-port=${CDP_PORT}`,
|
|
99
116
|
'--no-sandbox',
|