agent-bridge-aun 1.0.39 → 1.0.41
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 +2 -0
- package/config.schema.json +1 -1
- package/dist/src-ts/plugins/aun/index.js +9 -3
- package/dist/src-ts/plugins/aun/messages.js +1 -1
- package/dist/src-ts/plugins/aun/public/app.js +2 -1
- package/dist/src-ts/plugins/aun/public/index.html +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
`agent-bridge-aun` 为 mu-agent-bridge 提供 AUN 消息通道,支持使用已有 AID 或通过管理 API 注册 AID,并将收到的文本交给指定 Agent 插件处理。
|
|
4
4
|
|
|
5
|
+
来源白名单默认留空,表示接受所有 AUN Peer。需要限制来源时,可在 ABWeb 的 AUN 通道设置中填写一个或多个 AID,并用英文逗号分隔;清空白名单也会恢复接受所有 Peer。
|
|
6
|
+
|
|
5
7
|
安装后在 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"}`。
|
|
6
8
|
|
|
7
9
|
创建使用 SDK 的兼容注册流程;Owner AID 只保存为本地归属配置,不代表 AUN 协议 Owner 关系已签名或激活。Gateway 信任根使用随插件提供并校验指纹的 AUN 根证书,不从 Gateway 下载未经验证的 CA 链。
|
package/config.schema.json
CHANGED
|
@@ -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
|
|
@@ -13,7 +13,7 @@ const evolcore_1 = require("./evolcore");
|
|
|
13
13
|
const messages_1 = require("./messages");
|
|
14
14
|
const attachments_1 = require("./attachments");
|
|
15
15
|
const manifest = {
|
|
16
|
-
id: "aun", version: "1.0.
|
|
16
|
+
id: "aun", version: "1.0.41", type: "channel", displayName: "AUN 通道",
|
|
17
17
|
entry: "dist/src-ts/plugins/aun/index.js", apiVersion: "1", process: "in-process",
|
|
18
18
|
capabilities: ["channel", "channel.identity.create", "channel.receive", "channel.send", "health", "cli"],
|
|
19
19
|
configSchema: "config.schema.json",
|
|
@@ -959,7 +959,8 @@ class AunPlugin {
|
|
|
959
959
|
channel: "aun", recipientId: aid, peerId: message.peerId, messageId: message.messageId, text: message.text, threadId: message.threadId,
|
|
960
960
|
...(attachments.length ? { attachments } : {}),
|
|
961
961
|
agentPlugin,
|
|
962
|
-
reply: async (text) => {
|
|
962
|
+
reply: async (text, signal) => {
|
|
963
|
+
signal?.throwIfAborted();
|
|
963
964
|
if (!text.trim())
|
|
964
965
|
return;
|
|
965
966
|
try {
|
|
@@ -971,7 +972,8 @@ class AunPlugin {
|
|
|
971
972
|
throw new agent_1.AgentOperationError("AUN_TEXT_SEND_FAILED", "发送 AUN 文本消息(结果未确认,不自动重发)", error);
|
|
972
973
|
}
|
|
973
974
|
},
|
|
974
|
-
replyAttachments: async (items, text) => {
|
|
975
|
+
replyAttachments: async (items, text, signal) => {
|
|
976
|
+
signal?.throwIfAborted();
|
|
975
977
|
if (!items.length)
|
|
976
978
|
return;
|
|
977
979
|
let sent = 0;
|
|
@@ -983,6 +985,7 @@ class AunPlugin {
|
|
|
983
985
|
if (!client?.storage)
|
|
984
986
|
throw new Error("AUN SDK 不支持附件存储接口");
|
|
985
987
|
const refs = uploadedRefs && uploadedItems === items ? uploadedRefs : await (0, attachments_1.uploadAunAttachments)({ storage: client.storage }, aid, message.peerId, items);
|
|
988
|
+
signal?.throwIfAborted();
|
|
986
989
|
this.context?.logger.info("AUN FS 标准附件上传完成", { ...trace, stage: "上传附件", files: items.map(item => ({ filename: item.filename, sizeBytes: item.data.byteLength })) });
|
|
987
990
|
if (!uploadedRefs || uploadedItems !== items) {
|
|
988
991
|
uploadedItems = items;
|
|
@@ -997,6 +1000,7 @@ class AunPlugin {
|
|
|
997
1000
|
}
|
|
998
1001
|
groupsCount = groups.size;
|
|
999
1002
|
for (const [kind, group] of groups) {
|
|
1003
|
+
signal?.throwIfAborted();
|
|
1000
1004
|
const payloadText = withAttachmentDownloadLinks(text || (kind === "image" ? "图片已生成。" : kind === "video" ? "视频已生成。" : "文件已生成。"), kind, group);
|
|
1001
1005
|
// AUN 网页会隐藏带普通正文的单图卡片,图片说明需另发文本。
|
|
1002
1006
|
const payload = { type: kind, ...(kind === "image" ? {} : { text: payloadText }), attachments: group };
|
|
@@ -1016,6 +1020,7 @@ class AunPlugin {
|
|
|
1016
1020
|
sent++;
|
|
1017
1021
|
if (kind === "image" && payloadText) {
|
|
1018
1022
|
try {
|
|
1023
|
+
signal?.throwIfAborted();
|
|
1019
1024
|
const { attachments: _attachments, ...caption } = payload;
|
|
1020
1025
|
const result = await this.callAunWithRecovery(aid, { to: message.peerId, payload: { ...caption, type: "text", text: payloadText }, encrypt: true });
|
|
1021
1026
|
if (typeof result?.status !== "string" || !successfulSendStatuses.has(result.status))
|
|
@@ -1029,6 +1034,7 @@ class AunPlugin {
|
|
|
1029
1034
|
}
|
|
1030
1035
|
}
|
|
1031
1036
|
catch (error) {
|
|
1037
|
+
signal?.throwIfAborted();
|
|
1032
1038
|
deliveryFailed = true;
|
|
1033
1039
|
const failure = sending ? new agent_1.AgentOperationError("AUN_ATTACHMENT_SEND_FAILED", "发送 AUN 附件消息(FS 上传已完成)", error) : error;
|
|
1034
1040
|
const progress = sending ? `(已确认发送 ${sent}/${groupsCount} 组,当前组结果未确认,请勿重复发送)` : "";
|
|
@@ -10,7 +10,7 @@ function normalizeAunMessage(payload, selfAid, allowFrom) {
|
|
|
10
10
|
const data = payload;
|
|
11
11
|
const peerId = typeof data.from === "string" ? data.from.trim() : "";
|
|
12
12
|
const rules = (allowFrom ?? "").split(",").map((value) => value.trim()).filter(Boolean);
|
|
13
|
-
if (!peerId || peerId === selfAid || (rules.length > 0 && !rules.includes(peerId)))
|
|
13
|
+
if (!peerId || peerId === selfAid || (rules.length > 0 && !rules.includes("*") && !rules.includes(peerId)))
|
|
14
14
|
return undefined;
|
|
15
15
|
const body = data.payload && typeof data.payload === "object" ? data.payload : {};
|
|
16
16
|
// 对端的系统事件只作通知,转为任务回复会导致两个 Agent 循环互答。
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
agents = (plugins.plugins || []).filter((plugin) => plugin.type === "agent");
|
|
30
30
|
if (refreshForm) createForm.elements.ownerAid.value = config.owner_aid || "";
|
|
31
31
|
if (refreshForm) {
|
|
32
|
-
|
|
32
|
+
configForm.elements.allow_from.value = config.allow_from?.split(",").some(value => value.trim() === "*") ? "" : config.allow_from || "";
|
|
33
|
+
configForm.elements.aun_path.value = config.aun_path || "";
|
|
33
34
|
configForm.elements.encryption_seed.value = "";
|
|
34
35
|
}
|
|
35
36
|
list.replaceChildren();
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<p id="status" role="status"></p>
|
|
8
8
|
<div class="table-scroll"><table><thead><tr><th>AID</th><th>来源</th><th>已关联 Agent</th><th>操作</th></tr></thead><tbody id="identities"></tbody></table></div>
|
|
9
9
|
<form id="create-form"><h2>创建 AID</h2><div class="fields"><label>新 AID<input name="aid" required placeholder="例如:example.agentid.cn"></label><label>Owner AID<input name="ownerAid" placeholder="例如:owner.agentid.cn"><small class="hint">留空时使用已配置的默认 Owner;未配置时需填写。Owner 保存为本地归属配置;不代表 AUN 协议中的 Owner 关系已激活。</small></label></div><button type="submit">创建</button></form>
|
|
10
|
-
<form id="config-form"><h2>通道配置</h2><div class="fields"><label>允许的来源<input name="allow_from"></label><label>AUN 存储路径<input name="aun_path"></label><label>加密种子<input name="encryption_seed" type="password" autocomplete="new-password" placeholder="留空则不修改"></label></div><button type="submit">保存配置</button></form>
|
|
10
|
+
<form id="config-form"><h2>通道配置</h2><div class="fields"><label>允许的来源<input name="allow_from" placeholder="留空接受所有 Peer,填写 AID 后限制"></label><label>AUN 存储路径<input name="aun_path"></label><label>加密种子<input name="encryption_seed" type="password" autocomplete="new-password" placeholder="留空则不修改"></label></div><button type="submit">保存配置</button></form>
|
|
11
11
|
</main>
|
|
12
12
|
<script src="/abweb/channels/aun/app.js"></script>
|
|
13
13
|
</body>
|
package/package.json
CHANGED