agent-bridge-aun 1.0.16 → 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.
@@ -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.16", 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.16",
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.16",
3
+ "version": "1.0.17",
4
4
  "type": "channel",
5
5
  "displayName": "AUN 通道",
6
6
  "entry": "dist/src-ts/plugins/aun/index.js",