mu-agent-bridge 1.0.73 → 1.0.78

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 (152) hide show
  1. package/README.md +12 -8
  2. package/dist/src-ts/cli.js +67 -37
  3. package/dist/src-ts/control-server.js +7 -28
  4. package/dist/src-ts/core-updater.js +141 -33
  5. package/dist/src-ts/daemon-process.js +2 -1
  6. package/dist/src-ts/dsh-agent.js +7 -2
  7. package/dist/src-ts/http-agent.js +36 -0
  8. package/dist/src-ts/plugin-manager.js +185 -58
  9. package/dist/src-ts/plugins/abweb/index.js +1 -1
  10. package/dist/src-ts/plugins/abweb/public/app.js +8 -6
  11. package/dist/src-ts/plugins/abweb/public/index.html +3 -3
  12. package/dist/src-ts/plugins/aun/attachments.js +3 -21
  13. package/dist/src-ts/plugins/aun/index.js +89 -11
  14. package/dist/src-ts/plugins/aun/messages.js +1 -1
  15. package/dist/src-ts/plugins/aun/public/app.js +2 -1
  16. package/dist/src-ts/plugins/aun/public/index.html +1 -1
  17. package/dist/src-ts/plugins/cdp-draft.js +5 -2
  18. package/dist/src-ts/plugins/chatgpt/index.js +3 -2
  19. package/dist/src-ts/plugins/claude-cli/index.js +1 -1
  20. package/dist/src-ts/plugins/desktop-launch.js +44 -3
  21. package/dist/src-ts/plugins/doubao/cdp-client.js +231 -45
  22. package/dist/src-ts/plugins/doubao/index.js +119 -7
  23. package/dist/src-ts/plugins/doubao/native-task.js +134 -0
  24. package/dist/src-ts/plugins/dsh/cdp-client.js +334 -0
  25. package/dist/src-ts/plugins/dsh/index.js +102 -23
  26. package/dist/src-ts/plugins/dsh/session-history.js +31 -3
  27. package/dist/src-ts/plugins/feishu/index.js +1 -1
  28. package/dist/src-ts/plugins/personal-assistant/index.js +29 -8
  29. package/dist/src-ts/plugins/personal-assistant/model-client.js +20 -6
  30. package/dist/src-ts/plugins/personal-assistant/session-memory.js +124 -0
  31. package/dist/src-ts/plugins/personal-assistant/tools.js +4 -3
  32. package/dist/src-ts/plugins/qwenwork/cdp-client.js +43 -7
  33. package/dist/src-ts/plugins/qwenwork/index.js +52 -18
  34. package/dist/src-ts/plugins/workbuddy/cdp-client.js +349 -83
  35. package/dist/src-ts/plugins/workbuddy/index.js +24 -12
  36. package/dist/src-ts/plugins/zcode/cdp-client.js +500 -0
  37. package/dist/src-ts/plugins/zcode/index.js +97 -0
  38. package/dist/src-ts/session-management.js +27 -8
  39. package/dist/src-ts/version-manager.js +6 -3
  40. package/dist/tests-ts/abweb-model-config.test.js +44 -41
  41. package/dist/tests-ts/aun-attachments.test.js +19 -17
  42. package/dist/tests-ts/aun-default-owner-page.test.js +2 -1
  43. package/dist/tests-ts/aun-messages.test.js +14 -0
  44. package/dist/tests-ts/aun-plugin.test.js +207 -19
  45. package/dist/tests-ts/bundled-package.test.js +1 -1
  46. package/dist/tests-ts/cdp-draft-recovery.test.js +182 -3
  47. package/dist/tests-ts/chatgpt-plugin.test.js +19 -0
  48. package/dist/tests-ts/control-server.test.js +20 -0
  49. package/dist/tests-ts/core-updater.test.js +215 -46
  50. package/dist/tests-ts/daemon-process.test.js +126 -1
  51. package/dist/tests-ts/desktop-launch.test.js +73 -0
  52. package/dist/tests-ts/doubao-native-task.test.js +237 -0
  53. package/dist/tests-ts/doubao-plugin.test.js +688 -19
  54. package/dist/tests-ts/dsh-agent.test.js +91 -19
  55. package/dist/tests-ts/dsh-cdp.test.js +148 -0
  56. package/dist/tests-ts/dsh-history.test.js +37 -0
  57. package/dist/tests-ts/feishu-plugin.test.js +1 -1
  58. package/dist/tests-ts/http-agent.test.js +18 -0
  59. package/dist/tests-ts/local-cli.test.js +29 -2
  60. package/dist/tests-ts/model-provider-cancellation.test.js +2 -0
  61. package/dist/tests-ts/native-session-management.test.js +8 -7
  62. package/dist/tests-ts/personal-assistant-coordination.test.js +16 -0
  63. package/dist/tests-ts/personal-assistant-extensions.test.js +7 -1
  64. package/dist/tests-ts/personal-assistant-memory.test.js +117 -0
  65. package/dist/tests-ts/personal-assistant.test.js +277 -3
  66. package/dist/tests-ts/platform-integration.test.js +60 -1
  67. package/dist/tests-ts/plugin-manager.test.js +78 -6
  68. package/dist/tests-ts/plugin-upgrade-deadline.test.js +354 -0
  69. package/dist/tests-ts/publish-packages.test.js +1 -1
  70. package/dist/tests-ts/qwenwork-plugin.test.js +30 -0
  71. package/dist/tests-ts/qwenwork-reconnect.test.js +195 -0
  72. package/dist/tests-ts/qwenwork-sse.test.js +33 -0
  73. package/dist/tests-ts/session-access-defaults.test.js +112 -0
  74. package/dist/tests-ts/session-management.test.js +8 -8
  75. package/dist/tests-ts/version-manager.test.js +40 -0
  76. package/dist/tests-ts/workbuddy-cdp-recovery.test.js +311 -0
  77. package/dist/tests-ts/workbuddy-plugin.test.js +356 -13
  78. package/dist/tests-ts/zcode-cdp.test.js +894 -0
  79. package/dist/tests-ts/zcode-plugin.test.js +396 -0
  80. package/package.json +1 -1
  81. package/plugins/abweb/dist/src-ts/plugins/abweb/index.js +1 -1
  82. package/plugins/abweb/dist/src-ts/plugins/abweb/public/app.js +8 -6
  83. package/plugins/abweb/dist/src-ts/plugins/abweb/public/app.ts +7 -5
  84. package/plugins/abweb/dist/src-ts/plugins/abweb/public/index.html +3 -3
  85. package/plugins/abweb/package.json +1 -1
  86. package/plugins/abweb/plugin.json +1 -1
  87. package/plugins/aun/config.schema.json +1 -1
  88. package/plugins/aun/dist/src-ts/plugins/aun/attachments.js +3 -21
  89. package/plugins/aun/dist/src-ts/plugins/aun/index.js +89 -11
  90. package/plugins/aun/dist/src-ts/plugins/aun/messages.js +1 -1
  91. package/plugins/aun/dist/src-ts/plugins/aun/public/app.js +2 -1
  92. package/plugins/aun/dist/src-ts/plugins/aun/public/index.html +1 -1
  93. package/plugins/aun/package.json +1 -1
  94. package/plugins/aun/plugin.json +1 -1
  95. package/plugins/chatgpt/dist/src-ts/plugins/cdp-draft.js +5 -2
  96. package/plugins/chatgpt/dist/src-ts/plugins/chatgpt/index.js +3 -2
  97. package/plugins/chatgpt/dist/src-ts/plugins/desktop-launch.js +44 -3
  98. package/plugins/claude-cli/dist/src-ts/plugins/claude-cli/index.js +1 -1
  99. package/plugins/claude-cli/package.json +1 -1
  100. package/plugins/claude-cli/plugin.json +1 -1
  101. package/plugins/doubao/config.schema.json +2 -1
  102. package/plugins/doubao/dist/src-ts/plugins/desktop-launch.js +44 -3
  103. package/plugins/doubao/dist/src-ts/plugins/doubao/cdp-client.js +231 -45
  104. package/plugins/doubao/dist/src-ts/plugins/doubao/index.js +119 -7
  105. package/plugins/doubao/dist/src-ts/plugins/doubao/native-task.js +134 -0
  106. package/plugins/doubao/package.json +1 -1
  107. package/plugins/doubao/plugin.json +1 -1
  108. package/plugins/dsh/config.schema.json +5 -2
  109. package/plugins/dsh/dist/src-ts/dsh-agent.js +7 -2
  110. package/plugins/dsh/dist/src-ts/plugins/desktop-launch.js +44 -3
  111. package/plugins/dsh/dist/src-ts/plugins/dsh/cdp-client.js +334 -0
  112. package/plugins/dsh/dist/src-ts/plugins/dsh/index.js +102 -23
  113. package/plugins/dsh/dist/src-ts/plugins/dsh/session-history.js +31 -3
  114. package/plugins/dsh/package.json +1 -1
  115. package/plugins/dsh/plugin.json +1 -1
  116. package/plugins/feishu/dist/src-ts/plugins/feishu/index.js +1 -1
  117. package/plugins/feishu/package.json +1 -1
  118. package/plugins/feishu/plugin.json +1 -1
  119. package/plugins/personal-assistant/config.schema.json +3 -2
  120. package/plugins/personal-assistant/dist/src-ts/attachments.js +62 -0
  121. package/plugins/personal-assistant/dist/src-ts/plugins/personal-assistant/index.js +29 -8
  122. package/plugins/personal-assistant/dist/src-ts/plugins/personal-assistant/model-client.js +20 -6
  123. package/plugins/personal-assistant/dist/src-ts/plugins/personal-assistant/session-memory.js +124 -0
  124. package/plugins/personal-assistant/dist/src-ts/plugins/personal-assistant/tools.js +4 -3
  125. package/plugins/personal-assistant/package.json +2 -2
  126. package/plugins/personal-assistant/plugin.json +1 -1
  127. package/plugins/qwenwork/dist/src-ts/plugins/cdp-draft.js +5 -2
  128. package/plugins/qwenwork/dist/src-ts/plugins/desktop-launch.js +44 -3
  129. package/plugins/qwenwork/dist/src-ts/plugins/qwenwork/cdp-client.js +43 -7
  130. package/plugins/qwenwork/dist/src-ts/plugins/qwenwork/index.js +52 -18
  131. package/plugins/qwenwork/package.json +1 -1
  132. package/plugins/qwenwork/plugin.json +1 -1
  133. package/plugins/workbuddy/config.schema.json +1 -1
  134. package/plugins/workbuddy/dist/src-ts/plugins/desktop-launch.js +44 -3
  135. package/plugins/workbuddy/dist/src-ts/plugins/workbuddy/cdp-client.js +349 -83
  136. package/plugins/workbuddy/dist/src-ts/plugins/workbuddy/index.js +24 -12
  137. package/plugins/workbuddy/package.json +1 -1
  138. package/plugins/workbuddy/plugin.json +1 -1
  139. package/plugins/zcode/config.schema.json +13 -0
  140. package/plugins/zcode/dist/src-ts/agent.js +69 -0
  141. package/plugins/zcode/dist/src-ts/attachments.js +62 -0
  142. package/plugins/zcode/dist/src-ts/plugin.js +13 -0
  143. package/plugins/zcode/dist/src-ts/plugins/desktop-launch.js +238 -0
  144. package/plugins/zcode/dist/src-ts/plugins/workbuddy/cdp-client.js +896 -0
  145. package/plugins/zcode/dist/src-ts/plugins/workbuddy/cli-client.js +39 -0
  146. package/plugins/zcode/dist/src-ts/plugins/workbuddy/desktop-launch.js +10 -0
  147. package/plugins/zcode/dist/src-ts/plugins/workbuddy/index.js +567 -0
  148. package/plugins/zcode/dist/src-ts/plugins/workbuddy/session-history.js +121 -0
  149. package/plugins/zcode/dist/src-ts/plugins/zcode/cdp-client.js +500 -0
  150. package/plugins/zcode/dist/src-ts/plugins/zcode/index.js +97 -0
  151. package/plugins/zcode/package.json +16 -0
  152. package/plugins/zcode/plugin.json +11 -0
@@ -0,0 +1,396 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const strict_1 = __importDefault(require("node:assert/strict"));
40
+ const node_test_1 = __importStar(require("node:test"));
41
+ const childProcess = require("node:child_process");
42
+ const desktop = __importStar(require("../src-ts/plugins/desktop-launch"));
43
+ const cdp_client_1 = require("../src-ts/plugins/zcode/cdp-client");
44
+ const zcode_1 = require("../src-ts/plugins/zcode");
45
+ const agent_1 = require("../src-ts/agent");
46
+ function startupFixture(error = new TypeError("fetch failed", { cause: Object.assign(new Error("端口拒绝连接"), { code: "ECONNREFUSED" }) })) {
47
+ const platform = Object.getOwnPropertyDescriptor(process, "platform");
48
+ Object.defineProperty(process, "platform", { value: "win32" });
49
+ let online = false;
50
+ let connections = 0;
51
+ const launches = [];
52
+ const discovery = node_test_1.mock.method(desktop, "findWindowsExecutable", async () => "D:\\自定义安装\\ZCode\\ZCode.exe");
53
+ node_test_1.mock.method(cdp_client_1.ZcodeCdpClient.prototype, "connect", async () => { connections++; if (!online)
54
+ throw error; });
55
+ node_test_1.mock.method(cdp_client_1.ZcodeCdpClient.prototype, "connected", () => online);
56
+ node_test_1.mock.method(childProcess, "spawn", (file, args, options) => {
57
+ launches.push({ file, args, env: options.env });
58
+ online = true;
59
+ return { unref() { }, exitCode: null, signalCode: null };
60
+ });
61
+ return { launches, discovery, connections: () => connections, online(value) { online = value; }, restore() { node_test_1.mock.restoreAll(); Object.defineProperty(process, "platform", platform); } };
62
+ }
63
+ const startupContext = (config = {}) => ({ config, logger: { info() { }, warn() { }, error() { } } });
64
+ (0, node_test_1.default)("ZCode 后台激活自动发现程序并带 CDP 和附加参数启动,重载重新启动自有桌面", async () => {
65
+ const fixture = startupFixture();
66
+ const previous = process.env.ELECTRON_RUN_AS_NODE;
67
+ process.env.ELECTRON_RUN_AS_NODE = "1";
68
+ const plugin = new zcode_1.ZcodePlugin();
69
+ try {
70
+ const context = startupContext({ cdpPort: 19321, startupArgs: ["--lang=zh-CN", "--test-value=含 空格"] });
71
+ await plugin.activate(context);
72
+ strict_1.default.equal((await plugin.health()).status, "ready");
73
+ strict_1.default.equal(fixture.discovery.mock.calls[0].arguments[0], "ZCode.exe");
74
+ strict_1.default.equal(fixture.launches[0].file, "D:\\自定义安装\\ZCode\\ZCode.exe");
75
+ strict_1.default.deepEqual(fixture.launches[0].args, ["--lang=zh-CN", "--test-value=含 空格", "--remote-debugging-address=127.0.0.1", "--remote-debugging-port=19321"]);
76
+ strict_1.default.equal(fixture.launches[0].env.ELECTRON_RUN_AS_NODE, undefined);
77
+ await plugin.deactivate("reload");
78
+ fixture.online(false);
79
+ await plugin.activate(context);
80
+ strict_1.default.equal(fixture.launches.length, 2);
81
+ strict_1.default.ok(fixture.connections() >= 3);
82
+ }
83
+ finally {
84
+ await plugin.deactivate("stop");
85
+ fixture.restore();
86
+ if (previous === undefined)
87
+ delete process.env.ELECTRON_RUN_AS_NODE;
88
+ else
89
+ process.env.ELECTRON_RUN_AS_NODE = previous;
90
+ }
91
+ });
92
+ (0, node_test_1.default)("ZCode 已有 CDP、禁用自动启动和非端口错误均不拉起桌面", async () => {
93
+ for (const mode of ["connected", "disabled", "page"]) {
94
+ const fixture = startupFixture(mode === "page" ? new Error("未找到 ZCode 页面 target") : undefined);
95
+ const plugin = new zcode_1.ZcodePlugin();
96
+ try {
97
+ if (mode === "connected")
98
+ fixture.online(true);
99
+ const start = plugin.activate(startupContext({ autoStart: mode !== "disabled" }));
100
+ if (mode === "connected")
101
+ await start;
102
+ else
103
+ await strict_1.default.rejects(start, mode === "page" ? /未找到 ZCode 页面/ : /fetch failed/);
104
+ strict_1.default.equal(fixture.launches.length, 0);
105
+ strict_1.default.equal(fixture.discovery.mock.callCount(), 0);
106
+ }
107
+ finally {
108
+ await plugin.deactivate("stop");
109
+ fixture.restore();
110
+ }
111
+ }
112
+ });
113
+ (0, node_test_1.default)("ZCode 找不到安装记录时给出自身程序的配置提示", async () => {
114
+ const fixture = startupFixture();
115
+ fixture.discovery.mock.mockImplementation(async () => undefined);
116
+ const plugin = new zcode_1.ZcodePlugin();
117
+ try {
118
+ await strict_1.default.rejects(plugin.activate(startupContext()), /未找到 ZCode.exe.*executablePath/);
119
+ strict_1.default.equal(fixture.launches.length, 0);
120
+ }
121
+ finally {
122
+ await plugin.deactivate("stop");
123
+ fixture.restore();
124
+ }
125
+ });
126
+ (0, node_test_1.default)("ZCode 附加启动参数不能覆盖配置中的 CDP 地址或端口", async () => {
127
+ const fixture = startupFixture();
128
+ const plugin = new zcode_1.ZcodePlugin();
129
+ try {
130
+ for (const startupArgs of [["--remote-debugging-port=9999"], ["--remote-debugging-address", "0.0.0.0"], [123]]) {
131
+ await strict_1.default.rejects(plugin.activate(startupContext({ startupArgs })), /startupArgs/);
132
+ }
133
+ strict_1.default.equal(fixture.launches.length, 0);
134
+ }
135
+ finally {
136
+ await plugin.deactivate("stop");
137
+ fixture.restore();
138
+ }
139
+ });
140
+ (0, node_test_1.default)("ZCode 重载时清理自有进程,委托退出失败也执行清理", async () => {
141
+ for (const delegateFails of [false, true]) {
142
+ const fixture = startupFixture();
143
+ const plugin = new zcode_1.ZcodePlugin();
144
+ const child = { pid: 4321, exitCode: null, signalCode: null, unref() { } };
145
+ const cleanup = node_test_1.mock.method(desktop, "terminateOwnedProcess", async () => undefined);
146
+ try {
147
+ await plugin.activate(startupContext());
148
+ plugin.process = child;
149
+ if (delegateFails)
150
+ plugin.delegate.deactivate = async () => { throw new Error("委托退出失败"); };
151
+ if (delegateFails)
152
+ await strict_1.default.rejects(plugin.deactivate("reload"), /委托退出失败/);
153
+ else
154
+ await plugin.deactivate("reload");
155
+ strict_1.default.equal(cleanup.mock.callCount(), 1);
156
+ strict_1.default.equal(cleanup.mock.calls[0].arguments[0], child);
157
+ }
158
+ finally {
159
+ await plugin.deactivate("stop");
160
+ fixture.restore();
161
+ }
162
+ }
163
+ });
164
+ (0, node_test_1.default)("zcode CDP 客户端选择 zcode 页面", async () => {
165
+ const original = globalThis.WebSocket;
166
+ let url = "";
167
+ class TestWebSocket {
168
+ static OPEN = 1;
169
+ readyState = 0;
170
+ onopen;
171
+ onclose;
172
+ onerror;
173
+ onmessage;
174
+ constructor(target) { url = target; queueMicrotask(() => { this.readyState = 1; this.onopen?.(); }); }
175
+ send(message) { const { id } = JSON.parse(message); queueMicrotask(() => this.onmessage?.({ data: JSON.stringify({ id, result: { result: { value: true } } }) })); }
176
+ close() { this.readyState = 3; }
177
+ }
178
+ globalThis.WebSocket = TestWebSocket;
179
+ const client = new cdp_client_1.ZcodeCdpClient({
180
+ timeoutMs: 20,
181
+ fetchImpl: async () => new Response(JSON.stringify([
182
+ { type: "page", title: "WorkBuddy", url: "app://workbuddy", webSocketDebuggerUrl: "ws://127.0.0.1:9231/devtools/page/1" },
183
+ { type: "page", title: "ZCode", url: "app://zcode", webSocketDebuggerUrl: "ws://127.0.0.1:9231/devtools/page/2" },
184
+ ])),
185
+ });
186
+ try {
187
+ await client.connect();
188
+ strict_1.default.equal(url, "ws://127.0.0.1:9231/devtools/page/2");
189
+ }
190
+ finally {
191
+ client.close();
192
+ globalThis.WebSocket = original;
193
+ }
194
+ });
195
+ (0, node_test_1.default)("zcode CDP 客户端拒绝其他桌面页面", async () => {
196
+ const client = new cdp_client_1.ZcodeCdpClient({
197
+ fetchImpl: async () => new Response(JSON.stringify([
198
+ { type: "page", title: "WorkBuddy", url: "app://workbuddy", webSocketDebuggerUrl: "ws://127.0.0.1:9231/devtools/page/1" },
199
+ ])),
200
+ });
201
+ await strict_1.default.rejects(() => client.connect(), /未找到 ZCode 页面 target/);
202
+ });
203
+ (0, node_test_1.default)("ZCode 重载后仅对发现请求的旧连接重置重试一次,保留端口拒绝错误", async () => {
204
+ for (const mode of ["reset", "reset-refused", "refused"]) {
205
+ let attempts = 0;
206
+ const refused = new TypeError("fetch failed", { cause: Object.assign(new Error("端口拒绝连接"), { code: "ECONNREFUSED" }) });
207
+ const client = new cdp_client_1.ZcodeCdpClient({ fetchImpl: async () => {
208
+ attempts++;
209
+ if (mode !== "refused" && attempts === 1)
210
+ throw new TypeError("fetch failed", { cause: Object.assign(new Error("旧连接重置"), { code: "ECONNRESET" }) });
211
+ if (mode !== "reset")
212
+ throw refused;
213
+ return new Response("[]");
214
+ } });
215
+ await strict_1.default.rejects(client.connect(), mode === "reset" ? /未找到 ZCode 页面 target/ : error => error === refused);
216
+ strict_1.default.equal(attempts, mode === "refused" ? 1 : 2);
217
+ }
218
+ });
219
+ (0, node_test_1.default)("zcode 插件通过 CDP 客户端返回桌面回复", async () => {
220
+ const calls = [];
221
+ const plugin = new zcode_1.ZcodePlugin({ client: {
222
+ connect: async () => undefined,
223
+ close() { },
224
+ connected: () => true,
225
+ createTask: async () => undefined,
226
+ direct: async (text) => { calls.push(text); return "ZCODE_DESKTOP_REPLY"; },
227
+ } });
228
+ await plugin.activate({ config: { cdpPort: 9231 }, logger: { info() { }, warn() { }, error() { } } });
229
+ strict_1.default.deepEqual(await plugin.handle({ task: "请回复固定文本", sessionId: "zcode:test" }), { text: "ZCODE_DESKTOP_REPLY", sessionId: "zcode:test" });
230
+ strict_1.default.deepEqual(calls, ["请回复固定文本"]);
231
+ await plugin.deactivate("stop");
232
+ });
233
+ (0, node_test_1.default)("ZCode 将包含专家称呼的消息作为普通文本发送", async () => {
234
+ const plugin = new zcode_1.ZcodePlugin({ client: {
235
+ connect: async () => undefined, close() { }, connected: () => true,
236
+ direct: async (text, _timeout, expert) => { strict_1.default.equal(expert, undefined); return text; },
237
+ } });
238
+ await plugin.activate({ config: {}, logger: { info() { }, warn() { }, error() { } } });
239
+ try {
240
+ strict_1.default.equal((await plugin.handle({ task: "用数学专家解释这个题" })).text, "用数学专家解释这个题");
241
+ }
242
+ finally {
243
+ await plugin.deactivate("stop");
244
+ }
245
+ });
246
+ (0, node_test_1.default)("ZCode 复用会话层时保留原有等待配置", async () => {
247
+ const timeouts = [];
248
+ const plugin = new zcode_1.ZcodePlugin({ client: {
249
+ connect: async () => undefined, close() { }, connected: () => true,
250
+ direct: async (_text, timeout) => { timeouts.push(timeout); return "回复"; },
251
+ } });
252
+ await plugin.activate({ config: {}, logger: { info() { }, warn() { }, error() { } } });
253
+ try {
254
+ await plugin.handle({ task: "默认" });
255
+ await plugin.handle({ task: "短等待", timeoutMs: 1234 });
256
+ await plugin.handle({ task: "既有长等待", timeoutMs: 7_200_000 });
257
+ strict_1.default.deepEqual(timeouts, [3_600_000, 1234, 7_200_000]);
258
+ }
259
+ finally {
260
+ await plugin.deactivate("stop");
261
+ }
262
+ });
263
+ (0, node_test_1.default)("ZCode 失败后保留原任务绑定,续聊必须恢复原任务", async () => {
264
+ let desktop = "A";
265
+ let fail = false;
266
+ const sent = [];
267
+ const restored = [];
268
+ const plugin = new zcode_1.ZcodePlugin({ client: {
269
+ connect: async () => undefined, close() { }, connected: () => true,
270
+ createTask: async () => { desktop = "A"; },
271
+ conversationId: async () => desktop,
272
+ activateConversation: async (id) => { restored.push(id); desktop = id; },
273
+ direct: async () => { if (fail) {
274
+ desktop = "B";
275
+ throw new Error("桌面任务已切换");
276
+ } sent.push(desktop); return "回复"; },
277
+ } });
278
+ await plugin.activate({ config: {}, logger: { info() { }, warn() { }, error() { } } });
279
+ try {
280
+ await plugin.handle({ task: "首轮", sessionId: "peer-A" });
281
+ fail = true;
282
+ await strict_1.default.rejects(() => plugin.handle({ task: "切换", sessionId: "peer-A" }), /桌面任务已切换/);
283
+ fail = false;
284
+ await plugin.handle({ task: "续聊", sessionId: "peer-A" });
285
+ strict_1.default.deepEqual(restored, ["A"]);
286
+ strict_1.default.deepEqual(sent, ["A", "A"]);
287
+ }
288
+ finally {
289
+ await plugin.deactivate("stop");
290
+ }
291
+ });
292
+ (0, node_test_1.default)("ZCode 会话管理失败使用自身错误码和文案,不冒充 WorkBuddy", async () => {
293
+ let desktop = "session_original";
294
+ const plugin = new zcode_1.ZcodePlugin({ client: {
295
+ connect: async () => undefined, close() { }, connected: () => true,
296
+ createTask: async () => { desktop = "session_original"; },
297
+ conversationId: async () => desktop,
298
+ direct: async () => "回复",
299
+ } });
300
+ await plugin.activate({ config: {}, logger: { info() { }, warn() { }, error() { } } });
301
+ try {
302
+ await plugin.handle({ task: "首轮", sessionId: "peer-A" });
303
+ desktop = "session_other";
304
+ await strict_1.default.rejects(plugin.handle({ task: "续聊", sessionId: "peer-A" }), error => {
305
+ strict_1.default.ok(error instanceof agent_1.AgentOperationError);
306
+ strict_1.default.equal(error.code, "ZCODE_TASK_FAILED");
307
+ strict_1.default.equal(error.stage, "准备或恢复 ZCode 会话");
308
+ strict_1.default.doesNotMatch((0, agent_1.errorDetails)(error), /WorkBuddy|WORKBUDDY/);
309
+ strict_1.default.match((0, agent_1.errorDetails)(error), /ZCode 桌面任务已切换/);
310
+ return true;
311
+ });
312
+ }
313
+ finally {
314
+ await plugin.deactivate("stop");
315
+ }
316
+ });
317
+ (0, node_test_1.default)("ZCode 排队请求取消后不创建或切换桌面任务", async () => {
318
+ let created = 0;
319
+ const plugin = new zcode_1.ZcodePlugin({ client: {
320
+ connect: async () => undefined, close() { }, connected: () => true,
321
+ createTask: async () => { created++; }, direct: async () => "回复",
322
+ } });
323
+ await plugin.activate({ config: {}, logger: { info() { }, warn() { }, error() { } } });
324
+ const controller = new AbortController();
325
+ controller.abort(new Error("已取消"));
326
+ try {
327
+ await strict_1.default.rejects(() => plugin.handle({ task: "已取消请求", sessionId: "cancelled", signal: controller.signal }), /已取消/);
328
+ strict_1.default.equal(created, 0);
329
+ }
330
+ finally {
331
+ await plugin.deactivate("stop");
332
+ }
333
+ });
334
+ (0, node_test_1.default)("ZCode 委托将原生任务绑定传给发送端复核", async () => {
335
+ let desktop;
336
+ const expected = [];
337
+ const plugin = new zcode_1.ZcodePlugin({ client: {
338
+ connect: async () => undefined, close() { }, connected: () => true,
339
+ createTask: async () => { desktop = undefined; }, conversationId: async () => desktop,
340
+ direct: async () => "",
341
+ complete: async (_request, _expert, _newTask, expectedConversationId) => { expected.push(expectedConversationId); desktop = "A"; return { text: "回复" }; },
342
+ } });
343
+ await plugin.activate({ config: {}, logger: { info() { }, warn() { }, error() { } } });
344
+ try {
345
+ await plugin.handle({ task: "首轮", sessionId: "peer-A" });
346
+ await plugin.handle({ task: "续聊", sessionId: "peer-A" });
347
+ strict_1.default.deepEqual(expected, [null, "A"]);
348
+ }
349
+ finally {
350
+ await plugin.deactivate("stop");
351
+ }
352
+ });
353
+ (0, node_test_1.default)("ZCode CDP 协议错误、页面异常、超时和断线会拒绝请求并清理等待", async () => {
354
+ const original = globalThis.WebSocket;
355
+ let socket;
356
+ let reply = "error";
357
+ class TestWebSocket {
358
+ static OPEN = 1;
359
+ readyState = 0;
360
+ onopen;
361
+ onclose;
362
+ onerror;
363
+ onmessage;
364
+ constructor() { socket = this; queueMicrotask(() => { this.readyState = 1; this.onopen?.(); }); }
365
+ send(raw) {
366
+ const { id } = JSON.parse(raw);
367
+ if (reply === "silent")
368
+ return;
369
+ const response = reply === "error" ? { id, error: { code: -32000, message: "协议失败" } } : { id, result: { exceptionDetails: { text: "页面异常" } } };
370
+ queueMicrotask(() => this.onmessage?.({ data: JSON.stringify(response) }));
371
+ }
372
+ close() { this.readyState = 3; this.onclose?.(); }
373
+ }
374
+ globalThis.WebSocket = TestWebSocket;
375
+ const client = new cdp_client_1.ZcodeCdpClient({ timeoutMs: 20, fetchImpl: async () => new Response(JSON.stringify([{ type: "page", title: "ZCode", webSocketDebuggerUrl: "ws://127.0.0.1:9231/devtools/page/1" }])) });
376
+ const internal = client;
377
+ try {
378
+ await client.connect();
379
+ await strict_1.default.rejects(() => internal.cdp("Runtime.evaluate"), /协议失败/);
380
+ reply = "exception";
381
+ await strict_1.default.rejects(() => internal.evaluate("1"), /页面异常/);
382
+ reply = "silent";
383
+ await strict_1.default.rejects(() => internal.cdp("Runtime.evaluate"), /超时/);
384
+ strict_1.default.equal(internal.pending.size, 0);
385
+ const pending = internal.cdp("Runtime.evaluate");
386
+ const rejected = strict_1.default.rejects(pending, /已关闭|已断开/);
387
+ socket.close();
388
+ await rejected;
389
+ strict_1.default.equal(internal.pending.size, 0);
390
+ strict_1.default.equal(client.connected(), false);
391
+ }
392
+ finally {
393
+ client.close();
394
+ globalThis.WebSocket = original;
395
+ }
396
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mu-agent-bridge",
3
- "version": "1.0.73",
3
+ "version": "1.0.78",
4
4
  "description": "将 AUN Agent 连接到本地桌面 AI 客户端的插件平台。",
5
5
  "main": "dist/src-ts/cli.js",
6
6
  "bin": {
@@ -5,7 +5,7 @@ const node_fs_1 = require("node:fs");
5
5
  const node_path_1 = require("node:path");
6
6
  const MANIFEST = {
7
7
  id: "abweb",
8
- version: "1.0.13",
8
+ version: "1.0.15",
9
9
  displayName: "Agent Bridge Web",
10
10
  entry: "dist/index.js",
11
11
  apiVersion: "1",
@@ -219,7 +219,8 @@
219
219
  versionsNode.replaceChildren(...entries.map((entry) => {
220
220
  const row = document.createElement("div");
221
221
  row.className = "version-row";
222
- row.textContent = `${entry.packageName} · 当前 ${entry.currentVersion} · ${entry.latestVersion ? `最新 ${entry.latestVersion}` : "最新版本未知"} · ${entry.state}${entry.error ? ` · ${entry.error}` : ""}`;
222
+ const state = entry.state === "unpublished" ? "未发布" : entry.state;
223
+ row.textContent = `${entry.packageName} · 当前 ${entry.currentVersion} · ${entry.latestVersion ? `最新 ${entry.latestVersion}` : "最新版本未知"} · ${state}${entry.error ? ` · ${entry.error}` : ""}`;
223
224
  return row;
224
225
  }));
225
226
  if (!entries.length)
@@ -427,8 +428,8 @@
427
428
  node("#assistant-api-key").value = "";
428
429
  node("#assistant-api-key").placeholder = config.apiKey ? "已配置,留空保留" : "可选,本地免认证服务可留空";
429
430
  node("#assistant-timeout").value = String(config.timeoutMs ?? 120000);
430
- node("#assistant-allowed-peers").value = (config.allowedPeers ?? []).join("\n");
431
- node("#assistant-allowed-agents").value = (config.allowedAgents ?? []).join("\n");
431
+ node("#assistant-allowed-peers").value = config.allowedPeers?.includes("*") ? "" : (config.allowedPeers ?? []).join("\n");
432
+ node("#assistant-allowed-agents").value = config.allowedAgents?.includes("*") ? "" : (config.allowedAgents ?? []).join("\n");
432
433
  node("#assistant-config-error").hidden = true;
433
434
  node("#assistant-config-dialog").showModal();
434
435
  }
@@ -457,7 +458,8 @@
457
458
  if (timeoutMs !== Number(assistantOriginal.timeoutMs ?? 120000))
458
459
  body.timeoutMs = timeoutMs;
459
460
  for (const [field, selector] of [["allowedPeers", "#assistant-allowed-peers"], ["allowedAgents", "#assistant-allowed-agents"]]) {
460
- const values = [...new Set(node(selector).value.split(/[\s,,]+/).filter(Boolean))];
461
+ const entries = [...new Set(node(selector).value.split(/[\s,,]+/).filter(Boolean))];
462
+ const values = entries.includes("*") ? [] : entries;
461
463
  if (JSON.stringify(values) !== JSON.stringify(assistantOriginal[field]))
462
464
  body[field] = values;
463
465
  }
@@ -519,8 +521,8 @@
519
521
  node("#check-versions").onclick = () => void request("/api/versions/check", "POST", {}).then(() => load()).catch((cause) => error(String(cause)));
520
522
  node("#save-update-policy").onclick = () => void request("/api/update-policy", "PATCH", { mode: policyNode.value }).then(() => load()).catch((cause) => error(String(cause)));
521
523
  node("#save-plugin-trust").onclick = () => { const button = node("#save-plugin-trust"); button.disabled = true; trustStatusNode.textContent = "正在保存…"; void request("/api/plugin-trust", "PATCH", pluginTrustConfig).then(() => { pluginTrustDirty = false; trustStatusNode.textContent = "信任设置已保存"; return load(false); }).catch((cause) => { trustStatusNode.textContent = String(cause); }).finally(() => { button.disabled = false; }); };
522
- node("#update-core").onclick = () => { if (confirm("确认升级后台并自动重启?"))
523
- void request("/api/update", "POST", {}).then(() => { error("后台正在升级,页面将在几秒后恢复"); }).catch((cause) => error(String(cause))); };
524
+ node("#update-core").onclick = () => { if (confirm("确认检查后台更新?有更高版本时将升级并自动重启"))
525
+ void request("/api/update", "POST", {}).then(() => { error("后台正在检查更新,有更高版本时升级并重启;结果请查看运行日志"); }).catch((cause) => error(String(cause))); };
524
526
  node("#pair-button").onclick = () => {
525
527
  const code = pairCodeNode.value.trim();
526
528
  if (!/^\d{6}$/.test(code))
@@ -150,7 +150,8 @@
150
150
  const entries = [data.core, ...(data.plugins ?? []).map((plugin: any) => plugin.versionStatus)].filter(Boolean);
151
151
  versionsNode.replaceChildren(...entries.map((entry: any) => {
152
152
  const row = document.createElement("div"); row.className = "version-row";
153
- row.textContent = `${entry.packageName} · 当前 ${entry.currentVersion} · ${entry.latestVersion ? `最新 ${entry.latestVersion}` : "最新版本未知"} · ${entry.state}${entry.error ? ` · ${entry.error}` : ""}`;
153
+ const state = entry.state === "unpublished" ? "未发布" : entry.state;
154
+ row.textContent = `${entry.packageName} · 当前 ${entry.currentVersion} · ${entry.latestVersion ? `最新 ${entry.latestVersion}` : "最新版本未知"} · ${state}${entry.error ? ` · ${entry.error}` : ""}`;
154
155
  return row;
155
156
  }));
156
157
  if (!entries.length) versionsNode.textContent = "尚未检查版本";
@@ -268,8 +269,8 @@
268
269
  node<HTMLInputElement>("#assistant-api-key").value = "";
269
270
  node<HTMLInputElement>("#assistant-api-key").placeholder = config.apiKey ? "已配置,留空保留" : "可选,本地免认证服务可留空";
270
271
  node<HTMLInputElement>("#assistant-timeout").value = String(config.timeoutMs ?? 120000);
271
- node<HTMLTextAreaElement>("#assistant-allowed-peers").value = (config.allowedPeers ?? []).join("\n");
272
- node<HTMLTextAreaElement>("#assistant-allowed-agents").value = (config.allowedAgents ?? []).join("\n");
272
+ node<HTMLTextAreaElement>("#assistant-allowed-peers").value = config.allowedPeers?.includes("*") ? "" : (config.allowedPeers ?? []).join("\n");
273
+ node<HTMLTextAreaElement>("#assistant-allowed-agents").value = config.allowedAgents?.includes("*") ? "" : (config.allowedAgents ?? []).join("\n");
273
274
  node<HTMLElement>("#assistant-config-error").hidden = true;
274
275
  node<HTMLDialogElement>("#assistant-config-dialog").showModal();
275
276
  }
@@ -289,7 +290,8 @@
289
290
  const timeoutMs = Number(node<HTMLInputElement>("#assistant-timeout").value);
290
291
  if (timeoutMs !== Number(assistantOriginal.timeoutMs ?? 120000)) body.timeoutMs = timeoutMs;
291
292
  for (const [field, selector] of [["allowedPeers", "#assistant-allowed-peers"], ["allowedAgents", "#assistant-allowed-agents"]]) {
292
- const values = [...new Set(node<HTMLTextAreaElement>(selector).value.split(/[\s,,]+/).filter(Boolean))];
293
+ const entries = [...new Set(node<HTMLTextAreaElement>(selector).value.split(/[\s,,]+/).filter(Boolean))];
294
+ const values = entries.includes("*") ? [] : entries;
293
295
  if (JSON.stringify(values) !== JSON.stringify(assistantOriginal[field])) body[field] = values;
294
296
  }
295
297
  void request("/api/plugins/personal-assistant/config", "PATCH", body).then(result => {
@@ -330,7 +332,7 @@
330
332
  node<HTMLButtonElement>("#check-versions").onclick = () => void request("/api/versions/check", "POST", {}).then(() => load()).catch((cause) => error(String(cause)));
331
333
  node<HTMLButtonElement>("#save-update-policy").onclick = () => void request("/api/update-policy", "PATCH", { mode: policyNode.value }).then(() => load()).catch((cause) => error(String(cause)));
332
334
  node<HTMLButtonElement>("#save-plugin-trust").onclick = () => { const button = node<HTMLButtonElement>("#save-plugin-trust"); button.disabled = true; trustStatusNode.textContent = "正在保存…"; void request("/api/plugin-trust", "PATCH", pluginTrustConfig).then(() => { pluginTrustDirty = false; trustStatusNode.textContent = "信任设置已保存"; return load(false); }).catch((cause) => { trustStatusNode.textContent = String(cause); }).finally(() => { button.disabled = false; }); };
333
- node<HTMLButtonElement>("#update-core").onclick = () => { if (confirm("确认升级后台并自动重启?")) void request("/api/update", "POST", {}).then(() => { error("后台正在升级,页面将在几秒后恢复"); }).catch((cause) => error(String(cause))); };
335
+ node<HTMLButtonElement>("#update-core").onclick = () => { if (confirm("确认检查后台更新?有更高版本时将升级并自动重启")) void request("/api/update", "POST", {}).then(() => { error("后台正在检查更新,有更高版本时升级并重启;结果请查看运行日志"); }).catch((cause) => error(String(cause))); };
334
336
  node<HTMLButtonElement>("#pair-button").onclick = () => {
335
337
  const code = pairCodeNode.value.trim();
336
338
  if (!/^\d{6}$/.test(code)) return error("请输入 6 位配置码");
@@ -39,9 +39,9 @@
39
39
  <label for="assistant-endpoint">OpenAI 兼容地址</label><input id="assistant-endpoint" type="url" placeholder="http://127.0.0.1:11434/v1/chat/completions">
40
40
  <label for="assistant-api-key">API 密钥(留空保留已有密钥)</label><input id="assistant-api-key" type="password" autocomplete="new-password">
41
41
  <label for="assistant-timeout">模型超时(毫秒)</label><input id="assistant-timeout" type="number" min="1000" max="120000" required>
42
- <label for="assistant-allowed-peers">允许使用助理的 Peer AID(每行一个)</label><textarea id="assistant-allowed-peers" rows="3" placeholder="example.agentid.cn"></textarea>
43
- <label for="assistant-allowed-agents">允许调用的 Agent 插件 ID(每行一个)</label><textarea id="assistant-allowed-agents" rows="3" placeholder="workbuddy&#10;dsh"></textarea>
44
- <p class="muted">插件来源沿用客户端登录及当前模型;留空白名单表示不授权。AID 关联请在 Channel 设置中完成。</p>
42
+ <label for="assistant-allowed-peers">允许使用助理的 Peer AID(每行一个,留空接受所有)</label><textarea id="assistant-allowed-peers" rows="3" placeholder="留空接受所有 Peer"></textarea>
43
+ <label for="assistant-allowed-agents">允许调用的 Agent 插件 ID(每行一个,留空允许所有)</label><textarea id="assistant-allowed-agents" rows="3" placeholder="留空允许所有已就绪 Agent"></textarea>
44
+ <p class="muted">默认留空,接受所有 Peer 并允许调用所有已就绪的普通 Agent;填写具体名单后才限制。插件来源沿用客户端登录及当前模型,AID 关联请在 Channel 设置中完成。</p>
45
45
  <p id="assistant-config-error" class="error" role="alert" hidden></p>
46
46
  <div><button id="assistant-config-save" type="submit">保存配置</button><button id="assistant-config-cancel" type="button">取消</button></div>
47
47
  </form>
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-bridge-abweb",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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.13",
3
+ "version": "1.0.15",
4
4
  "type": "management",
5
5
  "displayName": "Agent Bridge Web",
6
6
  "entry": "dist/src-ts/plugins/abweb/index.js",
@@ -12,7 +12,7 @@
12
12
  "encryption_seed": { "type": "string" },
13
13
  "verify_ssl": { "type": "boolean", "default": true },
14
14
  "root_ca_path": { "type": "string" },
15
- "allow_from": { "type": "string" },
15
+ "allow_from": { "type": "string", "default": "", "description": "留空接受所有 AUN Peer;填写 AID 后限制来源,可用英文逗号分隔。" },
16
16
  "delivery_mode": { "enum": ["fanout", "queue"] }
17
17
  },
18
18
  "additionalProperties": false
@@ -250,30 +250,12 @@ async function uploadAunAttachments(client, ownerAid, peerAid, items) {
250
250
  const objectKey = `shared/${(0, node_crypto_1.randomUUID)()}/${filename.replace(/[^A-Za-z0-9._-]/g, "_")}`;
251
251
  const sha256 = digest(item.data);
252
252
  const contentType = item.contentType.toLowerCase();
253
- // 视频播放器不携带 AID 凭据,沿用 EvolCore 的标准可读对象上传方式。
254
- const video = contentType.startsWith("video/");
253
+ // 会话媒体控件不携带 AID 凭据,沿用 ec msg 的标准可读对象上传方式。
255
254
  const ref = { ownerAid, bucket: "default", objectKey, filename, contentType, sizeBytes: item.data.byteLength, sha256 };
256
- const uploaded = await client.storage.writeBytes(`/${objectKey}`, item.data, { contentType, public: video, overwrite: video })
255
+ const uploaded = await client.storage.writeBytes(`/${objectKey}`, item.data, { contentType, public: true, overwrite: true })
257
256
  .catch(error => { throw new agent_1.AgentOperationError("AUN_FS_UPLOAD_FAILED", `上传 AUN FS 文件“${filename}”`, error); });
258
257
  checkedMetadata({ ...uploaded, size: uploaded.size ?? uploaded.size_bytes ?? item.data.byteLength }, ref);
259
- if (video) {
260
- result.push({ owner_aid: ownerAid, object_key: objectKey, filename, content_type: contentType, size_bytes: item.data.byteLength, sha256 });
261
- continue;
262
- }
263
- const share = await client.storage.lowlevel.createShareLink({ owner: ownerAid, bucket: "default", objectKey, allowedAids: [peerAid], expireInSeconds: 86400 })
264
- .catch(error => { throw new agent_1.AgentOperationError("AUN_FS_SHARE_FAILED", `创建 AUN FS 文件“${filename}”的接收方授权`, error); });
265
- if (share.owner_aid && share.owner_aid !== ownerAid || share.bucket && share.bucket !== "default" || share.object_key && share.object_key !== objectKey)
266
- throw new Error("AUN 附件分享对象不一致");
267
- if (share.allowed_aids !== undefined && (!Array.isArray(share.allowed_aids) || share.allowed_aids.length !== 1 || share.allowed_aids[0] !== peerAid))
268
- throw new Error("AUN 附件分享授权不一致");
269
- const shareId = typeof share.share_id === "string" && /^[A-Za-z0-9]{10}$/.test(share.share_id) ? share.share_id : undefined;
270
- if (share.share_id !== undefined && !shareId)
271
- throw new Error("AUN 附件分享标识无效");
272
- const url = typeof share.path_url === "string" && share.path_url ? share.path_url : shareId ? `https://${ownerAid}/${objectKey}?t=${shareId}` : "";
273
- const token = url ? pathToken(url, ownerAid, objectKey) : undefined;
274
- if (!token || shareId && shareId !== token)
275
- throw new Error("AUN 附件分享链接无效");
276
- result.push({ owner_aid: ownerAid, bucket: "default", object_key: objectKey, url, filename, content_type: item.contentType, size_bytes: item.data.byteLength, sha256 });
258
+ result.push({ owner_aid: ownerAid, object_key: objectKey, filename, content_type: contentType, size_bytes: item.data.byteLength, sha256 });
277
259
  }
278
260
  return result;
279
261
  }