@lightcone-ai/daemon 0.9.73 → 0.9.75
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/package.json +1 -1
- package/src/browser-login.js +17 -3
- package/src/mcp-config.js +11 -7
package/package.json
CHANGED
package/src/browser-login.js
CHANGED
|
@@ -56,7 +56,7 @@ export const PLATFORM_CONFIGS = {
|
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
58
|
douyin: {
|
|
59
|
-
loginUrl: 'https://
|
|
59
|
+
loginUrl: 'https://creator.douyin.com/creator-micro/content/upload-image-text',
|
|
60
60
|
getSessionValue: (cookies) => cookies.find(c => c.name === 'sessionid')?.value ?? null,
|
|
61
61
|
isLoggedIn: (cookies, baseline) => {
|
|
62
62
|
const val = cookies.find(c => c.name === 'sessionid')?.value ?? null;
|
|
@@ -136,6 +136,7 @@ export class BrowserLoginSession {
|
|
|
136
136
|
|
|
137
137
|
async start(connection, userId) {
|
|
138
138
|
this._profileDir = profileDir(this._platform, userId);
|
|
139
|
+
connection.send({ type: 'browser:login_status', platform: this._platform, status: 'starting', message: '正在启动浏览器...' });
|
|
139
140
|
this._profileLock = await acquireProfileLock(this._platform, this._profileDir, {
|
|
140
141
|
owner: `browser-login:${this._platform}`,
|
|
141
142
|
timeoutMs: 10_000,
|
|
@@ -202,6 +203,7 @@ export class BrowserLoginSession {
|
|
|
202
203
|
} catch { /* not ready yet */ }
|
|
203
204
|
}
|
|
204
205
|
if (!ready) throw new Error('Chrome CDP did not become ready in time');
|
|
206
|
+
connection.send({ type: 'browser:login_status', platform: this._platform, status: 'browser_ready', message: '浏览器已启动,正在打开登录页...' });
|
|
205
207
|
|
|
206
208
|
const pagesJson = await httpGet(`http://localhost:${CDP_PORT}/json`);
|
|
207
209
|
const pages = JSON.parse(pagesJson);
|
|
@@ -217,6 +219,7 @@ export class BrowserLoginSession {
|
|
|
217
219
|
});
|
|
218
220
|
|
|
219
221
|
await this.send('Page.navigate', { url: this._config.loginUrl });
|
|
222
|
+
connection.send({ type: 'browser:login_status', platform: this._platform, status: 'navigating', message: '登录页加载中...' });
|
|
220
223
|
|
|
221
224
|
// Wait for page to settle
|
|
222
225
|
await sleep(4000);
|
|
@@ -239,6 +242,7 @@ export class BrowserLoginSession {
|
|
|
239
242
|
const baselineSession = this._config.getSessionValue(baselineCookies.cookies ?? []);
|
|
240
243
|
|
|
241
244
|
this._startPolling(connection, baselineSession);
|
|
245
|
+
await this._sendScreenshot(connection);
|
|
242
246
|
} catch (err) {
|
|
243
247
|
if (this._profileLock) { this._profileLock.release(); this._profileLock = null; }
|
|
244
248
|
throw err;
|
|
@@ -286,6 +290,17 @@ export class BrowserLoginSession {
|
|
|
286
290
|
return result.data;
|
|
287
291
|
}
|
|
288
292
|
|
|
293
|
+
async _sendScreenshot(connection) {
|
|
294
|
+
try {
|
|
295
|
+
const screenshot = await this.screenshot();
|
|
296
|
+
connection.send({ type: 'browser:screenshot', platform: this._platform, screenshot });
|
|
297
|
+
connection.send({ type: 'browser:login_status', platform: this._platform, status: 'ready', message: '请扫描页面中的二维码完成登录' });
|
|
298
|
+
} catch (err) {
|
|
299
|
+
console.error(`[BrowserLogin][${this._platform}] Screenshot error:`, err.message);
|
|
300
|
+
connection.send({ type: 'browser:login_status', platform: this._platform, status: 'screenshot_error', message: `截图失败:${err.message}` });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
289
304
|
async _switchToQrLogin() {
|
|
290
305
|
const selectors = this._config.qrTabSelector ?? [];
|
|
291
306
|
const result = await this.send('Runtime.evaluate', {
|
|
@@ -360,8 +375,7 @@ export class BrowserLoginSession {
|
|
|
360
375
|
if (_screenshotInProgress) return;
|
|
361
376
|
_screenshotInProgress = true;
|
|
362
377
|
try {
|
|
363
|
-
|
|
364
|
-
connection.send({ type: 'browser:screenshot', platform: this._platform, screenshot });
|
|
378
|
+
await this._sendScreenshot(connection);
|
|
365
379
|
} catch (err) {
|
|
366
380
|
console.error(`[BrowserLogin][${this._platform}] Screenshot error:`, err.message);
|
|
367
381
|
} finally {
|
package/src/mcp-config.js
CHANGED
|
@@ -66,13 +66,17 @@ export function buildSkillMcpServers({
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
for (const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
for (const [serverKey, server] of Object.entries(mcpServers)) {
|
|
70
|
+
const grantsForServer = (credentialGrants ?? []).filter(grant => {
|
|
71
|
+
const hasMatchingSkill = (skills ?? []).some(skill =>
|
|
72
|
+
skill.mcpConfig?.server === serverKey && skill.mcpConfig?.platform === grant.platform
|
|
73
|
+
);
|
|
74
|
+
const isSharedPlatformServer = serverKey === 'publisher' || serverKey === 'platform';
|
|
75
|
+
return hasMatchingSkill || isSharedPlatformServer;
|
|
76
|
+
});
|
|
77
|
+
for (const grant of grantsForServer) {
|
|
78
|
+
server.env = { ...(server.env ?? {}), ...(grant.envVars ?? {}) };
|
|
79
|
+
}
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
return mcpServers;
|