agent-bridge-qwenwork 1.0.14 → 1.0.15

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.
@@ -227,17 +227,35 @@ class QwenCdpClient {
227
227
  throw new Error("千问办公 UI 超时未返回回复");
228
228
  }
229
229
  async readImages(beforeIds) {
230
- const encoded = await this.evaluate(`(() => {
230
+ const collectImages = `(() => {
231
231
  const before = new Set(${JSON.stringify([...beforeIds])}); const files = [];
232
232
  for (const part of document.querySelectorAll(${JSON.stringify(exports.assistantMessageSelector)})) {
233
233
  if (before.has(part.getAttribute('data-message-id'))) continue;
234
234
  const message = part.closest?.('[data-assistant-message-id]') || part;
235
- for (const button of (message.querySelectorAll?.('button') ?? [])) if (button.innerText.includes('已展示最终文件')) button.click();
236
235
  for (const image of (message.querySelectorAll?.('img[src^="data:image/"]') ?? [])) files.push({ address: image.getAttribute('src'), filename: image.getAttribute('alt') || '' });
237
- for (const link of (message.querySelectorAll?.('a[href]') ?? [])) files.push({ address: link.getAttribute('href'), filename: link.innerText || '' });
236
+ for (const link of (message.querySelectorAll?.('a[href^="file://"]') ?? [])) files.push({ address: link.getAttribute('href'), filename: link.innerText || '' });
238
237
  }
239
238
  return JSON.stringify(files);
239
+ })()`;
240
+ // 工具区域由 React 异步展开,点击和读取必须分开执行。
241
+ await this.evaluate(`(() => {
242
+ const before = new Set(${JSON.stringify([...beforeIds])});
243
+ for (const part of document.querySelectorAll(${JSON.stringify(exports.assistantMessageSelector)})) {
244
+ if (before.has(part.getAttribute('data-message-id'))) continue;
245
+ const message = part.closest?.('[data-assistant-message-id]') || part;
246
+ for (const button of (message.querySelectorAll?.('button') ?? [])) {
247
+ if (button.innerText.includes('已展示最终文件') && button.getAttribute('aria-expanded') !== 'true') button.click();
248
+ }
249
+ }
250
+ return true;
240
251
  })()`);
252
+ let encoded = "[]";
253
+ for (let attempt = 0; attempt < 12; attempt++) {
254
+ encoded = String(await this.evaluate(collectImages) ?? "[]");
255
+ if (encoded !== "[]")
256
+ break;
257
+ await wait(250);
258
+ }
241
259
  const files = [...new Map(JSON.parse(encoded || "[]")
242
260
  .map((item) => [item.address, item]).filter(([address]) => typeof address === "string")).values()];
243
261
  const dataImages = files.map((item) => ({ ...item, image: decodeQwenDataImage(item.address) })).filter((item) => Boolean(item.image));
@@ -11,7 +11,7 @@ const desktop_launch_1 = require("../desktop-launch");
11
11
  const CHAT_HEARTBEAT_INTERVAL_MS = 2 * 60 * 60_000;
12
12
  exports.qwenworkManifest = {
13
13
  id: "qwenwork",
14
- version: "1.0.14",
14
+ version: "1.0.15",
15
15
  displayName: "千问办公",
16
16
  entry: "dist/index.js",
17
17
  apiVersion: "1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-bridge-qwenwork",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "agent-bridge 的千问办公插件。",
5
5
  "keywords": [
6
6
  "mu-agent-bridge-plugin",
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "qwenwork",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "type": "agent",
5
5
  "displayName": "千问办公",
6
6
  "entry": "dist/src-ts/plugins/qwenwork/index.js",