agent-bridge-aun 1.0.15 → 1.0.17

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/README.md CHANGED
@@ -7,3 +7,5 @@
7
7
  该插件依赖 `@agentunion/fastaun`,要求 Node.js 22.16 或更高版本。
8
8
 
9
9
  ABWeb 的 AUN 设置只展示已连接 AID,并按来源分组。插件通过 SDK 密钥库枚举 AID,再逐个建立连接;只有连接成功的身份才会显示。EvolCore 来源身份只用于连接状态检测,不订阅消息,避免重复收信;本工程创建的身份负责消息收发。连接状态检测不调用 `ec agent list/show`。将 EvolCore 身份关联到 Agent 时仍使用既有 `ec agent set/reload` 路由配置,该配置不参与连接状态检测。列表先显示已关联 Agent 的身份,各组按最近成功关联的时间倒序排列,时间相同或旧记录没有时间时按 AID 名称排序。关联时间保存在插件配置的 `binding_times` 中,刷新或重启后保留;旧记录不补造时间,再次关联成功后开始记录。
10
+
11
+ AUN 独立包支持核心后台每五分钟检测更新;可信提供者在自动安装策略下会下载新副本并重载通道。
@@ -10,7 +10,7 @@ const node_url_1 = require("node:url");
10
10
  const messages_1 = require("./messages");
11
11
  const evolcore_1 = require("./evolcore");
12
12
  const manifest = {
13
- id: "aun", version: "1.0.15", type: "channel", displayName: "AUN 通道",
13
+ id: "aun", version: "1.0.17", type: "channel", displayName: "AUN 通道",
14
14
  entry: "dist/src-ts/plugins/aun/index.js", apiVersion: "1", process: "in-process",
15
15
  capabilities: ["channel", "channel.identity.create", "channel.receive", "channel.send", "health"],
16
16
  configSchema: "config.schema.json",
@@ -87,9 +87,8 @@ class AunPlugin {
87
87
  await this.persist();
88
88
  this.context?.logger.info("AUN 身份已创建", { aid, owner });
89
89
  }
90
- if (!this.clients.has(aid))
91
- await this.connectAid(aid);
92
- return { aid, status: "已创建", connection: this.clients.has(aid) ? "ready" : "degraded" };
90
+ const connectionError = !this.clients.has(aid) ? await this.connectAid(aid) : undefined;
91
+ return { aid, status: "已创建", connection: this.clients.has(aid) ? "ready" : "degraded", ...(connectionError ? { connectionError } : {}) };
93
92
  }
94
93
  finally {
95
94
  this.creating = false;
@@ -244,7 +243,8 @@ class AunPlugin {
244
243
  catch (error) {
245
244
  this.status = "degraded";
246
245
  this.healthMessage = safeError(error);
247
- this.context?.logger.warn("AUN 通道连接失败", { error: this.healthMessage });
246
+ this.context?.logger.warn("AUN 通道连接失败", { aid, error: this.healthMessage });
247
+ return this.healthMessage;
248
248
  }
249
249
  }
250
250
  async deactivate(_reason) {
@@ -15,6 +15,12 @@
15
15
  return result;
16
16
  }
17
17
  function show(message, failed = false) { status.textContent = message; status.className = failed ? "error" : ""; }
18
+ function notify(title, message, failed = false) {
19
+ show(message, failed);
20
+ if (window.parent !== window) window.parent.postMessage({ type: "mab:operation-result", title, message, failed }, window.location.origin);
21
+ else window.alert(`${title}\n${message}`);
22
+ }
23
+ const errorMessage = (error) => error instanceof Error ? error.message : String(error);
18
24
  async function load(refreshForm = true) {
19
25
  if (loading) return;
20
26
  loading = true;
@@ -50,15 +56,22 @@
50
56
  async function bind(aid, pluginId) {
51
57
  try {
52
58
  await request(`/api/plugins/${encodeURIComponent(pluginId)}/aid`, "PATCH", { aid });
53
- await load(); show(`${aid} 已关联 ${pluginId}`);
54
- } catch (error) { show(`关联失败:${String(error)}`, true); }
59
+ await load(); notify("关联成功", `${aid} 已关联 ${pluginId}`);
60
+ } catch (error) { notify("关联失败", errorMessage(error), true); }
55
61
  }
56
62
  createForm.onsubmit = (event) => { event.preventDefault(); const aid = createForm.elements.aid.value.trim(); const owner = createForm.elements.ownerAid.value.trim();
57
- void request("/api/plugins/aun/aid", "POST", { aid, ownerAid: owner }).then((result) => load().then(() => show(result.status === "等待 Owner 确认" ? `${aid} 等待 Owner 确认` : `${aid} 已创建`))).catch((error) => show(String(error), true));
63
+ show("正在创建 AID 并连接,请稍候……");
64
+ void request("/api/plugins/aun/aid", "POST", { aid, ownerAid: owner }).then((result) => {
65
+ const failed = result.connection === "degraded";
66
+ const message = failed ? `${aid} 已创建,但连接失败:${result.connectionError || "未提供连接失败原因,请查看运行日志"}\n身份已经保存在本地,请勿重复注册。`
67
+ : result.status === "等待 Owner 确认" ? `${aid} 等待 Owner 确认` : `${aid} 已创建并连接`;
68
+ notify(failed ? "AID 创建完成,连接失败" : "AID 创建结果", message, failed);
69
+ return load();
70
+ }).catch((error) => notify("创建 AID 失败", errorMessage(error), true));
58
71
  };
59
72
  configForm.onsubmit = (event) => { event.preventDefault(); const changes = { agent_plugin: configForm.elements.agent_plugin.value, allow_from: configForm.elements.allow_from.value, aun_path: configForm.elements.aun_path.value };
60
73
  if (configForm.elements.encryption_seed.value) changes.encryption_seed = configForm.elements.encryption_seed.value;
61
- void request("/api/plugins/aun/settings", "POST", changes).then(() => request("/api/plugins/aun/reload", "POST")).then(() => load()).then(() => show("配置已保存")).catch((error) => show(String(error), true));
74
+ void request("/api/plugins/aun/settings", "POST", changes).then(() => request("/api/plugins/aun/reload", "POST")).then(() => load()).then(() => notify("保存成功", "配置已保存")).catch((error) => notify("保存配置失败", errorMessage(error), true));
62
75
  };
63
76
  find("#refresh").onclick = () => void load();
64
77
  void load();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-bridge-aun",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "mu-agent-bridge 的 AUN 通道插件。",
5
5
  "keywords": [
6
6
  "mu-agent-bridge-plugin",
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "aun",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "type": "channel",
5
5
  "displayName": "AUN 通道",
6
6
  "entry": "dist/src-ts/plugins/aun/index.js",