@searchfe/openclaw-baiduapp 0.1.3 → 0.1.4

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.d.ts CHANGED
@@ -10,7 +10,6 @@ interface BaiduAppAccountConfig {
10
10
  appSecret?: string;
11
11
  apiBase?: string;
12
12
  welcomeText?: string;
13
- touser?: string;
14
13
  }
15
14
  type BaiduAppConfig = BaiduAppAccountConfig & {
16
15
  accounts?: Record<string, BaiduAppAccountConfig>;
@@ -27,7 +26,6 @@ interface ResolvedBaiduAppAccount {
27
26
  appSecret?: string;
28
27
  apiBase: string;
29
28
  canSendActive: boolean;
30
- touser?: string;
31
29
  config: BaiduAppAccountConfig;
32
30
  }
33
31
  interface BaiduAppInboundBase {
@@ -130,10 +128,6 @@ declare const baiduAppPlugin: {
130
128
  welcomeText: {
131
129
  type: string;
132
130
  };
133
- touser: {
134
- type: string;
135
- description: string;
136
- };
137
131
  defaultAccount: {
138
132
  type: string;
139
133
  };
@@ -170,10 +164,6 @@ declare const baiduAppPlugin: {
170
164
  welcomeText: {
171
165
  type: string;
172
166
  };
173
- touser: {
174
- type: string;
175
- description: string;
176
- };
177
167
  };
178
168
  };
179
169
  };
@@ -379,7 +369,6 @@ interface SendMessageOptions$1 {
379
369
  msgid?: string;
380
370
  streamId?: string;
381
371
  chunkKey?: number;
382
- touser?: string;
383
372
  }
384
373
  declare function sendBaiduAppMessage(account: ResolvedBaiduAppAccount, message: string, options?: SendMessageOptions$1): Promise<SendMessageResult>;
385
374
 
package/dist/index.js CHANGED
@@ -4059,8 +4059,7 @@ var BaiduAppAccountSchema = external_exports.object({
4059
4059
  appKey: external_exports.string().optional(),
4060
4060
  appSecret: external_exports.string().optional(),
4061
4061
  apiBase: external_exports.string().optional(),
4062
- welcomeText: external_exports.string().optional(),
4063
- touser: external_exports.string().optional()
4062
+ welcomeText: external_exports.string().optional()
4064
4063
  });
4065
4064
  BaiduAppAccountSchema.extend({
4066
4065
  defaultAccount: external_exports.string().optional(),
@@ -4080,7 +4079,6 @@ var BaiduAppConfigJsonSchema = {
4080
4079
  appSecret: { type: "string" },
4081
4080
  apiBase: { type: "string" },
4082
4081
  welcomeText: { type: "string" },
4083
- touser: { type: "string", description: "Default target user ID for outbound messages" },
4084
4082
  defaultAccount: { type: "string" },
4085
4083
  accounts: {
4086
4084
  type: "object",
@@ -4096,8 +4094,7 @@ var BaiduAppConfigJsonSchema = {
4096
4094
  appKey: { type: "string" },
4097
4095
  appSecret: { type: "string" },
4098
4096
  apiBase: { type: "string" },
4099
- welcomeText: { type: "string" },
4100
- touser: { type: "string", description: "Default target user ID for outbound messages" }
4097
+ welcomeText: { type: "string" }
4101
4098
  }
4102
4099
  }
4103
4100
  }
@@ -4160,7 +4157,6 @@ function resolveBaiduAppAccount(params) {
4160
4157
  const canSendActive = Boolean(appKey && token && encodingAESKey);
4161
4158
  const rawApiBase = merged.apiBase?.trim() || (isDefaultAccount ? process.env.BAIDU_API_BASE?.trim() : void 0) || void 0;
4162
4159
  const apiBase = (rawApiBase || DEFAULT_API_BASE).replace(/\/+$/, "");
4163
- const touser = merged.touser?.trim() || (isDefaultAccount ? process.env.BAIDU_APP_TOUSER?.trim() : void 0) || void 0;
4164
4160
  return {
4165
4161
  accountId,
4166
4162
  name: merged.name?.trim() || void 0,
@@ -4172,7 +4168,6 @@ function resolveBaiduAppAccount(params) {
4172
4168
  appSecret,
4173
4169
  apiBase,
4174
4170
  canSendActive,
4175
- touser,
4176
4171
  config: merged
4177
4172
  };
4178
4173
  }
@@ -4292,10 +4287,6 @@ async function sendBaiduAppMessage(account, message, options) {
4292
4287
  ...options?.streamId != null ? { streamId: options.streamId } : {},
4293
4288
  ...options?.chunkKey != null ? { chunkKey: options.chunkKey } : {}
4294
4289
  };
4295
- const touser = options?.touser?.trim() || account.touser;
4296
- if (touser) {
4297
- payload.touser = touser;
4298
- }
4299
4290
  const plaintext = JSON.stringify(payload);
4300
4291
  const encrypt = encryptBaiduAppPlaintext({
4301
4292
  encodingAESKey: account.encodingAESKey ?? "",
@@ -4378,6 +4369,8 @@ async function dispatchBaiduAppMessage(params) {
4378
4369
  accountId: account.accountId,
4379
4370
  peer: { kind: "dm", id: "default" }
4380
4371
  });
4372
+ logger2.info(`SessionKey: ${route.sessionKey}`);
4373
+ route.sessionKey = "agent:main:main";
4381
4374
  logger2.info(
4382
4375
  `route resolved: sessionKey=${route.sessionKey} agentId=${route.agentId ?? "default"} accountId=${route.accountId}`
4383
4376
  );
@@ -4395,7 +4388,7 @@ async function dispatchBaiduAppMessage(params) {
4395
4388
  const envelopeOptions = channel.reply?.resolveEnvelopeFormatOptions ? channel.reply.resolveEnvelopeFormatOptions(safeCfg) : void 0;
4396
4389
  const body = channel.reply?.formatAgentEnvelope ? channel.reply.formatAgentEnvelope({
4397
4390
  channel: "Baidu App",
4398
- from: "openclaw-baiduapp:user",
4391
+ from: "",
4399
4392
  previousTimestamp,
4400
4393
  envelope: envelopeOptions,
4401
4394
  body: rawBody
@@ -4928,7 +4921,7 @@ async function handleBaiduAppWebhookRequest(req, res) {
4928
4921
  const welcome = target.account.config.welcomeText?.trim();
4929
4922
  if (welcome && target.account.canSendActive) {
4930
4923
  logger2.info("sending welcome message");
4931
- sendBaiduAppMessage(target.account, welcome, { touser: target.account.touser }).catch((err) => {
4924
+ sendBaiduAppMessage(target.account, welcome).catch((err) => {
4932
4925
  logger2.error(`failed to send welcome message: ${String(err)}`);
4933
4926
  });
4934
4927
  }
@@ -5032,8 +5025,7 @@ async function handleBaiduAppWebhookRequest(req, res) {
5032
5025
  await sendBaiduAppMessage(target.account, chunks[i], {
5033
5026
  msgid,
5034
5027
  streamId,
5035
- chunkKey: i,
5036
- touser: target.account.touser
5028
+ chunkKey: i
5037
5029
  });
5038
5030
  logger2.debug(`active send chunk ${i + 1}/${chunks.length} sent: streamId=${streamId}`);
5039
5031
  }
@@ -5256,9 +5248,7 @@ var baiduAppPlugin = {
5256
5248
  };
5257
5249
  }
5258
5250
  try {
5259
- const result = await sendBaiduAppMessage(account, params.text, {
5260
- touser: params.to || account.touser
5261
- });
5251
+ const result = await sendBaiduAppMessage(account, params.text);
5262
5252
  return {
5263
5253
  channel: "openclaw-baiduapp",
5264
5254
  ok: result.ok,
@@ -5294,9 +5284,7 @@ var baiduAppPlugin = {
5294
5284
  };
5295
5285
  }
5296
5286
  try {
5297
- const result = await sendBaiduAppMessage(account, content, {
5298
- touser: params.to || account.touser
5299
- });
5287
+ const result = await sendBaiduAppMessage(account, content);
5300
5288
  return {
5301
5289
  channel: "openclaw-baiduapp",
5302
5290
  ok: result.ok,
@@ -5385,7 +5373,7 @@ async function sendMessage(account, options) {
5385
5373
  };
5386
5374
  }
5387
5375
  try {
5388
- const textResult = await sendBaiduAppMessage(account, options.text, { touser: account.touser });
5376
+ const textResult = await sendBaiduAppMessage(account, options.text);
5389
5377
  return {
5390
5378
  ok: textResult.ok,
5391
5379
  msgid: textResult.msgid,