agent-bridge-doubao 1.0.10 → 1.0.12

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.
@@ -6,17 +6,19 @@ exports.requestBody = requestBody;
6
6
  const node_crypto_1 = require("node:crypto");
7
7
  function doubaoStreamErrorMessage(data) {
8
8
  let code = "";
9
- let subtype = "";
9
+ let message = "";
10
10
  try {
11
11
  const value = JSON.parse(data);
12
- code = String(value.code ?? value.error?.code ?? "");
13
- subtype = String(value.subtype ?? value.error?.subtype ?? "").toLowerCase();
12
+ code = String(value.error_code ?? value.code ?? value.error?.error_code ?? value.error?.code ?? "");
13
+ message = String(value.error_msg ?? value.message ?? value.error?.message ?? "").trim();
14
14
  }
15
15
  catch { /* 平台可能返回非 JSON 错误 */ }
16
- if (code === "710022004" || subtype === "slide" || /rate limited|verify|slide/i.test(data)) {
17
- return `豆包平台触发滑块验证${code ? `(错误码 ${code})` : ""},请在豆包客户端完成验证后重试`;
18
- }
19
- return `豆包平台返回流式错误${code ? `(错误码 ${code})` : ""},请稍后重试`;
16
+ if (message.length > 300)
17
+ message = message.slice(0, 300);
18
+ message = message.replace(/[\r\n\t]+/g, " ");
19
+ if (message)
20
+ return `豆包平台返回错误${code ? `(错误码 ${code})` : ""}:${message}`;
21
+ return `豆包平台返回流式错误${code ? `(错误码 ${code})` : ""}`;
20
22
  }
21
23
  const defaults = { port: Number(process.env.DOUBAO_CDP_PORT ?? "9227"), conversationId: process.env.DOUBAO_CONVERSATION_ID ?? "759450172544514", botId: process.env.DOUBAO_BOT_ID ?? "7338286299411103781", timeoutMs: Number(process.env.DOUBAO_TIMEOUT_MS ?? "180000") };
22
24
  function sleep(ms, signal) {
@@ -57,7 +59,7 @@ class DoubaoCdpClient {
57
59
  this.closeController.abort();
58
60
  if (this.socket) {
59
61
  try {
60
- await this.evaluate("window.__mab_doubao_controller?.abort()");
62
+ await this.cdp("Runtime.evaluate", { expression: "window.__mab_doubao_controller?.abort()", returnByValue: true }, 3_000);
61
63
  }
62
64
  catch { /* CDP 已断开时无需等待页面确认 */ }
63
65
  }
@@ -95,10 +97,10 @@ class DoubaoCdpClient {
95
97
  } if (message.id === undefined)
96
98
  return; const pending = this.pending.get(message.id); if (!pending)
97
99
  return; this.pending.delete(message.id); pending.resolve(message); }
98
- async cdp(method, params = {}) { if (!this.socket)
100
+ async cdp(method, params = {}, timeoutMs = this.options.timeoutMs) { if (!this.socket)
99
101
  throw new Error("豆包 CDP 尚未连接"); const id = ++this.sequence; const result = new Promise((resolve, reject) => this.pending.set(id, { resolve, reject })); let timer; try {
100
102
  this.socket.send(JSON.stringify({ id, method, params }));
101
- return await Promise.race([result, new Promise((_, reject) => { timer = setTimeout(() => { this.pending.delete(id); reject(new Error(`CDP ${method} 超时`)); }, this.options.timeoutMs); })]);
103
+ return await Promise.race([result, new Promise((_, reject) => { timer = setTimeout(() => { this.pending.delete(id); reject(new Error(`CDP ${method} 超时`)); }, timeoutMs); })]);
102
104
  }
103
105
  finally {
104
106
  clearTimeout(timer);
@@ -6,7 +6,7 @@ const plugin_1 = require("../../plugin");
6
6
  const desktop_launch_1 = require("../desktop-launch");
7
7
  exports.doubaoManifest = {
8
8
  id: "doubao",
9
- version: "1.0.10",
9
+ version: "1.0.12",
10
10
  displayName: "豆包",
11
11
  entry: "dist/index.js",
12
12
  apiVersion: "1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-bridge-doubao",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
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": "doubao",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "type": "agent",
5
5
  "displayName": "豆包",
6
6
  "entry": "dist/src-ts/plugins/doubao/index.js",