agent-bridge-doubao 1.0.2 → 1.0.4
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DoubaoCdpClient = void 0;
|
|
4
|
+
exports.requestBody = requestBody;
|
|
4
5
|
const node_crypto_1 = require("node:crypto");
|
|
5
6
|
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") };
|
|
6
7
|
function sleep(ms, signal) {
|
|
@@ -8,17 +9,17 @@ function sleep(ms, signal) {
|
|
|
8
9
|
return Promise.reject(new Error("请求已取消"));
|
|
9
10
|
return new Promise((resolve, reject) => { const timer = setTimeout(resolve, ms); signal?.addEventListener("abort", () => { clearTimeout(timer); reject(new Error("请求已取消")); }, { once: true }); });
|
|
10
11
|
}
|
|
11
|
-
function requestBody(text, conversationId, botId) {
|
|
12
|
+
function requestBody(text, conversationId, botId, pluginList = []) {
|
|
12
13
|
const general = { runtime_type: 0, agent_task_param: {}, agent_task_param_change: { runtime_changed: false, device_changed: false, sandbox_auth_type_changed: false }, project_id: "", need_modify_conversation: false };
|
|
13
14
|
const block = { block_type: 10000, content: { text_block: { text, icon_url: "", icon_url_dark: "", summary: "" }, pc_event_block: "" }, block_id: (0, node_crypto_1.randomUUID)(), parent_id: "", meta_info: [], append_fields: [] };
|
|
14
|
-
return JSON.stringify({ client_meta: { conversation_id: conversationId, bot_id: botId, last_section_id: "", last_message_index: null, local_permissions: [{ permission_name: "ACCESS_COARSE_LOCATION", status: 1 }, { permission_name: "ACCESS_FINE_LOCATION", status: 1 }, { permission_name: "ACCESS_BACKGROUND_LOCATION", status: 1 }] }, messages: [{ local_message_id: (0, node_crypto_1.randomUUID)(), content_block: [block], message_status: 0 }], option: { send_message_scene: "", create_time_ms: Date.now(), collect_id: "", is_audio: false, answer_with_suggest: false, agent_mode: 2, tts_switch: false, need_deep_think: 0, click_clear_context: false, is_regen: false, is_replace: false, is_from_click_option: false, is_from_click_softlink: false, disable_sse_cache: false, scene_type: 0, unique_key: (0, node_crypto_1.randomUUID)(), start_seq: 0, need_create_conversation: false, regen_query_id: [], edit_query_id: [], message_from: 0, sse_recv_event_options: { support_chunk_delta: true }, support_lazy_fetch_stream: true, is_ai_playground: false, is_old_user: true, general_task_param: general, recovery_option: { is_recovery: false, req_create_time_sec: Math.floor(Date.now() / 1000), append_sse_event_scene: 0 }, message_storage_type: 0, related_deleted_message_ids: {}, connector_info_list: [], model_config: { model_item_key: "0", model_extra_params: {}, reasoning_effort: 5 }, aggregate_params: { mention_skill_list: "[]", mention_plugin_list:
|
|
15
|
+
return JSON.stringify({ client_meta: { conversation_id: conversationId, bot_id: botId, last_section_id: "", last_message_index: null, local_permissions: [{ permission_name: "ACCESS_COARSE_LOCATION", status: 1 }, { permission_name: "ACCESS_FINE_LOCATION", status: 1 }, { permission_name: "ACCESS_BACKGROUND_LOCATION", status: 1 }] }, messages: [{ local_message_id: (0, node_crypto_1.randomUUID)(), content_block: [block], message_status: 0 }], option: { send_message_scene: "", create_time_ms: Date.now(), collect_id: "", is_audio: false, answer_with_suggest: false, agent_mode: 2, tts_switch: false, need_deep_think: 0, click_clear_context: false, is_regen: false, is_replace: false, is_from_click_option: false, is_from_click_softlink: false, disable_sse_cache: false, scene_type: 0, unique_key: (0, node_crypto_1.randomUUID)(), start_seq: 0, need_create_conversation: false, regen_query_id: [], edit_query_id: [], message_from: 0, sse_recv_event_options: { support_chunk_delta: true }, support_lazy_fetch_stream: true, is_ai_playground: false, is_old_user: true, general_task_param: general, recovery_option: { is_recovery: false, req_create_time_sec: Math.floor(Date.now() / 1000), append_sse_event_scene: 0 }, message_storage_type: 0, related_deleted_message_ids: {}, connector_info_list: [], model_config: { model_item_key: "0", model_extra_params: {}, reasoning_effort: 5 }, aggregate_params: { mention_skill_list: "[]", mention_plugin_list: JSON.stringify(pluginList), mention_ext: "[{}]", conversation_mode: "", mode_id: "1", model_item_key: "0", agent_mode: "2", reasoning_effort: "5", provider_id: "" } }, user_context: [], ext: { agent_mode: "2", use_deep_think: "0", general_task_param: JSON.stringify(general), collection_id: "", is_finish: "1", commerce_credit_config_enable: "0" } });
|
|
15
16
|
}
|
|
16
17
|
class DoubaoCdpClient {
|
|
17
18
|
socket;
|
|
18
19
|
sequence = 0;
|
|
19
20
|
pending = new Map();
|
|
20
21
|
options;
|
|
21
|
-
constructor(options = {}) { this.options = { port: options.port ?? defaults.port, conversationId: options.conversationId ?? defaults.conversationId, botId: options.botId ?? defaults.botId, timeoutMs: options.timeoutMs ?? defaults.timeoutMs, fetchImpl: options.fetchImpl }; }
|
|
22
|
+
constructor(options = {}) { this.options = { port: options.port ?? defaults.port, conversationId: options.conversationId ?? defaults.conversationId, botId: options.botId ?? defaults.botId, pluginList: options.pluginList ?? [], timeoutMs: options.timeoutMs ?? defaults.timeoutMs, fetchImpl: options.fetchImpl }; }
|
|
22
23
|
connected() { return Boolean(this.socket); }
|
|
23
24
|
async connect() {
|
|
24
25
|
if (this.socket)
|
|
@@ -38,7 +39,7 @@ class DoubaoCdpClient {
|
|
|
38
39
|
close() { this.socket?.close(); this.socket = undefined; for (const pending of this.pending.values())
|
|
39
40
|
pending.reject(new Error("豆包 CDP 已关闭")); this.pending.clear(); }
|
|
40
41
|
async direct(text, signal) {
|
|
41
|
-
await this.evaluate(buildInjection(requestBody(text, this.options.conversationId, this.options.botId)));
|
|
42
|
+
await this.evaluate(buildInjection(requestBody(text, this.options.conversationId, this.options.botId, this.options.pluginList)));
|
|
42
43
|
const deadline = Date.now() + this.options.timeoutMs;
|
|
43
44
|
while (Date.now() < deadline) {
|
|
44
45
|
await sleep(1000, signal);
|
|
@@ -4,7 +4,7 @@ exports.DoubaoPlugin = exports.doubaoManifest = void 0;
|
|
|
4
4
|
const cdp_client_1 = require("./cdp-client");
|
|
5
5
|
exports.doubaoManifest = {
|
|
6
6
|
id: "doubao",
|
|
7
|
-
version: "1.0.
|
|
7
|
+
version: "1.0.4",
|
|
8
8
|
displayName: "豆包",
|
|
9
9
|
entry: "dist/index.js",
|
|
10
10
|
apiVersion: "1",
|
|
@@ -27,6 +27,7 @@ class DoubaoPlugin {
|
|
|
27
27
|
port: typeof context.config.cdpPort === "number" ? context.config.cdpPort : undefined,
|
|
28
28
|
conversationId: typeof context.config.conversationId === "string" ? context.config.conversationId : undefined,
|
|
29
29
|
botId: typeof context.config.botId === "string" ? context.config.botId : undefined,
|
|
30
|
+
pluginList: Array.isArray(context.config.pluginList) ? context.config.pluginList.filter((value) => typeof value === "string") : undefined,
|
|
30
31
|
timeoutMs: typeof context.config.timeoutMs === "number" ? context.config.timeoutMs : undefined,
|
|
31
32
|
});
|
|
32
33
|
try {
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-bridge-doubao",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "agent-bridge 的豆包插件。",
|
|
5
|
-
"keywords": [
|
|
6
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mu-agent-bridge-plugin",
|
|
7
|
+
"mu-agent-bridge-agent"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://codeup.aliyun.com/6808da56fb3da14b899afd54/agent_bridge.git",
|
|
12
|
+
"directory": "packages/doubao"
|
|
13
|
+
},
|
|
7
14
|
"main": "dist/src-ts/plugins/doubao/index.js",
|
|
8
15
|
"files": [
|
|
9
16
|
"dist/",
|
package/plugin.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "doubao",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"type": "agent",
|
|
5
5
|
"displayName": "豆包",
|
|
6
6
|
"entry": "dist/src-ts/plugins/doubao/index.js",
|
|
7
7
|
"apiVersion": "1",
|
|
8
8
|
"process": "in-process",
|
|
9
|
-
"capabilities": [
|
|
9
|
+
"capabilities": [
|
|
10
|
+
"chat",
|
|
11
|
+
"health"
|
|
12
|
+
],
|
|
10
13
|
"configSchema": "config.schema.json"
|
|
11
14
|
}
|