@napuketto/adapter 0.17.0 → 0.17.1
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/dist/{buddy-req-BvAxJo6d.mjs → buddy-req-BtlTJhYX.mjs} +2 -2
- package/dist/{buddy-req-BvAxJo6d.mjs.map → buddy-req-BtlTJhYX.mjs.map} +1 -1
- package/dist/{index-DBD-IZKn.d.mts → index-B2Hf9yzT.d.mts} +18 -6
- package/dist/{index-DBD-IZKn.d.mts.map → index-B2Hf9yzT.d.mts.map} +1 -1
- package/dist/{index-CepyMhuM.d.mts → index-d_RSpWyb.d.mts} +17 -6
- package/dist/index-d_RSpWyb.d.mts.map +1 -0
- package/dist/index-dsurF2t_.d.mts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -4
- package/dist/kurobot/index.mjs +1 -1
- package/dist/{kurobot-cMBAVX3L.mjs → kurobot-qVM9AdYt.mjs} +2 -2
- package/dist/{kurobot-cMBAVX3L.mjs.map → kurobot-qVM9AdYt.mjs.map} +1 -1
- package/dist/milky/index.d.mts +1 -1
- package/dist/milky/index.mjs +1 -1
- package/dist/{milky-CYAOJLv_.mjs → milky-g7xcz0B5.mjs} +207 -121
- package/dist/milky-g7xcz0B5.mjs.map +1 -0
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +1 -1
- package/dist/{onebot11-BikYDo3k.mjs → onebot11-C_yEFxou.mjs} +189 -101
- package/dist/onebot11-C_yEFxou.mjs.map +1 -0
- package/dist/{raw-message-D5nMIebz.mjs → raw-message-Cs4vDKUU.mjs} +11 -3
- package/dist/raw-message-Cs4vDKUU.mjs.map +1 -0
- package/dist/satori/index.mjs +1 -1
- package/dist/{satori-Cb2uM3PY.mjs → satori-D9t3K5J5.mjs} +18 -7
- package/dist/{satori-Cb2uM3PY.mjs.map → satori-D9t3K5J5.mjs.map} +1 -1
- package/package.json +2 -2
- package/dist/index-CepyMhuM.d.mts.map +0 -1
- package/dist/milky-CYAOJLv_.mjs.map +0 -1
- package/dist/onebot11-BikYDo3k.mjs.map +0 -1
- package/dist/raw-message-D5nMIebz.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as resolveProtocolConfig, i as BaseProtocolAdapter, o as ActionRegistry, s as runAction } from "./core-D8sq68iP.mjs";
|
|
2
2
|
import { a as logEventFailure, i as hasGrayTip, n as findRevokeElement, o as sliceRaw, r as firstUntranslatedGrayTip, t as collectGrayTipUids, u as fileUriToPath } from "./gray-tip-DmZmdtjP.mjs";
|
|
3
|
-
import { a as firstNonEmptyString, c as MS_TO_SEC, d as resolveUin, f as toUin, i as toUnixSeconds, l as NUMERIC_RE, o as stringOrUndefined, r as subscribeRawMessages, s as startupBaselineSec, t as forEachRawMessage, u as numericUin } from "./raw-message-
|
|
4
|
-
import { a as EssenceListSync, c as OBSERVED_UNNAMED_SYSMSG_KEYS, d as processSysMsgBlob, f as recognizeSysMsg, h as varintOf, i as narrowBuddyReqs, l as narrowSysMsgBlobs, m as varintAt, n as batchUnreadNums, o as extractEssenceSetSysMsg, p as textOf, r as filterBuddyReqs, s as narrowEssenceGroupArg, t as BuddyReqDedup, u as nodeAt } from "./buddy-req-
|
|
5
|
-
import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, errorMessage, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
3
|
+
import { a as firstNonEmptyString, c as MS_TO_SEC, d as resolveUin, f as toUin, i as toUnixSeconds, l as NUMERIC_RE, o as stringOrUndefined, r as subscribeRawMessages, s as startupBaselineSec, t as forEachRawMessage, u as numericUin } from "./raw-message-Cs4vDKUU.mjs";
|
|
4
|
+
import { a as EssenceListSync, c as OBSERVED_UNNAMED_SYSMSG_KEYS, d as processSysMsgBlob, f as recognizeSysMsg, h as varintOf, i as narrowBuddyReqs, l as narrowSysMsgBlobs, m as varintAt, n as batchUnreadNums, o as extractEssenceSetSysMsg, p as textOf, r as filterBuddyReqs, s as narrowEssenceGroupArg, t as BuddyReqDedup, u as nodeAt } from "./buddy-req-BtlTJhYX.mjs";
|
|
5
|
+
import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, errorMessage, hasNumberProp, hasStringProp, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
6
6
|
import { HttpClient, HttpServer, createSseResponse, isWsOpen } from "@napuketto/network";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
@@ -1076,6 +1076,10 @@ function notifyToEntity(notify, isFiltered, uidToUin) {
|
|
|
1076
1076
|
return entity;
|
|
1077
1077
|
}
|
|
1078
1078
|
// src/milky/helper/message/segments.ts
|
|
1079
|
+
/** 发送段最小形状守卫(type + data 对象)。 */
|
|
1080
|
+
function isRawOutgoingSegment(val) {
|
|
1081
|
+
return isRecord(val) && hasStringProp(val, "type") && isRecord(val["data"]);
|
|
1082
|
+
}
|
|
1079
1083
|
/** uin 字符串 → Milky user_id(非有限正数 = 转换失败)。 */
|
|
1080
1084
|
function toUserId(uin) {
|
|
1081
1085
|
const n = Number(uin);
|
|
@@ -1128,43 +1132,62 @@ function videoToIncoming(el) {
|
|
|
1128
1132
|
}
|
|
1129
1133
|
};
|
|
1130
1134
|
}
|
|
1131
|
-
/**
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
face: (el) => ({
|
|
1139
|
-
type: "face",
|
|
1140
|
-
data: {
|
|
1141
|
-
face_id: el.id,
|
|
1142
|
-
is_large: false
|
|
1143
|
-
}
|
|
1144
|
-
}),
|
|
1145
|
-
reply: replyToIncoming,
|
|
1146
|
-
image: imageToIncoming,
|
|
1147
|
-
voice: voiceToIncoming,
|
|
1148
|
-
video: videoToIncoming,
|
|
1149
|
-
file: fileToIncoming,
|
|
1150
|
-
json: (el) => ({
|
|
1151
|
-
type: "light_app",
|
|
1152
|
-
data: {
|
|
1153
|
-
app_name: parseAppName(el.raw),
|
|
1154
|
-
json_payload: rawToPayload(el.raw)
|
|
1155
|
-
}
|
|
1156
|
-
}),
|
|
1157
|
-
xml: (el) => ({
|
|
1158
|
-
type: "xml",
|
|
1159
|
-
data: {
|
|
1160
|
-
service_id: 0,
|
|
1161
|
-
xml_payload: rawToPayload(el.raw)
|
|
1162
|
-
}
|
|
1163
|
-
})
|
|
1164
|
-
};
|
|
1135
|
+
/**
|
|
1136
|
+
* canonical → IncomingSegment 单元素分发(可辨识联合 switch)。
|
|
1137
|
+
* 未映射类型(unknown / forward / 规范无对应)→ null(规范兼容性要求跳过)。
|
|
1138
|
+
*
|
|
1139
|
+
* 按「简单段 / 媒体与载荷段」拆两级:一级 switch 只分派,二级各管一类,
|
|
1140
|
+
* 单函数分支数保持低位(fallow 复杂度门禁)。
|
|
1141
|
+
*/
|
|
1165
1142
|
function canonicalToIncomingSegment(el, ctx) {
|
|
1166
|
-
|
|
1167
|
-
|
|
1143
|
+
switch (el.type) {
|
|
1144
|
+
case "at": return atToIncoming(el, ctx);
|
|
1145
|
+
case "reply": return replyToIncoming(el, ctx);
|
|
1146
|
+
case "text":
|
|
1147
|
+
case "face":
|
|
1148
|
+
case "file": return simpleIncoming(el);
|
|
1149
|
+
default: return mediaOrPayloadIncoming(el);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
/** text / face / file 直映射。 */
|
|
1153
|
+
function simpleIncoming(el) {
|
|
1154
|
+
switch (el.type) {
|
|
1155
|
+
case "text": return {
|
|
1156
|
+
type: "text",
|
|
1157
|
+
data: { text: el.text }
|
|
1158
|
+
};
|
|
1159
|
+
case "face": return {
|
|
1160
|
+
type: "face",
|
|
1161
|
+
data: {
|
|
1162
|
+
face_id: el.id,
|
|
1163
|
+
is_large: false
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
case "file": return fileToIncoming(el);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
/** 媒体段(image / voice / video)与载荷段(json / xml)映射;其余返回 null。 */
|
|
1170
|
+
function mediaOrPayloadIncoming(el) {
|
|
1171
|
+
switch (el.type) {
|
|
1172
|
+
case "image": return imageToIncoming(el);
|
|
1173
|
+
case "voice": return voiceToIncoming(el);
|
|
1174
|
+
case "video": return videoToIncoming(el);
|
|
1175
|
+
case "json": return {
|
|
1176
|
+
type: "light_app",
|
|
1177
|
+
data: {
|
|
1178
|
+
app_name: parseAppName(el.raw),
|
|
1179
|
+
json_payload: rawToPayload(el.raw)
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
case "xml": return {
|
|
1183
|
+
type: "xml",
|
|
1184
|
+
data: {
|
|
1185
|
+
service_id: 0,
|
|
1186
|
+
xml_payload: rawToPayload(el.raw)
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
default: return null;
|
|
1190
|
+
}
|
|
1168
1191
|
}
|
|
1169
1192
|
/** canonical at → mention / mention_all(uid→uin 失败跳过该段)。 */
|
|
1170
1193
|
function atToIncoming(el, ctx) {
|
|
@@ -1232,7 +1255,7 @@ function parseAppName(raw) {
|
|
|
1232
1255
|
} catch {
|
|
1233
1256
|
return "";
|
|
1234
1257
|
}
|
|
1235
|
-
if (
|
|
1258
|
+
if (!isRecord(obj)) return "";
|
|
1236
1259
|
const app = obj["app"];
|
|
1237
1260
|
return typeof app === "string" ? app : "";
|
|
1238
1261
|
}
|
|
@@ -1248,74 +1271,23 @@ function rawToPayload(raw) {
|
|
|
1248
1271
|
/**
|
|
1249
1272
|
* OutgoingSegment 数组 → canonical 元素(同步映射;媒体 URI 解析与 at uin→uid
|
|
1250
1273
|
* 由调用方在返回值上继续处理)。
|
|
1251
|
-
*
|
|
1252
|
-
|
|
1253
|
-
*
|
|
1274
|
+
*
|
|
1275
|
+
* 入参兼容 `RawOutgoingSegment`(HTTP 载荷只保证 {type,data} 形状):已知类型的
|
|
1276
|
+
* 必填字段逐项守卫,缺失/类型错误立即抛 INVALID_PARAM;未知 type 按协议跳过。
|
|
1277
|
+
* forward 在此报错:顶层 forward 已由 sendMilkyMessage 分流到组装链(message.ts),
|
|
1278
|
+
* 命中本分支 = forward 与其他段混发漏网或嵌套 forward(组装链内逐项转换经过此处)
|
|
1279
|
+
* ——均显式拒绝。
|
|
1254
1280
|
*/
|
|
1255
1281
|
function outgoingSegmentsToCanonical(segments) {
|
|
1256
1282
|
const elements = [];
|
|
1257
1283
|
const atUins = [];
|
|
1258
1284
|
const replySeqs = [];
|
|
1259
|
-
for (const seg of segments)
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
break;
|
|
1266
|
-
case "mention": {
|
|
1267
|
-
const uin = String(seg.data.user_id);
|
|
1268
|
-
atUins.push(uin);
|
|
1269
|
-
elements.push({
|
|
1270
|
-
type: "at",
|
|
1271
|
-
target: uin
|
|
1272
|
-
});
|
|
1273
|
-
break;
|
|
1274
|
-
}
|
|
1275
|
-
case "mention_all":
|
|
1276
|
-
elements.push({
|
|
1277
|
-
type: "at",
|
|
1278
|
-
target: "all"
|
|
1279
|
-
});
|
|
1280
|
-
break;
|
|
1281
|
-
case "face":
|
|
1282
|
-
elements.push({
|
|
1283
|
-
type: "face",
|
|
1284
|
-
id: seg.data.face_id
|
|
1285
|
-
});
|
|
1286
|
-
break;
|
|
1287
|
-
case "reply":
|
|
1288
|
-
replySeqs.push(seg.data.message_seq);
|
|
1289
|
-
elements.push({
|
|
1290
|
-
type: "reply",
|
|
1291
|
-
messageId: String(seg.data.message_seq)
|
|
1292
|
-
});
|
|
1293
|
-
break;
|
|
1294
|
-
case "image":
|
|
1295
|
-
elements.push({
|
|
1296
|
-
type: "image",
|
|
1297
|
-
path: resolveUriToPathPlaceholder(seg.data.uri)
|
|
1298
|
-
});
|
|
1299
|
-
break;
|
|
1300
|
-
case "record":
|
|
1301
|
-
elements.push({
|
|
1302
|
-
type: "voice",
|
|
1303
|
-
path: resolveUriToPathPlaceholder(seg.data.uri)
|
|
1304
|
-
});
|
|
1305
|
-
break;
|
|
1306
|
-
case "video":
|
|
1307
|
-
elements.push({
|
|
1308
|
-
type: "video",
|
|
1309
|
-
path: resolveUriToPathPlaceholder(seg.data.uri)
|
|
1310
|
-
});
|
|
1311
|
-
break;
|
|
1312
|
-
case "light_app":
|
|
1313
|
-
elements.push({
|
|
1314
|
-
type: "json",
|
|
1315
|
-
raw: seg.data.json_payload
|
|
1316
|
-
});
|
|
1317
|
-
break;
|
|
1318
|
-
case "forward": throw kernelError("forward 段不可与其他消息段混发或嵌套(顶层 forward 须单独发送)", "INVALID_PARAM");
|
|
1285
|
+
for (const seg of segments) {
|
|
1286
|
+
const converted = outgoingSegmentToCanonical(seg);
|
|
1287
|
+
if (converted === null) continue;
|
|
1288
|
+
elements.push(converted.element);
|
|
1289
|
+
if (converted.atUin !== void 0) atUins.push(converted.atUin);
|
|
1290
|
+
if (converted.replySeq !== void 0) replySeqs.push(converted.replySeq);
|
|
1319
1291
|
}
|
|
1320
1292
|
return {
|
|
1321
1293
|
elements,
|
|
@@ -1323,6 +1295,115 @@ function outgoingSegmentsToCanonical(segments) {
|
|
|
1323
1295
|
replySeqs
|
|
1324
1296
|
};
|
|
1325
1297
|
}
|
|
1298
|
+
/** 段 data 收窄(非对象按空对象处理,字段守卫会立即拒绝)。 */
|
|
1299
|
+
function segmentData(seg) {
|
|
1300
|
+
return isRecord(seg.data) ? seg.data : {};
|
|
1301
|
+
}
|
|
1302
|
+
/** 已知段缺必填字段 / 类型错误 → INVALID_PARAM。 */
|
|
1303
|
+
function invalidSegment(type) {
|
|
1304
|
+
throw kernelError(`Milky 消息段 ${type} 参数不合法`, "INVALID_PARAM");
|
|
1305
|
+
}
|
|
1306
|
+
/** text 段(必填 text: string)。 */
|
|
1307
|
+
function textSegment(data) {
|
|
1308
|
+
if (!hasStringProp(data, "text")) return invalidSegment("text");
|
|
1309
|
+
return { element: {
|
|
1310
|
+
type: "text",
|
|
1311
|
+
text: data["text"]
|
|
1312
|
+
} };
|
|
1313
|
+
}
|
|
1314
|
+
/** mention 段(必填 user_id: number)。 */
|
|
1315
|
+
function mentionSegment(data) {
|
|
1316
|
+
if (!hasNumberProp(data, "user_id")) return invalidSegment("mention");
|
|
1317
|
+
const uin = String(data["user_id"]);
|
|
1318
|
+
return {
|
|
1319
|
+
element: {
|
|
1320
|
+
type: "at",
|
|
1321
|
+
target: uin
|
|
1322
|
+
},
|
|
1323
|
+
atUin: uin
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
/** face 段(必填 face_id: string)。 */
|
|
1327
|
+
function faceSegment(data) {
|
|
1328
|
+
if (!hasStringProp(data, "face_id")) return invalidSegment("face");
|
|
1329
|
+
return { element: {
|
|
1330
|
+
type: "face",
|
|
1331
|
+
id: data["face_id"]
|
|
1332
|
+
} };
|
|
1333
|
+
}
|
|
1334
|
+
/** reply 段(必填 message_seq: number)。 */
|
|
1335
|
+
function replySegment(data) {
|
|
1336
|
+
if (!hasNumberProp(data, "message_seq")) return invalidSegment("reply");
|
|
1337
|
+
return {
|
|
1338
|
+
element: {
|
|
1339
|
+
type: "reply",
|
|
1340
|
+
messageId: String(data["message_seq"])
|
|
1341
|
+
},
|
|
1342
|
+
replySeq: data["message_seq"]
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
/** 媒体段(image/record/video,必填 uri: string)。 */
|
|
1346
|
+
function mediaSegment(type, data) {
|
|
1347
|
+
if (!hasStringProp(data, "uri")) return invalidSegment(type);
|
|
1348
|
+
const path = resolveUriToPathPlaceholder(data["uri"]);
|
|
1349
|
+
if (type === "record") return { element: {
|
|
1350
|
+
type: "voice",
|
|
1351
|
+
path
|
|
1352
|
+
} };
|
|
1353
|
+
return { element: {
|
|
1354
|
+
type: type === "image" ? "image" : "video",
|
|
1355
|
+
path
|
|
1356
|
+
} };
|
|
1357
|
+
}
|
|
1358
|
+
/** light_app 段(json_payload 缺省按空串,保持容忍)。 */
|
|
1359
|
+
function lightAppSegment(data) {
|
|
1360
|
+
const payload = data["json_payload"];
|
|
1361
|
+
return { element: {
|
|
1362
|
+
type: "json",
|
|
1363
|
+
raw: typeof payload === "string" ? payload : ""
|
|
1364
|
+
} };
|
|
1365
|
+
}
|
|
1366
|
+
/** 简单段类型判定(字面量联合收窄)。 */
|
|
1367
|
+
function isSimpleOutgoingType(type) {
|
|
1368
|
+
switch (type) {
|
|
1369
|
+
case "text":
|
|
1370
|
+
case "mention":
|
|
1371
|
+
case "mention_all":
|
|
1372
|
+
case "face":
|
|
1373
|
+
case "reply": return true;
|
|
1374
|
+
default: return false;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
/** 简单段分发。 */
|
|
1378
|
+
function simpleOutgoingSegment(type, data) {
|
|
1379
|
+
switch (type) {
|
|
1380
|
+
case "text": return textSegment(data);
|
|
1381
|
+
case "mention": return mentionSegment(data);
|
|
1382
|
+
case "mention_all": return { element: {
|
|
1383
|
+
type: "at",
|
|
1384
|
+
target: "all"
|
|
1385
|
+
} };
|
|
1386
|
+
case "face": return faceSegment(data);
|
|
1387
|
+
case "reply": return replySegment(data);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
/** 复杂段分发(媒体 / light_app / forward / 未知)。 */
|
|
1391
|
+
function complexOutgoingSegment(type, data) {
|
|
1392
|
+
switch (type) {
|
|
1393
|
+
case "image": return mediaSegment("image", data);
|
|
1394
|
+
case "record": return mediaSegment("record", data);
|
|
1395
|
+
case "video": return mediaSegment("video", data);
|
|
1396
|
+
case "light_app": return lightAppSegment(data);
|
|
1397
|
+
case "forward": throw kernelError("forward 段不可与其他消息段混发或嵌套(顶层 forward 须单独发送)", "INVALID_PARAM");
|
|
1398
|
+
default: return null;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
/** 单段分派入口(简单段 / 复杂段两级,避免单函数分支过多)。 */
|
|
1402
|
+
function outgoingSegmentToCanonical(seg) {
|
|
1403
|
+
const data = segmentData(seg);
|
|
1404
|
+
if (isSimpleOutgoingType(seg.type)) return simpleOutgoingSegment(seg.type, data);
|
|
1405
|
+
return complexOutgoingSegment(seg.type, data);
|
|
1406
|
+
}
|
|
1326
1407
|
/**
|
|
1327
1408
|
* 媒体 URI → 本地路径(同步面:file:// / 裸路径直接给 canonical;base64:// 与
|
|
1328
1409
|
* http(s):// 需要异步落盘,由 send 核心在 canonical 上二次解析——此处先放原始
|
|
@@ -1699,7 +1780,9 @@ async function recallBySeq(peer, seq, api) {
|
|
|
1699
1780
|
// src/milky/action/message-send.ts
|
|
1700
1781
|
/**
|
|
1701
1782
|
* OutgoingSegment 宽松校验:入口只保证「{type, data}」形状,字段级转换在
|
|
1702
|
-
* outgoingSegmentsToCanonical
|
|
1783
|
+
* outgoingSegmentsToCanonical 内做(已知段缺字段抛 INVALID_PARAM,未知段跳过)。
|
|
1784
|
+
* 类型标注直接写 RawOutgoingSegment——不再把「只保证 {type,data} 的入口值」
|
|
1785
|
+
* 谎称成完整的 OutgoingSegment:入口本就不保证字段,校验后的形状必须诚实。
|
|
1703
1786
|
*/
|
|
1704
1787
|
const outgoingSegmentSchema = z.object({
|
|
1705
1788
|
type: z.string(),
|
|
@@ -1751,7 +1834,7 @@ async function sendForwardComposition(peer, segments, api) {
|
|
|
1751
1834
|
if (segments.length !== 1) throw kernelError("forward 段必须单独发送(不支持与其他消息段混发)", "INVALID_PARAM");
|
|
1752
1835
|
const [forward] = segments;
|
|
1753
1836
|
if (forward === void 0 || forward.type !== "forward") throw kernelError("forward 组装链收到非 forward 段", "UNKNOWN");
|
|
1754
|
-
const messages = narrowForwardMessages(forward);
|
|
1837
|
+
const messages = narrowForwardMessages(forward.data);
|
|
1755
1838
|
const srcMsgIds = [];
|
|
1756
1839
|
for (const [i, item] of messages.entries()) {
|
|
1757
1840
|
const { elements, atUins } = outgoingSegmentsToCanonical(item.segments);
|
|
@@ -1766,18 +1849,24 @@ async function sendForwardComposition(peer, segments, api) {
|
|
|
1766
1849
|
}
|
|
1767
1850
|
/**
|
|
1768
1851
|
* forward 段载荷收窄(入口 schema 只保证 data 为 record):messages 非空数组,
|
|
1769
|
-
* 项内 segments
|
|
1770
|
-
*
|
|
1852
|
+
* 项内 segments 非空数组且**每个元素**都是 {type, data} 对象。user_id /
|
|
1853
|
+
* sender_name / time 不参与组装不校验(丢弃字段不设门槛);title / preview /
|
|
1854
|
+
* summary / prompt 忽略。
|
|
1771
1855
|
*/
|
|
1772
|
-
function narrowForwardMessages(
|
|
1773
|
-
const raw =
|
|
1856
|
+
function narrowForwardMessages(data) {
|
|
1857
|
+
const raw = data["messages"];
|
|
1774
1858
|
if (!Array.isArray(raw) || raw.length === 0) throw kernelError("forward 段 messages 必须是非空数组", "INVALID_PARAM");
|
|
1775
1859
|
const out = [];
|
|
1776
1860
|
for (const item of raw) {
|
|
1777
|
-
if (
|
|
1778
|
-
const segments = item
|
|
1861
|
+
if (!isRecord(item)) throw kernelError("forward 段 messages 项必须是对象", "INVALID_PARAM");
|
|
1862
|
+
const segments = item["segments"];
|
|
1779
1863
|
if (!Array.isArray(segments) || segments.length === 0) throw kernelError("forward 段 messages 项的 segments 必须是非空数组", "INVALID_PARAM");
|
|
1780
|
-
|
|
1864
|
+
const narrowed = [];
|
|
1865
|
+
for (const segment of segments) {
|
|
1866
|
+
if (!isRawOutgoingSegment(segment)) throw kernelError("forward 段内嵌 segment 必须是包含 type 与 data 的对象", "INVALID_PARAM");
|
|
1867
|
+
narrowed.push(segment);
|
|
1868
|
+
}
|
|
1869
|
+
out.push({ segments: narrowed });
|
|
1781
1870
|
}
|
|
1782
1871
|
return out;
|
|
1783
1872
|
}
|
|
@@ -1820,18 +1909,15 @@ async function resolveElement(el, uinToUid, api) {
|
|
|
1820
1909
|
...el,
|
|
1821
1910
|
target: uinToUid?.get(el.target) ?? el.target
|
|
1822
1911
|
};
|
|
1823
|
-
if (isRemoteMediaUri(el)) {
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
path: await resolveMediaUri(media.path, api.mediaDir)
|
|
1828
|
-
};
|
|
1829
|
-
}
|
|
1912
|
+
if ((el.type === "image" || el.type === "voice" || el.type === "video") && isRemoteMediaUri(el)) return {
|
|
1913
|
+
...el,
|
|
1914
|
+
path: await resolveMediaUri(el.path, api.mediaDir)
|
|
1915
|
+
};
|
|
1830
1916
|
return el;
|
|
1831
1917
|
}
|
|
1832
1918
|
/** 远程媒体元素(image/voice/video 且 path 为需落盘的 URI)。 */
|
|
1833
1919
|
function isRemoteMediaUri(el) {
|
|
1834
|
-
return
|
|
1920
|
+
return el.path.startsWith("http://") || el.path.startsWith("https://") || el.path.startsWith("base64://");
|
|
1835
1921
|
}
|
|
1836
1922
|
// src/milky/action/profile.ts
|
|
1837
1923
|
/**
|
|
@@ -3320,4 +3406,4 @@ var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
|
|
|
3320
3406
|
};
|
|
3321
3407
|
export { MilkyApi as a, createMilkyActionRegistry as i, assembleMilkyTransports as n, milkyErrorCodeMap as o, milkyConfigSchema as r, NapukettoMilkyAdapter as t };
|
|
3322
3408
|
|
|
3323
|
-
//# sourceMappingURL=milky-
|
|
3409
|
+
//# sourceMappingURL=milky-g7xcz0B5.mjs.map
|