mmx-cli 1.0.25 → 1.0.26

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/sdk.mjs CHANGED
@@ -1,6 +1,3 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
1
  // src/config/loader.ts
5
2
  import { copyFileSync, existsSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "fs";
6
3
 
@@ -438,8 +435,14 @@ Re-authenticate: mmx auth login`);
438
435
  if (status === 408 || status === 504) {
439
436
  return new CLIError(`Request timed out (HTTP ${status}).`, ExitCode.TIMEOUT, "Try increasing --timeout or retry later.");
440
437
  }
438
+ if (status === 422 && url?.includes("/speech_to_text")) {
439
+ return new CLIError(`Input audio flagged by sensitivity filter${apiMsg ? ` (${apiMsg})` : ""}.`, ExitCode.CONTENT_FILTER);
440
+ }
441
+ if (status === 413 && url?.includes("/speech_to_text")) {
442
+ return new CLIError(`Audio file exceeds the speech-to-text size limit (HTTP 413). ${apiMsg}`, ExitCode.USAGE, "Re-encode to compressed mono audio (e.g. mp3 / aac) or split it into smaller files.");
443
+ }
441
444
  const isV2ContentFilter = status === 422 && errorType === "unprocessable_entity_error" && (/sensitive content/i.test(apiMsg) || /(?:^|\D)1026(?:\D|$)/.test(apiMsg));
442
- if (apiCode === 1002 || apiCode === 1039 || isV2ContentFilter) {
445
+ if (apiCode === 1002 || apiCode === 1039 || apiCode === 1026 || isV2ContentFilter) {
443
446
  const filterType = body.base_resp?.status_msg || body.error?.message || "content sensitivity";
444
447
  return new CLIError(`Input content flagged by sensitivity filter (${filterType}).`, ExitCode.CONTENT_FILTER);
445
448
  }
@@ -453,6 +456,9 @@ Upgrade plan: ${upgradeUrl(url)}`);
453
456
  return new CLIError(`This model is not available on your current Token Plan. ${apiMsg}`, ExitCode.QUOTA, `Check usage: mmx quota show${hint}
454
457
  Upgrade plan: ${upgradeUrl(url)}`);
455
458
  }
459
+ if (apiCode === 1027 || /output.*sensitive/i.test(apiMsg)) {
460
+ return new CLIError(`Output withheld by content moderation (${apiMsg}).`, ExitCode.CONTENT_FILTER, "Refine your query and try again.");
461
+ }
456
462
  return new CLIError(`API error: ${apiMsg} (HTTP ${status})`, ExitCode.GENERAL);
457
463
  }
458
464
 
@@ -809,6 +815,9 @@ function chatEndpoint(baseUrl) {
809
815
  function speechEndpoint(baseUrl) {
810
816
  return `${baseUrl}/v1/t2a_v2`;
811
817
  }
818
+ function speechToTextEndpoint(baseUrl) {
819
+ return `${baseUrl}/v1/speech_to_text`;
820
+ }
812
821
  function voicesEndpoint(baseUrl) {
813
822
  return `${baseUrl}/v1/get_voice`;
814
823
  }
@@ -884,8 +893,8 @@ class TextSDK extends Client {
884
893
  }
885
894
  yield* this.streamSSE(res);
886
895
  }
887
- async chat(request2) {
888
- const body = this.validateParams(request2);
896
+ async chat(request) {
897
+ const body = this.validateParams(request);
889
898
  const url = chatEndpoint(this.config.baseUrl);
890
899
  if (body.stream) {
891
900
  return this.chatStream(body);
@@ -910,8 +919,8 @@ class TextSDK extends Client {
910
919
  }
911
920
 
912
921
  // src/sdk/speech/index.ts
913
- import { existsSync as existsSync2, mkdirSync, writeFileSync as writeFileSync2 } from "node:fs";
914
- import { resolve, dirname } from "node:path";
922
+ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, statSync, writeFileSync as writeFileSync2 } from "node:fs";
923
+ import { basename, resolve, dirname } from "node:path";
915
924
 
916
925
  // src/command.ts
917
926
  function defineCommand(spec) {
@@ -1112,6 +1121,76 @@ function toMerged(target, source) {
1112
1121
  }
1113
1122
  });
1114
1123
  }
1124
+ // src/utils/stt.ts
1125
+ var STT_DEFAULT_MODEL = "asr-1.0";
1126
+ var STT_RESPONSE_FORMATS = [
1127
+ "json",
1128
+ "verbose_json",
1129
+ "srt",
1130
+ "vtt"
1131
+ ];
1132
+ var STT_SUBTITLE_FORMATS = ["srt", "vtt"];
1133
+ var STT_STREAM_FORMAT = "json";
1134
+ var STT_MAX_FILE_BYTES = 50 * 1024 * 1024;
1135
+ function isSubtitleFormat(format) {
1136
+ return STT_SUBTITLE_FORMATS.includes(format);
1137
+ }
1138
+ function sttFormFields({
1139
+ model,
1140
+ response_format,
1141
+ timestamp_level,
1142
+ stream
1143
+ }) {
1144
+ const fields = {
1145
+ model: model ?? STT_DEFAULT_MODEL,
1146
+ response_format: response_format ?? STT_STREAM_FORMAT
1147
+ };
1148
+ if (timestamp_level)
1149
+ fields.timestamp_level = timestamp_level;
1150
+ if (stream)
1151
+ fields.stream = "true";
1152
+ return fields;
1153
+ }
1154
+ function validateSttResponseFormat(format, errorCtor = CLIError) {
1155
+ if (!STT_RESPONSE_FORMATS.includes(format)) {
1156
+ throw new errorCtor(`Invalid response format "${format}". Supported: ${STT_RESPONSE_FORMATS.join(", ")}`, ExitCode.USAGE);
1157
+ }
1158
+ }
1159
+ function validateSttStreaming(responseFormat, stream, errorCtor = CLIError) {
1160
+ if (stream && responseFormat !== STT_STREAM_FORMAT) {
1161
+ throw new errorCtor(`response_format "${responseFormat}" cannot be combined with stream=true; streaming returns incremental json only.`, ExitCode.USAGE);
1162
+ }
1163
+ }
1164
+ function validateSttFileSize(source, sizeBytes, errorCtor = CLIError) {
1165
+ if (sizeBytes > STT_MAX_FILE_BYTES) {
1166
+ throw new errorCtor(`Audio file is ${(sizeBytes / 1024 / 1024).toFixed(1)} MB; speech-to-text allows at most ${STT_MAX_FILE_BYTES / 1024 / 1024} MB: ${source}`, ExitCode.USAGE, "Re-encode to compressed mono audio (e.g. mp3 / aac) or split it into smaller files.");
1167
+ }
1168
+ }
1169
+ async function submitSttForm({
1170
+ config,
1171
+ url,
1172
+ form,
1173
+ headers,
1174
+ responseFormat,
1175
+ stream
1176
+ }) {
1177
+ if (stream) {
1178
+ const res = await request(config, { url, method: "POST", body: form, headers, stream: true });
1179
+ return { kind: "stream", res };
1180
+ }
1181
+ if (isSubtitleFormat(responseFormat)) {
1182
+ const res = await request(config, { url, method: "POST", body: form, headers });
1183
+ return { kind: "subtitle", document: await res.text() };
1184
+ }
1185
+ const response = await requestJson(config, {
1186
+ url,
1187
+ method: "POST",
1188
+ body: form,
1189
+ headers
1190
+ });
1191
+ return { kind: "json", response };
1192
+ }
1193
+
1115
1194
  // src/sdk/speech/index.ts
1116
1195
  function hexToBuffer(hex) {
1117
1196
  if (!/^[0-9a-fA-F]*$/.test(hex)) {
@@ -1126,10 +1205,27 @@ function defaultFilename(prefix, ext) {
1126
1205
  const ts = new Date().toISOString().slice(0, 19).replace(/[T:]/g, "-");
1127
1206
  return `${prefix}_${ts}.${ext}`;
1128
1207
  }
1208
+ function blobFilename(file) {
1209
+ const name = file.name;
1210
+ return typeof name === "string" && name ? name : "audio";
1211
+ }
1212
+ function prepareAudioUpload(file) {
1213
+ if (typeof file === "string") {
1214
+ const fullPath = resolve(file);
1215
+ if (!existsSync2(fullPath)) {
1216
+ throw new SDKError(`File not found: ${fullPath}`, ExitCode.USAGE);
1217
+ }
1218
+ validateSttFileSize(fullPath, statSync(fullPath).size, SDKError);
1219
+ return { blob: new Blob([readFileSync2(fullPath)]), filename: basename(fullPath) };
1220
+ }
1221
+ const filename = blobFilename(file);
1222
+ validateSttFileSize(filename, file.size, SDKError);
1223
+ return { blob: file, filename };
1224
+ }
1129
1225
 
1130
1226
  class SpeechSDK extends Client {
1131
- async synthesize(request2) {
1132
- const body = this.validateParams(request2);
1227
+ async synthesize(request) {
1228
+ const body = this.validateParams(request);
1133
1229
  const url = speechEndpoint(this.config.baseUrl);
1134
1230
  if (body.stream) {
1135
1231
  return this.synthesizeStream(body, url);
@@ -1164,6 +1260,54 @@ class SpeechSDK extends Client {
1164
1260
  }
1165
1261
  return voices;
1166
1262
  }
1263
+ async transcribe(params) {
1264
+ const { file, language, model, response_format, timestamp_level, stream } = params;
1265
+ if (!file) {
1266
+ throw new SDKError("file is required", ExitCode.USAGE);
1267
+ }
1268
+ const responseFormat = this.validateTranscribeFormat(response_format, stream === true);
1269
+ const { blob, filename } = prepareAudioUpload(file);
1270
+ const form = new FormData;
1271
+ for (const [field, value] of Object.entries(sttFormFields({ model, response_format: responseFormat, timestamp_level, stream }))) {
1272
+ form.append(field, value);
1273
+ }
1274
+ form.append("file", blob, filename);
1275
+ const url = speechToTextEndpoint(this.config.baseUrl);
1276
+ const headers = {};
1277
+ if (language)
1278
+ headers.language = language;
1279
+ const submission = await submitSttForm({
1280
+ config: this.config,
1281
+ url,
1282
+ form,
1283
+ headers,
1284
+ responseFormat,
1285
+ stream: stream === true
1286
+ });
1287
+ if (submission.kind === "stream")
1288
+ return this.transcribeStream(submission.res);
1289
+ if (submission.kind === "subtitle")
1290
+ return submission.document;
1291
+ return submission.response;
1292
+ }
1293
+ async* transcribeStream(res) {
1294
+ try {
1295
+ const contentType = res.headers.get("content-type") || "";
1296
+ if (contentType.split(";", 1)[0].trim().toLowerCase() !== "text/event-stream") {
1297
+ throw new SDKError(`Expected SSE stream but got content-type "${contentType}". Server may be experiencing issues.`, ExitCode.GENERAL);
1298
+ }
1299
+ for await (const event of this.streamSSE(res)) {
1300
+ yield event;
1301
+ if (event.finish)
1302
+ return;
1303
+ }
1304
+ throw new SDKError("Stream ended before the final event; the transcript may be incomplete.", ExitCode.GENERAL);
1305
+ } finally {
1306
+ await res.body?.cancel().catch(() => {
1307
+ return;
1308
+ });
1309
+ }
1310
+ }
1167
1311
  save(response, outPath, ext = "mp3") {
1168
1312
  const dest = resolve(outPath || defaultFilename("speech", ext));
1169
1313
  const audioHex = response.data.audio;
@@ -1201,6 +1345,12 @@ class SpeechSDK extends Client {
1201
1345
  output_format: "hex"
1202
1346
  }, params);
1203
1347
  }
1348
+ validateTranscribeFormat(responseFormat, stream) {
1349
+ const resolved = responseFormat ?? "json";
1350
+ validateSttResponseFormat(resolved, SDKError);
1351
+ validateSttStreaming(resolved, stream, SDKError);
1352
+ return resolved;
1353
+ }
1204
1354
  }
1205
1355
 
1206
1356
  // src/sdk/image/index.ts
@@ -1333,10 +1483,10 @@ async function waitForDelay(delayMs, signal) {
1333
1483
  throw abortReason(signal, "Download aborted.");
1334
1484
  if (delayMs <= 0)
1335
1485
  return;
1336
- await new Promise((resolve2, reject) => {
1486
+ await new Promise((resolve, reject) => {
1337
1487
  const timer = setTimeout(() => {
1338
1488
  signal.removeEventListener("abort", onAbort);
1339
- resolve2();
1489
+ resolve();
1340
1490
  }, delayMs);
1341
1491
  const onAbort = () => {
1342
1492
  clearTimeout(timer);
@@ -1377,8 +1527,8 @@ async function withIdleTimeout2(operation, controller, idleTimeoutMs, phase, ret
1377
1527
  }
1378
1528
  }
1379
1529
  async function waitForDrain(writer, controller, idleTimeoutMs) {
1380
- const drain = new Promise((resolve2, reject) => {
1381
- const onDrain = () => finish(resolve2);
1530
+ const drain = new Promise((resolve, reject) => {
1531
+ const onDrain = () => finish(resolve);
1382
1532
  const onError = (error) => finish(() => reject(error));
1383
1533
  const onClose = () => finish(() => reject(new Error("File writer closed before draining.")));
1384
1534
  const finish = (done) => {
@@ -1400,8 +1550,8 @@ async function waitForDrain(writer, controller, idleTimeoutMs) {
1400
1550
  }
1401
1551
  }
1402
1552
  async function finishWriter(writer, controller, idleTimeoutMs) {
1403
- const finished = new Promise((resolve2, reject) => {
1404
- const onFinish = () => finish(resolve2);
1553
+ const finished = new Promise((resolve, reject) => {
1554
+ const onFinish = () => finish(resolve);
1405
1555
  const onError = (error) => finish(() => reject(error));
1406
1556
  const onClose = () => {
1407
1557
  if (!writer.writableFinished)
@@ -1429,14 +1579,14 @@ async function finishWriter(writer, controller, idleTimeoutMs) {
1429
1579
  async function destroyWriter(writer) {
1430
1580
  if (writer.closed)
1431
1581
  return;
1432
- await new Promise((resolve2) => {
1582
+ await new Promise((resolve) => {
1433
1583
  const timer = setTimeout(() => {
1434
1584
  writer.off("close", onClose);
1435
- resolve2();
1585
+ resolve();
1436
1586
  }, CLEANUP_TIMEOUT_MS);
1437
1587
  const onClose = () => {
1438
1588
  clearTimeout(timer);
1439
- resolve2();
1589
+ resolve();
1440
1590
  };
1441
1591
  writer.once("close", onClose);
1442
1592
  writer.destroy();
@@ -1448,8 +1598,8 @@ async function settleCleanup(operation) {
1448
1598
  operation.catch(() => {
1449
1599
  return;
1450
1600
  }),
1451
- new Promise((resolve2) => {
1452
- timer = setTimeout(resolve2, CLEANUP_TIMEOUT_MS);
1601
+ new Promise((resolve) => {
1602
+ timer = setTimeout(resolve, CLEANUP_TIMEOUT_MS);
1453
1603
  })
1454
1604
  ]);
1455
1605
  if (timer)
@@ -1624,8 +1774,8 @@ async function downloadFile(url, destPath, opts) {
1624
1774
 
1625
1775
  // src/sdk/image/index.ts
1626
1776
  class ImageSDK extends Client {
1627
- async generate(request2) {
1628
- const body = this.validateParams(request2);
1777
+ async generate(request) {
1778
+ const body = this.validateParams(request);
1629
1779
  const url = imageEndpoint(this.config.baseUrl);
1630
1780
  return await this.requestJson({
1631
1781
  url,
@@ -1776,8 +1926,8 @@ class VideoV2InputError extends Error {
1776
1926
  function isVideoV2Model(model) {
1777
1927
  return model === VIDEO_V2_MODEL;
1778
1928
  }
1779
- function isVideoV2Request(request2) {
1780
- return isVideoV2Model(request2.model);
1929
+ function isVideoV2Request(request) {
1930
+ return isVideoV2Model(request.model);
1781
1931
  }
1782
1932
  function getVideoV2FailureReason(task) {
1783
1933
  const code = task.error?.code?.trim();
@@ -1811,7 +1961,7 @@ function buildVideoV2Request(options) {
1811
1961
  ];
1812
1962
  const hasFrameInput = content.some((item) => item.type === "image_url" && (item.role === "first_frame" || item.role === "last_frame"));
1813
1963
  const hasReferenceInput = content.some((item) => item.type !== "text" && item.role?.startsWith("reference_"));
1814
- const request2 = {
1964
+ const request = {
1815
1965
  model: VIDEO_V2_MODEL,
1816
1966
  content,
1817
1967
  resolution: options.resolution ?? "2K",
@@ -1819,33 +1969,33 @@ function buildVideoV2Request(options) {
1819
1969
  ratio: hasFrameInput ? "adaptive" : options.ratio ?? (hasReferenceInput ? "adaptive" : "16:9")
1820
1970
  };
1821
1971
  if (options.callbackUrl)
1822
- request2.callback_url = options.callbackUrl;
1823
- validateVideoV2Request(request2);
1824
- return request2;
1972
+ request.callback_url = options.callbackUrl;
1973
+ validateVideoV2Request(request);
1974
+ return request;
1825
1975
  }
1826
- function validateVideoV2Request(request2) {
1827
- if (!isVideoV2Model(request2.model)) {
1976
+ function validateVideoV2Request(request) {
1977
+ if (!isVideoV2Model(request.model)) {
1828
1978
  throw new VideoV2InputError(`Video Generation V2 only supports ${VIDEO_V2_MODEL}.`);
1829
1979
  }
1830
- const textItems = request2.content.filter((item) => item.type === "text");
1980
+ const textItems = request.content.filter((item) => item.type === "text");
1831
1981
  if (!textItems.some((item) => item.text.trim().length > 0)) {
1832
1982
  throw new VideoV2InputError("MiniMax-H3 requires a non-empty text content item.");
1833
1983
  }
1834
1984
  if (textItems.some((item) => item.text.length > 7000)) {
1835
1985
  throw new VideoV2InputError("MiniMax-H3 text content must not exceed 7000 characters.");
1836
1986
  }
1837
- if (request2.resolution !== "2K") {
1987
+ if (request.resolution !== "2K") {
1838
1988
  throw new VideoV2InputError("MiniMax-H3 currently only supports 2K resolution.");
1839
1989
  }
1840
- if (!Number.isInteger(request2.duration) || request2.duration < 4 || request2.duration > 15) {
1990
+ if (!Number.isInteger(request.duration) || request.duration < 4 || request.duration > 15) {
1841
1991
  throw new VideoV2InputError("MiniMax-H3 duration must be an integer from 4 to 15 seconds.");
1842
1992
  }
1843
- if (request2.ratio && !VIDEO_V2_RATIOS.has(request2.ratio)) {
1993
+ if (request.ratio && !VIDEO_V2_RATIOS.has(request.ratio)) {
1844
1994
  throw new VideoV2InputError("MiniMax-H3 ratio must be one of: adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16.");
1845
1995
  }
1846
- const images = request2.content.filter((item) => item.type === "image_url");
1847
- const videos = request2.content.filter((item) => item.type === "video_url");
1848
- const audios = request2.content.filter((item) => item.type === "audio_url");
1996
+ const images = request.content.filter((item) => item.type === "image_url");
1997
+ const videos = request.content.filter((item) => item.type === "video_url");
1998
+ const audios = request.content.filter((item) => item.type === "audio_url");
1849
1999
  if (images.some((item) => item.role && !VIDEO_V2_IMAGE_ROLES.has(item.role))) {
1850
2000
  throw new VideoV2InputError("MiniMax-H3 image role must be one of: first_frame, last_frame, reference_image.");
1851
2001
  }
@@ -1864,7 +2014,7 @@ function validateVideoV2Request(request2) {
1864
2014
  for (const audio of audios) {
1865
2015
  validateDataUriSize(audio.audio_url.url, "audio");
1866
2016
  }
1867
- const requestBodyBytes = Buffer.byteLength(JSON.stringify(request2));
2017
+ const requestBodyBytes = Buffer.byteLength(JSON.stringify(request));
1868
2018
  if (requestBodyBytes > VIDEO_V2_MAX_REQUEST_BODY_BYTES) {
1869
2019
  throw new VideoV2InputError(`MiniMax-H3 request body is ${(requestBodyBytes / 1024 / 1024).toFixed(1)} MB; the maximum is 64 MB. Use public URLs or mm_file:// file IDs instead of Base64.`);
1870
2020
  }
@@ -1885,8 +2035,8 @@ function validateVideoV2Request(request2) {
1885
2035
  if (audios.length > 0 && referenceImages.length === 0 && videos.length === 0) {
1886
2036
  throw new VideoV2InputError("MiniMax-H3 reference audio requires at least one reference image or reference video.");
1887
2037
  }
1888
- const isTextOnly = request2.content.every((item) => item.type === "text");
1889
- if (isTextOnly && (!request2.ratio || request2.ratio === "adaptive")) {
2038
+ const isTextOnly = request.content.every((item) => item.type === "text");
2039
+ if (isTextOnly && (!request.ratio || request.ratio === "adaptive")) {
1890
2040
  throw new VideoV2InputError("MiniMax-H3 text-to-video requires a concrete ratio; adaptive is not supported.");
1891
2041
  }
1892
2042
  }
@@ -1900,8 +2050,8 @@ function validateDataUriSize(url, kind) {
1900
2050
 
1901
2051
  // src/sdk/video/index.ts
1902
2052
  class VideoSDK extends Client {
1903
- async generate(request2) {
1904
- const body = this.validateParams(request2);
2053
+ async generate(request) {
2054
+ const body = this.validateParams(request);
1905
2055
  const usesV2 = isVideoV2Request(body);
1906
2056
  const url = usesV2 ? videoGenerateV2Endpoint(this.config.baseUrl) : videoGenerateEndpoint(this.config.baseUrl);
1907
2057
  const res = await this.requestJson({
@@ -1910,15 +2060,15 @@ class VideoSDK extends Client {
1910
2060
  body
1911
2061
  });
1912
2062
  const taskId = res.task_id;
1913
- if (request2.async) {
2063
+ if (request.async) {
1914
2064
  return { taskId };
1915
2065
  }
1916
2066
  if (usesV2) {
1917
- const taskUrl2 = videoTaskV2Endpoint(this.config.baseUrl, taskId);
2067
+ const taskUrl = videoTaskV2Endpoint(this.config.baseUrl, taskId);
1918
2068
  const result = await poll(this.config, {
1919
- url: taskUrl2,
1920
- intervalSec: request2.pollInterval ?? 5,
1921
- timeoutSec: request2.timeout ?? this.config.timeout,
2069
+ url: taskUrl,
2070
+ intervalSec: request.pollInterval ?? 5,
2071
+ timeoutSec: request.timeout ?? this.config.timeout,
1922
2072
  isComplete: (d) => d.task.status === "succeeded",
1923
2073
  isFailed: (d) => ["failed", "cancelled", "expired"].includes(d.task.status),
1924
2074
  getStatus: (d) => d.task.status,
@@ -1929,8 +2079,8 @@ class VideoSDK extends Client {
1929
2079
  const taskUrl = videoTaskEndpoint(this.config.baseUrl, taskId);
1930
2080
  return await poll(this.config, {
1931
2081
  url: taskUrl,
1932
- intervalSec: request2.pollInterval ?? 5,
1933
- timeoutSec: request2.timeout ?? this.config.timeout,
2082
+ intervalSec: request.pollInterval ?? 5,
2083
+ timeoutSec: request.timeout ?? this.config.timeout,
1934
2084
  isComplete: (d) => d.status === "Success",
1935
2085
  isFailed: (d) => d.status === "Failed",
1936
2086
  getStatus: (d) => d.status
@@ -1938,29 +2088,29 @@ class VideoSDK extends Client {
1938
2088
  }
1939
2089
  async getTask({ taskId, model }) {
1940
2090
  if (isVideoV2Model(model)) {
1941
- const url2 = videoTaskV2Endpoint(this.config.baseUrl, taskId);
1942
- const result = await this.requestJson({ url: url2 });
2091
+ const url = videoTaskV2Endpoint(this.config.baseUrl, taskId);
2092
+ const result = await this.requestJson({ url });
1943
2093
  return result.task;
1944
2094
  }
1945
2095
  const url = videoTaskEndpoint(this.config.baseUrl, taskId);
1946
2096
  return await this.requestJson({ url });
1947
2097
  }
1948
- async download(request2) {
1949
- const url = fileRetrieveEndpoint(this.config.baseUrl, request2.fileId);
2098
+ async download(request) {
2099
+ const url = fileRetrieveEndpoint(this.config.baseUrl, request.fileId);
1950
2100
  const fileInfo = await this.requestJson({ url });
1951
2101
  const downloadUrl = fileInfo.file?.download_url;
1952
2102
  if (!downloadUrl) {
1953
2103
  throw new SDKError("No download URL available for this file.", ExitCode.GENERAL);
1954
2104
  }
1955
- const { size } = await downloadFile(downloadUrl, request2.outPath, { quiet: true });
2105
+ const { size } = await downloadFile(downloadUrl, request.outPath, { quiet: true });
1956
2106
  return {
1957
2107
  size,
1958
- save: request2.outPath,
2108
+ save: request.outPath,
1959
2109
  downloadUrl
1960
2110
  };
1961
2111
  }
1962
- validateParams(request2) {
1963
- const params = { ...request2 };
2112
+ validateParams(request) {
2113
+ const params = { ...request };
1964
2114
  delete params.async;
1965
2115
  delete params.pollInterval;
1966
2116
  delete params.timeout;
@@ -1992,15 +2142,15 @@ class VideoSDK extends Client {
1992
2142
  validateVideoV2Request(body);
1993
2143
  return body;
1994
2144
  }
1995
- const prompt2 = params.prompt;
1996
- if (!prompt2) {
2145
+ const prompt = params.prompt;
2146
+ if (!prompt) {
1997
2147
  throw new VideoV2InputError("prompt or content is required");
1998
2148
  }
1999
2149
  if (params.subject_reference !== undefined) {
2000
2150
  throw new VideoV2InputError("subject_reference is only supported by legacy video models. Use content with role reference_image for MiniMax-H3.");
2001
2151
  }
2002
2152
  return buildVideoV2Request({
2003
- prompt: prompt2,
2153
+ prompt,
2004
2154
  images: [
2005
2155
  ...params.first_frame_image ? [{ url: params.first_frame_image, role: "first_frame" }] : [],
2006
2156
  ...params.last_frame_image ? [{ url: params.last_frame_image, role: "last_frame" }] : []
@@ -2064,7 +2214,7 @@ class SearchSDK extends Client {
2064
2214
  }
2065
2215
 
2066
2216
  // src/utils/image.ts
2067
- import { readFileSync as readFileSync2, existsSync as existsSync4, statSync } from "fs";
2217
+ import { readFileSync as readFileSync3, existsSync as existsSync4, statSync as statSync2 } from "fs";
2068
2218
  import { extname } from "path";
2069
2219
  var IMAGE_MIME_TYPES = {
2070
2220
  ".jpg": "image/jpeg",
@@ -2076,14 +2226,14 @@ var IMAGE_MIME_TYPES = {
2076
2226
  };
2077
2227
  function localFileToDataUri(filePath, maxBytes) {
2078
2228
  if (maxBytes !== undefined) {
2079
- const size = statSync(filePath).size;
2229
+ const size = statSync2(filePath).size;
2080
2230
  if (size > maxBytes) {
2081
2231
  throw new CLIError(`Image file is ${(size / 1024 / 1024).toFixed(1)} MB; MiniMax-H3 allows at most ${maxBytes / 1024 / 1024} MB.`, ExitCode.USAGE, "Use a public URL or mm_file:// file ID for large images.");
2082
2232
  }
2083
2233
  }
2084
2234
  const ext = extname(filePath).toLowerCase();
2085
2235
  const mime = IMAGE_MIME_TYPES[ext] || "image/jpeg";
2086
- const data = readFileSync2(filePath);
2236
+ const data = readFileSync3(filePath);
2087
2237
  return `data:${mime};base64,${data.toString("base64")}`;
2088
2238
  }
2089
2239
  var MAX_IMAGE_SIZE_BYTES = 50 * 1024 * 1024;
@@ -2112,10 +2262,10 @@ async function toDataUri(image) {
2112
2262
 
2113
2263
  // src/sdk/vision/index.ts
2114
2264
  class VisionSDK extends Client {
2115
- async describe(request2) {
2265
+ async describe(request) {
2116
2266
  const body = {
2117
- prompt: request2.prompt || "Describe the image.",
2118
- image_url: await toDataUri(request2.image)
2267
+ prompt: request.prompt || "Describe the image.",
2268
+ image_url: await toDataUri(request.image)
2119
2269
  };
2120
2270
  const url = vlmEndpoint(this.config.baseUrl);
2121
2271
  const res = await this.requestJson({
@@ -2149,7 +2299,7 @@ class QuotaSDK extends Client {
2149
2299
  // src/files/upload.ts
2150
2300
  import { existsSync as existsSync5 } from "node:fs";
2151
2301
  import { readFile } from "node:fs/promises";
2152
- import { basename, resolve as resolve3 } from "node:path";
2302
+ import { basename as basename2, resolve as resolve3 } from "node:path";
2153
2303
  function resolveFileUploadPath(filePath, createFileNotFoundError) {
2154
2304
  const fullPath = resolve3(filePath);
2155
2305
  if (!existsSync5(fullPath)) {
@@ -2161,15 +2311,15 @@ async function uploadFile({
2161
2311
  filePath,
2162
2312
  purpose,
2163
2313
  baseUrl,
2164
- requestJson: requestJson2,
2314
+ requestJson,
2165
2315
  createFileNotFoundError
2166
2316
  }) {
2167
2317
  const fullPath = resolveFileUploadPath(filePath, createFileNotFoundError);
2168
2318
  const fileData = await readFile(fullPath);
2169
2319
  const formData = new FormData;
2170
- formData.append("file", new Blob([fileData]), basename(fullPath));
2320
+ formData.append("file", new Blob([fileData]), basename2(fullPath));
2171
2321
  formData.append("purpose", purpose);
2172
- return requestJson2({
2322
+ return requestJson({
2173
2323
  url: fileUploadEndpoint(baseUrl),
2174
2324
  method: "POST",
2175
2325
  body: formData
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mmx-cli",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "CLI for the MiniMax AI Platform",
5
5
  "type": "module",
6
6
  "repository": {