agent-bridge-aun 1.0.49 → 1.0.50

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
@@ -23,7 +23,7 @@ mab aun repair-old-aids --json
23
23
 
24
24
  安装后在 ABWeb 的插件管理中启动 AUN 通道。收到的 AID 消息仅投递给用户在 AUN 身份页中明确关联的 Agent;未关联的 AID 消息会被忽略。旧配置中的 `agent_plugin` 字段不再作为默认路由。配置字段 `owner_aid` 是可选字符串,用作默认 Owner。AID 创建接口为 `POST /api/plugins/aun/aid`,请求内容为 `{"aid":"新AID.agentid.cn","owner_aid":"所有者AID.agentid.cn"}`。
25
25
 
26
- 创建调用 SDK 0.5.31 的 `register(aid, { type: "agent", owner })`。注册、连接成功与 Owner 双边共识是不同状态;Owner 声明仍可能为 `single_sided/pending`,不能把“已创建”解释为归属已激活。创建后尝试把新 AID 加入 Owner 名录,默认 `allow_pa_use: true`;只有本地拥有 Owner 私钥且 Storage 可用时才能同步,失败通过 `directorySync` 单独返回。Gateway 信任根使用随插件提供并校验指纹的 AUN 根证书,不从 Gateway 下载未经验证的 CA 链。
26
+ 创建调用 SDK 0.5.31 的 `register(aid, { type: "agent", owner })`。注册、连接成功与 Owner 双边共识是不同状态;Owner 声明仍可能为 `single_sided/pending`,不能把“已创建”解释为归属已激活。创建后先读取新鲜签名归属;关联请求已送达但 Owner 尚未确认时,接口返回 `202`、`status: "等待 Owner 确认"`,页面和 CLI 仅给普通提醒,日志为 `info`,不重复注册或发送邀请,也不尝试用 Owner 公钥登录。仅共识成立后尝试把新 AID 加入 Owner 名录,默认 `allow_pa_use: true`;只有本地拥有 Owner 私钥且 Storage 可用时才能同步,失败通过 `directorySync` 单独返回。Gateway 信任根使用随插件提供并校验指纹的 AUN 根证书,不从 Gateway 下载未经验证的 CA 链。
27
27
 
28
28
  核心支持插件命令后,可运行 `mab aun status`、`mab aun list`、`mab aun agents`、`mab aun default-owner`、`mab aun default-owner set <owner-aid>`、`mab aun create <aid> [--owner <owner-aid>] [--agent <plugin-id>]`、`mab aun bind <aid> <plugin-id>` 和 `mab aun unbind <aid>`。关联或解绑只修改指定 AID,不会影响同一 Agent 下的其它 AID,也不会写入 Agent 全局 AID 配置。`default-owner` 不带参数显示当前配置,`default-owner set <owner-aid>` 校验格式并持久化新的默认值。`create` 明确传入 `--owner` 时优先使用该值;省略时回退到同一配置中的 `owner_aid`,两者都没有时返回错误,不会创建 AID。创建新身份时,实际使用的 Owner 会保存为下次默认值。ABWeb 从同一插件配置读取 `owner_aid` 并预填创建表单,因此 CLI 和 ABWeb 共用默认 Owner。Agent 从当前已就绪的插件动态发现。创建后连接或关联失败时,响应会标明 AID 已创建;先用 `mab aun list` 检查,不要重试创建。运行日志不记录原始参数或 Owner AID;默认 Owner 查询会在终端显示当前值。
29
29
 
@@ -31,7 +31,7 @@ const ownership_1 = require("./ownership");
31
31
  const sdk_loader_1 = require("./sdk-loader");
32
32
  const owned_profiles_1 = require("./owned-profiles");
33
33
  const manifest = {
34
- id: "aun", version: "1.0.49", type: "channel", displayName: "AUN 通道",
34
+ id: "aun", version: "1.0.50", type: "channel", displayName: "AUN 通道",
35
35
  entry: "dist/src-ts/plugins/aun/index.js", apiVersion: "1", process: "in-process",
36
36
  capabilities: ["channel", "channel.identity.create", "channel.receive", "channel.send", "health", "cli"],
37
37
  configSchema: "config.schema.json",
@@ -332,6 +332,7 @@ class AunPlugin {
332
332
  this.context?.logger.info("AUN 身份已创建", { aid });
333
333
  }
334
334
  const connectionError = !this.clients.has(aid) ? await this.connectAid(aid) : undefined;
335
+ let status = "已创建";
335
336
  let directorySync;
336
337
  try {
337
338
  await this.syncOwnerDirectory(aid, owner);
@@ -339,10 +340,17 @@ class AunPlugin {
339
340
  this.context?.logger.info("AUN 新 AID 已加入 Owner 名录", { aid });
340
341
  }
341
342
  catch (error) {
342
- directorySync = { status: "not_synced", error: safeError(error) };
343
- this.context?.logger.warn("AUN AID 已创建,但 Owner 名录未同步", { aid, error: directorySync.error });
343
+ if (error instanceof fs_1.AunFsError && error.code === "OWNERSHIP_PENDING") {
344
+ status = "等待 Owner 确认";
345
+ directorySync = { status: "not_synced" };
346
+ this.context?.logger.info("AUN AID 已创建并连接,关联请求已发送,等待 Owner 确认", { aid });
347
+ }
348
+ else {
349
+ directorySync = { status: "not_synced", error: safeError(error) };
350
+ this.context?.logger.warn("AUN AID 已创建,但 Owner 名录未同步", { aid, error: directorySync.error });
351
+ }
344
352
  }
345
- return { aid, status: "已创建", connection: this.clients.has(aid) ? "ready" : "degraded", ...(connectionError ? { connectionError } : {}), directorySync };
353
+ return { aid, status, connection: this.clients.has(aid) ? "ready" : "degraded", ...(connectionError ? { connectionError } : {}), directorySync };
346
354
  }
347
355
  finally {
348
356
  this.creating = false;
@@ -464,12 +472,25 @@ class AunPlugin {
464
472
  async syncOwnerDirectory(aid, ownerAid) {
465
473
  if (aid === ownerAid)
466
474
  throw new Error("新 AID 与 Owner AID 相同,未写入 Owner 名录");
475
+ const subClient = this.clients.get(aid)?.client;
476
+ if (this.store?.resolve && subClient?.checkOwnershipConsensus) {
477
+ const verified = await (0, ownership_1.readAunOwnership)(this.store, subClient, aid);
478
+ if (verified.declaredOwner !== ownerAid)
479
+ throw new fs_1.AunFsError("OWNERSHIP_CONFLICT", "指定 Owner 与已验签的现有 Owner 不同,未同步名录");
480
+ if (verified.ownership.status === "single_sided")
481
+ throw new fs_1.AunFsError("OWNERSHIP_PENDING", "关联请求已发送,等待 Owner 确认;确认前暂不加入通信名录,请勿重复创建 AID");
482
+ if (verified.ownership.status !== "consensus")
483
+ throw new fs_1.AunFsError("OWNERSHIP_UNAVAILABLE", `Owner 归属尚未核验完成(${verified.ownership.status}),未同步名录`);
484
+ }
467
485
  let client = this.ownerClients.get(ownerAid)?.client ?? this.clients.get(ownerAid)?.client;
468
486
  let temporary = false;
469
487
  if (!client) {
470
488
  const loaded = this.store?.load(ownerAid);
471
489
  if (!loaded?.ok || !loaded.data)
472
490
  throw new Error("Owner AID 不在本地密钥库,AID 已创建但无法同步 Owner 名录");
491
+ // SDK load() 成功也可能只有公钥证书;list() 只返回持有有效私钥的身份。
492
+ if (!this.listStoreAids().includes(ownerAid))
493
+ throw new Error("本机没有 Owner 的有效私钥,AID 已创建但无法在本机同步 Owner 名录");
473
494
  await this.prepareTrustRoots(ownerAid);
474
495
  const trusted = this.store?.load(ownerAid);
475
496
  if (!trusted?.ok || !trusted.data)
@@ -1618,8 +1639,8 @@ class AunPlugin {
1618
1639
  let task;
1619
1640
  let operationError;
1620
1641
  if (verified.ownership.status !== "consensus") {
1621
- const local = this.store?.load(ownerAid);
1622
- const connectedOwner = this.clients.get(ownerAid)?.client;
1642
+ const local = this.listStoreAids().includes(ownerAid) ? this.store?.load(ownerAid) : undefined;
1643
+ const connectedOwner = this.ownerClients.get(ownerAid)?.client ?? this.clients.get(ownerAid)?.client;
1623
1644
  let temporary;
1624
1645
  try {
1625
1646
  if (connectedOwner || local?.ok && local.data) {
@@ -1766,7 +1787,7 @@ class AunPlugin {
1766
1787
  await this.requireAgent(agent);
1767
1788
  }
1768
1789
  const created = await this.createIdentity(aid, owner);
1769
- const data = { created: true, aid, connection: created.connection ?? "ready", directorySync: created.directorySync };
1790
+ const data = { created: true, aid, connection: created.connection ?? "ready", directorySync: created.directorySync, ...(created.status === "等待 Owner 确认" ? { status: created.status } : {}) };
1770
1791
  if (created.connection !== "ready")
1771
1792
  throw new AunCommandError("AID 已创建,但连接失败;请先执行 mab aun list 确认,不要重试创建", 502, { ...data, connectionError: created.connectionError });
1772
1793
  if (agent) {
@@ -1779,9 +1800,10 @@ class AunPlugin {
1779
1800
  }
1780
1801
  }
1781
1802
  return {
1782
- message: created.directorySync?.status === "not_synced"
1783
- ? `AID 已创建${agent ? `并关联到 ${agent}` : "并连接"},但 Owner 名录未同步:${created.directorySync.error ?? "原因未知"}`
1784
- : agent ? `AID 已创建并关联到 ${agent}` : "AID 已创建并连接",
1803
+ message: created.status === "等待 Owner 确认" ? `AID 已创建并连接${agent ? `并关联到 ${agent}` : ""},关联请求已发送,等待 Owner 确认`
1804
+ : created.directorySync?.status === "not_synced"
1805
+ ? `AID 已创建${agent ? `并关联到 ${agent}` : "并连接"},但 Owner 名录未同步:${created.directorySync.error ?? "原因未知"}`
1806
+ : agent ? `AID 已创建并关联到 ${agent}` : "AID 已创建并连接",
1785
1807
  data: { ...data, ...(agent ? { agent } : {}) },
1786
1808
  };
1787
1809
  }
@@ -73,14 +73,16 @@
73
73
  show("正在创建 AID 并连接,请稍候……");
74
74
  void request("/api/plugins/aun/aid", "POST", { aid, ownerAid: owner }).then((result) => {
75
75
  const failed = result.connection === "degraded";
76
- const directoryFailed = result.directorySync?.status === "not_synced";
76
+ const pending = result.status === "等待 Owner 确认";
77
+ const directoryFailed = !pending && result.directorySync?.status === "not_synced";
77
78
  const message = [
78
79
  failed ? `${aid} 已创建,但连接失败:${result.connectionError || "未提供连接失败原因,请查看运行日志"}\n身份已经保存在本地,请勿重复注册。`
79
- : result.status === "等待 Owner 确认" ? `${aid} 等待 Owner 确认` : `${aid} 已创建并连接`,
80
- directoryFailed ? `Owner 名录未同步:${result.directorySync.error || "原因未知"}`
80
+ : `${aid} 已创建并连接`,
81
+ pending ? "关联请求已发送,等待 Owner 确认;确认前暂不加入通信名录,请勿重复创建 AID。"
82
+ : directoryFailed ? `Owner 名录未同步:${result.directorySync.error || "原因未知"}`
81
83
  : result.directorySync?.status === "synced" ? "已加入 Owner 名录,个人助理可按默认权限使用该联系人。" : "Owner 名录同步状态未知,请查看运行日志。",
82
84
  ].join("\n");
83
- notify(failed || directoryFailed ? "AID 创建完成,部分步骤失败" : "AID 创建结果", message, failed || directoryFailed);
85
+ notify(failed || directoryFailed ? "AID 创建完成,部分步骤失败" : pending ? "等待 Owner 确认" : "AID 创建结果", message, failed || directoryFailed);
84
86
  return load();
85
87
  }).catch((error) => notify("创建 AID 失败", errorMessage(error), true));
86
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-bridge-aun",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
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.49",
3
+ "version": "1.0.50",
4
4
  "type": "channel",
5
5
  "displayName": "AUN 通道",
6
6
  "entry": "dist/src-ts/plugins/aun/index.js",