@wecom/wecom-openclaw-plugin 2026.3.25-beta.3 → 2026.3.25-beta.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.esm.js CHANGED
@@ -1376,19 +1376,6 @@ function normalizeTemplateCardFields(card, log) {
1376
1376
  }
1377
1377
  return card;
1378
1378
  }
1379
- // ============================================================================
1380
- // 必填字段校验与自动补全
1381
- // ============================================================================
1382
- /** task_id 合法字符:数字、字母、_-@ */
1383
- const TASK_ID_RE = /^[a-zA-Z0-9_\-@]+$/;
1384
- /**
1385
- * 生成一个合法的 task_id。
1386
- * 格式:task_{cardType}_{timestamp}_{随机4位},确保唯一且符合 API 要求。
1387
- */
1388
- function generateTaskId(cardType) {
1389
- const rand = Math.random().toString(36).slice(2, 6);
1390
- return `task_${cardType}_${Date.now()}_${rand}`;
1391
- }
1392
1379
  /**
1393
1380
  * 校验并补全模板卡片的必填字段。
1394
1381
  *
@@ -1408,29 +1395,25 @@ function validateAndFixRequiredFields(card, log) {
1408
1395
  const cardType = card.card_type;
1409
1396
  const fixes = [];
1410
1397
  const warnings = [];
1411
- // ── task_id(所有卡片) ────────────────────────────────────────────
1412
- if (!card.task_id || typeof card.task_id !== "string" || !card.task_id.trim()) {
1413
- const generated = generateTaskId(cardType);
1414
- fixes.push(`task_id: (missing) → "${generated}"`);
1415
- card.task_id = generated;
1398
+ // ── task_id(所有卡片:始终确保唯一性) ─────────────────────────────
1399
+ // LLM 可能编造时间戳导致重复,因此无论是否提供了 task_id,
1400
+ // 都提取语义前缀 + 代码追加真实时间戳和随机后缀来保证唯一。
1401
+ const rawTid = (typeof card.task_id === "string" && card.task_id.trim()) ? card.task_id.trim() : "";
1402
+ const rand = Math.random().toString(36).slice(2, 6);
1403
+ const ts = Date.now();
1404
+ let finalTid;
1405
+ if (rawTid) {
1406
+ // 提取 LLM 的语义前缀:去掉尾部的数字串(LLM 编造的假时间戳)
1407
+ const prefix = rawTid.replace(/_\d{8,}$/, "").replace(/[^a-zA-Z0-9_\-@]/g, "_").slice(0, 80);
1408
+ finalTid = prefix ? `${prefix}_${ts}_${rand}` : `task_${cardType}_${ts}_${rand}`;
1416
1409
  }
1417
1410
  else {
1418
- // 校验合法性:只能由数字、字母和 "_-@" 组成
1419
- const tid = card.task_id;
1420
- if (!TASK_ID_RE.test(tid)) {
1421
- // 尝试清理非法字符
1422
- const cleaned = tid.replace(/[^a-zA-Z0-9_\-@]/g, "_").slice(0, 128);
1423
- if (cleaned && TASK_ID_RE.test(cleaned)) {
1424
- fixes.push(`task_id: "${tid}" → "${cleaned}" (cleaned illegal chars)`);
1425
- card.task_id = cleaned;
1426
- }
1427
- else {
1428
- const generated = generateTaskId(cardType);
1429
- fixes.push(`task_id: "${tid}" → "${generated}" (replaced, too many illegal chars)`);
1430
- card.task_id = generated;
1431
- }
1432
- }
1411
+ finalTid = `task_${cardType}_${ts}_${rand}`;
1412
+ }
1413
+ if (finalTid !== rawTid) {
1414
+ fixes.push(`task_id: "${rawTid || "(missing)"}" → "${finalTid}"`);
1433
1415
  }
1416
+ card.task_id = finalTid;
1434
1417
  // ── main_title ────────────────────────────────────────────────────────
1435
1418
  const mainTitle = card.main_title;
1436
1419
  const hasMainTitle = mainTitle && typeof mainTitle === "object" &&