mmx-cli 1.0.0
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 +150 -0
- package/dist/mmx.mjs +255 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/logo.png" alt="MiniMax" width="320" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<strong>The official CLI for the MiniMax AI Platform</strong><br>
|
|
7
|
+
Generate text, images, video, speech, and music — all from your terminal.
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://www.npmjs.com/package/mmx-cli"><img src="https://img.shields.io/npm/v/mmx-cli.svg" alt="npm version" /></a>
|
|
12
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT" /></a>
|
|
13
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg" alt="Node.js >= 18" /></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="README_CN.md">中文文档</a> · <a href="https://platform.minimax.io">Platform</a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Text** — Multi-turn chat, streaming, system prompts, JSON output
|
|
23
|
+
- **Image** — Text-to-image with aspect ratio and batch controls
|
|
24
|
+
- **Video** — Async video generation with progress tracking
|
|
25
|
+
- **Speech** — TTS with 30+ voices, speed control, streaming playback
|
|
26
|
+
- **Music** — Text-to-music with optional lyrics
|
|
27
|
+
- **Vision** — Image understanding and description
|
|
28
|
+
- **Search** — Web search powered by MiniMax
|
|
29
|
+
- **Dual Region** — Seamless Global (`api.minimax.io`) and CN (`api.minimaxi.com`) support
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Install CLI
|
|
35
|
+
npm install -g mmx-cli
|
|
36
|
+
|
|
37
|
+
# Install CLI Skill (for AI agents / Cursor)
|
|
38
|
+
npx skills add MiniMax-AI/cli -y -g
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
> Requires [Node.js](https://nodejs.org) 18+
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Authenticate
|
|
47
|
+
mmx auth login --api-key sk-xxxxx
|
|
48
|
+
|
|
49
|
+
# Start creating
|
|
50
|
+
mmx text chat --message "What is MiniMax?"
|
|
51
|
+
mmx image "A cat in a spacesuit"
|
|
52
|
+
mmx speech synthesize --text "Hello!" --out hello.mp3
|
|
53
|
+
mmx video generate --prompt "Ocean waves at sunset"
|
|
54
|
+
mmx music generate --prompt "Upbeat pop" --lyrics "[verse] La da dee, sunny day"
|
|
55
|
+
mmx search "MiniMax AI latest news"
|
|
56
|
+
mmx vision photo.jpg
|
|
57
|
+
mmx quota
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Commands
|
|
61
|
+
|
|
62
|
+
### `mmx text`
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
mmx text chat --message "Write a poem"
|
|
66
|
+
mmx text chat --model MiniMax-M2.7-highspeed --message "Hello" --stream
|
|
67
|
+
mmx text chat --system "You are a coding assistant" --message "Fizzbuzz in Go"
|
|
68
|
+
mmx text chat --message "user:Hi" --message "assistant:Hey!" --message "How are you?"
|
|
69
|
+
cat messages.json | mmx text chat --messages-file - --output json
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### `mmx image`
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
mmx image "A cat in a spacesuit"
|
|
76
|
+
mmx image generate --prompt "A cat" --n 3 --aspect-ratio 16:9
|
|
77
|
+
mmx image generate --prompt "Logo" --out-dir ./out/
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `mmx video`
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
mmx video generate --prompt "Ocean waves at sunset" --async
|
|
84
|
+
mmx video generate --prompt "A robot painting" --download sunset.mp4
|
|
85
|
+
mmx video task get --task-id 123456
|
|
86
|
+
mmx video download --file-id 176844028768320 --out video.mp4
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### `mmx speech`
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
mmx speech synthesize --text "Hello!" --out hello.mp3
|
|
93
|
+
mmx speech synthesize --text "Stream me" --stream | mpv -
|
|
94
|
+
mmx speech synthesize --text "Hi" --voice English_magnetic_voiced_man --speed 1.2
|
|
95
|
+
echo "Breaking news" | mmx speech synthesize --text-file - --out news.mp3
|
|
96
|
+
mmx speech voices
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### `mmx music`
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
mmx music generate --prompt "Upbeat pop" --lyrics "[verse] La da dee, sunny day"
|
|
103
|
+
mmx music generate --prompt "Jazz" --lyrics "La la la" --out song.mp3
|
|
104
|
+
mmx music generate --prompt "Cinematic orchestral" --instrumental --out bgm.mp3
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `mmx vision`
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
mmx vision photo.jpg
|
|
111
|
+
mmx vision describe --image https://example.com/img.jpg --prompt "What breed?"
|
|
112
|
+
mmx vision describe --file-id file-123
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### `mmx search`
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
mmx search "MiniMax AI"
|
|
119
|
+
mmx search query --q "latest news" --output json
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### `mmx auth`
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
mmx auth login --api-key sk-xxxxx
|
|
126
|
+
mmx auth login # OAuth browser flow
|
|
127
|
+
mmx auth status
|
|
128
|
+
mmx auth refresh
|
|
129
|
+
mmx auth logout
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### `mmx config` · `mmx quota`
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
mmx quota
|
|
136
|
+
mmx config show
|
|
137
|
+
mmx config set --key region --value cn
|
|
138
|
+
mmx config export-schema | jq .
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### `mmx update`
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
mmx update
|
|
145
|
+
mmx update latest
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
[MIT](LICENSE)
|
package/dist/mmx.mjs
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire as $i}from"node:module";var si=Object.create;var{getPrototypeOf:pi,defineProperty:It,getOwnPropertyNames:mi}=Object;var ai=Object.prototype.hasOwnProperty;var Y=(t,e,i)=>{i=t!=null?si(pi(t)):{};let r=e||!t||!t.__esModule?It(i,"default",{value:t,enumerable:!0}):i;for(let o of mi(t))if(!ai.call(r,o))It(r,o,{get:()=>t[o],enumerable:!0});return r};var ce=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ui=(t,e)=>{for(var i in e)It(t,i,{get:e[i],enumerable:!0,configurable:!0,set:(r)=>e[i]=()=>r})};var ye=(t,e)=>()=>(t&&(e=t(t=0)),e);var it=$i(import.meta.url);var Ht=ce((Is,Qe)=>{var Wt={to(t,e){if(!e)return`\x1B[${t+1}G`;return`\x1B[${e+1};${t+1}H`},move(t,e){let i="";if(t<0)i+=`\x1B[${-t}D`;else if(t>0)i+=`\x1B[${t}C`;if(e<0)i+=`\x1B[${-e}A`;else if(e>0)i+=`\x1B[${e}B`;return i},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Xi={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},Qi={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let i=0;i<t;i++)e+=this.line+(i<t-1?Wt.up():"");if(t)e+=Wt.left;return e}};Qe.exports={cursor:Wt,scroll:Xi,erase:Qi,beep:"\x07"}});var Ct=ce((zs,Ut)=>{var kt=process||{},Ve=kt.argv||[],Rt=kt.env||{},Vi=!(!!Rt.NO_COLOR||Ve.includes("--no-color"))&&(!!Rt.FORCE_COLOR||Ve.includes("--color")||kt.platform==="win32"||(kt.stdout||{}).isTTY&&Rt.TERM!=="dumb"||!!Rt.CI),Zi=(t,e,i=t)=>(r)=>{let o=""+r,s=o.indexOf(e,t.length);return~s?t+Wi(o,e,i,s)+e:t+o+e},Wi=(t,e,i,r)=>{let o="",s=0;do o+=t.substring(s,r)+i,s=r+e.length,r=t.indexOf(e,s);while(~r);return o+t.substring(s)},Ze=(t=Vi)=>{let e=t?Zi:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};Ut.exports=Ze();Ut.exports.createColors=Ze});import{stdin as on,stdout as sn}from"node:process";import*as H from"node:readline";import We from"node:readline";import{WriteStream as Hi}from"node:tty";function Ui({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function pn(t){if(typeof t!="string")throw TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(Ci,"")}function mn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ut(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=pn(t),t.length===0))return 0;t=t.replace(Fi()," ");let i=e.ambiguousIsNarrow?1:2,r=0;for(let o of t){let s=o.codePointAt(0);if(s<=31||s>=127&&s<=159||s>=768&&s<=879)continue;switch(Pi.eastAsianWidth(o)){case"F":case"W":r+=2;break;case"A":r+=i;break;default:r+=1}}return r}function er(){let t=new Map;for(let[e,i]of Object.entries(S)){for(let[r,o]of Object.entries(i))S[r]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},i[r]=S[r],t.set(o[0],o[1]);Object.defineProperty(S,e,{value:i,enumerable:!1})}return Object.defineProperty(S,"codes",{value:t,enumerable:!1}),S.color.close="\x1B[39m",S.bgColor.close="\x1B[49m",S.color.ansi=He(),S.color.ansi256=Ue(),S.color.ansi16m=Ce(),S.bgColor.ansi=He(Et),S.bgColor.ansi256=Ue(Et),S.bgColor.ansi16m=Ce(Et),Object.defineProperties(S,{rgbToAnsi256:{value:(e,i,r)=>e===i&&i===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(i/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value:(e)=>{let i=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!i)return[0,0,0];let[r]=i;r.length===3&&(r=[...r].map((s)=>s+s).join(""));let o=Number.parseInt(r,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:(e)=>S.rgbToAnsi256(...S.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:(e)=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let i,r,o;if(e>=232)i=((e-232)*10+8)/255,r=i,o=i;else{e-=16;let m=e%36;i=Math.floor(e/36)/5,r=Math.floor(m/6)/5,o=m%6/5}let s=Math.max(i,r,o)*2;if(s===0)return 30;let n=30+(Math.round(o)<<2|Math.round(r)<<1|Math.round(i));return s===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(e,i,r)=>S.ansi256ToAnsi(S.rgbToAnsi256(e,i,r)),enumerable:!1},hexToAnsi:{value:(e)=>S.ansi256ToAnsi(S.hexToAnsi256(e)),enumerable:!1}}),S}function Le(t,e,i){return String(t).normalize().replace(/\r\n/g,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`).map((r)=>pr(r,e,i)).join(`
|
|
5
|
+
`)}function ur(t,e){if(t===e)return;let i=t.split(`
|
|
6
|
+
`),r=e.split(`
|
|
7
|
+
`),o=[];for(let s=0;s<Math.max(i.length,r.length);s++)i[s]!==r[s]&&o.push(s);return o}function jt(t){return t===ln}function gt(t,e){t.isTTY&&t.setRawMode(e)}class U{constructor({render:t,input:e=on,output:i=sn,...r},o=!0){N(this,"input"),N(this,"output"),N(this,"rl"),N(this,"opts"),N(this,"_track",!1),N(this,"_render"),N(this,"_cursor",0),N(this,"state","initial"),N(this,"value"),N(this,"error",""),N(this,"subscribers",new Map),N(this,"_prevFrame",""),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=t.bind(this),this._track=o,this.input=e,this.output=i}prompt(){let t=new Hi(0);return t._write=(e,i,r)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),r()},this.input.pipe(t),this.rl=We.createInterface({input:this.input,output:t,tabSize:2,prompt:"",escapeCodeTimeout:50}),We.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),gt(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((e,i)=>{this.once("submit",()=>{this.output.write(j.cursor.show),this.output.off("resize",this.render),gt(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(j.cursor.show),this.output.off("resize",this.render),gt(this.input,!1),e(ln)})})}on(t,e){let i=this.subscribers.get(t)??[];i.push({cb:e}),this.subscribers.set(t,i)}once(t,e){let i=this.subscribers.get(t)??[];i.push({cb:e,once:!0}),this.subscribers.set(t,i)}emit(t,...e){let i=this.subscribers.get(t)??[],r=[];for(let o of i)o.cb(...e),o.once&&r.push(()=>i.splice(i.indexOf(o),1));for(let o of r)o()}unsubscribe(){this.subscribers.clear()}onKeypress(t,e){if(this.state==="error"&&(this.state="active"),e?.name&&!this._track&&Fe.has(e.name)&&this.emit("cursor",Fe.get(e.name)),e?.name&&$r.has(e.name)&&this.emit("cursor",e.name),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),t==="\t"&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),t&&this.emit("key",t.toLowerCase()),e?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}t==="\x03"&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
8
|
+
`),gt(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=Le(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
9
|
+
`).length-1;this.output.write(j.cursor.move(-999,t*-1))}render(){let t=Le(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(j.cursor.hide);else{let e=ur(this._prevFrame,t);if(this.restoreCursor(),e&&e?.length===1){let i=e[0];this.output.write(j.cursor.move(0,i)),this.output.write(j.erase.lines(1));let r=t.split(`
|
|
10
|
+
`);this.output.write(r[i]),this._prevFrame=t,this.output.write(j.cursor.move(0,r.length-i-1));return}else if(e&&e?.length>1){let i=e[0];this.output.write(j.cursor.move(0,i)),this.output.write(j.erase.down());let r=t.split(`
|
|
11
|
+
`).slice(i);this.output.write(r.join(`
|
|
12
|
+
`)),this._prevFrame=t;return}this.output.write(j.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function xn({input:t=on,output:e=sn,overwrite:i=!0,hideCursor:r=!0}={}){let o=H.createInterface({input:t,output:e,prompt:"",tabSize:1});H.emitKeypressEvents(t,o),t.isTTY&&t.setRawMode(!0);let s=(n,{name:m})=>{if(String(n)==="\x03"){r&&e.write(j.cursor.show),process.exit(0);return}if(!i)return;H.moveCursor(e,m==="return"?0:-1,m==="return"?-1:0,()=>{H.clearLine(e,1,()=>{t.once("keypress",s)})})};return r&&e.write(j.cursor.hide),t.once("keypress",s),()=>{t.off("keypress",s),r&&e.write(j.cursor.show),t.isTTY&&!kr&&t.setRawMode(!1),o.terminal=!1,o.close()}}var j,L,Ci,an,Ei,Pi,Li=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},Fi,Et=10,He=(t=0)=>(e)=>`\x1B[${e+t}m`,Ue=(t=0)=>(e)=>`\x1B[${38+t};5;${e}m`,Ce=(t=0)=>(e,i,r)=>`\x1B[${38+t};2;${e};${i};${r}m`,S,Di,tr,nr,At,ir=39,Lt="\x07",un="[",rr="]",$n="m",Ft,Ee=(t)=>`${At.values().next().value}${un}${t}${$n}`,Pe=(t)=>`${At.values().next().value}${Ft}${t}${Lt}`,or=(t)=>t.split(" ").map((e)=>ut(e)),Pt=(t,e,i)=>{let r=[...e],o=!1,s=!1,n=ut(pn(t[t.length-1]));for(let[m,a]of r.entries()){let u=ut(a);if(n+u<=i?t[t.length-1]+=a:(t.push(a),n=0),At.has(a)&&(o=!0,s=r.slice(m+1).join("").startsWith(Ft)),o){s?a===Lt&&(o=!1,s=!1):a===$n&&(o=!1);continue}n+=u,n===i&&m<r.length-1&&(t.push(""),n=0)}!n&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},sr=(t)=>{let e=t.split(" "),i=e.length;for(;i>0&&!(ut(e[i-1])>0);)i--;return i===e.length?t:e.slice(0,i).join(" ")+e.slice(i).join("")},pr=(t,e,i={})=>{if(i.trim!==!1&&t.trim()==="")return"";let r="",o,s,n=or(t),m=[""];for(let[u,y]of t.split(" ").entries()){i.trim!==!1&&(m[m.length-1]=m[m.length-1].trimStart());let $=ut(m[m.length-1]);if(u!==0&&($>=e&&(i.wordWrap===!1||i.trim===!1)&&(m.push(""),$=0),($>0||i.trim===!1)&&(m[m.length-1]+=" ",$++)),i.hard&&n[u]>e){let h=e-$,b=1+Math.floor((n[u]-h-1)/e);Math.floor((n[u]-1)/e)<b&&m.push(""),Pt(m,y,e);continue}if($+n[u]>e&&$>0&&n[u]>0){if(i.wordWrap===!1&&$<e){Pt(m,y,e);continue}m.push("")}if($+n[u]>e&&i.wordWrap===!1){Pt(m,y,e);continue}m[m.length-1]+=y}i.trim!==!1&&(m=m.map((u)=>sr(u)));let a=[...m.join(`
|
|
13
|
+
`)];for(let[u,y]of a.entries()){if(r+=y,At.has(y)){let{groups:h}=new RegExp(`(?:\\${un}(?<code>\\d+)m|\\${Ft}(?<uri>.*)${Lt})`).exec(a.slice(u).join(""))||{groups:{}};if(h.code!==void 0){let b=Number.parseFloat(h.code);o=b===ir?void 0:b}else h.uri!==void 0&&(s=h.uri.length===0?void 0:h.uri)}let $=nr.codes.get(Number(o));a[u+1]===`
|
|
14
|
+
`?(s&&(r+=Pe("")),o&&$&&(r+=Ee($))):y===`
|
|
15
|
+
`&&(o&&$&&(r+=Ee(o)),s&&(r+=Pe(s)))}return r},mr,ar=(t,e,i)=>(e in t)?mr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,N=(t,e,i)=>(ar(t,typeof e!="symbol"?e+"":e,i),i),ln,Fe,$r,Dt,lr,cr=(t,e,i)=>(e in t)?lr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,De=(t,e,i)=>(cr(t,typeof e!="symbol"?e+"":e,i),i),te,yr,xr=(t,e,i)=>(e in t)?yr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,tn=(t,e,i)=>(xr(t,typeof e!="symbol"?e+"":e,i),i),cn,hr,br=(t,e,i)=>(e in t)?hr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,en=(t,e,i)=>(br(t,typeof e!="symbol"?e+"":e,i),i),ee,wr,dr=(t,e,i)=>(e in t)?wr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,nn=(t,e,i)=>(dr(t,typeof e!="symbol"?e+"":e,i),i),yn,_r,vr=(t,e,i)=>(e in t)?_r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,rn=(t,e,i)=>(vr(t,typeof e!="symbol"?e+"":e,i),i),ne,fr,Sr=(t,e,i)=>(e in t)?fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Rr=(t,e,i)=>(Sr(t,typeof e!="symbol"?e+"":e,i),i),ie,kr;var re=ye(()=>{j=Y(Ht(),1),L=Y(Ct(),1);Ci=Ui();an={exports:{}};(function(t){var e={};t.exports=e,e.eastAsianWidth=function(r){var o=r.charCodeAt(0),s=r.length==2?r.charCodeAt(1):0,n=o;return 55296<=o&&o<=56319&&56320<=s&&s<=57343&&(o&=1023,s&=1023,n=o<<10|s,n+=65536),n==12288||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":n==8361||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||n==172||n==175||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":n==161||n==164||167<=n&&n<=168||n==170||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||n==198||n==208||215<=n&&n<=216||222<=n&&n<=225||n==230||232<=n&&n<=234||236<=n&&n<=237||n==240||242<=n&&n<=243||247<=n&&n<=250||n==252||n==254||n==257||n==273||n==275||n==283||294<=n&&n<=295||n==299||305<=n&&n<=307||n==312||319<=n&&n<=322||n==324||328<=n&&n<=331||n==333||338<=n&&n<=339||358<=n&&n<=359||n==363||n==462||n==464||n==466||n==468||n==470||n==472||n==474||n==476||n==593||n==609||n==708||n==711||713<=n&&n<=715||n==717||n==720||728<=n&&n<=731||n==733||n==735||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||n==1025||1040<=n&&n<=1103||n==1105||n==8208||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||n==8240||8242<=n&&n<=8243||n==8245||n==8251||n==8254||n==8308||n==8319||8321<=n&&n<=8324||n==8364||n==8451||n==8453||n==8457||n==8467||n==8470||8481<=n&&n<=8482||n==8486||n==8491||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||n==8585||8592<=n&&n<=8601||8632<=n&&n<=8633||n==8658||n==8660||n==8679||n==8704||8706<=n&&n<=8707||8711<=n&&n<=8712||n==8715||n==8719||n==8721||n==8725||n==8730||8733<=n&&n<=8736||n==8739||n==8741||8743<=n&&n<=8748||n==8750||8756<=n&&n<=8759||8764<=n&&n<=8765||n==8776||n==8780||n==8786||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||n==8853||n==8857||n==8869||n==8895||n==8978||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||n==9675||9678<=n&&n<=9681||9698<=n&&n<=9701||n==9711||9733<=n&&n<=9734||n==9737||9742<=n&&n<=9743||9748<=n&&n<=9749||n==9756||n==9758||n==9792||n==9794||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||n==9839||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||n==9955||9960<=n&&n<=9983||n==10045||n==10071||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||n==65533||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"},e.characterLength=function(r){var o=this.eastAsianWidth(r);return o=="F"||o=="W"||o=="A"?2:1};function i(r){return r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(r){for(var o=i(r),s=0,n=0;n<o.length;n++)s=s+this.characterLength(o[n]);return s},e.slice=function(r,o,s){textLen=e.length(r),o=o||0,s=s||1,o<0&&(o=textLen+o),s<0&&(s=textLen+s);for(var n="",m=0,a=i(r),u=0;u<a.length;u++){var y=a[u],$=e.length(y);if(m>=o-($==2?1:0))if(m+$<=s)n+=y;else break;m+=$}return n}})(an);Ei=an.exports,Pi=mn(Ei),Fi=mn(Li);S={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(S.modifier);Di=Object.keys(S.color),tr=Object.keys(S.bgColor);[...Di,...tr];nr=er(),At=new Set(["\x1B",""]),Ft=`${rr}8;;`;mr=Object.defineProperty;ln=Symbol("clack:cancel");Fe=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),$r=new Set(["up","down","left","right","space","enter"]);Dt=class Dt extends U{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(e)=>{this.output.write(j.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};lr=Object.defineProperty;te=class te extends U{constructor(t){super(t,!1),De(this,"options"),De(this,"cursor",0);let{options:e}=t;this.options=Object.entries(e).flatMap(([i,r])=>[{value:i,group:!0,label:i},...r.map((o)=>({...o,group:i}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:i})=>i===t.cursorAt),0),this.on("cursor",(i)=>{switch(i){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(t){return this.options.filter((e)=>e.group===t)}isGroupSelected(t){return this.getGroupItems(t).every((e)=>this.value.includes(e.value))}toggleValue(){let t=this.options[this.cursor];if(t.group===!0){let e=t.value,i=this.getGroupItems(e);this.isGroupSelected(e)?this.value=this.value.filter((r)=>i.findIndex((o)=>o.value===r)===-1):this.value=[...this.value,...i.map((r)=>r.value)],this.value=Array.from(new Set(this.value))}else{let e=this.value.includes(t.value);this.value=e?this.value.filter((i)=>i!==t.value):[...this.value,t.value]}}};yr=Object.defineProperty,cn=class extends U{constructor(t){super(t,!1),tn(this,"options"),tn(this,"cursor",0),this.options=t.options,this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===t.cursorAt),0),this.on("key",(e)=>{e==="a"&&this.toggleAll()}),this.on("cursor",(e)=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let t=this.value.length===this.options.length;this.value=t?[]:this.options.map((e)=>e.value)}toggleValue(){let t=this.value.includes(this._value);this.value=t?this.value.filter((e)=>e!==this._value):[...this.value,this._value]}},hr=Object.defineProperty;ee=class ee extends U{constructor({mask:t,...e}){super(e),en(this,"valueWithCursor",""),en(this,"_mask","•"),this._mask=t??"•",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${L.default.inverse(L.default.hidden("_"))}`;else{let i=this.masked.slice(0,this.cursor),r=this.masked.slice(this.cursor);this.valueWithCursor=`${i}${L.default.inverse(r[0])}${r.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};wr=Object.defineProperty,yn=class extends U{constructor(t){super(t,!1),nn(this,"options"),nn(this,"cursor",0),this.options=t.options,this.cursor=this.options.findIndex(({value:e})=>e===t.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(e)=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},_r=Object.defineProperty;ne=class ne extends U{constructor(t){super(t,!1),rn(this,"options"),rn(this,"cursor",0),this.options=t.options;let e=this.options.map(({value:[i]})=>i?.toLowerCase());this.cursor=Math.max(e.indexOf(t.initialValue),0),this.on("key",(i)=>{if(!e.includes(i))return;let r=this.options.find(({value:[o]})=>o?.toLowerCase()===i);r&&(this.value=r.value,this.state="submit",this.emit("submit"))})}};fr=Object.defineProperty;ie=class ie extends U{constructor(t){super(t),Rr(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${L.default.inverse(L.default.hidden("_"))}`;else{let e=this.value.slice(0,this.cursor),i=this.value.slice(this.cursor);this.valueWithCursor=`${e}${L.default.inverse(i[0])}${i.slice(1)}`}})}get cursor(){return this._cursor}};kr=globalThis.process.platform.startsWith("win")});var qt={};ui(qt,{text:()=>zr,spinner:()=>Cr,selectKey:()=>Xr,select:()=>Kr,password:()=>Jr,outro:()=>Ur,note:()=>Zr,multiselect:()=>Qr,log:()=>F,isCancel:()=>jt,intro:()=>Hr,groupMultiselect:()=>Vr,group:()=>Pr,confirm:()=>Yr,cancel:()=>Wr});import z from"node:process";function gr(){return z.platform!=="win32"?z.env.TERM!=="linux":Boolean(z.env.CI)||Boolean(z.env.WT_SESSION)||Boolean(z.env.TERMINUS_SUBLIME)||z.env.ConEmuTask==="{cmd::Cmder}"||z.env.TERM_PROGRAM==="Terminus-Sublime"||z.env.TERM_PROGRAM==="vscode"||z.env.TERM==="xterm-256color"||z.env.TERM==="alacritty"||z.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function Er(){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}var p,st,se,R=(t,e)=>se?t:e,Ar,bn,wn,Mt,jr,x,T,pe,me,ae,$t,dn,Mr,hn,qr,Tr,Or,Gr,Nr,Br,Ir,D=(t)=>{switch(t){case"initial":case"active":return p.default.cyan(Ar);case"cancel":return p.default.red(bn);case"error":return p.default.yellow(wn);case"submit":return p.default.green(Mt)}},zr=(t)=>new ie({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let e=`${p.default.gray(x)}
|
|
16
|
+
${D(this.state)} ${t.message}
|
|
17
|
+
`,i=t.placeholder?p.default.inverse(t.placeholder[0])+p.default.dim(t.placeholder.slice(1)):p.default.inverse(p.default.hidden("_")),r=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${e.trim()}
|
|
18
|
+
${p.default.yellow(x)} ${r}
|
|
19
|
+
${p.default.yellow(T)} ${p.default.yellow(this.error)}
|
|
20
|
+
`;case"submit":return`${e}${p.default.gray(x)} ${p.default.dim(this.value||t.placeholder)}`;case"cancel":return`${e}${p.default.gray(x)} ${p.default.strikethrough(p.default.dim(this.value??""))}${this.value?.trim()?`
|
|
21
|
+
`+p.default.gray(x):""}`;default:return`${e}${p.default.cyan(x)} ${r}
|
|
22
|
+
${p.default.cyan(T)}
|
|
23
|
+
`}}}).prompt(),Jr=(t)=>new ee({validate:t.validate,mask:t.mask??Mr,render(){let e=`${p.default.gray(x)}
|
|
24
|
+
${D(this.state)} ${t.message}
|
|
25
|
+
`,i=this.valueWithCursor,r=this.masked;switch(this.state){case"error":return`${e.trim()}
|
|
26
|
+
${p.default.yellow(x)} ${r}
|
|
27
|
+
${p.default.yellow(T)} ${p.default.yellow(this.error)}
|
|
28
|
+
`;case"submit":return`${e}${p.default.gray(x)} ${p.default.dim(r)}`;case"cancel":return`${e}${p.default.gray(x)} ${p.default.strikethrough(p.default.dim(r??""))}${r?`
|
|
29
|
+
`+p.default.gray(x):""}`;default:return`${e}${p.default.cyan(x)} ${i}
|
|
30
|
+
${p.default.cyan(T)}
|
|
31
|
+
`}}}).prompt(),Yr=(t)=>{let e=t.active??"Yes",i=t.inactive??"No";return new Dt({active:e,inactive:i,initialValue:t.initialValue??!0,render(){let r=`${p.default.gray(x)}
|
|
32
|
+
${D(this.state)} ${t.message}
|
|
33
|
+
`,o=this.value?e:i;switch(this.state){case"submit":return`${r}${p.default.gray(x)} ${p.default.dim(o)}`;case"cancel":return`${r}${p.default.gray(x)} ${p.default.strikethrough(p.default.dim(o))}
|
|
34
|
+
${p.default.gray(x)}`;default:return`${r}${p.default.cyan(x)} ${this.value?`${p.default.green(pe)} ${e}`:`${p.default.dim(me)} ${p.default.dim(e)}`} ${p.default.dim("/")} ${this.value?`${p.default.dim(me)} ${p.default.dim(i)}`:`${p.default.green(pe)} ${i}`}
|
|
35
|
+
${p.default.cyan(T)}
|
|
36
|
+
`}}}).prompt()},Kr=(t)=>{let e=(r,o)=>{let s=r.label??String(r.value);return o==="active"?`${p.default.green(pe)} ${s} ${r.hint?p.default.dim(`(${r.hint})`):""}`:o==="selected"?`${p.default.dim(s)}`:o==="cancelled"?`${p.default.strikethrough(p.default.dim(s))}`:`${p.default.dim(me)} ${p.default.dim(s)}`},i=0;return new yn({options:t.options,initialValue:t.initialValue,render(){let r=`${p.default.gray(x)}
|
|
37
|
+
${D(this.state)} ${t.message}
|
|
38
|
+
`;switch(this.state){case"submit":return`${r}${p.default.gray(x)} ${e(this.options[this.cursor],"selected")}`;case"cancel":return`${r}${p.default.gray(x)} ${e(this.options[this.cursor],"cancelled")}
|
|
39
|
+
${p.default.gray(x)}`;default:{let o=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=i+o-3?i=Math.max(Math.min(this.cursor-o+3,this.options.length-o),0):this.cursor<i+2&&(i=Math.max(this.cursor-2,0));let s=o<this.options.length&&i>0,n=o<this.options.length&&i+o<this.options.length;return`${r}${p.default.cyan(x)} ${this.options.slice(i,i+o).map((m,a,u)=>a===0&&s?p.default.dim("..."):a===u.length-1&&n?p.default.dim("..."):e(m,a+i===this.cursor?"active":"inactive")).join(`
|
|
40
|
+
${p.default.cyan(x)} `)}
|
|
41
|
+
${p.default.cyan(T)}
|
|
42
|
+
`}}}}).prompt()},Xr=(t)=>{let e=(i,r="inactive")=>{let o=i.label??String(i.value);return r==="selected"?`${p.default.dim(o)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(o))}`:r==="active"?`${p.default.bgCyan(p.default.gray(` ${i.value} `))} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:`${p.default.gray(p.default.bgWhite(p.default.inverse(` ${i.value} `)))} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`};return new ne({options:t.options,initialValue:t.initialValue,render(){let i=`${p.default.gray(x)}
|
|
43
|
+
${D(this.state)} ${t.message}
|
|
44
|
+
`;switch(this.state){case"submit":return`${i}${p.default.gray(x)} ${e(this.options.find((r)=>r.value===this.value),"selected")}`;case"cancel":return`${i}${p.default.gray(x)} ${e(this.options[0],"cancelled")}
|
|
45
|
+
${p.default.gray(x)}`;default:return`${i}${p.default.cyan(x)} ${this.options.map((r,o)=>e(r,o===this.cursor?"active":"inactive")).join(`
|
|
46
|
+
${p.default.cyan(x)} `)}
|
|
47
|
+
${p.default.cyan(T)}
|
|
48
|
+
`}}}).prompt()},Qr=(t)=>{let e=(i,r)=>{let o=i.label??String(i.value);return r==="active"?`${p.default.cyan(ae)} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="selected"?`${p.default.green($t)} ${p.default.dim(o)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(o))}`:r==="active-selected"?`${p.default.green($t)} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="submitted"?`${p.default.dim(o)}`:`${p.default.dim(dn)} ${p.default.dim(o)}`};return new cn({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
|
|
49
|
+
${p.default.reset(p.default.dim(`Press ${p.default.gray(p.default.bgWhite(p.default.inverse(" space ")))} to select, ${p.default.gray(p.default.bgWhite(p.default.inverse(" enter ")))} to submit`))}`},render(){let i=`${p.default.gray(x)}
|
|
50
|
+
${D(this.state)} ${t.message}
|
|
51
|
+
`;switch(this.state){case"submit":return`${i}${p.default.gray(x)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>e(r,"submitted")).join(p.default.dim(", "))||p.default.dim("none")}`;case"cancel":{let r=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>e(o,"cancelled")).join(p.default.dim(", "));return`${i}${p.default.gray(x)} ${r.trim()?`${r}
|
|
52
|
+
${p.default.gray(x)}`:""}`}case"error":{let r=this.error.split(`
|
|
53
|
+
`).map((o,s)=>s===0?`${p.default.yellow(T)} ${p.default.yellow(o)}`:` ${o}`).join(`
|
|
54
|
+
`);return i+p.default.yellow(x)+" "+this.options.map((o,s)=>{let n=this.value.includes(o.value),m=s===this.cursor;return m&&n?e(o,"active-selected"):n?e(o,"selected"):e(o,m?"active":"inactive")}).join(`
|
|
55
|
+
${p.default.yellow(x)} `)+`
|
|
56
|
+
`+r+`
|
|
57
|
+
`}default:return`${i}${p.default.cyan(x)} ${this.options.map((r,o)=>{let s=this.value.includes(r.value),n=o===this.cursor;return n&&s?e(r,"active-selected"):s?e(r,"selected"):e(r,n?"active":"inactive")}).join(`
|
|
58
|
+
${p.default.cyan(x)} `)}
|
|
59
|
+
${p.default.cyan(T)}
|
|
60
|
+
`}}}).prompt()},Vr=(t)=>{let e=(i,r,o=[])=>{let s=i.label??String(i.value),n=typeof i.group=="string",m=n&&(o[o.indexOf(i)+1]??{group:!0}),a=n&&m.group===!0,u=n?`${a?T:x} `:"";return r==="active"?`${p.default.dim(u)}${p.default.cyan(ae)} ${s} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="group-active"?`${u}${p.default.cyan(ae)} ${p.default.dim(s)}`:r==="group-active-selected"?`${u}${p.default.green($t)} ${p.default.dim(s)}`:r==="selected"?`${p.default.dim(u)}${p.default.green($t)} ${p.default.dim(s)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(s))}`:r==="active-selected"?`${p.default.dim(u)}${p.default.green($t)} ${s} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="submitted"?`${p.default.dim(s)}`:`${p.default.dim(u)}${p.default.dim(dn)} ${p.default.dim(s)}`};return new te({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
|
|
61
|
+
${p.default.reset(p.default.dim(`Press ${p.default.gray(p.default.bgWhite(p.default.inverse(" space ")))} to select, ${p.default.gray(p.default.bgWhite(p.default.inverse(" enter ")))} to submit`))}`},render(){let i=`${p.default.gray(x)}
|
|
62
|
+
${D(this.state)} ${t.message}
|
|
63
|
+
`;switch(this.state){case"submit":return`${i}${p.default.gray(x)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>e(r,"submitted")).join(p.default.dim(", "))}`;case"cancel":{let r=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>e(o,"cancelled")).join(p.default.dim(", "));return`${i}${p.default.gray(x)} ${r.trim()?`${r}
|
|
64
|
+
${p.default.gray(x)}`:""}`}case"error":{let r=this.error.split(`
|
|
65
|
+
`).map((o,s)=>s===0?`${p.default.yellow(T)} ${p.default.yellow(o)}`:` ${o}`).join(`
|
|
66
|
+
`);return`${i}${p.default.yellow(x)} ${this.options.map((o,s,n)=>{let m=this.value.includes(o.value)||o.group===!0&&this.isGroupSelected(`${o.value}`),a=s===this.cursor;return!a&&typeof o.group=="string"&&this.options[this.cursor].value===o.group?e(o,m?"group-active-selected":"group-active",n):a&&m?e(o,"active-selected",n):m?e(o,"selected",n):e(o,a?"active":"inactive",n)}).join(`
|
|
67
|
+
${p.default.yellow(x)} `)}
|
|
68
|
+
${r}
|
|
69
|
+
`}default:return`${i}${p.default.cyan(x)} ${this.options.map((r,o,s)=>{let n=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),m=o===this.cursor;return!m&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?e(r,n?"group-active-selected":"group-active",s):m&&n?e(r,"active-selected",s):n?e(r,"selected",s):e(r,m?"active":"inactive",s)}).join(`
|
|
70
|
+
${p.default.cyan(x)} `)}
|
|
71
|
+
${p.default.cyan(T)}
|
|
72
|
+
`}}}).prompt()},oe=(t)=>t.replace(Er(),""),Zr=(t="",e="")=>{let i=`
|
|
73
|
+
${t}
|
|
74
|
+
`.split(`
|
|
75
|
+
`),r=oe(e).length,o=Math.max(i.reduce((n,m)=>(m=oe(m),m.length>n?m.length:n),0),r)+2,s=i.map((n)=>`${p.default.gray(x)} ${p.default.dim(n)}${" ".repeat(o-oe(n).length)}${p.default.gray(x)}`).join(`
|
|
76
|
+
`);process.stdout.write(`${p.default.gray(x)}
|
|
77
|
+
${p.default.green(Mt)} ${p.default.reset(e)} ${p.default.gray(hn.repeat(Math.max(o-r-1,1))+qr)}
|
|
78
|
+
${s}
|
|
79
|
+
${p.default.gray(Tr+hn.repeat(o+2)+Or)}
|
|
80
|
+
`)},Wr=(t="")=>{process.stdout.write(`${p.default.gray(T)} ${p.default.red(t)}
|
|
81
|
+
|
|
82
|
+
`)},Hr=(t="")=>{process.stdout.write(`${p.default.gray(jr)} ${t}
|
|
83
|
+
`)},Ur=(t="")=>{process.stdout.write(`${p.default.gray(x)}
|
|
84
|
+
${p.default.gray(T)} ${t}
|
|
85
|
+
|
|
86
|
+
`)},F,Cr=()=>{let t=se?["◒","◐","◓","◑"]:["•","o","O","0"],e=se?80:120,i,r,o=!1,s="",n=(y="")=>{o=!0,i=xn(),s=y.replace(/\.+$/,""),process.stdout.write(`${p.default.gray(x)}
|
|
87
|
+
`);let $=0,h=0;r=setInterval(()=>{let b=p.default.magenta(t[$]),f=".".repeat(Math.floor(h)).slice(0,3);process.stdout.write(st.cursor.move(-999,0)),process.stdout.write(st.erase.down(1)),process.stdout.write(`${b} ${s}${f}`),$=$+1<t.length?$+1:0,h=h<t.length?h+0.125:0},e)},m=(y="",$=0)=>{s=y??s,o=!1,clearInterval(r);let h=$===0?p.default.green(Mt):$===1?p.default.red(bn):p.default.red(wn);process.stdout.write(st.cursor.move(-999,0)),process.stdout.write(st.erase.down(1)),process.stdout.write(`${h} ${s}
|
|
88
|
+
`),i()},a=(y="")=>{s=y??s},u=(y)=>{let $=y>1?"Something went wrong":"Canceled";o&&m($,y)};return process.on("uncaughtExceptionMonitor",()=>u(2)),process.on("unhandledRejection",()=>u(2)),process.on("SIGINT",()=>u(1)),process.on("SIGTERM",()=>u(1)),process.on("exit",u),{start:n,stop:m,message:a}},Pr=async(t,e)=>{let i={},r=Object.keys(t);for(let o of r){let s=t[o],n=await s({results:i})?.catch((m)=>{throw m});if(typeof e?.onCancel=="function"&&jt(n)){i[o]="canceled",e.onCancel({results:i});continue}i[o]=n}return i};var Tt=ye(()=>{re();re();p=Y(Ct(),1),st=Y(Ht(),1);se=gr(),Ar=R("◆","*"),bn=R("■","x"),wn=R("▲","x"),Mt=R("◇","o"),jr=R("┌","T"),x=R("│","|"),T=R("└","—"),pe=R("●",">"),me=R("○"," "),ae=R("◻","[•]"),$t=R("◼","[+]"),dn=R("◻","[ ]"),Mr=R("▪","•"),hn=R("─","-"),qr=R("╮","+"),Tr=R("├","+"),Or=R("╯","+"),Gr=R("●","•"),Nr=R("◆","*"),Br=R("▲","!"),Ir=R("■","x"),F={message:(t="",{symbol:e=p.default.gray(x)}={})=>{let i=[`${p.default.gray(x)}`];if(t){let[r,...o]=t.split(`
|
|
89
|
+
`);i.push(`${e} ${r}`,...o.map((s)=>`${p.default.gray(x)} ${s}`))}process.stdout.write(`${i.join(`
|
|
90
|
+
`)}
|
|
91
|
+
`)},info:(t)=>{F.message(t,{symbol:p.default.blue(Gr)})},success:(t)=>{F.message(t,{symbol:p.default.green(Nr)})},step:(t)=>{F.message(t,{symbol:p.default.green(Mt)})},warn:(t)=>{F.message(t,{symbol:p.default.yellow(Br)})},warning:(t)=>{F.warn(t)},error:(t)=>{F.message(t,{symbol:p.default.red(Ir)})}}});function zt(t){return t.replace(/-([a-z])/g,(e,i)=>i.toUpperCase())}function li(t){let e=t.flag.match(/^--([a-z][a-z0-9-]*)/i);return e?zt(e[1]):null}function ci(t){if(t.type==="boolean")return!0;if(t.type==="string"||t.type==="number"||t.type==="array")return!1;return!t.flag.includes("<")&&!t.flag.includes("[")}function xe(t){let e=new Set,i=new Set,r=new Set;for(let o of t){let s=li(o);if(!s)continue;if(ci(o))e.add(s);else if(o.type==="number")i.add(s);else if(o.type==="array")r.add(s)}return{booleans:e,numbers:i,arrays:r}}function he(t,e=[]){let i=xe(e),r=[],o=0;while(o<t.length){let s=t[o];if(s==="--")break;if(s.startsWith("--")){let n=s.indexOf("="),m=n!==-1?s.slice(2,n):s.slice(2),a=zt(m);if(!i.booleans.has(a)&&n===-1)o+=2;else o+=1;continue}if(s.startsWith("-")){o++;continue}r.push(s),o++}return r}function Jt(t,e){let i=xe(e),r={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},o=0;while(o<t.length){let s=t[o];if(s==="--help"||s==="-h"){r.help=!0,o++;continue}if(s==="--")break;if(s.startsWith("--")){let n=s.indexOf("="),m,a;if(n!==-1)m=s.slice(2,n),a=s.slice(n+1);else m=s.slice(2);let u=zt(m);if(i.booleans.has(u)){r[u]=!0,o++;continue}if(a===void 0)o++,a=t[o];if(a===void 0)throw Error(`Flag --${m} requires a value.`);if(i.arrays.has(u)){let y=r[u];if(y)y.push(a);else r[u]=[a]}else if(i.numbers.has(u))r[u]=Number(a);else r[u]=a}o++}return r}var l={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10};class c extends Error{exitCode;hint;constructor(t,e=l.GENERAL,i){super(t);this.name="CLIError",this.exitCode=e,this.hint=i}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}function d(t){return{name:t.name,description:t.description,usage:t.usage,options:t.options,examples:t.examples,execute:t.run}}var ht=[{flag:"--api-key <key>",description:"API key"},{flag:"--region <region>",description:"API region: global, cn"},{flag:"--base-url <url>",description:"API base URL"},{flag:"--output <format>",description:"Output format: text, json"},{flag:"--timeout <seconds>",description:"Request timeout",type:"number"},{flag:"--quiet",description:"Suppress non-essential output"},{flag:"--verbose",description:"Print HTTP request/response details"},{flag:"--no-color",description:"Disable ANSI colors"},{flag:"--dry-run",description:"Dry run mode"},{flag:"--non-interactive",description:"Disable interactive prompts"},{flag:"--help",description:"Show help"},{flag:"--version",description:"Print version"}];import{readFileSync as hi,writeFileSync as bi,renameSync as wi,unlinkSync as di,existsSync as be,statSync as _i}from"fs";import{homedir as yi}from"os";import{join as Yt}from"path";var xi=".mmx";function at(){return Yt(yi(),xi)}function Q(){return Yt(at(),"config.json")}function bt(){return Yt(at(),"credentials.json")}async function wt(){let t=at();await(await import("fs/promises")).mkdir(t,{recursive:!0,mode:448})}async function B(){let t=bt();if(!be(t))return null;try{vi(t);let e=hi(t,"utf-8"),i=JSON.parse(e);if(!i.access_token||!i.refresh_token)return null;return i}catch(e){let i=e;if(i instanceof SyntaxError||i.message.includes("JSON"))process.stderr.write(`Warning: credentials file is corrupted. Run 'mmx auth logout' to reset.
|
|
92
|
+
`);return null}}async function rt(t){await wt();let e=bt(),i=e+".tmp";bi(i,JSON.stringify(t,null,2)+`
|
|
93
|
+
`,{mode:384}),wi(i,e)}async function we(){let t=bt();if(be(t))di(t)}function vi(t){try{let i=_i(t).mode&511;if(i!==384)process.stderr.write(`Warning: ${t} has permissions ${i.toString(8)}, expected 600.
|
|
94
|
+
`)}catch{}}var de={clientId:"mmx-cli",authorizationUrl:"https://platform.minimax.io/oauth/authorize",tokenUrl:"https://api.minimax.io/v1/oauth/token",deviceCodeUrl:"https://api.minimax.io/v1/oauth/device/code",scopes:["api"],callbackPort:18991};async function _e(t=de){let{randomBytes:e,createHash:i}=await import("crypto"),r=e(32).toString("base64url"),o=i("sha256").update(r).digest("base64url"),s=e(16).toString("hex"),n=new URLSearchParams({client_id:t.clientId,response_type:"code",redirect_uri:`http://localhost:${t.callbackPort}/callback`,scope:t.scopes.join(" "),state:s,code_challenge:o,code_challenge_method:"S256"}),m=`${t.authorizationUrl}?${n}`,{exec:a}=await import("child_process"),u=process.platform;a(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} "${m}"`),process.stderr.write(`Opening browser to authenticate with MiniMax...
|
|
95
|
+
`);let $=await fi(t.callbackPort,s),h=await fetch(t.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:$,client_id:t.clientId,redirect_uri:`http://localhost:${t.callbackPort}/callback`,code_verifier:r})});if(!h.ok){let b=await h.text();throw new c(`OAuth token exchange failed: ${b}`,l.AUTH)}return await h.json()}async function fi(t,e){return new Promise((i,r)=>{let o=setTimeout(()=>{s.stop(),r(new c("OAuth callback timed out.",l.TIMEOUT))},120000),s=Bun.serve({port:t,fetch(n){let m=new URL(n.url);if(m.pathname!=="/callback")return new Response("Not found",{status:404});let a=m.searchParams.get("code"),u=m.searchParams.get("state"),y=m.searchParams.get("error");if(y)return clearTimeout(o),s.stop(),r(new c(`OAuth error: ${y}`,l.AUTH)),new Response("<html><body><h1>Authentication Failed</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}});if(!a||u!==e)return clearTimeout(o),s.stop(),r(new c("Invalid OAuth callback.",l.AUTH)),new Response("Invalid callback",{status:400});return clearTimeout(o),s.stop(),i(a),new Response("<html><body><h1>Authentication Successful</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}})}})})}async function ve(t=de){let e=await fetch(t.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:t.clientId,scope:t.scopes.join(" ")})});if(!e.ok)throw new c("Failed to start device code flow.",l.AUTH);let{device_code:i,user_code:r,verification_uri:o,interval:s,expires_in:n}=await e.json();process.stderr.write(`
|
|
96
|
+
Visit: ${o}
|
|
97
|
+
`),process.stderr.write(`Enter code: ${r}
|
|
98
|
+
`),process.stderr.write(`Waiting for authorization...
|
|
99
|
+
`);let m=Date.now()+n*1000,a=(s||5)*1000;while(Date.now()<m){await new Promise(($)=>setTimeout($,a));let u=await fetch(t.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:i,client_id:t.clientId})});if(u.ok)return await u.json();let y=await u.json();if(y.error==="authorization_pending")continue;if(y.error==="slow_down"){await new Promise(($)=>setTimeout($,5000));continue}throw new c(`Device code authorization failed: ${y.error}`,l.AUTH)}throw new c("Device code authorization timed out.",l.TIMEOUT)}var Si="https://api.minimax.io/v1/oauth/token";async function Kt(t){let e=await fetch(Si,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:t})});if(!e.ok)throw new c("OAuth session expired and could not be refreshed.",l.AUTH,"Re-authenticate: mmx auth login");return await e.json()}async function fe(t){let e=new Date(t.expires_at).getTime(),i=300000;if(Date.now()<e-300000)return t.access_token;let r=await Kt(t.refresh_token),o={access_token:r.access_token,refresh_token:r.refresh_token,expires_at:new Date(Date.now()+r.expires_in*1000).toISOString(),token_type:"Bearer",account:t.account};return await rt(o),o.access_token}async function dt(t){if(t.apiKey)return{token:t.apiKey,method:"api-key",source:"flag"};let e=await B();if(e)return{token:await fe(e),method:"oauth",source:"credentials.json"};if(t.fileApiKey)return{token:t.fileApiKey,method:"api-key",source:"config.json"};throw new c("No credentials found.",l.AUTH,`Log in: mmx auth login
|
|
100
|
+
Pass directly: --api-key sk-xxxxx`)}function Se(t){if(!t)return"";if(t.includes("/t2a"))return`
|
|
101
|
+
|
|
102
|
+
Speech models require the Plus plan or above.`;if(t.includes("/image_generation"))return`
|
|
103
|
+
|
|
104
|
+
image-01 requires the Plus plan or above.`;if(t.includes("/video_generation")||t.includes("/query/video_generation"))return`
|
|
105
|
+
|
|
106
|
+
Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;if(t.includes("/music_generation"))return`
|
|
107
|
+
|
|
108
|
+
Music-2.5 requires the Max plan or above.`;return""}function Re(t){return`${t?.includes("minimaxi.com")?"https://platform.minimaxi.com":"https://platform.minimax.io"}/subscribe/token-plan`}function Xt(t,e,i){let r=e.base_resp?.status_msg||e.error?.message||`HTTP ${t}`,o=e.base_resp?.status_code||e.error?.code;if(t===401||t===403)return new c(`API key rejected (HTTP ${t}).`,l.AUTH,`Check status: mmx auth status
|
|
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
|
+
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
|
+
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",V="\x1B[2m",Ri="\x1B[1m",ki="\x1B[38;2;43;82;255m",gi="\x1B[38;2;147;51;234m",Ai="\x1B[38;2;6;184;212m",ji="\x1B[38;2;236;72;153m";function Mi(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?Mi(t.configPath):"~/.mmx/config.json",o=t.fileRegion?`${t.fileRegion} (file)`:"global (default)",s=t.apiKey?"(flag)":"(file)",n=I(e),m=i?` ${V}|${G} ${V}Model:${G} ${gi}${i}${G}`:"";process.stderr.write(`${Ri}${ki}MINIMAX${G} ${V}${r}${G} ${V}|${G} ${V}Region:${G} ${Ai}${o}${G} ${V}|${G} ${V}Key:${G} ${ji}${n}${G} ${V}${s}${G}${m}
|
|
112
|
+
`)}async function E(t,e){let i=typeof FormData<"u"&&e.body instanceof FormData,r="1.0.0",o={"User-Agent":"mmx-cli/1.0.0",...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
|
+
`),process.stderr.write(`> Auth: ${m.token.slice(0,8)}...
|
|
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
|
+
`);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 E(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 qi={dashboard:"Quota Dashboard",week:"Week",weekly:"Weekly",resetsIn:"Resets in",noData:"No quota data available.",now:"now"},Ti={dashboard:"配额面板",week:"周期",weekly:"每周",resetsIn:"重置于",noData:"暂无配额数据",now:"即将"};function Oi(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 Gi(t){return t>=11904&&t<=40959||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65281&&t<=65376||t>=131072&&t<=195103}function Z(t){let e=t.replace(/\x1b\[[0-9;]*m/g,""),i=0;for(let r of e)i+=Gi(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 ot(t,e){let i=!e.noColor&&process.stdout.isTTY===!0,r=e.region==="cn"?Ti:qi,o=t.length>0?Math.max(...t.map((b)=>b.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-Z(a)-Z(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=Z(a)+y+Z(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(`
|
|
116
|
+
${r.noData}
|
|
117
|
+
`);return}for(let b of t){console.log(ft(n,"├","─","┤",i));let{current_interval_usage_count:f,current_interval_total_count:g}=b,M=Math.max(0,g-f),J=g>0?Math.round(M/g*100):0,nt=b.current_weekly_usage_count,q=b.current_weekly_total_count,k=Math.max(0,q-nt),mt=Oi(b.remains_time,r.now),lt=b.model_name.padEnd(o),ct=`${M.toLocaleString()} / ${g.toLocaleString()}`,ei=ze(J,i),ni=o+2+15+2+s,ii=i?`\x1B[1m\x1B[38;2;255;255;255m${lt}\x1B[0m ${Je(J)[0]}${ct.padStart(15)}\x1B[0m ${ei}`:`${lt} ${ct.padStart(15)} ${ze(J,!1)}`;console.log(Qt(ii,n,ni,i));let yt=`└ ${r.weekly} ${k.toLocaleString()} / ${q.toLocaleString()}`,xt=`${r.resetsIn} ${mt}`,Bt=Math.max(2,n-2-2-Z(yt)-Z(xt)),ri=2+Z(yt)+Bt+Z(xt),oi=i?` \x1B[2m${yt}${" ".repeat(Bt)}${xt}\x1B[0m`:` ${yt}${" ".repeat(Bt)}${xt}`;console.log(Qt(oi,n,ri,i))}console.log(ft(n,"╰","─","╯",i)),console.log("")}import{readFileSync as zi,writeFileSync as Ji,renameSync as Yi,existsSync as Ki}from"fs";var W={global:"https://api.minimax.io",cn:"https://api.minimaxi.com"},Ni=new Set(["global","cn"]),Bi=new Set(["text","json"]);function Ye(t){if(!t||typeof t!=="object"||Array.isArray(t))return{};let e=t,i={};if(typeof e.api_key==="string")i.api_key=e.api_key;if(typeof e.region==="string"&&Ni.has(e.region))i.region=e.region;if(typeof e.base_url==="string"&&e.base_url.startsWith("http"))i.base_url=e.base_url;if(typeof e.output==="string"&&Bi.has(e.output))i.output=e.output;if(typeof e.timeout==="number"&&e.timeout>0)i.timeout=e.timeout;return i}function Ke(t){if(t===null||t===void 0)return"";if(typeof t==="string")return t;if(typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t)){if(t.length===0)return"(empty)";if(typeof t[0]==="object"&&t[0]!==null)return Ii(t);return t.map(String).join(`
|
|
118
|
+
`)}if(typeof t==="object")return Vt(t);return String(t)}function Vt(t,e=0){let i=" ".repeat(e),r=[];for(let[o,s]of Object.entries(t)){if(s===null||s===void 0)continue;if(Array.isArray(s)){r.push(`${i}${o}:`);for(let n of s)if(typeof n==="object"&&n!==null)r.push(`${i} - ${Vt(n,e+4).trimStart()}`);else r.push(`${i} - ${String(n)}`)}else if(typeof s==="object")r.push(`${i}${o}:`),r.push(Vt(s,e+2));else r.push(`${i}${o}: ${String(s)}`)}return r.join(`
|
|
119
|
+
`)}function Ii(t){if(t.length===0)return"(empty)";let e=Object.keys(t[0]),i=e.map((n)=>Math.max(n.length,...t.map((m)=>String(m[n]??"").length))),r=e.map((n,m)=>n.toUpperCase().padEnd(i[m])).join(" "),o=i.map((n)=>"-".repeat(n)).join(" "),s=t.map((n)=>e.map((m,a)=>String(n[m]??"").padEnd(i[a])).join(" "));return[r,o,...s].join(`
|
|
120
|
+
`)}function Xe(t){return JSON.stringify(t,null,2)}function _(t){if(t==="json"||t==="text")return t;if(!process.stdout.isTTY)return"json";return"text"}function w(t,e){switch(e){case"json":return Xe(t);case"text":return Ke(t)}}function O(){let t=Q();if(!Ki(t))return{};try{return Ye(JSON.parse(zi(t,"utf-8")))}catch(e){let i=e;if(i instanceof SyntaxError||i.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
|
|
121
|
+
`);return{}}}async function K(t){await wt();let e=Q(),i=e+".tmp";Ji(i,JSON.stringify(t,null,2)+`
|
|
122
|
+
`,{mode:384}),Yi(i,e)}function Zt(t){let e=O(),i=t.apiKey||void 0,r=e.api_key,o=t.region||process.env.MINIMAX_REGION||void 0,s=e.region,n=o||s||"global",m=i||r,a=!o&&(!s||m!==void 0&&m!==e.api_key),u=t.baseUrl||process.env.MINIMAX_BASE_URL||e.base_url||W[n]||W.global,y=_(t.output||process.env.MINIMAX_OUTPUT||e.output),$=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,h=$!==void 0&&Number.isFinite($)&&$>0?$:void 0,b=t.timeout??h??e.timeout??300;return{apiKey:i,fileApiKey:r,fileRegion:e.region,configPath:Q(),region:n,baseUrl:u,output:y,timeout:b,verbose:t.verbose||process.env.MINIMAX_VERBOSE==="1",quiet:t.quiet||!1,noColor:t.noColor||process.env.NO_COLOR!==void 0||!process.stdout.isTTY,yes:t.yes||!1,dryRun:t.dryRun||!1,nonInteractive:t.nonInteractive||!1,async:t.async||!1,needsRegionDetection:a}}function A(t){if(t?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}async function _n(t){try{let e=P(t.baseUrl),i=await v(t,{url:e});ot(i.model_remains||[],t)}catch{}}var vn=d({name:"auth login",description:"Authenticate via OAuth or API key",usage:"mmx auth login [--method oauth|api-key] [--api-key <key>] [--no-browser]",options:[{flag:"--method <method>",description:"Auth method: oauth (default), api-key"},{flag:"--api-key <key>",description:"API key to store"},{flag:"--no-browser",description:"Use device-code flow instead of browser"}],examples:["mmx auth login","mmx auth login --no-browser","mmx auth login --api-key sk-xxxxx","mmx auth login --method api-key --api-key sk-xxxxx"],async run(t,e){let i=process.env.MINIMAX_API_KEY;if(i&&!e.apiKey){let n=I(i);if(A({nonInteractive:t.nonInteractive})){let{confirm:m}=await Promise.resolve().then(() => (Tt(),qt));if(!await m({message:`Detected MINIMAX_API_KEY in environment (${n}).
|
|
123
|
+
You are already authenticated via env.
|
|
124
|
+
Do you still want to configure local persistent credentials?`,initialValue:!1}))process.stdout.write(`Login skipped. Using environment variables.
|
|
125
|
+
`),process.exit(0)}else process.stderr.write(`Warning: MINIMAX_API_KEY is already set in environment.
|
|
126
|
+
`)}if((e.apiKey?"api-key":e.method||"oauth")==="api-key"){let n=e.apiKey||t.apiKey;if(!n)throw new c("--api-key is required when using --method api-key.",l.USAGE,"mmx auth login --api-key sk-xxxxx");if(!t.dryRun){process.stderr.write("Testing key... ");try{let a={...t,apiKey:n};await v(a,{url:P(a.baseUrl)}),process.stderr.write(`Valid
|
|
127
|
+
`)}catch{throw new c("API key validation failed.",l.AUTH,"Check that your key is valid and belongs to a Token Plan.")}let m=O();m.api_key=n,await K(m),process.stderr.write(`API key saved to ${Q()}
|
|
128
|
+
`),await _n({...t,apiKey:n})}else console.log("Would validate and save API key.");return}if(t.dryRun){console.log("Would start OAuth login flow.");return}let o;if(e.noBrowser)o=await ve();else o=await _e();let s={access_token:o.access_token,refresh_token:o.refresh_token,expires_at:new Date(Date.now()+o.expires_in*1000).toISOString(),token_type:"Bearer"};await rt(s),process.stderr.write(`Logged in successfully.
|
|
129
|
+
`),process.stderr.write(`Credentials saved to ~/.mmx/credentials.json
|
|
130
|
+
`),await _n({...t,apiKey:s.access_token})}});var fn=d({name:"auth status",description:"Show current authentication state and quota snapshot",usage:"mmx auth status",examples:["mmx auth status","mmx auth status --output json"],async run(t,e){try{let i=await dt(t),r=_(t.output);if(r!=="text"){let s={method:i.method,source:i.source};if(i.method==="oauth"){let n=await B();if(n){if(s.token_expires=n.expires_at,n.account)s.account=n.account}}else s.key=I(i.token);console.log(w(s,r));return}console.log("Authentication Status:"),console.log(` Method: ${i.method}`),console.log(` Source: ${i.source}`);let o=i.token;if(console.log(` Key: ${I(o)}`),i.method==="oauth"){let s=await B();if(s){if(s.account)console.log(` Account: ${s.account}`);let n=new Date(s.expires_at),m=Math.round((n.getTime()-Date.now())/60000);console.log(` Expires in: ${m} minutes`)}}process.stderr.write(`Fetching quota snapshot...
|
|
131
|
+
`);try{let s=P(t.baseUrl),n=await v(t,{url:s,method:"GET"});ot(n.model_remains||[],t)}catch(s){console.log(` Quota fetch failed: ${s.message}`)}}catch{let i=_(t.output);console.log(w({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
|
|
132
|
+
Or set $MINIMAX_API_KEY`},i))}}});var Sn=d({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(t,e){let i=await B();if(!i)throw new c("Not applicable: not authenticated via OAuth.",l.USAGE,"Run mmx auth login first.");if(t.dryRun){console.log("Would refresh OAuth token.");return}let r=await Kt(i.refresh_token),o={access_token:r.access_token,refresh_token:r.refresh_token,expires_at:new Date(Date.now()+r.expires_in*1000).toISOString(),token_type:"Bearer",account:i.account};await rt(o);let s=_(t.output);if(t.quiet){console.log(o.expires_at);return}console.log(w({status:"Token refreshed",expires:o.expires_at},s))}});var Rn=d({name:"auth logout",description:"Revoke tokens and clear stored credentials",usage:"mmx auth logout [--yes] [--dry-run]",options:[{flag:"--yes",description:"Skip confirmation prompt"}],examples:["mmx auth logout","mmx auth logout --dry-run","mmx auth logout --yes"],async run(t,e){let i=await B(),r=O(),o=!!r.api_key;if(t.dryRun){if(i)console.log("Would remove ~/.mmx/credentials.json");if(o)console.log("Would clear api_key from ~/.mmx/config.json");if(!i&&!o)console.log("No credentials to clear.");console.log("No changes made.");return}if(i)await we(),process.stderr.write(`Removed ~/.mmx/credentials.json
|
|
133
|
+
`);if(o)try{let s=r;delete s.api_key,await K(s),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
|
|
134
|
+
`)}catch{}if(!i&&!o)process.stderr.write(`No credentials to clear.
|
|
135
|
+
`)}});async function*kn(t){let e=t.body?.getReader();if(!e)return;let i=new TextDecoder,r="";try{while(!0){let{done:o,value:s}=await e.read();if(o)break;r+=i.decode(s,{stream:!0});let n=r.split(`
|
|
136
|
+
`);r=n.pop()||"";let m={};for(let a of n){if(a===""){if(m.data!==void 0)yield{data:m.data,event:m.event,id:m.id};m={};continue}if(a.startsWith(":"))continue;let u=a.indexOf(":");if(u===-1)continue;let y=a.slice(0,u),$=a.slice(u+1).trimStart();switch(y){case"data":m.data=m.data!==void 0?`${m.data}
|
|
137
|
+
${$}`:$;break;case"event":m.event=$;break;case"id":m.id=$;break}}}if(r.trim()&&r.includes("data:")){let o=r.indexOf(":");if(o!==-1)yield{data:r.slice(o+1).trimStart()}}}finally{e.releaseLock()}}import{readFileSync as ue}from"fs";async function X(t){if(!A())return;let{defaultValue:e,message:i}=t,o=await(await Promise.resolve().then(() => (Tt(),qt))).text({message:i,default:e,placeholder:e});if(typeof o==="symbol")return;return o}async function gn(t){if(!A())return;let{message:e}=t,r=await(await Promise.resolve().then(() => (Tt(),qt))).confirm({message:e});if(typeof r==="symbol")return;return r}function pt(t,e){throw new c(`Missing required argument: --${t}
|
|
138
|
+
Hint: In non-interactive (CI / agent) environments all required flags must be provided.
|
|
139
|
+
In an interactive terminal, run without --${t} and the CLI will prompt for it.`,l.USAGE,e)}function Lr(t){let e=[],i;if(t.system)i=t.system;if(t.messagesFile){let r=t.messagesFile,o=r==="-"?ue("/dev/stdin","utf-8"):ue(r,"utf-8"),s=JSON.parse(o);for(let n of s)if(n.role==="system")i=typeof n.content==="string"?n.content:"";else e.push(n)}if(t.message){let r=new Set(["system","user","assistant"]),o=t.message;for(let s of o){let n=s.indexOf(":"),m=n!==-1?s.slice(0,n):"";if(r.has(m)){let a=s.slice(n+1);if(m==="system")i=a;else e.push({role:m,content:a})}else e.push({role:"user",content:s})}}return{system:i,messages:e}}function Fr(t){return t.filter((e)=>e.type==="text").map((e)=>e.text).join("")}var An=d({name:"text chat",description:"Send a chat completion (MiniMax Messages API)",usage:"mmx text chat --message <text> [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-M2.7)"},{flag:"--message <text>",description:"Message text (repeatable, prefix role: to set role)",required:!0,type:"array"},{flag:"--messages-file <path>",description:"JSON file with messages array (use - for stdin)"},{flag:"--system <text>",description:"System prompt"},{flag:"--max-tokens <n>",description:"Maximum tokens to generate (default: 4096)",type:"number"},{flag:"--temperature <n>",description:"Sampling temperature (0.0, 1.0]",type:"number"},{flag:"--top-p <n>",description:"Nucleus sampling threshold",type:"number"},{flag:"--stream",description:"Stream response tokens (default: on in TTY)"},{flag:"--tool <json-or-path>",description:"Tool definition as JSON or file path (repeatable)",type:"array"}],examples:['mmx text chat --message "What is MiniMax?"','mmx text chat --model MiniMax-M2.7-highspeed --system "You are a coding assistant." --message "Write fizzbuzz in Python"','mmx text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"',"cat conversation.json | mmx text chat --messages-file - --stream",'mmx text chat --message "Hello" --output json'],async run(t,e){let{system:i,messages:r}=Lr(e),o=r;if(o.length===0)if(A({nonInteractive:t.nonInteractive})){let y=await X({message:"Enter your message:"});if(!y)process.stderr.write(`Chat cancelled.
|
|
140
|
+
`),process.exit(1);o=[{role:"user",content:y}]}else pt("message","mmx text chat --message <text>");let s=e.model||"MiniMax-M2.7",n=e.stream===!0||e.stream===void 0&&process.stdout.isTTY,m=_(t.output),a={model:s,messages:o,max_tokens:e.maxTokens??4096,stream:n};if(i)a.system=i;if(e.temperature!==void 0)a.temperature=e.temperature;if(e.topP!==void 0)a.top_p=e.topP;if(e.tool){let y=e.tool.map(($)=>{try{return JSON.parse($)}catch{let h=ue($,"utf-8");return JSON.parse(h)}});a.tools=y}if(t.dryRun){console.log(w({request:a},m));return}let u=je(t.baseUrl);if(n){let y=await E(t,{url:u,method:"POST",body:a,stream:!0,authStyle:"x-api-key"}),$="",h=!1,b=t.noColor?"":"\x1B[2m",f=t.noColor?"":"\x1B[0m",M=process.stdout.isTTY?process.stdout:process.stderr,J=process.stdout;for await(let nt of kn(y)){if(nt.data==="[DONE]")break;try{let q=JSON.parse(nt.data);if(q.type==="content_block_start"){if(q.content_block.type==="thinking")h=!0,M.write(`${b}Thinking:
|
|
141
|
+
`);else if(q.content_block.type==="text"&&h)M.write(`${f}
|
|
142
|
+
|
|
143
|
+
Response:
|
|
144
|
+
`),h=!1}else if(q.type==="content_block_delta"){if(q.delta.type==="text_delta")$+=q.delta.text,J.write(q.delta.text);else if(q.delta.type==="thinking_delta")M.write(q.delta.thinking)}}catch{}}if(h)M.write(f);if(J.write(`
|
|
145
|
+
`),m==="json")console.log(w({content:$},m))}else{let y=await v(t,{url:u,method:"POST",body:a,authStyle:"x-api-key"}),$=Fr(y.content);if(t.quiet||m==="text")console.log($);else console.log(w(y,m))}}});import{writeFileSync as Dr}from"fs";function Ot(t,e,i,r){if(e)if(Dr(e,Buffer.from(t.data.audio,"hex")),r)console.log(e);else console.log(w({saved:e,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size,sample_rate:t.extra_info?.audio_sample_rate},i));else{let o=t.data.audio_url??t.data.audio;if(r)console.log(o);else console.log(w({url:o,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size},i))}}import{readFileSync as to}from"fs";function Gt(t){return to(t==="-"?"/dev/stdin":t,"utf-8")}var jn=d({name:"speech synthesize",description:"Synchronous TTS, up to 10k chars (speech-2.8-hd / 2.6 / 02)",usage:"mmx speech synthesize --text <text> [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model ID (default: speech-2.8-hd)"},{flag:"--text <text>",description:"Text to synthesize"},{flag:"--text-file <path>",description:"Read text from file (use - for stdin)"},{flag:"--voice <id>",description:"Voice ID (default: English_expressive_narrator)"},{flag:"--speed <n>",description:"Speech speed multiplier",type:"number"},{flag:"--volume <n>",description:"Volume level",type:"number"},{flag:"--pitch <n>",description:"Pitch adjustment",type:"number"},{flag:"--format <fmt>",description:"Audio format (default: mp3)"},{flag:"--sample-rate <hz>",description:"Sample rate (default: 32000)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 128000)",type:"number"},{flag:"--channels <n>",description:"Audio channels (default: 1)",type:"number"},{flag:"--language <code>",description:"Language boost"},{flag:"--subtitles",description:"Include subtitle timing data"},{flag:"--pronunciation <from/to>",description:"Custom pronunciation (repeatable)",type:"array"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"},{flag:"--stream",description:"Stream raw audio to stdout"}],examples:['mmx speech synthesize --text "Hello, world!"','mmx speech synthesize --text "Hello, world!" --out hello.mp3','echo "Breaking news." | mmx speech synthesize --text-file - --out news.mp3','mmx speech synthesize --text "Stream" --stream | mpv --no-terminal -'],async run(t,e){let i=e.text??e._positional?.[0];if(e.textFile)i=Gt(e.textFile);if(!i)throw new c("--text or --text-file is required.",l.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let r=e.model||"speech-2.8-hd",o=e.voice||"English_expressive_narrator",s=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),n=e.out??`speech_${s}.mp3`,m="hex",a=_(t.output),u={model:r,text:i,voice_setting:{voice_id:o,speed:e.speed??void 0,vol:e.volume??void 0,pitch:e.pitch??void 0},audio_setting:{format:e.format||"mp3",sample_rate:e.sampleRate??32000,bitrate:e.bitrate??128000,channel:e.channels??1},output_format:m,stream:e.stream===!0};if(e.language)u.language_boost=e.language;if(e.subtitles)u.subtitle=!0;if(e.pronunciation)u.pronunciation_dict=e.pronunciation.map((h)=>{let[b,f]=h.split("/");return{tone:f||b,text:b}});if(t.dryRun){console.log(w({request:u},a));return}let y=Me(t.baseUrl);if(e.stream){let b=(await E(t,{url:y,method:"POST",body:u,stream:!0})).body?.getReader();if(!b)throw new c("No response body",l.GENERAL);while(!0){let{done:f,value:g}=await b.read();if(f)break;process.stdout.write(g)}b.releaseLock();return}let $=await v(t,{url:y,method:"POST",body:u});if(!t.quiet)process.stderr.write(`[Model: ${r}]
|
|
146
|
+
`);Ot($,n,a,t.quiet)}});function eo(t){let e=t.match(/^(.+?)_[A-Z]/);return e?e[1]:t}function no(t,e){let i=e.toLowerCase();return t.filter((r)=>eo(r.voice_id).toLowerCase().includes(i))}var Mn=d({name:"speech voices",description:"List available system voices",usage:"mmx speech voices [--language <lang>]",options:[{flag:"--language <lang>",description:"Filter voices by language (e.g. english, korean, japanese)"}],examples:["mmx speech voices","mmx speech voices --language english","mmx speech voices --language korean","mmx speech voices --output json"],async run(t,e){let i=_(t.output);if(t.dryRun){console.log(w({request:{voice_type:"system"}},i));return}let o=(await v(t,{url:qe(t.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],s=e.language;if(s){let n=no(o,s);if(i!=="text"){console.log(w(n,i));return}for(let m of n){let a=m.description?.join("; ")||"",u=m.voice_name?` (${m.voice_name})`:"";if(console.log(` ${m.voice_id}${u}`),a)console.log(` ${a}`)}}else{if(i!=="text"){console.log(w(o.map((n)=>n.voice_id),i));return}for(let n of o)console.log(n.voice_id)}}});import{createWriteStream as io,unlinkSync as ro}from"fs";var qn=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function Tn(t){let e=process.stderr.isTTY,i=0,r=null,o=t;return{start(){if(!e)return;r=setInterval(()=>{process.stderr.write(`\r${qn[i%qn.length]} ${o}`),i++},80)},update(s){o=s},stop(s){if(r)clearInterval(r),r=null;if(e){if(process.stderr.write("\r\x1B[K"),s)process.stderr.write(`${s}
|
|
147
|
+
`)}}}}function On(t,e=""){let i=process.stderr.isTTY,r=30;return{update(o){if(!i)return;let s=Math.min(1,o/t),n=Math.round(30*s),m=30-n,a="█".repeat(n)+"░".repeat(m),u=`${Math.round(s*100)}%`;process.stderr.write(`\r${e} ${a} ${u}`)},finish(){if(i)process.stderr.write(`
|
|
148
|
+
`)}}}async function tt(t,e,i){let r=await fetch(t);if(!r.ok)throw new c(`Download failed: HTTP ${r.status}`,l.GENERAL);let o=Number(r.headers.get("content-length")||0),s=r.body?.getReader();if(!s)throw new c("No response body",l.GENERAL);let n=io(e),m=o>0&&!i?.quiet?On(o,"Downloading"):null,a=0,u=!1;try{let y=new Promise(($,h)=>{n.on("error",h)});while(!0){let{done:$,value:h}=await Promise.race([s.read(),y]);if($)break;if(!n.write(h))await new Promise((f)=>n.once("drain",f));a+=h.byteLength,m?.update(a)}u=!0}finally{if(s.releaseLock(),m?.finish(),await new Promise((y,$)=>{n.on("finish",y),n.on("error",$),n.end()}),!u)try{ro(e)}catch{}}return{size:a}}function Nt(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(1)} MB`;return`${(t/1073741824).toFixed(1)} GB`}import{mkdirSync as oo,existsSync as so,readFileSync as po}from"fs";import{join as mo,resolve as ao,extname as uo}from"path";var $o={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},Gn=d({name:"image generate",description:"Generate images (image-01)",usage:"mmx image generate --prompt <text> [flags]",options:[{flag:"--prompt <text>",description:"Image description",required:!0},{flag:"--aspect-ratio <ratio>",description:"Aspect ratio (e.g. 16:9, 1:1)"},{flag:"--n <count>",description:"Number of images to generate (default: 1)",type:"number"},{flag:"--subject-ref <params>",description:"Subject reference (type=character,image=path)"},{flag:"--out-dir <dir>",description:"Download images to directory"},{flag:"--out-prefix <prefix>",description:"Filename prefix (default: image)"}],examples:['mmx image generate --prompt "A cat in a spacesuit on Mars" --aspect-ratio 16:9','mmx image generate --prompt "Logo design" --n 3 --out-dir ./generated/','mmx image generate --prompt "Mountain landscape" --quiet'],async run(t,e){let i=e.prompt??e._positional?.[0];if(!i)if(A({nonInteractive:t.nonInteractive})){let $=await X({message:"Enter your image prompt:"});if(!$)process.stderr.write(`Image generation cancelled.
|
|
149
|
+
`),process.exit(1);i=$}else pt("prompt","mmx image generate --prompt <text>");let r={model:"image-01",prompt:i,aspect_ratio:e.aspectRatio||void 0,n:e.n??1};if(e.subjectRef){let $=e.subjectRef,h=Object.fromEntries($.split(",").map((f)=>{let g=f.indexOf("=");if(g===-1)return[f,""];return[f.slice(0,g),f.slice(g+1)]})),b={type:h.type||"character"};if(h.image)if(h.image.startsWith("http"))b.image_url=h.image;else{let f=ao(h.image),g=po(f),M=uo(f).toLowerCase(),J=$o[M]||"image/jpeg";b.image_file=`data:${J};base64,${g.toString("base64")}`}r.subject_reference=[b]}let o=_(t.output);if(t.dryRun){console.log(w({request:r},o));return}let s=Te(t.baseUrl),n=await v(t,{url:s,method:"POST",body:r}),m=n.data.image_urls||[];if(!t.quiet)process.stderr.write(`[Model: image-01]
|
|
150
|
+
`);let a=e.outDir??".";if(!so(a))oo(a,{recursive:!0});let u=e.outPrefix||"image",y=[];for(let $=0;$<m.length;$++){let h=`${u}_${String($+1).padStart(3,"0")}.jpg`,b=mo(a,h);await tt(m[$],b,{quiet:t.quiet}),y.push(b)}if(t.quiet)console.log(y.join(`
|
|
151
|
+
`));else console.log(w({id:n.data.task_id,saved:y,success_count:n.data.success_count,failed_count:n.data.failed_count},o))}});async function Nn(t,e){let i=Date.now()+e.timeoutSec*1000,r=Tn("Polling...");if(!t.quiet)r.start();try{while(Date.now()<i){let o=await v(t,{url:e.url});if(e.getStatus&&!t.quiet)r.update(`Status: ${e.getStatus(o)}`);if(e.isComplete(o))return r.stop("Done."),o;if(e.isFailed(o))throw r.stop("Failed."),new c("Task failed.",l.GENERAL);await new Promise((s)=>setTimeout(s,e.intervalSec*1000))}}finally{r.stop()}throw new c("Polling timed out.",l.TIMEOUT,"Try increasing --timeout or check task status manually.")}import{readFileSync as lo}from"fs";import{extname as co}from"path";var yo={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},Bn=d({name:"video generate",description:"Generate a video (Hailuo-2.3 / 2.3-Fast)",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-Hailuo-2.3)"},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--first-frame <path-or-url>",description:"First frame image"},{flag:"--callback-url <url>",description:"Webhook URL for completion notification"},{flag:"--download <path>",description:"Save video to file on completion"},{flag:"--no-wait",description:"Return task ID immediately without waiting"},{flag:"--async",description:"Return task ID immediately (agent/CI mode, same as --no-wait but explicit)"},{flag:"--poll-interval <seconds>",description:"Polling interval when waiting (default: 5)",type:"number"}],examples:['mmx video generate --prompt "A man reads a book. Static shot."','mmx video generate --prompt "Ocean waves at sunset." --download sunset.mp4','mmx video generate --prompt "A robot painting." --async --quiet','mmx video generate --prompt "A robot painting." --no-wait --quiet'],async run(t,e){let i=e.prompt;if(!i)if(A({nonInteractive:t.nonInteractive})){let k=await X({message:"Enter your video prompt:"});if(!k)process.stderr.write(`Video generation cancelled.
|
|
152
|
+
`),process.exit(1);i=k}else pt("prompt","mmx video generate --prompt <text>");let r=e.model||"MiniMax-Hailuo-2.3",o=_(t.output),s={model:r,prompt:i};if(e.firstFrame){let k=e.firstFrame;if(k.startsWith("http"))s.first_frame_image=k;else{let mt=lo(k),lt=co(k).toLowerCase(),ct=yo[lt]||"image/jpeg";s.first_frame_image=`data:${ct};base64,${mt.toString("base64")}`}}if(e.callbackUrl)s.callback_url=e.callbackUrl;if(t.dryRun){console.log(w({request:s},o));return}let n=Oe(t.baseUrl),a=(await v(t,{url:n,method:"POST",body:s})).task_id;if(!t.quiet&&!e.noWait&&!t.async)process.stderr.write(`[Model: ${r}]
|
|
153
|
+
`);else if(!t.quiet)process.stderr.write(`[Model: ${r}]
|
|
154
|
+
`);if(e.noWait||t.async){process.stdout.write(JSON.stringify({taskId:a})),process.stdout.write(`
|
|
155
|
+
`);return}let u=e.pollInterval??5,y=_t(t.baseUrl,a),$=await Nn(t,{url:y,intervalSec:u,timeoutSec:t.timeout,isComplete:(k)=>k.status==="Success",isFailed:(k)=>k.status==="Failed",getStatus:(k)=>k.status});if(!$.file_id)throw new c("Task completed but no file_id returned.",l.GENERAL);let b=(await v(t,{url:vt(t.baseUrl,$.file_id)})).file?.download_url;if(!b)throw new c("No download URL available for this file.",l.GENERAL);if(e.download){let k=e.download,{size:mt}=await tt(b,k,{quiet:t.quiet});if(t.quiet)console.log(k);else console.log(w({task_id:a,status:"Success",file_id:$.file_id,saved:k,size:Nt(mt)},o));return}let f=await import("os"),{join:g}=await import("path"),M=g(f.tmpdir(),"mmx-video"),{existsSync:J,mkdirSync:nt}=await import("fs");if(!J(M))nt(M,{recursive:!0});let q=g(M,`${a}.mp4`);await tt(b,q,{quiet:t.quiet}),process.stdout.write(q),process.stdout.write(`
|
|
156
|
+
`)}});var In=d({name:"video task get",description:"Query video task status",usage:"mmx video task get --task-id <id>",options:[{flag:"--task-id <id>",description:"Video generation task ID"}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json"],async run(t,e){let i=e.taskId;if(!i)throw new c("--task-id is required.",l.USAGE,"mmx video task get --task-id <id>");if(t.dryRun){console.log(`Would query task: ${i}`);return}let r=_t(t.baseUrl,i),o=await v(t,{url:r}),s=_(t.output);if(t.quiet){console.log(o.status);return}console.log(w({task_id:o.task_id,status:o.status,file_id:o.file_id,video_width:o.video_width,video_height:o.video_height},s))}});var zn=d({name:"video download",description:"Download a completed video by file ID",usage:"mmx video download --file-id <id> --out <path>",options:[{flag:"--file-id <id>",description:"File ID to download"},{flag:"--out <path>",description:"Output file path"}],examples:["mmx video download --file-id 176844028768320 --out video.mp4","mmx video download --file-id 176844028768320 --out video.mp4 --quiet"],async run(t,e){let i=e.fileId;if(!i)throw new c("--file-id is required.",l.USAGE,"mmx video download --file-id <id> --out <path>");let r=e.out;if(!r)throw new c("--out is required.",l.USAGE,"mmx video download --file-id <id> --out video.mp4");if(t.dryRun){console.log(`Would download file ${i} to ${r}`);return}let o=vt(t.baseUrl,i),n=(await v(t,{url:o})).file?.download_url;if(!n)throw new c("No download URL available for this file.",l.GENERAL,"The file may still be processing. Check task status first.");let{size:m}=await tt(n,r,{quiet:t.quiet}),a=_(t.output);if(t.quiet){console.log(r);return}console.log(w({saved:r,size:Nt(m)},a))}});var Jn=d({name:"music generate",description:"Generate a song (music-2.5)",usage:"mmx music generate --prompt <text> (--lyrics <text> | --instrumental) [--out <path>] [flags]",options:[{flag:"--prompt <text>",description:"Music style description (can be detailed — see examples)"},{flag:"--lyrics <text>",description:'Song lyrics with structure tags. Use "无歌词" for instrumental music. Cannot be used with --instrumental.'},{flag:"--lyrics-file <path>",description:'Read lyrics from file. Use "无歌词" for instrumental. (use - for stdin)'},{flag:"--vocals <text>",description:'Vocal style, e.g. "warm male baritone", "bright female soprano", "duet with harmonies"'},{flag:"--genre <text>",description:"Music genre, e.g. folk, pop, jazz"},{flag:"--mood <text>",description:"Mood or emotion, e.g. warm, melancholic, uplifting"},{flag:"--instruments <text>",description:'Instruments to feature, e.g. "acoustic guitar, piano"'},{flag:"--tempo <text>",description:"Tempo description, e.g. fast, slow, moderate"},{flag:"--bpm <number>",description:"Exact tempo in beats per minute",type:"number"},{flag:"--key <text>",description:"Musical key, e.g. C major, A minor, G sharp"},{flag:"--avoid <text>",description:"Elements to avoid in the generated music"},{flag:"--use-case <text>",description:'Use case context, e.g. "background music for video", "theme song"'},{flag:"--structure <text>",description:'Song structure, e.g. "verse-chorus-verse-bridge-chorus"'},{flag:"--references <text>",description:'Reference tracks or artists, e.g. "similar to Ed Sheeran, Taylor Swift"'},{flag:"--extra <text>",description:"Additional fine-grained requirements not covered above"},{flag:"--instrumental",description:"Generate instrumental music (no vocals)"},{flag:"--aigc-watermark",description:"Embed AI-generated content watermark in audio for content provenance"},{flag:"--format <fmt>",description:"Audio format (default: mp3)"},{flag:"--sample-rate <hz>",description:"Sample rate (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 256000)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"}],examples:['mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --out summer.mp3','mmx music generate --prompt "Indie folk, melancholic" --lyrics-file song.txt --out my_song.mp3',"# Detailed prompt with vocal characteristics — music-2.5 responds well to rich descriptions:",'mmx music generate --prompt "Warm morning folk" --vocals "male and female duet, harmonies in chorus" --instruments "acoustic guitar, piano" --bpm 95 --lyrics-file song.txt --out duet.mp3',"# Instrumental (use --instrumental flag):",'mmx music generate --prompt "Cinematic orchestral, building tension" --instrumental --out bgm.mp3','# Or specify "无歌词" in lyrics:','mmx music generate --prompt "Cinematic orchestral" --lyrics "无歌词" --out bgm.mp3'],async run(t,e){let{prompt:i,lyrics:r}=e;if(e.lyricsFile)r=Gt(e.lyricsFile);if(e.instrumental&&(r||e.lyricsFile))throw new c("Cannot use --instrumental with --lyrics or --lyrics-file. For instrumental music, simply use --instrumental without --lyrics.",l.USAGE,"mmx music generate --prompt <style> --instrumental");let o=[];if(e.vocals)o.push(`Vocals: ${e.vocals}`);if(e.genre)o.push(`Genre: ${e.genre}`);if(e.mood)o.push(`Mood: ${e.mood}`);if(e.instruments)o.push(`Instruments: ${e.instruments}`);if(e.tempo)o.push(`Tempo: ${e.tempo}`);if(e.bpm)o.push(`BPM: ${e.bpm}`);if(e.key)o.push(`Key: ${e.key}`);if(e.avoid)o.push(`Avoid: ${e.avoid}`);if(e.useCase)o.push(`Use case: ${e.useCase}`);if(e.structure)o.push(`Structure: ${e.structure}`);if(e.references)o.push(`References: ${e.references}`);if(e.extra)o.push(`Extra: ${e.extra}`);if(r==="无歌词"||r==="no lyrics")r="[intro] [outro]",o.push("Style: instrumental, no vocals, pure music");if(e.instrumental)r="[intro] [outro]",o.push("Style: instrumental, no vocals, pure music");if(!i&&!r)throw new c("At least one of --prompt or --lyrics is required.",l.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(!r?.trim())throw new c('The API requires lyrics. Add --lyrics or --lyrics-file, or use --instrumental (or --lyrics "无歌词") for instrumental output.',l.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(o.length>0){let b=o.join(". ");i=i?`${i}. ${b}`:b}let s=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),n=e.format||"mp3",m=e.out??`music_${s}.${n}`,a="hex",u=_(t.output),y={model:"music-2.5",prompt:i,lyrics:r,audio_setting:{format:e.format||"mp3",sample_rate:e.sampleRate??44100,bitrate:e.bitrate??256000},output_format:a,stream:e.stream===!0};if(e.aigcWatermark)y.aigc_watermark=!0;if(t.dryRun){console.log(w({request:y},u));return}let $=Ge(t.baseUrl);if(e.stream){let f=(await E(t,{url:$,method:"POST",body:y,stream:!0})).body?.getReader();if(!f)throw new c("No response body",l.GENERAL);while(!0){let{done:g,value:M}=await f.read();if(g)break;process.stdout.write(M)}f.releaseLock();return}let h=await v(t,{url:$,method:"POST",body:y});if(!t.quiet)process.stderr.write(`[Model: music-2.5]
|
|
157
|
+
`);Ot(h,m,u,t.quiet)}});var Yn=d({name:"search query",description:"Search the web via MiniMax",usage:"mmx search query --q <query>",options:[{flag:"--q <query>",description:"Search query string"}],examples:['mmx search query --q "MiniMax AI"','mmx search query --q "latest news" --output json'],async run(t,e){let i=e.q??e._positional?.[0];if(!i)throw new c("--q is required.",l.USAGE,'mmx search query --q "your search query"');let r=_(t.output);if(t.dryRun){console.log(w({request:{q:i}},r));return}let o=Ne(t.baseUrl),s=await v(t,{url:o,method:"POST",body:{q:i}}),n=s.organic||[];if(r!=="text"){console.log(w(s,r));return}if(t.quiet){for(let m of n)console.log(`${m.title} ${m.link}`);return}if(n.length===0){console.log("No results found.");return}for(let m of n){if(console.log(`${m.title}`),console.log(` ${m.link}`),m.snippet)console.log(` ${m.snippet}`);if(m.date)console.log(` ${m.date}`);console.log("")}}});import{readFileSync as xo,existsSync as ho}from"fs";import{extname as bo}from"path";var wo={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"};async function _o(t){if(t.startsWith("data:"))return t;if(t.startsWith("http://")||t.startsWith("https://")){let o=await fetch(t);if(!o.ok)throw new c(`Failed to download image: HTTP ${o.status}`,l.GENERAL);let n=(o.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),m=await o.arrayBuffer(),a=Buffer.from(m).toString("base64");return`data:${n};base64,${a}`}if(!ho(t))throw new c(`File not found: ${t}`,l.USAGE);let e=bo(t).toLowerCase(),i=wo[e];if(!i)throw new c(`Unsupported image format "${e}". Supported: jpg, jpeg, png, webp`,l.USAGE);let r=xo(t);return`data:${i};base64,${r.toString("base64")}`}var Kn=d({name:"vision describe",description:"Describe an image using MiniMax VLM",usage:"mmx vision describe (--image <path-or-url> | --file-id <id>) [--prompt <text>]",options:[{flag:"--image <path-or-url>",description:"Local image path or URL (base64 encoded automatically)"},{flag:"--file-id <id>",description:"Pre-uploaded file ID (skips base64 conversion)"},{flag:"--prompt <text>",description:'Question about the image (default: "Describe the image.")'}],examples:["mmx vision describe --image photo.jpg",'mmx vision describe --image https://example.com/photo.jpg --prompt "What breed is this dog?"','mmx vision describe --file-id file-123456789 --prompt "Extract the text"'],async run(t,e){let i=e.image??e._positional?.[0],r=e.fileId,o=e.prompt||"Describe the image.";if(!i&&!r)if(A({nonInteractive:t.nonInteractive})){let u=await X({message:"Enter image path, URL, or File ID:"});if(!u)process.stderr.write(`Vision describe cancelled.
|
|
158
|
+
`),process.exit(1);if(!u.includes(".")&&!u.startsWith("http"))r=u;else i=u}else throw new c("Missing required argument. Must provide either --image or --file-id.",l.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(i&&r)throw new c("Conflicting arguments: cannot provide both --image and --file-id.",l.USAGE);let s=_(t.output);if(t.dryRun){process.stdout.write(w({request:{prompt:o,image:i,fileId:r}},s)+`
|
|
159
|
+
`);return}let n=Be(t.baseUrl),m={prompt:o};if(r)m.file_id=r;else if(i){let u=await _o(i);m.image_url=u}let a=await v(t,{url:n,method:"POST",body:m});if(s!=="text"){process.stdout.write(w(a,s)+`
|
|
160
|
+
`);return}process.stdout.write(a.content+`
|
|
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(w(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}ot(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:Q()};if(i.api_key)o.api_key=I(i.api_key);console.log(w(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(w({would_set:{[i]:r}},o));return}let s=O();if(s[i]=i==="timeout"?Number(r):r,await K(s),!t.quiet)console.log(w({[i]:s[i]},o))}});function vo(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}=vo(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 fo=["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}=C.resolve(i.split(" ")),n=$e(s);process.stdout.write(JSON.stringify(n,null,2)+`
|
|
162
|
+
`)}catch{throw new c(`Command "${i}" not found.`,l.USAGE)}return}let o=C.getAllCommands().filter((s)=>!fo.some((n)=>s.name.startsWith(n))).map((s)=>$e(s));process.stdout.write(JSON.stringify(o,null,2)+`
|
|
163
|
+
`)}});var So="1.0.0",Hn=d({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${So}
|
|
164
|
+
|
|
165
|
+
`),process.stderr.write(`Run:
|
|
166
|
+
`),process.stderr.write(` npm update -g mmx-cli
|
|
167
|
+
|
|
168
|
+
`)}});class Un{root={children:new Map};constructor(t){for(let[e,i]of Object.entries(t))this.register(e,i)}register(t,e){let i=t.split(" "),r=this.root;for(let o of i){if(!r.children.has(o))r.children.set(o,{children:new Map});r=r.children.get(o)}r.command=e}getAllCommands(){let t=[],e=(i)=>{if(i.command)t.push(i.command);for(let r of i.children.values())e(r)};return e(this.root),t}resolve(t){let e=this.root,i=[];for(let r of t){let o=e.children.get(r);if(!o)break;e=o,i.push(r)}if(e.command)return{command:e.command,extra:t.slice(i.length)};if(i.length>0&&e.children.size===1){let[,r]=e.children.entries().next().value;if(r.command)return{command:r.command,extra:t.slice(i.length)}}if(i.length>0&&e.children.size>0){let r=Array.from(e.children.entries()).map(([o,s])=>{if(s.command)return` ${i.join(" ")} ${o} ${s.command.description}`;let n=Array.from(s.children.keys()).join(", ");return` ${i.join(" ")} ${o} [${n}]`}).join(`
|
|
169
|
+
`);throw new c(`Unknown command: mmx ${t.join(" ")}
|
|
170
|
+
|
|
171
|
+
Available commands:
|
|
172
|
+
${r}`,l.USAGE,`mmx ${i.join(" ")} --help`)}throw new c(`Unknown command: mmx ${t.join(" ")}`,l.USAGE,"mmx --help")}printHelp(t,e=process.stdout){if(t.length===0){this.printRootHelp(e);return}let i=this.root;for(let r of t){let o=i.children.get(r);if(!o){this.printRootHelp(e);return}i=o}if(i.command){this.printCommandHelp(i.command,e);return}e.write(`
|
|
173
|
+
Usage: mmx ${t.join(" ")} <command> [flags]
|
|
174
|
+
|
|
175
|
+
`),e.write(`Commands:
|
|
176
|
+
`),this.printChildren(i,t.join(" "),e),e.write(`
|
|
177
|
+
`)}printRootHelp(t){t.write(`
|
|
178
|
+
__ __ __ ____ __
|
|
179
|
+
| \\/ | \\/ \\ \\/ /
|
|
180
|
+
| |\\/| | |\\/| |\\ /
|
|
181
|
+
| | | | | | |/ \\
|
|
182
|
+
|_| |_|_| |_/_/\\_\\
|
|
183
|
+
|
|
184
|
+
Usage: mmx <resource> <command> [flags]
|
|
185
|
+
|
|
186
|
+
Resources:
|
|
187
|
+
auth Authentication (login, status, refresh, logout)
|
|
188
|
+
text Text generation (chat)
|
|
189
|
+
speech Speech synthesis (synthesize, voices)
|
|
190
|
+
image Image generation (generate)
|
|
191
|
+
video Video generation (generate, task get, download)
|
|
192
|
+
music Music generation (generate)
|
|
193
|
+
search Web search (query)
|
|
194
|
+
vision Image understanding (describe)
|
|
195
|
+
quota Usage quotas (show)
|
|
196
|
+
config CLI configuration (show, set, export-schema)
|
|
197
|
+
update Update mmx to a newer version
|
|
198
|
+
|
|
199
|
+
Global Flags:
|
|
200
|
+
--api-key <key> API key (overrides all other auth)
|
|
201
|
+
--region <region> API region: global (default), cn
|
|
202
|
+
--base-url <url> API base URL (overrides region)
|
|
203
|
+
--output <format> Output format: text, json
|
|
204
|
+
--quiet Suppress non-essential output
|
|
205
|
+
--verbose Print HTTP request/response details
|
|
206
|
+
--timeout <seconds> Request timeout (default: 300)
|
|
207
|
+
--no-color Disable ANSI colors and spinners
|
|
208
|
+
--dry-run Show what would happen without executing
|
|
209
|
+
--non-interactive Disable interactive prompts (CI/agent mode)
|
|
210
|
+
--version Print version and exit
|
|
211
|
+
--help Show help
|
|
212
|
+
|
|
213
|
+
Getting Help:
|
|
214
|
+
Add --help after any command to see its full list of options, defaults,
|
|
215
|
+
and usage examples. For example: mmx text chat --help
|
|
216
|
+
`)}printCommandHelp(t,e){if(e.write(`
|
|
217
|
+
${t.description}
|
|
218
|
+
`),t.usage)e.write(`Usage: ${t.usage}
|
|
219
|
+
`);if(t.options&&t.options.length>0){let i=Math.max(...t.options.map((r)=>r.flag.length));e.write(`Options:
|
|
220
|
+
`);for(let r of t.options)e.write(` ${r.flag.padEnd(i+2)} ${r.description}
|
|
221
|
+
`);e.write(`
|
|
222
|
+
`)}if(t.examples&&t.examples.length>0){e.write(`Examples:
|
|
223
|
+
`);for(let i of t.examples)e.write(` ${i}
|
|
224
|
+
`);e.write(`
|
|
225
|
+
`)}e.write(`Global flags (--api-key, --output, --quiet, etc.) are always available.
|
|
226
|
+
`),e.write(`Run 'mmx --help' for the full list.
|
|
227
|
+
`)}printChildren(t,e,i){let r=[],o=(n,m)=>{for(let[a,u]of n.children){if(u.command)r.push({fullName:`${m} ${a}`,description:u.command.description});if(u.children.size>0)o(u,`${m} ${a}`)}};o(t,e);let s=Math.max(...r.map((n)=>n.fullName.length));for(let{fullName:n,description:m}of r)i.write(` ${n.padEnd(s)} ${m}
|
|
228
|
+
`)}}var C=new Un({"auth login":vn,"auth status":fn,"auth refresh":Sn,"auth logout":Rn,"text chat":An,"speech synthesize":jn,"speech voices":Mn,"image generate":Gn,"video generate":Bn,"video task get":In,"video download":zn,"music generate":Jn,"search query":Yn,"vision describe":Kn,"quota show":Xn,"config show":Qn,"config set":Zn,"config export-schema":Wn,update:Hn});function et(t){if(t instanceof c){if(_(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
|
|
229
|
+
`);else{if(process.stderr.write(`
|
|
230
|
+
Error: ${t.message}
|
|
231
|
+
`),t.hint)process.stderr.write(`
|
|
232
|
+
${t.hint.split(`
|
|
233
|
+
`).join(`
|
|
234
|
+
`)}
|
|
235
|
+
`);process.stderr.write(` (exit code ${t.exitCode})
|
|
236
|
+
`)}process.exit(t.exitCode)}if(t instanceof Error){if(t.name==="AbortError"||t.message.includes("timed out")){let o=new c("Request timed out.",l.TIMEOUT,"Try increasing --timeout or retry later.");return et(o)}if(t instanceof TypeError&&t.message==="fetch failed"){let o=new c("Network request failed.",l.NETWORK,"Check your network connection and proxy settings. Also verify MINIMAX_BASE_URL is a valid URL.");return et(o)}let e=t.message.toLowerCase();if(e.includes("failed to fetch")||e.includes("connection refused")||e.includes("econnrefused")||e.includes("connection reset")||e.includes("econnreset")||e.includes("network error")||e.includes("enotfound")||e.includes("getaddrinfo")||e.includes("proxy")||e.includes("socket")||e.includes("etimedout")||e.includes("timeout")||e.includes("eai_AGAIN")){let o="Check your network connection and proxy settings.";if(e.includes("proxy"))o="Proxy error — check HTTP_PROXY / HTTPS_PROXY environment variables and proxy authentication.";let s=new c("Network request failed.",l.NETWORK,o);return et(s)}let r=t.code;if(r==="ENOENT"||r==="EACCES"||r==="ENOSPC"||r==="ENOTDIR"||r==="EISDIR"||r==="EPERM"||r==="EBUSY"){let o="Check the file path and permissions.";if(r==="ENOENT")o="File or directory not found.";if(r==="EACCES"||r==="EPERM")o="Permission denied — check file or directory permissions.";if(r==="ENOSPC")o="Disk full — free up space and try again.";let s=new c(`File system error: ${t.message}`,l.GENERAL,o);return et(s)}else if(typeof r==="string"&&r.startsWith("E")){let o=new c(`File system error: ${t.message}`,l.GENERAL,"Check the file path and permissions.");return et(o)}if(process.stderr.write(`
|
|
237
|
+
Error: ${t.message}
|
|
238
|
+
`),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${t.stack}
|
|
239
|
+
`)}else process.stderr.write(`
|
|
240
|
+
Error: ${String(t)}
|
|
241
|
+
`);process.exit(l.GENERAL)}var Ro="/v1/api/openplatform/coding_plan/remains";function ko(t){return W[t]+Ro}async function go(t,e,i){try{let r=await fetch(ko(t),{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(i)});if(!r.ok)return!1;return(await r.json()).base_resp?.status_code===0}catch{return!1}}async function Cn(t){process.stderr.write("Detecting region...");let e=Object.keys(W),r=(await Promise.all(e.map(async(s)=>({region:s,ok:await go(s,t,5000)})))).find((s)=>s.ok);if(!r)return process.stderr.write(` failed
|
|
242
|
+
`),process.stderr.write(`Warning: API key failed validation against all regions. Falling back to global.
|
|
243
|
+
`),"global";let o=r.region;return process.stderr.write(` ${o}
|
|
244
|
+
`),o}async function En(t){let e=O();e.region=t,await K(e)}import{join as Ao}from"path";import{readFileSync as jo,writeFileSync as Mo}from"fs";var Pn=()=>Ao(at(),"update-state.json"),qo=86400000,To=3000,Oo="MiniMax-AI-Dev/minimax-cli";function Go(){try{let t=jo(Pn(),"utf-8");return JSON.parse(t)}catch{return null}}function No(t){try{Mo(Pn(),JSON.stringify(t))}catch{}}async function Bo(){try{let t=await fetch(`https://api.github.com/repos/${Oo}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(To)});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=Go(),i=Date.now();if(e&&i-e.lastChecked<qo){if(e.latestVersion&&e.latestVersion!==`v${t}`)le=e.latestVersion;return}let r=await Bo();if(!r)return;if(No({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
|
|
245
|
+
Pass directly: --api-key sk-xxxxx`);let s=await X({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 K(r),t.fileApiKey=i;let o=t.configPath??"~/.mmx/config.json";process.stderr.write(`API key saved to ${o}
|
|
246
|
+
`)}var ti="1.0.0";process.on("SIGINT",()=>{process.stderr.write(`
|
|
247
|
+
Interrupted. Exiting.
|
|
248
|
+
`),process.exit(130)});var Io=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function zo(){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"))C.printHelp(e,process.stderr),process.exit(0);if(e.length===0){C.printHelp([],process.stderr);let{command:u}=C.resolve(["quota","show"]),y=Jt(t,[...ht,...u.options??[]]),$=Zt(y),h=!!($.apiKey||$.fileApiKey),b=!!await B();if(h||b)await u.execute($,y);else process.stderr.write(` Not logged in.
|
|
249
|
+
`),process.stderr.write(` mmx auth login --api-key sk-xxxxx
|
|
250
|
+
|
|
251
|
+
`);process.exit(0)}let{command:i,extra:r}=C.resolve(e),o=Jt(t,[...ht,...i.options??[]]);if(r.length>0)o._positional=r;let s=Zt(o);if(!Io.some((u)=>u.every((y,$)=>e[$]===y)))await Dn(s);if(s.needsRegionDetection){let u=s.apiKey||s.fileApiKey;if(u){let y=await Cn(u);s.region=y,s.baseUrl=W[y],s.needsRegionDetection=!1,await En(y)}}let m=Fn(ti).catch(()=>{});await i.execute(s,o),await m;let a=Ln();if(a&&!s.quiet)process.stderr.write(`
|
|
252
|
+
Update available: ${a}
|
|
253
|
+
`),process.stderr.write(` npm update -g mmx-cli
|
|
254
|
+
|
|
255
|
+
`)}zo().catch(et);
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mmx-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI for the MiniMax AI Platform",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=18"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"mmx": "dist/mmx.mjs"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/mmx.mjs"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "bun run src/main.ts",
|
|
17
|
+
"build": "bun run build.ts",
|
|
18
|
+
"build:dev": "bun build src/main.ts --outfile dist/mmx.mjs --target node --minify --define \"process.env.CLI_VERSION='1.0.0'\" && printf '#!/usr/bin/env node\\n' | cat - dist/mmx.mjs > dist/tmp && mv dist/tmp dist/mmx.mjs && chmod +x dist/mmx.mjs",
|
|
19
|
+
"prepublishOnly": "bun run build",
|
|
20
|
+
"lint": "eslint src/ test/",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"test": "bun test",
|
|
23
|
+
"test:watch": "bun test --watch"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@clack/prompts": "^0.7.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@eslint/js": "^9.0.0",
|
|
30
|
+
"@types/bun": "latest",
|
|
31
|
+
"eslint": "^9.24.0",
|
|
32
|
+
"typescript": "^5.8.3",
|
|
33
|
+
"typescript-eslint": "^8.58.0"
|
|
34
|
+
}
|
|
35
|
+
}
|