@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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !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]="959450cb-879c-5526-aedb-26ef8ba0e7a8")}catch(e){}}();
2
+ !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]="028a0eb4-9179-5708-bae0-75174165ae68")}catch(e){}}();
3
3
  var __webpack_modules__ = {
4
4
  "./src/utils/XhsXsCommonEnc.js": function(module) {
5
5
  var encrypt_lookup = [
@@ -4403,7 +4403,9 @@ var __webpack_exports__ = {};
4403
4403
  });
4404
4404
  const package_json_namespaceObject = require("@iflyrpa/share/package.json");
4405
4405
  var package_json_default = /*#__PURE__*/ __webpack_require__.n(package_json_namespaceObject);
4406
- var package_namespaceObject = JSON.parse('{"i8":"4.1.0-beta.6"}');
4406
+ var package_namespaceObject = {
4407
+ i8: "4.1.0"
4408
+ };
4407
4409
  const share_namespaceObject = require("@iflyrpa/share");
4408
4410
  const external_node_fs_namespaceObject = require("node:fs");
4409
4411
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
@@ -4452,6 +4454,11 @@ var __webpack_exports__ = {};
4452
4454
  const RPA_ERROR_WEBHOOK_URL = "https://open.xfchat.iflytek.com/open-apis/bot/v2/hook/d202c0dc-5af5-40bc-83ed-abc677caa4a5";
4453
4455
  const ALARM_THROTTLE_MS = 60000;
4454
4456
  const lastSentAt = new Map();
4457
+ const THROTTLE_MAP_MAX_KEYS = 500;
4458
+ const pruneThrottleMap = (now)=>{
4459
+ if (lastSentAt.size < THROTTLE_MAP_MAX_KEYS) return;
4460
+ for (const [key, at] of lastSentAt)if (now - at >= ALARM_THROTTLE_MS) lastSentAt.delete(key);
4461
+ };
4455
4462
  const postFeishuWebhook = (webhookUrl, payload)=>external_axios_default().post(webhookUrl, payload, {
4456
4463
  headers: {
4457
4464
  "Content-Type": "application/json"
@@ -4529,10 +4536,11 @@ var __webpack_exports__ = {};
4529
4536
  };
4530
4537
  const reportFeishuAlarm = (report)=>{
4531
4538
  try {
4532
- const key = `${report.platform}|${report.source}|${report.errorType}|${report.code ?? ""}`;
4539
+ const key = `${report.platform}|${report.source}|${report.stage}|${report.errorType}|${report.code ?? ""}`;
4533
4540
  const now = Date.now();
4534
4541
  const last = lastSentAt.get(key);
4535
4542
  if (last && now - last < ALARM_THROTTLE_MS) return;
4543
+ pruneThrottleMap(now);
4536
4544
  lastSentAt.set(key, now);
4537
4545
  postFeishuWebhook(RPA_ERROR_WEBHOOK_URL, buildFeishuPostMessage(report)).catch(()=>{});
4538
4546
  } catch {}
@@ -4679,6 +4687,19 @@ var __webpack_exports__ = {};
4679
4687
  461,
4680
4688
  471
4681
4689
  ]);
4690
+ function isLocalAddress(url) {
4691
+ let hostname;
4692
+ try {
4693
+ hostname = new URL(url).hostname.toLowerCase();
4694
+ } catch {
4695
+ return false;
4696
+ }
4697
+ if ("localhost" === hostname || "::1" === hostname || "[::1]" === hostname) return true;
4698
+ if (hostname.endsWith(".localhost") || hostname.endsWith(".local")) return true;
4699
+ if (/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(hostname)) return true;
4700
+ if ("0.0.0.0" === hostname) return true;
4701
+ return false;
4702
+ }
4682
4703
  const HTTP_STATUS_MESSAGE = {
4683
4704
  400: "请求参数错误,请检查参数格式是否正确!",
4684
4705
  401: "登录状态已失效,请重新登录后重试!",
@@ -4715,7 +4736,14 @@ var __webpack_exports__ = {};
4715
4736
  };
4716
4737
  class Http {
4717
4738
  static handleApiError(error) {
4718
- if (error && "object" == typeof error && "code" in error && "message" in error) return error;
4739
+ if (error && "object" == typeof error && "code" in error && "message" in error) {
4740
+ const resp = error;
4741
+ if ("string" != typeof resp.message || !resp.message.trim()) return {
4742
+ ...resp,
4743
+ message: USER_MESSAGE.SYSTEM_ERROR
4744
+ };
4745
+ return resp;
4746
+ }
4719
4747
  return {
4720
4748
  code: 500,
4721
4749
  message: USER_MESSAGE.SYSTEM_ERROR,
@@ -4853,21 +4881,43 @@ var __webpack_exports__ = {};
4853
4881
  errorResponse.message = message;
4854
4882
  }
4855
4883
  if (error.message.includes("Proxy connection ended")) errorResponse.message = "所在区域代理连接超时,请更换区域或稍后重试!";
4856
- const status = error.response?.status;
4857
- reportFeishuAlarm({
4858
- level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
4859
- platform: this.platform || "unknown",
4860
- source: "http",
4861
- stage: `${(error.config?.method || "get").toUpperCase()} ${error.config?.url || "-"}`,
4862
- errorType: status ? `HTTP_${status}` : error.code || "NETWORK_ERROR",
4863
- code: errorResponse.code,
4864
- msg: errorResponse.message,
4865
- url: error.config?.url,
4866
- title: "RPA接口异常"
4867
- });
4884
+ errorResponse.extra = {
4885
+ ...errorResponse.extra,
4886
+ alarmStatus: error.response?.status,
4887
+ alarmErrorCode: error.code
4888
+ };
4868
4889
  throw errorResponse;
4869
4890
  });
4870
4891
  }
4892
+ reportRequestFailure(config, error, attempts) {
4893
+ const status = error.extra?.alarmStatus;
4894
+ const axiosCode = error.extra?.alarmErrorCode;
4895
+ const method = (config.method || "get").toUpperCase();
4896
+ const baseURL = config.baseURL || this.apiClient.defaults.baseURL || "";
4897
+ const fullUrl = config.url ? /^https?:\/\//.test(config.url) ? config.url : `${baseURL.replace(/\/$/, "")}${config.url}` : baseURL;
4898
+ if (!fullUrl) {
4899
+ this.logger?.debug(`[告警跳过] 请求失败但无 URL,不上报: ${error.message}`);
4900
+ return;
4901
+ }
4902
+ if (isLocalAddress(fullUrl)) {
4903
+ this.logger?.debug(`[告警跳过] 本机地址不上报: ${fullUrl}`);
4904
+ return;
4905
+ }
4906
+ const rawMsg = "string" == typeof error.message && error.message.trim() ? error.message : "";
4907
+ const baseMsg = rawMsg || `请求失败(无错误文案,code=${error.code ?? "unknown"})`;
4908
+ const retriedSuffix = attempts > 0 ? `(已重试${attempts}次仍失败)` : "";
4909
+ reportFeishuAlarm({
4910
+ level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
4911
+ platform: "@iflyrpa/playwright",
4912
+ source: "http",
4913
+ stage: `${method} ${fullUrl}`,
4914
+ errorType: status ? `HTTP_${status}` : axiosCode || "NETWORK_ERROR",
4915
+ code: error.code,
4916
+ msg: `${baseMsg}${retriedSuffix}`,
4917
+ url: fullUrl,
4918
+ title: "RPA接口异常"
4919
+ });
4920
+ }
4871
4921
  async api(config, options) {
4872
4922
  const retries = options?.retries ?? 0;
4873
4923
  const retryDelay = options?.retryDelay ?? 500;
@@ -4912,10 +4962,12 @@ var __webpack_exports__ = {};
4912
4962
  ].includes(handledError.code);
4913
4963
  if (Rtimes < retries && isRetry) {
4914
4964
  const url = config.url || "";
4915
- this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 请求地址: ${url}`);
4916
- await new Promise((resolve)=>setTimeout(resolve, retryDelay));
4965
+ const backoff = Math.min(retryDelay * 2 ** Rtimes, 5000);
4966
+ this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 等待: ${backoff}ms, 请求地址: ${url}`);
4967
+ await new Promise((resolve)=>setTimeout(resolve, backoff));
4917
4968
  return sessionRt(Rtimes + 1);
4918
4969
  }
4970
+ this.reportRequestFailure(config, handledError, Rtimes);
4919
4971
  return Promise.reject(handledError);
4920
4972
  }
4921
4973
  };
@@ -6031,7 +6083,7 @@ var __webpack_exports__ = {};
6031
6083
  const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
6032
6084
  const regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
6033
6085
  const regexes_base64url = /^[A-Za-z0-9_-]*$/;
6034
- const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
6086
+ const regexes_hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
6035
6087
  const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
6036
6088
  const dateSource = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";
6037
6089
  const regexes_date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
@@ -6627,7 +6679,7 @@ var __webpack_exports__ = {};
6627
6679
  code: "invalid_format",
6628
6680
  format: "url",
6629
6681
  note: "Invalid hostname",
6630
- pattern: hostname.source,
6682
+ pattern: regexes_hostname.source,
6631
6683
  input: payload.value,
6632
6684
  inst,
6633
6685
  continue: !def.abort
@@ -9340,7 +9392,7 @@ var __webpack_exports__ = {};
9340
9392
  ".png"
9341
9393
  ].includes(ext)) throw {
9342
9394
  code: 414,
9343
- message: `图片格式不支持:${fileName}。百家号仅支持 jpg、png 格式,请转换后重试。`,
9395
+ message: "图片格式不支持,百家号仅支持 jpg、png 格式,请转换后重试。",
9344
9396
  data: ""
9345
9397
  };
9346
9398
  const image = await (0, share_namespaceObject.downloadImage)(url, external_node_path_default().join(tmpCachePath, fileName));
@@ -10023,7 +10075,8 @@ var __webpack_exports__ = {};
10023
10075
  },
10024
10076
  _task.logger,
10025
10077
  params.proxyLoc,
10026
- params.accountId
10078
+ params.accountId,
10079
+ "xiaohongshu"
10027
10080
  ];
10028
10081
  const http = new Http(...args);
10029
10082
  const fans = {
@@ -10037,8 +10090,8 @@ var __webpack_exports__ = {};
10037
10090
  url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
10038
10091
  }, {
10039
10092
  retries: 3,
10040
- retryDelay: 20,
10041
- timeout: 3000
10093
+ retryDelay: 300,
10094
+ timeout: 30000
10042
10095
  });
10043
10096
  fans.fans_count = Number(res.data.fans_count);
10044
10097
  fans.digg_count = Number(res.data.faved_count);
@@ -11175,7 +11228,8 @@ var __webpack_exports__ = {};
11175
11228
  },
11176
11229
  _task.logger,
11177
11230
  params.proxyLoc,
11178
- params.accountId
11231
+ params.accountId,
11232
+ "xiaohongshu"
11179
11233
  ];
11180
11234
  const http = new Http(...args);
11181
11235
  http.addResponseInterceptor((response)=>{
@@ -11223,8 +11277,8 @@ var __webpack_exports__ = {};
11223
11277
  headers: loginBaseXsHeader
11224
11278
  }, {
11225
11279
  retries: 3,
11226
- retryDelay: 20,
11227
- timeout: 5000
11280
+ retryDelay: 300,
11281
+ timeout: 30000
11228
11282
  }).catch((e)=>{
11229
11283
  const clientTimestamp = Date.now();
11230
11284
  const serverDate = e?.extra?.serverDate;
@@ -11256,8 +11310,8 @@ var __webpack_exports__ = {};
11256
11310
  headers: webSessionXsHeader
11257
11311
  }, {
11258
11312
  retries: 3,
11259
- retryDelay: 20,
11260
- timeout: 5000
11313
+ retryDelay: 300,
11314
+ timeout: 30000
11261
11315
  });
11262
11316
  const [baseInfo, web_session] = await Promise.all([
11263
11317
  _baseInfo,
@@ -11349,6 +11403,10 @@ var __webpack_exports__ = {};
11349
11403
  };
11350
11404
  return (0, share_namespaceObject.success)(data, message);
11351
11405
  };
11406
+ const extractEncFileKey = (downloadUrl)=>{
11407
+ if (!downloadUrl) return "";
11408
+ return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
11409
+ };
11352
11410
  const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
11353
11411
  ...Array(8)
11354
11412
  ].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
@@ -15508,7 +15566,8 @@ var __webpack_exports__ = {};
15508
15566
  },
15509
15567
  _task.logger,
15510
15568
  params.proxyLoc,
15511
- params.accountId
15569
+ params.accountId,
15570
+ "xiaohongshu"
15512
15571
  ];
15513
15572
  const http = new Http(...args);
15514
15573
  let unreadCount = {
@@ -15537,8 +15596,8 @@ var __webpack_exports__ = {};
15537
15596
  headers: xsHeader
15538
15597
  }, {
15539
15598
  retries: 3,
15540
- retryDelay: 20,
15541
- timeout: 3000
15599
+ retryDelay: 300,
15600
+ timeout: 30000
15542
15601
  });
15543
15602
  const isSuccess = 0 === res.code;
15544
15603
  if (isSuccess) unreadCount = res.data;
@@ -15951,7 +16010,8 @@ var __webpack_exports__ = {};
15951
16010
  },
15952
16011
  _task.logger,
15953
16012
  params.proxyLoc,
15954
- params.accountId
16013
+ params.accountId,
16014
+ "xiaohongshu"
15955
16015
  ];
15956
16016
  const http = new Http(...args);
15957
16017
  const xsEncrypt = new Xhshow();
@@ -15967,8 +16027,8 @@ var __webpack_exports__ = {};
15967
16027
  url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
15968
16028
  }, {
15969
16029
  retries: 3,
15970
- retryDelay: 20,
15971
- timeout: 3000
16030
+ retryDelay: 300,
16031
+ timeout: 30000
15972
16032
  }),
15973
16033
  http.api({
15974
16034
  method: "get",
@@ -15977,8 +16037,8 @@ var __webpack_exports__ = {};
15977
16037
  headers: sevenDataXsHeader
15978
16038
  }, {
15979
16039
  retries: 3,
15980
- retryDelay: 20,
15981
- timeout: 3000
16040
+ retryDelay: 300,
16041
+ timeout: 30000
15982
16042
  })
15983
16043
  ]);
15984
16044
  const xhsData = {
@@ -18840,7 +18900,7 @@ var __webpack_exports__ = {};
18840
18900
  name: params.music.name,
18841
18901
  artist: params.music.authorName,
18842
18902
  mediaStreamingUrl: params.music.url,
18843
- docType: params.music.raw.playableInfo.type
18903
+ docType: 2 === params.music.raw.bgmSource ? 0 : 1
18844
18904
  },
18845
18905
  groupId: params.music.id,
18846
18906
  hasBgm: 1,
@@ -19017,7 +19077,7 @@ var __webpack_exports__ = {};
19017
19077
  const resultMsg = publishResult.data?.baseResp?.errmsg ?? publishResult.errMsg;
19018
19078
  if (0 === resultCode) {
19019
19079
  task.logger.info("[shipinhaoPublish] 发布成功");
19020
- const publishId = uploadedImages[0]?.thumbUrl?.split("encfilekey=")[1]?.split("&")[0] || "";
19080
+ const publishId = extractEncFileKey(uploadedImages[0]?.thumbUrl);
19021
19081
  await updateTaskState?.({
19022
19082
  state: share_namespaceObject.TaskState.SUCCESS,
19023
19083
  result: {
@@ -19912,8 +19972,7 @@ var __webpack_exports__ = {};
19912
19972
  const partTimeout = tuning?.partTimeout ?? DEFAULT_TUNING.partTimeout;
19913
19973
  const partRetries = tuning?.partRetries ?? DEFAULT_TUNING.partRetries;
19914
19974
  const completeTimeout = tuning?.completeTimeout ?? DEFAULT_TUNING.completeTimeout;
19915
- logger?.info(`开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
19916
- logger?.info(`上传超时策略: 单片 ${partTimeout / 1000}s(重试 ${partRetries} 次)、合并 ${completeTimeout / 1000}s`);
19975
+ logger?.info(`[shipinhaoPublishVideo] 开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
19917
19976
  const fileMd5 = await computeFileMd5(filePath);
19918
19977
  const taskId = generateTaskId(fileName, fileSize, fileMd5);
19919
19978
  const baseUrl = "https://finderassistancea.video.qq.com";
@@ -19924,7 +19983,7 @@ var __webpack_exports__ = {};
19924
19983
  const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
19925
19984
  const blockPartLength = [];
19926
19985
  for(let i = 0; i < chunkCount; i++)blockPartLength.push(Math.min((i + 1) * CHUNK_SIZE, fileSize));
19927
- logger?.info(`申请 UploadID: ${chunkCount} 片`);
19986
+ logger?.info(`[shipinhaoPublishVideo] 视频分片: ${chunkCount} 片`);
19928
19987
  const applyRes = await http.api({
19929
19988
  method: "PUT",
19930
19989
  url: `${baseUrl}/applyuploaddfs`,
@@ -19945,7 +20004,6 @@ var __webpack_exports__ = {};
19945
20004
  let uploadId = applyRes.UploadID;
19946
20005
  const uploadedParts = new Set();
19947
20006
  if (applyRes.ListPartsResult) {
19948
- logger?.info("检测到已上传分片,执行续传");
19949
20007
  const parts = Array.isArray(applyRes.ListPartsResult.Part) ? applyRes.ListPartsResult.Part : applyRes.ListPartsResult.Part ? [
19950
20008
  applyRes.ListPartsResult.Part
19951
20009
  ] : [];
@@ -19981,7 +20039,6 @@ var __webpack_exports__ = {};
19981
20039
  PartNumber: partNumber,
19982
20040
  ETag: existing.ETag
19983
20041
  });
19984
- logger?.info(`分片 ${partNumber}/${chunkCount} 已存在,跳过`);
19985
20042
  continue;
19986
20043
  }
19987
20044
  }
@@ -20006,18 +20063,15 @@ var __webpack_exports__ = {};
20006
20063
  retries: partRetries,
20007
20064
  retryDelay: 2000
20008
20065
  });
20009
- const partElapsed = Date.now() - partStart;
20010
- const throughput = Math.round(chunkSize / (partElapsed / 1000));
20066
+ Date.now();
20011
20067
  partInfo.push({
20012
20068
  PartNumber: partNumber,
20013
20069
  ETag: `"${chunkMd5}"`
20014
20070
  });
20015
- logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B, ${partElapsed}ms, ${Math.round(throughput / 1024)}KB/s)`);
20016
20071
  }
20017
20072
  } finally{
20018
20073
  external_node_fs_default().closeSync(fd);
20019
20074
  }
20020
- logger?.info("合并分片...");
20021
20075
  const completeRes = await http.api({
20022
20076
  method: "POST",
20023
20077
  url: `${baseUrl}/completepartuploaddfs?UploadID=${encodeURIComponent(uploadId)}`,
@@ -20035,7 +20089,7 @@ var __webpack_exports__ = {};
20035
20089
  retryDelay: 3000
20036
20090
  });
20037
20091
  if (!completeRes.DownloadURL) throw new Error("合并分片失败: " + JSON.stringify(completeRes));
20038
- logger?.info("上传成功");
20092
+ logger?.info(`[shipinhaoPublishVideo] ${fileName} 上传成功`);
20039
20093
  return {
20040
20094
  downloadUrl: completeRes.DownloadURL,
20041
20095
  md5: fileMd5,
@@ -20353,6 +20407,7 @@ var __webpack_exports__ = {};
20353
20407
  "avc3"
20354
20408
  ];
20355
20409
  const MIN_TITLE_LENGTH = 6;
20410
+ const MAX_TITLE_LENGTH = 16;
20356
20411
  function formatFileSize(bytes) {
20357
20412
  if (bytes < 1048576) return `${(bytes / 1024).toFixed(2)} KB`;
20358
20413
  if (bytes < 1073741824) return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
@@ -20379,10 +20434,11 @@ var __webpack_exports__ = {};
20379
20434
  function validateShipinhaoTitle(title) {
20380
20435
  if (void 0 === title) return null;
20381
20436
  const trimmed = title.trim();
20437
+ if ("" === trimmed) return null;
20382
20438
  const length = [
20383
20439
  ...trimmed
20384
20440
  ].length;
20385
- if (length < MIN_TITLE_LENGTH) return `视频号标题至少需要 ${MIN_TITLE_LENGTH} 个字符,请补充后重试。`;
20441
+ if (length < MIN_TITLE_LENGTH || length > MAX_TITLE_LENGTH) return `视频号标题需要在 ${MIN_TITLE_LENGTH}-${MAX_TITLE_LENGTH} 个字符之间,当前 ${length} 个字符,请调整后重试。`;
20386
20442
  return null;
20387
20443
  }
20388
20444
  const POST_CREATE_PAGE_URL = "https://channels.weixin.qq.com/micro/content/post/create";
@@ -20427,7 +20483,6 @@ var __webpack_exports__ = {};
20427
20483
  };
20428
20484
  }
20429
20485
  async function getTraceKey(auth, client, http, logger) {
20430
- logger.info("[getTraceKey] 开始获取 traceKey...");
20431
20486
  const res = await http.api({
20432
20487
  method: "POST",
20433
20488
  url: `${MICRO_CONTENT_BASE}/post/get-finder-post-trace-key`,
@@ -20442,11 +20497,9 @@ var __webpack_exports__ = {};
20442
20497
  logger.error("[getTraceKey] 获取失败:", JSON.stringify(res));
20443
20498
  throw new Error(`获取 traceKey 失败: ${JSON.stringify(res)}`);
20444
20499
  }
20445
- logger.info(`[getTraceKey] 获取成功: ${res.data.traceKey}`);
20446
20500
  return res.data.traceKey;
20447
20501
  }
20448
20502
  async function getObjectTagKey(auth, client, http, logger) {
20449
- logger.info("[getObjectTagKey] 获取内容声明 tagKey...");
20450
20503
  try {
20451
20504
  const res = await http.api({
20452
20505
  method: "POST",
@@ -20462,7 +20515,6 @@ var __webpack_exports__ = {};
20462
20515
  logger.warn(`[getObjectTagKey] 未取到 tagKey: ${JSON.stringify(res)}`);
20463
20516
  return null;
20464
20517
  }
20465
- logger.info(`[getObjectTagKey] tagKey: ${res.data.tagKey}`);
20466
20518
  return res.data.tagKey;
20467
20519
  } catch (error) {
20468
20520
  logger.warn(`[getObjectTagKey] 获取 tagKey 异常: ${stringifyError(error)}`);
@@ -20471,7 +20523,6 @@ var __webpack_exports__ = {};
20471
20523
  }
20472
20524
  async function submitAndPollTranscode(opts) {
20473
20525
  const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, client, http, logger } = opts;
20474
- logger.info("[submitAndPollTranscode] 开始提交转码任务...");
20475
20526
  const finderUrl = videoUrl.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${videoUrl.split("qq.com")[1]}` : videoUrl;
20476
20527
  logger.info(`[submitAndPollTranscode] 视频尺寸: ${videoMeta.width}x${videoMeta.height}, 时长: ${videoMeta.duration}s`);
20477
20528
  const submitRes = await http.api({
@@ -20510,12 +20561,10 @@ var __webpack_exports__ = {};
20510
20561
  throw new Error(`提交转码失败: ${JSON.stringify(submitRes)}`);
20511
20562
  }
20512
20563
  const { clipKey, draftId } = submitRes.data;
20513
- logger.info(`[submitAndPollTranscode] 转码任务已提交,clipKey: ${clipKey}, draftId: ${draftId}`);
20514
20564
  const pollInterval = 5000;
20515
20565
  const pollBudget = Math.min(1800000, 300000 + 1000 * Math.ceil(1.5 * videoMeta.duration));
20516
20566
  const maxPolls = Math.ceil(pollBudget / pollInterval);
20517
20567
  let pollCount = 0;
20518
- logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls} 次(${Math.round(pollBudget / 1000)}s),间隔 ${pollInterval / 1000}s`);
20519
20568
  while(pollCount < maxPolls){
20520
20569
  await sleep(pollInterval);
20521
20570
  pollCount++;
@@ -20539,14 +20588,12 @@ var __webpack_exports__ = {};
20539
20588
  throw new Error(`转码轮询失败 (poll ${pollCount}): ${JSON.stringify(pollRes)}`);
20540
20589
  }
20541
20590
  const { flag, url, width, height, duration, md5, fileSize } = pollRes.data || {};
20542
- logger.info(`[submitAndPollTranscode] 轮询第 ${pollCount} 次,flag=${flag}`);
20543
20591
  if (1 === flag) {
20544
20592
  if (!url || !width || !height || !duration || !md5 || !fileSize) {
20545
20593
  logger.error("[submitAndPollTranscode] 转码完成但返回数据不完整:", JSON.stringify(pollRes.data));
20546
20594
  throw new Error(`转码完成但返回数据不完整: ${JSON.stringify(pollRes.data)}`);
20547
20595
  }
20548
20596
  logger.info(`[submitAndPollTranscode] 转码完成! 用时: ${pollCount * pollInterval / 1000}s`);
20549
- logger.info(`[submitAndPollTranscode] 视频信息: ${width}x${height}, 时长: ${duration}s, 大小: ${fileSize}`);
20550
20597
  return {
20551
20598
  clipKey,
20552
20599
  url,
@@ -20557,7 +20604,7 @@ var __webpack_exports__ = {};
20557
20604
  fileSize
20558
20605
  };
20559
20606
  }
20560
- if (2 === flag) logger.info(`[submitAndPollTranscode] 转码中... (${pollCount}/${maxPolls})`);
20607
+ if (2 === flag) ;
20561
20608
  else {
20562
20609
  logger.error(`[submitAndPollTranscode] 转码失败,未知 flag=${flag}:`, JSON.stringify(pollRes.data));
20563
20610
  throw new Error(`转码失败,未知 flag=${flag}: ${JSON.stringify(pollRes.data)}`);
@@ -20568,16 +20615,11 @@ var __webpack_exports__ = {};
20568
20615
  }
20569
20616
  async function publishVideo(opts) {
20570
20617
  const { params, auth, client, clipResult, videoUpload, coverUpload, verticalCoverUpload, videoMeta, traceKey, tagKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
20571
- logger.info("[publishVideo] 开始构建发布请求...");
20572
20618
  const toFinderUrl = (url)=>url.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${url.split("qq.com")[1]}` : url;
20573
20619
  const thumbFinderUrl = toFinderUrl(coverUpload.downloadUrl);
20574
20620
  const coverFinderUrl = toFinderUrl(verticalCoverUpload.downloadUrl);
20575
20621
  const md5sumUuid = external_node_crypto_default().randomUUID();
20576
20622
  const description = params.description;
20577
- logger.info("[publishVideo] 发布参数:");
20578
- logger.info(` - 短标题: ${params.title || "(无)"}`);
20579
- logger.info(` - 描述: ${description.substring(0, 50)}${description.length > 50 ? "..." : ""}`);
20580
- logger.info(` - 定时发布: ${params.scheduledTime ? new Date(1000 * params.scheduledTime).toLocaleString() : "立即发布"}`);
20581
20623
  const objectDesc = {
20582
20624
  mpTitle: "",
20583
20625
  description,
@@ -20651,7 +20693,6 @@ var __webpack_exports__ = {};
20651
20693
  };
20652
20694
  if (params.scheduledTime) publishData.effectiveTime = params.scheduledTime;
20653
20695
  if (params.tagInfo && tagKey) publishData.tagInfo = buildTagInfo(params.tagInfo, tagKey);
20654
- logger.info("[publishVideo] 开始发布视频,全部参数:" + JSON.stringify(publishData));
20655
20696
  const publishRes = await proxyHttp.api({
20656
20697
  method: "POST",
20657
20698
  url: `${MICRO_CONTENT_BASE}/post/post_create`,
@@ -20659,7 +20700,7 @@ var __webpack_exports__ = {};
20659
20700
  data: publishData,
20660
20701
  defaultErrorMsg: "发布视频失败"
20661
20702
  });
20662
- logger.info(`[publishVideo] 发布响应: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
20703
+ logger.info(`[publishVideo] 发布结果: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
20663
20704
  return publishRes;
20664
20705
  }
20665
20706
  function sleep(ms) {
@@ -20673,11 +20714,9 @@ var __webpack_exports__ = {};
20673
20714
  return savePath;
20674
20715
  }
20675
20716
  const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
20676
- task.logger.info("[shipinhaoPublishVideo] 开始执行视频号视频发布 - Mock API 方式");
20677
20717
  const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
20678
20718
  let currentStep = "初始化";
20679
20719
  try {
20680
- task.logger.info(`[shipinhaoPublishVideo] 发布方式: ${params.scheduledTime ? `定时 ${new Date(1000 * params.scheduledTime).toLocaleString()}` : "立即发布"}`);
20681
20720
  currentStep = "解析认证信息";
20682
20721
  const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
20683
20722
  const http = new Http({
@@ -20689,11 +20728,8 @@ var __webpack_exports__ = {};
20689
20728
  if (!params.videoPath) return (0, share_namespaceObject.response)(414, "视频文件路径不能为空", "");
20690
20729
  if (!params.coverPath) return (0, share_namespaceObject.response)(414, "横屏封面图片路径不能为空", "");
20691
20730
  currentStep = "获取上传认证";
20692
- task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
20693
20731
  const auth = await getShipinhaoUploadAuth(cookieString, http);
20694
20732
  const client = resolveClientContext(params, auth.uin);
20695
- if (!client.aId) task.logger.warn("[shipinhaoPublishVideo] extraParam.aId 缺失,query 将不带 _aid");
20696
- if (!client.fingerPrintDeviceId) task.logger.warn("[shipinhaoPublishVideo] extraParam.fingerPrintDeviceId 缺失,请求将不带 finger-print-device-id");
20697
20733
  const publishHeaders = buildPublishHeaders(cookieString, client);
20698
20734
  const microHttp = new Http({
20699
20735
  headers: publishHeaders
@@ -20709,25 +20745,20 @@ var __webpack_exports__ = {};
20709
20745
  ];
20710
20746
  const proxyHttp = new Http(...args);
20711
20747
  currentStep = "组装视频元数据";
20712
- task.logger.info("[shipinhaoPublishVideo] 组装视频元数据...");
20713
20748
  const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
20714
20749
  task.logger.info(`[shipinhaoPublishVideo] 视频: ${videoMeta.width}×${videoMeta.height}, ${videoMeta.duration.toFixed(2)}s, ${(videoMeta.fileSize / 1024 / 1024).toFixed(2)}MB, codec=${videoMeta.codec || "unknown"}`);
20715
- if (!videoMeta.codec) task.logger.warn("[shipinhaoPublishVideo] 未能读取视频编码格式,跳过 H.264 预检,交由服务端判断");
20716
20750
  currentStep = "校验视频限制";
20717
20751
  const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
20718
20752
  if (validationError) {
20719
- task.logger.error(`[shipinhaoPublishVideo] 视频校验未通过: ${validationError}`);
20720
20753
  await updateTaskState?.({
20721
20754
  state: share_namespaceObject.TaskState.FAILED,
20722
20755
  error: validationError
20723
20756
  });
20724
20757
  return (0, share_namespaceObject.response)(414, validationError, "");
20725
20758
  }
20726
- task.logger.info("[shipinhaoPublishVideo] 视频校验通过");
20727
20759
  currentStep = "校验标题";
20728
20760
  const titleError = validateShipinhaoTitle(params.title);
20729
20761
  if (titleError) {
20730
- task.logger.error(`[shipinhaoPublishVideo] 标题校验未通过: ${titleError}`);
20731
20762
  await updateTaskState?.({
20732
20763
  state: share_namespaceObject.TaskState.FAILED,
20733
20764
  error: titleError
@@ -20735,7 +20766,6 @@ var __webpack_exports__ = {};
20735
20766
  return (0, share_namespaceObject.response)(414, titleError, "");
20736
20767
  }
20737
20768
  currentStep = "获取 traceKey";
20738
- task.logger.info("[shipinhaoPublishVideo] 获取 traceKey...");
20739
20769
  const traceKey = await getTraceKey(auth, client, microHttp, task.logger);
20740
20770
  let tagKey = null;
20741
20771
  if (params.tagInfo) {
@@ -20743,11 +20773,7 @@ var __webpack_exports__ = {};
20743
20773
  tagKey = await getObjectTagKey(auth, client, microHttp, task.logger);
20744
20774
  }
20745
20775
  const uploadStartTime = Math.floor(Date.now() / 1000);
20746
- task.logger.info(`[shipinhaoPublishVideo] 上传开始时间: ${uploadStartTime}`);
20747
20776
  currentStep = "上传视频";
20748
- task.logger.info("[shipinhaoPublishVideo] 上传视频...");
20749
- task.logger.info(`[shipinhaoPublishVideo] 视频路径: ${params.videoPath}`);
20750
- task.logger.info(`[shipinhaoPublishVideo] 视频文件类型: ${auth.videoFileType}`);
20751
20777
  const videoUpload = await uploader_uploadFile({
20752
20778
  filePath: params.videoPath,
20753
20779
  fileType: auth.videoFileType,
@@ -20756,12 +20782,10 @@ var __webpack_exports__ = {};
20756
20782
  http,
20757
20783
  logger: task.logger
20758
20784
  });
20759
- task.logger.info("[shipinhaoPublishVideo] 视频上传完成");
20760
20785
  const uploadEndTime = Math.floor(Date.now() / 1000);
20761
- task.logger.info(`[shipinhaoPublishVideo] 上传结束时间: ${uploadEndTime}, 耗时: ${uploadEndTime - uploadStartTime}s`);
20786
+ task.logger.info(`[shipinhaoPublishVideo] 耗时: ${uploadEndTime - uploadStartTime}s`);
20762
20787
  currentStep = "上传横屏封面";
20763
20788
  const localCoverPath = await resolveLocalCoverPath(params.coverPath, "横屏封面", task.getTmpPath(), task.logger);
20764
- task.logger.info("[shipinhaoPublishVideo] 上传横屏封面...");
20765
20789
  const coverUpload = await uploader_uploadFile({
20766
20790
  filePath: localCoverPath,
20767
20791
  fileType: auth.pictureFileType,
@@ -20770,12 +20794,10 @@ var __webpack_exports__ = {};
20770
20794
  http,
20771
20795
  logger: task.logger
20772
20796
  });
20773
- task.logger.info("[shipinhaoPublishVideo] 横屏封面上传完成");
20774
20797
  let verticalCoverUpload = coverUpload;
20775
20798
  if (params.verticalCoverPath) {
20776
20799
  currentStep = "上传竖屏封面";
20777
20800
  const localVerticalPath = await resolveLocalCoverPath(params.verticalCoverPath, "竖屏封面", task.getTmpPath(), task.logger);
20778
- task.logger.info("[shipinhaoPublishVideo] 上传竖屏封面");
20779
20801
  verticalCoverUpload = await uploader_uploadFile({
20780
20802
  filePath: localVerticalPath,
20781
20803
  fileType: auth.pictureFileType,
@@ -20784,10 +20806,8 @@ var __webpack_exports__ = {};
20784
20806
  http,
20785
20807
  logger: task.logger
20786
20808
  });
20787
- task.logger.info("[shipinhaoPublishVideo] 竖屏封面上传完成");
20788
- } else task.logger.info("[shipinhaoPublishVideo] 未传竖屏封面,复用横屏封面");
20809
+ }
20789
20810
  currentStep = "提交转码";
20790
- task.logger.info("[shipinhaoPublishVideo] 提交转码...");
20791
20811
  const clipResult = await submitAndPollTranscode({
20792
20812
  videoUrl: videoUpload.downloadUrl,
20793
20813
  videoMeta,
@@ -20800,8 +20820,6 @@ var __webpack_exports__ = {};
20800
20820
  logger: task.logger
20801
20821
  });
20802
20822
  currentStep = "发布视频";
20803
- task.logger.info("[shipinhaoPublishVideo] 发布视频...");
20804
- task.logger.info(`[shipinhaoPublishVideo] clipKey: ${clipResult.clipKey}`);
20805
20823
  let publishResult;
20806
20824
  try {
20807
20825
  publishResult = await publishVideo({
@@ -20826,7 +20844,6 @@ var __webpack_exports__ = {};
20826
20844
  const classified = classifyPublishError(handledError);
20827
20845
  if (classified) {
20828
20846
  const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
20829
- task.logger.error(`[shipinhaoPublishVideo] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
20830
20847
  await updateTaskState?.({
20831
20848
  state: share_namespaceObject.TaskState.FAILED,
20832
20849
  error: message
@@ -20843,11 +20860,8 @@ var __webpack_exports__ = {};
20843
20860
  const resultCode = publishResult.data?.baseResp?.errcode ?? publishResult.errCode;
20844
20861
  const resultMsg = publishResult.data?.baseResp?.errmsg ?? (0 === resultCode ? "发布成功" : `发布失败(errCode=${resultCode})`);
20845
20862
  if (0 === resultCode) {
20846
- task.logger.info("[shipinhaoPublishVideo] 发布成功");
20847
- task.logger.info(`[shipinhaoPublishVideo] 作品ID: ${clipResult.clipKey}`);
20848
- task.logger.info(`[shipinhaoPublishVideo] 视频URL: ${clipResult.url}`);
20849
- task.logger.info(`[shipinhaoPublishVideo] 横屏封面URL: ${coverUpload.downloadUrl}`);
20850
- task.logger.info(`[shipinhaoPublishVideo] 竖屏封面URL: ${verticalCoverUpload.downloadUrl}`);
20863
+ const publishId = extractEncFileKey(verticalCoverUpload.downloadUrl);
20864
+ if (!publishId) task.logger.error(`[shipinhaoPublishVideo] 封面 DownloadURL 中未解析到 encfilekey,关联 id 为空: ${verticalCoverUpload.downloadUrl}`);
20851
20865
  await updateTaskState?.({
20852
20866
  state: share_namespaceObject.TaskState.SUCCESS,
20853
20867
  result: {
@@ -20877,8 +20891,7 @@ var __webpack_exports__ = {};
20877
20891
  },
20878
20892
  platform: "shipinhao"
20879
20893
  });
20880
- task.logger.info("[shipinhaoPublishVideo] 日志上报完成");
20881
- return (0, share_namespaceObject.response)(0, "发布成功", clipResult.clipKey);
20894
+ return (0, share_namespaceObject.response)(0, "发布成功", publishId);
20882
20895
  }
20883
20896
  let errorMessage = resultMsg;
20884
20897
  if (-11224 === resultCode) errorMessage = "视频号管理员完成实名且绑定手机号后才可以发表";
@@ -20890,18 +20903,16 @@ var __webpack_exports__ = {};
20890
20903
  state: share_namespaceObject.TaskState.FAILED,
20891
20904
  error: errorMessage
20892
20905
  });
20893
- return (0, share_namespaceObject.response)(resultCode || 414, errorMessage, "");
20906
+ return (0, share_namespaceObject.response)(414, errorMessage, "");
20894
20907
  } catch (error) {
20895
20908
  const handledError = Http.handleApiError(error);
20896
20909
  const errorMsg = handledError.message || "发布失败,请稍后重试";
20897
- const errorCode = handledError.code || 414;
20898
20910
  task.logger.error(`[shipinhaoPublishVideo] 发布流程异常 [${currentStep}]: ${errorMsg}`, stringifyError(error), handledError.extra);
20899
- task.logger.error(`[shipinhaoPublishVideo] 错误码: ${errorCode}, 当前步骤: ${currentStep}`);
20900
20911
  await updateTaskState?.({
20901
20912
  state: share_namespaceObject.TaskState.FAILED,
20902
20913
  error: errorMsg
20903
20914
  });
20904
- return (0, share_namespaceObject.response)(errorCode, errorMsg, "");
20915
+ return (0, share_namespaceObject.response)(414, errorMsg, "");
20905
20916
  }
20906
20917
  };
20907
20918
  const shipinhaoPublishVideo_rpa_rpaAction = async (task, params)=>{
@@ -27473,4 +27484,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
27473
27484
  });
27474
27485
 
27475
27486
  //# sourceMappingURL=index.js.map
27476
- //# debugId=959450cb-879c-5526-aedb-26ef8ba0e7a8
27487
+ //# debugId=028a0eb4-9179-5708-bae0-75174165ae68