@iflyrpa/actions 4.0.8-beta.0 → 4.0.9-beta.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.mjs 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]="ef023941-5d5d-5514-b133-72fa4303f973")}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]="4801cf8d-6f2d-5cdd-9a97-97673fa7dfff")}catch(e){}}();
3
3
  import * as __WEBPACK_EXTERNAL_MODULE_crypto__ from "crypto";
4
4
  import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
5
5
  import * as __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_package_json_58ae5f06__ from "@iflyrpa/share/package.json";
@@ -4352,7 +4352,95 @@ function __webpack_require__(moduleId) {
4352
4352
  return module;
4353
4353
  };
4354
4354
  })();
4355
- var package_namespaceObject = JSON.parse('{"i8":"4.0.8-beta.0"}');
4355
+ var package_namespaceObject = JSON.parse('{"i8":"4.0.9-beta.0"}');
4356
+ const RPA_ERROR_WEBHOOK_URL = "https://open.xfchat.iflytek.com/open-apis/bot/v2/hook/d202c0dc-5af5-40bc-83ed-abc677caa4a5";
4357
+ const ALARM_THROTTLE_MS = 60000;
4358
+ const lastSentAt = new Map();
4359
+ const postFeishuWebhook = (webhookUrl, payload)=>__WEBPACK_EXTERNAL_MODULE_axios__["default"].post(webhookUrl, payload, {
4360
+ headers: {
4361
+ "Content-Type": "application/json"
4362
+ },
4363
+ timeout: 10000
4364
+ });
4365
+ const buildFeishuPostMessage = (report)=>{
4366
+ const content = [
4367
+ [
4368
+ {
4369
+ tag: "text",
4370
+ text: `平台:${report.platform || "未知平台"}`
4371
+ }
4372
+ ],
4373
+ [
4374
+ {
4375
+ tag: "text",
4376
+ text: `错误信息:${report.msg || "未知错误信息"}`
4377
+ }
4378
+ ],
4379
+ [
4380
+ {
4381
+ tag: "text",
4382
+ text: `错误类型:${report.errorType || "未知错误类型"}`
4383
+ }
4384
+ ],
4385
+ [
4386
+ {
4387
+ tag: "text",
4388
+ text: `阶段:${report.stage || "未知阶段"}`
4389
+ }
4390
+ ],
4391
+ [
4392
+ {
4393
+ tag: "text",
4394
+ text: `等级:${report.level}`
4395
+ }
4396
+ ],
4397
+ [
4398
+ {
4399
+ tag: "text",
4400
+ text: `来源:${report.source}`
4401
+ }
4402
+ ]
4403
+ ];
4404
+ if (void 0 !== report.code && null !== report.code) content.push([
4405
+ {
4406
+ tag: "text",
4407
+ text: `接口错误码:${report.code}`
4408
+ }
4409
+ ]);
4410
+ if (report.url) content.push([
4411
+ {
4412
+ tag: "text",
4413
+ text: `地址:${report.url}`
4414
+ }
4415
+ ]);
4416
+ if ("alarm" === report.level) content.push([
4417
+ {
4418
+ tag: "at",
4419
+ user_id: "all"
4420
+ }
4421
+ ]);
4422
+ return {
4423
+ msg_type: "post",
4424
+ content: {
4425
+ post: {
4426
+ zh_cn: {
4427
+ title: report.title || "RPA异常",
4428
+ content
4429
+ }
4430
+ }
4431
+ }
4432
+ };
4433
+ };
4434
+ const reportFeishuAlarm = (report)=>{
4435
+ try {
4436
+ const key = `${report.platform}|${report.source}|${report.errorType}|${report.code ?? ""}`;
4437
+ const now = Date.now();
4438
+ const last = lastSentAt.get(key);
4439
+ if (last && now - last < ALARM_THROTTLE_MS) return;
4440
+ lastSentAt.set(key, now);
4441
+ postFeishuWebhook(RPA_ERROR_WEBHOOK_URL, buildFeishuPostMessage(report)).catch(()=>{});
4442
+ } catch {}
4443
+ };
4356
4444
  const PROXY_CREDENTIALS = [
4357
4445
  {
4358
4446
  ip: "47.110.131.129",
@@ -4454,6 +4542,17 @@ async function ProxyAgent(task, addr, accountId, refresh) {
4454
4542
  url: "https://fetdev.iflysec.com/ip-pool/pool/eip/proxy",
4455
4543
  data: params
4456
4544
  }).catch((err)=>{
4545
+ reportFeishuAlarm({
4546
+ level: "alarm",
4547
+ platform: "ip-pool",
4548
+ source: "proxy",
4549
+ stage: "POST /ip-pool/pool/eip/proxy",
4550
+ errorType: "PROXY_REQUEST_FAILED",
4551
+ code: err?.code,
4552
+ msg: `请求代理失败:${err.message},区域:${addr ?? "-"},AccountId:${accountId ?? "-"}`,
4553
+ url: "https://fetdev.iflysec.com/ip-pool/pool/eip/proxy",
4554
+ title: "代理异常"
4555
+ });
4457
4556
  throw {
4458
4557
  code: 414,
4459
4558
  message: `请求代理失败:${err.message}`,
@@ -4476,6 +4575,47 @@ async function ProxyAgent(task, addr, accountId, refresh) {
4476
4575
  } : null;
4477
4576
  return proxyAgent;
4478
4577
  }
4578
+ const ALARM_STATUS = new Set([
4579
+ 401,
4580
+ 403,
4581
+ 429,
4582
+ 461,
4583
+ 471
4584
+ ]);
4585
+ const HTTP_STATUS_MESSAGE = {
4586
+ 400: "请求参数错误,请检查参数格式是否正确!",
4587
+ 401: "登录状态已失效,请重新登录后重试!",
4588
+ 403: "没有访问权限,账号可能受限或签名已失效!",
4589
+ 404: "请求的资源不存在,请检查接口地址!",
4590
+ 405: "请求方法不被允许,请检查接口调用方式!",
4591
+ 406: "服务端无法返回可接受的内容格式!",
4592
+ 407: "代理需要身份验证,请检查代理配置!",
4593
+ 408: "请求超时,请检查网络连接!",
4594
+ 409: "请求冲突,资源状态已变更,请刷新后重试!",
4595
+ 410: "请求的资源已被移除!",
4596
+ 412: "请求前置条件不满足,请刷新后重试!",
4597
+ 413: "提交内容过大,请压缩或分批后重试!",
4598
+ 414: "请求地址过长,请检查参数!",
4599
+ 415: "不支持的内容类型,请检查请求格式!",
4600
+ 422: "请求内容校验失败,请检查参数内容!",
4601
+ 423: "资源已被锁定,请稍后重试!",
4602
+ 429: "请求过于频繁,请稍后重试!",
4603
+ 431: "请求头过大,请清理 Cookie 后重试!",
4604
+ 451: "内容不合规或因法律原因被拒绝!",
4605
+ 461: "账号可能受限,请在网页上完成验证后重试!",
4606
+ 471: "账号可能受限,请在网页上完成验证后重试!",
4607
+ 500: "服务器内部错误,请稍后重试!",
4608
+ 501: "服务端不支持该请求,请稍后重试!",
4609
+ 502: "网关错误,请稍后重试!",
4610
+ 503: "服务暂时不可用,请稍后重试!",
4611
+ 504: "网关超时,请稍后重试!",
4612
+ 507: "服务端存储空间不足,请稍后重试!",
4613
+ 509: "服务带宽超限,请稍后重试!",
4614
+ 520: "服务端返回未知错误,请稍后重试!",
4615
+ 521: "源站拒绝连接,请稍后重试!",
4616
+ 522: "源站连接超时,请稍后重试!",
4617
+ 524: "源站响应超时,请稍后重试!"
4618
+ };
4479
4619
  class Http {
4480
4620
  static handleApiError(error) {
4481
4621
  if (error && "object" == typeof error && "code" in error && "message" in error) return error;
@@ -4536,6 +4676,18 @@ class Http {
4536
4676
  const verifyDecision = error.response?.headers?.["x-tt-verify-passport-decision"];
4537
4677
  if (verifyDecision) this.logger?.warn(`[403 验证决策] x-tt-verify-passport-decision: ${verifyDecision}`);
4538
4678
  }
4679
+ if (error.response?.status === 461 || error.response?.status === 471) {
4680
+ const h = error.response?.headers ?? {};
4681
+ const pick = (name)=>h[name] ?? h[name.toLowerCase()];
4682
+ this.logger?.warn(`[${error.response.status} 风控验证] URL: ${error.config?.url} Verifytype: ${pick("Verifytype") ?? "-"} Verifyuuid: ${pick("Verifyuuid") ?? "-"} Verifybiz: ${pick("Verifybiz") ?? "-"}`);
4683
+ this.logger?.warn(`[${error.response.status} 响应头] ${JSON.stringify(h)}`);
4684
+ errorResponse.extra = {
4685
+ ...errorResponse.extra,
4686
+ verifyType: pick("Verifytype"),
4687
+ verifyUuid: pick("Verifyuuid"),
4688
+ verifyBiz: pick("Verifybiz")
4689
+ };
4690
+ }
4539
4691
  if (error.response?.data) {
4540
4692
  if ("object" == typeof error.response.data) {
4541
4693
  const serverError = error.response.data;
@@ -4566,11 +4718,17 @@ class Http {
4566
4718
  _message = "DNS 查询超时,请稍后重试!";
4567
4719
  break;
4568
4720
  case "ERR_BAD_REQUEST":
4569
- _message = "请求出现错误,请检查请求参数!";
4570
- break;
4721
+ {
4722
+ const status = error.response?.status;
4723
+ _message = status && HTTP_STATUS_MESSAGE[status] || `请求失败,状态码${status ?? "unknown"}!`;
4724
+ break;
4725
+ }
4571
4726
  case "ERR_BAD_RESPONSE":
4572
- _message = `服务器响应异常 (${error.response?.status ?? "unknown"}),请稍后重试!`;
4573
- break;
4727
+ {
4728
+ const status = error.response?.status;
4729
+ _message = status && HTTP_STATUS_MESSAGE[status] || `服务器响应异常 (${status ?? "unknown"}),请稍后重试!`;
4730
+ break;
4731
+ }
4574
4732
  case "ERR_CANCELED":
4575
4733
  errorResponse.code = 414;
4576
4734
  _message = "请求连接超时,请稍候重试!";
@@ -4581,11 +4739,14 @@ class Http {
4581
4739
  }
4582
4740
  break;
4583
4741
  default:
4584
- this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
4585
- errorString: stringifyError(error)
4586
- });
4587
- _message = `网络错误: ${error.message}`;
4588
- break;
4742
+ {
4743
+ this.logger?.debug(`未处理的网络错误代码: ${error.code} ${error.message}`, {
4744
+ errorString: stringifyError(error)
4745
+ });
4746
+ const status = error.response?.status;
4747
+ _message = status && HTTP_STATUS_MESSAGE[status] || `网络错误: ${error.message} ${status}`;
4748
+ break;
4749
+ }
4589
4750
  }
4590
4751
  }
4591
4752
  if (error.code && !error.response?.data) errorResponse.message = _message || errorResponse.message;
@@ -4595,6 +4756,18 @@ class Http {
4595
4756
  errorResponse.message = message;
4596
4757
  }
4597
4758
  if (error.message.includes("Proxy connection ended")) errorResponse.message = "所在区域代理连接超时,请更换区域或稍后重试!";
4759
+ const status = error.response?.status;
4760
+ reportFeishuAlarm({
4761
+ level: status && ALARM_STATUS.has(status) ? "alarm" : "warning",
4762
+ platform: this.platform || "unknown",
4763
+ source: "http",
4764
+ stage: `${(error.config?.method || "get").toUpperCase()} ${error.config?.url || "-"}`,
4765
+ errorType: status ? `HTTP_${status}` : error.code || "NETWORK_ERROR",
4766
+ code: errorResponse.code,
4767
+ msg: errorResponse.message,
4768
+ url: error.config?.url,
4769
+ title: "RPA接口异常"
4770
+ });
4598
4771
  throw errorResponse;
4599
4772
  });
4600
4773
  }
@@ -5362,7 +5535,7 @@ const NUMBER_FORMAT_RANGES = {
5362
5535
  Number.MAX_VALUE
5363
5536
  ]
5364
5537
  };
5365
- function pick(schema, mask) {
5538
+ function util_pick(schema, mask) {
5366
5539
  const currDef = schema._zod.def;
5367
5540
  const def = mergeDefs(schema._zod.def, {
5368
5541
  get shape () {
@@ -8343,7 +8516,7 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def)=>{
8343
8516
  inst.extend = (incoming)=>extend(inst, incoming);
8344
8517
  inst.safeExtend = (incoming)=>safeExtend(inst, incoming);
8345
8518
  inst.merge = (other)=>merge(inst, other);
8346
- inst.pick = (mask)=>pick(inst, mask);
8519
+ inst.pick = (mask)=>util_pick(inst, mask);
8347
8520
  inst.omit = (mask)=>omit(inst, mask);
8348
8521
  inst.partial = (...args)=>partial(ZodOptional, inst, args[0]);
8349
8522
  inst.required = (...args)=>required(ZodNonOptional, inst, args[0]);
@@ -23515,6 +23688,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
23515
23688
  });
23516
23689
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(data, message);
23517
23690
  }
23691
+ task.logger.info(`[xiaohongshuPublish] publishData: ${JSON.stringify(publishData)} `);
23518
23692
  let publishResult;
23519
23693
  try {
23520
23694
  publishResult = await proxyHttp.api({
@@ -23525,8 +23699,8 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
23525
23699
  defaultErrorMsg: "文章发布异常,请稍后重试。"
23526
23700
  }, {
23527
23701
  retries: 2,
23528
- retryDelay: 500,
23529
- timeout: 12000
23702
+ retryDelay: 3000,
23703
+ timeout: 30000
23530
23704
  });
23531
23705
  } catch (error) {
23532
23706
  const handledError = Http.handleApiError(error);
@@ -25516,4 +25690,4 @@ var __webpack_exports__version = package_namespaceObject.i8;
25516
25690
  export { Action, ActionCommonParamsSchema, BaijiahaoPublishParamsSchema, BetaFlag, CollectionDetailSchema, ConfigDataSchema, DouyinCheckVerifyQrCodeParamsSchema, DouyinCreateCommentReplyParamsSchema, DouyinGetCollectionParamsSchema, DouyinGetCommentListParamsSchema, DouyinGetCommentReplyListParamsSchema, DouyinGetHotParamsSchema, DouyinGetLocationParamsSchema, DouyinGetMusicByCategoryParamsSchema, DouyinGetMusicCategoryParamsSchema, DouyinGetMusicParamsSchema, DouyinGetTopicsParamsSchema, DouyinGetVerifyQrCodeParamsSchema, DouyinGetWorkListParamsSchema, DouyinPublishParamsSchema, FetchArticlesDataSchema, FetchArticlesParamsSchema, Http, ProxyAgent, SearchAccountInfoParamsSchema, SessionCheckResultSchema, ShipinhaoCheckLinkValidateParamsSchema, ShipinhaoGetLocationParamsSchema, ShipinhaoGetMsgParamsSchema, ShipinhaoPublishParamsSchema, ShipinhaoSendMsgParamsSchema, ToutiaoPublishParamsSchema, UnreadCountSchema, WeixinPublishParamsSchema, WxBjhSessionParamsSchema, XhsWebSearchParamsSchema, XiaohongshuPublishParamsSchema, bjhConfigDataSchema, douyinConfigDataSchema, getFileState, reportLogger, rpaAction_Server_Mock, shipinhaoConfigDataSchema, ttConfigDataSchema, wxConfigDataSchema, xhsConfigDataSchema, __webpack_exports__version as version };
25517
25691
 
25518
25692
  //# sourceMappingURL=index.mjs.map
25519
- //# debugId=ef023941-5d5d-5514-b133-72fa4303f973
25693
+ //# debugId=4801cf8d-6f2d-5cdd-9a97-97673fa7dfff