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.
@@ -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.29", displayName: "WorkBuddy", type: "agent",
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 || !this.client.activateConversation)
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" }), /不支持恢复旧 WorkBuddy 会话/);
940
- strict_1.default.equal(creates, 2);
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 跨插件重启持久化已使用的会话 ID", async () => {
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
- await strict_1.default.rejects(() => second.handle({ task: "恢复旧会话", sessionId: "session-a" }), /不支持恢复旧 WorkBuddy 会话/);
1181
- strict_1.default.equal(creates, 1);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mu-agent-bridge",
3
- "version": "1.0.66",
3
+ "version": "1.0.68",
4
4
  "description": "将 AUN Agent 连接到本地桌面 AI 客户端的插件平台。",
5
5
  "main": "dist/src-ts/cli.js",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-bridge-abweb",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "agent-bridge 的网页管理插件。",
5
5
  "keywords": [
6
6
  "mu-agent-bridge-plugin",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "abweb",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "type": "management",
5
5
  "displayName": "Agent Bridge Web",
6
6
  "entry": "dist/src-ts/plugins/abweb/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-bridge-doubao",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "agent-bridge 的豆包插件。",
5
5
  "keywords": [
6
6
  "mu-agent-bridge-plugin",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "doubao",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "type": "agent",
5
5
  "displayName": "豆包",
6
6
  "entry": "dist/src-ts/plugins/doubao/index.js",
@@ -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.29", displayName: "WorkBuddy", type: "agent",
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 || !this.client.activateConversation)
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;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-bridge-workbuddy",
3
- "version": "1.1.29",
3
+ "version": "1.1.31",
4
4
  "description": "mu-agent-bridge 的 WorkBuddy 桌面端插件。",
5
5
  "keywords": [
6
6
  "mu-agent-bridge-plugin",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "workbuddy",
3
- "version": "1.1.29",
3
+ "version": "1.1.31",
4
4
  "type": "agent",
5
5
  "displayName": "WorkBuddy",
6
6
  "entry": "dist/src-ts/plugins/workbuddy/index.js",