@iflyrpa/actions 4.1.0-beta.6 → 4.1.0

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/bundle.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! For license information please see bundle.js.LICENSE.txt */
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ed6f9fc8-db66-5df4-be7c-d5593224a8b2")}catch(e){}}();
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bf64112a-57bc-5eae-9ede-8d23fc55671f")}catch(e){}}();
4
4
  var __webpack_modules__ = {
5
5
  "../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js": function(__unused_webpack_module, exports1, __webpack_require__) {
6
6
  "use strict";
@@ -12491,9 +12491,11 @@ var __webpack_exports__ = {};
12491
12491
  origin: ()=>utils_origin
12492
12492
  });
12493
12493
  var package_namespaceObject = {
12494
- i8: "0.1.2"
12494
+ i8: "0.2.0"
12495
+ };
12496
+ var package_namespaceObject_0 = {
12497
+ i8: "4.1.0"
12495
12498
  };
12496
- var package_namespaceObject_0 = JSON.parse('{"i8":"4.1.0-beta.6"}');
12497
12499
  const external_node_fs_namespaceObject = require("node:fs");
12498
12500
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
12499
12501
  const external_node_http_namespaceObject = require("node:http");
@@ -12584,7 +12586,7 @@ var __webpack_exports__ = {};
12584
12586
  fileStream.on("error", (err)=>{
12585
12587
  reject({
12586
12588
  code: 500,
12587
- message: `图片Buffer写入失败: ${err.message}`
12589
+ message: "图片写入失败,请检查磁盘空间"
12588
12590
  });
12589
12591
  });
12590
12592
  } else {
@@ -27073,6 +27075,11 @@ var __webpack_exports__ = {};
27073
27075
  const RPA_ERROR_WEBHOOK_URL = "https://open.xfchat.iflytek.com/open-apis/bot/v2/hook/d202c0dc-5af5-40bc-83ed-abc677caa4a5";
27074
27076
  const ALARM_THROTTLE_MS = 60000;
27075
27077
  const lastSentAt = new Map();
27078
+ const THROTTLE_MAP_MAX_KEYS = 500;
27079
+ const pruneThrottleMap = (now)=>{
27080
+ if (lastSentAt.size < THROTTLE_MAP_MAX_KEYS) return;
27081
+ for (const [key, at] of lastSentAt)if (now - at >= ALARM_THROTTLE_MS) lastSentAt.delete(key);
27082
+ };
27076
27083
  const postFeishuWebhook = (webhookUrl, payload)=>lib_axios.post(webhookUrl, payload, {
27077
27084
  headers: {
27078
27085
  "Content-Type": "application/json"
@@ -27150,10 +27157,11 @@ var __webpack_exports__ = {};
27150
27157
  };
27151
27158
  const reportFeishuAlarm = (report)=>{
27152
27159
  try {
27153
- const key = `${report.platform}|${report.source}|${report.errorType}|${report.code ?? ""}`;
27160
+ const key = `${report.platform}|${report.source}|${report.stage}|${report.errorType}|${report.code ?? ""}`;
27154
27161
  const now = Date.now();
27155
27162
  const last = lastSentAt.get(key);
27156
27163
  if (last && now - last < ALARM_THROTTLE_MS) return;
27164
+ pruneThrottleMap(now);
27157
27165
  lastSentAt.set(key, now);
27158
27166
  postFeishuWebhook(RPA_ERROR_WEBHOOK_URL, buildFeishuPostMessage(report)).catch(()=>{});
27159
27167
  } catch {}
@@ -27300,6 +27308,19 @@ var __webpack_exports__ = {};
27300
27308
  461,
27301
27309
  471
27302
27310
  ]);
27311
+ function isLocalAddress(url) {
27312
+ let hostname;
27313
+ try {
27314
+ hostname = new URL(url).hostname.toLowerCase();
27315
+ } catch {
27316
+ return false;
27317
+ }
27318
+ if ("localhost" === hostname || "::1" === hostname || "[::1]" === hostname) return true;
27319
+ if (hostname.endsWith(".localhost") || hostname.endsWith(".local")) return true;
27320
+ if (/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(hostname)) return true;
27321
+ if ("0.0.0.0" === hostname) return true;
27322
+ return false;
27323
+ }
27303
27324
  const HTTP_STATUS_MESSAGE = {
27304
27325
  400: "请求参数错误,请检查参数格式是否正确!",
27305
27326
  401: "登录状态已失效,请重新登录后重试!",
@@ -27336,7 +27357,14 @@ var __webpack_exports__ = {};
27336
27357
  };
27337
27358
  class Http {
27338
27359
  static handleApiError(error) {
27339
- if (error && "object" == typeof error && "code" in error && "message" in error) return error;
27360
+ if (error && "object" == typeof error && "code" in error && "message" in error) {
27361
+ const resp = error;
27362
+ if ("string" != typeof resp.message || !resp.message.trim()) return {
27363
+ ...resp,
27364
+ message: USER_MESSAGE.SYSTEM_ERROR
27365
+ };
27366
+ return resp;
27367
+ }
27340
27368
  return {
27341
27369
  code: 500,
27342
27370
  message: USER_MESSAGE.SYSTEM_ERROR,
@@ -27474,21 +27502,43 @@ var __webpack_exports__ = {};
27474
27502
  errorResponse.message = message;
27475
27503
  }
27476
27504
  if (error.message.includes("Proxy connection ended")) errorResponse.message = "所在区域代理连接超时,请更换区域或稍后重试!";
27477
- const status = error.response?.status;
27478
- reportFeishuAlarm({
27479
- level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
27480
- platform: this.platform || "unknown",
27481
- source: "http",
27482
- stage: `${(error.config?.method || "get").toUpperCase()} ${error.config?.url || "-"}`,
27483
- errorType: status ? `HTTP_${status}` : error.code || "NETWORK_ERROR",
27484
- code: errorResponse.code,
27485
- msg: errorResponse.message,
27486
- url: error.config?.url,
27487
- title: "RPA接口异常"
27488
- });
27505
+ errorResponse.extra = {
27506
+ ...errorResponse.extra,
27507
+ alarmStatus: error.response?.status,
27508
+ alarmErrorCode: error.code
27509
+ };
27489
27510
  throw errorResponse;
27490
27511
  });
27491
27512
  }
27513
+ reportRequestFailure(config, error, attempts) {
27514
+ const status = error.extra?.alarmStatus;
27515
+ const axiosCode = error.extra?.alarmErrorCode;
27516
+ const method = (config.method || "get").toUpperCase();
27517
+ const baseURL = config.baseURL || this.apiClient.defaults.baseURL || "";
27518
+ const fullUrl = config.url ? /^https?:\/\//.test(config.url) ? config.url : `${baseURL.replace(/\/$/, "")}${config.url}` : baseURL;
27519
+ if (!fullUrl) {
27520
+ this.logger?.debug(`[告警跳过] 请求失败但无 URL,不上报: ${error.message}`);
27521
+ return;
27522
+ }
27523
+ if (isLocalAddress(fullUrl)) {
27524
+ this.logger?.debug(`[告警跳过] 本机地址不上报: ${fullUrl}`);
27525
+ return;
27526
+ }
27527
+ const rawMsg = "string" == typeof error.message && error.message.trim() ? error.message : "";
27528
+ const baseMsg = rawMsg || `请求失败(无错误文案,code=${error.code ?? "unknown"})`;
27529
+ const retriedSuffix = attempts > 0 ? `(已重试${attempts}次仍失败)` : "";
27530
+ reportFeishuAlarm({
27531
+ level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
27532
+ platform: "@iflyrpa/playwright",
27533
+ source: "http",
27534
+ stage: `${method} ${fullUrl}`,
27535
+ errorType: status ? `HTTP_${status}` : axiosCode || "NETWORK_ERROR",
27536
+ code: error.code,
27537
+ msg: `${baseMsg}${retriedSuffix}`,
27538
+ url: fullUrl,
27539
+ title: "RPA接口异常"
27540
+ });
27541
+ }
27492
27542
  async api(config, options) {
27493
27543
  const retries = options?.retries ?? 0;
27494
27544
  const retryDelay = options?.retryDelay ?? 500;
@@ -27533,10 +27583,12 @@ var __webpack_exports__ = {};
27533
27583
  ].includes(handledError.code);
27534
27584
  if (Rtimes < retries && isRetry) {
27535
27585
  const url = config.url || "";
27536
- this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 请求地址: ${url}`);
27537
- await new Promise((resolve)=>setTimeout(resolve, retryDelay));
27586
+ const backoff = Math.min(retryDelay * 2 ** Rtimes, 5000);
27587
+ this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 等待: ${backoff}ms, 请求地址: ${url}`);
27588
+ await new Promise((resolve)=>setTimeout(resolve, backoff));
27538
27589
  return sessionRt(Rtimes + 1);
27539
27590
  }
27591
+ this.reportRequestFailure(config, handledError, Rtimes);
27540
27592
  return Promise.reject(handledError);
27541
27593
  }
27542
27594
  };
@@ -32927,7 +32979,7 @@ var __webpack_exports__ = {};
32927
32979
  ".png"
32928
32980
  ].includes(ext)) throw {
32929
32981
  code: 414,
32930
- message: `图片格式不支持:${fileName}。百家号仅支持 jpg、png 格式,请转换后重试。`,
32982
+ message: "图片格式不支持,百家号仅支持 jpg、png 格式,请转换后重试。",
32931
32983
  data: ""
32932
32984
  };
32933
32985
  const image = await downloadImage(url, external_node_path_default().join(tmpCachePath, fileName));
@@ -33608,7 +33660,8 @@ var __webpack_exports__ = {};
33608
33660
  },
33609
33661
  _task.logger,
33610
33662
  params.proxyLoc,
33611
- params.accountId
33663
+ params.accountId,
33664
+ "xiaohongshu"
33612
33665
  ];
33613
33666
  const http = new Http(...args);
33614
33667
  const fans = {
@@ -33622,8 +33675,8 @@ var __webpack_exports__ = {};
33622
33675
  url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
33623
33676
  }, {
33624
33677
  retries: 3,
33625
- retryDelay: 20,
33626
- timeout: 3000
33678
+ retryDelay: 300,
33679
+ timeout: 30000
33627
33680
  });
33628
33681
  fans.fans_count = Number(res.data.fans_count);
33629
33682
  fans.digg_count = Number(res.data.faved_count);
@@ -34760,7 +34813,8 @@ var __webpack_exports__ = {};
34760
34813
  },
34761
34814
  _task.logger,
34762
34815
  params.proxyLoc,
34763
- params.accountId
34816
+ params.accountId,
34817
+ "xiaohongshu"
34764
34818
  ];
34765
34819
  const http = new Http(...args);
34766
34820
  http.addResponseInterceptor((response)=>{
@@ -34808,8 +34862,8 @@ var __webpack_exports__ = {};
34808
34862
  headers: loginBaseXsHeader
34809
34863
  }, {
34810
34864
  retries: 3,
34811
- retryDelay: 20,
34812
- timeout: 5000
34865
+ retryDelay: 300,
34866
+ timeout: 30000
34813
34867
  }).catch((e)=>{
34814
34868
  const clientTimestamp = Date.now();
34815
34869
  const serverDate = e?.extra?.serverDate;
@@ -34841,8 +34895,8 @@ var __webpack_exports__ = {};
34841
34895
  headers: webSessionXsHeader
34842
34896
  }, {
34843
34897
  retries: 3,
34844
- retryDelay: 20,
34845
- timeout: 5000
34898
+ retryDelay: 300,
34899
+ timeout: 30000
34846
34900
  });
34847
34901
  const [baseInfo, web_session] = await Promise.all([
34848
34902
  _baseInfo,
@@ -34934,6 +34988,10 @@ var __webpack_exports__ = {};
34934
34988
  };
34935
34989
  return success(data, message);
34936
34990
  };
34991
+ const extractEncFileKey = (downloadUrl)=>{
34992
+ if (!downloadUrl) return "";
34993
+ return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
34994
+ };
34937
34995
  const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
34938
34996
  ...Array(8)
34939
34997
  ].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
@@ -40579,7 +40637,8 @@ var __webpack_exports__ = {};
40579
40637
  },
40580
40638
  _task.logger,
40581
40639
  params.proxyLoc,
40582
- params.accountId
40640
+ params.accountId,
40641
+ "xiaohongshu"
40583
40642
  ];
40584
40643
  const http = new Http(...args);
40585
40644
  let unreadCount = {
@@ -40608,8 +40667,8 @@ var __webpack_exports__ = {};
40608
40667
  headers: xsHeader
40609
40668
  }, {
40610
40669
  retries: 3,
40611
- retryDelay: 20,
40612
- timeout: 3000
40670
+ retryDelay: 300,
40671
+ timeout: 30000
40613
40672
  });
40614
40673
  const isSuccess = 0 === res.code;
40615
40674
  if (isSuccess) unreadCount = res.data;
@@ -41022,7 +41081,8 @@ var __webpack_exports__ = {};
41022
41081
  },
41023
41082
  _task.logger,
41024
41083
  params.proxyLoc,
41025
- params.accountId
41084
+ params.accountId,
41085
+ "xiaohongshu"
41026
41086
  ];
41027
41087
  const http = new Http(...args);
41028
41088
  const xsEncrypt = new Xhshow();
@@ -41038,8 +41098,8 @@ var __webpack_exports__ = {};
41038
41098
  url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
41039
41099
  }, {
41040
41100
  retries: 3,
41041
- retryDelay: 20,
41042
- timeout: 3000
41101
+ retryDelay: 300,
41102
+ timeout: 30000
41043
41103
  }),
41044
41104
  http.api({
41045
41105
  method: "get",
@@ -41048,8 +41108,8 @@ var __webpack_exports__ = {};
41048
41108
  headers: sevenDataXsHeader
41049
41109
  }, {
41050
41110
  retries: 3,
41051
- retryDelay: 20,
41052
- timeout: 3000
41111
+ retryDelay: 300,
41112
+ timeout: 30000
41053
41113
  })
41054
41114
  ]);
41055
41115
  const xhsData = {
@@ -43911,7 +43971,7 @@ var __webpack_exports__ = {};
43911
43971
  name: params.music.name,
43912
43972
  artist: params.music.authorName,
43913
43973
  mediaStreamingUrl: params.music.url,
43914
- docType: params.music.raw.playableInfo.type
43974
+ docType: 2 === params.music.raw.bgmSource ? 0 : 1
43915
43975
  },
43916
43976
  groupId: params.music.id,
43917
43977
  hasBgm: 1,
@@ -44088,7 +44148,7 @@ var __webpack_exports__ = {};
44088
44148
  const resultMsg = publishResult.data?.baseResp?.errmsg ?? publishResult.errMsg;
44089
44149
  if (0 === resultCode) {
44090
44150
  task.logger.info("[shipinhaoPublish] 发布成功");
44091
- const publishId = uploadedImages[0]?.thumbUrl?.split("encfilekey=")[1]?.split("&")[0] || "";
44151
+ const publishId = extractEncFileKey(uploadedImages[0]?.thumbUrl);
44092
44152
  await updateTaskState?.({
44093
44153
  state: types_TaskState.SUCCESS,
44094
44154
  result: {
@@ -44983,8 +45043,7 @@ var __webpack_exports__ = {};
44983
45043
  const partTimeout = tuning?.partTimeout ?? DEFAULT_TUNING.partTimeout;
44984
45044
  const partRetries = tuning?.partRetries ?? DEFAULT_TUNING.partRetries;
44985
45045
  const completeTimeout = tuning?.completeTimeout ?? DEFAULT_TUNING.completeTimeout;
44986
- logger?.info(`开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
44987
- logger?.info(`上传超时策略: 单片 ${partTimeout / 1000}s(重试 ${partRetries} 次)、合并 ${completeTimeout / 1000}s`);
45046
+ logger?.info(`[shipinhaoPublishVideo] 开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
44988
45047
  const fileMd5 = await computeFileMd5(filePath);
44989
45048
  const taskId = generateTaskId(fileName, fileSize, fileMd5);
44990
45049
  const baseUrl = "https://finderassistancea.video.qq.com";
@@ -44995,7 +45054,7 @@ var __webpack_exports__ = {};
44995
45054
  const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
44996
45055
  const blockPartLength = [];
44997
45056
  for(let i = 0; i < chunkCount; i++)blockPartLength.push(Math.min((i + 1) * CHUNK_SIZE, fileSize));
44998
- logger?.info(`申请 UploadID: ${chunkCount} 片`);
45057
+ logger?.info(`[shipinhaoPublishVideo] 视频分片: ${chunkCount} 片`);
44999
45058
  const applyRes = await http.api({
45000
45059
  method: "PUT",
45001
45060
  url: `${baseUrl}/applyuploaddfs`,
@@ -45016,7 +45075,6 @@ var __webpack_exports__ = {};
45016
45075
  let uploadId = applyRes.UploadID;
45017
45076
  const uploadedParts = new Set();
45018
45077
  if (applyRes.ListPartsResult) {
45019
- logger?.info("检测到已上传分片,执行续传");
45020
45078
  const parts = Array.isArray(applyRes.ListPartsResult.Part) ? applyRes.ListPartsResult.Part : applyRes.ListPartsResult.Part ? [
45021
45079
  applyRes.ListPartsResult.Part
45022
45080
  ] : [];
@@ -45052,7 +45110,6 @@ var __webpack_exports__ = {};
45052
45110
  PartNumber: partNumber,
45053
45111
  ETag: existing.ETag
45054
45112
  });
45055
- logger?.info(`分片 ${partNumber}/${chunkCount} 已存在,跳过`);
45056
45113
  continue;
45057
45114
  }
45058
45115
  }
@@ -45077,18 +45134,15 @@ var __webpack_exports__ = {};
45077
45134
  retries: partRetries,
45078
45135
  retryDelay: 2000
45079
45136
  });
45080
- const partElapsed = Date.now() - partStart;
45081
- const throughput = Math.round(chunkSize / (partElapsed / 1000));
45137
+ Date.now();
45082
45138
  partInfo.push({
45083
45139
  PartNumber: partNumber,
45084
45140
  ETag: `"${chunkMd5}"`
45085
45141
  });
45086
- logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B, ${partElapsed}ms, ${Math.round(throughput / 1024)}KB/s)`);
45087
45142
  }
45088
45143
  } finally{
45089
45144
  external_node_fs_default().closeSync(fd);
45090
45145
  }
45091
- logger?.info("合并分片...");
45092
45146
  const completeRes = await http.api({
45093
45147
  method: "POST",
45094
45148
  url: `${baseUrl}/completepartuploaddfs?UploadID=${encodeURIComponent(uploadId)}`,
@@ -45106,7 +45160,7 @@ var __webpack_exports__ = {};
45106
45160
  retryDelay: 3000
45107
45161
  });
45108
45162
  if (!completeRes.DownloadURL) throw new Error("合并分片失败: " + JSON.stringify(completeRes));
45109
- logger?.info("上传成功");
45163
+ logger?.info(`[shipinhaoPublishVideo] ${fileName} 上传成功`);
45110
45164
  return {
45111
45165
  downloadUrl: completeRes.DownloadURL,
45112
45166
  md5: fileMd5,
@@ -45424,6 +45478,7 @@ var __webpack_exports__ = {};
45424
45478
  "avc3"
45425
45479
  ];
45426
45480
  const MIN_TITLE_LENGTH = 6;
45481
+ const MAX_TITLE_LENGTH = 16;
45427
45482
  function formatFileSize(bytes) {
45428
45483
  if (bytes < 1048576) return `${(bytes / 1024).toFixed(2)} KB`;
45429
45484
  if (bytes < 1073741824) return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
@@ -45450,10 +45505,11 @@ var __webpack_exports__ = {};
45450
45505
  function validateShipinhaoTitle(title) {
45451
45506
  if (void 0 === title) return null;
45452
45507
  const trimmed = title.trim();
45508
+ if ("" === trimmed) return null;
45453
45509
  const length = [
45454
45510
  ...trimmed
45455
45511
  ].length;
45456
- if (length < MIN_TITLE_LENGTH) return `视频号标题至少需要 ${MIN_TITLE_LENGTH} 个字符,请补充后重试。`;
45512
+ if (length < MIN_TITLE_LENGTH || length > MAX_TITLE_LENGTH) return `视频号标题需要在 ${MIN_TITLE_LENGTH}-${MAX_TITLE_LENGTH} 个字符之间,当前 ${length} 个字符,请调整后重试。`;
45457
45513
  return null;
45458
45514
  }
45459
45515
  const POST_CREATE_PAGE_URL = "https://channels.weixin.qq.com/micro/content/post/create";
@@ -45498,7 +45554,6 @@ var __webpack_exports__ = {};
45498
45554
  };
45499
45555
  }
45500
45556
  async function getTraceKey(auth, client, http, logger) {
45501
- logger.info("[getTraceKey] 开始获取 traceKey...");
45502
45557
  const res = await http.api({
45503
45558
  method: "POST",
45504
45559
  url: `${MICRO_CONTENT_BASE}/post/get-finder-post-trace-key`,
@@ -45513,11 +45568,9 @@ var __webpack_exports__ = {};
45513
45568
  logger.error("[getTraceKey] 获取失败:", JSON.stringify(res));
45514
45569
  throw new Error(`获取 traceKey 失败: ${JSON.stringify(res)}`);
45515
45570
  }
45516
- logger.info(`[getTraceKey] 获取成功: ${res.data.traceKey}`);
45517
45571
  return res.data.traceKey;
45518
45572
  }
45519
45573
  async function getObjectTagKey(auth, client, http, logger) {
45520
- logger.info("[getObjectTagKey] 获取内容声明 tagKey...");
45521
45574
  try {
45522
45575
  const res = await http.api({
45523
45576
  method: "POST",
@@ -45533,7 +45586,6 @@ var __webpack_exports__ = {};
45533
45586
  logger.warn(`[getObjectTagKey] 未取到 tagKey: ${JSON.stringify(res)}`);
45534
45587
  return null;
45535
45588
  }
45536
- logger.info(`[getObjectTagKey] tagKey: ${res.data.tagKey}`);
45537
45589
  return res.data.tagKey;
45538
45590
  } catch (error) {
45539
45591
  logger.warn(`[getObjectTagKey] 获取 tagKey 异常: ${stringifyError(error)}`);
@@ -45542,7 +45594,6 @@ var __webpack_exports__ = {};
45542
45594
  }
45543
45595
  async function submitAndPollTranscode(opts) {
45544
45596
  const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, client, http, logger } = opts;
45545
- logger.info("[submitAndPollTranscode] 开始提交转码任务...");
45546
45597
  const finderUrl = videoUrl.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${videoUrl.split("qq.com")[1]}` : videoUrl;
45547
45598
  logger.info(`[submitAndPollTranscode] 视频尺寸: ${videoMeta.width}x${videoMeta.height}, 时长: ${videoMeta.duration}s`);
45548
45599
  const submitRes = await http.api({
@@ -45581,12 +45632,10 @@ var __webpack_exports__ = {};
45581
45632
  throw new Error(`提交转码失败: ${JSON.stringify(submitRes)}`);
45582
45633
  }
45583
45634
  const { clipKey, draftId } = submitRes.data;
45584
- logger.info(`[submitAndPollTranscode] 转码任务已提交,clipKey: ${clipKey}, draftId: ${draftId}`);
45585
45635
  const pollInterval = 5000;
45586
45636
  const pollBudget = Math.min(1800000, 300000 + 1000 * Math.ceil(1.5 * videoMeta.duration));
45587
45637
  const maxPolls = Math.ceil(pollBudget / pollInterval);
45588
45638
  let pollCount = 0;
45589
- logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls} 次(${Math.round(pollBudget / 1000)}s),间隔 ${pollInterval / 1000}s`);
45590
45639
  while(pollCount < maxPolls){
45591
45640
  await mock_sleep(pollInterval);
45592
45641
  pollCount++;
@@ -45610,14 +45659,12 @@ var __webpack_exports__ = {};
45610
45659
  throw new Error(`转码轮询失败 (poll ${pollCount}): ${JSON.stringify(pollRes)}`);
45611
45660
  }
45612
45661
  const { flag, url, width, height, duration, md5, fileSize } = pollRes.data || {};
45613
- logger.info(`[submitAndPollTranscode] 轮询第 ${pollCount} 次,flag=${flag}`);
45614
45662
  if (1 === flag) {
45615
45663
  if (!url || !width || !height || !duration || !md5 || !fileSize) {
45616
45664
  logger.error("[submitAndPollTranscode] 转码完成但返回数据不完整:", JSON.stringify(pollRes.data));
45617
45665
  throw new Error(`转码完成但返回数据不完整: ${JSON.stringify(pollRes.data)}`);
45618
45666
  }
45619
45667
  logger.info(`[submitAndPollTranscode] 转码完成! 用时: ${pollCount * pollInterval / 1000}s`);
45620
- logger.info(`[submitAndPollTranscode] 视频信息: ${width}x${height}, 时长: ${duration}s, 大小: ${fileSize}`);
45621
45668
  return {
45622
45669
  clipKey,
45623
45670
  url,
@@ -45628,7 +45675,7 @@ var __webpack_exports__ = {};
45628
45675
  fileSize
45629
45676
  };
45630
45677
  }
45631
- if (2 === flag) logger.info(`[submitAndPollTranscode] 转码中... (${pollCount}/${maxPolls})`);
45678
+ if (2 === flag) ;
45632
45679
  else {
45633
45680
  logger.error(`[submitAndPollTranscode] 转码失败,未知 flag=${flag}:`, JSON.stringify(pollRes.data));
45634
45681
  throw new Error(`转码失败,未知 flag=${flag}: ${JSON.stringify(pollRes.data)}`);
@@ -45639,16 +45686,11 @@ var __webpack_exports__ = {};
45639
45686
  }
45640
45687
  async function publishVideo(opts) {
45641
45688
  const { params, auth, client, clipResult, videoUpload, coverUpload, verticalCoverUpload, videoMeta, traceKey, tagKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
45642
- logger.info("[publishVideo] 开始构建发布请求...");
45643
45689
  const toFinderUrl = (url)=>url.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${url.split("qq.com")[1]}` : url;
45644
45690
  const thumbFinderUrl = toFinderUrl(coverUpload.downloadUrl);
45645
45691
  const coverFinderUrl = toFinderUrl(verticalCoverUpload.downloadUrl);
45646
45692
  const md5sumUuid = external_node_crypto_default().randomUUID();
45647
45693
  const description = params.description;
45648
- logger.info("[publishVideo] 发布参数:");
45649
- logger.info(` - 短标题: ${params.title || "(无)"}`);
45650
- logger.info(` - 描述: ${description.substring(0, 50)}${description.length > 50 ? "..." : ""}`);
45651
- logger.info(` - 定时发布: ${params.scheduledTime ? new Date(1000 * params.scheduledTime).toLocaleString() : "立即发布"}`);
45652
45694
  const objectDesc = {
45653
45695
  mpTitle: "",
45654
45696
  description,
@@ -45722,7 +45764,6 @@ var __webpack_exports__ = {};
45722
45764
  };
45723
45765
  if (params.scheduledTime) publishData.effectiveTime = params.scheduledTime;
45724
45766
  if (params.tagInfo && tagKey) publishData.tagInfo = buildTagInfo(params.tagInfo, tagKey);
45725
- logger.info("[publishVideo] 开始发布视频,全部参数:" + JSON.stringify(publishData));
45726
45767
  const publishRes = await proxyHttp.api({
45727
45768
  method: "POST",
45728
45769
  url: `${MICRO_CONTENT_BASE}/post/post_create`,
@@ -45730,7 +45771,7 @@ var __webpack_exports__ = {};
45730
45771
  data: publishData,
45731
45772
  defaultErrorMsg: "发布视频失败"
45732
45773
  });
45733
- logger.info(`[publishVideo] 发布响应: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
45774
+ logger.info(`[publishVideo] 发布结果: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
45734
45775
  return publishRes;
45735
45776
  }
45736
45777
  function mock_sleep(ms) {
@@ -45744,11 +45785,9 @@ var __webpack_exports__ = {};
45744
45785
  return savePath;
45745
45786
  }
45746
45787
  const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
45747
- task.logger.info("[shipinhaoPublishVideo] 开始执行视频号视频发布 - Mock API 方式");
45748
45788
  const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
45749
45789
  let currentStep = "初始化";
45750
45790
  try {
45751
- task.logger.info(`[shipinhaoPublishVideo] 发布方式: ${params.scheduledTime ? `定时 ${new Date(1000 * params.scheduledTime).toLocaleString()}` : "立即发布"}`);
45752
45791
  currentStep = "解析认证信息";
45753
45792
  const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
45754
45793
  const http = new Http({
@@ -45760,11 +45799,8 @@ var __webpack_exports__ = {};
45760
45799
  if (!params.videoPath) return utils_response(414, "视频文件路径不能为空", "");
45761
45800
  if (!params.coverPath) return utils_response(414, "横屏封面图片路径不能为空", "");
45762
45801
  currentStep = "获取上传认证";
45763
- task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
45764
45802
  const auth = await getShipinhaoUploadAuth(cookieString, http);
45765
45803
  const client = resolveClientContext(params, auth.uin);
45766
- if (!client.aId) task.logger.warn("[shipinhaoPublishVideo] extraParam.aId 缺失,query 将不带 _aid");
45767
- if (!client.fingerPrintDeviceId) task.logger.warn("[shipinhaoPublishVideo] extraParam.fingerPrintDeviceId 缺失,请求将不带 finger-print-device-id");
45768
45804
  const publishHeaders = buildPublishHeaders(cookieString, client);
45769
45805
  const microHttp = new Http({
45770
45806
  headers: publishHeaders
@@ -45780,25 +45816,20 @@ var __webpack_exports__ = {};
45780
45816
  ];
45781
45817
  const proxyHttp = new Http(...args);
45782
45818
  currentStep = "组装视频元数据";
45783
- task.logger.info("[shipinhaoPublishVideo] 组装视频元数据...");
45784
45819
  const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
45785
45820
  task.logger.info(`[shipinhaoPublishVideo] 视频: ${videoMeta.width}×${videoMeta.height}, ${videoMeta.duration.toFixed(2)}s, ${(videoMeta.fileSize / 1024 / 1024).toFixed(2)}MB, codec=${videoMeta.codec || "unknown"}`);
45786
- if (!videoMeta.codec) task.logger.warn("[shipinhaoPublishVideo] 未能读取视频编码格式,跳过 H.264 预检,交由服务端判断");
45787
45821
  currentStep = "校验视频限制";
45788
45822
  const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
45789
45823
  if (validationError) {
45790
- task.logger.error(`[shipinhaoPublishVideo] 视频校验未通过: ${validationError}`);
45791
45824
  await updateTaskState?.({
45792
45825
  state: types_TaskState.FAILED,
45793
45826
  error: validationError
45794
45827
  });
45795
45828
  return utils_response(414, validationError, "");
45796
45829
  }
45797
- task.logger.info("[shipinhaoPublishVideo] 视频校验通过");
45798
45830
  currentStep = "校验标题";
45799
45831
  const titleError = validateShipinhaoTitle(params.title);
45800
45832
  if (titleError) {
45801
- task.logger.error(`[shipinhaoPublishVideo] 标题校验未通过: ${titleError}`);
45802
45833
  await updateTaskState?.({
45803
45834
  state: types_TaskState.FAILED,
45804
45835
  error: titleError
@@ -45806,7 +45837,6 @@ var __webpack_exports__ = {};
45806
45837
  return utils_response(414, titleError, "");
45807
45838
  }
45808
45839
  currentStep = "获取 traceKey";
45809
- task.logger.info("[shipinhaoPublishVideo] 获取 traceKey...");
45810
45840
  const traceKey = await getTraceKey(auth, client, microHttp, task.logger);
45811
45841
  let tagKey = null;
45812
45842
  if (params.tagInfo) {
@@ -45814,11 +45844,7 @@ var __webpack_exports__ = {};
45814
45844
  tagKey = await getObjectTagKey(auth, client, microHttp, task.logger);
45815
45845
  }
45816
45846
  const uploadStartTime = Math.floor(Date.now() / 1000);
45817
- task.logger.info(`[shipinhaoPublishVideo] 上传开始时间: ${uploadStartTime}`);
45818
45847
  currentStep = "上传视频";
45819
- task.logger.info("[shipinhaoPublishVideo] 上传视频...");
45820
- task.logger.info(`[shipinhaoPublishVideo] 视频路径: ${params.videoPath}`);
45821
- task.logger.info(`[shipinhaoPublishVideo] 视频文件类型: ${auth.videoFileType}`);
45822
45848
  const videoUpload = await uploader_uploadFile({
45823
45849
  filePath: params.videoPath,
45824
45850
  fileType: auth.videoFileType,
@@ -45827,12 +45853,10 @@ var __webpack_exports__ = {};
45827
45853
  http,
45828
45854
  logger: task.logger
45829
45855
  });
45830
- task.logger.info("[shipinhaoPublishVideo] 视频上传完成");
45831
45856
  const uploadEndTime = Math.floor(Date.now() / 1000);
45832
- task.logger.info(`[shipinhaoPublishVideo] 上传结束时间: ${uploadEndTime}, 耗时: ${uploadEndTime - uploadStartTime}s`);
45857
+ task.logger.info(`[shipinhaoPublishVideo] 耗时: ${uploadEndTime - uploadStartTime}s`);
45833
45858
  currentStep = "上传横屏封面";
45834
45859
  const localCoverPath = await resolveLocalCoverPath(params.coverPath, "横屏封面", task.getTmpPath(), task.logger);
45835
- task.logger.info("[shipinhaoPublishVideo] 上传横屏封面...");
45836
45860
  const coverUpload = await uploader_uploadFile({
45837
45861
  filePath: localCoverPath,
45838
45862
  fileType: auth.pictureFileType,
@@ -45841,12 +45865,10 @@ var __webpack_exports__ = {};
45841
45865
  http,
45842
45866
  logger: task.logger
45843
45867
  });
45844
- task.logger.info("[shipinhaoPublishVideo] 横屏封面上传完成");
45845
45868
  let verticalCoverUpload = coverUpload;
45846
45869
  if (params.verticalCoverPath) {
45847
45870
  currentStep = "上传竖屏封面";
45848
45871
  const localVerticalPath = await resolveLocalCoverPath(params.verticalCoverPath, "竖屏封面", task.getTmpPath(), task.logger);
45849
- task.logger.info("[shipinhaoPublishVideo] 上传竖屏封面");
45850
45872
  verticalCoverUpload = await uploader_uploadFile({
45851
45873
  filePath: localVerticalPath,
45852
45874
  fileType: auth.pictureFileType,
@@ -45855,10 +45877,8 @@ var __webpack_exports__ = {};
45855
45877
  http,
45856
45878
  logger: task.logger
45857
45879
  });
45858
- task.logger.info("[shipinhaoPublishVideo] 竖屏封面上传完成");
45859
- } else task.logger.info("[shipinhaoPublishVideo] 未传竖屏封面,复用横屏封面");
45880
+ }
45860
45881
  currentStep = "提交转码";
45861
- task.logger.info("[shipinhaoPublishVideo] 提交转码...");
45862
45882
  const clipResult = await submitAndPollTranscode({
45863
45883
  videoUrl: videoUpload.downloadUrl,
45864
45884
  videoMeta,
@@ -45871,8 +45891,6 @@ var __webpack_exports__ = {};
45871
45891
  logger: task.logger
45872
45892
  });
45873
45893
  currentStep = "发布视频";
45874
- task.logger.info("[shipinhaoPublishVideo] 发布视频...");
45875
- task.logger.info(`[shipinhaoPublishVideo] clipKey: ${clipResult.clipKey}`);
45876
45894
  let publishResult;
45877
45895
  try {
45878
45896
  publishResult = await publishVideo({
@@ -45897,7 +45915,6 @@ var __webpack_exports__ = {};
45897
45915
  const classified = classifyPublishError(handledError);
45898
45916
  if (classified) {
45899
45917
  const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
45900
- task.logger.error(`[shipinhaoPublishVideo] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
45901
45918
  await updateTaskState?.({
45902
45919
  state: types_TaskState.FAILED,
45903
45920
  error: message
@@ -45914,11 +45931,8 @@ var __webpack_exports__ = {};
45914
45931
  const resultCode = publishResult.data?.baseResp?.errcode ?? publishResult.errCode;
45915
45932
  const resultMsg = publishResult.data?.baseResp?.errmsg ?? (0 === resultCode ? "发布成功" : `发布失败(errCode=${resultCode})`);
45916
45933
  if (0 === resultCode) {
45917
- task.logger.info("[shipinhaoPublishVideo] 发布成功");
45918
- task.logger.info(`[shipinhaoPublishVideo] 作品ID: ${clipResult.clipKey}`);
45919
- task.logger.info(`[shipinhaoPublishVideo] 视频URL: ${clipResult.url}`);
45920
- task.logger.info(`[shipinhaoPublishVideo] 横屏封面URL: ${coverUpload.downloadUrl}`);
45921
- task.logger.info(`[shipinhaoPublishVideo] 竖屏封面URL: ${verticalCoverUpload.downloadUrl}`);
45934
+ const publishId = extractEncFileKey(verticalCoverUpload.downloadUrl);
45935
+ if (!publishId) task.logger.error(`[shipinhaoPublishVideo] 封面 DownloadURL 中未解析到 encfilekey,关联 id 为空: ${verticalCoverUpload.downloadUrl}`);
45922
45936
  await updateTaskState?.({
45923
45937
  state: types_TaskState.SUCCESS,
45924
45938
  result: {
@@ -45948,8 +45962,7 @@ var __webpack_exports__ = {};
45948
45962
  },
45949
45963
  platform: "shipinhao"
45950
45964
  });
45951
- task.logger.info("[shipinhaoPublishVideo] 日志上报完成");
45952
- return utils_response(0, "发布成功", clipResult.clipKey);
45965
+ return utils_response(0, "发布成功", publishId);
45953
45966
  }
45954
45967
  let errorMessage = resultMsg;
45955
45968
  if (-11224 === resultCode) errorMessage = "视频号管理员完成实名且绑定手机号后才可以发表";
@@ -45961,18 +45974,16 @@ var __webpack_exports__ = {};
45961
45974
  state: types_TaskState.FAILED,
45962
45975
  error: errorMessage
45963
45976
  });
45964
- return utils_response(resultCode || 414, errorMessage, "");
45977
+ return utils_response(414, errorMessage, "");
45965
45978
  } catch (error) {
45966
45979
  const handledError = Http.handleApiError(error);
45967
45980
  const errorMsg = handledError.message || "发布失败,请稍后重试";
45968
- const errorCode = handledError.code || 414;
45969
45981
  task.logger.error(`[shipinhaoPublishVideo] 发布流程异常 [${currentStep}]: ${errorMsg}`, stringifyError(error), handledError.extra);
45970
- task.logger.error(`[shipinhaoPublishVideo] 错误码: ${errorCode}, 当前步骤: ${currentStep}`);
45971
45982
  await updateTaskState?.({
45972
45983
  state: types_TaskState.FAILED,
45973
45984
  error: errorMsg
45974
45985
  });
45975
- return utils_response(errorCode, errorMsg, "");
45986
+ return utils_response(414, errorMsg, "");
45976
45987
  }
45977
45988
  };
45978
45989
  const shipinhaoPublishVideo_rpa_rpaAction = async (task, params)=>{
@@ -52544,4 +52555,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
52544
52555
  });
52545
52556
 
52546
52557
  //# sourceMappingURL=bundle.js.map
52547
- //# debugId=ed6f9fc8-db66-5df4-be7c-d5593224a8b2
52558
+ //# debugId=bf64112a-57bc-5eae-9ede-8d23fc55671f