mu-agent-bridge 1.0.66 → 1.0.68
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.
- package/dist/src-ts/plugins/workbuddy/cdp-client.js +1 -1
- package/dist/src-ts/plugins/workbuddy/index.js +10 -2
- package/dist/tests-ts/workbuddy-plugin.test.js +21 -5
- package/package.json +1 -1
- package/plugins/abweb/package.json +1 -1
- package/plugins/abweb/plugin.json +1 -1
- package/plugins/doubao/package.json +1 -1
- package/plugins/doubao/plugin.json +1 -1
- package/plugins/workbuddy/dist/src-ts/plugins/workbuddy/cdp-client.js +1 -1
- package/plugins/workbuddy/dist/src-ts/plugins/workbuddy/index.js +10 -2
- package/plugins/workbuddy/package.json +1 -1
- package/plugins/workbuddy/plugin.json +1 -1
|
@@ -129,7 +129,7 @@ class WorkbuddyCdpClient {
|
|
|
129
129
|
throw new Error("WorkBuddy 尚未登录,请先在桌面端登录后重试");
|
|
130
130
|
await this.waitFor(`(() => { const button = [...document.querySelectorAll('button,[role="button"],[role="tab"]')].find(item => { const label = [item.innerText, item.textContent, item.getAttribute('aria-label'), item.getAttribute('title'), item.getAttribute('data-testid')].filter(Boolean).map(value => String(value).normalize('NFKC').replace(/\\s+/g, ' ').trim().toLowerCase()); return label.some(value => /^(?:新建任务|新建会话|新建对话|开始新任务|new (?:task|chat|conversation))$/.test(value)) && (!item.getClientRects || item.getClientRects().length > 0); }); if (!button || button.disabled || button.getAttribute('aria-disabled') === 'true') return false; button.click(); return true; })()`, "WorkBuddy 新建任务入口未找到或不可用");
|
|
131
131
|
// WorkBuddy 首页不分配任务 ID;此时仅接受无选中任务的空白首页。
|
|
132
|
-
await this.waitFor(`(() => { const state = ${snapshot}; const blank = state.editor !== null && state.editor.trim() === '' && state.messages === 0; return blank && ((state.conversationId && state.conversationId !== ${JSON.stringify(before.conversationId)}) || state.url !== ${JSON.stringify(before.url)} || (state.home && !state.selected)); })()`, "WorkBuddy 新任务状态校验失败");
|
|
132
|
+
await this.waitFor(`(() => { const state = ${snapshot}; const blank = state.editor !== null && state.editor.trim() === '' && state.messages === 0; const clearedToUnselected = ${before.selected} && !state.selected && state.messages < ${before.messages}; return blank && ((state.conversationId && state.conversationId !== ${JSON.stringify(before.conversationId)}) || state.url !== ${JSON.stringify(before.url)} || (state.home && !state.selected) || clearedToUnselected); })()`, "WorkBuddy 新任务状态校验失败");
|
|
133
133
|
this.pendingInteraction = undefined;
|
|
134
134
|
const temporaryPaths = this.pendingInteractionCleanup;
|
|
135
135
|
this.pendingInteractionCleanup = undefined;
|
|
@@ -16,7 +16,7 @@ const session_history_1 = require("./session-history");
|
|
|
16
16
|
const desktop_launch_1 = require("../desktop-launch");
|
|
17
17
|
const desktop_launch_2 = require("./desktop-launch");
|
|
18
18
|
exports.workbuddyManifest = {
|
|
19
|
-
id: "workbuddy", version: "1.1.
|
|
19
|
+
id: "workbuddy", version: "1.1.31", displayName: "WorkBuddy", type: "agent",
|
|
20
20
|
entry: "dist/index.js", apiVersion: "1", process: "in-process",
|
|
21
21
|
capabilities: ["chat", "health"], configSchema: "config.schema.json",
|
|
22
22
|
};
|
|
@@ -364,7 +364,15 @@ class WorkbuddyPlugin {
|
|
|
364
364
|
if (this.knownSessions.has(sessionId)) {
|
|
365
365
|
const binding = this.sessionBindings.get(sessionId);
|
|
366
366
|
const conversationId = binding?.conversationId ?? (this.recoverableSessionId === sessionId ? this.recoverableConversationId : undefined);
|
|
367
|
-
if (!conversationId
|
|
367
|
+
if (!conversationId) {
|
|
368
|
+
// 旧版本可能在新任务校验前写入会话 ID,无法恢复时允许重新创建。
|
|
369
|
+
this.knownSessions.delete(sessionId);
|
|
370
|
+
this.sessionBindings.delete(sessionId);
|
|
371
|
+
await this.persistKnownSessions();
|
|
372
|
+
await this.createSession(sessionId);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (!this.client.activateConversation)
|
|
368
376
|
throw new Error("WorkBuddy 不支持恢复旧 WorkBuddy 会话");
|
|
369
377
|
await this.client.activateConversation(conversationId);
|
|
370
378
|
this.activeSessionId = sessionId;
|
|
@@ -936,8 +936,8 @@ const cdp_client_1 = require("../src-ts/plugins/workbuddy/cdp-client");
|
|
|
936
936
|
strict_1.default.equal(creates, 1);
|
|
937
937
|
fail = true;
|
|
938
938
|
await strict_1.default.rejects(() => plugin.controlSession({ operation: "new", sessionId: "failed-session" }), /校验失败/);
|
|
939
|
-
await strict_1.default.rejects(() => plugin.handle({ task: "续聊", sessionId: "new-session" }),
|
|
940
|
-
strict_1.default.equal(creates,
|
|
939
|
+
await strict_1.default.rejects(() => plugin.handle({ task: "续聊", sessionId: "new-session" }), /校验失败/);
|
|
940
|
+
strict_1.default.equal(creates, 3);
|
|
941
941
|
});
|
|
942
942
|
(0, node_test_1.default)("workbuddy auto 选择 CLI 时不会创建无关桌面任务", async () => {
|
|
943
943
|
const root = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), "wb-cli-session-"));
|
|
@@ -1018,6 +1018,22 @@ const cdp_client_1 = require("../src-ts/plugins/workbuddy/cdp-client");
|
|
|
1018
1018
|
await client.createTask();
|
|
1019
1019
|
}
|
|
1020
1020
|
});
|
|
1021
|
+
(0, node_test_1.default)("workbuddy CDP 新建接受旧版界面清空消息并取消旧任务选中", async () => {
|
|
1022
|
+
let selected = true;
|
|
1023
|
+
let messages = 1;
|
|
1024
|
+
const button = { textContent: "新建任务", disabled: false, getAttribute: () => null, click: () => { selected = false; messages = 0; } };
|
|
1025
|
+
const editor = { innerText: "今天帮你做些什么?", querySelector: () => null, cloneNode: () => ({ textContent: "", querySelectorAll: () => [] }) };
|
|
1026
|
+
const document = {
|
|
1027
|
+
querySelectorAll: (selector) => selector === '.cr-agent[data-message-id]' ? Array(messages).fill({}) : selector === '[data-conversation-id]' ? selected ? [{ className: "_selected_old", getAttribute: () => "old-conversation" }] : [] : [button],
|
|
1028
|
+
querySelector: () => editor,
|
|
1029
|
+
};
|
|
1030
|
+
const client = new cdp_client_1.WorkbuddyCdpClient({ timeoutMs: 1 });
|
|
1031
|
+
const internal = client;
|
|
1032
|
+
internal.evaluate = async (expression) => (0, node_vm_1.runInNewContext)(expression, { document, location: { href: "app://workbuddy/task/old" } });
|
|
1033
|
+
await client.createTask();
|
|
1034
|
+
strict_1.default.equal(selected, false);
|
|
1035
|
+
strict_1.default.equal(messages, 0);
|
|
1036
|
+
});
|
|
1021
1037
|
(0, node_test_1.default)("workbuddy CDP 等待新建任务入口完成渲染后再点击", async () => {
|
|
1022
1038
|
let lookups = 0;
|
|
1023
1039
|
let clicked = false;
|
|
@@ -1162,7 +1178,7 @@ const cdp_client_1 = require("../src-ts/plugins/workbuddy/cdp-client");
|
|
|
1162
1178
|
await strict_1.default.rejects(() => plugin.handle({ task: "调用文案写作专家改写" }), /sessionId|会话/);
|
|
1163
1179
|
strict_1.default.equal(calls, 1);
|
|
1164
1180
|
});
|
|
1165
|
-
(0, node_test_1.default)("workbuddy
|
|
1181
|
+
(0, node_test_1.default)("workbuddy 跨插件重启清理没有桌面绑定的旧会话并重新创建", async () => {
|
|
1166
1182
|
const dataDir = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), "wb-sessions-"));
|
|
1167
1183
|
let creates = 0;
|
|
1168
1184
|
const client = {
|
|
@@ -1177,8 +1193,8 @@ const cdp_client_1 = require("../src-ts/plugins/workbuddy/cdp-client");
|
|
|
1177
1193
|
await first.deactivate("reload");
|
|
1178
1194
|
const second = new workbuddy_1.WorkbuddyPlugin({ client });
|
|
1179
1195
|
await second.activate(context);
|
|
1180
|
-
|
|
1181
|
-
strict_1.default.equal(creates,
|
|
1196
|
+
strict_1.default.equal((await second.handle({ task: "恢复旧会话", sessionId: "session-a" })).text, "恢复旧会话");
|
|
1197
|
+
strict_1.default.equal(creates, 2);
|
|
1182
1198
|
await second.deactivate("stop");
|
|
1183
1199
|
}
|
|
1184
1200
|
finally {
|
package/package.json
CHANGED
|
@@ -129,7 +129,7 @@ class WorkbuddyCdpClient {
|
|
|
129
129
|
throw new Error("WorkBuddy 尚未登录,请先在桌面端登录后重试");
|
|
130
130
|
await this.waitFor(`(() => { const button = [...document.querySelectorAll('button,[role="button"],[role="tab"]')].find(item => { const label = [item.innerText, item.textContent, item.getAttribute('aria-label'), item.getAttribute('title'), item.getAttribute('data-testid')].filter(Boolean).map(value => String(value).normalize('NFKC').replace(/\\s+/g, ' ').trim().toLowerCase()); return label.some(value => /^(?:新建任务|新建会话|新建对话|开始新任务|new (?:task|chat|conversation))$/.test(value)) && (!item.getClientRects || item.getClientRects().length > 0); }); if (!button || button.disabled || button.getAttribute('aria-disabled') === 'true') return false; button.click(); return true; })()`, "WorkBuddy 新建任务入口未找到或不可用");
|
|
131
131
|
// WorkBuddy 首页不分配任务 ID;此时仅接受无选中任务的空白首页。
|
|
132
|
-
await this.waitFor(`(() => { const state = ${snapshot}; const blank = state.editor !== null && state.editor.trim() === '' && state.messages === 0; return blank && ((state.conversationId && state.conversationId !== ${JSON.stringify(before.conversationId)}) || state.url !== ${JSON.stringify(before.url)} || (state.home && !state.selected)); })()`, "WorkBuddy 新任务状态校验失败");
|
|
132
|
+
await this.waitFor(`(() => { const state = ${snapshot}; const blank = state.editor !== null && state.editor.trim() === '' && state.messages === 0; const clearedToUnselected = ${before.selected} && !state.selected && state.messages < ${before.messages}; return blank && ((state.conversationId && state.conversationId !== ${JSON.stringify(before.conversationId)}) || state.url !== ${JSON.stringify(before.url)} || (state.home && !state.selected) || clearedToUnselected); })()`, "WorkBuddy 新任务状态校验失败");
|
|
133
133
|
this.pendingInteraction = undefined;
|
|
134
134
|
const temporaryPaths = this.pendingInteractionCleanup;
|
|
135
135
|
this.pendingInteractionCleanup = undefined;
|
|
@@ -16,7 +16,7 @@ const session_history_1 = require("./session-history");
|
|
|
16
16
|
const desktop_launch_1 = require("../desktop-launch");
|
|
17
17
|
const desktop_launch_2 = require("./desktop-launch");
|
|
18
18
|
exports.workbuddyManifest = {
|
|
19
|
-
id: "workbuddy", version: "1.1.
|
|
19
|
+
id: "workbuddy", version: "1.1.31", displayName: "WorkBuddy", type: "agent",
|
|
20
20
|
entry: "dist/index.js", apiVersion: "1", process: "in-process",
|
|
21
21
|
capabilities: ["chat", "health"], configSchema: "config.schema.json",
|
|
22
22
|
};
|
|
@@ -364,7 +364,15 @@ class WorkbuddyPlugin {
|
|
|
364
364
|
if (this.knownSessions.has(sessionId)) {
|
|
365
365
|
const binding = this.sessionBindings.get(sessionId);
|
|
366
366
|
const conversationId = binding?.conversationId ?? (this.recoverableSessionId === sessionId ? this.recoverableConversationId : undefined);
|
|
367
|
-
if (!conversationId
|
|
367
|
+
if (!conversationId) {
|
|
368
|
+
// 旧版本可能在新任务校验前写入会话 ID,无法恢复时允许重新创建。
|
|
369
|
+
this.knownSessions.delete(sessionId);
|
|
370
|
+
this.sessionBindings.delete(sessionId);
|
|
371
|
+
await this.persistKnownSessions();
|
|
372
|
+
await this.createSession(sessionId);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (!this.client.activateConversation)
|
|
368
376
|
throw new Error("WorkBuddy 不支持恢复旧 WorkBuddy 会话");
|
|
369
377
|
await this.client.activateConversation(conversationId);
|
|
370
378
|
this.activeSessionId = sessionId;
|