@searchfe/openclaw-baiduapp 0.1.0-beta.6 → 0.1.0-beta.7

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 CHANGED
@@ -4111,7 +4111,7 @@ function normalizeAccountId(raw) {
4111
4111
  return trimmed || DEFAULT_ACCOUNT_ID;
4112
4112
  }
4113
4113
  function listConfiguredAccountIds(cfg) {
4114
- const accounts = cfg.channels?.["baidu-app"]?.accounts;
4114
+ const accounts = cfg.channels?.["openclaw-baiduapp"]?.accounts;
4115
4115
  if (!accounts || typeof accounts !== "object") {
4116
4116
  return [];
4117
4117
  }
@@ -4125,7 +4125,7 @@ function listBaiduAppAccountIds(cfg) {
4125
4125
  return ids.sort((a, b) => a.localeCompare(b));
4126
4126
  }
4127
4127
  function resolveDefaultBaiduAppAccountId(cfg) {
4128
- const baiduAppConfig = cfg.channels?.["baidu-app"];
4128
+ const baiduAppConfig = cfg.channels?.["openclaw-baiduapp"];
4129
4129
  if (baiduAppConfig?.defaultAccount?.trim()) {
4130
4130
  return baiduAppConfig.defaultAccount.trim();
4131
4131
  }
@@ -4136,21 +4136,21 @@ function resolveDefaultBaiduAppAccountId(cfg) {
4136
4136
  return ids[0] ?? DEFAULT_ACCOUNT_ID;
4137
4137
  }
4138
4138
  function resolveAccountConfig(cfg, accountId) {
4139
- const accounts = cfg.channels?.["baidu-app"]?.accounts;
4139
+ const accounts = cfg.channels?.["openclaw-baiduapp"]?.accounts;
4140
4140
  if (!accounts || typeof accounts !== "object") {
4141
4141
  return void 0;
4142
4142
  }
4143
4143
  return accounts[accountId];
4144
4144
  }
4145
4145
  function mergeBaiduAppAccountConfig(cfg, accountId) {
4146
- const base = cfg.channels?.["baidu-app"] ?? {};
4146
+ const base = cfg.channels?.["openclaw-baiduapp"] ?? {};
4147
4147
  const { accounts: _ignored, defaultAccount: _ignored2, ...baseConfig } = base;
4148
4148
  const account = resolveAccountConfig(cfg, accountId) ?? {};
4149
4149
  return { ...baseConfig, ...account };
4150
4150
  }
4151
4151
  function resolveBaiduAppAccount(params) {
4152
4152
  const accountId = normalizeAccountId(params.accountId);
4153
- const baseEnabled = params.cfg.channels?.["baidu-app"]?.enabled !== false;
4153
+ const baseEnabled = params.cfg.channels?.["openclaw-baiduapp"]?.enabled !== false;
4154
4154
  const merged = mergeBaiduAppAccountConfig(params.cfg, accountId);
4155
4155
  const enabled = baseEnabled && merged.enabled !== false;
4156
4156
  const isDefaultAccount = accountId === DEFAULT_ACCOUNT_ID;
@@ -4159,7 +4159,7 @@ function resolveBaiduAppAccount(params) {
4159
4159
  const appKey = merged.appKey?.trim() || (isDefaultAccount ? process.env.BAIDU_APP_KEY?.trim() : void 0) || void 0;
4160
4160
  const appSecret = merged.appSecret?.trim() || (isDefaultAccount ? process.env.BAIDU_APP_SECRET?.trim() : void 0) || void 0;
4161
4161
  const configured = Boolean(token && encodingAESKey);
4162
- const canSendActive = Boolean(appKey && appSecret);
4162
+ const canSendActive = Boolean(appKey && token && encodingAESKey);
4163
4163
  const rawApiBase = merged.apiBase?.trim() || (isDefaultAccount ? process.env.BAIDU_API_BASE?.trim() : void 0) || void 0;
4164
4164
  const apiBase = (rawApiBase || DEFAULT_API_BASE).replace(/\/+$/, "");
4165
4165
  return {
@@ -4215,69 +4215,120 @@ function checkDmPolicy(params) {
4215
4215
  return { allowed: true };
4216
4216
  }
4217
4217
  }
4218
-
4219
- // src/api.ts
4220
- var accessTokenCache = /* @__PURE__ */ new Map();
4221
- var ACCESS_TOKEN_TTL_MS = 7200 * 1e3 - 5 * 60 * 1e3;
4222
- async function getAccessToken(account) {
4223
- if (!account.appKey || !account.appSecret) {
4224
- throw new Error("appKey or appSecret not configured");
4225
- }
4226
- const key = `${account.appKey}`;
4227
- const cached = accessTokenCache.get(key);
4228
- if (cached && Date.now() < cached.expiresAt) {
4229
- return cached.token;
4230
- }
4231
- const tokenUrl = `${account.apiBase}/auth/token`;
4232
- const url = `${tokenUrl}?appKey=${encodeURIComponent(account.appKey)}&appSecret=${encodeURIComponent(account.appSecret)}`;
4233
- const resp = await fetch(url);
4234
- const text = await resp.text();
4235
- if (!text) {
4236
- throw new Error(`gettoken failed: empty response (status=${resp.status})`);
4218
+ function decodeEncodingAESKey(encodingAESKey) {
4219
+ const trimmed = encodingAESKey.trim();
4220
+ if (!trimmed) {
4221
+ throw new Error("encodingAESKey missing");
4237
4222
  }
4238
- let data;
4239
- try {
4240
- data = JSON.parse(text);
4241
- } catch {
4242
- throw new Error(`gettoken failed: invalid JSON response (status=${resp.status}, body=${text.slice(0, 200)})`);
4223
+ const withPadding = trimmed.endsWith("=") ? trimmed : `${trimmed}=`;
4224
+ const key = Buffer.from(withPadding, "base64");
4225
+ if (key.length !== 32) {
4226
+ throw new Error(`invalid encodingAESKey (expected 32 bytes after base64 decode, got ${key.length})`);
4227
+ }
4228
+ return key;
4229
+ }
4230
+ var PKCS7_BLOCK_SIZE = 32;
4231
+ function pkcs7Pad(buf, blockSize) {
4232
+ const mod = buf.length % blockSize;
4233
+ const pad = mod === 0 ? blockSize : blockSize - mod;
4234
+ return Buffer.concat([buf, Buffer.alloc(pad, pad)]);
4235
+ }
4236
+ function pkcs7Unpad(buf, blockSize) {
4237
+ if (buf.length === 0) {
4238
+ throw new Error("invalid pkcs7 payload");
4243
4239
  }
4244
- if (data.errcode !== void 0 && data.errcode !== 0) {
4245
- throw new Error(`gettoken failed: ${data.errmsg ?? "unknown error"} (errcode=${data.errcode})`);
4240
+ const pad = buf[buf.length - 1];
4241
+ if (!pad || pad < 1 || pad > blockSize || pad > buf.length) {
4242
+ throw new Error("invalid pkcs7 padding");
4246
4243
  }
4247
- if (!data.access_token) {
4248
- throw new Error("gettoken returned empty access_token");
4244
+ for (let i = 1; i <= pad; i += 1) {
4245
+ if (buf[buf.length - i] !== pad) {
4246
+ throw new Error("invalid pkcs7 padding");
4247
+ }
4249
4248
  }
4250
- accessTokenCache.set(key, {
4251
- token: data.access_token,
4252
- expiresAt: Date.now() + ACCESS_TOKEN_TTL_MS
4249
+ return buf.subarray(0, buf.length - pad);
4250
+ }
4251
+ function sha1Hex(input) {
4252
+ return crypto.createHash("sha1").update(input).digest("hex");
4253
+ }
4254
+ function computeBaiduAppMsgSignature(params) {
4255
+ const parts = [params.token, params.timestamp, params.nonce, params.encrypt].map((value) => String(value ?? "")).sort();
4256
+ return sha1Hex(parts.join(""));
4257
+ }
4258
+ function verifyBaiduAppSignature(params) {
4259
+ const expected = computeBaiduAppMsgSignature({
4260
+ token: params.token,
4261
+ timestamp: params.timestamp,
4262
+ nonce: params.nonce,
4263
+ encrypt: params.encrypt
4253
4264
  });
4254
- return data.access_token;
4265
+ return expected === params.signature;
4255
4266
  }
4256
- function clearAccessTokenCache(account) {
4257
- const key = `${account.appKey}`;
4258
- accessTokenCache.delete(key);
4267
+ function decryptBaiduAppEncrypted(params) {
4268
+ const aesKey = decodeEncodingAESKey(params.encodingAESKey);
4269
+ const iv = aesKey.subarray(0, 16);
4270
+ const decipher = crypto.createDecipheriv("aes-256-cbc", aesKey, iv);
4271
+ decipher.setAutoPadding(false);
4272
+ const decryptedPadded = Buffer.concat([decipher.update(Buffer.from(params.encrypt, "base64")), decipher.final()]);
4273
+ const decrypted = pkcs7Unpad(decryptedPadded, PKCS7_BLOCK_SIZE);
4274
+ if (decrypted.length < 20) {
4275
+ throw new Error(`invalid decrypted payload (expected at least 20 bytes, got ${decrypted.length})`);
4276
+ }
4277
+ const msgLen = decrypted.readUInt32BE(16);
4278
+ const msgStart = 20;
4279
+ const msgEnd = msgStart + msgLen;
4280
+ if (msgEnd > decrypted.length) {
4281
+ throw new Error(`invalid decrypted msg length (msgEnd=${msgEnd}, payloadLength=${decrypted.length})`);
4282
+ }
4283
+ return decrypted.subarray(msgStart, msgEnd).toString("utf8");
4259
4284
  }
4260
- function clearAllAccessTokenCache() {
4261
- accessTokenCache.clear();
4285
+ function encryptBaiduAppPlaintext(params) {
4286
+ const aesKey = decodeEncodingAESKey(params.encodingAESKey);
4287
+ const iv = aesKey.subarray(0, 16);
4288
+ const random16 = crypto.randomBytes(16);
4289
+ const msg = Buffer.from(params.plaintext ?? "", "utf8");
4290
+ const msgLen = Buffer.alloc(4);
4291
+ msgLen.writeUInt32BE(msg.length, 0);
4292
+ const raw = Buffer.concat([random16, msgLen, msg]);
4293
+ const padded = pkcs7Pad(raw, PKCS7_BLOCK_SIZE);
4294
+ const cipher = crypto.createCipheriv("aes-256-cbc", aesKey, iv);
4295
+ cipher.setAutoPadding(false);
4296
+ const encrypted = Buffer.concat([cipher.update(padded), cipher.final()]);
4297
+ return encrypted.toString("base64");
4262
4298
  }
4299
+
4300
+ // src/api.ts
4263
4301
  async function sendBaiduAppMessage(account, target, message) {
4264
4302
  if (!account.canSendActive) {
4265
4303
  return {
4266
4304
  ok: false,
4267
4305
  errcode: -1,
4268
- errmsg: "Account not configured for active sending (missing appKey or appSecret)"
4306
+ errmsg: "Account not configured for active sending (missing appKey, token, or encodingAESKey)"
4269
4307
  };
4270
4308
  }
4271
- const token = await getAccessToken(account);
4272
4309
  const payload = {
4273
4310
  msgtype: "text",
4274
4311
  text: { content: message },
4275
4312
  touser: target.userId
4276
4313
  };
4314
+ const plaintext = JSON.stringify(payload);
4315
+ const encrypt = encryptBaiduAppPlaintext({
4316
+ encodingAESKey: account.encodingAESKey ?? "",
4317
+ plaintext
4318
+ });
4319
+ const timestamp = String(Math.floor(Date.now() / 1e3));
4320
+ const nonce = crypto.randomBytes(8).toString("hex");
4321
+ const msgSignature = computeBaiduAppMsgSignature({
4322
+ token: account.token ?? "",
4323
+ timestamp,
4324
+ nonce,
4325
+ encrypt
4326
+ });
4277
4327
  const sendMessageUrl = `${account.apiBase}/chat/openclaw/callback`;
4278
- const resp = await fetch(`${sendMessageUrl}?access_token=${encodeURIComponent(token)}`, {
4328
+ const url = `${sendMessageUrl}?timestamp=${encodeURIComponent(timestamp)}&ak=${encodeURIComponent(account.appKey ?? "")}&nonce=${encodeURIComponent(nonce)}&msg_signature=${encodeURIComponent(msgSignature)}`;
4329
+ const resp = await fetch(url, {
4279
4330
  method: "POST",
4280
- body: JSON.stringify(payload),
4331
+ body: JSON.stringify({ encrypt }),
4281
4332
  headers: { "Content-Type": "application/json" }
4282
4333
  });
4283
4334
  const text = await resp.text();
@@ -4329,7 +4380,7 @@ function resolveSenderId(msg) {
4329
4380
  async function dispatchBaiduAppMessage(params) {
4330
4381
  const { cfg, account, msg, core, hooks } = params;
4331
4382
  const safeCfg = cfg ?? {};
4332
- const logger = createLogger("baidu-app", { log: params.log, error: params.error });
4383
+ const logger = createLogger("openclaw-baiduapp", { log: params.log, error: params.error });
4333
4384
  const senderId = resolveSenderId(msg);
4334
4385
  const chatId = senderId;
4335
4386
  const accountConfig = account?.config ?? {};
@@ -4356,7 +4407,7 @@ async function dispatchBaiduAppMessage(params) {
4356
4407
  }
4357
4408
  const route = channel.routing.resolveAgentRoute({
4358
4409
  cfg: safeCfg,
4359
- channel: "baidu-app",
4410
+ channel: "openclaw-baiduapp",
4360
4411
  accountId: account.accountId,
4361
4412
  peer: { kind: "dm", id: chatId }
4362
4413
  });
@@ -4384,7 +4435,7 @@ async function dispatchBaiduAppMessage(params) {
4384
4435
  body: rawBody
4385
4436
  }) : rawBody;
4386
4437
  const msgid = msg.msgid ?? msg.MsgId ?? void 0;
4387
- const from = `baidu-app:user:${senderId}`;
4438
+ const from = `openclaw-baiduapp:user:${senderId}`;
4388
4439
  const to = `user:${senderId}`;
4389
4440
  const ctxPayload = channel.reply?.finalizeInboundContext ? channel.reply.finalizeInboundContext({
4390
4441
  Body: body,
@@ -4398,10 +4449,10 @@ async function dispatchBaiduAppMessage(params) {
4398
4449
  ConversationLabel: fromLabel,
4399
4450
  SenderName: senderId,
4400
4451
  SenderId: senderId,
4401
- Provider: "baidu-app",
4402
- Surface: "baidu-app",
4452
+ Provider: "openclaw-baiduapp",
4453
+ Surface: "openclaw-baiduapp",
4403
4454
  MessageSid: msgid,
4404
- OriginatingChannel: "baidu-app",
4455
+ OriginatingChannel: "openclaw-baiduapp",
4405
4456
  OriginatingTo: to
4406
4457
  }) : {
4407
4458
  Body: body,
@@ -4415,10 +4466,10 @@ async function dispatchBaiduAppMessage(params) {
4415
4466
  ConversationLabel: fromLabel,
4416
4467
  SenderName: senderId,
4417
4468
  SenderId: senderId,
4418
- Provider: "baidu-app",
4419
- Surface: "baidu-app",
4469
+ Provider: "openclaw-baiduapp",
4470
+ Surface: "openclaw-baiduapp",
4420
4471
  MessageSid: msgid,
4421
- OriginatingChannel: "baidu-app",
4472
+ OriginatingChannel: "openclaw-baiduapp",
4422
4473
  OriginatingTo: to
4423
4474
  };
4424
4475
  if (channel.session?.recordInboundSession && storePath) {
@@ -4427,11 +4478,15 @@ async function dispatchBaiduAppMessage(params) {
4427
4478
  sessionKey: ctxPayload.SessionKey ?? route.sessionKey,
4428
4479
  ctx: ctxPayload,
4429
4480
  onRecordError: (err) => {
4430
- logger.error(`baidu-app: failed updating session meta: ${String(err)}`);
4481
+ logger.error(`openclaw-baiduapp: failed updating session meta: ${String(err)}`);
4431
4482
  }
4432
4483
  });
4433
4484
  }
4434
- const tableMode = channel.text?.resolveMarkdownTableMode ? channel.text.resolveMarkdownTableMode({ cfg: safeCfg, channel: "baidu-app", accountId: account.accountId }) : void 0;
4485
+ const tableMode = channel.text?.resolveMarkdownTableMode ? channel.text.resolveMarkdownTableMode({
4486
+ cfg: safeCfg,
4487
+ channel: "openclaw-baiduapp",
4488
+ accountId: account.accountId
4489
+ }) : void 0;
4435
4490
  logger.info(`dispatching to agent: sessionKey=${route.sessionKey} sender=${senderId}`);
4436
4491
  await channel.reply.dispatchReplyWithBufferedBlockDispatcher({
4437
4492
  ctx: ctxPayload,
@@ -4455,87 +4510,6 @@ async function dispatchBaiduAppMessage(params) {
4455
4510
  });
4456
4511
  logger.info(`agent reply dispatch complete: sessionKey=${route.sessionKey} sender=${senderId}`);
4457
4512
  }
4458
- function decodeEncodingAESKey(encodingAESKey) {
4459
- const trimmed = encodingAESKey.trim();
4460
- if (!trimmed) {
4461
- throw new Error("encodingAESKey missing");
4462
- }
4463
- const withPadding = trimmed.endsWith("=") ? trimmed : `${trimmed}=`;
4464
- const key = Buffer.from(withPadding, "base64");
4465
- if (key.length !== 32) {
4466
- throw new Error(`invalid encodingAESKey (expected 32 bytes after base64 decode, got ${key.length})`);
4467
- }
4468
- return key;
4469
- }
4470
- var PKCS7_BLOCK_SIZE = 32;
4471
- function pkcs7Pad(buf, blockSize) {
4472
- const mod = buf.length % blockSize;
4473
- const pad = mod === 0 ? blockSize : blockSize - mod;
4474
- return Buffer.concat([buf, Buffer.alloc(pad, pad)]);
4475
- }
4476
- function pkcs7Unpad(buf, blockSize) {
4477
- if (buf.length === 0) {
4478
- throw new Error("invalid pkcs7 payload");
4479
- }
4480
- const pad = buf[buf.length - 1];
4481
- if (!pad || pad < 1 || pad > blockSize || pad > buf.length) {
4482
- throw new Error("invalid pkcs7 padding");
4483
- }
4484
- for (let i = 1; i <= pad; i += 1) {
4485
- if (buf[buf.length - i] !== pad) {
4486
- throw new Error("invalid pkcs7 padding");
4487
- }
4488
- }
4489
- return buf.subarray(0, buf.length - pad);
4490
- }
4491
- function sha1Hex(input) {
4492
- return crypto.createHash("sha1").update(input).digest("hex");
4493
- }
4494
- function computeBaiduAppMsgSignature(params) {
4495
- const parts = [params.token, params.timestamp, params.nonce, params.encrypt].map((value) => String(value ?? "")).sort();
4496
- return sha1Hex(parts.join(""));
4497
- }
4498
- function verifyBaiduAppSignature(params) {
4499
- const expected = computeBaiduAppMsgSignature({
4500
- token: params.token,
4501
- timestamp: params.timestamp,
4502
- nonce: params.nonce,
4503
- encrypt: params.encrypt
4504
- });
4505
- return expected === params.signature;
4506
- }
4507
- function decryptBaiduAppEncrypted(params) {
4508
- const aesKey = decodeEncodingAESKey(params.encodingAESKey);
4509
- const iv = aesKey.subarray(0, 16);
4510
- const decipher = crypto.createDecipheriv("aes-256-cbc", aesKey, iv);
4511
- decipher.setAutoPadding(false);
4512
- const decryptedPadded = Buffer.concat([decipher.update(Buffer.from(params.encrypt, "base64")), decipher.final()]);
4513
- const decrypted = pkcs7Unpad(decryptedPadded, PKCS7_BLOCK_SIZE);
4514
- if (decrypted.length < 20) {
4515
- throw new Error(`invalid decrypted payload (expected at least 20 bytes, got ${decrypted.length})`);
4516
- }
4517
- const msgLen = decrypted.readUInt32BE(16);
4518
- const msgStart = 20;
4519
- const msgEnd = msgStart + msgLen;
4520
- if (msgEnd > decrypted.length) {
4521
- throw new Error(`invalid decrypted msg length (msgEnd=${msgEnd}, payloadLength=${decrypted.length})`);
4522
- }
4523
- return decrypted.subarray(msgStart, msgEnd).toString("utf8");
4524
- }
4525
- function encryptBaiduAppPlaintext(params) {
4526
- const aesKey = decodeEncodingAESKey(params.encodingAESKey);
4527
- const iv = aesKey.subarray(0, 16);
4528
- const random16 = crypto.randomBytes(16);
4529
- const msg = Buffer.from(params.plaintext ?? "", "utf8");
4530
- const msgLen = Buffer.alloc(4);
4531
- msgLen.writeUInt32BE(msg.length, 0);
4532
- const raw = Buffer.concat([random16, msgLen, msg]);
4533
- const padded = pkcs7Pad(raw, PKCS7_BLOCK_SIZE);
4534
- const cipher = crypto.createCipheriv("aes-256-cbc", aesKey, iv);
4535
- cipher.setAutoPadding(false);
4536
- const encrypted = Buffer.concat([cipher.update(padded), cipher.final()]);
4537
- return encrypted.toString("base64");
4538
- }
4539
4513
 
4540
4514
  // src/runtime.ts
4541
4515
  var runtime = null;
@@ -4778,7 +4752,9 @@ function selectDecryptedTarget(params) {
4778
4752
  return params.candidates[0];
4779
4753
  }
4780
4754
  const accountIds = params.candidates.map((candidate) => candidate.target.account.accountId).join(", ");
4781
- params.logger.warn(`multiple baidu-app accounts matched signature; using first match (accounts: ${accountIds})`);
4755
+ params.logger.warn(
4756
+ `multiple openclaw-baiduapp accounts matched signature; using first match (accounts: ${accountIds})`
4757
+ );
4782
4758
  return params.candidates[0];
4783
4759
  }
4784
4760
  function appendStreamContent(state, nextText) {
@@ -4789,7 +4765,7 @@ ${nextText}`.trim() : nextText.trim();
4789
4765
  state.updatedAt = Date.now();
4790
4766
  }
4791
4767
  function buildLogger(target) {
4792
- return createLogger("baidu-app", {
4768
+ return createLogger("openclaw-baiduapp", {
4793
4769
  log: target.runtime.log,
4794
4770
  error: target.runtime.error
4795
4771
  });
@@ -4922,7 +4898,7 @@ async function handleBaiduAppWebhookRequest(req, res) {
4922
4898
  const decryptable = signatureMatched.filter((candidate) => Boolean(candidate.account.encodingAESKey));
4923
4899
  if (decryptable.length === 0) {
4924
4900
  logger.warn(`no account has encodingAESKey configured`);
4925
- jsonError(res, "baidu-app not configured");
4901
+ jsonError(res, "openclaw-baiduapp not configured");
4926
4902
  return true;
4927
4903
  }
4928
4904
  const decryptedCandidates = decryptBaiduAppCandidates({
@@ -4938,7 +4914,7 @@ async function handleBaiduAppWebhookRequest(req, res) {
4938
4914
  const target = selected.target;
4939
4915
  if (!target.account.configured || !target.account.token || !target.account.encodingAESKey) {
4940
4916
  logger.warn(`selected account ${target.account.accountId} not fully configured`);
4941
- jsonError(res, "baidu-app not configured");
4917
+ jsonError(res, "openclaw-baiduapp not configured");
4942
4918
  return true;
4943
4919
  }
4944
4920
  const msg = selected.msg;
@@ -5068,7 +5044,7 @@ async function handleBaiduAppWebhookRequest(req, res) {
5068
5044
  current.finished = true;
5069
5045
  current.updatedAt = Date.now();
5070
5046
  }
5071
- logger.error(`baidu-app agent failed: ${String(err)}`);
5047
+ logger.error(`openclaw-baiduapp agent failed: ${String(err)}`);
5072
5048
  }
5073
5049
  };
5074
5050
  dispatchBaiduAppMessage({
@@ -5149,18 +5125,18 @@ async function handleBaiduAppWebhookRequest(req, res) {
5149
5125
 
5150
5126
  // src/channel.ts
5151
5127
  var meta = {
5152
- id: "baidu-app",
5128
+ id: "openclaw-baiduapp",
5153
5129
  label: "Baidu App",
5154
5130
  selectionLabel: "Baidu Search AI (\u767E\u5EA6\u641C\u7D22\u5BF9\u8BDD\u5F0FAI)",
5155
- docsPath: "/channels/baidu-app",
5156
- docsLabel: "baidu-app",
5131
+ docsPath: "/channels/openclaw-baiduapp",
5132
+ docsLabel: "openclaw-baiduapp",
5157
5133
  blurb: "\u767E\u5EA6\u641C\u7D22\u5BF9\u8BDD\u5F0FAI\uFF0C\u652F\u6301\u4E3B\u52A8\u53D1\u9001\u6D88\u606F",
5158
5134
  aliases: ["baidu-ai", "\u767E\u5EA6\u641C\u7D22AI"],
5159
5135
  order: 85
5160
5136
  };
5161
5137
  var unregisterHooks = /* @__PURE__ */ new Map();
5162
5138
  var baiduAppPlugin = {
5163
- id: "baidu-app",
5139
+ id: "openclaw-baiduapp",
5164
5140
  meta: {
5165
5141
  ...meta
5166
5142
  },
@@ -5175,21 +5151,21 @@ var baiduAppPlugin = {
5175
5151
  activeSend: true
5176
5152
  },
5177
5153
  configSchema: BaiduAppConfigJsonSchema,
5178
- reload: { configPrefixes: ["channels.baidu-app"] },
5154
+ reload: { configPrefixes: ["channels.openclaw-baiduapp"] },
5179
5155
  config: {
5180
5156
  listAccountIds: (cfg) => listBaiduAppAccountIds(cfg),
5181
5157
  resolveAccount: (cfg, accountId) => resolveBaiduAppAccount({ cfg, accountId }),
5182
5158
  defaultAccountId: (cfg) => resolveDefaultBaiduAppAccountId(cfg),
5183
5159
  setAccountEnabled: (params) => {
5184
5160
  const accountId = params.accountId ?? DEFAULT_ACCOUNT_ID;
5185
- const useAccount = Boolean(params.cfg.channels?.["baidu-app"]?.accounts?.[accountId]);
5161
+ const useAccount = Boolean(params.cfg.channels?.["openclaw-baiduapp"]?.accounts?.[accountId]);
5186
5162
  if (!useAccount) {
5187
5163
  return {
5188
5164
  ...params.cfg,
5189
5165
  channels: {
5190
5166
  ...params.cfg.channels,
5191
- "baidu-app": {
5192
- ...params.cfg.channels?.["baidu-app"] ?? {},
5167
+ "openclaw-baiduapp": {
5168
+ ...params.cfg.channels?.["openclaw-baiduapp"] ?? {},
5193
5169
  enabled: params.enabled
5194
5170
  }
5195
5171
  }
@@ -5199,12 +5175,12 @@ var baiduAppPlugin = {
5199
5175
  ...params.cfg,
5200
5176
  channels: {
5201
5177
  ...params.cfg.channels,
5202
- "baidu-app": {
5203
- ...params.cfg.channels?.["baidu-app"] ?? {},
5178
+ "openclaw-baiduapp": {
5179
+ ...params.cfg.channels?.["openclaw-baiduapp"] ?? {},
5204
5180
  accounts: {
5205
- ...params.cfg.channels?.["baidu-app"]?.accounts ?? {},
5181
+ ...params.cfg.channels?.["openclaw-baiduapp"]?.accounts ?? {},
5206
5182
  [accountId]: {
5207
- ...params.cfg.channels?.["baidu-app"]?.accounts?.[accountId] ?? {},
5183
+ ...params.cfg.channels?.["openclaw-baiduapp"]?.accounts?.[accountId] ?? {},
5208
5184
  enabled: params.enabled
5209
5185
  }
5210
5186
  }
@@ -5215,7 +5191,7 @@ var baiduAppPlugin = {
5215
5191
  deleteAccount: (params) => {
5216
5192
  const accountId = params.accountId ?? DEFAULT_ACCOUNT_ID;
5217
5193
  const next = { ...params.cfg };
5218
- const current = next.channels?.["baidu-app"];
5194
+ const current = next.channels?.["openclaw-baiduapp"];
5219
5195
  if (!current) {
5220
5196
  return next;
5221
5197
  }
@@ -5223,7 +5199,7 @@ var baiduAppPlugin = {
5223
5199
  const { accounts: _ignored, defaultAccount: _ignored2, ...rest } = current;
5224
5200
  next.channels = {
5225
5201
  ...next.channels,
5226
- "baidu-app": { ...rest, enabled: false }
5202
+ "openclaw-baiduapp": { ...rest, enabled: false }
5227
5203
  };
5228
5204
  return next;
5229
5205
  }
@@ -5231,7 +5207,7 @@ var baiduAppPlugin = {
5231
5207
  delete accounts[accountId];
5232
5208
  next.channels = {
5233
5209
  ...next.channels,
5234
- "baidu-app": {
5210
+ "openclaw-baiduapp": {
5235
5211
  ...current,
5236
5212
  accounts: Object.keys(accounts).length > 0 ? accounts : void 0
5237
5213
  }
@@ -5245,7 +5221,7 @@ var baiduAppPlugin = {
5245
5221
  enabled: account.enabled,
5246
5222
  configured: account.configured,
5247
5223
  canSendActive: account.canSendActive,
5248
- webhookPath: account.config.webhookPath ?? "/baidu-app"
5224
+ webhookPath: account.config.webhookPath ?? "/openclaw-baiduapp"
5249
5225
  }),
5250
5226
  resolveAllowFrom: (params) => {
5251
5227
  const account = resolveBaiduAppAccount({ cfg: params.cfg, accountId: params.accountId });
@@ -5259,7 +5235,7 @@ var baiduAppPlugin = {
5259
5235
  if (!raw) {
5260
5236
  return false;
5261
5237
  }
5262
- if (raw.startsWith("baidu-app:")) {
5238
+ if (raw.startsWith("openclaw-baiduapp:")) {
5263
5239
  return true;
5264
5240
  }
5265
5241
  const knownChannelPrefixes = [
@@ -5284,7 +5260,7 @@ var baiduAppPlugin = {
5284
5260
  if (!raw) {
5285
5261
  return null;
5286
5262
  }
5287
- const channelPrefix = "baidu-app:";
5263
+ const channelPrefix = "openclaw-baiduapp:";
5288
5264
  if (raw.startsWith(channelPrefix)) {
5289
5265
  raw = raw.slice(channelPrefix.length);
5290
5266
  }
@@ -5299,9 +5275,9 @@ var baiduAppPlugin = {
5299
5275
  }
5300
5276
  }
5301
5277
  if (to.startsWith("user:")) {
5302
- return { channel: "baidu-app", accountId, to: to.slice(5) };
5278
+ return { channel: "openclaw-baiduapp", accountId, to: to.slice(5) };
5303
5279
  }
5304
- return { channel: "baidu-app", accountId, to };
5280
+ return { channel: "openclaw-baiduapp", accountId, to };
5305
5281
  },
5306
5282
  resolveTargets: (params) => {
5307
5283
  const results = [];
@@ -5316,7 +5292,7 @@ var baiduAppPlugin = {
5316
5292
  }
5317
5293
  return results;
5318
5294
  },
5319
- getTargetFormats: () => ["baidu-app:user:<userId>", "user:<userId>", "<userId>"]
5295
+ getTargetFormats: () => ["openclaw-baiduapp:user:<userId>", "user:<userId>", "<userId>"]
5320
5296
  },
5321
5297
  outbound: {
5322
5298
  deliveryMode: "direct",
@@ -5324,14 +5300,14 @@ var baiduAppPlugin = {
5324
5300
  const account = resolveBaiduAppAccount({ cfg: params.cfg, accountId: params.accountId });
5325
5301
  if (!account.canSendActive) {
5326
5302
  return {
5327
- channel: "baidu-app",
5303
+ channel: "openclaw-baiduapp",
5328
5304
  ok: false,
5329
5305
  messageId: "",
5330
5306
  error: new Error("Account not configured for active sending (missing appKey or appSecret)")
5331
5307
  };
5332
5308
  }
5333
5309
  let to = params.to;
5334
- const channelPrefix = "baidu-app:";
5310
+ const channelPrefix = "openclaw-baiduapp:";
5335
5311
  if (to.startsWith(channelPrefix)) {
5336
5312
  to = to.slice(channelPrefix.length);
5337
5313
  }
@@ -5344,14 +5320,14 @@ var baiduAppPlugin = {
5344
5320
  try {
5345
5321
  const result = await sendBaiduAppMessage(account, target, params.text);
5346
5322
  return {
5347
- channel: "baidu-app",
5323
+ channel: "openclaw-baiduapp",
5348
5324
  ok: result.ok,
5349
5325
  messageId: result.msgid ?? "",
5350
5326
  error: result.ok ? void 0 : new Error(result.errmsg ?? "send failed")
5351
5327
  };
5352
5328
  } catch (err) {
5353
5329
  return {
5354
- channel: "baidu-app",
5330
+ channel: "openclaw-baiduapp",
5355
5331
  ok: false,
5356
5332
  messageId: "",
5357
5333
  error: err instanceof Error ? err : new Error(String(err))
@@ -5370,11 +5346,11 @@ var baiduAppPlugin = {
5370
5346
  }
5371
5347
  const account = resolveBaiduAppAccount({ cfg: ctx.cfg, accountId: ctx.accountId });
5372
5348
  if (!account.configured) {
5373
- ctx.log?.info(`[baidu-app] account ${ctx.accountId} not configured; webhook not registered`);
5349
+ ctx.log?.info(`[openclaw-baiduapp] account ${ctx.accountId} not configured; webhook not registered`);
5374
5350
  ctx.setStatus?.({ accountId: ctx.accountId, running: false, configured: false });
5375
5351
  return;
5376
5352
  }
5377
- const path = (account.config.webhookPath ?? "/baidu-app").trim();
5353
+ const path = (account.config.webhookPath ?? "/openclaw-baiduapp").trim();
5378
5354
  const unregister = registerBaiduAppWebhookTarget({
5379
5355
  account,
5380
5356
  config: ctx.cfg ?? {},
@@ -5391,7 +5367,7 @@ var baiduAppPlugin = {
5391
5367
  }
5392
5368
  unregisterHooks.set(ctx.accountId, unregister);
5393
5369
  ctx.log?.info(
5394
- `[baidu-app] webhook registered at ${path} for account ${ctx.accountId} (canSendActive=${account.canSendActive})`
5370
+ `[openclaw-baiduapp] webhook registered at ${path} for account ${ctx.accountId} (canSendActive=${account.canSendActive})`
5395
5371
  );
5396
5372
  ctx.setStatus?.({
5397
5373
  accountId: ctx.accountId,
@@ -5416,7 +5392,7 @@ var baiduAppPlugin = {
5416
5392
  // src/send.ts
5417
5393
  function normalizeTarget(target, type) {
5418
5394
  let normalized = target.trim();
5419
- const channelPrefix = "baidu-app:";
5395
+ const channelPrefix = "openclaw-baiduapp:";
5420
5396
  if (normalized.startsWith(channelPrefix)) {
5421
5397
  normalized = normalized.slice(channelPrefix.length);
5422
5398
  }
@@ -5474,7 +5450,7 @@ async function sendBaidu(account, target, options) {
5474
5450
  };
5475
5451
  }
5476
5452
  let normalizedTarget = target.trim();
5477
- const channelPrefix = "baidu-app:";
5453
+ const channelPrefix = "openclaw-baiduapp:";
5478
5454
  if (normalizedTarget.startsWith(channelPrefix)) {
5479
5455
  normalizedTarget = normalizedTarget.slice(channelPrefix.length);
5480
5456
  }
@@ -5504,6 +5480,6 @@ var plugin = {
5504
5480
  };
5505
5481
  var index_default = plugin;
5506
5482
 
5507
- export { DEFAULT_ACCOUNT_ID, baiduAppPlugin, clearAccessTokenCache, clearAllAccessTokenCache, index_default as default, getAccessToken, getBaiduAppRuntime, normalizeTarget, parseTarget, sendBaidu, sendBaiduAppMessage, sendBaiduDM, setBaiduAppRuntime };
5483
+ export { DEFAULT_ACCOUNT_ID, baiduAppPlugin, index_default as default, getBaiduAppRuntime, normalizeTarget, parseTarget, sendBaidu, sendBaiduAppMessage, sendBaiduDM, setBaiduAppRuntime };
5508
5484
  //# sourceMappingURL=index.js.map
5509
5485
  //# sourceMappingURL=index.js.map