jimeng-cli 0.3.1 → 0.3.3

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.
@@ -5571,7 +5571,6 @@ var import_node_path = __toESM(require("path"), 1);
5571
5571
  // src/api/consts/common.ts
5572
5572
  var BASE_URL_CN = "https://jimeng.jianying.com";
5573
5573
  var BASE_URL_US_COMMERCE = "https://commerce.us.capcut.com";
5574
- var BASE_URL_HK_COMMERCE = "https://commerce-api-sg.capcut.com";
5575
5574
  var DEFAULT_ASSISTANT_ID_CN = 513695;
5576
5575
  var DEFAULT_ASSISTANT_ID_US = 513641;
5577
5576
  var DEFAULT_ASSISTANT_ID_HK = 513641;
@@ -5587,9 +5586,9 @@ var VERSION_CODE = "8.4.0";
5587
5586
  var DEFAULT_IMAGE_MODEL = "jimeng-4.5";
5588
5587
  var DEFAULT_IMAGE_MODEL_US = "jimeng-4.5";
5589
5588
  var DEFAULT_VIDEO_MODEL = "jimeng-video-3.5-pro";
5590
- var DRAFT_VERSION = "3.3.8";
5589
+ var DRAFT_VERSION = "3.3.12";
5591
5590
  var DRAFT_MIN_VERSION = "3.0.2";
5592
- var DRAFT_VERSION_OMNI = "3.3.9";
5591
+ var DRAFT_VERSION_OMNI = "3.3.12";
5593
5592
  var OMNI_BENEFIT_TYPE = "dreamina_video_seedance_20_video_add";
5594
5593
  var OMNI_BENEFIT_TYPE_FAST = "dreamina_seedance_20_fast_with_video";
5595
5594
  var IMAGE_MODEL_MAP = {
@@ -5605,6 +5604,8 @@ var IMAGE_MODEL_MAP = {
5605
5604
  "jimeng-lab": "high_aes_general_v50_lab"
5606
5605
  };
5607
5606
  var IMAGE_MODEL_MAP_US = {
5607
+ "jimeng-5.0": "high_aes_general_v50",
5608
+ "jimeng-4.6": "high_aes_general_v42",
5608
5609
  "jimeng-4.5": "high_aes_general_v40l",
5609
5610
  "jimeng-4.1": "high_aes_general_v41",
5610
5611
  "jimeng-4.0": "high_aes_general_v40",
@@ -5618,6 +5619,7 @@ var IMAGE_MODEL_MAP_ASIA = {
5618
5619
  "jimeng-4.5": "high_aes_general_v40l",
5619
5620
  "jimeng-4.1": "high_aes_general_v41",
5620
5621
  "jimeng-4.0": "high_aes_general_v40",
5622
+ "jimeng-3.1": "high_aes_general_v30l_art:general_v3.0_18b",
5621
5623
  "jimeng-3.0": "high_aes_general_v30l:general_v3.0_18b",
5622
5624
  "nanobanana": "external_model_gemini_flash_image_v25",
5623
5625
  "nanobananapro": "dreamina_image_lib_1"
@@ -5635,10 +5637,14 @@ var VIDEO_MODEL_MAP = {
5635
5637
  "jimeng-video-2.0-pro": "dreamina_ic_generate_video_model_vgfm1.0"
5636
5638
  };
5637
5639
  var VIDEO_MODEL_MAP_US = {
5640
+ "jimeng-video-seedance-2.0": "dreamina_seedance_40_pro",
5641
+ "jimeng-video-seedance-2.0-fast": "dreamina_seedance_40",
5638
5642
  "jimeng-video-3.5-pro": "dreamina_ic_generate_video_model_vgfm_3.5_pro",
5639
5643
  "jimeng-video-3.0": "dreamina_ic_generate_video_model_vgfm_3.0"
5640
5644
  };
5641
5645
  var VIDEO_MODEL_MAP_ASIA = {
5646
+ "jimeng-video-seedance-2.0": "dreamina_seedance_40_pro",
5647
+ "jimeng-video-seedance-2.0-fast": "dreamina_seedance_40",
5642
5648
  "jimeng-video-veo3": "dreamina_veo3_generate_video",
5643
5649
  "jimeng-video-veo3.1": "dreamina_veo3.1_generate_video",
5644
5650
  "jimeng-video-sora2": "dreamina_sora2_generate_video",
@@ -5877,6 +5883,17 @@ var import_mime = __toESM(require("mime"), 1);
5877
5883
  var import_axios = __toESM(require("axios"), 1);
5878
5884
  var import_uuid = require("uuid");
5879
5885
  var import_date_fns = require("date-fns");
5886
+ var CRC32_TABLE = (() => {
5887
+ const table = [];
5888
+ for (let i = 0; i < 256; i++) {
5889
+ let crc = i;
5890
+ for (let j = 0; j < 8; j++) {
5891
+ crc = crc & 1 ? 3988292384 ^ crc >>> 1 : crc >>> 1;
5892
+ }
5893
+ table[i] = crc;
5894
+ }
5895
+ return table;
5896
+ })();
5880
5897
  var util = {
5881
5898
  uuid: (separator = true) => separator ? (0, import_uuid.v4)() : (0, import_uuid.v4)().replace(/-/g, ""),
5882
5899
  getDateString(format = "yyyy-MM-dd", date = /* @__PURE__ */ new Date()) {
@@ -5922,22 +5939,18 @@ var util = {
5922
5939
  * @returns CRC32 十六进制字符串
5923
5940
  */
5924
5941
  calculateCRC32(buffer) {
5925
- const crcTable = [];
5926
- for (let i = 0; i < 256; i++) {
5927
- let crc2 = i;
5928
- for (let j = 0; j < 8; j++) {
5929
- crc2 = crc2 & 1 ? 3988292384 ^ crc2 >>> 1 : crc2 >>> 1;
5930
- }
5931
- crcTable[i] = crc2;
5932
- }
5933
5942
  let crc = 0 ^ -1;
5934
5943
  const bytes = buffer instanceof ArrayBuffer ? new Uint8Array(buffer) : new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
5935
5944
  for (let i = 0; i < bytes.length; i++) {
5936
- crc = crc >>> 8 ^ crcTable[(crc ^ bytes[i]) & 255];
5945
+ crc = crc >>> 8 ^ CRC32_TABLE[(crc ^ bytes[i]) & 255];
5937
5946
  }
5938
5947
  return ((crc ^ -1) >>> 0).toString(16).padStart(8, "0");
5939
5948
  }
5940
5949
  };
5950
+ function maskToken(token) {
5951
+ if (token.length <= 10) return "***";
5952
+ return `${token.slice(0, 4)}...${token.slice(-4)}`;
5953
+ }
5941
5954
  var util_default = util;
5942
5955
 
5943
5956
  // src/lib/logger.ts
@@ -6137,6 +6150,8 @@ var JimengErrorHandler = class {
6137
6150
  throw new APIException(exceptions_default.API_IMAGE_GENERATION_FAILED, `[\u751F\u6210\u5931\u8D25]: ${errmsg}`);
6138
6151
  case "5002":
6139
6152
  throw new APIException(exceptions_default.API_VIDEO_GENERATION_FAILED, `[\u89C6\u9891\u751F\u6210\u5931\u8D25]: ${errmsg}`);
6153
+ case "34010105":
6154
+ throw new APIException(exceptions_default.API_REQUEST_FAILED, `[\u767B\u5F55\u9A8C\u8BC1\u5931\u8D25]: ${errmsg} (\u9519\u8BEF\u7801: ${ret})`);
6140
6155
  default:
6141
6156
  throw new APIException(exceptions_default.API_REQUEST_FAILED, `[${operation}\u5931\u8D25]: ${errmsg} (\u9519\u8BEF\u7801: ${ret})`);
6142
6157
  }
@@ -6166,16 +6181,18 @@ var JimengErrorHandler = class {
6166
6181
  * 处理轮询超时错误
6167
6182
  * @returns 如果有部分结果,返回 void 而不抛出异常
6168
6183
  */
6169
- static handlePollingTimeout(pollCount, maxPollCount, elapsedTime, status, itemCount, historyId) {
6170
- const message = `\u8F6E\u8BE2\u8D85\u65F6: \u5DF2\u8F6E\u8BE2 ${pollCount} \u6B21\uFF0C\u8017\u65F6 ${elapsedTime} \u79D2\uFF0C\u6700\u7EC8\u72B6\u6001: ${status}\uFF0C\u56FE\u7247\u6570\u91CF: ${itemCount}`;
6184
+ static handlePollingTimeout(pollCount, maxPollCount, elapsedTime, status, itemCount, historyId, type = "image") {
6185
+ const typeText = type === "image" ? "\u56FE\u7247" : "\u89C6\u9891";
6186
+ const message = `\u8F6E\u8BE2\u8D85\u65F6: \u5DF2\u8F6E\u8BE2 ${pollCount} \u6B21\uFF0C\u8017\u65F6 ${elapsedTime} \u79D2\uFF0C\u6700\u7EC8\u72B6\u6001: ${status}\uFF0C${typeText}\u6570\u91CF: ${itemCount}`;
6171
6187
  logger_default.warn(message + (historyId ? `\uFF0C\u5386\u53F2ID: ${historyId}` : ""));
6172
6188
  if (itemCount === 0) {
6189
+ const exception = type === "image" ? exceptions_default.API_IMAGE_GENERATION_FAILED : exceptions_default.API_VIDEO_GENERATION_FAILED;
6173
6190
  throw new APIException(
6174
- exceptions_default.API_IMAGE_GENERATION_FAILED,
6175
- `\u751F\u6210\u8D85\u65F6\u4E14\u65E0\u7ED3\u679C\uFF0C\u72B6\u6001\u7801: ${status}${historyId ? `\uFF0C\u5386\u53F2ID: ${historyId}` : ""}`
6191
+ exception,
6192
+ `${typeText}\u751F\u6210\u8D85\u65F6\u4E14\u65E0\u7ED3\u679C\uFF0C\u72B6\u6001\u7801: ${status}${historyId ? `\uFF0C\u5386\u53F2ID: ${historyId}` : ""}`
6176
6193
  );
6177
6194
  }
6178
- logger_default.info(`\u8F6E\u8BE2\u8D85\u65F6\u4F46\u5DF2\u83B7\u5F97 ${itemCount} \u5F20\u56FE\u7247\uFF0C\u5C06\u8FD4\u56DE\u73B0\u6709\u7ED3\u679C`);
6195
+ logger_default.info(`\u8F6E\u8BE2\u8D85\u65F6\u4F46\u5DF2\u83B7\u5F97 ${itemCount} \u4E2A${typeText}\uFF0C\u5C06\u8FD4\u56DE\u73B0\u6709\u7ED3\u679C`);
6179
6196
  }
6180
6197
  /**
6181
6198
  * 处理生成失败错误
@@ -6240,12 +6257,13 @@ var BASE_URL_IMAGEX_US = "https://imagex16-normal-us-ttp.capcutapi.us";
6240
6257
  var BASE_URL_DREAMINA_HK = "https://mweb-api-sg.capcut.com";
6241
6258
  var BASE_URL_IMAGEX_HK = "https://imagex-normal-sg.capcutapi.com";
6242
6259
  var WEB_VERSION = "7.5.0";
6243
- var DA_VERSION = "3.3.8";
6260
+ var DA_VERSION = "3.3.12";
6244
6261
 
6245
6262
  // src/api/controllers/core.ts
6246
6263
  var DEVICE_ID = Math.random() * 1e18 + 7e18;
6247
6264
  var WEB_ID = Math.random() * 1e18 + 7e18;
6248
6265
  var USER_ID = util_default.uuid(false);
6266
+ var INTERNATIONAL_FRONTEND_ORIGIN = "https://dreamina.capcut.com";
6249
6267
  var FAKE_HEADERS = {
6250
6268
  Accept: "application/json, text/plain, */*",
6251
6269
  "Accept-Encoding": "gzip, deflate, br, zstd",
@@ -6369,8 +6387,7 @@ function parseProxyFromToken(rawToken) {
6369
6387
  return { token, proxyUrl };
6370
6388
  }
6371
6389
  function getRefererByRegion(regionInfo, cnPath) {
6372
- const { isInternational } = regionInfo;
6373
- return isInternational ? "https://dreamina.capcut.com/" : `https://jimeng.jianying.com${cnPath}`;
6390
+ return regionInfo.isInternational ? `${INTERNATIONAL_FRONTEND_ORIGIN}/` : `${BASE_URL_CN}${cnPath}`;
6374
6391
  }
6375
6392
  function getAssistantId(regionInfo) {
6376
6393
  if (regionInfo.isUS) return DEFAULT_ASSISTANT_ID_US;
@@ -6401,12 +6418,14 @@ function generateCookie(refreshToken) {
6401
6418
  }
6402
6419
  async function getCredit(refreshToken, regionInfo) {
6403
6420
  const referer = getRefererByRegion(regionInfo, "/ai-tool/image/generate");
6421
+ const origin = regionInfo.isInternational ? INTERNATIONAL_FRONTEND_ORIGIN : void 0;
6404
6422
  const {
6405
6423
  credit: { gift_credit, purchase_credit, vip_credit }
6406
6424
  } = await request("POST", "/commerce/v1/benefits/user_credit", refreshToken, regionInfo, {
6407
6425
  data: {},
6408
6426
  headers: {
6409
- Referer: referer
6427
+ Referer: referer,
6428
+ ...origin ? { Origin: origin } : {}
6410
6429
  },
6411
6430
  noDefaultParams: true
6412
6431
  });
@@ -6423,13 +6442,15 @@ async function getCredit(refreshToken, regionInfo) {
6423
6442
  async function receiveCredit(refreshToken, regionInfo) {
6424
6443
  logger_default.info("\u6B63\u5728\u5C1D\u8BD5\u6536\u53D6\u4ECA\u65E5\u79EF\u5206...");
6425
6444
  const referer = getRefererByRegion(regionInfo, "/ai-tool/home");
6445
+ const origin = regionInfo.isInternational ? INTERNATIONAL_FRONTEND_ORIGIN : void 0;
6426
6446
  const timeZone = regionInfo.isUS ? "America/New_York" : regionInfo.isHK ? "Asia/Hong_Kong" : regionInfo.isJP ? "Asia/Tokyo" : regionInfo.isSG ? "Asia/Singapore" : "Asia/Shanghai";
6427
6447
  const { receive_quota } = await request("POST", "/commerce/v1/benefits/credit_receive", refreshToken, regionInfo, {
6428
6448
  data: {
6429
6449
  time_zone: timeZone
6430
6450
  },
6431
6451
  headers: {
6432
- Referer: referer
6452
+ Referer: referer,
6453
+ ...origin ? { Origin: origin } : {}
6433
6454
  }
6434
6455
  });
6435
6456
  logger_default.info(`\u4ECA\u65E5${receive_quota}\u79EF\u5206\u6536\u53D6\u6210\u529F`);
@@ -6457,7 +6478,7 @@ async function request(method, uri, refreshToken, regionInfo, options = {}) {
6457
6478
  region = REGION_US;
6458
6479
  } else if (isHK || isJP || isSG) {
6459
6480
  if (uri.startsWith("/commerce/")) {
6460
- baseUrl = BASE_URL_HK_COMMERCE;
6481
+ baseUrl = BASE_URL_US_COMMERCE;
6461
6482
  } else {
6462
6483
  baseUrl = BASE_URL_DREAMINA_HK;
6463
6484
  }
@@ -6537,7 +6558,8 @@ async function request(method, uri, refreshToken, regionInfo, options = {}) {
6537
6558
  });
6538
6559
  logger_default.info(`\u54CD\u5E94\u72B6\u6001: ${response.status} ${response.statusText}`);
6539
6560
  if (options.responseType == "stream") return response;
6540
- const responseDataSummary = JSON.stringify(response.data).substring(0, 500) + (JSON.stringify(response.data).length > 500 ? "..." : "");
6561
+ const responseJson = JSON.stringify(response.data);
6562
+ const responseDataSummary = responseJson.substring(0, 500) + (responseJson.length > 500 ? "..." : "");
6541
6563
  logger_default.info(`\u54CD\u5E94\u6570\u636E\u6458\u8981: ${responseDataSummary}`);
6542
6564
  if (response.status >= 400) {
6543
6565
  logger_default.warn(`HTTP\u9519\u8BEF: ${response.status} ${response.statusText}`);
@@ -6628,6 +6650,9 @@ function checkResult(result) {
6628
6650
  }
6629
6651
  async function getTokenLiveStatus(refreshToken, regionInfo) {
6630
6652
  try {
6653
+ if (regionInfo.isInternational) {
6654
+ return await checkInternationalTokenLive(refreshToken, regionInfo);
6655
+ }
6631
6656
  const result = await request(
6632
6657
  "POST",
6633
6658
  "/passport/account/info/v2",
@@ -6646,6 +6671,44 @@ async function getTokenLiveStatus(refreshToken, regionInfo) {
6646
6671
  return false;
6647
6672
  }
6648
6673
  }
6674
+ async function checkInternationalTokenLive(refreshToken, regionInfo) {
6675
+ const aid = getAssistantId(regionInfo);
6676
+ const countryCode = regionInfo.isUS ? "us" : regionInfo.isJP ? "jp" : regionInfo.isHK ? "hk" : "sg";
6677
+ const cookie = generateCookie(refreshToken);
6678
+ try {
6679
+ const response = await import_axios2.default.get(
6680
+ `${INTERNATIONAL_FRONTEND_ORIGIN}/passport/web/account/info/`,
6681
+ {
6682
+ params: {
6683
+ aid,
6684
+ account_sdk_source: "web",
6685
+ sdk_version: "2.1.10-tiktok",
6686
+ language: countryCode === "jp" ? "ja" : "en"
6687
+ },
6688
+ headers: {
6689
+ ...FAKE_HEADERS,
6690
+ Cookie: cookie,
6691
+ Referer: `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/home/`,
6692
+ Origin: INTERNATIONAL_FRONTEND_ORIGIN,
6693
+ Appid: String(aid),
6694
+ "store-country-code": countryCode,
6695
+ "store-country-code-src": "uid"
6696
+ },
6697
+ timeout: 15e3
6698
+ }
6699
+ );
6700
+ const data = response.data;
6701
+ if (data && typeof data === "object") {
6702
+ const obj = data;
6703
+ if (obj.user_id || obj.email || obj.data) {
6704
+ return true;
6705
+ }
6706
+ }
6707
+ return false;
6708
+ } catch {
6709
+ return false;
6710
+ }
6711
+ }
6649
6712
 
6650
6713
  // src/lib/smart-poller.ts
6651
6714
  var SmartPoller = class {
@@ -6673,7 +6736,7 @@ var SmartPoller = class {
6673
6736
  /**
6674
6737
  * 根据状态码计算智能轮询间隔
6675
6738
  */
6676
- getSmartInterval(status, itemCount) {
6739
+ getSmartInterval(status, _itemCount) {
6677
6740
  const baseInterval = this.options.pollInterval;
6678
6741
  switch (status) {
6679
6742
  case 20:
@@ -6710,9 +6773,6 @@ var SmartPoller = class {
6710
6773
  if (status === 30) {
6711
6774
  return { shouldExit: true, reason: "\u4EFB\u52A1\u5931\u8D25" };
6712
6775
  }
6713
- if (itemCount >= this.options.expectedItemCount && (status === 10 || status === 50)) {
6714
- return { shouldExit: true, reason: `\u5DF2\u83B7\u5F97\u5B8C\u6574\u7ED3\u679C\u96C6(${itemCount}/${this.options.expectedItemCount})` };
6715
- }
6716
6776
  if (this.pollCount >= this.options.maxPollCount) {
6717
6777
  return { shouldExit: true, reason: "\u8F6E\u8BE2\u6B21\u6570\u8D85\u9650" };
6718
6778
  }
@@ -6729,6 +6789,7 @@ var SmartPoller = class {
6729
6789
  logger_default.info(`\u5F00\u59CB\u667A\u80FD\u8F6E\u8BE2: historyId=${historyId || "N/A"}, \u6700\u5927\u8F6E\u8BE2\u6B21\u6570=${this.options.maxPollCount}, \u671F\u671B\u7ED3\u679C\u6570=${this.options.expectedItemCount}`);
6730
6790
  let lastData;
6731
6791
  let lastStatus = { status: 20, itemCount: 0 };
6792
+ let exitReason = "";
6732
6793
  while (true) {
6733
6794
  this.pollCount++;
6734
6795
  const elapsedTime = Math.round((Date.now() - this.startTime) / 1e3);
@@ -6742,6 +6803,7 @@ var SmartPoller = class {
6742
6803
  }
6743
6804
  const { shouldExit, reason } = this.shouldExitPolling(status);
6744
6805
  if (shouldExit) {
6806
+ exitReason = reason;
6745
6807
  logger_default.info(`\u9000\u51FA\u8F6E\u8BE2: ${reason}, \u6700\u7EC8${this.options.type === "image" ? "\u56FE\u7247" : "\u89C6\u9891"}\u6570\u91CF=${status.itemCount}`);
6746
6808
  if (status.status === 30) {
6747
6809
  handleGenerationFailure(status.status, status.failCode, historyId, this.options.type, status.itemCount);
@@ -6753,7 +6815,8 @@ var SmartPoller = class {
6753
6815
  elapsedTime,
6754
6816
  status.status,
6755
6817
  status.itemCount,
6756
- historyId
6818
+ historyId,
6819
+ this.options.type
6757
6820
  );
6758
6821
  }
6759
6822
  break;
@@ -6797,7 +6860,7 @@ var SmartPoller = class {
6797
6860
  itemCount: lastStatus.itemCount,
6798
6861
  elapsedTime: finalElapsedTime,
6799
6862
  pollCount: this.pollCount,
6800
- exitReason: this.shouldExitPolling(lastStatus).reason
6863
+ exitReason
6801
6864
  };
6802
6865
  logger_default.info(`${this.options.type === "image" ? "\u56FE\u50CF" : "\u89C6\u9891"}\u751F\u6210\u5B8C\u6210: \u6210\u529F\u751F\u6210 ${lastStatus.itemCount} \u4E2A\u7ED3\u679C\uFF0C\u603B\u8017\u65F6 ${finalElapsedTime} \u79D2\uFF0C\u6700\u7EC8\u72B6\u6001: ${this.getStatusName(lastStatus.status)}`);
6803
6866
  return { result, data: lastData };
@@ -7036,7 +7099,7 @@ async function uploadImageBuffer(imageBuffer, refreshToken, regionInfo) {
7036
7099
  "Authorization": auth,
7037
7100
  "Connection": "keep-alive",
7038
7101
  "Content-CRC32": crc32,
7039
- "Content-Disposition": 'attachment; filename="undefined"',
7102
+ "Content-Disposition": 'attachment; filename="upload.bin"',
7040
7103
  "Content-Type": "application/octet-stream",
7041
7104
  "Origin": origin,
7042
7105
  "Referer": RegionUtils.getRefererPath(regionInfo),
@@ -7165,17 +7228,20 @@ function extractImageUrls(itemList) {
7165
7228
  return itemList.map((item, index) => extractImageUrl(item, index)).filter((url) => url !== null);
7166
7229
  }
7167
7230
  function extractVideoUrl(item) {
7168
- var _a, _b, _c, _d, _e, _f;
7169
- if ((_c = (_b = (_a = item == null ? void 0 : item.video) == null ? void 0 : _a.transcoded_video) == null ? void 0 : _b.origin) == null ? void 0 : _c.video_url) {
7231
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
7232
+ if ((_c = (_b = (_a = item == null ? void 0 : item.common_attr) == null ? void 0 : _a.transcoded_video) == null ? void 0 : _b.origin) == null ? void 0 : _c.video_url) {
7233
+ return item.common_attr.transcoded_video.origin.video_url;
7234
+ }
7235
+ if ((_f = (_e = (_d = item == null ? void 0 : item.video) == null ? void 0 : _d.transcoded_video) == null ? void 0 : _e.origin) == null ? void 0 : _f.video_url) {
7170
7236
  return item.video.transcoded_video.origin.video_url;
7171
7237
  }
7172
- if ((_d = item == null ? void 0 : item.video) == null ? void 0 : _d.play_url) {
7238
+ if ((_g = item == null ? void 0 : item.video) == null ? void 0 : _g.play_url) {
7173
7239
  return item.video.play_url;
7174
7240
  }
7175
- if ((_e = item == null ? void 0 : item.video) == null ? void 0 : _e.download_url) {
7241
+ if ((_h = item == null ? void 0 : item.video) == null ? void 0 : _h.download_url) {
7176
7242
  return item.video.download_url;
7177
7243
  }
7178
- if ((_f = item == null ? void 0 : item.video) == null ? void 0 : _f.url) {
7244
+ if ((_i = item == null ? void 0 : item.video) == null ? void 0 : _i.url) {
7179
7245
  return item.video.url;
7180
7246
  }
7181
7247
  return null;
@@ -7205,20 +7271,15 @@ async function fetchHighQualityVideoUrl(itemId, refreshToken, regionInfo) {
7205
7271
  return videoUrl;
7206
7272
  }
7207
7273
  }
7208
- const hqUrlMatch = responseStr.match(/https:\/\/v[0-9]+-dreamnia\.jimeng\.com\/[^"\s\\]+/);
7209
- if (hqUrlMatch && hqUrlMatch[0]) {
7210
- logger_default.info(`\u6B63\u5219\u63D0\u53D6\u5230\u9AD8\u8D28\u91CF\u89C6\u9891URL (dreamnia): ${hqUrlMatch[0]}`);
7211
- return hqUrlMatch[0];
7274
+ const cdnUrlMatch = responseStr.match(/https:\/\/v[0-9]+-[^"\\]*\.(jimeng|capcut|dreamina)\.com\/[^"\s\\]+/);
7275
+ if (cdnUrlMatch && cdnUrlMatch[0]) {
7276
+ logger_default.info(`\u6B63\u5219\u63D0\u53D6\u5230\u89C6\u9891URL: ${cdnUrlMatch[0]}`);
7277
+ return cdnUrlMatch[0];
7212
7278
  }
7213
- const jimengUrlMatch = responseStr.match(/https:\/\/v[0-9]+-[^"\\]*\.jimeng\.com\/[^"\s\\]+/);
7214
- if (jimengUrlMatch && jimengUrlMatch[0]) {
7215
- logger_default.info(`\u6B63\u5219\u63D0\u53D6\u5230jimeng\u89C6\u9891URL: ${jimengUrlMatch[0]}`);
7216
- return jimengUrlMatch[0];
7217
- }
7218
- const anyVideoUrlMatch = responseStr.match(/https:\/\/v[0-9]+-[^"\\]*\.(vlabvod|jimeng)\.com\/[^"\s\\]+/);
7219
- if (anyVideoUrlMatch && anyVideoUrlMatch[0]) {
7220
- logger_default.info(`\u4ECEget_local_item_list\u63D0\u53D6\u5230\u89C6\u9891URL: ${anyVideoUrlMatch[0]}`);
7221
- return anyVideoUrlMatch[0];
7279
+ const vlabUrlMatch = responseStr.match(/https:\/\/v[0-9]+-[^"\\]*\.vlabvod\.com\/[^"\s\\]+/);
7280
+ if (vlabUrlMatch && vlabUrlMatch[0]) {
7281
+ logger_default.info(`\u6B63\u5219\u63D0\u53D6\u5230\u89C6\u9891URL: ${vlabUrlMatch[0]}`);
7282
+ return vlabUrlMatch[0];
7222
7283
  }
7223
7284
  logger_default.warn(`\u672A\u80FD\u4ECEget_local_item_list\u54CD\u5E94\u4E2D\u63D0\u53D6\u5230\u89C6\u9891URL`);
7224
7285
  return null;
@@ -7616,7 +7677,7 @@ async function generateImageComposition(_model, prompt, images, {
7616
7677
  abilityName: "byte_edit",
7617
7678
  strength: sampleStrength,
7618
7679
  source: {
7619
- imageUrl: `blob:https://dreamina.capcut.com/${util_default.uuid()}`
7680
+ imageUrl: `blob:${INTERNATIONAL_FRONTEND_ORIGIN}/${util_default.uuid()}`
7620
7681
  }
7621
7682
  }));
7622
7683
  const metricsExtra = buildMetricsExtra({
@@ -7651,7 +7712,7 @@ async function generateImageComposition(_model, prompt, images, {
7651
7712
  draftContent,
7652
7713
  metricsExtra
7653
7714
  });
7654
- const imageReferer = regionInfo.isCN ? "https://jimeng.jianying.com/ai-tool/generate?type=image" : "https://dreamina.capcut.com/ai-tool/generate?type=image";
7715
+ const imageReferer = regionInfo.isCN ? `${BASE_URL_CN}/ai-tool/generate?type=image` : `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/generate?type=image`;
7655
7716
  const { aigc_data } = await request(
7656
7717
  "post",
7657
7718
  "/mweb/v1/aigc_draft/generate",
@@ -7815,7 +7876,7 @@ async function generateImagesInternal(_model, prompt, {
7815
7876
  draftContent,
7816
7877
  metricsExtra
7817
7878
  });
7818
- const imageReferer = regionInfo.isCN ? "https://jimeng.jianying.com/ai-tool/generate?type=image" : "https://dreamina.capcut.com/ai-tool/generate?type=image";
7879
+ const imageReferer = regionInfo.isCN ? `${BASE_URL_CN}/ai-tool/generate?type=image` : `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/generate?type=image`;
7819
7880
  const { aigc_data } = await request(
7820
7881
  "post",
7821
7882
  "/mweb/v1/aigc_draft/generate",
@@ -7937,7 +7998,7 @@ async function generateJimeng4xMultiImages(_model, prompt, {
7937
7998
  draftContent,
7938
7999
  metricsExtra
7939
8000
  });
7940
- const imageReferer = regionInfo.isCN ? "https://jimeng.jianying.com/ai-tool/generate?type=image" : "https://dreamina.capcut.com/ai-tool/generate?type=image";
8001
+ const imageReferer = regionInfo.isCN ? `${BASE_URL_CN}/ai-tool/generate?type=image` : `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/generate?type=image`;
7941
8002
  const { aigc_data } = await request(
7942
8003
  "post",
7943
8004
  "/mweb/v1/aigc_draft/generate",
@@ -8109,7 +8170,7 @@ async function upscaleImage(_model, image, {
8109
8170
  draftContent,
8110
8171
  metricsExtra
8111
8172
  });
8112
- const imageReferer = regionInfo.isCN ? "https://jimeng.jianying.com/ai-tool/generate?type=image" : "https://dreamina.capcut.com/ai-tool/generate?type=image";
8173
+ const imageReferer = regionInfo.isCN ? `${BASE_URL_CN}/ai-tool/generate?type=image` : `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/generate?type=image`;
8113
8174
  const { aigc_data } = await request(
8114
8175
  "post",
8115
8176
  "/mweb/v1/aigc_draft/generate",
@@ -8223,10 +8284,14 @@ var TokenPool = class {
8223
8284
  );
8224
8285
  }
8225
8286
  getSummary() {
8226
- const entries = this.getEntries(false);
8227
- const enabledCount = entries.filter((item) => item.enabled).length;
8228
- const liveCount = entries.filter((item) => item.enabled && item.live === true).length;
8229
- const missingRegionCount = entries.filter((item) => !item.region).length;
8287
+ let enabledCount = 0;
8288
+ let liveCount = 0;
8289
+ let missingRegionCount = 0;
8290
+ for (const item of this.entryMap.values()) {
8291
+ if (item.enabled) enabledCount++;
8292
+ if (item.enabled && item.live === true) liveCount++;
8293
+ if (!item.region) missingRegionCount++;
8294
+ }
8230
8295
  return {
8231
8296
  enabled: this.enabled,
8232
8297
  filePath: this.filePath,
@@ -8235,19 +8300,19 @@ var TokenPool = class {
8235
8300
  fetchCreditOnCheck: this.fetchCreditOnCheck,
8236
8301
  autoDisableEnabled: this.autoDisableEnabled,
8237
8302
  autoDisableFailures: this.autoDisableFailures,
8238
- total: entries.length,
8303
+ total: this.entryMap.size,
8239
8304
  enabledCount,
8240
8305
  liveCount,
8241
8306
  missingRegionCount,
8242
8307
  lastHealthCheckAt: this.lastHealthCheckAt || null
8243
8308
  };
8244
8309
  }
8245
- getEntries(maskToken = true) {
8310
+ getEntries(shouldMask = true) {
8246
8311
  const items = Array.from(this.entryMap.values()).map((item) => ({ ...item }));
8247
- if (!maskToken) return items;
8312
+ if (!shouldMask) return items;
8248
8313
  return items.map((item) => ({
8249
8314
  ...item,
8250
- token: this.maskToken(item.token)
8315
+ token: maskToken(item.token)
8251
8316
  }));
8252
8317
  }
8253
8318
  getAllTokens(options = {}) {
@@ -8318,7 +8383,7 @@ var TokenPool = class {
8318
8383
  token: null,
8319
8384
  region: null,
8320
8385
  error: "prefixed_token_not_supported",
8321
- reason: `token ${this.maskToken(prefixedCandidate.token)} \u4F7F\u7528\u4E86\u5DF2\u5E9F\u5F03\u7684 region \u524D\u7F00`
8386
+ reason: `token ${maskToken(prefixedCandidate.token)} \u4F7F\u7528\u4E86\u5DF2\u5E9F\u5F03\u7684 region \u524D\u7F00`
8322
8387
  };
8323
8388
  }
8324
8389
  const regionLockedCandidates = validCandidates.filter(
@@ -8424,8 +8489,8 @@ var TokenPool = class {
8424
8489
  async refreshDynamicCapabilitiesForToken(token) {
8425
8490
  if (!this.enabled) throw new Error("Token pool disabled");
8426
8491
  const item = this.entryMap.get(token);
8427
- if (!item) throw new Error(`Token not found in pool: ${this.maskToken(token)}`);
8428
- if (!item.region) throw new Error(`Token ${this.maskToken(token)} has no region`);
8492
+ if (!item) throw new Error(`Token not found in pool: ${maskToken(token)}`);
8493
+ if (!item.region) throw new Error(`Token ${maskToken(token)} has no region`);
8429
8494
  const regionInfo = buildRegionInfo(item.region);
8430
8495
  const capabilities = await this.fetchDynamicCapabilities(token, regionInfo);
8431
8496
  item.dynamicCapabilities = { ...capabilities, updatedAt: Date.now() };
@@ -8437,39 +8502,41 @@ var TokenPool = class {
8437
8502
  * Returns a per-token result summary.
8438
8503
  */
8439
8504
  async refreshAllDynamicCapabilities() {
8440
- var _a, _b;
8441
8505
  if (!this.enabled) return [];
8442
8506
  const entries = this.getEntries(false).filter(
8443
8507
  (item) => item.enabled && item.live !== false && Boolean(item.region)
8444
8508
  );
8445
- const results = [];
8446
- for (const entry of entries) {
8447
- try {
8448
- const regionInfo = buildRegionInfo(entry.region);
8449
- const capabilities = await this.fetchDynamicCapabilities(entry.token, regionInfo);
8450
- const current = this.entryMap.get(entry.token);
8451
- if (current) {
8452
- current.dynamicCapabilities = { ...capabilities, updatedAt: Date.now() };
8453
- }
8454
- results.push({
8455
- token: this.maskToken(entry.token),
8456
- region: entry.region,
8457
- imageModels: ((_a = capabilities.imageModels) == null ? void 0 : _a.length) ?? 0,
8458
- videoModels: ((_b = capabilities.videoModels) == null ? void 0 : _b.length) ?? 0,
8459
- capabilityTags: capabilities.capabilityTags ?? []
8460
- });
8461
- } catch (err) {
8462
- results.push({
8463
- token: this.maskToken(entry.token),
8464
- region: entry.region,
8465
- imageModels: 0,
8466
- videoModels: 0,
8467
- capabilityTags: [],
8468
- error: (err == null ? void 0 : err.message) || String(err)
8469
- });
8470
- }
8471
- }
8472
- if (entries.length > 0) await this.persistToDisk();
8509
+ if (entries.length === 0) return [];
8510
+ const results = await Promise.all(
8511
+ entries.map(async (entry) => {
8512
+ var _a, _b;
8513
+ try {
8514
+ const regionInfo = buildRegionInfo(entry.region);
8515
+ const capabilities = await this.fetchDynamicCapabilities(entry.token, regionInfo);
8516
+ const current = this.entryMap.get(entry.token);
8517
+ if (current) {
8518
+ current.dynamicCapabilities = { ...capabilities, updatedAt: Date.now() };
8519
+ }
8520
+ return {
8521
+ token: maskToken(entry.token),
8522
+ region: entry.region,
8523
+ imageModels: ((_a = capabilities.imageModels) == null ? void 0 : _a.length) ?? 0,
8524
+ videoModels: ((_b = capabilities.videoModels) == null ? void 0 : _b.length) ?? 0,
8525
+ capabilityTags: capabilities.capabilityTags ?? []
8526
+ };
8527
+ } catch (err) {
8528
+ return {
8529
+ token: maskToken(entry.token),
8530
+ region: entry.region,
8531
+ imageModels: 0,
8532
+ videoModels: 0,
8533
+ capabilityTags: [],
8534
+ error: err instanceof Error ? err.message : String(err)
8535
+ };
8536
+ }
8537
+ })
8538
+ );
8539
+ await this.persistToDisk();
8473
8540
  return results;
8474
8541
  }
8475
8542
  async runHealthCheck() {
@@ -8590,14 +8657,10 @@ var TokenPool = class {
8590
8657
  await import_fs_extra4.default.ensureDir(import_path4.default.dirname(this.filePath));
8591
8658
  const payload = {
8592
8659
  updatedAt: Date.now(),
8593
- tokens: this.getEntries(false)
8660
+ tokens: Array.from(this.entryMap.values())
8594
8661
  };
8595
8662
  await import_fs_extra4.default.writeJson(this.filePath, payload, { spaces: 2 });
8596
8663
  }
8597
- maskToken(token) {
8598
- if (token.length <= 10) return "***";
8599
- return `${token.slice(0, 4)}...${token.slice(-4)}`;
8600
- }
8601
8664
  parseAuthorizationTokens(authorization) {
8602
8665
  if (typeof authorization !== "string" || authorization.trim().length === 0) {
8603
8666
  return { tokens: [], error: null };
@@ -8626,7 +8689,7 @@ var TokenPool = class {
8626
8689
  if (!token) continue;
8627
8690
  const parsedRegion = parseRegionCode(item.region || defaultRegion);
8628
8691
  if (!parsedRegion) {
8629
- throw new Error(`token ${this.maskToken(token)} \u7F3A\u5C11\u6709\u6548 region\uFF08\u4EC5\u652F\u6301 cn/us/hk/jp/sg\uFF09`);
8692
+ throw new Error(`token ${maskToken(token)} \u7F3A\u5C11\u6709\u6548 region\uFF08\u4EC5\u652F\u6301 cn/us/hk/jp/sg\uFF09`);
8630
8693
  }
8631
8694
  normalized.push({
8632
8695
  token,
@@ -8734,40 +8797,22 @@ var TokenPool = class {
8734
8797
  }
8735
8798
  async fetchDynamicCapabilities(token, regionInfo) {
8736
8799
  const regionCode = regionInfo.isUS ? "us" : regionInfo.isHK ? "hk" : regionInfo.isJP ? "jp" : regionInfo.isSG ? "sg" : "cn";
8737
- const reverseMap = this.getReverseModelMapByRegion(regionCode);
8738
- const imageConfig = await request("post", "/mweb/v1/get_common_config", token, regionInfo, {
8739
- data: {},
8740
- params: { needCache: true, needRefresh: false }
8741
- });
8742
- const videoConfig = await request("post", "/mweb/v1/video_generate/get_common_config", token, regionInfo, {
8743
- data: { scene: "generate_video", params: {} }
8744
- });
8745
- const imageReqKeys = Array.isArray(imageConfig == null ? void 0 : imageConfig.model_list) ? imageConfig.model_list.map((item) => typeof (item == null ? void 0 : item.model_req_key) === "string" ? item.model_req_key : "").filter(Boolean) : [];
8746
- const videoReqKeys = Array.isArray(videoConfig == null ? void 0 : videoConfig.model_list) ? videoConfig.model_list.map((item) => typeof (item == null ? void 0 : item.model_req_key) === "string" ? item.model_req_key : "").filter(Boolean) : [];
8747
- const imageModels = imageReqKeys.map((key) => reverseMap[key]).filter(Boolean);
8748
- const videoModels = videoReqKeys.map((key) => reverseMap[key]).filter(Boolean);
8800
+ const reverseMap = buildReverseMap(regionCode);
8801
+ const { imageModels, videoModels } = await fetchConfigModelReqKeys(token, regionCode);
8802
+ const imageIds = imageModels.map((m) => reverseMap[m.reqKey]).filter(Boolean);
8803
+ const videoIds = videoModels.map((m) => reverseMap[m.reqKey]).filter(Boolean);
8749
8804
  const capabilityTags = /* @__PURE__ */ new Set();
8750
- for (const model of videoModels) {
8805
+ for (const model of videoIds) {
8751
8806
  if (model.includes("seedance_40")) capabilityTags.add("omni_reference");
8752
8807
  if (model.includes("veo3")) capabilityTags.add("veo3");
8753
8808
  if (model.includes("sora2")) capabilityTags.add("sora2");
8754
8809
  }
8755
8810
  return {
8756
- imageModels: imageModels.length ? Array.from(new Set(imageModels)) : void 0,
8757
- videoModels: videoModels.length ? Array.from(new Set(videoModels)) : void 0,
8811
+ imageModels: imageIds.length ? Array.from(new Set(imageIds)) : void 0,
8812
+ videoModels: videoIds.length ? Array.from(new Set(videoIds)) : void 0,
8758
8813
  capabilityTags: capabilityTags.size ? Array.from(capabilityTags) : void 0
8759
8814
  };
8760
8815
  }
8761
- getReverseModelMapByRegion(region) {
8762
- const maps = region === "us" ? [IMAGE_MODEL_MAP_US, VIDEO_MODEL_MAP_US] : region === "hk" || region === "jp" || region === "sg" ? [IMAGE_MODEL_MAP_ASIA, VIDEO_MODEL_MAP_ASIA] : [IMAGE_MODEL_MAP, VIDEO_MODEL_MAP];
8763
- const reverse = {};
8764
- for (const map of maps) {
8765
- for (const [modelId, reqKey] of Object.entries(map)) {
8766
- reverse[reqKey] = modelId;
8767
- }
8768
- }
8769
- return reverse;
8770
- }
8771
8816
  };
8772
8817
  var session_pool_default = new TokenPool();
8773
8818
 
@@ -8811,6 +8856,7 @@ function buildModelItem(modelId, meta) {
8811
8856
  if (meta == null ? void 0 : meta.reqKey) item.model_req_key = meta.reqKey;
8812
8857
  if (meta == null ? void 0 : meta.modelName) item.model_name = meta.modelName;
8813
8858
  if ((_a = meta == null ? void 0 : meta.capabilities) == null ? void 0 : _a.length) item.capabilities = Array.from(new Set(meta.capabilities)).sort();
8859
+ if ((meta == null ? void 0 : meta.params) && Object.keys(meta.params).length > 0) item.params = meta.params;
8814
8860
  if (meta == null ? void 0 : meta.modelTip) {
8815
8861
  item.description = meta.modelTip;
8816
8862
  } else if (modelType === "video") {
@@ -8854,13 +8900,17 @@ function resolveRegion(authorization, xRegion) {
8854
8900
  }
8855
8901
  return "cn";
8856
8902
  }
8903
+ var reverseMapCache = /* @__PURE__ */ new Map();
8857
8904
  function buildReverseMap(region) {
8905
+ const cached = reverseMapCache.get(region);
8906
+ if (cached) return cached;
8858
8907
  const reverse = {};
8859
8908
  for (const map of getRegionalMaps(region)) {
8860
8909
  for (const [modelId, upstreamKey] of Object.entries(map)) {
8861
8910
  reverse[upstreamKey] = modelId;
8862
8911
  }
8863
8912
  }
8913
+ reverseMapCache.set(region, reverse);
8864
8914
  return reverse;
8865
8915
  }
8866
8916
  function buildFallbackModels(region) {
@@ -8877,43 +8927,62 @@ function resolveFetchToken(token) {
8877
8927
  assertTokenWithoutRegionPrefix(normalizedToken);
8878
8928
  return normalizedToken;
8879
8929
  }
8930
+ function extractValidOptions(item) {
8931
+ return (Array.isArray(item.options) ? item.options : []).filter(
8932
+ (opt) => !!opt && typeof opt === "object" && typeof opt.key === "string" && opt.key.length > 0
8933
+ );
8934
+ }
8880
8935
  function extractCapabilities(item) {
8881
- const features = Array.isArray(item.feats) ? item.feats.filter((feature) => typeof feature === "string" && feature.length > 0) : [];
8882
- const options = Array.isArray(item.options) ? item.options.map(
8883
- (option) => option && typeof option === "object" && typeof option.key === "string" ? option.key : void 0
8884
- ).filter((key) => typeof key === "string" && key.length > 0) : [];
8885
- return Array.from(/* @__PURE__ */ new Set([...features, ...options]));
8936
+ const features = Array.isArray(item.feats) ? item.feats.filter((f) => typeof f === "string" && f.length > 0) : [];
8937
+ const optionKeys = extractValidOptions(item).map((o) => o.key);
8938
+ return Array.from(/* @__PURE__ */ new Set([...features, ...optionKeys]));
8939
+ }
8940
+ function extractEnumParams(item) {
8941
+ const params = {};
8942
+ for (const o of extractValidOptions(item)) {
8943
+ const ev = o.enum_val;
8944
+ if (!ev) continue;
8945
+ const sv = ev.string_value;
8946
+ const iv = ev.int_value;
8947
+ const vals = sv || iv;
8948
+ if (vals && vals.length > 0) {
8949
+ params[o.key] = vals;
8950
+ }
8951
+ }
8952
+ const rm = item.resolution_map;
8953
+ if (rm && typeof rm === "object") {
8954
+ params["resolution"] = Object.keys(rm).map(String);
8955
+ }
8956
+ const steps = item.sample_steps;
8957
+ if (steps && typeof steps === "object") {
8958
+ params["steps"] = [steps.min_steps, steps.max_steps];
8959
+ }
8960
+ return params;
8961
+ }
8962
+ function toUpstreamMeta(item) {
8963
+ const reqKey = item == null ? void 0 : item.model_req_key;
8964
+ if (typeof reqKey !== "string" || reqKey.length === 0) return void 0;
8965
+ return {
8966
+ reqKey,
8967
+ modelName: typeof (item == null ? void 0 : item.model_name) === "string" ? item.model_name : void 0,
8968
+ modelTip: typeof (item == null ? void 0 : item.model_tip) === "string" ? item.model_tip : void 0,
8969
+ capabilities: extractCapabilities(item),
8970
+ params: extractEnumParams(item)
8971
+ };
8886
8972
  }
8887
8973
  async function fetchConfigModelReqKeys(token, region) {
8888
8974
  const regionInfo = buildRegionInfo(region);
8889
- const imageConfig = await request("post", "/mweb/v1/get_common_config", token, regionInfo, {
8890
- data: {},
8891
- params: { needCache: true, needRefresh: false }
8892
- });
8893
- const videoConfig = await request("post", "/mweb/v1/video_generate/get_common_config", token, regionInfo, {
8894
- data: { scene: "generate_video", params: {} }
8895
- });
8896
- const imageModels = Array.isArray(imageConfig == null ? void 0 : imageConfig.model_list) ? imageConfig.model_list.map((item) => {
8897
- const reqKey = item == null ? void 0 : item.model_req_key;
8898
- if (typeof reqKey !== "string" || reqKey.length === 0) return void 0;
8899
- return {
8900
- reqKey,
8901
- modelName: typeof (item == null ? void 0 : item.model_name) === "string" ? item.model_name : void 0,
8902
- modelTip: typeof (item == null ? void 0 : item.model_tip) === "string" ? item.model_tip : void 0,
8903
- capabilities: extractCapabilities(item)
8904
- };
8905
- }).filter((item) => Boolean(item)) : [];
8906
- const videoModels = Array.isArray(videoConfig == null ? void 0 : videoConfig.model_list) ? videoConfig.model_list.map((item) => {
8907
- const reqKey = item == null ? void 0 : item.model_req_key;
8908
- if (typeof reqKey !== "string" || reqKey.length === 0) return void 0;
8909
- return {
8910
- reqKey,
8911
- modelName: typeof (item == null ? void 0 : item.model_name) === "string" ? item.model_name : void 0,
8912
- modelTip: typeof (item == null ? void 0 : item.model_tip) === "string" ? item.model_tip : void 0,
8913
- capabilities: extractCapabilities(item)
8914
- };
8915
- }).filter((item) => Boolean(item)) : [];
8916
- return { imageModels, videoModels };
8975
+ const [imageConfig, videoConfig] = await Promise.all([
8976
+ request("post", "/mweb/v1/get_common_config", token, regionInfo, {
8977
+ data: {},
8978
+ params: { needCache: true, needRefresh: false }
8979
+ }),
8980
+ request("post", "/mweb/v1/video_generate/get_common_config", token, regionInfo, {
8981
+ data: { scene: "generate_video", params: {} }
8982
+ })
8983
+ ]);
8984
+ const toList = (config) => Array.isArray(config == null ? void 0 : config.model_list) ? config.model_list.map(toUpstreamMeta).filter((m) => Boolean(m)) : [];
8985
+ return { imageModels: toList(imageConfig), videoModels: toList(videoConfig) };
8917
8986
  }
8918
8987
  async function getLiveModels(authorization, xRegion) {
8919
8988
  const region = resolveRegion(authorization, xRegion);
@@ -10031,7 +10100,8 @@ async function generateVideo(_model, prompt, {
10031
10100
  isDefaultSeed: 1,
10032
10101
  originSubmitId,
10033
10102
  isRegenerate: false,
10034
- enterFrom: "click",
10103
+ enterFrom: "use_bgimage_prompt",
10104
+ position: "page_bottom_box",
10035
10105
  functionMode: flFunctionMode,
10036
10106
  sceneOptions: JSON.stringify([sceneOption])
10037
10107
  });
@@ -10125,7 +10195,7 @@ async function generateVideo(_model, prompt, {
10125
10195
  }
10126
10196
  };
10127
10197
  }
10128
- const videoReferer = regionInfo.isCN ? "https://jimeng.jianying.com/ai-tool/generate?type=video" : "https://dreamina.capcut.com/ai-tool/generate?type=video";
10198
+ const videoReferer = regionInfo.isCN ? `${BASE_URL_CN}/ai-tool/generate?type=video` : `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/generate?type=video`;
10129
10199
  const { aigc_data } = await request(
10130
10200
  "post",
10131
10201
  "/mweb/v1/aigc_draft/generate",
@@ -10156,7 +10226,7 @@ async function generateVideo(_model, prompt, {
10156
10226
  timeoutSeconds: pollerOptions.timeoutSeconds
10157
10227
  });
10158
10228
  const { result: pollingResult, data: finalHistoryData } = await poller.poll(async () => {
10159
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
10229
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l, _m, _n, _o;
10160
10230
  pollAttempts++;
10161
10231
  const result = await request("post", "/mweb/v1/get_history_by_ids", refreshToken, regionInfo, {
10162
10232
  data: {
@@ -10181,7 +10251,7 @@ async function generateVideo(_model, prompt, {
10181
10251
  const currentItemList = historyData.item_list || [];
10182
10252
  const finishTime = ((_a2 = historyData.task) == null ? void 0 : _a2.finish_time) || 0;
10183
10253
  if (currentItemList.length > 0) {
10184
- const tempVideoUrl = ((_e2 = (_d2 = (_c2 = (_b2 = currentItemList[0]) == null ? void 0 : _b2.video) == null ? void 0 : _c2.transcoded_video) == null ? void 0 : _d2.origin) == null ? void 0 : _e2.video_url) || ((_g2 = (_f2 = currentItemList[0]) == null ? void 0 : _f2.video) == null ? void 0 : _g2.play_url) || ((_i2 = (_h2 = currentItemList[0]) == null ? void 0 : _h2.video) == null ? void 0 : _i2.download_url) || ((_k2 = (_j2 = currentItemList[0]) == null ? void 0 : _j2.video) == null ? void 0 : _k2.url);
10254
+ const tempVideoUrl = ((_e2 = (_d2 = (_c2 = (_b2 = currentItemList[0]) == null ? void 0 : _b2.common_attr) == null ? void 0 : _c2.transcoded_video) == null ? void 0 : _d2.origin) == null ? void 0 : _e2.video_url) || ((_i2 = (_h2 = (_g2 = (_f2 = currentItemList[0]) == null ? void 0 : _f2.video) == null ? void 0 : _g2.transcoded_video) == null ? void 0 : _h2.origin) == null ? void 0 : _i2.video_url) || ((_k2 = (_j2 = currentItemList[0]) == null ? void 0 : _j2.video) == null ? void 0 : _k2.play_url) || ((_m = (_l = currentItemList[0]) == null ? void 0 : _l.video) == null ? void 0 : _m.download_url) || ((_o = (_n = currentItemList[0]) == null ? void 0 : _n.video) == null ? void 0 : _o.url);
10185
10255
  if (tempVideoUrl) {
10186
10256
  logger_default.info(`\u68C0\u6D4B\u5230\u89C6\u9891URL: ${tempVideoUrl}`);
10187
10257
  }
@@ -10268,8 +10338,8 @@ var JimengApiClient = class {
10268
10338
  }
10269
10339
  const candidates = session_pool_default.getEntries(false).filter((item) => item.enabled && item.live !== false && item.region).filter((item) => {
10270
10340
  var _a;
10271
- const modelHint = type === "video" ? "video" : "jimeng";
10272
- return !((_a = item.allowedModels) == null ? void 0 : _a.length) || item.allowedModels.some((m) => m.includes(modelHint));
10341
+ if (!((_a = item.allowedModels) == null ? void 0 : _a.length)) return true;
10342
+ return true;
10273
10343
  });
10274
10344
  if (candidates.length === 0) {
10275
10345
  throw new Error("No token available for task request. Configure token-pool or pass token.");
@@ -10383,10 +10453,10 @@ var JimengApiClient = class {
10383
10453
  return videoResult;
10384
10454
  }
10385
10455
  if (body.response_format === "b64_json") {
10386
- const videoBase64 = await util_default.fetchFileBASE64(videoResult);
10456
+ logger_default.warn("Video b64_json mode is not recommended \u2014 video files can be very large. Using URL mode instead.");
10387
10457
  return {
10388
10458
  created: util_default.unixTimestamp(),
10389
- data: [{ b64_json: videoBase64, revised_prompt: prompt }]
10459
+ data: [{ url: videoResult, revised_prompt: prompt }]
10390
10460
  };
10391
10461
  }
10392
10462
  return {