mu-agent-bridge 1.0.3 → 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.
@@ -84,7 +84,7 @@ class PluginManager {
84
84
  try {
85
85
  const spec = version ? `${packageName}@${version}` : packageName;
86
86
  if (process.platform === "win32")
87
- await execFileAsync(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", `npm install --prefix "${staging}" --no-save --ignore-scripts ${spec}`]);
87
+ await execFileAsync("npm.cmd", ["install", "--prefix", staging, "--no-save", "--ignore-scripts", spec]);
88
88
  else
89
89
  await execFileAsync("npm", ["install", "--prefix", staging, "--no-save", "--ignore-scripts", spec]);
90
90
  const candidate = (0, node_path_1.join)(staging, "node_modules", packageName);
@@ -141,7 +141,7 @@ class PluginManager {
141
141
  await (0, promises_1.mkdir)(prefix, { recursive: true });
142
142
  try {
143
143
  if (process.platform === "win32")
144
- await execFileAsync(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", `npm install --prefix "${prefix}" --no-save --ignore-scripts ${packageName}`]);
144
+ await execFileAsync("npm.cmd", ["install", "--prefix", prefix, "--no-save", "--ignore-scripts", packageName]);
145
145
  else
146
146
  await execFileAsync("npm", ["install", "--prefix", prefix, "--no-save", "--ignore-scripts", packageName]);
147
147
  const directory = (0, node_path_1.join)(prefix, "node_modules", name);
@@ -6,7 +6,6 @@
6
6
  const errorNode = node("#error");
7
7
  const tokenNode = node("#token");
8
8
  const pairCodeNode = node("#pair-code");
9
- const packageNode = node("#package-name");
10
9
  const packageSearchNode = node("#package-search");
11
10
  const catalogNode = node("#catalog");
12
11
  const pluginPathNode = node("#plugin-path");
@@ -18,19 +17,58 @@
18
17
  let plugins = [];
19
18
  let pluginConfigs = {};
20
19
  let pluginVersions = {};
20
+ const installingPackages = new Set();
21
21
  function error(message) { errorNode.textContent = message; errorNode.hidden = !message; }
22
22
  async function loadCatalog() {
23
23
  const result = await request(`/api/plugins/catalog?q=${encodeURIComponent(packageSearchNode.value.trim())}`);
24
24
  const items = result.plugins ?? [];
25
- packageNode.replaceChildren(...[["Agent", "agent"], ["Channel", "channel"], ["管理", "management"]].flatMap(([label, type]) => {
26
- const group = document.createElement("optgroup");
27
- group.label = label;
28
- group.append(...items.filter((item) => item.type === type).map((item) => new Option(`${item.name} · v${item.version}`, item.name)));
29
- return group.children.length ? [group] : [];
30
- }));
31
- catalogNode.replaceChildren(...items.map((plugin) => { const item = document.createElement("div"); item.className = "catalog-row"; item.textContent = `${plugin.type} · ${plugin.name} · ${plugin.description || "无描述"}`; return item; }));
32
- if (!(result.plugins ?? []).length)
25
+ catalogNode.replaceChildren();
26
+ if (!items.length) {
33
27
  catalogNode.textContent = "未找到已声明类型的 npm 插件";
28
+ return;
29
+ }
30
+ const typeNames = { agent: "Agent", channel: "通道", management: "管理" };
31
+ const table = document.createElement("table");
32
+ table.className = "catalog-table";
33
+ const head = document.createElement("thead");
34
+ const headRow = document.createElement("tr");
35
+ for (const label of ["名称", "版本", "类型", "描述", "操作"]) {
36
+ const cell = document.createElement("th");
37
+ cell.scope = "col";
38
+ cell.textContent = label;
39
+ headRow.append(cell);
40
+ }
41
+ head.append(headRow);
42
+ const body = document.createElement("tbody");
43
+ for (const plugin of items) {
44
+ const row = document.createElement("tr");
45
+ for (const value of [plugin.name, `v${plugin.version}`, typeNames[plugin.type] ?? plugin.type, plugin.description || "无描述"]) {
46
+ const cell = document.createElement("td");
47
+ cell.textContent = value;
48
+ row.append(cell);
49
+ }
50
+ const actionCell = document.createElement("td");
51
+ const install = document.createElement("button");
52
+ install.type = "button";
53
+ install.className = "catalog-action";
54
+ install.title = `安装 ${plugin.name}`;
55
+ install.disabled = installingPackages.has(plugin.name);
56
+ install.textContent = install.disabled ? "安装中…" : "安装";
57
+ install.onclick = () => {
58
+ installingPackages.add(plugin.name);
59
+ install.disabled = true;
60
+ install.textContent = "安装中…";
61
+ void request("/api/plugins/install", "POST", { packageName: plugin.name }).then(async () => { await load(); await loadCatalog(); }).catch((cause) => error(String(cause))).finally(() => { installingPackages.delete(plugin.name); if (install.isConnected) {
62
+ install.disabled = false;
63
+ install.textContent = "安装";
64
+ } });
65
+ };
66
+ actionCell.append(install);
67
+ row.append(actionCell);
68
+ body.append(row);
69
+ }
70
+ table.append(head, body);
71
+ catalogNode.append(table);
34
72
  }
35
73
  async function request(path, method = "GET", body) {
36
74
  const response = await fetch(path, { method, headers: {
@@ -209,17 +247,6 @@
209
247
  return load();
210
248
  }).catch((cause) => error(String(cause)));
211
249
  };
212
- node("#install-package").onclick = () => {
213
- if (!packageNode.value)
214
- return error("请先选择插件");
215
- void request("/api/plugins/install", "POST", { packageName: packageNode.value })
216
- .then(() => load()).catch((cause) => error(String(cause)));
217
- };
218
- node("#install-name-form").onsubmit = (event) => {
219
- event.preventDefault();
220
- const packageName = node("#manual-package-name").value.trim();
221
- void request("/api/plugins/install", "POST", { packageName }).then(() => load()).catch((cause) => error(String(cause)));
222
- };
223
250
  node("#search-packages").onclick = () => void loadCatalog().catch((cause) => error(String(cause)));
224
251
  packageSearchNode.onkeydown = (event) => { if (event.key === "Enter")
225
252
  void loadCatalog().catch((cause) => error(String(cause))); };
@@ -13,7 +13,7 @@
13
13
  <nav class="tabs" role="tablist" aria-label="管理视图"><button id="settings-tab" type="button" role="tab" aria-selected="true" aria-controls="settings-panel">插件设置</button><button id="messages-tab" type="button" role="tab" aria-selected="false" aria-controls="messages-panel">通信记录</button></nav>
14
14
  <div id="settings-panel" role="tabpanel" aria-labelledby="settings-tab">
15
15
  <section><div class="section-heading"><h2>版本管理</h2><button id="check-versions" type="button">检查更新</button></div><div id="versions" class="muted"></div></section>
16
- <section><div class="section-heading"><h2>插件</h2><select id="plugin-picker" aria-label="选择插件"></select></div><div id="plugins" class="plugins"></div><div class="plugin-catalog"><div class="section-heading"><h3>npm 插件目录</h3><button id="search-packages" type="button">刷新目录</button></div><input id="package-search" placeholder="搜索插件名称或功能" aria-label="搜索 npm 插件"><select id="package-name" aria-label="选择 npm 插件"></select><button id="install-package" type="button">安装选中插件</button><form id="install-name-form"><input id="manual-package-name" required pattern="agent-bridge-[a-z0-9-]+" placeholder="输入 npm 包名,例如 agent-bridge-workbuddy" aria-label="直接输入 npm 包名"><button type="submit">按包名安装</button></form><div id="catalog" class="catalog"></div></div><form id="install-local-form"><input id="plugin-path" required placeholder="Windows 上的插件目录路径" aria-label="本地插件目录"><button type="submit">安装本地插件</button></form></section>
16
+ <section><div class="section-heading"><h2>插件</h2><select id="plugin-picker" aria-label="选择插件"></select></div><div id="plugins" class="plugins"></div><div class="plugin-catalog"><div class="section-heading"><h3>npm 插件目录</h3><button id="search-packages" type="button">刷新目录</button></div><input id="package-search" placeholder="搜索插件名称或功能" aria-label="搜索 npm 插件"><div id="catalog" class="catalog" aria-live="polite"></div></div><form id="install-local-form"><input id="plugin-path" required placeholder="Windows 上的插件目录路径" aria-label="本地插件目录"><button type="submit">安装本地插件</button></form></section>
17
17
  <section><div class="section-heading"><h2>已连接 AID</h2><span id="aid-count" class="muted"></span></div><div id="aids" class="aid-list"></div><form id="create-aid-form"><input id="new-aid" required placeholder="新 AID,例如 new.agentid.cn" aria-label="新 AID"><input id="owner-aid" required placeholder="owner AID" aria-label="owner AID"><button type="submit">创建 AID</button></form><p id="aid-result" class="muted" role="status"></p><p class="muted">在插件列表中选择插件,再用“关联 AID”下拉框保存对应身份。</p></section>
18
18
  </div>
19
19
  <div id="messages-panel" role="tabpanel" aria-labelledby="messages-tab" hidden><section><div class="section-heading"><h2>最近通信</h2></div><div class="table-scroll"><table><thead><tr><th scope="col">时间</th><th scope="col">插件</th><th scope="col">接收 AID</th><th scope="col">来源 Peer</th><th scope="col">方向</th><th scope="col">消息</th><th scope="col">错误</th></tr></thead><tbody id="messages"></tbody></table></div><p id="messages-empty" class="muted" hidden>暂无通信记录</p></section></div>
@@ -32,8 +32,14 @@ form { margin-top: 14px; flex-wrap: wrap; }
32
32
  .plugin-catalog { border-top: 1px solid #e0e5e2; margin-top: 18px; padding-top: 14px; }
33
33
  .plugin-catalog h3 { font-size: 14px; margin: 0; }
34
34
  .plugin-catalog input { width: min(100%, 420px); margin: 10px 0; }
35
- .catalog { margin-top: 10px; }
36
- .catalog-row { padding: 7px 0; color: #566761; font-size: 13px; border-bottom: 1px solid #edf1ef; }
35
+ .catalog { overflow-x: auto; margin-top: 10px; }
36
+ .catalog-table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 13px; }
37
+ .catalog-table th, .catalog-table td { padding: 9px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid #dce3df; overflow-wrap: anywhere; }
38
+ .catalog-table th { color: #566761; font-weight: 600; background: #edf1ef; }
39
+ .catalog-table th:nth-child(1) { width: 210px; } .catalog-table th:nth-child(2) { width: 100px; } .catalog-table th:nth-child(3) { width: 90px; } .catalog-table th:nth-child(5) { width: 88px; }
40
+ .catalog-action { min-height: 30px; padding: 4px 10px; }
41
+ .catalog-action:disabled { cursor: wait; opacity: .65; }
42
+ .catalog:empty { color: #566761; font-size: 13px; }
37
43
  .plugin-catalog form { margin-top: 8px; }
38
44
  .muted { color: #65736e; font-size: 13px; }
39
45
  .status { font-size: 12px; padding: 3px 7px; background: #e7ebea; border-radius: 4px; }
@@ -49,6 +49,8 @@ function createContext(config = {}) {
49
49
  strict_1.default.match(String(response.body), /插件设置/);
50
50
  strict_1.default.match(String(response.body), /通信记录/);
51
51
  strict_1.default.match(String(response.body), /<th scope="col">来源 Peer<\/th>/);
52
+ strict_1.default.match(String(response.body), /id="catalog" class="catalog" aria-live="polite"/);
53
+ strict_1.default.doesNotMatch(String(response.body), /id="package-name"/);
52
54
  strict_1.default.equal(response.headers["content-type"], "text/html; charset=utf-8");
53
55
  });
54
56
  (0, node_test_1.default)("abweb returns 404 for unknown static assets", async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mu-agent-bridge",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "将 AUN Agent 连接到本地桌面 AI 客户端的插件平台。",
5
5
  "main": "dist/src-ts/cli.js",
6
6
  "bin": { "mab": "dist/src-ts/cli.js", "agent-bridge": "dist/src-ts/cli.js" },