agent-bridge-qwenwork 1.0.26 → 1.0.27
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/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
`/new` 在已确认的空白新任务页可重复执行。远程消息和 `/new` 遇到输入框残留时,先将原文、页面地址和时间追加到插件数据目录的 `draft-recovery.jsonl`,再通过编辑器原生删除操作清理;备份失败、内容发生变化或正在生成回复时不清理。后台心跳只清理桥接自己的检测文本,遇到普通用户草稿则跳过。发送消息会点击桌面端“发送消息”按钮并确认输入框清空,避免仅按 Enter 后消息仍停留在输入框。真实通信失败后保持降级,普通 CDP 检查通过不会把状态改回就绪,须有真实回复或真实对话心跳通过。
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
提交前等待发送按钮就绪;窗口在插入、点击复查或回复轮询期间被最小化时,插件会恢复千问主窗口并继续确认。只有复查确认尚未点击时最多再尝试一次;仅备份并清理原会话内仍与本次请求完全一致的文字,保留用户后来修改的草稿。点击后无法确认提交状态时不会自动重发或清理输入,避免重复执行。
|
|
18
18
|
|
|
19
19
|
真实心跳会消耗模型额度,并在当前千问聊天会话留下检测消息;它通过与用户请求相同的发送和取回回复路径运行。云端故障、账号额度不足或登录过期仍可能需要修复服务或账号,验证失败期间不会报告健康。
|
|
20
20
|
|
|
@@ -265,21 +265,25 @@ class QwenCdpClient {
|
|
|
265
265
|
const input = document.querySelector(${JSON.stringify(exports.inputSelector)});
|
|
266
266
|
const button = document.querySelector('button[aria-label="发送消息"]');
|
|
267
267
|
const generating = document.querySelector('button[aria-label="停止"],button[aria-label="停止生成"],button[aria-label="Stop generating"]');
|
|
268
|
-
return Boolean(location.href === ${JSON.stringify(submitUrl)} && input && input.innerText.trim() === ${JSON.stringify(text.trim())}
|
|
268
|
+
return Boolean(!document.hidden && location.href === ${JSON.stringify(submitUrl)} && input && input.innerText.trim() === ${JSON.stringify(text.trim())}
|
|
269
269
|
&& button && !button.disabled && button.getAttribute('aria-disabled') !== 'true' && !generating);
|
|
270
270
|
})()`;
|
|
271
271
|
await this.cdp("Input.insertText", { text });
|
|
272
272
|
inserted = true;
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
273
|
+
// 只有复查确认尚未点击时才再试一次,不能重发提交结果未知的任务。
|
|
274
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
275
|
+
await this.waitFor(readyToSubmit, "千问发送按钮未就绪或输入校验失败,未发送消息");
|
|
276
|
+
submitAttempted = true;
|
|
277
|
+
const sent = await this.evaluate(`(() => {
|
|
278
|
+
if (!${readyToSubmit}) return false;
|
|
279
|
+
document.querySelector('button[aria-label="发送消息"]').click();
|
|
280
|
+
return true;
|
|
281
|
+
})()`);
|
|
282
|
+
if (sent === true)
|
|
283
|
+
break;
|
|
281
284
|
submitAttempted = false;
|
|
282
|
-
|
|
285
|
+
if (attempt === 1)
|
|
286
|
+
throw new Error("千问发送按钮未就绪或输入校验失败,未发送消息");
|
|
283
287
|
}
|
|
284
288
|
await this.waitFor(`(() => { const input = document.querySelector(${JSON.stringify(exports.inputSelector)}); return Boolean(input && !input.innerText.trim()); })()`, "千问未确认消息已提交");
|
|
285
289
|
}
|
|
@@ -309,6 +313,7 @@ class QwenCdpClient {
|
|
|
309
313
|
while (Date.now() < deadline || signal?.aborted) {
|
|
310
314
|
// 上游取消不停止桌面生成;确认结束前保留插件队列。
|
|
311
315
|
await wait(2_000);
|
|
316
|
+
await this.restoreVisible();
|
|
312
317
|
const messagesJson = await this.evaluate(`JSON.stringify([...document.querySelectorAll(${JSON.stringify(exports.assistantMessageSelector)})].map(element => ({ id: element.getAttribute('data-message-id'), text: element.innerText })))`);
|
|
313
318
|
const messages = JSON.parse(messagesJson || "[]");
|
|
314
319
|
const fresh = freshAssistantMessages(beforeIds, messages);
|
|
@@ -572,9 +577,8 @@ class QwenCdpClient {
|
|
|
572
577
|
try {
|
|
573
578
|
await this.evaluate(`(async () => {
|
|
574
579
|
if (document.querySelector('button[aria-label="停止"],button[aria-label="停止生成"],button[aria-label="Stop generating"]')) throw new Error('千问桌面端正在生成回复');
|
|
575
|
-
// 隐藏窗口会暂停消息渲染,使桌面端的提交前检查一直等不到确认。
|
|
576
|
-
if (document.hidden && typeof window.desktopApi?.focusMainWindow === 'function') await window.desktopApi.focusMainWindow();
|
|
577
580
|
})()`);
|
|
581
|
+
await this.restoreVisible();
|
|
578
582
|
}
|
|
579
583
|
catch (error) {
|
|
580
584
|
let permission;
|
|
@@ -587,6 +591,11 @@ class QwenCdpClient {
|
|
|
587
591
|
throw error;
|
|
588
592
|
}
|
|
589
593
|
}
|
|
594
|
+
async restoreVisible() {
|
|
595
|
+
await this.evaluate(`(async () => {
|
|
596
|
+
if (document.hidden && typeof window.desktopApi?.focusMainWindow === 'function') await window.desktopApi.focusMainWindow();
|
|
597
|
+
})()`);
|
|
598
|
+
}
|
|
590
599
|
recoverDraft(expected) {
|
|
591
600
|
return (0, cdp_draft_1.recoverCdpDraft)(this.evaluate.bind(this), exports.inputSelector, 'button[aria-label="停止"],button[aria-label="停止生成"],button[aria-label="Stop generating"]', this.options.dataDir, expected);
|
|
592
601
|
}
|
|
@@ -650,6 +659,7 @@ class QwenCdpClient {
|
|
|
650
659
|
async waitFor(expression, message) {
|
|
651
660
|
const deadline = Date.now() + this.options.timeoutMs;
|
|
652
661
|
while (Date.now() < deadline) {
|
|
662
|
+
await this.restoreVisible();
|
|
653
663
|
if (await this.evaluate(expression))
|
|
654
664
|
return;
|
|
655
665
|
await wait(200);
|
|
@@ -12,7 +12,7 @@ const desktop_launch_1 = require("../desktop-launch");
|
|
|
12
12
|
const session_history_1 = require("./session-history");
|
|
13
13
|
exports.qwenworkManifest = {
|
|
14
14
|
id: "qwenwork",
|
|
15
|
-
version: "1.0.
|
|
15
|
+
version: "1.0.27",
|
|
16
16
|
displayName: "千问办公",
|
|
17
17
|
entry: "dist/index.js",
|
|
18
18
|
apiVersion: "1",
|
package/package.json
CHANGED