@minimax-ai/code 0.6.1 → 0.6.3

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 (29) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/CHANGELOG.zh-CN.md +15 -0
  3. package/README.md +21 -0
  4. package/README.zh-CN.md +15 -0
  5. package/chunks/{auth-command-7CDRKDVD.js → auth-command-CO6IUQQ5.js} +1 -1
  6. package/chunks/{chunk-UNHOACX2.js → chunk-7CKVJIAL.js} +1 -1
  7. package/chunks/{chunk-UI7OHI22.js → chunk-EL5XOH23.js} +510 -510
  8. package/chunks/chunk-G7Q4HUMC.js +23 -0
  9. package/chunks/{chunk-JVKXU2EF.js → chunk-K7X2ELVZ.js} +2 -2
  10. package/chunks/{chunk-H2MLHV4N.js → chunk-T4F6MBL2.js} +1 -1
  11. package/chunks/{chunk-FD7DWNRT.js → chunk-T6KXDH7B.js} +1 -1
  12. package/chunks/{chunk-PUFWXRWS.js → chunk-U7ACBEGU.js} +5 -5
  13. package/chunks/{chunk-K3IQFB2P.js → chunk-VN3EYAMT.js} +1 -1
  14. package/chunks/chunk-WROGTDVD.js +3 -0
  15. package/chunks/{chunk-5DNOXYNO.js → chunk-YC47AWPX.js} +1 -1
  16. package/chunks/{data-dir-3FQYZA5W.js → data-dir-4GSZVAMG.js} +1 -1
  17. package/chunks/{launcher-Z2CKZB4R.js → launcher-ST7GNBTY.js} +152 -152
  18. package/chunks/{lifecycle-SQHUVIJ7.js → lifecycle-MEDWAANQ.js} +1 -1
  19. package/chunks/main-7X6VQMDB.js +9 -0
  20. package/chunks/{plugin-command-YRAYZBNS.js → plugin-command-EZNOWONW.js} +1 -1
  21. package/chunks/{provider-command-GJYV7UUM.js → provider-command-OJLRQ76A.js} +1 -1
  22. package/chunks/{run-acp-command-MUUZAUTS.js → run-acp-command-Z5CVNHZZ.js} +2 -2
  23. package/chunks/run-exec-command-MT4Y6VPF.js +17 -0
  24. package/cli.js +2 -2
  25. package/package.json +1 -1
  26. package/chunks/chunk-Q45WUEPQ.js +0 -3
  27. package/chunks/chunk-RO4BB34M.js +0 -2
  28. package/chunks/main-2G4XWJUW.js +0 -30
  29. package/chunks/run-exec-command-NWUGZRC4.js +0 -17
@@ -0,0 +1,23 @@
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 U}from"./chunk-CF3YFDG4.js";import{a as G}from"./chunk-PRXIML4F.js";import{a as w,c as C,e as le}from"./chunk-D76SO2ME.js";var E=C(V=>{var x=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}},H=class extends x{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};V.CommanderError=x;V.InvalidArgumentError=H});var $=C(P=>{var{InvalidArgumentError:pe}=E(),k=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 pe(`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 fe(o){let e=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+e+">":"["+e+"]"}P.Argument=k;P.humanReadableArgName=fe});var T=C(K=>{var{humanReadableArgName:ge}=$(),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=>ge(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,O){if(O){let S=`${m.padEnd(i+s)}${O}`;return t.wrap(S,n-r,i+s)}return m}function a(m){return m.join(`
3
+ `).replace(/^/gm," ".repeat(r))}let u=[`Usage: ${t.commandUsage(e)}`,""],h=t.commandDescription(e);h.length>0&&(u=u.concat([t.wrap(h,n,0),""]));let c=t.visibleArguments(e).map(m=>l(t.argumentTerm(m),t.argumentDescription(m)));c.length>0&&(u=u.concat(["Arguments:",a(c),""]));let p=t.visibleOptions(e).map(m=>l(t.optionTerm(m),t.optionDescription(m)));if(p.length>0&&(u=u.concat(["Options:",a(p),""])),this.showGlobalOptions){let m=t.visibleGlobalOptions(e).map(O=>l(t.optionTerm(O),t.optionDescription(O)));m.length>0&&(u=u.concat(["Global Options:",a(m),""]))}let b=t.visibleCommands(e).map(m=>l(t.subcommandTerm(m),t.subcommandDescription(m)));return b.length>0&&(u=u.concat(["Commands:",a(b),""])),u.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),u=e.slice(i).replace(`\r
5
+ `,`
6
+ `),h=" ".repeat(i),p="\\s\u200B",b=new RegExp(`
7
+ |.{1,${l-1}}([${p}]|$)|[^${p}]+?([${p}]|$)`,"g"),m=u.match(b)||[];return a+m.map((O,S)=>O===`
8
+ `?"":(S>0?h:"")+O.trimEnd()).join(`
9
+ `)}};K.Help=I});var q=C(N=>{var{InvalidArgumentError:_e}=E(),M=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=be(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 _e(`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 Oe(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},F=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 Oe(o){return o.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function be(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}}N.Option=M;N.DualOptions=F});var Y=C(X=>{function Ce(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 Ae(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=Ce(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]}?)`:""}X.suggestSimilar=Ae});var ee=C(Z=>{var ye=w("node:events").EventEmitter,D=w("node:child_process"),_=w("node:path"),j=w("node:fs"),d=w("node:process"),{Argument:we,humanReadableArgName:Ee}=$(),{CommanderError:W}=E(),{Help:ve}=T(),{Option:J,DualOptions:xe}=q(),{suggestSimilar:z}=Y(),R=class o extends ye{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=>d.stdout.write(t),writeErr:t=>d.stderr.write(t),getOutHelpWidth:()=>d.stdout.isTTY?d.stdout.columns:void 0,getErrHelpWidth:()=>d.stderr.isTTY?d.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 ve,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 we(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)),d.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 J(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 J)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,u)=>{let h=l.exec(a);return h?h[0]:u},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){d.versions?.electron&&(t.from="electron");let n=d.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(t.from="eval")}e===void 0&&(e=d.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":d.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,c){let p=_.resolve(h,c);if(j.existsSync(p))return p;if(n.includes(_.extname(c)))return;let b=n.find(m=>j.existsSync(`${p}${m}`));if(b)return`${p}${b}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let h;try{h=j.realpathSync(this._scriptPath)}catch{h=this._scriptPath}l=_.resolve(_.dirname(h),l)}if(l){let h=r(l,s);if(!h&&!e._executableFile&&this._scriptPath){let c=_.basename(this._scriptPath,_.extname(this._scriptPath));c!==this._name&&(h=r(l,`${c}-${e._name}`))}s=h||s}i=n.includes(_.extname(s));let a;d.platform!=="win32"?i?(t.unshift(s),t=Q(d.execArgv).concat(t),a=D.spawn(d.argv[0],t,{stdio:"inherit"})):a=D.spawn(s,t,{stdio:"inherit"}):(t.unshift(s),t=Q(d.execArgv).concat(t),a=D.spawn(d.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(c=>{d.on(c,()=>{a.killed===!1&&a.exitCode===null&&a.kill(c)})});let u=this._exitCallback;a.on("close",h=>{h=h??1,u?u(new W(h,"commander.executeSubCommandAsync","(close)")):d.exit(h)}),a.on("error",h=>{if(h.code==="ENOENT"){let c=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",p=`'${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
+ - ${c}`;throw new Error(p)}else if(h.code==="EACCES")throw new Error(`'${s}' not executable`);if(!u)d.exit(1);else{let c=new W(1,"commander.executeSubCommandAsync","(error)");c.nestedError=h,u(c)}}),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 u=this._findOption(a);if(u){if(u.required){let h=r.shift();h===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,h)}else if(u.optional){let h=null;r.length>0&&!s(r[0])&&(h=r.shift()),this.emit(`option:${u.name()}`,h)}else this.emit(`option:${u.name()}`);l=u.variadic?u:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let u=this._findOption(`-${a[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,a.slice(2)):(this.emit(`option:${u.name()}`),r.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let u=a.indexOf("="),h=this._findOption(a.slice(0,u));if(h&&(h.required||h.optional)){this.emit(`option:${h.name()}`,a.slice(u+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 d.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()}`,d.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new xe(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),u=this.options.find(c=>c.negate&&l===c.attributeName()),h=this.options.find(c=>!c.negate&&l===c.attributeName());return u&&(u.presetArg===void 0&&a===!1||u.presetArg!==void 0&&a===u.presetArg)?u: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=z(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=z(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=>Ee(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=_.basename(e,_.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=d.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 Q(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})}Z.Command=R});var re=C(f=>{var{Argument:te}=$(),{Command:L}=ee(),{CommanderError:$e,InvalidArgumentError:ie}=E(),{Help:Se}=T(),{Option:ne}=q();f.program=new L;f.createCommand=o=>new L(o);f.createOption=(o,e)=>new ne(o,e);f.createArgument=(o,e)=>new te(o,e);f.Command=L;f.Option=ne;f.Argument=te;f.Help=Se;f.CommanderError=$e;f.InvalidArgumentError=ie;f.InvalidOptionArgumentError=ie});var g=Object.freeze({success:0,invocation:2,config:3,runtime:4,timeout:6,limit:7,internal:70,cancelled:130,brokenPipe:141}),y=class extends G{constructor(t,i,n){super(t,i,{code:`exec.${t}`,retryable:t==="runtime",...n});this.kind=t;this.name="TuiExecError"}};function Te(o){switch(o.status){case"succeeded":return g.success;case"failed":return o.error?.category==="config"?g.config:o.error?.category==="internal"?g.internal:g.runtime;case"timeout":return g.timeout;case"cancelled":return g.cancelled;case"limit_exceeded":return g.limit}return g.internal}function Me(o){return o instanceof y?g[o.kind]:g.internal}var ue=new Set(["none-thinking",""]),B="--model must use provider/model or provider/model#variant.";function he(o){let e=o.indexOf("/");if(e<1||e===o.length-1)throw A(B);let t=o.slice(0,e),i=o.slice(e+1),n=i.lastIndexOf("#"),r=n>0?i.slice(0,n):i,s=n>0?i.slice(n+1):void 0;if(!t||!r||n>0&&!s)throw A(B);return{providerId:t,modelId:r,...s?{variant:s}:{}}}async function De(o){let e=o.model?he(o.model):void 0,t=o.effort;if(t===void 0)return e?{...e}:void 0;let i=await de(o,t),n=e??me(o.session,i);if(!n)throw A("--effort could not resolve a model. Pass --model provider/model, or select a model for this Session first.");let r=i.find(u=>u.providerId===n.providerId&&u.modelId===n.modelId),s=U(r?.effortOptions),l=`${n.providerId}/${n.modelId}`,a=n.variant??r?.variant;if(a!==void 0&&ue.has(a))throw A(ce({requested:e,reference:l,effort:t,effectiveVariant:a,target:r}));if(!r)throw A(`${l} is not in this Session's model list, so --effort ${t} cannot be validated. Check the provider and model id.`);if(s.length===0)throw A(`${l} does not support reasoning effort selection, so --effort ${t} cannot be applied.`);if(!s.includes(t))throw A(`--effort ${t} is not available for ${l}. Available levels: ${s.join(", ")}.`);return{providerId:n.providerId,modelId:n.modelId,...n.variant===void 0?{}:{variant:n.variant},thinking:{effort:t}}}function ce(o){let{requested:e,reference:t,effort:i,effectiveVariant:n,target:r}=o;if(e?.variant!==void 0)return`--effort cannot be combined with the thinking-off variant "#${n}". Drop one of them.`;if(!e)return`--effort cannot be applied because this Session runs the thinking-off variant "#${n}". Switch the Session model, or pass --model with a thinking-capable variant.`;let s=r?.thinkingConfig?.mode==="switchable"?` Pass --model ${t}#thinking to turn thinking on.`:"";return`${t} runs with thinking off by default, so --effort ${i} would be discarded.${s}`}async function de(o,e){try{return await o.runtime.listModels(o.session.sessionId)}catch(t){throw new y("runtime",`--effort ${e} could not be validated because the model roster is unavailable: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}function me(o,e){let t=e.find(n=>n.selected===!0);if(t)return{providerId:t.providerId,modelId:t.modelId,...t.variant===void 0?{}:{variant:t.variant}};let i=o.model;if(i?.providerId&&i.modelId)return{providerId:i.providerId,modelId:i.modelId,...i.variant===void 0?{}:{variant:i.variant}}}function A(o){return new y("invocation",o)}import{readFileSync as He}from"node:fs";import{resolve as Ve}from"node:path";var se=le(re(),1),{program:Xe,createCommand:Ye,createArgument:Je,createOption:ze,CommanderError:Qe,InvalidArgumentError:Ze,InvalidOptionArgumentError:et,Command:tt,Argument:it,Option:v,Help:nt}=se.default;var ke=["--system-prompt","--system-prompt-file","--append-system-prompt","--append-system-prompt-file"],ae=[["systemPrompt","systemPromptFile"],["appendSystemPrompt","appendSystemPromptFile"]],Pe=new Set(ae.flat());function lt(o){return o.addOption(new v("--system-prompt <text>","replace the main Agent identity prompt for this process")).addOption(new v("--system-prompt-file <path>","read the replacement main Agent identity prompt from a file")).addOption(new v("--append-system-prompt <text>","append text after the main Agent identity prompt for this process")).addOption(new v("--append-system-prompt-file <path>","read the appended main Agent prompt text from a file"))}function ut(o,e){let t=e;for(let i of ae)if(!i.some(n=>e[n]!==void 0))for(let n=o.parent;n;n=n.parent){let r=n,s=i.filter(l=>r.getOptionValueSource(l)==="cli");if(s.length!==0){for(let l of s)t={...t,[l]:r.getOptionValue(l)};break}}return t}function ht(o){if(!o.options.some(e=>e.attributeName()==="systemPrompt"))for(let e=o.parent;e;e=e.parent)for(let t of e.options){let i=t.attributeName();if(!Pe.has(i)||e.getOptionValueSource(i)!=="cli")continue;let n=[];for(let r=o;r?.parent;r=r.parent)n.unshift(r.name());o.error(`error: option '${t.long}' is not supported by '${n.join(" ")}'`,{code:"commander.unknownOption"})}}function ct(o,e=process.cwd()){let t=oe("--system-prompt",o.systemPrompt,o.systemPromptFile,e),i=oe("--append-system-prompt",o.appendSystemPrompt,o.appendSystemPromptFile,e);if(!(t===void 0&&i===void 0))return{...t===void 0?{}:{customPrompt:t},...i===void 0?{}:{appendSystemPrompt:i}}}function dt(o){let e=[];for(let t=0;t<o.length;t+=1){let i=o[t];if(i===void 0||i==="--")break;let n=ke.find(s=>i===s||i.startsWith(`${s}=`));if(!n)continue;if(i!==n){e.push(i);continue}let r=o[t+1];if(r===void 0)break;e.push(n,r),t+=1}return e}function oe(o,e,t,i){if(e!==void 0&&t!==void 0)throw new Error(`${o} and ${o}-file cannot be combined.`);if(e!==void 0){if(!e.trim())throw new Error(`${o} cannot be empty.`);return e}if(t===void 0)return;if(!t.trim())throw new Error(`${o}-file requires a path.`);let n;try{n=He(Ve(i,t),"utf8")}catch(r){throw new Error(`Failed to read ${o}-file ${t}: ${r instanceof Error?r.message:String(r)}`,{cause:r})}if(!n.trim())throw new Error(`${o}-file ${t} is empty.`);return n}export{Ze as a,tt as b,v as c,g as d,y as e,Te as f,Me as g,he as h,De as i,Pe as j,lt as k,ut as l,ht as m,ct as n,dt as o};
@@ -1,9 +1,9 @@
1
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
- var N=["local-task:","local-background-task:","team-plan:"],x=new Set(["explore","worker","verifier"]);function w(e){return e.sessionKind==="task"||N.some(n=>e.purpose?.startsWith(n))}function C(e){return e.sessionType!=="branch"||!e.parentSessionId?!1:w(e)}function v(e){let n=e.agentName?.trim().toLocaleLowerCase();return n!==void 0&&x.has(n)}function he(e){return w(e)||v(e)}function we(e,n){let r=[],t=new Set,i=new Set([n]),s=!0;for(;s;){s=!1;for(let o of e)t.has(o.sessionId)||!C(o)||!i.has(o.parentSessionId)||(r.push(o),t.add(o.sessionId),i.add(o.sessionId),s=!0)}return r}function Se(e){return{sessionId:e.sessionId,parentSessionId:e.parentSessionId,...e.agentName?{agentName:e.agentName}:{},...e.title?{task:e.title}:{},status:D(e.status),...O(e.purpose),...h("createdAtMs",e.createdAt),...h("updatedAtMs",e.updatedAt),...e.errorMessage?{errorMessage:e.errorMessage}:{}}}function be(e){return e.status==="queued"||e.status==="running"}function D(e){let n=e?.trim().toLocaleLowerCase().replaceAll("-","_");return n?n==="queued"||n==="pending"||n==="created"?"queued":n==="running"||n==="started"||n==="active"||n==="busy"||n==="processing"||n==="in_progress"?"running":n==="finished"||n==="completed"||n==="succeeded"||n==="success"||n==="idle"?"completed":n==="error"||n==="failed"||n==="lost"?"failed":n==="aborted"||n==="interrupted"||n==="cancelled"||n==="canceled"||n==="stopped"?"stopped":"unknown":"unknown"}function O(e){let n="local-background-task:";return e?.startsWith(n)?{backgroundTaskId:e.slice(n.length)||void 0}:{}}function h(e,n){if(typeof n=="number"&&Number.isFinite(n))return{[e]:n};if(typeof n!="string")return{};let r=Number(n);if(Number.isFinite(r))return{[e]:r};let t=Date.parse(n);return Number.isFinite(t)?{[e]:t}:{}}function I(e){let n=V(e.toolName),r=p(e.input);if(!n)return;let t=W(e.status,e.error),i=X(n)?B(r??{},e.output):K(n)?r?L(r):[]:[];if(i.length!==0)return{schemaVersion:1,state:t,blocks:i}}function B(e,n){let r=g(e,["path","filePath","file_path"]),t=j(n);return t?[t.omitted===void 0?S(r,t.diff):z(r,t.diff,t.omitted)]:F(e).map(({oldText:i,newText:s})=>{let o=[...i.split(`
2
+ var x=["local-task:","local-background-task:","team-plan:"],N=new Set(["explore","worker","verifier"]);function w(e){return e.sessionKind==="task"||x.some(n=>e.purpose?.startsWith(n))}function C(e){return e.sessionType!=="branch"||!e.parentSessionId?!1:w(e)}function v(e){let n=e.agentName?.trim().toLocaleLowerCase();return n!==void 0&&N.has(n)}function he(e){return w(e)||v(e)}function we(e,n){let r=[],t=new Set,i=new Set([n]),s=!0;for(;s;){s=!1;for(let o of e)t.has(o.sessionId)||!C(o)||!i.has(o.parentSessionId)||(r.push(o),t.add(o.sessionId),i.add(o.sessionId),s=!0)}return r}function Se(e){return{sessionId:e.sessionId,parentSessionId:e.parentSessionId,...e.agentName?{agentName:e.agentName}:{},...e.title?{task:e.title}:{},status:D(e.status),...O(e.purpose),...h("createdAtMs",e.createdAt),...h("updatedAtMs",e.updatedAt),...e.errorMessage?{errorMessage:e.errorMessage}:{}}}function be(e){return e.status==="queued"||e.status==="running"}function D(e){let n=e?.trim().toLocaleLowerCase().replaceAll("-","_");return n?n==="queued"||n==="pending"||n==="created"?"queued":n==="running"||n==="started"||n==="active"||n==="busy"||n==="processing"||n==="in_progress"?"running":n==="finished"||n==="completed"||n==="succeeded"||n==="success"||n==="idle"?"completed":n==="error"||n==="failed"||n==="lost"?"failed":n==="aborted"||n==="interrupted"||n==="cancelled"||n==="canceled"||n==="stopped"?"stopped":"unknown":"unknown"}function O(e){let n="local-background-task:";return e?.startsWith(n)?{backgroundTaskId:e.slice(n.length)||void 0}:{}}function h(e,n){if(typeof n=="number"&&Number.isFinite(n))return{[e]:n};if(typeof n!="string")return{};let r=Number(n);if(Number.isFinite(r))return{[e]:r};let t=Date.parse(n);return Number.isFinite(t)?{[e]:t}:{}}var Ie="mavis";function M(e){let n=J(e.toolName),r=p(e.input);if(!n)return;let t=U(e.status,e.error),i=V(n)?B(r??{},e.output):G(n)?r?L(r):[]:[];if(i.length!==0)return{schemaVersion:1,state:t,blocks:i}}function B(e,n){let r=g(e,["path","filePath","file_path"]),t=j(n);return t?[t.omitted===void 0?S(r,t.diff):z(r,t.diff,t.omitted)]:F(e).map(({oldText:i,newText:s})=>{let o=[...i.split(`
3
3
  `).map(d=>`- ${d}`),...s.split(`
4
4
  `).map(d=>`+ ${d}`)].join(`
5
5
  `);return S(r,o)})}function L(e){let n=g(e,["path","filePath","file_path"]),r=g(e,["content","fileContent","file_content"]);if(r===void 0)return[];let t=m(r);return r.includes("\0")?[{kind:"summary",...n?{path:n}:{},message:"Binary content cannot be previewed safely.",reason:"binary",byteCount:t}]:t>65536?[{kind:"summary",...n?{path:n}:{},message:`File preview omitted because it is ${Y(t)}.`,reason:"too-large",byteCount:t}]:[{kind:"file",...n?{path:n}:{},content:r,lineCount:r.split(`
6
6
  `).length,truncated:!1}]}function S(e,n){let r=n.split(`
7
7
  `),t=m(n),i=r.slice(0,400),s=t>65536,o=i.join(`
8
8
  `);s&&(o=$(o,65536));let d=Math.max(0,r.length-o.split(`
9
- `).length);return{kind:"diff",...e?{path:e}:{},diff:o,addedLines:b(r,"+"),removedLines:b(r,"-"),truncated:d>0||s,...d>0?{omittedLines:d}:{}}}function z(e,n,r){return{kind:"summary",...e?{path:e}:{},message:n,reason:r==="timeout"?"unavailable":"too-large"}}function j(e){let n=p(e);if(!n)return;let r=[n,p(n.result),p(n.output)].filter(t=>t!==void 0);for(let t of r){let i=p(t.details),s=i?g(i,["diff","previewDiff","preview_diff"]):void 0;if(s){let o=i?g(i,["diffOmitted","diff_omitted"]):void 0;return o===void 0?{diff:s}:{diff:s,omitted:o}}}}function F(e){let r=(G(e.edits)??[]).flatMap(s=>{let o=p(s),d=o?g(o,["oldText","old_text"]):void 0,f=o?g(o,["newText","new_text"]):void 0;return d!==void 0&&f!==void 0?[{oldText:d,newText:f}]:[]}),t=g(e,["oldText","old_text"]),i=g(e,["newText","new_text"]);return t!==void 0&&i!==void 0&&r.push({oldText:t,newText:i}),r}function W(e,n){return J(n)||q(e)?"not-applied":U(e)?"applied":"proposed"}function U(e){return e===2||e==="2"||e==="completed"||e==="complete"||e==="done"||e==="finished"||e==="succeeded"||e==="success"}function q(e){return e===3||e==="3"||e==="failed"||e==="error"}function J(e){return e!=null&&e!==""}function V(e){return e?.trim().toLocaleLowerCase().replace(/[^a-z0-9]/gu,"")||void 0}function X(e){return e==="edit"||e==="editfile"||e==="replace"}function K(e){return e==="write"||e==="writefile"||e==="createfile"}function p(e){let n=M(e);return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function G(e){let n=M(e);return Array.isArray(n)?n:void 0}function M(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return}}function g(e,n){for(let r of n){let t=e[r];if(typeof t=="string")return t}}function b(e,n){return e.filter(r=>r.startsWith(n)&&!r.startsWith(n.repeat(3))).length}function m(e){return new TextEncoder().encode(e).byteLength}function $(e,n){if(m(e)<=n)return e;let r=0,t=e.length;for(;r<t;){let i=Math.ceil((r+t)/2);m(e.slice(0,i))<=n?r=i:t=i-1}return e.slice(0,r)}function Y(e){return e<1024?`${e} B`:`${(e/1024).toFixed(e<10*1024?1:0)} KiB`}var H=2,Q=6,Z=10,ee=3,ne=4;function Ee(e,n){let r=e.dataJson?.trim();if(!r)return;if(r==="[DONE]")return R({type:"done",turnId:n},e);let t;try{t=JSON.parse(r)}catch{return}let i=a(t);if(!i)return;let s=u(i,["turn_id","turnId"])??n,o=i.type,d;if(o===Z||o==="heartbeat")d={type:"heartbeat",turnId:s};else if(o===H||o==="agent_message"){let f=a(i.agent_message)??a(i.agentMessage);d=f?re(f,s):void 0}else if(te(i)){let f=a(i.agent_message_chunk)??a(i.agentMessageChunk);d=f?ie(f,s):void 0}else if(o==="error")d={type:"error",message:u(i,["error","message"])??"Runtime stream failed",turnId:s};else if(o==="session_status")d=se(i,s);else if(o===ee||o===ne)d=ue(i,s);else if(o==="resume_overflow")d={type:"resync-required",turnId:s};else if(typeof o=="string"){let f={...i};delete f.type,delete f.turnId,d={type:"generic",eventType:o,data:f,turnId:s}}return d?R(d,e):void 0}function te(e){return e.type===Q&&("agent_message_chunk"in e||"agentMessageChunk"in e)||e.type==="agent_message_chunk"}function re(e,n){let r=oe(e,n);if(r)return r;let t=P(e,n);if(t.role!=="unknown")return t.role==="assistant"&&t.finishReason==="error"?{type:"error",message:t.content?.trim()||"Runtime stream failed",turnId:n}:{type:"message",message:t}}function ie(e,n){let r=P(e,n);if(r.role==="assistant")return l({type:"delta",messageId:r.id,turnId:r.turnId??n,role:r.role,content:r.content,thinking:r.thinking,toolCalls:r.toolCalls,timestamp:r.timestamp,chunkIndex:c(e,["chunk_index","chunkIndex"]),finish:e.finish===!0?!0:void 0})}function oe(e,n){let r=u(e,["msg_content","msgContent","content"]);if(!r)return;let t;try{t=a(JSON.parse(r))}catch{return}let i=t?u(t,["eventType"]):void 0;if(!t||!i||!(c(e,["msg_type","msgType","message_type","messageType"])===3)&&!["session.spawned","communication.message","delegation.message","todo_updated"].includes(i))return;let o={...t};return delete o.eventType,l({type:"generic",eventType:i,data:o,turnId:u(e,["turn_id","turnId"])??n,messageId:u(e,["msg_id","msgId","id"]),timestamp:c(e,["timestamp"])})}function se(e,n){let r=a(e.session_status)??{},t=de(u(r,["type","status"]));return t?l({type:"session-status",status:t,message:u(r,["message"]),turnId:n}):void 0}function ue(e,n){let r=a(e.payload)??{},t=ae(c(r,["status"]));if(!t)return;let i=a(r.error);return l({type:"session-status",status:t,message:u(i??r,["message","detail"]),turnId:n})}function de(e){if(e==="idle"||e==="started"||e==="finished"||e==="error"||e==="aborted"||e==="interrupted")return e}function ae(e){if(e===1||e===2)return"started";if(e===3)return"idle";if(e===4)return"error";if(e===5)return"aborted";if(e===6)return"finished"}function R(e,n){return n.cursor?{...e,cursor:n.cursor}:e}function P(e,n){return ce(a(e)??{},n)}function ce(e,n){let r=a(T(e.rawJson??e.raw_json))??{};return l({id:u(e,["msg_id","msgId","id"]),turnId:u(e,["turn_id","turnId"])??n,role:ye(u(e,["role"]))??"unknown",kind:pe(u(e,["kind"])),source:u(e,["source"]),origin:T(e.origin??e.originJson??e.origin_json),error:u(e,["error"]),tokensBefore:c(e,["tokensBefore","tokens_before"]),tokensAfter:c(e,["tokensAfter","tokens_after"]),content:u(e,["msg_content","msgContent","content"]),editContent:u(e,["editContent"])??u(r,["editContent"]),thinking:u(e,["thinking_content","thinkingContent","thinking"]),thinkingDurationMs:c(e,["thinking_duration_ms","thinkingDurationMs"]),toolCalls:A(k(e,["tool_calls","toolCalls"])),toolResult:ge(a(e.toolResult??e.tool_result)),parts:me(k(e,["parts"])),attachments:Te(k(e,["attachments"])),timestamp:c(e,["timestamp","createdAt","created_at"]),finishReason:u(e,["finish_reason","finishReason"]),usage:fe(a(e.usage)),actions:le(a(e.actions))})}function le(e){if(!e)return;let n=l({fork:E(e,["fork"]),rewind:E(e,["rewind"])});return Object.keys(n).length>0?n:void 0}function fe(e){if(!e)return;let n=l({totalTokens:c(e,["total_tokens","totalTokens"]),inputTokens:c(e,["input_tokens","inputTokens"]),outputTokens:c(e,["output_tokens","outputTokens"]),reasoningTokens:c(e,["reasoning","reasoning_tokens","reasoningTokens"]),requestDurationMs:c(e,["request_duration_ms","requestDurationMs"]),decodeDurationMs:c(e,["decode_duration_ms","decodeDurationMs"]),cacheReadTokens:c(e,["cache_read","cacheRead","cache_read_tokens"]),cacheWriteTokens:c(e,["cache_write","cacheWrite","cache_write_tokens"])});return Object.keys(n).length>0?n:void 0}function ge(e){if(!e)return;let n=u(e,["toolCallId","tool_call_id"]);if(!n)return;let r=a(e.details),t=r?l({taskId:u(r,["taskId","task_id"]),subSessionId:u(r,["subSessionId","sub_session_id"]),subTurnId:u(r,["subTurnId","sub_turn_id"])}):void 0;return l({toolCallId:n,toolName:u(e,["toolName","tool_name"]),details:t&&Object.keys(t).length>0?t:void 0})}function pe(e){if(e==="preamble"||e==="final"||e==="compaction_start"||e==="compaction"||e==="compaction_failed"||e==="review_start"||e==="review_result"||e==="review_failed"||e==="review_aborted"||e==="review_interrupted")return e}function Pe(e){return e.parts?.length?[...e.parts]:[...e.thinking?.trim()?[l({type:"thinking",content:e.thinking,durationMs:e.thinkingDurationMs})]:[],...e.content?.trim()?[{type:"text",content:e.content}]:[],...(e.toolCalls??[]).map(n=>({type:"tool",toolCall:n}))]}function me(e){if(!e)return;let n=e.flatMap(r=>{let t=a(r);if(!t)return[];let i=u(t,["id","part_id","partId"]),s=u(t,["type","kind"]);if(s==="thinking"||s==="cognitive_text"){let o=u(t,["content","text","thinking"]);return o===void 0?[]:[l({id:i,type:"thinking",content:o,durationMs:c(t,["durationMs","duration_ms"])})]}if(s==="text"){let o=u(t,["content","text"]);return o===void 0?[]:[l({id:i,type:"text",content:o})]}if(s==="tool"||s==="tool_call"||s==="toolCall"){let o=a(t.toolCall??t.tool_call)??t,[d]=A([o])??[];return d?[l({id:i,type:"tool",toolCall:d})]:[]}return[]});return n.length>0?n:void 0}function Te(e){if(!e)return;let n=e.flatMap(r=>{let t=a(r);if(!t)return[];let i=a(t.meta)??t,s=a(t.local),o=a(t.cloud),d=u(i,["mimeType","mime_type"])??u(t,["mimeType","mime_type"])??"application/octet-stream",f=u(i,["attachmentType","attachment_type","type"])??u(t,["attachmentType","attachment_type","type"]);return[l({type:f==="image"||d.startsWith("image/")?"image":"file",fileName:u(i,["fileName","file_name"])??u(t,["fileName","file_name"])??"attachment",mimeType:d,sizeBytes:c(i,["sizeBytes","size_bytes"]),filePath:(s?u(s,["filePath","file_path"]):void 0)??u(t,["filePath","file_path"]),assetId:s?u(s,["assetId","asset_id"]):void 0,previewUrl:u(t,["previewUrl","preview_url"])??(o?u(o,["url"]):void 0)})]});return n.length>0?n:void 0}function A(e){if(!e)return;let n=e.flatMap(r=>{let t=a(r);if(!t)return[];let i=u(t,["tool_name","tool_call_name","toolName","name"]);if(!i)return[];let s=l({id:u(t,["tool_call_id","toolCallId","id"]),name:i,status:u(t,["tool_call_status","toolCallStatus","status"])??c(t,["tool_call_status","toolCallStatus","status"]),input:T(_(t,["tool_call_args","toolCallArgs","args","arguments","input"])),output:T(_(t,["tool_call_result_data","toolCallResultData","tool_call_result","toolCallResult","result","output"])),error:_(t,["tool_call_error","toolCallError","error"]),durationMs:c(t,["tool_call_duration_ms","toolCallDurationMs","durationMs","duration_ms"])}),o=I({toolName:s.name,status:s.status,input:s.input,output:s.output,error:s.error});return[{...s,...o?{structuredPreview:o}:{}}]});return n.length>0?n:void 0}function ye(e){return e==="user"||e==="assistant"||e==="system"?e:e===void 0?void 0:"unknown"}function a(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function u(e,n){for(let r of n)if(typeof e[r]=="string")return e[r]}function c(e,n){for(let r of n){let t=e[r];if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()){let i=Number(t);if(Number.isFinite(i))return i}}}function E(e,n){for(let r of n)if(typeof e[r]=="boolean")return e[r]}function k(e,n){for(let r of n)if(Array.isArray(e[r]))return e[r]}function _(e,n){for(let r of n)if(Object.prototype.hasOwnProperty.call(e,r))return e[r]}function T(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function l(e){return Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}var y=["default","auto","bypassPermissions"],ke={default:"Ask",auto:"Auto",bypassPermissions:"Full access",off:"Off"},_e={default:"ASK",auto:"AUTO",bypassPermissions:"FULL",off:"OFF"};function Ne(e){return y.find(n=>n===e)}function xe(e){return ke[e]}function Ce(e){return _e[e]}function ve(e){return e==="bypassPermissions"}function De(e){if(e==="off")return"default";let n=y.indexOf(e);return y[(n+1)%y.length]}export{C as a,v as b,he as c,we as d,Se as e,be as f,I as g,Ee as h,P as i,Pe as j,y as k,Ne as l,xe as m,Ce as n,ve as o,De as p};
9
+ `).length);return{kind:"diff",...e?{path:e}:{},diff:o,addedLines:b(r,"+"),removedLines:b(r,"-"),truncated:d>0||s,...d>0?{omittedLines:d}:{}}}function z(e,n,r){return{kind:"summary",...e?{path:e}:{},message:n,reason:r==="timeout"?"unavailable":"too-large"}}function j(e){let n=p(e);if(!n)return;let r=[n,p(n.result),p(n.output)].filter(t=>t!==void 0);for(let t of r){let i=p(t.details),s=i?g(i,["diff","previewDiff","preview_diff"]):void 0;if(s){let o=i?g(i,["diffOmitted","diff_omitted"]):void 0;return o===void 0?{diff:s}:{diff:s,omitted:o}}}}function F(e){let r=(K(e.edits)??[]).flatMap(s=>{let o=p(s),d=o?g(o,["oldText","old_text"]):void 0,f=o?g(o,["newText","new_text"]):void 0;return d!==void 0&&f!==void 0?[{oldText:d,newText:f}]:[]}),t=g(e,["oldText","old_text"]),i=g(e,["newText","new_text"]);return t!==void 0&&i!==void 0&&r.push({oldText:t,newText:i}),r}function U(e,n){return q(n)||X(e)?"not-applied":W(e)?"applied":"proposed"}function W(e){return e===2||e==="2"||e==="completed"||e==="complete"||e==="done"||e==="finished"||e==="succeeded"||e==="success"}function X(e){return e===3||e==="3"||e==="failed"||e==="error"}function q(e){return e!=null&&e!==""}function J(e){return e?.trim().toLocaleLowerCase().replace(/[^a-z0-9]/gu,"")||void 0}function V(e){return e==="edit"||e==="editfile"||e==="replace"}function G(e){return e==="write"||e==="writefile"||e==="createfile"}function p(e){let n=I(e);return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function K(e){let n=I(e);return Array.isArray(n)?n:void 0}function I(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return}}function g(e,n){for(let r of n){let t=e[r];if(typeof t=="string")return t}}function b(e,n){return e.filter(r=>r.startsWith(n)&&!r.startsWith(n.repeat(3))).length}function m(e){return new TextEncoder().encode(e).byteLength}function $(e,n){if(m(e)<=n)return e;let r=0,t=e.length;for(;r<t;){let i=Math.ceil((r+t)/2);m(e.slice(0,i))<=n?r=i:t=i-1}return e.slice(0,r)}function Y(e){return e<1024?`${e} B`:`${(e/1024).toFixed(e<10*1024?1:0)} KiB`}var H=2,Q=6,Z=10,ee=3,ne=4;function Ae(e,n){let r=e.dataJson?.trim();if(!r)return;if(r==="[DONE]")return E({type:"done",turnId:n},e);let t;try{t=JSON.parse(r)}catch{return}let i=a(t);if(!i)return;let s=u(i,["turn_id","turnId"])??n,o=i.type,d;if(o===Z||o==="heartbeat")d={type:"heartbeat",turnId:s};else if(o===H||o==="agent_message"){let f=a(i.agent_message)??a(i.agentMessage);d=f?re(f,s):void 0}else if(te(i)){let f=a(i.agent_message_chunk)??a(i.agentMessageChunk);d=f?ie(f,s):void 0}else if(o==="error")d={type:"error",message:u(i,["error","message"])??"Runtime stream failed",turnId:s};else if(o==="session_status")d=se(i,s);else if(o===ee||o===ne)d=ue(i,s);else if(o==="resume_overflow")d={type:"resync-required",turnId:s};else if(typeof o=="string"){let f={...i};delete f.type,delete f.turnId,d={type:"generic",eventType:o,data:f,turnId:s}}return d?E(d,e):void 0}function te(e){return e.type===Q&&("agent_message_chunk"in e||"agentMessageChunk"in e)||e.type==="agent_message_chunk"}function re(e,n){let r=oe(e,n);if(r)return r;let t=P(e,n);if(t.role!=="unknown")return t.role==="assistant"&&t.finishReason==="error"?{type:"error",message:t.content?.trim()||"Runtime stream failed",turnId:n}:{type:"message",message:t}}function ie(e,n){let r=P(e,n);if(r.role==="assistant")return l({type:"delta",messageId:r.id,turnId:r.turnId??n,role:r.role,content:r.content,thinking:r.thinking,toolCalls:r.toolCalls,timestamp:r.timestamp,chunkIndex:c(e,["chunk_index","chunkIndex"]),finish:e.finish===!0?!0:void 0})}function oe(e,n){let r=u(e,["msg_content","msgContent","content"]);if(!r)return;let t;try{t=a(JSON.parse(r))}catch{return}let i=t?u(t,["eventType"]):void 0;if(!t||!i||!(c(e,["msg_type","msgType","message_type","messageType"])===3)&&!["session.spawned","communication.message","delegation.message","todo_updated"].includes(i))return;let o={...t};return delete o.eventType,l({type:"generic",eventType:i,data:o,turnId:u(e,["turn_id","turnId"])??n,messageId:u(e,["msg_id","msgId","id"]),timestamp:c(e,["timestamp"])})}function se(e,n){let r=a(e.session_status)??{},t=de(u(r,["type","status"]));return t?l({type:"session-status",status:t,message:u(r,["message"]),turnId:n}):void 0}function ue(e,n){let r=a(e.payload)??{},t=ae(c(r,["status"]));if(!t)return;let i=a(r.error);return l({type:"session-status",status:t,message:u(i??r,["message","detail"]),turnId:n})}function de(e){if(e==="idle"||e==="started"||e==="finished"||e==="error"||e==="aborted"||e==="interrupted")return e}function ae(e){if(e===1||e===2)return"started";if(e===3)return"idle";if(e===4)return"error";if(e===5)return"aborted";if(e===6)return"finished"}function E(e,n){return n.cursor?{...e,cursor:n.cursor}:e}function P(e,n){return ce(a(e)??{},n)}function ce(e,n){let r=a(T(e.rawJson??e.raw_json))??{};return l({id:u(e,["msg_id","msgId","id"]),turnId:u(e,["turn_id","turnId"])??n,role:ye(u(e,["role"]))??"unknown",kind:pe(u(e,["kind"])),source:u(e,["source"]),origin:T(e.origin??e.originJson??e.origin_json),error:u(e,["error"]),tokensBefore:c(e,["tokensBefore","tokens_before"]),tokensAfter:c(e,["tokensAfter","tokens_after"]),content:u(e,["msg_content","msgContent","content"]),editContent:u(e,["editContent"])??u(r,["editContent"]),thinking:u(e,["thinking_content","thinkingContent","thinking"]),thinkingDurationMs:c(e,["thinking_duration_ms","thinkingDurationMs"]),toolCalls:A(k(e,["tool_calls","toolCalls"])),toolResult:ge(a(e.toolResult??e.tool_result)),parts:me(k(e,["parts"])),attachments:Te(k(e,["attachments"])),timestamp:c(e,["timestamp","createdAt","created_at"]),finishReason:u(e,["finish_reason","finishReason"]),usage:fe(a(e.usage)),actions:le(a(e.actions))})}function le(e){if(!e)return;let n=l({fork:R(e,["fork"]),rewind:R(e,["rewind"])});return Object.keys(n).length>0?n:void 0}function fe(e){if(!e)return;let n=l({totalTokens:c(e,["total_tokens","totalTokens"]),inputTokens:c(e,["input_tokens","inputTokens"]),outputTokens:c(e,["output_tokens","outputTokens"]),reasoningTokens:c(e,["reasoning","reasoning_tokens","reasoningTokens"]),requestDurationMs:c(e,["request_duration_ms","requestDurationMs"]),decodeDurationMs:c(e,["decode_duration_ms","decodeDurationMs"]),cacheReadTokens:c(e,["cache_read","cacheRead","cache_read_tokens"]),cacheWriteTokens:c(e,["cache_write","cacheWrite","cache_write_tokens"])});return Object.keys(n).length>0?n:void 0}function ge(e){if(!e)return;let n=u(e,["toolCallId","tool_call_id"]);if(!n)return;let r=a(e.details),t=r?l({taskId:u(r,["taskId","task_id"]),subSessionId:u(r,["subSessionId","sub_session_id"]),subTurnId:u(r,["subTurnId","sub_turn_id"])}):void 0;return l({toolCallId:n,toolName:u(e,["toolName","tool_name"]),details:t&&Object.keys(t).length>0?t:void 0})}function pe(e){if(e==="preamble"||e==="final"||e==="compaction_start"||e==="compaction"||e==="compaction_failed"||e==="review_start"||e==="review_result"||e==="review_failed"||e==="review_aborted"||e==="review_interrupted")return e}function xe(e){return e.parts?.length?[...e.parts]:[...e.thinking?.trim()?[l({type:"thinking",content:e.thinking,durationMs:e.thinkingDurationMs})]:[],...e.content?.trim()?[{type:"text",content:e.content}]:[],...(e.toolCalls??[]).map(n=>({type:"tool",toolCall:n}))]}function me(e){if(!e)return;let n=e.flatMap(r=>{let t=a(r);if(!t)return[];let i=u(t,["id","part_id","partId"]),s=u(t,["type","kind"]);if(s==="thinking"||s==="cognitive_text"){let o=u(t,["content","text","thinking"]);return o===void 0?[]:[l({id:i,type:"thinking",content:o,durationMs:c(t,["durationMs","duration_ms"])})]}if(s==="text"){let o=u(t,["content","text"]);return o===void 0?[]:[l({id:i,type:"text",content:o})]}if(s==="tool"||s==="tool_call"||s==="toolCall"){let o=a(t.toolCall??t.tool_call)??t,[d]=A([o])??[];return d?[l({id:i,type:"tool",toolCall:d})]:[]}return[]});return n.length>0?n:void 0}function Te(e){if(!e)return;let n=e.flatMap(r=>{let t=a(r);if(!t)return[];let i=a(t.meta)??t,s=a(t.local),o=a(t.cloud),d=u(i,["mimeType","mime_type"])??u(t,["mimeType","mime_type"])??"application/octet-stream",f=u(i,["attachmentType","attachment_type","type"])??u(t,["attachmentType","attachment_type","type"]);return[l({type:f==="image"||d.startsWith("image/")?"image":"file",fileName:u(i,["fileName","file_name"])??u(t,["fileName","file_name"])??"attachment",mimeType:d,sizeBytes:c(i,["sizeBytes","size_bytes"]),filePath:(s?u(s,["filePath","file_path"]):void 0)??u(t,["filePath","file_path"]),assetId:s?u(s,["assetId","asset_id"]):void 0,previewUrl:u(t,["previewUrl","preview_url"])??(o?u(o,["url"]):void 0)})]});return n.length>0?n:void 0}function A(e){if(!e)return;let n=e.flatMap(r=>{let t=a(r);if(!t)return[];let i=u(t,["tool_name","tool_call_name","toolName","name"]);if(!i)return[];let s=l({id:u(t,["tool_call_id","toolCallId","id"]),name:i,status:u(t,["tool_call_status","toolCallStatus","status"])??c(t,["tool_call_status","toolCallStatus","status"]),input:T(_(t,["tool_call_args","toolCallArgs","args","arguments","input"])),output:T(_(t,["tool_call_result_data","toolCallResultData","tool_call_result","toolCallResult","result","output"])),error:_(t,["tool_call_error","toolCallError","error"]),durationMs:c(t,["tool_call_duration_ms","toolCallDurationMs","durationMs","duration_ms"])}),o=M({toolName:s.name,status:s.status,input:s.input,output:s.output,error:s.error});return[{...s,...o?{structuredPreview:o}:{}}]});return n.length>0?n:void 0}function ye(e){return e==="user"||e==="assistant"||e==="system"?e:e===void 0?void 0:"unknown"}function a(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function u(e,n){for(let r of n)if(typeof e[r]=="string")return e[r]}function c(e,n){for(let r of n){let t=e[r];if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()){let i=Number(t);if(Number.isFinite(i))return i}}}function R(e,n){for(let r of n)if(typeof e[r]=="boolean")return e[r]}function k(e,n){for(let r of n)if(Array.isArray(e[r]))return e[r]}function _(e,n){for(let r of n)if(Object.prototype.hasOwnProperty.call(e,r))return e[r]}function T(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function l(e){return Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}var y=["default","auto","bypassPermissions"],ke={default:"Ask",auto:"Auto",bypassPermissions:"Full access",off:"Off"},_e={default:"ASK",auto:"AUTO",bypassPermissions:"FULL",off:"OFF"};function Ce(e){return y.find(n=>n===e)}function ve(e){return ke[e]}function De(e){return _e[e]}function Oe(e){return e==="bypassPermissions"}function Be(e){if(e==="off")return"default";let n=y.indexOf(e);return y[(n+1)%y.length]}export{C as a,v as b,he as c,we as d,Se as e,be as f,M as g,Ae as h,P as i,xe as j,y as k,Ce as l,ve as m,De as n,Oe as o,Be as p,Ie as q};
@@ -1,2 +1,2 @@
1
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{l as i,n as D}from"./chunk-UNHOACX2.js";import{ua as a,y as n}from"./chunk-XYED4XTT.js";function o(t,r=n,e=a){return r(void 0,e())}function u(){return o(i())}function m(t){let r=t.MINIMAX_DATA_DIR?.trim();return r||t.MAVIS_DATA_DIR?.trim()||void 0}function f(t=process.env,r=u){return m(t)??r()}function v(t=u,r=process.env){return f(r,t)}function p(t={}){let r=(t.getBuildEnv??i)(),e=v(t.getDefaultDataDir??(()=>o(r)),t.environment??process.env);return(t.configureRuntimeEnvironment??D)({dataDir:e}),Promise.resolve(e)}export{o as a,f as b,v as c,p as d};
2
+ import{l as i,n as D}from"./chunk-7CKVJIAL.js";import{ua as a,y as n}from"./chunk-XYED4XTT.js";function o(t,r=n,e=a){return r(void 0,e())}function u(){return o(i())}function m(t){let r=t.MINIMAX_DATA_DIR?.trim();return r||t.MAVIS_DATA_DIR?.trim()||void 0}function f(t=process.env,r=u){return m(t)??r()}function v(t=u,r=process.env){return f(r,t)}function p(t={}){let r=(t.getBuildEnv??i)(),e=v(t.getDefaultDataDir??(()=>o(r)),t.environment??process.env);return(t.configureRuntimeEnvironment??D)({dataDir:e}),Promise.resolve(e)}export{o as a,f as b,v as c,p as d};
@@ -1,2 +1,2 @@
1
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{b as i,c as n,d as o,h as a,i as r}from"./chunk-UNHOACX2.js";function s(t){let e=i({dataDir:t.dataDir,buildEnv:t.buildEnv,region:t.region}),u=t.oauthClient??h(t.oauthEndpoints),d=r({authHome:e.namespaceHome});return new a({namespace:e,oauthClient:u,credentialStore:d,initialize:()=>n(e)})}function h(t){if(!t)throw new TypeError("Shared MCode OAuth requires explicit device authorization, token, and revocation endpoints.");return new o(t)}export{s as a};
2
+ import{b as i,c as n,d as o,h as a,i as r}from"./chunk-7CKVJIAL.js";function s(t){let e=i({dataDir:t.dataDir,buildEnv:t.buildEnv,region:t.region}),u=t.oauthClient??h(t.oauthEndpoints),d=r({authHome:e.namespaceHome});return new a({namespace:e,oauthClient:u,credentialStore:d,initialize:()=>n(e)})}function h(t){if(!t)throw new TypeError("Shared MCode OAuth requires explicit device authorization, token, and revocation endpoints.");return new o(t)}export{s as a};