agent-bridge-doubao 1.0.10 → 1.0.11
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.
|
@@ -57,7 +57,7 @@ class DoubaoCdpClient {
|
|
|
57
57
|
this.closeController.abort();
|
|
58
58
|
if (this.socket) {
|
|
59
59
|
try {
|
|
60
|
-
await this.
|
|
60
|
+
await this.cdp("Runtime.evaluate", { expression: "window.__mab_doubao_controller?.abort()", returnByValue: true }, 3_000);
|
|
61
61
|
}
|
|
62
62
|
catch { /* CDP 已断开时无需等待页面确认 */ }
|
|
63
63
|
}
|
|
@@ -95,10 +95,10 @@ class DoubaoCdpClient {
|
|
|
95
95
|
} if (message.id === undefined)
|
|
96
96
|
return; const pending = this.pending.get(message.id); if (!pending)
|
|
97
97
|
return; this.pending.delete(message.id); pending.resolve(message); }
|
|
98
|
-
async cdp(method, params = {}) { if (!this.socket)
|
|
98
|
+
async cdp(method, params = {}, timeoutMs = this.options.timeoutMs) { if (!this.socket)
|
|
99
99
|
throw new Error("豆包 CDP 尚未连接"); const id = ++this.sequence; const result = new Promise((resolve, reject) => this.pending.set(id, { resolve, reject })); let timer; try {
|
|
100
100
|
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} 超时`)); },
|
|
101
|
+
return await Promise.race([result, new Promise((_, reject) => { timer = setTimeout(() => { this.pending.delete(id); reject(new Error(`CDP ${method} 超时`)); }, timeoutMs); })]);
|
|
102
102
|
}
|
|
103
103
|
finally {
|
|
104
104
|
clearTimeout(timer);
|
package/package.json
CHANGED