@minimax-ai/code 0.4.6 → 0.4.7

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 (76) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/CHANGELOG.zh-CN.md +19 -0
  3. package/README.md +13 -0
  4. package/README.zh-CN.md +10 -0
  5. package/assets/agents/_default/prompt-base-all.md +35 -141
  6. package/assets/agents/_default/prompt-base-all.md.hbs +6 -4
  7. package/assets/agents/_default/prompt-base-worker.md +8 -19
  8. package/assets/agents/_default/prompt-session-branch.md +0 -1
  9. package/assets/agents/_default/prompt-session-root.md +4 -32
  10. package/assets/agents/_v2/AGENT_CONTEXT.md.hbs +222 -0
  11. package/assets/agents/_v2/coding/SYSTEM.md.hbs +161 -0
  12. package/assets/agents/_v2/explore.md.hbs +30 -0
  13. package/assets/agents/_v2/tui/SYSTEM.md.hbs +147 -0
  14. package/assets/agents/_v2/verifier.md.hbs +32 -0
  15. package/assets/agents/_v2/work/SYSTEM.md.hbs +173 -0
  16. package/assets/agents/_v2/worker.md.hbs +27 -0
  17. package/assets/agents/managed-prompts.json +8 -1
  18. package/assets/agents/mavis/PERSONA-zh.md +0 -13
  19. package/assets/agents/mavis/PERSONA.md +0 -13
  20. package/assets/agents/mavis/features/recoverable-deletion.md.hbs +10 -0
  21. package/assets/agents/mavis/modes/coding/online/SYSTEM.md.hbs +2 -0
  22. package/assets/agents/mavis/modes/work/online/SYSTEM.md.hbs +2 -0
  23. package/assets/agents/mavis/prompt-session-root.md +4 -46
  24. package/assets/agents/mavis/prompt-session-root.md.hbs +4 -46
  25. package/assets/agents/mavis/skills/control-in-app-browser/SKILL.md +0 -8
  26. package/assets/agents/mavis/skills/minimax-code-product/SKILL.md +2 -2
  27. package/assets/agents/mavis/system-prompt.md.hbs +47 -37
  28. package/assets/agents/prompt-exemptions.json +2 -12
  29. package/assets/agents/verifier/agent.md +3 -0
  30. package/assets/agents/worker/agent.md +3 -0
  31. package/chunks/{application-FCLZ6WHZ.js → application-OZ6YEJNG.js} +1 -1
  32. package/chunks/{auth-command-HEXCI24E.js → auth-command-TP25VHV4.js} +1 -1
  33. package/chunks/{chunk-AAJMOWWM.js → chunk-22LVIQ2T.js} +1 -1
  34. package/chunks/{chunk-6BYKHQOV.js → chunk-2SW3R5AB.js} +31 -17
  35. package/chunks/{chunk-E2J47VVN.js → chunk-AJSGEEWR.js} +1 -1
  36. package/chunks/{chunk-Y27DNFV2.js → chunk-B2NJMA4I.js} +32 -32
  37. package/chunks/{chunk-NF72FWAW.js → chunk-BNU46XHR.js} +1 -1
  38. package/chunks/{chunk-LJXS2KRC.js → chunk-C2OVBAOI.js} +1 -1
  39. package/chunks/{chunk-FLEWADRD.js → chunk-KVMK6REW.js} +1 -1
  40. package/chunks/{chunk-4FNXBXOU.js → chunk-OVLV6FQA.js} +863 -869
  41. package/chunks/{chunk-4NX3LPKA.js → chunk-QJWOGW27.js} +1 -1
  42. package/chunks/{chunk-V7D3N7GI.js → chunk-SYLCIHHV.js} +1 -1
  43. package/chunks/{chunk-MNN6EKX3.js → chunk-W7JHDTPW.js} +1 -1
  44. package/chunks/{chunk-J756IG32.js → chunk-YBZTB54I.js} +804 -798
  45. package/chunks/{data-dir-LETCXX3O.js → data-dir-KTXCGPJZ.js} +1 -1
  46. package/chunks/{dist-63B3F7A6.js → dist-MM7GHB2J.js} +1 -1
  47. package/chunks/{install-source-4BFOZZBU.js → install-source-3CE52ZIN.js} +1 -1
  48. package/chunks/{launcher-TV5PCI3Y.js → launcher-BNIFOBXD.js} +3 -3
  49. package/chunks/{lifecycle-ON5VQU5P.js → lifecycle-EKT5LQIE.js} +1 -1
  50. package/chunks/{main-TWT22DQQ.js → main-FAPYW7S4.js} +9 -9
  51. package/chunks/{plugin-command-K2IRBTGL.js → plugin-command-TD3DWK7U.js} +1 -1
  52. package/chunks/{provider-command-PJOTRG7S.js → provider-command-AQPDCWDR.js} +1 -1
  53. package/chunks/{run-acp-command-ATGVOKDQ.js → run-acp-command-OPS4CBHL.js} +2 -2
  54. package/chunks/run-exec-command-QR3TWWDO.js +17 -0
  55. package/chunks/{update-4OXHCWOL.js → update-KWS4AOND.js} +1 -1
  56. package/cli.js +2 -2
  57. package/configs/data-minimal.yaml +0 -2
  58. package/embedded/mcode-tools/cli.mjs +19119 -4
  59. package/embedded/mcode-tools/manifest.json +27 -5
  60. package/embedded/mcode-tools/native/registry-js.LICENSE +21 -0
  61. package/embedded/mcode-tools/native/win32-arm64/registry.node +0 -0
  62. package/embedded/mcode-tools/native/win32-ia32/registry.node +0 -0
  63. package/embedded/mcode-tools/native/win32-x64/registry.node +0 -0
  64. package/package.json +1 -1
  65. package/assets/agents/_tui/prompt-base-all.md.hbs +0 -12
  66. package/assets/agents/_tui/prompt-base-windows.md.hbs +0 -45
  67. package/assets/agents/_tui/prompt-base-worker.md.hbs +0 -4
  68. package/assets/agents/_tui/prompt-session-branch.md.hbs +0 -13
  69. package/assets/agents/_tui/prompt-session-root.md.hbs +0 -4
  70. package/assets/agents/mavis/tui/PERSONA-zh.md.hbs +0 -17
  71. package/assets/agents/mavis/tui/PERSONA.md.hbs +0 -22
  72. package/assets/agents/mavis/tui/SYSTEM.md.hbs +0 -110
  73. package/assets/agents/mavis/tui/features/delegation.md.hbs +0 -54
  74. package/assets/agents/mavis/tui/features/task-management.md.hbs +0 -11
  75. package/assets/agents/mavis/tui/features/web-search.md.hbs +0 -7
  76. package/chunks/run-exec-command-SHZVUF36.js +0 -17
@@ -1,38 +1,52 @@
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 Ei}from"./chunk-2ZG44JU6.js";import{l as un}from"./chunk-Y27DNFV2.js";import{e as vi}from"./chunk-D76SO2ME.js";function Si(e){return!1}function hc(e){return e.replace(/^## MCP\/App citation examples\r?\n\r?\n```\r?\n[\s\S]*?^```\r?\n\s*/gm,n=>n.includes("#mavis-source=")?"":n).replace(/^## Citations\r?\n\r?\nCite 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 xc(e){return[[e.includes("- **Security first.** Never introduce code that exposes or logs secrets.")?"- **Security first.** Never introduce code that exposes or logs secrets.":"- **Mimic existing patterns.** Look at neighboring files for naming, typing, and framework choices.","- When referencing code, use `file_path:line_number` format."],["- Keep each numbered item as one complete semantic unit. Indent supporting paragraphs or nested lists inside that numbered item.","- 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."],["- Independent tool calls can run in parallel in one response.","- Reference code as `file_path:line_number` \u2014 it's clickable."]].reduce((i,[r,t])=>i.includes(t)?i:i.replace(r,`${r}
3
- ${t}`),e)}function uo(e,n=process.env){return Si({platform:e,internalBuild:n.__MAVIS_BUILD_INTERNAL==="true",insideBuild:n.__MAVIS_BUILD_INSIDE==="true"})}import{randomBytes as Tl}from"node:crypto";import{promises as U}from"node:fs";import{dirname as Ol,join as kr}from"node:path";function ji(e){return typeof e>"u"||e===null}function co(e){return typeof e=="object"&&e!==null}function fo(e){return Array.isArray(e)?e:ji(e)?[]:[e]}function po(e,n){var i,r,t,o;if(n)for(o=Object.keys(n),i=0,r=o.length;i<r;i+=1)t=o[i],e[t]=n[t];return e}function mo(e,n){var i="",r;for(r=0;r<n;r+=1)i+=e;return i}function go(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var yo=ji,ho=co,xo=fo,bo=mo,Ao=go,_o=po,v={isNothing:yo,isObject:ho,toArray:xo,repeat:bo,isNegativeZero:Ao,extend:_o};function $i(e,n){var i="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(i+='in "'+e.mark.name+'" '),i+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!n&&e.mark.snippet&&(i+=`
2
+ import{a as Ei}from"./chunk-2ZG44JU6.js";import{l as un}from"./chunk-B2NJMA4I.js";import{e as vi}from"./chunk-D76SO2ME.js";function Si(e){return!1}function bc(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 Ac(e){let i=["- 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."].find(c=>e.includes(c));if(!i)return e;let r="- Reference code as `file_path:line_number` \u2014 it's clickable.",t="- 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.",o=["- 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(`
3
+ `),l=["- 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.",r,"- Reference code as `file_path:line_number` \u2014 it's clickable in the TUI."].reduce((c,f)=>c.replaceAll(`${f}\r
4
+ `,"").replaceAll(`${f}
5
+ `,""),e.replace(t,"- Place references near the relevant claim; group them only when there are many files.")).replace(i,`${i}
6
+ ${r}`);if(l.includes(o))return l;let s=/^(#{1,2}) Communication & Delivery\r?$/m.exec(l);if(s){let c=s[1],f=s.index+s[0].length,d=new RegExp(`^(?:#{1,${c.length}} |\\{\\{[#/])`,"m").exec(l.slice(f)),p=d?f+d.index:l.length;return`${l.slice(0,p).trimEnd()}
4
7
 
5
- `+e.mark.snippet),r+" "+i):r}function Ae(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=$i(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Ae.prototype=Object.create(Error.prototype);Ae.prototype.constructor=Ae;Ae.prototype.toString=function(n){return this.name+": "+$i(this,n)};var L=Ae;function cn(e,n,i,r,t){var o="",a="",l=Math.floor(t/2)-1;return r-n>l&&(o=" ... ",n=r-l+o.length),i-r>l&&(a=" ...",i=r+l-a.length),{str:o+e.slice(n,i).replace(/\t/g,"\u2192")+a,pos:r-n+o.length}}function fn(e,n){return v.repeat(" ",n-e.length)+e}function vo(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var i=/\r?\n|\r|\0/g,r=[0],t=[],o,a=-1;o=i.exec(e.buffer);)t.push(o.index),r.push(o.index+o[0].length),e.position<=o.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l="",s,u,c=Math.min(e.line+n.linesAfter,t.length).toString().length,f=n.maxLength-(n.indent+c+3);for(s=1;s<=n.linesBefore&&!(a-s<0);s++)u=cn(e.buffer,r[a-s],t[a-s],e.position-(r[a]-r[a-s]),f),l=v.repeat(" ",n.indent)+fn((e.line-s+1).toString(),c)+" | "+u.str+`
8
+ ${c}# References
9
+ ${o}
10
+
11
+ ${l.slice(p)}`}let u=/^(#{2,4}) (?:Media Output|Deliverable Files)\r?$/m;return u.test(l)?l.replace(u,(c,f)=>`${f} References
12
+ ${o}
13
+
14
+ ${c}`):`${l.trimEnd()}
15
+
16
+ ## References
17
+ ${o}`}function co(e,n=process.env){return Si({platform:e,internalBuild:n.__MAVIS_BUILD_INTERNAL==="true",insideBuild:n.__MAVIS_BUILD_INSIDE==="true"})}import{randomBytes as Rl}from"node:crypto";import{promises as j}from"node:fs";import{dirname as Ol,join as kr}from"node:path";function ji(e){return typeof e>"u"||e===null}function fo(e){return typeof e=="object"&&e!==null}function po(e){return Array.isArray(e)?e:ji(e)?[]:[e]}function mo(e,n){var i,r,t,o;if(n)for(o=Object.keys(n),i=0,r=o.length;i<r;i+=1)t=o[i],e[t]=n[t];return e}function go(e,n){var i="",r;for(r=0;r<n;r+=1)i+=e;return i}function yo(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var ho=ji,xo=fo,bo=po,Ao=go,_o=yo,vo=mo,v={isNothing:ho,isObject:xo,toArray:bo,repeat:Ao,isNegativeZero:_o,extend:vo};function $i(e,n){var i="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(i+='in "'+e.mark.name+'" '),i+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!n&&e.mark.snippet&&(i+=`
18
+
19
+ `+e.mark.snippet),r+" "+i):r}function Ae(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=$i(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Ae.prototype=Object.create(Error.prototype);Ae.prototype.constructor=Ae;Ae.prototype.toString=function(n){return this.name+": "+$i(this,n)};var L=Ae;function cn(e,n,i,r,t){var o="",a="",l=Math.floor(t/2)-1;return r-n>l&&(o=" ... ",n=r-l+o.length),i-r>l&&(a=" ...",i=r+l-a.length),{str:o+e.slice(n,i).replace(/\t/g,"\u2192")+a,pos:r-n+o.length}}function fn(e,n){return v.repeat(" ",n-e.length)+e}function Eo(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var i=/\r?\n|\r|\0/g,r=[0],t=[],o,a=-1;o=i.exec(e.buffer);)t.push(o.index),r.push(o.index+o[0].length),e.position<=o.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l="",s,u,c=Math.min(e.line+n.linesAfter,t.length).toString().length,f=n.maxLength-(n.indent+c+3);for(s=1;s<=n.linesBefore&&!(a-s<0);s++)u=cn(e.buffer,r[a-s],t[a-s],e.position-(r[a]-r[a-s]),f),l=v.repeat(" ",n.indent)+fn((e.line-s+1).toString(),c)+" | "+u.str+`
6
20
  `+l;for(u=cn(e.buffer,r[a],t[a],e.position,f),l+=v.repeat(" ",n.indent)+fn((e.line+1).toString(),c)+" | "+u.str+`
7
21
  `,l+=v.repeat("-",n.indent+c+3+u.pos)+`^
8
22
  `,s=1;s<=n.linesAfter&&!(a+s>=t.length);s++)u=cn(e.buffer,r[a+s],t[a+s],e.position-(r[a]-r[a+s]),f),l+=v.repeat(" ",n.indent)+fn((e.line+s+1).toString(),c)+" | "+u.str+`
9
- `;return l.replace(/\n$/,"")}var Eo=vo,So=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Co=["scalar","sequence","mapping"];function Mo(e){var n={};return e!==null&&Object.keys(e).forEach(function(i){e[i].forEach(function(r){n[String(r)]=i})}),n}function Io(e,n){if(n=n||{},Object.keys(n).forEach(function(i){if(So.indexOf(i)===-1)throw new L('Unknown option "'+i+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(i){return i},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||!1,this.styleAliases=Mo(n.styleAliases||null),Co.indexOf(this.kind)===-1)throw new L('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var M=Io;function Ci(e,n){var i=[];return e[n].forEach(function(r){var t=i.length;i.forEach(function(o,a){o.tag===r.tag&&o.kind===r.kind&&o.multi===r.multi&&(t=a)}),i[t]=r}),i}function ko(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,i;function r(t){t.multi?(e.multi[t.kind].push(t),e.multi.fallback.push(t)):e[t.kind][t.tag]=e.fallback[t.tag]=t}for(n=0,i=arguments.length;n<i;n+=1)arguments[n].forEach(r);return e}function pn(e){return this.extend(e)}pn.prototype.extend=function(n){var i=[],r=[];if(n instanceof M)r.push(n);else if(Array.isArray(n))r=r.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(i=i.concat(n.implicit)),n.explicit&&(r=r.concat(n.explicit));else throw new L("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");i.forEach(function(o){if(!(o instanceof M))throw new L("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new L("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(o.multi)throw new L("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(o){if(!(o instanceof M))throw new L("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var t=Object.create(pn.prototype);return t.implicit=(this.implicit||[]).concat(i),t.explicit=(this.explicit||[]).concat(r),t.compiledImplicit=Ci(t,"implicit"),t.compiledExplicit=Ci(t,"explicit"),t.compiledTypeMap=ko(t.compiledImplicit,t.compiledExplicit),t};var Vi=pn,Ki=new M("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Gi=new M("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Yi=new M("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Wi=new Vi({explicit:[Ki,Gi,Yi]});function Lo(e){if(e===null)return!0;var n=e.length;return n===1&&e==="~"||n===4&&(e==="null"||e==="Null"||e==="NULL")}function To(){return null}function Oo(e){return e===null}var Hi=new M("tag:yaml.org,2002:null",{kind:"scalar",resolve:Lo,construct:To,predicate:Oo,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Ro(e){if(e===null)return!1;var n=e.length;return n===4&&(e==="true"||e==="True"||e==="TRUE")||n===5&&(e==="false"||e==="False"||e==="FALSE")}function wo(e){return e==="true"||e==="True"||e==="TRUE"}function Fo(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Xi=new M("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Ro,construct:wo,predicate:Fo,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function Po(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function No(e){return 48<=e&&e<=55}function Do(e){return 48<=e&&e<=57}function Bo(e){if(e===null)return!1;var n=e.length,i=0,r=!1,t;if(!n)return!1;if(t=e[i],(t==="-"||t==="+")&&(t=e[++i]),t==="0"){if(i+1===n)return!0;if(t=e[++i],t==="b"){for(i++;i<n;i++)if(t=e[i],t!=="_"){if(t!=="0"&&t!=="1")return!1;r=!0}return r&&t!=="_"}if(t==="x"){for(i++;i<n;i++)if(t=e[i],t!=="_"){if(!Po(e.charCodeAt(i)))return!1;r=!0}return r&&t!=="_"}if(t==="o"){for(i++;i<n;i++)if(t=e[i],t!=="_"){if(!No(e.charCodeAt(i)))return!1;r=!0}return r&&t!=="_"}}if(t==="_")return!1;for(;i<n;i++)if(t=e[i],t!=="_"){if(!Do(e.charCodeAt(i)))return!1;r=!0}return!(!r||t==="_")}function Uo(e){var n=e,i=1,r;if(n.indexOf("_")!==-1&&(n=n.replace(/_/g,"")),r=n[0],(r==="-"||r==="+")&&(r==="-"&&(i=-1),n=n.slice(1),r=n[0]),n==="0")return 0;if(r==="0"){if(n[1]==="b")return i*parseInt(n.slice(2),2);if(n[1]==="x")return i*parseInt(n.slice(2),16);if(n[1]==="o")return i*parseInt(n.slice(2),8)}return i*parseInt(n,10)}function jo(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!v.isNegativeZero(e)}var qi=new M("tag:yaml.org,2002:int",{kind:"scalar",resolve:Bo,construct:Uo,predicate:jo,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),$o=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Vo(e){return!(e===null||!$o.test(e)||e[e.length-1]==="_")}function Ko(e){var n,i;return n=e.replace(/_/g,"").toLowerCase(),i=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?i===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:i*parseFloat(n,10)}var Go=/^[-+]?[0-9]+e/;function Yo(e,n){var i;if(isNaN(e))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(v.isNegativeZero(e))return"-0.0";return i=e.toString(10),Go.test(i)?i.replace("e",".e"):i}function Wo(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||v.isNegativeZero(e))}var zi=new M("tag:yaml.org,2002:float",{kind:"scalar",resolve:Vo,construct:Ko,predicate:Wo,represent:Yo,defaultStyle:"lowercase"}),Qi=Wi.extend({implicit:[Hi,Xi,qi,zi]}),Zi=Qi,Ji=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),er=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 Ho(e){return e===null?!1:Ji.exec(e)!==null||er.exec(e)!==null}function Xo(e){var n,i,r,t,o,a,l,s=0,u=null,c,f,d;if(n=Ji.exec(e),n===null&&(n=er.exec(e)),n===null)throw new Error("Date resolve error");if(i=+n[1],r=+n[2]-1,t=+n[3],!n[4])return new Date(Date.UTC(i,r,t));if(o=+n[4],a=+n[5],l=+n[6],n[7]){for(s=n[7].slice(0,3);s.length<3;)s+="0";s=+s}return n[9]&&(c=+n[10],f=+(n[11]||0),u=(c*60+f)*6e4,n[9]==="-"&&(u=-u)),d=new Date(Date.UTC(i,r,t,o,a,l,s)),u&&d.setTime(d.getTime()-u),d}function qo(e){return e.toISOString()}var nr=new M("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Ho,construct:Xo,instanceOf:Date,represent:qo});function zo(e){return e==="<<"||e===null}var ir=new M("tag:yaml.org,2002:merge",{kind:"scalar",resolve:zo}),xn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
10
- \r`;function Qo(e){if(e===null)return!1;var n,i,r=0,t=e.length,o=xn;for(i=0;i<t;i++)if(n=o.indexOf(e.charAt(i)),!(n>64)){if(n<0)return!1;r+=6}return r%8===0}function Zo(e){var n,i,r=e.replace(/[\r\n=]/g,""),t=r.length,o=xn,a=0,l=[];for(n=0;n<t;n++)n%4===0&&n&&(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)),a=a<<6|o.indexOf(r.charAt(n));return i=t%4*6,i===0?(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)):i===18?(l.push(a>>10&255),l.push(a>>2&255)):i===12&&l.push(a>>4&255),new Uint8Array(l)}function Jo(e){var n="",i=0,r,t,o=e.length,a=xn;for(r=0;r<o;r++)r%3===0&&r&&(n+=a[i>>18&63],n+=a[i>>12&63],n+=a[i>>6&63],n+=a[i&63]),i=(i<<8)+e[r];return t=o%3,t===0?(n+=a[i>>18&63],n+=a[i>>12&63],n+=a[i>>6&63],n+=a[i&63]):t===2?(n+=a[i>>10&63],n+=a[i>>4&63],n+=a[i<<2&63],n+=a[64]):t===1&&(n+=a[i>>2&63],n+=a[i<<4&63],n+=a[64],n+=a[64]),n}function ea(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var rr=new M("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Qo,construct:Zo,predicate:ea,represent:Jo}),na=Object.prototype.hasOwnProperty,ia=Object.prototype.toString;function ra(e){if(e===null)return!0;var n=[],i,r,t,o,a,l=e;for(i=0,r=l.length;i<r;i+=1){if(t=l[i],a=!1,ia.call(t)!=="[object Object]")return!1;for(o in t)if(na.call(t,o))if(!a)a=!0;else return!1;if(!a)return!1;if(n.indexOf(o)===-1)n.push(o);else return!1}return!0}function ta(e){return e!==null?e:[]}var tr=new M("tag:yaml.org,2002:omap",{kind:"sequence",resolve:ra,construct:ta}),oa=Object.prototype.toString;function aa(e){if(e===null)return!0;var n,i,r,t,o,a=e;for(o=new Array(a.length),n=0,i=a.length;n<i;n+=1){if(r=a[n],oa.call(r)!=="[object Object]"||(t=Object.keys(r),t.length!==1))return!1;o[n]=[t[0],r[t[0]]]}return!0}function la(e){if(e===null)return[];var n,i,r,t,o,a=e;for(o=new Array(a.length),n=0,i=a.length;n<i;n+=1)r=a[n],t=Object.keys(r),o[n]=[t[0],r[t[0]]];return o}var or=new M("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:aa,construct:la}),sa=Object.prototype.hasOwnProperty;function ua(e){if(e===null)return!0;var n,i=e;for(n in i)if(sa.call(i,n)&&i[n]!==null)return!1;return!0}function ca(e){return e!==null?e:{}}var ar=new M("tag:yaml.org,2002:set",{kind:"mapping",resolve:ua,construct:ca}),bn=Zi.extend({implicit:[nr,ir],explicit:[rr,tr,or,ar]}),Y=Object.prototype.hasOwnProperty,Pe=1,lr=2,sr=3,Ne=4,dn=1,fa=2,Mi=3,da=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,pa=/[\x85\u2028\u2029]/,ma=/[,\[\]\{\}]/,ur=/^(?:!|!!|![a-z\-]+!)$/i,cr=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Ii(e){return Object.prototype.toString.call(e)}function N(e){return e===10||e===13}function Z(e){return e===9||e===32}function O(e){return e===9||e===32||e===10||e===13}function oe(e){return e===44||e===91||e===93||e===123||e===125}function ga(e){var n;return 48<=e&&e<=57?e-48:(n=e|32,97<=n&&n<=102?n-97+10:-1)}function ya(e){return e===120?2:e===117?4:e===85?8:0}function ha(e){return 48<=e&&e<=57?e-48:-1}function ki(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
11
- `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function xa(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function fr(e,n,i){n==="__proto__"?Object.defineProperty(e,n,{configurable:!0,enumerable:!0,writable:!0,value:i}):e[n]=i}var dr=new Array(256),pr=new Array(256);for(Q=0;Q<256;Q++)dr[Q]=ki(Q)?1:0,pr[Q]=ki(Q);var Q;function ba(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||bn,this.onWarning=n.onWarning||null,this.legacy=n.legacy||!1,this.json=n.json||!1,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function mr(e,n){var i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=Eo(i),new L(n,i)}function m(e,n){throw mr(e,n)}function De(e,n){e.onWarning&&e.onWarning.call(null,mr(e,n))}var Li={YAML:function(n,i,r){var t,o,a;n.version!==null&&m(n,"duplication of %YAML directive"),r.length!==1&&m(n,"YAML directive accepts exactly one argument"),t=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),t===null&&m(n,"ill-formed argument of the YAML directive"),o=parseInt(t[1],10),a=parseInt(t[2],10),o!==1&&m(n,"unacceptable YAML version of the document"),n.version=r[0],n.checkLineBreaks=a<2,a!==1&&a!==2&&De(n,"unsupported YAML version of the document")},TAG:function(n,i,r){var t,o;r.length!==2&&m(n,"TAG directive accepts exactly two arguments"),t=r[0],o=r[1],ur.test(t)||m(n,"ill-formed tag handle (first argument) of the TAG directive"),Y.call(n.tagMap,t)&&m(n,'there is a previously declared suffix for "'+t+'" tag handle'),cr.test(o)||m(n,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch{m(n,"tag prefix is malformed: "+o)}n.tagMap[t]=o}};function G(e,n,i,r){var t,o,a,l;if(n<i){if(l=e.input.slice(n,i),r)for(t=0,o=l.length;t<o;t+=1)a=l.charCodeAt(t),a===9||32<=a&&a<=1114111||m(e,"expected valid JSON character");else da.test(l)&&m(e,"the stream contains non-printable characters");e.result+=l}}function Ti(e,n,i,r){var t,o,a,l;for(v.isObject(i)||m(e,"cannot merge mappings; the provided source object is unacceptable"),t=Object.keys(i),a=0,l=t.length;a<l;a+=1)o=t[a],Y.call(n,o)||(fr(n,o,i[o]),r[o]=!0)}function ae(e,n,i,r,t,o,a,l,s){var u,c;if(Array.isArray(t))for(t=Array.prototype.slice.call(t),u=0,c=t.length;u<c;u+=1)Array.isArray(t[u])&&m(e,"nested arrays are not supported inside keys"),typeof t=="object"&&Ii(t[u])==="[object Object]"&&(t[u]="[object Object]");if(typeof t=="object"&&Ii(t)==="[object Object]"&&(t="[object Object]"),t=String(t),n===null&&(n={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(o))for(u=0,c=o.length;u<c;u+=1)Ti(e,n,o[u],i);else Ti(e,n,o,i);else!e.json&&!Y.call(i,t)&&Y.call(n,t)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=s||e.position,m(e,"duplicated mapping key")),fr(n,t,o),delete i[t];return n}function An(e){var n;n=e.input.charCodeAt(e.position),n===10?e.position++:n===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):m(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function _(e,n,i){for(var r=0,t=e.input.charCodeAt(e.position);t!==0;){for(;Z(t);)t===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),t=e.input.charCodeAt(++e.position);if(n&&t===35)do t=e.input.charCodeAt(++e.position);while(t!==10&&t!==13&&t!==0);if(N(t))for(An(e),t=e.input.charCodeAt(e.position),r++,e.lineIndent=0;t===32;)e.lineIndent++,t=e.input.charCodeAt(++e.position);else break}return i!==-1&&r!==0&&e.lineIndent<i&&De(e,"deficient indentation"),r}function je(e){var n=e.position,i;return i=e.input.charCodeAt(n),!!((i===45||i===46)&&i===e.input.charCodeAt(n+1)&&i===e.input.charCodeAt(n+2)&&(n+=3,i=e.input.charCodeAt(n),i===0||O(i)))}function _n(e,n){n===1?e.result+=" ":n>1&&(e.result+=v.repeat(`
12
- `,n-1))}function Aa(e,n,i){var r,t,o,a,l,s,u,c,f=e.kind,d=e.result,p;if(p=e.input.charCodeAt(e.position),O(p)||oe(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96||(p===63||p===45)&&(t=e.input.charCodeAt(e.position+1),O(t)||i&&oe(t)))return!1;for(e.kind="scalar",e.result="",o=a=e.position,l=!1;p!==0;){if(p===58){if(t=e.input.charCodeAt(e.position+1),O(t)||i&&oe(t))break}else if(p===35){if(r=e.input.charCodeAt(e.position-1),O(r))break}else{if(e.position===e.lineStart&&je(e)||i&&oe(p))break;if(N(p))if(s=e.line,u=e.lineStart,c=e.lineIndent,_(e,!1,-1),e.lineIndent>=n){l=!0,p=e.input.charCodeAt(e.position);continue}else{e.position=a,e.line=s,e.lineStart=u,e.lineIndent=c;break}}l&&(G(e,o,a,!1),_n(e,e.line-s),o=a=e.position,l=!1),Z(p)||(a=e.position+1),p=e.input.charCodeAt(++e.position)}return G(e,o,a,!1),e.result?!0:(e.kind=f,e.result=d,!1)}function _a(e,n){var i,r,t;if(i=e.input.charCodeAt(e.position),i!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=t=e.position;(i=e.input.charCodeAt(e.position))!==0;)if(i===39)if(G(e,r,e.position,!0),i=e.input.charCodeAt(++e.position),i===39)r=e.position,e.position++,t=e.position;else return!0;else N(i)?(G(e,r,t,!0),_n(e,_(e,!1,n)),r=t=e.position):e.position===e.lineStart&&je(e)?m(e,"unexpected end of the document within a single quoted scalar"):(e.position++,t=e.position);m(e,"unexpected end of the stream within a single quoted scalar")}function va(e,n){var i,r,t,o,a,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,i=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return G(e,i,e.position,!0),e.position++,!0;if(l===92){if(G(e,i,e.position,!0),l=e.input.charCodeAt(++e.position),N(l))_(e,!1,n);else if(l<256&&dr[l])e.result+=pr[l],e.position++;else if((a=ya(l))>0){for(t=a,o=0;t>0;t--)l=e.input.charCodeAt(++e.position),(a=ga(l))>=0?o=(o<<4)+a:m(e,"expected hexadecimal character");e.result+=xa(o),e.position++}else m(e,"unknown escape sequence");i=r=e.position}else N(l)?(G(e,i,r,!0),_n(e,_(e,!1,n)),i=r=e.position):e.position===e.lineStart&&je(e)?m(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}m(e,"unexpected end of the stream within a double quoted scalar")}function Ea(e,n){var i=!0,r,t,o,a=e.tag,l,s=e.anchor,u,c,f,d,p,y=Object.create(null),g,x,b,h;if(h=e.input.charCodeAt(e.position),h===91)c=93,p=!1,l=[];else if(h===123)c=125,p=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),h=e.input.charCodeAt(++e.position);h!==0;){if(_(e,!0,n),h=e.input.charCodeAt(e.position),h===c)return e.position++,e.tag=a,e.anchor=s,e.kind=p?"mapping":"sequence",e.result=l,!0;i?h===44&&m(e,"expected the node content, but found ','"):m(e,"missed comma between flow collection entries"),x=g=b=null,f=d=!1,h===63&&(u=e.input.charCodeAt(e.position+1),O(u)&&(f=d=!0,e.position++,_(e,!0,n))),r=e.line,t=e.lineStart,o=e.position,le(e,n,Pe,!1,!0),x=e.tag,g=e.result,_(e,!0,n),h=e.input.charCodeAt(e.position),(d||e.line===r)&&h===58&&(f=!0,h=e.input.charCodeAt(++e.position),_(e,!0,n),le(e,n,Pe,!1,!0),b=e.result),p?ae(e,l,y,x,g,b,r,t,o):f?l.push(ae(e,null,y,x,g,b,r,t,o)):l.push(g),_(e,!0,n),h=e.input.charCodeAt(e.position),h===44?(i=!0,h=e.input.charCodeAt(++e.position)):i=!1}m(e,"unexpected end of the stream within a flow collection")}function Sa(e,n){var i,r,t=dn,o=!1,a=!1,l=n,s=0,u=!1,c,f;if(f=e.input.charCodeAt(e.position),f===124)r=!1;else if(f===62)r=!0;else return!1;for(e.kind="scalar",e.result="";f!==0;)if(f=e.input.charCodeAt(++e.position),f===43||f===45)dn===t?t=f===43?Mi:fa:m(e,"repeat of a chomping mode identifier");else if((c=ha(f))>=0)c===0?m(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?m(e,"repeat of an indentation width identifier"):(l=n+c-1,a=!0);else break;if(Z(f)){do f=e.input.charCodeAt(++e.position);while(Z(f));if(f===35)do f=e.input.charCodeAt(++e.position);while(!N(f)&&f!==0)}for(;f!==0;){for(An(e),e.lineIndent=0,f=e.input.charCodeAt(e.position);(!a||e.lineIndent<l)&&f===32;)e.lineIndent++,f=e.input.charCodeAt(++e.position);if(!a&&e.lineIndent>l&&(l=e.lineIndent),N(f)){s++;continue}if(e.lineIndent<l){t===Mi?e.result+=v.repeat(`
23
+ `;return l.replace(/\n$/,"")}var So=Eo,Co=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Io=["scalar","sequence","mapping"];function Mo(e){var n={};return e!==null&&Object.keys(e).forEach(function(i){e[i].forEach(function(r){n[String(r)]=i})}),n}function ko(e,n){if(n=n||{},Object.keys(n).forEach(function(i){if(Co.indexOf(i)===-1)throw new L('Unknown option "'+i+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(i){return i},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||!1,this.styleAliases=Mo(n.styleAliases||null),Io.indexOf(this.kind)===-1)throw new L('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var I=ko;function Ci(e,n){var i=[];return e[n].forEach(function(r){var t=i.length;i.forEach(function(o,a){o.tag===r.tag&&o.kind===r.kind&&o.multi===r.multi&&(t=a)}),i[t]=r}),i}function Lo(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,i;function r(t){t.multi?(e.multi[t.kind].push(t),e.multi.fallback.push(t)):e[t.kind][t.tag]=e.fallback[t.tag]=t}for(n=0,i=arguments.length;n<i;n+=1)arguments[n].forEach(r);return e}function pn(e){return this.extend(e)}pn.prototype.extend=function(n){var i=[],r=[];if(n instanceof I)r.push(n);else if(Array.isArray(n))r=r.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(i=i.concat(n.implicit)),n.explicit&&(r=r.concat(n.explicit));else throw new L("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");i.forEach(function(o){if(!(o instanceof I))throw new L("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new L("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(o.multi)throw new L("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(o){if(!(o instanceof I))throw new L("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var t=Object.create(pn.prototype);return t.implicit=(this.implicit||[]).concat(i),t.explicit=(this.explicit||[]).concat(r),t.compiledImplicit=Ci(t,"implicit"),t.compiledExplicit=Ci(t,"explicit"),t.compiledTypeMap=Lo(t.compiledImplicit,t.compiledExplicit),t};var Vi=pn,Ki=new I("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Gi=new I("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Yi=new I("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Wi=new Vi({explicit:[Ki,Gi,Yi]});function To(e){if(e===null)return!0;var n=e.length;return n===1&&e==="~"||n===4&&(e==="null"||e==="Null"||e==="NULL")}function Ro(){return null}function Oo(e){return e===null}var Hi=new I("tag:yaml.org,2002:null",{kind:"scalar",resolve:To,construct:Ro,predicate:Oo,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function wo(e){if(e===null)return!1;var n=e.length;return n===4&&(e==="true"||e==="True"||e==="TRUE")||n===5&&(e==="false"||e==="False"||e==="FALSE")}function Fo(e){return e==="true"||e==="True"||e==="TRUE"}function Po(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Xi=new I("tag:yaml.org,2002:bool",{kind:"scalar",resolve:wo,construct:Fo,predicate:Po,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function No(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Do(e){return 48<=e&&e<=55}function Bo(e){return 48<=e&&e<=57}function Uo(e){if(e===null)return!1;var n=e.length,i=0,r=!1,t;if(!n)return!1;if(t=e[i],(t==="-"||t==="+")&&(t=e[++i]),t==="0"){if(i+1===n)return!0;if(t=e[++i],t==="b"){for(i++;i<n;i++)if(t=e[i],t!=="_"){if(t!=="0"&&t!=="1")return!1;r=!0}return r&&t!=="_"}if(t==="x"){for(i++;i<n;i++)if(t=e[i],t!=="_"){if(!No(e.charCodeAt(i)))return!1;r=!0}return r&&t!=="_"}if(t==="o"){for(i++;i<n;i++)if(t=e[i],t!=="_"){if(!Do(e.charCodeAt(i)))return!1;r=!0}return r&&t!=="_"}}if(t==="_")return!1;for(;i<n;i++)if(t=e[i],t!=="_"){if(!Bo(e.charCodeAt(i)))return!1;r=!0}return!(!r||t==="_")}function jo(e){var n=e,i=1,r;if(n.indexOf("_")!==-1&&(n=n.replace(/_/g,"")),r=n[0],(r==="-"||r==="+")&&(r==="-"&&(i=-1),n=n.slice(1),r=n[0]),n==="0")return 0;if(r==="0"){if(n[1]==="b")return i*parseInt(n.slice(2),2);if(n[1]==="x")return i*parseInt(n.slice(2),16);if(n[1]==="o")return i*parseInt(n.slice(2),8)}return i*parseInt(n,10)}function $o(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!v.isNegativeZero(e)}var qi=new I("tag:yaml.org,2002:int",{kind:"scalar",resolve:Uo,construct:jo,predicate:$o,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Vo=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Ko(e){return!(e===null||!Vo.test(e)||e[e.length-1]==="_")}function Go(e){var n,i;return n=e.replace(/_/g,"").toLowerCase(),i=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?i===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:i*parseFloat(n,10)}var Yo=/^[-+]?[0-9]+e/;function Wo(e,n){var i;if(isNaN(e))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(v.isNegativeZero(e))return"-0.0";return i=e.toString(10),Yo.test(i)?i.replace("e",".e"):i}function Ho(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||v.isNegativeZero(e))}var zi=new I("tag:yaml.org,2002:float",{kind:"scalar",resolve:Ko,construct:Go,predicate:Ho,represent:Wo,defaultStyle:"lowercase"}),Qi=Wi.extend({implicit:[Hi,Xi,qi,zi]}),Zi=Qi,Ji=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),er=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 Xo(e){return e===null?!1:Ji.exec(e)!==null||er.exec(e)!==null}function qo(e){var n,i,r,t,o,a,l,s=0,u=null,c,f,d;if(n=Ji.exec(e),n===null&&(n=er.exec(e)),n===null)throw new Error("Date resolve error");if(i=+n[1],r=+n[2]-1,t=+n[3],!n[4])return new Date(Date.UTC(i,r,t));if(o=+n[4],a=+n[5],l=+n[6],n[7]){for(s=n[7].slice(0,3);s.length<3;)s+="0";s=+s}return n[9]&&(c=+n[10],f=+(n[11]||0),u=(c*60+f)*6e4,n[9]==="-"&&(u=-u)),d=new Date(Date.UTC(i,r,t,o,a,l,s)),u&&d.setTime(d.getTime()-u),d}function zo(e){return e.toISOString()}var nr=new I("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Xo,construct:qo,instanceOf:Date,represent:zo});function Qo(e){return e==="<<"||e===null}var ir=new I("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Qo}),xn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
24
+ \r`;function Zo(e){if(e===null)return!1;var n,i,r=0,t=e.length,o=xn;for(i=0;i<t;i++)if(n=o.indexOf(e.charAt(i)),!(n>64)){if(n<0)return!1;r+=6}return r%8===0}function Jo(e){var n,i,r=e.replace(/[\r\n=]/g,""),t=r.length,o=xn,a=0,l=[];for(n=0;n<t;n++)n%4===0&&n&&(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)),a=a<<6|o.indexOf(r.charAt(n));return i=t%4*6,i===0?(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)):i===18?(l.push(a>>10&255),l.push(a>>2&255)):i===12&&l.push(a>>4&255),new Uint8Array(l)}function ea(e){var n="",i=0,r,t,o=e.length,a=xn;for(r=0;r<o;r++)r%3===0&&r&&(n+=a[i>>18&63],n+=a[i>>12&63],n+=a[i>>6&63],n+=a[i&63]),i=(i<<8)+e[r];return t=o%3,t===0?(n+=a[i>>18&63],n+=a[i>>12&63],n+=a[i>>6&63],n+=a[i&63]):t===2?(n+=a[i>>10&63],n+=a[i>>4&63],n+=a[i<<2&63],n+=a[64]):t===1&&(n+=a[i>>2&63],n+=a[i<<4&63],n+=a[64],n+=a[64]),n}function na(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var rr=new I("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Zo,construct:Jo,predicate:na,represent:ea}),ia=Object.prototype.hasOwnProperty,ra=Object.prototype.toString;function ta(e){if(e===null)return!0;var n=[],i,r,t,o,a,l=e;for(i=0,r=l.length;i<r;i+=1){if(t=l[i],a=!1,ra.call(t)!=="[object Object]")return!1;for(o in t)if(ia.call(t,o))if(!a)a=!0;else return!1;if(!a)return!1;if(n.indexOf(o)===-1)n.push(o);else return!1}return!0}function oa(e){return e!==null?e:[]}var tr=new I("tag:yaml.org,2002:omap",{kind:"sequence",resolve:ta,construct:oa}),aa=Object.prototype.toString;function la(e){if(e===null)return!0;var n,i,r,t,o,a=e;for(o=new Array(a.length),n=0,i=a.length;n<i;n+=1){if(r=a[n],aa.call(r)!=="[object Object]"||(t=Object.keys(r),t.length!==1))return!1;o[n]=[t[0],r[t[0]]]}return!0}function sa(e){if(e===null)return[];var n,i,r,t,o,a=e;for(o=new Array(a.length),n=0,i=a.length;n<i;n+=1)r=a[n],t=Object.keys(r),o[n]=[t[0],r[t[0]]];return o}var or=new I("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:la,construct:sa}),ua=Object.prototype.hasOwnProperty;function ca(e){if(e===null)return!0;var n,i=e;for(n in i)if(ua.call(i,n)&&i[n]!==null)return!1;return!0}function fa(e){return e!==null?e:{}}var ar=new I("tag:yaml.org,2002:set",{kind:"mapping",resolve:ca,construct:fa}),bn=Zi.extend({implicit:[nr,ir],explicit:[rr,tr,or,ar]}),Y=Object.prototype.hasOwnProperty,Pe=1,lr=2,sr=3,Ne=4,dn=1,da=2,Ii=3,pa=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,ma=/[\x85\u2028\u2029]/,ga=/[,\[\]\{\}]/,ur=/^(?:!|!!|![a-z\-]+!)$/i,cr=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Mi(e){return Object.prototype.toString.call(e)}function N(e){return e===10||e===13}function Z(e){return e===9||e===32}function R(e){return e===9||e===32||e===10||e===13}function oe(e){return e===44||e===91||e===93||e===123||e===125}function ya(e){var n;return 48<=e&&e<=57?e-48:(n=e|32,97<=n&&n<=102?n-97+10:-1)}function ha(e){return e===120?2:e===117?4:e===85?8:0}function xa(e){return 48<=e&&e<=57?e-48:-1}function ki(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
25
+ `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function ba(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function fr(e,n,i){n==="__proto__"?Object.defineProperty(e,n,{configurable:!0,enumerable:!0,writable:!0,value:i}):e[n]=i}var dr=new Array(256),pr=new Array(256);for(Q=0;Q<256;Q++)dr[Q]=ki(Q)?1:0,pr[Q]=ki(Q);var Q;function Aa(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||bn,this.onWarning=n.onWarning||null,this.legacy=n.legacy||!1,this.json=n.json||!1,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function mr(e,n){var i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=So(i),new L(n,i)}function m(e,n){throw mr(e,n)}function De(e,n){e.onWarning&&e.onWarning.call(null,mr(e,n))}var Li={YAML:function(n,i,r){var t,o,a;n.version!==null&&m(n,"duplication of %YAML directive"),r.length!==1&&m(n,"YAML directive accepts exactly one argument"),t=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),t===null&&m(n,"ill-formed argument of the YAML directive"),o=parseInt(t[1],10),a=parseInt(t[2],10),o!==1&&m(n,"unacceptable YAML version of the document"),n.version=r[0],n.checkLineBreaks=a<2,a!==1&&a!==2&&De(n,"unsupported YAML version of the document")},TAG:function(n,i,r){var t,o;r.length!==2&&m(n,"TAG directive accepts exactly two arguments"),t=r[0],o=r[1],ur.test(t)||m(n,"ill-formed tag handle (first argument) of the TAG directive"),Y.call(n.tagMap,t)&&m(n,'there is a previously declared suffix for "'+t+'" tag handle'),cr.test(o)||m(n,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch{m(n,"tag prefix is malformed: "+o)}n.tagMap[t]=o}};function G(e,n,i,r){var t,o,a,l;if(n<i){if(l=e.input.slice(n,i),r)for(t=0,o=l.length;t<o;t+=1)a=l.charCodeAt(t),a===9||32<=a&&a<=1114111||m(e,"expected valid JSON character");else pa.test(l)&&m(e,"the stream contains non-printable characters");e.result+=l}}function Ti(e,n,i,r){var t,o,a,l;for(v.isObject(i)||m(e,"cannot merge mappings; the provided source object is unacceptable"),t=Object.keys(i),a=0,l=t.length;a<l;a+=1)o=t[a],Y.call(n,o)||(fr(n,o,i[o]),r[o]=!0)}function ae(e,n,i,r,t,o,a,l,s){var u,c;if(Array.isArray(t))for(t=Array.prototype.slice.call(t),u=0,c=t.length;u<c;u+=1)Array.isArray(t[u])&&m(e,"nested arrays are not supported inside keys"),typeof t=="object"&&Mi(t[u])==="[object Object]"&&(t[u]="[object Object]");if(typeof t=="object"&&Mi(t)==="[object Object]"&&(t="[object Object]"),t=String(t),n===null&&(n={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(o))for(u=0,c=o.length;u<c;u+=1)Ti(e,n,o[u],i);else Ti(e,n,o,i);else!e.json&&!Y.call(i,t)&&Y.call(n,t)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=s||e.position,m(e,"duplicated mapping key")),fr(n,t,o),delete i[t];return n}function An(e){var n;n=e.input.charCodeAt(e.position),n===10?e.position++:n===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):m(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function _(e,n,i){for(var r=0,t=e.input.charCodeAt(e.position);t!==0;){for(;Z(t);)t===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),t=e.input.charCodeAt(++e.position);if(n&&t===35)do t=e.input.charCodeAt(++e.position);while(t!==10&&t!==13&&t!==0);if(N(t))for(An(e),t=e.input.charCodeAt(e.position),r++,e.lineIndent=0;t===32;)e.lineIndent++,t=e.input.charCodeAt(++e.position);else break}return i!==-1&&r!==0&&e.lineIndent<i&&De(e,"deficient indentation"),r}function je(e){var n=e.position,i;return i=e.input.charCodeAt(n),!!((i===45||i===46)&&i===e.input.charCodeAt(n+1)&&i===e.input.charCodeAt(n+2)&&(n+=3,i=e.input.charCodeAt(n),i===0||R(i)))}function _n(e,n){n===1?e.result+=" ":n>1&&(e.result+=v.repeat(`
26
+ `,n-1))}function _a(e,n,i){var r,t,o,a,l,s,u,c,f=e.kind,d=e.result,p;if(p=e.input.charCodeAt(e.position),R(p)||oe(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96||(p===63||p===45)&&(t=e.input.charCodeAt(e.position+1),R(t)||i&&oe(t)))return!1;for(e.kind="scalar",e.result="",o=a=e.position,l=!1;p!==0;){if(p===58){if(t=e.input.charCodeAt(e.position+1),R(t)||i&&oe(t))break}else if(p===35){if(r=e.input.charCodeAt(e.position-1),R(r))break}else{if(e.position===e.lineStart&&je(e)||i&&oe(p))break;if(N(p))if(s=e.line,u=e.lineStart,c=e.lineIndent,_(e,!1,-1),e.lineIndent>=n){l=!0,p=e.input.charCodeAt(e.position);continue}else{e.position=a,e.line=s,e.lineStart=u,e.lineIndent=c;break}}l&&(G(e,o,a,!1),_n(e,e.line-s),o=a=e.position,l=!1),Z(p)||(a=e.position+1),p=e.input.charCodeAt(++e.position)}return G(e,o,a,!1),e.result?!0:(e.kind=f,e.result=d,!1)}function va(e,n){var i,r,t;if(i=e.input.charCodeAt(e.position),i!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=t=e.position;(i=e.input.charCodeAt(e.position))!==0;)if(i===39)if(G(e,r,e.position,!0),i=e.input.charCodeAt(++e.position),i===39)r=e.position,e.position++,t=e.position;else return!0;else N(i)?(G(e,r,t,!0),_n(e,_(e,!1,n)),r=t=e.position):e.position===e.lineStart&&je(e)?m(e,"unexpected end of the document within a single quoted scalar"):(e.position++,t=e.position);m(e,"unexpected end of the stream within a single quoted scalar")}function Ea(e,n){var i,r,t,o,a,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,i=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return G(e,i,e.position,!0),e.position++,!0;if(l===92){if(G(e,i,e.position,!0),l=e.input.charCodeAt(++e.position),N(l))_(e,!1,n);else if(l<256&&dr[l])e.result+=pr[l],e.position++;else if((a=ha(l))>0){for(t=a,o=0;t>0;t--)l=e.input.charCodeAt(++e.position),(a=ya(l))>=0?o=(o<<4)+a:m(e,"expected hexadecimal character");e.result+=ba(o),e.position++}else m(e,"unknown escape sequence");i=r=e.position}else N(l)?(G(e,i,r,!0),_n(e,_(e,!1,n)),i=r=e.position):e.position===e.lineStart&&je(e)?m(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}m(e,"unexpected end of the stream within a double quoted scalar")}function Sa(e,n){var i=!0,r,t,o,a=e.tag,l,s=e.anchor,u,c,f,d,p,y=Object.create(null),g,x,b,h;if(h=e.input.charCodeAt(e.position),h===91)c=93,p=!1,l=[];else if(h===123)c=125,p=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),h=e.input.charCodeAt(++e.position);h!==0;){if(_(e,!0,n),h=e.input.charCodeAt(e.position),h===c)return e.position++,e.tag=a,e.anchor=s,e.kind=p?"mapping":"sequence",e.result=l,!0;i?h===44&&m(e,"expected the node content, but found ','"):m(e,"missed comma between flow collection entries"),x=g=b=null,f=d=!1,h===63&&(u=e.input.charCodeAt(e.position+1),R(u)&&(f=d=!0,e.position++,_(e,!0,n))),r=e.line,t=e.lineStart,o=e.position,le(e,n,Pe,!1,!0),x=e.tag,g=e.result,_(e,!0,n),h=e.input.charCodeAt(e.position),(d||e.line===r)&&h===58&&(f=!0,h=e.input.charCodeAt(++e.position),_(e,!0,n),le(e,n,Pe,!1,!0),b=e.result),p?ae(e,l,y,x,g,b,r,t,o):f?l.push(ae(e,null,y,x,g,b,r,t,o)):l.push(g),_(e,!0,n),h=e.input.charCodeAt(e.position),h===44?(i=!0,h=e.input.charCodeAt(++e.position)):i=!1}m(e,"unexpected end of the stream within a flow collection")}function Ca(e,n){var i,r,t=dn,o=!1,a=!1,l=n,s=0,u=!1,c,f;if(f=e.input.charCodeAt(e.position),f===124)r=!1;else if(f===62)r=!0;else return!1;for(e.kind="scalar",e.result="";f!==0;)if(f=e.input.charCodeAt(++e.position),f===43||f===45)dn===t?t=f===43?Ii:da:m(e,"repeat of a chomping mode identifier");else if((c=xa(f))>=0)c===0?m(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?m(e,"repeat of an indentation width identifier"):(l=n+c-1,a=!0);else break;if(Z(f)){do f=e.input.charCodeAt(++e.position);while(Z(f));if(f===35)do f=e.input.charCodeAt(++e.position);while(!N(f)&&f!==0)}for(;f!==0;){for(An(e),e.lineIndent=0,f=e.input.charCodeAt(e.position);(!a||e.lineIndent<l)&&f===32;)e.lineIndent++,f=e.input.charCodeAt(++e.position);if(!a&&e.lineIndent>l&&(l=e.lineIndent),N(f)){s++;continue}if(e.lineIndent<l){t===Ii?e.result+=v.repeat(`
13
27
  `,o?1+s:s):t===dn&&o&&(e.result+=`
14
28
  `);break}for(r?Z(f)?(u=!0,e.result+=v.repeat(`
15
29
  `,o?1+s:s)):u?(u=!1,e.result+=v.repeat(`
16
30
  `,s+1)):s===0?o&&(e.result+=" "):e.result+=v.repeat(`
17
31
  `,s):e.result+=v.repeat(`
18
- `,o?1+s:s),o=!0,a=!0,s=0,i=e.position;!N(f)&&f!==0;)f=e.input.charCodeAt(++e.position);G(e,i,e.position,!1)}return!0}function Oi(e,n){var i,r=e.tag,t=e.anchor,o=[],a,l=!1,s;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=o),s=e.input.charCodeAt(e.position);s!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation")),!(s!==45||(a=e.input.charCodeAt(e.position+1),!O(a))));){if(l=!0,e.position++,_(e,!0,-1)&&e.lineIndent<=n){o.push(null),s=e.input.charCodeAt(e.position);continue}if(i=e.line,le(e,n,sr,!1,!0),o.push(e.result),_(e,!0,-1),s=e.input.charCodeAt(e.position),(e.line===i||e.lineIndent>n)&&s!==0)m(e,"bad indentation of a sequence entry");else if(e.lineIndent<n)break}return l?(e.tag=r,e.anchor=t,e.kind="sequence",e.result=o,!0):!1}function Ca(e,n,i){var r,t,o,a,l,s,u=e.tag,c=e.anchor,f={},d=Object.create(null),p=null,y=null,g=null,x=!1,b=!1,h;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=f),h=e.input.charCodeAt(e.position);h!==0;){if(!x&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),o=e.line,(h===63||h===58)&&O(r))h===63?(x&&(ae(e,f,d,p,y,null,a,l,s),p=y=g=null),b=!0,x=!0,t=!0):x?(x=!1,t=!0):m(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,h=r;else{if(a=e.line,l=e.lineStart,s=e.position,!le(e,i,lr,!1,!0))break;if(e.line===o){for(h=e.input.charCodeAt(e.position);Z(h);)h=e.input.charCodeAt(++e.position);if(h===58)h=e.input.charCodeAt(++e.position),O(h)||m(e,"a whitespace character is expected after the key-value separator within a block mapping"),x&&(ae(e,f,d,p,y,null,a,l,s),p=y=g=null),b=!0,x=!1,t=!1,p=e.tag,y=e.result;else if(b)m(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=u,e.anchor=c,!0}else if(b)m(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=u,e.anchor=c,!0}if((e.line===o||e.lineIndent>n)&&(x&&(a=e.line,l=e.lineStart,s=e.position),le(e,n,Ne,!0,t)&&(x?y=e.result:g=e.result),x||(ae(e,f,d,p,y,g,a,l,s),p=y=g=null),_(e,!0,-1),h=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>n)&&h!==0)m(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return x&&ae(e,f,d,p,y,null,a,l,s),b&&(e.tag=u,e.anchor=c,e.kind="mapping",e.result=f),b}function Ma(e){var n,i=!1,r=!1,t,o,a;if(a=e.input.charCodeAt(e.position),a!==33)return!1;if(e.tag!==null&&m(e,"duplication of a tag property"),a=e.input.charCodeAt(++e.position),a===60?(i=!0,a=e.input.charCodeAt(++e.position)):a===33?(r=!0,t="!!",a=e.input.charCodeAt(++e.position)):t="!",n=e.position,i){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(o=e.input.slice(n,e.position),a=e.input.charCodeAt(++e.position)):m(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!O(a);)a===33&&(r?m(e,"tag suffix cannot contain exclamation marks"):(t=e.input.slice(n-1,e.position+1),ur.test(t)||m(e,"named tag handle cannot contain such characters"),r=!0,n=e.position+1)),a=e.input.charCodeAt(++e.position);o=e.input.slice(n,e.position),ma.test(o)&&m(e,"tag suffix cannot contain flow indicator characters")}o&&!cr.test(o)&&m(e,"tag name cannot contain such characters: "+o);try{o=decodeURIComponent(o)}catch{m(e,"tag name is malformed: "+o)}return i?e.tag=o:Y.call(e.tagMap,t)?e.tag=e.tagMap[t]+o:t==="!"?e.tag="!"+o:t==="!!"?e.tag="tag:yaml.org,2002:"+o:m(e,'undeclared tag handle "'+t+'"'),!0}function Ia(e){var n,i;if(i=e.input.charCodeAt(e.position),i!==38)return!1;for(e.anchor!==null&&m(e,"duplication of an anchor property"),i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!O(i)&&!oe(i);)i=e.input.charCodeAt(++e.position);return e.position===n&&m(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),!0}function ka(e){var n,i,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),n=e.position;r!==0&&!O(r)&&!oe(r);)r=e.input.charCodeAt(++e.position);return e.position===n&&m(e,"name of an alias node must contain at least one character"),i=e.input.slice(n,e.position),Y.call(e.anchorMap,i)||m(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],_(e,!0,-1),!0}function le(e,n,i,r,t){var o,a,l,s=1,u=!1,c=!1,f,d,p,y,g,x;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=a=l=Ne===i||sr===i,r&&_(e,!0,-1)&&(u=!0,e.lineIndent>n?s=1:e.lineIndent===n?s=0:e.lineIndent<n&&(s=-1)),s===1)for(;Ma(e)||Ia(e);)_(e,!0,-1)?(u=!0,l=o,e.lineIndent>n?s=1:e.lineIndent===n?s=0:e.lineIndent<n&&(s=-1)):l=!1;if(l&&(l=u||t),(s===1||Ne===i)&&(Pe===i||lr===i?g=n:g=n+1,x=e.position-e.lineStart,s===1?l&&(Oi(e,x)||Ca(e,x,g))||Ea(e,g)?c=!0:(a&&Sa(e,g)||_a(e,g)||va(e,g)?c=!0:ka(e)?(c=!0,(e.tag!==null||e.anchor!==null)&&m(e,"alias node should not have any properties")):Aa(e,g,Pe===i)&&(c=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):s===0&&(c=l&&Oi(e,x))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&m(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),f=0,d=e.implicitTypes.length;f<d;f+=1)if(y=e.implicitTypes[f],y.resolve(e.result)){e.result=y.construct(e.result),e.tag=y.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(Y.call(e.typeMap[e.kind||"fallback"],e.tag))y=e.typeMap[e.kind||"fallback"][e.tag];else for(y=null,p=e.typeMap.multi[e.kind||"fallback"],f=0,d=p.length;f<d;f+=1)if(e.tag.slice(0,p[f].tag.length)===p[f].tag){y=p[f];break}y||m(e,"unknown tag !<"+e.tag+">"),e.result!==null&&y.kind!==e.kind&&m(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+y.kind+'", not "'+e.kind+'"'),y.resolve(e.result,e.tag)?(e.result=y.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):m(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||c}function La(e){var n=e.position,i,r,t,o=!1,a;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(a=e.input.charCodeAt(e.position))!==0&&(_(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||a!==37));){for(o=!0,a=e.input.charCodeAt(++e.position),i=e.position;a!==0&&!O(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(i,e.position),t=[],r.length<1&&m(e,"directive name must not be less than one character in length");a!==0;){for(;Z(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!N(a));break}if(N(a))break;for(i=e.position;a!==0&&!O(a);)a=e.input.charCodeAt(++e.position);t.push(e.input.slice(i,e.position))}a!==0&&An(e),Y.call(Li,r)?Li[r](e,r,t):De(e,'unknown document directive "'+r+'"')}if(_(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,_(e,!0,-1)):o&&m(e,"directives end mark is expected"),le(e,e.lineIndent-1,Ne,!1,!0),_(e,!0,-1),e.checkLineBreaks&&pa.test(e.input.slice(n,e.position))&&De(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&je(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,_(e,!0,-1));return}if(e.position<e.length-1)m(e,"end of the stream or a document separator is expected");else return}function gr(e,n){e=String(e),n=n||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
19
- `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var i=new ba(e,n),r=e.indexOf("\0");for(r!==-1&&(i.position=r,m(i,"null byte is not allowed in input")),i.input+="\0";i.input.charCodeAt(i.position)===32;)i.lineIndent+=1,i.position+=1;for(;i.position<i.length-1;)La(i);return i.documents}function Ta(e,n,i){n!==null&&typeof n=="object"&&typeof i>"u"&&(i=n,n=null);var r=gr(e,i);if(typeof n!="function")return r;for(var t=0,o=r.length;t<o;t+=1)n(r[t])}function Oa(e,n){var i=gr(e,n);if(i.length!==0){if(i.length===1)return i[0];throw new L("expected a single document in the stream, but found more")}}var Ra=Ta,wa=Oa,yr={loadAll:Ra,load:wa},hr=Object.prototype.toString,xr=Object.prototype.hasOwnProperty,vn=65279,Fa=9,_e=10,Pa=13,Na=32,Da=33,Ba=34,mn=35,Ua=37,ja=38,$a=39,Va=42,br=44,Ka=45,Be=58,Ga=61,Ya=62,Wa=63,Ha=64,Ar=91,_r=93,Xa=96,vr=123,qa=124,Er=125,I={};I[0]="\\0";I[7]="\\a";I[8]="\\b";I[9]="\\t";I[10]="\\n";I[11]="\\v";I[12]="\\f";I[13]="\\r";I[27]="\\e";I[34]='\\"';I[92]="\\\\";I[133]="\\N";I[160]="\\_";I[8232]="\\L";I[8233]="\\P";var za=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Qa=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Za(e,n){var i,r,t,o,a,l,s;if(n===null)return{};for(i={},r=Object.keys(n),t=0,o=r.length;t<o;t+=1)a=r[t],l=String(n[a]),a.slice(0,2)==="!!"&&(a="tag:yaml.org,2002:"+a.slice(2)),s=e.compiledTypeMap.fallback[a],s&&xr.call(s.styleAliases,l)&&(l=s.styleAliases[l]),i[a]=l;return i}function Ja(e){var n,i,r;if(n=e.toString(16).toUpperCase(),e<=255)i="x",r=2;else if(e<=65535)i="u",r=4;else if(e<=4294967295)i="U",r=8;else throw new L("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+i+v.repeat("0",r-n.length)+n}var el=1,ve=2;function nl(e){this.schema=e.schema||bn,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=v.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=Za(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?ve:el,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Ri(e,n){for(var i=v.repeat(" ",n),r=0,t=-1,o="",a,l=e.length;r<l;)t=e.indexOf(`
32
+ `,o?1+s:s),o=!0,a=!0,s=0,i=e.position;!N(f)&&f!==0;)f=e.input.charCodeAt(++e.position);G(e,i,e.position,!1)}return!0}function Ri(e,n){var i,r=e.tag,t=e.anchor,o=[],a,l=!1,s;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=o),s=e.input.charCodeAt(e.position);s!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation")),!(s!==45||(a=e.input.charCodeAt(e.position+1),!R(a))));){if(l=!0,e.position++,_(e,!0,-1)&&e.lineIndent<=n){o.push(null),s=e.input.charCodeAt(e.position);continue}if(i=e.line,le(e,n,sr,!1,!0),o.push(e.result),_(e,!0,-1),s=e.input.charCodeAt(e.position),(e.line===i||e.lineIndent>n)&&s!==0)m(e,"bad indentation of a sequence entry");else if(e.lineIndent<n)break}return l?(e.tag=r,e.anchor=t,e.kind="sequence",e.result=o,!0):!1}function Ia(e,n,i){var r,t,o,a,l,s,u=e.tag,c=e.anchor,f={},d=Object.create(null),p=null,y=null,g=null,x=!1,b=!1,h;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=f),h=e.input.charCodeAt(e.position);h!==0;){if(!x&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),o=e.line,(h===63||h===58)&&R(r))h===63?(x&&(ae(e,f,d,p,y,null,a,l,s),p=y=g=null),b=!0,x=!0,t=!0):x?(x=!1,t=!0):m(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,h=r;else{if(a=e.line,l=e.lineStart,s=e.position,!le(e,i,lr,!1,!0))break;if(e.line===o){for(h=e.input.charCodeAt(e.position);Z(h);)h=e.input.charCodeAt(++e.position);if(h===58)h=e.input.charCodeAt(++e.position),R(h)||m(e,"a whitespace character is expected after the key-value separator within a block mapping"),x&&(ae(e,f,d,p,y,null,a,l,s),p=y=g=null),b=!0,x=!1,t=!1,p=e.tag,y=e.result;else if(b)m(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=u,e.anchor=c,!0}else if(b)m(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=u,e.anchor=c,!0}if((e.line===o||e.lineIndent>n)&&(x&&(a=e.line,l=e.lineStart,s=e.position),le(e,n,Ne,!0,t)&&(x?y=e.result:g=e.result),x||(ae(e,f,d,p,y,g,a,l,s),p=y=g=null),_(e,!0,-1),h=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>n)&&h!==0)m(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return x&&ae(e,f,d,p,y,null,a,l,s),b&&(e.tag=u,e.anchor=c,e.kind="mapping",e.result=f),b}function Ma(e){var n,i=!1,r=!1,t,o,a;if(a=e.input.charCodeAt(e.position),a!==33)return!1;if(e.tag!==null&&m(e,"duplication of a tag property"),a=e.input.charCodeAt(++e.position),a===60?(i=!0,a=e.input.charCodeAt(++e.position)):a===33?(r=!0,t="!!",a=e.input.charCodeAt(++e.position)):t="!",n=e.position,i){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(o=e.input.slice(n,e.position),a=e.input.charCodeAt(++e.position)):m(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!R(a);)a===33&&(r?m(e,"tag suffix cannot contain exclamation marks"):(t=e.input.slice(n-1,e.position+1),ur.test(t)||m(e,"named tag handle cannot contain such characters"),r=!0,n=e.position+1)),a=e.input.charCodeAt(++e.position);o=e.input.slice(n,e.position),ga.test(o)&&m(e,"tag suffix cannot contain flow indicator characters")}o&&!cr.test(o)&&m(e,"tag name cannot contain such characters: "+o);try{o=decodeURIComponent(o)}catch{m(e,"tag name is malformed: "+o)}return i?e.tag=o:Y.call(e.tagMap,t)?e.tag=e.tagMap[t]+o:t==="!"?e.tag="!"+o:t==="!!"?e.tag="tag:yaml.org,2002:"+o:m(e,'undeclared tag handle "'+t+'"'),!0}function ka(e){var n,i;if(i=e.input.charCodeAt(e.position),i!==38)return!1;for(e.anchor!==null&&m(e,"duplication of an anchor property"),i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!R(i)&&!oe(i);)i=e.input.charCodeAt(++e.position);return e.position===n&&m(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),!0}function La(e){var n,i,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),n=e.position;r!==0&&!R(r)&&!oe(r);)r=e.input.charCodeAt(++e.position);return e.position===n&&m(e,"name of an alias node must contain at least one character"),i=e.input.slice(n,e.position),Y.call(e.anchorMap,i)||m(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],_(e,!0,-1),!0}function le(e,n,i,r,t){var o,a,l,s=1,u=!1,c=!1,f,d,p,y,g,x;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=a=l=Ne===i||sr===i,r&&_(e,!0,-1)&&(u=!0,e.lineIndent>n?s=1:e.lineIndent===n?s=0:e.lineIndent<n&&(s=-1)),s===1)for(;Ma(e)||ka(e);)_(e,!0,-1)?(u=!0,l=o,e.lineIndent>n?s=1:e.lineIndent===n?s=0:e.lineIndent<n&&(s=-1)):l=!1;if(l&&(l=u||t),(s===1||Ne===i)&&(Pe===i||lr===i?g=n:g=n+1,x=e.position-e.lineStart,s===1?l&&(Ri(e,x)||Ia(e,x,g))||Sa(e,g)?c=!0:(a&&Ca(e,g)||va(e,g)||Ea(e,g)?c=!0:La(e)?(c=!0,(e.tag!==null||e.anchor!==null)&&m(e,"alias node should not have any properties")):_a(e,g,Pe===i)&&(c=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):s===0&&(c=l&&Ri(e,x))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&m(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),f=0,d=e.implicitTypes.length;f<d;f+=1)if(y=e.implicitTypes[f],y.resolve(e.result)){e.result=y.construct(e.result),e.tag=y.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(Y.call(e.typeMap[e.kind||"fallback"],e.tag))y=e.typeMap[e.kind||"fallback"][e.tag];else for(y=null,p=e.typeMap.multi[e.kind||"fallback"],f=0,d=p.length;f<d;f+=1)if(e.tag.slice(0,p[f].tag.length)===p[f].tag){y=p[f];break}y||m(e,"unknown tag !<"+e.tag+">"),e.result!==null&&y.kind!==e.kind&&m(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+y.kind+'", not "'+e.kind+'"'),y.resolve(e.result,e.tag)?(e.result=y.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):m(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||c}function Ta(e){var n=e.position,i,r,t,o=!1,a;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(a=e.input.charCodeAt(e.position))!==0&&(_(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||a!==37));){for(o=!0,a=e.input.charCodeAt(++e.position),i=e.position;a!==0&&!R(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(i,e.position),t=[],r.length<1&&m(e,"directive name must not be less than one character in length");a!==0;){for(;Z(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!N(a));break}if(N(a))break;for(i=e.position;a!==0&&!R(a);)a=e.input.charCodeAt(++e.position);t.push(e.input.slice(i,e.position))}a!==0&&An(e),Y.call(Li,r)?Li[r](e,r,t):De(e,'unknown document directive "'+r+'"')}if(_(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,_(e,!0,-1)):o&&m(e,"directives end mark is expected"),le(e,e.lineIndent-1,Ne,!1,!0),_(e,!0,-1),e.checkLineBreaks&&ma.test(e.input.slice(n,e.position))&&De(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&je(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,_(e,!0,-1));return}if(e.position<e.length-1)m(e,"end of the stream or a document separator is expected");else return}function gr(e,n){e=String(e),n=n||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
33
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var i=new Aa(e,n),r=e.indexOf("\0");for(r!==-1&&(i.position=r,m(i,"null byte is not allowed in input")),i.input+="\0";i.input.charCodeAt(i.position)===32;)i.lineIndent+=1,i.position+=1;for(;i.position<i.length-1;)Ta(i);return i.documents}function Ra(e,n,i){n!==null&&typeof n=="object"&&typeof i>"u"&&(i=n,n=null);var r=gr(e,i);if(typeof n!="function")return r;for(var t=0,o=r.length;t<o;t+=1)n(r[t])}function Oa(e,n){var i=gr(e,n);if(i.length!==0){if(i.length===1)return i[0];throw new L("expected a single document in the stream, but found more")}}var wa=Ra,Fa=Oa,yr={loadAll:wa,load:Fa},hr=Object.prototype.toString,xr=Object.prototype.hasOwnProperty,vn=65279,Pa=9,_e=10,Na=13,Da=32,Ba=33,Ua=34,mn=35,ja=37,$a=38,Va=39,Ka=42,br=44,Ga=45,Be=58,Ya=61,Wa=62,Ha=63,Xa=64,Ar=91,_r=93,qa=96,vr=123,za=124,Er=125,M={};M[0]="\\0";M[7]="\\a";M[8]="\\b";M[9]="\\t";M[10]="\\n";M[11]="\\v";M[12]="\\f";M[13]="\\r";M[27]="\\e";M[34]='\\"';M[92]="\\\\";M[133]="\\N";M[160]="\\_";M[8232]="\\L";M[8233]="\\P";var Qa=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Za=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Ja(e,n){var i,r,t,o,a,l,s;if(n===null)return{};for(i={},r=Object.keys(n),t=0,o=r.length;t<o;t+=1)a=r[t],l=String(n[a]),a.slice(0,2)==="!!"&&(a="tag:yaml.org,2002:"+a.slice(2)),s=e.compiledTypeMap.fallback[a],s&&xr.call(s.styleAliases,l)&&(l=s.styleAliases[l]),i[a]=l;return i}function el(e){var n,i,r;if(n=e.toString(16).toUpperCase(),e<=255)i="x",r=2;else if(e<=65535)i="u",r=4;else if(e<=4294967295)i="U",r=8;else throw new L("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+i+v.repeat("0",r-n.length)+n}var nl=1,ve=2;function il(e){this.schema=e.schema||bn,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=v.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=Ja(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?ve:nl,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Oi(e,n){for(var i=v.repeat(" ",n),r=0,t=-1,o="",a,l=e.length;r<l;)t=e.indexOf(`
20
34
  `,r),t===-1?(a=e.slice(r),r=l):(a=e.slice(r,t+1),r=t+1),a.length&&a!==`
21
35
  `&&(o+=i),o+=a;return o}function gn(e,n){return`
22
- `+v.repeat(" ",e.indent*n)}function il(e,n){var i,r,t;for(i=0,r=e.implicitTypes.length;i<r;i+=1)if(t=e.implicitTypes[i],t.resolve(n))return!0;return!1}function Ue(e){return e===Na||e===Fa}function Ee(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==vn||65536<=e&&e<=1114111}function wi(e){return Ee(e)&&e!==vn&&e!==Pa&&e!==_e}function Fi(e,n,i){var r=wi(e),t=r&&!Ue(e);return(i?r:r&&e!==br&&e!==Ar&&e!==_r&&e!==vr&&e!==Er)&&e!==mn&&!(n===Be&&!t)||wi(n)&&!Ue(n)&&e===mn||n===Be&&t}function rl(e){return Ee(e)&&e!==vn&&!Ue(e)&&e!==Ka&&e!==Wa&&e!==Be&&e!==br&&e!==Ar&&e!==_r&&e!==vr&&e!==Er&&e!==mn&&e!==ja&&e!==Va&&e!==Da&&e!==qa&&e!==Ga&&e!==Ya&&e!==$a&&e!==Ba&&e!==Ua&&e!==Ha&&e!==Xa}function tl(e){return!Ue(e)&&e!==Be}function be(e,n){var i=e.charCodeAt(n),r;return i>=55296&&i<=56319&&n+1<e.length&&(r=e.charCodeAt(n+1),r>=56320&&r<=57343)?(i-55296)*1024+r-56320+65536:i}function Sr(e){var n=/^\n* /;return n.test(e)}var Cr=1,yn=2,Mr=3,Ir=4,te=5;function ol(e,n,i,r,t,o,a,l){var s,u=0,c=null,f=!1,d=!1,p=r!==-1,y=-1,g=rl(be(e,0))&&tl(be(e,e.length-1));if(n||a)for(s=0;s<e.length;u>=65536?s+=2:s++){if(u=be(e,s),!Ee(u))return te;g=g&&Fi(u,c,l),c=u}else{for(s=0;s<e.length;u>=65536?s+=2:s++){if(u=be(e,s),u===_e)f=!0,p&&(d=d||s-y-1>r&&e[y+1]!==" ",y=s);else if(!Ee(u))return te;g=g&&Fi(u,c,l),c=u}d=d||p&&s-y-1>r&&e[y+1]!==" "}return!f&&!d?g&&!a&&!t(e)?Cr:o===ve?te:yn:i>9&&Sr(e)?te:a?o===ve?te:yn:d?Ir:Mr}function al(e,n,i,r,t){e.dump=(function(){if(n.length===0)return e.quotingType===ve?'""':"''";if(!e.noCompatMode&&(za.indexOf(n)!==-1||Qa.test(n)))return e.quotingType===ve?'"'+n+'"':"'"+n+"'";var o=e.indent*Math.max(1,i),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),l=r||e.flowLevel>-1&&i>=e.flowLevel;function s(u){return il(e,u)}switch(ol(n,l,e.indent,a,s,e.quotingType,e.forceQuotes&&!r,t)){case Cr:return n;case yn:return"'"+n.replace(/'/g,"''")+"'";case Mr:return"|"+Pi(n,e.indent)+Ni(Ri(n,o));case Ir:return">"+Pi(n,e.indent)+Ni(Ri(ll(n,a),o));case te:return'"'+sl(n)+'"';default:throw new L("impossible error: invalid scalar style")}})()}function Pi(e,n){var i=Sr(e)?String(n):"",r=e[e.length-1]===`
36
+ `+v.repeat(" ",e.indent*n)}function rl(e,n){var i,r,t;for(i=0,r=e.implicitTypes.length;i<r;i+=1)if(t=e.implicitTypes[i],t.resolve(n))return!0;return!1}function Ue(e){return e===Da||e===Pa}function Ee(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==vn||65536<=e&&e<=1114111}function wi(e){return Ee(e)&&e!==vn&&e!==Na&&e!==_e}function Fi(e,n,i){var r=wi(e),t=r&&!Ue(e);return(i?r:r&&e!==br&&e!==Ar&&e!==_r&&e!==vr&&e!==Er)&&e!==mn&&!(n===Be&&!t)||wi(n)&&!Ue(n)&&e===mn||n===Be&&t}function tl(e){return Ee(e)&&e!==vn&&!Ue(e)&&e!==Ga&&e!==Ha&&e!==Be&&e!==br&&e!==Ar&&e!==_r&&e!==vr&&e!==Er&&e!==mn&&e!==$a&&e!==Ka&&e!==Ba&&e!==za&&e!==Ya&&e!==Wa&&e!==Va&&e!==Ua&&e!==ja&&e!==Xa&&e!==qa}function ol(e){return!Ue(e)&&e!==Be}function be(e,n){var i=e.charCodeAt(n),r;return i>=55296&&i<=56319&&n+1<e.length&&(r=e.charCodeAt(n+1),r>=56320&&r<=57343)?(i-55296)*1024+r-56320+65536:i}function Sr(e){var n=/^\n* /;return n.test(e)}var Cr=1,yn=2,Ir=3,Mr=4,te=5;function al(e,n,i,r,t,o,a,l){var s,u=0,c=null,f=!1,d=!1,p=r!==-1,y=-1,g=tl(be(e,0))&&ol(be(e,e.length-1));if(n||a)for(s=0;s<e.length;u>=65536?s+=2:s++){if(u=be(e,s),!Ee(u))return te;g=g&&Fi(u,c,l),c=u}else{for(s=0;s<e.length;u>=65536?s+=2:s++){if(u=be(e,s),u===_e)f=!0,p&&(d=d||s-y-1>r&&e[y+1]!==" ",y=s);else if(!Ee(u))return te;g=g&&Fi(u,c,l),c=u}d=d||p&&s-y-1>r&&e[y+1]!==" "}return!f&&!d?g&&!a&&!t(e)?Cr:o===ve?te:yn:i>9&&Sr(e)?te:a?o===ve?te:yn:d?Mr:Ir}function ll(e,n,i,r,t){e.dump=(function(){if(n.length===0)return e.quotingType===ve?'""':"''";if(!e.noCompatMode&&(Qa.indexOf(n)!==-1||Za.test(n)))return e.quotingType===ve?'"'+n+'"':"'"+n+"'";var o=e.indent*Math.max(1,i),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),l=r||e.flowLevel>-1&&i>=e.flowLevel;function s(u){return rl(e,u)}switch(al(n,l,e.indent,a,s,e.quotingType,e.forceQuotes&&!r,t)){case Cr:return n;case yn:return"'"+n.replace(/'/g,"''")+"'";case Ir:return"|"+Pi(n,e.indent)+Ni(Oi(n,o));case Mr:return">"+Pi(n,e.indent)+Ni(Oi(sl(n,a),o));case te:return'"'+ul(n)+'"';default:throw new L("impossible error: invalid scalar style")}})()}function Pi(e,n){var i=Sr(e)?String(n):"",r=e[e.length-1]===`
23
37
  `,t=r&&(e[e.length-2]===`
24
38
  `||e===`
25
39
  `),o=t?"+":r?"":"-";return i+o+`
26
40
  `}function Ni(e){return e[e.length-1]===`
27
- `?e.slice(0,-1):e}function ll(e,n){for(var i=/(\n+)([^\n]*)/g,r=(function(){var u=e.indexOf(`
41
+ `?e.slice(0,-1):e}function sl(e,n){for(var i=/(\n+)([^\n]*)/g,r=(function(){var u=e.indexOf(`
28
42
  `);return u=u!==-1?u:e.length,i.lastIndex=u,Di(e.slice(0,u),n)})(),t=e[0]===`
29
43
  `||e[0]===" ",o,a;a=i.exec(e);){var l=a[1],s=a[2];o=s[0]===" ",r+=l+(!t&&!o&&s!==""?`
30
44
  `:"")+Di(s,n),t=o}return r}function Di(e,n){if(e===""||e[0]===" ")return e;for(var i=/ [^ ]/g,r,t=0,o,a=0,l=0,s="";r=i.exec(e);)l=r.index,l-t>n&&(o=a>t?a:l,s+=`
31
45
  `+e.slice(t,o),t=o+1),a=l;return s+=`
32
46
  `,e.length-t>n&&a>t?s+=e.slice(t,a)+`
33
- `+e.slice(a+1):s+=e.slice(t),s.slice(1)}function sl(e){for(var n="",i=0,r,t=0;t<e.length;i>=65536?t+=2:t++)i=be(e,t),r=I[i],!r&&Ee(i)?(n+=e[t],i>=65536&&(n+=e[t+1])):n+=r||Ja(i);return n}function ul(e,n,i){var r="",t=e.tag,o,a,l;for(o=0,a=i.length;o<a;o+=1)l=i[o],e.replacer&&(l=e.replacer.call(i,String(o),l)),(B(e,n,l,!1,!1)||typeof l>"u"&&B(e,n,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=t,e.dump="["+r+"]"}function Bi(e,n,i,r){var t="",o=e.tag,a,l,s;for(a=0,l=i.length;a<l;a+=1)s=i[a],e.replacer&&(s=e.replacer.call(i,String(a),s)),(B(e,n+1,s,!0,!0,!1,!0)||typeof s>"u"&&B(e,n+1,null,!0,!0,!1,!0))&&((!r||t!=="")&&(t+=gn(e,n)),e.dump&&_e===e.dump.charCodeAt(0)?t+="-":t+="- ",t+=e.dump);e.tag=o,e.dump=t||"[]"}function cl(e,n,i){var r="",t=e.tag,o=Object.keys(i),a,l,s,u,c;for(a=0,l=o.length;a<l;a+=1)c="",r!==""&&(c+=", "),e.condenseFlow&&(c+='"'),s=o[a],u=i[s],e.replacer&&(u=e.replacer.call(i,s,u)),B(e,n,s,!1,!1)&&(e.dump.length>1024&&(c+="? "),c+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),B(e,n,u,!1,!1)&&(c+=e.dump,r+=c));e.tag=t,e.dump="{"+r+"}"}function fl(e,n,i,r){var t="",o=e.tag,a=Object.keys(i),l,s,u,c,f,d;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new L("sortKeys must be a boolean or a function");for(l=0,s=a.length;l<s;l+=1)d="",(!r||t!=="")&&(d+=gn(e,n)),u=a[l],c=i[u],e.replacer&&(c=e.replacer.call(i,u,c)),B(e,n+1,u,!0,!0,!0)&&(f=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,f&&(e.dump&&_e===e.dump.charCodeAt(0)?d+="?":d+="? "),d+=e.dump,f&&(d+=gn(e,n)),B(e,n+1,c,!0,f)&&(e.dump&&_e===e.dump.charCodeAt(0)?d+=":":d+=": ",d+=e.dump,t+=d));e.tag=o,e.dump=t||"{}"}function Ui(e,n,i){var r,t,o,a,l,s;for(t=i?e.explicitTypes:e.implicitTypes,o=0,a=t.length;o<a;o+=1)if(l=t[o],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof n=="object"&&n instanceof l.instanceOf)&&(!l.predicate||l.predicate(n))){if(i?l.multi&&l.representName?e.tag=l.representName(n):e.tag=l.tag:e.tag="?",l.represent){if(s=e.styleMap[l.tag]||l.defaultStyle,hr.call(l.represent)==="[object Function]")r=l.represent(n,s);else if(xr.call(l.represent,s))r=l.represent[s](n,s);else throw new L("!<"+l.tag+'> tag resolver accepts not "'+s+'" style');e.dump=r}return!0}return!1}function B(e,n,i,r,t,o,a){e.tag=null,e.dump=i,Ui(e,i,!1)||Ui(e,i,!0);var l=hr.call(e.dump),s=r,u;r&&(r=e.flowLevel<0||e.flowLevel>n);var c=l==="[object Object]"||l==="[object Array]",f,d;if(c&&(f=e.duplicates.indexOf(i),d=f!==-1),(e.tag!==null&&e.tag!=="?"||d||e.indent!==2&&n>0)&&(t=!1),d&&e.usedDuplicates[f])e.dump="*ref_"+f;else{if(c&&d&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(fl(e,n,e.dump,t),d&&(e.dump="&ref_"+f+e.dump)):(cl(e,n,e.dump),d&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&n>0?Bi(e,n-1,e.dump,t):Bi(e,n,e.dump,t),d&&(e.dump="&ref_"+f+e.dump)):(ul(e,n,e.dump),d&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&al(e,e.dump,n,o,s);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new L("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(u=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?u="!"+u:u.slice(0,18)==="tag:yaml.org,2002:"?u="!!"+u.slice(18):u="!<"+u+">",e.dump=u+" "+e.dump)}return!0}function dl(e,n){var i=[],r=[],t,o;for(hn(e,i,r),t=0,o=r.length;t<o;t+=1)n.duplicates.push(i[r[t]]);n.usedDuplicates=new Array(o)}function hn(e,n,i){var r,t,o;if(e!==null&&typeof e=="object")if(t=n.indexOf(e),t!==-1)i.indexOf(t)===-1&&i.push(t);else if(n.push(e),Array.isArray(e))for(t=0,o=e.length;t<o;t+=1)hn(e[t],n,i);else for(r=Object.keys(e),t=0,o=r.length;t<o;t+=1)hn(e[r[t]],n,i)}function pl(e,n){n=n||{};var i=new nl(n);i.noRefs||dl(e,i);var r=e;return i.replacer&&(r=i.replacer.call({"":r},"",r)),B(i,0,r,!0,!0)?i.dump+`
34
- `:""}var ml=pl,gl={dump:ml};function En(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var yl=M,hl=Vi,xl=Wi,bl=Qi,Al=Zi,_l=bn,vl=yr.load,El=yr.loadAll,Sl=gl.dump,Cl=L,Ml={binary:rr,float:zi,map:Yi,null:Hi,pairs:or,set:ar,timestamp:nr,bool:Xi,int:qi,merge:ir,omap:tr,seq:Gi,str:Ki},Il=En("safeLoad","load"),kl=En("safeLoadAll","loadAll"),Ll=En("safeDump","dump"),C={Type:yl,Schema:hl,FAILSAFE_SCHEMA:xl,JSON_SCHEMA:bl,CORE_SCHEMA:Al,DEFAULT_SCHEMA:_l,load:vl,loadAll:El,dump:Sl,YAMLException:Cl,types:Ml,safeLoad:Il,safeLoadAll:kl,safeDump:Ll};var Tr=vi(Ei(),1);async function Rl(e,n){let i=kr(e,"config.yaml"),r,t;try{await U.mkdir(e,{recursive:!0}),await U.writeFile(i,"",{flag:"a",mode:384});let o=await U.realpath(i);r=kr(Ol(o),`.config-tmp-${Tl(6).toString("hex")}`),t=await Tr.default.lock(o,{stale:1e4,retries:{retries:20,factor:1,minTimeout:5,maxTimeout:25}});let l=C.load(await U.readFile(o,"utf8"))??{};if(!Lr(l))throw new Error("Invalid config document");let s=l.tui??{};if(!Lr(s))throw new Error("Invalid TUI settings");let u={...s};n===void 0?delete u.statusLine:u.statusLine=[...n];let c={...l,tui:u},f=(await U.stat(o)).mode&511;await U.writeFile(r,C.dump(c,{lineWidth:-1,noRefs:!0}),{encoding:"utf8",mode:f}),await U.chmod(r,f),await U.rename(r,o)}catch{throw new Error("Unable to save status line settings. Check config.yaml syntax and permissions.")}finally{r&&await U.unlink(r).catch(()=>{}),await t?.().catch(()=>{})}}function Lr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function Sn(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};let n=e.enabled;return typeof n=="boolean"?{enabled:n}:{}}function Cn(e,n){return{enabled:Sn(n).enabled??Sn(e).enabled??!0}}import $ from"node:fs";import T from"node:path";import Ts from"node:os";import{spawnSync as Os}from"node:child_process";import{fileURLToPath as Rs}from"node:url";function Or(e){let n=e.tui;if(n==null||typeof n!="object"||Array.isArray(n))return{};let i=n,r=i.notifications,t;if(r&&typeof r=="object"&&!Array.isArray(r)){let{when:s,method:u}=r;t={...s==="unfocused"||s==="always"||s==="never"?{when:s}:{},...u==="auto"||u==="osc9"||u==="osc777"||u==="bel"?{method:u}:{}}}let o=i.statusLine,a=Array.isArray(o)?o.filter(s=>typeof s=="string").map(s=>s.trim()).filter(Boolean):void 0,l=wl(i.customStatusLine);return{...typeof i.showTips=="boolean"?{showTips:i.showTips}:{},...t?{notifications:t}:{},...a?{statusLine:a}:{},...l?{customStatusLine:l}:{}}}function wl(e){if(e==null||typeof e!="object"||Array.isArray(e))return;let n=e,i=typeof n.command=="string"?n.command.trim():"";if(i)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 Fl}from"node:crypto";import $e from"node:fs";import Rr from"node:path";function Pr(e){if(e==null||typeof e!="object"||Array.isArray(e))return;let n=e,i={};typeof n.apiKey=="string"&&(i.apiKey=n.apiKey),typeof n.baseURL=="string"&&(i.baseURL=n.baseURL);let r=In(n.modelContextLimits);return r&&(i.modelContextLimits=r),Object.keys(i).length>0?i:void 0}function In(e){if(!A(e))return;let 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 Nr(e,n){let i=e.minimax;if(!i?.models||!n)return e;let r=!1,t=Object.fromEntries(Object.entries(i.models).map(([o,a])=>{let l=n[o];return l===void 0||!a.contextWindowOptions?.includes(l)||a.limit?.context===l?[o,a]:(r=!0,[o,{...a,limit:{...a.limit,context:l}}])}));return r?{...e,minimax:{...i,models:t}}:e}function Dr(e){if(e==null||typeof e!="object"||Array.isArray(e))return;let n=Object.entries(e).filter(([,i])=>i!=null&&typeof i=="object"&&!Array.isArray(i));if(n.length!==0)return Object.fromEntries(n.map(([i,r])=>[i,Ur(r)]))}function Br(e){return Object.fromEntries(Object.entries(e).map(([n,i])=>[n,A(i)?Ur(i):i]))}function Ur(e){if(!A(e.models))return e;let n=!1,i=Object.fromEntries(Object.entries(e.models).map(([r,t])=>{if(!A(t)||!A(t.thinking))return[r,t];let o=typeof t.thinking.effort=="string"?t.thinking.effort.trim():"",a=typeof t.thinking.defaultEffort=="string"?t.thinking.defaultEffort.trim():"";if(!Object.hasOwn(t.thinking,"effort")&&!Object.hasOwn(t.thinking,"defaultEffort"))return[r,t];let l=[],s=new Set;if(Array.isArray(t.thinking.effortOptions))for(let d of t.thinking.effortOptions){if(typeof d!="string")continue;let p=d.trim();!p||s.has(p)||(s.add(p),l.push(p))}o&&!s.has(o)&&(s.add(o),l.push(o)),a&&!s.has(a)&&(s.add(a),l.push(a));let u={...t.thinking};delete u.effort,delete u.effortOptions,delete u.defaultEffort;let c={...u,...l.length>0?{effortOptions:l}:{},...a?{defaultEffort:a}:{}},f={...t};return Object.keys(c).length>0?f.thinking=c:delete f.thinking,n=!0,[r,f]}));return n?{...e,models:i}:e}var jr="byok_legacy_provider_to_custom_provider_v1",Pl="config.yaml.bak.byok-legacy-provider.",Mn=new Set(["minimax","minimax_api","provider","custom_provider"]),Nl=/^[A-Za-z0-9 _-]+$/;function $r(e,n){let i={migrated:!1,migratedProviders:{}};if(!n.isManagedRuntime()||!$e.existsSync(e))return i;let r=Ul(e);if(!A(r.provider))return i;let t=r.provider,o=A(r.custom_provider)?r.custom_provider:{},a=Xl(r),l={},s={...o},u=new Set(Object.keys(s)),c=!1,f=n.getManagedPreset().provider;for(let[d,p]of Object.entries(t)){if(!jl(d,p,f))continue;let y=a.providers[d];if(y&&!Mn.has(y)&&!A(s[y])){delete t[d],c=!0;continue}let g=y&&!Mn.has(y)?y:Kl(d,p,u);l[d]=g,A(s[g])||(s[g]=Vl(p),u.add(g),c=!0),a.providers[d]!==g&&(a.providers[d]=g,c=!0),delete t[d],c=!0}if(!c&&Object.keys(l).length===0)return i;if(c=Fr(r,"defaultModel",l)||c,c=Fr(r,"defaultLightModel",l)||c,c=Wl(r,l)||c,!c)return{migrated:!1,migratedProviders:l};Object.keys(s).length>0?r.custom_provider=s:delete r.custom_provider,ql(r,a);try{let d=Hl(e);return $e.writeFileSync(e,C.dump(r,{indent:2,lineWidth:-1,noRefs:!0}),"utf-8"),{migrated:!0,migratedProviders:l,backupPath:d}}catch(d){return console.warn(`[config] legacy BYOK provider migration skipped: ${Ql(d)}`),{migrated:!1,migratedProviders:l}}}function Vr(e,n){let i=e.provider,r=e.defaultModel;if(Object.prototype.hasOwnProperty.call(i,"minimax_api")){let{minimax_api:y,...g}=i;i=g,console.warn('[config] "minimax_api" is a reserved provider id; ignoring provider.minimax_api from config.yaml')}let o=n.getManagedPreset().provider.minimax,a=i.minimax,l=n.isManagedRuntime();if(!(l||Dl(a,n)))return{provider:i,defaultModel:r};let u=a?.options,c=l&&n.shouldEnforceManagedProviderProtection(),f=Bl(o.models,a?.models),d=typeof u?.baseURL=="string"&&u.baseURL.length>0?u.baseURL:void 0,p=c&&d!=null&&!n.isManagedPresetBaseUrl(d);return i={...i,minimax:{...o,...a??{},npm:a?.npm??o.npm,models:f,options:{...o.options??{},...u??{},...p?{apiKey:o.options?.apiKey}:{},...c?{authMode:"managed-login",baseURL:o.options?.baseURL}:{}}}},{provider:i,defaultModel:r}}function Dl(e,n){let i=e?.options;return i?.authMode==="managed-login"?!0:typeof i?.baseURL=="string"&&n.isManagedPresetBaseUrl(i.baseURL)}function Bl(e,n){return n&&Object.keys(n).length>0?n:e??{}}function Ul(e){try{let n=C.load($e.readFileSync(e,"utf-8"));return A(n)?n:{}}catch{return{}}}function jl(e,n,i){return e==="minimax"||e==="minimax_api"||!zl(n)||!$l(n)?!1:!Object.prototype.hasOwnProperty.call(i,e)}function $l(e){let n=A(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&&A(e.models)}function Vl(e){let n=A(e.options)?e.options:{};return{...e,kind:"custom",enabled:e.enabled!==!1,options:{...n,authMode:"api-key"}}}function Kl(e,n,i){let r=A(n)?n:{},t=typeof r.name=="string"?r.name:void 0,o=`provider-${Gl(e)}`,a=wr(e)??wr(t)??o;for(let l=0;;l+=1){let s=l===0?a:`${a}-${l+1}`;if(!i.has(s)&&!Mn.has(s))return s}}function wr(e){let n=e?.trim();return!n||!Nl.test(n)?void 0:n.toLowerCase().replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")||void 0}function Gl(e){return Fl("sha256").update(e).digest("hex").slice(0,8)}function Fr(e,n,i){let r=e[n];if(typeof r!="string")return!1;let t=Yl(r,i);return t===r?!1:(e[n]=t,!0)}function Yl(e,n){let i=e.indexOf("/");if(i<=0||i===e.length-1)return e;let r=e.slice(0,i),t=n[r];return t?`custom_provider:${t}/${e.slice(i+1)}`:e}function Wl(e,n){if(!A(e.nexus)||!A(e.nexus.model))return!1;let i=e.nexus.model.providerID;if(typeof i!="string")return!1;let r=n[i];return r?(e.nexus.model.providerID=`custom_provider:${r}`,!0):!1}function Hl(e){let n=Rr.join(Rr.dirname(e),`${Pl}${Date.now()}`);return $e.copyFileSync(e,n),n}function Xl(e){let i=(A(e.migrations)?e.migrations:void 0)?.[jr];return{providers:A(i)&&A(i.providers)?Object.fromEntries(Object.entries(i.providers).filter(t=>typeof t[1]=="string")):{}}}function ql(e,n){let i=A(e.migrations)?e.migrations:{};i[jr]={version:1,providers:n.providers},e.migrations=i}function zl(e){return A(e)?typeof e.name=="string"||typeof e.npm=="string"||typeof e.api=="string"||A(e.options)||A(e.models):!1}function A(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Ql(e){return e instanceof Error?e.message:String(e)}var Se="native";function Ce(e){return e==="native"||e==="mcp"?e:Se}function Kr(e){if(e==="mcp")throw new Error("MCP backend coming in v2 follow-up plan")}function Gr(e,n){if(e==null||typeof e!="object"||Array.isArray(e))return n;let i=Reflect.get(e,"mode");return{mode:i==="inline"||i==="subagent"?i:n.mode,modeSource:i==="inline"||i==="subagent"?"explicit":"default"}}function Yr(e,n){let i=n.keepAlive,r=n.xdg,t=n.spawnConcurrency,o=()=>({enabled:i.enabled,maxProcesses:i.maxProcesses,maxLifetimeMs:i.maxLifetimeMs,agents:[...i.agents]}),a=e.opencode;if(a==null||typeof a!="object"||Array.isArray(a))return{keepAlive:o(),xdg:{...r},spawnConcurrency:t};let l=a,s=l.spawnConcurrency,u=typeof s=="number"&&Number.isFinite(s)&&s>0&&Number.isInteger(s)?s:t,c=Zl(l.xdg,r),f=l.keepAlive;if(f==null||typeof f!="object"||Array.isArray(f))return{keepAlive:o(),xdg:c,spawnConcurrency:u};let d=f,p=d.maxProcesses,y=typeof p=="number"&&Number.isFinite(p)&&p>0&&Number.isInteger(p)?p:i.maxProcesses,g=d.maxLifetimeMs,x=typeof g=="number"&&Number.isFinite(g)&&g>0&&Number.isInteger(g)?g:i.maxLifetimeMs,b=d.agents,h;return Array.isArray(b)?(h=b.filter(we=>typeof we=="string"&&we.length>0),h.length===0&&(h=[...i.agents])):h=[...i.agents],{keepAlive:{enabled:typeof d.enabled=="boolean"?d.enabled:i.enabled,maxProcesses:y,maxLifetimeMs:x,agents:h},xdg:c,spawnConcurrency:u}}function Zl(e,n){let i=e!=null&&typeof e=="object"&&!Array.isArray(e)?e:void 0,r=i?.startupImport,t=r==="background"||r==="blocking"||r==="off"?r:n.startupImport;return{dataIsolation:typeof i?.dataIsolation=="boolean"?i.dataIsolation:n.dataIsolation,startupImport:t}}function Ve(e){let n=JSON.stringify({level:40,time:Date.now(),name:"config.asr",msg:e});process.stderr.write(`${n}
35
- `)}var Ge={enabled:!0};function Wr(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let n=e,i=typeof n.apiKey=="string"&&n.apiKey.trim().length>0,r=typeof n.resourceId=="string"&&n.resourceId.trim().length>0;return i||r}function Ke(e){return typeof e=="string"&&e.trim().length>0}function Hr(e){let n=e.asr;if(n==null||typeof n!="object"||Array.isArray(n))return{...Ge};let i=n;return Wr(i.seed)&&Ve("Ignoring legacy `asr.seed.*` in config \u2014 Seed ASR was retired from the daemon; only Amadeus remains. Remove `asr.seed` from config.yaml."),Wr(i.qwen)&&Ve("Ignoring legacy `asr.qwen.apiKey` in config \u2014 Qwen ASR was retired from the daemon; only Amadeus remains. Remove `asr.qwen` from config.yaml."),(Ke(i.mode)||Ke(i.proxyBaseUrl))&&Ve("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."),(Ke(i.primaryProvider)||Ke(i.fallbackProvider))&&Ve("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."),{enabled:typeof i.enabled=="boolean"?i.enabled:Ge.enabled}}var Jl={policyOwner:"core",storageWriteVersion:2,classifierTimeoutMs:6e4,userConfirmationEnabled:!0};function Xr(e,n=Jl){let i=e.permission;if(i==null||typeof i!="object"||Array.isArray(i))return{...n};let r=i,t=r.policyOwner===void 0?n.policyOwner:r.policyOwner==="engine"||r.policyOwner==="core"?r.policyOwner:"engine",o=r.storageWriteVersion===1||r.storageWriteVersion===2?r.storageWriteVersion:n.storageWriteVersion,a=r.classifierTimeoutMs,l=typeof a=="number"&&Number.isFinite(a)&&a>=5e3?Math.floor(a):n.classifierTimeoutMs,s=typeof r.userConfirmationEnabled=="boolean"?r.userConfirmationEnabled:n.userConfirmationEnabled;return{policyOwner:t,storageWriteVersion:o,classifierTimeoutMs:l,userConfirmationEnabled:s}}var qr=["user-cc","user-codex","user-agents","workspace-minimax","workspace-cc","workspace-agents"],es={"user-cc":"user-claude","workspace-cc":"workspace-claude"},We={external:{enabled:!0,walkUp:!0,duplicateWarn:!0,sources:{"workspace-minimax":{enabled:!0,priority:65},"workspace-cc":{enabled:!0,priority:60},"workspace-agents":{enabled:!0,priority:55},"user-cc":{enabled:!0,priority:40},"user-codex":{enabled:!0,priority:35},"user-agents":{enabled:!0,priority:30}}}};function Ye(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function ns(e,n){return Ye(e)?{enabled:typeof e.enabled=="boolean"?e.enabled:n.enabled,priority:typeof e.priority=="number"&&Number.isFinite(e.priority)?e.priority:n.priority}:n}function kn(e){let n=We,i=Ye(e.skills)?e.skills:{},r=Ye(i.external)?i.external:{},t=Ye(r.sources)?r.sources:{},o={...n.external.sources};for(let a of qr){let l=es[a],s=Object.hasOwn(t,a)?t[a]:l?t[l]:void 0;o[a]=ns(s,n.external.sources[a])}return{external:{enabled:typeof r.enabled=="boolean"?r.enabled:n.external.enabled,walkUp:typeof r.walkUp=="boolean"?r.walkUp:n.external.walkUp,duplicateWarn:typeof r.duplicateWarn=="boolean"?r.duplicateWarn:n.external.duplicateWarn,sources:o}}}var is=qr;var zr=["pi-agent"],se="pi-agent";function Qr(e){return typeof e!="string"?se:zr.includes(e)?e:se}function Ln(e){return e==null||typeof e!="object"||Array.isArray(e)?{defaultFramework:se}:{defaultFramework:Qr(e.defaultFramework)}}import E from"node:fs";import rs from"node:os";import ue from"node:path";var rt=".minimax",tt=".mavis",ts={error:()=>{},info:()=>{},warn:()=>{}};function Fn(e){return e??rs.homedir()}function ot(e,n){return n?`${e}-${n}`:e}function at(e,n){return ue.join(Fn(e),ot(rt,n))}function lt(e,n){return ue.join(Fn(e),ot(tt,n))}function On(e){try{let n=E.lstatSync(e);return n.isSymbolicLink()?{kind:"link"}:n.isDirectory()?{kind:"directory"}:{kind:"other"}}catch(n){let i=n.code;return i==="ENOENT"||i==="ENOTDIR"?{kind:"missing"}:{kind:"inaccessible",error:n}}}function Tn(e){let n=ue.resolve(e);return process.platform==="win32"?(n=n.replace(/^\\\\\?\\/,""),n.toLowerCase()):n}function Pn(e,n){try{let i=E.readlinkSync(e),r=Tn(n);return Tn(ue.resolve(ue.dirname(e),i))===r||Tn(i)===r}catch{return!1}}function He(e,n,i){if(!Pn(e,n))try{E.symlinkSync(n,e,process.platform==="win32"?"junction":"dir")}catch(r){i.warn(`Failed to create compat link ${e} -> ${n}: ${String(r)}`)}}function Zr(e,n,i){if(n.kind==="missing")return!0;if(n.kind==="link"||n.kind==="other")try{return E.unlinkSync(e),!0}catch(r){return i.warn(`Failed to remove ${e} before creating compat link: ${String(r)}`),!1}return!1}function Rn(e){try{let n=E.readdirSync(e);if(n.length===0)return"empty";if(n.length===1&&n[0]==="workspace")try{return E.readdirSync(ue.join(e,"workspace")).length>0?"hasData":"empty"}catch{return"unknown"}return"hasData"}catch{return"unknown"}}function wn(e){try{return E.statSync(e).isDirectory()?Rn(e):void 0}catch{return"unknown"}}function os(e,n){return`${e}.backup-${n()}`}function as(e,n,i){let r=os(e,i);try{return E.renameSync(e,r),n.warn(`Backed up legacy data dir ${e} -> ${r}`),!0}catch(t){return n.warn(`Failed to back up legacy data dir ${e}: ${String(t)}`),!1}}function ls(e,n,i,r){if(Pn(e,n))return!0;let t=On(e);if(t.kind==="missing")return!0;if(t.kind==="link"){let o=wn(e);return o==="hasData"||o==="unknown"?(i.warn(`Cannot replace legacy data dir symlink ${e}; it may point to real data outside ${n}`),!1):Zr(e,t,i)}return t.kind==="other"?Zr(e,t,i):t.kind==="directory"?as(e,i,r):(i.warn(`Cannot replace inaccessible legacy data dir ${e}; leaving it untouched`),!1)}function Jr(e,n,i,r){ls(e,n,i,r)&&He(e,n,i)}function ss(e,n){try{return E.rmSync(e,{recursive:!0,force:!1}),!0}catch(i){return n.warn(`Failed to remove empty primary data dir ${e}: ${String(i)}`),!1}}function et(e,n,i){try{return E.renameSync(e,n),i.info(`Migrated legacy data dir ${e} -> ${n}`),!0}catch(r){return i.warn(`Failed to migrate legacy data dir ${e} -> ${n}: ${String(r)}`),!1}}function us(e,n,i,r){try{E.cpSync(e,i,{recursive:!0,errorOnExist:!0,force:!1}),E.unlinkSync(n);try{E.rmSync(e,{recursive:!0,force:!1})}catch(t){r.warn(`Copied legacy symlink data dir ${e} -> ${i}, but failed to remove old target: ${String(t)}`)}return r.info(`Copied legacy data dir symlink target ${e} -> ${i}`),!0}catch(t){try{E.existsSync(i)&&E.rmSync(i,{recursive:!0,force:!0})}catch(o){r.warn(`Failed to clean up partial primary data dir ${i}: ${String(o)}`)}return r.warn(`Failed to copy legacy symlink data dir ${n} -> ${i}: ${String(t)}`),!1}}function nt(e,n,i){try{let r=E.realpathSync(e);try{E.renameSync(r,n)}catch(t){if(t.code==="EXDEV")return us(r,e,n,i);throw t}return E.unlinkSync(e),i.info(`Migrated legacy data dir symlink target ${r} -> ${n}`),!0}catch(r){return i.warn(`Failed to migrate legacy symlink data dir ${e} -> ${n}: ${String(r)}`),!1}}function it(e,n){try{return E.mkdirSync(e,{recursive:!0}),!0}catch(i){return n.warn(`Failed to create primary data dir ${e}: ${String(i)}`),!1}}function cs(e,n,i,r){let t=On(e),o=On(n);if(t.kind==="inaccessible")return i.warn(`Primary data dir ${e} is inaccessible; not treating it as missing`),e;if(t.kind==="directory"){let a=Rn(e),l=o.kind==="directory"?Rn(n):o.kind==="link"?wn(n)??"empty":"empty";if(a==="empty"){if(o.kind==="inaccessible"||l==="unknown")return i.warn(`Legacy data dir ${n} may contain data but is inaccessible; not using empty primary ${e}`),n;if((o.kind==="directory"||o.kind==="link")&&l==="hasData"){if(!ss(e,i))return n;if(o.kind==="link"){if(!nt(n,e,i))return n}else if(!et(n,e,i))return n;return He(n,e,i),e}}return Jr(n,e,i,r),e}if(Pn(n,e))return it(e,i),e;if(o.kind==="directory")return et(n,e,i)?(He(n,e,i),e):n;if(o.kind==="link"){let a=wn(n);if(a==="hasData")return nt(n,e,i)?(He(n,e,i),e):n;if(a==="unknown")return i.warn(`Legacy data dir symlink ${n} target is inaccessible; not treating it as missing`),n}return o.kind==="inaccessible"?(i.warn(`Legacy data dir ${n} is inaccessible; not treating it as missing`),n):t.kind==="link"||t.kind==="other"?(i.warn(`Primary data dir path ${e} exists but is not a directory; using it without migration`),e):(it(e,i),Jr(n,e,i,r),e)}function W(e={}){let n=Fn(e.homeDir),i=e.profile??null;return cs(at(n,i),lt(n,i),e.logger??ts,e.nowMs??Date.now)}function fs(e,n){return W({homeDir:e,logger:n})}function ds(e,n,i){return W({homeDir:n,profile:e,logger:i})}var $n=["read","write","edit","bash","grep","glob","todowrite","web_fetch","website_deploy","workspace_semantic_search"],Vn=["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"],Kn=["code-review","deep-research","docx","init","lark-tools","llm-call","mcode-tools-master","mavis-doctor","pdf","plugin-creator","pptx","skill-creator","skill-refiner","visual-page","x-link-reader","xlsx"],ut=["control-in-app-browser","cu-desktop","resume-codex","mavis","create-agent","minimax-code-product","mavis-team","miniapp-creator"],ps=new Set(["modelConfigId","persona","tools","builtinTools","skills","features"]),ms=new Set(["enabled"]),Un=new Set(["mavis","delegation","webSearch"]),ct=new Set($n),ft=new Set(Vn),jn=new Set(Kn),dt=new Set(ut),gs=new Set(["plan-mode"]);function Gn(e){let n=Xe(e),i=Xe(n?.default);return{default:i?hs(i):{}}}function ys(e,n="agent"){if(e===void 0)return{};let i=Dn(e,n);Bn(i,ps,n);let r={};if(i.modelConfigId!==void 0&&((typeof i.modelConfigId!="string"||!i.modelConfigId.trim())&&w(`${n}.modelConfigId`,"must be a non-empty string"),r.modelConfigId=i.modelConfigId.trim()),i.persona!==void 0){let t=Dn(i.persona,`${n}.persona`);Bn(t,ms,`${n}.persona`),t.enabled!==void 0&&typeof t.enabled!="boolean"&&w(`${n}.persona.enabled`,"must be a boolean"),r.persona={...typeof t.enabled=="boolean"?{enabled:t.enabled}:{}}}if(i.tools!==void 0&&(Array.isArray(i.tools)||w(`${n}.tools`,"must be an array"),r.tools=i.tools.map((t,o)=>((typeof t!="string"||!ct.has(t))&&w(`${n}.tools[${o}]`,`must be one of ${$n.join(", ")}`),t))),i.builtinTools!==void 0&&(Array.isArray(i.builtinTools)||w(`${n}.builtinTools`,"must be an array"),r.builtinTools=i.builtinTools.map((t,o)=>(t==="web_search"&&w(`${n}.builtinTools[${o}]`,"web_search is feature-owned; use features.webSearch"),(typeof t!="string"||!ft.has(t))&&w(`${n}.builtinTools[${o}]`,`must be one of ${Vn.join(", ")}`),t))),i.skills!==void 0&&(Array.isArray(i.skills)||w(`${n}.skills`,"must be an array"),r.skills=i.skills.map((t,o)=>{if(typeof t=="string"&&dt.has(t.trim())){let a=t.trim();w(`${n}.skills[${o}]`,`${a} is capability-owned; use its owning Tool or feature switch`)}return(typeof t!="string"||!jn.has(t.trim()))&&w(`${n}.skills[${o}]`,`must be one of ${Kn.join(", ")}`),t.trim()})),i.features!==void 0){let t=Dn(i.features,`${n}.features`);Bn(t,Un,`${n}.features`);for(let o of Un)t[o]!==void 0&&typeof t[o]!="boolean"&&w(`${n}.features.${o}`,"must be a boolean");r.features={...typeof t.mavis=="boolean"?{mavis:t.mavis}:{},...typeof t.delegation=="boolean"?{delegation:t.delegation}:{},...typeof t.webSearch=="boolean"?{webSearch:t.webSearch}:{}}}return r}function hs(e){let n={};typeof e.modelConfigId=="string"&&e.modelConfigId.trim()&&(n.modelConfigId=e.modelConfigId.trim());let i=Xe(e.persona);if(typeof i?.enabled=="boolean"&&(n.persona={enabled:i.enabled}),st(e.tools,ct)&&(n.tools=[...e.tools]),st(e.builtinTools,ft)&&(n.builtinTools=[...e.builtinTools]),Array.isArray(e.skills)){let t=e.skills.map(o=>typeof o=="string"?o.trim():o);t.every(o=>typeof o=="string"&&(jn.has(o)||gs.has(o))&&!dt.has(o))&&(n.skills=t.filter(o=>typeof o=="string"&&jn.has(o)))}let r=Xe(e.features);if(r){let t={};for(let o of Un)typeof r[o]=="boolean"&&(t[o]=r[o]);Object.keys(t).length>0&&(n.features=t)}return n}function Xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function st(e,n){return Array.isArray(e)&&e.every(i=>typeof i=="string"&&n.has(i))}function xs(e={},n={}){return{persona:{enabled:n.persona?.enabled??e.persona?.enabled??!0},tools:Nn(n.tools??e.tools),builtinTools:Nn(n.builtinTools??e.builtinTools),skills:Nn(n.skills??e.skills),features:{mavis:n.features?.mavis??e.features?.mavis??!0,delegation:n.features?.delegation??e.features?.delegation??!0,webSearch:n.features?.webSearch??e.features?.webSearch??!0}}}function bs(e,n){return e.tools===void 0||e.tools.includes(n)}function As(e,n){return e.builtinTools===void 0||e.builtinTools.includes(n)}function _s(e,n){return e.skills===void 0||e.skills.includes(n)}function Nn(e){return e===void 0?void 0:[...e]}function Dn(e,n){return(e==null||typeof e!="object"||Array.isArray(e))&&w(n,"must be an object"),e}function Bn(e,n,i){for(let r of Object.keys(e))n.has(r)||w(`${i}.${r}`,"is not supported")}function w(e,n){throw new Error(`Invalid configuration at ${e}: ${n}`)}var Yn={enabled:!0};function pt(e,n=Yn){let i=e.askUser;if(i==null||typeof i!="object"||Array.isArray(i))return{...n};let r=i;return{enabled:typeof r.enabled=="boolean"?r.enabled:n.enabled}}var yt=["none","evaluator","subagent"],ht=["brief","transcript"],xt=["same-route-small-fast"],bt="goal-verifier-readonly",At=[bt],F={budget:{graceSteps:1},breaker:{repeatedReplyLimit:3},verifier:{repeatedNotMetLimit:5,evidence:"brief"},evaluator:{modelPolicy:"same-route-small-fast",maxTokens:32e3,timeoutSeconds:60,maxRetries:1}},Wn={budget:{graceSteps:3},evaluator:{maxRetries:1}};function Hn(e){let n=[],i=ce(e,"goal",n);fe(i,"goal",n,["objectiveMaxChars","verification","budget","breaker","verifier","evaluator","subagent"]);let r=ce(i.budget,"goal.budget",n);fe(r,"goal.budget",n,["defaultTokens","defaultMainTurns","defaultActiveSeconds","graceSteps"]);let t=ce(i.breaker,"goal.breaker",n);fe(t,"goal.breaker",n,["repeatedReplyLimit"]);let o=ce(i.verifier,"goal.verifier",n);fe(o,"goal.verifier",n,["repeatedNotMetLimit","evidence"]);let a=ce(i.evaluator,"goal.evaluator",n);fe(a,"goal.evaluator",n,["modelPolicy","maxTokens","timeoutSeconds","maxRetries"]);let l=ce(i.subagent,"goal.subagent",n);fe(l,"goal.subagent",n,["profile","maxTurns","maxTokens","timeoutSeconds"]);let s=gt(i.verification,"goal.verification",yt,n),u=J(i.objectiveMaxChars,"goal.objectiveMaxChars",n,{min:1}),c=J(r.defaultTokens,"goal.budget.defaultTokens",n,{min:1}),f=J(r.defaultMainTurns,"goal.budget.defaultMainTurns",n,{min:1}),d=J(r.defaultActiveSeconds,"goal.budget.defaultActiveSeconds",n,{min:1}),p=gt(l.profile,"goal.subagent.profile",At,n),y=J(l.maxTurns,"goal.subagent.maxTurns",n,{min:1}),g=J(l.maxTokens,"goal.subagent.maxTokens",n,{min:1}),x=J(l.timeoutSeconds,"goal.subagent.timeoutSeconds",n,{min:1}),b={...p!==void 0?{profile:p}:{},...y!==void 0?{maxTurns:y}:{},...g!==void 0?{maxTokens:g}:{},...x!==void 0?{timeoutSeconds:x}:{}};return{config:{...u!==void 0?{objectiveMaxChars:u}:{},...s!==void 0?{verification:s}:{},budget:{...c!==void 0?{defaultTokens:c}:{},...f!==void 0?{defaultMainTurns:f}:{},...d!==void 0?{defaultActiveSeconds:d}:{},graceSteps:de(r.graceSteps,"goal.budget.graceSteps",F.budget.graceSteps,n,{min:0,max:Wn.budget.graceSteps})},breaker:{repeatedReplyLimit:de(t.repeatedReplyLimit,"goal.breaker.repeatedReplyLimit",F.breaker.repeatedReplyLimit,n,{min:1})},verifier:{repeatedNotMetLimit:de(o.repeatedNotMetLimit,"goal.verifier.repeatedNotMetLimit",F.verifier.repeatedNotMetLimit,n,{min:1}),evidence:mt(o.evidence,"goal.verifier.evidence",ht,F.verifier.evidence,n)},evaluator:{modelPolicy:mt(a.modelPolicy,"goal.evaluator.modelPolicy",xt,F.evaluator.modelPolicy,n),maxTokens:de(a.maxTokens,"goal.evaluator.maxTokens",F.evaluator.maxTokens,n,{min:1}),timeoutSeconds:de(a.timeoutSeconds,"goal.evaluator.timeoutSeconds",F.evaluator.timeoutSeconds,n,{min:1}),maxRetries:de(a.maxRetries,"goal.evaluator.maxRetries",F.evaluator.maxRetries,n,{min:0,max:Wn.evaluator.maxRetries})},...Object.keys(b).length>0?{subagent:b}:{}},warnings:n}}function ce(e,n,i){return e===void 0?{}:e===null||typeof e!="object"||Array.isArray(e)?(i.push(H(n,"expected an object; using defaults")),{}):e}function fe(e,n,i,r){for(let t of Object.keys(e))r.includes(t)||i.push(H(`${n}.${t}`,"unknown key ignored"))}function de(e,n,i,r,t){return e==null?i:!Number.isInteger(e)||e<t.min?(r.push(H(n,`expected an integer >= ${t.min}; using default`)),i):t.max!=null&&e>t.max?(r.push(H(n,`exceeds maximum ${t.max}; clamped`)),t.max):e}function J(e,n,i,r){if(e!=null){if(!Number.isInteger(e)||e<r.min){i.push(H(n,`expected an integer >= ${r.min}; ignored`));return}return r.max!=null&&e>r.max?(i.push(H(n,`exceeds maximum ${r.max}; clamped`)),r.max):e}}function mt(e,n,i,r,t){return e==null?r:typeof e!="string"||!i.includes(e)?(t.push(H(n,`expected one of: ${i.join(", ")}; using default`)),r):e}function gt(e,n,i,r){if(e!=null){if(typeof e!="string"||!i.includes(e)){r.push(H(n,`expected one of: ${i.join(", ")}; ignored`));return}return e}}function H(e,n){return`Invalid goal config at ${e}: ${n}`}var j={enabled:!0,maxInlineKiB:32,mcpDetailsMaxInlineKiB:32,watermarkKiB:256,minSavingsKiB:128,minCandidateKiB:2},vs=Math.floor(Number.MAX_SAFE_INTEGER/1024);function Xn(e){let n=Es(e)?e:{};return{enabled:typeof n.enabled=="boolean"?n.enabled:j.enabled,maxInlineKiB:Me(n.maxInlineKiB,j.maxInlineKiB),mcpDetailsMaxInlineKiB:Me(n.mcpDetailsMaxInlineKiB,j.mcpDetailsMaxInlineKiB),watermarkKiB:Me(n.watermarkKiB,j.watermarkKiB),minSavingsKiB:Me(n.minSavingsKiB,j.minSavingsKiB),minCandidateKiB:Me(n.minCandidateKiB,j.minCandidateKiB)}}function Me(e,n){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0&&e<=vs?e:n}function Es(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ie={};function qn(e){if(e==null||typeof e!="object"||Array.isArray(e))return{...Ie};let n=Reflect.get(e,"chromePath");return typeof n!="string"||!n.trim()?{...Ie}:{chromePath:n.trim()}}import{isIP as Ss}from"node:net";function _t(e){return{enabled:!1,filesystemMode:"full_access"}}function vt(e){return!e.enabled||e.filesystemMode==="full_access"?{enabled:!1,filesystemMode:"full_access"}:{...e}}function Qn(e){let n=_t(e);return{enabled:n.enabled,filesystem:{policy:{mode:n.filesystemMode},denyRead:[],denyWrite:[]},network:{policy:{mode:"allow_all"},deniedDomains:[]},localAccess:"open"}}var Zn=Qn(process.platform),Cs=new Set(["read_only","workspace_write","delete_guard","full_access"]),Ms=new Set(["deny","allow_all"]);function Jn(e,n=process.platform){let i=Qn(n);if(e===void 0)return i;let r=ke(e,"sandbox",["enabled","filesystem","network","localAccess"]),t=r.filesystem===void 0?{}:ke(r.filesystem,"sandbox.filesystem",["policy","denyRead","denyWrite","allowGitConfig"]),o=t.policy===void 0?{}:ke(t.policy,"sandbox.filesystem.policy",["mode"]),a=r.network===void 0?{}:ke(r.network,"sandbox.network",["policy","deniedDomains"]),l=a.policy===void 0?{}:ke(a.policy,"sandbox.network.policy",["mode"]),s=r.enabled===void 0?i.enabled:Is(r.enabled,"sandbox.enabled"),u=o.mode??(s?"delete_guard":"full_access");if(typeof u!="string"||!Cs.has(u))throw new Error(`Invalid sandbox.filesystem.policy.mode "${String(u)}"`);let c=l.mode??i.network.policy.mode;if(typeof c!="string"||!Ms.has(c))throw new Error(`Invalid sandbox.network.policy.mode "${String(c)}"`);let f=a.deniedDomains===void 0?[...i.network.deniedDomains]:zn(a.deniedDomains,"sandbox.network.deniedDomains");for(let p of f)ks(p);let d=vt({enabled:s,filesystemMode:u});return{enabled:d.enabled,filesystem:{policy:{mode:d.filesystemMode},denyRead:t.denyRead===void 0?[...i.filesystem.denyRead]:zn(t.denyRead,"sandbox.filesystem.denyRead"),denyWrite:t.denyWrite===void 0?[...i.filesystem.denyWrite]:zn(t.denyWrite,"sandbox.filesystem.denyWrite")},network:{policy:{mode:"allow_all"},deniedDomains:[]},localAccess:r.localAccess===void 0?i.localAccess:r.localAccess==="open"||r.localAccess==="restricted"?r.localAccess:(()=>{throw new Error(`Invalid sandbox.localAccess "${String(r.localAccess)}"`)})()}}function ke(e,n,i){if(e==null||typeof e!="object"||Array.isArray(e))throw new Error(`Invalid ${n}: expected object`);let r=e,t=Object.keys(r).find(o=>!i.includes(o));if(t)throw new Error(`Unknown ${n}.${t}`);return r}function Is(e,n){if(typeof e!="boolean")throw new Error(`Invalid ${n}: expected boolean`);return e}function zn(e,n){if(!Array.isArray(e)||e.some(i=>typeof i!="string"))throw new Error(`Invalid ${n}: expected string array`);return[...e]}function ks(e){let n=()=>{throw new Error(`Invalid sandbox.network.deniedDomains entry "${e}"`)},i=e.match(/^\[([^\]]+)\](?::(.+))?$/);if(i){Ss(i[1]??"")!==6&&n(),Et(i[2],e);return}(e.match(/:/g)??[]).length>1&&n();let r=e.lastIndexOf(":"),t=r>-1?e.slice(0,r):e,o=r>-1?e.slice(r+1):void 0;Et(o,e),t!=="*"&&(Ls(t)||n())}function Ls(e){if(e.includes("://")||e.includes("/")||e.includes(":"))return!1;if(e==="localhost")return!0;if(e.startsWith("*.")){let i=e.slice(2).split(".");return i.length>=2&&i.every(r=>r.length>0)}return e.includes("*")?!1:e.includes(".")&&!e.startsWith(".")&&!e.endsWith(".")}function Et(e,n){if(e===void 0)return;let 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 St(e,n){return n.length===0?!1:n.includes("*")?!0:n.includes(e)}function ws(){return process.env.__MAVIS_ALLOW_LEGACY_RUNTIME_ENV==="1"}var Ct={dev:"test",test:"test",staging:"staging",prod:"prod"};function Fs(e){return e==="cn"||e==="en"}function Ot(e){return e==="test"||e==="prod"||e==="dev"||e==="staging"}function Rt(){let e=process.env.MAVIS_REGION;if(Fs(e))return e;if(ze()){let n=process.env.NEXT_PUBLIC_LOCALE;if(n==="zh")return"cn";if(n==="en")return"en"}return"en"}function K(){let e=process.env.MAVIS_BUILD_ENV;if(Ot(e))return e;if(ze()){let n=process.env.NEXT_PUBLIC_BUILD_ENV,i=n&&Object.prototype.hasOwnProperty.call(Ct,n)?Ct[n]:void 0;if(i)return i}return"dev"}function qe(){if(Ft("managed"))return!0;let e=process.env.__MAVIS_RUNTIME_MANAGED;return e==="1"?!0:e==="0"?!1:!!(ze()||K()==="prod"||K()==="staging")}function ze(){let e=process.versions;return process.env.ELECTRON_RUN_AS_NODE==="1"||typeof e.electron=="string"}function Qe(){return`${Rt()}-${K()}`}var V={none:0,test:1,internal:2,online:3},Ps={internal:"internal",inside:"online"};function Ns(e){for(let[n,i]of Object.entries(e)){if(V[i.defaultVisibility]>V[i.configurableVisibility])throw new Error(`Invalid beta feature definition "${n}": defaultVisibility (${i.defaultVisibility}) must not exceed configurableVisibility (${i.configurableVisibility})`);for(let r of i.defaultBuildVariants??[]){let t=Ps[r];if(V[t]>V[i.configurableVisibility])throw new Error(`Invalid beta feature definition "${n}": defaultBuildVariant (${r}) must not exceed configurableVisibility (${i.configurableVisibility})`)}for(let r of i.defaultBuildEnvironments??[])if(V[r==="prod"?"online":"test"]>V[i.configurableVisibility])throw new Error(`Invalid beta feature definition "${n}": defaultBuildEnvironment (${r}) must not exceed configurableVisibility (${i.configurableVisibility})`)}}var Te={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"},teamPlanWorkspaceCard:{defaultVisibility:"test",configurableVisibility:"online"},teamPlanDrilldown:{defaultVisibility:"test",configurableVisibility:"test"},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:"none",defaultBuildEnvironments:["dev"],defaultBuildVariants:["internal"],configurableVisibility:"online"}};Ns(Te);function Ds(e){return(e.buildEnv??K())!=="prod"?"test":e.internalBuild===!0?"internal":"online"}function Bs(e,n){let i=e.defaultBuildVariants;return i?n.internalBuild===!0&&i.includes("internal")||n.insideBuild===!0&&i.includes("inside"):!1}function Us(e,n){let i=n.defaultBuildEnvironment??n.buildEnv??ri();return e.defaultBuildEnvironments?.includes(i)===!0}function ri(){let e=ze()?process.env.NEXT_PUBLIC_BUILD_ENV:void 0;return Ot(e)?e:K()}function Mt(e,n){return e.defaultPlatforms?.includes(n.platform??process.platform)!==!1}function ti(e,n,i={}){let r=Te[e],t=V[Ds(i)],o=i.defaultBuildEnvironment??i.buildEnv??ri();return e==="mcodeTools"&&o==="dev"&&i.mcodeToolsDevMode==="published"&&Mt(r,i)?!0:n===!1?!1:n===!0?t<=V[r.configurableVisibility]:Mt(r,i)?Us(r,i)||Bs(r,i)?!0:t<=V[r.defaultVisibility]:!1}function js(e){return Te[e].configurableVisibility==="online"}function oi(e=process.env){return e.__MAVIS_BUILD_INTERNAL==="true"}function $s(e=process.env){return e.__MAVIS_BUILD_INSIDE==="true"}var Vs={APP_DIR:".minimax",ENV_PREFIX:"minimax",CLI_NAME:"minimax"},wt="__MAVIS_RUNTIME";function Ze(e){return ws()?process.env[`${wt}_${e}`]:void 0}function Je(e){let n=`--${e}`;for(let i=2;i<process.argv.length;i++){let r=process.argv[i];if(r===n)return process.argv[i+1];if(r?.startsWith(`${n}=`))return r.slice(n.length+1)}}function Ft(e){let n=`--${e}`;return process.argv.slice(2).some(i=>i===n||i.startsWith(`${n}=`))}var pe=5321,ni=5001,ei=65535,Pt=500,ai=2,Ks=Pt*ai,Nt=Ks+ai,It=1,Gs=new Set(["agent-archon","mavis"]),kt=(()=>{let n=new Uint32Array(256);for(let i=0;i<256;i++){let r=i<<24;for(let t=0;t<8;t++)r=(r&2147483648)!==0?79764919^r<<1:r<<1,r>>>=0;n[i]=r>>>0}return n})();function Ys(e){let n=Buffer.from(`${e}
36
- `,"utf-8"),i=0;for(let t of n)i=(kt[(i>>>24^t)&255]^i<<8)>>>0;let r=n.length;for(;r!==0;)i=(kt[(i>>>24^r&255)&255]^i<<8)>>>0,r>>>=8;return(i^4294967295)>>>0}function Ws(e){return Ys(e)%Pt*ai+2}function Lt(e,n){try{let i=Os("git",e,{encoding:"utf-8",timeout:3e3,stdio:["ignore","pipe","pipe"],...n?{cwd:n}:{}});return i.status===0&&i.stdout?i.stdout.trim():null}catch{return null}}function Hs(e){return e.match(/[/:]([^/:]+?)(?:\.git)?$/)?.[1]??null}function Dt(){return process.env.MINIMAX_DATA_DIR?.trim()||process.env.MAVIS_DATA_DIR?.trim()}function en(){return!(Ft("disable-git-auto-config")||Ze("DISABLE_GIT_AUTO_CONFIG")||Je("data-dir")||Dt())}function nn(){let e=Je("profile")??Ze("PROFILE");return e&&e.length>0?e:null}function Bt(){let e=Je("port")??Ze("PORT"),n=e?parseInt(e,10):NaN;return Number.isNaN(n)?null:n}function ii(){let e=Je("data-dir")??Dt()??Ze("DATA_DIR");return e&&e.length>0?e:null}function Xs(){return!!(nn()&&ii())}function Ut(){return!!(nn()&&Bt()!==null)}var ee=null;function qs(){ee=null}function ne(){if(ee!==null)return ee;let e={runtimePort:pe,uiPort:ni,profile:null,autoDetected:!1};return ee=e,e}function zs(){try{if(typeof __dirname=="string")return __dirname}catch{}let e=new Error().stack??"";for(let n of e.split(`
37
- `)){let i=/file:\/\/[^)\s]+/u.exec(n)?.[0]?.replace(/:\d+:\d+$/u,"");if(i)try{return T.dirname(Rs(i))}catch{}let r=/\(?((?:\/|[A-Za-z]:\\)[^()]+?\.(?:cjs|mjs|js|ts)):\d+:\d+\)?/u.exec(n)?.[1];if(r)return T.dirname(r)}}function Qs(){let e=nn();return e||(en()?ne().profile:null)}function li(){let e=nn();if(Xs())return ii();if(en()){let i=ne();if(i.autoDetected&&i.profile)return W({profile:i.profile})}let n=ii();return n||(e?W({profile:e}):W())}function ie(){return T.join(li(),"config.yaml")}var Zs={support_files_api:!0,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},jt={"MiniMax-M3":{name:"MiniMax-M3",attachment:!0,reasoning:!0,tool_call:!0,temperature:!0,modalities:{input:["text","image","video"],output:["text"]},limit:{context:512e3,output:128e3},contextWindowOptions:[512e3,1e6],contextWindowOptionHints:{1e6:"higher_usage"},options:{reasoningSummary:"auto"},thinking_config:{mode:"switchable",default_value:"true"},variants:{"none-thinking":{thinking:{type:"disabled"}},thinking:{thinking:{type:"adaptive"}}},capabilities:Zs},"MiniMax-M2.7-highspeed":{name:"MiniMax-M2.7-highspeed",attachment:!1,reasoning:!0,tool_call:!0,temperature:!0,modalities:{input:["text"],output:["text"]},limit:{context:2e5,output:128e3}},"MiniMax-M2.7":{name:"MiniMax-M2.7",attachment:!1,reasoning:!0,tool_call:!0,temperature:!0,modalities:{input:["text"],output:["text"]},limit:{context:2e5,output:128e3}}},me=jt,rn={"cn-test":"https://agent.minimaxi.com/mavis/api/v1/llm/v1","cn-dev":"https://agent.minimaxi.com/mavis/api/v1/llm/v1","cn-staging":"https://agent.minimaxi.com/mavis/api/v1/llm/v1","en-test":"https://agent.minimax.io/mavis/api/v1/llm/v1","en-dev":"https://agent.minimax.io/mavis/api/v1/llm/v1","en-staging":"https://agent.minimax.io/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"},$t=["https://agent.minimaxi.com/mavis/api/v1/llm/v1"],Js=new Set([...Object.values(rn),...$t]),eu=new Set([...Object.values(rn),...$t].map(e=>new URL(e).origin));function Vt(e){if(Js.has(e))return!0;try{let n=new URL(e);return!n.username&&!n.password&&eu.has(n.origin)}catch{return!1}}function Kt(){return K()==="test"}function nu(){return!Kt()}function iu(e){if(!qe()||!$.existsSync(e))return;let n=Gt(e),{provider:i}=n;if(i==null||typeof i!="object"||Array.isArray(i))return;let{minimax:r}=i;if(r==null||typeof r!="object"||Array.isArray(r))return;let{options:t}=r;if(t==null||typeof t!="object"||Array.isArray(t))return;let o=t.baseURL;if(typeof o!="string")return;let a=rn[Qe()];o===a||!Vt(o)||(t.baseURL=a,$.writeFileSync(e,C.dump(n,{indent:2,lineWidth:-1,noRefs:!0}),"utf-8"))}function X(e){return{provider:{minimax:{name:"MiniMax",npm:"@ai-sdk/anthropic",options:{authMode:"managed-login",apiKey:"sk-xxx",baseURL:rn[e]},models:jt}},defaultModel:"minimax/MiniMax-M3"}}var si={"cn-test":X("cn-test"),"cn-dev":X("cn-dev"),"cn-staging":X("cn-staging"),"cn-prod":X("cn-prod"),"en-test":X("en-test"),"en-dev":X("en-dev"),"en-staging":X("en-staging"),"en-prod":X("en-prod")},S={logLevel:"info",devPort:ni,permissionMode:"auto",sseErrorPush:{history:!0,stream:!0},beta:Object.fromEntries(Object.keys(Te).map(e=>[e,ti(e,void 0,{buildEnv:"dev"})])),agents:{default:{}},memory:{enabled:!0,proactive:!1,dailyDigest:{enabled:!1}},skillEvolve:{enabled:!0,inSession:{N:20,minIntervalSeconds:30,maxPendingPerSession:1},signalCooldownHours:24,minConfidence:.7,excludeAgents:["skill-editor"],disableModelPrefixes:["MiniMax-M2"],builtinMrEnabled:!1,sourceRepo:void 0,proposal:{enabled:!1,eligibleAgents:["mavis"],minMessageCount:40,skipPassiveSessionEnd:!0},lifecycle:{staleThresholdDays:15,archiveThresholdDays:30}},sessionRotate:{enabled:!0,activeSessionLookbackHours:12},agentStop:{debounceMs:500,maxActiveSpanMs:1800*1e3},asr:{...Ge},skills:We,askUser:{...Yn},sessionTitle:{enabled:!0},cli:{spawn:{enabled:!1}},browser:{...Ie},tui:{},opencode:{xdg:{dataIsolation:!1,startupImport:"off"},keepAlive:{enabled:!1,maxProcesses:5,maxLifetimeMs:288e5,agents:["mavis","main","verifier","code-reviewer"]},spawnConcurrency:3},contextManagement:{disableSystemReminderModels:[],cuMaxScreenshotsInContext:2},runawayGuard:{enabled:!0},toolResultCompaction:{...j},agentRuntime:{defaultFramework:se},logRetentionDays:3,cuBackend:Se,review:{mode:"subagent",modeSource:"default"},goal:structuredClone(F),sandbox:structuredClone(Zn),goalWarnings:[]};function ru(){let e=ie(),n=T.dirname(e);if($.existsSync(n)||$.mkdirSync(n,{recursive:!0}),$.existsSync(e)){ci(e);return}if(!qe()){let t=W({homeDir:Ts.homedir()}),o=T.join(t,"config.yaml");e!==o&&$.existsSync(o)&&$.copyFileSync(o,e);return}let i=si[Qe()],r=C.dump({logLevel:S.logLevel,provider:ui?i.provider:void 0,defaultModel:i.defaultModel});$.writeFileSync(e,r,"utf-8")}function Gt(e=ie()){try{let n=$.readFileSync(e,"utf-8"),i=C.load(n);return i!=null&&typeof i=="object"&&!Array.isArray(i)?i:{}}catch{return{}}}var Le=null;function tu(e){if(e==null||typeof e!="object"||Array.isArray(e))return;let n=e;return{branchFinish:typeof n.branchFinish=="boolean"?n.branchFinish:!1}}var Yt={isManagedRuntime:qe,shouldEnforceManagedProviderProtection:nu,getManagedPreset:()=>si[Qe()],isManagedPresetBaseUrl:Vt},Wt=!0,ui=!0;function ou(e){Wt=e}function au(e){ui=e}function ci(e){Wt&&$r(e,Yt),ui&&iu(e)}function ge(){Le=null}function ye(){if(Le)return Le;ru();let e=Gt();return Le=fi(e,li()),Le}function fi(e,n){let i=e.sseErrorPush,r=i!=null&&typeof i=="object"&&!Array.isArray(i)?i:void 0,t=typeof e.devPort=="number"?e.devPort:S.devPort;if(en()&&!Ut()){let u=ne();u.autoDetected&&(t=u.uiPort)}let o=Hn(e.goal),a=Vr({provider:e.provider!=null&&typeof e.provider=="object"&&!Array.isArray(e.provider)?Br(e.provider):{},defaultModel:typeof e.defaultModel=="string"?e.defaultModel:void 0},Yt),l=In(e.minimaxModelContextLimits),s=su(e);return{logLevel:typeof e.logLevel=="string"?e.logLevel:S.logLevel,devPort:t,...a,provider:Nr(a.provider,l),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:Pr(e.minimax_api),minimaxModelContextLimits:l,custom_provider:Dr(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)?(()=>{let u={};typeof Reflect.get(e.nexus,"enabled")=="boolean"&&(u.enabled=Reflect.get(e.nexus,"enabled"));let c=Reflect.get(e.nexus,"model");return c!=null&&typeof c=="object"&&!Array.isArray(c)&&typeof Reflect.get(c,"providerID")=="string"&&typeof Reflect.get(c,"modelID")=="string"&&(u.model={providerID:Reflect.get(c,"providerID"),modelID:Reflect.get(c,"modelID"),...typeof Reflect.get(c,"variant")=="string"?{variant:Reflect.get(c,"variant")}:{}}),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:S.permissionMode,permission:Xr(e),sseErrorPush:{history:typeof r?.history=="boolean"?r.history:S.sseErrorPush.history,stream:typeof r?.stream=="boolean"?r.stream:S.sseErrorPush.stream},notifications:tu(e.notifications),dataDir:n,agentsDir:T.join(n,"agents"),sessionsDir:T.join(n,"sessions"),memoryDir:T.join(n,"memory"),skillsDir:T.join(n,"skills"),builtinSkillsDir:T.join(n,".builtin-skills"),logsDir:T.join(n,"logs"),pluginsDir:T.join(n,"plugins"),plansDir:T.join(n,"plans"),harnessesDir:T.join(n,"harnesses"),subAgentsDir:T.join(n,"subagents"),beta:s,agents:Gn(e.agents),memory:lu(e),skillEvolve:fu(e,s),sessionRotate:du(e),agentStop:pu(e),asr:Hr(e),skills:kn(e),askUser:pt(e,S.askUser),sessionTitle:mu(e),cli:gu(e),browser:qn(e.browser),tui:Or(e),opencode:Yr(e,S.opencode),contextManagement:yu(e),runawayGuard:Cn(e.runawayGuard),toolResultCompaction:Xn(e.toolResultCompaction),agentRuntime:Ln(e.agentRuntime),logRetentionDays:hu(e),contentReview:xu(e),mcpToolSearch:bu(e),cuBackend:Ce(e.cuBackend),review:Gr(e.review,S.review),promptConfig:Ht(e.promptConfig),goal:o.config,goalWarnings:o.warnings,sandbox:Jn(e.sandbox)}}function lu(e){let n=e.memory,i=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},r=i.dailyDigest,t=r!=null&&typeof r=="object"&&!Array.isArray(r)?r:{};return{enabled:typeof i.enabled=="boolean"?i.enabled:S.memory.enabled,proactive:typeof i.proactive=="boolean"?i.proactive:S.memory.proactive,dailyDigest:{enabled:typeof t.enabled=="boolean"?t.enabled:S.memory.dailyDigest.enabled}}}function su(e){let n=e.beta!=null&&typeof e.beta=="object"&&!Array.isArray(e.beta)?e.beta:{},i={buildEnv:K(),defaultBuildEnvironment:ri(),internalBuild:oi(),insideBuild:$s(),mcodeToolsDevMode:process.env.MAVIS_DEV_MCODE_TOOLS_MODE==="published"?"published":void 0},r={};for(let t of Object.keys(Te))r[t]=ti(t,n[t],i);return r}function uu(e){let n=e.provider;if(n==null||typeof n!="object"||Array.isArray(n))return[];let i=[];for(let r of Object.values(n)){if(r==null||typeof r!="object"||Array.isArray(r))continue;let{models:t}=r;t==null||typeof t!="object"||Array.isArray(t)||i.push(...Object.keys(t))}return i}function cu(e,n){if(n.length===0)return!0;let i=uu(e);if(i.length===0)return!1;let r=n.map(t=>t.toLowerCase());return!i.every(t=>r.some(o=>t.toLowerCase().startsWith(o)))}function Tt(e,n){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:n}function fu(e,n){let i=S.skillEvolve,r=e.skillEvolve,o=r!=null&&typeof r=="object"&&!Array.isArray(r)?r:{},a=o.inSession,{inSession:l}=i;if(a!=null&&typeof a=="object"&&!Array.isArray(a)){let k=a;l={N:typeof k.N=="number"&&k.N>0?k.N:i.inSession.N,minIntervalSeconds:typeof k.minIntervalSeconds=="number"&&k.minIntervalSeconds>=0?k.minIntervalSeconds:i.inSession.minIntervalSeconds,maxPendingPerSession:typeof k.maxPendingPerSession=="number"&&k.maxPendingPerSession>=1?k.maxPendingPerSession:i.inSession.maxPendingPerSession}}let s=o.excludeAgents,u=Array.isArray(s)&&s.every(k=>typeof k=="string")?s:i.excludeAgents,c=Array.isArray(o.disableModelPrefixes)&&o.disableModelPrefixes.every(k=>typeof k=="string")?o.disableModelPrefixes:i.disableModelPrefixes,f=n.skillEvolve?typeof o.enabled=="boolean"?o.enabled:cu(e,c):!1,d=f&&n.skillEvolveBuiltinMr?typeof o.builtinMrEnabled=="boolean"?o.builtinMrEnabled:i.builtinMrEnabled:!1,p=o.sourceRepo,y=typeof p=="string"&&p.trim().length>0?p.trim():i.sourceRepo,g=o.proposal,x=i.proposal,b=g!=null&&typeof g=="object"&&!Array.isArray(g)?g:{},h=Array.isArray(b.eligibleAgents)&&b.eligibleAgents.every(k=>typeof k=="string")?b.eligibleAgents:x.eligibleAgents,we=typeof b.minMessageCount=="number"&&b.minMessageCount>=1?Math.floor(b.minMessageCount):x.minMessageCount,ao=typeof b.skipPassiveSessionEnd=="boolean"?b.skipPassiveSessionEnd:x.skipPassiveSessionEnd,lo=typeof b.enabled=="boolean"?b.enabled:null,so=f&&n.skillProposal?lo??!0:!1,Fe=o.lifecycle,_i=Fe&&typeof Fe=="object"&&!Array.isArray(Fe)?Fe:{},ln=Tt(_i.staleThresholdDays,i.lifecycle.staleThresholdDays),sn=Tt(_i.archiveThresholdDays,i.lifecycle.archiveThresholdDays);if(!(ln<sn))throw new Error(`Invalid skillEvolve.lifecycle config: staleThresholdDays (${ln}) must be strictly less than archiveThresholdDays (${sn}).`);return{enabled:f,inSession:l,signalCooldownHours:typeof o.signalCooldownHours=="number"&&o.signalCooldownHours>0?o.signalCooldownHours:i.signalCooldownHours,minConfidence:typeof o.minConfidence=="number"&&o.minConfidence>=0&&o.minConfidence<=1?o.minConfidence:i.minConfidence,scannerModel:typeof o.scannerModel=="string"?o.scannerModel:void 0,excludeAgents:u,disableModelPrefixes:c,builtinMrEnabled:d,sourceRepo:y,proposal:{enabled:so,eligibleAgents:h,minMessageCount:we,skipPassiveSessionEnd:ao},lifecycle:{staleThresholdDays:ln,archiveThresholdDays:sn}}}function du(e){let n=S.sessionRotate,i=e.sessionRotate;if(i==null||typeof i!="object"||Array.isArray(i))return{...n};let r=i,t=r.activeSessionLookbackHours;return{enabled:typeof r.enabled=="boolean"?r.enabled:n.enabled,activeSessionLookbackHours:typeof t=="number"&&Number.isFinite(t)&&t>0?t:n.activeSessionLookbackHours}}function pu(e){let n=S.agentStop,i=e.agentStop;if(i==null||typeof i!="object"||Array.isArray(i))return{...n};let r=i,t=r.debounceMs,o=r.maxActiveSpanMs;return{debounceMs:typeof t=="number"&&Number.isFinite(t)&&t>=0?t:n.debounceMs,maxActiveSpanMs:typeof o=="number"&&Number.isFinite(o)&&o>=0?o:n.maxActiveSpanMs}}function Ht(e){let n=K()==="prod"&&!oi();if(e==null||typeof e!="object"||Array.isArray(e))return{autoUpdate:n};let i=e.autoUpdate;return{autoUpdate:typeof i=="boolean"?i:n}}function mu(e){let n=S.sessionTitle,i=e.sessionTitle;if(i==null||typeof i!="object"||Array.isArray(i))return{...n};let r=i;return{enabled:typeof r.enabled=="boolean"?r.enabled:n.enabled}}function gu(e){let n=S.cli,i=e.cli;if(i==null||typeof i!="object"||Array.isArray(i))return{spawn:{...n.spawn}};let r=i.spawn;if(r==null||typeof r!="object"||Array.isArray(r))return{spawn:{...n.spawn}};let t=r;return{spawn:{enabled:typeof t.enabled=="boolean"?t.enabled:n.spawn.enabled}}}function yu(e){let n=S.contextManagement,i=e.contextManagement;if(i==null||typeof i!="object"||Array.isArray(i))return{disableSystemReminderModels:[...n.disableSystemReminderModels],cuMaxScreenshotsInContext:n.cuMaxScreenshotsInContext};let r=i,t=r.disableSystemReminderModels,o=Array.isArray(t)&&t.every(s=>typeof s=="string"&&s.length>0)?t:[...n.disableSystemReminderModels],a=r.cuMaxScreenshotsInContext,l=typeof a=="number"&&Number.isFinite(a)&&a>=0?Math.floor(a):n.cuMaxScreenshotsInContext;return{disableSystemReminderModels:o,cuMaxScreenshotsInContext:l}}function hu(e){let n=e.logRetentionDays;return typeof n=="number"&&n>=1&&Number.isFinite(n)?Math.floor(n):S.logRetentionDays}function xu(e){let n=e.contentReview;if(n==null||typeof n!="object"||Array.isArray(n))return;let i={},r=Reflect.get(n,"enabled");typeof r=="boolean"&&(i.enabled=r);let t=Reflect.get(n,"testBaseURL");return typeof t=="string"&&t.trim()&&(i.testBaseURL=t.trim()),Object.keys(i).length>0?i:void 0}function bu(e){let n=e.mcpToolSearch;if(n==null||typeof n!="object"||Array.isArray(n))return;let i={},r=Reflect.get(n,"enabled");typeof r=="boolean"&&(i.enabled=r);let t=Reflect.get(n,"systemHint");typeof t=="boolean"&&(i.systemHint=t);let o=Reflect.get(n,"thresholdPct");typeof o=="number"&&(i.thresholdPct=o);let a=Reflect.get(n,"minDeferCount");typeof a=="number"&&(i.minDeferCount=a);let l=Reflect.get(n,"topKDefault");typeof l=="number"&&(i.topKDefault=l);let s=Reflect.get(n,"topKMax");typeof s=="number"&&(i.topKMax=s);let u=Reflect.get(n,"maxSchemaTextLen");typeof u=="number"&&(i.maxSchemaTextLen=u);let c=Reflect.get(n,"modelWhitelist");return Array.isArray(c)&&(i.modelWhitelist=c.filter(f=>typeof f=="string")),Object.keys(i).length>0?i:void 0}function Xt(){let e=Bt();if(en()&&!Ut()){let n=ne();if(n.autoDetected)return n.runtimePort}return e??pe}function Au(e=Xt()){let n=e+Nt;if(n<=ei)return n;let i=e+It;if(i<=ei)return i;throw new Error(`Cannot allocate an OpenCode sidecar port for runtime port ${String(e)}; choose a runtime port <= ${String(ei-It)}.`)}var _u=["agent.minimaxi.com","agent.minimaxi.com","agent.minimax.io","agent.minimax.io","agent.minimax.io","agent.minimax.cn","agent.minimaxi.com"],vu=new Set(_u.map(e=>`https://${e}`));function Eu(e,n){return/^custom_provider:minimax-legacy(?:-\d+)?$/u.test(e)&&(!n||di(n))}function di(e){try{let n=new URL(e);return n.username||n.password?!1:vu.has(n.origin.toLowerCase())}catch{return!1}}function Su(e){if(!(e!=="managed-login"&&e!=="api-key"&&e!=="oauth"))return e}function pi(e){let n=typeof e?.baseURL=="string"?e.baseURL.trim():"",i=n.length>0&&di(n),r=Su(e?.authMode),t=[];return typeof e?.authMode=="string"&&!r&&t.push(`Unknown provider authMode "${e.authMode}"; falling back to compatibility resolution.`),r?(r==="managed-login"&&n.length>0&&!i&&!e?.allowManagedBaseURLOverride&&t.push("Provider authMode is managed-login but baseURL is not a known managed MiniMax host."),{authMode:r,source:"explicit",managedBaseURL:i,warnings:t}):i?(t.push("Provider authMode is inferred from a managed MiniMax baseURL; set options.authMode: managed-login to make this explicit."),{authMode:"managed-login",source:"inferred-managed-base-url",managedBaseURL:i,warnings:t}):{authMode:"api-key",source:"default-api-key",managedBaseURL:i,warnings:t}}var q="minimax",he="minimax_api",gi="custom_provider:";function Cu(e,n){return e==="anthropic-messages"&&(n===q||n===he)}function yi(e,n){if(n===he)return"minimax_api_key";if(n.startsWith(gi))return"custom_provider";if(n!==q)return"configured_provider";if(e.minimaxModelSource==="minimax_api_key")return"minimax_api_key";let i=e.provider?.[n]?.options;return pi({authMode:i?.authMode,baseURL:i?.baseURL}).authMode==="managed-login"?"managed_token_plan":"configured_provider"}function qt(e,n,i){switch(yi(e,n)){case"managed_token_plan":return mi(e.provider?.[n]);case"minimax_api_key":return Object.keys(me);case"custom_provider":{let t=e.custom_provider?.[n.slice(gi.length)];return!t||t.enabled===!1?[]:mi(t)}case"configured_provider":return mi(e.provider?.[n])}}function Mu(e){let n=yi(e.config,e.providerId),i=e.modelId.trim();return i.length>0&&qt(e.config,e.providerId,e.preset).includes(i)?{available:!0,route:n}:{available:!1,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 mi(e){return Object.entries(e?.models??{}).filter(([,n])=>n?.enabled!==!1).map(([n])=>n)}import{randomBytes as Iu}from"node:crypto";import re,{existsSync as ku,readFileSync as Lu}from"node:fs";import{dirname as zt,join as Tu}from"node:path";var Qt=vi(Ei(),1);var Zt=384,tn=new Set(["__proto__","prototype","constructor"]),Ou=["minimax_api","custom_provider"];async function Ru(e){let n=e.trim();if(!n||n.includes(".")||tn.has(n))throw new R("Invalid provider id");return Re(async i=>(P(i.provider)&&delete i.provider[n],{write:!0,value:void 0})).then(({config:i})=>({config:i}))}async function wu(e){if(!P(e)||!P(e.models))throw new R("Invalid managed MiniMax provider snapshot");return on(e),Re(async n=>(n.provider={...P(n.provider)?n.provider:{},[q]:structuredClone(e)},{write:!0,value:void 0})).then(({config:n})=>({config:n}))}var R=class extends Error{name="LocalModelProviderConfigValidationError"},Oe=class extends Error{name="LocalModelProviderConfigWriteError";constructor(){super("Local runtime failed to update config file")}};async function Fu(e){return Re(async(n,i)=>{let r={minimax_api:P(n.minimax_api)?n.minimax_api:void 0,custom_provider:$u(P(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(r,i);for(let t of Ou){let o=r[t];if(o===void 0){delete n[t];continue}if(!P(o))throw new R(`Invalid BYOK config subtree "${t}"`);on(o),n[t]=o}return hi(n,"minimaxModelSource",r.minimaxModelSource),n.defaultModel!==r.defaultModel&&(delete n.defaultModelThinking,delete n.defaultModelContextWindow),hi(n,"defaultModel",r.defaultModel),hi(n,"defaultModelVariant",r.defaultModelVariant),{write:!0,value:void 0}}).then(({config:n})=>({config:n}))}async function Pu(e){let n=e.modelKey.trim();if(!n)throw new R("Default model must not be empty");if(e.contextLimit!==void 0&&(!Number.isSafeInteger(e.contextLimit)||e.contextLimit<=0||e.contextLimit>2147483647))throw new R("Invalid default context");if(e.thinking?.effort!==void 0&&(typeof e.thinking.effort!="string"||!e.thinking.effort.trim()))throw new R("Invalid default effort");return Re(async i=>(i.defaultModel=n,e.contextLimit===void 0?delete i.defaultModelContextWindow:i.defaultModelContextWindow=e.contextLimit,e.thinking?.effort===void 0?delete i.defaultModelThinking:i.defaultModelThinking={effort:e.thinking.effort},e.variant===void 0?delete i.defaultModelVariant:i.defaultModelVariant=e.variant,{write:!0,value:void 0})).then(({config:i})=>({config:i}))}async function Nu(e,n){let i=e.modelId.trim();if(e.providerId!==q&&e.providerId!==he||!i||tn.has(i))throw new R("Invalid MiniMax model context target");if(e.providerId===he&&!me[i]?.contextWindowOptions?.includes(e.contextLimit))throw new R("Invalid MiniMax API context limit");let r=await Re(async(t,o)=>{if((e.providerId===q?o.provider?.[e.providerId]?.models?.[i]?.limit?.context:Du(o,i))!==e.expectedContextLimit)return{write:!1,value:!1};if(!await n(o))return{write:!1,value:!1};let l=e.providerId===q?["minimaxModelContextLimits",i]:["minimax_api","modelContextLimits",i];return Vu(t,l,e.contextLimit),{write:!0,value:!0}});return{config:r.config,updated:r.value}}function Du(e,n){let i=me[n],r=e.minimax_api?.modelContextLimits?.[n];return r!==void 0&&i?.contextWindowOptions?.includes(r)?r:i?.limit?.context}async function Re(e){let n=ie(),i;try{await re.promises.mkdir(zt(n),{recursive:!0}),await re.promises.writeFile(n,"",{flag:"a",mode:Zt}),i=await Qt.default.lock(n,{stale:1e4,retries:{retries:20,factor:1,minTimeout:5,maxTimeout:25}});let r=ju(n);ge();let t=await e(r,ye());return t.write&&(on(r),await Bu(n,C.dump(r,{indent:2,lineWidth:-1,noRefs:!0})),ge()),{config:ye(),value:t.value}}catch(r){throw r instanceof R||r instanceof Oe?r:new Oe}finally{await i?.().catch(()=>{})}}async function Bu(e,n){let i=Tu(zt(e),`.config-tmp-${Iu(6).toString("hex")}`);try{let r=await Uu(e);await re.promises.writeFile(i,n,{encoding:"utf-8",mode:r}),await re.promises.chmod(i,r),await re.promises.rename(i,e)}catch{throw await re.promises.unlink(i).catch(()=>{}),new Oe}}async function Uu(e){try{return(await re.promises.stat(e)).mode&511}catch(n){if(Ku(n)&&n.code==="ENOENT")return Zt;throw n}}function ju(e){if(!ku(e))return{};try{let n=C.load(Lu(e,"utf-8"));return P(n)?n:{}}catch{return{}}}function $u(e){if(e)return Object.fromEntries(Object.entries(e).filter(([,n])=>P(n)))}function hi(e,n,i){i===void 0?delete e[n]:e[n]=i}function Vu(e,n,i){let r=n.at(-1);if(!r)throw new R("Invalid config path");let t=e;for(let o of n.slice(0,-1)){if(!o||tn.has(o))throw new R("Invalid config path");let a=t[o];if(P(a))t=a;else{let l={};t[o]=l,t=l}}t[r]=i}function on(e){for(let[n,i]of Object.entries(e)){if(!n||tn.has(n))throw new R(`Local runtime cannot update config field segment "${n}"`);P(i)&&on(i)}}function Ku(e){return e instanceof Error&&"code"in e}function P(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ju(e){let n=e.trim();if(!n)return null;if(n.startsWith("{"))try{let r=JSON.parse(n),t=typeof r.pid=="number"?r.pid:parseInt(String(r.pid),10);if(isNaN(t)||t<=0)return null;let o=ec(r.owner)?r.owner:"unknown",a=nc(r.startedAt);return{pid:t,owner:o,...a!==void 0?{startedAt:a}:{},...typeof r.mode=="string"?{mode:r.mode}:{},...typeof r.startupToken=="string"?{startupToken:r.startupToken}:{}}}catch{return null}let i=parseInt(n,10);return isNaN(i)||i<=0?null:{pid:i,owner:"unknown"}}function ec(e){return e==="electron"||e==="cli"||e==="unknown"}function nc(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string")return;let n=new Date(e).getTime();return Number.isFinite(n)?n:void 0}function ic(e,n){let i={pid:e,owner:n,startedAt:Date.now()};return JSON.stringify(i)}function rc(){let e=process.argv.slice(2);for(let n=0;n<e.length;n++){let i=e[n],r=i==="--owner"?e[n+1]:i?.startsWith("--owner=")?i.slice(8):void 0;if(r==="electron")return"electron";if(r==="service"||r==="cli")return"cli"}return"cli"}import z from"node:fs";import tc from"node:path";var Jt="local-runtime.auth.json";function D(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function xi(e){return e?{...D(e.accessToken)?{accessToken:D(e.accessToken)}:{},...D(e.realUserID)?{realUserID:D(e.realUserID)}:{},...D(e.userEmail)?{userEmail:D(e.userEmail)}:{},...D(e.userName)?{userName:D(e.userName)}:{},...D(e.subUserName)?{subUserName:D(e.subUserName)}:{}}:{}}function an(e){return tc.join(e,Jt)}function oc(e){try{let n=z.readFileSync(an(e),"utf-8"),i=JSON.parse(n);if(i.version!==1||!i.auth||typeof i.auth!="object")return;let r=xi(i.auth);return r.accessToken?r:void 0}catch{return}}function ac(e,n,i={}){let r=an(e),t=xi(n);if(!t.accessToken)return eo(e),{path:r,written:!1};z.mkdirSync(e,{recursive:!0,mode:448});let o={version:1,updatedAtMs:Date.now(),auth:t},a=`${r}.${process.pid}.${Date.now()}.tmp`;return z.writeFileSync(a,`${JSON.stringify(o,null,2)}
38
- `,{encoding:"utf-8",mode:384}),i.retryWindowsFileSystem?(un(()=>z.renameSync(a,r)),un(()=>z.chmodSync(r,384))):(z.renameSync(a,r),z.chmodSync(r,384)),{path:r,written:!0}}function eo(e){try{z.rmSync(an(e),{force:!0})}catch{}}import no from"node:net";var io={"e2e-runtime":5e3,"e2e-ui":5500,"smoke-runtime":7e3},bi=100;async function lc(e,n={}){let i=n.isPortFree??uc,r=n.getFreePort??cc,t=n.getWorktreeBasePort??sc,o=t()+io[e],a=o-t();if(a<bi)throw new Error(`pickTestPort(${e}): role offset ${a} collides with app runtime (0); must be >= ${bi}.`);return o>65535?r():await i(o)?o:r()}function sc(){let e=ne();return e.autoDetected?e.runtimePort:pe}async function uc(e){return new Promise(n=>{let i=no.createServer();i.once("error",()=>n(!1)),i.listen(e,"127.0.0.1",()=>{i.close(()=>n(!0))})})}async function cc(){return new Promise((e,n)=>{let i=no.createServer();i.listen(0,"127.0.0.1",()=>{let r=i.address();if(r&&typeof r!="string"){let{port:t}=r;i.close(()=>e(t))}else i.close(()=>n(new Error("Failed to get free port")))}),i.on("error",n)})}import Ai from"node:fs";import fc from"node:path";var dc=new Set(["native","mcp"]);function ro(){return Ce(ye().cuBackend)}function pc(e){if(!dc.has(e))throw new Error(`invalid cuBackend value: ${String(e)}`);let n=ie(),i={};try{let r=Ai.readFileSync(n,"utf-8"),t=C.load(r);t!=null&&typeof t=="object"&&!Array.isArray(t)&&(i=t)}catch{}i.cuBackend=e,Ai.mkdirSync(fc.dirname(n),{recursive:!0}),Ai.writeFileSync(n,C.dump(i),"utf-8"),ge()}function mc(e=ro()){Kr(e)}import to from"node:fs";var xe=class extends Error{code;configPath;constructor(n,i,r,t){super(r,t),this.name="ConfigFileError",this.code=n,this.configPath=i}};function oo(e){let n;try{n=to.readFileSync(e,"utf-8")}catch(r){throw new xe("CONFIG_READ_FAILED",e,`Cannot read config ${e}.`,{cause:r})}let i;try{i=C.load(n)}catch(r){throw new xe("CONFIG_PARSE_FAILED",e,`Config is not valid YAML: ${e}`,{cause:r})}if(i==null||typeof i!="object"||Array.isArray(i))throw new xe("CONFIG_ROOT_INVALID",e,`Config root must be an object: ${e}`);return i}function gc(e,n){return to.existsSync(e)&&ci(e),fi(oo(e),n.dataDir)}function yc(e,n){let i=oo(e);if(i.beta==null||typeof i.beta!="object"||Array.isArray(i.beta))return;let r=i.beta[n];return typeof r=="boolean"?r:void 0}export{hc as a,xc as b,uo as c,C as d,Rl as e,Sn as f,Cn as g,Se as h,Ce as i,We as j,kn as k,is as l,zr as m,se as n,Qr as o,Ln as p,rt as q,tt as r,at as s,lt as t,W as u,fs as v,ds as w,$n as x,Vn as y,Kn as z,ut as A,Gn as B,ys as C,xs as D,bs as E,As as F,_s as G,yt as H,ht as I,xt as J,bt as K,At as L,F as M,Wn as N,Hn as O,j as P,Xn as Q,Ie as R,qn as S,vt as T,Qn as U,Zn as V,Jn as W,St as X,Rt as Y,K as Z,qe as _,Qe as $,ti as aa,js as ba,oi as ca,Vs as da,wt as ea,pe as fa,Nt as ga,qs as ha,ne as ia,Qs as ja,li as ka,ie as la,me as ma,Kt as na,si as oa,ou as pa,au as qa,ge as ra,ye as sa,Ht as ta,Xt as ua,Au as va,Eu as wa,di as xa,pi as ya,q as za,he as Aa,gi as Ba,Cu as Ca,yi as Da,qt as Ea,Mu as Fa,Ru as Ga,wu as Ha,Fu as Ia,Pu as Ja,Nu as Ka,Ju as La,ic as Ma,rc as Na,Jt as Oa,xi as Pa,an as Qa,oc as Ra,ac as Sa,eo as Ta,io as Ua,bi as Va,lc as Wa,ro as Xa,pc as Ya,mc as Za,xe as _a,gc as $a,yc as ab};
47
+ `+e.slice(a+1):s+=e.slice(t),s.slice(1)}function ul(e){for(var n="",i=0,r,t=0;t<e.length;i>=65536?t+=2:t++)i=be(e,t),r=M[i],!r&&Ee(i)?(n+=e[t],i>=65536&&(n+=e[t+1])):n+=r||el(i);return n}function cl(e,n,i){var r="",t=e.tag,o,a,l;for(o=0,a=i.length;o<a;o+=1)l=i[o],e.replacer&&(l=e.replacer.call(i,String(o),l)),(U(e,n,l,!1,!1)||typeof l>"u"&&U(e,n,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=t,e.dump="["+r+"]"}function Bi(e,n,i,r){var t="",o=e.tag,a,l,s;for(a=0,l=i.length;a<l;a+=1)s=i[a],e.replacer&&(s=e.replacer.call(i,String(a),s)),(U(e,n+1,s,!0,!0,!1,!0)||typeof s>"u"&&U(e,n+1,null,!0,!0,!1,!0))&&((!r||t!=="")&&(t+=gn(e,n)),e.dump&&_e===e.dump.charCodeAt(0)?t+="-":t+="- ",t+=e.dump);e.tag=o,e.dump=t||"[]"}function fl(e,n,i){var r="",t=e.tag,o=Object.keys(i),a,l,s,u,c;for(a=0,l=o.length;a<l;a+=1)c="",r!==""&&(c+=", "),e.condenseFlow&&(c+='"'),s=o[a],u=i[s],e.replacer&&(u=e.replacer.call(i,s,u)),U(e,n,s,!1,!1)&&(e.dump.length>1024&&(c+="? "),c+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),U(e,n,u,!1,!1)&&(c+=e.dump,r+=c));e.tag=t,e.dump="{"+r+"}"}function dl(e,n,i,r){var t="",o=e.tag,a=Object.keys(i),l,s,u,c,f,d;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new L("sortKeys must be a boolean or a function");for(l=0,s=a.length;l<s;l+=1)d="",(!r||t!=="")&&(d+=gn(e,n)),u=a[l],c=i[u],e.replacer&&(c=e.replacer.call(i,u,c)),U(e,n+1,u,!0,!0,!0)&&(f=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,f&&(e.dump&&_e===e.dump.charCodeAt(0)?d+="?":d+="? "),d+=e.dump,f&&(d+=gn(e,n)),U(e,n+1,c,!0,f)&&(e.dump&&_e===e.dump.charCodeAt(0)?d+=":":d+=": ",d+=e.dump,t+=d));e.tag=o,e.dump=t||"{}"}function Ui(e,n,i){var r,t,o,a,l,s;for(t=i?e.explicitTypes:e.implicitTypes,o=0,a=t.length;o<a;o+=1)if(l=t[o],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof n=="object"&&n instanceof l.instanceOf)&&(!l.predicate||l.predicate(n))){if(i?l.multi&&l.representName?e.tag=l.representName(n):e.tag=l.tag:e.tag="?",l.represent){if(s=e.styleMap[l.tag]||l.defaultStyle,hr.call(l.represent)==="[object Function]")r=l.represent(n,s);else if(xr.call(l.represent,s))r=l.represent[s](n,s);else throw new L("!<"+l.tag+'> tag resolver accepts not "'+s+'" style');e.dump=r}return!0}return!1}function U(e,n,i,r,t,o,a){e.tag=null,e.dump=i,Ui(e,i,!1)||Ui(e,i,!0);var l=hr.call(e.dump),s=r,u;r&&(r=e.flowLevel<0||e.flowLevel>n);var c=l==="[object Object]"||l==="[object Array]",f,d;if(c&&(f=e.duplicates.indexOf(i),d=f!==-1),(e.tag!==null&&e.tag!=="?"||d||e.indent!==2&&n>0)&&(t=!1),d&&e.usedDuplicates[f])e.dump="*ref_"+f;else{if(c&&d&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(dl(e,n,e.dump,t),d&&(e.dump="&ref_"+f+e.dump)):(fl(e,n,e.dump),d&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&n>0?Bi(e,n-1,e.dump,t):Bi(e,n,e.dump,t),d&&(e.dump="&ref_"+f+e.dump)):(cl(e,n,e.dump),d&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&ll(e,e.dump,n,o,s);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new L("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(u=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?u="!"+u:u.slice(0,18)==="tag:yaml.org,2002:"?u="!!"+u.slice(18):u="!<"+u+">",e.dump=u+" "+e.dump)}return!0}function pl(e,n){var i=[],r=[],t,o;for(hn(e,i,r),t=0,o=r.length;t<o;t+=1)n.duplicates.push(i[r[t]]);n.usedDuplicates=new Array(o)}function hn(e,n,i){var r,t,o;if(e!==null&&typeof e=="object")if(t=n.indexOf(e),t!==-1)i.indexOf(t)===-1&&i.push(t);else if(n.push(e),Array.isArray(e))for(t=0,o=e.length;t<o;t+=1)hn(e[t],n,i);else for(r=Object.keys(e),t=0,o=r.length;t<o;t+=1)hn(e[r[t]],n,i)}function ml(e,n){n=n||{};var i=new il(n);i.noRefs||pl(e,i);var r=e;return i.replacer&&(r=i.replacer.call({"":r},"",r)),U(i,0,r,!0,!0)?i.dump+`
48
+ `:""}var gl=ml,yl={dump:gl};function En(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var hl=I,xl=Vi,bl=Wi,Al=Qi,_l=Zi,vl=bn,El=yr.load,Sl=yr.loadAll,Cl=yl.dump,Il=L,Ml={binary:rr,float:zi,map:Yi,null:Hi,pairs:or,set:ar,timestamp:nr,bool:Xi,int:qi,merge:ir,omap:tr,seq:Gi,str:Ki},kl=En("safeLoad","load"),Ll=En("safeLoadAll","loadAll"),Tl=En("safeDump","dump"),C={Type:hl,Schema:xl,FAILSAFE_SCHEMA:bl,JSON_SCHEMA:Al,CORE_SCHEMA:_l,DEFAULT_SCHEMA:vl,load:El,loadAll:Sl,dump:Cl,YAMLException:Il,types:Ml,safeLoad:kl,safeLoadAll:Ll,safeDump:Tl};var Tr=vi(Ei(),1);async function wl(e,n){let i=kr(e,"config.yaml"),r,t;try{await j.mkdir(e,{recursive:!0}),await j.writeFile(i,"",{flag:"a",mode:384});let o=await j.realpath(i);r=kr(Ol(o),`.config-tmp-${Rl(6).toString("hex")}`),t=await Tr.default.lock(o,{stale:1e4,retries:{retries:20,factor:1,minTimeout:5,maxTimeout:25}});let l=C.load(await j.readFile(o,"utf8"))??{};if(!Lr(l))throw new Error("Invalid config document");let s=l.tui??{};if(!Lr(s))throw new Error("Invalid TUI settings");let u={...s};n===void 0?delete u.statusLine:u.statusLine=[...n];let c={...l,tui:u},f=(await j.stat(o)).mode&511;await j.writeFile(r,C.dump(c,{lineWidth:-1,noRefs:!0}),{encoding:"utf8",mode:f}),await j.chmod(r,f),await j.rename(r,o)}catch{throw new Error("Unable to save status line settings. Check config.yaml syntax and permissions.")}finally{r&&await j.unlink(r).catch(()=>{}),await t?.().catch(()=>{})}}function Lr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function Sn(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};let n=e.enabled;return typeof n=="boolean"?{enabled:n}:{}}function Cn(e,n){return{enabled:Sn(n).enabled??Sn(e).enabled??!0}}import $ from"node:fs";import T from"node:path";import Os from"node:os";import{spawnSync as ws}from"node:child_process";import{fileURLToPath as Fs}from"node:url";function Rr(e){let n=e.tui;if(n==null||typeof n!="object"||Array.isArray(n))return{};let i=n,r=i.notifications,t;if(r&&typeof r=="object"&&!Array.isArray(r)){let{when:s,method:u}=r;t={...s==="unfocused"||s==="always"||s==="never"?{when:s}:{},...u==="auto"||u==="osc9"||u==="osc777"||u==="bel"?{method:u}:{}}}let o=i.statusLine,a=Array.isArray(o)?o.filter(s=>typeof s=="string").map(s=>s.trim()).filter(Boolean):void 0,l=Fl(i.customStatusLine);return{...typeof i.showTips=="boolean"?{showTips:i.showTips}:{},...t?{notifications:t}:{},...a?{statusLine:a}:{},...l?{customStatusLine:l}:{}}}function Fl(e){if(e==null||typeof e!="object"||Array.isArray(e))return;let n=e,i=typeof n.command=="string"?n.command.trim():"";if(i)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 Pl}from"node:crypto";import $e from"node:fs";import Or from"node:path";function Pr(e){if(e==null||typeof e!="object"||Array.isArray(e))return;let n=e,i={};typeof n.apiKey=="string"&&(i.apiKey=n.apiKey),typeof n.baseURL=="string"&&(i.baseURL=n.baseURL);let r=Mn(n.modelContextLimits);return r&&(i.modelContextLimits=r),Object.keys(i).length>0?i:void 0}function Mn(e){if(!A(e))return;let 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 Nr(e,n){let i=e.minimax;if(!i?.models||!n)return e;let r=!1,t=Object.fromEntries(Object.entries(i.models).map(([o,a])=>{let l=n[o];return l===void 0||!a.contextWindowOptions?.includes(l)||a.limit?.context===l?[o,a]:(r=!0,[o,{...a,limit:{...a.limit,context:l}}])}));return r?{...e,minimax:{...i,models:t}}:e}function Dr(e){if(e==null||typeof e!="object"||Array.isArray(e))return;let n=Object.entries(e).filter(([,i])=>i!=null&&typeof i=="object"&&!Array.isArray(i));if(n.length!==0)return Object.fromEntries(n.map(([i,r])=>[i,Ur(r)]))}function Br(e){return Object.fromEntries(Object.entries(e).map(([n,i])=>[n,A(i)?Ur(i):i]))}function Ur(e){if(!A(e.models))return e;let n=!1,i=Object.fromEntries(Object.entries(e.models).map(([r,t])=>{if(!A(t)||!A(t.thinking))return[r,t];let o=typeof t.thinking.effort=="string"?t.thinking.effort.trim():"",a=typeof t.thinking.defaultEffort=="string"?t.thinking.defaultEffort.trim():"";if(!Object.hasOwn(t.thinking,"effort")&&!Object.hasOwn(t.thinking,"defaultEffort"))return[r,t];let l=[],s=new Set;if(Array.isArray(t.thinking.effortOptions))for(let d of t.thinking.effortOptions){if(typeof d!="string")continue;let p=d.trim();!p||s.has(p)||(s.add(p),l.push(p))}o&&!s.has(o)&&(s.add(o),l.push(o)),a&&!s.has(a)&&(s.add(a),l.push(a));let u={...t.thinking};delete u.effort,delete u.effortOptions,delete u.defaultEffort;let c={...u,...l.length>0?{effortOptions:l}:{},...a?{defaultEffort:a}:{}},f={...t};return Object.keys(c).length>0?f.thinking=c:delete f.thinking,n=!0,[r,f]}));return n?{...e,models:i}:e}var jr="byok_legacy_provider_to_custom_provider_v1",Nl="config.yaml.bak.byok-legacy-provider.",In=new Set(["minimax","minimax_api","provider","custom_provider"]),Dl=/^[A-Za-z0-9 _-]+$/;function $r(e,n){let i={migrated:!1,migratedProviders:{}};if(!n.isManagedRuntime()||!$e.existsSync(e))return i;let r=jl(e);if(!A(r.provider))return i;let t=r.provider,o=A(r.custom_provider)?r.custom_provider:{},a=ql(r),l={},s={...o},u=new Set(Object.keys(s)),c=!1,f=n.getManagedPreset().provider;for(let[d,p]of Object.entries(t)){if(!$l(d,p,f))continue;let y=a.providers[d];if(y&&!In.has(y)&&!A(s[y])){delete t[d],c=!0;continue}let g=y&&!In.has(y)?y:Gl(d,p,u);l[d]=g,A(s[g])||(s[g]=Kl(p),u.add(g),c=!0),a.providers[d]!==g&&(a.providers[d]=g,c=!0),delete t[d],c=!0}if(!c&&Object.keys(l).length===0)return i;if(c=Fr(r,"defaultModel",l)||c,c=Fr(r,"defaultLightModel",l)||c,c=Hl(r,l)||c,!c)return{migrated:!1,migratedProviders:l};Object.keys(s).length>0?r.custom_provider=s:delete r.custom_provider,zl(r,a);try{let d=Xl(e);return $e.writeFileSync(e,C.dump(r,{indent:2,lineWidth:-1,noRefs:!0}),"utf-8"),{migrated:!0,migratedProviders:l,backupPath:d}}catch(d){return console.warn(`[config] legacy BYOK provider migration skipped: ${Zl(d)}`),{migrated:!1,migratedProviders:l}}}function Vr(e,n){let i=e.provider,r=e.defaultModel;if(Object.prototype.hasOwnProperty.call(i,"minimax_api")){let{minimax_api:y,...g}=i;i=g,console.warn('[config] "minimax_api" is a reserved provider id; ignoring provider.minimax_api from config.yaml')}let o=n.getManagedPreset().provider.minimax,a=i.minimax,l=n.isManagedRuntime();if(!(l||Bl(a,n)))return{provider:i,defaultModel:r};let u=a?.options,c=l&&n.shouldEnforceManagedProviderProtection(),f=Ul(o.models,a?.models),d=typeof u?.baseURL=="string"&&u.baseURL.length>0?u.baseURL:void 0,p=c&&d!=null&&!n.isManagedPresetBaseUrl(d);return i={...i,minimax:{...o,...a??{},npm:a?.npm??o.npm,models:f,options:{...o.options??{},...u??{},...p?{apiKey:o.options?.apiKey}:{},...c?{authMode:"managed-login",baseURL:o.options?.baseURL}:{}}}},{provider:i,defaultModel:r}}function Bl(e,n){let i=e?.options;return i?.authMode==="managed-login"?!0:typeof i?.baseURL=="string"&&n.isManagedPresetBaseUrl(i.baseURL)}function Ul(e,n){return n&&Object.keys(n).length>0?n:e??{}}function jl(e){try{let n=C.load($e.readFileSync(e,"utf-8"));return A(n)?n:{}}catch{return{}}}function $l(e,n,i){return e==="minimax"||e==="minimax_api"||!Ql(n)||!Vl(n)?!1:!Object.prototype.hasOwnProperty.call(i,e)}function Vl(e){let n=A(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&&A(e.models)}function Kl(e){let n=A(e.options)?e.options:{};return{...e,kind:"custom",enabled:e.enabled!==!1,options:{...n,authMode:"api-key"}}}function Gl(e,n,i){let r=A(n)?n:{},t=typeof r.name=="string"?r.name:void 0,o=`provider-${Yl(e)}`,a=wr(e)??wr(t)??o;for(let l=0;;l+=1){let s=l===0?a:`${a}-${l+1}`;if(!i.has(s)&&!In.has(s))return s}}function wr(e){let n=e?.trim();return!n||!Dl.test(n)?void 0:n.toLowerCase().replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")||void 0}function Yl(e){return Pl("sha256").update(e).digest("hex").slice(0,8)}function Fr(e,n,i){let r=e[n];if(typeof r!="string")return!1;let t=Wl(r,i);return t===r?!1:(e[n]=t,!0)}function Wl(e,n){let i=e.indexOf("/");if(i<=0||i===e.length-1)return e;let r=e.slice(0,i),t=n[r];return t?`custom_provider:${t}/${e.slice(i+1)}`:e}function Hl(e,n){if(!A(e.nexus)||!A(e.nexus.model))return!1;let i=e.nexus.model.providerID;if(typeof i!="string")return!1;let r=n[i];return r?(e.nexus.model.providerID=`custom_provider:${r}`,!0):!1}function Xl(e){let n=Or.join(Or.dirname(e),`${Nl}${Date.now()}`);return $e.copyFileSync(e,n),n}function ql(e){let i=(A(e.migrations)?e.migrations:void 0)?.[jr];return{providers:A(i)&&A(i.providers)?Object.fromEntries(Object.entries(i.providers).filter(t=>typeof t[1]=="string")):{}}}function zl(e,n){let i=A(e.migrations)?e.migrations:{};i[jr]={version:1,providers:n.providers},e.migrations=i}function Ql(e){return A(e)?typeof e.name=="string"||typeof e.npm=="string"||typeof e.api=="string"||A(e.options)||A(e.models):!1}function A(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Zl(e){return e instanceof Error?e.message:String(e)}var Se="native";function Ce(e){return e==="native"||e==="mcp"?e:Se}function Kr(e){if(e==="mcp")throw new Error("MCP backend coming in v2 follow-up plan")}function Gr(e,n){if(e==null||typeof e!="object"||Array.isArray(e))return n;let i=Reflect.get(e,"mode");return{mode:i==="inline"||i==="subagent"?i:n.mode,modeSource:i==="inline"||i==="subagent"?"explicit":"default"}}function Yr(e,n){let i=n.keepAlive,r=n.xdg,t=n.spawnConcurrency,o=()=>({enabled:i.enabled,maxProcesses:i.maxProcesses,maxLifetimeMs:i.maxLifetimeMs,agents:[...i.agents]}),a=e.opencode;if(a==null||typeof a!="object"||Array.isArray(a))return{keepAlive:o(),xdg:{...r},spawnConcurrency:t};let l=a,s=l.spawnConcurrency,u=typeof s=="number"&&Number.isFinite(s)&&s>0&&Number.isInteger(s)?s:t,c=Jl(l.xdg,r),f=l.keepAlive;if(f==null||typeof f!="object"||Array.isArray(f))return{keepAlive:o(),xdg:c,spawnConcurrency:u};let d=f,p=d.maxProcesses,y=typeof p=="number"&&Number.isFinite(p)&&p>0&&Number.isInteger(p)?p:i.maxProcesses,g=d.maxLifetimeMs,x=typeof g=="number"&&Number.isFinite(g)&&g>0&&Number.isInteger(g)?g:i.maxLifetimeMs,b=d.agents,h;return Array.isArray(b)?(h=b.filter(we=>typeof we=="string"&&we.length>0),h.length===0&&(h=[...i.agents])):h=[...i.agents],{keepAlive:{enabled:typeof d.enabled=="boolean"?d.enabled:i.enabled,maxProcesses:y,maxLifetimeMs:x,agents:h},xdg:c,spawnConcurrency:u}}function Jl(e,n){let i=e!=null&&typeof e=="object"&&!Array.isArray(e)?e:void 0,r=i?.startupImport,t=r==="background"||r==="blocking"||r==="off"?r:n.startupImport;return{dataIsolation:typeof i?.dataIsolation=="boolean"?i.dataIsolation:n.dataIsolation,startupImport:t}}function Ve(e){let n=JSON.stringify({level:40,time:Date.now(),name:"config.asr",msg:e});process.stderr.write(`${n}
49
+ `)}var Ge={enabled:!0};function Wr(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let n=e,i=typeof n.apiKey=="string"&&n.apiKey.trim().length>0,r=typeof n.resourceId=="string"&&n.resourceId.trim().length>0;return i||r}function Ke(e){return typeof e=="string"&&e.trim().length>0}function Hr(e){let n=e.asr;if(n==null||typeof n!="object"||Array.isArray(n))return{...Ge};let i=n;return Wr(i.seed)&&Ve("Ignoring legacy `asr.seed.*` in config \u2014 Seed ASR was retired from the daemon; only Amadeus remains. Remove `asr.seed` from config.yaml."),Wr(i.qwen)&&Ve("Ignoring legacy `asr.qwen.apiKey` in config \u2014 Qwen ASR was retired from the daemon; only Amadeus remains. Remove `asr.qwen` from config.yaml."),(Ke(i.mode)||Ke(i.proxyBaseUrl))&&Ve("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."),(Ke(i.primaryProvider)||Ke(i.fallbackProvider))&&Ve("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."),{enabled:typeof i.enabled=="boolean"?i.enabled:Ge.enabled}}var es={policyOwner:"core",storageWriteVersion:2,classifierTimeoutMs:6e4,userConfirmationEnabled:!0};function Xr(e,n=es){let i=e.permission;if(i==null||typeof i!="object"||Array.isArray(i))return{...n};let r=i,t=r.policyOwner===void 0?n.policyOwner:r.policyOwner==="engine"||r.policyOwner==="core"?r.policyOwner:"engine",o=r.storageWriteVersion===1||r.storageWriteVersion===2?r.storageWriteVersion:n.storageWriteVersion,a=r.classifierTimeoutMs,l=typeof a=="number"&&Number.isFinite(a)&&a>=5e3?Math.floor(a):n.classifierTimeoutMs,s=typeof r.userConfirmationEnabled=="boolean"?r.userConfirmationEnabled:n.userConfirmationEnabled;return{policyOwner:t,storageWriteVersion:o,classifierTimeoutMs:l,userConfirmationEnabled:s}}var qr=["user-cc","user-codex","user-agents","workspace-minimax","workspace-cc","workspace-agents"],ns={"user-cc":"user-claude","workspace-cc":"workspace-claude"},We={external:{enabled:!0,walkUp:!0,duplicateWarn:!0,sources:{"workspace-minimax":{enabled:!0,priority:65},"workspace-cc":{enabled:!0,priority:60},"workspace-agents":{enabled:!0,priority:55},"user-cc":{enabled:!0,priority:40},"user-codex":{enabled:!0,priority:35},"user-agents":{enabled:!0,priority:30}}}};function Ye(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function is(e,n){return Ye(e)?{enabled:typeof e.enabled=="boolean"?e.enabled:n.enabled,priority:typeof e.priority=="number"&&Number.isFinite(e.priority)?e.priority:n.priority}:n}function kn(e){let n=We,i=Ye(e.skills)?e.skills:{},r=Ye(i.external)?i.external:{},t=Ye(r.sources)?r.sources:{},o={...n.external.sources};for(let a of qr){let l=ns[a],s=Object.hasOwn(t,a)?t[a]:l?t[l]:void 0;o[a]=is(s,n.external.sources[a])}return{external:{enabled:typeof r.enabled=="boolean"?r.enabled:n.external.enabled,walkUp:typeof r.walkUp=="boolean"?r.walkUp:n.external.walkUp,duplicateWarn:typeof r.duplicateWarn=="boolean"?r.duplicateWarn:n.external.duplicateWarn,sources:o}}}var rs=qr;var zr=["pi-agent"],se="pi-agent";function Qr(e){return typeof e!="string"?se:zr.includes(e)?e:se}function Ln(e){return e==null||typeof e!="object"||Array.isArray(e)?{defaultFramework:se}:{defaultFramework:Qr(e.defaultFramework)}}import E from"node:fs";import ts from"node:os";import ue from"node:path";var rt=".minimax",tt=".mavis",os={error:()=>{},info:()=>{},warn:()=>{}};function Fn(e){return e??ts.homedir()}function ot(e,n){return n?`${e}-${n}`:e}function at(e,n){return ue.join(Fn(e),ot(rt,n))}function lt(e,n){return ue.join(Fn(e),ot(tt,n))}function Rn(e){try{let n=E.lstatSync(e);return n.isSymbolicLink()?{kind:"link"}:n.isDirectory()?{kind:"directory"}:{kind:"other"}}catch(n){let i=n.code;return i==="ENOENT"||i==="ENOTDIR"?{kind:"missing"}:{kind:"inaccessible",error:n}}}function Tn(e){let n=ue.resolve(e);return process.platform==="win32"?(n=n.replace(/^\\\\\?\\/,""),n.toLowerCase()):n}function Pn(e,n){try{let i=E.readlinkSync(e),r=Tn(n);return Tn(ue.resolve(ue.dirname(e),i))===r||Tn(i)===r}catch{return!1}}function He(e,n,i){if(!Pn(e,n))try{E.symlinkSync(n,e,process.platform==="win32"?"junction":"dir")}catch(r){i.warn(`Failed to create compat link ${e} -> ${n}: ${String(r)}`)}}function Zr(e,n,i){if(n.kind==="missing")return!0;if(n.kind==="link"||n.kind==="other")try{return E.unlinkSync(e),!0}catch(r){return i.warn(`Failed to remove ${e} before creating compat link: ${String(r)}`),!1}return!1}function On(e){try{let n=E.readdirSync(e);if(n.length===0)return"empty";if(n.length===1&&n[0]==="workspace")try{return E.readdirSync(ue.join(e,"workspace")).length>0?"hasData":"empty"}catch{return"unknown"}return"hasData"}catch{return"unknown"}}function wn(e){try{return E.statSync(e).isDirectory()?On(e):void 0}catch{return"unknown"}}function as(e,n){return`${e}.backup-${n()}`}function ls(e,n,i){let r=as(e,i);try{return E.renameSync(e,r),n.warn(`Backed up legacy data dir ${e} -> ${r}`),!0}catch(t){return n.warn(`Failed to back up legacy data dir ${e}: ${String(t)}`),!1}}function ss(e,n,i,r){if(Pn(e,n))return!0;let t=Rn(e);if(t.kind==="missing")return!0;if(t.kind==="link"){let o=wn(e);return o==="hasData"||o==="unknown"?(i.warn(`Cannot replace legacy data dir symlink ${e}; it may point to real data outside ${n}`),!1):Zr(e,t,i)}return t.kind==="other"?Zr(e,t,i):t.kind==="directory"?ls(e,i,r):(i.warn(`Cannot replace inaccessible legacy data dir ${e}; leaving it untouched`),!1)}function Jr(e,n,i,r){ss(e,n,i,r)&&He(e,n,i)}function us(e,n){try{return E.rmSync(e,{recursive:!0,force:!1}),!0}catch(i){return n.warn(`Failed to remove empty primary data dir ${e}: ${String(i)}`),!1}}function et(e,n,i){try{return E.renameSync(e,n),i.info(`Migrated legacy data dir ${e} -> ${n}`),!0}catch(r){return i.warn(`Failed to migrate legacy data dir ${e} -> ${n}: ${String(r)}`),!1}}function cs(e,n,i,r){try{E.cpSync(e,i,{recursive:!0,errorOnExist:!0,force:!1}),E.unlinkSync(n);try{E.rmSync(e,{recursive:!0,force:!1})}catch(t){r.warn(`Copied legacy symlink data dir ${e} -> ${i}, but failed to remove old target: ${String(t)}`)}return r.info(`Copied legacy data dir symlink target ${e} -> ${i}`),!0}catch(t){try{E.existsSync(i)&&E.rmSync(i,{recursive:!0,force:!0})}catch(o){r.warn(`Failed to clean up partial primary data dir ${i}: ${String(o)}`)}return r.warn(`Failed to copy legacy symlink data dir ${n} -> ${i}: ${String(t)}`),!1}}function nt(e,n,i){try{let r=E.realpathSync(e);try{E.renameSync(r,n)}catch(t){if(t.code==="EXDEV")return cs(r,e,n,i);throw t}return E.unlinkSync(e),i.info(`Migrated legacy data dir symlink target ${r} -> ${n}`),!0}catch(r){return i.warn(`Failed to migrate legacy symlink data dir ${e} -> ${n}: ${String(r)}`),!1}}function it(e,n){try{return E.mkdirSync(e,{recursive:!0}),!0}catch(i){return n.warn(`Failed to create primary data dir ${e}: ${String(i)}`),!1}}function fs(e,n,i,r){let t=Rn(e),o=Rn(n);if(t.kind==="inaccessible")return i.warn(`Primary data dir ${e} is inaccessible; not treating it as missing`),e;if(t.kind==="directory"){let a=On(e),l=o.kind==="directory"?On(n):o.kind==="link"?wn(n)??"empty":"empty";if(a==="empty"){if(o.kind==="inaccessible"||l==="unknown")return i.warn(`Legacy data dir ${n} may contain data but is inaccessible; not using empty primary ${e}`),n;if((o.kind==="directory"||o.kind==="link")&&l==="hasData"){if(!us(e,i))return n;if(o.kind==="link"){if(!nt(n,e,i))return n}else if(!et(n,e,i))return n;return He(n,e,i),e}}return Jr(n,e,i,r),e}if(Pn(n,e))return it(e,i),e;if(o.kind==="directory")return et(n,e,i)?(He(n,e,i),e):n;if(o.kind==="link"){let a=wn(n);if(a==="hasData")return nt(n,e,i)?(He(n,e,i),e):n;if(a==="unknown")return i.warn(`Legacy data dir symlink ${n} target is inaccessible; not treating it as missing`),n}return o.kind==="inaccessible"?(i.warn(`Legacy data dir ${n} is inaccessible; not treating it as missing`),n):t.kind==="link"||t.kind==="other"?(i.warn(`Primary data dir path ${e} exists but is not a directory; using it without migration`),e):(it(e,i),Jr(n,e,i,r),e)}function W(e={}){let n=Fn(e.homeDir),i=e.profile??null;return fs(at(n,i),lt(n,i),e.logger??os,e.nowMs??Date.now)}function ds(e,n){return W({homeDir:e,logger:n})}function ps(e,n,i){return W({homeDir:n,profile:e,logger:i})}var $n=["read","write","edit","bash","task_query","task_output","task_stop","grep","glob","todowrite","web_fetch","website_deploy","workspace_semantic_search"],Vn=["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"],Kn=["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"],ct=["control-in-app-browser","cu-desktop","resume-codex","mavis","create-agent","minimax-code-product","miniapp-creator"],ms=new Set(["modelConfigId","persona","tools","builtinTools","skills","features"]),gs=new Set(["enabled"]),Un=new Set(["mavis","delegation","webSearch"]),ft=new Set($n),st=["task_query","task_output","task_stop"],dt=new Set(Vn),jn=new Set(Kn),pt=new Set(ct),ys=new Set(["plan-mode"]);function Gn(e){let n=Xe(e),i=Xe(n?.default);return{default:i?xs(i):{}}}function hs(e,n="agent"){if(e===void 0)return{};let i=Dn(e,n);Bn(i,ms,n);let r={};if(i.modelConfigId!==void 0&&((typeof i.modelConfigId!="string"||!i.modelConfigId.trim())&&w(`${n}.modelConfigId`,"must be a non-empty string"),r.modelConfigId=i.modelConfigId.trim()),i.persona!==void 0){let t=Dn(i.persona,`${n}.persona`);Bn(t,gs,`${n}.persona`),t.enabled!==void 0&&typeof t.enabled!="boolean"&&w(`${n}.persona.enabled`,"must be a boolean"),r.persona={...typeof t.enabled=="boolean"?{enabled:t.enabled}:{}}}if(i.tools!==void 0&&(Array.isArray(i.tools)||w(`${n}.tools`,"must be an array"),r.tools=i.tools.map((t,o)=>((typeof t!="string"||!ft.has(t))&&w(`${n}.tools[${o}]`,`must be one of ${$n.join(", ")}`),t))),i.builtinTools!==void 0&&(Array.isArray(i.builtinTools)||w(`${n}.builtinTools`,"must be an array"),r.builtinTools=i.builtinTools.map((t,o)=>(t==="web_search"&&w(`${n}.builtinTools[${o}]`,"web_search is feature-owned; use features.webSearch"),(typeof t!="string"||!dt.has(t))&&w(`${n}.builtinTools[${o}]`,`must be one of ${Vn.join(", ")}`),t))),i.skills!==void 0&&(Array.isArray(i.skills)||w(`${n}.skills`,"must be an array"),r.skills=i.skills.map((t,o)=>{if(typeof t=="string"&&pt.has(t.trim())){let a=t.trim();w(`${n}.skills[${o}]`,`${a} is capability-owned; use its owning Tool or feature switch`)}return(typeof t!="string"||!jn.has(t.trim()))&&w(`${n}.skills[${o}]`,`must be one of ${Kn.join(", ")}`),t.trim()})),i.features!==void 0){let t=Dn(i.features,`${n}.features`);Bn(t,Un,`${n}.features`);for(let o of Un)t[o]!==void 0&&typeof t[o]!="boolean"&&w(`${n}.features.${o}`,"must be a boolean");r.features={...typeof t.mavis=="boolean"?{mavis:t.mavis}:{},...typeof t.delegation=="boolean"?{delegation:t.delegation}:{},...typeof t.webSearch=="boolean"?{webSearch:t.webSearch}:{}}}return r}function xs(e){let n={};typeof e.modelConfigId=="string"&&e.modelConfigId.trim()&&(n.modelConfigId=e.modelConfigId.trim());let i=Xe(e.persona);if(typeof i?.enabled=="boolean"&&(n.persona={enabled:i.enabled}),ut(e.tools,ft)){let t=[...e.tools];st.some(o=>t.includes(o))||t.push(...st),n.tools=t}if(ut(e.builtinTools,dt)&&(n.builtinTools=[...e.builtinTools]),Array.isArray(e.skills)){let t=e.skills.map(o=>typeof o=="string"?o.trim():o);t.every(o=>typeof o=="string"&&(jn.has(o)||ys.has(o))&&!pt.has(o))&&(n.skills=t.filter(o=>typeof o=="string"&&jn.has(o)))}let r=Xe(e.features);if(r){let t={};for(let o of Un)typeof r[o]=="boolean"&&(t[o]=r[o]);Object.keys(t).length>0&&(n.features=t)}return n}function Xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function ut(e,n){return Array.isArray(e)&&e.every(i=>typeof i=="string"&&n.has(i))}function bs(e={},n={}){return{persona:{enabled:n.persona?.enabled??e.persona?.enabled??!0},tools:Nn(n.tools??e.tools),builtinTools:Nn(n.builtinTools??e.builtinTools),skills:Nn(n.skills??e.skills),features:{mavis:n.features?.mavis??e.features?.mavis??!0,delegation:n.features?.delegation??e.features?.delegation??!0,webSearch:n.features?.webSearch??e.features?.webSearch??!0}}}function As(e,n){return e.tools===void 0||e.tools.includes(n)}function _s(e,n){return e.builtinTools===void 0||e.builtinTools.includes(n)}function vs(e,n){return e.skills===void 0||e.skills.includes(n)}function Nn(e){return e===void 0?void 0:[...e]}function Dn(e,n){return(e==null||typeof e!="object"||Array.isArray(e))&&w(n,"must be an object"),e}function Bn(e,n,i){for(let r of Object.keys(e))n.has(r)||w(`${i}.${r}`,"is not supported")}function w(e,n){throw new Error(`Invalid configuration at ${e}: ${n}`)}var Yn={enabled:!0};function mt(e,n=Yn){let i=e.askUser;if(i==null||typeof i!="object"||Array.isArray(i))return{...n};let r=i;return{enabled:typeof r.enabled=="boolean"?r.enabled:n.enabled}}var ht=["none","evaluator","subagent"],xt=["brief","transcript"],bt=["same-route-small-fast"],At="goal-verifier-readonly",_t=[At],F={budget:{graceSteps:1},breaker:{repeatedReplyLimit:3},verifier:{repeatedNotMetLimit:5,evidence:"brief"},evaluator:{modelPolicy:"same-route-small-fast",maxTokens:32e3,timeoutSeconds:60,maxRetries:1}},Wn={budget:{graceSteps:3},evaluator:{maxRetries:1}};function Hn(e){let n=[],i=ce(e,"goal",n);fe(i,"goal",n,["objectiveMaxChars","verification","budget","breaker","verifier","evaluator","subagent"]);let r=ce(i.budget,"goal.budget",n);fe(r,"goal.budget",n,["defaultTokens","defaultMainTurns","defaultActiveSeconds","graceSteps"]);let t=ce(i.breaker,"goal.breaker",n);fe(t,"goal.breaker",n,["repeatedReplyLimit"]);let o=ce(i.verifier,"goal.verifier",n);fe(o,"goal.verifier",n,["repeatedNotMetLimit","evidence"]);let a=ce(i.evaluator,"goal.evaluator",n);fe(a,"goal.evaluator",n,["modelPolicy","maxTokens","timeoutSeconds","maxRetries"]);let l=ce(i.subagent,"goal.subagent",n);fe(l,"goal.subagent",n,["profile","maxTurns","maxTokens","timeoutSeconds"]);let s=yt(i.verification,"goal.verification",ht,n),u=J(i.objectiveMaxChars,"goal.objectiveMaxChars",n,{min:1}),c=J(r.defaultTokens,"goal.budget.defaultTokens",n,{min:1}),f=J(r.defaultMainTurns,"goal.budget.defaultMainTurns",n,{min:1}),d=J(r.defaultActiveSeconds,"goal.budget.defaultActiveSeconds",n,{min:1}),p=yt(l.profile,"goal.subagent.profile",_t,n),y=J(l.maxTurns,"goal.subagent.maxTurns",n,{min:1}),g=J(l.maxTokens,"goal.subagent.maxTokens",n,{min:1}),x=J(l.timeoutSeconds,"goal.subagent.timeoutSeconds",n,{min:1}),b={...p!==void 0?{profile:p}:{},...y!==void 0?{maxTurns:y}:{},...g!==void 0?{maxTokens:g}:{},...x!==void 0?{timeoutSeconds:x}:{}};return{config:{...u!==void 0?{objectiveMaxChars:u}:{},...s!==void 0?{verification:s}:{},budget:{...c!==void 0?{defaultTokens:c}:{},...f!==void 0?{defaultMainTurns:f}:{},...d!==void 0?{defaultActiveSeconds:d}:{},graceSteps:de(r.graceSteps,"goal.budget.graceSteps",F.budget.graceSteps,n,{min:0,max:Wn.budget.graceSteps})},breaker:{repeatedReplyLimit:de(t.repeatedReplyLimit,"goal.breaker.repeatedReplyLimit",F.breaker.repeatedReplyLimit,n,{min:1})},verifier:{repeatedNotMetLimit:de(o.repeatedNotMetLimit,"goal.verifier.repeatedNotMetLimit",F.verifier.repeatedNotMetLimit,n,{min:1}),evidence:gt(o.evidence,"goal.verifier.evidence",xt,F.verifier.evidence,n)},evaluator:{modelPolicy:gt(a.modelPolicy,"goal.evaluator.modelPolicy",bt,F.evaluator.modelPolicy,n),maxTokens:de(a.maxTokens,"goal.evaluator.maxTokens",F.evaluator.maxTokens,n,{min:1}),timeoutSeconds:de(a.timeoutSeconds,"goal.evaluator.timeoutSeconds",F.evaluator.timeoutSeconds,n,{min:1}),maxRetries:de(a.maxRetries,"goal.evaluator.maxRetries",F.evaluator.maxRetries,n,{min:0,max:Wn.evaluator.maxRetries})},...Object.keys(b).length>0?{subagent:b}:{}},warnings:n}}function ce(e,n,i){return e===void 0?{}:e===null||typeof e!="object"||Array.isArray(e)?(i.push(H(n,"expected an object; using defaults")),{}):e}function fe(e,n,i,r){for(let t of Object.keys(e))r.includes(t)||i.push(H(`${n}.${t}`,"unknown key ignored"))}function de(e,n,i,r,t){return e==null?i:!Number.isInteger(e)||e<t.min?(r.push(H(n,`expected an integer >= ${t.min}; using default`)),i):t.max!=null&&e>t.max?(r.push(H(n,`exceeds maximum ${t.max}; clamped`)),t.max):e}function J(e,n,i,r){if(e!=null){if(!Number.isInteger(e)||e<r.min){i.push(H(n,`expected an integer >= ${r.min}; ignored`));return}return r.max!=null&&e>r.max?(i.push(H(n,`exceeds maximum ${r.max}; clamped`)),r.max):e}}function gt(e,n,i,r,t){return e==null?r:typeof e!="string"||!i.includes(e)?(t.push(H(n,`expected one of: ${i.join(", ")}; using default`)),r):e}function yt(e,n,i,r){if(e!=null){if(typeof e!="string"||!i.includes(e)){r.push(H(n,`expected one of: ${i.join(", ")}; ignored`));return}return e}}function H(e,n){return`Invalid goal config at ${e}: ${n}`}var D={enabled:!0,maxInlineKiB:64,mcpDetailsMaxInlineKiB:32,watermarkKiB:256,minSavingsKiB:256,minCandidateKiB:2,keepRecentRounds:5},Es=Math.floor(Number.MAX_SAFE_INTEGER/1024);function Xn(e){let n=Cs(e)?e:{};return{enabled:typeof n.enabled=="boolean"?n.enabled:D.enabled,maxInlineKiB:Ie(n.maxInlineKiB,D.maxInlineKiB),mcpDetailsMaxInlineKiB:Ie(n.mcpDetailsMaxInlineKiB,D.mcpDetailsMaxInlineKiB),watermarkKiB:Ie(n.watermarkKiB,D.watermarkKiB),minSavingsKiB:Ie(n.minSavingsKiB,D.minSavingsKiB),minCandidateKiB:Ie(n.minCandidateKiB,D.minCandidateKiB),keepRecentRounds:Ss(n.keepRecentRounds,D.keepRecentRounds)}}function Ie(e,n){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0&&e<=Es?e:n}function Ss(e,n){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0?e:n}function Cs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Me={};function qn(e){if(e==null||typeof e!="object"||Array.isArray(e))return{...Me};let n=Reflect.get(e,"chromePath");return typeof n!="string"||!n.trim()?{...Me}:{chromePath:n.trim()}}import{isIP as Is}from"node:net";function vt(e){return{enabled:!1,filesystemMode:"full_access"}}function Et(e){return!e.enabled||e.filesystemMode==="full_access"?{enabled:!1,filesystemMode:"full_access"}:{...e}}function Qn(e){let n=vt(e);return{enabled:n.enabled,filesystem:{policy:{mode:n.filesystemMode},denyRead:[],denyWrite:[]},network:{policy:{mode:"allow_all"},deniedDomains:[]},localAccess:"open"}}var Zn=Qn(process.platform),Ms=new Set(["read_only","workspace_write","delete_guard","full_access"]),ks=new Set(["deny","allow_all"]);function Jn(e,n=process.platform){let i=Qn(n);if(e===void 0)return i;let r=ke(e,"sandbox",["enabled","filesystem","network","localAccess"]),t=r.filesystem===void 0?{}:ke(r.filesystem,"sandbox.filesystem",["policy","denyRead","denyWrite","allowGitConfig"]),o=t.policy===void 0?{}:ke(t.policy,"sandbox.filesystem.policy",["mode"]),a=r.network===void 0?{}:ke(r.network,"sandbox.network",["policy","deniedDomains"]),l=a.policy===void 0?{}:ke(a.policy,"sandbox.network.policy",["mode"]),s=r.enabled===void 0?i.enabled:Ls(r.enabled,"sandbox.enabled"),u=o.mode??(s?"delete_guard":"full_access");if(typeof u!="string"||!Ms.has(u))throw new Error(`Invalid sandbox.filesystem.policy.mode "${String(u)}"`);let c=l.mode??i.network.policy.mode;if(typeof c!="string"||!ks.has(c))throw new Error(`Invalid sandbox.network.policy.mode "${String(c)}"`);let f=a.deniedDomains===void 0?[...i.network.deniedDomains]:zn(a.deniedDomains,"sandbox.network.deniedDomains");for(let p of f)Ts(p);let d=Et({enabled:s,filesystemMode:u});return{enabled:d.enabled,filesystem:{policy:{mode:d.filesystemMode},denyRead:t.denyRead===void 0?[...i.filesystem.denyRead]:zn(t.denyRead,"sandbox.filesystem.denyRead"),denyWrite:t.denyWrite===void 0?[...i.filesystem.denyWrite]:zn(t.denyWrite,"sandbox.filesystem.denyWrite")},network:{policy:{mode:"allow_all"},deniedDomains:[]},localAccess:r.localAccess===void 0?i.localAccess:r.localAccess==="open"||r.localAccess==="restricted"?r.localAccess:(()=>{throw new Error(`Invalid sandbox.localAccess "${String(r.localAccess)}"`)})()}}function ke(e,n,i){if(e==null||typeof e!="object"||Array.isArray(e))throw new Error(`Invalid ${n}: expected object`);let r=e,t=Object.keys(r).find(o=>!i.includes(o));if(t)throw new Error(`Unknown ${n}.${t}`);return r}function Ls(e,n){if(typeof e!="boolean")throw new Error(`Invalid ${n}: expected boolean`);return e}function zn(e,n){if(!Array.isArray(e)||e.some(i=>typeof i!="string"))throw new Error(`Invalid ${n}: expected string array`);return[...e]}function Ts(e){let n=()=>{throw new Error(`Invalid sandbox.network.deniedDomains entry "${e}"`)},i=e.match(/^\[([^\]]+)\](?::(.+))?$/);if(i){Is(i[1]??"")!==6&&n(),St(i[2],e);return}(e.match(/:/g)??[]).length>1&&n();let r=e.lastIndexOf(":"),t=r>-1?e.slice(0,r):e,o=r>-1?e.slice(r+1):void 0;St(o,e),t!=="*"&&(Rs(t)||n())}function Rs(e){if(e.includes("://")||e.includes("/")||e.includes(":"))return!1;if(e==="localhost")return!0;if(e.startsWith("*.")){let i=e.slice(2).split(".");return i.length>=2&&i.every(r=>r.length>0)}return e.includes("*")?!1:e.includes(".")&&!e.startsWith(".")&&!e.endsWith(".")}function St(e,n){if(e===void 0)return;let 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 Ct(e,n){return n.length===0?!1:n.includes("*")?!0:n.includes(e)}function Ps(){return process.env.__MAVIS_ALLOW_LEGACY_RUNTIME_ENV==="1"}var It={dev:"test",test:"test",staging:"staging",prod:"prod"};function Ns(e){return e==="cn"||e==="en"}function Ot(e){return e==="test"||e==="prod"||e==="dev"||e==="staging"}function wt(){let e=process.env.MAVIS_REGION;if(Ns(e))return e;if(ze()){let n=process.env.NEXT_PUBLIC_LOCALE;if(n==="zh")return"cn";if(n==="en")return"en"}return"en"}function K(){let e=process.env.MAVIS_BUILD_ENV;if(Ot(e))return e;if(ze()){let n=process.env.NEXT_PUBLIC_BUILD_ENV,i=n&&Object.prototype.hasOwnProperty.call(It,n)?It[n]:void 0;if(i)return i}return"dev"}function qe(){if(Pt("managed"))return!0;let e=process.env.__MAVIS_RUNTIME_MANAGED;return e==="1"?!0:e==="0"?!1:!!(ze()||K()==="prod"||K()==="staging")}function ze(){let e=process.versions;return process.env.ELECTRON_RUN_AS_NODE==="1"||typeof e.electron=="string"}function Qe(){return`${wt()}-${K()}`}var V={none:0,test:1,internal:2,online:3},Ds={internal:"internal",inside:"online"};function Bs(e){for(let[n,i]of Object.entries(e)){if(V[i.defaultVisibility]>V[i.configurableVisibility])throw new Error(`Invalid beta feature definition "${n}": defaultVisibility (${i.defaultVisibility}) must not exceed configurableVisibility (${i.configurableVisibility})`);for(let r of i.defaultBuildVariants??[]){let t=Ds[r];if(V[t]>V[i.configurableVisibility])throw new Error(`Invalid beta feature definition "${n}": defaultBuildVariant (${r}) must not exceed configurableVisibility (${i.configurableVisibility})`)}for(let r of i.defaultBuildEnvironments??[])if(V[r==="prod"?"online":"test"]>V[i.configurableVisibility])throw new Error(`Invalid beta feature definition "${n}": defaultBuildEnvironment (${r}) must not exceed configurableVisibility (${i.configurableVisibility})`)}}var Te={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:"none",defaultBuildEnvironments:["dev"],defaultBuildVariants:["internal"],configurableVisibility:"online"}};Bs(Te);function Us(e){return(e.buildEnv??K())!=="prod"?"test":e.internalBuild===!0?"internal":"online"}function js(e,n){let i=e.defaultBuildVariants;return i?n.internalBuild===!0&&i.includes("internal")||n.insideBuild===!0&&i.includes("inside"):!1}function $s(e,n){let i=n.defaultBuildEnvironment??n.buildEnv??ri();return e.defaultBuildEnvironments?.includes(i)===!0}function ri(){let e=ze()?process.env.NEXT_PUBLIC_BUILD_ENV:void 0;return Ot(e)?e:K()}function Mt(e,n){return e.defaultPlatforms?.includes(n.platform??process.platform)!==!1}function ti(e,n,i={}){let r=Te[e],t=V[Us(i)],o=i.defaultBuildEnvironment??i.buildEnv??ri();return e==="mcodeTools"&&o==="dev"&&i.mcodeToolsDevMode==="published"&&Mt(r,i)?!0:n===!1?!1:n===!0?t<=V[r.configurableVisibility]:Mt(r,i)?$s(r,i)||js(r,i)?!0:t<=V[r.defaultVisibility]:!1}function Vs(e){return Te[e].configurableVisibility==="online"}function oi(e=process.env){return e.__MAVIS_BUILD_INTERNAL==="true"}function Ks(e=process.env){return e.__MAVIS_BUILD_INSIDE==="true"}var Gs={APP_DIR:".minimax",ENV_PREFIX:"minimax",CLI_NAME:"minimax"},Ft="__MAVIS_RUNTIME";function Ze(e){return Ps()?process.env[`${Ft}_${e}`]:void 0}function Je(e){let n=`--${e}`;for(let i=2;i<process.argv.length;i++){let r=process.argv[i];if(r===n)return process.argv[i+1];if(r?.startsWith(`${n}=`))return r.slice(n.length+1)}}function Pt(e){let n=`--${e}`;return process.argv.slice(2).some(i=>i===n||i.startsWith(`${n}=`))}var pe=5321,ni=5001,ei=65535,Nt=500,ai=2,Ys=Nt*ai,Dt=Ys+ai,kt=1,Ws=new Set(["agent-archon","mavis"]),Lt=(()=>{let n=new Uint32Array(256);for(let i=0;i<256;i++){let r=i<<24;for(let t=0;t<8;t++)r=(r&2147483648)!==0?79764919^r<<1:r<<1,r>>>=0;n[i]=r>>>0}return n})();function Hs(e){let n=Buffer.from(`${e}
50
+ `,"utf-8"),i=0;for(let t of n)i=(Lt[(i>>>24^t)&255]^i<<8)>>>0;let r=n.length;for(;r!==0;)i=(Lt[(i>>>24^r&255)&255]^i<<8)>>>0,r>>>=8;return(i^4294967295)>>>0}function Xs(e){return Hs(e)%Nt*ai+2}function Tt(e,n){try{let i=ws("git",e,{encoding:"utf-8",timeout:3e3,stdio:["ignore","pipe","pipe"],...n?{cwd:n}:{}});return i.status===0&&i.stdout?i.stdout.trim():null}catch{return null}}function qs(e){return e.match(/[/:]([^/:]+?)(?:\.git)?$/)?.[1]??null}function Bt(){return process.env.MINIMAX_DATA_DIR?.trim()||process.env.MAVIS_DATA_DIR?.trim()}function en(){return!(Pt("disable-git-auto-config")||Ze("DISABLE_GIT_AUTO_CONFIG")||Je("data-dir")||Bt())}function nn(){let e=Je("profile")??Ze("PROFILE");return e&&e.length>0?e:null}function Ut(){let e=Je("port")??Ze("PORT"),n=e?parseInt(e,10):NaN;return Number.isNaN(n)?null:n}function ii(){let e=Je("data-dir")??Bt()??Ze("DATA_DIR");return e&&e.length>0?e:null}function zs(){return!!(nn()&&ii())}function jt(){return!!(nn()&&Ut()!==null)}var ee=null;function Qs(){ee=null}function ne(){if(ee!==null)return ee;let e={runtimePort:pe,uiPort:ni,profile:null,autoDetected:!1};return ee=e,e}function Zs(){try{if(typeof __dirname=="string")return __dirname}catch{}let e=new Error().stack??"";for(let n of e.split(`
51
+ `)){let i=/file:\/\/[^)\s]+/u.exec(n)?.[0]?.replace(/:\d+:\d+$/u,"");if(i)try{return T.dirname(Fs(i))}catch{}let r=/\(?((?:\/|[A-Za-z]:\\)[^()]+?\.(?:cjs|mjs|js|ts)):\d+:\d+\)?/u.exec(n)?.[1];if(r)return T.dirname(r)}}function Js(){let e=nn();return e||(en()?ne().profile:null)}function li(){let e=nn();if(zs())return ii();if(en()){let i=ne();if(i.autoDetected&&i.profile)return W({profile:i.profile})}let n=ii();return n||(e?W({profile:e}):W())}function ie(){return T.join(li(),"config.yaml")}var eu={support_files_api:!0,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},$t={"MiniMax-M3":{name:"MiniMax-M3",attachment:!0,reasoning:!0,tool_call:!0,temperature:!0,modalities:{input:["text","image","video"],output:["text"]},limit:{context:512e3,output:128e3},contextWindowOptions:[512e3,1e6],contextWindowOptionHints:{1e6:"higher_usage"},options:{reasoningSummary:"auto"},thinking_config:{mode:"switchable",default_value:"true"},variants:{"none-thinking":{thinking:{type:"disabled"}},thinking:{thinking:{type:"adaptive"}}},capabilities:eu},"MiniMax-M2.7-highspeed":{name:"MiniMax-M2.7-highspeed",attachment:!1,reasoning:!0,tool_call:!0,temperature:!0,modalities:{input:["text"],output:["text"]},limit:{context:2e5,output:128e3}},"MiniMax-M2.7":{name:"MiniMax-M2.7",attachment:!1,reasoning:!0,tool_call:!0,temperature:!0,modalities:{input:["text"],output:["text"]},limit:{context:2e5,output:128e3}}},me=$t,rn={"cn-test":"https://agent.minimaxi.com/mavis/api/v1/llm/v1","cn-dev":"https://agent.minimaxi.com/mavis/api/v1/llm/v1","cn-staging":"https://agent.minimaxi.com/mavis/api/v1/llm/v1","en-test":"https://agent.minimax.io/mavis/api/v1/llm/v1","en-dev":"https://agent.minimax.io/mavis/api/v1/llm/v1","en-staging":"https://agent.minimax.io/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"},Vt=["https://agent.minimaxi.com/mavis/api/v1/llm/v1"],nu=new Set([...Object.values(rn),...Vt]),iu=new Set([...Object.values(rn),...Vt].map(e=>new URL(e).origin));function Kt(e){if(nu.has(e))return!0;try{let n=new URL(e);return!n.username&&!n.password&&iu.has(n.origin)}catch{return!1}}function Gt(){return K()==="test"}function ru(){return!Gt()}function tu(e){if(!qe()||!$.existsSync(e))return;let n=Yt(e),{provider:i}=n;if(i==null||typeof i!="object"||Array.isArray(i))return;let{minimax:r}=i;if(r==null||typeof r!="object"||Array.isArray(r))return;let{options:t}=r;if(t==null||typeof t!="object"||Array.isArray(t))return;let o=t.baseURL;if(typeof o!="string")return;let a=rn[Qe()];o===a||!Kt(o)||(t.baseURL=a,$.writeFileSync(e,C.dump(n,{indent:2,lineWidth:-1,noRefs:!0}),"utf-8"))}function X(e){return{provider:{minimax:{name:"MiniMax",npm:"@ai-sdk/anthropic",options:{authMode:"managed-login",apiKey:"sk-xxx",baseURL:rn[e]},models:$t}},defaultModel:"minimax/MiniMax-M3"}}var si={"cn-test":X("cn-test"),"cn-dev":X("cn-dev"),"cn-staging":X("cn-staging"),"cn-prod":X("cn-prod"),"en-test":X("en-test"),"en-dev":X("en-dev"),"en-staging":X("en-staging"),"en-prod":X("en-prod")},S={logLevel:"info",devPort:ni,permissionMode:"auto",sseErrorPush:{history:!0,stream:!0},beta:Object.fromEntries(Object.keys(Te).map(e=>[e,ti(e,void 0,{buildEnv:"dev"})])),agents:{default:{}},memory:{enabled:!0,proactive:!1,dailyDigest:{enabled:!1}},skillEvolve:{enabled:!0,inSession:{N:20,minIntervalSeconds:30,maxPendingPerSession:1},signalCooldownHours:24,minConfidence:.7,excludeAgents:["skill-editor"],disableModelPrefixes:["MiniMax-M2"],builtinMrEnabled:!1,sourceRepo:void 0,proposal:{enabled:!1,eligibleAgents:["mavis"],minMessageCount:40,skipPassiveSessionEnd:!0},lifecycle:{staleThresholdDays:15,archiveThresholdDays:30}},sessionRotate:{enabled:!0,activeSessionLookbackHours:12},agentStop:{debounceMs:500,maxActiveSpanMs:1800*1e3},asr:{...Ge},skills:We,askUser:{...Yn},sessionTitle:{enabled:!0},cli:{spawn:{enabled:!1}},browser:{...Me},tui:{},opencode:{xdg:{dataIsolation:!1,startupImport:"off"},keepAlive:{enabled:!1,maxProcesses:5,maxLifetimeMs:288e5,agents:["mavis","main","verifier","code-reviewer"]},spawnConcurrency:3},contextManagement:{disableSystemReminderModels:[],cuMaxScreenshotsInContext:2},runawayGuard:{enabled:!0},toolResultCompaction:{...D},agentRuntime:{defaultFramework:se},logRetentionDays:3,cuBackend:Se,review:{mode:"subagent",modeSource:"default"},goal:structuredClone(F),sandbox:structuredClone(Zn),goalWarnings:[]};function ou(){let e=ie(),n=T.dirname(e);if($.existsSync(n)||$.mkdirSync(n,{recursive:!0}),$.existsSync(e)){ci(e);return}if(!qe()){let t=W({homeDir:Os.homedir()}),o=T.join(t,"config.yaml");e!==o&&$.existsSync(o)&&$.copyFileSync(o,e);return}let i=si[Qe()],r=C.dump({logLevel:S.logLevel,provider:ui?i.provider:void 0,defaultModel:i.defaultModel});$.writeFileSync(e,r,"utf-8")}function Yt(e=ie()){try{let n=$.readFileSync(e,"utf-8"),i=C.load(n);return i!=null&&typeof i=="object"&&!Array.isArray(i)?i:{}}catch{return{}}}var Le=null;function au(e){if(e==null||typeof e!="object"||Array.isArray(e))return;let n=e;return{branchFinish:typeof n.branchFinish=="boolean"?n.branchFinish:!1}}var Wt={isManagedRuntime:qe,shouldEnforceManagedProviderProtection:ru,getManagedPreset:()=>si[Qe()],isManagedPresetBaseUrl:Kt},Ht=!0,ui=!0;function lu(e){Ht=e}function su(e){ui=e}function ci(e){Ht&&$r(e,Wt),ui&&tu(e)}function ge(){Le=null}function ye(){if(Le)return Le;ou();let e=Yt();return Le=fi(e,li()),Le}function fi(e,n){let i=e.sseErrorPush,r=i!=null&&typeof i=="object"&&!Array.isArray(i)?i:void 0,t=typeof e.devPort=="number"?e.devPort:S.devPort;if(en()&&!jt()){let u=ne();u.autoDetected&&(t=u.uiPort)}let o=Hn(e.goal),a=Vr({provider:e.provider!=null&&typeof e.provider=="object"&&!Array.isArray(e.provider)?Br(e.provider):{},defaultModel:typeof e.defaultModel=="string"?e.defaultModel:void 0},Wt),l=Mn(e.minimaxModelContextLimits),s=cu(e);return{logLevel:typeof e.logLevel=="string"?e.logLevel:S.logLevel,devPort:t,...a,provider:Nr(a.provider,l),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:Pr(e.minimax_api),minimaxModelContextLimits:l,custom_provider:Dr(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)?(()=>{let u={};typeof Reflect.get(e.nexus,"enabled")=="boolean"&&(u.enabled=Reflect.get(e.nexus,"enabled"));let c=Reflect.get(e.nexus,"model");return c!=null&&typeof c=="object"&&!Array.isArray(c)&&typeof Reflect.get(c,"providerID")=="string"&&typeof Reflect.get(c,"modelID")=="string"&&(u.model={providerID:Reflect.get(c,"providerID"),modelID:Reflect.get(c,"modelID"),...typeof Reflect.get(c,"variant")=="string"?{variant:Reflect.get(c,"variant")}:{}}),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:S.permissionMode,permission:Xr(e),sseErrorPush:{history:typeof r?.history=="boolean"?r.history:S.sseErrorPush.history,stream:typeof r?.stream=="boolean"?r.stream:S.sseErrorPush.stream},notifications:au(e.notifications),dataDir:n,agentsDir:T.join(n,"agents"),sessionsDir:T.join(n,"sessions"),memoryDir:T.join(n,"memory"),skillsDir:T.join(n,"skills"),builtinSkillsDir:T.join(n,".builtin-skills"),logsDir:T.join(n,"logs"),pluginsDir:T.join(n,"plugins"),plansDir:T.join(n,"plans"),harnessesDir:T.join(n,"harnesses"),subAgentsDir:T.join(n,"subagents"),beta:s,agents:Gn(e.agents),memory:uu(e),skillEvolve:pu(e,s),sessionRotate:mu(e),agentStop:gu(e),asr:Hr(e),skills:kn(e),askUser:mt(e,S.askUser),sessionTitle:yu(e),cli:hu(e),browser:qn(e.browser),tui:Rr(e),opencode:Yr(e,S.opencode),contextManagement:xu(e),runawayGuard:Cn(e.runawayGuard),toolResultCompaction:Xn(e.toolResultCompaction),agentRuntime:Ln(e.agentRuntime),logRetentionDays:bu(e),contentReview:Au(e),mcpToolSearch:_u(e),cuBackend:Ce(e.cuBackend),review:Gr(e.review,S.review),promptConfig:Xt(e.promptConfig),goal:o.config,goalWarnings:o.warnings,sandbox:Jn(e.sandbox)}}function uu(e){let n=e.memory,i=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},r=i.dailyDigest,t=r!=null&&typeof r=="object"&&!Array.isArray(r)?r:{};return{enabled:typeof i.enabled=="boolean"?i.enabled:S.memory.enabled,proactive:typeof i.proactive=="boolean"?i.proactive:S.memory.proactive,dailyDigest:{enabled:typeof t.enabled=="boolean"?t.enabled:S.memory.dailyDigest.enabled}}}function cu(e){let n=e.beta!=null&&typeof e.beta=="object"&&!Array.isArray(e.beta)?e.beta:{},i={buildEnv:K(),defaultBuildEnvironment:ri(),internalBuild:oi(),insideBuild:Ks(),mcodeToolsDevMode:process.env.MAVIS_DEV_MCODE_TOOLS_MODE==="published"?"published":void 0},r={};for(let t of Object.keys(Te))r[t]=ti(t,n[t],i);return r}function fu(e){let n=e.provider;if(n==null||typeof n!="object"||Array.isArray(n))return[];let i=[];for(let r of Object.values(n)){if(r==null||typeof r!="object"||Array.isArray(r))continue;let{models:t}=r;t==null||typeof t!="object"||Array.isArray(t)||i.push(...Object.keys(t))}return i}function du(e,n){if(n.length===0)return!0;let i=fu(e);if(i.length===0)return!1;let r=n.map(t=>t.toLowerCase());return!i.every(t=>r.some(o=>t.toLowerCase().startsWith(o)))}function Rt(e,n){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:n}function pu(e,n){let i=S.skillEvolve,r=e.skillEvolve,o=r!=null&&typeof r=="object"&&!Array.isArray(r)?r:{},a=o.inSession,{inSession:l}=i;if(a!=null&&typeof a=="object"&&!Array.isArray(a)){let k=a;l={N:typeof k.N=="number"&&k.N>0?k.N:i.inSession.N,minIntervalSeconds:typeof k.minIntervalSeconds=="number"&&k.minIntervalSeconds>=0?k.minIntervalSeconds:i.inSession.minIntervalSeconds,maxPendingPerSession:typeof k.maxPendingPerSession=="number"&&k.maxPendingPerSession>=1?k.maxPendingPerSession:i.inSession.maxPendingPerSession}}let s=o.excludeAgents,u=Array.isArray(s)&&s.every(k=>typeof k=="string")?s:i.excludeAgents,c=Array.isArray(o.disableModelPrefixes)&&o.disableModelPrefixes.every(k=>typeof k=="string")?o.disableModelPrefixes:i.disableModelPrefixes,f=n.skillEvolve?typeof o.enabled=="boolean"?o.enabled:du(e,c):!1,d=f&&n.skillEvolveBuiltinMr?typeof o.builtinMrEnabled=="boolean"?o.builtinMrEnabled:i.builtinMrEnabled:!1,p=o.sourceRepo,y=typeof p=="string"&&p.trim().length>0?p.trim():i.sourceRepo,g=o.proposal,x=i.proposal,b=g!=null&&typeof g=="object"&&!Array.isArray(g)?g:{},h=Array.isArray(b.eligibleAgents)&&b.eligibleAgents.every(k=>typeof k=="string")?b.eligibleAgents:x.eligibleAgents,we=typeof b.minMessageCount=="number"&&b.minMessageCount>=1?Math.floor(b.minMessageCount):x.minMessageCount,lo=typeof b.skipPassiveSessionEnd=="boolean"?b.skipPassiveSessionEnd:x.skipPassiveSessionEnd,so=typeof b.enabled=="boolean"?b.enabled:null,uo=f&&n.skillProposal?so??!0:!1,Fe=o.lifecycle,_i=Fe&&typeof Fe=="object"&&!Array.isArray(Fe)?Fe:{},ln=Rt(_i.staleThresholdDays,i.lifecycle.staleThresholdDays),sn=Rt(_i.archiveThresholdDays,i.lifecycle.archiveThresholdDays);if(!(ln<sn))throw new Error(`Invalid skillEvolve.lifecycle config: staleThresholdDays (${ln}) must be strictly less than archiveThresholdDays (${sn}).`);return{enabled:f,inSession:l,signalCooldownHours:typeof o.signalCooldownHours=="number"&&o.signalCooldownHours>0?o.signalCooldownHours:i.signalCooldownHours,minConfidence:typeof o.minConfidence=="number"&&o.minConfidence>=0&&o.minConfidence<=1?o.minConfidence:i.minConfidence,scannerModel:typeof o.scannerModel=="string"?o.scannerModel:void 0,excludeAgents:u,disableModelPrefixes:c,builtinMrEnabled:d,sourceRepo:y,proposal:{enabled:uo,eligibleAgents:h,minMessageCount:we,skipPassiveSessionEnd:lo},lifecycle:{staleThresholdDays:ln,archiveThresholdDays:sn}}}function mu(e){let n=S.sessionRotate,i=e.sessionRotate;if(i==null||typeof i!="object"||Array.isArray(i))return{...n};let r=i,t=r.activeSessionLookbackHours;return{enabled:typeof r.enabled=="boolean"?r.enabled:n.enabled,activeSessionLookbackHours:typeof t=="number"&&Number.isFinite(t)&&t>0?t:n.activeSessionLookbackHours}}function gu(e){let n=S.agentStop,i=e.agentStop;if(i==null||typeof i!="object"||Array.isArray(i))return{...n};let r=i,t=r.debounceMs,o=r.maxActiveSpanMs;return{debounceMs:typeof t=="number"&&Number.isFinite(t)&&t>=0?t:n.debounceMs,maxActiveSpanMs:typeof o=="number"&&Number.isFinite(o)&&o>=0?o:n.maxActiveSpanMs}}function Xt(e){let n=K()==="prod"&&!oi();if(e==null||typeof e!="object"||Array.isArray(e))return{autoUpdate:n};let i=e.autoUpdate;return{autoUpdate:typeof i=="boolean"?i:n}}function yu(e){let n=S.sessionTitle,i=e.sessionTitle;if(i==null||typeof i!="object"||Array.isArray(i))return{...n};let r=i;return{enabled:typeof r.enabled=="boolean"?r.enabled:n.enabled}}function hu(e){let n=S.cli,i=e.cli;if(i==null||typeof i!="object"||Array.isArray(i))return{spawn:{...n.spawn}};let r=i.spawn;if(r==null||typeof r!="object"||Array.isArray(r))return{spawn:{...n.spawn}};let t=r;return{spawn:{enabled:typeof t.enabled=="boolean"?t.enabled:n.spawn.enabled}}}function xu(e){let n=S.contextManagement,i=e.contextManagement;if(i==null||typeof i!="object"||Array.isArray(i))return{disableSystemReminderModels:[...n.disableSystemReminderModels],cuMaxScreenshotsInContext:n.cuMaxScreenshotsInContext};let r=i,t=r.disableSystemReminderModels,o=Array.isArray(t)&&t.every(s=>typeof s=="string"&&s.length>0)?t:[...n.disableSystemReminderModels],a=r.cuMaxScreenshotsInContext,l=typeof a=="number"&&Number.isFinite(a)&&a>=0?Math.floor(a):n.cuMaxScreenshotsInContext;return{disableSystemReminderModels:o,cuMaxScreenshotsInContext:l}}function bu(e){let n=e.logRetentionDays;return typeof n=="number"&&n>=1&&Number.isFinite(n)?Math.floor(n):S.logRetentionDays}function Au(e){let n=e.contentReview;if(n==null||typeof n!="object"||Array.isArray(n))return;let i={},r=Reflect.get(n,"enabled");typeof r=="boolean"&&(i.enabled=r);let t=Reflect.get(n,"testBaseURL");return typeof t=="string"&&t.trim()&&(i.testBaseURL=t.trim()),Object.keys(i).length>0?i:void 0}function _u(e){let n=e.mcpToolSearch;if(n==null||typeof n!="object"||Array.isArray(n))return;let i={},r=Reflect.get(n,"enabled");typeof r=="boolean"&&(i.enabled=r);let t=Reflect.get(n,"systemHint");typeof t=="boolean"&&(i.systemHint=t);let o=Reflect.get(n,"thresholdPct");typeof o=="number"&&(i.thresholdPct=o);let a=Reflect.get(n,"minDeferCount");typeof a=="number"&&(i.minDeferCount=a);let l=Reflect.get(n,"topKDefault");typeof l=="number"&&(i.topKDefault=l);let s=Reflect.get(n,"topKMax");typeof s=="number"&&(i.topKMax=s);let u=Reflect.get(n,"maxSchemaTextLen");typeof u=="number"&&(i.maxSchemaTextLen=u);let c=Reflect.get(n,"modelWhitelist");return Array.isArray(c)&&(i.modelWhitelist=c.filter(f=>typeof f=="string")),Object.keys(i).length>0?i:void 0}function qt(){let e=Ut();if(en()&&!jt()){let n=ne();if(n.autoDetected)return n.runtimePort}return e??pe}function vu(e=qt()){let n=e+Dt;if(n<=ei)return n;let i=e+kt;if(i<=ei)return i;throw new Error(`Cannot allocate an OpenCode sidecar port for runtime port ${String(e)}; choose a runtime port <= ${String(ei-kt)}.`)}var Eu=["agent.minimaxi.com","agent.minimaxi.com","agent.minimax.io","agent.minimax.io","agent.minimax.io","agent.minimax.cn","agent.minimaxi.com"],Su=new Set(Eu.map(e=>`https://${e}`));function Cu(e,n){return/^custom_provider:minimax-legacy(?:-\d+)?$/u.test(e)&&(!n||di(n))}function di(e){try{let n=new URL(e);return n.username||n.password?!1:Su.has(n.origin.toLowerCase())}catch{return!1}}function Iu(e){if(!(e!=="managed-login"&&e!=="api-key"&&e!=="oauth"))return e}function pi(e){let n=typeof e?.baseURL=="string"?e.baseURL.trim():"",i=n.length>0&&di(n),r=Iu(e?.authMode),t=[];return typeof e?.authMode=="string"&&!r&&t.push(`Unknown provider authMode "${e.authMode}"; falling back to compatibility resolution.`),r?(r==="managed-login"&&n.length>0&&!i&&!e?.allowManagedBaseURLOverride&&t.push("Provider authMode is managed-login but baseURL is not a known managed MiniMax host."),{authMode:r,source:"explicit",managedBaseURL:i,warnings:t}):i?(t.push("Provider authMode is inferred from a managed MiniMax baseURL; set options.authMode: managed-login to make this explicit."),{authMode:"managed-login",source:"inferred-managed-base-url",managedBaseURL:i,warnings:t}):{authMode:"api-key",source:"default-api-key",managedBaseURL:i,warnings:t}}var q="minimax",he="minimax_api",gi="custom_provider:";function Mu(e,n){return e==="anthropic-messages"&&(n===q||n===he)}function yi(e,n){if(n===he)return"minimax_api_key";if(n.startsWith(gi))return"custom_provider";if(n!==q)return"configured_provider";if(e.minimaxModelSource==="minimax_api_key")return"minimax_api_key";let i=e.provider?.[n]?.options;return pi({authMode:i?.authMode,baseURL:i?.baseURL}).authMode==="managed-login"?"managed_token_plan":"configured_provider"}function zt(e,n,i){switch(yi(e,n)){case"managed_token_plan":return mi(e.provider?.[n],!0);case"minimax_api_key":return Object.keys(me);case"custom_provider":{let t=e.custom_provider?.[n.slice(gi.length)];return!t||t.enabled===!1?[]:mi(t)}case"configured_provider":return mi(e.provider?.[n])}}function ku(e){let n=yi(e.config,e.providerId),i=e.modelId.trim();return i.length>0&&zt(e.config,e.providerId,e.preset).includes(i)?{available:!0,route:n}:{available:!1,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 mi(e,n=!1){let i=Object.entries(e?.models??{}).filter(([,a])=>a?.enabled!==!1).map(([a])=>a),r=e?.model_order;if(!n||!Array.isArray(r)||!r.every(a=>typeof a=="string"))return i;let t=new Set(i);return[...r.filter(a=>t.delete(a)),...i.filter(a=>t.has(a))]}import{randomBytes as Lu}from"node:crypto";import re,{existsSync as Tu,readFileSync as Ru}from"node:fs";import{dirname as Qt,join as Ou}from"node:path";var Zt=vi(Ei(),1);var Jt=384,tn=new Set(["__proto__","prototype","constructor"]),wu=["minimax_api","custom_provider"];async function Fu(e){let n=e.trim();if(!n||n.includes(".")||tn.has(n))throw new O("Invalid provider id");return Oe(async i=>(P(i.provider)&&delete i.provider[n],{write:!0,value:void 0})).then(({config:i})=>({config:i}))}async function Pu(e){if(!P(e)||!P(e.models))throw new O("Invalid managed MiniMax provider snapshot");return on(e),Oe(async n=>(n.provider={...P(n.provider)?n.provider:{},[q]:structuredClone(e)},{write:!0,value:void 0})).then(({config:n})=>({config:n}))}var O=class extends Error{name="LocalModelProviderConfigValidationError"},Re=class extends Error{name="LocalModelProviderConfigWriteError";constructor(){super("Local runtime failed to update config file")}};async function Nu(e){return Oe(async(n,i)=>{let r={minimax_api:P(n.minimax_api)?n.minimax_api:void 0,custom_provider:Ku(P(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(r,i);for(let t of wu){let o=r[t];if(o===void 0){delete n[t];continue}if(!P(o))throw new O(`Invalid BYOK config subtree "${t}"`);on(o),n[t]=o}return hi(n,"minimaxModelSource",r.minimaxModelSource),n.defaultModel!==r.defaultModel&&(delete n.defaultModelThinking,delete n.defaultModelContextWindow),hi(n,"defaultModel",r.defaultModel),hi(n,"defaultModelVariant",r.defaultModelVariant),{write:!0,value:void 0}}).then(({config:n})=>({config:n}))}async function Du(e){let n=e.modelKey.trim();if(!n)throw new O("Default model must not be empty");if(e.contextLimit!==void 0&&(!Number.isSafeInteger(e.contextLimit)||e.contextLimit<=0||e.contextLimit>2147483647))throw new O("Invalid default context");if(e.thinking?.effort!==void 0&&(typeof e.thinking.effort!="string"||!e.thinking.effort.trim()))throw new O("Invalid default effort");return Oe(async i=>(i.defaultModel=n,e.contextLimit===void 0?delete i.defaultModelContextWindow:i.defaultModelContextWindow=e.contextLimit,e.thinking?.effort===void 0?delete i.defaultModelThinking:i.defaultModelThinking={effort:e.thinking.effort},e.variant===void 0?delete i.defaultModelVariant:i.defaultModelVariant=e.variant,{write:!0,value:void 0})).then(({config:i})=>({config:i}))}async function Bu(e,n){let i=e.modelId.trim();if(e.providerId!==q&&e.providerId!==he||!i||tn.has(i))throw new O("Invalid MiniMax model context target");if(e.providerId===he&&!me[i]?.contextWindowOptions?.includes(e.contextLimit))throw new O("Invalid MiniMax API context limit");let r=await Oe(async(t,o)=>{if((e.providerId===q?o.provider?.[e.providerId]?.models?.[i]?.limit?.context:Uu(o,i))!==e.expectedContextLimit)return{write:!1,value:!1};if(!await n(o))return{write:!1,value:!1};let l=e.providerId===q?["minimaxModelContextLimits",i]:["minimax_api","modelContextLimits",i];return Gu(t,l,e.contextLimit),{write:!0,value:!0}});return{config:r.config,updated:r.value}}function Uu(e,n){let i=me[n],r=e.minimax_api?.modelContextLimits?.[n];return r!==void 0&&i?.contextWindowOptions?.includes(r)?r:i?.limit?.context}async function Oe(e){let n=ie(),i;try{await re.promises.mkdir(Qt(n),{recursive:!0}),await re.promises.writeFile(n,"",{flag:"a",mode:Jt}),i=await Zt.default.lock(n,{stale:1e4,retries:{retries:20,factor:1,minTimeout:5,maxTimeout:25}});let r=Vu(n);ge();let t=await e(r,ye());return t.write&&(on(r),await ju(n,C.dump(r,{indent:2,lineWidth:-1,noRefs:!0})),ge()),{config:ye(),value:t.value}}catch(r){throw r instanceof O||r instanceof Re?r:new Re}finally{await i?.().catch(()=>{})}}async function ju(e,n){let i=Ou(Qt(e),`.config-tmp-${Lu(6).toString("hex")}`);try{let r=await $u(e);await re.promises.writeFile(i,n,{encoding:"utf-8",mode:r}),await re.promises.chmod(i,r),await re.promises.rename(i,e)}catch{throw await re.promises.unlink(i).catch(()=>{}),new Re}}async function $u(e){try{return(await re.promises.stat(e)).mode&511}catch(n){if(Yu(n)&&n.code==="ENOENT")return Jt;throw n}}function Vu(e){if(!Tu(e))return{};try{let n=C.load(Ru(e,"utf-8"));return P(n)?n:{}}catch{return{}}}function Ku(e){if(e)return Object.fromEntries(Object.entries(e).filter(([,n])=>P(n)))}function hi(e,n,i){i===void 0?delete e[n]:e[n]=i}function Gu(e,n,i){let r=n.at(-1);if(!r)throw new O("Invalid config path");let t=e;for(let o of n.slice(0,-1)){if(!o||tn.has(o))throw new O("Invalid config path");let a=t[o];if(P(a))t=a;else{let l={};t[o]=l,t=l}}t[r]=i}function on(e){for(let[n,i]of Object.entries(e)){if(!n||tn.has(n))throw new O(`Local runtime cannot update config field segment "${n}"`);P(i)&&on(i)}}function Yu(e){return e instanceof Error&&"code"in e}function P(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function nc(e){let n=e.trim();if(!n)return null;if(n.startsWith("{"))try{let r=JSON.parse(n),t=typeof r.pid=="number"?r.pid:parseInt(String(r.pid),10);if(isNaN(t)||t<=0)return null;let o=ic(r.owner)?r.owner:"unknown",a=rc(r.startedAt);return{pid:t,owner:o,...a!==void 0?{startedAt:a}:{},...typeof r.mode=="string"?{mode:r.mode}:{},...typeof r.startupToken=="string"?{startupToken:r.startupToken}:{}}}catch{return null}let i=parseInt(n,10);return isNaN(i)||i<=0?null:{pid:i,owner:"unknown"}}function ic(e){return e==="electron"||e==="cli"||e==="unknown"}function rc(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string")return;let n=new Date(e).getTime();return Number.isFinite(n)?n:void 0}function tc(e,n){let i={pid:e,owner:n,startedAt:Date.now()};return JSON.stringify(i)}function oc(){let e=process.argv.slice(2);for(let n=0;n<e.length;n++){let i=e[n],r=i==="--owner"?e[n+1]:i?.startsWith("--owner=")?i.slice(8):void 0;if(r==="electron")return"electron";if(r==="service"||r==="cli")return"cli"}return"cli"}import z from"node:fs";import ac from"node:path";var eo="local-runtime.auth.json";function B(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function xi(e){return e?{...B(e.accessToken)?{accessToken:B(e.accessToken)}:{},...B(e.realUserID)?{realUserID:B(e.realUserID)}:{},...B(e.userEmail)?{userEmail:B(e.userEmail)}:{},...B(e.userName)?{userName:B(e.userName)}:{},...B(e.subUserName)?{subUserName:B(e.subUserName)}:{}}:{}}function an(e){return ac.join(e,eo)}function lc(e){try{let n=z.readFileSync(an(e),"utf-8"),i=JSON.parse(n);if(i.version!==1||!i.auth||typeof i.auth!="object")return;let r=xi(i.auth);return r.accessToken?r:void 0}catch{return}}function sc(e,n,i={}){let r=an(e),t=xi(n);if(!t.accessToken)return no(e),{path:r,written:!1};z.mkdirSync(e,{recursive:!0,mode:448});let o={version:1,updatedAtMs:Date.now(),auth:t},a=`${r}.${process.pid}.${Date.now()}.tmp`;return z.writeFileSync(a,`${JSON.stringify(o,null,2)}
52
+ `,{encoding:"utf-8",mode:384}),i.retryWindowsFileSystem?(un(()=>z.renameSync(a,r)),un(()=>z.chmodSync(r,384))):(z.renameSync(a,r),z.chmodSync(r,384)),{path:r,written:!0}}function no(e){try{z.rmSync(an(e),{force:!0})}catch{}}import io from"node:net";var ro={"e2e-runtime":5e3,"e2e-ui":5500,"smoke-runtime":7e3},bi=100;async function uc(e,n={}){let i=n.isPortFree??fc,r=n.getFreePort??dc,t=n.getWorktreeBasePort??cc,o=t()+ro[e],a=o-t();if(a<bi)throw new Error(`pickTestPort(${e}): role offset ${a} collides with app runtime (0); must be >= ${bi}.`);return o>65535?r():await i(o)?o:r()}function cc(){let e=ne();return e.autoDetected?e.runtimePort:pe}async function fc(e){return new Promise(n=>{let i=io.createServer();i.once("error",()=>n(!1)),i.listen(e,"127.0.0.1",()=>{i.close(()=>n(!0))})})}async function dc(){return new Promise((e,n)=>{let i=io.createServer();i.listen(0,"127.0.0.1",()=>{let r=i.address();if(r&&typeof r!="string"){let{port:t}=r;i.close(()=>e(t))}else i.close(()=>n(new Error("Failed to get free port")))}),i.on("error",n)})}import Ai from"node:fs";import pc from"node:path";var mc=new Set(["native","mcp"]);function to(){return Ce(ye().cuBackend)}function gc(e){if(!mc.has(e))throw new Error(`invalid cuBackend value: ${String(e)}`);let n=ie(),i={};try{let r=Ai.readFileSync(n,"utf-8"),t=C.load(r);t!=null&&typeof t=="object"&&!Array.isArray(t)&&(i=t)}catch{}i.cuBackend=e,Ai.mkdirSync(pc.dirname(n),{recursive:!0}),Ai.writeFileSync(n,C.dump(i),"utf-8"),ge()}function yc(e=to()){Kr(e)}import oo from"node:fs";var xe=class extends Error{code;configPath;constructor(n,i,r,t){super(r,t),this.name="ConfigFileError",this.code=n,this.configPath=i}};function ao(e){let n;try{n=oo.readFileSync(e,"utf-8")}catch(r){throw new xe("CONFIG_READ_FAILED",e,`Cannot read config ${e}.`,{cause:r})}let i;try{i=C.load(n)}catch(r){throw new xe("CONFIG_PARSE_FAILED",e,`Config is not valid YAML: ${e}`,{cause:r})}if(i==null||typeof i!="object"||Array.isArray(i))throw new xe("CONFIG_ROOT_INVALID",e,`Config root must be an object: ${e}`);return i}function hc(e,n){return oo.existsSync(e)&&ci(e),fi(ao(e),n.dataDir)}function xc(e,n){let i=ao(e);if(i.beta==null||typeof i.beta!="object"||Array.isArray(i.beta))return;let r=i.beta[n];return typeof r=="boolean"?r:void 0}export{bc as a,Ac as b,co as c,C as d,wl as e,Sn as f,Cn as g,Se as h,Ce as i,We as j,kn as k,rs as l,zr as m,se as n,Qr as o,Ln as p,rt as q,tt as r,at as s,lt as t,W as u,ds as v,ps as w,$n as x,Vn as y,Kn as z,ct as A,Gn as B,hs as C,bs as D,As as E,_s as F,vs as G,ht as H,xt as I,bt as J,At as K,_t as L,F as M,Wn as N,Hn as O,D as P,Xn as Q,Me as R,qn as S,Et as T,Qn as U,Zn as V,Jn as W,Ct as X,wt as Y,K as Z,qe as _,Qe as $,ti as aa,Vs as ba,oi as ca,Gs as da,Ft as ea,pe as fa,Dt as ga,Qs as ha,ne as ia,Js as ja,li as ka,ie as la,me as ma,Gt as na,si as oa,lu as pa,su as qa,ge as ra,ye as sa,Xt as ta,qt as ua,vu as va,Cu as wa,di as xa,pi as ya,q as za,he as Aa,gi as Ba,Mu as Ca,yi as Da,zt as Ea,ku as Fa,Fu as Ga,Pu as Ha,Nu as Ia,Du as Ja,Bu as Ka,nc as La,tc as Ma,oc as Na,eo as Oa,xi as Pa,an as Qa,lc as Ra,sc as Sa,no as Ta,ro as Ua,bi as Va,uc as Wa,to as Xa,gc as Ya,yc as Za,xe as _a,hc as $a,xc as ab};