mu-agent-bridge 1.0.34 → 1.0.39

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.
Files changed (89) hide show
  1. package/README.md +4 -2
  2. package/dist/src-ts/channel-sessions.js +90 -24
  3. package/dist/src-ts/control-server.js +48 -7
  4. package/dist/src-ts/dsh-agent.js +141 -46
  5. package/dist/src-ts/headless-account.patch.yml +8 -1
  6. package/dist/src-ts/plugin-manager.js +69 -3
  7. package/dist/src-ts/plugins/aun/attachments.js +44 -13
  8. package/dist/src-ts/plugins/aun/index.js +5 -6
  9. package/dist/src-ts/plugins/chatgpt/cdp-client.js +342 -9
  10. package/dist/src-ts/plugins/chatgpt/index.js +127 -7
  11. package/dist/src-ts/plugins/desktop-launch.js +19 -0
  12. package/dist/src-ts/plugins/doubao/attachments.js +42 -0
  13. package/dist/src-ts/plugins/doubao/cdp-client.js +530 -48
  14. package/dist/src-ts/plugins/doubao/index.js +114 -25
  15. package/dist/src-ts/plugins/doubao/session-history.js +123 -0
  16. package/dist/src-ts/plugins/dsh/index.js +18 -2
  17. package/dist/src-ts/plugins/dsh/session-history.js +371 -0
  18. package/dist/src-ts/plugins/qwenwork/cdp-client.js +271 -10
  19. package/dist/src-ts/plugins/qwenwork/index.js +42 -3
  20. package/dist/src-ts/plugins/qwenwork/session-history.js +245 -0
  21. package/dist/src-ts/plugins/workbuddy/cdp-client.js +42 -2
  22. package/dist/src-ts/plugins/workbuddy/index.js +23 -3
  23. package/dist/src-ts/plugins/workbuddy/session-history.js +121 -0
  24. package/dist/src-ts/session-archive.js +509 -0
  25. package/dist/src-ts/session-history.js +2 -0
  26. package/dist/src-ts/session-management.js +665 -0
  27. package/dist/src-ts/session-summary.js +171 -0
  28. package/dist/tests-ts/aun-attachments.test.js +41 -3
  29. package/dist/tests-ts/aun-plugin.test.js +28 -5
  30. package/dist/tests-ts/bundled-package.test.js +3 -1
  31. package/dist/tests-ts/channel-sessions.test.js +255 -2
  32. package/dist/tests-ts/chatgpt-history.test.js +197 -0
  33. package/dist/tests-ts/chatgpt-plugin.test.js +279 -2
  34. package/dist/tests-ts/control-server.test.js +39 -0
  35. package/dist/tests-ts/desktop-launch.test.js +41 -0
  36. package/dist/tests-ts/doubao-history.test.js +172 -0
  37. package/dist/tests-ts/doubao-plugin.test.js +549 -2
  38. package/dist/tests-ts/dsh-agent.test.js +199 -0
  39. package/dist/tests-ts/dsh-history.test.js +165 -0
  40. package/dist/tests-ts/native-session-management.test.js +195 -0
  41. package/dist/tests-ts/plugin-manager.test.js +354 -4
  42. package/dist/tests-ts/qwenwork-history.test.js +339 -0
  43. package/dist/tests-ts/qwenwork-images.test.js +166 -0
  44. package/dist/tests-ts/qwenwork-plugin.test.js +40 -1
  45. package/dist/tests-ts/session-archive.test.js +422 -0
  46. package/dist/tests-ts/session-management.test.js +323 -0
  47. package/dist/tests-ts/session-summary.test.js +199 -0
  48. package/dist/tests-ts/workbuddy-history.test.js +256 -0
  49. package/dist/tests-ts/workbuddy-plugin.test.js +43 -0
  50. package/package.json +1 -1
  51. package/plugins/aun/dist/src-ts/plugins/aun/attachments.js +44 -13
  52. package/plugins/aun/dist/src-ts/plugins/aun/index.js +5 -6
  53. package/plugins/aun/package.json +1 -1
  54. package/plugins/aun/plugin.json +1 -1
  55. package/plugins/chatgpt/dist/src-ts/attachments.js +62 -0
  56. package/plugins/chatgpt/dist/src-ts/plugins/chatgpt/cdp-client.js +342 -9
  57. package/plugins/chatgpt/dist/src-ts/plugins/chatgpt/index.js +127 -7
  58. package/plugins/chatgpt/package.json +1 -1
  59. package/plugins/chatgpt/plugin.json +14 -1
  60. package/plugins/doubao/config.schema.json +3 -0
  61. package/plugins/doubao/dist/src-ts/attachments.js +62 -0
  62. package/plugins/doubao/dist/src-ts/plugins/desktop-launch.js +19 -0
  63. package/plugins/doubao/dist/src-ts/plugins/doubao/attachments.js +42 -0
  64. package/plugins/doubao/dist/src-ts/plugins/doubao/cdp-client.js +530 -48
  65. package/plugins/doubao/dist/src-ts/plugins/doubao/index.js +114 -25
  66. package/plugins/doubao/dist/src-ts/plugins/doubao/session-history.js +123 -0
  67. package/plugins/doubao/package.json +1 -1
  68. package/plugins/doubao/plugin.json +1 -1
  69. package/plugins/dsh/config.schema.json +2 -1
  70. package/plugins/dsh/dist/src-ts/attachments.js +62 -0
  71. package/plugins/dsh/dist/src-ts/dsh-agent.js +141 -46
  72. package/plugins/dsh/dist/src-ts/headless-account.patch.yml +8 -1
  73. package/plugins/dsh/dist/src-ts/plugins/dsh/index.js +18 -2
  74. package/plugins/dsh/dist/src-ts/plugins/dsh/session-history.js +371 -0
  75. package/plugins/dsh/package.json +5 -2
  76. package/plugins/dsh/plugin.json +1 -1
  77. package/plugins/qwenwork/dist/src-ts/attachments.js +62 -0
  78. package/plugins/qwenwork/dist/src-ts/plugins/desktop-launch.js +19 -0
  79. package/plugins/qwenwork/dist/src-ts/plugins/qwenwork/cdp-client.js +271 -10
  80. package/plugins/qwenwork/dist/src-ts/plugins/qwenwork/index.js +42 -3
  81. package/plugins/qwenwork/dist/src-ts/plugins/qwenwork/session-history.js +245 -0
  82. package/plugins/qwenwork/package.json +1 -1
  83. package/plugins/qwenwork/plugin.json +1 -1
  84. package/plugins/workbuddy/config.schema.json +1 -1
  85. package/plugins/workbuddy/dist/src-ts/plugins/workbuddy/cdp-client.js +42 -2
  86. package/plugins/workbuddy/dist/src-ts/plugins/workbuddy/index.js +23 -3
  87. package/plugins/workbuddy/dist/src-ts/plugins/workbuddy/session-history.js +121 -0
  88. package/plugins/workbuddy/package.json +1 -1
  89. package/plugins/workbuddy/plugin.json +1 -1
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const strict_1 = __importDefault(require("node:assert/strict"));
7
+ const node_test_1 = __importDefault(require("node:test"));
8
+ const node_vm_1 = require("node:vm");
9
+ const session_history_1 = require("../src-ts/plugins/doubao/session-history");
10
+ const cdp_client_1 = require("../src-ts/plugins/doubao/cdp-client");
11
+ const rawConversation = {
12
+ conversation_id: "conv-1", name: "今天的问题", create_time: "1792555702", update_time: "1792555770",
13
+ latest_index: "2", messages: [
14
+ { message_id: "user-1", user_type: 2, index_in_conv: "1", create_time: "1792555702", tts_content: "修复图片回传" },
15
+ { message_id: "assistant-1", user_type: 1, index_in_conv: "2", create_time: "1792555770", tts_content: "已修复并验证" },
16
+ ],
17
+ };
18
+ (0, node_test_1.default)("豆包只读历史脚本解析原生会话目录、Unix 时间与角色文本", async () => {
19
+ const require = (id) => {
20
+ strict_1.default.equal(id, 55807);
21
+ return { V: async (query) => {
22
+ strict_1.default.equal(query.conv_version, "cursor-1");
23
+ strict_1.default.equal(query.message_count_per_conv, 100);
24
+ return { code: 0, data: { cells: [{ conversation: rawConversation }], has_more: false, next_cursor: "" } };
25
+ } };
26
+ };
27
+ const chunks = [];
28
+ chunks.push = (...items) => {
29
+ for (const item of items) {
30
+ const install = item[2];
31
+ install(require);
32
+ }
33
+ return items.length;
34
+ };
35
+ const window = { "@flow-web/desktop:stable": chunks };
36
+ const execute = (0, node_vm_1.runInNewContext)(`(${cdp_client_1.doubaoHistoryPageScript})`, { window });
37
+ const page = await execute("cursor-1", 20);
38
+ strict_1.default.equal(page.complete, true);
39
+ strict_1.default.equal(JSON.stringify(page.conversations[0].messages.map(({ id, role, text }) => ({ id, role, text }))), JSON.stringify([
40
+ { id: "user-1", role: "user", text: "修复图片回传" },
41
+ { id: "assistant-1", role: "assistant", text: "已修复并验证" },
42
+ ]));
43
+ strict_1.default.equal(page.conversations[0].messages[0].time, new Date(1_792_555_702_000).toISOString());
44
+ strict_1.default.equal(JSON.stringify(page.missingReasons), "[]");
45
+ });
46
+ (0, node_test_1.default)("豆包历史 provider 使用原生正文游标分页并校验会话 ID", async () => {
47
+ let next;
48
+ const client = {
49
+ connected: () => true,
50
+ listHistory: async (cursor) => {
51
+ next = cursor;
52
+ return { conversations: [{ id: "conv-1", title: "会话", messages: [], truncated: true }], nextCursor: "next", complete: false, missingReasons: [] };
53
+ },
54
+ readHistory: async (id, cursor) => {
55
+ strict_1.default.equal(id, "conv-1");
56
+ strict_1.default.equal(cursor, undefined);
57
+ return { conversationId: id, messages: [{ id: "m-1", role: "user", text: "正文", time: new Date().toISOString() }], nextCursor: "42", hasMore: true, complete: true, missingReasons: [] };
58
+ },
59
+ };
60
+ const provider = new session_history_1.DoubaoSessionHistoryProvider({ scope: "doubao:9227", client: () => client });
61
+ strict_1.default.equal(provider.mode, "all");
62
+ const listed = await provider.listSessions({ limit: 20, cursor: "before" });
63
+ strict_1.default.equal(next, "before");
64
+ strict_1.default.equal(listed.supported && listed.nextCursor, "next");
65
+ strict_1.default.equal(listed.supported && listed.complete, false);
66
+ const result = await provider.readSession({ sessionId: "conv-1", limit: 100 });
67
+ strict_1.default.equal(result.supported && result.complete, true);
68
+ strict_1.default.equal(result.supported && result.nextCursor, "42");
69
+ strict_1.default.equal(result.supported && result.turns.length, 1);
70
+ });
71
+ (0, node_test_1.default)("豆包正文分页脚本使用原生单会话链游标并排除思考字段", async () => {
72
+ let nativeQuery;
73
+ const require = (id) => {
74
+ strict_1.default.equal(id, 77049);
75
+ return { J: async (query) => {
76
+ nativeQuery = query;
77
+ return { code: 0, data: { messages: [
78
+ { conversation_id: "conv-1", message_id: "m-1", user_type: 1, create_time: "1792555770", thinking_content: "不可见思考", content_block: [{ thinking_content: { text_block: { text: "不可见嵌套思考" } }, reasoning_block: { text_block: { text: "不可见推理" } }, text_block: { text: "可见正文" } }] },
79
+ ], has_more: true, next_index: "41" } };
80
+ } };
81
+ };
82
+ const chunks = [];
83
+ chunks.push = (...items) => { for (const item of items)
84
+ item[2](require); return items.length; };
85
+ const execute = (0, node_vm_1.runInNewContext)(`(${cdp_client_1.doubaoHistoryReadPageScript})`, { window: { "@flow-web/desktop:stable": chunks } });
86
+ const page = await execute("conv-1", "50", 50);
87
+ strict_1.default.equal(page.error, undefined);
88
+ strict_1.default.equal(nativeQuery?.conversation_id, "conv-1");
89
+ strict_1.default.equal(nativeQuery?.anchor_index, 50);
90
+ strict_1.default.equal(nativeQuery?.direction, 1);
91
+ strict_1.default.equal(JSON.stringify(page.messages.map(({ id, role, text }) => ({ id, role, text }))), JSON.stringify([{ id: "m-1", role: "assistant", text: "可见正文" }]));
92
+ strict_1.default.equal(page.nextCursor, "41");
93
+ strict_1.default.equal(page.complete, true);
94
+ });
95
+ (0, node_test_1.default)("豆包今日正文先按时间排除旧附件消息,未知时间仍报告不完整", async () => {
96
+ const messages = [
97
+ { conversation_id: "conv-1", message_id: "m-today", user_type: 1, create_time: "1792555770", tts_content: "今天的答复" },
98
+ { conversation_id: "conv-1", message_id: "m-old", user_type: 2, create_time: "1792497638", content_block: [{ content: { thinking_block: {}, creation_block: { creations: [{ image: {} }] } } }] },
99
+ ];
100
+ const require = (_id) => ({ J: async () => ({ code: 0, data: { messages, has_more: true, next_index: "41" } }) });
101
+ const chunks = [];
102
+ chunks.push = (...items) => { for (const item of items)
103
+ item[2](require); return items.length; };
104
+ const execute = (0, node_vm_1.runInNewContext)(`(${cdp_client_1.doubaoHistoryReadPageScript})`, { window: { "@flow-web/desktop:stable": chunks } });
105
+ const page = await execute("conv-1", "", 100, "2026-10-21T00:00:00+08:00");
106
+ strict_1.default.equal(page.complete, true);
107
+ strict_1.default.equal(page.reachedSince, true);
108
+ strict_1.default.equal(page.messages.length, 1);
109
+ strict_1.default.equal(page.messages[0].text, "今天的答复");
110
+ messages.push({ conversation_id: "conv-1", message_id: "m-unknown", user_type: 1, thinking_content: "仅思考" });
111
+ const incomplete = await execute("conv-1", "", 100, "2026-10-21T00:00:00+08:00");
112
+ strict_1.default.equal(incomplete.complete, false);
113
+ strict_1.default.ok(incomplete.missingReasons.some(reason => reason.includes("时间")));
114
+ });
115
+ (0, node_test_1.default)("豆包今日 provider 转交起点并在原生已越过起点时结束正文分页", async () => {
116
+ const since = "2026-10-21T00:00:00+08:00";
117
+ const client = {
118
+ connected: () => true,
119
+ listHistory: async () => ({ conversations: [{ id: "conv-1", title: "会话", messages: [], truncated: true }], complete: true, missingReasons: [] }),
120
+ readHistory: async (id, _cursor, _limit, nativeSince) => {
121
+ strict_1.default.equal(nativeSince, since);
122
+ return { conversationId: id, messages: [{ id: "m-1", role: "assistant", text: "今日答复", time: "2026-10-21T01:00:00Z" }], hasMore: true, nextCursor: "42", reachedSince: true, complete: true, missingReasons: [] };
123
+ },
124
+ };
125
+ const provider = new session_history_1.DoubaoSessionHistoryProvider({ scope: "doubao:9227", client: () => client });
126
+ await provider.listSessions({ limit: 20 });
127
+ const result = await provider.readSession({ sessionId: "conv-1", limit: 100, since });
128
+ strict_1.default.equal(result.supported && result.complete, true);
129
+ strict_1.default.equal(result.supported && result.nextCursor, undefined);
130
+ strict_1.default.equal(result.supported && result.turns.length, 1);
131
+ });
132
+ (0, node_test_1.default)("豆包历史脚本重复调用兼容 webpack 已安装 chunk 缓存", async () => {
133
+ const installed = new Set();
134
+ let calls = 0;
135
+ const require = (_id) => ({ V: async () => {
136
+ calls++;
137
+ return { code: 0, data: { cells: [{ conversation: rawConversation }], has_more: false } };
138
+ } });
139
+ const chunks = [];
140
+ chunks.push = (...items) => {
141
+ for (const item of items) {
142
+ const [ids, , install] = item;
143
+ // webpack 仅在存在未安装的 chunk 时执行 runtime callback。
144
+ if (ids.some(id => !installed.has(id)))
145
+ install(require);
146
+ for (const id of ids)
147
+ installed.add(id);
148
+ }
149
+ return items.length;
150
+ };
151
+ const execute = (0, node_vm_1.runInNewContext)(`(${cdp_client_1.doubaoHistoryPageScript})`, { window: { "@flow-web/desktop:stable": chunks } });
152
+ const first = await execute("", 20);
153
+ const second = await execute("", 20);
154
+ strict_1.default.equal(first.error, undefined);
155
+ strict_1.default.equal(second.error, undefined);
156
+ strict_1.default.equal(second.conversations?.length, 1);
157
+ strict_1.default.equal(calls, 2);
158
+ });
159
+ (0, node_test_1.default)("豆包历史目录 has_more 但游标缺失时报告不完整", async () => {
160
+ const require = (_id) => ({ V: async () => ({ code: 0, data: { cells: [], has_more: true, next_cursor: "" } }) });
161
+ const chunks = [];
162
+ chunks.push = (...items) => {
163
+ for (const item of items)
164
+ item[2](require);
165
+ return items.length;
166
+ };
167
+ const execute = (0, node_vm_1.runInNewContext)(`(${cdp_client_1.doubaoHistoryPageScript})`, { window: { "@flow-web/desktop:stable": chunks } });
168
+ const page = await execute("", 20);
169
+ strict_1.default.equal(page.complete, false);
170
+ strict_1.default.equal(page.nextCursor, undefined);
171
+ strict_1.default.ok(page.missingReasons.some(reason => reason.includes("游标")));
172
+ });