@niwa-labs/ncode 0.1.0 → 0.1.1

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 (46) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/CHANGELOG.zh-CN.md +5 -0
  3. package/README.md +2 -2
  4. package/chunks/{application-A3S2LMBY.js → application-6B6N6MDM.js} +1 -1
  5. package/chunks/{auth-command-QNQ32TBI.js → auth-command-L57HWPOO.js} +1 -1
  6. package/chunks/{chunk-6LDRLO4Y.js → chunk-3LRARE6Z.js} +1 -1
  7. package/chunks/{chunk-5R2PGOIA.js → chunk-3MLT4F77.js} +1 -1
  8. package/chunks/{chunk-NOGL6Y6L.js → chunk-7F3QKGB7.js} +1 -1
  9. package/chunks/{chunk-LFGHL5A2.js → chunk-ALZZ3WAV.js} +1 -1
  10. package/chunks/{chunk-RD7XROJD.js → chunk-CUPCI2YC.js} +1 -1
  11. package/chunks/{chunk-OOBSLGMR.js → chunk-DBSRTVJC.js} +1 -1
  12. package/chunks/{chunk-XSWWOH4F.js → chunk-GS7TCNDK.js} +1 -1
  13. package/chunks/{chunk-36COWQLE.js → chunk-GZPVFWYD.js} +1 -1
  14. package/chunks/{chunk-CAY2BP2G.js → chunk-JEHPL5Z6.js} +1 -1
  15. package/chunks/{chunk-R7NDEPS3.js → chunk-LC7ZI6EV.js} +1 -1
  16. package/chunks/{chunk-ELHMZ5OD.js → chunk-NWMN2FDO.js} +1 -1
  17. package/chunks/{chunk-MVI24MQ2.js → chunk-O5EROATK.js} +664 -664
  18. package/chunks/{chunk-UMGGEC4N.js → chunk-QIYZZJVO.js} +1 -1
  19. package/chunks/{chunk-PBGCNSGZ.js → chunk-QMBFFQPV.js} +1 -1
  20. package/chunks/{chunk-JLFN6WSO.js → chunk-RZDVNG5Z.js} +1 -1
  21. package/chunks/{chunk-MI4YWYJF.js → chunk-UEPKZSE6.js} +1 -1
  22. package/chunks/{chunk-V4IDVAIA.js → chunk-WHBWI5OQ.js} +1 -1
  23. package/chunks/{chunk-ZPIJSTUE.js → chunk-WUORF7YS.js} +1 -1
  24. package/chunks/{chunk-UNEPZJKK.js → chunk-XWNCITOR.js} +5 -5
  25. package/chunks/{data-dir-OKWMOLNQ.js → data-dir-6RWVCAMB.js} +1 -1
  26. package/chunks/{launcher-4QSNU24J.js → launcher-B3C4PQ6Q.js} +3 -3
  27. package/chunks/{lifecycle-ELQ2EYO3.js → lifecycle-56K655PJ.js} +1 -1
  28. package/chunks/main-W3SJ2POE.js +14 -0
  29. package/chunks/{plugin-command-NGTATXBX.js → plugin-command-EBSKJLM3.js} +1 -1
  30. package/chunks/{profile-command-ZHVREBWO.js → profile-command-HIJDJDEL.js} +1 -1
  31. package/chunks/{provider-command-BGKOLCUG.js → provider-command-VCCPLOXR.js} +1 -1
  32. package/chunks/{run-acp-command-2CJQDXHQ.js → run-acp-command-FBV27QBE.js} +13 -13
  33. package/chunks/run-daemon-command-PZ2TU524.js +2 -0
  34. package/chunks/run-exec-command-K7BC2HEI.js +16 -0
  35. package/chunks/src-7ZMHMWLX.js +2 -0
  36. package/chunks/{telemetry-command-6FE4WQ4Q.js → telemetry-command-ZYOF64Y4.js} +1 -1
  37. package/chunks/{update-4VPIX7FP.js → update-ZKUCGIOR.js} +1 -1
  38. package/cli.js +3 -3
  39. package/matrix-mcp-stdio.js +1 -1
  40. package/mcoded.js +1 -1
  41. package/package.json +1 -1
  42. package/release.json +4 -4
  43. package/chunks/main-TXP74KHK.js +0 -14
  44. package/chunks/run-daemon-command-NDOIPTKF.js +0 -2
  45. package/chunks/run-exec-command-VNT4IKOJ.js +0 -16
  46. package/chunks/src-ED5HBSWE.js +0 -2
@@ -1,7 +1,7 @@
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{a as Pn,c as ln,e as Fe,n as Ue,o as po}from"./chunk-ISBSRM3S.js";import{n as go}from"./chunk-5R2PGOIA.js";import{a as Ui}from"./chunk-4GGSPZK3.js";import{e as Fi}from"./chunk-FK3SSGJE.js";var ji={support_files_api:true,files_api_upload_endpoint:"/v1/files/upload",max_image_bytes_inline:10485760,max_video_bytes_inline:52428800,max_request_body_bytes:67108864,max_attachments_count:4,max_images_per_request:20};var je={"MiniMax-M3":{name:"MiniMax-M3",attachment:true,reasoning:true,tool_call:true,temperature:true,modalities:{input:["text","image","video"],output:["text"]},limit:{context:512e3,output:128e3},contextWindowOptions:[512e3,1e6],contextWindowOptionHints:{"1000000":"higher_usage"},options:{reasoningSummary:"auto"},thinking_config:{mode:"switchable",default_value:"true"},variants:{"none-thinking":{thinking:{type:"disabled"}},thinking:{thinking:{type:"adaptive"}}},capabilities:ji},"MiniMax-M3.1-Flash":{name:"M3.1-Flash",attachment:true,reasoning:true,tool_call:true,temperature:true,modalities:{input:["text","image","video"],output:["text"]},limit:{context:512e3,output:128e3},contextWindowOptions:[512e3,1e6],contextWindowOptionHints:{"1000000":"higher_usage"},options:{reasoningSummary:"auto"},thinking:{effortOptions:["default","low","medium","high","xhigh","max"],defaultEffort:"default"},thinking_config:{mode:"forced_on"},variants:{"none-thinking":{thinking:{type:"disabled"}},thinking:{thinking:{type:"adaptive"}}},capabilities:ji},"MiniMax-M2.7-highspeed":{name:"MiniMax-M2.7-highspeed",attachment:false,reasoning:true,tool_call:true,temperature:true,modalities:{input:["text"],output:["text"]},limit:{context:2e5,output:128e3}},"MiniMax-M2.7":{name:"MiniMax-M2.7",attachment:false,reasoning:true,tool_call:true,temperature:true,modalities:{input:["text"],output:["text"]},limit:{context:2e5,output:128e3}}};function mo(e){if(typeof e!=="object"||e===null||Array.isArray(e))return{};const n=e.enabled;return typeof n==="boolean"?{enabled:n}:{}}function yo(e,n){return{enabled:mo(n).enabled??mo(e).enabled??true}}import de from"node:fs";import ie from"node:fs";var Vi=384;function Ve(e){if(process.platform==="win32")return;const n=ie.statSync(e).mode;if((n&63)===0)return;ie.chmodSync(e,n&448)}function ue(e,n,i=false){const t=ie.constants.O_WRONLY|ie.constants.O_CREAT|(i?ie.constants.O_EXCL:0);const r=ie.openSync(e,t,Vi);try{ie.fchmodSync(r,Vi);ie.ftruncateSync(r,0);ie.writeFileSync(r,n)}finally{ie.closeSync(r)}}import z from"node:path";import pl from"node:os";import{spawnSync as gl}from"node:child_process";import{fileURLToPath as ml}from"node:url";function hs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var q={};var Ln={};var Ce={};var Ki;function an(){if(Ki)return Ce;Ki=1;function e(a){return typeof a==="undefined"||a===null}function n(a){return typeof a==="object"&&a!==null}function i(a){if(Array.isArray(a))return a;else if(e(a))return[];return[a]}function t(a,c){if(c){const p=Object.keys(c);for(let u=0,d=p.length;u<d;u+=1){const h=p[u];a[h]=c[h]}}return a}function r(a,c){let p="";for(let u=0;u<c;u+=1){p+=a}return p}function l(a){return a===0&&Number.NEGATIVE_INFINITY===1/a}Ce.isNothing=e;Ce.isObject=n;Ce.toArray=i;Ce.repeat=r;Ce.isNegativeZero=l;Ce.extend=t;return Ce}var bo;var Gi;function un(){if(Gi)return bo;Gi=1;function e(i,t){let r="";const l=i.reason||"(unknown reason)";if(!i.mark)return l;if(i.mark.name){r+='in "'+i.mark.name+'" '}r+="("+(i.mark.line+1)+":"+(i.mark.column+1)+")";if(!t&&i.mark.snippet){r+="\n\n"+i.mark.snippet}return l+" "+r}function n(i,t){Error.call(this);this.name="YAMLException";this.reason=i;this.mark=t;this.message=e(this,false);if(Error.captureStackTrace){Error.captureStackTrace(this,this.constructor)}else{this.stack=new Error().stack||""}}n.prototype=Object.create(Error.prototype);n.prototype.constructor=n;n.prototype.toString=function i(t){return this.name+": "+e(this,t)};bo=n;return bo}var ho;var $i;function xs(){if($i)return ho;$i=1;const e=an();function n(r,l,a,c,p){let u="";let d="";const h=Math.floor(p/2)-1;if(c-l>h){u=" ... ";l=c-h+u.length}if(a-c>h){d=" ...";a=c+h-d.length}return{str:u+r.slice(l,a).replace(/\t/g,"\u2192")+d,pos:c-l+u.length}}function i(r,l){return e.repeat(" ",l-r.length)+r}function t(r,l){l=Object.create(l||null);if(!r.buffer)return null;if(!l.maxLength)l.maxLength=79;if(typeof l.indent!=="number")l.indent=1;if(typeof l.linesBefore!=="number")l.linesBefore=3;if(typeof l.linesAfter!=="number")l.linesAfter=2;const a=/\r?\n|\r|\0/g;const c=[0];const p=[];let u;let d=-1;while(u=a.exec(r.buffer)){p.push(u.index);c.push(u.index+u[0].length);if(r.position<=u.index&&d<0){d=c.length-2}}if(d<0)d=c.length-1;let h="";const R=Math.min(r.line+l.linesAfter,p.length).toString().length;const k=l.maxLength-(l.indent+R+3);for(let I=1;I<=l.linesBefore;I++){if(d-I<0)break;const U=n(r.buffer,c[d-I],p[d-I],r.position-(c[d]-c[d-I]),k);h=e.repeat(" ",l.indent)+i((r.line-I+1).toString(),R)+" | "+U.str+"\n"+h}const D=n(r.buffer,c[d],p[d],r.position,k);h+=e.repeat(" ",l.indent)+i((r.line+1).toString(),R)+" | "+D.str+"\n";h+=e.repeat("-",l.indent+R+3+D.pos)+"^\n";for(let I=1;I<=l.linesAfter;I++){if(d+I>=p.length)break;const U=n(r.buffer,c[d+I],p[d+I],r.position-(c[d]-c[d+I]),k);h+=e.repeat(" ",l.indent)+i((r.line+I+1).toString(),R)+" | "+U.str+"\n"}return h.replace(/\n$/,"")}ho=t;return ho}var xo;var Yi;function X(){if(Yi)return xo;Yi=1;const e=un();const n=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"];const i=["scalar","sequence","mapping"];function t(l){const a={};if(l!==null){Object.keys(l).forEach(function(c){l[c].forEach(function(p){a[String(p)]=c})})}return a}function r(l,a){a=a||{};Object.keys(a).forEach(function(c){if(n.indexOf(c)===-1){throw new e('Unknown option "'+c+'" is met in definition of "'+l+'" YAML type.')}});this.options=a;this.tag=l;this.kind=a["kind"]||null;this.resolve=a["resolve"]||function(){return true};this.construct=a["construct"]||function(c){return c};this.instanceOf=a["instanceOf"]||null;this.predicate=a["predicate"]||null;this.represent=a["represent"]||null;this.representName=a["representName"]||null;this.defaultStyle=a["defaultStyle"]||null;this.multi=a["multi"]||false;this.styleAliases=t(a["styleAliases"]||null);if(i.indexOf(this.kind)===-1){throw new e('Unknown kind "'+this.kind+'" is specified for "'+l+'" YAML type.')}}xo=r;return xo}var Co;var Wi;function pt(){if(Wi)return Co;Wi=1;const e=un();const n=X();function i(l,a){const c=[];l[a].forEach(function(p){let u=c.length;c.forEach(function(d,h){if(d.tag===p.tag&&d.kind===p.kind&&d.multi===p.multi){u=h}});c[u]=p});return c}function t(){const l={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function a(c){if(c.multi){l.multi[c.kind].push(c);l.multi["fallback"].push(c)}else{l[c.kind][c.tag]=l["fallback"][c.tag]=c}}for(let c=0,p=arguments.length;c<p;c+=1){arguments[c].forEach(a)}return l}function r(l){return this.extend(l)}r.prototype.extend=function l(a){let c=[];let p=[];if(a instanceof n){p.push(a)}else if(Array.isArray(a)){p=p.concat(a)}else if(a&&(Array.isArray(a.implicit)||Array.isArray(a.explicit))){if(a.implicit)c=c.concat(a.implicit);if(a.explicit)p=p.concat(a.explicit)}else{throw new e("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })")}c.forEach(function(d){if(!(d instanceof n)){throw new e("Specified list of YAML types (or a single Type object) contains a non-Type object.")}if(d.loadKind&&d.loadKind!=="scalar"){throw new e("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}if(d.multi){throw new e("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}});p.forEach(function(d){if(!(d instanceof n)){throw new e("Specified list of YAML types (or a single Type object) contains a non-Type object.")}});const u=Object.create(r.prototype);u.implicit=(this.implicit||[]).concat(c);u.explicit=(this.explicit||[]).concat(p);u.compiledImplicit=i(u,"implicit");u.compiledExplicit=i(u,"explicit");u.compiledTypeMap=t(u.compiledImplicit,u.compiledExplicit);return u};Co=r;return Co}var Ao;var qi;function gt(){if(qi)return Ao;qi=1;const e=X();Ao=new e("tag:yaml.org,2002:str",{kind:"scalar",construct:function(n){return n!==null?n:""}});return Ao}var So;var Hi;function mt(){if(Hi)return So;Hi=1;const e=X();So=new e("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(n){return n!==null?n:[]}});return So}var _o;var Xi;function yt(){if(Xi)return _o;Xi=1;const e=X();_o=new e("tag:yaml.org,2002:map",{kind:"mapping",construct:function(n){return n!==null?n:{}}});return _o}var vo;var zi;function bt(){if(zi)return vo;zi=1;const e=pt();vo=new e({explicit:[gt(),mt(),yt()]});return vo}var Ro;var Ji;function ht(){if(Ji)return Ro;Ji=1;const e=X();function n(r){if(r===null)return true;const l=r.length;return l===1&&r==="~"||l===4&&(r==="null"||r==="Null"||r==="NULL")}function i(){return null}function t(r){return r===null}Ro=new e("tag:yaml.org,2002:null",{kind:"scalar",resolve:n,construct:i,predicate:t,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});return Ro}var Eo;var Qi;function xt(){if(Qi)return Eo;Qi=1;const e=X();function n(r){if(r===null)return false;const l=r.length;return l===4&&(r==="true"||r==="True"||r==="TRUE")||l===5&&(r==="false"||r==="False"||r==="FALSE")}function i(r){return r==="true"||r==="True"||r==="TRUE"}function t(r){return Object.prototype.toString.call(r)==="[object Boolean]"}Eo=new e("tag:yaml.org,2002:bool",{kind:"scalar",resolve:n,construct:i,predicate:t,represent:{lowercase:function(r){return r?"true":"false"},uppercase:function(r){return r?"TRUE":"FALSE"},camelcase:function(r){return r?"True":"False"}},defaultStyle:"lowercase"});return Eo}var Mo;var Zi;function Ct(){if(Zi)return Mo;Zi=1;const e=an();const n=X();function i(u){return u>=48&&u<=57||u>=65&&u<=70||u>=97&&u<=102}function t(u){return u>=48&&u<=55}function r(u){return u>=48&&u<=57}function l(u){if(u===null)return false;const d=u.length;let h=0;let R=false;if(!d)return false;let k=u[h];if(k==="-"||k==="+"){k=u[++h]}if(k==="0"){if(h+1===d)return true;k=u[++h];if(k==="b"){h++;for(;h<d;h++){k=u[h];if(k!=="0"&&k!=="1")return false;R=true}return R&&isFinite(a(u))}if(k==="x"){h++;for(;h<d;h++){if(!i(u.charCodeAt(h)))return false;R=true}return R&&isFinite(a(u))}if(k==="o"){h++;for(;h<d;h++){if(!t(u.charCodeAt(h)))return false;R=true}return R&&isFinite(a(u))}}for(;h<d;h++){if(!r(u.charCodeAt(h))){return false}R=true}if(!R)return false;return isFinite(a(u))}function a(u){let d=u;let h=1;let R=d[0];if(R==="-"||R==="+"){if(R==="-")h=-1;d=d.slice(1);R=d[0]}if(d==="0")return 0;if(R==="0"){if(d[1]==="b")return h*parseInt(d.slice(2),2);if(d[1]==="x")return h*parseInt(d.slice(2),16);if(d[1]==="o")return h*parseInt(d.slice(2),8)}return h*parseInt(d,10)}function c(u){return a(u)}function p(u){return Object.prototype.toString.call(u)==="[object Number]"&&(u%1===0&&!e.isNegativeZero(u))}Mo=new n("tag:yaml.org,2002:int",{kind:"scalar",resolve:l,construct:c,predicate:p,represent:{binary:function(u){return u>=0?"0b"+u.toString(2):"-0b"+u.toString(2).slice(1)},octal:function(u){return u>=0?"0o"+u.toString(8):"-0o"+u.toString(8).slice(1)},decimal:function(u){return u.toString(10)},hexadecimal:function(u){return u>=0?"0x"+u.toString(16).toUpperCase():"-0x"+u.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}});return Mo}var ko;var et;function At(){if(et)return ko;et=1;const e=an();const n=X();const i=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");const t=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function r(u){if(u===null)return false;if(!i.test(u)){return false}if(isFinite(parseFloat(u,10))){return true}return t.test(u)}function l(u){let d=u.toLowerCase();const h=d[0]==="-"?-1:1;if("+-".indexOf(d[0])>=0){d=d.slice(1)}if(d===".inf"){return h===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY}else if(d===".nan"){return NaN}return h*parseFloat(d,10)}const a=/^[-+]?[0-9]+e/;function c(u,d){if(isNaN(u)){switch(d){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}}else if(Number.POSITIVE_INFINITY===u){switch(d){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}}else if(Number.NEGATIVE_INFINITY===u){switch(d){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}}else if(e.isNegativeZero(u)){return"-0.0"}const h=u.toString(10);return a.test(h)?h.replace("e",".e"):h}function p(u){return Object.prototype.toString.call(u)==="[object Number]"&&(u%1!==0||e.isNegativeZero(u))}ko=new n("tag:yaml.org,2002:float",{kind:"scalar",resolve:r,construct:l,predicate:p,represent:c,defaultStyle:"lowercase"});return ko}var wo;var nt;function St(){if(nt)return wo;nt=1;wo=bt().extend({implicit:[ht(),xt(),Ct(),At()]});return wo}var To;var ot;function _t(){if(ot)return To;ot=1;To=St();return To}var Io;var it;function vt(){if(it)return Io;it=1;const e=X();const n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");const i=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function t(a){if(a===null)return false;if(n.exec(a)!==null)return true;if(i.exec(a)!==null)return true;return false}function r(a){let c=0;let p=null;let u=n.exec(a);if(u===null)u=i.exec(a);if(u===null)throw new Error("Date resolve error");const d=+u[1];const h=+u[2]-1;const R=+u[3];if(!u[4]){return new Date(Date.UTC(d,h,R))}const k=+u[4];const D=+u[5];const I=+u[6];if(u[7]){c=u[7].slice(0,3);while(c.length<3){c+="0"}c=+c}if(u[9]){const L=+u[10];const B=+(u[11]||0);p=(L*60+B)*6e4;if(u[9]==="-")p=-p}const U=new Date(Date.UTC(d,h,R,k,D,I,c));if(p)U.setTime(U.getTime()-p);return U}function l(a){return a.toISOString()}Io=new e("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:t,construct:r,instanceOf:Date,represent:l});return Io}var Oo;var tt;function Rt(){if(tt)return Oo;tt=1;const e=X();function n(i){return i==="<<"||i===null}Oo=new e("tag:yaml.org,2002:merge",{kind:"scalar",resolve:n});return Oo}var Po;var rt;function Et(){if(rt)return Po;rt=1;const e=X();const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";function i(a){if(a===null)return false;let c=0;const p=a.length;const u=n;for(let d=0;d<p;d++){const h=u.indexOf(a.charAt(d));if(h>64)continue;if(h<0)return false;c+=6}return c%8===0}function t(a){const c=a.replace(/[\r\n=]/g,"");const p=c.length;const u=n;let d=0;const h=[];for(let k=0;k<p;k++){if(k%4===0&&k){h.push(d>>16&255);h.push(d>>8&255);h.push(d&255)}d=d<<6|u.indexOf(c.charAt(k))}const R=p%4*6;if(R===0){h.push(d>>16&255);h.push(d>>8&255);h.push(d&255)}else if(R===18){h.push(d>>10&255);h.push(d>>2&255)}else if(R===12){h.push(d>>4&255)}return new Uint8Array(h)}function r(a){let c="";let p=0;const u=a.length;const d=n;for(let R=0;R<u;R++){if(R%3===0&&R){c+=d[p>>18&63];c+=d[p>>12&63];c+=d[p>>6&63];c+=d[p&63]}p=(p<<8)+a[R]}const h=u%3;if(h===0){c+=d[p>>18&63];c+=d[p>>12&63];c+=d[p>>6&63];c+=d[p&63]}else if(h===2){c+=d[p>>10&63];c+=d[p>>4&63];c+=d[p<<2&63];c+=d[64]}else if(h===1){c+=d[p>>2&63];c+=d[p<<4&63];c+=d[64];c+=d[64]}return c}function l(a){return Object.prototype.toString.call(a)==="[object Uint8Array]"}Po=new e("tag:yaml.org,2002:binary",{kind:"scalar",resolve:i,construct:t,predicate:l,represent:r});return Po}var Lo;var st;function Mt(){if(st)return Lo;st=1;const e=X();const n=Object.prototype.hasOwnProperty;const i=Object.prototype.toString;function t(l){if(l===null)return true;const a={};const c=l;for(let p=0,u=c.length;p<u;p+=1){const d=c[p];let h=false;if(i.call(d)!=="[object Object]")return false;let R;for(R in d){if(n.call(d,R)){if(!h)h=true;else return false}}if(!h)return false;if(n.call(a,R))return false;Object.defineProperty(a,R,{value:true})}return true}function r(l){return l!==null?l:[]}Lo=new e("tag:yaml.org,2002:omap",{kind:"sequence",resolve:t,construct:r});return Lo}var Do;var lt;function kt(){if(lt)return Do;lt=1;const e=X();const n=Object.prototype.toString;function i(r){if(r===null)return true;const l=r;const a=new Array(l.length);for(let c=0,p=l.length;c<p;c+=1){const u=l[c];if(n.call(u)!=="[object Object]")return false;const d=Object.keys(u);if(d.length!==1)return false;a[c]=[d[0],u[d[0]]]}return true}function t(r){if(r===null)return[];const l=r;const a=new Array(l.length);for(let c=0,p=l.length;c<p;c+=1){const u=l[c];const d=Object.keys(u);a[c]=[d[0],u[d[0]]]}return a}Do=new e("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:i,construct:t});return Do}var No;var at;function wt(){if(at)return No;at=1;const e=X();const n=Object.prototype.hasOwnProperty;function i(r){if(r===null)return true;const l=r;for(const a in l){if(n.call(l,a)){if(l[a]!==null)return false}}return true}function t(r){return r!==null?r:{}}No=new e("tag:yaml.org,2002:set",{kind:"mapping",resolve:i,construct:t});return No}var Bo;var ut;function Uo(){if(ut)return Bo;ut=1;Bo=_t().extend({implicit:[vt(),Rt()],explicit:[Et(),Mt(),kt(),wt()]});return Bo}var ct;function Cs(){if(ct)return Ln;ct=1;const e=an();const n=un();const i=xs();const t=Uo();const r=Object.prototype.hasOwnProperty;const l=1;const a=2;const c=3;const p=4;const u=1;const d=2;const h=3;const R=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;const k=/[\x85\u2028\u2029]/;const D=/[,\[\]{}]/;const I=/^(?:!|!!|![0-9A-Za-z-]+!)$/;const U=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function L(o){return Object.prototype.toString.call(o)}function B(o){return o===10||o===13}function $(o){return o===9||o===32}function Y(o){return o===9||o===32||o===10||o===13}function ne(o){return o===44||o===91||o===93||o===123||o===125}function Je(o){if(o>=48&&o<=57){return o-48}const f=o|32;if(f>=97&&f<=102){return f-97+10}return-1}function me(o){if(o===120){return 2}if(o===117){return 4}if(o===85){return 8}return 0}function Ee(o){if(o>=48&&o<=57){return o-48}return-1}function se(o){switch(o){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return"\n";case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function Me(o){if(o<=65535){return String.fromCharCode(o)}return String.fromCharCode((o-65536>>10)+55296,(o-65536&1023)+56320)}function j(o,f,x){if(f==="__proto__"){Object.defineProperty(o,f,{configurable:true,enumerable:true,writable:true,value:x})}else{o[f]=x}}const Sn=new Array(256);const Qe=new Array(256);for(let o=0;o<256;o++){Sn[o]=se(o)?1:0;Qe[o]=se(o)}function W(o,f){this.input=o;this.filename=f["filename"]||null;this.schema=f["schema"]||t;this.onWarning=f["onWarning"]||null;this.legacy=f["legacy"]||false;this.json=f["json"]||false;this.listener=f["listener"]||null;this.maxDepth=typeof f["maxDepth"]==="number"?f["maxDepth"]:100;this.maxTotalMergeKeys=typeof f["maxTotalMergeKeys"]==="number"?f["maxTotalMergeKeys"]:1e4;this.implicitTypes=this.schema.compiledImplicit;this.typeMap=this.schema.compiledTypeMap;this.length=o.length;this.position=0;this.line=0;this.lineStart=0;this.lineIndent=0;this.depth=0;this.totalMergeKeys=0;this.firstTabInLine=-1;this.documents=[];this.anchorMapTransactions=[]}function _n(o,f){const x={name:o.filename,buffer:o.input.slice(0,-1),position:o.position,line:o.line,column:o.position-o.lineStart};x.snippet=i(x);return new n(f,x)}function M(o,f){throw _n(o,f)}function De(o,f){if(o.onWarning){o.onWarning.call(null,_n(o,f))}}function le(o,f,x){const C=o.anchorMapTransactions;if(C.length!==0){const y=C[C.length-1];if(!r.call(y,f)){y[f]={existed:r.call(o.anchorMap,f),value:o.anchorMap[f]}}}o.anchorMap[f]=x}function so(o){o.anchorMapTransactions.push(Object.create(null))}function ke(o){const f=o.anchorMapTransactions.pop();const x=o.anchorMapTransactions;if(x.length===0)return;const C=x[x.length-1];const y=Object.keys(f);for(let s=0,g=y.length;s<g;s+=1){const m=y[s];if(!r.call(C,m)){C[m]=f[m]}}}function lo(o){const f=o.anchorMapTransactions.pop();const x=Object.keys(f);for(let C=x.length-1;C>=0;C-=1){const y=f[x[C]];if(y.existed){o.anchorMap[x[C]]=y.value}else{delete o.anchorMap[x[C]]}}}function Ze(o){return{position:o.position,line:o.line,lineStart:o.lineStart,lineIndent:o.lineIndent,firstTabInLine:o.firstTabInLine,tag:o.tag,anchor:o.anchor,kind:o.kind,result:o.result}}function Ne(o,f){o.position=f.position;o.line=f.line;o.lineStart=f.lineStart;o.lineIndent=f.lineIndent;o.firstTabInLine=f.firstTabInLine;o.tag=f.tag;o.anchor=f.anchor;o.kind=f.kind;o.result=f.result}const vn={YAML:function o(f,x,C){if(f.version!==null){M(f,"duplication of %YAML directive")}if(C.length!==1){M(f,"YAML directive accepts exactly one argument")}const y=/^([0-9]+)\.([0-9]+)$/.exec(C[0]);if(y===null){M(f,"ill-formed argument of the YAML directive")}const s=parseInt(y[1],10);const g=parseInt(y[2],10);if(s!==1){M(f,"unacceptable YAML version of the document")}f.version=C[0];f.checkLineBreaks=g<2;if(g!==1&&g!==2){De(f,"unsupported YAML version of the document")}},TAG:function o(f,x,C){let y;if(C.length!==2){M(f,"TAG directive accepts exactly two arguments")}const s=C[0];y=C[1];if(!I.test(s)){M(f,"ill-formed tag handle (first argument) of the TAG directive")}if(r.call(f.tagMap,s)){M(f,'there is a previously declared suffix for "'+s+'" tag handle')}if(!U.test(y)){M(f,"ill-formed tag prefix (second argument) of the TAG directive")}try{y=decodeURIComponent(y)}catch(g){M(f,"tag prefix is malformed: "+y)}f.tagMap[s]=y}};function J(o,f,x,C){if(f<x){const y=o.input.slice(f,x);if(C){for(let s=0,g=y.length;s<g;s+=1){const m=y.charCodeAt(s);if(!(m===9||m>=32&&m<=1114111)){M(o,"expected valid JSON character")}}}else if(R.test(y)){M(o,"the stream contains non-printable characters")}o.result+=y}}function ye(o){o.totalMergeKeys++;if(o.maxTotalMergeKeys!==-1&&o.totalMergeKeys>o.maxTotalMergeKeys){M(o,"merge keys exceeded maxTotalMergeKeys ("+o.maxTotalMergeKeys+")")}}function en(o,f,x,C){if(!e.isObject(x)){M(o,"cannot merge mappings; the provided source object is unacceptable")}ye(o);const y=Object.keys(x);for(let s=0,g=y.length;s<g;s+=1){const m=y[s];ye(o);if(!r.call(f,m)){j(f,m,x[m]);C[m]=true}}}function ae(o,f,x,C,y,s,g,m,A){if(Array.isArray(y)){y=Array.prototype.slice.call(y);for(let S=0,_=y.length;S<_;S+=1){if(Array.isArray(y[S])){M(o,"nested arrays are not supported inside keys")}if(typeof y==="object"&&L(y[S])==="[object Object]"){y[S]="[object Object]"}}}if(typeof y==="object"&&L(y)==="[object Object]"){y="[object Object]"}y=String(y);if(f===null){f={}}if(C==="tag:yaml.org,2002:merge"){if(Array.isArray(s)){if(s.length>100){M(o,"abnormal merge sequence size")}for(let S=0,_=s.length;S<_;S+=1){en(o,f,s[S],x)}}else{en(o,f,s,x)}}else{if(!o.json&&!r.call(x,y)&&r.call(f,y)){o.line=g||o.line;o.lineStart=m||o.lineStart;o.position=A||o.position;M(o,"duplicated mapping key")}j(f,y,s);delete x[y]}return f}function nn(o){const f=o.input.charCodeAt(o.position);if(f===10){o.position++}else if(f===13){o.position++;if(o.input.charCodeAt(o.position)===10){o.position++}}else{M(o,"a line break is expected")}o.line+=1;o.lineStart=o.position;o.firstTabInLine=-1}function F(o,f,x){let C=0;let y=o.input.charCodeAt(o.position);while(y!==0){while($(y)){if(y===9&&o.firstTabInLine===-1){o.firstTabInLine=o.position}y=o.input.charCodeAt(++o.position)}if(f&&y===35){do{y=o.input.charCodeAt(++o.position)}while(y!==10&&y!==13&&y!==0)}if(B(y)){nn(o);y=o.input.charCodeAt(o.position);C++;o.lineIndent=0;while(y===32){o.lineIndent++;y=o.input.charCodeAt(++o.position)}}else{break}}if(x!==-1&&C!==0&&o.lineIndent<x){De(o,"deficient indentation")}return C}function oe(o){let f=o.position;let x=o.input.charCodeAt(f);if((x===45||x===46)&&x===o.input.charCodeAt(f+1)&&x===o.input.charCodeAt(f+2)){f+=3;x=o.input.charCodeAt(f);if(x===0||Y(x)){return true}}return false}function Be(o,f){if(f===1){o.result+=" "}else if(f>1){o.result+=e.repeat("\n",f-1)}}function Rn(o,f,x){let C;let y;let s;let g;let m;let A;const S=o.kind;const _=o.result;let b=o.input.charCodeAt(o.position);if(Y(b)||ne(b)||b===35||b===38||b===42||b===33||b===124||b===62||b===39||b===34||b===37||b===64||b===96){return false}if(b===63||b===45){const v=o.input.charCodeAt(o.position+1);if(Y(v)||x&&ne(v)){return false}}o.kind="scalar";o.result="";C=y=o.position;s=false;while(b!==0){if(b===58){const v=o.input.charCodeAt(o.position+1);if(Y(v)||x&&ne(v)){break}}else if(b===35){const v=o.input.charCodeAt(o.position-1);if(Y(v)){break}}else if(o.position===o.lineStart&&oe(o)||x&&ne(b)){break}else if(B(b)){g=o.line;m=o.lineStart;A=o.lineIndent;F(o,false,-1);if(o.lineIndent>=f){s=true;b=o.input.charCodeAt(o.position);continue}else{o.position=y;o.line=g;o.lineStart=m;o.lineIndent=A;break}}if(s){J(o,C,y,false);Be(o,o.line-g);C=y=o.position;s=false}if(!$(b)){y=o.position+1}b=o.input.charCodeAt(++o.position)}J(o,C,y,false);if(o.result){return true}o.kind=S;o.result=_;return false}function on(o,f){let x;let C;let y=o.input.charCodeAt(o.position);if(y!==39){return false}o.kind="scalar";o.result="";o.position++;x=C=o.position;while((y=o.input.charCodeAt(o.position))!==0){if(y===39){J(o,x,o.position,true);y=o.input.charCodeAt(++o.position);if(y===39){x=o.position;o.position++;C=o.position}else{return true}}else if(B(y)){J(o,x,C,true);Be(o,F(o,false,f));x=C=o.position}else if(o.position===o.lineStart&&oe(o)){M(o,"unexpected end of the document within a single quoted scalar")}else{o.position++;if(!$(y)){C=o.position}}}M(o,"unexpected end of the stream within a single quoted scalar")}function En(o,f){let x;let C;let y;let s=o.input.charCodeAt(o.position);if(s!==34){return false}o.kind="scalar";o.result="";o.position++;x=C=o.position;while((s=o.input.charCodeAt(o.position))!==0){if(s===34){J(o,x,o.position,true);o.position++;return true}else if(s===92){J(o,x,o.position,true);s=o.input.charCodeAt(++o.position);if(B(s)){F(o,false,f)}else if(s<256&&Sn[s]){o.result+=Qe[s];o.position++}else if((y=me(s))>0){let g=y;let m=0;for(;g>0;g--){s=o.input.charCodeAt(++o.position);if((y=Je(s))>=0){m=(m<<4)+y}else{M(o,"expected hexadecimal character")}}o.result+=Me(m);o.position++}else{M(o,"unknown escape sequence")}x=C=o.position}else if(B(s)){J(o,x,C,true);Be(o,F(o,false,f));x=C=o.position}else if(o.position===o.lineStart&&oe(o)){M(o,"unexpected end of the document within a double quoted scalar")}else{o.position++;if(!$(s)){C=o.position}}}M(o,"unexpected end of the stream within a double quoted scalar")}function Mn(o,f){let x=true;let C;let y;let s;const g=o.tag;let m;const A=o.anchor;let S;let _;let b;let v;const E=Object.create(null);let w;let T;let O;let P=o.input.charCodeAt(o.position);if(P===91){S=93;v=false;m=[]}else if(P===123){S=125;v=true;m={}}else{return false}if(o.anchor!==null){le(o,o.anchor,m)}P=o.input.charCodeAt(++o.position);while(P!==0){F(o,true,f);P=o.input.charCodeAt(o.position);if(P===S){o.position++;o.tag=g;o.anchor=A;o.kind=v?"mapping":"sequence";o.result=m;return true}else if(!x){M(o,"missed comma between flow collection entries")}else if(P===44){M(o,"expected the node content, but found ','")}T=w=O=null;_=b=false;if(P===63){const xe=o.input.charCodeAt(o.position+1);if(Y(xe)){_=b=true;o.position++;F(o,true,f)}}C=o.line;y=o.lineStart;s=o.position;he(o,f,l,false,true);T=o.tag;w=o.result;F(o,true,f);P=o.input.charCodeAt(o.position);if((b||o.line===C)&&P===58){_=true;P=o.input.charCodeAt(++o.position);F(o,true,f);he(o,f,l,false,true);O=o.result}if(v){ae(o,m,E,T,w,O,C,y,s)}else if(_){m.push(ae(o,null,E,T,w,O,C,y,s))}else{m.push(w)}F(o,true,f);P=o.input.charCodeAt(o.position);if(P===44){x=true;P=o.input.charCodeAt(++o.position)}else{x=false}}M(o,"unexpected end of the stream within a flow collection")}function be(o,f){let x;let C=u;let y=false;let s=false;let g=f;let m=0;let A=false;let S;let _=o.input.charCodeAt(o.position);if(_===124){x=false}else if(_===62){x=true}else{return false}o.kind="scalar";o.result="";while(_!==0){_=o.input.charCodeAt(++o.position);if(_===43||_===45){if(u===C){C=_===43?h:d}else{M(o,"repeat of a chomping mode identifier")}}else if((S=Ee(_))>=0){if(S===0){M(o,"bad explicit indentation width of a block scalar; it cannot be less than one")}else if(!s){g=f+S-1;s=true}else{M(o,"repeat of an indentation width identifier")}}else{break}}if($(_)){do{_=o.input.charCodeAt(++o.position)}while($(_));if(_===35){do{_=o.input.charCodeAt(++o.position)}while(!B(_)&&_!==0)}}while(_!==0){nn(o);o.lineIndent=0;_=o.input.charCodeAt(o.position);while((!s||o.lineIndent<g)&&_===32){o.lineIndent++;_=o.input.charCodeAt(++o.position)}if(!s&&o.lineIndent>g){g=o.lineIndent}if(B(_)){m++;continue}if(!s&&g===0){M(o,"missing indentation for block scalar")}if(o.lineIndent<g){if(C===h){o.result+=e.repeat("\n",y?1+m:m)}else if(C===u){if(y){o.result+="\n"}}break}if(x){if($(_)){A=true;o.result+=e.repeat("\n",y?1+m:m)}else if(A){A=false;o.result+=e.repeat("\n",m+1)}else if(m===0){if(y){o.result+=" "}}else{o.result+=e.repeat("\n",m)}}else{o.result+=e.repeat("\n",y?1+m:m)}y=true;s=true;m=0;const b=o.position;while(!B(_)&&_!==0){_=o.input.charCodeAt(++o.position)}J(o,b,o.position,false)}return true}function kn(o,f){const x=o.tag;const C=o.anchor;const y=[];let s=false;if(o.firstTabInLine!==-1)return false;if(o.anchor!==null){le(o,o.anchor,y)}let g=o.input.charCodeAt(o.position);while(g!==0){if(o.firstTabInLine!==-1){o.position=o.firstTabInLine;M(o,"tab characters must not be used in indentation")}if(g!==45){break}const m=o.input.charCodeAt(o.position+1);if(!Y(m)){break}s=true;o.position++;if(F(o,true,-1)){if(o.lineIndent<=f){y.push(null);g=o.input.charCodeAt(o.position);continue}}const A=o.line;he(o,f,c,false,true);y.push(o.result);F(o,true,-1);g=o.input.charCodeAt(o.position);if((o.line===A||o.lineIndent>f)&&g!==0){M(o,"bad indentation of a sequence entry")}else if(o.lineIndent<f){break}}if(s){o.tag=x;o.anchor=C;o.kind="sequence";o.result=y;return true}return false}function wn(o,f,x){let C;let y;let s;let g;const m=o.tag;const A=o.anchor;const S={};const _=Object.create(null);let b=null;let v=null;let E=null;let w=false;let T=false;if(o.firstTabInLine!==-1)return false;if(o.anchor!==null){le(o,o.anchor,S)}let O=o.input.charCodeAt(o.position);while(O!==0){if(!w&&o.firstTabInLine!==-1){o.position=o.firstTabInLine;M(o,"tab characters must not be used in indentation")}const P=o.input.charCodeAt(o.position+1);const xe=o.line;if((O===63||O===58)&&Y(P)){if(O===63){if(w){ae(o,S,_,b,v,null,y,s,g);b=v=E=null}T=true;w=true;C=true}else if(w){w=false;C=true}else{M(o,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line")}o.position+=1;O=P}else{y=o.line;s=o.lineStart;g=o.position;if(!he(o,x,a,false,true)){break}if(o.line===xe){O=o.input.charCodeAt(o.position);while($(O)){O=o.input.charCodeAt(++o.position)}if(O===58){O=o.input.charCodeAt(++o.position);if(!Y(O)){M(o,"a whitespace character is expected after the key-value separator within a block mapping")}if(w){ae(o,S,_,b,v,null,y,s,g);b=v=E=null}T=true;w=false;C=false;b=o.tag;v=o.result}else if(T){M(o,"can not read an implicit mapping pair; a colon is missed")}else{o.tag=m;o.anchor=A;return true}}else if(T){M(o,"can not read a block mapping entry; a multiline key may not be an implicit key")}else{o.tag=m;o.anchor=A;return true}}if(o.line===xe||o.lineIndent>f){if(w){y=o.line;s=o.lineStart;g=o.position}if(he(o,f,p,true,C)){if(w){v=o.result}else{E=o.result}}if(!w){ae(o,S,_,b,v,E,y,s,g);b=v=E=null}F(o,true,-1);O=o.input.charCodeAt(o.position)}if((o.line===xe||o.lineIndent>f)&&O!==0){M(o,"bad indentation of a mapping entry")}else if(o.lineIndent<f){break}}if(w){ae(o,S,_,b,v,null,y,s,g)}if(T){o.tag=m;o.anchor=A;o.kind="mapping";o.result=S}return T}function Tn(o){let f=false;let x=false;let C;let y;let s=o.input.charCodeAt(o.position);if(s!==33)return false;if(o.tag!==null){M(o,"duplication of a tag property")}s=o.input.charCodeAt(++o.position);if(s===60){f=true;s=o.input.charCodeAt(++o.position)}else if(s===33){x=true;C="!!";s=o.input.charCodeAt(++o.position)}else{C="!"}let g=o.position;if(f){do{s=o.input.charCodeAt(++o.position)}while(s!==0&&s!==62);if(o.position<o.length){y=o.input.slice(g,o.position);s=o.input.charCodeAt(++o.position)}else{M(o,"unexpected end of the stream within a verbatim tag")}}else{while(s!==0&&!Y(s)){if(s===33){if(!x){C=o.input.slice(g-1,o.position+1);if(!I.test(C)){M(o,"named tag handle cannot contain such characters")}x=true;g=o.position+1}else{M(o,"tag suffix cannot contain exclamation marks")}}s=o.input.charCodeAt(++o.position)}y=o.input.slice(g,o.position);if(D.test(y)){M(o,"tag suffix cannot contain flow indicator characters")}}if(y&&!U.test(y)){M(o,"tag name cannot contain such characters: "+y)}try{y=decodeURIComponent(y)}catch(m){M(o,"tag name is malformed: "+y)}if(f){o.tag=y}else if(r.call(o.tagMap,C)){o.tag=o.tagMap[C]+y}else if(C==="!"){o.tag="!"+y}else if(C==="!!"){o.tag="tag:yaml.org,2002:"+y}else{M(o,'undeclared tag handle "'+C+'"')}return true}function In(o){let f=o.input.charCodeAt(o.position);if(f!==38)return false;if(o.anchor!==null){M(o,"duplication of an anchor property")}f=o.input.charCodeAt(++o.position);const x=o.position;while(f!==0&&!Y(f)&&!ne(f)){f=o.input.charCodeAt(++o.position)}if(o.position===x){M(o,"name of an anchor node must contain at least one character")}o.anchor=o.input.slice(x,o.position);return true}function ao(o){let f=o.input.charCodeAt(o.position);if(f!==42)return false;f=o.input.charCodeAt(++o.position);const x=o.position;while(f!==0&&!Y(f)&&!ne(f)){f=o.input.charCodeAt(++o.position)}if(o.position===x){M(o,"name of an alias node must contain at least one character")}const C=o.input.slice(x,o.position);if(!r.call(o.anchorMap,C)){M(o,'unidentified alias "'+C+'"')}o.result=o.anchorMap[C];F(o,true,-1);return true}function On(o,f,x,C){const y=Ze(o);so(o);Ne(o,f);o.tag=null;o.anchor=null;o.kind=null;o.result=null;if(wn(o,x,C)&&o.kind==="mapping"){ke(o);return true}lo(o);Ne(o,y);return false}function he(o,f,x,C,y){let s;let g;let m=1;let A=false;let S=false;let _=null;let b;let v;let E;if(o.depth>=o.maxDepth){M(o,"nesting exceeded maxDepth ("+o.maxDepth+")")}o.depth+=1;if(o.listener!==null){o.listener("open",o)}o.tag=null;o.anchor=null;o.kind=null;o.result=null;const w=s=g=p===x||c===x;if(C){if(F(o,true,-1)){A=true;if(o.lineIndent>f){m=1}else if(o.lineIndent===f){m=0}else if(o.lineIndent<f){m=-1}}}if(m===1){while(true){const T=o.input.charCodeAt(o.position);const O=Ze(o);if(A&&(T===33&&o.tag!==null||T===38&&o.anchor!==null)){break}if(!Tn(o)&&!In(o)){break}if(_===null){_=O}if(F(o,true,-1)){A=true;g=w;if(o.lineIndent>f){m=1}else if(o.lineIndent===f){m=0}else if(o.lineIndent<f){m=-1}}else{g=false}}}if(g){g=A||y}if(m===1||p===x){if(l===x||a===x){v=f}else{v=f+1}E=o.position-o.lineStart;if(m===1){if(g&&(kn(o,E)||wn(o,E,v))||Mn(o,v)){S=true}else{const T=o.input.charCodeAt(o.position);if(_!==null&&w&&!g&&T!==124&&T!==62&&On(o,_,_.position-_.lineStart,v)){S=true}else if(s&&be(o,v)||on(o,v)||En(o,v)){S=true}else if(ao(o)){S=true;if(o.tag!==null||o.anchor!==null){M(o,"alias node should not have any properties")}}else if(Rn(o,v,l===x)){S=true;if(o.tag===null){o.tag="?"}}if(o.anchor!==null){le(o,o.anchor,o.result)}}}else if(m===0){S=g&&kn(o,E)}}if(o.tag===null){if(o.anchor!==null){le(o,o.anchor,o.result)}}else if(o.tag==="?"){if(o.result!==null&&o.kind!=="scalar"){M(o,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+o.kind+'"')}for(let T=0,O=o.implicitTypes.length;T<O;T+=1){b=o.implicitTypes[T];if(b.resolve(o.result)){o.result=b.construct(o.result);o.tag=b.tag;if(o.anchor!==null){le(o,o.anchor,o.result)}break}}}else if(o.tag!=="!"){if(r.call(o.typeMap[o.kind||"fallback"],o.tag)){b=o.typeMap[o.kind||"fallback"][o.tag]}else{b=null;const T=o.typeMap.multi[o.kind||"fallback"];for(let O=0,P=T.length;O<P;O+=1){if(o.tag.slice(0,T[O].tag.length)===T[O].tag){b=T[O];break}}}if(!b){M(o,"unknown tag !<"+o.tag+">")}if(o.result!==null&&b.kind!==o.kind){M(o,"unacceptable node kind for !<"+o.tag+'> tag; it should be "'+b.kind+'", not "'+o.kind+'"')}if(!b.resolve(o.result,o.tag)){M(o,"cannot resolve a node with !<"+o.tag+"> explicit tag")}else{o.result=b.construct(o.result,o.tag);if(o.anchor!==null){le(o,o.anchor,o.result)}}}if(o.listener!==null){o.listener("close",o)}o.depth-=1;return o.tag!==null||o.anchor!==null||S}function uo(o){const f=o.position;let x=false;let C;o.version=null;o.checkLineBreaks=o.legacy;o.tagMap=Object.create(null);o.anchorMap=Object.create(null);while((C=o.input.charCodeAt(o.position))!==0){F(o,true,-1);C=o.input.charCodeAt(o.position);if(o.lineIndent>0||C!==37){break}x=true;C=o.input.charCodeAt(++o.position);let y=o.position;while(C!==0&&!Y(C)){C=o.input.charCodeAt(++o.position)}const s=o.input.slice(y,o.position);const g=[];if(s.length<1){M(o,"directive name must not be less than one character in length")}while(C!==0){while($(C)){C=o.input.charCodeAt(++o.position)}if(C===35){do{C=o.input.charCodeAt(++o.position)}while(C!==0&&!B(C));break}if(B(C))break;y=o.position;while(C!==0&&!Y(C)){C=o.input.charCodeAt(++o.position)}g.push(o.input.slice(y,o.position))}if(C!==0)nn(o);if(r.call(vn,s)){vn[s](o,s,g)}else{De(o,'unknown document directive "'+s+'"')}}F(o,true,-1);if(o.lineIndent===0&&o.input.charCodeAt(o.position)===45&&o.input.charCodeAt(o.position+1)===45&&o.input.charCodeAt(o.position+2)===45){o.position+=3;F(o,true,-1)}else if(x){M(o,"directives end mark is expected")}he(o,o.lineIndent-1,p,false,true);F(o,true,-1);if(o.checkLineBreaks&&k.test(o.input.slice(f,o.position))){De(o,"non-ASCII line breaks are interpreted as content")}o.documents.push(o.result);if(o.position===o.lineStart&&oe(o)){if(o.input.charCodeAt(o.position)===46){o.position+=3;F(o,true,-1)}return}if(o.position<o.length-1){M(o,"end of the stream or a document separator is expected")}}function tn(o,f){o=String(o);f=f||{};if(o.length!==0){if(o.charCodeAt(o.length-1)!==10&&o.charCodeAt(o.length-1)!==13){o+="\n"}if(o.charCodeAt(0)===65279){o=o.slice(1)}}const x=new W(o,f);const C=o.indexOf("\0");if(C!==-1){x.position=C;M(x,"null byte is not allowed in input")}x.input+="\0";while(x.input.charCodeAt(x.position)===32){x.lineIndent+=1;x.position+=1}while(x.position<x.length-1){uo(x)}return x.documents}function co(o,f,x){if(f!==null&&typeof f==="object"&&typeof x==="undefined"){x=f;f=null}const C=tn(o,x);if(typeof f!=="function"){return C}for(let y=0,s=C.length;y<s;y+=1){f(C[y])}}function fo(o,f){const x=tn(o,f);if(x.length===0){return void 0}else if(x.length===1){return x[0]}throw new n("expected a single document in the stream, but found more")}Ln.loadAll=co;Ln.load=fo;return Ln}var Fo={};var dt;function As(){if(dt)return Fo;dt=1;const e=an();const n=un();const i=Uo();const t=Object.prototype.toString;const r=Object.prototype.hasOwnProperty;const l=65279;const a=9;const c=10;const p=13;const u=32;const d=33;const h=34;const R=35;const k=37;const D=38;const I=39;const U=42;const L=44;const B=45;const $=58;const Y=61;const ne=62;const Je=63;const me=64;const Ee=91;const se=93;const Me=96;const j=123;const Sn=124;const Qe=125;const W={};W[0]="\\0";W[7]="\\a";W[8]="\\b";W[9]="\\t";W[10]="\\n";W[11]="\\v";W[12]="\\f";W[13]="\\r";W[27]="\\e";W[34]='\\"';W[92]="\\\\";W[133]="\\N";W[160]="\\_";W[8232]="\\L";W[8233]="\\P";const _n=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];const M=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function De(s,g){if(g===null)return{};const m={};const A=Object.keys(g);for(let S=0,_=A.length;S<_;S+=1){let b=A[S];let v=String(g[b]);if(b.slice(0,2)==="!!"){b="tag:yaml.org,2002:"+b.slice(2)}const E=s.compiledTypeMap["fallback"][b];if(E&&r.call(E.styleAliases,v)){v=E.styleAliases[v]}m[b]=v}return m}function le(s){let g;let m;const A=s.toString(16).toUpperCase();if(s<=255){g="x";m=2}else if(s<=65535){g="u";m=4}else if(s<=4294967295){g="U";m=8}else{throw new n("code point within a string may not be greater than 0xFFFFFFFF")}return"\\"+g+e.repeat("0",m-A.length)+A}const so=1;const ke=2;function lo(s){this.schema=s["schema"]||i;this.indent=Math.max(1,s["indent"]||2);this.noArrayIndent=s["noArrayIndent"]||false;this.skipInvalid=s["skipInvalid"]||false;this.flowLevel=e.isNothing(s["flowLevel"])?-1:s["flowLevel"];this.styleMap=De(this.schema,s["styles"]||null);this.sortKeys=s["sortKeys"]||false;this.lineWidth=s["lineWidth"]||80;this.noRefs=s["noRefs"]||false;this.noCompatMode=s["noCompatMode"]||false;this.condenseFlow=s["condenseFlow"]||false;this.quotingType=s["quotingType"]==='"'?ke:so;this.forceQuotes=s["forceQuotes"]||false;this.replacer=typeof s["replacer"]==="function"?s["replacer"]:null;this.implicitTypes=this.schema.compiledImplicit;this.explicitTypes=this.schema.compiledExplicit;this.tag=null;this.result="";this.duplicates=[];this.usedDuplicates=null}function Ze(s,g){const m=e.repeat(" ",g);let A=0;let S="";const _=s.length;while(A<_){let b;const v=s.indexOf("\n",A);if(v===-1){b=s.slice(A);A=_}else{b=s.slice(A,v+1);A=v+1}if(b.length&&b!=="\n")S+=m;S+=b}return S}function Ne(s,g){return"\n"+e.repeat(" ",s.indent*g)}function vn(s,g){for(let m=0,A=s.implicitTypes.length;m<A;m+=1){const S=s.implicitTypes[m];if(S.resolve(g)){return true}}return false}function J(s){return s===u||s===a}function ye(s){return s>=32&&s<=126||s>=161&&s<=55295&&s!==8232&&s!==8233||s>=57344&&s<=65533&&s!==l||s>=65536&&s<=1114111}function en(s){return ye(s)&&s!==l&&s!==p&&s!==c}function ae(s,g,m){const A=en(s);const S=A&&!J(s);return(m?A:A&&s!==L&&s!==Ee&&s!==se&&s!==j&&s!==Qe)&&s!==R&&!(g===$&&!S)||en(g)&&!J(g)&&s===R||g===$&&S}function nn(s){return ye(s)&&s!==l&&!J(s)&&s!==B&&s!==Je&&s!==$&&s!==L&&s!==Ee&&s!==se&&s!==j&&s!==Qe&&s!==R&&s!==D&&s!==U&&s!==d&&s!==Sn&&s!==Y&&s!==ne&&s!==I&&s!==h&&s!==k&&s!==me&&s!==Me}function F(s){return!J(s)&&s!==$}function oe(s,g){const m=s.charCodeAt(g);let A;if(m>=55296&&m<=56319&&g+1<s.length){A=s.charCodeAt(g+1);if(A>=56320&&A<=57343){return(m-55296)*1024+A-56320+65536}}return m}function Be(s){const g=/^\n* /;return g.test(s)}const Rn=1;const on=2;const En=3;const Mn=4;const be=5;function kn(s,g,m,A,S,_,b,v){let E;let w=0;let T=null;let O=false;let P=false;const xe=A!==-1;let rn=-1;let sn=nn(oe(s,0))&&F(oe(s,s.length-1));if(g||b){for(E=0;E<s.length;w>=65536?E+=2:E++){w=oe(s,E);if(!ye(w)){return be}sn=sn&&ae(w,T,v);T=w}}else{for(E=0;E<s.length;w>=65536?E+=2:E++){w=oe(s,E);if(w===c){O=true;if(xe){P=P||E-rn-1>A&&s[rn+1]!==" ";rn=E}}else if(!ye(w)){return be}sn=sn&&ae(w,T,v);T=w}P=P||xe&&(E-rn-1>A&&s[rn+1]!==" ")}if(!O&&!P){if(sn&&!b&&!S(s)){return Rn}return _===ke?be:on}if(m>9&&Be(s)){return be}if(!b){return P?Mn:En}return _===ke?be:on}function wn(s,g,m,A,S){s.dump=(function(){if(g.length===0){return s.quotingType===ke?'""':"''"}if(!s.noCompatMode){if(_n.indexOf(g)!==-1||M.test(g)){return s.quotingType===ke?'"'+g+'"':"'"+g+"'"}}const _=s.indent*Math.max(1,m);const b=s.lineWidth===-1?-1:Math.max(Math.min(s.lineWidth,40),s.lineWidth-_);const v=A||s.flowLevel>-1&&m>=s.flowLevel;function E(w){return vn(s,w)}switch(kn(g,v,s.indent,b,E,s.quotingType,s.forceQuotes&&!A,S)){case Rn:return g;case on:return"'"+g.replace(/'/g,"''")+"'";case En:return"|"+Tn(g,s.indent)+In(Ze(g,_));case Mn:return">"+Tn(g,s.indent)+In(Ze(ao(g,b),_));case be:return'"'+he(g)+'"';default:throw new n("impossible error: invalid scalar style")}})()}function Tn(s,g){const m=Be(s)?String(g):"";const A=s[s.length-1]==="\n";const S=A&&(s[s.length-2]==="\n"||s==="\n");const _=S?"+":A?"":"-";return m+_+"\n"}function In(s){return s[s.length-1]==="\n"?s.slice(0,-1):s}function ao(s,g){const m=/(\n+)([^\n]*)/g;let A=(function(){let v=s.indexOf("\n");v=v!==-1?v:s.length;m.lastIndex=v;return On(s.slice(0,v),g)})();let S=s[0]==="\n"||s[0]===" ";let _;let b;while(b=m.exec(s)){const v=b[1];const E=b[2];_=E[0]===" ";A+=v+(!S&&!_&&E!==""?"\n":"")+On(E,g);S=_}return A}function On(s,g){if(s===""||s[0]===" ")return s;const m=/ [^ ]/g;let A;let S=0;let _;let b=0;let v=0;let E="";while(A=m.exec(s)){v=A.index;if(v-S>g){_=b>S?b:v;E+="\n"+s.slice(S,_);S=_+1}b=v}E+="\n";if(s.length-S>g&&b>S){E+=s.slice(S,b)+"\n"+s.slice(b+1)}else{E+=s.slice(S)}return E.slice(1)}function he(s){let g="";let m=0;for(let A=0;A<s.length;m>=65536?A+=2:A++){m=oe(s,A);const S=W[m];if(!S&&ye(m)){g+=s[A];if(m>=65536)g+=s[A+1]}else{g+=S||le(m)}}return g}function uo(s,g,m){let A="";const S=s.tag;for(let _=0,b=m.length;_<b;_+=1){let v=m[_];if(s.replacer){v=s.replacer.call(m,String(_),v)}if(f(s,g,v,false,false)||typeof v==="undefined"&&f(s,g,null,false,false)){if(A!=="")A+=","+(!s.condenseFlow?" ":"");A+=s.dump}}s.tag=S;s.dump="["+A+"]"}function tn(s,g,m,A){let S="";const _=s.tag;for(let b=0,v=m.length;b<v;b+=1){let E=m[b];if(s.replacer){E=s.replacer.call(m,String(b),E)}if(f(s,g+1,E,true,true,false,true)||typeof E==="undefined"&&f(s,g+1,null,true,true,false,true)){if(!A||S!==""){S+=Ne(s,g)}if(s.dump&&c===s.dump.charCodeAt(0)){S+="-"}else{S+="- "}S+=s.dump}}s.tag=_;s.dump=S||"[]"}function co(s,g,m){let A="";const S=s.tag;const _=Object.keys(m);for(let b=0,v=_.length;b<v;b+=1){let E="";if(A!=="")E+=", ";if(s.condenseFlow)E+='"';const w=_[b];let T=m[w];if(s.replacer){T=s.replacer.call(m,w,T)}if(!f(s,g,w,false,false)){continue}if(s.dump.length>1024)E+="? ";E+=s.dump+(s.condenseFlow?'"':"")+":"+(s.condenseFlow?"":" ");if(!f(s,g,T,false,false)){continue}E+=s.dump;A+=E}s.tag=S;s.dump="{"+A+"}"}function fo(s,g,m,A){let S="";const _=s.tag;const b=Object.keys(m);if(s.sortKeys===true){b.sort()}else if(typeof s.sortKeys==="function"){b.sort(s.sortKeys)}else if(s.sortKeys){throw new n("sortKeys must be a boolean or a function")}for(let v=0,E=b.length;v<E;v+=1){let w="";if(!A||S!==""){w+=Ne(s,g)}const T=b[v];let O=m[T];if(s.replacer){O=s.replacer.call(m,T,O)}if(!f(s,g+1,T,true,true,true)){continue}const P=s.tag!==null&&s.tag!=="?"||s.dump&&s.dump.length>1024;if(P){if(s.dump&&c===s.dump.charCodeAt(0)){w+="?"}else{w+="? "}}w+=s.dump;if(P){w+=Ne(s,g)}if(!f(s,g+1,O,true,P)){continue}if(s.dump&&c===s.dump.charCodeAt(0)){w+=":"}else{w+=": "}w+=s.dump;S+=w}s.tag=_;s.dump=S||"{}"}function o(s,g,m){const A=m?s.explicitTypes:s.implicitTypes;for(let S=0,_=A.length;S<_;S+=1){const b=A[S];if((b.instanceOf||b.predicate)&&(!b.instanceOf||typeof g==="object"&&g instanceof b.instanceOf)&&(!b.predicate||b.predicate(g))){if(m){if(b.multi&&b.representName){s.tag=b.representName(g)}else{s.tag=b.tag}}else{s.tag="?"}if(b.represent){const v=s.styleMap[b.tag]||b.defaultStyle;let E;if(t.call(b.represent)==="[object Function]"){E=b.represent(g,v)}else if(r.call(b.represent,v)){E=b.represent[v](g,v)}else{throw new n("!<"+b.tag+'> tag resolver accepts not "'+v+'" style')}s.dump=E}return true}}return false}function f(s,g,m,A,S,_,b){s.tag=null;s.dump=m;if(!o(s,m,false)){o(s,m,true)}const v=t.call(s.dump);const E=A;if(A){A=s.flowLevel<0||s.flowLevel>g}const w=v==="[object Object]"||v==="[object Array]";let T;let O;if(w){T=s.duplicates.indexOf(m);O=T!==-1}if(s.tag!==null&&s.tag!=="?"||O||s.indent!==2&&g>0){S=false}if(O&&s.usedDuplicates[T]){s.dump="*ref_"+T}else{if(w&&O&&!s.usedDuplicates[T]){s.usedDuplicates[T]=true}if(v==="[object Object]"){if(A&&Object.keys(s.dump).length!==0){fo(s,g,s.dump,S);if(O){s.dump="&ref_"+T+s.dump}}else{co(s,g,s.dump);if(O){s.dump="&ref_"+T+" "+s.dump}}}else if(v==="[object Array]"){if(A&&s.dump.length!==0){if(s.noArrayIndent&&!b&&g>0){tn(s,g-1,s.dump,S)}else{tn(s,g,s.dump,S)}if(O){s.dump="&ref_"+T+s.dump}}else{uo(s,g,s.dump);if(O){s.dump="&ref_"+T+" "+s.dump}}}else if(v==="[object String]"){if(s.tag!=="?"){wn(s,s.dump,g,_,E)}}else if(v==="[object Undefined]"){return false}else{if(s.skipInvalid)return false;throw new n("unacceptable kind of an object to dump "+v)}if(s.tag!==null&&s.tag!=="?"){let P=encodeURI(s.tag[0]==="!"?s.tag.slice(1):s.tag).replace(/!/g,"%21");if(s.tag[0]==="!"){P="!"+P}else if(P.slice(0,18)==="tag:yaml.org,2002:"){P="!!"+P.slice(18)}else{P="!<"+P+">"}s.dump=P+" "+s.dump}}return true}function x(s,g){const m=[];const A=[];C(s,m,A);const S=A.length;for(let _=0;_<S;_+=1){g.duplicates.push(m[A[_]])}g.usedDuplicates=new Array(S)}function C(s,g,m){if(s!==null&&typeof s==="object"){const A=g.indexOf(s);if(A!==-1){if(m.indexOf(A)===-1){m.push(A)}}else{g.push(s);if(Array.isArray(s)){for(let S=0,_=s.length;S<_;S+=1){C(s[S],g,m)}}else{const S=Object.keys(s);for(let _=0,b=S.length;_<b;_+=1){C(s[S[_]],g,m)}}}}}function y(s,g){g=g||{};const m=new lo(g);if(!m.noRefs)x(s,m);let A=s;if(m.replacer){A=m.replacer.call({"":A},"",A)}if(f(m,0,A,true,true))return m.dump+"\n";return""}Fo.dump=y;return Fo}var ft;function Ss(){if(ft)return q;ft=1;const e=Cs();const n=As();function i(t,r){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+r+" instead, which is now safe by default.")}}q.Type=X();q.Schema=pt();q.FAILSAFE_SCHEMA=bt();q.JSON_SCHEMA=St();q.CORE_SCHEMA=_t();q.DEFAULT_SCHEMA=Uo();q.load=e.load;q.loadAll=e.loadAll;q.dump=n.dump;q.YAMLException=un();q.types={binary:Et(),float:At(),map:yt(),null:ht(),pairs:kt(),set:wt(),timestamp:vt(),bool:xt(),int:Ct(),merge:Rt(),omap:Mt(),seq:mt(),str:gt()};q.safeLoad=i("safeLoad","load");q.safeLoadAll=i("safeLoadAll","loadAll");q.safeDump=i("safeDump","dump");return q}var _s=Ss();var V=hs(_s);var{Type:Su,Schema:_u,FAILSAFE_SCHEMA:vu,JSON_SCHEMA:Ru,CORE_SCHEMA:Eu,DEFAULT_SCHEMA:Mu,load:ku,loadAll:wu,dump:Tu,YAMLException:Iu,types:Ou,safeLoad:Pu,safeLoadAll:Lu,safeDump:Du}=V;function Tt(e){const n=e.tui;if(n==null||typeof n!=="object"||Array.isArray(n))return{};const i=n;const t=i.notifications;let r;if(t&&typeof t==="object"&&!Array.isArray(t)){const{when:p,method:u,events:d}=t;r={...p==="unfocused"||p==="always"||p==="never"?{when:p}:{},...u==="auto"||u==="osc9"||u==="osc777"||u==="bel"?{method:u}:{},...Array.isArray(d)?{events:d.filter(h=>typeof h==="string")}:{}}}const l=i.statusLine;const a=Array.isArray(l)?l.filter(p=>typeof p==="string").map(p=>p.trim()).filter(Boolean):void 0;const c=vs(i.customStatusLine);return{...i.terminalTitle===null?{terminalTitle:null}:Array.isArray(i.terminalTitle)?{terminalTitle:i.terminalTitle.filter(p=>typeof p==="string").map(p=>p.trim()).filter(Boolean)}:{},...typeof i.showTips==="boolean"?{showTips:i.showTips}:{},...typeof i.programStatus==="boolean"?{programStatus:i.programStatus}:{},...r?{notifications:r}:{},...a?{statusLine:a}:{},...c?{customStatusLine:c}:{}}}function vs(e){if(e==null||typeof e!=="object"||Array.isArray(e))return void 0;const n=e;const i=typeof n.command==="string"?n.command.trim():"";if(!i)return void 0;return{command:i,...n.display==="inline"||n.display==="block"?{display:n.display}:{},...n.position==="above"||n.position==="below"?{position:n.position}:{},...n.colorMode==="plain"||n.colorMode==="ansi"?{colorMode:n.colorMode}:{},...typeof n.maxLines==="number"&&Number.isFinite(n.maxLines)?{maxLines:n.maxLines}:{},...typeof n.timeoutMs==="number"&&Number.isFinite(n.timeoutMs)?{timeoutMs:n.timeoutMs}:{},...typeof n.intervalSeconds==="number"&&Number.isFinite(n.intervalSeconds)?{intervalSeconds:n.intervalSeconds}:{}}}import{createHash as Rs,randomUUID as Es}from"node:crypto";import Nn from"node:fs";import Dn from"node:path";function Pt(e){if(e==null||typeof e!=="object"||Array.isArray(e))return void 0;const n=e;const i={};if(typeof n.apiKey==="string")i.apiKey=n.apiKey;if(typeof n.baseURL==="string")i.baseURL=n.baseURL;const t=Vo(n.modelContextLimits);if(t)i.modelContextLimits=t;return Object.keys(i).length>0?i:void 0}function Vo(e){if(!N(e))return void 0;const n=Object.entries(e).filter(i=>i[0].length>0&&Number.isSafeInteger(i[1])&&i[1]>0);return n.length>0?Object.fromEntries(n):void 0}function Lt(e,n){if(!n)return e;return Object.fromEntries(Object.entries(e).map(([i,t])=>{const r=n[i];return[i,r!==void 0&&t.contextWindowOptions?.includes(r)?{...t,limit:{...t.limit,context:r}}:t]}))}function Ko(e){const n=e.provider?.minimax;const i=n?.catalogModels??n?.models??je;return Lt(Object.fromEntries(Object.entries(i).filter(([,t])=>t.enabled!==false)),e.minimax_api?.modelContextLimits)}function Dt(e,n){const i=e.minimax;if(!i?.models)return e;return{...e,minimax:{...i,catalogModels:i.models,models:Lt(i.models,n)}}}function Nt(e){if(e==null||typeof e!=="object"||Array.isArray(e))return void 0;const n=Object.entries(e).filter(([,i])=>i!=null&&typeof i==="object"&&!Array.isArray(i));if(n.length===0)return void 0;return Object.fromEntries(n.map(([i,t])=>[i,Ft(t)]))}function Bt(e){return Object.fromEntries(Object.entries(e).map(([n,i])=>[n,N(i)?Ft(i):i]))}function Ft(e){if(!N(e.models))return e;let n=false;const i=Object.fromEntries(Object.entries(e.models).map(([t,r])=>{if(!N(r)||!N(r.thinking))return[t,r];const l=typeof r.thinking.effort==="string"?r.thinking.effort.trim():"";const a=typeof r.thinking.defaultEffort==="string"?r.thinking.defaultEffort.trim():"";if(!Object.hasOwn(r.thinking,"effort")&&!Object.hasOwn(r.thinking,"defaultEffort")){return[t,r]}const c=[];const p=new Set;if(Array.isArray(r.thinking.effortOptions)){for(const R of r.thinking.effortOptions){if(typeof R!=="string")continue;const k=R.trim();if(!k||p.has(k))continue;p.add(k);c.push(k)}}if(l&&!p.has(l)){p.add(l);c.push(l)}if(a&&!p.has(a)){p.add(a);c.push(a)}const u={...r.thinking};delete u.effort;delete u.effortOptions;delete u.defaultEffort;const d={...u,...c.length>0?{effortOptions:c}:{},...a?{defaultEffort:a}:{}};const h={...r};if(Object.keys(d).length>0)h.thinking=d;else delete h.thinking;n=true;return[t,h]}));return n?{...e,models:i}:e}var Ut="byok_legacy_provider_to_custom_provider_v1";var jt="config.yaml.bak.byok-legacy-provider.";var jo=new Set(["minimax","minimax_api","provider","custom_provider"]);var Ms=/^[A-Za-z0-9 _-]+$/;function Vt(e,n){const i={migrated:false,migratedProviders:{}};if(!n.isManagedRuntime())return i;if(!Nn.existsSync(e))return i;const t=Ts(e);if(!N(t.provider))return i;const r=t.provider;const l=N(t.custom_provider)?t.custom_provider:{};const a=Us(t);const c={};const p={...l};const u=new Set(Object.keys(p));let d=false;const h=n.getManagedPreset().provider;for(const[R,k]of Object.entries(r)){if(!Is(R,k,h)){continue}const D=a.providers[R];if(D&&!jo.has(D)&&!N(p[D])){delete r[R];d=true;continue}const I=D&&!jo.has(D)?D:Ls(R,k,u);c[R]=I;if(!N(p[I])){p[I]=Ps(k);u.add(I);d=true}if(a.providers[R]!==I){a.providers[R]=I;d=true}delete r[R];d=true}if(!d&&Object.keys(c).length===0)return i;d=Ot(t,"defaultModel",c)||d;d=Ot(t,"defaultLightModel",c)||d;d=Bs(t,c)||d;if(!d)return{migrated:false,migratedProviders:c};if(Object.keys(p).length>0)t.custom_provider=p;else delete t.custom_provider;js(t,a);try{const R=Fs(e);ue(e,V.dump(t,{indent:2,lineWidth:-1,noRefs:true}));return{migrated:true,migratedProviders:c,backupPath:R}}catch(R){console.warn(`[config] legacy BYOK provider migration skipped: ${Ks(R)}`);return{migrated:false,migratedProviders:c}}}function Kt(e,n){let i=e.provider;const t=e.defaultModel;if(Object.prototype.hasOwnProperty.call(i,"minimax_api")){const{minimax_api:D,...I}=i;i=I;console.warn('[config] "minimax_api" is a reserved provider id; ignoring provider.minimax_api from config.yaml')}const r=n.getManagedPreset();const l=r.provider.minimax;const a=i.minimax;const c=n.isManagedRuntime();const p=c||ks(a,n);if(!p)return{provider:i,defaultModel:t};const u=a?.options;const d=c&&n.shouldEnforceManagedProviderProtection();const h=ws(l.models,a?.models);const R=typeof u?.baseURL==="string"&&u.baseURL.length>0?u.baseURL:void 0;const k=d&&R!=null&&!n.isManagedPresetBaseUrl(R);i={...i,minimax:{...l,...a??{},npm:a?.npm??l.npm,models:h,options:{...l.options??{},...u??{},...k?{apiKey:l.options?.apiKey}:{},...d?{authMode:"managed-login",baseURL:l.options?.baseURL}:{}}}};return{provider:i,defaultModel:t}}function ks(e,n){const i=e?.options;if(i?.authMode==="managed-login")return true;return typeof i?.baseURL==="string"&&n.isManagedPresetBaseUrl(i.baseURL)}function ws(e,n){return n&&Object.keys(n).length>0?n:e??{}}function Ts(e){try{const n=V.load(Nn.readFileSync(e,"utf-8"));return N(n)?n:{}}catch{return{}}}function Is(e,n,i){if(e==="minimax"||e==="minimax_api")return false;if(!Vs(n))return false;if(!Os(n))return false;return!Object.prototype.hasOwnProperty.call(i,e)}function Os(e){const n=N(e.options)?e.options:void 0;return typeof n?.apiKey==="string"&&n.apiKey.trim().length>0&&typeof n.baseURL==="string"&&n.baseURL.trim().length>0&&N(e.models)}function Ps(e){const n=N(e.options)?e.options:{};return{...e,kind:"custom",enabled:e.enabled!==false,options:{...n,authMode:"api-key"}}}function Ls(e,n,i){const t=N(n)?n:{};const r=typeof t.name==="string"?t.name:void 0;const l=`provider-${Ds(e)}`;const a=It(e)??It(r)??l;for(let c=0;;c+=1){const p=c===0?a:`${a}-${c+1}`;if(!i.has(p)&&!jo.has(p)){return p}}}function It(e){const n=e?.trim();if(!n||!Ms.test(n))return void 0;const i=n.toLowerCase().replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"");return i||void 0}function Ds(e){return Rs("sha256").update(e).digest("hex").slice(0,8)}function Ot(e,n,i){const t=e[n];if(typeof t!=="string")return false;const r=Ns(t,i);if(r===t)return false;e[n]=r;return true}function Ns(e,n){const i=e.indexOf("/");if(i<=0||i===e.length-1)return e;const t=e.slice(0,i);const r=n[t];if(!r)return e;return`custom_provider:${r}/${e.slice(i+1)}`}function Bs(e,n){if(!N(e.nexus)||!N(e.nexus.model))return false;const i=e.nexus.model.providerID;if(typeof i!=="string")return false;const t=n[i];if(!t)return false;e.nexus.model.providerID=`custom_provider:${t}`;return true}function Gt(e){if(process.platform==="win32")return;const n=Dn.dirname(e);let i;try{i=Nn.readdirSync(n,{withFileTypes:true})}catch{console.warn(`[config] Could not inspect legacy BYOK backups in ${JSON.stringify(n)}. Backup permissions were not verified; check directory access and restrict backup permissions manually.`);return}for(const t of i){if(t.isFile()&&t.name.startsWith(jt)){const r=Dn.join(n,t.name);try{Ve(r)}catch{console.warn(`[config] Could not restrict legacy BYOK backup ${JSON.stringify(r)}. It may still be readable by other users; restrict its permissions manually.`)}}}}function Fs(e){const n=Dn.join(Dn.dirname(e),`${jt}${Date.now()}.${Es()}`);Ve(e);ue(n,Nn.readFileSync(e),true);return n}function Us(e){const n=N(e.migrations)?e.migrations:void 0;const i=n?.[Ut];const t=N(i)&&N(i.providers)?Object.fromEntries(Object.entries(i.providers).filter(r=>typeof r[1]==="string")):{};return{providers:t}}function js(e,n){const i=N(e.migrations)?e.migrations:{};i[Ut]={version:1,providers:n.providers};e.migrations=i}function Vs(e){if(!N(e))return false;return typeof e.name==="string"||typeof e.npm==="string"||typeof e.api==="string"||N(e.options)||N(e.models)}function N(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function Ks(e){if(e instanceof Error)return e.message;return String(e)}var cn="native";function dn(e){if(e==="native"||e==="mcp")return e;return cn}function $t(e){if(e==="mcp"){throw new Error("MCP backend coming in v2 follow-up plan")}}function Yt(e,n){if(e==null||typeof e!=="object"||Array.isArray(e)){return n}const i=Reflect.get(e,"mode");return{mode:i==="inline"||i==="subagent"?i:n.mode,modeSource:i==="inline"||i==="subagent"?"explicit":"default"}}function Wt(e,n){const i=n.keepAlive;const t=n.xdg;const r=n.spawnConcurrency;const l=()=>({enabled:i.enabled,maxProcesses:i.maxProcesses,maxLifetimeMs:i.maxLifetimeMs,agents:[...i.agents]});const a=e.opencode;if(a==null||typeof a!=="object"||Array.isArray(a)){return{keepAlive:l(),xdg:{...t},spawnConcurrency:r}}const c=a;const p=c.spawnConcurrency;const u=typeof p==="number"&&Number.isFinite(p)&&p>0&&Number.isInteger(p)?p:r;const d=Gs(c.xdg,t);const h=c.keepAlive;if(h==null||typeof h!=="object"||Array.isArray(h)){return{keepAlive:l(),xdg:d,spawnConcurrency:u}}const R=h;const k=R.maxProcesses;const D=typeof k==="number"&&Number.isFinite(k)&&k>0&&Number.isInteger(k)?k:i.maxProcesses;const I=R.maxLifetimeMs;const U=typeof I==="number"&&Number.isFinite(I)&&I>0&&Number.isInteger(I)?I:i.maxLifetimeMs;const L=R.agents;let B;if(Array.isArray(L)){B=L.filter($=>typeof $==="string"&&$.length>0);if(B.length===0)B=[...i.agents]}else{B=[...i.agents]}return{keepAlive:{enabled:typeof R.enabled==="boolean"?R.enabled:i.enabled,maxProcesses:D,maxLifetimeMs:U,agents:B},xdg:d,spawnConcurrency:u}}function Gs(e,n){const i=e!=null&&typeof e==="object"&&!Array.isArray(e)?e:void 0;const t=i?.startupImport;const r=t==="background"||t==="blocking"||t==="off"?t:n.startupImport;return{dataIsolation:typeof i?.dataIsolation==="boolean"?i.dataIsolation:n.dataIsolation,startupImport:r}}function Bn(e){const n=JSON.stringify({level:40,time:Date.now(),name:"config.asr",msg:e});process.stderr.write(`${n}
3
- `)}var Un={enabled:true};function qt(e){if(e==null||typeof e!=="object"||Array.isArray(e))return false;const n=e;const i=typeof n.apiKey==="string"&&n.apiKey.trim().length>0;const t=typeof n.resourceId==="string"&&n.resourceId.trim().length>0;return i||t}function Fn(e){return typeof e==="string"&&e.trim().length>0}function Ht(e){const n=e.asr;if(n==null||typeof n!=="object"||Array.isArray(n)){return{...Un}}const i=n;if(qt(i.seed)){Bn("Ignoring legacy `asr.seed.*` in config \u2014 Seed ASR was retired from the daemon; only Amadeus remains. Remove `asr.seed` from config.yaml.")}if(qt(i.qwen)){Bn("Ignoring legacy `asr.qwen.apiKey` in config \u2014 Qwen ASR was retired from the daemon; only Amadeus remains. Remove `asr.qwen` from config.yaml.")}if(Fn(i.mode)||Fn(i.proxyBaseUrl)){Bn("Ignoring legacy `asr.mode` / `asr.proxyBaseUrl` in config \u2014 the daemon no longer runs the shared asr-proxy WebSocket path. The Amadeus HTTP proxy is managed by the application environment. Remove these keys from config.yaml.")}if(Fn(i.primaryProvider)||Fn(i.fallbackProvider)){Bn("Ignoring legacy `asr.primaryProvider` / `asr.fallbackProvider` in config \u2014 only Amadeus remains and provider selection is no longer configurable. Remove these keys from config.yaml.")}return{enabled:typeof i.enabled==="boolean"?i.enabled:Un.enabled}}var $s={policyOwner:"core",storageWriteVersion:2,classifierTimeoutMs:6e4,userConfirmationEnabled:true,dangerousCommandGateEnabled:true};function Xt(e,n=$s){const i=e.permission;if(i==null||typeof i!=="object"||Array.isArray(i)){return{...n}}const t=i;const r=t.policyOwner===void 0?n.policyOwner:t.policyOwner==="engine"||t.policyOwner==="core"?t.policyOwner:"engine";const l=t.storageWriteVersion===1||t.storageWriteVersion===2?t.storageWriteVersion:n.storageWriteVersion;const a=t.classifierTimeoutMs;const c=typeof a==="number"&&Number.isFinite(a)&&a>=5e3?Math.floor(a):n.classifierTimeoutMs;const p=typeof t.userConfirmationEnabled==="boolean"?t.userConfirmationEnabled:n.userConfirmationEnabled;const u=typeof t.dangerousCommandGateEnabled==="boolean"?t.dangerousCommandGateEnabled:n.dangerousCommandGateEnabled;return{policyOwner:r,storageWriteVersion:l,classifierTimeoutMs:c,userConfirmationEnabled:p,dangerousCommandGateEnabled:u}}var Ys=5*1024*1024;var fn={recoveryDivisor:2,image:{max_width:2e3,max_height:2e3,max_base64_bytes:4.5*1024*1024}};function $o(e){const n=zt(e)?e:{};const i=n.recoveryDivisor;const t=zt(n.image)?n.image:{};const r=fn.image;return{recoveryDivisor:typeof i==="number"&&Number.isFinite(i)&&i>1?i:fn.recoveryDivisor,image:{max_width:Go(t.max_width)??r.max_width,max_height:Go(t.max_height)??r.max_height,max_base64_bytes:Math.min(Go(t.max_base64_bytes)??r.max_base64_bytes,Ys)}}}function Go(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>0?e:void 0}function zt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Jt=["user-cc","user-codex","user-agents","workspace-minimax","workspace-cc","workspace-agents"];var Ws={"user-cc":"user-claude","workspace-cc":"workspace-claude"};var Vn={external:{enabled:true,walkUp:true,duplicateWarn:true,sources:{"workspace-minimax":{enabled:true,priority:65},"workspace-cc":{enabled:true,priority:60},"workspace-agents":{enabled:true,priority:55},"user-cc":{enabled:true,priority:40},"user-codex":{enabled:true,priority:35},"user-agents":{enabled:true,priority:30}}}};function jn(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function qs(e,n){if(!jn(e))return n;return{enabled:typeof e.enabled==="boolean"?e.enabled:n.enabled,priority:typeof e.priority==="number"&&Number.isFinite(e.priority)?e.priority:n.priority}}function Yo(e){const n=Vn;const i=jn(e.skills)?e.skills:{};const t=jn(i.external)?i.external:{};const r=jn(t.sources)?t.sources:{};const l={...n.external.sources};for(const a of Jt){const c=Ws[a];const p=Object.hasOwn(r,a)?r[a]:c?r[c]:void 0;l[a]=qs(p,n.external.sources[a])}return{external:{enabled:typeof t.enabled==="boolean"?t.enabled:n.external.enabled,walkUp:typeof t.walkUp==="boolean"?t.walkUp:n.external.walkUp,duplicateWarn:typeof t.duplicateWarn==="boolean"?t.duplicateWarn:n.external.duplicateWarn,sources:l}}}var Hs=Jt;var Qt=["pi-agent"];var Ke="pi-agent";function Zt(e){if(typeof e!=="string")return Ke;if(Qt.includes(e)){return e}return Ke}function Wo(e){if(e==null||typeof e!=="object"||Array.isArray(e)){return{defaultFramework:Ke}}const n=e;return{defaultFramework:Zt(n.defaultFramework)}}var Qo=["read","write","edit","bash","task_query","task_output","task_stop","grep","glob","todowrite","web_fetch","website_deploy"];var Zo=["images_understand","image_synthesize","images_search_and_download","image_reverse_search","submit_video_generation","query_video_generation","gen_videos","batch_text_to_video","batch_image_to_video","get_voice_list","batch_text_to_audio","batch_text_to_music","synthesize_speech","batch_synthesize_speech","audios_understand","videos_understand","transcribe_audio"];var ei=["code-review","deep-research","deploy-website","docx","edit-deployed-website","init","lark-tools","llm-call","mcode-tools-master","mavis-doctor","pdf","plugin-creator","pptx","skill-creator","skill-refiner","visual-page","x-link-reader","xlsx"];var or=["control-in-app-browser","cu-desktop","resume-codex","mavis","create-agent","minimax-code-product","miniapp-creator"];var Xs=new Set(["modelConfigId","persona","tools","builtinTools","skills","features"]);var zs=new Set(["enabled"]);var zo=new Set(["mavis","delegation","webSearch"]);var ir=new Set(Qo);var er=["task_query","task_output","task_stop"];var tr=new Set(Zo);var Jo=new Set(ei);var rr=new Set(or);var Js=new Set(["plan-mode"]);function ni(e){const n=Kn(e);const i=Kn(n?.default);return{default:i?Zs(i):{}}}function Qs(e,n="agent"){if(e===void 0)return{};const i=Ho(e,n);Xo(i,Xs,n);const t={};if(i.modelConfigId!==void 0){if(typeof i.modelConfigId!=="string"||!i.modelConfigId.trim()){Q(`${n}.modelConfigId`,"must be a non-empty string")}t.modelConfigId=i.modelConfigId.trim()}if(i.persona!==void 0){const r=Ho(i.persona,`${n}.persona`);Xo(r,zs,`${n}.persona`);if(r.enabled!==void 0&&typeof r.enabled!=="boolean"){Q(`${n}.persona.enabled`,"must be a boolean")}t.persona={...typeof r.enabled==="boolean"?{enabled:r.enabled}:{}}}if(i.tools!==void 0){if(!Array.isArray(i.tools))Q(`${n}.tools`,"must be an array");t.tools=i.tools.map((r,l)=>{if(typeof r!=="string"||!ir.has(r)){Q(`${n}.tools[${l}]`,`must be one of ${Qo.join(", ")}`)}return r})}if(i.builtinTools!==void 0){if(!Array.isArray(i.builtinTools))Q(`${n}.builtinTools`,"must be an array");t.builtinTools=i.builtinTools.map((r,l)=>{if(r==="web_search"){Q(`${n}.builtinTools[${l}]`,"web_search is feature-owned; use features.webSearch")}if(typeof r!=="string"||!tr.has(r)){Q(`${n}.builtinTools[${l}]`,`must be one of ${Zo.join(", ")}`)}return r})}if(i.skills!==void 0){if(!Array.isArray(i.skills))Q(`${n}.skills`,"must be an array");t.skills=i.skills.map((r,l)=>{if(typeof r==="string"&&rr.has(r.trim())){const a=r.trim();Q(`${n}.skills[${l}]`,`${a} is capability-owned; use its owning Tool or feature switch`)}if(typeof r!=="string"||!Jo.has(r.trim())){Q(`${n}.skills[${l}]`,`must be one of ${ei.join(", ")}`)}return r.trim()})}if(i.features!==void 0){const r=Ho(i.features,`${n}.features`);Xo(r,zo,`${n}.features`);for(const l of zo){if(r[l]!==void 0&&typeof r[l]!=="boolean"){Q(`${n}.features.${l}`,"must be a boolean")}}t.features={...typeof r.mavis==="boolean"?{mavis:r.mavis}:{},...typeof r.delegation==="boolean"?{delegation:r.delegation}:{},...typeof r.webSearch==="boolean"?{webSearch:r.webSearch}:{}}}return t}function Zs(e){const n={};if(typeof e.modelConfigId==="string"&&e.modelConfigId.trim()){n.modelConfigId=e.modelConfigId.trim()}const i=Kn(e.persona);if(typeof i?.enabled==="boolean"){n.persona={enabled:i.enabled}}if(nr(e.tools,ir)){const r=[...e.tools];if(!er.some(l=>r.includes(l))){r.push(...er)}n.tools=r}if(nr(e.builtinTools,tr)){n.builtinTools=[...e.builtinTools]}if(Array.isArray(e.skills)){const r=e.skills.map(l=>typeof l==="string"?l.trim():l);if(r.every(l=>typeof l==="string"&&(Jo.has(l)||Js.has(l))&&!rr.has(l))){n.skills=r.filter(l=>typeof l==="string"&&Jo.has(l))}}const t=Kn(e.features);if(t){const r={};for(const l of zo){if(typeof t[l]==="boolean")r[l]=t[l]}if(Object.keys(r).length>0)n.features=r}return n}function Kn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)?e:void 0}function nr(e,n){return Array.isArray(e)&&e.every(i=>typeof i==="string"&&n.has(i))}function el(e={},n={}){return{persona:{enabled:n.persona?.enabled??e.persona?.enabled??true},tools:qo(n.tools??e.tools),builtinTools:qo(n.builtinTools??e.builtinTools),skills:qo(n.skills??e.skills),features:{mavis:n.features?.mavis??e.features?.mavis??true,delegation:n.features?.delegation??e.features?.delegation??true,webSearch:n.features?.webSearch??e.features?.webSearch??true}}}function nl(e,n){return e.tools===void 0||e.tools.includes(n)}function ol(e,n){return e.builtinTools===void 0||e.builtinTools.includes(n)}function il(e,n){return e.skills===void 0||e.skills.includes(n)}function qo(e){return e===void 0?void 0:[...e]}function Ho(e,n){if(e==null||typeof e!=="object"||Array.isArray(e)){Q(n,"must be an object")}return e}function Xo(e,n,i){for(const t of Object.keys(e)){if(!n.has(t))Q(`${i}.${t}`,"is not supported")}}function Q(e,n){throw new Error(`Invalid configuration at ${e}: ${n}`)}var oi={enabled:true};function sr(e,n=oi){const i=e.askUser;if(i==null||typeof i!=="object"||Array.isArray(i)){return{...n}}const t=i;return{enabled:typeof t.enabled==="boolean"?t.enabled:n.enabled}}var ur=["none","evaluator","subagent"];var cr=["brief","transcript"];var dr=["same-route-small-fast"];var fr="goal-verifier-readonly";var pr=[fr];var Z={budget:{graceSteps:1},breaker:{repeatedReplyLimit:3},verifier:{repeatedNotMetLimit:5,evidence:"brief"},evaluator:{modelPolicy:"same-route-small-fast",maxTokens:32e3,timeoutSeconds:60,maxRetries:1}};var ii={budget:{graceSteps:3},evaluator:{maxRetries:1}};function ti(e){const n=[];const i=Ge(e,"goal",n);$e(i,"goal",n,["objectiveMaxChars","verification","budget","breaker","verifier","evaluator","subagent"]);const t=Ge(i.budget,"goal.budget",n);$e(t,"goal.budget",n,["defaultTokens","defaultMainTurns","defaultActiveSeconds","graceSteps"]);const r=Ge(i.breaker,"goal.breaker",n);$e(r,"goal.breaker",n,["repeatedReplyLimit"]);const l=Ge(i.verifier,"goal.verifier",n);$e(l,"goal.verifier",n,["repeatedNotMetLimit","evidence"]);const a=Ge(i.evaluator,"goal.evaluator",n);$e(a,"goal.evaluator",n,["modelPolicy","maxTokens","timeoutSeconds","maxRetries"]);const c=Ge(i.subagent,"goal.subagent",n);$e(c,"goal.subagent",n,["profile","maxTurns","maxTokens","timeoutSeconds"]);const p=ar(i.verification,"goal.verification",ur,n);const u=we(i.objectiveMaxChars,"goal.objectiveMaxChars",n,{min:1});const d=we(t.defaultTokens,"goal.budget.defaultTokens",n,{min:1});const h=we(t.defaultMainTurns,"goal.budget.defaultMainTurns",n,{min:1});const R=we(t.defaultActiveSeconds,"goal.budget.defaultActiveSeconds",n,{min:1});const k=ar(c.profile,"goal.subagent.profile",pr,n);const D=we(c.maxTurns,"goal.subagent.maxTurns",n,{min:1});const I=we(c.maxTokens,"goal.subagent.maxTokens",n,{min:1});const U=we(c.timeoutSeconds,"goal.subagent.timeoutSeconds",n,{min:1});const L={...k!==void 0?{profile:k}:{},...D!==void 0?{maxTurns:D}:{},...I!==void 0?{maxTokens:I}:{},...U!==void 0?{timeoutSeconds:U}:{}};return{config:{...u!==void 0?{objectiveMaxChars:u}:{},...p!==void 0?{verification:p}:{},budget:{...d!==void 0?{defaultTokens:d}:{},...h!==void 0?{defaultMainTurns:h}:{},...R!==void 0?{defaultActiveSeconds:R}:{},graceSteps:Ye(t.graceSteps,"goal.budget.graceSteps",Z.budget.graceSteps,n,{min:0,max:ii.budget.graceSteps})},breaker:{repeatedReplyLimit:Ye(r.repeatedReplyLimit,"goal.breaker.repeatedReplyLimit",Z.breaker.repeatedReplyLimit,n,{min:1})},verifier:{repeatedNotMetLimit:Ye(l.repeatedNotMetLimit,"goal.verifier.repeatedNotMetLimit",Z.verifier.repeatedNotMetLimit,n,{min:1}),evidence:lr(l.evidence,"goal.verifier.evidence",cr,Z.verifier.evidence,n)},evaluator:{modelPolicy:lr(a.modelPolicy,"goal.evaluator.modelPolicy",dr,Z.evaluator.modelPolicy,n),maxTokens:Ye(a.maxTokens,"goal.evaluator.maxTokens",Z.evaluator.maxTokens,n,{min:1}),timeoutSeconds:Ye(a.timeoutSeconds,"goal.evaluator.timeoutSeconds",Z.evaluator.timeoutSeconds,n,{min:1}),maxRetries:Ye(a.maxRetries,"goal.evaluator.maxRetries",Z.evaluator.maxRetries,n,{min:0,max:ii.evaluator.maxRetries})},...Object.keys(L).length>0?{subagent:L}:{}},warnings:n}}function Ge(e,n,i){if(e===void 0)return{};if(e===null||typeof e!=="object"||Array.isArray(e)){i.push(Ae(n,"expected an object; using defaults"));return{}}return e}function $e(e,n,i,t){for(const r of Object.keys(e)){if(!t.includes(r))i.push(Ae(`${n}.${r}`,"unknown key ignored"))}}function Ye(e,n,i,t,r){if(e==null)return i;if(!Number.isInteger(e)||e<r.min){t.push(Ae(n,`expected an integer >= ${r.min}; using default`));return i}if(r.max!=null&&e>r.max){t.push(Ae(n,`exceeds maximum ${r.max}; clamped`));return r.max}return e}function we(e,n,i,t){if(e==null)return void 0;if(!Number.isInteger(e)||e<t.min){i.push(Ae(n,`expected an integer >= ${t.min}; ignored`));return void 0}if(t.max!=null&&e>t.max){i.push(Ae(n,`exceeds maximum ${t.max}; clamped`));return t.max}return e}function lr(e,n,i,t,r){if(e==null)return t;if(typeof e!=="string"||!i.includes(e)){r.push(Ae(n,`expected one of: ${i.join(", ")}; using default`));return t}return e}function ar(e,n,i,t){if(e==null)return void 0;if(typeof e!=="string"||!i.includes(e)){t.push(Ae(n,`expected one of: ${i.join(", ")}; ignored`));return void 0}return e}function Ae(e,n){return`Invalid goal config at ${e}: ${n}`}var te={enabled:true,maxInlineKiB:64,mcpDetailsMaxInlineKiB:32,watermarkKiB:256,minSavingsKiB:256,minCandidateKiB:2,keepRecentRounds:5};var tl=Math.floor(Number.MAX_SAFE_INTEGER/1024);function ri(e){const n=sl(e)?e:{};return{enabled:typeof n.enabled==="boolean"?n.enabled:te.enabled,maxInlineKiB:pn(n.maxInlineKiB,te.maxInlineKiB),mcpDetailsMaxInlineKiB:pn(n.mcpDetailsMaxInlineKiB,te.mcpDetailsMaxInlineKiB),watermarkKiB:pn(n.watermarkKiB,te.watermarkKiB),minSavingsKiB:pn(n.minSavingsKiB,te.minSavingsKiB),minCandidateKiB:pn(n.minCandidateKiB,te.minCandidateKiB),keepRecentRounds:rl(n.keepRecentRounds,te.keepRecentRounds)}}function pn(e,n){return typeof e==="number"&&Number.isSafeInteger(e)&&e>0&&e<=tl?e:n}function rl(e,n){return typeof e==="number"&&Number.isSafeInteger(e)&&e>0?e:n}function sl(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var gn={};function si(e){if(e==null||typeof e!=="object"||Array.isArray(e)){return{...gn}}const n=Reflect.get(e,"chromePath");if(typeof n!=="string"||!n.trim()){return{...gn}}return{chromePath:n.trim()}}import{isIP as ll}from"node:net";var li=["read_only","workspace_write","delete_guard","full_access"];function gr(e){return{enabled:false,filesystemMode:"full_access"}}function mr(e){return!e.enabled||e.filesystemMode==="full_access"?{enabled:false,filesystemMode:"full_access"}:{...e}}function ui(e){const n=gr(e);return{enabled:n.enabled,filesystem:{policy:{mode:n.filesystemMode},denyRead:[],denyWrite:[]},network:{policy:{mode:"allow_all"},deniedDomains:[]},localAccess:"open"}}var ci=ui(process.platform);var al=new Set(li);var ul=new Set(["deny","allow_all"]);function di(e,n=process.platform){const i=ui(n);if(e===void 0)return i;const t=mn(e,"sandbox",["enabled","filesystem","network","localAccess"]);const r=t.filesystem===void 0?{}:mn(t.filesystem,"sandbox.filesystem",["policy","denyRead","denyWrite","allowGitConfig"]);const l=r.policy===void 0?{}:mn(r.policy,"sandbox.filesystem.policy",["mode"]);const a=t.network===void 0?{}:mn(t.network,"sandbox.network",["policy","deniedDomains"]);const c=a.policy===void 0?{}:mn(a.policy,"sandbox.network.policy",["mode"]);const p=t.enabled===void 0?i.enabled:cl(t.enabled,"sandbox.enabled");const u=l.mode??(p?"delete_guard":"full_access");if(typeof u!=="string"||!al.has(u)){throw new Error(`Invalid sandbox.filesystem.policy.mode "${String(u)}"`)}const d=c.mode??i.network.policy.mode;if(typeof d!=="string"||!ul.has(d)){throw new Error(`Invalid sandbox.network.policy.mode "${String(d)}"`)}const h=a.deniedDomains===void 0?[...i.network.deniedDomains]:ai(a.deniedDomains,"sandbox.network.deniedDomains");for(const k of h)dl(k);const R=mr({enabled:p,filesystemMode:u});return{enabled:R.enabled,filesystem:{policy:{mode:R.filesystemMode},denyRead:r.denyRead===void 0?[...i.filesystem.denyRead]:ai(r.denyRead,"sandbox.filesystem.denyRead"),denyWrite:r.denyWrite===void 0?[...i.filesystem.denyWrite]:ai(r.denyWrite,"sandbox.filesystem.denyWrite")},network:{policy:{mode:"allow_all"},deniedDomains:[]},localAccess:t.localAccess===void 0?i.localAccess:t.localAccess==="open"||t.localAccess==="restricted"?t.localAccess:(()=>{throw new Error(`Invalid sandbox.localAccess "${String(t.localAccess)}"`)})()}}function mn(e,n,i){if(e==null||typeof e!=="object"||Array.isArray(e)){throw new Error(`Invalid ${n}: expected object`)}const t=e;const r=Object.keys(t).find(l=>!i.includes(l));if(r)throw new Error(`Unknown ${n}.${r}`);return t}function cl(e,n){if(typeof e!=="boolean")throw new Error(`Invalid ${n}: expected boolean`);return e}function ai(e,n){if(!Array.isArray(e)||e.some(i=>typeof i!=="string")){throw new Error(`Invalid ${n}: expected string array`)}return[...e]}function dl(e){const n=()=>{throw new Error(`Invalid sandbox.network.deniedDomains entry "${e}"`)};const i=e.match(/^\[([^\]]+)\](?::(.+))?$/);if(i){if(ll(i[1]??"")!==6)n();yr(i[2],e);return}if((e.match(/:/g)??[]).length>1){n()}const t=e.lastIndexOf(":");const r=t>-1?e.slice(0,t):e;const l=t>-1?e.slice(t+1):void 0;yr(l,e);if(r==="*")return;if(!fl(r))n()}function fl(e){if(e.includes("://")||e.includes("/")||e.includes(":"))return false;if(e==="localhost")return true;if(e.startsWith("*.")){const n=e.slice(2);const i=n.split(".");return i.length>=2&&i.every(t=>t.length>0)}if(e.includes("*"))return false;return e.includes(".")&&!e.startsWith(".")&&!e.endsWith(".")}function yr(e,n){if(e===void 0)return;const i=Number(e);if(!/^[1-9][0-9]{0,4}$/.test(e)||!Number.isInteger(i)||i>65535){throw new Error(`Invalid sandbox.network.deniedDomains entry "${n}"`)}}function br(e,n){if(n.length===0)return false;if(n.includes("*"))return true;return n.includes(e)}function yl(){return process.env.__MAVIS_ALLOW_LEGACY_RUNTIME_ENV==="1"}var hr={dev:"test",test:"test",staging:"staging",prod:"prod"};function bl(e){return e==="cn"||e==="en"}function vr(e){return e==="test"||e==="prod"||e==="dev"||e==="staging"}function Rr(){const e=process.env.MAVIS_REGION;if(bl(e))return e;if($n()){const n=process.env.NEXT_PUBLIC_LOCALE;if(n==="zh")return"cn";if(n==="en")return"en"}return"en"}function fe(){const e=process.env.MAVIS_BUILD_ENV;if(vr(e))return e;if($n()){const n=process.env.NEXT_PUBLIC_BUILD_ENV;const i=n&&Object.prototype.hasOwnProperty.call(hr,n)?hr[n]:void 0;if(i)return i}return"dev"}function Gn(){if(Mr("managed"))return true;const e=process.env.__MAVIS_RUNTIME_MANAGED;if(e==="1")return true;if(e==="0")return false;if($n())return true;if(fe()==="prod"||fe()==="staging")return true;return false}function $n(){const e=process.versions;return process.env.ELECTRON_RUN_AS_NODE==="1"||typeof e.electron==="string"}function Yn(){return`${Rr()}-${fe()}`}var ce={none:0,test:1,internal:2,online:3};var hl={internal:"internal",inside:"online"};function xl(e){for(const[n,i]of Object.entries(e)){if(ce[i.defaultVisibility]>ce[i.configurableVisibility]){throw new Error(`Invalid beta feature definition "${n}": defaultVisibility (${i.defaultVisibility}) must not exceed configurableVisibility (${i.configurableVisibility})`)}for(const t of i.defaultBuildVariants??[]){const r=hl[t];if(ce[r]>ce[i.configurableVisibility]){throw new Error(`Invalid beta feature definition "${n}": defaultBuildVariant (${t}) must not exceed configurableVisibility (${i.configurableVisibility})`)}}for(const t of i.defaultBuildEnvironments??[]){const r=t==="prod"?"online":"test";if(ce[r]>ce[i.configurableVisibility]){throw new Error(`Invalid beta feature definition "${n}": defaultBuildEnvironment (${t}) must not exceed configurableVisibility (${i.configurableVisibility})`)}}}}var bn={autoMemory:{defaultVisibility:"online",configurableVisibility:"online"},skillEvolve:{defaultVisibility:"test",configurableVisibility:"online"},skillEvolveBuiltinMr:{defaultVisibility:"none",configurableVisibility:"test"},skillProposal:{defaultVisibility:"test",configurableVisibility:"online"},browserBridge:{defaultVisibility:"test",configurableVisibility:"online"},filePanelBrowser:{defaultVisibility:"online",configurableVisibility:"online"},filePanelBrowserMultiTab:{defaultVisibility:"online",configurableVisibility:"online"},browserUseTooling:{defaultVisibility:"online",configurableVisibility:"online"},browserUseAutoOpenPanel:{defaultVisibility:"online",configurableVisibility:"online"},browserAgentCursor:{defaultVisibility:"online",configurableVisibility:"online"},desktopPlanMode:{defaultVisibility:"online",configurableVisibility:"online"},desktopPlanModeAgentEntry:{defaultVisibility:"none",configurableVisibility:"online"},peek:{defaultVisibility:"test",configurableVisibility:"test"},keepAlive:{defaultVisibility:"test",configurableVisibility:"test"},promptOverride:{defaultVisibility:"test",configurableVisibility:"test"},cuMode:{defaultVisibility:"online",configurableVisibility:"online"},asr:{defaultVisibility:"online",configurableVisibility:"online"},taskHistoryProjectGrouping:{defaultVisibility:"online",configurableVisibility:"online"},threadGoal:{defaultVisibility:"online",configurableVisibility:"online"},mcodeTools:{defaultVisibility:"none",defaultBuildEnvironments:["dev","test","staging","prod"],defaultPlatforms:["darwin","linux","win32"],configurableVisibility:"online"},codexOAuth:{defaultVisibility:"online",configurableVisibility:"online"},runCode:{defaultVisibility:"none",configurableVisibility:"online"}};xl(bn);function Cl(e){const n=e.buildEnv??fe();if(n!=="prod")return"test";return e.internalBuild===true?"internal":"online"}function Al(e,n){const i=e.defaultBuildVariants;if(!i)return false;return n.internalBuild===true&&i.includes("internal")||n.insideBuild===true&&i.includes("inside")}function Sl(e,n){const i=n.defaultBuildEnvironment??n.buildEnv??mi();return e.defaultBuildEnvironments?.includes(i)===true}function mi(){const e=$n()?process.env.NEXT_PUBLIC_BUILD_ENV:void 0;return vr(e)?e:fe()}function xr(e,n){return e.defaultPlatforms?.includes(n.platform??process.platform)!==false}function yi(e,n,i={}){const t=bn[e];const r=ce[Cl(i)];const l=i.defaultBuildEnvironment??i.buildEnv??mi();if(e==="mcodeTools"&&l==="dev"&&i.mcodeToolsDevMode==="published"&&xr(t,i))return true;if(n===false)return false;if(n===true)return r<=ce[t.configurableVisibility];if(!xr(t,i))return false;if(Sl(t,i))return true;if(Al(t,i))return true;return r<=ce[t.defaultVisibility]}function _l(e){return bn[e].configurableVisibility==="online"}function bi(e=process.env){return e.__MAVIS_BUILD_INTERNAL==="true"}function vl(e=process.env){return e.__MAVIS_BUILD_INSIDE==="true"}var Rl={APP_DIR:".minimax",ENV_PREFIX:"minimax",CLI_NAME:"minimax"};var Er="__MAVIS_RUNTIME";function Wn(e){return yl()?process.env[`${Er}_${e}`]:void 0}function qn(e){const n=`--${e}`;let i;for(let t=2;t<process.argv.length;t++){const r=process.argv[t];if(r==="--")break;if(r===n){const l=process.argv[t+1];i=l===void 0||l.startsWith("-")?void 0:l;t++;continue}if(r?.startsWith(`${n}=`)){const l=r.slice(n.length+1);i=l.length>0?l:void 0}}return i}function Mr(e){const n=`--${e}`;for(let i=2;i<process.argv.length;i++){const t=process.argv[i];if(t==="--")return false;if(t===n||t?.startsWith(`${n}=`))return true}return false}var We=5321;var pi=5001;var fi=65535;var kr=500;var hi=2;var El=kr*hi;var wr=El+hi;var Cr=1;var Ml=new Set(["agent-archon","mavis"]);var Ar=(()=>{const e=79764919;const n=new Uint32Array(256);for(let i=0;i<256;i++){let t=i<<24;for(let r=0;r<8;r++){t=(t&2147483648)!==0?e^t<<1:t<<1;t>>>=0}n[i]=t>>>0}return n})();function kl(e){const n=Buffer.from(`${e}
4
- `,"utf-8");let i=0;for(const r of n){i=(Ar[(i>>>24^r)&255]^i<<8)>>>0}let t=n.length;while(t!==0){i=(Ar[(i>>>24^t&255)&255]^i<<8)>>>0;t>>>=8}return(i^4294967295)>>>0}function wl(e){return kl(e)%kr*hi+2}function Sr(e,n){try{const i=gl("git",e,{encoding:"utf-8",timeout:3e3,stdio:["ignore","pipe","pipe"],...n?{cwd:n}:{}});if(i.status===0&&i.stdout)return i.stdout.trim();return null}catch{return null}}function Tl(e){const n=e.match(/[/:]([^/:]+?)(?:\.git)?$/);return n?.[1]??null}function Tr(){return process.env.MINIMAX_DATA_DIR?.trim()||process.env.MAVIS_DATA_DIR?.trim()}function Hn(){if(Mr("disable-git-auto-config")||Wn("DISABLE_GIT_AUTO_CONFIG"))return false;if(qn("data-dir"))return false;if(Tr())return false;return true}function Xn(){const e=qn("profile")??po()??Wn("PROFILE");return Ue(e)}function Ir(){const e=qn("port")??Wn("PORT");const n=e?parseInt(e,10):NaN;return Number.isNaN(n)?null:n}function gi(){const e=qn("data-dir")??Tr()??Wn("DATA_DIR");return e&&e.length>0?e:null}function Il(){return Boolean(Xn()&&gi())}function Or(){return Boolean(Xn()&&Ir()!==null)}var Te=null;function Ol(){Te=null}function Ie(){if(Te!==null)return Te;const e={runtimePort:We,uiPort:pi,profile:null,autoDetected:false};if(true){Te=e;return e}const n=[void 0,Pl()];for(const i of n){try{const t=Sr(["remote","get-url","origin"],i);if(!t)continue;const r=Tl(t);if(!r||!Ml.has(r))continue;const l=Sr(["branch","--show-current"],i);if(!l)continue;const a=wl(l);Te={runtimePort:We+a,uiPort:pi+a,profile:l.replace(/\//g,"-"),autoDetected:true};return Te}catch{}}Te=e;return e}function Pl(){try{if(typeof __dirname==="string")return __dirname}catch{}const e=new Error().stack??"";for(const n of e.split("\n")){const i=/file:\/\/[^)\s]+/u.exec(n)?.[0]?.replace(/:\d+:\d+$/u,"");if(i){try{return z.dirname(ml(i))}catch{}}const t=/\(?((?:\/|[A-Za-z]:\\)[^()]+?\.(?:cjs|mjs|js|ts)):\d+:\d+\)?/u.exec(n)?.[1];if(t)return z.dirname(t)}return void 0}function Ll(){const e=Xn();if(e)return e;if(!Hn())return null;return Ie().profile}function xi(){const e=Xn();if(Il()){return gi()}if(Hn()){const i=Ie();if(i.autoDetected&&i.profile){return Fe({profile:i.profile})}}const n=gi();if(n){return n}if(e){return Fe({profile:e})}return Fe()}function pe(){return z.join(xi(),"config.yaml")}var zn={"cn-test":"https://matrix-test.example.invalid/mavis/api/v1/llm/v1","cn-dev":"https://matrix-test.example.invalid/mavis/api/v1/llm/v1","cn-staging":"https://matrix-pre.example.invalid/mavis/api/v1/llm/v1","en-test":"https://matrix-overseas-test.example.invalid/mavis/api/v1/llm/v1","en-dev":"https://matrix-overseas-test.example.invalid/mavis/api/v1/llm/v1","en-staging":"https://matrix-overseas-pre.example.invalid/mavis/api/v1/llm/v1","cn-prod":"https://agent.minimax.cn/mavis/api/v1/llm/v1","en-prod":"https://agent.minimax.io/mavis/api/v1/llm/v1"};var Pr=["https://agent.minimaxi.com/mavis/api/v1/llm/v1"];var Dl=new Set([...Object.values(zn),...Pr]);var Nl=new Set([...Object.values(zn),...Pr].map(e=>new URL(e).origin));function Lr(e){if(Dl.has(e))return true;try{const n=new URL(e);return!n.username&&!n.password&&Nl.has(n.origin)}catch{return false}}function Dr(){return fe()==="test"}function Bl(){return!Dr()}function Fl(e){if(!Gn()||!de.existsSync(e)){return}const n=Nr(e);const{provider:i}=n;if(i==null||typeof i!=="object"||Array.isArray(i))return;const{minimax:t}=i;if(t==null||typeof t!=="object"||Array.isArray(t))return;const{options:r}=t;if(r==null||typeof r!=="object"||Array.isArray(r))return;const l=r.baseURL;if(typeof l!=="string")return;const a=zn[Yn()];if(l===a||!Lr(l))return;const c=de.readFileSync(e);r.baseURL=a;try{ue(e,V.dump(n,{indent:2,lineWidth:-1,noRefs:true}))}catch(p){let u=false;try{u=de.readFileSync(e).equals(c)}catch{}if(!u)throw p;console.warn("[config] managed preset baseURL sync skipped; config file unchanged, using runtime provider settings")}}function Se(e){const n={name:"MiniMax",npm:"@ai-sdk/anthropic",options:{authMode:"managed-login",apiKey:"sk-xxx",baseURL:zn[e]},models:je};return{provider:{minimax:n},defaultModel:"minimax/MiniMax-M3.1-Flash"}}var Ci={"cn-test":Se("cn-test"),"cn-dev":Se("cn-dev"),"cn-staging":Se("cn-staging"),"cn-prod":Se("cn-prod"),"en-test":Se("en-test"),"en-dev":Se("en-dev"),"en-staging":Se("en-staging"),"en-prod":Se("en-prod")};var K={logLevel:"info",devPort:pi,permissionMode:"auto",sseErrorPush:{history:true,stream:true},beta:Object.fromEntries(Object.keys(bn).map(e=>[e,yi(e,void 0,{buildEnv:"dev"})])),agents:{default:{}},memory:{enabled:true,proactive:false,dailyDigest:{enabled:false}},skillEvolve:{enabled:true,inSession:{N:20,minIntervalSeconds:30,maxPendingPerSession:1},signalCooldownHours:24,minConfidence:.7,excludeAgents:["skill-editor"],disableModelPrefixes:["MiniMax-M2"],builtinMrEnabled:false,sourceRepo:void 0,proposal:{enabled:false,eligibleAgents:["mavis"],minMessageCount:40,skipPassiveSessionEnd:true},lifecycle:{staleThresholdDays:15,archiveThresholdDays:30}},sessionRotate:{enabled:true,activeSessionLookbackHours:12},agentStop:{debounceMs:500,maxActiveSpanMs:30*60*1e3},asr:{...Un},skills:Vn,askUser:{...oi},sessionTitle:{enabled:true},requestMedia:fn,cli:{spawn:{enabled:false}},browser:{...gn},tui:{},telemetry:{enabled:false,metrics:false,diagnostics:false},opencode:{xdg:{dataIsolation:false,startupImport:"off"},keepAlive:{enabled:false,maxProcesses:5,maxLifetimeMs:288e5,agents:["mavis","main","verifier","code-reviewer"]},spawnConcurrency:3},contextManagement:{disableSystemReminderModels:[],cuMaxScreenshotsInContext:2},runawayGuard:{enabled:true},toolResultCompaction:{...te},agentRuntime:{defaultFramework:Ke},logRetentionDays:3,cuBackend:cn,worktreeRefreshBeforeCreate:true,review:{mode:"subagent",modeSource:"default"},goal:structuredClone(Z),sandbox:structuredClone(ci),goalWarnings:[],promptSuggestion:{}};function Ul(){const e=pe();const n=z.dirname(e);if(!de.existsSync(n)){de.mkdirSync(n,{recursive:true})}if(de.existsSync(e)){Si(e);return}if(!Gn()){const r=Fe({homeDir:pl.homedir()});const l=z.join(r,"config.yaml");if(e!==l&&de.existsSync(l)){Ve(l);ue(e,de.readFileSync(l),true)}return}const i=Ci[Yn()];const t=V.dump({logLevel:K.logLevel,provider:Ai?i.provider:void 0,defaultModel:i.defaultModel});ue(e,t,true)}function Nr(e=pe()){try{const n=de.readFileSync(e,"utf-8");const i=V.load(n);if(i!=null&&typeof i==="object"&&!Array.isArray(i)){return i}return{}}catch{return{}}}var yn=null;function jl(e){if(e==null||typeof e!=="object"||Array.isArray(e))return void 0;const n=e;return{branchFinish:typeof n.branchFinish==="boolean"?n.branchFinish:false}}var Br={isManagedRuntime:Gn,shouldEnforceManagedProviderProtection:Bl,getManagedPreset:()=>Ci[Yn()],isManagedPresetBaseUrl:Lr};var Fr=true;var Ai=true;function Vl(e){Fr=e}function Kl(e){Ai=e}function Si(e){Ve(e);Gt(e);if(Fr){Vt(e,Br)}if(Ai)Fl(e)}function qe(){yn=null}function _e(){if(yn)return yn;Ul();const e=Nr();yn=_i(e,xi());return yn}function _i(e,n){const i=e.sseErrorPush;const t=i!=null&&typeof i==="object"&&!Array.isArray(i)?i:void 0;let r=typeof e.devPort==="number"?e.devPort:K.devPort;if(Hn()&&!Or()){const u=Ie();if(u.autoDetected){r=u.uiPort}}const l=ti(e.goal);const a=Kt({provider:e.provider!=null&&typeof e.provider==="object"&&!Array.isArray(e.provider)?Bt(e.provider):{},defaultModel:typeof e.defaultModel==="string"?e.defaultModel:void 0},Br);const c=Vo(e.minimaxModelContextLimits);const p=Yl(e);return{logLevel:typeof e.logLevel==="string"?e.logLevel:K.logLevel,devPort:r,...a,provider:Dt(a.provider,c),defaultModelVariant:typeof e.defaultModelVariant==="string"?e.defaultModelVariant:void 0,defaultModelThinking:e.defaultModelThinking&&typeof e.defaultModelThinking==="object"&&typeof e.defaultModelThinking.effort==="string"?{effort:e.defaultModelThinking.effort}:void 0,defaultModelContextWindow:Number.isSafeInteger(e.defaultModelContextWindow)&&Number(e.defaultModelContextWindow)>0&&Number(e.defaultModelContextWindow)<=2147483647?Number(e.defaultModelContextWindow):void 0,minimax_api:Pt(e.minimax_api),minimaxModelContextLimits:c,custom_provider:Nt(e.custom_provider),minimaxModelSource:typeof e.minimaxModelSource==="string"&&(e.minimaxModelSource==="token_plan"||e.minimaxModelSource==="minimax_api_key")?e.minimaxModelSource:void 0,nexus:e.nexus!=null&&typeof e.nexus==="object"&&!Array.isArray(e.nexus)?(()=>{const u={};if(typeof Reflect.get(e.nexus,"enabled")==="boolean"){u.enabled=Reflect.get(e.nexus,"enabled")}const d=Reflect.get(e.nexus,"model");if(d!=null&&typeof d==="object"&&!Array.isArray(d)&&typeof Reflect.get(d,"providerID")==="string"&&typeof Reflect.get(d,"modelID")==="string"){u.model={providerID:Reflect.get(d,"providerID"),modelID:Reflect.get(d,"modelID"),...typeof Reflect.get(d,"variant")==="string"?{variant:Reflect.get(d,"variant")}:{}}}return Object.keys(u).length>0?u:void 0})():void 0,defaultLightModel:typeof e.defaultLightModel==="string"?e.defaultLightModel:void 0,permissionMode:typeof e.permissionMode==="string"&&["default","bypassPermissions","auto","off"].includes(e.permissionMode)?e.permissionMode:K.permissionMode,permission:Xt(e),sseErrorPush:{history:typeof t?.history==="boolean"?t.history:K.sseErrorPush.history,stream:typeof t?.stream==="boolean"?t.stream:K.sseErrorPush.stream},notifications:jl(e.notifications),dataDir:n,agentsDir:z.join(n,"agents"),sessionsDir:z.join(n,"sessions"),memoryDir:z.join(n,"memory"),skillsDir:z.join(n,"skills"),builtinSkillsDir:z.join(n,".builtin-skills"),logsDir:z.join(n,"logs"),pluginsDir:z.join(n,"plugins"),plansDir:z.join(n,"plans"),harnessesDir:z.join(n,"harnesses"),subAgentsDir:z.join(n,"subagents"),beta:p,agents:ni(e.agents),memory:$l(e),skillEvolve:Xl(e,p),sessionRotate:zl(e),agentStop:Jl(e),asr:Ht(e),skills:Yo(e),askUser:sr(e,K.askUser),sessionTitle:Ql(e),requestMedia:$o(e.requestMedia),promptSuggestion:Zl(e),cli:ea(e),browser:si(e.browser),tui:Tt(e),telemetry:Gl(e.telemetry),opencode:Wt(e,K.opencode),contextManagement:na(e),runawayGuard:yo(e.runawayGuard),toolResultCompaction:ri(e.toolResultCompaction),agentRuntime:Wo(e.agentRuntime),logRetentionDays:oa(e),contentReview:ia(e),mcpToolSearch:ta(e),cuBackend:dn(e.cuBackend),review:Yt(e.review,K.review),worktreeRefreshBeforeCreate:e.worktreeRefreshBeforeCreate!==false,promptConfig:Ur(e.promptConfig),goal:l.config,goalWarnings:l.warnings,sandbox:di(e.sandbox)}}function Gl(e){if(e==null||typeof e!=="object"||Array.isArray(e)){return{...K.telemetry}}const n=Reflect.get(e,"enabled");return{enabled:typeof n==="boolean"?n:K.telemetry.enabled,metrics:Reflect.get(e,"metrics")===true,diagnostics:Reflect.get(e,"diagnostics")===true}}function $l(e){const n=e.memory;const i=n!=null&&typeof n==="object"&&!Array.isArray(n)?n:{};const t=i.dailyDigest;const r=t!=null&&typeof t==="object"&&!Array.isArray(t)?t:{};return{enabled:typeof i.enabled==="boolean"?i.enabled:K.memory.enabled,proactive:typeof i.proactive==="boolean"?i.proactive:K.memory.proactive,dailyDigest:{enabled:typeof r.enabled==="boolean"?r.enabled:K.memory.dailyDigest.enabled}}}function Yl(e){const n=e.beta!=null&&typeof e.beta==="object"&&!Array.isArray(e.beta)?e.beta:{};const i={buildEnv:fe(),defaultBuildEnvironment:mi(),internalBuild:bi(),insideBuild:vl(),mcodeToolsDevMode:process.env.MAVIS_DEV_MCODE_TOOLS_MODE==="published"?"published":void 0};const t={};for(const r of Object.keys(bn)){t[r]=yi(r,Wl(r,n),i)}return t}function Wl(e,n){if(e==="runCode"&&n.runCode===void 0&&process.env.MCODE_CODEMODE==="1"){return true}return n[e]}function ql(e){const n=e.provider;if(n==null||typeof n!=="object"||Array.isArray(n)){return[]}const i=[];for(const t of Object.values(n)){if(t==null||typeof t!=="object"||Array.isArray(t))continue;const{models:r}=t;if(r==null||typeof r!=="object"||Array.isArray(r))continue;i.push(...Object.keys(r))}return i}function Hl(e,n){if(n.length===0)return true;const i=ql(e);if(i.length===0)return false;const t=n.map(r=>r.toLowerCase());return!i.every(r=>t.some(l=>r.toLowerCase().startsWith(l)))}function _r(e,n){return typeof e==="number"&&Number.isFinite(e)&&e>0?e:n}function Xl(e,n){const i=K.skillEvolve;const t=e.skillEvolve;const r=t!=null&&typeof t==="object"&&!Array.isArray(t);const l=r?t:{};const a=l.inSession;let{inSession:c}=i;if(a!=null&&typeof a==="object"&&!Array.isArray(a)){const j=a;c={N:typeof j.N==="number"&&j.N>0?j.N:i.inSession.N,minIntervalSeconds:typeof j.minIntervalSeconds==="number"&&j.minIntervalSeconds>=0?j.minIntervalSeconds:i.inSession.minIntervalSeconds,maxPendingPerSession:typeof j.maxPendingPerSession==="number"&&j.maxPendingPerSession>=1?j.maxPendingPerSession:i.inSession.maxPendingPerSession}}const p=l.excludeAgents;const u=Array.isArray(p)&&p.every(j=>typeof j==="string")?p:i.excludeAgents;const d=Array.isArray(l.disableModelPrefixes)&&l.disableModelPrefixes.every(j=>typeof j==="string")?l.disableModelPrefixes:i.disableModelPrefixes;const h=!n.skillEvolve?false:typeof l.enabled==="boolean"?l.enabled:Hl(e,d);const R=!h?false:!n.skillEvolveBuiltinMr?false:typeof l.builtinMrEnabled==="boolean"?l.builtinMrEnabled:i.builtinMrEnabled;const k=l.sourceRepo;const D=typeof k==="string"&&k.trim().length>0?k.trim():i.sourceRepo;const I=l.proposal;const U=i.proposal;const L=I!=null&&typeof I==="object"&&!Array.isArray(I)?I:{};const B=Array.isArray(L.eligibleAgents)&&L.eligibleAgents.every(j=>typeof j==="string")?L.eligibleAgents:U.eligibleAgents;const $=typeof L.minMessageCount==="number"&&L.minMessageCount>=1?Math.floor(L.minMessageCount):U.minMessageCount;const Y=typeof L.skipPassiveSessionEnd==="boolean"?L.skipPassiveSessionEnd:U.skipPassiveSessionEnd;const ne=typeof L.enabled==="boolean"?L.enabled:null;const Je=!h?false:!n.skillProposal?false:ne??true;const me=l.lifecycle;const Ee=me&&typeof me==="object"&&!Array.isArray(me)?me:{};const se=_r(Ee.staleThresholdDays,i.lifecycle.staleThresholdDays);const Me=_r(Ee.archiveThresholdDays,i.lifecycle.archiveThresholdDays);if(!(se<Me)){throw new Error(`Invalid skillEvolve.lifecycle config: staleThresholdDays (${se}) must be strictly less than archiveThresholdDays (${Me}).`)}return{enabled:h,inSession:c,signalCooldownHours:typeof l.signalCooldownHours==="number"&&l.signalCooldownHours>0?l.signalCooldownHours:i.signalCooldownHours,minConfidence:typeof l.minConfidence==="number"&&l.minConfidence>=0&&l.minConfidence<=1?l.minConfidence:i.minConfidence,scannerModel:typeof l.scannerModel==="string"?l.scannerModel:void 0,excludeAgents:u,disableModelPrefixes:d,builtinMrEnabled:R,sourceRepo:D,proposal:{enabled:Je,eligibleAgents:B,minMessageCount:$,skipPassiveSessionEnd:Y},lifecycle:{staleThresholdDays:se,archiveThresholdDays:Me}}}function zl(e){const n=K.sessionRotate;const i=e.sessionRotate;if(i==null||typeof i!=="object"||Array.isArray(i))return{...n};const t=i;const r=t.activeSessionLookbackHours;return{enabled:typeof t.enabled==="boolean"?t.enabled:n.enabled,activeSessionLookbackHours:typeof r==="number"&&Number.isFinite(r)&&r>0?r:n.activeSessionLookbackHours}}function Jl(e){const n=K.agentStop;const i=e.agentStop;if(i==null||typeof i!=="object"||Array.isArray(i)){return{...n}}const t=i;const r=t.debounceMs;const l=t.maxActiveSpanMs;return{debounceMs:typeof r==="number"&&Number.isFinite(r)&&r>=0?r:n.debounceMs,maxActiveSpanMs:typeof l==="number"&&Number.isFinite(l)&&l>=0?l:n.maxActiveSpanMs}}function Ur(e){const n=fe()==="prod"&&!bi();if(e==null||typeof e!=="object"||Array.isArray(e)){return{autoUpdate:n}}const i=e.autoUpdate;return{autoUpdate:typeof i==="boolean"?i:n}}function Ql(e){const n=K.sessionTitle;const i=e.sessionTitle;if(i==null||typeof i!=="object"||Array.isArray(i)){return{...n}}const t=i;return{enabled:typeof t.enabled==="boolean"?t.enabled:n.enabled}}function Zl(e){const n=e.promptSuggestion;const i=n!=null&&typeof n==="object"&&!Array.isArray(n)?n.enabled:void 0;return typeof i==="boolean"?{enabled:i}:{}}function ea(e){const n=K.cli;const i=e.cli;if(i==null||typeof i!=="object"||Array.isArray(i)){return{spawn:{...n.spawn}}}const t=i.spawn;if(t==null||typeof t!=="object"||Array.isArray(t)){return{spawn:{...n.spawn}}}const r=t;return{spawn:{enabled:typeof r.enabled==="boolean"?r.enabled:n.spawn.enabled}}}function na(e){const n=K.contextManagement;const i=e.contextManagement;if(i==null||typeof i!=="object"||Array.isArray(i)){return{disableSystemReminderModels:[...n.disableSystemReminderModels],cuMaxScreenshotsInContext:n.cuMaxScreenshotsInContext}}const t=i;const r=t.disableSystemReminderModels;const l=Array.isArray(r)&&r.every(u=>typeof u==="string"&&u.length>0)?r:[...n.disableSystemReminderModels];const a=t.cuMaxScreenshotsInContext;const c=typeof a==="number"&&Number.isFinite(a)&&a>=0?Math.floor(a):n.cuMaxScreenshotsInContext;const p=typeof t.compactionTriggerAt==="number"?t.compactionTriggerAt:void 0;return{disableSystemReminderModels:l,cuMaxScreenshotsInContext:c,...p===void 0?{}:{compactionTriggerAt:p}}}function oa(e){const n=e.logRetentionDays;if(typeof n==="number"&&n>=1&&Number.isFinite(n)){return Math.floor(n)}return K.logRetentionDays}function ia(e){const n=e.contentReview;if(n==null||typeof n!=="object"||Array.isArray(n))return void 0;const i={};const t=Reflect.get(n,"enabled");if(typeof t==="boolean")i.enabled=t;const r=Reflect.get(n,"testBaseURL");if(typeof r==="string"&&r.trim()){i.testBaseURL=r.trim()}return Object.keys(i).length>0?i:void 0}function ta(e){const n=e.mcpToolSearch;if(n==null||typeof n!=="object"||Array.isArray(n))return void 0;const i={};const t=Reflect.get(n,"enabled");if(typeof t==="boolean")i.enabled=t;const r=Reflect.get(n,"systemHint");if(typeof r==="boolean")i.systemHint=r;const l=Reflect.get(n,"thresholdPct");if(typeof l==="number")i.thresholdPct=l;const a=Reflect.get(n,"minDeferCount");if(typeof a==="number")i.minDeferCount=a;const c=Reflect.get(n,"topKDefault");if(typeof c==="number")i.topKDefault=c;const p=Reflect.get(n,"topKMax");if(typeof p==="number")i.topKMax=p;const u=Reflect.get(n,"maxSchemaTextLen");if(typeof u==="number")i.maxSchemaTextLen=u;const d=Reflect.get(n,"modelWhitelist");if(Array.isArray(d)){i.modelWhitelist=d.filter(h=>typeof h==="string")}return Object.keys(i).length>0?i:void 0}function jr(){const e=Ir();if(Hn()&&!Or()){const n=Ie();if(n.autoDetected){return n.runtimePort}}return e??We}function ra(e=jr()){const n=e+wr;if(n<=fi){return n}const i=e+Cr;if(i<=fi){return i}throw new Error(`Cannot allocate an OpenCode sidecar port for runtime port ${String(e)}; choose a runtime port <= ${String(fi-Cr)}.`)}var sa=["MCODE_DISABLE_TELEMETRY","DO_NOT_TRACK"];function la(e,n=()=>_e().telemetry[e]){for(const i of sa){if(/^(?:1|true|yes|on)$/iu.test(process.env[i]?.trim()??""))return false}try{return n()===true}catch{return false}}function Vr(e){return false}function jc(e){return e.replace(/^#{2,4} MCP\/App citation examples\r?\n\r?\n```\r?\n[\s\S]*?^```\r?\n\s*/gm,n=>n.includes("#mavis-source=")?"":n).replace(/^#{2,4} Citations\r?\n(?:[ \t]*\r?\n)*Cite every used result where it supports the answer\.[\s\S]*?^Do not cite unused calls or unsupported claims, invent metadata, output bare parenthesized links, or add trailing source\/reference lists\.\r?\n*/gm,n=>n.includes("Citation candidate")?"":n)}function Vc(e){const n=["- Independent tool calls can run in parallel in one response.","- Issue independent tool calls together when safe. Run dependent calls or conflicting writes sequentially, and follow each tool's concurrency restrictions.",'- Tool selection for this turn is described in "Tool calls in this turn".'];const i=n.find(d=>e.includes(d));if(!i)return e;const t="- Reference code as `file_path:line_number` \u2014 it's clickable.";const r="- Reference code as `file_path:line_number` so it is clickable. Place references near the relevant claim; group them only when there are many files.";const l=["- Cite sources where they support the answer, using exact source URLs or supplied links.","- Place references near the relevant claim; group them only when there are many files.","- Cite only sources you used; do not invent sources or links."].join("\n");const a=["- When referencing code, use `file_path:line_number` format.","- When citing one or two files, place one or two `file_path:line_number` references in the relevant conclusion sentence. Use a separate evidence list only when there are many references.",t,"- Reference code as `file_path:line_number` \u2014 it's clickable in the TUI."];const c=a.reduce((d,h)=>d.replaceAll(`${h}\r
2
+ import{a as Pn,c as ln,e as Fe,n as Ue,o as po}from"./chunk-ISBSRM3S.js";import{n as go}from"./chunk-3MLT4F77.js";import{a as Ui}from"./chunk-4GGSPZK3.js";import{e as Fi}from"./chunk-FK3SSGJE.js";var ji={support_files_api:true,files_api_upload_endpoint:"/v1/files/upload",max_image_bytes_inline:10485760,max_video_bytes_inline:52428800,max_request_body_bytes:67108864,max_attachments_count:4,max_images_per_request:20};var je={"MiniMax-M3":{name:"MiniMax-M3",attachment:true,reasoning:true,tool_call:true,temperature:true,modalities:{input:["text","image","video"],output:["text"]},limit:{context:512e3,output:128e3},contextWindowOptions:[512e3,1e6],contextWindowOptionHints:{"1000000":"higher_usage"},options:{reasoningSummary:"auto"},thinking_config:{mode:"switchable",default_value:"true"},variants:{"none-thinking":{thinking:{type:"disabled"}},thinking:{thinking:{type:"adaptive"}}},capabilities:ji},"MiniMax-M3.1-Flash":{name:"M3.1-Flash",attachment:true,reasoning:true,tool_call:true,temperature:true,modalities:{input:["text","image","video"],output:["text"]},limit:{context:512e3,output:128e3},contextWindowOptions:[512e3,1e6],contextWindowOptionHints:{"1000000":"higher_usage"},options:{reasoningSummary:"auto"},thinking:{effortOptions:["default","low","medium","high","xhigh","max"],defaultEffort:"default"},thinking_config:{mode:"forced_on"},variants:{"none-thinking":{thinking:{type:"disabled"}},thinking:{thinking:{type:"adaptive"}}},capabilities:ji},"MiniMax-M2.7-highspeed":{name:"MiniMax-M2.7-highspeed",attachment:false,reasoning:true,tool_call:true,temperature:true,modalities:{input:["text"],output:["text"]},limit:{context:2e5,output:128e3}},"MiniMax-M2.7":{name:"MiniMax-M2.7",attachment:false,reasoning:true,tool_call:true,temperature:true,modalities:{input:["text"],output:["text"]},limit:{context:2e5,output:128e3}}};function mo(e){if(typeof e!=="object"||e===null||Array.isArray(e))return{};const n=e.enabled;return typeof n==="boolean"?{enabled:n}:{}}function yo(e,n){return{enabled:mo(n).enabled??mo(e).enabled??true}}import de from"node:fs";import ie from"node:fs";var Vi=384;function Ve(e){if(process.platform==="win32")return;const n=ie.statSync(e).mode;if((n&63)===0)return;ie.chmodSync(e,n&448)}function ue(e,n,i=false){const t=ie.constants.O_WRONLY|ie.constants.O_CREAT|(i?ie.constants.O_EXCL:0);const r=ie.openSync(e,t,Vi);try{ie.fchmodSync(r,Vi);ie.ftruncateSync(r,0);ie.writeFileSync(r,n)}finally{ie.closeSync(r)}}import z from"node:path";import bl from"node:os";import{spawnSync as hl}from"node:child_process";import{fileURLToPath as xl}from"node:url";function Cs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var q={};var Ln={};var Ce={};var Ki;function an(){if(Ki)return Ce;Ki=1;function e(a){return typeof a==="undefined"||a===null}function n(a){return typeof a==="object"&&a!==null}function i(a){if(Array.isArray(a))return a;else if(e(a))return[];return[a]}function t(a,c){if(c){const p=Object.keys(c);for(let u=0,d=p.length;u<d;u+=1){const h=p[u];a[h]=c[h]}}return a}function r(a,c){let p="";for(let u=0;u<c;u+=1){p+=a}return p}function l(a){return a===0&&Number.NEGATIVE_INFINITY===1/a}Ce.isNothing=e;Ce.isObject=n;Ce.toArray=i;Ce.repeat=r;Ce.isNegativeZero=l;Ce.extend=t;return Ce}var bo;var Gi;function un(){if(Gi)return bo;Gi=1;function e(i,t){let r="";const l=i.reason||"(unknown reason)";if(!i.mark)return l;if(i.mark.name){r+='in "'+i.mark.name+'" '}r+="("+(i.mark.line+1)+":"+(i.mark.column+1)+")";if(!t&&i.mark.snippet){r+="\n\n"+i.mark.snippet}return l+" "+r}function n(i,t){Error.call(this);this.name="YAMLException";this.reason=i;this.mark=t;this.message=e(this,false);if(Error.captureStackTrace){Error.captureStackTrace(this,this.constructor)}else{this.stack=new Error().stack||""}}n.prototype=Object.create(Error.prototype);n.prototype.constructor=n;n.prototype.toString=function i(t){return this.name+": "+e(this,t)};bo=n;return bo}var ho;var $i;function As(){if($i)return ho;$i=1;const e=an();function n(r,l,a,c,p){let u="";let d="";const h=Math.floor(p/2)-1;if(c-l>h){u=" ... ";l=c-h+u.length}if(a-c>h){d=" ...";a=c+h-d.length}return{str:u+r.slice(l,a).replace(/\t/g,"\u2192")+d,pos:c-l+u.length}}function i(r,l){return e.repeat(" ",l-r.length)+r}function t(r,l){l=Object.create(l||null);if(!r.buffer)return null;if(!l.maxLength)l.maxLength=79;if(typeof l.indent!=="number")l.indent=1;if(typeof l.linesBefore!=="number")l.linesBefore=3;if(typeof l.linesAfter!=="number")l.linesAfter=2;const a=/\r?\n|\r|\0/g;const c=[0];const p=[];let u;let d=-1;while(u=a.exec(r.buffer)){p.push(u.index);c.push(u.index+u[0].length);if(r.position<=u.index&&d<0){d=c.length-2}}if(d<0)d=c.length-1;let h="";const R=Math.min(r.line+l.linesAfter,p.length).toString().length;const k=l.maxLength-(l.indent+R+3);for(let I=1;I<=l.linesBefore;I++){if(d-I<0)break;const U=n(r.buffer,c[d-I],p[d-I],r.position-(c[d]-c[d-I]),k);h=e.repeat(" ",l.indent)+i((r.line-I+1).toString(),R)+" | "+U.str+"\n"+h}const D=n(r.buffer,c[d],p[d],r.position,k);h+=e.repeat(" ",l.indent)+i((r.line+1).toString(),R)+" | "+D.str+"\n";h+=e.repeat("-",l.indent+R+3+D.pos)+"^\n";for(let I=1;I<=l.linesAfter;I++){if(d+I>=p.length)break;const U=n(r.buffer,c[d+I],p[d+I],r.position-(c[d]-c[d+I]),k);h+=e.repeat(" ",l.indent)+i((r.line+I+1).toString(),R)+" | "+U.str+"\n"}return h.replace(/\n$/,"")}ho=t;return ho}var xo;var Yi;function X(){if(Yi)return xo;Yi=1;const e=un();const n=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"];const i=["scalar","sequence","mapping"];function t(l){const a={};if(l!==null){Object.keys(l).forEach(function(c){l[c].forEach(function(p){a[String(p)]=c})})}return a}function r(l,a){a=a||{};Object.keys(a).forEach(function(c){if(n.indexOf(c)===-1){throw new e('Unknown option "'+c+'" is met in definition of "'+l+'" YAML type.')}});this.options=a;this.tag=l;this.kind=a["kind"]||null;this.resolve=a["resolve"]||function(){return true};this.construct=a["construct"]||function(c){return c};this.instanceOf=a["instanceOf"]||null;this.predicate=a["predicate"]||null;this.represent=a["represent"]||null;this.representName=a["representName"]||null;this.defaultStyle=a["defaultStyle"]||null;this.multi=a["multi"]||false;this.styleAliases=t(a["styleAliases"]||null);if(i.indexOf(this.kind)===-1){throw new e('Unknown kind "'+this.kind+'" is specified for "'+l+'" YAML type.')}}xo=r;return xo}var Co;var Wi;function pt(){if(Wi)return Co;Wi=1;const e=un();const n=X();function i(l,a){const c=[];l[a].forEach(function(p){let u=c.length;c.forEach(function(d,h){if(d.tag===p.tag&&d.kind===p.kind&&d.multi===p.multi){u=h}});c[u]=p});return c}function t(){const l={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function a(c){if(c.multi){l.multi[c.kind].push(c);l.multi["fallback"].push(c)}else{l[c.kind][c.tag]=l["fallback"][c.tag]=c}}for(let c=0,p=arguments.length;c<p;c+=1){arguments[c].forEach(a)}return l}function r(l){return this.extend(l)}r.prototype.extend=function l(a){let c=[];let p=[];if(a instanceof n){p.push(a)}else if(Array.isArray(a)){p=p.concat(a)}else if(a&&(Array.isArray(a.implicit)||Array.isArray(a.explicit))){if(a.implicit)c=c.concat(a.implicit);if(a.explicit)p=p.concat(a.explicit)}else{throw new e("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })")}c.forEach(function(d){if(!(d instanceof n)){throw new e("Specified list of YAML types (or a single Type object) contains a non-Type object.")}if(d.loadKind&&d.loadKind!=="scalar"){throw new e("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}if(d.multi){throw new e("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}});p.forEach(function(d){if(!(d instanceof n)){throw new e("Specified list of YAML types (or a single Type object) contains a non-Type object.")}});const u=Object.create(r.prototype);u.implicit=(this.implicit||[]).concat(c);u.explicit=(this.explicit||[]).concat(p);u.compiledImplicit=i(u,"implicit");u.compiledExplicit=i(u,"explicit");u.compiledTypeMap=t(u.compiledImplicit,u.compiledExplicit);return u};Co=r;return Co}var Ao;var qi;function gt(){if(qi)return Ao;qi=1;const e=X();Ao=new e("tag:yaml.org,2002:str",{kind:"scalar",construct:function(n){return n!==null?n:""}});return Ao}var So;var Hi;function mt(){if(Hi)return So;Hi=1;const e=X();So=new e("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(n){return n!==null?n:[]}});return So}var _o;var Xi;function yt(){if(Xi)return _o;Xi=1;const e=X();_o=new e("tag:yaml.org,2002:map",{kind:"mapping",construct:function(n){return n!==null?n:{}}});return _o}var vo;var zi;function bt(){if(zi)return vo;zi=1;const e=pt();vo=new e({explicit:[gt(),mt(),yt()]});return vo}var Ro;var Ji;function ht(){if(Ji)return Ro;Ji=1;const e=X();function n(r){if(r===null)return true;const l=r.length;return l===1&&r==="~"||l===4&&(r==="null"||r==="Null"||r==="NULL")}function i(){return null}function t(r){return r===null}Ro=new e("tag:yaml.org,2002:null",{kind:"scalar",resolve:n,construct:i,predicate:t,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});return Ro}var Eo;var Qi;function xt(){if(Qi)return Eo;Qi=1;const e=X();function n(r){if(r===null)return false;const l=r.length;return l===4&&(r==="true"||r==="True"||r==="TRUE")||l===5&&(r==="false"||r==="False"||r==="FALSE")}function i(r){return r==="true"||r==="True"||r==="TRUE"}function t(r){return Object.prototype.toString.call(r)==="[object Boolean]"}Eo=new e("tag:yaml.org,2002:bool",{kind:"scalar",resolve:n,construct:i,predicate:t,represent:{lowercase:function(r){return r?"true":"false"},uppercase:function(r){return r?"TRUE":"FALSE"},camelcase:function(r){return r?"True":"False"}},defaultStyle:"lowercase"});return Eo}var Mo;var Zi;function Ct(){if(Zi)return Mo;Zi=1;const e=an();const n=X();function i(u){return u>=48&&u<=57||u>=65&&u<=70||u>=97&&u<=102}function t(u){return u>=48&&u<=55}function r(u){return u>=48&&u<=57}function l(u){if(u===null)return false;const d=u.length;let h=0;let R=false;if(!d)return false;let k=u[h];if(k==="-"||k==="+"){k=u[++h]}if(k==="0"){if(h+1===d)return true;k=u[++h];if(k==="b"){h++;for(;h<d;h++){k=u[h];if(k!=="0"&&k!=="1")return false;R=true}return R&&isFinite(a(u))}if(k==="x"){h++;for(;h<d;h++){if(!i(u.charCodeAt(h)))return false;R=true}return R&&isFinite(a(u))}if(k==="o"){h++;for(;h<d;h++){if(!t(u.charCodeAt(h)))return false;R=true}return R&&isFinite(a(u))}}for(;h<d;h++){if(!r(u.charCodeAt(h))){return false}R=true}if(!R)return false;return isFinite(a(u))}function a(u){let d=u;let h=1;let R=d[0];if(R==="-"||R==="+"){if(R==="-")h=-1;d=d.slice(1);R=d[0]}if(d==="0")return 0;if(R==="0"){if(d[1]==="b")return h*parseInt(d.slice(2),2);if(d[1]==="x")return h*parseInt(d.slice(2),16);if(d[1]==="o")return h*parseInt(d.slice(2),8)}return h*parseInt(d,10)}function c(u){return a(u)}function p(u){return Object.prototype.toString.call(u)==="[object Number]"&&(u%1===0&&!e.isNegativeZero(u))}Mo=new n("tag:yaml.org,2002:int",{kind:"scalar",resolve:l,construct:c,predicate:p,represent:{binary:function(u){return u>=0?"0b"+u.toString(2):"-0b"+u.toString(2).slice(1)},octal:function(u){return u>=0?"0o"+u.toString(8):"-0o"+u.toString(8).slice(1)},decimal:function(u){return u.toString(10)},hexadecimal:function(u){return u>=0?"0x"+u.toString(16).toUpperCase():"-0x"+u.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}});return Mo}var ko;var et;function At(){if(et)return ko;et=1;const e=an();const n=X();const i=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");const t=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function r(u){if(u===null)return false;if(!i.test(u)){return false}if(isFinite(parseFloat(u,10))){return true}return t.test(u)}function l(u){let d=u.toLowerCase();const h=d[0]==="-"?-1:1;if("+-".indexOf(d[0])>=0){d=d.slice(1)}if(d===".inf"){return h===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY}else if(d===".nan"){return NaN}return h*parseFloat(d,10)}const a=/^[-+]?[0-9]+e/;function c(u,d){if(isNaN(u)){switch(d){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}}else if(Number.POSITIVE_INFINITY===u){switch(d){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}}else if(Number.NEGATIVE_INFINITY===u){switch(d){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}}else if(e.isNegativeZero(u)){return"-0.0"}const h=u.toString(10);return a.test(h)?h.replace("e",".e"):h}function p(u){return Object.prototype.toString.call(u)==="[object Number]"&&(u%1!==0||e.isNegativeZero(u))}ko=new n("tag:yaml.org,2002:float",{kind:"scalar",resolve:r,construct:l,predicate:p,represent:c,defaultStyle:"lowercase"});return ko}var wo;var nt;function St(){if(nt)return wo;nt=1;wo=bt().extend({implicit:[ht(),xt(),Ct(),At()]});return wo}var To;var ot;function _t(){if(ot)return To;ot=1;To=St();return To}var Io;var it;function vt(){if(it)return Io;it=1;const e=X();const n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");const i=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function t(a){if(a===null)return false;if(n.exec(a)!==null)return true;if(i.exec(a)!==null)return true;return false}function r(a){let c=0;let p=null;let u=n.exec(a);if(u===null)u=i.exec(a);if(u===null)throw new Error("Date resolve error");const d=+u[1];const h=+u[2]-1;const R=+u[3];if(!u[4]){return new Date(Date.UTC(d,h,R))}const k=+u[4];const D=+u[5];const I=+u[6];if(u[7]){c=u[7].slice(0,3);while(c.length<3){c+="0"}c=+c}if(u[9]){const L=+u[10];const B=+(u[11]||0);p=(L*60+B)*6e4;if(u[9]==="-")p=-p}const U=new Date(Date.UTC(d,h,R,k,D,I,c));if(p)U.setTime(U.getTime()-p);return U}function l(a){return a.toISOString()}Io=new e("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:t,construct:r,instanceOf:Date,represent:l});return Io}var Oo;var tt;function Rt(){if(tt)return Oo;tt=1;const e=X();function n(i){return i==="<<"||i===null}Oo=new e("tag:yaml.org,2002:merge",{kind:"scalar",resolve:n});return Oo}var Po;var rt;function Et(){if(rt)return Po;rt=1;const e=X();const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";function i(a){if(a===null)return false;let c=0;const p=a.length;const u=n;for(let d=0;d<p;d++){const h=u.indexOf(a.charAt(d));if(h>64)continue;if(h<0)return false;c+=6}return c%8===0}function t(a){const c=a.replace(/[\r\n=]/g,"");const p=c.length;const u=n;let d=0;const h=[];for(let k=0;k<p;k++){if(k%4===0&&k){h.push(d>>16&255);h.push(d>>8&255);h.push(d&255)}d=d<<6|u.indexOf(c.charAt(k))}const R=p%4*6;if(R===0){h.push(d>>16&255);h.push(d>>8&255);h.push(d&255)}else if(R===18){h.push(d>>10&255);h.push(d>>2&255)}else if(R===12){h.push(d>>4&255)}return new Uint8Array(h)}function r(a){let c="";let p=0;const u=a.length;const d=n;for(let R=0;R<u;R++){if(R%3===0&&R){c+=d[p>>18&63];c+=d[p>>12&63];c+=d[p>>6&63];c+=d[p&63]}p=(p<<8)+a[R]}const h=u%3;if(h===0){c+=d[p>>18&63];c+=d[p>>12&63];c+=d[p>>6&63];c+=d[p&63]}else if(h===2){c+=d[p>>10&63];c+=d[p>>4&63];c+=d[p<<2&63];c+=d[64]}else if(h===1){c+=d[p>>2&63];c+=d[p<<4&63];c+=d[64];c+=d[64]}return c}function l(a){return Object.prototype.toString.call(a)==="[object Uint8Array]"}Po=new e("tag:yaml.org,2002:binary",{kind:"scalar",resolve:i,construct:t,predicate:l,represent:r});return Po}var Lo;var st;function Mt(){if(st)return Lo;st=1;const e=X();const n=Object.prototype.hasOwnProperty;const i=Object.prototype.toString;function t(l){if(l===null)return true;const a={};const c=l;for(let p=0,u=c.length;p<u;p+=1){const d=c[p];let h=false;if(i.call(d)!=="[object Object]")return false;let R;for(R in d){if(n.call(d,R)){if(!h)h=true;else return false}}if(!h)return false;if(n.call(a,R))return false;Object.defineProperty(a,R,{value:true})}return true}function r(l){return l!==null?l:[]}Lo=new e("tag:yaml.org,2002:omap",{kind:"sequence",resolve:t,construct:r});return Lo}var Do;var lt;function kt(){if(lt)return Do;lt=1;const e=X();const n=Object.prototype.toString;function i(r){if(r===null)return true;const l=r;const a=new Array(l.length);for(let c=0,p=l.length;c<p;c+=1){const u=l[c];if(n.call(u)!=="[object Object]")return false;const d=Object.keys(u);if(d.length!==1)return false;a[c]=[d[0],u[d[0]]]}return true}function t(r){if(r===null)return[];const l=r;const a=new Array(l.length);for(let c=0,p=l.length;c<p;c+=1){const u=l[c];const d=Object.keys(u);a[c]=[d[0],u[d[0]]]}return a}Do=new e("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:i,construct:t});return Do}var No;var at;function wt(){if(at)return No;at=1;const e=X();const n=Object.prototype.hasOwnProperty;function i(r){if(r===null)return true;const l=r;for(const a in l){if(n.call(l,a)){if(l[a]!==null)return false}}return true}function t(r){return r!==null?r:{}}No=new e("tag:yaml.org,2002:set",{kind:"mapping",resolve:i,construct:t});return No}var Bo;var ut;function Uo(){if(ut)return Bo;ut=1;Bo=_t().extend({implicit:[vt(),Rt()],explicit:[Et(),Mt(),kt(),wt()]});return Bo}var ct;function Ss(){if(ct)return Ln;ct=1;const e=an();const n=un();const i=As();const t=Uo();const r=Object.prototype.hasOwnProperty;const l=1;const a=2;const c=3;const p=4;const u=1;const d=2;const h=3;const R=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;const k=/[\x85\u2028\u2029]/;const D=/[,\[\]{}]/;const I=/^(?:!|!!|![0-9A-Za-z-]+!)$/;const U=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function L(o){return Object.prototype.toString.call(o)}function B(o){return o===10||o===13}function $(o){return o===9||o===32}function Y(o){return o===9||o===32||o===10||o===13}function ne(o){return o===44||o===91||o===93||o===123||o===125}function Je(o){if(o>=48&&o<=57){return o-48}const f=o|32;if(f>=97&&f<=102){return f-97+10}return-1}function me(o){if(o===120){return 2}if(o===117){return 4}if(o===85){return 8}return 0}function Ee(o){if(o>=48&&o<=57){return o-48}return-1}function se(o){switch(o){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return"\n";case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function Me(o){if(o<=65535){return String.fromCharCode(o)}return String.fromCharCode((o-65536>>10)+55296,(o-65536&1023)+56320)}function j(o,f,x){if(f==="__proto__"){Object.defineProperty(o,f,{configurable:true,enumerable:true,writable:true,value:x})}else{o[f]=x}}const Sn=new Array(256);const Qe=new Array(256);for(let o=0;o<256;o++){Sn[o]=se(o)?1:0;Qe[o]=se(o)}function W(o,f){this.input=o;this.filename=f["filename"]||null;this.schema=f["schema"]||t;this.onWarning=f["onWarning"]||null;this.legacy=f["legacy"]||false;this.json=f["json"]||false;this.listener=f["listener"]||null;this.maxDepth=typeof f["maxDepth"]==="number"?f["maxDepth"]:100;this.maxTotalMergeKeys=typeof f["maxTotalMergeKeys"]==="number"?f["maxTotalMergeKeys"]:1e4;this.implicitTypes=this.schema.compiledImplicit;this.typeMap=this.schema.compiledTypeMap;this.length=o.length;this.position=0;this.line=0;this.lineStart=0;this.lineIndent=0;this.depth=0;this.totalMergeKeys=0;this.firstTabInLine=-1;this.documents=[];this.anchorMapTransactions=[]}function _n(o,f){const x={name:o.filename,buffer:o.input.slice(0,-1),position:o.position,line:o.line,column:o.position-o.lineStart};x.snippet=i(x);return new n(f,x)}function M(o,f){throw _n(o,f)}function De(o,f){if(o.onWarning){o.onWarning.call(null,_n(o,f))}}function le(o,f,x){const C=o.anchorMapTransactions;if(C.length!==0){const y=C[C.length-1];if(!r.call(y,f)){y[f]={existed:r.call(o.anchorMap,f),value:o.anchorMap[f]}}}o.anchorMap[f]=x}function so(o){o.anchorMapTransactions.push(Object.create(null))}function ke(o){const f=o.anchorMapTransactions.pop();const x=o.anchorMapTransactions;if(x.length===0)return;const C=x[x.length-1];const y=Object.keys(f);for(let s=0,g=y.length;s<g;s+=1){const m=y[s];if(!r.call(C,m)){C[m]=f[m]}}}function lo(o){const f=o.anchorMapTransactions.pop();const x=Object.keys(f);for(let C=x.length-1;C>=0;C-=1){const y=f[x[C]];if(y.existed){o.anchorMap[x[C]]=y.value}else{delete o.anchorMap[x[C]]}}}function Ze(o){return{position:o.position,line:o.line,lineStart:o.lineStart,lineIndent:o.lineIndent,firstTabInLine:o.firstTabInLine,tag:o.tag,anchor:o.anchor,kind:o.kind,result:o.result}}function Ne(o,f){o.position=f.position;o.line=f.line;o.lineStart=f.lineStart;o.lineIndent=f.lineIndent;o.firstTabInLine=f.firstTabInLine;o.tag=f.tag;o.anchor=f.anchor;o.kind=f.kind;o.result=f.result}const vn={YAML:function o(f,x,C){if(f.version!==null){M(f,"duplication of %YAML directive")}if(C.length!==1){M(f,"YAML directive accepts exactly one argument")}const y=/^([0-9]+)\.([0-9]+)$/.exec(C[0]);if(y===null){M(f,"ill-formed argument of the YAML directive")}const s=parseInt(y[1],10);const g=parseInt(y[2],10);if(s!==1){M(f,"unacceptable YAML version of the document")}f.version=C[0];f.checkLineBreaks=g<2;if(g!==1&&g!==2){De(f,"unsupported YAML version of the document")}},TAG:function o(f,x,C){let y;if(C.length!==2){M(f,"TAG directive accepts exactly two arguments")}const s=C[0];y=C[1];if(!I.test(s)){M(f,"ill-formed tag handle (first argument) of the TAG directive")}if(r.call(f.tagMap,s)){M(f,'there is a previously declared suffix for "'+s+'" tag handle')}if(!U.test(y)){M(f,"ill-formed tag prefix (second argument) of the TAG directive")}try{y=decodeURIComponent(y)}catch(g){M(f,"tag prefix is malformed: "+y)}f.tagMap[s]=y}};function J(o,f,x,C){if(f<x){const y=o.input.slice(f,x);if(C){for(let s=0,g=y.length;s<g;s+=1){const m=y.charCodeAt(s);if(!(m===9||m>=32&&m<=1114111)){M(o,"expected valid JSON character")}}}else if(R.test(y)){M(o,"the stream contains non-printable characters")}o.result+=y}}function ye(o){o.totalMergeKeys++;if(o.maxTotalMergeKeys!==-1&&o.totalMergeKeys>o.maxTotalMergeKeys){M(o,"merge keys exceeded maxTotalMergeKeys ("+o.maxTotalMergeKeys+")")}}function en(o,f,x,C){if(!e.isObject(x)){M(o,"cannot merge mappings; the provided source object is unacceptable")}ye(o);const y=Object.keys(x);for(let s=0,g=y.length;s<g;s+=1){const m=y[s];ye(o);if(!r.call(f,m)){j(f,m,x[m]);C[m]=true}}}function ae(o,f,x,C,y,s,g,m,A){if(Array.isArray(y)){y=Array.prototype.slice.call(y);for(let S=0,_=y.length;S<_;S+=1){if(Array.isArray(y[S])){M(o,"nested arrays are not supported inside keys")}if(typeof y==="object"&&L(y[S])==="[object Object]"){y[S]="[object Object]"}}}if(typeof y==="object"&&L(y)==="[object Object]"){y="[object Object]"}y=String(y);if(f===null){f={}}if(C==="tag:yaml.org,2002:merge"){if(Array.isArray(s)){if(s.length>100){M(o,"abnormal merge sequence size")}for(let S=0,_=s.length;S<_;S+=1){en(o,f,s[S],x)}}else{en(o,f,s,x)}}else{if(!o.json&&!r.call(x,y)&&r.call(f,y)){o.line=g||o.line;o.lineStart=m||o.lineStart;o.position=A||o.position;M(o,"duplicated mapping key")}j(f,y,s);delete x[y]}return f}function nn(o){const f=o.input.charCodeAt(o.position);if(f===10){o.position++}else if(f===13){o.position++;if(o.input.charCodeAt(o.position)===10){o.position++}}else{M(o,"a line break is expected")}o.line+=1;o.lineStart=o.position;o.firstTabInLine=-1}function F(o,f,x){let C=0;let y=o.input.charCodeAt(o.position);while(y!==0){while($(y)){if(y===9&&o.firstTabInLine===-1){o.firstTabInLine=o.position}y=o.input.charCodeAt(++o.position)}if(f&&y===35){do{y=o.input.charCodeAt(++o.position)}while(y!==10&&y!==13&&y!==0)}if(B(y)){nn(o);y=o.input.charCodeAt(o.position);C++;o.lineIndent=0;while(y===32){o.lineIndent++;y=o.input.charCodeAt(++o.position)}}else{break}}if(x!==-1&&C!==0&&o.lineIndent<x){De(o,"deficient indentation")}return C}function oe(o){let f=o.position;let x=o.input.charCodeAt(f);if((x===45||x===46)&&x===o.input.charCodeAt(f+1)&&x===o.input.charCodeAt(f+2)){f+=3;x=o.input.charCodeAt(f);if(x===0||Y(x)){return true}}return false}function Be(o,f){if(f===1){o.result+=" "}else if(f>1){o.result+=e.repeat("\n",f-1)}}function Rn(o,f,x){let C;let y;let s;let g;let m;let A;const S=o.kind;const _=o.result;let b=o.input.charCodeAt(o.position);if(Y(b)||ne(b)||b===35||b===38||b===42||b===33||b===124||b===62||b===39||b===34||b===37||b===64||b===96){return false}if(b===63||b===45){const v=o.input.charCodeAt(o.position+1);if(Y(v)||x&&ne(v)){return false}}o.kind="scalar";o.result="";C=y=o.position;s=false;while(b!==0){if(b===58){const v=o.input.charCodeAt(o.position+1);if(Y(v)||x&&ne(v)){break}}else if(b===35){const v=o.input.charCodeAt(o.position-1);if(Y(v)){break}}else if(o.position===o.lineStart&&oe(o)||x&&ne(b)){break}else if(B(b)){g=o.line;m=o.lineStart;A=o.lineIndent;F(o,false,-1);if(o.lineIndent>=f){s=true;b=o.input.charCodeAt(o.position);continue}else{o.position=y;o.line=g;o.lineStart=m;o.lineIndent=A;break}}if(s){J(o,C,y,false);Be(o,o.line-g);C=y=o.position;s=false}if(!$(b)){y=o.position+1}b=o.input.charCodeAt(++o.position)}J(o,C,y,false);if(o.result){return true}o.kind=S;o.result=_;return false}function on(o,f){let x;let C;let y=o.input.charCodeAt(o.position);if(y!==39){return false}o.kind="scalar";o.result="";o.position++;x=C=o.position;while((y=o.input.charCodeAt(o.position))!==0){if(y===39){J(o,x,o.position,true);y=o.input.charCodeAt(++o.position);if(y===39){x=o.position;o.position++;C=o.position}else{return true}}else if(B(y)){J(o,x,C,true);Be(o,F(o,false,f));x=C=o.position}else if(o.position===o.lineStart&&oe(o)){M(o,"unexpected end of the document within a single quoted scalar")}else{o.position++;if(!$(y)){C=o.position}}}M(o,"unexpected end of the stream within a single quoted scalar")}function En(o,f){let x;let C;let y;let s=o.input.charCodeAt(o.position);if(s!==34){return false}o.kind="scalar";o.result="";o.position++;x=C=o.position;while((s=o.input.charCodeAt(o.position))!==0){if(s===34){J(o,x,o.position,true);o.position++;return true}else if(s===92){J(o,x,o.position,true);s=o.input.charCodeAt(++o.position);if(B(s)){F(o,false,f)}else if(s<256&&Sn[s]){o.result+=Qe[s];o.position++}else if((y=me(s))>0){let g=y;let m=0;for(;g>0;g--){s=o.input.charCodeAt(++o.position);if((y=Je(s))>=0){m=(m<<4)+y}else{M(o,"expected hexadecimal character")}}o.result+=Me(m);o.position++}else{M(o,"unknown escape sequence")}x=C=o.position}else if(B(s)){J(o,x,C,true);Be(o,F(o,false,f));x=C=o.position}else if(o.position===o.lineStart&&oe(o)){M(o,"unexpected end of the document within a double quoted scalar")}else{o.position++;if(!$(s)){C=o.position}}}M(o,"unexpected end of the stream within a double quoted scalar")}function Mn(o,f){let x=true;let C;let y;let s;const g=o.tag;let m;const A=o.anchor;let S;let _;let b;let v;const E=Object.create(null);let w;let T;let O;let P=o.input.charCodeAt(o.position);if(P===91){S=93;v=false;m=[]}else if(P===123){S=125;v=true;m={}}else{return false}if(o.anchor!==null){le(o,o.anchor,m)}P=o.input.charCodeAt(++o.position);while(P!==0){F(o,true,f);P=o.input.charCodeAt(o.position);if(P===S){o.position++;o.tag=g;o.anchor=A;o.kind=v?"mapping":"sequence";o.result=m;return true}else if(!x){M(o,"missed comma between flow collection entries")}else if(P===44){M(o,"expected the node content, but found ','")}T=w=O=null;_=b=false;if(P===63){const xe=o.input.charCodeAt(o.position+1);if(Y(xe)){_=b=true;o.position++;F(o,true,f)}}C=o.line;y=o.lineStart;s=o.position;he(o,f,l,false,true);T=o.tag;w=o.result;F(o,true,f);P=o.input.charCodeAt(o.position);if((b||o.line===C)&&P===58){_=true;P=o.input.charCodeAt(++o.position);F(o,true,f);he(o,f,l,false,true);O=o.result}if(v){ae(o,m,E,T,w,O,C,y,s)}else if(_){m.push(ae(o,null,E,T,w,O,C,y,s))}else{m.push(w)}F(o,true,f);P=o.input.charCodeAt(o.position);if(P===44){x=true;P=o.input.charCodeAt(++o.position)}else{x=false}}M(o,"unexpected end of the stream within a flow collection")}function be(o,f){let x;let C=u;let y=false;let s=false;let g=f;let m=0;let A=false;let S;let _=o.input.charCodeAt(o.position);if(_===124){x=false}else if(_===62){x=true}else{return false}o.kind="scalar";o.result="";while(_!==0){_=o.input.charCodeAt(++o.position);if(_===43||_===45){if(u===C){C=_===43?h:d}else{M(o,"repeat of a chomping mode identifier")}}else if((S=Ee(_))>=0){if(S===0){M(o,"bad explicit indentation width of a block scalar; it cannot be less than one")}else if(!s){g=f+S-1;s=true}else{M(o,"repeat of an indentation width identifier")}}else{break}}if($(_)){do{_=o.input.charCodeAt(++o.position)}while($(_));if(_===35){do{_=o.input.charCodeAt(++o.position)}while(!B(_)&&_!==0)}}while(_!==0){nn(o);o.lineIndent=0;_=o.input.charCodeAt(o.position);while((!s||o.lineIndent<g)&&_===32){o.lineIndent++;_=o.input.charCodeAt(++o.position)}if(!s&&o.lineIndent>g){g=o.lineIndent}if(B(_)){m++;continue}if(!s&&g===0){M(o,"missing indentation for block scalar")}if(o.lineIndent<g){if(C===h){o.result+=e.repeat("\n",y?1+m:m)}else if(C===u){if(y){o.result+="\n"}}break}if(x){if($(_)){A=true;o.result+=e.repeat("\n",y?1+m:m)}else if(A){A=false;o.result+=e.repeat("\n",m+1)}else if(m===0){if(y){o.result+=" "}}else{o.result+=e.repeat("\n",m)}}else{o.result+=e.repeat("\n",y?1+m:m)}y=true;s=true;m=0;const b=o.position;while(!B(_)&&_!==0){_=o.input.charCodeAt(++o.position)}J(o,b,o.position,false)}return true}function kn(o,f){const x=o.tag;const C=o.anchor;const y=[];let s=false;if(o.firstTabInLine!==-1)return false;if(o.anchor!==null){le(o,o.anchor,y)}let g=o.input.charCodeAt(o.position);while(g!==0){if(o.firstTabInLine!==-1){o.position=o.firstTabInLine;M(o,"tab characters must not be used in indentation")}if(g!==45){break}const m=o.input.charCodeAt(o.position+1);if(!Y(m)){break}s=true;o.position++;if(F(o,true,-1)){if(o.lineIndent<=f){y.push(null);g=o.input.charCodeAt(o.position);continue}}const A=o.line;he(o,f,c,false,true);y.push(o.result);F(o,true,-1);g=o.input.charCodeAt(o.position);if((o.line===A||o.lineIndent>f)&&g!==0){M(o,"bad indentation of a sequence entry")}else if(o.lineIndent<f){break}}if(s){o.tag=x;o.anchor=C;o.kind="sequence";o.result=y;return true}return false}function wn(o,f,x){let C;let y;let s;let g;const m=o.tag;const A=o.anchor;const S={};const _=Object.create(null);let b=null;let v=null;let E=null;let w=false;let T=false;if(o.firstTabInLine!==-1)return false;if(o.anchor!==null){le(o,o.anchor,S)}let O=o.input.charCodeAt(o.position);while(O!==0){if(!w&&o.firstTabInLine!==-1){o.position=o.firstTabInLine;M(o,"tab characters must not be used in indentation")}const P=o.input.charCodeAt(o.position+1);const xe=o.line;if((O===63||O===58)&&Y(P)){if(O===63){if(w){ae(o,S,_,b,v,null,y,s,g);b=v=E=null}T=true;w=true;C=true}else if(w){w=false;C=true}else{M(o,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line")}o.position+=1;O=P}else{y=o.line;s=o.lineStart;g=o.position;if(!he(o,x,a,false,true)){break}if(o.line===xe){O=o.input.charCodeAt(o.position);while($(O)){O=o.input.charCodeAt(++o.position)}if(O===58){O=o.input.charCodeAt(++o.position);if(!Y(O)){M(o,"a whitespace character is expected after the key-value separator within a block mapping")}if(w){ae(o,S,_,b,v,null,y,s,g);b=v=E=null}T=true;w=false;C=false;b=o.tag;v=o.result}else if(T){M(o,"can not read an implicit mapping pair; a colon is missed")}else{o.tag=m;o.anchor=A;return true}}else if(T){M(o,"can not read a block mapping entry; a multiline key may not be an implicit key")}else{o.tag=m;o.anchor=A;return true}}if(o.line===xe||o.lineIndent>f){if(w){y=o.line;s=o.lineStart;g=o.position}if(he(o,f,p,true,C)){if(w){v=o.result}else{E=o.result}}if(!w){ae(o,S,_,b,v,E,y,s,g);b=v=E=null}F(o,true,-1);O=o.input.charCodeAt(o.position)}if((o.line===xe||o.lineIndent>f)&&O!==0){M(o,"bad indentation of a mapping entry")}else if(o.lineIndent<f){break}}if(w){ae(o,S,_,b,v,null,y,s,g)}if(T){o.tag=m;o.anchor=A;o.kind="mapping";o.result=S}return T}function Tn(o){let f=false;let x=false;let C;let y;let s=o.input.charCodeAt(o.position);if(s!==33)return false;if(o.tag!==null){M(o,"duplication of a tag property")}s=o.input.charCodeAt(++o.position);if(s===60){f=true;s=o.input.charCodeAt(++o.position)}else if(s===33){x=true;C="!!";s=o.input.charCodeAt(++o.position)}else{C="!"}let g=o.position;if(f){do{s=o.input.charCodeAt(++o.position)}while(s!==0&&s!==62);if(o.position<o.length){y=o.input.slice(g,o.position);s=o.input.charCodeAt(++o.position)}else{M(o,"unexpected end of the stream within a verbatim tag")}}else{while(s!==0&&!Y(s)){if(s===33){if(!x){C=o.input.slice(g-1,o.position+1);if(!I.test(C)){M(o,"named tag handle cannot contain such characters")}x=true;g=o.position+1}else{M(o,"tag suffix cannot contain exclamation marks")}}s=o.input.charCodeAt(++o.position)}y=o.input.slice(g,o.position);if(D.test(y)){M(o,"tag suffix cannot contain flow indicator characters")}}if(y&&!U.test(y)){M(o,"tag name cannot contain such characters: "+y)}try{y=decodeURIComponent(y)}catch(m){M(o,"tag name is malformed: "+y)}if(f){o.tag=y}else if(r.call(o.tagMap,C)){o.tag=o.tagMap[C]+y}else if(C==="!"){o.tag="!"+y}else if(C==="!!"){o.tag="tag:yaml.org,2002:"+y}else{M(o,'undeclared tag handle "'+C+'"')}return true}function In(o){let f=o.input.charCodeAt(o.position);if(f!==38)return false;if(o.anchor!==null){M(o,"duplication of an anchor property")}f=o.input.charCodeAt(++o.position);const x=o.position;while(f!==0&&!Y(f)&&!ne(f)){f=o.input.charCodeAt(++o.position)}if(o.position===x){M(o,"name of an anchor node must contain at least one character")}o.anchor=o.input.slice(x,o.position);return true}function ao(o){let f=o.input.charCodeAt(o.position);if(f!==42)return false;f=o.input.charCodeAt(++o.position);const x=o.position;while(f!==0&&!Y(f)&&!ne(f)){f=o.input.charCodeAt(++o.position)}if(o.position===x){M(o,"name of an alias node must contain at least one character")}const C=o.input.slice(x,o.position);if(!r.call(o.anchorMap,C)){M(o,'unidentified alias "'+C+'"')}o.result=o.anchorMap[C];F(o,true,-1);return true}function On(o,f,x,C){const y=Ze(o);so(o);Ne(o,f);o.tag=null;o.anchor=null;o.kind=null;o.result=null;if(wn(o,x,C)&&o.kind==="mapping"){ke(o);return true}lo(o);Ne(o,y);return false}function he(o,f,x,C,y){let s;let g;let m=1;let A=false;let S=false;let _=null;let b;let v;let E;if(o.depth>=o.maxDepth){M(o,"nesting exceeded maxDepth ("+o.maxDepth+")")}o.depth+=1;if(o.listener!==null){o.listener("open",o)}o.tag=null;o.anchor=null;o.kind=null;o.result=null;const w=s=g=p===x||c===x;if(C){if(F(o,true,-1)){A=true;if(o.lineIndent>f){m=1}else if(o.lineIndent===f){m=0}else if(o.lineIndent<f){m=-1}}}if(m===1){while(true){const T=o.input.charCodeAt(o.position);const O=Ze(o);if(A&&(T===33&&o.tag!==null||T===38&&o.anchor!==null)){break}if(!Tn(o)&&!In(o)){break}if(_===null){_=O}if(F(o,true,-1)){A=true;g=w;if(o.lineIndent>f){m=1}else if(o.lineIndent===f){m=0}else if(o.lineIndent<f){m=-1}}else{g=false}}}if(g){g=A||y}if(m===1||p===x){if(l===x||a===x){v=f}else{v=f+1}E=o.position-o.lineStart;if(m===1){if(g&&(kn(o,E)||wn(o,E,v))||Mn(o,v)){S=true}else{const T=o.input.charCodeAt(o.position);if(_!==null&&w&&!g&&T!==124&&T!==62&&On(o,_,_.position-_.lineStart,v)){S=true}else if(s&&be(o,v)||on(o,v)||En(o,v)){S=true}else if(ao(o)){S=true;if(o.tag!==null||o.anchor!==null){M(o,"alias node should not have any properties")}}else if(Rn(o,v,l===x)){S=true;if(o.tag===null){o.tag="?"}}if(o.anchor!==null){le(o,o.anchor,o.result)}}}else if(m===0){S=g&&kn(o,E)}}if(o.tag===null){if(o.anchor!==null){le(o,o.anchor,o.result)}}else if(o.tag==="?"){if(o.result!==null&&o.kind!=="scalar"){M(o,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+o.kind+'"')}for(let T=0,O=o.implicitTypes.length;T<O;T+=1){b=o.implicitTypes[T];if(b.resolve(o.result)){o.result=b.construct(o.result);o.tag=b.tag;if(o.anchor!==null){le(o,o.anchor,o.result)}break}}}else if(o.tag!=="!"){if(r.call(o.typeMap[o.kind||"fallback"],o.tag)){b=o.typeMap[o.kind||"fallback"][o.tag]}else{b=null;const T=o.typeMap.multi[o.kind||"fallback"];for(let O=0,P=T.length;O<P;O+=1){if(o.tag.slice(0,T[O].tag.length)===T[O].tag){b=T[O];break}}}if(!b){M(o,"unknown tag !<"+o.tag+">")}if(o.result!==null&&b.kind!==o.kind){M(o,"unacceptable node kind for !<"+o.tag+'> tag; it should be "'+b.kind+'", not "'+o.kind+'"')}if(!b.resolve(o.result,o.tag)){M(o,"cannot resolve a node with !<"+o.tag+"> explicit tag")}else{o.result=b.construct(o.result,o.tag);if(o.anchor!==null){le(o,o.anchor,o.result)}}}if(o.listener!==null){o.listener("close",o)}o.depth-=1;return o.tag!==null||o.anchor!==null||S}function uo(o){const f=o.position;let x=false;let C;o.version=null;o.checkLineBreaks=o.legacy;o.tagMap=Object.create(null);o.anchorMap=Object.create(null);while((C=o.input.charCodeAt(o.position))!==0){F(o,true,-1);C=o.input.charCodeAt(o.position);if(o.lineIndent>0||C!==37){break}x=true;C=o.input.charCodeAt(++o.position);let y=o.position;while(C!==0&&!Y(C)){C=o.input.charCodeAt(++o.position)}const s=o.input.slice(y,o.position);const g=[];if(s.length<1){M(o,"directive name must not be less than one character in length")}while(C!==0){while($(C)){C=o.input.charCodeAt(++o.position)}if(C===35){do{C=o.input.charCodeAt(++o.position)}while(C!==0&&!B(C));break}if(B(C))break;y=o.position;while(C!==0&&!Y(C)){C=o.input.charCodeAt(++o.position)}g.push(o.input.slice(y,o.position))}if(C!==0)nn(o);if(r.call(vn,s)){vn[s](o,s,g)}else{De(o,'unknown document directive "'+s+'"')}}F(o,true,-1);if(o.lineIndent===0&&o.input.charCodeAt(o.position)===45&&o.input.charCodeAt(o.position+1)===45&&o.input.charCodeAt(o.position+2)===45){o.position+=3;F(o,true,-1)}else if(x){M(o,"directives end mark is expected")}he(o,o.lineIndent-1,p,false,true);F(o,true,-1);if(o.checkLineBreaks&&k.test(o.input.slice(f,o.position))){De(o,"non-ASCII line breaks are interpreted as content")}o.documents.push(o.result);if(o.position===o.lineStart&&oe(o)){if(o.input.charCodeAt(o.position)===46){o.position+=3;F(o,true,-1)}return}if(o.position<o.length-1){M(o,"end of the stream or a document separator is expected")}}function tn(o,f){o=String(o);f=f||{};if(o.length!==0){if(o.charCodeAt(o.length-1)!==10&&o.charCodeAt(o.length-1)!==13){o+="\n"}if(o.charCodeAt(0)===65279){o=o.slice(1)}}const x=new W(o,f);const C=o.indexOf("\0");if(C!==-1){x.position=C;M(x,"null byte is not allowed in input")}x.input+="\0";while(x.input.charCodeAt(x.position)===32){x.lineIndent+=1;x.position+=1}while(x.position<x.length-1){uo(x)}return x.documents}function co(o,f,x){if(f!==null&&typeof f==="object"&&typeof x==="undefined"){x=f;f=null}const C=tn(o,x);if(typeof f!=="function"){return C}for(let y=0,s=C.length;y<s;y+=1){f(C[y])}}function fo(o,f){const x=tn(o,f);if(x.length===0){return void 0}else if(x.length===1){return x[0]}throw new n("expected a single document in the stream, but found more")}Ln.loadAll=co;Ln.load=fo;return Ln}var Fo={};var dt;function _s(){if(dt)return Fo;dt=1;const e=an();const n=un();const i=Uo();const t=Object.prototype.toString;const r=Object.prototype.hasOwnProperty;const l=65279;const a=9;const c=10;const p=13;const u=32;const d=33;const h=34;const R=35;const k=37;const D=38;const I=39;const U=42;const L=44;const B=45;const $=58;const Y=61;const ne=62;const Je=63;const me=64;const Ee=91;const se=93;const Me=96;const j=123;const Sn=124;const Qe=125;const W={};W[0]="\\0";W[7]="\\a";W[8]="\\b";W[9]="\\t";W[10]="\\n";W[11]="\\v";W[12]="\\f";W[13]="\\r";W[27]="\\e";W[34]='\\"';W[92]="\\\\";W[133]="\\N";W[160]="\\_";W[8232]="\\L";W[8233]="\\P";const _n=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];const M=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function De(s,g){if(g===null)return{};const m={};const A=Object.keys(g);for(let S=0,_=A.length;S<_;S+=1){let b=A[S];let v=String(g[b]);if(b.slice(0,2)==="!!"){b="tag:yaml.org,2002:"+b.slice(2)}const E=s.compiledTypeMap["fallback"][b];if(E&&r.call(E.styleAliases,v)){v=E.styleAliases[v]}m[b]=v}return m}function le(s){let g;let m;const A=s.toString(16).toUpperCase();if(s<=255){g="x";m=2}else if(s<=65535){g="u";m=4}else if(s<=4294967295){g="U";m=8}else{throw new n("code point within a string may not be greater than 0xFFFFFFFF")}return"\\"+g+e.repeat("0",m-A.length)+A}const so=1;const ke=2;function lo(s){this.schema=s["schema"]||i;this.indent=Math.max(1,s["indent"]||2);this.noArrayIndent=s["noArrayIndent"]||false;this.skipInvalid=s["skipInvalid"]||false;this.flowLevel=e.isNothing(s["flowLevel"])?-1:s["flowLevel"];this.styleMap=De(this.schema,s["styles"]||null);this.sortKeys=s["sortKeys"]||false;this.lineWidth=s["lineWidth"]||80;this.noRefs=s["noRefs"]||false;this.noCompatMode=s["noCompatMode"]||false;this.condenseFlow=s["condenseFlow"]||false;this.quotingType=s["quotingType"]==='"'?ke:so;this.forceQuotes=s["forceQuotes"]||false;this.replacer=typeof s["replacer"]==="function"?s["replacer"]:null;this.implicitTypes=this.schema.compiledImplicit;this.explicitTypes=this.schema.compiledExplicit;this.tag=null;this.result="";this.duplicates=[];this.usedDuplicates=null}function Ze(s,g){const m=e.repeat(" ",g);let A=0;let S="";const _=s.length;while(A<_){let b;const v=s.indexOf("\n",A);if(v===-1){b=s.slice(A);A=_}else{b=s.slice(A,v+1);A=v+1}if(b.length&&b!=="\n")S+=m;S+=b}return S}function Ne(s,g){return"\n"+e.repeat(" ",s.indent*g)}function vn(s,g){for(let m=0,A=s.implicitTypes.length;m<A;m+=1){const S=s.implicitTypes[m];if(S.resolve(g)){return true}}return false}function J(s){return s===u||s===a}function ye(s){return s>=32&&s<=126||s>=161&&s<=55295&&s!==8232&&s!==8233||s>=57344&&s<=65533&&s!==l||s>=65536&&s<=1114111}function en(s){return ye(s)&&s!==l&&s!==p&&s!==c}function ae(s,g,m){const A=en(s);const S=A&&!J(s);return(m?A:A&&s!==L&&s!==Ee&&s!==se&&s!==j&&s!==Qe)&&s!==R&&!(g===$&&!S)||en(g)&&!J(g)&&s===R||g===$&&S}function nn(s){return ye(s)&&s!==l&&!J(s)&&s!==B&&s!==Je&&s!==$&&s!==L&&s!==Ee&&s!==se&&s!==j&&s!==Qe&&s!==R&&s!==D&&s!==U&&s!==d&&s!==Sn&&s!==Y&&s!==ne&&s!==I&&s!==h&&s!==k&&s!==me&&s!==Me}function F(s){return!J(s)&&s!==$}function oe(s,g){const m=s.charCodeAt(g);let A;if(m>=55296&&m<=56319&&g+1<s.length){A=s.charCodeAt(g+1);if(A>=56320&&A<=57343){return(m-55296)*1024+A-56320+65536}}return m}function Be(s){const g=/^\n* /;return g.test(s)}const Rn=1;const on=2;const En=3;const Mn=4;const be=5;function kn(s,g,m,A,S,_,b,v){let E;let w=0;let T=null;let O=false;let P=false;const xe=A!==-1;let rn=-1;let sn=nn(oe(s,0))&&F(oe(s,s.length-1));if(g||b){for(E=0;E<s.length;w>=65536?E+=2:E++){w=oe(s,E);if(!ye(w)){return be}sn=sn&&ae(w,T,v);T=w}}else{for(E=0;E<s.length;w>=65536?E+=2:E++){w=oe(s,E);if(w===c){O=true;if(xe){P=P||E-rn-1>A&&s[rn+1]!==" ";rn=E}}else if(!ye(w)){return be}sn=sn&&ae(w,T,v);T=w}P=P||xe&&(E-rn-1>A&&s[rn+1]!==" ")}if(!O&&!P){if(sn&&!b&&!S(s)){return Rn}return _===ke?be:on}if(m>9&&Be(s)){return be}if(!b){return P?Mn:En}return _===ke?be:on}function wn(s,g,m,A,S){s.dump=(function(){if(g.length===0){return s.quotingType===ke?'""':"''"}if(!s.noCompatMode){if(_n.indexOf(g)!==-1||M.test(g)){return s.quotingType===ke?'"'+g+'"':"'"+g+"'"}}const _=s.indent*Math.max(1,m);const b=s.lineWidth===-1?-1:Math.max(Math.min(s.lineWidth,40),s.lineWidth-_);const v=A||s.flowLevel>-1&&m>=s.flowLevel;function E(w){return vn(s,w)}switch(kn(g,v,s.indent,b,E,s.quotingType,s.forceQuotes&&!A,S)){case Rn:return g;case on:return"'"+g.replace(/'/g,"''")+"'";case En:return"|"+Tn(g,s.indent)+In(Ze(g,_));case Mn:return">"+Tn(g,s.indent)+In(Ze(ao(g,b),_));case be:return'"'+he(g)+'"';default:throw new n("impossible error: invalid scalar style")}})()}function Tn(s,g){const m=Be(s)?String(g):"";const A=s[s.length-1]==="\n";const S=A&&(s[s.length-2]==="\n"||s==="\n");const _=S?"+":A?"":"-";return m+_+"\n"}function In(s){return s[s.length-1]==="\n"?s.slice(0,-1):s}function ao(s,g){const m=/(\n+)([^\n]*)/g;let A=(function(){let v=s.indexOf("\n");v=v!==-1?v:s.length;m.lastIndex=v;return On(s.slice(0,v),g)})();let S=s[0]==="\n"||s[0]===" ";let _;let b;while(b=m.exec(s)){const v=b[1];const E=b[2];_=E[0]===" ";A+=v+(!S&&!_&&E!==""?"\n":"")+On(E,g);S=_}return A}function On(s,g){if(s===""||s[0]===" ")return s;const m=/ [^ ]/g;let A;let S=0;let _;let b=0;let v=0;let E="";while(A=m.exec(s)){v=A.index;if(v-S>g){_=b>S?b:v;E+="\n"+s.slice(S,_);S=_+1}b=v}E+="\n";if(s.length-S>g&&b>S){E+=s.slice(S,b)+"\n"+s.slice(b+1)}else{E+=s.slice(S)}return E.slice(1)}function he(s){let g="";let m=0;for(let A=0;A<s.length;m>=65536?A+=2:A++){m=oe(s,A);const S=W[m];if(!S&&ye(m)){g+=s[A];if(m>=65536)g+=s[A+1]}else{g+=S||le(m)}}return g}function uo(s,g,m){let A="";const S=s.tag;for(let _=0,b=m.length;_<b;_+=1){let v=m[_];if(s.replacer){v=s.replacer.call(m,String(_),v)}if(f(s,g,v,false,false)||typeof v==="undefined"&&f(s,g,null,false,false)){if(A!=="")A+=","+(!s.condenseFlow?" ":"");A+=s.dump}}s.tag=S;s.dump="["+A+"]"}function tn(s,g,m,A){let S="";const _=s.tag;for(let b=0,v=m.length;b<v;b+=1){let E=m[b];if(s.replacer){E=s.replacer.call(m,String(b),E)}if(f(s,g+1,E,true,true,false,true)||typeof E==="undefined"&&f(s,g+1,null,true,true,false,true)){if(!A||S!==""){S+=Ne(s,g)}if(s.dump&&c===s.dump.charCodeAt(0)){S+="-"}else{S+="- "}S+=s.dump}}s.tag=_;s.dump=S||"[]"}function co(s,g,m){let A="";const S=s.tag;const _=Object.keys(m);for(let b=0,v=_.length;b<v;b+=1){let E="";if(A!=="")E+=", ";if(s.condenseFlow)E+='"';const w=_[b];let T=m[w];if(s.replacer){T=s.replacer.call(m,w,T)}if(!f(s,g,w,false,false)){continue}if(s.dump.length>1024)E+="? ";E+=s.dump+(s.condenseFlow?'"':"")+":"+(s.condenseFlow?"":" ");if(!f(s,g,T,false,false)){continue}E+=s.dump;A+=E}s.tag=S;s.dump="{"+A+"}"}function fo(s,g,m,A){let S="";const _=s.tag;const b=Object.keys(m);if(s.sortKeys===true){b.sort()}else if(typeof s.sortKeys==="function"){b.sort(s.sortKeys)}else if(s.sortKeys){throw new n("sortKeys must be a boolean or a function")}for(let v=0,E=b.length;v<E;v+=1){let w="";if(!A||S!==""){w+=Ne(s,g)}const T=b[v];let O=m[T];if(s.replacer){O=s.replacer.call(m,T,O)}if(!f(s,g+1,T,true,true,true)){continue}const P=s.tag!==null&&s.tag!=="?"||s.dump&&s.dump.length>1024;if(P){if(s.dump&&c===s.dump.charCodeAt(0)){w+="?"}else{w+="? "}}w+=s.dump;if(P){w+=Ne(s,g)}if(!f(s,g+1,O,true,P)){continue}if(s.dump&&c===s.dump.charCodeAt(0)){w+=":"}else{w+=": "}w+=s.dump;S+=w}s.tag=_;s.dump=S||"{}"}function o(s,g,m){const A=m?s.explicitTypes:s.implicitTypes;for(let S=0,_=A.length;S<_;S+=1){const b=A[S];if((b.instanceOf||b.predicate)&&(!b.instanceOf||typeof g==="object"&&g instanceof b.instanceOf)&&(!b.predicate||b.predicate(g))){if(m){if(b.multi&&b.representName){s.tag=b.representName(g)}else{s.tag=b.tag}}else{s.tag="?"}if(b.represent){const v=s.styleMap[b.tag]||b.defaultStyle;let E;if(t.call(b.represent)==="[object Function]"){E=b.represent(g,v)}else if(r.call(b.represent,v)){E=b.represent[v](g,v)}else{throw new n("!<"+b.tag+'> tag resolver accepts not "'+v+'" style')}s.dump=E}return true}}return false}function f(s,g,m,A,S,_,b){s.tag=null;s.dump=m;if(!o(s,m,false)){o(s,m,true)}const v=t.call(s.dump);const E=A;if(A){A=s.flowLevel<0||s.flowLevel>g}const w=v==="[object Object]"||v==="[object Array]";let T;let O;if(w){T=s.duplicates.indexOf(m);O=T!==-1}if(s.tag!==null&&s.tag!=="?"||O||s.indent!==2&&g>0){S=false}if(O&&s.usedDuplicates[T]){s.dump="*ref_"+T}else{if(w&&O&&!s.usedDuplicates[T]){s.usedDuplicates[T]=true}if(v==="[object Object]"){if(A&&Object.keys(s.dump).length!==0){fo(s,g,s.dump,S);if(O){s.dump="&ref_"+T+s.dump}}else{co(s,g,s.dump);if(O){s.dump="&ref_"+T+" "+s.dump}}}else if(v==="[object Array]"){if(A&&s.dump.length!==0){if(s.noArrayIndent&&!b&&g>0){tn(s,g-1,s.dump,S)}else{tn(s,g,s.dump,S)}if(O){s.dump="&ref_"+T+s.dump}}else{uo(s,g,s.dump);if(O){s.dump="&ref_"+T+" "+s.dump}}}else if(v==="[object String]"){if(s.tag!=="?"){wn(s,s.dump,g,_,E)}}else if(v==="[object Undefined]"){return false}else{if(s.skipInvalid)return false;throw new n("unacceptable kind of an object to dump "+v)}if(s.tag!==null&&s.tag!=="?"){let P=encodeURI(s.tag[0]==="!"?s.tag.slice(1):s.tag).replace(/!/g,"%21");if(s.tag[0]==="!"){P="!"+P}else if(P.slice(0,18)==="tag:yaml.org,2002:"){P="!!"+P.slice(18)}else{P="!<"+P+">"}s.dump=P+" "+s.dump}}return true}function x(s,g){const m=[];const A=[];C(s,m,A);const S=A.length;for(let _=0;_<S;_+=1){g.duplicates.push(m[A[_]])}g.usedDuplicates=new Array(S)}function C(s,g,m){if(s!==null&&typeof s==="object"){const A=g.indexOf(s);if(A!==-1){if(m.indexOf(A)===-1){m.push(A)}}else{g.push(s);if(Array.isArray(s)){for(let S=0,_=s.length;S<_;S+=1){C(s[S],g,m)}}else{const S=Object.keys(s);for(let _=0,b=S.length;_<b;_+=1){C(s[S[_]],g,m)}}}}}function y(s,g){g=g||{};const m=new lo(g);if(!m.noRefs)x(s,m);let A=s;if(m.replacer){A=m.replacer.call({"":A},"",A)}if(f(m,0,A,true,true))return m.dump+"\n";return""}Fo.dump=y;return Fo}var ft;function vs(){if(ft)return q;ft=1;const e=Ss();const n=_s();function i(t,r){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+r+" instead, which is now safe by default.")}}q.Type=X();q.Schema=pt();q.FAILSAFE_SCHEMA=bt();q.JSON_SCHEMA=St();q.CORE_SCHEMA=_t();q.DEFAULT_SCHEMA=Uo();q.load=e.load;q.loadAll=e.loadAll;q.dump=n.dump;q.YAMLException=un();q.types={binary:Et(),float:At(),map:yt(),null:ht(),pairs:kt(),set:wt(),timestamp:vt(),bool:xt(),int:Ct(),merge:Rt(),omap:Mt(),seq:mt(),str:gt()};q.safeLoad=i("safeLoad","load");q.safeLoadAll=i("safeLoadAll","loadAll");q.safeDump=i("safeDump","dump");return q}var Rs=vs();var V=Cs(Rs);var{Type:Eu,Schema:Mu,FAILSAFE_SCHEMA:ku,JSON_SCHEMA:wu,CORE_SCHEMA:Tu,DEFAULT_SCHEMA:Iu,load:Ou,loadAll:Pu,dump:Lu,YAMLException:Du,types:Nu,safeLoad:Bu,safeLoadAll:Fu,safeDump:Uu}=V;function Tt(e){const n=e.tui;if(n==null||typeof n!=="object"||Array.isArray(n))return{};const i=n;const t=i.notifications;let r;if(t&&typeof t==="object"&&!Array.isArray(t)){const{when:p,method:u,events:d}=t;r={...p==="unfocused"||p==="always"||p==="never"?{when:p}:{},...u==="auto"||u==="osc9"||u==="osc777"||u==="bel"?{method:u}:{},...Array.isArray(d)?{events:d.filter(h=>typeof h==="string")}:{}}}const l=i.statusLine;const a=Array.isArray(l)?l.filter(p=>typeof p==="string").map(p=>p.trim()).filter(Boolean):void 0;const c=Es(i.customStatusLine);return{...i.terminalTitle===null?{terminalTitle:null}:Array.isArray(i.terminalTitle)?{terminalTitle:i.terminalTitle.filter(p=>typeof p==="string").map(p=>p.trim()).filter(Boolean)}:{},...typeof i.showTips==="boolean"?{showTips:i.showTips}:{},...typeof i.programStatus==="boolean"?{programStatus:i.programStatus}:{},...r?{notifications:r}:{},...a?{statusLine:a}:{},...c?{customStatusLine:c}:{}}}function Es(e){if(e==null||typeof e!=="object"||Array.isArray(e))return void 0;const n=e;const i=typeof n.command==="string"?n.command.trim():"";if(!i)return void 0;return{command:i,...n.display==="inline"||n.display==="block"?{display:n.display}:{},...n.position==="above"||n.position==="below"?{position:n.position}:{},...n.colorMode==="plain"||n.colorMode==="ansi"?{colorMode:n.colorMode}:{},...typeof n.maxLines==="number"&&Number.isFinite(n.maxLines)?{maxLines:n.maxLines}:{},...typeof n.timeoutMs==="number"&&Number.isFinite(n.timeoutMs)?{timeoutMs:n.timeoutMs}:{},...typeof n.intervalSeconds==="number"&&Number.isFinite(n.intervalSeconds)?{intervalSeconds:n.intervalSeconds}:{}}}import{createHash as Ms,randomUUID as ks}from"node:crypto";import Nn from"node:fs";import Dn from"node:path";function Pt(e){if(e==null||typeof e!=="object"||Array.isArray(e))return void 0;const n=e;const i={};if(typeof n.apiKey==="string")i.apiKey=n.apiKey;if(typeof n.baseURL==="string")i.baseURL=n.baseURL;const t=Vo(n.modelContextLimits);if(t)i.modelContextLimits=t;return Object.keys(i).length>0?i:void 0}function Vo(e){if(!N(e))return void 0;const n=Object.entries(e).filter(i=>i[0].length>0&&Number.isSafeInteger(i[1])&&i[1]>0);return n.length>0?Object.fromEntries(n):void 0}function Lt(e,n){if(!n)return e;return Object.fromEntries(Object.entries(e).map(([i,t])=>{const r=n[i];return[i,r!==void 0&&t.contextWindowOptions?.includes(r)?{...t,limit:{...t.limit,context:r}}:t]}))}function Ko(e){const n=e.provider?.minimax;const i=n?.catalogModels??n?.models??je;return Lt(Object.fromEntries(Object.entries(i).filter(([,t])=>t.enabled!==false)),e.minimax_api?.modelContextLimits)}function Dt(e,n){const i=e.minimax;if(!i?.models)return e;return{...e,minimax:{...i,catalogModels:i.models,models:Lt(i.models,n)}}}function Nt(e){if(e==null||typeof e!=="object"||Array.isArray(e))return void 0;const n=Object.entries(e).filter(([,i])=>i!=null&&typeof i==="object"&&!Array.isArray(i));if(n.length===0)return void 0;return Object.fromEntries(n.map(([i,t])=>[i,Ft(t)]))}function Bt(e){return Object.fromEntries(Object.entries(e).map(([n,i])=>[n,N(i)?Ft(i):i]))}function Ft(e){if(!N(e.models))return e;let n=false;const i=Object.fromEntries(Object.entries(e.models).map(([t,r])=>{if(!N(r)||!N(r.thinking))return[t,r];const l=typeof r.thinking.effort==="string"?r.thinking.effort.trim():"";const a=typeof r.thinking.defaultEffort==="string"?r.thinking.defaultEffort.trim():"";if(!Object.hasOwn(r.thinking,"effort")&&!Object.hasOwn(r.thinking,"defaultEffort")){return[t,r]}const c=[];const p=new Set;if(Array.isArray(r.thinking.effortOptions)){for(const R of r.thinking.effortOptions){if(typeof R!=="string")continue;const k=R.trim();if(!k||p.has(k))continue;p.add(k);c.push(k)}}if(l&&!p.has(l)){p.add(l);c.push(l)}if(a&&!p.has(a)){p.add(a);c.push(a)}const u={...r.thinking};delete u.effort;delete u.effortOptions;delete u.defaultEffort;const d={...u,...c.length>0?{effortOptions:c}:{},...a?{defaultEffort:a}:{}};const h={...r};if(Object.keys(d).length>0)h.thinking=d;else delete h.thinking;n=true;return[t,h]}));return n?{...e,models:i}:e}var Ut="byok_legacy_provider_to_custom_provider_v1";var jt="config.yaml.bak.byok-legacy-provider.";var jo=new Set(["minimax","minimax_api","provider","custom_provider"]);var ws=/^[A-Za-z0-9 _-]+$/;function Vt(e,n){const i={migrated:false,migratedProviders:{}};if(!n.isManagedRuntime())return i;if(!Nn.existsSync(e))return i;const t=Os(e);if(!N(t.provider))return i;const r=t.provider;const l=N(t.custom_provider)?t.custom_provider:{};const a=Vs(t);const c={};const p={...l};const u=new Set(Object.keys(p));let d=false;const h=n.getManagedPreset().provider;for(const[R,k]of Object.entries(r)){if(!Ps(R,k,h)){continue}const D=a.providers[R];if(D&&!jo.has(D)&&!N(p[D])){delete r[R];d=true;continue}const I=D&&!jo.has(D)?D:Ns(R,k,u);c[R]=I;if(!N(p[I])){p[I]=Ds(k);u.add(I);d=true}if(a.providers[R]!==I){a.providers[R]=I;d=true}delete r[R];d=true}if(!d&&Object.keys(c).length===0)return i;d=Ot(t,"defaultModel",c)||d;d=Ot(t,"defaultLightModel",c)||d;d=Us(t,c)||d;if(!d)return{migrated:false,migratedProviders:c};if(Object.keys(p).length>0)t.custom_provider=p;else delete t.custom_provider;Ks(t,a);try{const R=js(e);ue(e,V.dump(t,{indent:2,lineWidth:-1,noRefs:true}));return{migrated:true,migratedProviders:c,backupPath:R}}catch(R){console.warn(`[config] legacy BYOK provider migration skipped: ${$s(R)}`);return{migrated:false,migratedProviders:c}}}function Kt(e,n){let i=e.provider;const t=e.defaultModel;if(Object.prototype.hasOwnProperty.call(i,"minimax_api")){const{minimax_api:D,...I}=i;i=I;console.warn('[config] "minimax_api" is a reserved provider id; ignoring provider.minimax_api from config.yaml')}const r=n.getManagedPreset();const l=r.provider.minimax;const a=i.minimax;const c=n.isManagedRuntime();const p=c||Ts(a,n);if(!p)return{provider:i,defaultModel:t};const u=a?.options;const d=c&&n.shouldEnforceManagedProviderProtection();const h=Is(l.models,a?.models);const R=typeof u?.baseURL==="string"&&u.baseURL.length>0?u.baseURL:void 0;const k=d&&R!=null&&!n.isManagedPresetBaseUrl(R);i={...i,minimax:{...l,...a??{},npm:a?.npm??l.npm,models:h,options:{...l.options??{},...u??{},...k?{apiKey:l.options?.apiKey}:{},...d?{authMode:"managed-login",baseURL:l.options?.baseURL}:{}}}};return{provider:i,defaultModel:t}}function Ts(e,n){const i=e?.options;if(i?.authMode==="managed-login")return true;return typeof i?.baseURL==="string"&&n.isManagedPresetBaseUrl(i.baseURL)}function Is(e,n){return n&&Object.keys(n).length>0?n:e??{}}function Os(e){try{const n=V.load(Nn.readFileSync(e,"utf-8"));return N(n)?n:{}}catch{return{}}}function Ps(e,n,i){if(e==="minimax"||e==="minimax_api")return false;if(!Gs(n))return false;if(!Ls(n))return false;return!Object.prototype.hasOwnProperty.call(i,e)}function Ls(e){const n=N(e.options)?e.options:void 0;return typeof n?.apiKey==="string"&&n.apiKey.trim().length>0&&typeof n.baseURL==="string"&&n.baseURL.trim().length>0&&N(e.models)}function Ds(e){const n=N(e.options)?e.options:{};return{...e,kind:"custom",enabled:e.enabled!==false,options:{...n,authMode:"api-key"}}}function Ns(e,n,i){const t=N(n)?n:{};const r=typeof t.name==="string"?t.name:void 0;const l=`provider-${Bs(e)}`;const a=It(e)??It(r)??l;for(let c=0;;c+=1){const p=c===0?a:`${a}-${c+1}`;if(!i.has(p)&&!jo.has(p)){return p}}}function It(e){const n=e?.trim();if(!n||!ws.test(n))return void 0;const i=n.toLowerCase().replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"");return i||void 0}function Bs(e){return Ms("sha256").update(e).digest("hex").slice(0,8)}function Ot(e,n,i){const t=e[n];if(typeof t!=="string")return false;const r=Fs(t,i);if(r===t)return false;e[n]=r;return true}function Fs(e,n){const i=e.indexOf("/");if(i<=0||i===e.length-1)return e;const t=e.slice(0,i);const r=n[t];if(!r)return e;return`custom_provider:${r}/${e.slice(i+1)}`}function Us(e,n){if(!N(e.nexus)||!N(e.nexus.model))return false;const i=e.nexus.model.providerID;if(typeof i!=="string")return false;const t=n[i];if(!t)return false;e.nexus.model.providerID=`custom_provider:${t}`;return true}function Gt(e){if(process.platform==="win32")return;const n=Dn.dirname(e);let i;try{i=Nn.readdirSync(n,{withFileTypes:true})}catch{console.warn(`[config] Could not inspect legacy BYOK backups in ${JSON.stringify(n)}. Backup permissions were not verified; check directory access and restrict backup permissions manually.`);return}for(const t of i){if(t.isFile()&&t.name.startsWith(jt)){const r=Dn.join(n,t.name);try{Ve(r)}catch{console.warn(`[config] Could not restrict legacy BYOK backup ${JSON.stringify(r)}. It may still be readable by other users; restrict its permissions manually.`)}}}}function js(e){const n=Dn.join(Dn.dirname(e),`${jt}${Date.now()}.${ks()}`);Ve(e);ue(n,Nn.readFileSync(e),true);return n}function Vs(e){const n=N(e.migrations)?e.migrations:void 0;const i=n?.[Ut];const t=N(i)&&N(i.providers)?Object.fromEntries(Object.entries(i.providers).filter(r=>typeof r[1]==="string")):{};return{providers:t}}function Ks(e,n){const i=N(e.migrations)?e.migrations:{};i[Ut]={version:1,providers:n.providers};e.migrations=i}function Gs(e){if(!N(e))return false;return typeof e.name==="string"||typeof e.npm==="string"||typeof e.api==="string"||N(e.options)||N(e.models)}function N(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function $s(e){if(e instanceof Error)return e.message;return String(e)}var cn="native";function dn(e){if(e==="native"||e==="mcp")return e;return cn}function $t(e){if(e==="mcp"){throw new Error("MCP backend coming in v2 follow-up plan")}}function Yt(e,n){if(e==null||typeof e!=="object"||Array.isArray(e)){return n}const i=Reflect.get(e,"mode");return{mode:i==="inline"||i==="subagent"?i:n.mode,modeSource:i==="inline"||i==="subagent"?"explicit":"default"}}function Wt(e,n){const i=n.keepAlive;const t=n.xdg;const r=n.spawnConcurrency;const l=()=>({enabled:i.enabled,maxProcesses:i.maxProcesses,maxLifetimeMs:i.maxLifetimeMs,agents:[...i.agents]});const a=e.opencode;if(a==null||typeof a!=="object"||Array.isArray(a)){return{keepAlive:l(),xdg:{...t},spawnConcurrency:r}}const c=a;const p=c.spawnConcurrency;const u=typeof p==="number"&&Number.isFinite(p)&&p>0&&Number.isInteger(p)?p:r;const d=Ys(c.xdg,t);const h=c.keepAlive;if(h==null||typeof h!=="object"||Array.isArray(h)){return{keepAlive:l(),xdg:d,spawnConcurrency:u}}const R=h;const k=R.maxProcesses;const D=typeof k==="number"&&Number.isFinite(k)&&k>0&&Number.isInteger(k)?k:i.maxProcesses;const I=R.maxLifetimeMs;const U=typeof I==="number"&&Number.isFinite(I)&&I>0&&Number.isInteger(I)?I:i.maxLifetimeMs;const L=R.agents;let B;if(Array.isArray(L)){B=L.filter($=>typeof $==="string"&&$.length>0);if(B.length===0)B=[...i.agents]}else{B=[...i.agents]}return{keepAlive:{enabled:typeof R.enabled==="boolean"?R.enabled:i.enabled,maxProcesses:D,maxLifetimeMs:U,agents:B},xdg:d,spawnConcurrency:u}}function Ys(e,n){const i=e!=null&&typeof e==="object"&&!Array.isArray(e)?e:void 0;const t=i?.startupImport;const r=t==="background"||t==="blocking"||t==="off"?t:n.startupImport;return{dataIsolation:typeof i?.dataIsolation==="boolean"?i.dataIsolation:n.dataIsolation,startupImport:r}}function Bn(e){const n=JSON.stringify({level:40,time:Date.now(),name:"config.asr",msg:e});process.stderr.write(`${n}
3
+ `)}var Un={enabled:true};function qt(e){if(e==null||typeof e!=="object"||Array.isArray(e))return false;const n=e;const i=typeof n.apiKey==="string"&&n.apiKey.trim().length>0;const t=typeof n.resourceId==="string"&&n.resourceId.trim().length>0;return i||t}function Fn(e){return typeof e==="string"&&e.trim().length>0}function Ht(e){const n=e.asr;if(n==null||typeof n!=="object"||Array.isArray(n)){return{...Un}}const i=n;if(qt(i.seed)){Bn("Ignoring legacy `asr.seed.*` in config \u2014 Seed ASR was retired from the daemon; only Amadeus remains. Remove `asr.seed` from config.yaml.")}if(qt(i.qwen)){Bn("Ignoring legacy `asr.qwen.apiKey` in config \u2014 Qwen ASR was retired from the daemon; only Amadeus remains. Remove `asr.qwen` from config.yaml.")}if(Fn(i.mode)||Fn(i.proxyBaseUrl)){Bn("Ignoring legacy `asr.mode` / `asr.proxyBaseUrl` in config \u2014 the daemon no longer runs the shared asr-proxy WebSocket path. The Amadeus HTTP proxy is managed by the application environment. Remove these keys from config.yaml.")}if(Fn(i.primaryProvider)||Fn(i.fallbackProvider)){Bn("Ignoring legacy `asr.primaryProvider` / `asr.fallbackProvider` in config \u2014 only Amadeus remains and provider selection is no longer configurable. Remove these keys from config.yaml.")}return{enabled:typeof i.enabled==="boolean"?i.enabled:Un.enabled}}var Ws={policyOwner:"core",storageWriteVersion:2,classifierTimeoutMs:6e4,userConfirmationEnabled:true,dangerousCommandGateEnabled:true};function Xt(e,n=Ws){const i=e.permission;if(i==null||typeof i!=="object"||Array.isArray(i)){return{...n}}const t=i;const r=t.policyOwner===void 0?n.policyOwner:t.policyOwner==="engine"||t.policyOwner==="core"?t.policyOwner:"engine";const l=t.storageWriteVersion===1||t.storageWriteVersion===2?t.storageWriteVersion:n.storageWriteVersion;const a=t.classifierTimeoutMs;const c=typeof a==="number"&&Number.isFinite(a)&&a>=5e3?Math.floor(a):n.classifierTimeoutMs;const p=typeof t.userConfirmationEnabled==="boolean"?t.userConfirmationEnabled:n.userConfirmationEnabled;const u=typeof t.dangerousCommandGateEnabled==="boolean"?t.dangerousCommandGateEnabled:n.dangerousCommandGateEnabled;return{policyOwner:r,storageWriteVersion:l,classifierTimeoutMs:c,userConfirmationEnabled:p,dangerousCommandGateEnabled:u}}var qs=5*1024*1024;var fn={recoveryDivisor:2,image:{max_width:2e3,max_height:2e3,max_base64_bytes:4.5*1024*1024}};function $o(e){const n=zt(e)?e:{};const i=n.recoveryDivisor;const t=zt(n.image)?n.image:{};const r=fn.image;return{recoveryDivisor:typeof i==="number"&&Number.isFinite(i)&&i>1?i:fn.recoveryDivisor,image:{max_width:Go(t.max_width)??r.max_width,max_height:Go(t.max_height)??r.max_height,max_base64_bytes:Math.min(Go(t.max_base64_bytes)??r.max_base64_bytes,qs)}}}function Go(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>0?e:void 0}function zt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Jt=["user-cc","user-codex","user-agents","workspace-minimax","workspace-cc","workspace-agents"];var Hs={"user-cc":"user-claude","workspace-cc":"workspace-claude"};var Vn={external:{enabled:true,walkUp:true,duplicateWarn:true,sources:{"workspace-minimax":{enabled:true,priority:65},"workspace-cc":{enabled:true,priority:60},"workspace-agents":{enabled:true,priority:55},"user-cc":{enabled:true,priority:40},"user-codex":{enabled:true,priority:35},"user-agents":{enabled:true,priority:30}}}};function jn(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}function Xs(e,n){if(!jn(e))return n;return{enabled:typeof e.enabled==="boolean"?e.enabled:n.enabled,priority:typeof e.priority==="number"&&Number.isFinite(e.priority)?e.priority:n.priority}}function Yo(e){const n=Vn;const i=jn(e.skills)?e.skills:{};const t=jn(i.external)?i.external:{};const r=jn(t.sources)?t.sources:{};const l={...n.external.sources};for(const a of Jt){const c=Hs[a];const p=Object.hasOwn(r,a)?r[a]:c?r[c]:void 0;l[a]=Xs(p,n.external.sources[a])}return{external:{enabled:typeof t.enabled==="boolean"?t.enabled:n.external.enabled,walkUp:typeof t.walkUp==="boolean"?t.walkUp:n.external.walkUp,duplicateWarn:typeof t.duplicateWarn==="boolean"?t.duplicateWarn:n.external.duplicateWarn,sources:l}}}var zs=Jt;var Qt=["pi-agent"];var Ke="pi-agent";function Zt(e){if(typeof e!=="string")return Ke;if(Qt.includes(e)){return e}return Ke}function Wo(e){if(e==null||typeof e!=="object"||Array.isArray(e)){return{defaultFramework:Ke}}const n=e;return{defaultFramework:Zt(n.defaultFramework)}}var Qo=["read","write","edit","bash","task_query","task_output","task_stop","grep","glob","todowrite","web_fetch","website_deploy"];var Zo=["images_understand","image_synthesize","images_search_and_download","image_reverse_search","submit_video_generation","query_video_generation","gen_videos","batch_text_to_video","batch_image_to_video","get_voice_list","batch_text_to_audio","batch_text_to_music","synthesize_speech","batch_synthesize_speech","audios_understand","videos_understand","transcribe_audio"];var or="MCODE_NO_BUILTIN_TOOLS";function Js(e){return e[or]==="1"}var ir="MCODE_SESSION_MCP_ONLY";function Qs(e){return e[ir]==="1"}var ei=["code-review","deep-research","deploy-website","docx","edit-deployed-website","init","lark-tools","llm-call","mcode-tools-master","mavis-doctor","pdf","plugin-creator","pptx","skill-creator","skill-refiner","visual-page","x-link-reader","xlsx"];var tr=["control-in-app-browser","cu-desktop","resume-codex","mavis","create-agent","minimax-code-product","miniapp-creator"];var Zs=new Set(["modelConfigId","persona","tools","builtinTools","skills","features"]);var el=new Set(["enabled"]);var zo=new Set(["mavis","delegation","webSearch"]);var rr=new Set(Qo);var er=["task_query","task_output","task_stop"];var sr=new Set(Zo);var Jo=new Set(ei);var lr=new Set(tr);var nl=new Set(["plan-mode"]);function ni(e){const n=Kn(e);const i=Kn(n?.default);return{default:i?il(i):{}}}function ol(e,n="agent"){if(e===void 0)return{};const i=Ho(e,n);Xo(i,Zs,n);const t={};if(i.modelConfigId!==void 0){if(typeof i.modelConfigId!=="string"||!i.modelConfigId.trim()){Q(`${n}.modelConfigId`,"must be a non-empty string")}t.modelConfigId=i.modelConfigId.trim()}if(i.persona!==void 0){const r=Ho(i.persona,`${n}.persona`);Xo(r,el,`${n}.persona`);if(r.enabled!==void 0&&typeof r.enabled!=="boolean"){Q(`${n}.persona.enabled`,"must be a boolean")}t.persona={...typeof r.enabled==="boolean"?{enabled:r.enabled}:{}}}if(i.tools!==void 0){if(!Array.isArray(i.tools))Q(`${n}.tools`,"must be an array");t.tools=i.tools.map((r,l)=>{if(typeof r!=="string"||!rr.has(r)){Q(`${n}.tools[${l}]`,`must be one of ${Qo.join(", ")}`)}return r})}if(i.builtinTools!==void 0){if(!Array.isArray(i.builtinTools))Q(`${n}.builtinTools`,"must be an array");t.builtinTools=i.builtinTools.map((r,l)=>{if(r==="web_search"){Q(`${n}.builtinTools[${l}]`,"web_search is feature-owned; use features.webSearch")}if(typeof r!=="string"||!sr.has(r)){Q(`${n}.builtinTools[${l}]`,`must be one of ${Zo.join(", ")}`)}return r})}if(i.skills!==void 0){if(!Array.isArray(i.skills))Q(`${n}.skills`,"must be an array");t.skills=i.skills.map((r,l)=>{if(typeof r==="string"&&lr.has(r.trim())){const a=r.trim();Q(`${n}.skills[${l}]`,`${a} is capability-owned; use its owning Tool or feature switch`)}if(typeof r!=="string"||!Jo.has(r.trim())){Q(`${n}.skills[${l}]`,`must be one of ${ei.join(", ")}`)}return r.trim()})}if(i.features!==void 0){const r=Ho(i.features,`${n}.features`);Xo(r,zo,`${n}.features`);for(const l of zo){if(r[l]!==void 0&&typeof r[l]!=="boolean"){Q(`${n}.features.${l}`,"must be a boolean")}}t.features={...typeof r.mavis==="boolean"?{mavis:r.mavis}:{},...typeof r.delegation==="boolean"?{delegation:r.delegation}:{},...typeof r.webSearch==="boolean"?{webSearch:r.webSearch}:{}}}return t}function il(e){const n={};if(typeof e.modelConfigId==="string"&&e.modelConfigId.trim()){n.modelConfigId=e.modelConfigId.trim()}const i=Kn(e.persona);if(typeof i?.enabled==="boolean"){n.persona={enabled:i.enabled}}if(nr(e.tools,rr)){const r=[...e.tools];if(!er.some(l=>r.includes(l))){r.push(...er)}n.tools=r}if(nr(e.builtinTools,sr)){n.builtinTools=[...e.builtinTools]}if(Array.isArray(e.skills)){const r=e.skills.map(l=>typeof l==="string"?l.trim():l);if(r.every(l=>typeof l==="string"&&(Jo.has(l)||nl.has(l))&&!lr.has(l))){n.skills=r.filter(l=>typeof l==="string"&&Jo.has(l))}}const t=Kn(e.features);if(t){const r={};for(const l of zo){if(typeof t[l]==="boolean")r[l]=t[l]}if(Object.keys(r).length>0)n.features=r}return n}function Kn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)?e:void 0}function nr(e,n){return Array.isArray(e)&&e.every(i=>typeof i==="string"&&n.has(i))}function tl(e={},n={}){return{persona:{enabled:n.persona?.enabled??e.persona?.enabled??true},tools:qo(n.tools??e.tools),builtinTools:qo(n.builtinTools??e.builtinTools),skills:qo(n.skills??e.skills),features:{mavis:n.features?.mavis??e.features?.mavis??true,delegation:n.features?.delegation??e.features?.delegation??true,webSearch:n.features?.webSearch??e.features?.webSearch??true}}}function rl(e,n){return e.tools===void 0||e.tools.includes(n)}function sl(e,n){return e.builtinTools===void 0||e.builtinTools.includes(n)}function ll(e,n){return e.skills===void 0||e.skills.includes(n)}function qo(e){return e===void 0?void 0:[...e]}function Ho(e,n){if(e==null||typeof e!=="object"||Array.isArray(e)){Q(n,"must be an object")}return e}function Xo(e,n,i){for(const t of Object.keys(e)){if(!n.has(t))Q(`${i}.${t}`,"is not supported")}}function Q(e,n){throw new Error(`Invalid configuration at ${e}: ${n}`)}var oi={enabled:true};function ar(e,n=oi){const i=e.askUser;if(i==null||typeof i!=="object"||Array.isArray(i)){return{...n}}const t=i;return{enabled:typeof t.enabled==="boolean"?t.enabled:n.enabled}}var dr=["none","evaluator","subagent"];var fr=["brief","transcript"];var pr=["same-route-small-fast"];var gr="goal-verifier-readonly";var mr=[gr];var Z={budget:{graceSteps:1},breaker:{repeatedReplyLimit:3},verifier:{repeatedNotMetLimit:5,evidence:"brief"},evaluator:{modelPolicy:"same-route-small-fast",maxTokens:32e3,timeoutSeconds:60,maxRetries:1}};var ii={budget:{graceSteps:3},evaluator:{maxRetries:1}};function ti(e){const n=[];const i=Ge(e,"goal",n);$e(i,"goal",n,["objectiveMaxChars","verification","budget","breaker","verifier","evaluator","subagent"]);const t=Ge(i.budget,"goal.budget",n);$e(t,"goal.budget",n,["defaultTokens","defaultMainTurns","defaultActiveSeconds","graceSteps"]);const r=Ge(i.breaker,"goal.breaker",n);$e(r,"goal.breaker",n,["repeatedReplyLimit"]);const l=Ge(i.verifier,"goal.verifier",n);$e(l,"goal.verifier",n,["repeatedNotMetLimit","evidence"]);const a=Ge(i.evaluator,"goal.evaluator",n);$e(a,"goal.evaluator",n,["modelPolicy","maxTokens","timeoutSeconds","maxRetries"]);const c=Ge(i.subagent,"goal.subagent",n);$e(c,"goal.subagent",n,["profile","maxTurns","maxTokens","timeoutSeconds"]);const p=cr(i.verification,"goal.verification",dr,n);const u=we(i.objectiveMaxChars,"goal.objectiveMaxChars",n,{min:1});const d=we(t.defaultTokens,"goal.budget.defaultTokens",n,{min:1});const h=we(t.defaultMainTurns,"goal.budget.defaultMainTurns",n,{min:1});const R=we(t.defaultActiveSeconds,"goal.budget.defaultActiveSeconds",n,{min:1});const k=cr(c.profile,"goal.subagent.profile",mr,n);const D=we(c.maxTurns,"goal.subagent.maxTurns",n,{min:1});const I=we(c.maxTokens,"goal.subagent.maxTokens",n,{min:1});const U=we(c.timeoutSeconds,"goal.subagent.timeoutSeconds",n,{min:1});const L={...k!==void 0?{profile:k}:{},...D!==void 0?{maxTurns:D}:{},...I!==void 0?{maxTokens:I}:{},...U!==void 0?{timeoutSeconds:U}:{}};return{config:{...u!==void 0?{objectiveMaxChars:u}:{},...p!==void 0?{verification:p}:{},budget:{...d!==void 0?{defaultTokens:d}:{},...h!==void 0?{defaultMainTurns:h}:{},...R!==void 0?{defaultActiveSeconds:R}:{},graceSteps:Ye(t.graceSteps,"goal.budget.graceSteps",Z.budget.graceSteps,n,{min:0,max:ii.budget.graceSteps})},breaker:{repeatedReplyLimit:Ye(r.repeatedReplyLimit,"goal.breaker.repeatedReplyLimit",Z.breaker.repeatedReplyLimit,n,{min:1})},verifier:{repeatedNotMetLimit:Ye(l.repeatedNotMetLimit,"goal.verifier.repeatedNotMetLimit",Z.verifier.repeatedNotMetLimit,n,{min:1}),evidence:ur(l.evidence,"goal.verifier.evidence",fr,Z.verifier.evidence,n)},evaluator:{modelPolicy:ur(a.modelPolicy,"goal.evaluator.modelPolicy",pr,Z.evaluator.modelPolicy,n),maxTokens:Ye(a.maxTokens,"goal.evaluator.maxTokens",Z.evaluator.maxTokens,n,{min:1}),timeoutSeconds:Ye(a.timeoutSeconds,"goal.evaluator.timeoutSeconds",Z.evaluator.timeoutSeconds,n,{min:1}),maxRetries:Ye(a.maxRetries,"goal.evaluator.maxRetries",Z.evaluator.maxRetries,n,{min:0,max:ii.evaluator.maxRetries})},...Object.keys(L).length>0?{subagent:L}:{}},warnings:n}}function Ge(e,n,i){if(e===void 0)return{};if(e===null||typeof e!=="object"||Array.isArray(e)){i.push(Ae(n,"expected an object; using defaults"));return{}}return e}function $e(e,n,i,t){for(const r of Object.keys(e)){if(!t.includes(r))i.push(Ae(`${n}.${r}`,"unknown key ignored"))}}function Ye(e,n,i,t,r){if(e==null)return i;if(!Number.isInteger(e)||e<r.min){t.push(Ae(n,`expected an integer >= ${r.min}; using default`));return i}if(r.max!=null&&e>r.max){t.push(Ae(n,`exceeds maximum ${r.max}; clamped`));return r.max}return e}function we(e,n,i,t){if(e==null)return void 0;if(!Number.isInteger(e)||e<t.min){i.push(Ae(n,`expected an integer >= ${t.min}; ignored`));return void 0}if(t.max!=null&&e>t.max){i.push(Ae(n,`exceeds maximum ${t.max}; clamped`));return t.max}return e}function ur(e,n,i,t,r){if(e==null)return t;if(typeof e!=="string"||!i.includes(e)){r.push(Ae(n,`expected one of: ${i.join(", ")}; using default`));return t}return e}function cr(e,n,i,t){if(e==null)return void 0;if(typeof e!=="string"||!i.includes(e)){t.push(Ae(n,`expected one of: ${i.join(", ")}; ignored`));return void 0}return e}function Ae(e,n){return`Invalid goal config at ${e}: ${n}`}var te={enabled:true,maxInlineKiB:64,mcpDetailsMaxInlineKiB:32,watermarkKiB:256,minSavingsKiB:256,minCandidateKiB:2,keepRecentRounds:5};var al=Math.floor(Number.MAX_SAFE_INTEGER/1024);function ri(e){const n=cl(e)?e:{};return{enabled:typeof n.enabled==="boolean"?n.enabled:te.enabled,maxInlineKiB:pn(n.maxInlineKiB,te.maxInlineKiB),mcpDetailsMaxInlineKiB:pn(n.mcpDetailsMaxInlineKiB,te.mcpDetailsMaxInlineKiB),watermarkKiB:pn(n.watermarkKiB,te.watermarkKiB),minSavingsKiB:pn(n.minSavingsKiB,te.minSavingsKiB),minCandidateKiB:pn(n.minCandidateKiB,te.minCandidateKiB),keepRecentRounds:ul(n.keepRecentRounds,te.keepRecentRounds)}}function pn(e,n){return typeof e==="number"&&Number.isSafeInteger(e)&&e>0&&e<=al?e:n}function ul(e,n){return typeof e==="number"&&Number.isSafeInteger(e)&&e>0?e:n}function cl(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var gn={};function si(e){if(e==null||typeof e!=="object"||Array.isArray(e)){return{...gn}}const n=Reflect.get(e,"chromePath");if(typeof n!=="string"||!n.trim()){return{...gn}}return{chromePath:n.trim()}}import{isIP as dl}from"node:net";var li=["read_only","workspace_write","delete_guard","full_access"];function yr(e){return{enabled:false,filesystemMode:"full_access"}}function br(e){return!e.enabled||e.filesystemMode==="full_access"?{enabled:false,filesystemMode:"full_access"}:{...e}}function ui(e){const n=yr(e);return{enabled:n.enabled,filesystem:{policy:{mode:n.filesystemMode},denyRead:[],denyWrite:[]},network:{policy:{mode:"allow_all"},deniedDomains:[]},localAccess:"open"}}var ci=ui(process.platform);var fl=new Set(li);var pl=new Set(["deny","allow_all"]);function di(e,n=process.platform){const i=ui(n);if(e===void 0)return i;const t=mn(e,"sandbox",["enabled","filesystem","network","localAccess"]);const r=t.filesystem===void 0?{}:mn(t.filesystem,"sandbox.filesystem",["policy","denyRead","denyWrite","allowGitConfig"]);const l=r.policy===void 0?{}:mn(r.policy,"sandbox.filesystem.policy",["mode"]);const a=t.network===void 0?{}:mn(t.network,"sandbox.network",["policy","deniedDomains"]);const c=a.policy===void 0?{}:mn(a.policy,"sandbox.network.policy",["mode"]);const p=t.enabled===void 0?i.enabled:gl(t.enabled,"sandbox.enabled");const u=l.mode??(p?"delete_guard":"full_access");if(typeof u!=="string"||!fl.has(u)){throw new Error(`Invalid sandbox.filesystem.policy.mode "${String(u)}"`)}const d=c.mode??i.network.policy.mode;if(typeof d!=="string"||!pl.has(d)){throw new Error(`Invalid sandbox.network.policy.mode "${String(d)}"`)}const h=a.deniedDomains===void 0?[...i.network.deniedDomains]:ai(a.deniedDomains,"sandbox.network.deniedDomains");for(const k of h)ml(k);const R=br({enabled:p,filesystemMode:u});return{enabled:R.enabled,filesystem:{policy:{mode:R.filesystemMode},denyRead:r.denyRead===void 0?[...i.filesystem.denyRead]:ai(r.denyRead,"sandbox.filesystem.denyRead"),denyWrite:r.denyWrite===void 0?[...i.filesystem.denyWrite]:ai(r.denyWrite,"sandbox.filesystem.denyWrite")},network:{policy:{mode:"allow_all"},deniedDomains:[]},localAccess:t.localAccess===void 0?i.localAccess:t.localAccess==="open"||t.localAccess==="restricted"?t.localAccess:(()=>{throw new Error(`Invalid sandbox.localAccess "${String(t.localAccess)}"`)})()}}function mn(e,n,i){if(e==null||typeof e!=="object"||Array.isArray(e)){throw new Error(`Invalid ${n}: expected object`)}const t=e;const r=Object.keys(t).find(l=>!i.includes(l));if(r)throw new Error(`Unknown ${n}.${r}`);return t}function gl(e,n){if(typeof e!=="boolean")throw new Error(`Invalid ${n}: expected boolean`);return e}function ai(e,n){if(!Array.isArray(e)||e.some(i=>typeof i!=="string")){throw new Error(`Invalid ${n}: expected string array`)}return[...e]}function ml(e){const n=()=>{throw new Error(`Invalid sandbox.network.deniedDomains entry "${e}"`)};const i=e.match(/^\[([^\]]+)\](?::(.+))?$/);if(i){if(dl(i[1]??"")!==6)n();hr(i[2],e);return}if((e.match(/:/g)??[]).length>1){n()}const t=e.lastIndexOf(":");const r=t>-1?e.slice(0,t):e;const l=t>-1?e.slice(t+1):void 0;hr(l,e);if(r==="*")return;if(!yl(r))n()}function yl(e){if(e.includes("://")||e.includes("/")||e.includes(":"))return false;if(e==="localhost")return true;if(e.startsWith("*.")){const n=e.slice(2);const i=n.split(".");return i.length>=2&&i.every(t=>t.length>0)}if(e.includes("*"))return false;return e.includes(".")&&!e.startsWith(".")&&!e.endsWith(".")}function hr(e,n){if(e===void 0)return;const i=Number(e);if(!/^[1-9][0-9]{0,4}$/.test(e)||!Number.isInteger(i)||i>65535){throw new Error(`Invalid sandbox.network.deniedDomains entry "${n}"`)}}function xr(e,n){if(n.length===0)return false;if(n.includes("*"))return true;return n.includes(e)}function Cl(){return process.env.__MAVIS_ALLOW_LEGACY_RUNTIME_ENV==="1"}var Cr={dev:"test",test:"test",staging:"staging",prod:"prod"};function Al(e){return e==="cn"||e==="en"}function Er(e){return e==="test"||e==="prod"||e==="dev"||e==="staging"}function Mr(){const e=process.env.MAVIS_REGION;if(Al(e))return e;if($n()){const n=process.env.NEXT_PUBLIC_LOCALE;if(n==="zh")return"cn";if(n==="en")return"en"}return"en"}function fe(){const e=process.env.MAVIS_BUILD_ENV;if(Er(e))return e;if($n()){const n=process.env.NEXT_PUBLIC_BUILD_ENV;const i=n&&Object.prototype.hasOwnProperty.call(Cr,n)?Cr[n]:void 0;if(i)return i}return"dev"}function Gn(){if(wr("managed"))return true;const e=process.env.__MAVIS_RUNTIME_MANAGED;if(e==="1")return true;if(e==="0")return false;if($n())return true;if(fe()==="prod"||fe()==="staging")return true;return false}function $n(){const e=process.versions;return process.env.ELECTRON_RUN_AS_NODE==="1"||typeof e.electron==="string"}function Yn(){return`${Mr()}-${fe()}`}var ce={none:0,test:1,internal:2,online:3};var Sl={internal:"internal",inside:"online"};function _l(e){for(const[n,i]of Object.entries(e)){if(ce[i.defaultVisibility]>ce[i.configurableVisibility]){throw new Error(`Invalid beta feature definition "${n}": defaultVisibility (${i.defaultVisibility}) must not exceed configurableVisibility (${i.configurableVisibility})`)}for(const t of i.defaultBuildVariants??[]){const r=Sl[t];if(ce[r]>ce[i.configurableVisibility]){throw new Error(`Invalid beta feature definition "${n}": defaultBuildVariant (${t}) must not exceed configurableVisibility (${i.configurableVisibility})`)}}for(const t of i.defaultBuildEnvironments??[]){const r=t==="prod"?"online":"test";if(ce[r]>ce[i.configurableVisibility]){throw new Error(`Invalid beta feature definition "${n}": defaultBuildEnvironment (${t}) must not exceed configurableVisibility (${i.configurableVisibility})`)}}}}var bn={autoMemory:{defaultVisibility:"online",configurableVisibility:"online"},skillEvolve:{defaultVisibility:"test",configurableVisibility:"online"},skillEvolveBuiltinMr:{defaultVisibility:"none",configurableVisibility:"test"},skillProposal:{defaultVisibility:"test",configurableVisibility:"online"},browserBridge:{defaultVisibility:"test",configurableVisibility:"online"},filePanelBrowser:{defaultVisibility:"online",configurableVisibility:"online"},filePanelBrowserMultiTab:{defaultVisibility:"online",configurableVisibility:"online"},browserUseTooling:{defaultVisibility:"online",configurableVisibility:"online"},browserUseAutoOpenPanel:{defaultVisibility:"online",configurableVisibility:"online"},browserAgentCursor:{defaultVisibility:"online",configurableVisibility:"online"},desktopPlanMode:{defaultVisibility:"online",configurableVisibility:"online"},desktopPlanModeAgentEntry:{defaultVisibility:"none",configurableVisibility:"online"},peek:{defaultVisibility:"test",configurableVisibility:"test"},keepAlive:{defaultVisibility:"test",configurableVisibility:"test"},promptOverride:{defaultVisibility:"test",configurableVisibility:"test"},cuMode:{defaultVisibility:"online",configurableVisibility:"online"},asr:{defaultVisibility:"online",configurableVisibility:"online"},taskHistoryProjectGrouping:{defaultVisibility:"online",configurableVisibility:"online"},threadGoal:{defaultVisibility:"online",configurableVisibility:"online"},mcodeTools:{defaultVisibility:"none",defaultBuildEnvironments:["dev","test","staging","prod"],defaultPlatforms:["darwin","linux","win32"],configurableVisibility:"online"},codexOAuth:{defaultVisibility:"online",configurableVisibility:"online"},runCode:{defaultVisibility:"none",configurableVisibility:"online"}};_l(bn);function vl(e){const n=e.buildEnv??fe();if(n!=="prod")return"test";return e.internalBuild===true?"internal":"online"}function Rl(e,n){const i=e.defaultBuildVariants;if(!i)return false;return n.internalBuild===true&&i.includes("internal")||n.insideBuild===true&&i.includes("inside")}function El(e,n){const i=n.defaultBuildEnvironment??n.buildEnv??mi();return e.defaultBuildEnvironments?.includes(i)===true}function mi(){const e=$n()?process.env.NEXT_PUBLIC_BUILD_ENV:void 0;return Er(e)?e:fe()}function Ar(e,n){return e.defaultPlatforms?.includes(n.platform??process.platform)!==false}function yi(e,n,i={}){const t=bn[e];const r=ce[vl(i)];const l=i.defaultBuildEnvironment??i.buildEnv??mi();if(e==="mcodeTools"&&l==="dev"&&i.mcodeToolsDevMode==="published"&&Ar(t,i))return true;if(n===false)return false;if(n===true)return r<=ce[t.configurableVisibility];if(!Ar(t,i))return false;if(El(t,i))return true;if(Rl(t,i))return true;return r<=ce[t.defaultVisibility]}function Ml(e){return bn[e].configurableVisibility==="online"}function bi(e=process.env){return e.__MAVIS_BUILD_INTERNAL==="true"}function kl(e=process.env){return e.__MAVIS_BUILD_INSIDE==="true"}var wl={APP_DIR:".minimax",ENV_PREFIX:"minimax",CLI_NAME:"minimax"};var kr="__MAVIS_RUNTIME";function Wn(e){return Cl()?process.env[`${kr}_${e}`]:void 0}function qn(e){const n=`--${e}`;let i;for(let t=2;t<process.argv.length;t++){const r=process.argv[t];if(r==="--")break;if(r===n){const l=process.argv[t+1];i=l===void 0||l.startsWith("-")?void 0:l;t++;continue}if(r?.startsWith(`${n}=`)){const l=r.slice(n.length+1);i=l.length>0?l:void 0}}return i}function wr(e){const n=`--${e}`;for(let i=2;i<process.argv.length;i++){const t=process.argv[i];if(t==="--")return false;if(t===n||t?.startsWith(`${n}=`))return true}return false}var We=5321;var pi=5001;var fi=65535;var Tr=500;var hi=2;var Tl=Tr*hi;var Ir=Tl+hi;var Sr=1;var Il=new Set(["agent-archon","mavis"]);var _r=(()=>{const e=79764919;const n=new Uint32Array(256);for(let i=0;i<256;i++){let t=i<<24;for(let r=0;r<8;r++){t=(t&2147483648)!==0?e^t<<1:t<<1;t>>>=0}n[i]=t>>>0}return n})();function Ol(e){const n=Buffer.from(`${e}
4
+ `,"utf-8");let i=0;for(const r of n){i=(_r[(i>>>24^r)&255]^i<<8)>>>0}let t=n.length;while(t!==0){i=(_r[(i>>>24^t&255)&255]^i<<8)>>>0;t>>>=8}return(i^4294967295)>>>0}function Pl(e){return Ol(e)%Tr*hi+2}function vr(e,n){try{const i=hl("git",e,{encoding:"utf-8",timeout:3e3,stdio:["ignore","pipe","pipe"],...n?{cwd:n}:{}});if(i.status===0&&i.stdout)return i.stdout.trim();return null}catch{return null}}function Ll(e){const n=e.match(/[/:]([^/:]+?)(?:\.git)?$/);return n?.[1]??null}function Or(){return process.env.MINIMAX_DATA_DIR?.trim()||process.env.MAVIS_DATA_DIR?.trim()}function Hn(){if(wr("disable-git-auto-config")||Wn("DISABLE_GIT_AUTO_CONFIG"))return false;if(qn("data-dir"))return false;if(Or())return false;return true}function Xn(){const e=qn("profile")??po()??Wn("PROFILE");return Ue(e)}function Pr(){const e=qn("port")??Wn("PORT");const n=e?parseInt(e,10):NaN;return Number.isNaN(n)?null:n}function gi(){const e=qn("data-dir")??Or()??Wn("DATA_DIR");return e&&e.length>0?e:null}function Dl(){return Boolean(Xn()&&gi())}function Lr(){return Boolean(Xn()&&Pr()!==null)}var Te=null;function Nl(){Te=null}function Ie(){if(Te!==null)return Te;const e={runtimePort:We,uiPort:pi,profile:null,autoDetected:false};if(true){Te=e;return e}const n=[void 0,Bl()];for(const i of n){try{const t=vr(["remote","get-url","origin"],i);if(!t)continue;const r=Ll(t);if(!r||!Il.has(r))continue;const l=vr(["branch","--show-current"],i);if(!l)continue;const a=Pl(l);Te={runtimePort:We+a,uiPort:pi+a,profile:l.replace(/\//g,"-"),autoDetected:true};return Te}catch{}}Te=e;return e}function Bl(){try{if(typeof __dirname==="string")return __dirname}catch{}const e=new Error().stack??"";for(const n of e.split("\n")){const i=/file:\/\/[^)\s]+/u.exec(n)?.[0]?.replace(/:\d+:\d+$/u,"");if(i){try{return z.dirname(xl(i))}catch{}}const t=/\(?((?:\/|[A-Za-z]:\\)[^()]+?\.(?:cjs|mjs|js|ts)):\d+:\d+\)?/u.exec(n)?.[1];if(t)return z.dirname(t)}return void 0}function Fl(){const e=Xn();if(e)return e;if(!Hn())return null;return Ie().profile}function xi(){const e=Xn();if(Dl()){return gi()}if(Hn()){const i=Ie();if(i.autoDetected&&i.profile){return Fe({profile:i.profile})}}const n=gi();if(n){return n}if(e){return Fe({profile:e})}return Fe()}function pe(){return z.join(xi(),"config.yaml")}var zn={"cn-test":"https://matrix-test.example.invalid/mavis/api/v1/llm/v1","cn-dev":"https://matrix-test.example.invalid/mavis/api/v1/llm/v1","cn-staging":"https://matrix-pre.example.invalid/mavis/api/v1/llm/v1","en-test":"https://matrix-overseas-test.example.invalid/mavis/api/v1/llm/v1","en-dev":"https://matrix-overseas-test.example.invalid/mavis/api/v1/llm/v1","en-staging":"https://matrix-overseas-pre.example.invalid/mavis/api/v1/llm/v1","cn-prod":"https://agent.minimax.cn/mavis/api/v1/llm/v1","en-prod":"https://agent.minimax.io/mavis/api/v1/llm/v1"};var Dr=["https://agent.minimaxi.com/mavis/api/v1/llm/v1"];var Ul=new Set([...Object.values(zn),...Dr]);var jl=new Set([...Object.values(zn),...Dr].map(e=>new URL(e).origin));function Nr(e){if(Ul.has(e))return true;try{const n=new URL(e);return!n.username&&!n.password&&jl.has(n.origin)}catch{return false}}function Br(){return fe()==="test"}function Vl(){return!Br()}function Kl(e){if(!Gn()||!de.existsSync(e)){return}const n=Fr(e);const{provider:i}=n;if(i==null||typeof i!=="object"||Array.isArray(i))return;const{minimax:t}=i;if(t==null||typeof t!=="object"||Array.isArray(t))return;const{options:r}=t;if(r==null||typeof r!=="object"||Array.isArray(r))return;const l=r.baseURL;if(typeof l!=="string")return;const a=zn[Yn()];if(l===a||!Nr(l))return;const c=de.readFileSync(e);r.baseURL=a;try{ue(e,V.dump(n,{indent:2,lineWidth:-1,noRefs:true}))}catch(p){let u=false;try{u=de.readFileSync(e).equals(c)}catch{}if(!u)throw p;console.warn("[config] managed preset baseURL sync skipped; config file unchanged, using runtime provider settings")}}function Se(e){const n={name:"MiniMax",npm:"@ai-sdk/anthropic",options:{authMode:"managed-login",apiKey:"sk-xxx",baseURL:zn[e]},models:je};return{provider:{minimax:n},defaultModel:"minimax/MiniMax-M3.1-Flash"}}var Ci={"cn-test":Se("cn-test"),"cn-dev":Se("cn-dev"),"cn-staging":Se("cn-staging"),"cn-prod":Se("cn-prod"),"en-test":Se("en-test"),"en-dev":Se("en-dev"),"en-staging":Se("en-staging"),"en-prod":Se("en-prod")};var K={logLevel:"info",devPort:pi,permissionMode:"auto",sseErrorPush:{history:true,stream:true},beta:Object.fromEntries(Object.keys(bn).map(e=>[e,yi(e,void 0,{buildEnv:"dev"})])),agents:{default:{}},memory:{enabled:true,proactive:false,dailyDigest:{enabled:false}},skillEvolve:{enabled:true,inSession:{N:20,minIntervalSeconds:30,maxPendingPerSession:1},signalCooldownHours:24,minConfidence:.7,excludeAgents:["skill-editor"],disableModelPrefixes:["MiniMax-M2"],builtinMrEnabled:false,sourceRepo:void 0,proposal:{enabled:false,eligibleAgents:["mavis"],minMessageCount:40,skipPassiveSessionEnd:true},lifecycle:{staleThresholdDays:15,archiveThresholdDays:30}},sessionRotate:{enabled:true,activeSessionLookbackHours:12},agentStop:{debounceMs:500,maxActiveSpanMs:30*60*1e3},asr:{...Un},skills:Vn,askUser:{...oi},sessionTitle:{enabled:true},requestMedia:fn,cli:{spawn:{enabled:false}},browser:{...gn},tui:{},telemetry:{enabled:false,metrics:false,diagnostics:false},opencode:{xdg:{dataIsolation:false,startupImport:"off"},keepAlive:{enabled:false,maxProcesses:5,maxLifetimeMs:288e5,agents:["mavis","main","verifier","code-reviewer"]},spawnConcurrency:3},contextManagement:{disableSystemReminderModels:[],cuMaxScreenshotsInContext:2},runawayGuard:{enabled:true},toolResultCompaction:{...te},agentRuntime:{defaultFramework:Ke},logRetentionDays:3,cuBackend:cn,worktreeRefreshBeforeCreate:true,review:{mode:"subagent",modeSource:"default"},goal:structuredClone(Z),sandbox:structuredClone(ci),goalWarnings:[],promptSuggestion:{}};function Gl(){const e=pe();const n=z.dirname(e);if(!de.existsSync(n)){de.mkdirSync(n,{recursive:true})}if(de.existsSync(e)){Si(e);return}if(!Gn()){const r=Fe({homeDir:bl.homedir()});const l=z.join(r,"config.yaml");if(e!==l&&de.existsSync(l)){Ve(l);ue(e,de.readFileSync(l),true)}return}const i=Ci[Yn()];const t=V.dump({logLevel:K.logLevel,provider:Ai?i.provider:void 0,defaultModel:i.defaultModel});ue(e,t,true)}function Fr(e=pe()){try{const n=de.readFileSync(e,"utf-8");const i=V.load(n);if(i!=null&&typeof i==="object"&&!Array.isArray(i)){return i}return{}}catch{return{}}}var yn=null;function $l(e){if(e==null||typeof e!=="object"||Array.isArray(e))return void 0;const n=e;return{branchFinish:typeof n.branchFinish==="boolean"?n.branchFinish:false}}var Ur={isManagedRuntime:Gn,shouldEnforceManagedProviderProtection:Vl,getManagedPreset:()=>Ci[Yn()],isManagedPresetBaseUrl:Nr};var jr=true;var Ai=true;function Yl(e){jr=e}function Wl(e){Ai=e}function Si(e){Ve(e);Gt(e);if(jr){Vt(e,Ur)}if(Ai)Kl(e)}function qe(){yn=null}function _e(){if(yn)return yn;Gl();const e=Fr();yn=_i(e,xi());return yn}function _i(e,n){const i=e.sseErrorPush;const t=i!=null&&typeof i==="object"&&!Array.isArray(i)?i:void 0;let r=typeof e.devPort==="number"?e.devPort:K.devPort;if(Hn()&&!Lr()){const u=Ie();if(u.autoDetected){r=u.uiPort}}const l=ti(e.goal);const a=Kt({provider:e.provider!=null&&typeof e.provider==="object"&&!Array.isArray(e.provider)?Bt(e.provider):{},defaultModel:typeof e.defaultModel==="string"?e.defaultModel:void 0},Ur);const c=Vo(e.minimaxModelContextLimits);const p=Xl(e);return{logLevel:typeof e.logLevel==="string"?e.logLevel:K.logLevel,devPort:r,...a,provider:Dt(a.provider,c),defaultModelVariant:typeof e.defaultModelVariant==="string"?e.defaultModelVariant:void 0,defaultModelThinking:e.defaultModelThinking&&typeof e.defaultModelThinking==="object"&&typeof e.defaultModelThinking.effort==="string"?{effort:e.defaultModelThinking.effort}:void 0,defaultModelContextWindow:Number.isSafeInteger(e.defaultModelContextWindow)&&Number(e.defaultModelContextWindow)>0&&Number(e.defaultModelContextWindow)<=2147483647?Number(e.defaultModelContextWindow):void 0,minimax_api:Pt(e.minimax_api),minimaxModelContextLimits:c,custom_provider:Nt(e.custom_provider),minimaxModelSource:typeof e.minimaxModelSource==="string"&&(e.minimaxModelSource==="token_plan"||e.minimaxModelSource==="minimax_api_key")?e.minimaxModelSource:void 0,nexus:e.nexus!=null&&typeof e.nexus==="object"&&!Array.isArray(e.nexus)?(()=>{const u={};if(typeof Reflect.get(e.nexus,"enabled")==="boolean"){u.enabled=Reflect.get(e.nexus,"enabled")}const d=Reflect.get(e.nexus,"model");if(d!=null&&typeof d==="object"&&!Array.isArray(d)&&typeof Reflect.get(d,"providerID")==="string"&&typeof Reflect.get(d,"modelID")==="string"){u.model={providerID:Reflect.get(d,"providerID"),modelID:Reflect.get(d,"modelID"),...typeof Reflect.get(d,"variant")==="string"?{variant:Reflect.get(d,"variant")}:{}}}return Object.keys(u).length>0?u:void 0})():void 0,defaultLightModel:typeof e.defaultLightModel==="string"?e.defaultLightModel:void 0,permissionMode:typeof e.permissionMode==="string"&&["default","bypassPermissions","auto","off"].includes(e.permissionMode)?e.permissionMode:K.permissionMode,permission:Xt(e),sseErrorPush:{history:typeof t?.history==="boolean"?t.history:K.sseErrorPush.history,stream:typeof t?.stream==="boolean"?t.stream:K.sseErrorPush.stream},notifications:$l(e.notifications),dataDir:n,agentsDir:z.join(n,"agents"),sessionsDir:z.join(n,"sessions"),memoryDir:z.join(n,"memory"),skillsDir:z.join(n,"skills"),builtinSkillsDir:z.join(n,".builtin-skills"),logsDir:z.join(n,"logs"),pluginsDir:z.join(n,"plugins"),plansDir:z.join(n,"plans"),harnessesDir:z.join(n,"harnesses"),subAgentsDir:z.join(n,"subagents"),beta:p,agents:ni(e.agents),memory:Hl(e),skillEvolve:Zl(e,p),sessionRotate:ea(e),agentStop:na(e),asr:Ht(e),skills:Yo(e),askUser:ar(e,K.askUser),sessionTitle:oa(e),requestMedia:$o(e.requestMedia),promptSuggestion:ia(e),cli:ta(e),browser:si(e.browser),tui:Tt(e),telemetry:ql(e.telemetry),opencode:Wt(e,K.opencode),contextManagement:ra(e),runawayGuard:yo(e.runawayGuard),toolResultCompaction:ri(e.toolResultCompaction),agentRuntime:Wo(e.agentRuntime),logRetentionDays:sa(e),contentReview:la(e),mcpToolSearch:aa(e),cuBackend:dn(e.cuBackend),review:Yt(e.review,K.review),worktreeRefreshBeforeCreate:e.worktreeRefreshBeforeCreate!==false,promptConfig:Vr(e.promptConfig),goal:l.config,goalWarnings:l.warnings,sandbox:di(e.sandbox)}}function ql(e){if(e==null||typeof e!=="object"||Array.isArray(e)){return{...K.telemetry}}const n=Reflect.get(e,"enabled");return{enabled:typeof n==="boolean"?n:K.telemetry.enabled,metrics:Reflect.get(e,"metrics")===true,diagnostics:Reflect.get(e,"diagnostics")===true}}function Hl(e){const n=e.memory;const i=n!=null&&typeof n==="object"&&!Array.isArray(n)?n:{};const t=i.dailyDigest;const r=t!=null&&typeof t==="object"&&!Array.isArray(t)?t:{};return{enabled:typeof i.enabled==="boolean"?i.enabled:K.memory.enabled,proactive:typeof i.proactive==="boolean"?i.proactive:K.memory.proactive,dailyDigest:{enabled:typeof r.enabled==="boolean"?r.enabled:K.memory.dailyDigest.enabled}}}function Xl(e){const n=e.beta!=null&&typeof e.beta==="object"&&!Array.isArray(e.beta)?e.beta:{};const i={buildEnv:fe(),defaultBuildEnvironment:mi(),internalBuild:bi(),insideBuild:kl(),mcodeToolsDevMode:process.env.MAVIS_DEV_MCODE_TOOLS_MODE==="published"?"published":void 0};const t={};for(const r of Object.keys(bn)){t[r]=yi(r,zl(r,n),i)}return t}function zl(e,n){if(e==="runCode"&&n.runCode===void 0&&process.env.MCODE_CODEMODE==="1"){return true}return n[e]}function Jl(e){const n=e.provider;if(n==null||typeof n!=="object"||Array.isArray(n)){return[]}const i=[];for(const t of Object.values(n)){if(t==null||typeof t!=="object"||Array.isArray(t))continue;const{models:r}=t;if(r==null||typeof r!=="object"||Array.isArray(r))continue;i.push(...Object.keys(r))}return i}function Ql(e,n){if(n.length===0)return true;const i=Jl(e);if(i.length===0)return false;const t=n.map(r=>r.toLowerCase());return!i.every(r=>t.some(l=>r.toLowerCase().startsWith(l)))}function Rr(e,n){return typeof e==="number"&&Number.isFinite(e)&&e>0?e:n}function Zl(e,n){const i=K.skillEvolve;const t=e.skillEvolve;const r=t!=null&&typeof t==="object"&&!Array.isArray(t);const l=r?t:{};const a=l.inSession;let{inSession:c}=i;if(a!=null&&typeof a==="object"&&!Array.isArray(a)){const j=a;c={N:typeof j.N==="number"&&j.N>0?j.N:i.inSession.N,minIntervalSeconds:typeof j.minIntervalSeconds==="number"&&j.minIntervalSeconds>=0?j.minIntervalSeconds:i.inSession.minIntervalSeconds,maxPendingPerSession:typeof j.maxPendingPerSession==="number"&&j.maxPendingPerSession>=1?j.maxPendingPerSession:i.inSession.maxPendingPerSession}}const p=l.excludeAgents;const u=Array.isArray(p)&&p.every(j=>typeof j==="string")?p:i.excludeAgents;const d=Array.isArray(l.disableModelPrefixes)&&l.disableModelPrefixes.every(j=>typeof j==="string")?l.disableModelPrefixes:i.disableModelPrefixes;const h=!n.skillEvolve?false:typeof l.enabled==="boolean"?l.enabled:Ql(e,d);const R=!h?false:!n.skillEvolveBuiltinMr?false:typeof l.builtinMrEnabled==="boolean"?l.builtinMrEnabled:i.builtinMrEnabled;const k=l.sourceRepo;const D=typeof k==="string"&&k.trim().length>0?k.trim():i.sourceRepo;const I=l.proposal;const U=i.proposal;const L=I!=null&&typeof I==="object"&&!Array.isArray(I)?I:{};const B=Array.isArray(L.eligibleAgents)&&L.eligibleAgents.every(j=>typeof j==="string")?L.eligibleAgents:U.eligibleAgents;const $=typeof L.minMessageCount==="number"&&L.minMessageCount>=1?Math.floor(L.minMessageCount):U.minMessageCount;const Y=typeof L.skipPassiveSessionEnd==="boolean"?L.skipPassiveSessionEnd:U.skipPassiveSessionEnd;const ne=typeof L.enabled==="boolean"?L.enabled:null;const Je=!h?false:!n.skillProposal?false:ne??true;const me=l.lifecycle;const Ee=me&&typeof me==="object"&&!Array.isArray(me)?me:{};const se=Rr(Ee.staleThresholdDays,i.lifecycle.staleThresholdDays);const Me=Rr(Ee.archiveThresholdDays,i.lifecycle.archiveThresholdDays);if(!(se<Me)){throw new Error(`Invalid skillEvolve.lifecycle config: staleThresholdDays (${se}) must be strictly less than archiveThresholdDays (${Me}).`)}return{enabled:h,inSession:c,signalCooldownHours:typeof l.signalCooldownHours==="number"&&l.signalCooldownHours>0?l.signalCooldownHours:i.signalCooldownHours,minConfidence:typeof l.minConfidence==="number"&&l.minConfidence>=0&&l.minConfidence<=1?l.minConfidence:i.minConfidence,scannerModel:typeof l.scannerModel==="string"?l.scannerModel:void 0,excludeAgents:u,disableModelPrefixes:d,builtinMrEnabled:R,sourceRepo:D,proposal:{enabled:Je,eligibleAgents:B,minMessageCount:$,skipPassiveSessionEnd:Y},lifecycle:{staleThresholdDays:se,archiveThresholdDays:Me}}}function ea(e){const n=K.sessionRotate;const i=e.sessionRotate;if(i==null||typeof i!=="object"||Array.isArray(i))return{...n};const t=i;const r=t.activeSessionLookbackHours;return{enabled:typeof t.enabled==="boolean"?t.enabled:n.enabled,activeSessionLookbackHours:typeof r==="number"&&Number.isFinite(r)&&r>0?r:n.activeSessionLookbackHours}}function na(e){const n=K.agentStop;const i=e.agentStop;if(i==null||typeof i!=="object"||Array.isArray(i)){return{...n}}const t=i;const r=t.debounceMs;const l=t.maxActiveSpanMs;return{debounceMs:typeof r==="number"&&Number.isFinite(r)&&r>=0?r:n.debounceMs,maxActiveSpanMs:typeof l==="number"&&Number.isFinite(l)&&l>=0?l:n.maxActiveSpanMs}}function Vr(e){const n=fe()==="prod"&&!bi();if(e==null||typeof e!=="object"||Array.isArray(e)){return{autoUpdate:n}}const i=e.autoUpdate;return{autoUpdate:typeof i==="boolean"?i:n}}function oa(e){const n=K.sessionTitle;const i=e.sessionTitle;if(i==null||typeof i!=="object"||Array.isArray(i)){return{...n}}const t=i;return{enabled:typeof t.enabled==="boolean"?t.enabled:n.enabled}}function ia(e){const n=e.promptSuggestion;const i=n!=null&&typeof n==="object"&&!Array.isArray(n)?n.enabled:void 0;return typeof i==="boolean"?{enabled:i}:{}}function ta(e){const n=K.cli;const i=e.cli;if(i==null||typeof i!=="object"||Array.isArray(i)){return{spawn:{...n.spawn}}}const t=i.spawn;if(t==null||typeof t!=="object"||Array.isArray(t)){return{spawn:{...n.spawn}}}const r=t;return{spawn:{enabled:typeof r.enabled==="boolean"?r.enabled:n.spawn.enabled}}}function ra(e){const n=K.contextManagement;const i=e.contextManagement;if(i==null||typeof i!=="object"||Array.isArray(i)){return{disableSystemReminderModels:[...n.disableSystemReminderModels],cuMaxScreenshotsInContext:n.cuMaxScreenshotsInContext}}const t=i;const r=t.disableSystemReminderModels;const l=Array.isArray(r)&&r.every(u=>typeof u==="string"&&u.length>0)?r:[...n.disableSystemReminderModels];const a=t.cuMaxScreenshotsInContext;const c=typeof a==="number"&&Number.isFinite(a)&&a>=0?Math.floor(a):n.cuMaxScreenshotsInContext;const p=typeof t.compactionTriggerAt==="number"?t.compactionTriggerAt:void 0;return{disableSystemReminderModels:l,cuMaxScreenshotsInContext:c,...p===void 0?{}:{compactionTriggerAt:p}}}function sa(e){const n=e.logRetentionDays;if(typeof n==="number"&&n>=1&&Number.isFinite(n)){return Math.floor(n)}return K.logRetentionDays}function la(e){const n=e.contentReview;if(n==null||typeof n!=="object"||Array.isArray(n))return void 0;const i={};const t=Reflect.get(n,"enabled");if(typeof t==="boolean")i.enabled=t;const r=Reflect.get(n,"testBaseURL");if(typeof r==="string"&&r.trim()){i.testBaseURL=r.trim()}return Object.keys(i).length>0?i:void 0}function aa(e){const n=e.mcpToolSearch;if(n==null||typeof n!=="object"||Array.isArray(n))return void 0;const i={};const t=Reflect.get(n,"enabled");if(typeof t==="boolean")i.enabled=t;const r=Reflect.get(n,"systemHint");if(typeof r==="boolean")i.systemHint=r;const l=Reflect.get(n,"thresholdPct");if(typeof l==="number")i.thresholdPct=l;const a=Reflect.get(n,"minDeferCount");if(typeof a==="number")i.minDeferCount=a;const c=Reflect.get(n,"topKDefault");if(typeof c==="number")i.topKDefault=c;const p=Reflect.get(n,"topKMax");if(typeof p==="number")i.topKMax=p;const u=Reflect.get(n,"maxSchemaTextLen");if(typeof u==="number")i.maxSchemaTextLen=u;const d=Reflect.get(n,"modelWhitelist");if(Array.isArray(d)){i.modelWhitelist=d.filter(h=>typeof h==="string")}return Object.keys(i).length>0?i:void 0}function Kr(){const e=Pr();if(Hn()&&!Lr()){const n=Ie();if(n.autoDetected){return n.runtimePort}}return e??We}function ua(e=Kr()){const n=e+Ir;if(n<=fi){return n}const i=e+Sr;if(i<=fi){return i}throw new Error(`Cannot allocate an OpenCode sidecar port for runtime port ${String(e)}; choose a runtime port <= ${String(fi-Sr)}.`)}var ca=["MCODE_DISABLE_TELEMETRY","DO_NOT_TRACK"];function da(e,n=()=>_e().telemetry[e]){for(const i of ca){if(/^(?:1|true|yes|on)$/iu.test(process.env[i]?.trim()??""))return false}try{return n()===true}catch{return false}}function Gr(e){return false}function $c(e){return e.replace(/^#{2,4} MCP\/App citation examples\r?\n\r?\n```\r?\n[\s\S]*?^```\r?\n\s*/gm,n=>n.includes("#mavis-source=")?"":n).replace(/^#{2,4} Citations\r?\n(?:[ \t]*\r?\n)*Cite every used result where it supports the answer\.[\s\S]*?^Do not cite unused calls or unsupported claims, invent metadata, output bare parenthesized links, or add trailing source\/reference lists\.\r?\n*/gm,n=>n.includes("Citation candidate")?"":n)}function Yc(e){const n=["- Independent tool calls can run in parallel in one response.","- Issue independent tool calls together when safe. Run dependent calls or conflicting writes sequentially, and follow each tool's concurrency restrictions.",'- Tool selection for this turn is described in "Tool calls in this turn".'];const i=n.find(d=>e.includes(d));if(!i)return e;const t="- Reference code as `file_path:line_number` \u2014 it's clickable.";const r="- Reference code as `file_path:line_number` so it is clickable. Place references near the relevant claim; group them only when there are many files.";const l=["- Cite sources where they support the answer, using exact source URLs or supplied links.","- Place references near the relevant claim; group them only when there are many files.","- Cite only sources you used; do not invent sources or links."].join("\n");const a=["- When referencing code, use `file_path:line_number` format.","- When citing one or two files, place one or two `file_path:line_number` references in the relevant conclusion sentence. Use a separate evidence list only when there are many references.",t,"- Reference code as `file_path:line_number` \u2014 it's clickable in the TUI."];const c=a.reduce((d,h)=>d.replaceAll(`${h}\r
5
5
  `,"").replaceAll(`${h}
6
6
  `,""),e.replace(r,"- Place references near the relevant claim; group them only when there are many files.")).replace(i,`${i}
7
7
  ${t}`);if(c.includes(l))return c;const p=/^(#{1,2}) Communication & Delivery\r?$/m.exec(c);if(p){const d=p[1];const h=p.index+p[0].length;const R=new RegExp(`^(?:#{1,${d.length}} |\\{\\{[#/])`,"m").exec(c.slice(h));const k=R?h+R.index:c.length;return`${c.slice(0,k).trimEnd()}
@@ -15,5 +15,5 @@ ${l}
15
15
  ${d}`)}return`${c.trimEnd()}
16
16
 
17
17
  ## References
18
- ${l}`}function aa(e,n=process.env){return Vr({platform:e,internalBuild:n.__MAVIS_BUILD_INTERNAL==="true",insideBuild:n.__MAVIS_BUILD_INSIDE==="true"})}import{randomBytes as ua}from"node:crypto";import{promises as ve}from"node:fs";import{dirname as ca,join as Kr}from"node:path";var $r=Fi(Ui(),1);async function da(e,n){const i=Kr(e,"config.yaml");let t;let r=false;let l;try{await ve.mkdir(e,{recursive:true});await ve.writeFile(i,"",{flag:"a",mode:384});await ve.chmod(i,384);const a=await ve.realpath(i);t=Kr(ca(a),`.config-tmp-${ua(6).toString("hex")}`);l=await $r.default.lock(a,{stale:1e4,retries:{retries:20,factor:1,minTimeout:5,maxTimeout:25}});const c=V.load(await ve.readFile(a,"utf8"));const p=c??{};if(!Gr(p))throw new Error("Invalid config document");const u=p.tui??{};if(!Gr(u))throw new Error("Invalid TUI settings");const d={...u};if(n===void 0)delete d.statusLine;else d.statusLine=[...n];const h={...p,tui:d};const R=384;const k=await ve.open(t,"wx",R);r=true;try{await k.writeFile(V.dump(h,{lineWidth:-1,noRefs:true}),"utf8");await k.chmod(R)}finally{await k.close()}await ve.rename(t,a)}catch{throw new Error("Unable to save status line settings. Check config.yaml syntax and permissions.")}finally{if(r&&t)await ve.unlink(t).catch(()=>void 0);await l?.().catch(()=>void 0)}}function Gr(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function fa(e){if(typeof e!=="object"||e===null||Array.isArray(e))return{};const n=e;const i=n.kill_switch??n.killSwitch;const t=n.sample_rate??n.sampleRate;const r=n.default_enabled??n.defaultEnabled;return{...typeof i==="boolean"?{killSwitch:i}:{},...typeof t==="number"&&Number.isFinite(t)&&t>=0&&t<=1?{sampleRate:t}:{},...typeof r==="boolean"?{defaultEnabled:r}:{}}}function Yr(e,n){if(typeof e==="boolean")return e;return n?.defaultEnabled??true}function pa(e,n){const i=Yr(e.promptSuggestion?.enabled,n);return{...e,promptSuggestion:{...e.promptSuggestion,enabled:i}}}var ga=["agent.minimax.io","agent.minimax.cn","agent.minimaxi.com"];var ma=new Set(ga.map(e=>`https://${e}`));function ya(e,n){return/^custom_provider:minimax-legacy(?:-\d+)?$/u.test(e)&&(!n||vi(n))}function vi(e){try{const n=new URL(e);if(n.username||n.password)return false;return ma.has(n.origin.toLowerCase())}catch{return false}}function ba(e){if(e!=="managed-login"&&e!=="api-key"&&e!=="oauth")return void 0;return e}function Ri(e){const n=typeof e?.baseURL==="string"?e.baseURL.trim():"";const i=n.length>0&&vi(n);const t=ba(e?.authMode);const r=[];if(typeof e?.authMode==="string"&&!t){r.push(`Unknown provider authMode "${e.authMode}"; falling back to compatibility resolution.`)}if(t){if(t==="managed-login"&&n.length>0&&!i&&!e?.allowManagedBaseURLOverride){r.push("Provider authMode is managed-login but baseURL is not a known managed MiniMax host.")}return{authMode:t,source:"explicit",managedBaseURL:i,warnings:r}}if(i){r.push("Provider authMode is inferred from a managed MiniMax baseURL; set options.authMode: managed-login to make this explicit.");return{authMode:"managed-login",source:"inferred-managed-base-url",managedBaseURL:i,warnings:r}}return{authMode:"api-key",source:"default-api-key",managedBaseURL:i,warnings:r}}var ge="minimax";var He="minimax_api";var Ei="custom_provider:";function ha(e,n){return e==="anthropic-messages"&&(n===ge||n===He)}function Mi(e,n){if(n===He)return"minimax_api_key";if(n.startsWith(Ei))return"custom_provider";if(n!==ge)return"configured_provider";if(e.minimaxModelSource==="minimax_api_key")return"minimax_api_key";const i=e.provider?.[n]?.options;const t=Ri({authMode:i?.authMode,baseURL:i?.baseURL}).authMode;return t==="managed-login"?"managed_token_plan":"configured_provider"}function Wr(e,n,i){const t=Mi(e,n);switch(t){case"managed_token_plan":{return Jn(e.provider?.[n],true)}case"minimax_api_key":{const r=e.provider?.[ge];return Jn({...r,models:r?.models??je},true)}case"custom_provider":{const r=e.custom_provider?.[n.slice(Ei.length)];if(!r||r.enabled===false)return[];return Jn(r)}case"configured_provider":return Jn(e.provider?.[n])}}function xa(e){const n=Mi(e.config,e.providerId);const i=e.modelId.trim();if(i.length>0&&Wr(e.config,e.providerId,e.preset).includes(i)){return{available:true,route:n}}return{available:false,route:n,code:e.source==="config_default"?"DEFAULT_MODEL_NOT_AVAILABLE_FOR_ROUTE":"MODEL_NOT_AVAILABLE_FOR_ROUTE",message:`Model "${e.providerId}/${e.modelId}" is not available for the "${n}" route (preset ${e.preset}).`}}function Jn(e,n=false){const i=Object.entries(e?.models??{}).filter(([,a])=>a?.enabled!==false).map(([a])=>a);const t=e?.model_order;if(!n||!Array.isArray(t)||!t.every(a=>typeof a==="string")){return i}const r=new Set(i);const l=t.filter(a=>r.delete(a));return[...l,...i.filter(a=>r.has(a))]}import{createHash as Hr}from"node:crypto";import Pe from"node:fs";import no from"node:os";import G from"node:path";var ki=".mcode-durable";var Xr="cas";var zr="runtime.db";var Jr="mcoded.sock";var Qr="sessions";var Zr=1;var es=G.join(no.homedir(),Pn);var Qn=class extends Error{code="LEGACY_WRITE_FORBIDDEN";targetPath;legacyRoot;constructor(n,i){super(`Refusing to write "${n}": the path falls inside the legacy data root "${i}", which the durable runtime only reads.`);this.name="LegacyWriteError";this.targetPath=n;this.legacyRoot=i}};function hn(e,n=no.homedir()){const i=Ue(e);const t=G.resolve(n);return G.join(t,i?`${ki}-${i}`:ki)}function Ca(e,n=Zr){if(!Number.isInteger(n)||n<1){throw new RangeError(`Invalid session database generation ${n}. Use an integer >= 1.`)}return G.join(e,`${Qr}.g${n}.db`)}function ns(e){return G.join(e,Xr)}function Aa(e){return G.join(e,zr)}function Sa(e){const n=G.join(e,Jr);if(Buffer.byteLength(n)<=os)return n;return Ti(e)}var os=100;function Ti(e){const n=Hr("sha256").update(G.resolve(e)).digest("hex").slice(0,12);const i=typeof process.getuid==="function"?process.getuid():0;return G.join(no.tmpdir(),`mcoded-${i}`,`${n}.sock`)}function is(e){return G.dirname(Ti(e))}var xn="MCODE_SERVER_MODE";var Zn=class extends Error{code="SERVER_MODE_INVALID";value;constructor(n){super(`Invalid ${xn} value ${JSON.stringify(n)}. Expected one of: off, auto, required.`);this.name="ServerModeConfigError";this.value=n}};function ts(e=process.env){const n=e[xn];if(n===void 0||n.trim()==="")return"auto";const i=n.trim().toLowerCase();if(i==="off"||i==="auto"||i==="required")return i;throw new Zn(n)}var eo=class extends Error{code="SERVER_MODE_OFF";constructor(){super(`Refusing to start the daemon: ${xn} is 'off'. Set ${xn}=auto or =required, or use the in-process runtime.`);this.name="ServerModeOffError"}};function _a(e=process.env){const n=ts(e);if(n==="off")throw new eo;return n}var rs="dd-";function ss(e,n){const i=G.resolve(e);const t=Xe(n);if(t===Xe(ln(i,null))){return{kind:"default"}}const r=`${Pn}-`;const l=new Set;const a=G.basename(t);if(a.startsWith(r))l.add(a.slice(r.length));let c;try{c=Pe.readdirSync(i,{withFileTypes:true})}catch{c=[]}for(const p of c){if(p.name.startsWith(r))l.add(p.name.slice(r.length))}for(const p of l){let u;try{u=Ue(p)}catch{continue}if(u===null)continue;if(t===Xe(ln(i,u))){return{kind:"profile",profile:u}}}return{kind:"foreign"}}function va(e={}){const n=e.homeDir??no.homedir();const i=e.profile??null;const t=hn(i,n);const r=e.dataDir?.trim();if(!r)return t;const l=Xe(r);const a=Xe(ln(n,i));if(l===a)return t;if(i===null){const p=ss(n,l);if(p.kind==="profile")return hn(p.profile,n);if(p.kind==="default")return hn(null,n)}const c=Hr("sha256").update(l).digest("hex").slice(0,16);return G.join(hn(null,n),`${rs}${c}`)}function Xe(e){const n=G.resolve(e);try{return Pe.realpathSync(n)}catch{return n}}var Oe=class extends Error{code="CONTROL_ROOT_INSECURE";controlRoot;constructor(n,i){super(`Refusing to use control root "${n}": ${i}`);this.name="ControlRootInsecureError";this.controlRoot=n}};function wi(e){let n;try{n=Pe.statSync(e)}catch{throw new Oe(e,"the directory does not exist")}if(!n.isDirectory()){throw new Oe(e,"the path is not a directory")}const i=typeof process.getuid==="function"?process.getuid():void 0;if(i!==void 0&&n.uid!==i){throw new Oe(e,`it is owned by uid ${n.uid}, not by ${i}`)}if((n.mode&18)!==0){throw new Oe(e,`it is writable by group or other (mode ${(n.mode&511).toString(8)})`)}return e}function Ra(e){Ii(e);Pe.mkdirSync(e,{recursive:true,mode:448});const n=is(e);if(n!==e){Pe.mkdirSync(n,{recursive:true,mode:448});wi(n)}wi(e);return e}function qr(e){let n=G.resolve(e);if(process.platform==="win32"){n=n.replace(/^\\\\\?\\/,"");return n.toLowerCase()}return n}function Ea(e,n){const i=qr(n);const t=G.dirname(i);const r=G.relative(t,qr(e));if(r===""||r===".."||r.startsWith(`..${G.sep}`)||G.isAbsolute(r)){return false}const[l]=r.split(G.sep);const a=G.basename(i);return l!==void 0&&(l===a||l.startsWith(`${a}-`))}function Ii(e,n=es){if(Ea(e,n))throw new Qn(e,n);return e}function Ma(e){Ii(e);Pe.mkdirSync(e,{recursive:true});Pe.mkdirSync(ns(e),{recursive:true})}import{randomBytes as ka}from"node:crypto";import Le from"node:fs";import{dirname as ls,join as wa}from"node:path";var as=Fi(Ui(),1);var Pi=384;var oo=new Set(["__proto__","prototype","constructor"]);var Ta=["minimax_api","custom_provider"];async function Ia(e){const n=e.trim();if(!n||n.includes(".")||oo.has(n)){throw new H("Invalid provider id")}return An(async i=>{if(ee(i.provider))delete i.provider[n];return{write:true,value:void 0}}).then(({config:i})=>({config:i}))}async function Oa(e){if(!ee(e)||!ee(e.models)){throw new H("Invalid managed MiniMax provider snapshot")}io(e);return An(async n=>{n.provider={...ee(n.provider)?n.provider:{},[ge]:structuredClone(e)};return{write:true,value:void 0}}).then(({config:n})=>({config:n}))}var H=class extends Error{name="LocalModelProviderConfigValidationError"};var Cn=class extends Error{name="LocalModelProviderConfigWriteError";constructor(){super("Local runtime failed to update config file")}};async function Pa(e){return An(async(n,i)=>{const t={minimax_api:ee(n.minimax_api)?n.minimax_api:void 0,custom_provider:Fa(ee(n.custom_provider)?n.custom_provider:void 0),minimaxModelSource:typeof n.minimaxModelSource==="string"?n.minimaxModelSource:void 0,defaultModel:typeof n.defaultModel==="string"?n.defaultModel:void 0,defaultModelVariant:typeof n.defaultModelVariant==="string"?n.defaultModelVariant:void 0};await e(t,i);for(const r of Ta){const l=t[r];if(l===void 0){delete n[r];continue}if(!ee(l)){throw new H(`Invalid BYOK config subtree "${r}"`)}io(l);n[r]=l}Oi(n,"minimaxModelSource",t.minimaxModelSource);if(n.defaultModel!==t.defaultModel){delete n.defaultModelThinking;delete n.defaultModelContextWindow}Oi(n,"defaultModel",t.defaultModel);Oi(n,"defaultModelVariant",t.defaultModelVariant);return{write:true,value:void 0}}).then(({config:n})=>({config:n}))}async function La(e){const n=e.modelKey.trim();if(!n){throw new H("Default model must not be empty")}if(e.contextLimit!==void 0&&(!Number.isSafeInteger(e.contextLimit)||e.contextLimit<=0||e.contextLimit>2147483647))throw new H("Invalid default context");if(e.thinking?.effort!==void 0&&(typeof e.thinking.effort!=="string"||!e.thinking.effort.trim()))throw new H("Invalid default effort");return An(async i=>{i.defaultModel=n;if(e.contextLimit===void 0)delete i.defaultModelContextWindow;else i.defaultModelContextWindow=e.contextLimit;if(e.thinking?.effort===void 0)delete i.defaultModelThinking;else i.defaultModelThinking={effort:e.thinking.effort};if(e.variant===void 0)delete i.defaultModelVariant;else i.defaultModelVariant=e.variant;return{write:true,value:void 0}}).then(({config:i})=>({config:i}))}async function Da(e,n){const i=e.modelId.trim();if(e.providerId!==ge&&e.providerId!==He||!i||oo.has(i)){throw new H("Invalid MiniMax model context target")}const t=await An(async(r,l)=>{const a=e.providerId===ge?l.provider?.[e.providerId]?.models?.[i]:Ko(l)[i];if(e.providerId===He&&!a?.contextWindowOptions?.includes(e.contextLimit)){throw new H("Invalid MiniMax API context limit")}if(a?.limit?.context!==e.expectedContextLimit){return{write:false,value:false}}if(!await n(l))return{write:false,value:false};const c=e.providerId===ge?["minimaxModelContextLimits",i]:["minimax_api","modelContextLimits",i];Ua(r,c,e.contextLimit);return{write:true,value:true}});return{config:t.config,updated:t.value}}async function An(e){const n=pe();let i;try{await Le.promises.mkdir(ls(n),{recursive:true});await Le.promises.writeFile(n,"",{flag:"a",mode:Pi});await Le.promises.chmod(n,Pi);i=await as.default.lock(n,{stale:1e4,retries:{retries:20,factor:1,minTimeout:5,maxTimeout:25}});const t=Ba(n);qe();const r=await e(t,_e());if(r.write){io(t);await Na(n,V.dump(t,{indent:2,lineWidth:-1,noRefs:true}));qe()}return{config:_e(),value:r.value}}catch(t){if(t instanceof H||t instanceof Cn){throw t}throw new Cn}finally{await i?.().catch(()=>void 0)}}async function Na(e,n){const i=wa(ls(e),`.config-tmp-${ka(6).toString("hex")}`);let t=false;try{const r=Pi;const l=await Le.promises.open(i,"wx",r);t=true;try{await l.writeFile(n,"utf-8");await l.chmod(r)}finally{await l.close()}await Le.promises.rename(i,e)}catch{if(t)await Le.promises.unlink(i).catch(()=>void 0);throw new Cn}}function Ba(e){const n=Le.readFileSync(e,"utf-8");let i;try{i=V.load(n)}catch{throw new H("Invalid config.yaml: unable to parse YAML")}if(i==null)return{};if(!ee(i)||Object.getPrototypeOf(i)!==Object.prototype){throw new H("Invalid config.yaml: expected a YAML mapping")}return i}function Fa(e){if(!e)return void 0;return Object.fromEntries(Object.entries(e).filter(([,n])=>ee(n)))}function Oi(e,n,i){if(i===void 0)delete e[n];else e[n]=i}function Ua(e,n,i){const t=n.at(-1);if(!t)throw new H("Invalid config path");let r=e;for(const l of n.slice(0,-1)){if(!l||oo.has(l)){throw new H("Invalid config path")}const a=r[l];if(ee(a))r=a;else{const c={};r[l]=c;r=c}}r[t]=i}function io(e){for(const[n,i]of Object.entries(e)){if(!n||oo.has(n)){throw new H(`Local runtime cannot update config field segment "${n}"`)}if(ee(i))io(i)}}function ee(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Xa(e){const n=e.trim();if(!n)return null;if(n.startsWith("{")){try{const t=JSON.parse(n);const r=typeof t.pid==="number"?t.pid:parseInt(String(t.pid),10);if(isNaN(r)||r<=0)return null;const l=za(t.owner)?t.owner:"unknown";const a=Ja(t.startedAt);return{pid:r,owner:l,...a!==void 0?{startedAt:a}:{},...typeof t.mode==="string"?{mode:t.mode}:{},...typeof t.startupToken==="string"?{startupToken:t.startupToken}:{}}}catch{return null}}const i=parseInt(n,10);if(isNaN(i)||i<=0)return null;return{pid:i,owner:"unknown"}}function za(e){return e==="electron"||e==="cli"||e==="unknown"}function Ja(e){if(typeof e==="number"&&Number.isFinite(e))return e;if(typeof e!=="string")return void 0;const n=new Date(e).getTime();return Number.isFinite(n)?n:void 0}function Qa(e,n){const i={pid:e,owner:n,startedAt:Date.now()};return JSON.stringify(i)}function Za(){const e=process.argv.slice(2);for(let n=0;n<e.length;n++){const i=e[n];const t=i==="--owner"?e[n+1]:i?.startsWith("--owner=")?i.slice(8):void 0;if(t==="electron")return"electron";if(t==="service"||t==="cli")return"cli"}return"cli"}import Re from"node:fs";import eu from"node:path";var us="local-runtime.auth.json";function re(e){return typeof e==="string"&&e.trim().length>0?e.trim():void 0}function Li(e){if(!e)return{};return{...re(e.accessToken)?{accessToken:re(e.accessToken)}:{},...re(e.realUserID)?{realUserID:re(e.realUserID)}:{},...re(e.userEmail)?{userEmail:re(e.userEmail)}:{},...re(e.userName)?{userName:re(e.userName)}:{},...re(e.subUserName)?{subUserName:re(e.subUserName)}:{}}}function to(e){return eu.join(e,us)}function nu(e){try{const n=Re.readFileSync(to(e),"utf-8");const i=JSON.parse(n);if(i.version!==1||!i.auth||typeof i.auth!=="object")return void 0;const t=Li(i.auth);return t.accessToken?t:void 0}catch{return void 0}}function ou(e,n,i={}){const t=to(e);const r=Li(n);if(!r.accessToken){cs(e);return{path:t,written:false}}Re.mkdirSync(e,{recursive:true,mode:448});const l={version:1,updatedAtMs:Date.now(),auth:r};const a=`${t}.${process.pid}.${Date.now()}.tmp`;Re.writeFileSync(a,`${JSON.stringify(l,null,2)}
19
- `,{encoding:"utf-8",mode:384});if(i.retryWindowsFileSystem){go(()=>Re.renameSync(a,t));go(()=>Re.chmodSync(t,384))}else{Re.renameSync(a,t);Re.chmodSync(t,384)}return{path:t,written:true}}function cs(e){try{Re.rmSync(to(e),{force:true})}catch{}}import ds from"node:net";var fs={"e2e-runtime":5e3,"e2e-ui":5500,"smoke-runtime":7e3};var Di=100;async function iu(e,n={}){const i=n.isPortFree??ru;const t=n.getFreePort??su;const r=n.getWorktreeBasePort??tu;const l=r()+fs[e];const a=l-r();if(a<Di){throw new Error(`pickTestPort(${e}): role offset ${a} collides with app runtime (0); must be >= ${Di}.`)}if(l>65535){return t()}if(await i(l))return l;return t()}function tu(){const e=Ie();return e.autoDetected?e.runtimePort:We}async function ru(e){return new Promise(n=>{const i=ds.createServer();i.once("error",()=>n(false));i.listen(e,"127.0.0.1",()=>{i.close(()=>n(true))})})}async function su(){return new Promise((e,n)=>{const i=ds.createServer();i.listen(0,"127.0.0.1",()=>{const t=i.address();if(t&&typeof t!=="string"){const{port:r}=t;i.close(()=>e(r))}else{i.close(()=>n(new Error("Failed to get free port")))}});i.on("error",n)})}import ps from"node:fs";import lu from"node:path";var au=new Set(["native","mcp"]);function gs(){return dn(_e().cuBackend)}function uu(e){if(!au.has(e)){throw new Error(`invalid cuBackend value: ${String(e)}`)}const n=pe();let i={};try{const t=ps.readFileSync(n,"utf-8");const r=V.load(t);if(r!=null&&typeof r==="object"&&!Array.isArray(r)){i=r}}catch{}i.cuBackend=e;ps.mkdirSync(lu.dirname(n),{recursive:true});ue(n,V.dump(i));qe()}function cu(e=gs()){$t(e)}import ms from"node:fs";var ze=class extends Error{code;configPath;constructor(n,i,t,r){super(t,r);this.name="ConfigFileError";this.code=n;this.configPath=i}};function ys(e){let n;try{n=ms.readFileSync(e,"utf-8")}catch(t){throw new ze("CONFIG_READ_FAILED",e,`Cannot read config ${e}.`,{cause:t})}let i;try{i=V.load(n)}catch(t){throw new ze("CONFIG_PARSE_FAILED",e,`Config is not valid YAML: ${e}`,{cause:t})}if(i==null||typeof i!=="object"||Array.isArray(i)){throw new ze("CONFIG_ROOT_INVALID",e,`Config root must be an object: ${e}`)}return i}function du(e,n){if(ms.existsSync(e))Si(e);return _i(ys(e),n.dataDir)}function fu(e,n){const i=ys(e);if(i.beta==null||typeof i.beta!=="object"||Array.isArray(i.beta)){return void 0}const t=i.beta[n];return typeof t==="boolean"?t:void 0}import pu from"node:fs";var Bi=Object.freeze({stopSubAgent:true,stopAsyncBash:true});var gu=["stopSubAgent","stopAsyncBash"];function Ni(e){const n=bs(e.conversation)?e.conversation:{};const i={...Bi};const t={stopSubAgent:"default",stopAsyncBash:"default"};const r=[];for(const l of gu){const a=n[l];if(typeof a==="boolean"){i[l]=a;t[l]="explicit"}else if(a!==void 0){r.push(l)}}return{...i,policySource:t,...r.length>0?{ignoredKeys:r}:{}}}function mu(e){let n;try{n=e??pe()}catch{return ro({reason:"path_error"})}let i;try{i=pu.readFileSync(n,"utf8")}catch(r){const l=yu(r);if(l==="ENOENT")return{...Ni({}),configPath:n};return ro({reason:"read_error",...l?{errorCode:l}:{}},n)}let t;try{t=V.load(i)}catch(r){const l=bu(r);return ro({reason:"yaml_error",...l?{line:l}:{}},n)}if(t==null)return{...Ni({}),configPath:n};if(!bs(t))return ro({reason:"not_a_mapping"},n);return{...Ni(t),configPath:n}}function ro(e,n){return{...Bi,policySource:{stopSubAgent:"read_failed",stopAsyncBash:"read_failed"},failure:e,...n?{configPath:n}:{}}}function bs(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function yu(e){const n=e?.code;return typeof n==="string"?n:void 0}function bu(e){const n=e?.mark?.line;return typeof n==="number"&&Number.isInteger(n)&&n>=0?n+1:void 0}export{mo as a,yo as b,V as c,Ko as d,cn as e,dn as f,fn as g,$o as h,Vn as i,Yo as j,Hs as k,Qt as l,Ke as m,Zt as n,Wo as o,Qo as p,Zo as q,ei as r,or as s,ni as t,Qs as u,el as v,nl as w,ol as x,il as y,ur as z,cr as A,dr as B,fr as C,pr as D,Z as E,ii as F,ti as G,te as H,ri as I,gn as J,si as K,li as L,mr as M,ui as N,ci as O,di as P,br as Q,Rr as R,fe as S,Gn as T,Yn as U,yi as V,_l as W,bi as X,Rl as Y,Er as Z,We as _,wr as $,Ol as aa,Ie as ba,Ll as ca,xi as da,pe as ea,Dr as fa,Ci as ga,Vl as ha,Kl as ia,qe as ja,_e as ka,Ur as la,jr as ma,ra as na,la as oa,jc as pa,Vc as qa,aa as ra,da as sa,fa as ta,Yr as ua,pa as va,ya as wa,vi as xa,Ri as ya,ge as za,He as Aa,Ei as Ba,ha as Ca,Mi as Da,Wr as Ea,xa as Fa,ki as Ga,Xr as Ha,zr as Ia,Jr as Ja,Qr as Ka,Zr as La,es as Ma,Qn as Na,hn as Oa,Ca as Pa,ns as Qa,Aa as Ra,Sa,os as Ta,Ti as Ua,is as Va,xn as Wa,Zn as Xa,ts as Ya,eo as Za,_a,rs as $a,ss as ab,va as bb,Xe as cb,Oe as db,wi as eb,Ra as fb,Ii as gb,Ma as hb,Ia as ib,Oa as jb,Pa as kb,La as lb,Da as mb,Xa as nb,Qa as ob,Za as pb,us as qb,Li as rb,to as sb,nu as tb,ou as ub,cs as vb,fs as wb,Di as xb,iu as yb,gs as zb,uu as Ab,cu as Bb,ze as Cb,du as Db,fu as Eb,Bi as Fb,mu as Gb};
18
+ ${l}`}function fa(e,n=process.env){return Gr({platform:e,internalBuild:n.__MAVIS_BUILD_INTERNAL==="true",insideBuild:n.__MAVIS_BUILD_INSIDE==="true"})}import{randomBytes as pa}from"node:crypto";import{promises as ve}from"node:fs";import{dirname as ga,join as $r}from"node:path";var Wr=Fi(Ui(),1);async function ma(e,n){const i=$r(e,"config.yaml");let t;let r=false;let l;try{await ve.mkdir(e,{recursive:true});await ve.writeFile(i,"",{flag:"a",mode:384});await ve.chmod(i,384);const a=await ve.realpath(i);t=$r(ga(a),`.config-tmp-${pa(6).toString("hex")}`);l=await Wr.default.lock(a,{stale:1e4,retries:{retries:20,factor:1,minTimeout:5,maxTimeout:25}});const c=V.load(await ve.readFile(a,"utf8"));const p=c??{};if(!Yr(p))throw new Error("Invalid config document");const u=p.tui??{};if(!Yr(u))throw new Error("Invalid TUI settings");const d={...u};if(n===void 0)delete d.statusLine;else d.statusLine=[...n];const h={...p,tui:d};const R=384;const k=await ve.open(t,"wx",R);r=true;try{await k.writeFile(V.dump(h,{lineWidth:-1,noRefs:true}),"utf8");await k.chmod(R)}finally{await k.close()}await ve.rename(t,a)}catch{throw new Error("Unable to save status line settings. Check config.yaml syntax and permissions.")}finally{if(r&&t)await ve.unlink(t).catch(()=>void 0);await l?.().catch(()=>void 0)}}function Yr(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function ya(e){if(typeof e!=="object"||e===null||Array.isArray(e))return{};const n=e;const i=n.kill_switch??n.killSwitch;const t=n.sample_rate??n.sampleRate;const r=n.default_enabled??n.defaultEnabled;return{...typeof i==="boolean"?{killSwitch:i}:{},...typeof t==="number"&&Number.isFinite(t)&&t>=0&&t<=1?{sampleRate:t}:{},...typeof r==="boolean"?{defaultEnabled:r}:{}}}function qr(e,n){if(typeof e==="boolean")return e;return n?.defaultEnabled??true}function ba(e,n){const i=qr(e.promptSuggestion?.enabled,n);return{...e,promptSuggestion:{...e.promptSuggestion,enabled:i}}}var ha=["agent.minimax.io","agent.minimax.cn","agent.minimaxi.com"];var xa=new Set(ha.map(e=>`https://${e}`));function Ca(e,n){return/^custom_provider:minimax-legacy(?:-\d+)?$/u.test(e)&&(!n||vi(n))}function vi(e){try{const n=new URL(e);if(n.username||n.password)return false;return xa.has(n.origin.toLowerCase())}catch{return false}}function Aa(e){if(e!=="managed-login"&&e!=="api-key"&&e!=="oauth")return void 0;return e}function Ri(e){const n=typeof e?.baseURL==="string"?e.baseURL.trim():"";const i=n.length>0&&vi(n);const t=Aa(e?.authMode);const r=[];if(typeof e?.authMode==="string"&&!t){r.push(`Unknown provider authMode "${e.authMode}"; falling back to compatibility resolution.`)}if(t){if(t==="managed-login"&&n.length>0&&!i&&!e?.allowManagedBaseURLOverride){r.push("Provider authMode is managed-login but baseURL is not a known managed MiniMax host.")}return{authMode:t,source:"explicit",managedBaseURL:i,warnings:r}}if(i){r.push("Provider authMode is inferred from a managed MiniMax baseURL; set options.authMode: managed-login to make this explicit.");return{authMode:"managed-login",source:"inferred-managed-base-url",managedBaseURL:i,warnings:r}}return{authMode:"api-key",source:"default-api-key",managedBaseURL:i,warnings:r}}var ge="minimax";var He="minimax_api";var Ei="custom_provider:";function Sa(e,n){return e==="anthropic-messages"&&(n===ge||n===He)}function Mi(e,n){if(n===He)return"minimax_api_key";if(n.startsWith(Ei))return"custom_provider";if(n!==ge)return"configured_provider";if(e.minimaxModelSource==="minimax_api_key")return"minimax_api_key";const i=e.provider?.[n]?.options;const t=Ri({authMode:i?.authMode,baseURL:i?.baseURL}).authMode;return t==="managed-login"?"managed_token_plan":"configured_provider"}function Hr(e,n,i){const t=Mi(e,n);switch(t){case"managed_token_plan":{return Jn(e.provider?.[n],true)}case"minimax_api_key":{const r=e.provider?.[ge];return Jn({...r,models:r?.models??je},true)}case"custom_provider":{const r=e.custom_provider?.[n.slice(Ei.length)];if(!r||r.enabled===false)return[];return Jn(r)}case"configured_provider":return Jn(e.provider?.[n])}}function _a(e){const n=Mi(e.config,e.providerId);const i=e.modelId.trim();if(i.length>0&&Hr(e.config,e.providerId,e.preset).includes(i)){return{available:true,route:n}}return{available:false,route:n,code:e.source==="config_default"?"DEFAULT_MODEL_NOT_AVAILABLE_FOR_ROUTE":"MODEL_NOT_AVAILABLE_FOR_ROUTE",message:`Model "${e.providerId}/${e.modelId}" is not available for the "${n}" route (preset ${e.preset}).`}}function Jn(e,n=false){const i=Object.entries(e?.models??{}).filter(([,a])=>a?.enabled!==false).map(([a])=>a);const t=e?.model_order;if(!n||!Array.isArray(t)||!t.every(a=>typeof a==="string")){return i}const r=new Set(i);const l=t.filter(a=>r.delete(a));return[...l,...i.filter(a=>r.has(a))]}import{createHash as zr}from"node:crypto";import Pe from"node:fs";import no from"node:os";import G from"node:path";var ki=".mcode-durable";var Jr="cas";var Qr="runtime.db";var Zr="mcoded.sock";var es="sessions";var ns=1;var os=G.join(no.homedir(),Pn);var Qn=class extends Error{code="LEGACY_WRITE_FORBIDDEN";targetPath;legacyRoot;constructor(n,i){super(`Refusing to write "${n}": the path falls inside the legacy data root "${i}", which the durable runtime only reads.`);this.name="LegacyWriteError";this.targetPath=n;this.legacyRoot=i}};function hn(e,n=no.homedir()){const i=Ue(e);const t=G.resolve(n);return G.join(t,i?`${ki}-${i}`:ki)}function va(e,n=ns){if(!Number.isInteger(n)||n<1){throw new RangeError(`Invalid session database generation ${n}. Use an integer >= 1.`)}return G.join(e,`${es}.g${n}.db`)}function is(e){return G.join(e,Jr)}function Ra(e){return G.join(e,Qr)}function Ea(e){const n=G.join(e,Zr);if(Buffer.byteLength(n)<=ts)return n;return Ti(e)}var ts=100;function Ti(e){const n=zr("sha256").update(G.resolve(e)).digest("hex").slice(0,12);const i=typeof process.getuid==="function"?process.getuid():0;return G.join(no.tmpdir(),`mcoded-${i}`,`${n}.sock`)}function rs(e){return G.dirname(Ti(e))}var xn="MCODE_SERVER_MODE";var Zn=class extends Error{code="SERVER_MODE_INVALID";value;constructor(n){super(`Invalid ${xn} value ${JSON.stringify(n)}. Expected one of: off, auto, required.`);this.name="ServerModeConfigError";this.value=n}};function ss(e=process.env){const n=e[xn];if(n===void 0||n.trim()==="")return"auto";const i=n.trim().toLowerCase();if(i==="off"||i==="auto"||i==="required")return i;throw new Zn(n)}var eo=class extends Error{code="SERVER_MODE_OFF";constructor(){super(`Refusing to start the daemon: ${xn} is 'off'. Set ${xn}=auto or =required, or use the in-process runtime.`);this.name="ServerModeOffError"}};function Ma(e=process.env){const n=ss(e);if(n==="off")throw new eo;return n}var ls="dd-";function as(e,n){const i=G.resolve(e);const t=Xe(n);if(t===Xe(ln(i,null))){return{kind:"default"}}const r=`${Pn}-`;const l=new Set;const a=G.basename(t);if(a.startsWith(r))l.add(a.slice(r.length));let c;try{c=Pe.readdirSync(i,{withFileTypes:true})}catch{c=[]}for(const p of c){if(p.name.startsWith(r))l.add(p.name.slice(r.length))}for(const p of l){let u;try{u=Ue(p)}catch{continue}if(u===null)continue;if(t===Xe(ln(i,u))){return{kind:"profile",profile:u}}}return{kind:"foreign"}}function ka(e={}){const n=e.homeDir??no.homedir();const i=e.profile??null;const t=hn(i,n);const r=e.dataDir?.trim();if(!r)return t;const l=Xe(r);const a=Xe(ln(n,i));if(l===a)return t;if(i===null){const p=as(n,l);if(p.kind==="profile")return hn(p.profile,n);if(p.kind==="default")return hn(null,n)}const c=zr("sha256").update(l).digest("hex").slice(0,16);return G.join(hn(null,n),`${ls}${c}`)}function Xe(e){const n=G.resolve(e);try{return Pe.realpathSync(n)}catch{return n}}var Oe=class extends Error{code="CONTROL_ROOT_INSECURE";controlRoot;constructor(n,i){super(`Refusing to use control root "${n}": ${i}`);this.name="ControlRootInsecureError";this.controlRoot=n}};function wi(e){let n;try{n=Pe.statSync(e)}catch{throw new Oe(e,"the directory does not exist")}if(!n.isDirectory()){throw new Oe(e,"the path is not a directory")}const i=typeof process.getuid==="function"?process.getuid():void 0;if(i!==void 0&&n.uid!==i){throw new Oe(e,`it is owned by uid ${n.uid}, not by ${i}`)}if((n.mode&18)!==0){throw new Oe(e,`it is writable by group or other (mode ${(n.mode&511).toString(8)})`)}return e}function wa(e){Ii(e);Pe.mkdirSync(e,{recursive:true,mode:448});const n=rs(e);if(n!==e){Pe.mkdirSync(n,{recursive:true,mode:448});wi(n)}wi(e);return e}function Xr(e){let n=G.resolve(e);if(process.platform==="win32"){n=n.replace(/^\\\\\?\\/,"");return n.toLowerCase()}return n}function Ta(e,n){const i=Xr(n);const t=G.dirname(i);const r=G.relative(t,Xr(e));if(r===""||r===".."||r.startsWith(`..${G.sep}`)||G.isAbsolute(r)){return false}const[l]=r.split(G.sep);const a=G.basename(i);return l!==void 0&&(l===a||l.startsWith(`${a}-`))}function Ii(e,n=os){if(Ta(e,n))throw new Qn(e,n);return e}function Ia(e){Ii(e);Pe.mkdirSync(e,{recursive:true});Pe.mkdirSync(is(e),{recursive:true})}import{randomBytes as Oa}from"node:crypto";import Le from"node:fs";import{dirname as us,join as Pa}from"node:path";var cs=Fi(Ui(),1);var Pi=384;var oo=new Set(["__proto__","prototype","constructor"]);var La=["minimax_api","custom_provider"];async function Da(e){const n=e.trim();if(!n||n.includes(".")||oo.has(n)){throw new H("Invalid provider id")}return An(async i=>{if(ee(i.provider))delete i.provider[n];return{write:true,value:void 0}}).then(({config:i})=>({config:i}))}async function Na(e){if(!ee(e)||!ee(e.models)){throw new H("Invalid managed MiniMax provider snapshot")}io(e);return An(async n=>{n.provider={...ee(n.provider)?n.provider:{},[ge]:structuredClone(e)};return{write:true,value:void 0}}).then(({config:n})=>({config:n}))}var H=class extends Error{name="LocalModelProviderConfigValidationError"};var Cn=class extends Error{name="LocalModelProviderConfigWriteError";constructor(){super("Local runtime failed to update config file")}};async function Ba(e){return An(async(n,i)=>{const t={minimax_api:ee(n.minimax_api)?n.minimax_api:void 0,custom_provider:Ka(ee(n.custom_provider)?n.custom_provider:void 0),minimaxModelSource:typeof n.minimaxModelSource==="string"?n.minimaxModelSource:void 0,defaultModel:typeof n.defaultModel==="string"?n.defaultModel:void 0,defaultModelVariant:typeof n.defaultModelVariant==="string"?n.defaultModelVariant:void 0};await e(t,i);for(const r of La){const l=t[r];if(l===void 0){delete n[r];continue}if(!ee(l)){throw new H(`Invalid BYOK config subtree "${r}"`)}io(l);n[r]=l}Oi(n,"minimaxModelSource",t.minimaxModelSource);if(n.defaultModel!==t.defaultModel){delete n.defaultModelThinking;delete n.defaultModelContextWindow}Oi(n,"defaultModel",t.defaultModel);Oi(n,"defaultModelVariant",t.defaultModelVariant);return{write:true,value:void 0}}).then(({config:n})=>({config:n}))}async function Fa(e){const n=e.modelKey.trim();if(!n){throw new H("Default model must not be empty")}if(e.contextLimit!==void 0&&(!Number.isSafeInteger(e.contextLimit)||e.contextLimit<=0||e.contextLimit>2147483647))throw new H("Invalid default context");if(e.thinking?.effort!==void 0&&(typeof e.thinking.effort!=="string"||!e.thinking.effort.trim()))throw new H("Invalid default effort");return An(async i=>{i.defaultModel=n;if(e.contextLimit===void 0)delete i.defaultModelContextWindow;else i.defaultModelContextWindow=e.contextLimit;if(e.thinking?.effort===void 0)delete i.defaultModelThinking;else i.defaultModelThinking={effort:e.thinking.effort};if(e.variant===void 0)delete i.defaultModelVariant;else i.defaultModelVariant=e.variant;return{write:true,value:void 0}}).then(({config:i})=>({config:i}))}async function Ua(e,n){const i=e.modelId.trim();if(e.providerId!==ge&&e.providerId!==He||!i||oo.has(i)){throw new H("Invalid MiniMax model context target")}const t=await An(async(r,l)=>{const a=e.providerId===ge?l.provider?.[e.providerId]?.models?.[i]:Ko(l)[i];if(e.providerId===He&&!a?.contextWindowOptions?.includes(e.contextLimit)){throw new H("Invalid MiniMax API context limit")}if(a?.limit?.context!==e.expectedContextLimit){return{write:false,value:false}}if(!await n(l))return{write:false,value:false};const c=e.providerId===ge?["minimaxModelContextLimits",i]:["minimax_api","modelContextLimits",i];Ga(r,c,e.contextLimit);return{write:true,value:true}});return{config:t.config,updated:t.value}}async function An(e){const n=pe();let i;try{await Le.promises.mkdir(us(n),{recursive:true});await Le.promises.writeFile(n,"",{flag:"a",mode:Pi});await Le.promises.chmod(n,Pi);i=await cs.default.lock(n,{stale:1e4,retries:{retries:20,factor:1,minTimeout:5,maxTimeout:25}});const t=Va(n);qe();const r=await e(t,_e());if(r.write){io(t);await ja(n,V.dump(t,{indent:2,lineWidth:-1,noRefs:true}));qe()}return{config:_e(),value:r.value}}catch(t){if(t instanceof H||t instanceof Cn){throw t}throw new Cn}finally{await i?.().catch(()=>void 0)}}async function ja(e,n){const i=Pa(us(e),`.config-tmp-${Oa(6).toString("hex")}`);let t=false;try{const r=Pi;const l=await Le.promises.open(i,"wx",r);t=true;try{await l.writeFile(n,"utf-8");await l.chmod(r)}finally{await l.close()}await Le.promises.rename(i,e)}catch{if(t)await Le.promises.unlink(i).catch(()=>void 0);throw new Cn}}function Va(e){const n=Le.readFileSync(e,"utf-8");let i;try{i=V.load(n)}catch{throw new H("Invalid config.yaml: unable to parse YAML")}if(i==null)return{};if(!ee(i)||Object.getPrototypeOf(i)!==Object.prototype){throw new H("Invalid config.yaml: expected a YAML mapping")}return i}function Ka(e){if(!e)return void 0;return Object.fromEntries(Object.entries(e).filter(([,n])=>ee(n)))}function Oi(e,n,i){if(i===void 0)delete e[n];else e[n]=i}function Ga(e,n,i){const t=n.at(-1);if(!t)throw new H("Invalid config path");let r=e;for(const l of n.slice(0,-1)){if(!l||oo.has(l)){throw new H("Invalid config path")}const a=r[l];if(ee(a))r=a;else{const c={};r[l]=c;r=c}}r[t]=i}function io(e){for(const[n,i]of Object.entries(e)){if(!n||oo.has(n)){throw new H(`Local runtime cannot update config field segment "${n}"`)}if(ee(i))io(i)}}function ee(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Za(e){const n=e.trim();if(!n)return null;if(n.startsWith("{")){try{const t=JSON.parse(n);const r=typeof t.pid==="number"?t.pid:parseInt(String(t.pid),10);if(isNaN(r)||r<=0)return null;const l=eu(t.owner)?t.owner:"unknown";const a=nu(t.startedAt);return{pid:r,owner:l,...a!==void 0?{startedAt:a}:{},...typeof t.mode==="string"?{mode:t.mode}:{},...typeof t.startupToken==="string"?{startupToken:t.startupToken}:{}}}catch{return null}}const i=parseInt(n,10);if(isNaN(i)||i<=0)return null;return{pid:i,owner:"unknown"}}function eu(e){return e==="electron"||e==="cli"||e==="unknown"}function nu(e){if(typeof e==="number"&&Number.isFinite(e))return e;if(typeof e!=="string")return void 0;const n=new Date(e).getTime();return Number.isFinite(n)?n:void 0}function ou(e,n){const i={pid:e,owner:n,startedAt:Date.now()};return JSON.stringify(i)}function iu(){const e=process.argv.slice(2);for(let n=0;n<e.length;n++){const i=e[n];const t=i==="--owner"?e[n+1]:i?.startsWith("--owner=")?i.slice(8):void 0;if(t==="electron")return"electron";if(t==="service"||t==="cli")return"cli"}return"cli"}import Re from"node:fs";import tu from"node:path";var ds="local-runtime.auth.json";function re(e){return typeof e==="string"&&e.trim().length>0?e.trim():void 0}function Li(e){if(!e)return{};return{...re(e.accessToken)?{accessToken:re(e.accessToken)}:{},...re(e.realUserID)?{realUserID:re(e.realUserID)}:{},...re(e.userEmail)?{userEmail:re(e.userEmail)}:{},...re(e.userName)?{userName:re(e.userName)}:{},...re(e.subUserName)?{subUserName:re(e.subUserName)}:{}}}function to(e){return tu.join(e,ds)}function ru(e){try{const n=Re.readFileSync(to(e),"utf-8");const i=JSON.parse(n);if(i.version!==1||!i.auth||typeof i.auth!=="object")return void 0;const t=Li(i.auth);return t.accessToken?t:void 0}catch{return void 0}}function su(e,n,i={}){const t=to(e);const r=Li(n);if(!r.accessToken){fs(e);return{path:t,written:false}}Re.mkdirSync(e,{recursive:true,mode:448});const l={version:1,updatedAtMs:Date.now(),auth:r};const a=`${t}.${process.pid}.${Date.now()}.tmp`;Re.writeFileSync(a,`${JSON.stringify(l,null,2)}
19
+ `,{encoding:"utf-8",mode:384});if(i.retryWindowsFileSystem){go(()=>Re.renameSync(a,t));go(()=>Re.chmodSync(t,384))}else{Re.renameSync(a,t);Re.chmodSync(t,384)}return{path:t,written:true}}function fs(e){try{Re.rmSync(to(e),{force:true})}catch{}}import ps from"node:net";var gs={"e2e-runtime":5e3,"e2e-ui":5500,"smoke-runtime":7e3};var Di=100;async function lu(e,n={}){const i=n.isPortFree??uu;const t=n.getFreePort??cu;const r=n.getWorktreeBasePort??au;const l=r()+gs[e];const a=l-r();if(a<Di){throw new Error(`pickTestPort(${e}): role offset ${a} collides with app runtime (0); must be >= ${Di}.`)}if(l>65535){return t()}if(await i(l))return l;return t()}function au(){const e=Ie();return e.autoDetected?e.runtimePort:We}async function uu(e){return new Promise(n=>{const i=ps.createServer();i.once("error",()=>n(false));i.listen(e,"127.0.0.1",()=>{i.close(()=>n(true))})})}async function cu(){return new Promise((e,n)=>{const i=ps.createServer();i.listen(0,"127.0.0.1",()=>{const t=i.address();if(t&&typeof t!=="string"){const{port:r}=t;i.close(()=>e(r))}else{i.close(()=>n(new Error("Failed to get free port")))}});i.on("error",n)})}import ms from"node:fs";import du from"node:path";var fu=new Set(["native","mcp"]);function ys(){return dn(_e().cuBackend)}function pu(e){if(!fu.has(e)){throw new Error(`invalid cuBackend value: ${String(e)}`)}const n=pe();let i={};try{const t=ms.readFileSync(n,"utf-8");const r=V.load(t);if(r!=null&&typeof r==="object"&&!Array.isArray(r)){i=r}}catch{}i.cuBackend=e;ms.mkdirSync(du.dirname(n),{recursive:true});ue(n,V.dump(i));qe()}function gu(e=ys()){$t(e)}import bs from"node:fs";var ze=class extends Error{code;configPath;constructor(n,i,t,r){super(t,r);this.name="ConfigFileError";this.code=n;this.configPath=i}};function hs(e){let n;try{n=bs.readFileSync(e,"utf-8")}catch(t){throw new ze("CONFIG_READ_FAILED",e,`Cannot read config ${e}.`,{cause:t})}let i;try{i=V.load(n)}catch(t){throw new ze("CONFIG_PARSE_FAILED",e,`Config is not valid YAML: ${e}`,{cause:t})}if(i==null||typeof i!=="object"||Array.isArray(i)){throw new ze("CONFIG_ROOT_INVALID",e,`Config root must be an object: ${e}`)}return i}function mu(e,n){if(bs.existsSync(e))Si(e);return _i(hs(e),n.dataDir)}function yu(e,n){const i=hs(e);if(i.beta==null||typeof i.beta!=="object"||Array.isArray(i.beta)){return void 0}const t=i.beta[n];return typeof t==="boolean"?t:void 0}import bu from"node:fs";var Bi=Object.freeze({stopSubAgent:true,stopAsyncBash:true});var hu=["stopSubAgent","stopAsyncBash"];function Ni(e){const n=xs(e.conversation)?e.conversation:{};const i={...Bi};const t={stopSubAgent:"default",stopAsyncBash:"default"};const r=[];for(const l of hu){const a=n[l];if(typeof a==="boolean"){i[l]=a;t[l]="explicit"}else if(a!==void 0){r.push(l)}}return{...i,policySource:t,...r.length>0?{ignoredKeys:r}:{}}}function xu(e){let n;try{n=e??pe()}catch{return ro({reason:"path_error"})}let i;try{i=bu.readFileSync(n,"utf8")}catch(r){const l=Cu(r);if(l==="ENOENT")return{...Ni({}),configPath:n};return ro({reason:"read_error",...l?{errorCode:l}:{}},n)}let t;try{t=V.load(i)}catch(r){const l=Au(r);return ro({reason:"yaml_error",...l?{line:l}:{}},n)}if(t==null)return{...Ni({}),configPath:n};if(!xs(t))return ro({reason:"not_a_mapping"},n);return{...Ni(t),configPath:n}}function ro(e,n){return{...Bi,policySource:{stopSubAgent:"read_failed",stopAsyncBash:"read_failed"},failure:e,...n?{configPath:n}:{}}}function xs(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function Cu(e){const n=e?.code;return typeof n==="string"?n:void 0}function Au(e){const n=e?.mark?.line;return typeof n==="number"&&Number.isInteger(n)&&n>=0?n+1:void 0}export{mo as a,yo as b,V as c,Ko as d,cn as e,dn as f,fn as g,$o as h,Vn as i,Yo as j,zs as k,Qt as l,Ke as m,Zt as n,Wo as o,Qo as p,Zo as q,or as r,Js as s,ir as t,Qs as u,ei as v,tr as w,ni as x,ol as y,tl as z,rl as A,sl as B,ll as C,dr as D,fr as E,pr as F,gr as G,mr as H,Z as I,ii as J,ti as K,te as L,ri as M,gn as N,si as O,li as P,br as Q,ui as R,ci as S,di as T,xr as U,Mr as V,fe as W,Gn as X,Yn as Y,yi as Z,Ml as _,bi as $,wl as aa,kr as ba,We as ca,Ir as da,Nl as ea,Ie as fa,Fl as ga,xi as ha,pe as ia,Br as ja,Ci as ka,Yl as la,Wl as ma,qe as na,_e as oa,Vr as pa,Kr as qa,ua as ra,da as sa,$c as ta,Yc as ua,fa as va,ma as wa,ya as xa,qr as ya,ba as za,Ca as Aa,vi as Ba,Ri as Ca,ge as Da,He as Ea,Ei as Fa,Sa as Ga,Mi as Ha,Hr as Ia,_a as Ja,ki as Ka,Jr as La,Qr as Ma,Zr as Na,es as Oa,ns as Pa,os as Qa,Qn as Ra,hn as Sa,va as Ta,is as Ua,Ra as Va,Ea as Wa,ts as Xa,Ti as Ya,rs as Za,xn as _a,Zn as $a,ss as ab,eo as bb,Ma as cb,ls as db,as as eb,ka as fb,Xe as gb,Oe as hb,wi as ib,wa as jb,Ii as kb,Ia as lb,Da as mb,Na as nb,Ba as ob,Fa as pb,Ua as qb,Za as rb,ou as sb,iu as tb,ds as ub,Li as vb,to as wb,ru as xb,su as yb,fs as zb,gs as Ab,Di as Bb,lu as Cb,ys as Db,pu as Eb,gu as Fb,ze as Gb,mu as Hb,yu as Ib,Bi as Jb,xu as Kb};