mmx-cli 1.0.21 → 1.0.22

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/mmx.mjs CHANGED
@@ -117,7 +117,7 @@ Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;return""}fu
117
117
  Re-authenticate: mmx auth login`);if(e===429)return new m(`Rate limit or quota exceeded. ${n}`,d.QUOTA,"Check usage: mmx quota show");if(e===402||s==="insufficient_balance_error")return new m(`Quota or balance exhausted. ${n}`,d.QUOTA,"Check your MiniMax account balance and billing settings.");if(e===408||e===504)return new m(`Request timed out (HTTP ${e}).`,d.TIMEOUT,"Try increasing --timeout or retry later.");let r=e===422&&s==="unprocessable_entity_error"&&(/sensitive content/i.test(n)||/(?:^|\D)1026(?:\D|$)/.test(n));if(i===1002||i===1039||r){let u=t.base_resp?.status_msg||t.error?.message||"content sensitivity";return new m(`Input content flagged by sensitivity filter (${u}).`,d.CONTENT_FILTER)}if(i===1028||i===1030){let u=xo(o);return new m(`Quota exhausted. ${n}`,d.QUOTA,`Check usage: mmx quota show${u}
118
118
  Upgrade plan: ${wo(o)}`)}if(i===2061){let u=xo(o);return new m(`This model is not available on your current Token Plan. ${n}`,d.QUOTA,`Check usage: mmx quota show${u}
119
119
  Upgrade plan: ${wo(o)}`)}return new m(`API error: ${n} (HTTP ${e})`,d.GENERAL)}var or=C(()=>{R();S()});import{homedir as vo}from"os";function ku(e){return e.startsWith(vo())?e.replace(vo(),"~"):e}function Ru(e){return e.replace(/^https?:\/\//,"")}function _o(e,t,o){if(e.quiet||$o||!process.stderr.isTTY)return;$o=!0;let n=e.configPath?ku(e.configPath):"~/.mmx/config.json",i=Ru(e.baseUrl),s=e.apiKey?"(flag)":"(file)",r=J(t),u=o?` ${fe}|${Q} ${fe}Model:${Q} ${_u}${o}${Q}`:"";process.stderr.write(`${vu}${$u}MINIMAX${Q} ${fe}${n}${Q} ${fe}|${Q} ${fe}URL:${Q} ${Au}${i}${Q} ${fe}|${Q} ${fe}Key:${Q} ${Su}${r}${Q} ${fe}${s}${Q}${u}
120
- `)}var $o=!1,Q="\x1B[0m",fe="\x1B[2m",vu="\x1B[1m",$u="\x1B[38;2;43;82;255m",_u="\x1B[38;2;147;51;234m",Au="\x1B[38;2;6;184;212m",Su="\x1B[38;2;236;72;153m";var Ao=()=>{};var So=()=>{};var we="1.0.21";var ct=C(()=>{So()});function ko(e){return new DOMException(e,"TimeoutError")}function Bu(e,t,o){if(!e.body)return e;let n=e.body.getReader(),i=!1,s=()=>{if(i)return;i=!0,n.releaseLock()},r=async(l)=>{if(!o.signal.aborted)o.abort(l);try{await n.cancel(l)}finally{s()}},u=new ReadableStream({async pull(l){let p;try{let f=await new Promise((D,h)=>{p=setTimeout(()=>{let E=ko(`Stream received no data for ${t}ms.`);o.abort(E),h(E)},t),n.read().then(D,h)});if(f.done)s(),l.close();else l.enqueue(f.value)}catch(f){await r(f).catch(()=>{}),l.error(f)}finally{if(p)clearTimeout(p)}},cancel(l){return r(l)}}),a=new Response(u,{status:e.status,statusText:e.statusText,headers:e.headers});return Object.defineProperties(a,{url:{value:e.url},redirected:{value:e.redirected},type:{value:e.type}}),a}async function ve(e,t){let o=typeof FormData<"u"&&t.body instanceof FormData,n={"User-Agent":`mmx-cli/${we}`,...t.headers};if(!o&&!n["Content-Type"])n["Content-Type"]="application/json";if(!t.noAuth){let a=await at(e);if(t.authStyle==="x-api-key")n["x-api-key"]=a.token;else n.Authorization=`Bearer ${a.token}`;if(e.verbose)process.stderr.write(`> ${t.method??"GET"} ${t.url}
120
+ `)}var $o=!1,Q="\x1B[0m",fe="\x1B[2m",vu="\x1B[1m",$u="\x1B[38;2;43;82;255m",_u="\x1B[38;2;147;51;234m",Au="\x1B[38;2;6;184;212m",Su="\x1B[38;2;236;72;153m";var Ao=()=>{};var So=()=>{};var we="1.0.22";var ct=C(()=>{So()});function ko(e){return new DOMException(e,"TimeoutError")}function Bu(e,t,o){if(!e.body)return e;let n=e.body.getReader(),i=!1,s=()=>{if(i)return;i=!0,n.releaseLock()},r=async(l)=>{if(!o.signal.aborted)o.abort(l);try{await n.cancel(l)}finally{s()}},u=new ReadableStream({async pull(l){let p;try{let f=await new Promise((D,h)=>{p=setTimeout(()=>{let E=ko(`Stream received no data for ${t}ms.`);o.abort(E),h(E)},t),n.read().then(D,h)});if(f.done)s(),l.close();else l.enqueue(f.value)}catch(f){await r(f).catch(()=>{}),l.error(f)}finally{if(p)clearTimeout(p)}},cancel(l){return r(l)}}),a=new Response(u,{status:e.status,statusText:e.statusText,headers:e.headers});return Object.defineProperties(a,{url:{value:e.url},redirected:{value:e.redirected},type:{value:e.type}}),a}async function ve(e,t){let o=typeof FormData<"u"&&t.body instanceof FormData,n={"User-Agent":`mmx-cli/${we}`,...t.headers};if(!o&&!n["Content-Type"])n["Content-Type"]="application/json";if(!t.noAuth){let a=await at(e);if(t.authStyle==="x-api-key")n["x-api-key"]=a.token;else n.Authorization=`Bearer ${a.token}`;if(e.verbose)process.stderr.write(`> ${t.method??"GET"} ${t.url}
121
121
  `),process.stderr.write(`> Auth: ${a.token.slice(0,8)}...
122
122
  `);let l=t.body&&typeof t.body==="object"&&"model"in t.body?String(t.body.model):void 0;_o(e,a.token,l)}let i=(t.timeout??e.timeout)*1000,s=t.stream?new AbortController:void 0,r=s?setTimeout(()=>{s.abort(ko(`Request headers were not received within ${i}ms.`))},i):void 0,u;try{u=await fetch(t.url,{method:t.method??"GET",headers:n,body:t.body?o?t.body:JSON.stringify(t.body):void 0,signal:s?.signal??AbortSignal.timeout(i)})}finally{if(r)clearTimeout(r)}if(s)u=Bu(u,i,s);if(e.verbose)process.stderr.write(`< ${u.status} ${u.statusText}
123
123
  `);if(!u.ok){let a={};try{a=await u.json()}catch{}throw qe(u.status,a,t.url)}return u}async function A(e,t){let o=await ve(e,t),n;try{n=await o.json()}catch{let i=o.headers.get("content-type")||"";throw new m(`API returned non-JSON response (${i||"unknown type"}). Server may be experiencing issues.`,d.GENERAL)}if(n.base_resp?.status_code&&n.base_resp.status_code!==0)throw qe(200,{base_resp:n.base_resp},t.url);return n}var V=C(()=>{R();S();rr();or();Ao();ct()});function lt(e){return`${e}/anthropic/v1/messages`}function Ro(e){return`${e}/v1/t2a_v2`}function Bo(e){return`${e}/v1/get_voice`}function Io(e){return`${e}/v1/image_generation`}function To(e){return`${e}/v1/video_generation`}function Mo(e){return`${e}/v2/video_generation`}function mt(e,t){return`${e}/v1/query/video_generation?task_id=${t}`}function dt(e,t){return`${e}/v2/query/video_generation/${t}`}function pt(e,t){return`${e}/v1/files/retrieve?file_id=${t}`}function Oo(e){return`${e}/v1/coding_plan/search`}function Po(e){return`${e}/v1/coding_plan/vlm`}function $e(e){return`${e}/v1/token_plan/remains`}function Iu(e){return`${e}/account/query_balance`}function nr(e){return e.startsWith("sk-api-")}function ne(e,t){return nr(t)?Iu(e):$e(e)}function No(e){return`${e}/v1/files/upload`}function Lo(e){return`${e}/v1/files/list`}function Uo(e){return`${e}/v1/files/delete`}function Tu(e){return e?"on":"off"}function Go(e,t){if(console.log("Account Balance:"),console.log(` Available: ${e.available_amount}`),console.log(` Cash: ${e.cash_balance}`),console.log(` Voucher: ${e.voucher_balance}`),console.log(` Credit: ${e.credit_balance}`),console.log(` Owed: ${e.owed_amount}`),console.log(` Alert: ${Tu(e.balance_alert_switch)}`),e.balance_alert_threshold)console.log(` Threshold: ${e.balance_alert_threshold}`)}function Wo(e){if(e>=50)return["\x1B[38;2;74;222;128m","\x1B[48;2;22;163;74m"];if(e>=20)return["\x1B[38;2;250;204;21m","\x1B[48;2;202;138;4m"];return["\x1B[38;2;248;113;113m","\x1B[48;2;220;38;38m"]}function Nu(e,t){if(t!=="cn")return e;return Pu[e]??e}function Lu(e,t){if(e<=0)return t;let o=Math.floor(e/3600000),n=Math.floor(e%3600000/60000);return o>0?`${o}h ${n}m`:`${n}m`}function qo(e){return new Date(e).toISOString().slice(0,10)}function Uu(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65281&&e<=65376||e>=131072&&e<=195103}function Z(e){let t=e.replace(/\x1b\[[0-9;]*m/g,""),o=0;for(let n of t)o+=Uu(n.codePointAt(0))?2:1;return o}function Vu(e){return e===3}function ju(e){return e.current_interval_total_count===0&&e.current_weekly_total_count===0&&e.current_interval_status===3&&e.current_weekly_status===3}function ir(e){return Math.max(0,Math.min(qu,Math.round(e)))}function Hu(e){if(e===void 0||e===null)return 1;return Math.max(0,e)/1000}function Wu(e,t,o,n){let i=Hu(n);if(e!==void 0&&e!==null)return ir(e*i);return o>0?ir(t/o*100*i):0}function Ku(e,t,o=Gu,n=!0){let i=ir(e),s=Math.min(1,i/100),r=Math.round(o*s),u=o-r,a=`${i}%`.padStart(4);if(!t){let D=`[${"█".repeat(r)}${".".repeat(u)}]`;return n?`${D} ${a}`:D}let[l,p]=Wo(i),f=`${p}${" ".repeat(r)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(u)}\x1B[0m`;return n?`${f} ${l}\x1B[1m${a}\x1B[0m`:f}function Vo(e,t,o,n,i,s,r,u){if(r){let f=(u??zu).padStart(4);if(i){let h=`\x1B[48;2;22;163;74m${" ".repeat(Ve)}\x1B[0m`;return`\x1B[2m${e}\x1B[0m ${h} \x1B[38;2;74;222;128m\x1B[1m${f}\x1B[0m`}let D=`[${"█".repeat(Ve)}]`;return`${e} ${D} ${f}`}let a=Wu(n,t,o,s),l=Ku(a,i,Ve,o<=0);if(o>0){let p=`${t.toLocaleString()} / ${o.toLocaleString()}`;return i?`\x1B[2m${e}\x1B[0m ${l} ${Wo(a)[0]}${p}\x1B[0m`:`${e} ${l} ${p}`}return`${e} ${l}`}function jo(e,t,o){if(o){let n=`\x1B[48;2;55;65;81m${" ".repeat(Ve)}\x1B[0m`;return`\x1B[2m${e}\x1B[0m ${n} \x1B[38;2;248;113;113m\x1B[1m${t}\x1B[0m`}return`${e} [${".".repeat(Ve)}] ${t}`}function Dt(e,t,o,n,i){return i?`\x1B[2m${t}${o.repeat(e)}${n}\x1B[0m`:`+${"-".repeat(e)}+`}function Ho(e,t,o,n){let i=Math.max(0,t-2-o);return n?`${"\x1B[2m"}│${"\x1B[0m"} ${e}${" ".repeat(i)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${e}${" ".repeat(i)} |`}function Ko(e,t){let o=!t.noColor&&process.stdout.isTTY===!0,n=t.region==="cn"?Ou:Mu,i=e.map((g)=>{let y=Nu(g.model_name,t.region),v=ju(g),k=v?jo(n.current,n.notInPlan,o):Vo(n.current,g.current_interval_usage_count,g.current_interval_total_count,g.current_interval_remaining_percent,o),B=v?jo(n.weekly,n.notInPlan,o):Vo(n.weekly,g.current_weekly_usage_count,g.current_weekly_total_count,g.current_weekly_remaining_percent,o,g.weekly_boost_permille,Vu(g.current_weekly_status),t.region==="cn"?Ju:Yu),M=v?`${n.resetsIn} —`:`${n.resetsIn} ${Lu(g.remains_time,n.now)}`;return{displayName:y,current:k,weekly:B,reset:M}}),s=Math.max(6,...i.map((g)=>Z(g.displayName))),r=Math.max(...i.map((g)=>Z(g.current)),18),u=Math.max(...i.map((g)=>Z(g.weekly)),18),a=Math.max(...i.map((g)=>Z(g.reset)),10),l=Math.max(72,s+2+r+2+u+2+a+4),p=e.length>0?`${qo(e[0].weekly_start_time)} — ${qo(e[0].weekly_end_time)}`:"",f=`MINIMAX ${n.dashboard}`,D=`${n.week}: ${p}`,h=Math.max(2,l-2-Z(f)-Z(D)),E=o?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${n.dashboard}\x1B[0m${" ".repeat(h)}\x1B[2m${n.week}:\x1B[0m \x1B[38;2;6;184;212m${p}\x1B[0m`:`${f}${" ".repeat(h)}${D}`,x=Z(f)+h+Z(D);if(console.log(""),console.log(Dt(l,"╭","─","╮",o)),console.log(Ho(E,l,x,o)),e.length===0){console.log(Dt(l,"╰","─","╯",o)),console.log(`
package/dist/sdk.mjs CHANGED
@@ -494,7 +494,7 @@ function maybeShowStatusBar(config, token, model) {
494
494
  // package.json
495
495
  var package_default = {
496
496
  name: "mmx-cli",
497
- version: "1.0.21",
497
+ version: "0.0.0-dev",
498
498
  description: "CLI for the MiniMax AI Platform",
499
499
  type: "module",
500
500
  repository: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mmx-cli",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "CLI for the MiniMax AI Platform",
5
5
  "type": "module",
6
6
  "repository": {
package/README.md DELETED
@@ -1,193 +0,0 @@
1
- <img src="https://file.cdn.minimax.io/public/MMX-capabilities.png" alt="MiniMax" width="100%" />
2
-
3
- <p align="center">
4
- <strong>The official CLI for the MiniMax AI Platform</strong><br>
5
- Built for AI agents. Generate text, images, video, and speech — from any agent or terminal.
6
- </p>
7
-
8
- <p align="center">
9
- <a href="https://www.npmjs.com/package/mmx-cli"><img src="https://img.shields.io/npm/v/mmx-cli.svg" alt="npm version" /></a>
10
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT" /></a>
11
- <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg" alt="Node.js >= 18" /></a>
12
- </p>
13
-
14
- <p align="center">
15
- <a href="README_CN.md">中文文档</a> · <a href="https://platform.minimax.io">Global Platform</a> · <a href="https://platform.minimaxi.com">CN Platform</a> · <a href="https://platform.minimax.io/docs/token-plan/minimax-cli">Example</a>
16
- </p>
17
-
18
- ## Features
19
-
20
- - **Text** — Multi-turn chat, streaming, system prompts, JSON output
21
- - **Image** — Text-to-image with aspect ratio and batch controls
22
- - **Video** — Async video generation with progress tracking
23
- - **Speech** — TTS with 30+ voices, speed control, streaming playback
24
- - **Vision** — Image understanding and description
25
- - **Search** — Web search powered by MiniMax
26
- - **Dual Region** — Seamless Global (`api.minimax.io`) and CN (`api.minimaxi.com`) support
27
-
28
- <img src="https://file.cdn.minimax.io/public/MMX-CLI-help.png" alt="MiniMax" width="100%" />
29
-
30
- ## Install
31
-
32
- ```bash
33
- # For AI agents (OpenClaw, Cursor, Claude Code, etc.): add skill to your agent
34
- npx skills add MiniMax-AI/cli -y -g
35
-
36
- # Or install CLI globally for terminal use
37
- npm install -g mmx-cli
38
- ```
39
-
40
- > Requires [Node.js](https://nodejs.org) 18+
41
-
42
- > **Requires a MiniMax Token Plan** — [Global](https://platform.minimax.io/subscribe/token-plan) · [CN](https://platform.minimaxi.com/subscribe/token-plan)
43
-
44
- ## Quick Start
45
-
46
- ```bash
47
- # Authenticate (interactive — choose MiniMax OAuth or paste an API key)
48
- mmx auth login
49
-
50
- # Or non-interactive
51
- mmx auth login --api-key sk-xxxxx
52
-
53
- # Start creating
54
- mmx text chat --message "What is MiniMax?"
55
- mmx image "A cat in a spacesuit"
56
- mmx speech synthesize --text "Hello!" --out hello.mp3
57
- mmx video generate --prompt "Ocean waves at sunset"
58
- mmx search "MiniMax AI latest news"
59
- mmx vision photo.jpg
60
- mmx quota
61
- ```
62
-
63
- ## Commands
64
-
65
- ### `mmx text`
66
-
67
- ```bash
68
- mmx text chat --message "Write a poem"
69
- mmx text chat --model MiniMax-M3 --message "Hello" --stream
70
- mmx text chat --system "You are a coding assistant" --message "Fizzbuzz in Go"
71
- mmx text chat --message "user:Hi" --message "assistant:Hey!" --message "How are you?"
72
- cat messages.json | mmx text chat --messages-file - --output json
73
- ```
74
-
75
- ### `mmx image`
76
-
77
- ```bash
78
- mmx image "A cat in a spacesuit"
79
- mmx image generate --prompt "A cat" --n 3 --aspect-ratio 16:9
80
- mmx image generate --prompt "Logo" --out-dir ./out/
81
- ```
82
-
83
- ### `mmx video`
84
-
85
- ```bash
86
- # Hailuo-2.3 (Video Generation V1)
87
- mmx video generate --prompt "Ocean waves at sunset" --download sunset.mp4
88
- mmx video generate --prompt "A robot painting" --async
89
-
90
- # MiniMax-H3 (Video Generation V2)
91
- mmx video generate --api-key "$MINIMAX_API_KEY" --model MiniMax-H3 --prompt "Ocean waves at sunset"
92
- mmx video generate --api-key "$MINIMAX_API_KEY" --model MiniMax-H3 --prompt "The subject walks forward" --image start.jpg
93
- mmx video generate --api-key "$MINIMAX_API_KEY" --model MiniMax-H3 --prompt "Keep the same character" --reference-image character.png --reference-video motion.mp4
94
-
95
- mmx video task get --task-id 123456
96
- mmx video task get --task-id 424010985738629 --model MiniMax-H3
97
- mmx video download --file-id 176844028768320 --out video.mp4
98
- ```
99
-
100
- For MiniMax-H3, local files and Base64 data URIs are preflight-checked against the documented limits: image 30 MB, reference video 50 MB, reference audio 15 MB, and total JSON request body 64 MB. The API validates dimensions, aspect ratio, duration, frame rate, and codecs for all media.
101
-
102
- `--region` is an existing global CLI option, not an H3 parameter. Normal video generation does not need it; the CLI uses the saved or automatically detected region. H3 defaults to 2K, 5 seconds, and 16:9 for text-to-video.
103
-
104
- ### `mmx speech`
105
-
106
- ```bash
107
- mmx speech synthesize --text "Hello!" --out hello.mp3
108
- mmx speech synthesize --text "Stream me" --stream | mpv -
109
- mmx speech synthesize --text "Hi" --voice English_magnetic_voiced_man --speed 1.2
110
- echo "Breaking news" | mmx speech synthesize --text-file - --out news.mp3
111
- mmx speech voices
112
- ```
113
-
114
- ### `mmx vision`
115
-
116
- ```bash
117
- mmx vision photo.jpg
118
- mmx vision describe --image https://example.com/img.jpg --prompt "What breed?"
119
- mmx vision describe --file-id file-123
120
- ```
121
-
122
- ### `mmx search`
123
-
124
- ```bash
125
- mmx search "MiniMax AI"
126
- mmx search query --q "latest news" --output json
127
- ```
128
-
129
- > The `/v1/coding_plan/search` API returns at most 10 results per call and does not currently expose a pagination parameter (see #107). Refine your query if you need different results.
130
-
131
- ### `mmx auth`
132
-
133
- ```bash
134
- mmx auth login # interactive: pick OAuth (Global / China) or paste an API key
135
- mmx auth login --api-key sk-xxxxx # save an API key directly
136
- mmx auth login --recommend # skip the menu, pick OAuth region interactively
137
- mmx auth login --recommend --region=global # OAuth → api.minimax.io
138
- mmx auth login --recommend --region=cn # OAuth → api.minimaxi.com
139
- mmx auth status
140
- mmx auth refresh
141
- mmx auth logout
142
- ```
143
-
144
- `mmx auth status` is the canonical way to verify active authentication.
145
-
146
- **OAuth** uses the [Device Authorization Grant (RFC 8628)](https://tools.ietf.org/html/rfc8628) with PKCE —
147
- the CLI opens your browser, you enter a code, and `access_token` + `refresh_token`
148
- are saved to `~/.mmx/config.json`. Tokens refresh automatically (5-min buffer);
149
- manual refresh via `mmx auth refresh`.
150
-
151
- **API key** auth auto-detects the correct region by probing both Global and CN.
152
- Useful for CI/CD (`mmx auth login --api-key sk-xxxxx`), or pass per-command via `--api-key`.
153
-
154
- OAuth and API key are mutually exclusive — logging in with one clears the other.
155
- Credential priority: `--api-key` flag > OAuth (config) > `api_key` (config).
156
-
157
- ### Environment variables
158
-
159
- | Variable | Description |
160
- |---|---|
161
- | `MINIMAX_REGION` | `global` or `cn`. |
162
- | `MINIMAX_BASE_URL` | Override the API base URL. |
163
- | `MINIMAX_OUTPUT` | `text` or `json`. |
164
- | `MINIMAX_TIMEOUT` | Request timeout in seconds. |
165
- | `MINIMAX_VERBOSE` | `1` to enable verbose HTTP logging. |
166
- | `MMX_CONFIG_DIR` | Directory containing the `config.json` file (default: `~/.mmx`). Set this when `mmx` runs from a subprocess, service, or CI job whose home directory differs from where you logged in. |
167
-
168
- ### `mmx config` · `mmx quota`
169
-
170
- ```bash
171
- mmx quota
172
- mmx config show
173
- mmx config set --key region --value cn
174
- mmx config set --key default-text-model --value MiniMax-M3
175
- mmx config export-schema | jq .
176
- ```
177
-
178
- ### `mmx update`
179
-
180
- ```bash
181
- mmx update
182
- mmx update latest
183
- ```
184
-
185
- ## Thanks to
186
-
187
- <a href="https://github.com/MiniMax-AI/cli/graphs/contributors">
188
- <img src="https://contrib.rocks/image?repo=MiniMax-AI/cli" />
189
- </a>
190
-
191
- ## License
192
-
193
- [MIT](LICENSE)