@iflyrpa/actions 4.1.0-beta.0 → 4.1.0-beta.2

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.
@@ -38,9 +38,9 @@ export declare const SearchAccountInfoParamsSchema: z.ZodObject<{
38
38
  token: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
39
39
  platform: z.ZodEnum<{
40
40
  baijiahao: "baijiahao";
41
+ xiaohongshu: "xiaohongshu";
41
42
  douyin: "douyin";
42
43
  toutiao: "toutiao";
43
- xiaohongshu: "xiaohongshu";
44
44
  weixin: "weixin";
45
45
  shipinhao: "shipinhao";
46
46
  }>;
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]="6fdb1841-1467-5c52-bdfa-6acbd4df3bcb")}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]="e5c917b4-4ca0-5538-9e4e-f99d97e05dd9")}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";
@@ -12490,10 +12490,8 @@ var __webpack_exports__ = {};
12490
12490
  navigator: ()=>_navigator,
12491
12491
  origin: ()=>utils_origin
12492
12492
  });
12493
- var package_namespaceObject = {
12494
- i8: "0.1.2"
12495
- };
12496
- var package_namespaceObject_0 = JSON.parse('{"i8":"4.1.0-beta.0"}');
12493
+ var package_namespaceObject = JSON.parse('{"i8":"0.1.3-beta.0"}');
12494
+ var package_namespaceObject_0 = JSON.parse('{"i8":"4.1.0-beta.2"}');
12497
12495
  const external_node_fs_namespaceObject = require("node:fs");
12498
12496
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
12499
12497
  const external_node_http_namespaceObject = require("node:http");
@@ -12584,7 +12582,7 @@ var __webpack_exports__ = {};
12584
12582
  fileStream.on("error", (err)=>{
12585
12583
  reject({
12586
12584
  code: 500,
12587
- message: `图片Buffer写入失败: ${err.message}`
12585
+ message: "图片写入失败,请检查磁盘空间"
12588
12586
  });
12589
12587
  });
12590
12588
  } else {
@@ -27073,6 +27071,11 @@ var __webpack_exports__ = {};
27073
27071
  const RPA_ERROR_WEBHOOK_URL = "https://open.xfchat.iflytek.com/open-apis/bot/v2/hook/d202c0dc-5af5-40bc-83ed-abc677caa4a5";
27074
27072
  const ALARM_THROTTLE_MS = 60000;
27075
27073
  const lastSentAt = new Map();
27074
+ const THROTTLE_MAP_MAX_KEYS = 500;
27075
+ const pruneThrottleMap = (now)=>{
27076
+ if (lastSentAt.size < THROTTLE_MAP_MAX_KEYS) return;
27077
+ for (const [key, at] of lastSentAt)if (now - at >= ALARM_THROTTLE_MS) lastSentAt.delete(key);
27078
+ };
27076
27079
  const postFeishuWebhook = (webhookUrl, payload)=>lib_axios.post(webhookUrl, payload, {
27077
27080
  headers: {
27078
27081
  "Content-Type": "application/json"
@@ -27150,10 +27153,11 @@ var __webpack_exports__ = {};
27150
27153
  };
27151
27154
  const reportFeishuAlarm = (report)=>{
27152
27155
  try {
27153
- const key = `${report.platform}|${report.source}|${report.errorType}|${report.code ?? ""}`;
27156
+ const key = `${report.platform}|${report.source}|${report.stage}|${report.errorType}|${report.code ?? ""}`;
27154
27157
  const now = Date.now();
27155
27158
  const last = lastSentAt.get(key);
27156
27159
  if (last && now - last < ALARM_THROTTLE_MS) return;
27160
+ pruneThrottleMap(now);
27157
27161
  lastSentAt.set(key, now);
27158
27162
  postFeishuWebhook(RPA_ERROR_WEBHOOK_URL, buildFeishuPostMessage(report)).catch(()=>{});
27159
27163
  } catch {}
@@ -27336,7 +27340,14 @@ var __webpack_exports__ = {};
27336
27340
  };
27337
27341
  class Http {
27338
27342
  static handleApiError(error) {
27339
- if (error && "object" == typeof error && "code" in error && "message" in error) return error;
27343
+ if (error && "object" == typeof error && "code" in error && "message" in error) {
27344
+ const resp = error;
27345
+ if ("string" != typeof resp.message || !resp.message.trim()) return {
27346
+ ...resp,
27347
+ message: USER_MESSAGE.SYSTEM_ERROR
27348
+ };
27349
+ return resp;
27350
+ }
27340
27351
  return {
27341
27352
  code: 500,
27342
27353
  message: USER_MESSAGE.SYSTEM_ERROR,
@@ -27474,21 +27485,35 @@ var __webpack_exports__ = {};
27474
27485
  errorResponse.message = message;
27475
27486
  }
27476
27487
  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
- });
27488
+ errorResponse.extra = {
27489
+ ...errorResponse.extra,
27490
+ alarmStatus: error.response?.status,
27491
+ alarmErrorCode: error.code
27492
+ };
27489
27493
  throw errorResponse;
27490
27494
  });
27491
27495
  }
27496
+ reportRequestFailure(config, error, attempts) {
27497
+ const status = error.extra?.alarmStatus;
27498
+ const axiosCode = error.extra?.alarmErrorCode;
27499
+ const method = (config.method || "get").toUpperCase();
27500
+ const baseURL = config.baseURL || this.apiClient.defaults.baseURL || "";
27501
+ const fullUrl = config.url ? /^https?:\/\//.test(config.url) ? config.url : `${baseURL.replace(/\/$/, "")}${config.url}` : baseURL || "-";
27502
+ const rawMsg = "string" == typeof error.message && error.message.trim() ? error.message : "";
27503
+ const baseMsg = rawMsg || `请求失败(无错误文案,code=${error.code ?? "unknown"})`;
27504
+ const retriedSuffix = attempts > 0 ? `(已重试${attempts}次仍失败)` : "";
27505
+ reportFeishuAlarm({
27506
+ level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
27507
+ platform: "@iflyrpa/playwright",
27508
+ source: "http",
27509
+ stage: `${method} ${fullUrl}`,
27510
+ errorType: status ? `HTTP_${status}` : axiosCode || "NETWORK_ERROR",
27511
+ code: error.code,
27512
+ msg: `${baseMsg}${retriedSuffix}`,
27513
+ url: "-" !== fullUrl ? fullUrl : void 0,
27514
+ title: "RPA接口异常"
27515
+ });
27516
+ }
27492
27517
  async api(config, options) {
27493
27518
  const retries = options?.retries ?? 0;
27494
27519
  const retryDelay = options?.retryDelay ?? 500;
@@ -27533,10 +27558,12 @@ var __webpack_exports__ = {};
27533
27558
  ].includes(handledError.code);
27534
27559
  if (Rtimes < retries && isRetry) {
27535
27560
  const url = config.url || "";
27536
- this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 请求地址: ${url}`);
27537
- await new Promise((resolve)=>setTimeout(resolve, retryDelay));
27561
+ const backoff = Math.min(retryDelay * 2 ** Rtimes, 5000);
27562
+ this.logger?.warn(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}, 等待: ${backoff}ms, 请求地址: ${url}`);
27563
+ await new Promise((resolve)=>setTimeout(resolve, backoff));
27538
27564
  return sessionRt(Rtimes + 1);
27539
27565
  }
27566
+ this.reportRequestFailure(config, handledError, Rtimes);
27540
27567
  return Promise.reject(handledError);
27541
27568
  }
27542
27569
  };
@@ -33608,7 +33635,8 @@ var __webpack_exports__ = {};
33608
33635
  },
33609
33636
  _task.logger,
33610
33637
  params.proxyLoc,
33611
- params.accountId
33638
+ params.accountId,
33639
+ "xiaohongshu"
33612
33640
  ];
33613
33641
  const http = new Http(...args);
33614
33642
  const fans = {
@@ -33622,8 +33650,8 @@ var __webpack_exports__ = {};
33622
33650
  url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
33623
33651
  }, {
33624
33652
  retries: 3,
33625
- retryDelay: 20,
33626
- timeout: 3000
33653
+ retryDelay: 300,
33654
+ timeout: 30000
33627
33655
  });
33628
33656
  fans.fans_count = Number(res.data.fans_count);
33629
33657
  fans.digg_count = Number(res.data.faved_count);
@@ -34760,7 +34788,8 @@ var __webpack_exports__ = {};
34760
34788
  },
34761
34789
  _task.logger,
34762
34790
  params.proxyLoc,
34763
- params.accountId
34791
+ params.accountId,
34792
+ "xiaohongshu"
34764
34793
  ];
34765
34794
  const http = new Http(...args);
34766
34795
  http.addResponseInterceptor((response)=>{
@@ -34808,8 +34837,8 @@ var __webpack_exports__ = {};
34808
34837
  headers: loginBaseXsHeader
34809
34838
  }, {
34810
34839
  retries: 3,
34811
- retryDelay: 20,
34812
- timeout: 5000
34840
+ retryDelay: 300,
34841
+ timeout: 30000
34813
34842
  }).catch((e)=>{
34814
34843
  const clientTimestamp = Date.now();
34815
34844
  const serverDate = e?.extra?.serverDate;
@@ -34841,8 +34870,8 @@ var __webpack_exports__ = {};
34841
34870
  headers: webSessionXsHeader
34842
34871
  }, {
34843
34872
  retries: 3,
34844
- retryDelay: 20,
34845
- timeout: 5000
34873
+ retryDelay: 300,
34874
+ timeout: 30000
34846
34875
  });
34847
34876
  const [baseInfo, web_session] = await Promise.all([
34848
34877
  _baseInfo,
@@ -34934,6 +34963,10 @@ var __webpack_exports__ = {};
34934
34963
  };
34935
34964
  return success(data, message);
34936
34965
  };
34966
+ const extractEncFileKey = (downloadUrl)=>{
34967
+ if (!downloadUrl) return "";
34968
+ return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
34969
+ };
34937
34970
  const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
34938
34971
  ...Array(8)
34939
34972
  ].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
@@ -40579,7 +40612,8 @@ var __webpack_exports__ = {};
40579
40612
  },
40580
40613
  _task.logger,
40581
40614
  params.proxyLoc,
40582
- params.accountId
40615
+ params.accountId,
40616
+ "xiaohongshu"
40583
40617
  ];
40584
40618
  const http = new Http(...args);
40585
40619
  let unreadCount = {
@@ -40608,8 +40642,8 @@ var __webpack_exports__ = {};
40608
40642
  headers: xsHeader
40609
40643
  }, {
40610
40644
  retries: 3,
40611
- retryDelay: 20,
40612
- timeout: 3000
40645
+ retryDelay: 300,
40646
+ timeout: 30000
40613
40647
  });
40614
40648
  const isSuccess = 0 === res.code;
40615
40649
  if (isSuccess) unreadCount = res.data;
@@ -41022,7 +41056,8 @@ var __webpack_exports__ = {};
41022
41056
  },
41023
41057
  _task.logger,
41024
41058
  params.proxyLoc,
41025
- params.accountId
41059
+ params.accountId,
41060
+ "xiaohongshu"
41026
41061
  ];
41027
41062
  const http = new Http(...args);
41028
41063
  const xsEncrypt = new Xhshow();
@@ -41038,8 +41073,8 @@ var __webpack_exports__ = {};
41038
41073
  url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
41039
41074
  }, {
41040
41075
  retries: 3,
41041
- retryDelay: 20,
41042
- timeout: 3000
41076
+ retryDelay: 300,
41077
+ timeout: 30000
41043
41078
  }),
41044
41079
  http.api({
41045
41080
  method: "get",
@@ -41048,8 +41083,8 @@ var __webpack_exports__ = {};
41048
41083
  headers: sevenDataXsHeader
41049
41084
  }, {
41050
41085
  retries: 3,
41051
- retryDelay: 20,
41052
- timeout: 3000
41086
+ retryDelay: 300,
41087
+ timeout: 30000
41053
41088
  })
41054
41089
  ]);
41055
41090
  const xhsData = {
@@ -44088,7 +44123,7 @@ var __webpack_exports__ = {};
44088
44123
  const resultMsg = publishResult.data?.baseResp?.errmsg ?? publishResult.errMsg;
44089
44124
  if (0 === resultCode) {
44090
44125
  task.logger.info("[shipinhaoPublish] 发布成功");
44091
- const publishId = uploadedImages[0]?.thumbUrl?.split("encfilekey=")[1]?.split("&")[0] || "";
44126
+ const publishId = extractEncFileKey(uploadedImages[0]?.thumbUrl);
44092
44127
  await updateTaskState?.({
44093
44128
  state: types_TaskState.SUCCESS,
44094
44129
  result: {
@@ -44983,8 +45018,7 @@ var __webpack_exports__ = {};
44983
45018
  const partTimeout = tuning?.partTimeout ?? DEFAULT_TUNING.partTimeout;
44984
45019
  const partRetries = tuning?.partRetries ?? DEFAULT_TUNING.partRetries;
44985
45020
  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`);
45021
+ logger?.info(`[shipinhaoPublishVideo] 开始上传: ${fileName} (${fileSize} B, filetype=${fileType})`);
44988
45022
  const fileMd5 = await computeFileMd5(filePath);
44989
45023
  const taskId = generateTaskId(fileName, fileSize, fileMd5);
44990
45024
  const baseUrl = "https://finderassistancea.video.qq.com";
@@ -44995,7 +45029,7 @@ var __webpack_exports__ = {};
44995
45029
  const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
44996
45030
  const blockPartLength = [];
44997
45031
  for(let i = 0; i < chunkCount; i++)blockPartLength.push(Math.min((i + 1) * CHUNK_SIZE, fileSize));
44998
- logger?.info(`申请 UploadID: ${chunkCount} 片`);
45032
+ logger?.info(`[shipinhaoPublishVideo] 视频分片: ${chunkCount} 片`);
44999
45033
  const applyRes = await http.api({
45000
45034
  method: "PUT",
45001
45035
  url: `${baseUrl}/applyuploaddfs`,
@@ -45016,7 +45050,6 @@ var __webpack_exports__ = {};
45016
45050
  let uploadId = applyRes.UploadID;
45017
45051
  const uploadedParts = new Set();
45018
45052
  if (applyRes.ListPartsResult) {
45019
- logger?.info("检测到已上传分片,执行续传");
45020
45053
  const parts = Array.isArray(applyRes.ListPartsResult.Part) ? applyRes.ListPartsResult.Part : applyRes.ListPartsResult.Part ? [
45021
45054
  applyRes.ListPartsResult.Part
45022
45055
  ] : [];
@@ -45052,7 +45085,6 @@ var __webpack_exports__ = {};
45052
45085
  PartNumber: partNumber,
45053
45086
  ETag: existing.ETag
45054
45087
  });
45055
- logger?.info(`分片 ${partNumber}/${chunkCount} 已存在,跳过`);
45056
45088
  continue;
45057
45089
  }
45058
45090
  }
@@ -45077,18 +45109,15 @@ var __webpack_exports__ = {};
45077
45109
  retries: partRetries,
45078
45110
  retryDelay: 2000
45079
45111
  });
45080
- const partElapsed = Date.now() - partStart;
45081
- const throughput = Math.round(chunkSize / (partElapsed / 1000));
45112
+ Date.now();
45082
45113
  partInfo.push({
45083
45114
  PartNumber: partNumber,
45084
45115
  ETag: `"${chunkMd5}"`
45085
45116
  });
45086
- logger?.info(`分片 ${partNumber}/${chunkCount} 完成 (${chunkSize} B, ${partElapsed}ms, ${Math.round(throughput / 1024)}KB/s)`);
45087
45117
  }
45088
45118
  } finally{
45089
45119
  external_node_fs_default().closeSync(fd);
45090
45120
  }
45091
- logger?.info("合并分片...");
45092
45121
  const completeRes = await http.api({
45093
45122
  method: "POST",
45094
45123
  url: `${baseUrl}/completepartuploaddfs?UploadID=${encodeURIComponent(uploadId)}`,
@@ -45106,7 +45135,7 @@ var __webpack_exports__ = {};
45106
45135
  retryDelay: 3000
45107
45136
  });
45108
45137
  if (!completeRes.DownloadURL) throw new Error("合并分片失败: " + JSON.stringify(completeRes));
45109
- logger?.info("上传成功");
45138
+ logger?.info(`[shipinhaoPublishVideo] ${fileName} 上传成功`);
45110
45139
  return {
45111
45140
  downloadUrl: completeRes.DownloadURL,
45112
45141
  md5: fileMd5,
@@ -45500,7 +45529,6 @@ var __webpack_exports__ = {};
45500
45529
  };
45501
45530
  }
45502
45531
  async function getTraceKey(auth, client, http, logger) {
45503
- logger.info("[getTraceKey] 开始获取 traceKey...");
45504
45532
  const res = await http.api({
45505
45533
  method: "POST",
45506
45534
  url: `${MICRO_CONTENT_BASE}/post/get-finder-post-trace-key`,
@@ -45515,11 +45543,9 @@ var __webpack_exports__ = {};
45515
45543
  logger.error("[getTraceKey] 获取失败:", JSON.stringify(res));
45516
45544
  throw new Error(`获取 traceKey 失败: ${JSON.stringify(res)}`);
45517
45545
  }
45518
- logger.info(`[getTraceKey] 获取成功: ${res.data.traceKey}`);
45519
45546
  return res.data.traceKey;
45520
45547
  }
45521
45548
  async function getObjectTagKey(auth, client, http, logger) {
45522
- logger.info("[getObjectTagKey] 获取内容声明 tagKey...");
45523
45549
  try {
45524
45550
  const res = await http.api({
45525
45551
  method: "POST",
@@ -45535,7 +45561,6 @@ var __webpack_exports__ = {};
45535
45561
  logger.warn(`[getObjectTagKey] 未取到 tagKey: ${JSON.stringify(res)}`);
45536
45562
  return null;
45537
45563
  }
45538
- logger.info(`[getObjectTagKey] tagKey: ${res.data.tagKey}`);
45539
45564
  return res.data.tagKey;
45540
45565
  } catch (error) {
45541
45566
  logger.warn(`[getObjectTagKey] 获取 tagKey 异常: ${stringifyError(error)}`);
@@ -45544,7 +45569,6 @@ var __webpack_exports__ = {};
45544
45569
  }
45545
45570
  async function submitAndPollTranscode(opts) {
45546
45571
  const { videoUrl, videoMeta, traceKey, uploadStartTime, uploadEndTime, finderUsername, client, http, logger } = opts;
45547
- logger.info("[submitAndPollTranscode] 开始提交转码任务...");
45548
45572
  const finderUrl = videoUrl.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${videoUrl.split("qq.com")[1]}` : videoUrl;
45549
45573
  logger.info(`[submitAndPollTranscode] 视频尺寸: ${videoMeta.width}x${videoMeta.height}, 时长: ${videoMeta.duration}s`);
45550
45574
  const submitRes = await http.api({
@@ -45583,12 +45607,10 @@ var __webpack_exports__ = {};
45583
45607
  throw new Error(`提交转码失败: ${JSON.stringify(submitRes)}`);
45584
45608
  }
45585
45609
  const { clipKey, draftId } = submitRes.data;
45586
- logger.info(`[submitAndPollTranscode] 转码任务已提交,clipKey: ${clipKey}, draftId: ${draftId}`);
45587
45610
  const pollInterval = 5000;
45588
45611
  const pollBudget = Math.min(1800000, 300000 + 1000 * Math.ceil(1.5 * videoMeta.duration));
45589
45612
  const maxPolls = Math.ceil(pollBudget / pollInterval);
45590
45613
  let pollCount = 0;
45591
- logger.info(`[submitAndPollTranscode] 开始轮询转码结果,最多 ${maxPolls} 次(${Math.round(pollBudget / 1000)}s),间隔 ${pollInterval / 1000}s`);
45592
45614
  while(pollCount < maxPolls){
45593
45615
  await mock_sleep(pollInterval);
45594
45616
  pollCount++;
@@ -45612,14 +45634,12 @@ var __webpack_exports__ = {};
45612
45634
  throw new Error(`转码轮询失败 (poll ${pollCount}): ${JSON.stringify(pollRes)}`);
45613
45635
  }
45614
45636
  const { flag, url, width, height, duration, md5, fileSize } = pollRes.data || {};
45615
- logger.info(`[submitAndPollTranscode] 轮询第 ${pollCount} 次,flag=${flag}`);
45616
45637
  if (1 === flag) {
45617
45638
  if (!url || !width || !height || !duration || !md5 || !fileSize) {
45618
45639
  logger.error("[submitAndPollTranscode] 转码完成但返回数据不完整:", JSON.stringify(pollRes.data));
45619
45640
  throw new Error(`转码完成但返回数据不完整: ${JSON.stringify(pollRes.data)}`);
45620
45641
  }
45621
45642
  logger.info(`[submitAndPollTranscode] 转码完成! 用时: ${pollCount * pollInterval / 1000}s`);
45622
- logger.info(`[submitAndPollTranscode] 视频信息: ${width}x${height}, 时长: ${duration}s, 大小: ${fileSize}`);
45623
45643
  return {
45624
45644
  clipKey,
45625
45645
  url,
@@ -45630,7 +45650,7 @@ var __webpack_exports__ = {};
45630
45650
  fileSize
45631
45651
  };
45632
45652
  }
45633
- if (2 === flag) logger.info(`[submitAndPollTranscode] 转码中... (${pollCount}/${maxPolls})`);
45653
+ if (2 === flag) ;
45634
45654
  else {
45635
45655
  logger.error(`[submitAndPollTranscode] 转码失败,未知 flag=${flag}:`, JSON.stringify(pollRes.data));
45636
45656
  throw new Error(`转码失败,未知 flag=${flag}: ${JSON.stringify(pollRes.data)}`);
@@ -45641,16 +45661,11 @@ var __webpack_exports__ = {};
45641
45661
  }
45642
45662
  async function publishVideo(opts) {
45643
45663
  const { params, auth, client, clipResult, videoUpload, coverUpload, verticalCoverUpload, videoMeta, traceKey, tagKey, uploadStartTime, uploadEndTime, proxyHttp, logger } = opts;
45644
- logger.info("[publishVideo] 开始构建发布请求...");
45645
45664
  const toFinderUrl = (url)=>url.includes("wxapp.tc.qq.com") ? `https://finder.video.qq.com${url.split("qq.com")[1]}` : url;
45646
45665
  const thumbFinderUrl = toFinderUrl(coverUpload.downloadUrl);
45647
45666
  const coverFinderUrl = toFinderUrl(verticalCoverUpload.downloadUrl);
45648
45667
  const md5sumUuid = external_node_crypto_default().randomUUID();
45649
45668
  const description = params.description;
45650
- logger.info("[publishVideo] 发布参数:");
45651
- logger.info(` - 短标题: ${params.title || "(无)"}`);
45652
- logger.info(` - 描述: ${description.substring(0, 50)}${description.length > 50 ? "..." : ""}`);
45653
- logger.info(` - 定时发布: ${params.scheduledTime ? new Date(1000 * params.scheduledTime).toLocaleString() : "立即发布"}`);
45654
45669
  const objectDesc = {
45655
45670
  mpTitle: "",
45656
45671
  description,
@@ -45724,7 +45739,6 @@ var __webpack_exports__ = {};
45724
45739
  };
45725
45740
  if (params.scheduledTime) publishData.effectiveTime = params.scheduledTime;
45726
45741
  if (params.tagInfo && tagKey) publishData.tagInfo = buildTagInfo(params.tagInfo, tagKey);
45727
- logger.info("[publishVideo] 开始发布视频,全部参数:" + JSON.stringify(publishData));
45728
45742
  const publishRes = await proxyHttp.api({
45729
45743
  method: "POST",
45730
45744
  url: `${MICRO_CONTENT_BASE}/post/post_create`,
@@ -45732,7 +45746,7 @@ var __webpack_exports__ = {};
45732
45746
  data: publishData,
45733
45747
  defaultErrorMsg: "发布视频失败"
45734
45748
  });
45735
- logger.info(`[publishVideo] 发布响应: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
45749
+ logger.info(`[publishVideo] 发布结果: errCode=${publishRes.errCode}, baseResp.errcode=${publishRes.data?.baseResp?.errcode}`);
45736
45750
  return publishRes;
45737
45751
  }
45738
45752
  function mock_sleep(ms) {
@@ -45746,11 +45760,9 @@ var __webpack_exports__ = {};
45746
45760
  return savePath;
45747
45761
  }
45748
45762
  const shipinhaoPublishVideo_mock_mockAction = async (task, params)=>{
45749
- task.logger.info("[shipinhaoPublishVideo] 开始执行视频号视频发布 - Mock API 方式");
45750
45763
  const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
45751
45764
  let currentStep = "初始化";
45752
45765
  try {
45753
- task.logger.info(`[shipinhaoPublishVideo] 发布方式: ${params.scheduledTime ? `定时 ${new Date(1000 * params.scheduledTime).toLocaleString()}` : "立即发布"}`);
45754
45766
  currentStep = "解析认证信息";
45755
45767
  const cookieString = params.cookies.map((c)=>`${c.name}=${c.value}`).join("; ");
45756
45768
  const http = new Http({
@@ -45762,11 +45774,8 @@ var __webpack_exports__ = {};
45762
45774
  if (!params.videoPath) return utils_response(414, "视频文件路径不能为空", "");
45763
45775
  if (!params.coverPath) return utils_response(414, "横屏封面图片路径不能为空", "");
45764
45776
  currentStep = "获取上传认证";
45765
- task.logger.info("[shipinhaoPublishVideo] 获取上传认证...");
45766
45777
  const auth = await getShipinhaoUploadAuth(cookieString, http);
45767
45778
  const client = resolveClientContext(params, auth.uin);
45768
- if (!client.aId) task.logger.warn("[shipinhaoPublishVideo] extraParam.aId 缺失,query 将不带 _aid");
45769
- if (!client.fingerPrintDeviceId) task.logger.warn("[shipinhaoPublishVideo] extraParam.fingerPrintDeviceId 缺失,请求将不带 finger-print-device-id");
45770
45779
  const publishHeaders = buildPublishHeaders(cookieString, client);
45771
45780
  const microHttp = new Http({
45772
45781
  headers: publishHeaders
@@ -45782,25 +45791,20 @@ var __webpack_exports__ = {};
45782
45791
  ];
45783
45792
  const proxyHttp = new Http(...args);
45784
45793
  currentStep = "组装视频元数据";
45785
- task.logger.info("[shipinhaoPublishVideo] 组装视频元数据...");
45786
45794
  const videoMeta = buildVideoMetaFromParams(params.videoPath, params.videoMetadata);
45787
45795
  task.logger.info(`[shipinhaoPublishVideo] 视频: ${videoMeta.width}×${videoMeta.height}, ${videoMeta.duration.toFixed(2)}s, ${(videoMeta.fileSize / 1024 / 1024).toFixed(2)}MB, codec=${videoMeta.codec || "unknown"}`);
45788
- if (!videoMeta.codec) task.logger.warn("[shipinhaoPublishVideo] 未能读取视频编码格式,跳过 H.264 预检,交由服务端判断");
45789
45796
  currentStep = "校验视频限制";
45790
45797
  const validationError = validateShipinhaoVideo(params.videoPath, videoMeta);
45791
45798
  if (validationError) {
45792
- task.logger.error(`[shipinhaoPublishVideo] 视频校验未通过: ${validationError}`);
45793
45799
  await updateTaskState?.({
45794
45800
  state: types_TaskState.FAILED,
45795
45801
  error: validationError
45796
45802
  });
45797
45803
  return utils_response(414, validationError, "");
45798
45804
  }
45799
- task.logger.info("[shipinhaoPublishVideo] 视频校验通过");
45800
45805
  currentStep = "校验标题";
45801
45806
  const titleError = validateShipinhaoTitle(params.title);
45802
45807
  if (titleError) {
45803
- task.logger.error(`[shipinhaoPublishVideo] 标题校验未通过: ${titleError}`);
45804
45808
  await updateTaskState?.({
45805
45809
  state: types_TaskState.FAILED,
45806
45810
  error: titleError
@@ -45808,7 +45812,6 @@ var __webpack_exports__ = {};
45808
45812
  return utils_response(414, titleError, "");
45809
45813
  }
45810
45814
  currentStep = "获取 traceKey";
45811
- task.logger.info("[shipinhaoPublishVideo] 获取 traceKey...");
45812
45815
  const traceKey = await getTraceKey(auth, client, microHttp, task.logger);
45813
45816
  let tagKey = null;
45814
45817
  if (params.tagInfo) {
@@ -45816,11 +45819,7 @@ var __webpack_exports__ = {};
45816
45819
  tagKey = await getObjectTagKey(auth, client, microHttp, task.logger);
45817
45820
  }
45818
45821
  const uploadStartTime = Math.floor(Date.now() / 1000);
45819
- task.logger.info(`[shipinhaoPublishVideo] 上传开始时间: ${uploadStartTime}`);
45820
45822
  currentStep = "上传视频";
45821
- task.logger.info("[shipinhaoPublishVideo] 上传视频...");
45822
- task.logger.info(`[shipinhaoPublishVideo] 视频路径: ${params.videoPath}`);
45823
- task.logger.info(`[shipinhaoPublishVideo] 视频文件类型: ${auth.videoFileType}`);
45824
45823
  const videoUpload = await uploader_uploadFile({
45825
45824
  filePath: params.videoPath,
45826
45825
  fileType: auth.videoFileType,
@@ -45829,12 +45828,10 @@ var __webpack_exports__ = {};
45829
45828
  http,
45830
45829
  logger: task.logger
45831
45830
  });
45832
- task.logger.info("[shipinhaoPublishVideo] 视频上传完成");
45833
45831
  const uploadEndTime = Math.floor(Date.now() / 1000);
45834
- task.logger.info(`[shipinhaoPublishVideo] 上传结束时间: ${uploadEndTime}, 耗时: ${uploadEndTime - uploadStartTime}s`);
45832
+ task.logger.info(`[shipinhaoPublishVideo] 耗时: ${uploadEndTime - uploadStartTime}s`);
45835
45833
  currentStep = "上传横屏封面";
45836
45834
  const localCoverPath = await resolveLocalCoverPath(params.coverPath, "横屏封面", task.getTmpPath(), task.logger);
45837
- task.logger.info("[shipinhaoPublishVideo] 上传横屏封面...");
45838
45835
  const coverUpload = await uploader_uploadFile({
45839
45836
  filePath: localCoverPath,
45840
45837
  fileType: auth.pictureFileType,
@@ -45843,12 +45840,10 @@ var __webpack_exports__ = {};
45843
45840
  http,
45844
45841
  logger: task.logger
45845
45842
  });
45846
- task.logger.info("[shipinhaoPublishVideo] 横屏封面上传完成");
45847
45843
  let verticalCoverUpload = coverUpload;
45848
45844
  if (params.verticalCoverPath) {
45849
45845
  currentStep = "上传竖屏封面";
45850
45846
  const localVerticalPath = await resolveLocalCoverPath(params.verticalCoverPath, "竖屏封面", task.getTmpPath(), task.logger);
45851
- task.logger.info("[shipinhaoPublishVideo] 上传竖屏封面");
45852
45847
  verticalCoverUpload = await uploader_uploadFile({
45853
45848
  filePath: localVerticalPath,
45854
45849
  fileType: auth.pictureFileType,
@@ -45857,10 +45852,8 @@ var __webpack_exports__ = {};
45857
45852
  http,
45858
45853
  logger: task.logger
45859
45854
  });
45860
- task.logger.info("[shipinhaoPublishVideo] 竖屏封面上传完成");
45861
- } else task.logger.info("[shipinhaoPublishVideo] 未传竖屏封面,复用横屏封面");
45855
+ }
45862
45856
  currentStep = "提交转码";
45863
- task.logger.info("[shipinhaoPublishVideo] 提交转码...");
45864
45857
  const clipResult = await submitAndPollTranscode({
45865
45858
  videoUrl: videoUpload.downloadUrl,
45866
45859
  videoMeta,
@@ -45873,8 +45866,6 @@ var __webpack_exports__ = {};
45873
45866
  logger: task.logger
45874
45867
  });
45875
45868
  currentStep = "发布视频";
45876
- task.logger.info("[shipinhaoPublishVideo] 发布视频...");
45877
- task.logger.info(`[shipinhaoPublishVideo] clipKey: ${clipResult.clipKey}`);
45878
45869
  let publishResult;
45879
45870
  try {
45880
45871
  publishResult = await publishVideo({
@@ -45899,7 +45890,6 @@ var __webpack_exports__ = {};
45899
45890
  const classified = classifyPublishError(handledError);
45900
45891
  if (classified) {
45901
45892
  const message = `${classified.userMessage}${task.debug ? ` ${http.proxyInfo}` : ""}`;
45902
- task.logger.error(`[shipinhaoPublishVideo] ${classified.category},直接返回: ${handledError.message} (code=${handledError.code})`, stringifyError(handledError));
45903
45893
  await updateTaskState?.({
45904
45894
  state: types_TaskState.FAILED,
45905
45895
  error: message
@@ -45916,11 +45906,8 @@ var __webpack_exports__ = {};
45916
45906
  const resultCode = publishResult.data?.baseResp?.errcode ?? publishResult.errCode;
45917
45907
  const resultMsg = publishResult.data?.baseResp?.errmsg ?? (0 === resultCode ? "发布成功" : `发布失败(errCode=${resultCode})`);
45918
45908
  if (0 === resultCode) {
45919
- task.logger.info("[shipinhaoPublishVideo] 发布成功");
45920
- task.logger.info(`[shipinhaoPublishVideo] 作品ID: ${clipResult.clipKey}`);
45921
- task.logger.info(`[shipinhaoPublishVideo] 视频URL: ${clipResult.url}`);
45922
- task.logger.info(`[shipinhaoPublishVideo] 横屏封面URL: ${coverUpload.downloadUrl}`);
45923
- task.logger.info(`[shipinhaoPublishVideo] 竖屏封面URL: ${verticalCoverUpload.downloadUrl}`);
45909
+ const publishId = extractEncFileKey(verticalCoverUpload.downloadUrl);
45910
+ if (!publishId) task.logger.error(`[shipinhaoPublishVideo] 封面 DownloadURL 中未解析到 encfilekey,关联 id 为空: ${verticalCoverUpload.downloadUrl}`);
45924
45911
  await updateTaskState?.({
45925
45912
  state: types_TaskState.SUCCESS,
45926
45913
  result: {
@@ -45950,8 +45937,7 @@ var __webpack_exports__ = {};
45950
45937
  },
45951
45938
  platform: "shipinhao"
45952
45939
  });
45953
- task.logger.info("[shipinhaoPublishVideo] 日志上报完成");
45954
- return utils_response(0, "发布成功", clipResult.clipKey);
45940
+ return utils_response(0, "发布成功", publishId);
45955
45941
  }
45956
45942
  let errorMessage = resultMsg;
45957
45943
  if (-11224 === resultCode) errorMessage = "视频号管理员完成实名且绑定手机号后才可以发表";
@@ -45963,18 +45949,16 @@ var __webpack_exports__ = {};
45963
45949
  state: types_TaskState.FAILED,
45964
45950
  error: errorMessage
45965
45951
  });
45966
- return utils_response(resultCode || 414, errorMessage, "");
45952
+ return utils_response(414, errorMessage, "");
45967
45953
  } catch (error) {
45968
45954
  const handledError = Http.handleApiError(error);
45969
45955
  const errorMsg = handledError.message || "发布失败,请稍后重试";
45970
- const errorCode = handledError.code || 414;
45971
45956
  task.logger.error(`[shipinhaoPublishVideo] 发布流程异常 [${currentStep}]: ${errorMsg}`, stringifyError(error), handledError.extra);
45972
- task.logger.error(`[shipinhaoPublishVideo] 错误码: ${errorCode}, 当前步骤: ${currentStep}`);
45973
45957
  await updateTaskState?.({
45974
45958
  state: types_TaskState.FAILED,
45975
45959
  error: errorMsg
45976
45960
  });
45977
- return utils_response(errorCode, errorMsg, "");
45961
+ return utils_response(414, errorMsg, "");
45978
45962
  }
45979
45963
  };
45980
45964
  const shipinhaoPublishVideo_rpa_rpaAction = async (task, params)=>{
@@ -52546,4 +52530,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
52546
52530
  });
52547
52531
 
52548
52532
  //# sourceMappingURL=bundle.js.map
52549
- //# debugId=6fdb1841-1467-5c52-bdfa-6acbd4df3bcb
52533
+ //# debugId=e5c917b4-4ca0-5538-9e4e-f99d97e05dd9