@lightcone-ai/daemon 0.9.28 → 0.9.30
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.
|
@@ -66,14 +66,13 @@ export class XhsAdapter {
|
|
|
66
66
|
await sleep(1000);
|
|
67
67
|
|
|
68
68
|
// Click publish button
|
|
69
|
-
await this._clickByText('发布');
|
|
70
|
-
|
|
69
|
+
const clicked = await this._clickByText('发布');
|
|
70
|
+
if (!clicked) throw new Error('PUBLISH_FAILED: 找不到发布按钮,页面结构可能已变化');
|
|
71
|
+
await sleep(5000);
|
|
71
72
|
|
|
72
|
-
// Check result
|
|
73
|
+
// Check result — must confirm URL changed or success element appeared
|
|
73
74
|
const currentUrl = await this._getUrl();
|
|
74
|
-
|
|
75
|
-
return { success: true, post_url: currentUrl };
|
|
76
|
-
}
|
|
75
|
+
const isSuccess = currentUrl.includes('success') || currentUrl.includes('works') || currentUrl.includes('note-manager');
|
|
77
76
|
|
|
78
77
|
// Try to grab post URL from page
|
|
79
78
|
const urlResult = await cdp.send('Runtime.evaluate', {
|
|
@@ -81,7 +80,19 @@ export class XhsAdapter {
|
|
|
81
80
|
returnByValue: true,
|
|
82
81
|
});
|
|
83
82
|
const postUrl = urlResult.result?.value || currentUrl;
|
|
84
|
-
|
|
83
|
+
|
|
84
|
+
if (!isSuccess && !urlResult.result?.value) {
|
|
85
|
+
// Check if still on publish page (means publish didn't go through)
|
|
86
|
+
if (currentUrl.includes('/publish/publish')) {
|
|
87
|
+
const errorText = await cdp.send('Runtime.evaluate', {
|
|
88
|
+
expression: `document.querySelector('[class*="error"], [class*="fail"], [class*="tips"]')?.innerText || ''`,
|
|
89
|
+
returnByValue: true,
|
|
90
|
+
});
|
|
91
|
+
throw new Error(`PUBLISH_FAILED: 发布后仍停留在发布页,可能未成功。页面提示:${errorText.result?.value || '无'}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return { success: true, post_url: postUrl || currentUrl };
|
|
85
96
|
}
|
|
86
97
|
|
|
87
98
|
async publishShortVideo({ title, text, tags = [], video, cover }) {
|
|
@@ -186,7 +197,7 @@ export class XhsAdapter {
|
|
|
186
197
|
}
|
|
187
198
|
|
|
188
199
|
async _clickByText(text) {
|
|
189
|
-
await this._cdp.send('Runtime.evaluate', {
|
|
200
|
+
const result = await this._cdp.send('Runtime.evaluate', {
|
|
190
201
|
expression: `
|
|
191
202
|
(function() {
|
|
192
203
|
const els = [...document.querySelectorAll('button, [role="button"]')];
|
|
@@ -197,6 +208,7 @@ export class XhsAdapter {
|
|
|
197
208
|
`,
|
|
198
209
|
returnByValue: true,
|
|
199
210
|
});
|
|
211
|
+
return result.result?.value === true;
|
|
200
212
|
}
|
|
201
213
|
|
|
202
214
|
async _getUrl() {
|
|
@@ -111,7 +111,7 @@ async function _spawnChrome(profileDir, port) {
|
|
|
111
111
|
`--remote-debugging-port=${port}`,
|
|
112
112
|
'--no-sandbox',
|
|
113
113
|
'--disable-dev-shm-usage',
|
|
114
|
-
'--headless=
|
|
114
|
+
'--headless=false',
|
|
115
115
|
`--user-data-dir=${profileDir}`,
|
|
116
116
|
'--window-size=1280,900',
|
|
117
117
|
'--disable-blink-features=AutomationControlled',
|
package/package.json
CHANGED
package/src/chat-bridge.js
CHANGED
|
@@ -439,9 +439,12 @@ server.tool('execute_approved_action',
|
|
|
439
439
|
const data = await api('POST', `/actions/${action_id}/execute`, {});
|
|
440
440
|
if (data.error) return { isError: true, content: [{ type: 'text', text: `Failed: ${data.error}` }] };
|
|
441
441
|
return { content: [{ type: 'text', text:
|
|
442
|
-
`Action
|
|
442
|
+
`Action approved. Now call the appropriate platform tool to actually perform the operation.\n` +
|
|
443
443
|
`actionType=${data.actionType} platform=${data.platform}\n` +
|
|
444
|
-
`Payload
|
|
444
|
+
`Payload: ${JSON.stringify(data.payload)}\n\n` +
|
|
445
|
+
`For xhs_post: call publish_content(platform="xhs", ...) with the payload fields above.\n` +
|
|
446
|
+
`For douyin_post: call publish_content(platform="douyin", ...).\n` +
|
|
447
|
+
`For x_post: call post_tweet(...).`
|
|
445
448
|
}]};
|
|
446
449
|
} catch (err) {
|
|
447
450
|
return { isError: true, content: [{ type: 'text', text: `Error: ${err.message}` }] };
|