@53ai/53ai-openclaw 1.1.0 → 1.1.1

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.cjs.js CHANGED
@@ -58,8 +58,26 @@ const WS_RECONNECT_BASE_DELAY_MS = 1000;
58
58
  // ============================================================================
59
59
  /** 文本分块限制 */
60
60
  const TEXT_CHUNK_LIMIT = 4000;
61
- /** 消息处理超时(毫秒) */
62
- const MESSAGE_PROCESS_TIMEOUT_MS = 120000;
61
+ /**
62
+ * 请求分析软阈值(毫秒)
63
+ * 超过该时间后只告警并继续等待,不直接中断长分析任务。
64
+ */
65
+ const REQUEST_ANALYSIS_TIMEOUT_MS = 600000;
66
+ /**
67
+ * 读取请求分析软阈值的运行时覆盖值。
68
+ * 仅用于本地或特定部署快速调参;未设置时回退到默认值。
69
+ */
70
+ function getRequestAnalysisTimeoutMs() {
71
+ const raw = process.env.OPENCLAW_REQUEST_ANALYSIS_TIMEOUT_MS?.trim();
72
+ if (!raw) {
73
+ return REQUEST_ANALYSIS_TIMEOUT_MS;
74
+ }
75
+ const parsed = Number(raw);
76
+ if (!Number.isFinite(parsed) || parsed <= 0) {
77
+ return REQUEST_ANALYSIS_TIMEOUT_MS;
78
+ }
79
+ return parsed;
80
+ }
63
81
  /**
64
82
  * 消息缓存 TTL(毫秒)
65
83
  * 设为 35 分钟,确保覆盖最大重连时间(约 28.5 分钟)+ 缓冲
@@ -1225,6 +1243,8 @@ async function processMessage(params) {
1225
1243
  const mediaList = [...imageMediaList, ...fileMediaList];
1226
1244
  const ctxPayload = buildMessageContext(body, account, config, mediaList);
1227
1245
  let cleanedUp = false;
1246
+ let analysisTimeoutTimer = null;
1247
+ const analysisTimeoutMs = getRequestAnalysisTimeoutMs();
1228
1248
  const safeCleanup = () => {
1229
1249
  if (!cleanedUp) {
1230
1250
  cleanedUp = true;
@@ -1233,7 +1253,20 @@ async function processMessage(params) {
1233
1253
  };
1234
1254
  runtime.log?.(`[53aihub] processMessage: Starting dispatchReplyWithBufferedBlockDispatcher for msgId=${body.msgId}`);
1235
1255
  try {
1236
- await withTimeout(core.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
1256
+ analysisTimeoutTimer = setTimeout(() => {
1257
+ runtime.log?.(`[53aihub] processMessage: analysis exceeded soft threshold ${analysisTimeoutMs}ms for msgId=${body.msgId}, keep waiting for completion`);
1258
+ if (wsClient.readyState !== WebSocket.OPEN) {
1259
+ return;
1260
+ }
1261
+ try {
1262
+ wsClient.ping();
1263
+ runtime.log?.(`[53aihub] processMessage: timeout keepalive ping sent for msgId=${body.msgId}`);
1264
+ }
1265
+ catch (err) {
1266
+ runtime.error?.(`[53aihub] processMessage: timeout keepalive ping failed for msgId=${body.msgId}: ${String(err)}`);
1267
+ }
1268
+ }, analysisTimeoutMs);
1269
+ await core.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
1237
1270
  ctx: ctxPayload,
1238
1271
  cfg: config,
1239
1272
  dispatcherOptions: {
@@ -1297,7 +1330,7 @@ async function processMessage(params) {
1297
1330
  });
1298
1331
  },
1299
1332
  },
1300
- }), MESSAGE_PROCESS_TIMEOUT_MS, `Message processing timed out (msgId=${body.msgId})`);
1333
+ });
1301
1334
  runtime.log?.(`[53aihub] processMessage: dispatchReply completed, accumulatedTextLen=${state.accumulatedText.length}`);
1302
1335
  if (state.accumulatedText) {
1303
1336
  runtime.log?.(`[53aihub] processMessage: Sending final reply with accumulatedText`);
@@ -1344,6 +1377,12 @@ async function processMessage(params) {
1344
1377
  }
1345
1378
  safeCleanup();
1346
1379
  }
1380
+ finally {
1381
+ if (analysisTimeoutTimer) {
1382
+ clearTimeout(analysisTimeoutTimer);
1383
+ analysisTimeoutTimer = null;
1384
+ }
1385
+ }
1347
1386
  }
1348
1387
  async function monitorProvider(options) {
1349
1388
  const { account, config, runtime, abortSignal } = options;
@@ -1562,6 +1601,12 @@ async function promptWSUrl(prompter, account) {
1562
1601
  },
1563
1602
  })).trim();
1564
1603
  }
1604
+ async function promptSendThinkingMessage(prompter, account) {
1605
+ return await prompter.confirm({
1606
+ message: "Send a thinking message while the agent is processing?",
1607
+ initialValue: account?.sendThinkingMessage ?? true,
1608
+ });
1609
+ }
1565
1610
  function setAccessPolicy(cfg, accessPolicy) {
1566
1611
  const account = resolveAccount(cfg);
1567
1612
  const existingAllowFrom = account.config.allowFrom ?? [];
@@ -1621,6 +1666,7 @@ const aiHubOnboardingAdapter = {
1621
1666
  const botId = await promptBotId(prompter, account);
1622
1667
  const secret = await promptSecret(prompter, account);
1623
1668
  const WSUrl = await promptWSUrl(prompter, account);
1669
+ const sendThinkingMessage = await promptSendThinkingMessage(prompter, account);
1624
1670
  const cfgWithAccount = setAccount(cfg, {
1625
1671
  botId,
1626
1672
  secret,
@@ -1628,7 +1674,7 @@ const aiHubOnboardingAdapter = {
1628
1674
  enabled: true,
1629
1675
  accessPolicy: account.config.accessPolicy ?? "open",
1630
1676
  allowFrom: account.config.allowFrom ?? [],
1631
- sendThinkingMessage: account.sendThinkingMessage ?? true,
1677
+ sendThinkingMessage,
1632
1678
  });
1633
1679
  return { cfg: cfgWithAccount };
1634
1680
  },