@minimax-ai/code 0.3.1 → 0.3.2

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/CHANGELOG.zh-CN.md +21 -0
  3. package/README.md +14 -0
  4. package/README.zh-CN.md +22 -13
  5. package/chunks/{application-AG6XR6TH.js → application-2DVWZRSC.js} +1 -1
  6. package/chunks/{auth-command-MIT2ROTA.js → auth-command-M34DRUOJ.js} +1 -1
  7. package/chunks/{chunk-T7V3D5XQ.js → chunk-2LLMI3OF.js} +1 -1
  8. package/chunks/{chunk-F33I4QSG.js → chunk-4ODJYYGY.js} +351 -337
  9. package/chunks/{chunk-L2BHZE4F.js → chunk-AQSBE25I.js} +586 -586
  10. package/chunks/{chunk-FO5IMY26.js → chunk-D3NBJEJ2.js} +1 -1
  11. package/chunks/{chunk-YRXRNL2F.js → chunk-EFJXTS5E.js} +1 -1
  12. package/chunks/chunk-IEL7EQIF.js +5 -0
  13. package/chunks/{chunk-IBEXP44J.js → chunk-LTIHXDFE.js} +1 -1
  14. package/chunks/{chunk-AOZUEPXI.js → chunk-OYVCWRBD.js} +6 -6
  15. package/chunks/{chunk-NF23WB7F.js → chunk-TYJKJAGQ.js} +1 -1
  16. package/chunks/chunk-YKYKYGJQ.js +2 -0
  17. package/chunks/{data-dir-335LYS7R.js → data-dir-4HGM3ZJQ.js} +1 -1
  18. package/chunks/launcher-BZUOAHBT.js +244 -0
  19. package/chunks/{lifecycle-O4VWU5MP.js → lifecycle-7R7AUB6A.js} +1 -1
  20. package/chunks/main-LHJR7CNP.js +29 -0
  21. package/chunks/{plugin-command-T6LW4ONC.js → plugin-command-JY34MFAX.js} +1 -1
  22. package/chunks/{provider-command-2JVOUOBS.js → provider-command-ARZDXCQA.js} +1 -1
  23. package/chunks/{run-acp-command-DWPL6R6W.js → run-acp-command-ETB7QAFT.js} +2 -2
  24. package/chunks/{run-exec-command-5UZ7WFH4.js → run-exec-command-OO3TJOSC.js} +1 -1
  25. package/chunks/{update-J2OGG3ZH.js → update-N3TZCYN3.js} +1 -1
  26. package/cli.js +2 -1
  27. package/package.json +1 -1
  28. package/chunks/chunk-77VGHMFO.js +0 -5
  29. package/chunks/chunk-VTJC5EVO.js +0 -2
  30. package/chunks/launcher-P2FIIDHG.js +0 -244
  31. package/chunks/main-PUHNEWJZ.js +0 -29
@@ -1,29 +0,0 @@
1
- import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
2
- import{a as Q,b as Z,c as w,d as ee,f as ne}from"./chunk-U62SRHG3.js";import{a as M,b as te}from"./chunk-I3GV76MP.js";import{c as ie}from"./chunk-A2CQYOXE.js";import{a as Y}from"./chunk-O6RIRKRN.js";import{l as X}from"./chunk-77VGHMFO.js";import"./chunk-PGOU6MFH.js";import"./chunk-MMRA4VD2.js";import"./chunk-CWWDVX6C.js";import"./chunk-ZITT4GJK.js";import{a as x,c as b,e as S}from"./chunk-D76SO2ME.js";var P=b(R=>{var A=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},$=class extends A{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};R.CommanderError=A;R.InvalidArgumentError=$});var E=b(H=>{var{InvalidArgumentError:Me}=P(),V=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new Me(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function $e(o){let e=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+e+">":"["+e+"]"}H.Argument=V;H.humanReadableArgName=$e});var L=b(re=>{var{humanReadableArgName:Re}=E(),I=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(n=>!n._hidden),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort((n,r)=>n.name().localeCompare(r.name())),t}compareOptions(e,t){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){let t=e.options.filter(n=>!n.hidden),i=e._getHelpOption();if(i&&!i.hidden){let n=i.short&&e._findOption(i.short),r=i.long&&e._findOption(i.long);!n&&!r?t.push(i):i.long&&!r?t.push(e.createOption(i.long,i.description)):i.short&&!n&&t.push(e.createOption(i.short,i.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let i=e.parent;i;i=i.parent){let n=i.options.filter(r=>!r.hidden);t.push(...n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(i=>Re(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,n)=>Math.max(i,t.subcommandTerm(n).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,n)=>Math.max(i,t.argumentTerm(n).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let n=e.parent;n;n=n.parent)i=n.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){let i=t.padWidth(e,t),n=t.helpWidth||80,r=2,s=2;function l(m,v){if(v){let k=`${m.padEnd(i+s)}${v}`;return t.wrap(k,n-r,i+s)}return m}function a(m){return m.join(`
3
- `).replace(/^/gm," ".repeat(r))}let c=[`Usage: ${t.commandUsage(e)}`,""],h=t.commandDescription(e);h.length>0&&(c=c.concat([t.wrap(h,n,0),""]));let d=t.visibleArguments(e).map(m=>l(t.argumentTerm(m),t.argumentDescription(m)));d.length>0&&(c=c.concat(["Arguments:",a(d),""]));let u=t.visibleOptions(e).map(m=>l(t.optionTerm(m),t.optionDescription(m)));if(u.length>0&&(c=c.concat(["Options:",a(u),""])),this.showGlobalOptions){let m=t.visibleGlobalOptions(e).map(v=>l(t.optionTerm(v),t.optionDescription(v)));m.length>0&&(c=c.concat(["Global Options:",a(m),""]))}let p=t.visibleCommands(e).map(m=>l(t.subcommandTerm(m),t.subcommandDescription(m)));return p.length>0&&(c=c.concat(["Commands:",a(p),""])),c.join(`
4
- `)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){let r=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",s=new RegExp(`[\\n][${r}]+`);if(e.match(s))return e;let l=t-i;if(l<n)return e;let a=e.slice(0,i),c=e.slice(i).replace(`\r
5
- `,`
6
- `),h=" ".repeat(i),u="\\s\u200B",p=new RegExp(`
7
- |.{1,${l-1}}([${u}]|$)|[^${u}]+?([${u}]|$)`,"g"),m=c.match(p)||[];return a+m.map((v,k)=>v===`
8
- `?"":(k>0?h:"")+v.trimEnd()).join(`
9
- `)}};re.Help=I});var j=b(q=>{var{InvalidArgumentError:Ve}=P(),N=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=Ie(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new Ve(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return He(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},D=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(e,t){let i=t.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,r=n!==void 0?n:!1;return t.negate===(r===e)}};function He(o){return o.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Ie(o){let e,t,i=o.split(/[ |,]+/);return i.length>1&&!/^[[<]/.test(i[1])&&(e=i.shift()),t=i.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}q.Option=N;q.DualOptions=D});var se=b(oe=>{function Le(o,e){if(Math.abs(o.length-e.length)>3)return Math.max(o.length,e.length);let t=[];for(let i=0;i<=o.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let n=1;n<=o.length;n++){let r=1;o[n-1]===e[i-1]?r=0:r=1,t[n][i]=Math.min(t[n-1][i]+1,t[n][i-1]+1,t[n-1][i-1]+r),n>1&&i>1&&o[n-1]===e[i-2]&&o[n-2]===e[i-1]&&(t[n][i]=Math.min(t[n][i],t[n-2][i-2]+1))}return t[o.length][e.length]}function Ne(o,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=o.startsWith("--");t&&(o=o.slice(2),e=e.map(s=>s.slice(2)));let i=[],n=3,r=.4;return e.forEach(s=>{if(s.length<=1)return;let l=Le(o,s),a=Math.max(o.length,s.length);(a-l)/a>r&&(l<n?(n=l,i=[s]):l===n&&i.push(s))}),i.sort((s,l)=>s.localeCompare(l)),t&&(i=i.map(s=>`--${s}`)),i.length>1?`
10
- (Did you mean one of ${i.join(", ")}?)`:i.length===1?`
11
- (Did you mean ${i[0]}?)`:""}oe.suggestSimilar=Ne});var he=b(ce=>{var De=x("node:events").EventEmitter,F=x("node:child_process"),y=x("node:path"),U=x("node:fs"),f=x("node:process"),{Argument:qe,humanReadableArgName:je}=E(),{CommanderError:W}=P(),{Help:Fe}=L(),{Option:ae,DualOptions:Ue}=j(),{suggestSimilar:ue}=se(),B=class o extends De{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>f.stdout.write(t),writeErr:t=>f.stderr.write(t),getOutHelpWidth:()=>f.stdout.isTTY?f.stdout.columns:void 0,getErrHelpWidth:()=>f.stderr.isTTY?f.stderr.columns:void 0,outputError:(t,i)=>i(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let n=t,r=i;typeof n=="object"&&n!==null&&(r=n,n=null),r=r||{};let[,s,l]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return n&&(a.description(n),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(r.noHelp||r.hidden),a._executableFile=r.executableFile||null,l&&a.arguments(l),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(e){return new o(e)}createHelp(){return Object.assign(new Fe,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
12
- - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new qe(e,t)}argument(e,t,i,n){let r=this.createArgument(e,t);return typeof i=="function"?r.default(n).argParser(i):r.default(i),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,i,n]=e.match(/([^ ]+) *(.*)/),r=t??"display help for command",s=this.createCommand(i);return s.helpOption(!1),n&&s.arguments(n),r&&s.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=s,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
13
- Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new W(e,t,i)),f.exit(e)}action(e){let t=i=>{let n=this.registeredArguments.length,r=i.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new ae(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(r){if(r.code==="commander.invalidArgument"){let s=`${n} ${r.message}`;this.error(s,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let i=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
14
- - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=n=>[n.name()].concat(n.aliases()),i=t(e).find(n=>this._findCommand(n));if(i){let n=t(this._findCommand(i)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${n}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let r=e.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let n=(r,s,l)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let a=this.getOptionValue(i);r!==null&&e.parseArg?r=this._callParseArg(e,r,a,s):r!==null&&e.variadic&&(r=e._concatValue(r,a)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(i,r,l)};return this.on("option:"+t,r=>{let s=`error: option '${e.flags}' argument '${r}' is invalid.`;n(r,s,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let s=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;n(r,s,"env")}),this}_optionEx(e,t,i,n,r){if(typeof t=="object"&&t instanceof ae)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(t,i);if(s.makeOptionMandatory(!!e.mandatory),typeof n=="function")s.default(r).argParser(n);else if(n instanceof RegExp){let l=n;n=(a,c)=>{let h=l.exec(a);return h?h[0]:c},s.default(r).argParser(n)}else s.default(n);return this.addOption(s)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:!0},e,t,i,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(e)!==void 0&&(t=i.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){f.versions?.electron&&(t.from="electron");let n=f.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(t.from="eval")}e===void 0&&(e=f.argv),this.rawArgs=e.slice();let i;switch(t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":f.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(e,t){let i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){let i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_executeSubCommand(e,t){t=t.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function r(h,d){let u=y.resolve(h,d);if(U.existsSync(u))return u;if(n.includes(y.extname(d)))return;let p=n.find(m=>U.existsSync(`${u}${m}`));if(p)return`${u}${p}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let h;try{h=U.realpathSync(this._scriptPath)}catch{h=this._scriptPath}l=y.resolve(y.dirname(h),l)}if(l){let h=r(l,s);if(!h&&!e._executableFile&&this._scriptPath){let d=y.basename(this._scriptPath,y.extname(this._scriptPath));d!==this._name&&(h=r(l,`${d}-${e._name}`))}s=h||s}i=n.includes(y.extname(s));let a;f.platform!=="win32"?i?(t.unshift(s),t=le(f.execArgv).concat(t),a=F.spawn(f.argv[0],t,{stdio:"inherit"})):a=F.spawn(s,t,{stdio:"inherit"}):(t.unshift(s),t=le(f.execArgv).concat(t),a=F.spawn(f.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(d=>{f.on(d,()=>{a.killed===!1&&a.exitCode===null&&a.kill(d)})});let c=this._exitCallback;a.on("close",h=>{h=h??1,c?c(new W(h,"commander.executeSubCommandAsync","(close)")):f.exit(h)}),a.on("error",h=>{if(h.code==="ENOENT"){let d=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",u=`'${s}' does not exist
15
- - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
16
- - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
17
- - ${d}`;throw new Error(u)}else if(h.code==="EACCES")throw new Error(`'${s}' not executable`);if(!c)f.exit(1);else{let d=new W(1,"commander.executeSubCommandAsync","(error)");d.nestedError=h,c(d)}}),this.runningCommand=a}_dispatchSubcommand(e,t,i){let n=this._findCommand(e);n||this.help({error:!0});let r;return r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,()=>{if(n._executableHandler)this._executeSubCommand(n,t.concat(i));else return n._parseCommand(t,i)}),r}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(i,n,r)=>{let s=n;if(n!==null&&i.parseArg){let l=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;s=this._callParseArg(i,n,r,l)}return s};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((i,n)=>{let r=i.defaultValue;i.variadic?n<this.args.length?(r=this.args.slice(n),i.parseArg&&(r=r.reduce((s,l)=>e(i,l,s),i.defaultValue))):r===void 0&&(r=[]):n<this.args.length&&(r=this.args[n],i.parseArg&&(r=e(i,r,i.defaultValue))),t[n]=r}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let i=e,n=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(s=>{n.push({hookedCommand:r,callback:s})})}),t==="postAction"&&n.reverse(),n.forEach(r=>{i=this._chainOrCall(i,()=>r.callback(r.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(r=>{n=this._chainOrCall(n,()=>r(this,t))}),n}_parseCommand(e,t){let i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(r,e,t)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent&&this.parent.listenerCount(r))n(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});e.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=e.find(r=>i.conflictsWith.includes(r.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],n=t,r=e.slice();function s(a){return a.length>1&&a[0]==="-"}let l=null;for(;r.length;){let a=r.shift();if(a==="--"){n===i&&n.push(a),n.push(...r);break}if(l&&!s(a)){this.emit(`option:${l.name()}`,a);continue}if(l=null,s(a)){let c=this._findOption(a);if(c){if(c.required){let h=r.shift();h===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,h)}else if(c.optional){let h=null;r.length>0&&!s(r[0])&&(h=r.shift()),this.emit(`option:${c.name()}`,h)}else this.emit(`option:${c.name()}`);l=c.variadic?c:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let c=this._findOption(`-${a[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,a.slice(2)):(this.emit(`option:${c.name()}`),r.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let c=a.indexOf("="),h=this._findOption(a.slice(0,c));if(h&&(h.required||h.optional)){this.emit(`option:${h.name()}`,a.slice(c+1));continue}}if(s(a)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(a)){t.push(a),r.length>0&&i.push(...r);break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a),r.length>0&&t.push(...r);break}else if(this._defaultCommandName){i.push(a),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){n.push(a),r.length>0&&n.push(...r);break}n.push(a)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let i=0;i<t;i++){let n=this.options[i].attributeName();e[n]=n===this._versionOptionName?this._version:this[n]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
18
- `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
19
- `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
20
- `),this.outputHelp({error:!0}));let i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in f.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,f.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Ue(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!t(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=s=>{let l=s.attributeName(),a=this.getOptionValue(l),c=this.options.find(d=>d.negate&&l===d.attributeName()),h=this.options.find(d=>!d.negate&&l===d.attributeName());return c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg)?c:h||s},n=s=>{let l=i(s),a=l.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},r=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],r=this;do{let s=r.createHelp().visibleOptions(r).filter(l=>l.long).map(l=>l.long);n=n.concat(s),r=r.parent}while(r&&!r._enablePositionalOptions);t=ue(e,n)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(r=>{n.push(r.name()),r.alias()&&n.push(r.alias())}),t=ue(e,n)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e}
21
- `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${n}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>je(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=y.basename(e,y.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},i;return t.error?i=n=>this._outputConfiguration.writeErr(n):i=n=>this._outputConfiguration.writeOut(n),t.write=e.write||i,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=f.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.
22
- Expecting one of '${i.join("', '")}'`);let n=`${e}Help`;return this.on(n,r=>{let s;typeof t=="function"?s=t({error:r.error,command:r.command}):s=t,s&&r.write(`${s}
23
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function le(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?n=r[3]:i=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],i=r[3],n=r[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}ce.Command=B});var fe=b(_=>{var{Argument:de}=E(),{Command:G}=he(),{CommanderError:We,InvalidArgumentError:me}=P(),{Help:Be}=L(),{Option:pe}=j();_.program=new G;_.createCommand=o=>new G(o);_.createOption=(o,e)=>new pe(o,e);_.createArgument=(o,e)=>new de(o,e);_.Command=G;_.Option=pe;_.Argument=de;_.Help=Be;_.CommanderError=We;_.InvalidArgumentError=me;_.InvalidOptionArgumentError=me});var ge=S(fe(),1),{program:bt,createCommand:Ct,createArgument:Ot,createOption:xt,CommanderError:Pt,InvalidArgumentError:C,InvalidOptionArgumentError:At,Command:_e,Argument:Et,Option:g,Help:Tt}=ge.default;var Ge=new Set(["git","changes","projects"]);function ye(o){return o.argument("[prompt]","task to execute in the interactive TUI").addOption(new g("--lane <lane>","managed backend lane for test or staging builds")).addOption(new g("--session [id]","open a Session by id, or browse Sessions when id is omitted")).addOption(new g("-c, --continue","continue the latest Session in the current workspace")).addOption(new g("--tui-mode <mode>","TUI mode: regular (default) or fullscreen").argParser(Je)).addOption(new g("--resume <id>").hideHelp()).allowExcessArguments(!1).showHelpAfterError()}function ve(o,e){if(o&&Ge.has(o))throw new Error("too many arguments");let t=typeof e.session=="string"?e.session.trim():void 0,i=e.resume?.trim(),n=e.session===!0;if([!!(t||n),!!i,e.continue===!0].filter(Boolean).length>1)throw new Error("--session, --continue, and --resume cannot be combined");let s=t||i;return{...o?{initialPrompt:o}:{},...s?{sessionId:s}:{},...n?{showSessionPicker:!0}:{},...e.continue?{continueLatestSession:!0}:{},...e.tuiMode?{tuiMode:e.tuiMode}:{},...e.lane?{lane:e.lane}:{}}}function we(o){return o.argument("[prompt]","task to execute").addOption(new g("--input <source>",'read explicit input; only "-" is supported')).addOption(new g("--input-format <format>","input format: text or json").default("text")).addOption(new g("--cwd <path>","workspace directory")).addOption(new g("--file <path>","attach a file (repeatable)").argParser(Ke).default([])).addOption(new g("--model <provider/model>","override the model for this Run only")).addOption(new g("--session <id>","run in an existing active Session")).addOption(new g("--continue","continue the latest active Session in --cwd")).addOption(new g("--config <path>","use an explicit Runtime config file for this process")).addOption(new g("--permission <policy>","permission policy: smart, full, or off (ask requires TUI/ACP)").default("smart")).addOption(new g("--timeout <duration>","Run timeout, for example 30s or 2m")).addOption(new g("--max-steps <count>","maximum assistant steps")).addOption(new g("--output-format <format>","output format: text, json, or stream-json")).addOption(new g("--output-schema <schema>","JSON Schema file or inline object for the final answer")).addOption(new g("-o, --output-last-message <path>","write the final agent message to a file"))}function Je(o){if(o==="regular"||o==="fullscreen")return o;throw new C("TUI mode must be regular or fullscreen")}function Ke(o,e){return[...e,o]}function Pe(o){let e,t=u=>({...u,...e?{lane:e}:{}}),i=u=>e?Ce(o)(u,e):Ce(o)(u),n=u=>e?Oe(o)(u,e):Oe(o)(u),r=ye(new _e().name("mcode").description("Minimax Code \u2014 terminal coding agent").version(o.version).enablePositionalOptions()).action((u,p)=>o.launchTui(t(ve(u,p))));r.hook("preAction",()=>{e=(o.resolveLane??X)(r.opts().lane)}),r.command("init").description("Analyze the codebase and generate AGENTS.md with the Runtime init Skill").argument("[directory]","project directory",".").action(u=>o.launchTui(t({initialPrompt:"/init",workspaceDir:u})));let s=r.command("exec").description("Run one prompt without starting the TUI");we(s).action((u,p)=>e?o.runExec(u,p,e):o.runExec(u,p)),r.command("acp").description("Run MiniMax Code as an Agent Client Protocol server over stdio").allowExcessArguments(!1).action(()=>e?xe(o)(e):xe(o)()).command("login").description("Sign in to use MiniMax Code Agent features").option("--region <region>","account region: cn or global",J).option("--no-browser","print the authorization URL without opening a browser").allowExcessArguments(!1).action(u=>e?o.runLogin(u.region,u.browser!==!1,e):o.runLogin(u.region,u.browser!==!1)),r.command("login").description("Sign in to use MiniMax Code Agent features").option("--region <region>","account region: cn or global",J).option("--no-browser","print the authorization URL without opening a browser").allowExcessArguments(!1).action(u=>e?o.runLogin(u.region,u.browser!==!1,e):o.runLogin(u.region,u.browser!==!1)),r.command("logout").description("Sign out of the MiniMax account used by this CLI").option("--region <region>","account region: cn or global",J).allowExcessArguments(!1).action(u=>o.runLogout(u.region)),r.command("update").description("Check for and install a Minimax Code update").allowExcessArguments(!1).action(o.runUpdate);let a=r.command("provider").description("Manage model providers and API keys").allowExcessArguments(!1).action(()=>o.launchTui(t({initialPrompt:"/provider"})));a.command("list").description("List configured providers").option("--json","print a JSON document").action(u=>i({action:"list",json:u.json})),a.command("add").description("Add a custom provider").requiredOption("--name <name>","provider display name").requiredOption("--base-url <url>","provider API base URL").option("--api-format <format>",M.join(", "),Xe,"anthropic-messages").option("--model <id>","model ID (repeatable)",ze,[]).option("--api-key-env <name>","environment variable containing the API key").option("--use","select the first model as the default").action(u=>{if(u.model.length===0)throw new Error("At least one --model <id> is required.");return i({action:"add",name:u.name,baseUrl:u.baseUrl,apiFormat:u.apiFormat,models:u.model,apiKeyEnv:u.apiKeyEnv,saveAndUse:u.use})}),a.command("remove").description("Remove a custom provider").argument("<provider-id>","custom_provider:<id>").option("--yes","confirm removal").action((u,p)=>i({action:"remove",providerId:u,confirmed:!!p.yes})),a.command("test").description("Test a provider or one configured model").argument("<provider-id>","provider id").option("--model <id>","test one model").option("--json","print a JSON document").action((u,p)=>i({action:"test",providerId:u,modelId:p.model,json:p.json})),a.command("use").description("Choose the MiniMax credential source").argument("<source>","token-plan or api-key",Ye).action(u=>i({action:"use",source:u})),a.command("set-minimax-key").description("Save and use a MiniMax API key").option("--api-key-env <name>","environment variable containing the API key").action(u=>i({action:"set-minimax-key",apiKeyEnv:u.apiKeyEnv}));let c=r.command("plugin").description("Manage MiniMax Code Plugins").allowExcessArguments(!1).action(()=>o.launchTui(t({initialPrompt:"/plugins"})));c.command("list").description("List installed or available Plugins").option("-m, --marketplace <marketplace>","official or local",be).option("--available","include uninstalled Plugins").option("--json","print a JSON document").action(u=>n({action:"list",marketplace:u.marketplace,available:u.available,json:u.json}));for(let u of["add","remove","enable","disable"])c.command(u).description(`${Qe(u)} a Plugin`).argument("<plugin[@marketplace]>","Plugin selector").option("-m, --marketplace <marketplace>","official or local",be).option("--json","print a JSON document").action((p,m)=>n({action:u,selector:p,marketplace:m.marketplace,json:m.json}));let h=c.command("marketplace").description("List or refresh MiniMax Code Plugin sources");h.command("list").description("List Plugin sources").option("--json","print a JSON document").action(u=>n({action:"marketplace-list",json:u.json})),h.command("upgrade").description("Refresh all Plugin source snapshots").option("--json","print a JSON document").action(u=>n({action:"marketplace-upgrade",json:u.json}));let d=new ee;d.registerAll(o.commandContributions??[]);for(let u of d.freeze()){if(r.commands.some(p=>p.name()===u.name))throw new Error(`Duplicate CLI command name: ${u.name}`);u.register(r,o)}return r}function ze(o,e){return[...e,o]}function J(o){if(o==="cn")return"cn";if(o==="global")return"en";throw new C('expected "cn" or "global"')}function Xe(o){if(te(o))return o;throw new C(`expected one of: ${M.join(", ")}`)}function Ye(o){if(o==="token-plan")return"token_plan";if(o==="api-key")return"minimax_api_key";throw new C('expected "token-plan" or "api-key"')}function be(o){let e=o.trim().toLocaleLowerCase();if(e==="official"||e==="local")return e;throw new C('expected "official" or "local"')}function Qe(o){return o==="add"?"Install":o==="remove"?"Uninstall":o==="enable"?"Enable":"Disable"}function Ce(o){if(!o.runProvider)throw new Error("Provider management is unavailable.");return o.runProvider}function Oe(o){if(!o.runPlugin)throw new Error("Plugin management is unavailable.");return o.runPlugin}function xe(o){if(!o.runAcp)throw new Error("ACP server is unavailable.");return o.runAcp}var T=S(Y(),1),O=S(Y(),1),Ze=["localhost","127.0.0.1","::1"];function et(o=process.env){let e=K(o,"ALL_PROXY","all_proxy"),t=K(o,"HTTP_PROXY","http_proxy")??e,i=K(o,"HTTPS_PROXY","https_proxy")??e??t;return!t&&!i?{mode:"direct"}:(Ae(t),Ae(i),{mode:"proxy",httpProxy:t?.value??"",httpsProxy:i?.value??"",noProxy:tt(o.NO_PROXY??o.no_proxy)})}function Ee(o={}){let e=et(o.environment);if(e.mode==="direct")return e;let i=(o.createProxyDispatcher??(n=>new z(n)))({httpProxy:e.httpProxy,httpsProxy:e.httpsProxy,noProxy:e.noProxy});return(o.setGlobalDispatcher??T.setGlobalDispatcher)(i),(o.installFetch??it)(),e}function K(o,...e){for(let t of e){let i=o[t]?.trim();if(i)return{name:t,value:i}}}function Ae(o){if(!o)return;let e;try{e=new URL(o.value)}catch{throw new Error(`${o.name} must be an http:// or https:// URL.`)}if(e.protocol!=="http:"&&e.protocol!=="https:"||!e.hostname)throw new Error(`${o.name} must be an http:// or https:// URL.`)}function tt(o){let e=[];for(let t of(o??"").split(",")){let i=t.trim();i&&!e.includes(i)&&e.push(i)}for(let t of Ze)e.includes(t)||e.push(t);return e.join(",")}function it(){T.install?.()}var z=class extends O.Dispatcher{#e=new O.Agent;#t;#i;#n;#r;constructor(e){super(),this.#t=e.httpProxy?new O.ProxyAgent({uri:e.httpProxy}):this.#e,this.#i=e.httpsProxy?e.httpsProxy===e.httpProxy?this.#t:new O.ProxyAgent({uri:e.httpsProxy}):this.#e,this.#n=[...new Set([this.#e,this.#t,this.#i])],this.#r=e.noProxy}dispatch(e,t){let i=new URL(e.origin??"");return nt(i,this.#r)?this.#e.dispatch(e,t):(i.protocol==="https:"?this.#i:this.#t).dispatch(e,t)}close(e){let t=Promise.all(this.#n.map(i=>i.close())).then(()=>{});if(!e)return t;t.then(e,e)}destroy(e,t){let i=typeof e=="function"?null:e??null,n=typeof e=="function"?e:t,r=Promise.all(this.#n.map(s=>s.destroy(i))).then(()=>{});if(!n)return r;r.then(n,n)}};function nt(o,e){let t=Te(o.hostname),i=Number(o.port)||(o.protocol==="https:"?443:80);for(let n of e.split(/[\s,]+/u)){let r=rt(n);if(r){if(r.hostname==="*")return!0;if(!(r.port!==void 0&&r.port!==i)&&(t===r.hostname||r.includeSubdomains&&t.endsWith(`.${r.hostname}`)))return!0}}return!1}function rt(o){let e=o.trim().toLowerCase();if(!e)return;if(e==="*")return{hostname:"*",includeSubdomains:!0};let t;if(e.startsWith("[")){let r=e.indexOf("]");if(r>0){let s=e.slice(r+1);/^:\d+$/u.test(s)&&(t=Number(s.slice(1))),e=e.slice(1,r)}}else if(e.split(":").length===2){let[r,s]=e.split(":");r&&/^\d+$/u.test(s??"")&&(e=r,t=Number(s))}let i=e.startsWith(".")||e.startsWith("*");e=e.replace(/^\*?\./u,"");let n=Te(e);return n?{hostname:n,port:t,includeSubdomains:i}:void 0}function Te(o){return o.toLowerCase().replace(/^\[|\]$/gu,"")}var ke=250,ot="minimax-code";async function Wt(o={}){let e=o.processRef??process;e.title=ot;let t=ne(e.env);if(!(o.supportsNodeVersion??(r=>Z(r)))(e.versions.node)){e.stderr.write(`Minimax Code supports Node.js ${Q}; current version is ${e.versions.node}.
24
- `),e.exitCode=1;return}let n;try{if((o.configureNetworkProxy??Ee)({environment:e.env}),await(o.createProgram??Pe)({version:w,launchTui:async({initialPrompt:s,sessionId:l,showSessionPicker:a,continueLatestSession:c,workspaceDir:h,tuiMode:d,lane:u})=>{await(o.launchTui??st)({version:w,...s?{initialPrompt:s}:{},...l?{sessionId:l}:{},...a?{showSessionPicker:!0}:{},...c?{continueLatestSession:!0}:{},...h?{workspaceDir:h}:{},...d?{tuiMode:d}:{},...u?{lane:u}:{},...t?{resumeDraftAfterLogin:!0}:{}}),n="force"},runExec:async(s,l,a)=>{await(o.runExec??at)(s,a?{...l,lane:a}:l,w),n="natural"},runAcp:async s=>{await(o.runAcp??ut)(w,s),n="natural"},runLogin:async(s,l,a)=>{let c=o.runLogin??lt;e.stdout.write(`${await c(s,l,a)}
25
- `),n="natural"},runLogout:async s=>{let l=o.runLogout??ct;e.stdout.write(`${await l(s)}
26
- `),n="natural"},runUpdate:async()=>{n="natural",await(o.runUpdate??ht)(w)},runProvider:async(s,l)=>{let a=o.runProvider??dt;e.stdout.write(`${await a(s,w,l)}
27
- `),n="natural"},runPlugin:async(s,l)=>{let a=o.runPlugin??mt;e.stdout.write(`${await a(s,w,l)}
28
- `),n="natural"}}).parseAsync(e.argv,{from:"node"}),n){let s=typeof e.exitCode=="number"?e.exitCode:0;await Promise.all([Se(e.stdout,o.outputDrainTimeoutMs??ke),Se(e.stderr,o.outputDrainTimeoutMs??ke)]),(o.platform??process.platform)==="win32"&&n==="natural"?e.exitCode=s:e.exit(s)}}catch(r){e.stderr.write(`${ie(r)}
29
- `),e.exitCode=1}}function Se(o,e){return o.destroyed||o.writableEnded?Promise.resolve():new Promise(t=>{let i=!1,n,r=()=>s(!0),s=(l=!1)=>{i||(i=!0,n&&clearTimeout(n),l||o.off?.("error",r),t())};n=setTimeout(s,e),n.unref?.(),o.once?.("error",r);try{o.write("",l=>s(!!l))}catch{s()}})}async function st(o){let{launchTui:e}=await import("./launcher-P2FIIDHG.js");await e(o)}async function at(o,e,t){let{runTuiExecCommand:i}=await import("./run-exec-command-5UZ7WFH4.js");await i(o,e,t)}async function ut(o,e){let{runTuiAcpCommand:t}=await import("./run-acp-command-DWPL6R6W.js");await t(o,{},e)}async function lt(o,e=!0,t){let{runTuiLogin:i}=await import("./auth-command-MIT2ROTA.js");return i({region:o,openBrowser:e,lane:t})}async function ct(o){let{runTuiLogout:e}=await import("./auth-command-MIT2ROTA.js");return e({region:o})}async function ht(o){let{runMcodeUpdate:e}=await import("./update-J2OGG3ZH.js");await e(o)}async function dt(o,e,t){let{runMcodeProviderCommand:i}=await import("./provider-command-2JVOUOBS.js");return i({request:o,version:e,lane:t})}async function mt(o,e,t){let{runMcodePluginCommand:i}=await import("./plugin-command-T6LW4ONC.js");return i({request:o,version:e,lane:t})}export{Se as drainTuiOutput,Wt as runTuiCli};