mmx-cli 1.0.12 → 1.0.14

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/README.md CHANGED
@@ -45,7 +45,10 @@ npm install -g mmx-cli
45
45
  ## Quick Start
46
46
 
47
47
  ```bash
48
- # Authenticate
48
+ # Authenticate (interactive — choose MiniMax OAuth or paste an API key)
49
+ mmx auth login
50
+
51
+ # Or non-interactive
49
52
  mmx auth login --api-key sk-xxxxx
50
53
 
51
54
  # Start creating
@@ -130,16 +133,21 @@ mmx search query --q "latest news" --output json
130
133
  ### `mmx auth`
131
134
 
132
135
  ```bash
133
- mmx auth login --api-key sk-xxxxx
134
- mmx auth login # OAuth browser flow
136
+ mmx auth login # interactive: pick OAuth (Global / China) or paste an API key
137
+ mmx auth login --api-key sk-xxxxx # save an API key directly
138
+ mmx auth login --recommend # skip the menu, pick OAuth region interactively
139
+ mmx auth login --recommend --region=global # OAuth → api.minimax.io
140
+ mmx auth login --recommend --region=cn # OAuth → api.minimaxi.com
135
141
  mmx auth status
136
142
  mmx auth refresh
137
143
  mmx auth logout
138
144
  ```
139
145
 
140
146
  `mmx auth status` is the canonical way to verify active authentication.
141
- `~/.mmx/credentials.json` exists only for OAuth login. API-key login persists to
142
- `~/.mmx/config.json` (and `--api-key` can also be passed per command).
147
+ Both OAuth and API-key credentials live in `~/.mmx/config.json` (the two are
148
+ mutually exclusive — logging in with one method clears the other). API keys
149
+ can also be passed per command via `--api-key`. With an API key, the region
150
+ is auto-detected by probing both Global and CN.
143
151
 
144
152
  ### `mmx config` · `mmx quota`
145
153
 
@@ -0,0 +1,520 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ declare const REGIONS: {
4
+ readonly global: "https://api.minimax.io";
5
+ readonly cn: "https://api.minimaxi.com";
6
+ };
7
+ export type Region = keyof typeof REGIONS;
8
+ export interface Config {
9
+ apiKey?: string;
10
+ fileApiKey?: string;
11
+ fileRegion?: Region;
12
+ configPath?: string;
13
+ region: Region;
14
+ baseUrl: string;
15
+ output: "text" | "json";
16
+ timeout: number;
17
+ defaultTextModel?: string;
18
+ defaultSpeechModel?: string;
19
+ defaultVideoModel?: string;
20
+ defaultMusicModel?: string;
21
+ verbose: boolean;
22
+ quiet: boolean;
23
+ noColor: boolean;
24
+ yes: boolean;
25
+ dryRun: boolean;
26
+ nonInteractive: boolean;
27
+ async: boolean;
28
+ needsRegionDetection?: boolean;
29
+ }
30
+ export interface RequestOpts {
31
+ url: string;
32
+ method?: string;
33
+ body?: unknown;
34
+ headers?: Record<string, string>;
35
+ timeout?: number;
36
+ stream?: boolean;
37
+ noAuth?: boolean;
38
+ authStyle?: "bearer" | "x-api-key";
39
+ }
40
+ export interface MiniMaxSDKOptions {
41
+ apiKey?: string;
42
+ baseUrl?: string;
43
+ region?: Region;
44
+ }
45
+ export type ModelPartial<T> = "model" extends keyof T ? Omit<T, "model"> & {
46
+ model?: T["model"];
47
+ } : T;
48
+ declare class Client {
49
+ protected config: Config;
50
+ constructor(options: MiniMaxSDKOptions);
51
+ protected request(opts: RequestOpts): Promise<Response>;
52
+ protected requestJson<T>(opts: RequestOpts): Promise<T>;
53
+ protected streamSSE<T>(res: Response): AsyncGenerator<T>;
54
+ }
55
+ export type ContentBlock = {
56
+ type: "text";
57
+ text: string;
58
+ } | {
59
+ type: "thinking";
60
+ thinking: string;
61
+ } | {
62
+ type: "tool_use";
63
+ id: string;
64
+ name: string;
65
+ input: Record<string, unknown>;
66
+ } | {
67
+ type: "tool_result";
68
+ tool_use_id: string;
69
+ content: string;
70
+ };
71
+ export interface ChatMessage {
72
+ role: "user" | "assistant";
73
+ content: string | ContentBlock[];
74
+ }
75
+ export interface ChatTool {
76
+ name: string;
77
+ description?: string;
78
+ input_schema: Record<string, unknown>;
79
+ }
80
+ export interface ChatRequest {
81
+ model: string;
82
+ messages: ChatMessage[];
83
+ max_tokens: number;
84
+ system?: string;
85
+ temperature?: number;
86
+ top_p?: number;
87
+ stream?: boolean;
88
+ tools?: ChatTool[];
89
+ tool_choice?: {
90
+ type: "auto" | "any" | "tool";
91
+ name?: string;
92
+ };
93
+ }
94
+ export interface ChatResponse {
95
+ id: string;
96
+ type: "message";
97
+ role: "assistant";
98
+ content: ContentBlock[];
99
+ model: string;
100
+ stop_reason: string;
101
+ usage: {
102
+ input_tokens: number;
103
+ output_tokens: number;
104
+ };
105
+ }
106
+ export interface StreamMessageStart {
107
+ type: "message_start";
108
+ message: ChatResponse;
109
+ }
110
+ export interface StreamContentBlockStart {
111
+ type: "content_block_start";
112
+ index: number;
113
+ content_block: ContentBlock;
114
+ }
115
+ export interface StreamContentBlockDelta {
116
+ type: "content_block_delta";
117
+ index: number;
118
+ delta: {
119
+ type: "text_delta";
120
+ text: string;
121
+ } | {
122
+ type: "thinking_delta";
123
+ thinking: string;
124
+ } | {
125
+ type: "input_json_delta";
126
+ partial_json: string;
127
+ };
128
+ }
129
+ export interface StreamContentBlockStop {
130
+ type: "content_block_stop";
131
+ index: number;
132
+ }
133
+ export interface StreamMessageDelta {
134
+ type: "message_delta";
135
+ delta: {
136
+ stop_reason: string;
137
+ };
138
+ usage: {
139
+ output_tokens: number;
140
+ };
141
+ }
142
+ export interface StreamMessageStop {
143
+ type: "message_stop";
144
+ }
145
+ export type StreamEvent = StreamMessageStart | StreamContentBlockStart | StreamContentBlockDelta | StreamContentBlockStop | StreamMessageDelta | StreamMessageStop;
146
+ export interface SpeechRequest {
147
+ model: string;
148
+ text: string;
149
+ voice_setting?: {
150
+ voice_id?: string;
151
+ speed?: number;
152
+ vol?: number;
153
+ pitch?: number;
154
+ };
155
+ audio_setting?: {
156
+ format?: string;
157
+ sample_rate?: number;
158
+ bitrate?: number;
159
+ channel?: number;
160
+ };
161
+ language_boost?: string;
162
+ pronunciation_dict?: Array<{
163
+ tone: string;
164
+ text: string;
165
+ }>;
166
+ output_format?: "url" | "hex";
167
+ stream?: boolean;
168
+ subtitle_enable?: boolean;
169
+ }
170
+ export interface SpeechResponse {
171
+ base_resp: BaseResp;
172
+ data: {
173
+ audio?: string;
174
+ audio_url?: string;
175
+ subtitle_file?: string;
176
+ status: number;
177
+ };
178
+ extra_info?: {
179
+ audio_length?: number;
180
+ audio_sample_rate?: number;
181
+ audio_size?: number;
182
+ bitrate?: number;
183
+ word_count?: number;
184
+ invisible_character_ratio?: number;
185
+ };
186
+ }
187
+ export interface SystemVoiceInfo {
188
+ voice_id: string;
189
+ voice_name: string;
190
+ description: string[];
191
+ }
192
+ export interface ImageRequest {
193
+ model: string;
194
+ prompt: string;
195
+ aspect_ratio?: string;
196
+ n?: number;
197
+ seed?: number;
198
+ width?: number;
199
+ height?: number;
200
+ prompt_optimizer?: boolean;
201
+ aigc_watermark?: boolean;
202
+ response_format?: "url" | "base64";
203
+ subject_reference?: Array<{
204
+ type: string;
205
+ image_url?: string;
206
+ image_file?: string;
207
+ }>;
208
+ }
209
+ export interface ImageResponse {
210
+ base_resp: BaseResp;
211
+ data: {
212
+ image_urls?: string[];
213
+ image_base64?: string[];
214
+ task_id: string;
215
+ success_count: number;
216
+ failed_count: number;
217
+ };
218
+ }
219
+ export interface VideoRequest {
220
+ model: string;
221
+ prompt: string;
222
+ first_frame_image?: string;
223
+ last_frame_image?: string;
224
+ callback_url?: string;
225
+ subject_reference?: Array<{
226
+ type: string;
227
+ image: string[];
228
+ }>;
229
+ }
230
+ export interface VideoResponse {
231
+ base_resp: BaseResp;
232
+ task_id: string;
233
+ status: string;
234
+ }
235
+ export interface VideoTaskResponse {
236
+ base_resp: BaseResp;
237
+ task_id: string;
238
+ status: "Queueing" | "Processing" | "Success" | "Failed" | "Unknown";
239
+ file_id?: string;
240
+ video_width?: number;
241
+ video_height?: number;
242
+ }
243
+ export interface MusicRequest {
244
+ model: string;
245
+ prompt?: string;
246
+ lyrics?: string;
247
+ is_instrumental?: boolean;
248
+ lyrics_optimizer?: boolean;
249
+ audio_url?: string;
250
+ audio_base64?: string;
251
+ seed?: number;
252
+ audio_setting?: {
253
+ format?: string;
254
+ sample_rate?: number;
255
+ bitrate?: number;
256
+ channel?: number;
257
+ };
258
+ output_format?: "url" | "hex";
259
+ stream?: boolean;
260
+ aigc_watermark?: boolean;
261
+ }
262
+ export interface MusicResponse {
263
+ base_resp: BaseResp;
264
+ data: {
265
+ audio?: string;
266
+ audio_url?: string;
267
+ status: number;
268
+ };
269
+ extra_info?: {
270
+ audio_length?: number;
271
+ audio_sample_rate?: number;
272
+ audio_size?: number;
273
+ bitrate?: number;
274
+ };
275
+ }
276
+ export interface QuotaResponse {
277
+ model_remains: QuotaModelRemain[];
278
+ }
279
+ export interface QuotaModelRemain {
280
+ model_name: string;
281
+ start_time: number;
282
+ end_time: number;
283
+ remains_time: number;
284
+ current_interval_total_count: number;
285
+ current_interval_usage_count: number;
286
+ current_weekly_total_count: number;
287
+ current_weekly_usage_count: number;
288
+ weekly_start_time: number;
289
+ weekly_end_time: number;
290
+ weekly_remains_time: number;
291
+ }
292
+ export interface FileUploadResponse {
293
+ base_resp: BaseResp;
294
+ file: {
295
+ file_id: string;
296
+ bytes: number;
297
+ created_at: number;
298
+ filename: string;
299
+ purpose: string;
300
+ };
301
+ }
302
+ export interface FileListResponse {
303
+ base_resp: BaseResp;
304
+ files: Array<{
305
+ file_id: string;
306
+ bytes: number;
307
+ created_at: number;
308
+ filename: string;
309
+ purpose: string;
310
+ }>;
311
+ }
312
+ export interface FileDeleteResponse {
313
+ base_resp: BaseResp;
314
+ file_id: number;
315
+ }
316
+ export interface FileRetrieveResponse {
317
+ base_resp: BaseResp;
318
+ file: {
319
+ file_id: string;
320
+ bytes: number;
321
+ created_at: number;
322
+ filename: string;
323
+ purpose: string;
324
+ download_url?: string;
325
+ };
326
+ }
327
+ export interface BaseResp {
328
+ status_code: number;
329
+ status_msg: string;
330
+ }
331
+ declare class TextSDK extends Client {
332
+ private chatStream;
333
+ chat(request: Partial<ChatRequest> & {
334
+ stream: true;
335
+ }): Promise<AsyncGenerator<StreamEvent>>;
336
+ chat(request: Partial<ChatRequest>): Promise<ChatResponse>;
337
+ private validateParams;
338
+ }
339
+ declare class SpeechSDK extends Client {
340
+ synthesize(request: ModelPartial<SpeechRequest> & {
341
+ stream: true;
342
+ }): Promise<AsyncGenerator<SpeechResponse>>;
343
+ synthesize(request: ModelPartial<SpeechRequest>): Promise<SpeechResponse>;
344
+ private synthesizeStream;
345
+ voices(language?: string): Promise<SystemVoiceInfo[]>;
346
+ /**
347
+ * Save synthesized speech audio to a file. Decodes the hex-encoded audio
348
+ * from the API response and writes it to disk. Creates intermediate
349
+ * directories as needed.
350
+ *
351
+ * @param response — The response from `synthesize()`.
352
+ * @param outPath — Target file path. Defaults to `speech_<timestamp>.mp3`.
353
+ * @param ext — File extension (default: `"mp3"`).
354
+ * @returns The absolute path of the saved file.
355
+ */
356
+ save(response: SpeechResponse, outPath?: string, ext?: string): string;
357
+ private validateParams;
358
+ }
359
+ export interface ImageSaveOptions {
360
+ /** Save to exact file path (single image only). */
361
+ out?: string;
362
+ /** Save images to directory (default: "."). */
363
+ outDir?: string;
364
+ /** Filename prefix (default: "image"). */
365
+ prefix?: string;
366
+ /** Response format used by generate() — "url" or "base64" (default: "url"). */
367
+ responseFormat?: "url" | "base64";
368
+ /** Suppress progress output. */
369
+ quiet?: boolean;
370
+ }
371
+ declare class ImageSDK extends Client {
372
+ generate(request: ModelPartial<ImageRequest>): Promise<ImageResponse>;
373
+ /**
374
+ * Download and save images from a `generate()` response to disk.
375
+ *
376
+ * Handles both `"url"` (CDN download) and `"base64"` response formats
377
+ * and creates intermediate directories as needed. Returns the absolute
378
+ * paths of all saved files.
379
+ */
380
+ save(response: ImageResponse, options?: ImageSaveOptions): Promise<string[]>;
381
+ private validateParams;
382
+ }
383
+ export interface VideoAsyncGenerateRequest extends ModelPartial<VideoRequest> {
384
+ async?: boolean;
385
+ pollInterval?: number;
386
+ timeout?: number;
387
+ }
388
+ export interface VideoDownloadRequest {
389
+ fileId: string;
390
+ outPath: string;
391
+ }
392
+ declare class VideoSDK extends Client {
393
+ generate(request: VideoAsyncGenerateRequest & {
394
+ async: true;
395
+ }): Promise<{
396
+ taskId: string;
397
+ }>;
398
+ generate(request: ModelPartial<VideoAsyncGenerateRequest>): Promise<VideoResponse>;
399
+ getTask({ taskId }: {
400
+ taskId: string;
401
+ }): Promise<VideoTaskResponse>;
402
+ download(request: VideoDownloadRequest): Promise<{
403
+ size: number;
404
+ save: string;
405
+ downloadUrl: string;
406
+ }>;
407
+ private validateParams;
408
+ }
409
+ export interface MusicGenerateRequest extends MusicRequest {
410
+ /** Vocal style, e.g. "warm male baritone", "bright female soprano", "duet with harmonies" */
411
+ vocals?: string;
412
+ /** Music genre, e.g. folk, pop, jazz */
413
+ genre?: string;
414
+ /** Mood or emotion, e.g. warm, melancholic, uplifting */
415
+ mood?: string;
416
+ /** Instruments to feature, e.g. "acoustic guitar, piano" */
417
+ instruments?: string;
418
+ /** Tempo description, e.g. fast, slow, moderate */
419
+ tempo?: string;
420
+ /** Exact tempo in beats per minute */
421
+ bpm?: number;
422
+ /** Musical key, e.g. C major, A minor, G sharp */
423
+ key?: string;
424
+ /** Elements to avoid in the generated music */
425
+ avoid?: string;
426
+ /** Use case context, e.g. "background music for video", "theme song" */
427
+ use_case?: string;
428
+ /** Song structure, e.g. "verse-chorus-verse-bridge-chorus" */
429
+ structure?: string;
430
+ /** Reference tracks or artists, e.g. "similar to Ed Sheeran, Taylor Swift" */
431
+ references?: string;
432
+ /** Additional fine-grained requirements not covered above */
433
+ extra?: string;
434
+ /** Generate instrumental music (no vocals) */
435
+ instrumental?: boolean;
436
+ /** Use case */
437
+ useCase?: string;
438
+ }
439
+ declare class MusicSDK extends Client {
440
+ private generateStream;
441
+ generate(request: ModelPartial<MusicGenerateRequest> & {
442
+ stream: true;
443
+ }): Promise<AsyncGenerator<Uint8Array<ArrayBuffer>>>;
444
+ generate(request: ModelPartial<MusicGenerateRequest>): Promise<MusicResponse>;
445
+ /**
446
+ * Save generated music audio to a file. Decodes the hex-encoded audio
447
+ * from the API response and writes it to disk. Creates intermediate
448
+ * directories as needed.
449
+ *
450
+ * @param response — The response from `generate()`.
451
+ * @param outPath — Target file path. Defaults to `music_<timestamp>.mp3`.
452
+ * @param ext — File extension (default: `"mp3"`).
453
+ * @returns The absolute path of the saved file.
454
+ */
455
+ save(response: MusicResponse, outPath?: string, ext?: string): string;
456
+ private buildPrompt;
457
+ private validateParams;
458
+ }
459
+ export interface SearchResult {
460
+ title: string;
461
+ link: string;
462
+ snippet: string;
463
+ date: string;
464
+ }
465
+ export interface SearchResponse {
466
+ organic: SearchResult[];
467
+ }
468
+ declare class SearchSDK extends Client {
469
+ query(query: string): Promise<SearchResponse>;
470
+ }
471
+ export interface VlmResponse {
472
+ content: string;
473
+ }
474
+ export interface ImageDescribeRequest {
475
+ prompt?: string;
476
+ image: string;
477
+ }
478
+ declare class VisionSDK extends Client {
479
+ describe(request: ImageDescribeRequest): Promise<VlmResponse>;
480
+ }
481
+ declare class QuotaSDK extends Client {
482
+ info(): Promise<QuotaResponse>;
483
+ }
484
+ declare class FileSDK extends Client {
485
+ /**
486
+ * Upload a file to MiniMax storage.
487
+ *
488
+ * @param filePath - Absolute or relative path to the file on disk.
489
+ * @param purpose - File purpose, defaults to `"retrieval"`.
490
+ */
491
+ upload(filePath: string, purpose?: string): Promise<FileUploadResponse>;
492
+ /** List all files in MiniMax storage. */
493
+ list(): Promise<FileListResponse>;
494
+ /**
495
+ * Delete a file from MiniMax storage by its file ID.
496
+ *
497
+ * @param fileId - The ID of the file to delete (string or number).
498
+ */
499
+ delete(fileId: string | number): Promise<FileDeleteResponse>;
500
+ /**
501
+ * Retrieve metadata (and optional download URL) for a file.
502
+ *
503
+ * @param fileId - The ID of the file to retrieve.
504
+ */
505
+ retrieve(fileId: string): Promise<FileRetrieveResponse>;
506
+ }
507
+ export declare class MiniMaxSDK extends Client {
508
+ readonly text: TextSDK;
509
+ readonly speech: SpeechSDK;
510
+ readonly image: ImageSDK;
511
+ readonly video: VideoSDK;
512
+ readonly music: MusicSDK;
513
+ readonly search: SearchSDK;
514
+ readonly vision: VisionSDK;
515
+ readonly quota: QuotaSDK;
516
+ readonly file: FileSDK;
517
+ constructor(options: MiniMaxSDKOptions);
518
+ }
519
+
520
+ export {};