mmx-cli 1.0.4 → 1.0.5
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 +15 -7
- package/dist/mmx.mjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://
|
|
2
|
+
<img src="https://file.cdn.minimax.io/public/MMX.png" alt="MiniMax" width="320" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<strong>The official CLI for the MiniMax AI Platform</strong><br>
|
|
7
|
-
Generate text, images, video, speech, and music —
|
|
7
|
+
Built for AI agents. Generate text, images, video, speech, and music — from any agent or terminal.
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
10
|
<p align="center">
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
16
|
<p align="center">
|
|
17
|
-
<a href="README_CN.md">中文文档</a> · <a href="https://platform.minimax.io">Platform</a>
|
|
17
|
+
<a href="README_CN.md">中文文档</a> · <a href="https://platform.minimax.io">Global Platform</a> · <a href="https://platform.minimaxi.com">CN Platform</a>
|
|
18
18
|
</p>
|
|
19
19
|
|
|
20
20
|
## Features
|
|
@@ -31,15 +31,17 @@
|
|
|
31
31
|
## Install
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
#
|
|
35
|
-
npm install -g mmx-cli
|
|
36
|
-
|
|
37
|
-
# Install CLI Skill (for AI agents / Cursor)
|
|
34
|
+
# For AI agents (OpenClaw, Cursor, Claude Code, etc.): add skill to your agent
|
|
38
35
|
npx skills add MiniMax-AI/cli -y -g
|
|
36
|
+
|
|
37
|
+
# Or install CLI globally for terminal use
|
|
38
|
+
npm install -g mmx-cli
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
> Requires [Node.js](https://nodejs.org) 18+
|
|
42
42
|
|
|
43
|
+
> **Requires a MiniMax Token Plan** — [Global](https://platform.minimax.io/subscribe/token-plan) · [CN](https://platform.minimaxi.com/subscribe/token-plan)
|
|
44
|
+
|
|
43
45
|
## Quick Start
|
|
44
46
|
|
|
45
47
|
```bash
|
|
@@ -145,6 +147,12 @@ mmx update
|
|
|
145
147
|
mmx update latest
|
|
146
148
|
```
|
|
147
149
|
|
|
150
|
+
## Thanks to
|
|
151
|
+
|
|
152
|
+
<a href="https://github.com/MiniMax-AI/cli/graphs/contributors">
|
|
153
|
+
<img src="https://contrib.rocks/image?repo=MiniMax-AI/cli" />
|
|
154
|
+
</a>
|
|
155
|
+
|
|
148
156
|
## License
|
|
149
157
|
|
|
150
158
|
[MIT](LICENSE)
|
package/dist/mmx.mjs
CHANGED
|
@@ -109,7 +109,7 @@ Music-2.5 requires the Max plan or above.`;return""}function Re(t){return`${t?.i
|
|
|
109
109
|
Re-authenticate: mmx auth login`);if(t===429)return new c(`Rate limit or quota exceeded. ${r}`,l.QUOTA,"Check usage: mmx quota show");if(t===408||t===504)return new c(`Request timed out (HTTP ${t}).`,l.TIMEOUT,"Try increasing --timeout or retry later.");if(o===1002||o===1039){let s=e.base_resp?.status_msg||"content sensitivity";return new c(`Input content flagged by sensitivity filter (${s}).`,l.CONTENT_FILTER)}if(o===1028||o===1030){let s=Se(i);return new c(`Quota exhausted. ${r}`,l.QUOTA,`Check usage: mmx quota show${s}
|
|
110
110
|
Upgrade plan: ${Re(i)}`)}if(o===2061){let s=Se(i);return new c(`This model is not available on your current Token Plan. ${r}`,l.QUOTA,`Check usage: mmx quota show${s}
|
|
111
111
|
Upgrade plan: ${Re(i)}`)}return new c(`API error: ${r} (HTTP ${t})`,l.GENERAL)}import{homedir as ke}from"os";function I(t){return t.length>8?`${t.slice(0,4)}...${t.slice(-4)}`:"***"}var ge=!1;var G="\x1B[0m",Q="\x1B[2m",Mi="\x1B[1m",qi="\x1B[38;2;43;82;255m",Ti="\x1B[38;2;147;51;234m",Oi="\x1B[38;2;6;184;212m",Gi="\x1B[38;2;236;72;153m";function Ni(t){return t.startsWith(ke())?t.replace(ke(),"~"):t}function Ae(t,e,i){if(t.quiet||ge||!process.stderr.isTTY)return;ge=!0;let r=t.configPath?Ni(t.configPath):"~/.mmx/config.json",o=t.fileRegion?`${t.fileRegion} (file)`:"global (default)",s=t.apiKey?"(flag)":"(file)",n=I(e),m=i?` ${Q}|${G} ${Q}Model:${G} ${Ti}${i}${G}`:"";process.stderr.write(`${Mi}${qi}MINIMAX${G} ${Q}${r}${G} ${Q}|${G} ${Q}Region:${G} ${Oi}${o}${G} ${Q}|${G} ${Q}Key:${G} ${Gi}${n}${G} ${Q}${s}${G}${m}
|
|
112
|
-
`)}async function C(t,e){let i=typeof FormData<"u"&&e.body instanceof FormData,r="1.0.
|
|
112
|
+
`)}async function C(t,e){let i=typeof FormData<"u"&&e.body instanceof FormData,r="1.0.5",o={"User-Agent":"mmx-cli/1.0.5",...e.headers};if(!i&&!o["Content-Type"])o["Content-Type"]="application/json";if(!e.noAuth){let m=await dt(t);if(e.authStyle==="x-api-key")o["x-api-key"]=m.token;else o.Authorization=`Bearer ${m.token}`;if(t.verbose)process.stderr.write(`> ${e.method??"GET"} ${e.url}
|
|
113
113
|
`),process.stderr.write(`> Auth: ${m.token.slice(0,8)}...
|
|
114
114
|
`);let a=e.body&&typeof e.body==="object"&&"model"in e.body?String(e.body.model):void 0;Ae(t,m.token,a)}let s=(e.timeout??t.timeout)*1000,n=await fetch(e.url,{method:e.method??"GET",headers:o,body:e.body?i?e.body:JSON.stringify(e.body):void 0,signal:AbortSignal.timeout(s)});if(t.verbose)process.stderr.write(`< ${n.status} ${n.statusText}
|
|
115
115
|
`);if(!n.ok){let m={};try{m=await n.json()}catch{}throw Xt(n.status,m,e.url)}return n}async function v(t,e){let i=await C(t,e),r;try{r=await i.json()}catch{let o=i.headers.get("content-type")||"";throw new c(`API returned non-JSON response (${o||"unknown type"}). Server may be experiencing issues.`,l.GENERAL)}if(r.base_resp?.status_code&&r.base_resp.status_code!==0)throw Xt(200,{base_resp:r.base_resp},e.url);return r}function je(t){return`${t}/anthropic/v1/messages`}function Me(t){return`${t}/v1/t2a_v2`}function qe(t){return`${t}/v1/get_voice`}function Te(t){return`${t}/v1/image_generation`}function Oe(t){return`${t}/v1/video_generation`}function _t(t,e){return`${t}/v1/query/video_generation?task_id=${e}`}function vt(t,e){return`${t}/v1/files/retrieve?file_id=${e}`}function Ge(t){return`${t}/v1/music_generation`}function Ne(t){return`${t}/v1/coding_plan/search`}function Be(t){return`${t}/v1/coding_plan/vlm`}function P(t){return`${t.includes("minimaxi.com")?"https://api.minimaxi.com":"https://api.minimax.io"}/v1/api/openplatform/coding_plan/remains`}function Je(t){if(t<50)return["\x1B[38;2;74;222;128m","\x1B[48;2;22;163;74m"];if(t<=80)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"]}var Bi={dashboard:"TokenPlan Quota",week:"Week",weekly:"Weekly",resetsIn:"Resets in",noData:"No quota data available.",now:"now"},Ii={dashboard:"TokenPlan 配额面板",week:"周期",weekly:"每周",resetsIn:"重置于",noData:"暂无配额数据",now:"即将"};function zi(t,e){if(t<=0)return e;let i=Math.floor(t/3600000),r=Math.floor(t%3600000/60000);return i>0?`${i}h ${r}m`:`${r}m`}function Ie(t){return new Date(t).toISOString().slice(0,10)}function Ji(t){return t>=11904&&t<=40959||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65281&&t<=65376||t>=131072&&t<=195103}function V(t){let e=t.replace(/\x1b\[[0-9;]*m/g,""),i=0;for(let r of e)i+=Ji(r.codePointAt(0))?2:1;return i}var St=16;function ze(t,e){let i=Math.max(0,Math.min(100,t))/100,r=Math.round(St*i),o=St-r,s=`${t}%`.padStart(4);if(!e)return`[${"█".repeat(r)}${".".repeat(o)}] ${s}`;let[n,m]=Je(t);return`${m}${" ".repeat(r)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(o)}\x1B[0m ${n}\x1B[1m${s}\x1B[0m`}function ft(t,e,i,r,o){return o?`\x1B[2m${e}${i.repeat(t)}${r}\x1B[0m`:`+${"-".repeat(t)}+`}function Qt(t,e,i,r){let o=Math.max(0,e-2-i);return r?`${"\x1B[2m"}│${"\x1B[0m"} ${t}${" ".repeat(o)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${t}${" ".repeat(o)} |`}function rt(t,e){let i=!e.noColor&&process.stdout.isTTY===!0,r=e.region==="cn"?Ii:Bi,o=t.length>0?Math.max(...t.map((w)=>w.model_name.length)):16,s=i?St+5:St+7,n=Math.max(68,o+2+15+2+s+2),m=t.length>0?`${Ie(t[0].weekly_start_time)} — ${Ie(t[0].weekly_end_time)}`:"",a=`MINIMAX ${r.dashboard}`,u=`${r.week}: ${m}`,y=Math.max(2,n-2-V(a)-V(u)),$=i?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${r.dashboard}\x1B[0m${" ".repeat(y)}\x1B[2m${r.week}:\x1B[0m \x1B[38;2;6;184;212m${m}\x1B[0m`:`${a}${" ".repeat(y)}${u}`,h=V(a)+y+V(u);if(console.log(""),console.log(ft(n,"╭","─","╮",i)),console.log(Qt($,n,h,i)),t.length===0){console.log(ft(n,"╰","─","╯",i)),console.log(`
|
|
@@ -160,7 +160,7 @@ Response:
|
|
|
160
160
|
`);return}process.stdout.write(a.content+`
|
|
161
161
|
`)}});var Xn=d({name:"quota show",description:"Display Token Plan usage and remaining quotas",usage:"mmx quota show",examples:["mmx quota show","mmx quota show --output json"],async run(t,e){if(t.dryRun){console.log("Would fetch quota information.");return}let i=P(t.baseUrl),r=await v(t,{url:i}),o=r.model_remains||[],s=_(e.output);if(s!=="text"){console.log(b(r,s));return}if(t.quiet){for(let n of o){let m=n.current_interval_total_count-n.current_interval_usage_count;console.log(`${n.model_name} ${n.current_interval_usage_count} ${n.current_interval_total_count} ${m}`)}return}rt(o,t)}});var Qn=d({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(t,e){let i=O(),r=_(t.output),o={region:t.region,base_url:t.baseUrl,output:t.output,timeout:t.timeout,config_file:X()};if(i.api_key)o.api_key=I(i.api_key);console.log(b(o,r))}});var Vn=["region","base_url","output","timeout","api_key"],Zn=d({name:"config set",description:"Set a config value",usage:"mmx config set --key <key> --value <value>",options:[{flag:"--key <key>",description:"Config key (region, base_url, output, timeout, api_key)"},{flag:"--value <value>",description:"Value to set"}],examples:["mmx config set --key output --value json","mmx config set --key timeout --value 600","mmx config set --key base_url --value https://api-uw.minimax.io"],async run(t,e){let{key:i,value:r}=e;if(!i||r===void 0)throw new c("--key and --value are required.",l.USAGE,"mmx config set --key <key> --value <value>");if(!Vn.includes(i))throw new c(`Invalid config key "${i}". Valid keys: ${Vn.join(", ")}`,l.USAGE);if(i==="region"&&!["global","cn"].includes(r))throw new c(`Invalid region "${r}". Valid values: global, cn`,l.USAGE);if(i==="output"&&!["text","json"].includes(r))throw new c(`Invalid output format "${r}". Valid values: text, json`,l.USAGE);if(i==="timeout"){let n=Number(r);if(isNaN(n)||n<=0)throw new c(`Invalid timeout "${r}". Must be a positive number.`,l.USAGE)}let o=_(t.output);if(t.dryRun){console.log(b({would_set:{[i]:r}},o));return}let s=O();if(s[i]=i==="timeout"?Number(r):r,await Y(s),!t.quiet)console.log(b({[i]:s[i]},o))}});function go(t){let e=t.match(/^--([a-zA-Z0-9-]+)/),i=e?e[1]:"",r=i.replace(/-([a-zA-Z0-9])/g,(n,m)=>m.toUpperCase()),o="string",s=!1;if(!t.includes("<")&&!t.includes("["))o="boolean";else if(t.includes("<n>")||t.includes("<hz>")||t.includes("<bps>")||t.includes("<count>"))o="number";if(t.toLowerCase().includes("repeatable"))s=!0;return{name:r,kebabName:i,inferredType:o,isArray:s}}function $e(t){let i={name:`mmx_${t.name.replace(/ /g,"_")}`,description:t.description,input_schema:{type:"object",properties:{},required:[]}};if(t.options)for(let r of t.options){let{name:o,inferredType:s,isArray:n}=go(r.flag);if(!o)continue;let m=r.type,a=n?"array":m??s,u={description:r.description};if(a==="array")u.type="array",u.items={type:"string"};else u.type=a;let y=i.input_schema;if(y.properties[o]=u,r.required)y.required.push(o)}return i}var Ao=["auth ","config ","update"],Wn=d({name:"config export-schema",description:"Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas",usage:'mmx config export-schema [--command "<name>"]',options:[{flag:"--command <name>",description:'Export schema for a specific command only (e.g. "image generate")'}],examples:["mmx config export-schema",'mmx config export-schema --command "video generate"'],async run(t,e){let i=e.command;if(i){try{let{command:s}=U.resolve(i.split(" ")),n=$e(s);process.stdout.write(JSON.stringify(n,null,2)+`
|
|
162
162
|
`)}catch{throw new c(`Command "${i}" not found.`,l.USAGE)}return}let o=U.getAllCommands().filter((s)=>!Ao.some((n)=>s.name.startsWith(n))).map((s)=>$e(s));process.stdout.write(JSON.stringify(o,null,2)+`
|
|
163
|
-
`)}});var jo="1.0.
|
|
163
|
+
`)}});var jo="1.0.5",Hn=d({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${jo}
|
|
164
164
|
|
|
165
165
|
`),process.stderr.write(`Run:
|
|
166
166
|
`),process.stderr.write(` npm update -g mmx-cli
|
|
@@ -241,7 +241,7 @@ Error: ${String(t)}
|
|
|
241
241
|
`),"global";let o=r.region;return process.stderr.write(` ${o}
|
|
242
242
|
`),o}async function Pn(t){let e=O();e.region=t,await Y(e)}import{join as Oo}from"path";import{readFileSync as Go,writeFileSync as No}from"fs";var En=()=>Oo(mt(),"update-state.json"),Bo=86400000,Io=3000,zo="MiniMax-AI-Dev/minimax-cli";function Jo(){try{let t=Go(En(),"utf-8");return JSON.parse(t)}catch{return null}}function Yo(t){try{No(En(),JSON.stringify(t))}catch{}}async function Ko(){try{let t=await fetch(`https://api.github.com/repos/${zo}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(Io)});if(!t.ok)return null;return(await t.json()).tag_name??null}catch{return null}}var le=null;function Ln(){return le}async function Fn(t){if(process.env.CI||!process.stderr.isTTY)return;let e=Jo(),i=Date.now();if(e&&i-e.lastChecked<Bo){if(e.latestVersion&&e.latestVersion!==`v${t}`)le=e.latestVersion;return}let r=await Ko();if(!r)return;if(Yo({lastChecked:i,latestVersion:r}),r!==`v${t}`)le=r}async function Dn(t){if(t.apiKey||t.fileApiKey)return;let e=process.env.MINIMAX_API_KEY,i;if(e){if(!A({nonInteractive:t.nonInteractive}))i=e;else if(await gn({message:`Found MINIMAX_API_KEY in environment (${I(e)}). Save it to config file?`}))i=e}if(!i){if(!A({nonInteractive:t.nonInteractive}))throw new c("No API key found.",l.AUTH,`Set env var: export MINIMAX_API_KEY=sk-xxxxx
|
|
243
243
|
Pass directly: --api-key sk-xxxxx`);let s=await K({message:"Enter your MiniMax API key:"});if(!s)throw new c("API key is required.",l.AUTH);i=s}let r={...O(),api_key:i};await Y(r),t.fileApiKey=i;let o=t.configPath??"~/.mmx/config.json";process.stderr.write(`API key saved to ${o}
|
|
244
|
-
`)}var ti="1.0.
|
|
244
|
+
`)}var ti="1.0.5";process.on("SIGINT",()=>{process.stderr.write(`
|
|
245
245
|
Interrupted. Exiting.
|
|
246
246
|
`),process.exit(130)});var Xo=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function Qo(){let t=process.argv.slice(2);if(t.includes("--version")||t.includes("-v"))console.log(`mmx ${ti}`),process.exit(0);let e=he(t,ht);if(t.includes("--help")||t.includes("-h"))U.printHelp(e,process.stderr),process.exit(0);if(e.length===0){U.printHelp([],process.stderr);let{command:u}=U.resolve(["quota","show"]),y=Jt(t,[...ht,...u.options??[]]),$=Zt(y),h=!!($.apiKey||$.fileApiKey),w=!!await B();if(h||w)await u.execute($,y);else process.stderr.write(` Not logged in.
|
|
247
247
|
`),process.stderr.write(` mmx auth login --api-key sk-xxxxx
|