@searchfe/openclaw-baiduapp 0.1.7-beta.6 → 0.1.7-beta.8
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 +53 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4127,6 +4127,9 @@ function listBaiduAppAccountIds(cfg) {
|
|
|
4127
4127
|
if (ids.length === 0) {
|
|
4128
4128
|
return [DEFAULT_ACCOUNT_ID];
|
|
4129
4129
|
}
|
|
4130
|
+
if (!ids.includes(DEFAULT_ACCOUNT_ID)) {
|
|
4131
|
+
ids.push(DEFAULT_ACCOUNT_ID);
|
|
4132
|
+
}
|
|
4130
4133
|
return ids.sort((a, b) => a.localeCompare(b));
|
|
4131
4134
|
}
|
|
4132
4135
|
function resolveDefaultBaiduAppAccountId(cfg) {
|
|
@@ -4338,17 +4341,13 @@ async function sendBaiduAppMessage(account, message, options) {
|
|
|
4338
4341
|
return { ok: false, errcode: resp.status, errmsg };
|
|
4339
4342
|
}
|
|
4340
4343
|
const result = {
|
|
4341
|
-
ok:
|
|
4342
|
-
errcode: data.errcode,
|
|
4343
|
-
errmsg: data.errmsg,
|
|
4344
|
-
invaliduser: data.invaliduser,
|
|
4345
|
-
msgid: data.msgid
|
|
4344
|
+
ok: true
|
|
4346
4345
|
};
|
|
4347
|
-
logger.info(`request succeeded
|
|
4346
|
+
logger.info(`request succeeded`);
|
|
4348
4347
|
return result;
|
|
4349
4348
|
}
|
|
4350
4349
|
|
|
4351
|
-
//
|
|
4350
|
+
// src/media-payload.ts
|
|
4352
4351
|
function buildMediaPayload(mediaList, opts) {
|
|
4353
4352
|
const first = mediaList[0];
|
|
4354
4353
|
const mediaPaths = mediaList.map((media) => media.path);
|
|
@@ -4453,7 +4452,6 @@ async function dispatchBaiduAppMessage(params) {
|
|
|
4453
4452
|
peer: { kind: "dm", id: "default" }
|
|
4454
4453
|
});
|
|
4455
4454
|
logger2.info(`SessionKey: ${route.sessionKey}`);
|
|
4456
|
-
route.sessionKey = "agent:main:main";
|
|
4457
4455
|
logger2.info(
|
|
4458
4456
|
`route resolved: sessionKey=${route.sessionKey} agentId=${route.agentId ?? "default"} accountId=${route.accountId}`
|
|
4459
4457
|
);
|
|
@@ -4707,7 +4705,7 @@ async function fetchSksCredentials(account, deps = {}) {
|
|
|
4707
4705
|
try {
|
|
4708
4706
|
payload = await response.json();
|
|
4709
4707
|
} catch (error) {
|
|
4710
|
-
throw new Error(`SKS response is not valid JSON: ${formatError(error)}
|
|
4708
|
+
throw new Error(`SKS response is not valid JSON: ${formatError(error)}`, { cause: error });
|
|
4711
4709
|
}
|
|
4712
4710
|
return parseSksCredentialsFromPayload(payload);
|
|
4713
4711
|
}
|
|
@@ -4822,7 +4820,7 @@ async function downloadInboundFileToTemp(options, deps = {}) {
|
|
|
4822
4820
|
};
|
|
4823
4821
|
} catch (error) {
|
|
4824
4822
|
if (isAbortError(error)) {
|
|
4825
|
-
throw new Error(`Download timed out after ${timeoutMs}ms
|
|
4823
|
+
throw new Error(`Download timed out after ${timeoutMs}ms`, { cause: error });
|
|
4826
4824
|
}
|
|
4827
4825
|
throw error;
|
|
4828
4826
|
} finally {
|
|
@@ -5021,7 +5019,7 @@ async function assertSafeRemoteHttpUrl(remoteUrl, lookupHost) {
|
|
|
5021
5019
|
try {
|
|
5022
5020
|
resolvedAddresses = await lookupHost(hostname);
|
|
5023
5021
|
} catch (error) {
|
|
5024
|
-
throw new Error(`Remote URL host lookup failed: ${hostname} (${formatError(error)})
|
|
5022
|
+
throw new Error(`Remote URL host lookup failed: ${hostname} (${formatError(error)})`, { cause: error });
|
|
5025
5023
|
}
|
|
5026
5024
|
if (!resolvedAddresses.length) {
|
|
5027
5025
|
throw new Error(`Remote URL host lookup returned no addresses: ${hostname}`);
|
|
@@ -5964,7 +5962,7 @@ function stopAccountPolling(accountId) {
|
|
|
5964
5962
|
accountPollers.delete(accountId);
|
|
5965
5963
|
}
|
|
5966
5964
|
|
|
5967
|
-
//
|
|
5965
|
+
// src/channel.ts
|
|
5968
5966
|
function resolveOutboundMediaUrls(payload) {
|
|
5969
5967
|
if (payload.mediaUrls?.length) {
|
|
5970
5968
|
return payload.mediaUrls;
|
|
@@ -5974,8 +5972,6 @@ function resolveOutboundMediaUrls(payload) {
|
|
|
5974
5972
|
}
|
|
5975
5973
|
return [];
|
|
5976
5974
|
}
|
|
5977
|
-
|
|
5978
|
-
// src/channel.ts
|
|
5979
5975
|
var meta = {
|
|
5980
5976
|
id: "openclaw-baiduapp",
|
|
5981
5977
|
label: "Baidu App",
|
|
@@ -6266,6 +6262,7 @@ var baiduAppPlugin = {
|
|
|
6266
6262
|
}
|
|
6267
6263
|
},
|
|
6268
6264
|
sendMedia: async (params) => {
|
|
6265
|
+
console.log("sendMedia \u5F00\u59CB");
|
|
6269
6266
|
const account = resolveBaiduAppAccount({ cfg: params.cfg, accountId: params.accountId ?? void 0 });
|
|
6270
6267
|
if (!account.canSendActive) {
|
|
6271
6268
|
return {
|
|
@@ -6277,12 +6274,38 @@ var baiduAppPlugin = {
|
|
|
6277
6274
|
}
|
|
6278
6275
|
const localMediaPath = resolveOutboundLocalMediaPath(params.mediaUrl);
|
|
6279
6276
|
if (!localMediaPath) {
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6277
|
+
const remoteUrl = params.mediaUrl?.trim() ?? "";
|
|
6278
|
+
if (!remoteUrl) {
|
|
6279
|
+
return {
|
|
6280
|
+
channel: "openclaw-baiduapp4",
|
|
6281
|
+
ok: false,
|
|
6282
|
+
messageId: "",
|
|
6283
|
+
error: new Error("Outbound media requires a URL or local file path")
|
|
6284
|
+
};
|
|
6285
|
+
}
|
|
6286
|
+
try {
|
|
6287
|
+
const result = await sendBaiduAppMessage(
|
|
6288
|
+
account,
|
|
6289
|
+
buildOutboundMediaPayload({
|
|
6290
|
+
caption: params.text,
|
|
6291
|
+
uploadedUrl: remoteUrl,
|
|
6292
|
+
fileType: inferBaiduOutboundFileType({ mediaPath: remoteUrl })
|
|
6293
|
+
})
|
|
6294
|
+
);
|
|
6295
|
+
console.log("result", JSON.stringify(result));
|
|
6296
|
+
return {
|
|
6297
|
+
channel: "openclaw-baiduapp2",
|
|
6298
|
+
ok: true,
|
|
6299
|
+
messageId: result.msgid ?? ""
|
|
6300
|
+
};
|
|
6301
|
+
} catch (err) {
|
|
6302
|
+
return {
|
|
6303
|
+
channel: "openclaw-baiduapp3",
|
|
6304
|
+
ok: false,
|
|
6305
|
+
messageId: "",
|
|
6306
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
6307
|
+
};
|
|
6308
|
+
}
|
|
6286
6309
|
}
|
|
6287
6310
|
try {
|
|
6288
6311
|
const uploaded = await uploadLocalFileToBos({
|
|
@@ -6303,7 +6326,7 @@ var baiduAppPlugin = {
|
|
|
6303
6326
|
);
|
|
6304
6327
|
if (!result.ok) {
|
|
6305
6328
|
return {
|
|
6306
|
-
channel: "openclaw-
|
|
6329
|
+
channel: "openclaw-baiduapp6",
|
|
6307
6330
|
ok: false,
|
|
6308
6331
|
messageId: result.msgid ?? "",
|
|
6309
6332
|
error: new Error(result.errmsg ?? "send failed")
|
|
@@ -6390,6 +6413,15 @@ var baiduAppPlugin = {
|
|
|
6390
6413
|
webhookPath: path4,
|
|
6391
6414
|
lastStartAt: Date.now()
|
|
6392
6415
|
});
|
|
6416
|
+
if (ctx.abortSignal) {
|
|
6417
|
+
await new Promise((resolve) => {
|
|
6418
|
+
if (ctx.abortSignal.aborted) {
|
|
6419
|
+
resolve();
|
|
6420
|
+
return;
|
|
6421
|
+
}
|
|
6422
|
+
ctx.abortSignal.addEventListener("abort", () => resolve(), { once: true });
|
|
6423
|
+
});
|
|
6424
|
+
}
|
|
6393
6425
|
},
|
|
6394
6426
|
stopAccount: async (ctx) => {
|
|
6395
6427
|
stopAccountPolling(ctx.accountId);
|