@searchfe/openclaw-baiduapp 0.1.7-beta.4 → 0.1.7-beta.6
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/index.js +18 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4760,12 +4760,16 @@ async function uploadLocalFileToBos(options, deps = {}) {
|
|
|
4760
4760
|
const uploadOptions = options.contentType?.trim() ? {
|
|
4761
4761
|
"Content-Type": options.contentType.trim()
|
|
4762
4762
|
} : void 0;
|
|
4763
|
-
|
|
4763
|
+
const [, fileStat] = await Promise.all([
|
|
4764
|
+
client.putObjectFromFile(credentials.bucketName, key, localFile, uploadOptions),
|
|
4765
|
+
fs2.stat(localFile)
|
|
4766
|
+
]);
|
|
4764
4767
|
return {
|
|
4765
4768
|
bucketName: credentials.bucketName,
|
|
4766
4769
|
key,
|
|
4767
4770
|
url: client.generateUrl(credentials.bucketName, key),
|
|
4768
|
-
fileName: sanitizedFileName
|
|
4771
|
+
fileName: sanitizedFileName,
|
|
4772
|
+
fileSize: fileStat.size
|
|
4769
4773
|
};
|
|
4770
4774
|
}
|
|
4771
4775
|
async function downloadInboundFileToTemp(options, deps = {}) {
|
|
@@ -5534,7 +5538,6 @@ async function processBaiduAppInboundMessage(params) {
|
|
|
5534
5538
|
`[REPLY-MODE:ACTIVE-SEND] active send starting: streamId=${streamId} chunks=${chunks.length} contentLen=${contentLen}`
|
|
5535
5539
|
);
|
|
5536
5540
|
for (let i = 0; i < chunks.length; i++) {
|
|
5537
|
-
console.log("dispatchBaiduAppMessage", target.account, chunks[i]);
|
|
5538
5541
|
await sendBaiduAppMessage(target.account, chunks[i], {
|
|
5539
5542
|
msgid,
|
|
5540
5543
|
streamId,
|
|
@@ -5910,9 +5913,6 @@ async function runPollCycle(account, state) {
|
|
|
5910
5913
|
fetchImpl: state.fetchImpl,
|
|
5911
5914
|
timeoutMs: state.requestTimeoutMs
|
|
5912
5915
|
});
|
|
5913
|
-
if (result.data.length > 0) {
|
|
5914
|
-
console.log("poll result", JSON.stringify(result));
|
|
5915
|
-
}
|
|
5916
5916
|
await dispatchPendingPollingMessages(result.data, state.dispatchTarget);
|
|
5917
5917
|
} catch (error) {
|
|
5918
5918
|
if (!(state.stopped && isAbortError2(error))) {
|
|
@@ -5987,30 +5987,6 @@ var meta = {
|
|
|
5987
5987
|
order: 85
|
|
5988
5988
|
};
|
|
5989
5989
|
var unregisterHooks = /* @__PURE__ */ new Map();
|
|
5990
|
-
var BAIDU_FILE_TYPE_BY_EXTENSION = {
|
|
5991
|
-
".amr": "audio/amr",
|
|
5992
|
-
".csv": "text/csv",
|
|
5993
|
-
".doc": "application/msword",
|
|
5994
|
-
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
5995
|
-
".gif": "image/gif",
|
|
5996
|
-
".jpeg": "image/jpeg",
|
|
5997
|
-
".jpg": "image/jpeg",
|
|
5998
|
-
".json": "application/json",
|
|
5999
|
-
".md": "text/markdown",
|
|
6000
|
-
".mov": "video/quicktime",
|
|
6001
|
-
".mp3": "audio/mpeg",
|
|
6002
|
-
".mp4": "video/mp4",
|
|
6003
|
-
".pdf": "application/pdf",
|
|
6004
|
-
".png": "image/png",
|
|
6005
|
-
".ppt": "application/vnd.ms-powerpoint",
|
|
6006
|
-
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
6007
|
-
".svg": "image/svg+xml",
|
|
6008
|
-
".txt": "text/plain",
|
|
6009
|
-
".wav": "audio/wav",
|
|
6010
|
-
".xls": "application/vnd.ms-excel",
|
|
6011
|
-
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
6012
|
-
".zip": "application/zip"
|
|
6013
|
-
};
|
|
6014
5990
|
function resolveOutboundLocalMediaPath(mediaUrl) {
|
|
6015
5991
|
const trimmed = mediaUrl?.trim();
|
|
6016
5992
|
if (!trimmed) {
|
|
@@ -6031,12 +6007,8 @@ function resolveOutboundLocalMediaPath(mediaUrl) {
|
|
|
6031
6007
|
return trimmed;
|
|
6032
6008
|
}
|
|
6033
6009
|
function inferBaiduOutboundFileType(params) {
|
|
6034
|
-
const
|
|
6035
|
-
|
|
6036
|
-
return normalizedMimeType;
|
|
6037
|
-
}
|
|
6038
|
-
const extension = path2.extname(params.mediaPath).toLowerCase();
|
|
6039
|
-
return BAIDU_FILE_TYPE_BY_EXTENSION[extension] ?? "application/octet-stream";
|
|
6010
|
+
const ext = path2.extname(params.mediaPath).toLowerCase();
|
|
6011
|
+
return ext.startsWith(".") ? ext.slice(1) : ext || "bin";
|
|
6040
6012
|
}
|
|
6041
6013
|
function buildOutboundMediaPayload(params) {
|
|
6042
6014
|
const caption = params.caption?.trim();
|
|
@@ -6139,7 +6111,7 @@ var baiduAppPlugin = {
|
|
|
6139
6111
|
channels: {
|
|
6140
6112
|
...params.cfg.channels,
|
|
6141
6113
|
"openclaw-baiduapp": {
|
|
6142
|
-
...params.cfg.channels?.["openclaw-baiduapp"]
|
|
6114
|
+
...params.cfg.channels?.["openclaw-baiduapp"],
|
|
6143
6115
|
enabled: params.enabled
|
|
6144
6116
|
}
|
|
6145
6117
|
}
|
|
@@ -6150,11 +6122,11 @@ var baiduAppPlugin = {
|
|
|
6150
6122
|
channels: {
|
|
6151
6123
|
...params.cfg.channels,
|
|
6152
6124
|
"openclaw-baiduapp": {
|
|
6153
|
-
...params.cfg.channels?.["openclaw-baiduapp"]
|
|
6125
|
+
...params.cfg.channels?.["openclaw-baiduapp"],
|
|
6154
6126
|
accounts: {
|
|
6155
|
-
...params.cfg.channels?.["openclaw-baiduapp"]?.accounts
|
|
6127
|
+
...params.cfg.channels?.["openclaw-baiduapp"]?.accounts,
|
|
6156
6128
|
[accountId]: {
|
|
6157
|
-
...params.cfg.channels?.["openclaw-baiduapp"]?.accounts?.[accountId]
|
|
6129
|
+
...params.cfg.channels?.["openclaw-baiduapp"]?.accounts?.[accountId],
|
|
6158
6130
|
enabled: params.enabled
|
|
6159
6131
|
}
|
|
6160
6132
|
}
|
|
@@ -6177,7 +6149,7 @@ var baiduAppPlugin = {
|
|
|
6177
6149
|
};
|
|
6178
6150
|
return next;
|
|
6179
6151
|
}
|
|
6180
|
-
const accounts = { ...current.accounts
|
|
6152
|
+
const accounts = { ...current.accounts };
|
|
6181
6153
|
delete accounts[accountId];
|
|
6182
6154
|
next.channels = {
|
|
6183
6155
|
...next.channels,
|
|
@@ -6318,15 +6290,14 @@ var baiduAppPlugin = {
|
|
|
6318
6290
|
filePath: localMediaPath,
|
|
6319
6291
|
contentType: params.mimeType
|
|
6320
6292
|
});
|
|
6321
|
-
console.log("uploaded", JSON.stringify(uploaded
|
|
6293
|
+
console.log("uploaded", JSON.stringify(uploaded));
|
|
6322
6294
|
const result = await sendBaiduAppMessage(
|
|
6323
6295
|
account,
|
|
6324
6296
|
buildOutboundMediaPayload({
|
|
6325
6297
|
caption: params.text,
|
|
6326
6298
|
uploadedUrl: uploaded.url,
|
|
6327
6299
|
fileType: inferBaiduOutboundFileType({
|
|
6328
|
-
mediaPath: uploaded.fileName || localMediaPath
|
|
6329
|
-
mimeType: params.mimeType
|
|
6300
|
+
mediaPath: uploaded.fileName || localMediaPath
|
|
6330
6301
|
})
|
|
6331
6302
|
})
|
|
6332
6303
|
);
|
|
@@ -6342,7 +6313,9 @@ var baiduAppPlugin = {
|
|
|
6342
6313
|
channel: "openclaw-baiduapp",
|
|
6343
6314
|
ok: true,
|
|
6344
6315
|
messageId: result.msgid ?? "",
|
|
6345
|
-
error: void 0
|
|
6316
|
+
error: void 0,
|
|
6317
|
+
fileName: uploaded.fileName,
|
|
6318
|
+
fileSize: uploaded.fileSize
|
|
6346
6319
|
};
|
|
6347
6320
|
} catch (err) {
|
|
6348
6321
|
return {
|
|
@@ -6448,7 +6421,6 @@ async function sendMessage(account, options) {
|
|
|
6448
6421
|
};
|
|
6449
6422
|
}
|
|
6450
6423
|
try {
|
|
6451
|
-
console.log("sendMessage", account, options.text);
|
|
6452
6424
|
const textResult = await sendBaiduAppMessage(account, options.text);
|
|
6453
6425
|
return {
|
|
6454
6426
|
ok: textResult.ok,
|