@searchfe/openclaw-baiduapp 0.1.0-beta.5 → 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
@@ -4055,7 +4055,6 @@ var BaiduAppAccountSchema = external_exports.object({
4055
4055
  webhookPath: external_exports.string().optional(),
4056
4056
  token: external_exports.string().optional(),
4057
4057
  encodingAESKey: external_exports.string().optional(),
4058
- receiveId: external_exports.string().optional(),
4059
4058
  appKey: external_exports.string().optional(),
4060
4059
  appSecret: external_exports.string().optional(),
4061
4060
  apiBase: external_exports.string().optional(),
@@ -4077,7 +4076,6 @@ var BaiduAppConfigJsonSchema = {
4077
4076
  webhookPath: { type: "string" },
4078
4077
  token: { type: "string" },
4079
4078
  encodingAESKey: { type: "string" },
4080
- receiveId: { type: "string" },
4081
4079
  appKey: { type: "string" },
4082
4080
  appSecret: { type: "string" },
4083
4081
  apiBase: { type: "string" },
@@ -4096,7 +4094,6 @@ var BaiduAppConfigJsonSchema = {
4096
4094
  webhookPath: { type: "string" },
4097
4095
  token: { type: "string" },
4098
4096
  encodingAESKey: { type: "string" },
4099
- receiveId: { type: "string" },
4100
4097
  appKey: { type: "string" },
4101
4098
  appSecret: { type: "string" },
4102
4099
  apiBase: { type: "string" },
@@ -4114,7 +4111,7 @@ function normalizeAccountId(raw) {
4114
4111
  return trimmed || DEFAULT_ACCOUNT_ID;
4115
4112
  }
4116
4113
  function listConfiguredAccountIds(cfg) {
4117
- const accounts = cfg.channels?.["baidu-app"]?.accounts;
4114
+ const accounts = cfg.channels?.["openclaw-baiduapp"]?.accounts;
4118
4115
  if (!accounts || typeof accounts !== "object") {
4119
4116
  return [];
4120
4117
  }
@@ -4128,7 +4125,7 @@ function listBaiduAppAccountIds(cfg) {
4128
4125
  return ids.sort((a, b) => a.localeCompare(b));
4129
4126
  }
4130
4127
  function resolveDefaultBaiduAppAccountId(cfg) {
4131
- const baiduAppConfig = cfg.channels?.["baidu-app"];
4128
+ const baiduAppConfig = cfg.channels?.["openclaw-baiduapp"];
4132
4129
  if (baiduAppConfig?.defaultAccount?.trim()) {
4133
4130
  return baiduAppConfig.defaultAccount.trim();
4134
4131
  }
@@ -4139,31 +4136,30 @@ function resolveDefaultBaiduAppAccountId(cfg) {
4139
4136
  return ids[0] ?? DEFAULT_ACCOUNT_ID;
4140
4137
  }
4141
4138
  function resolveAccountConfig(cfg, accountId) {
4142
- const accounts = cfg.channels?.["baidu-app"]?.accounts;
4139
+ const accounts = cfg.channels?.["openclaw-baiduapp"]?.accounts;
4143
4140
  if (!accounts || typeof accounts !== "object") {
4144
4141
  return void 0;
4145
4142
  }
4146
4143
  return accounts[accountId];
4147
4144
  }
4148
4145
  function mergeBaiduAppAccountConfig(cfg, accountId) {
4149
- const base = cfg.channels?.["baidu-app"] ?? {};
4146
+ const base = cfg.channels?.["openclaw-baiduapp"] ?? {};
4150
4147
  const { accounts: _ignored, defaultAccount: _ignored2, ...baseConfig } = base;
4151
4148
  const account = resolveAccountConfig(cfg, accountId) ?? {};
4152
4149
  return { ...baseConfig, ...account };
4153
4150
  }
4154
4151
  function resolveBaiduAppAccount(params) {
4155
4152
  const accountId = normalizeAccountId(params.accountId);
4156
- const baseEnabled = params.cfg.channels?.["baidu-app"]?.enabled !== false;
4153
+ const baseEnabled = params.cfg.channels?.["openclaw-baiduapp"]?.enabled !== false;
4157
4154
  const merged = mergeBaiduAppAccountConfig(params.cfg, accountId);
4158
4155
  const enabled = baseEnabled && merged.enabled !== false;
4159
4156
  const isDefaultAccount = accountId === DEFAULT_ACCOUNT_ID;
4160
4157
  const token = merged.token?.trim() || (isDefaultAccount ? process.env.BAIDU_APP_TOKEN?.trim() : void 0) || void 0;
4161
4158
  const encodingAESKey = merged.encodingAESKey?.trim() || (isDefaultAccount ? process.env.BAIDU_APP_ENCODING_AES_KEY?.trim() : void 0) || void 0;
4162
- const receiveId = merged.receiveId?.trim() ?? "";
4163
4159
  const appKey = merged.appKey?.trim() || (isDefaultAccount ? process.env.BAIDU_APP_KEY?.trim() : void 0) || void 0;
4164
4160
  const appSecret = merged.appSecret?.trim() || (isDefaultAccount ? process.env.BAIDU_APP_SECRET?.trim() : void 0) || void 0;
4165
4161
  const configured = Boolean(token && encodingAESKey);
4166
- const canSendActive = Boolean(appKey && appSecret);
4162
+ const canSendActive = Boolean(appKey && token && encodingAESKey);
4167
4163
  const rawApiBase = merged.apiBase?.trim() || (isDefaultAccount ? process.env.BAIDU_API_BASE?.trim() : void 0) || void 0;
4168
4164
  const apiBase = (rawApiBase || DEFAULT_API_BASE).replace(/\/+$/, "");
4169
4165
  return {
@@ -4173,7 +4169,6 @@ function resolveBaiduAppAccount(params) {
4173
4169
  configured,
4174
4170
  token,
4175
4171
  encodingAESKey,
4176
- receiveId,
4177
4172
  appKey,
4178
4173
  appSecret,
4179
4174
  apiBase,
@@ -4220,69 +4215,120 @@ function checkDmPolicy(params) {
4220
4215
  return { allowed: true };
4221
4216
  }
4222
4217
  }
4223
-
4224
- // src/api.ts
4225
- var accessTokenCache = /* @__PURE__ */ new Map();
4226
- var ACCESS_TOKEN_TTL_MS = 7200 * 1e3 - 5 * 60 * 1e3;
4227
- async function getAccessToken(account) {
4228
- if (!account.appKey || !account.appSecret) {
4229
- throw new Error("appKey or appSecret not configured");
4230
- }
4231
- const key = `${account.appKey}`;
4232
- const cached = accessTokenCache.get(key);
4233
- if (cached && Date.now() < cached.expiresAt) {
4234
- return cached.token;
4235
- }
4236
- const tokenUrl = `${account.apiBase}/auth/token`;
4237
- const url = `${tokenUrl}?appKey=${encodeURIComponent(account.appKey)}&appSecret=${encodeURIComponent(account.appSecret)}`;
4238
- const resp = await fetch(url);
4239
- const text = await resp.text();
4240
- if (!text) {
4241
- 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");
4242
4222
  }
4243
- let data;
4244
- try {
4245
- data = JSON.parse(text);
4246
- } catch {
4247
- 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})`);
4248
4227
  }
4249
- if (data.errcode !== void 0 && data.errcode !== 0) {
4250
- throw new Error(`gettoken failed: ${data.errmsg ?? "unknown error"} (errcode=${data.errcode})`);
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");
4251
4239
  }
4252
- if (!data.access_token) {
4253
- throw new Error("gettoken returned empty access_token");
4240
+ const pad = buf[buf.length - 1];
4241
+ if (!pad || pad < 1 || pad > blockSize || pad > buf.length) {
4242
+ throw new Error("invalid pkcs7 padding");
4254
4243
  }
4255
- accessTokenCache.set(key, {
4256
- token: data.access_token,
4257
- expiresAt: Date.now() + ACCESS_TOKEN_TTL_MS
4244
+ for (let i = 1; i <= pad; i += 1) {
4245
+ if (buf[buf.length - i] !== pad) {
4246
+ throw new Error("invalid pkcs7 padding");
4247
+ }
4248
+ }
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
4258
4264
  });
4259
- return data.access_token;
4265
+ return expected === params.signature;
4260
4266
  }
4261
- function clearAccessTokenCache(account) {
4262
- const key = `${account.appKey}`;
4263
- 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");
4264
4284
  }
4265
- function clearAllAccessTokenCache() {
4266
- 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");
4267
4298
  }
4299
+
4300
+ // src/api.ts
4268
4301
  async function sendBaiduAppMessage(account, target, message) {
4269
4302
  if (!account.canSendActive) {
4270
4303
  return {
4271
4304
  ok: false,
4272
4305
  errcode: -1,
4273
- errmsg: "Account not configured for active sending (missing appKey or appSecret)"
4306
+ errmsg: "Account not configured for active sending (missing appKey, token, or encodingAESKey)"
4274
4307
  };
4275
4308
  }
4276
- const token = await getAccessToken(account);
4277
4309
  const payload = {
4278
4310
  msgtype: "text",
4279
4311
  text: { content: message },
4280
4312
  touser: target.userId
4281
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
+ });
4282
4327
  const sendMessageUrl = `${account.apiBase}/chat/openclaw/callback`;
4283
- 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, {
4284
4330
  method: "POST",
4285
- body: JSON.stringify(payload),
4331
+ body: JSON.stringify({ encrypt }),
4286
4332
  headers: { "Content-Type": "application/json" }
4287
4333
  });
4288
4334
  const text = await resp.text();
@@ -4334,7 +4380,7 @@ function resolveSenderId(msg) {
4334
4380
  async function dispatchBaiduAppMessage(params) {
4335
4381
  const { cfg, account, msg, core, hooks } = params;
4336
4382
  const safeCfg = cfg ?? {};
4337
- const logger = createLogger("baidu-app", { log: params.log, error: params.error });
4383
+ const logger = createLogger("openclaw-baiduapp", { log: params.log, error: params.error });
4338
4384
  const senderId = resolveSenderId(msg);
4339
4385
  const chatId = senderId;
4340
4386
  const accountConfig = account?.config ?? {};
@@ -4361,7 +4407,7 @@ async function dispatchBaiduAppMessage(params) {
4361
4407
  }
4362
4408
  const route = channel.routing.resolveAgentRoute({
4363
4409
  cfg: safeCfg,
4364
- channel: "baidu-app",
4410
+ channel: "openclaw-baiduapp",
4365
4411
  accountId: account.accountId,
4366
4412
  peer: { kind: "dm", id: chatId }
4367
4413
  });
@@ -4389,7 +4435,7 @@ async function dispatchBaiduAppMessage(params) {
4389
4435
  body: rawBody
4390
4436
  }) : rawBody;
4391
4437
  const msgid = msg.msgid ?? msg.MsgId ?? void 0;
4392
- const from = `baidu-app:user:${senderId}`;
4438
+ const from = `openclaw-baiduapp:user:${senderId}`;
4393
4439
  const to = `user:${senderId}`;
4394
4440
  const ctxPayload = channel.reply?.finalizeInboundContext ? channel.reply.finalizeInboundContext({
4395
4441
  Body: body,
@@ -4403,10 +4449,10 @@ async function dispatchBaiduAppMessage(params) {
4403
4449
  ConversationLabel: fromLabel,
4404
4450
  SenderName: senderId,
4405
4451
  SenderId: senderId,
4406
- Provider: "baidu-app",
4407
- Surface: "baidu-app",
4452
+ Provider: "openclaw-baiduapp",
4453
+ Surface: "openclaw-baiduapp",
4408
4454
  MessageSid: msgid,
4409
- OriginatingChannel: "baidu-app",
4455
+ OriginatingChannel: "openclaw-baiduapp",
4410
4456
  OriginatingTo: to
4411
4457
  }) : {
4412
4458
  Body: body,
@@ -4420,10 +4466,10 @@ async function dispatchBaiduAppMessage(params) {
4420
4466
  ConversationLabel: fromLabel,
4421
4467
  SenderName: senderId,
4422
4468
  SenderId: senderId,
4423
- Provider: "baidu-app",
4424
- Surface: "baidu-app",
4469
+ Provider: "openclaw-baiduapp",
4470
+ Surface: "openclaw-baiduapp",
4425
4471
  MessageSid: msgid,
4426
- OriginatingChannel: "baidu-app",
4472
+ OriginatingChannel: "openclaw-baiduapp",
4427
4473
  OriginatingTo: to
4428
4474
  };
4429
4475
  if (channel.session?.recordInboundSession && storePath) {
@@ -4432,11 +4478,15 @@ async function dispatchBaiduAppMessage(params) {
4432
4478
  sessionKey: ctxPayload.SessionKey ?? route.sessionKey,
4433
4479
  ctx: ctxPayload,
4434
4480
  onRecordError: (err) => {
4435
- logger.error(`baidu-app: failed updating session meta: ${String(err)}`);
4481
+ logger.error(`openclaw-baiduapp: failed updating session meta: ${String(err)}`);
4436
4482
  }
4437
4483
  });
4438
4484
  }
4439
- 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;
4440
4490
  logger.info(`dispatching to agent: sessionKey=${route.sessionKey} sender=${senderId}`);
4441
4491
  await channel.reply.dispatchReplyWithBufferedBlockDispatcher({
4442
4492
  ctx: ctxPayload,
@@ -4460,96 +4510,6 @@ async function dispatchBaiduAppMessage(params) {
4460
4510
  });
4461
4511
  logger.info(`agent reply dispatch complete: sessionKey=${route.sessionKey} sender=${senderId}`);
4462
4512
  }
4463
- function decodeEncodingAESKey(encodingAESKey) {
4464
- const trimmed = encodingAESKey.trim();
4465
- if (!trimmed) {
4466
- throw new Error("encodingAESKey missing");
4467
- }
4468
- const withPadding = trimmed.endsWith("=") ? trimmed : `${trimmed}=`;
4469
- const key = Buffer.from(withPadding, "base64");
4470
- if (key.length !== 32) {
4471
- throw new Error(`invalid encodingAESKey (expected 32 bytes after base64 decode, got ${key.length})`);
4472
- }
4473
- return key;
4474
- }
4475
- var PKCS7_BLOCK_SIZE = 32;
4476
- function pkcs7Pad(buf, blockSize) {
4477
- const mod = buf.length % blockSize;
4478
- const pad = mod === 0 ? blockSize : blockSize - mod;
4479
- return Buffer.concat([buf, Buffer.alloc(pad, pad)]);
4480
- }
4481
- function pkcs7Unpad(buf, blockSize) {
4482
- if (buf.length === 0) {
4483
- throw new Error("invalid pkcs7 payload");
4484
- }
4485
- const pad = buf[buf.length - 1];
4486
- if (!pad || pad < 1 || pad > blockSize || pad > buf.length) {
4487
- throw new Error("invalid pkcs7 padding");
4488
- }
4489
- for (let i = 1; i <= pad; i += 1) {
4490
- if (buf[buf.length - i] !== pad) {
4491
- throw new Error("invalid pkcs7 padding");
4492
- }
4493
- }
4494
- return buf.subarray(0, buf.length - pad);
4495
- }
4496
- function sha1Hex(input) {
4497
- return crypto.createHash("sha1").update(input).digest("hex");
4498
- }
4499
- function computeBaiduAppMsgSignature(params) {
4500
- const parts = [params.token, params.timestamp, params.nonce, params.encrypt].map((value) => String(value ?? "")).sort();
4501
- return sha1Hex(parts.join(""));
4502
- }
4503
- function verifyBaiduAppSignature(params) {
4504
- const expected = computeBaiduAppMsgSignature({
4505
- token: params.token,
4506
- timestamp: params.timestamp,
4507
- nonce: params.nonce,
4508
- encrypt: params.encrypt
4509
- });
4510
- return expected === params.signature;
4511
- }
4512
- function decryptBaiduAppEncrypted(params) {
4513
- const aesKey = decodeEncodingAESKey(params.encodingAESKey);
4514
- const iv = aesKey.subarray(0, 16);
4515
- const decipher = crypto.createDecipheriv("aes-256-cbc", aesKey, iv);
4516
- decipher.setAutoPadding(false);
4517
- const decryptedPadded = Buffer.concat([decipher.update(Buffer.from(params.encrypt, "base64")), decipher.final()]);
4518
- const decrypted = pkcs7Unpad(decryptedPadded, PKCS7_BLOCK_SIZE);
4519
- if (decrypted.length < 20) {
4520
- throw new Error(`invalid decrypted payload (expected at least 20 bytes, got ${decrypted.length})`);
4521
- }
4522
- const msgLen = decrypted.readUInt32BE(16);
4523
- const msgStart = 20;
4524
- const msgEnd = msgStart + msgLen;
4525
- if (msgEnd > decrypted.length) {
4526
- throw new Error(`invalid decrypted msg length (msgEnd=${msgEnd}, payloadLength=${decrypted.length})`);
4527
- }
4528
- const msg = decrypted.subarray(msgStart, msgEnd).toString("utf8");
4529
- const receiveId = params.receiveId ?? "";
4530
- if (receiveId) {
4531
- const trailing = decrypted.subarray(msgEnd).toString("utf8");
4532
- if (trailing !== receiveId) {
4533
- throw new Error(`receiveId mismatch (expected "${receiveId}", got "${trailing}")`);
4534
- }
4535
- }
4536
- return msg;
4537
- }
4538
- function encryptBaiduAppPlaintext(params) {
4539
- const aesKey = decodeEncodingAESKey(params.encodingAESKey);
4540
- const iv = aesKey.subarray(0, 16);
4541
- const random16 = crypto.randomBytes(16);
4542
- const msg = Buffer.from(params.plaintext ?? "", "utf8");
4543
- const msgLen = Buffer.alloc(4);
4544
- msgLen.writeUInt32BE(msg.length, 0);
4545
- const receiveId = Buffer.from(params.receiveId ?? "", "utf8");
4546
- const raw = Buffer.concat([random16, msgLen, msg, receiveId]);
4547
- const padded = pkcs7Pad(raw, PKCS7_BLOCK_SIZE);
4548
- const cipher = crypto.createCipheriv("aes-256-cbc", aesKey, iv);
4549
- cipher.setAutoPadding(false);
4550
- const encrypted = Buffer.concat([cipher.update(padded), cipher.final()]);
4551
- return encrypted.toString("base64");
4552
- }
4553
4513
 
4554
4514
  // src/runtime.ts
4555
4515
  var runtime = null;
@@ -4690,7 +4650,6 @@ function buildEncryptedJsonReply(params) {
4690
4650
  const plaintext = JSON.stringify(params.plaintextJson ?? {});
4691
4651
  const encrypt = encryptBaiduAppPlaintext({
4692
4652
  encodingAESKey: params.account.encodingAESKey ?? "",
4693
- receiveId: params.account.receiveId ?? "",
4694
4653
  plaintext
4695
4654
  });
4696
4655
  const msgsignature = computeBaiduAppMsgSignature({
@@ -4779,7 +4738,6 @@ function decryptBaiduAppCandidates(params) {
4779
4738
  try {
4780
4739
  const plaintext = decryptBaiduAppEncrypted({
4781
4740
  encodingAESKey: candidate.account.encodingAESKey,
4782
- receiveId: candidate.account.receiveId,
4783
4741
  encrypt: params.encrypt
4784
4742
  });
4785
4743
  const msg = parseBaiduAppPlainMessage(plaintext);
@@ -4794,7 +4752,9 @@ function selectDecryptedTarget(params) {
4794
4752
  return params.candidates[0];
4795
4753
  }
4796
4754
  const accountIds = params.candidates.map((candidate) => candidate.target.account.accountId).join(", ");
4797
- 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
+ );
4798
4758
  return params.candidates[0];
4799
4759
  }
4800
4760
  function appendStreamContent(state, nextText) {
@@ -4805,7 +4765,7 @@ ${nextText}`.trim() : nextText.trim();
4805
4765
  state.updatedAt = Date.now();
4806
4766
  }
4807
4767
  function buildLogger(target) {
4808
- return createLogger("baidu-app", {
4768
+ return createLogger("openclaw-baiduapp", {
4809
4769
  log: target.runtime.log,
4810
4770
  error: target.runtime.error
4811
4771
  });
@@ -4938,7 +4898,7 @@ async function handleBaiduAppWebhookRequest(req, res) {
4938
4898
  const decryptable = signatureMatched.filter((candidate) => Boolean(candidate.account.encodingAESKey));
4939
4899
  if (decryptable.length === 0) {
4940
4900
  logger.warn(`no account has encodingAESKey configured`);
4941
- jsonError(res, "baidu-app not configured");
4901
+ jsonError(res, "openclaw-baiduapp not configured");
4942
4902
  return true;
4943
4903
  }
4944
4904
  const decryptedCandidates = decryptBaiduAppCandidates({
@@ -4954,7 +4914,7 @@ async function handleBaiduAppWebhookRequest(req, res) {
4954
4914
  const target = selected.target;
4955
4915
  if (!target.account.configured || !target.account.token || !target.account.encodingAESKey) {
4956
4916
  logger.warn(`selected account ${target.account.accountId} not fully configured`);
4957
- jsonError(res, "baidu-app not configured");
4917
+ jsonError(res, "openclaw-baiduapp not configured");
4958
4918
  return true;
4959
4919
  }
4960
4920
  const msg = selected.msg;
@@ -5084,7 +5044,7 @@ async function handleBaiduAppWebhookRequest(req, res) {
5084
5044
  current.finished = true;
5085
5045
  current.updatedAt = Date.now();
5086
5046
  }
5087
- logger.error(`baidu-app agent failed: ${String(err)}`);
5047
+ logger.error(`openclaw-baiduapp agent failed: ${String(err)}`);
5088
5048
  }
5089
5049
  };
5090
5050
  dispatchBaiduAppMessage({
@@ -5165,18 +5125,18 @@ async function handleBaiduAppWebhookRequest(req, res) {
5165
5125
 
5166
5126
  // src/channel.ts
5167
5127
  var meta = {
5168
- id: "baidu-app",
5128
+ id: "openclaw-baiduapp",
5169
5129
  label: "Baidu App",
5170
5130
  selectionLabel: "Baidu Search AI (\u767E\u5EA6\u641C\u7D22\u5BF9\u8BDD\u5F0FAI)",
5171
- docsPath: "/channels/baidu-app",
5172
- docsLabel: "baidu-app",
5131
+ docsPath: "/channels/openclaw-baiduapp",
5132
+ docsLabel: "openclaw-baiduapp",
5173
5133
  blurb: "\u767E\u5EA6\u641C\u7D22\u5BF9\u8BDD\u5F0FAI\uFF0C\u652F\u6301\u4E3B\u52A8\u53D1\u9001\u6D88\u606F",
5174
5134
  aliases: ["baidu-ai", "\u767E\u5EA6\u641C\u7D22AI"],
5175
5135
  order: 85
5176
5136
  };
5177
5137
  var unregisterHooks = /* @__PURE__ */ new Map();
5178
5138
  var baiduAppPlugin = {
5179
- id: "baidu-app",
5139
+ id: "openclaw-baiduapp",
5180
5140
  meta: {
5181
5141
  ...meta
5182
5142
  },
@@ -5191,21 +5151,21 @@ var baiduAppPlugin = {
5191
5151
  activeSend: true
5192
5152
  },
5193
5153
  configSchema: BaiduAppConfigJsonSchema,
5194
- reload: { configPrefixes: ["channels.baidu-app"] },
5154
+ reload: { configPrefixes: ["channels.openclaw-baiduapp"] },
5195
5155
  config: {
5196
5156
  listAccountIds: (cfg) => listBaiduAppAccountIds(cfg),
5197
5157
  resolveAccount: (cfg, accountId) => resolveBaiduAppAccount({ cfg, accountId }),
5198
5158
  defaultAccountId: (cfg) => resolveDefaultBaiduAppAccountId(cfg),
5199
5159
  setAccountEnabled: (params) => {
5200
5160
  const accountId = params.accountId ?? DEFAULT_ACCOUNT_ID;
5201
- const useAccount = Boolean(params.cfg.channels?.["baidu-app"]?.accounts?.[accountId]);
5161
+ const useAccount = Boolean(params.cfg.channels?.["openclaw-baiduapp"]?.accounts?.[accountId]);
5202
5162
  if (!useAccount) {
5203
5163
  return {
5204
5164
  ...params.cfg,
5205
5165
  channels: {
5206
5166
  ...params.cfg.channels,
5207
- "baidu-app": {
5208
- ...params.cfg.channels?.["baidu-app"] ?? {},
5167
+ "openclaw-baiduapp": {
5168
+ ...params.cfg.channels?.["openclaw-baiduapp"] ?? {},
5209
5169
  enabled: params.enabled
5210
5170
  }
5211
5171
  }
@@ -5215,12 +5175,12 @@ var baiduAppPlugin = {
5215
5175
  ...params.cfg,
5216
5176
  channels: {
5217
5177
  ...params.cfg.channels,
5218
- "baidu-app": {
5219
- ...params.cfg.channels?.["baidu-app"] ?? {},
5178
+ "openclaw-baiduapp": {
5179
+ ...params.cfg.channels?.["openclaw-baiduapp"] ?? {},
5220
5180
  accounts: {
5221
- ...params.cfg.channels?.["baidu-app"]?.accounts ?? {},
5181
+ ...params.cfg.channels?.["openclaw-baiduapp"]?.accounts ?? {},
5222
5182
  [accountId]: {
5223
- ...params.cfg.channels?.["baidu-app"]?.accounts?.[accountId] ?? {},
5183
+ ...params.cfg.channels?.["openclaw-baiduapp"]?.accounts?.[accountId] ?? {},
5224
5184
  enabled: params.enabled
5225
5185
  }
5226
5186
  }
@@ -5231,7 +5191,7 @@ var baiduAppPlugin = {
5231
5191
  deleteAccount: (params) => {
5232
5192
  const accountId = params.accountId ?? DEFAULT_ACCOUNT_ID;
5233
5193
  const next = { ...params.cfg };
5234
- const current = next.channels?.["baidu-app"];
5194
+ const current = next.channels?.["openclaw-baiduapp"];
5235
5195
  if (!current) {
5236
5196
  return next;
5237
5197
  }
@@ -5239,7 +5199,7 @@ var baiduAppPlugin = {
5239
5199
  const { accounts: _ignored, defaultAccount: _ignored2, ...rest } = current;
5240
5200
  next.channels = {
5241
5201
  ...next.channels,
5242
- "baidu-app": { ...rest, enabled: false }
5202
+ "openclaw-baiduapp": { ...rest, enabled: false }
5243
5203
  };
5244
5204
  return next;
5245
5205
  }
@@ -5247,7 +5207,7 @@ var baiduAppPlugin = {
5247
5207
  delete accounts[accountId];
5248
5208
  next.channels = {
5249
5209
  ...next.channels,
5250
- "baidu-app": {
5210
+ "openclaw-baiduapp": {
5251
5211
  ...current,
5252
5212
  accounts: Object.keys(accounts).length > 0 ? accounts : void 0
5253
5213
  }
@@ -5261,7 +5221,7 @@ var baiduAppPlugin = {
5261
5221
  enabled: account.enabled,
5262
5222
  configured: account.configured,
5263
5223
  canSendActive: account.canSendActive,
5264
- webhookPath: account.config.webhookPath ?? "/baidu-app"
5224
+ webhookPath: account.config.webhookPath ?? "/openclaw-baiduapp"
5265
5225
  }),
5266
5226
  resolveAllowFrom: (params) => {
5267
5227
  const account = resolveBaiduAppAccount({ cfg: params.cfg, accountId: params.accountId });
@@ -5275,7 +5235,7 @@ var baiduAppPlugin = {
5275
5235
  if (!raw) {
5276
5236
  return false;
5277
5237
  }
5278
- if (raw.startsWith("baidu-app:")) {
5238
+ if (raw.startsWith("openclaw-baiduapp:")) {
5279
5239
  return true;
5280
5240
  }
5281
5241
  const knownChannelPrefixes = [
@@ -5300,7 +5260,7 @@ var baiduAppPlugin = {
5300
5260
  if (!raw) {
5301
5261
  return null;
5302
5262
  }
5303
- const channelPrefix = "baidu-app:";
5263
+ const channelPrefix = "openclaw-baiduapp:";
5304
5264
  if (raw.startsWith(channelPrefix)) {
5305
5265
  raw = raw.slice(channelPrefix.length);
5306
5266
  }
@@ -5315,9 +5275,9 @@ var baiduAppPlugin = {
5315
5275
  }
5316
5276
  }
5317
5277
  if (to.startsWith("user:")) {
5318
- return { channel: "baidu-app", accountId, to: to.slice(5) };
5278
+ return { channel: "openclaw-baiduapp", accountId, to: to.slice(5) };
5319
5279
  }
5320
- return { channel: "baidu-app", accountId, to };
5280
+ return { channel: "openclaw-baiduapp", accountId, to };
5321
5281
  },
5322
5282
  resolveTargets: (params) => {
5323
5283
  const results = [];
@@ -5332,7 +5292,7 @@ var baiduAppPlugin = {
5332
5292
  }
5333
5293
  return results;
5334
5294
  },
5335
- getTargetFormats: () => ["baidu-app:user:<userId>", "user:<userId>", "<userId>"]
5295
+ getTargetFormats: () => ["openclaw-baiduapp:user:<userId>", "user:<userId>", "<userId>"]
5336
5296
  },
5337
5297
  outbound: {
5338
5298
  deliveryMode: "direct",
@@ -5340,14 +5300,14 @@ var baiduAppPlugin = {
5340
5300
  const account = resolveBaiduAppAccount({ cfg: params.cfg, accountId: params.accountId });
5341
5301
  if (!account.canSendActive) {
5342
5302
  return {
5343
- channel: "baidu-app",
5303
+ channel: "openclaw-baiduapp",
5344
5304
  ok: false,
5345
5305
  messageId: "",
5346
5306
  error: new Error("Account not configured for active sending (missing appKey or appSecret)")
5347
5307
  };
5348
5308
  }
5349
5309
  let to = params.to;
5350
- const channelPrefix = "baidu-app:";
5310
+ const channelPrefix = "openclaw-baiduapp:";
5351
5311
  if (to.startsWith(channelPrefix)) {
5352
5312
  to = to.slice(channelPrefix.length);
5353
5313
  }
@@ -5360,14 +5320,14 @@ var baiduAppPlugin = {
5360
5320
  try {
5361
5321
  const result = await sendBaiduAppMessage(account, target, params.text);
5362
5322
  return {
5363
- channel: "baidu-app",
5323
+ channel: "openclaw-baiduapp",
5364
5324
  ok: result.ok,
5365
5325
  messageId: result.msgid ?? "",
5366
5326
  error: result.ok ? void 0 : new Error(result.errmsg ?? "send failed")
5367
5327
  };
5368
5328
  } catch (err) {
5369
5329
  return {
5370
- channel: "baidu-app",
5330
+ channel: "openclaw-baiduapp",
5371
5331
  ok: false,
5372
5332
  messageId: "",
5373
5333
  error: err instanceof Error ? err : new Error(String(err))
@@ -5386,11 +5346,11 @@ var baiduAppPlugin = {
5386
5346
  }
5387
5347
  const account = resolveBaiduAppAccount({ cfg: ctx.cfg, accountId: ctx.accountId });
5388
5348
  if (!account.configured) {
5389
- 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`);
5390
5350
  ctx.setStatus?.({ accountId: ctx.accountId, running: false, configured: false });
5391
5351
  return;
5392
5352
  }
5393
- const path = (account.config.webhookPath ?? "/baidu-app").trim();
5353
+ const path = (account.config.webhookPath ?? "/openclaw-baiduapp").trim();
5394
5354
  const unregister = registerBaiduAppWebhookTarget({
5395
5355
  account,
5396
5356
  config: ctx.cfg ?? {},
@@ -5407,7 +5367,7 @@ var baiduAppPlugin = {
5407
5367
  }
5408
5368
  unregisterHooks.set(ctx.accountId, unregister);
5409
5369
  ctx.log?.info(
5410
- `[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})`
5411
5371
  );
5412
5372
  ctx.setStatus?.({
5413
5373
  accountId: ctx.accountId,
@@ -5432,7 +5392,7 @@ var baiduAppPlugin = {
5432
5392
  // src/send.ts
5433
5393
  function normalizeTarget(target, type) {
5434
5394
  let normalized = target.trim();
5435
- const channelPrefix = "baidu-app:";
5395
+ const channelPrefix = "openclaw-baiduapp:";
5436
5396
  if (normalized.startsWith(channelPrefix)) {
5437
5397
  normalized = normalized.slice(channelPrefix.length);
5438
5398
  }
@@ -5490,7 +5450,7 @@ async function sendBaidu(account, target, options) {
5490
5450
  };
5491
5451
  }
5492
5452
  let normalizedTarget = target.trim();
5493
- const channelPrefix = "baidu-app:";
5453
+ const channelPrefix = "openclaw-baiduapp:";
5494
5454
  if (normalizedTarget.startsWith(channelPrefix)) {
5495
5455
  normalizedTarget = normalizedTarget.slice(channelPrefix.length);
5496
5456
  }
@@ -5520,6 +5480,6 @@ var plugin = {
5520
5480
  };
5521
5481
  var index_default = plugin;
5522
5482
 
5523
- 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 };
5524
5484
  //# sourceMappingURL=index.js.map
5525
5485
  //# sourceMappingURL=index.js.map