@maincode-ai/matilda-code 0.21.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/chunks/agent-NKMZBTFX.js +3 -0
  2. package/chunks/agent-headless-QALB2VKF.js +3 -0
  3. package/chunks/{anthropicContentGenerator-I3ANKUSE.js → anthropicContentGenerator-GW3P6NLQ.js} +11 -11
  4. package/chunks/chunk-ASBKKKEC.js +107 -0
  5. package/chunks/{chunk-G7AJTQ56.js → chunk-BZMRSSEE.js} +1 -1
  6. package/chunks/{chunk-3ANXLJCZ.js → chunk-G6ZP2JXV.js} +1 -1
  7. package/chunks/{chunk-DQJ3VI2G.js → chunk-PPBGETQF.js} +16 -16
  8. package/chunks/chunk-QLEJOI4X.js +25 -0
  9. package/chunks/{chunk-4TPGNHQA.js → chunk-UBLZ73EY.js} +20 -20
  10. package/chunks/{chunk-UHD4X7RU.js → chunk-UUTPLLCJ.js} +423 -422
  11. package/chunks/{computer-use-FT3IXC3W.js → computer-use-D5SWPUWU.js} +1 -1
  12. package/chunks/contextCommand-Z577LUBV.js +3 -0
  13. package/chunks/{edit-HHWOLKWO.js → edit-PSPQYZEV.js} +1 -1
  14. package/chunks/{enter-worktree-5MK2DIQM.js → enter-worktree-HOQPTB4F.js} +1 -1
  15. package/chunks/{enterPlanMode-3UHEGNQ6.js → enterPlanMode-4KND327M.js} +1 -1
  16. package/chunks/{exit-worktree-7R4JPTL2.js → exit-worktree-2EUDTVQD.js} +1 -1
  17. package/chunks/{exitPlanMode-CML6BAGH.js → exitPlanMode-I5NUEMM2.js} +1 -1
  18. package/chunks/{geminiContentGenerator-ZQQSIRNW.js → geminiContentGenerator-KE5W2HAZ.js} +1 -1
  19. package/chunks/{glob-4QHENQIW.js → glob-6LD5EXSG.js} +1 -1
  20. package/chunks/{grep-M5SOSBIW.js → grep-D7F7VOBQ.js} +1 -1
  21. package/chunks/matildaAgentContentGenerator-53Y6ZKNX.js +32 -0
  22. package/chunks/matildaContentGenerator-XH7XBFUB.js +8 -0
  23. package/chunks/{monitor-HGVAACHM.js → monitor-GH5LJV3O.js} +1 -1
  24. package/chunks/notebook-edit-VYMSF622.js +17 -0
  25. package/chunks/openaiContentGenerator-W7WJAAQ3.js +3 -0
  26. package/chunks/ripGrep-AZQNLER7.js +3 -0
  27. package/chunks/scheduler-2XZK4D6E.js +8 -0
  28. package/chunks/{serve-NAHOXXTZ.js → serve-VB2EI7T2.js} +1 -1
  29. package/chunks/shell-QLCMTFUQ.js +3 -0
  30. package/chunks/{skill-HOXYLSX3.js → skill-EGDTMPHB.js} +1 -1
  31. package/chunks/src-O4M6KMI4.js +3 -0
  32. package/chunks/{team-create-YZP2OD7U.js → team-create-DAPGTPYR.js} +1 -1
  33. package/chunks/{workflow-CPUZRYXY.js → workflow-PI6BBTXZ.js} +2 -2
  34. package/chunks/write-file-4K4VALFS.js +15 -0
  35. package/cli.js +347 -347
  36. package/package.json +2 -2
  37. package/chunks/agent-LUXCJ7NA.js +0 -3
  38. package/chunks/agent-headless-GHOHNDBO.js +0 -3
  39. package/chunks/chunk-7VBRP4XQ.js +0 -18
  40. package/chunks/chunk-7VE3KGS4.js +0 -8
  41. package/chunks/chunk-B4GPJM2R.js +0 -101
  42. package/chunks/chunk-XYA3SFGC.js +0 -25
  43. package/chunks/contextCommand-6MUHW4I3.js +0 -3
  44. package/chunks/matildaAgentContentGenerator-ON6GCAVM.js +0 -32
  45. package/chunks/matildaContentGenerator-B6AI7SAJ.js +0 -8
  46. package/chunks/notebook-edit-W5A5ZFCS.js +0 -17
  47. package/chunks/openaiContentGenerator-U5OSOHY5.js +0 -3
  48. package/chunks/ripGrep-XSUPU4OD.js +0 -3
  49. package/chunks/scheduler-Z3KK7VT6.js +0 -8
  50. package/chunks/shell-KCHSF727.js +0 -3
  51. package/chunks/src-DTIIPH7M.js +0 -3
  52. package/chunks/write-file-T7BXLEV4.js +0 -15
@@ -0,0 +1,25 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{Y as te}from"./chunk-QWBNNEV2.js";import{b as f}from"./chunk-GZPNIYVZ.js";f();var Ne="MATILDA_CODE_PROFILE_RUNTIME";function ne(t=process.env){return t[Ne]==="1"}var W=class{enabled;now;startedAt;requestIndex=0;openAIWireRequestIndex=0;anthropicWireRequestIndex=0;requests=[];openaiWireRequests=[];anthropicWireRequests=[];tools=oe();constructor(e={}){this.enabled=e.enabled??ne(),this.now=e.now??(()=>new Date().toISOString()),this.startedAt=this.now()}reset(e={}){this.enabled=e.enabled??ne(),this.startedAt=this.now(),this.requestIndex=0,this.openAIWireRequestIndex=0,this.anthropicWireRequestIndex=0,this.requests=[],this.openaiWireRequests=[],this.anthropicWireRequests=[],this.tools=oe()}isEnabled(){return this.enabled}recordGenerateContentRequest(e,n){this.enabled&&(this.requestIndex+=1,this.requests.push({index:this.requestIndex,timestamp:this.now(),source:n.source,model:e.model,stream:n.stream,serializedBytes:p(We(e)),contents:re(e.contents),systemInstructionBytes:ve(e.config?.systemInstruction),generationConfigBytes:p(se(e.config)),tools:Me(e.config?.tools)}))}recordOpenAIWireRequest(e){this.enabled&&(this.openAIWireRequestIndex+=1,this.openaiWireRequests.push({index:this.openAIWireRequestIndex,timestamp:this.now(),...Ie(e)}))}recordAnthropicWireRequest(e){this.enabled&&(this.anthropicWireRequestIndex+=1,this.anthropicWireRequests.push({index:this.anthropicWireRequestIndex,timestamp:this.now(),...Le(e)}))}recordToolUse(e,n){if(!this.enabled)return;let o=p(n),r=this.getToolNameDiagnostics(e);r.uses+=1,r.argBytes+=o,r.maxArgBytes=Math.max(r.maxArgBytes,o),this.tools.toolUseCount+=1,this.tools.totalToolUseArgBytes+=o,this.tools.maxToolUseArgBytes=Math.max(this.tools.maxToolUseArgBytes,o)}recordToolResult(e){if(!this.enabled)return;let n=this.getToolNameDiagnostics(e.name);n.results+=1,n.resultBytes+=e.resultBytes,n.maxResultBytes=Math.max(n.maxResultBytes,e.resultBytes),e.isError&&(n.errors+=1,this.tools.toolResultErrorCount+=1),this.tools.toolResultCount+=1,this.tools.totalToolResultBytes+=e.resultBytes,this.tools.maxToolResultBytes=Math.max(this.tools.maxToolResultBytes,e.resultBytes)}snapshot(){return{enabled:this.enabled,startedAt:this.startedAt,requests:this.requests.map(e=>({...e,contents:{...e.contents,roleCounts:{...e.contents.roleCounts}},tools:{...e.tools}})),openaiWireRequests:this.openaiWireRequests.map(e=>({...e,messageBytesByRole:{...e.messageBytesByRole},topLevelKeys:[...e.topLevelKeys]})),anthropicWireRequests:this.anthropicWireRequests.map(e=>({...e,messageBytesByRole:{...e.messageBytesByRole},topLevelKeys:[...e.topLevelKeys]})),tools:{...this.tools,byName:Object.fromEntries(Object.entries(this.tools.byName).map(([e,n])=>[e,{...n}]))}}}getToolNameDiagnostics(e){let n=this.tools.byName[e];if(n)return n;let o=xe();return this.tools.byName[e]=o,o}},He=new W;function Ie(t){let e=b(t),n=Array.isArray(e.messages)?e.messages:[],o=Array.isArray(e.tools)?e.tools:[],r={};for(let u of n){let a=b(u),d=typeof a.role=="string"?a.role:"unknown";r[d]=(r[d]??0)+p(a.content)}return{model:typeof e.model=="string"?e.model:"unknown",stream:e.stream===!0,bodyBytes:p(t),messageCount:n.length,messageBytesByRole:r,toolsCount:o.length,toolSchemaBytes:p(o),topLevelKeys:Object.keys(e).sort()}}function Le(t){let e=b(t),n=Array.isArray(e.messages)?e.messages:[],o=Array.isArray(e.tools)?e.tools:[],r={};for(let u of n){let a=b(u),d=typeof a.role=="string"?a.role:"unknown";r[d]=(r[d]??0)+p(a.content)}return{model:typeof e.model=="string"?e.model:"unknown",stream:e.stream===!0,bodyBytes:p(t),messageCount:n.length,messageBytesByRole:r,systemBytes:p(e.system),toolsCount:o.length,toolSchemaBytes:p(o),topLevelKeys:Object.keys(e).sort()}}function oe(){return{toolUseCount:0,toolResultCount:0,toolResultErrorCount:0,totalToolUseArgBytes:0,maxToolUseArgBytes:0,totalToolResultBytes:0,maxToolResultBytes:0,byName:Object.create(null)}}function xe(){return{uses:0,argBytes:0,maxArgBytes:0,results:0,errors:0,resultBytes:0,maxResultBytes:0}}function re(t){let e={count:0,roleCounts:{},partCount:0,textBytes:0,functionCallCount:0,functionCallArgBytes:0,functionResponseCount:0,functionResponseBytes:0,inlineDataCount:0,inlineDataBytes:0,fileDataCount:0},n=Array.isArray(t)?t:t==null?[]:[t];for(let o of n){if(e.count+=1,typeof o=="string"){e.roleCounts.user=(e.roleCounts.user??0)+1,e.partCount+=1,e.textBytes+=p(o);continue}let r=b(o),u=typeof r.role=="string"?r.role:"unknown";e.roleCounts[u]=(e.roleCounts[u]??0)+1;let a=Array.isArray(r.parts)?r.parts:[];Ue(a,e)}return e}function ve(t){return re(t).textBytes}function Ue(t,e){for(let n of t){if(e.partCount+=1,typeof n=="string"){e.textBytes+=p(n);continue}let o=b(n);typeof o.text=="string"&&(e.textBytes+=p(o.text));let r=M(o.functionCall);r&&(e.functionCallCount+=1,e.functionCallArgBytes+=p(r.args));let u=M(o.functionResponse);u&&(e.functionResponseCount+=1,e.functionResponseBytes+=p(u.response)+p(u.parts));let a=M(o.inlineData);a&&(e.inlineDataCount+=1,e.inlineDataBytes+=p(a.data)),o.fileData&&(e.fileDataCount+=1)}}function Me(t){let e=Array.isArray(t)?t:[],n=0;for(let o of e){let r=b(o),u=Array.isArray(r.functionDeclarations)?r.functionDeclarations:[];n+=u.length}return{count:e.length,functionDeclarationCount:n,schemaBytes:p(e)}}function We(t){return{model:t.model,contents:t.contents,config:se(t.config)}}function se(t){if(!t)return;let e=b(t),n={};for(let[o,r]of Object.entries(e))o!=="abortSignal"&&(n[o]=r);return n}function p(t){return t==null?0:typeof t=="string"?Buffer.byteLength(t,"utf8"):Buffer.byteLength(Pe(t),"utf8")}function Pe(t){try{return JSON.stringify(t)??""}catch{return"[unserializable]"}}function b(t){return typeof t=="object"&&t!==null?t:{}}function M(t){return typeof t=="object"&&t!==null?t:null}f();var et=131072,tt=32e3,nt=8e3,ot=64e3,rt=2048;function st(t,e,n,o=2048){let r=e-n-o;return!Number.isFinite(r)||r<=0?0:Math.min(t,r)}var i={"32k":32768,"64k":65536,"128k":131072,"192k":196608,"200k":2e5,"256k":262144,"272k":272e3,"384k":384e3,"400k":4e5,"512k":524288,"1m":1e6,"4k":4096,"8k":8192,"16k":16384};function ie(t){let e=(t??"").toLowerCase().trim();return e=e.replace(/^.*\//,""),e=e.split("|").pop()??e,e=e.split(":").pop()??e,e=e.replace(/\s+/g,"-"),e=e.replace(/-preview/g,""),!e.match(/^matilda-(?:plus|flash|vl-max)-latest$/)&&!e.match(/^kimi-k2-\d{4}$/)&&(e=e.replace(/-(?:\d{4,}|\d+x\d+b|v\d+(?:\.\d+)*|(?<=-[^-]+-)\d+(?:\.\d+)+|latest|exp)$/g,"")),e=e.replace(/-(?:\d?bit|int[48]|bf16|fp16|q[45]|quantized)$/g,""),e}var qe=[[/^gemini-3/,i["1m"]],[/^gemini-/,i["1m"]],[/^gpt-5/,i["272k"]],[/^gpt-/,i["128k"]],[/^o\d/,i["200k"]],[/^claude-/,i["200k"]],[/^matilda3-coder-plus/,i["1m"]],[/^matilda3-coder-flash/,i["1m"]],[/^matilda3\.\d/,i["1m"]],[/^matilda-plus-latest$/,i["1m"]],[/^matilda-flash-latest$/,i["1m"]],[/^coder-model$/,i["1m"]],[/^matilda-code$/,i["1m"]],[/^matilda3-max/,i["256k"]],[/^matilda3-coder-/,i["256k"]],[/^matilda/,i["256k"]],[/^deepseek-v4/,i["1m"]],[/^deepseek/,i["128k"]],[/^glm-5(\.[01])?(-|$)/,202752],[/^glm-(?:[5-9]|\d{2,})/,i["1m"]],[/^glm-/,202752],[/^matilda/,i["256k"]],[/^ornith/,i["64k"]],[/^minimax-m3/i,i["1m"]],[/^minimax-m2\.5/i,i["192k"]],[/^minimax-/i,i["200k"]],[/^kimi-/,i["256k"]],[/^seed-oss/,i["512k"]]],ue=[[/^gemini-3/,i["64k"]],[/^gemini-/,i["8k"]],[/^gpt-5/,i["128k"]],[/^gpt-/,i["16k"]],[/^o\d/,i["128k"]],[/^claude-opus-4-6/,i["128k"]],[/^claude-sonnet-4-6/,i["64k"]],[/^claude-/,i["64k"]],[/^matilda3\.\d/,i["64k"]],[/^coder-model$/,i["64k"]],[/^matilda-code$/,i["64k"]],[/^matilda$/,i["64k"]],[/^matilda-core$/,i["64k"]],[/^matilda/,i["32k"]],[/^deepseek-v4/,i["384k"]],[/^deepseek-reasoner/,i["64k"]],[/^deepseek-r1/,i["64k"]],[/^deepseek-chat/,i["8k"]],[/^glm-5\.2/,i["64k"]],[/^glm-5/,i["64k"]],[/^glm-4\.7/,i["16k"]],[/^ornith/,i["32k"]],[/^minimax-m2\.5/i,i["64k"]],[/^kimi-k2\.5/,i["32k"]]];function $e(t,e="input"){let n=ie(t),o=e==="output"?ue:qe;for(let[r,u]of o)if(r.test(n))return u}function it(t){let e=ie(t);return ue.some(([n])=>n.test(e))}function Fe(t,e="input"){return $e(t,e)}function ut(t,e="input"){return Fe(t,e)??(e==="output"?32e3:131072)}f();f();f();f();var y=class extends Error{constructor(e,n){super(`${e} at position ${n}`),this.position=n}};f();function ae(t){return/^[0-9A-Fa-f]$/.test(t)}function k(t){return t>="0"&&t<="9"}function ce(t){return t>=" "}function _(t){return`,:[]/{}()
4
+ +`.includes(t)}function P(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"||t==="$"}function q(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"||t==="$"||t>="0"&&t<="9"}var $=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,F=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function K(t){return`,[]/{}
5
+ +`.includes(t)}function J(t){return E(t)||Ke.test(t)}var Ke=/^[[{\w-]$/;function le(t){return t===`
6
+ `||t==="\r"||t===" "||t==="\b"||t==="\f"}function C(t,e){let n=t.charCodeAt(e);return n===32||n===10||n===9||n===13}function me(t,e){let n=t.charCodeAt(e);return n===32||n===9||n===13}function fe(t,e){let n=t.charCodeAt(e);return n===160||n>=8192&&n<=8202||n===8239||n===8287||n===12288}function E(t){return Q(t)||L(t)}function Q(t){return t==='"'||t==="\u201C"||t==="\u201D"}function z(t){return t==='"'}function L(t){return t==="'"||t==="\u2018"||t==="\u2019"||t==="`"||t==="\xB4"}function G(t){return t==="'"}function B(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,o=t.lastIndexOf(e);return o!==-1?t.substring(0,o)+(n?"":t.substring(o+1)):t}function h(t,e){let n=t.length;if(!C(t,n-1))return t+e;for(;C(t,n-1);)n--;return t.substring(0,n)+e+t.substring(n)}function pe(t,e,n){return t.substring(0,e)+t.substring(e+n)}function de(t){return/[,\n][ \t\r]*$/.test(t)}var Je={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},Qe={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
7
+ `,r:"\r",t:" "};function x(t){let e=0,n="";V(["```","[```","{```"]),u()||_e(),V(["```","```]","```}"]);let r=S(",");for(r&&a(),J(t[e])&&de(n)?(r||(n=h(n,",")),Ae()):r&&(n=B(n,","));t[e]==="}"||t[e]==="]";)e++,a();if(e>=t.length)return n;De();function u(){a();let s=Ce()||ke()||T()||Te()||we()||H(!1)||Be();return a(),s}function a(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,c=e,l=d(s);do l=ye(),l&&(l=d(s));while(l);return e>c}function d(s){let c=s?C:me,l="";for(;;)if(c(t,e))l+=t[e],e++;else if(fe(t,e))l+=" ",e++;else break;return l.length>0?(n+=l,!0):!1}function ye(){if(t[e]==="/"&&t[e+1]==="*"){for(;e<t.length&&!ze(t,e);)e++;return e+=2,!0}if(t[e]==="/"&&t[e+1]==="/"){for(;e<t.length&&t[e]!==`
8
+ `;)e++;return!0}return!1}function V(s){if(Re(s)){if(P(t[e]))for(;e<t.length&&q(t[e]);)e++;return a(),!0}return!1}function Re(s){d(!0);for(let c of s){let l=e+c.length;if(t.slice(e,l)===c)return e=l,!0}return!1}function S(s){return t[e]===s?(n+=t[e],e++,!0):!1}function O(s){return t[e]===s?(e++,!0):!1}function be(){return O("\\")}function j(){return a(),t[e]==="."&&t[e+1]==="."&&t[e+2]==="."?(e+=3,a(),O(","),!0):!1}function Ce(){if(t[e]==="{"){n+="{",e++,a(),O(",")&&a();let s=!0;for(;e<t.length&&t[e]!=="}";){let c;if(s?(c=!0,s=!1):(c=S(","),c||(n=h(n,",")),a()),j(),!(T()||H(!0))){t[e]==="}"||t[e]==="{"||t[e]==="]"||t[e]==="["||t[e]===void 0?n=B(n,","):Ee();break}a();let I=S(":"),A=e>=t.length;I||(J(t[e])||A?n=h(n,":"):Z()),u()||(I||A?n+="null":Z())}return t[e]==="}"?(n+="}",e++):n=h(n,"}"),!0}return!1}function ke(){if(t[e]==="["){n+="[",e++,a(),O(",")&&a();let s=!0;for(;e<t.length&&t[e]!=="]";)if(s?s=!1:S(",")||(n=h(n,",")),j(),!u()){n=B(n,",");break}return t[e]==="]"?(n+="]",e++):n=h(n,"]"),!0}return!1}function Ae(){let s=!0,c=!0;for(;c;)s?s=!1:S(",")||(n=h(n,",")),c=u();c||(n=B(n,",")),n=`[
9
+ ${n}
10
+ ]`}function T(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,l=t[e]==="\\";if(l&&(e++,l=!0),E(t[e])){let I=z(t[e])?z:G(t[e])?G:L(t[e])?L:Q,A=e,D=n.length,m='"';for(e++;;){if(e>=t.length){let g=Y(e-1);return!s&&_(t.charAt(g))?(e=A,n=n.substring(0,D),T(!0)):(m=h(m,'"'),n+=m,!0)}if(e===c)return m=h(m,'"'),n+=m,!0;if(I(t[e])){let g=e,U=m.length;if(m+='"',e++,n+=m,a(!1),s||e>=t.length||_(t[e])||E(t[e])||k(t[e]))return X(),!0;let R=Y(g-1),ee=t.charAt(R);if(ee===",")return e=A,n=n.substring(0,D),T(!1,R);if(_(ee))return e=A,n=n.substring(0,D),T(!0);n=n.substring(0,D),e=g+1,m=`${m.substring(0,U)}\\${m.substring(U)}`}else if(s&&K(t[e])){if(t[e-1]===":"&&$.test(t.substring(A+1,e+2)))for(;e<t.length&&F.test(t[e]);)m+=t[e],e++;return m=h(m,'"'),n+=m,X(),!0}else if(t[e]==="\\"){let g=t.charAt(e+1);if(Qe[g]!==void 0)m+=t.slice(e,e+2),e+=2;else if(g==="u"){let R=2;for(;R<6&&ae(t[e+R]);)R++;R===6?(m+=t.slice(e,e+6),e+=6):e+R>=t.length?e=t.length:Oe()}else m+=g,e+=2}else{let g=t.charAt(e);g==='"'&&t[e-1]!=="\\"?(m+=`\\${g}`,e++):le(g)?(m+=Je[g],e++):(ce(g)||Se(g),m+=g,e++)}l&&be()}}return!1}function X(){let s=!1;for(a();t[e]==="+";){s=!0,e++,a(),n=B(n,'"',!0);let c=n.length;T()?n=pe(n,c,1):n=h(n,'"')}return s}function Te(){let s=e;if(t[e]==="-"){if(e++,N())return v(s),!0;if(!k(t[e]))return e=s,!1}for(;k(t[e]);)e++;if(t[e]==="."){if(e++,N())return v(s),!0;if(!k(t[e]))return e=s,!1;for(;k(t[e]);)e++}if(t[e]==="e"||t[e]==="E"){if(e++,(t[e]==="-"||t[e]==="+")&&e++,N())return v(s),!0;if(!k(t[e]))return e=s,!1;for(;k(t[e]);)e++}if(!N())return e=s,!1;if(e>s){let c=t.slice(s,e),l=/^0\d/.test(c);return n+=l?`"${c}"`:c,!0}return!1}function we(){return w("true","true")||w("false","false")||w("null","null")||w("True","true")||w("False","false")||w("None","null")}function w(s,c){return t.slice(e,e+s.length)===s?(n+=c,e+=s.length,!0):!1}function H(s){let c=e;if(P(t[e])){for(;e<t.length&&q(t[e]);)e++;let l=e;for(;C(t,l);)l++;if(t[l]==="(")return e=l+1,u(),t[e]===")"&&(e++,t[e]===";"&&e++),!0}for(;e<t.length&&!K(t[e])&&!E(t[e])&&(!s||t[e]!==":");)e++;if(t[e-1]===":"&&$.test(t.substring(c,e+2)))for(;e<t.length&&F.test(t[e]);)e++;if(e>c){for(;C(t,e-1)&&e>0;)e--;let l=t.slice(c,e);return n+=l==="undefined"?"null":JSON.stringify(l),t[e]==='"'&&e++,!0}}function Be(){if(t[e]==="/"){let s=e;for(e++;e<t.length&&(t[e]!=="/"||t[e-1]==="\\");)e++;return e++,n+=`"${t.substring(s,e)}"`,!0}}function Y(s){let c=s;for(;c>0&&C(t,c);)c--;return c}function N(){return e>=t.length||_(t[e])||C(t,e)}function v(s){n+=`${t.slice(s,e)}0`}function Se(s){throw new y(`Invalid character ${JSON.stringify(s)}`,e)}function De(){throw new y(`Unexpected character ${JSON.stringify(t[e])}`,e)}function _e(){throw new y("Unexpected end of json string",t.length)}function Ee(){throw new y("Object key expected",e)}function Z(){throw new y("Colon expected",e)}function Oe(){let s=t.slice(e,e+6);throw new y(`Invalid unicode character "${s}"`,e)}}function ze(t,e){return t[e]==="*"&&t[e+1]==="/"}var Ge=te("JSON_PARSE");function Ve(t,e={}){if(!t||typeof t!="string")return e;try{return JSON.parse(t)}catch(n){let o=je(t);if(o!==void 0)return o;try{let r=x(t);return JSON.parse(r)}catch(r){let u=he(t);if(u&&u!==t)try{return JSON.parse(x(u))}catch{}return Ge.error("Failed to parse JSON even with jsonrepair:",{originalError:n,repairError:r,jsonString:t}),e}}}var ge=Symbol("tool-args-parse-failed");function Tt(t){if(t==null)return{};let e=typeof t=="string"?t.trim():"";if(!e)return{};let n=Ve(e,ge);return n===ge?null:n&&typeof n=="object"&&!Array.isArray(n)?n:null}function je(t){let e=he(t);if(e&&e!==t.trim())try{return JSON.parse(e)}catch{return}}function he(t){let e=t.trimStart();if(!e)return null;let n=e[0];if(n!=="{"&&n!=="[")return null;let o=0,r=!1,u=!1;for(let a=0;a<e.length;a++){let d=e[a];if(r){u?u=!1:d==="\\"?u=!0:d==='"'&&(r=!1);continue}if(d==='"'){r=!0;continue}if(d==="{"||d==="[")o++;else if(d==="}"||d==="]"){if(o--,o===0)return e.slice(0,a+1);if(o<0)return null}}return null}f();function St(t,e="auto"){return e==="openapi_30"?Xe(t):t}function Xe(t){let e=n=>{if(typeof n!="object"||n===null)return n;if(Array.isArray(n))return n.map(e);let o=n,r={};if(Array.isArray(o.type)){let u=o.type;u.length===2&&u.includes("null")?(r.type=u.find(a=>a!=="null"),r.nullable=!0):r.type=u[0]}else o.type!==void 0&&(r.type=o.type);o.const!==void 0&&(r.enum=[o.const],delete r.const),typeof o.exclusiveMinimum=="number"&&(r.minimum=o.exclusiveMinimum,r.exclusiveMinimum=!0),typeof o.exclusiveMaximum=="number"&&(r.maximum=o.exclusiveMaximum,r.exclusiveMaximum=!0),Array.isArray(o.items)?delete r.items:typeof o.items=="object"&&o.items!==null&&(r.items=e(o.items)),Array.isArray(o.enum)&&(r.enum=o.enum.map(String));for(let[u,a]of Object.entries(o))u==="type"||u==="const"||u==="exclusiveMinimum"||u==="exclusiveMaximum"||u==="items"||u==="enum"||u==="$schema"||u==="$id"||u==="default"||u==="dependencies"||u==="patternProperties"||(r[u]=e(a));return r};return e(t)}f();var Et="https://api.openai.com/v1",Ot="https://matilda.maincode.com/api/v1/code";var Nt=process.env.MATILDA_COMPAT_PROXY_BASE_URL;export{Ve as a,Tt as b,he as c,St as d,ne as e,W as f,He as g,Ie as h,Le as i,Et as j,Ot as k,Nt as l,et as m,tt as n,nt as o,ot as p,rt as q,st as r,ie as s,it as t,Fe as u,ut as v};
11
+ /**
12
+ * @license
13
+ * Copyright 2026 Matilda
14
+ * SPDX-License-Identifier: Apache-2.0
15
+ */
16
+ /**
17
+ * @license
18
+ * Copyright 2025 Matilda
19
+ * SPDX-License-Identifier: Apache-2.0
20
+ */
21
+ /**
22
+ * @license
23
+ * Copyright 2025 Google LLC
24
+ * SPDX-License-Identifier: Apache-2.0
25
+ */