jimeng-cli 0.3.2 → 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.
@@ -5685,6 +5685,10 @@ var util = {
5685
5685
  return ((crc ^ -1) >>> 0).toString(16).padStart(8, "0");
5686
5686
  }
5687
5687
  };
5688
+ function maskToken(token) {
5689
+ if (token.length <= 10) return "***";
5690
+ return `${token.slice(0, 4)}...${token.slice(-4)}`;
5691
+ }
5688
5692
  var util_default = util;
5689
5693
 
5690
5694
  // src/lib/logger.ts
@@ -5960,6 +5964,8 @@ var JimengErrorHandler = class {
5960
5964
  throw new APIException(exceptions_default.API_IMAGE_GENERATION_FAILED, `[\u751F\u6210\u5931\u8D25]: ${errmsg}`);
5961
5965
  case "5002":
5962
5966
  throw new APIException(exceptions_default.API_VIDEO_GENERATION_FAILED, `[\u89C6\u9891\u751F\u6210\u5931\u8D25]: ${errmsg}`);
5967
+ case "34010105":
5968
+ throw new APIException(exceptions_default.API_REQUEST_FAILED, `[\u767B\u5F55\u9A8C\u8BC1\u5931\u8D25]: ${errmsg} (\u9519\u8BEF\u7801: ${ret})`);
5963
5969
  default:
5964
5970
  throw new APIException(exceptions_default.API_REQUEST_FAILED, `[${operation}\u5931\u8D25]: ${errmsg} (\u9519\u8BEF\u7801: ${ret})`);
5965
5971
  }
@@ -6070,7 +6076,6 @@ var DA_VERSION = "3.3.12";
6070
6076
  // src/api/consts/common.ts
6071
6077
  var BASE_URL_CN = "https://jimeng.jianying.com";
6072
6078
  var BASE_URL_US_COMMERCE = "https://commerce.us.capcut.com";
6073
- var BASE_URL_HK_COMMERCE = "https://commerce-api-sg.capcut.com";
6074
6079
  var DEFAULT_ASSISTANT_ID_CN = 513695;
6075
6080
  var DEFAULT_ASSISTANT_ID_US = 513641;
6076
6081
  var DEFAULT_ASSISTANT_ID_HK = 513641;
@@ -6086,9 +6091,9 @@ var VERSION_CODE = "8.4.0";
6086
6091
  var DEFAULT_IMAGE_MODEL = "jimeng-4.5";
6087
6092
  var DEFAULT_IMAGE_MODEL_US = "jimeng-4.5";
6088
6093
  var DEFAULT_VIDEO_MODEL = "jimeng-video-3.5-pro";
6089
- var DRAFT_VERSION = "3.3.9";
6094
+ var DRAFT_VERSION = "3.3.12";
6090
6095
  var DRAFT_MIN_VERSION = "3.0.2";
6091
- var DRAFT_VERSION_OMNI = "3.3.9";
6096
+ var DRAFT_VERSION_OMNI = "3.3.12";
6092
6097
  var OMNI_BENEFIT_TYPE = "dreamina_video_seedance_20_video_add";
6093
6098
  var OMNI_BENEFIT_TYPE_FAST = "dreamina_seedance_20_fast_with_video";
6094
6099
  var IMAGE_MODEL_MAP = {
@@ -6104,6 +6109,8 @@ var IMAGE_MODEL_MAP = {
6104
6109
  "jimeng-lab": "high_aes_general_v50_lab"
6105
6110
  };
6106
6111
  var IMAGE_MODEL_MAP_US = {
6112
+ "jimeng-5.0": "high_aes_general_v50",
6113
+ "jimeng-4.6": "high_aes_general_v42",
6107
6114
  "jimeng-4.5": "high_aes_general_v40l",
6108
6115
  "jimeng-4.1": "high_aes_general_v41",
6109
6116
  "jimeng-4.0": "high_aes_general_v40",
@@ -6117,6 +6124,7 @@ var IMAGE_MODEL_MAP_ASIA = {
6117
6124
  "jimeng-4.5": "high_aes_general_v40l",
6118
6125
  "jimeng-4.1": "high_aes_general_v41",
6119
6126
  "jimeng-4.0": "high_aes_general_v40",
6127
+ "jimeng-3.1": "high_aes_general_v30l_art:general_v3.0_18b",
6120
6128
  "jimeng-3.0": "high_aes_general_v30l:general_v3.0_18b",
6121
6129
  "nanobanana": "external_model_gemini_flash_image_v25",
6122
6130
  "nanobananapro": "dreamina_image_lib_1"
@@ -6134,10 +6142,14 @@ var VIDEO_MODEL_MAP = {
6134
6142
  "jimeng-video-2.0-pro": "dreamina_ic_generate_video_model_vgfm1.0"
6135
6143
  };
6136
6144
  var VIDEO_MODEL_MAP_US = {
6145
+ "jimeng-video-seedance-2.0": "dreamina_seedance_40_pro",
6146
+ "jimeng-video-seedance-2.0-fast": "dreamina_seedance_40",
6137
6147
  "jimeng-video-3.5-pro": "dreamina_ic_generate_video_model_vgfm_3.5_pro",
6138
6148
  "jimeng-video-3.0": "dreamina_ic_generate_video_model_vgfm_3.0"
6139
6149
  };
6140
6150
  var VIDEO_MODEL_MAP_ASIA = {
6151
+ "jimeng-video-seedance-2.0": "dreamina_seedance_40_pro",
6152
+ "jimeng-video-seedance-2.0-fast": "dreamina_seedance_40",
6141
6153
  "jimeng-video-veo3": "dreamina_veo3_generate_video",
6142
6154
  "jimeng-video-veo3.1": "dreamina_veo3.1_generate_video",
6143
6155
  "jimeng-video-sora2": "dreamina_sora2_generate_video",
@@ -6217,6 +6229,7 @@ var RESOLUTION_OPTIONS_NANOBANANAPRO_4K = {
6217
6229
  var DEVICE_ID = Math.random() * 1e18 + 7e18;
6218
6230
  var WEB_ID = Math.random() * 1e18 + 7e18;
6219
6231
  var USER_ID = util_default.uuid(false);
6232
+ var INTERNATIONAL_FRONTEND_ORIGIN = "https://dreamina.capcut.com";
6220
6233
  var FAKE_HEADERS = {
6221
6234
  Accept: "application/json, text/plain, */*",
6222
6235
  "Accept-Encoding": "gzip, deflate, br, zstd",
@@ -6340,8 +6353,7 @@ function parseProxyFromToken(rawToken) {
6340
6353
  return { token, proxyUrl };
6341
6354
  }
6342
6355
  function getRefererByRegion(regionInfo, cnPath) {
6343
- const { isInternational } = regionInfo;
6344
- return isInternational ? "https://dreamina.capcut.com/" : `https://jimeng.jianying.com${cnPath}`;
6356
+ return regionInfo.isInternational ? `${INTERNATIONAL_FRONTEND_ORIGIN}/` : `${BASE_URL_CN}${cnPath}`;
6345
6357
  }
6346
6358
  function getAssistantId(regionInfo) {
6347
6359
  if (regionInfo.isUS) return DEFAULT_ASSISTANT_ID_US;
@@ -6372,12 +6384,14 @@ function generateCookie(refreshToken) {
6372
6384
  }
6373
6385
  async function getCredit(refreshToken, regionInfo) {
6374
6386
  const referer = getRefererByRegion(regionInfo, "/ai-tool/image/generate");
6387
+ const origin = regionInfo.isInternational ? INTERNATIONAL_FRONTEND_ORIGIN : void 0;
6375
6388
  const {
6376
6389
  credit: { gift_credit, purchase_credit, vip_credit }
6377
6390
  } = await request("POST", "/commerce/v1/benefits/user_credit", refreshToken, regionInfo, {
6378
6391
  data: {},
6379
6392
  headers: {
6380
- Referer: referer
6393
+ Referer: referer,
6394
+ ...origin ? { Origin: origin } : {}
6381
6395
  },
6382
6396
  noDefaultParams: true
6383
6397
  });
@@ -6394,13 +6408,15 @@ async function getCredit(refreshToken, regionInfo) {
6394
6408
  async function receiveCredit(refreshToken, regionInfo) {
6395
6409
  logger_default.info("\u6B63\u5728\u5C1D\u8BD5\u6536\u53D6\u4ECA\u65E5\u79EF\u5206...");
6396
6410
  const referer = getRefererByRegion(regionInfo, "/ai-tool/home");
6411
+ const origin = regionInfo.isInternational ? INTERNATIONAL_FRONTEND_ORIGIN : void 0;
6397
6412
  const timeZone = regionInfo.isUS ? "America/New_York" : regionInfo.isHK ? "Asia/Hong_Kong" : regionInfo.isJP ? "Asia/Tokyo" : regionInfo.isSG ? "Asia/Singapore" : "Asia/Shanghai";
6398
6413
  const { receive_quota } = await request("POST", "/commerce/v1/benefits/credit_receive", refreshToken, regionInfo, {
6399
6414
  data: {
6400
6415
  time_zone: timeZone
6401
6416
  },
6402
6417
  headers: {
6403
- Referer: referer
6418
+ Referer: referer,
6419
+ ...origin ? { Origin: origin } : {}
6404
6420
  }
6405
6421
  });
6406
6422
  logger_default.info(`\u4ECA\u65E5${receive_quota}\u79EF\u5206\u6536\u53D6\u6210\u529F`);
@@ -6428,7 +6444,7 @@ async function request(method, uri, refreshToken, regionInfo, options = {}) {
6428
6444
  region = REGION_US;
6429
6445
  } else if (isHK || isJP || isSG) {
6430
6446
  if (uri.startsWith("/commerce/")) {
6431
- baseUrl = BASE_URL_HK_COMMERCE;
6447
+ baseUrl = BASE_URL_US_COMMERCE;
6432
6448
  } else {
6433
6449
  baseUrl = BASE_URL_DREAMINA_HK;
6434
6450
  }
@@ -6508,7 +6524,8 @@ async function request(method, uri, refreshToken, regionInfo, options = {}) {
6508
6524
  });
6509
6525
  logger_default.info(`\u54CD\u5E94\u72B6\u6001: ${response.status} ${response.statusText}`);
6510
6526
  if (options.responseType == "stream") return response;
6511
- const responseDataSummary = JSON.stringify(response.data).substring(0, 500) + (JSON.stringify(response.data).length > 500 ? "..." : "");
6527
+ const responseJson = JSON.stringify(response.data);
6528
+ const responseDataSummary = responseJson.substring(0, 500) + (responseJson.length > 500 ? "..." : "");
6512
6529
  logger_default.info(`\u54CD\u5E94\u6570\u636E\u6458\u8981: ${responseDataSummary}`);
6513
6530
  if (response.status >= 400) {
6514
6531
  logger_default.warn(`HTTP\u9519\u8BEF: ${response.status} ${response.statusText}`);
@@ -6626,7 +6643,7 @@ async function checkInternationalTokenLive(refreshToken, regionInfo) {
6626
6643
  const cookie = generateCookie(refreshToken);
6627
6644
  try {
6628
6645
  const response = await axios2.get(
6629
- "https://dreamina.capcut.com/passport/web/account/info/",
6646
+ `${INTERNATIONAL_FRONTEND_ORIGIN}/passport/web/account/info/`,
6630
6647
  {
6631
6648
  params: {
6632
6649
  aid,
@@ -6637,8 +6654,8 @@ async function checkInternationalTokenLive(refreshToken, regionInfo) {
6637
6654
  headers: {
6638
6655
  ...FAKE_HEADERS,
6639
6656
  Cookie: cookie,
6640
- Referer: "https://dreamina.capcut.com/ai-tool/home/",
6641
- Origin: "https://dreamina.capcut.com",
6657
+ Referer: `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/home/`,
6658
+ Origin: INTERNATIONAL_FRONTEND_ORIGIN,
6642
6659
  Appid: String(aid),
6643
6660
  "store-country-code": countryCode,
6644
6661
  "store-country-code-src": "uid"
@@ -6662,6 +6679,222 @@ async function checkInternationalTokenLive(refreshToken, regionInfo) {
6662
6679
  // src/lib/session-pool.ts
6663
6680
  import path4 from "path";
6664
6681
  import fs4 from "fs-extra";
6682
+
6683
+ // src/api/controllers/models.ts
6684
+ var CACHE_TTL_MS = 10 * 60 * 1e3;
6685
+ var FALLBACK_TOKEN = "test_token";
6686
+ var modelCache = /* @__PURE__ */ new Map();
6687
+ function mapVideoDescription(id) {
6688
+ if (id.includes("veo3.1")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B veo3.1";
6689
+ if (id.includes("veo3")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B veo3";
6690
+ if (id.includes("sora2")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B sora2";
6691
+ if (id.includes("seedance-2.0-fast")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B seedance 2.0-fast";
6692
+ if (id.includes("seedance-2.0")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B seedance 2.0";
6693
+ if (id.includes("3.5-pro")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 3.5 \u4E13\u4E1A\u7248";
6694
+ if (id.includes("3.0-fast")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 3.0 \u6781\u901F\u7248";
6695
+ if (id.includes("3.0-pro")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 3.0 \u4E13\u4E1A\u7248";
6696
+ if (id.includes("3.0")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 3.0";
6697
+ if (id.includes("2.0-pro")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 2.0 \u4E13\u4E1A\u7248";
6698
+ if (id.includes("2.0")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 2.0";
6699
+ return void 0;
6700
+ }
6701
+ function mapImageDescription(id) {
6702
+ if (id.includes("5.0")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 5.0";
6703
+ if (id.includes("4.6")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 4.6";
6704
+ if (id.includes("4.5")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 4.5";
6705
+ if (id.includes("4.1")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 4.1";
6706
+ if (id.includes("4.0")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 4.0";
6707
+ if (id.includes("3.1")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 3.1";
6708
+ if (id.includes("3.0")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 3.0";
6709
+ return `\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B ${id}`;
6710
+ }
6711
+ function buildModelItem(modelId, meta) {
6712
+ var _a;
6713
+ const modelType = modelId.startsWith("jimeng-video-") ? "video" : "image";
6714
+ const item = {
6715
+ id: modelId,
6716
+ object: "model",
6717
+ owned_by: "jimeng-cli",
6718
+ model_type: modelType
6719
+ };
6720
+ if (meta == null ? void 0 : meta.reqKey) item.model_req_key = meta.reqKey;
6721
+ if (meta == null ? void 0 : meta.modelName) item.model_name = meta.modelName;
6722
+ if ((_a = meta == null ? void 0 : meta.capabilities) == null ? void 0 : _a.length) item.capabilities = Array.from(new Set(meta.capabilities)).sort();
6723
+ if ((meta == null ? void 0 : meta.params) && Object.keys(meta.params).length > 0) item.params = meta.params;
6724
+ if (meta == null ? void 0 : meta.modelTip) {
6725
+ item.description = meta.modelTip;
6726
+ } else if (modelType === "video") {
6727
+ item.description = mapVideoDescription(modelId);
6728
+ } else {
6729
+ item.description = mapImageDescription(modelId);
6730
+ }
6731
+ return item;
6732
+ }
6733
+ function parseFirstToken(authorization) {
6734
+ var _a;
6735
+ if (!authorization || !/^Bearer\s+/i.test(authorization)) return void 0;
6736
+ const raw = authorization.replace(/^Bearer\s+/i, "").trim();
6737
+ if (!raw) return void 0;
6738
+ const first = (_a = raw.split(",")[0]) == null ? void 0 : _a.trim();
6739
+ return first || void 0;
6740
+ }
6741
+ function resolveToken(authorization) {
6742
+ const fromAuth = parseFirstToken(authorization);
6743
+ if (fromAuth) return fromAuth;
6744
+ const fromPool = session_pool_default.getAllTokens({ onlyEnabled: true, preferLive: true })[0];
6745
+ return fromPool || void 0;
6746
+ }
6747
+ function getRegionalMaps(region) {
6748
+ if (region === "us") return [IMAGE_MODEL_MAP_US, VIDEO_MODEL_MAP_US];
6749
+ if (region === "hk" || region === "jp" || region === "sg") return [IMAGE_MODEL_MAP_ASIA, VIDEO_MODEL_MAP_ASIA];
6750
+ if (region === "cn") return [IMAGE_MODEL_MAP, VIDEO_MODEL_MAP];
6751
+ return [IMAGE_MODEL_MAP, IMAGE_MODEL_MAP_US, IMAGE_MODEL_MAP_ASIA, VIDEO_MODEL_MAP, VIDEO_MODEL_MAP_US, VIDEO_MODEL_MAP_ASIA];
6752
+ }
6753
+ function resolveRegion(authorization, xRegion) {
6754
+ var _a;
6755
+ const token = resolveToken(authorization);
6756
+ const parsedXRegion = parseRegionCode(xRegion);
6757
+ if (parsedXRegion) return parsedXRegion;
6758
+ if (token) {
6759
+ assertTokenWithoutRegionPrefix(token);
6760
+ const normalizedToken = parseProxyFromToken(token).token;
6761
+ const poolRegion = (_a = session_pool_default.getTokenEntry(normalizedToken)) == null ? void 0 : _a.region;
6762
+ if (poolRegion) return poolRegion;
6763
+ throw new Error("\u7F3A\u5C11 region\u3002token \u672A\u5728 pool \u4E2D\u6CE8\u518C\u65F6\uFF0C/v1/models \u9700\u8981\u63D0\u4F9B\u8BF7\u6C42\u5934 X-Region");
6764
+ }
6765
+ return "cn";
6766
+ }
6767
+ var reverseMapCache = /* @__PURE__ */ new Map();
6768
+ function buildReverseMap(region) {
6769
+ const cached = reverseMapCache.get(region);
6770
+ if (cached) return cached;
6771
+ const reverse = {};
6772
+ for (const map of getRegionalMaps(region)) {
6773
+ for (const [modelId, upstreamKey] of Object.entries(map)) {
6774
+ reverse[upstreamKey] = modelId;
6775
+ }
6776
+ }
6777
+ reverseMapCache.set(region, reverse);
6778
+ return reverse;
6779
+ }
6780
+ function buildFallbackModels(region) {
6781
+ const maps = getRegionalMaps(region);
6782
+ const modelIds = Array.from(new Set(maps.flatMap((item) => Object.keys(item)))).sort();
6783
+ return modelIds.map((id) => buildModelItem(id));
6784
+ }
6785
+ function makeCacheKey(region) {
6786
+ return `models|${region}`;
6787
+ }
6788
+ function resolveFetchToken(token) {
6789
+ if (!token) return FALLBACK_TOKEN;
6790
+ const normalizedToken = parseProxyFromToken(token).token;
6791
+ assertTokenWithoutRegionPrefix(normalizedToken);
6792
+ return normalizedToken;
6793
+ }
6794
+ function extractValidOptions(item) {
6795
+ return (Array.isArray(item.options) ? item.options : []).filter(
6796
+ (opt) => !!opt && typeof opt === "object" && typeof opt.key === "string" && opt.key.length > 0
6797
+ );
6798
+ }
6799
+ function extractCapabilities(item) {
6800
+ const features = Array.isArray(item.feats) ? item.feats.filter((f) => typeof f === "string" && f.length > 0) : [];
6801
+ const optionKeys = extractValidOptions(item).map((o) => o.key);
6802
+ return Array.from(/* @__PURE__ */ new Set([...features, ...optionKeys]));
6803
+ }
6804
+ function extractEnumParams(item) {
6805
+ const params = {};
6806
+ for (const o of extractValidOptions(item)) {
6807
+ const ev = o.enum_val;
6808
+ if (!ev) continue;
6809
+ const sv = ev.string_value;
6810
+ const iv = ev.int_value;
6811
+ const vals = sv || iv;
6812
+ if (vals && vals.length > 0) {
6813
+ params[o.key] = vals;
6814
+ }
6815
+ }
6816
+ const rm = item.resolution_map;
6817
+ if (rm && typeof rm === "object") {
6818
+ params["resolution"] = Object.keys(rm).map(String);
6819
+ }
6820
+ const steps = item.sample_steps;
6821
+ if (steps && typeof steps === "object") {
6822
+ params["steps"] = [steps.min_steps, steps.max_steps];
6823
+ }
6824
+ return params;
6825
+ }
6826
+ function toUpstreamMeta(item) {
6827
+ const reqKey = item == null ? void 0 : item.model_req_key;
6828
+ if (typeof reqKey !== "string" || reqKey.length === 0) return void 0;
6829
+ return {
6830
+ reqKey,
6831
+ modelName: typeof (item == null ? void 0 : item.model_name) === "string" ? item.model_name : void 0,
6832
+ modelTip: typeof (item == null ? void 0 : item.model_tip) === "string" ? item.model_tip : void 0,
6833
+ capabilities: extractCapabilities(item),
6834
+ params: extractEnumParams(item)
6835
+ };
6836
+ }
6837
+ async function fetchConfigModelReqKeys(token, region) {
6838
+ const regionInfo = buildRegionInfo(region);
6839
+ const [imageConfig, videoConfig] = await Promise.all([
6840
+ request("post", "/mweb/v1/get_common_config", token, regionInfo, {
6841
+ data: {},
6842
+ params: { needCache: true, needRefresh: false }
6843
+ }),
6844
+ request("post", "/mweb/v1/video_generate/get_common_config", token, regionInfo, {
6845
+ data: { scene: "generate_video", params: {} }
6846
+ })
6847
+ ]);
6848
+ const toList = (config) => Array.isArray(config == null ? void 0 : config.model_list) ? config.model_list.map(toUpstreamMeta).filter((m) => Boolean(m)) : [];
6849
+ return { imageModels: toList(imageConfig), videoModels: toList(videoConfig) };
6850
+ }
6851
+ async function getLiveModels(authorization, xRegion) {
6852
+ const region = resolveRegion(authorization, xRegion);
6853
+ const token = resolveToken(authorization);
6854
+ const effectiveToken = resolveFetchToken(token);
6855
+ const cacheKey = makeCacheKey(region);
6856
+ const cached = modelCache.get(cacheKey);
6857
+ if (cached && cached.expiresAt > Date.now()) {
6858
+ return { source: cached.source, data: cached.data };
6859
+ }
6860
+ try {
6861
+ const reverseMap = buildReverseMap(region);
6862
+ const { imageModels, videoModels } = await fetchConfigModelReqKeys(effectiveToken, region);
6863
+ const upstreamModels = [...imageModels, ...videoModels];
6864
+ const metaByModelId = /* @__PURE__ */ new Map();
6865
+ const mapped = upstreamModels.map((model) => {
6866
+ const modelId = reverseMap[model.reqKey];
6867
+ if (modelId && !metaByModelId.has(modelId)) {
6868
+ metaByModelId.set(modelId, model);
6869
+ }
6870
+ return modelId;
6871
+ }).filter((item) => typeof item === "string" && item.length > 0);
6872
+ const modelIds = Array.from(new Set(mapped)).sort();
6873
+ if (modelIds.length === 0) {
6874
+ throw new Error("model_req_key resolved but none matched local reverse map");
6875
+ }
6876
+ const data = modelIds.map((id) => buildModelItem(id, metaByModelId.get(id)));
6877
+ modelCache.set(cacheKey, {
6878
+ expiresAt: Date.now() + CACHE_TTL_MS,
6879
+ source: "upstream",
6880
+ data
6881
+ });
6882
+ return { source: "upstream", data };
6883
+ } catch {
6884
+ const data = buildFallbackModels(region);
6885
+ modelCache.set(cacheKey, {
6886
+ expiresAt: Date.now() + CACHE_TTL_MS,
6887
+ source: "fallback",
6888
+ data
6889
+ });
6890
+ return { source: "fallback", data };
6891
+ }
6892
+ }
6893
+ async function refreshAllTokenModels() {
6894
+ return session_pool_default.refreshAllDynamicCapabilities();
6895
+ }
6896
+
6897
+ // src/lib/session-pool.ts
6665
6898
  function sample(arr) {
6666
6899
  return arr.length > 0 ? arr[Math.floor(Math.random() * arr.length)] : void 0;
6667
6900
  }
@@ -6710,10 +6943,14 @@ var TokenPool = class {
6710
6943
  );
6711
6944
  }
6712
6945
  getSummary() {
6713
- const entries = this.getEntries(false);
6714
- const enabledCount = entries.filter((item) => item.enabled).length;
6715
- const liveCount = entries.filter((item) => item.enabled && item.live === true).length;
6716
- const missingRegionCount = entries.filter((item) => !item.region).length;
6946
+ let enabledCount = 0;
6947
+ let liveCount = 0;
6948
+ let missingRegionCount = 0;
6949
+ for (const item of this.entryMap.values()) {
6950
+ if (item.enabled) enabledCount++;
6951
+ if (item.enabled && item.live === true) liveCount++;
6952
+ if (!item.region) missingRegionCount++;
6953
+ }
6717
6954
  return {
6718
6955
  enabled: this.enabled,
6719
6956
  filePath: this.filePath,
@@ -6722,19 +6959,19 @@ var TokenPool = class {
6722
6959
  fetchCreditOnCheck: this.fetchCreditOnCheck,
6723
6960
  autoDisableEnabled: this.autoDisableEnabled,
6724
6961
  autoDisableFailures: this.autoDisableFailures,
6725
- total: entries.length,
6962
+ total: this.entryMap.size,
6726
6963
  enabledCount,
6727
6964
  liveCount,
6728
6965
  missingRegionCount,
6729
6966
  lastHealthCheckAt: this.lastHealthCheckAt || null
6730
6967
  };
6731
6968
  }
6732
- getEntries(maskToken = true) {
6969
+ getEntries(shouldMask = true) {
6733
6970
  const items = Array.from(this.entryMap.values()).map((item) => ({ ...item }));
6734
- if (!maskToken) return items;
6971
+ if (!shouldMask) return items;
6735
6972
  return items.map((item) => ({
6736
6973
  ...item,
6737
- token: this.maskToken(item.token)
6974
+ token: maskToken(item.token)
6738
6975
  }));
6739
6976
  }
6740
6977
  getAllTokens(options = {}) {
@@ -6805,7 +7042,7 @@ var TokenPool = class {
6805
7042
  token: null,
6806
7043
  region: null,
6807
7044
  error: "prefixed_token_not_supported",
6808
- reason: `token ${this.maskToken(prefixedCandidate.token)} \u4F7F\u7528\u4E86\u5DF2\u5E9F\u5F03\u7684 region \u524D\u7F00`
7045
+ reason: `token ${maskToken(prefixedCandidate.token)} \u4F7F\u7528\u4E86\u5DF2\u5E9F\u5F03\u7684 region \u524D\u7F00`
6809
7046
  };
6810
7047
  }
6811
7048
  const regionLockedCandidates = validCandidates.filter(
@@ -6911,8 +7148,8 @@ var TokenPool = class {
6911
7148
  async refreshDynamicCapabilitiesForToken(token) {
6912
7149
  if (!this.enabled) throw new Error("Token pool disabled");
6913
7150
  const item = this.entryMap.get(token);
6914
- if (!item) throw new Error(`Token not found in pool: ${this.maskToken(token)}`);
6915
- if (!item.region) throw new Error(`Token ${this.maskToken(token)} has no region`);
7151
+ if (!item) throw new Error(`Token not found in pool: ${maskToken(token)}`);
7152
+ if (!item.region) throw new Error(`Token ${maskToken(token)} has no region`);
6916
7153
  const regionInfo = buildRegionInfo(item.region);
6917
7154
  const capabilities = await this.fetchDynamicCapabilities(token, regionInfo);
6918
7155
  item.dynamicCapabilities = { ...capabilities, updatedAt: Date.now() };
@@ -6924,39 +7161,41 @@ var TokenPool = class {
6924
7161
  * Returns a per-token result summary.
6925
7162
  */
6926
7163
  async refreshAllDynamicCapabilities() {
6927
- var _a, _b;
6928
7164
  if (!this.enabled) return [];
6929
7165
  const entries = this.getEntries(false).filter(
6930
7166
  (item) => item.enabled && item.live !== false && Boolean(item.region)
6931
7167
  );
6932
- const results = [];
6933
- for (const entry of entries) {
6934
- try {
6935
- const regionInfo = buildRegionInfo(entry.region);
6936
- const capabilities = await this.fetchDynamicCapabilities(entry.token, regionInfo);
6937
- const current = this.entryMap.get(entry.token);
6938
- if (current) {
6939
- current.dynamicCapabilities = { ...capabilities, updatedAt: Date.now() };
6940
- }
6941
- results.push({
6942
- token: this.maskToken(entry.token),
6943
- region: entry.region,
6944
- imageModels: ((_a = capabilities.imageModels) == null ? void 0 : _a.length) ?? 0,
6945
- videoModels: ((_b = capabilities.videoModels) == null ? void 0 : _b.length) ?? 0,
6946
- capabilityTags: capabilities.capabilityTags ?? []
6947
- });
6948
- } catch (err) {
6949
- results.push({
6950
- token: this.maskToken(entry.token),
6951
- region: entry.region,
6952
- imageModels: 0,
6953
- videoModels: 0,
6954
- capabilityTags: [],
6955
- error: (err == null ? void 0 : err.message) || String(err)
6956
- });
6957
- }
6958
- }
6959
- if (entries.length > 0) await this.persistToDisk();
7168
+ if (entries.length === 0) return [];
7169
+ const results = await Promise.all(
7170
+ entries.map(async (entry) => {
7171
+ var _a, _b;
7172
+ try {
7173
+ const regionInfo = buildRegionInfo(entry.region);
7174
+ const capabilities = await this.fetchDynamicCapabilities(entry.token, regionInfo);
7175
+ const current = this.entryMap.get(entry.token);
7176
+ if (current) {
7177
+ current.dynamicCapabilities = { ...capabilities, updatedAt: Date.now() };
7178
+ }
7179
+ return {
7180
+ token: maskToken(entry.token),
7181
+ region: entry.region,
7182
+ imageModels: ((_a = capabilities.imageModels) == null ? void 0 : _a.length) ?? 0,
7183
+ videoModels: ((_b = capabilities.videoModels) == null ? void 0 : _b.length) ?? 0,
7184
+ capabilityTags: capabilities.capabilityTags ?? []
7185
+ };
7186
+ } catch (err) {
7187
+ return {
7188
+ token: maskToken(entry.token),
7189
+ region: entry.region,
7190
+ imageModels: 0,
7191
+ videoModels: 0,
7192
+ capabilityTags: [],
7193
+ error: err instanceof Error ? err.message : String(err)
7194
+ };
7195
+ }
7196
+ })
7197
+ );
7198
+ await this.persistToDisk();
6960
7199
  return results;
6961
7200
  }
6962
7201
  async runHealthCheck() {
@@ -7077,14 +7316,10 @@ var TokenPool = class {
7077
7316
  await fs4.ensureDir(path4.dirname(this.filePath));
7078
7317
  const payload = {
7079
7318
  updatedAt: Date.now(),
7080
- tokens: this.getEntries(false)
7319
+ tokens: Array.from(this.entryMap.values())
7081
7320
  };
7082
7321
  await fs4.writeJson(this.filePath, payload, { spaces: 2 });
7083
7322
  }
7084
- maskToken(token) {
7085
- if (token.length <= 10) return "***";
7086
- return `${token.slice(0, 4)}...${token.slice(-4)}`;
7087
- }
7088
7323
  parseAuthorizationTokens(authorization) {
7089
7324
  if (typeof authorization !== "string" || authorization.trim().length === 0) {
7090
7325
  return { tokens: [], error: null };
@@ -7113,7 +7348,7 @@ var TokenPool = class {
7113
7348
  if (!token) continue;
7114
7349
  const parsedRegion = parseRegionCode(item.region || defaultRegion);
7115
7350
  if (!parsedRegion) {
7116
- throw new Error(`token ${this.maskToken(token)} \u7F3A\u5C11\u6709\u6548 region\uFF08\u4EC5\u652F\u6301 cn/us/hk/jp/sg\uFF09`);
7351
+ throw new Error(`token ${maskToken(token)} \u7F3A\u5C11\u6709\u6548 region\uFF08\u4EC5\u652F\u6301 cn/us/hk/jp/sg\uFF09`);
7117
7352
  }
7118
7353
  normalized.push({
7119
7354
  token,
@@ -7221,233 +7456,25 @@ var TokenPool = class {
7221
7456
  }
7222
7457
  async fetchDynamicCapabilities(token, regionInfo) {
7223
7458
  const regionCode = regionInfo.isUS ? "us" : regionInfo.isHK ? "hk" : regionInfo.isJP ? "jp" : regionInfo.isSG ? "sg" : "cn";
7224
- const reverseMap = this.getReverseModelMapByRegion(regionCode);
7225
- const imageConfig = await request("post", "/mweb/v1/get_common_config", token, regionInfo, {
7226
- data: {},
7227
- params: { needCache: true, needRefresh: false }
7228
- });
7229
- const videoConfig = await request("post", "/mweb/v1/video_generate/get_common_config", token, regionInfo, {
7230
- data: { scene: "generate_video", params: {} }
7231
- });
7232
- 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) : [];
7233
- 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) : [];
7234
- const imageModels = imageReqKeys.map((key) => reverseMap[key]).filter(Boolean);
7235
- const videoModels = videoReqKeys.map((key) => reverseMap[key]).filter(Boolean);
7459
+ const reverseMap = buildReverseMap(regionCode);
7460
+ const { imageModels, videoModels } = await fetchConfigModelReqKeys(token, regionCode);
7461
+ const imageIds = imageModels.map((m) => reverseMap[m.reqKey]).filter(Boolean);
7462
+ const videoIds = videoModels.map((m) => reverseMap[m.reqKey]).filter(Boolean);
7236
7463
  const capabilityTags = /* @__PURE__ */ new Set();
7237
- for (const model of videoModels) {
7464
+ for (const model of videoIds) {
7238
7465
  if (model.includes("seedance_40")) capabilityTags.add("omni_reference");
7239
7466
  if (model.includes("veo3")) capabilityTags.add("veo3");
7240
7467
  if (model.includes("sora2")) capabilityTags.add("sora2");
7241
7468
  }
7242
7469
  return {
7243
- imageModels: imageModels.length ? Array.from(new Set(imageModels)) : void 0,
7244
- videoModels: videoModels.length ? Array.from(new Set(videoModels)) : void 0,
7470
+ imageModels: imageIds.length ? Array.from(new Set(imageIds)) : void 0,
7471
+ videoModels: videoIds.length ? Array.from(new Set(videoIds)) : void 0,
7245
7472
  capabilityTags: capabilityTags.size ? Array.from(capabilityTags) : void 0
7246
7473
  };
7247
7474
  }
7248
- getReverseModelMapByRegion(region) {
7249
- 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];
7250
- const reverse = {};
7251
- for (const map of maps) {
7252
- for (const [modelId, reqKey] of Object.entries(map)) {
7253
- reverse[reqKey] = modelId;
7254
- }
7255
- }
7256
- return reverse;
7257
- }
7258
7475
  };
7259
7476
  var session_pool_default = new TokenPool();
7260
7477
 
7261
- // src/api/controllers/models.ts
7262
- var CACHE_TTL_MS = 10 * 60 * 1e3;
7263
- var FALLBACK_TOKEN = "test_token";
7264
- var modelCache = /* @__PURE__ */ new Map();
7265
- function mapVideoDescription(id) {
7266
- if (id.includes("veo3.1")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B veo3.1";
7267
- if (id.includes("veo3")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B veo3";
7268
- if (id.includes("sora2")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B sora2";
7269
- if (id.includes("seedance-2.0-fast")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B seedance 2.0-fast";
7270
- if (id.includes("seedance-2.0")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B seedance 2.0";
7271
- if (id.includes("3.5-pro")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 3.5 \u4E13\u4E1A\u7248";
7272
- if (id.includes("3.0-fast")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 3.0 \u6781\u901F\u7248";
7273
- if (id.includes("3.0-pro")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 3.0 \u4E13\u4E1A\u7248";
7274
- if (id.includes("3.0")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 3.0";
7275
- if (id.includes("2.0-pro")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 2.0 \u4E13\u4E1A\u7248";
7276
- if (id.includes("2.0")) return "\u5373\u68A6AI\u89C6\u9891\u751F\u6210\u6A21\u578B 2.0";
7277
- return void 0;
7278
- }
7279
- function mapImageDescription(id) {
7280
- if (id.includes("5.0")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 5.0";
7281
- if (id.includes("4.6")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 4.6";
7282
- if (id.includes("4.5")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 4.5";
7283
- if (id.includes("4.1")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 4.1";
7284
- if (id.includes("4.0")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 4.0";
7285
- if (id.includes("3.1")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 3.1";
7286
- if (id.includes("3.0")) return "\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B 3.0";
7287
- return `\u5373\u68A6AI\u56FE\u50CF\u6A21\u578B ${id}`;
7288
- }
7289
- function buildModelItem(modelId, meta) {
7290
- var _a;
7291
- const modelType = modelId.startsWith("jimeng-video-") ? "video" : "image";
7292
- const item = {
7293
- id: modelId,
7294
- object: "model",
7295
- owned_by: "jimeng-cli",
7296
- model_type: modelType
7297
- };
7298
- if (meta == null ? void 0 : meta.reqKey) item.model_req_key = meta.reqKey;
7299
- if (meta == null ? void 0 : meta.modelName) item.model_name = meta.modelName;
7300
- if ((_a = meta == null ? void 0 : meta.capabilities) == null ? void 0 : _a.length) item.capabilities = Array.from(new Set(meta.capabilities)).sort();
7301
- if (meta == null ? void 0 : meta.modelTip) {
7302
- item.description = meta.modelTip;
7303
- } else if (modelType === "video") {
7304
- item.description = mapVideoDescription(modelId);
7305
- } else {
7306
- item.description = mapImageDescription(modelId);
7307
- }
7308
- return item;
7309
- }
7310
- function parseFirstToken(authorization) {
7311
- var _a;
7312
- if (!authorization || !/^Bearer\s+/i.test(authorization)) return void 0;
7313
- const raw = authorization.replace(/^Bearer\s+/i, "").trim();
7314
- if (!raw) return void 0;
7315
- const first = (_a = raw.split(",")[0]) == null ? void 0 : _a.trim();
7316
- return first || void 0;
7317
- }
7318
- function resolveToken(authorization) {
7319
- const fromAuth = parseFirstToken(authorization);
7320
- if (fromAuth) return fromAuth;
7321
- const fromPool = session_pool_default.getAllTokens({ onlyEnabled: true, preferLive: true })[0];
7322
- return fromPool || void 0;
7323
- }
7324
- function getRegionalMaps(region) {
7325
- if (region === "us") return [IMAGE_MODEL_MAP_US, VIDEO_MODEL_MAP_US];
7326
- if (region === "hk" || region === "jp" || region === "sg") return [IMAGE_MODEL_MAP_ASIA, VIDEO_MODEL_MAP_ASIA];
7327
- if (region === "cn") return [IMAGE_MODEL_MAP, VIDEO_MODEL_MAP];
7328
- return [IMAGE_MODEL_MAP, IMAGE_MODEL_MAP_US, IMAGE_MODEL_MAP_ASIA, VIDEO_MODEL_MAP, VIDEO_MODEL_MAP_US, VIDEO_MODEL_MAP_ASIA];
7329
- }
7330
- function resolveRegion(authorization, xRegion) {
7331
- var _a;
7332
- const token = resolveToken(authorization);
7333
- const parsedXRegion = parseRegionCode(xRegion);
7334
- if (parsedXRegion) return parsedXRegion;
7335
- if (token) {
7336
- assertTokenWithoutRegionPrefix(token);
7337
- const normalizedToken = parseProxyFromToken(token).token;
7338
- const poolRegion = (_a = session_pool_default.getTokenEntry(normalizedToken)) == null ? void 0 : _a.region;
7339
- if (poolRegion) return poolRegion;
7340
- throw new Error("\u7F3A\u5C11 region\u3002token \u672A\u5728 pool \u4E2D\u6CE8\u518C\u65F6\uFF0C/v1/models \u9700\u8981\u63D0\u4F9B\u8BF7\u6C42\u5934 X-Region");
7341
- }
7342
- return "cn";
7343
- }
7344
- function buildReverseMap(region) {
7345
- const reverse = {};
7346
- for (const map of getRegionalMaps(region)) {
7347
- for (const [modelId, upstreamKey] of Object.entries(map)) {
7348
- reverse[upstreamKey] = modelId;
7349
- }
7350
- }
7351
- return reverse;
7352
- }
7353
- function buildFallbackModels(region) {
7354
- const maps = getRegionalMaps(region);
7355
- const modelIds = Array.from(new Set(maps.flatMap((item) => Object.keys(item)))).sort();
7356
- return modelIds.map((id) => buildModelItem(id));
7357
- }
7358
- function makeCacheKey(region) {
7359
- return `models|${region}`;
7360
- }
7361
- function resolveFetchToken(token) {
7362
- if (!token) return FALLBACK_TOKEN;
7363
- const normalizedToken = parseProxyFromToken(token).token;
7364
- assertTokenWithoutRegionPrefix(normalizedToken);
7365
- return normalizedToken;
7366
- }
7367
- function extractCapabilities(item) {
7368
- const features = Array.isArray(item.feats) ? item.feats.filter((feature) => typeof feature === "string" && feature.length > 0) : [];
7369
- const options = Array.isArray(item.options) ? item.options.map(
7370
- (option) => option && typeof option === "object" && typeof option.key === "string" ? option.key : void 0
7371
- ).filter((key) => typeof key === "string" && key.length > 0) : [];
7372
- return Array.from(/* @__PURE__ */ new Set([...features, ...options]));
7373
- }
7374
- async function fetchConfigModelReqKeys(token, region) {
7375
- const regionInfo = buildRegionInfo(region);
7376
- const imageConfig = await request("post", "/mweb/v1/get_common_config", token, regionInfo, {
7377
- data: {},
7378
- params: { needCache: true, needRefresh: false }
7379
- });
7380
- const videoConfig = await request("post", "/mweb/v1/video_generate/get_common_config", token, regionInfo, {
7381
- data: { scene: "generate_video", params: {} }
7382
- });
7383
- const imageModels = Array.isArray(imageConfig == null ? void 0 : imageConfig.model_list) ? imageConfig.model_list.map((item) => {
7384
- const reqKey = item == null ? void 0 : item.model_req_key;
7385
- if (typeof reqKey !== "string" || reqKey.length === 0) return void 0;
7386
- return {
7387
- reqKey,
7388
- modelName: typeof (item == null ? void 0 : item.model_name) === "string" ? item.model_name : void 0,
7389
- modelTip: typeof (item == null ? void 0 : item.model_tip) === "string" ? item.model_tip : void 0,
7390
- capabilities: extractCapabilities(item)
7391
- };
7392
- }).filter((item) => Boolean(item)) : [];
7393
- const videoModels = Array.isArray(videoConfig == null ? void 0 : videoConfig.model_list) ? videoConfig.model_list.map((item) => {
7394
- const reqKey = item == null ? void 0 : item.model_req_key;
7395
- if (typeof reqKey !== "string" || reqKey.length === 0) return void 0;
7396
- return {
7397
- reqKey,
7398
- modelName: typeof (item == null ? void 0 : item.model_name) === "string" ? item.model_name : void 0,
7399
- modelTip: typeof (item == null ? void 0 : item.model_tip) === "string" ? item.model_tip : void 0,
7400
- capabilities: extractCapabilities(item)
7401
- };
7402
- }).filter((item) => Boolean(item)) : [];
7403
- return { imageModels, videoModels };
7404
- }
7405
- async function getLiveModels(authorization, xRegion) {
7406
- const region = resolveRegion(authorization, xRegion);
7407
- const token = resolveToken(authorization);
7408
- const effectiveToken = resolveFetchToken(token);
7409
- const cacheKey = makeCacheKey(region);
7410
- const cached = modelCache.get(cacheKey);
7411
- if (cached && cached.expiresAt > Date.now()) {
7412
- return { source: cached.source, data: cached.data };
7413
- }
7414
- try {
7415
- const reverseMap = buildReverseMap(region);
7416
- const { imageModels, videoModels } = await fetchConfigModelReqKeys(effectiveToken, region);
7417
- const upstreamModels = [...imageModels, ...videoModels];
7418
- const metaByModelId = /* @__PURE__ */ new Map();
7419
- const mapped = upstreamModels.map((model) => {
7420
- const modelId = reverseMap[model.reqKey];
7421
- if (modelId && !metaByModelId.has(modelId)) {
7422
- metaByModelId.set(modelId, model);
7423
- }
7424
- return modelId;
7425
- }).filter((item) => typeof item === "string" && item.length > 0);
7426
- const modelIds = Array.from(new Set(mapped)).sort();
7427
- if (modelIds.length === 0) {
7428
- throw new Error("model_req_key resolved but none matched local reverse map");
7429
- }
7430
- const data = modelIds.map((id) => buildModelItem(id, metaByModelId.get(id)));
7431
- modelCache.set(cacheKey, {
7432
- expiresAt: Date.now() + CACHE_TTL_MS,
7433
- source: "upstream",
7434
- data
7435
- });
7436
- return { source: "upstream", data };
7437
- } catch {
7438
- const data = buildFallbackModels(region);
7439
- modelCache.set(cacheKey, {
7440
- expiresAt: Date.now() + CACHE_TTL_MS,
7441
- source: "fallback",
7442
- data
7443
- });
7444
- return { source: "fallback", data };
7445
- }
7446
- }
7447
- async function refreshAllTokenModels() {
7448
- return session_pool_default.refreshAllDynamicCapabilities();
7449
- }
7450
-
7451
7478
  // src/lib/smart-poller.ts
7452
7479
  var SmartPoller = class {
7453
7480
  pollCount = 0;
@@ -8596,7 +8623,7 @@ async function generateImageComposition(_model, prompt, images, {
8596
8623
  abilityName: "byte_edit",
8597
8624
  strength: sampleStrength,
8598
8625
  source: {
8599
- imageUrl: `blob:https://dreamina.capcut.com/${util_default.uuid()}`
8626
+ imageUrl: `blob:${INTERNATIONAL_FRONTEND_ORIGIN}/${util_default.uuid()}`
8600
8627
  }
8601
8628
  }));
8602
8629
  const metricsExtra = buildMetricsExtra({
@@ -8631,7 +8658,7 @@ async function generateImageComposition(_model, prompt, images, {
8631
8658
  draftContent,
8632
8659
  metricsExtra
8633
8660
  });
8634
- const imageReferer = regionInfo.isCN ? "https://jimeng.jianying.com/ai-tool/generate?type=image" : "https://dreamina.capcut.com/ai-tool/generate?type=image";
8661
+ const imageReferer = regionInfo.isCN ? `${BASE_URL_CN}/ai-tool/generate?type=image` : `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/generate?type=image`;
8635
8662
  const { aigc_data } = await request(
8636
8663
  "post",
8637
8664
  "/mweb/v1/aigc_draft/generate",
@@ -8795,7 +8822,7 @@ async function generateImagesInternal(_model, prompt, {
8795
8822
  draftContent,
8796
8823
  metricsExtra
8797
8824
  });
8798
- const imageReferer = regionInfo.isCN ? "https://jimeng.jianying.com/ai-tool/generate?type=image" : "https://dreamina.capcut.com/ai-tool/generate?type=image";
8825
+ const imageReferer = regionInfo.isCN ? `${BASE_URL_CN}/ai-tool/generate?type=image` : `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/generate?type=image`;
8799
8826
  const { aigc_data } = await request(
8800
8827
  "post",
8801
8828
  "/mweb/v1/aigc_draft/generate",
@@ -8917,7 +8944,7 @@ async function generateJimeng4xMultiImages(_model, prompt, {
8917
8944
  draftContent,
8918
8945
  metricsExtra
8919
8946
  });
8920
- const imageReferer = regionInfo.isCN ? "https://jimeng.jianying.com/ai-tool/generate?type=image" : "https://dreamina.capcut.com/ai-tool/generate?type=image";
8947
+ const imageReferer = regionInfo.isCN ? `${BASE_URL_CN}/ai-tool/generate?type=image` : `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/generate?type=image`;
8921
8948
  const { aigc_data } = await request(
8922
8949
  "post",
8923
8950
  "/mweb/v1/aigc_draft/generate",
@@ -9089,7 +9116,7 @@ async function upscaleImage(_model, image, {
9089
9116
  draftContent,
9090
9117
  metricsExtra
9091
9118
  });
9092
- const imageReferer = regionInfo.isCN ? "https://jimeng.jianying.com/ai-tool/generate?type=image" : "https://dreamina.capcut.com/ai-tool/generate?type=image";
9119
+ const imageReferer = regionInfo.isCN ? `${BASE_URL_CN}/ai-tool/generate?type=image` : `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/generate?type=image`;
9093
9120
  const { aigc_data } = await request(
9094
9121
  "post",
9095
9122
  "/mweb/v1/aigc_draft/generate",
@@ -10139,7 +10166,7 @@ async function generateVideo(_model, prompt, {
10139
10166
  }
10140
10167
  };
10141
10168
  }
10142
- const videoReferer = regionInfo.isCN ? "https://jimeng.jianying.com/ai-tool/generate?type=video" : "https://dreamina.capcut.com/ai-tool/generate?type=video";
10169
+ const videoReferer = regionInfo.isCN ? `${BASE_URL_CN}/ai-tool/generate?type=video` : `${INTERNATIONAL_FRONTEND_ORIGIN}/ai-tool/generate?type=video`;
10143
10170
  const { aigc_data } = await request(
10144
10171
  "post",
10145
10172
  "/mweb/v1/aigc_draft/generate",
@@ -10238,6 +10265,7 @@ async function generateVideo(_model, prompt, {
10238
10265
  export {
10239
10266
  environment_default,
10240
10267
  config_default,
10268
+ maskToken,
10241
10269
  util_default,
10242
10270
  logger_default,
10243
10271
  DEFAULT_IMAGE_MODEL,
@@ -10246,9 +10274,9 @@ export {
10246
10274
  getCredit,
10247
10275
  receiveCredit,
10248
10276
  getTokenLiveStatus,
10249
- session_pool_default,
10250
10277
  getLiveModels,
10251
10278
  refreshAllTokenModels,
10279
+ session_pool_default,
10252
10280
  getTaskResponse,
10253
10281
  waitForTaskResponse,
10254
10282
  getAssetList,
@@ -10270,4 +10298,4 @@ lodash/lodash.js:
10270
10298
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
10271
10299
  *)
10272
10300
  */
10273
- //# sourceMappingURL=chunk-FAXTAAQO.js.map
10301
+ //# sourceMappingURL=chunk-ZMTQQZFH.js.map