@maincode-ai/matilda-code 0.21.7-preview.0 → 0.21.8
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.
- package/chunks/{agent-UUCFMSBD.js → agent-IL7T4I2K.js} +1 -1
- package/chunks/{agent-headless-WVHRGFQH.js → agent-headless-PR64PSXJ.js} +1 -1
- package/chunks/{chunk-6DUA4QHF.js → chunk-6D5M34RS.js} +1 -1
- package/chunks/{chunk-WZI4OJVG.js → chunk-6GY6EBMC.js} +2 -2
- package/chunks/{chunk-S2CVFPFY.js → chunk-FV4IIIXN.js} +458 -458
- package/chunks/{chunk-7RXZY37W.js → chunk-QBBPRMPV.js} +1 -1
- package/chunks/{chunk-SHILLJ5Y.js → chunk-W6CQYQAL.js} +1 -1
- package/chunks/{chunk-CLUHH567.js → chunk-WOH6NLJH.js} +1 -1
- package/chunks/{chunk-VGT5HJ7R.js → chunk-YQNGLSJG.js} +1 -1
- package/chunks/{computer-use-GPO2LXUC.js → computer-use-LL6VH2YY.js} +1 -1
- package/chunks/{contextCommand-34YLPE2P.js → contextCommand-NYUQREN7.js} +1 -1
- package/chunks/{edit-5OOROJSC.js → edit-EZH4FRBA.js} +1 -1
- package/chunks/{enter-worktree-BA566WJD.js → enter-worktree-2NFK4Q5V.js} +1 -1
- package/chunks/{enterPlanMode-EJFIZN6F.js → enterPlanMode-3RRWLKZY.js} +1 -1
- package/chunks/{exit-worktree-6EJS75QL.js → exit-worktree-ROPZ6KRN.js} +1 -1
- package/chunks/{exitPlanMode-WY6BDPUM.js → exitPlanMode-XIZ2N2BH.js} +1 -1
- package/chunks/{geminiContentGenerator-BCI76IT7.js → geminiContentGenerator-Y5BT63HW.js} +1 -1
- package/chunks/{glob-ZBJ6LKGA.js → glob-ZZX5YQEW.js} +1 -1
- package/chunks/{grep-EYIEODLK.js → grep-RITQSEH3.js} +1 -1
- package/chunks/{matildaAgentContentGenerator-522K7OVF.js → matildaAgentContentGenerator-UATDDKKZ.js} +1 -1
- package/chunks/{matildaContentGenerator-BXETOJXX.js → matildaContentGenerator-4EWO3QKC.js} +1 -1
- package/chunks/{monitor-UQZLLIKO.js → monitor-DNWGCVNF.js} +1 -1
- package/chunks/{notebook-edit-JMIRAMTL.js → notebook-edit-FNCOZCKQ.js} +1 -1
- package/chunks/{openaiContentGenerator-VV354WQG.js → openaiContentGenerator-FEVSJC7Q.js} +1 -1
- package/chunks/{ripGrep-GKDPGDHU.js → ripGrep-6EYEXCRW.js} +1 -1
- package/chunks/{scheduler-CLBPJ3HG.js → scheduler-WIJWPRZD.js} +1 -1
- package/chunks/{serve-VEGQRSWY.js → serve-UUEBKOVV.js} +1 -1
- package/chunks/{shell-KSFD7HD2.js → shell-CTE2Z3PU.js} +1 -1
- package/chunks/{skill-XCDS6LQG.js → skill-ZEEJW7MU.js} +1 -1
- package/chunks/{src-CLPCRR5T.js → src-CPPHVZMK.js} +1 -1
- package/chunks/{team-create-5TN5DZSR.js → team-create-XO32YS6Q.js} +1 -1
- package/chunks/{workflow-3CZ6X44G.js → workflow-UFWS3C22.js} +2 -2
- package/chunks/{write-file-ZTBBOZ3L.js → write-file-4K5POBXD.js} +1 -1
- package/cli.js +388 -388
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as be}from"./chunk-LIWYWWOK.js";import{c as q,f as O}from"./chunk-QHA3ZBRO.js";import{M as pe,N as ce,O as k,Q as me,R as W,S as de,a as re,g as P,h as ie,la as ge}from"./chunk-
|
|
3
|
+
import{a as be}from"./chunk-LIWYWWOK.js";import{c as q,f as O}from"./chunk-QHA3ZBRO.js";import{M as pe,N as ce,O as k,Q as me,R as W,S as de,a as re,g as P,h as ie,la as ge}from"./chunk-6D5M34RS.js";import{a as he}from"./chunk-DC7LAFZZ.js";import{a as oe,g as ae,k as se,l as D,o as ue,t as fe,v as Ce}from"./chunk-S7G6QPEP.js";import{e as ne}from"./chunk-4J6DC24J.js";import{b as H,c as N,f as le,n as j}from"./chunk-SDTWBD62.js";import{b as z}from"./chunk-ESSYHTAZ.js";import{a as U,aa as A,c as ee,q as J,s as te,t as K}from"./chunk-VLYRNOD3.js";import{b as p}from"./chunk-GZPNIYVZ.js";p();p();p();p();p();function Re(i){return i.toLowerCase().includes("matilda3")}function Ie(i){if(i.role!=="assistant")return i;let e=i;return typeof e.reasoning_content!="string"||e.reasoning_content.length===0||typeof e.reasoning=="string"?i:{...e,reasoning:e.reasoning_content}}var f=class{contentGeneratorConfig;cliConfig;constructor(e,t){this.cliConfig=t,this.contentGeneratorConfig=e}buildHeaders(){let t=`MatildaCode/${this.cliConfig.getCliVersion()||"unknown"} (${process.platform}; ${process.arch})`,{customHeaders:n}=this.contentGeneratorConfig,r={"User-Agent":t};for(let[o,a]of Object.entries(n??{}))le(o)||(r[o]=a);return r}buildClient(){let{apiKey:e,baseUrl:t,timeout:n=6e5,maxRetries:r=3}=this.contentGeneratorConfig,o=this.buildHeaders(),a=q("openai",this.cliConfig.getProxy());return new U({apiKey:e,baseURL:t,timeout:n,maxRetries:r,defaultHeaders:o,...a||{}})}buildRequest(e,t){let n=this.contentGeneratorConfig.extra_body,r=this.applyOutputTokenLimit(e),o=Re(e.model)?r.messages.map(Ie):r.messages;return{...r,messages:o,...n||{}}}getDefaultGenerationConfig(){return{}}applyOutputTokenLimit(e){if(this.contentGeneratorConfig.samplingParams!==void 0)return e;let t=e.max_tokens,n=Ce(e.model,"output"),r=fe(e.model),o;if(t!=null)r?o=Math.min(t,n):o=t;else{let a=process.env.MATILDA_CODE_MAX_OUTPUT_TOKENS,s=a?parseInt(a,10):NaN;!isNaN(s)&&s>0?o=r?Math.min(s,n):s:o=Math.min(n,8e3)}return{...e,max_tokens:o}}};var w=class extends f{static isModelScopeProvider(e){return!!e.baseUrl?.includes("modelscope")}buildRequest(e,t){let n=super.buildRequest(e,t);return n.stream||delete n.stream_options,n}};p();var Me=A("MatildaOpenAICompatibleProvider"),b=class i extends f{constructor(e,t){super(e,t)}static isMatildaCompatibleProvider(e){let{authType:t,baseUrl:n}=e;if(t==="matilda-oauth"||!n)return!0;let r=n.endsWith("/")?n.slice(0,-1):n,o=null;try{o=new URL(r).hostname.toLowerCase()}catch{o=null}let a=o!==null&&(o==="matilda.maincode.com"||o.endsWith(".matilda.maincode.com")||o==="localhost"||o==="127.0.0.1"||o.endsWith(".matilda")||o==="core-api.matilda"),s=D?.endsWith("/")?D.slice(0,-1):D,l=!!(s&&r.toLowerCase()===s.toLowerCase());return s&&!a&&!l&&Me.debug("MATILDA_COMPAT_PROXY_BASE_URL is configured but the request baseUrl does not match. Cache control helpers will be skipped."),a||l}buildHeaders(){let t=`MatildaCode/${this.cliConfig.getCliVersion()||"unknown"} (${process.platform}; ${process.arch})`,{customHeaders:n}=this.contentGeneratorConfig,r={"User-Agent":t};for(let[o,a]of Object.entries(n??{}))!ce(o)&&o.toLowerCase()!=="x-stainless-retry-count"&&(r[o]=a);return k(this.contentGeneratorConfig)&&Object.assign(r,pe(this.cliConfig)),r}buildClient(){let{apiKey:e,baseUrl:t=se,timeout:n=6e5,maxRetries:r=3}=this.contentGeneratorConfig,o=this.buildHeaders(),a=q("openai",this.cliConfig.getProxy()),s=a?.fetch??globalThis.fetch,l=k(this.contentGeneratorConfig)?async(c,m)=>{let d=new Headers(c instanceof Request?c.headers:void 0);new Headers(m?.headers).forEach((C,u)=>{d.set(u,C)});let g=d.has(H)||d.has(N),h=j(),y=g||Object.keys(h).length>0;if(y){d.delete(H),d.delete(N);for(let[u,G]of Object.entries(h))d.set(u,G);let C=d.get("x-stainless-retry-count");d.has(H)&&C!==null&&/^[1-9][0-9]*$/.test(C)&&d.set(N,"retry")}this.cliConfig.getChannel()===void 0&&me({authStage:"inference_started",authOutcome:"started"},{baseUrl:t,token:e}).catch(()=>{});try{let C=await s(c,y?{...m,headers:d}:m);return de({baseUrl:this.contentGeneratorConfig.baseUrl,token:this.contentGeneratorConfig.apiKey}).catch(()=>{}),C}catch(C){throw W(C,{cliConfig:this.cliConfig,proxyConfigured:!!this.cliConfig.getProxy()}),C}}:void 0;return new U({apiKey:e,baseURL:t,timeout:n,maxRetries:r,defaultHeaders:o,...a||{},...l?{fetch:l}:{}})}buildRequest(e,t){let n=e.messages,r=e.tools;if(this.shouldEnableCacheControl()){let{messages:s,tools:l}=this.addCacheControl(e,e.stream?"all":"system_only");n=s,r=l}let o=this.applyOutputTokenLimit(e),a=this.contentGeneratorConfig.extra_body;return this.isVisionModel(e.model)?{...o,messages:n,...r?{tools:r}:{},...this.buildMetadata(t)||{},vl_high_resolution_images:!0,...a||{}}:{...o,messages:n,...r?{tools:r}:{},...this.buildMetadata(t)||{},...a||{}}}buildMetadata(e){let t=this.cliConfig.getChannel?.();return{metadata:{sessionId:this.cliConfig.getSessionId?.(),promptId:e,...t?{channel:t}:{}}}}getDefaultGenerationConfig(){return{}}addCacheControl(e,t){let n=e.messages,r=n.findIndex(l=>l.role==="system"),o=n.length-1,a=n.length===0?n:n.map((l,c)=>!(c===r&&r!==-1||c===o&&t==="all")||!("content"in l)||l.content===null||l.content===void 0?l:{...l,content:this.addCacheControlToContent(l.content)}),s=t==="all"&&e.tools?.length?this.addCacheControlToTools(e.tools):e.tools;return{messages:a,tools:s}}addCacheControlToTools(e){if(e.length===0)return e;let t=[...e],n=e.length-1;return t[n]={...t[n],cache_control:{type:"ephemeral"}},t}addCacheControlToContent(e){let t=this.normalizeContentToArray(e);return this.addCacheControlToContentArray(t)}normalizeContentToArray(e){return typeof e=="string"?[{type:"text",text:e}]:[...e]}addCacheControlToContentArray(e){if(e.length===0)return e;let t=e[e.length-1];return e[e.length-1]={...t,cache_control:{type:"ephemeral"}},e}static VISION_MODEL_EXACT_MATCHES=new Set(["coder-model"]);static VISION_MODEL_PREFIX_PATTERNS=["matilda-vl","matilda3-vl-plus","matilda3.5-plus","matilda3.6-plus","matilda3.7-plus"];isVisionModel(e){if(!e)return!1;let t=e.toLowerCase();if(i.VISION_MODEL_EXACT_MATCHES.has(t))return!0;for(let n of i.VISION_MODEL_PREFIX_PATTERNS)if(t.startsWith(n))return!0;return!1}shouldEnableCacheControl(){return this.cliConfig.getContentGeneratorConfig()?.enableCacheControl!==!1}};p();p();function F(i){if(i.role!=="assistant")return i;let e=i;return typeof e.reasoning_content=="string"?i:{...e,reasoning_content:""}}function E(i){let e=i.baseUrl??"";if(!e)return!1;try{let t=new URL(e).hostname.toLowerCase();return t==="api.deepseek.com"||t.endsWith(".api.deepseek.com")}catch{return!1}}function Te(i){return E(i)?!0:(i.model??"").toLowerCase().includes("deepseek")}var R=class extends f{constructor(e,t){super(e,t)}static isDeepSeekProvider=Te;static isDeepSeekHostname=E;buildRequest(e,t){let n=super.buildRequest(e,t),r=E(this.contentGeneratorConfig)?ve(n):n;if(!r.messages?.length)return r;let o=r.messages.map(a=>{let s=xe(a);return F(s)});return{...r,messages:o}}getDefaultGenerationConfig(){return{temperature:0}}};function xe(i){if(!("content"in i))return i;let{content:e}=i;if(typeof e=="string"||e===null||e===void 0||!Array.isArray(e))return i;let t=e.map(n=>typeof n=="string"?n:n.type==="text"?n.text??"":`[Unsupported content type: ${n.type}]`).join(`
|
|
4
4
|
|
|
5
5
|
`);return{...i,content:t}}function ve(i){let e=i,t=e.reasoning,n=t?.effort;if(typeof n!="string"||!n)return i;let r={...e};if(typeof r.reasoning_effort!="string"||!r.reasoning_effort){let o=n;o==="low"||o==="medium"?o="high":o==="xhigh"&&(o="max"),r.reasoning_effort=o}if(t&&Object.keys(t).length===1)delete r.reasoning;else if(t){let{effort:o,...a}=t;r.reasoning=a}return r}p();var I=class extends f{constructor(e,t){super(e,t)}static isOpenRouterProvider(e){return(e.baseUrl||"").includes("openrouter.ai")}buildHeaders(){return{...super.buildHeaders(),"HTTP-Referer":"https://github.com/MaincodeHQ/matilda-code.git","X-OpenRouter-Title":"Matilda"}}};p();var we=["api.minimaxi.com","api.minimax.io"],Ge=[".minimaxi.com",".minimax.io"],M=class extends f{static isMiniMaxProvider(e){if(!e.baseUrl)return!1;try{let t=new URL(e.baseUrl).hostname.toLowerCase();return we.includes(t)?!0:Ge.some(n=>t.endsWith(n))}catch{return!1}}getResponseParsingOptions(){return{taggedThinkingTags:!0}}};p();var ye="api.mistral.ai",ke=["mistral","mixtral","codestral","ministral","pixtral","magistral","devstral"];function Ee(i){let e=i.baseUrl??"";if(!e)return!1;try{let t=new URL(e).hostname.toLowerCase();return t===ye||t.endsWith(`.${ye}`)}catch{return!1}}function _e(i){if(Ee(i))return!0;let e=i.model?.toLowerCase()??"";return ke.some(t=>e.includes(t))}var T=class extends f{static isMistralProvider=_e;buildRequest(e,t){let n=super.buildRequest(e,t);return{...n,messages:n.messages.map(Se)}}};function Se(i){if(!("reasoning_content"in i))return i;let e={...i};return delete e.reasoning_content,e}p();function Le(i){let e=i.baseUrl??"";if(e)try{let n=new URL(e).hostname.toLowerCase();if(n==="xiaomimimo.com"||n.endsWith(".xiaomimimo.com"))return!0}catch{}return(i.model??"").toLowerCase().startsWith("mimo-")}var x=class extends f{constructor(e,t){super(e,t)}static isMiMoProvider=Le;buildRequest(e,t){let n=super.buildRequest(e,t);return n.messages?.length?{...n,messages:n.messages.map(F)}:n}getRequestContextOverrides(){return{splitToolMedia:this.contentGeneratorConfig.splitToolMedia??!0}}};p();p();var Ue=A("STREAMING_TOOL_CALL_PARSER"),V=class{buffers=new Map;depths=new Map;inStrings=new Map;escapes=new Map;toolCallMeta=new Map;idToIndexMap=new Map;nextAvailableIndex=0;addChunk(e,t,n,r){let o=e,a=!!(n&&this.idToIndexMap.has(n));if(n)if(this.idToIndexMap.has(n))o=this.idToIndexMap.get(n);else{if(this.buffers.has(e)){let u=this.buffers.get(e),G=this.depths.get(e),Z=this.toolCallMeta.get(e);if(u.trim()&&G===0&&Z?.id&&Z.id!==n)try{JSON.parse(u),o=this.findNextAvailableIndex()}catch{}}this.idToIndexMap.set(n,o)}else if(this.buffers.has(e)){let u=this.buffers.get(e);if(this.depths.get(e)>0||!u.trim())o=e;else try{JSON.parse(u),o=this.findMostRecentIncompleteIndex()}catch{o=e}}this.buffers.has(o)||(this.buffers.set(o,""),this.depths.set(o,0),this.inStrings.set(o,!1),this.escapes.set(o,!1),this.toolCallMeta.set(o,{}));let s=this.buffers.get(o),l=this.depths.get(o);if(a&&s.trim()&&l===0)try{return JSON.parse(s),Ue.debug(`Ignoring replay chunk for completed toolCall id=${n}`),{complete:!1}}catch{}let c=this.toolCallMeta.get(o);n&&(c.id=n),r&&(c.name=r);let m=this.inStrings.get(o),d=this.escapes.get(o),g=s+t;this.buffers.set(o,g);let h=l,y=m,C=d;for(let u of t)y||(u==="{"||u==="["?h++:(u==="}"||u==="]")&&h--),u==='"'&&!C&&(y=!y),C=u==="\\"&&!C;if(this.depths.set(o,h),this.inStrings.set(o,y),this.escapes.set(o,C),h===0&&g.trim().length>0)try{return{complete:!0,value:JSON.parse(g)}}catch(u){if(y)try{return{complete:!0,value:JSON.parse(g+'"'),repaired:!0}}catch{}return{complete:!1,error:u instanceof Error?u:new Error(String(u))}}return{complete:!1}}getToolCallMeta(e){return this.toolCallMeta.get(e)||{}}getCompletedToolCalls(){return this.collectCompletedToolCalls({allowJsonRepair:!0})}getStrictCompletedToolCalls(){return this.collectCompletedToolCalls({allowJsonRepair:!1})}collectCompletedToolCalls({allowJsonRepair:e}){let t=[],n=new Set;for(let[r,o]of this.buffers.entries()){let a=this.toolCallMeta.get(r);if(a?.name){let s=this.depths.get(r)||0,l=this.inStrings.get(r)||!1;if(s>0||l)continue;if(a.id){if(n.has(a.id))continue;n.add(a.id)}let c;if(!o.trim())c={};else try{c=JSON.parse(o)}catch{if(!e)continue;let m=oe(o,null);if(!m||typeof m!="object")continue;c=m}t.push({id:a.id,name:a.name,args:c,index:r})}}return t}findNextAvailableIndex(){for(;this.buffers.has(this.nextAvailableIndex);){let e=this.buffers.get(this.nextAvailableIndex),t=this.depths.get(this.nextAvailableIndex),n=this.toolCallMeta.get(this.nextAvailableIndex);if(!e.trim()||t>0||!n?.id)return this.nextAvailableIndex;try{if(JSON.parse(e),t===0){this.nextAvailableIndex++;continue}}catch{return this.nextAvailableIndex}this.nextAvailableIndex++}return this.nextAvailableIndex++}findMostRecentIncompleteIndex(){let e=-1;for(let[t,n]of this.buffers.entries()){let r=this.depths.get(t);if(this.toolCallMeta.get(t)?.id&&(r>0||!n.trim()))e=Math.max(e,t);else if(n.trim())try{JSON.parse(n)}catch{e=Math.max(e,t)}}return e>=0?e:this.findNextAvailableIndex()}resetIndex(e){this.buffers.set(e,""),this.depths.set(e,0),this.inStrings.set(e,!1),this.escapes.set(e,!1),this.toolCallMeta.set(e,{})}reset(){this.buffers.clear(),this.depths.clear(),this.inStrings.clear(),this.escapes.clear(),this.toolCallMeta.clear(),this.idToIndexMap.clear(),this.nextAvailableIndex=0}getBuffer(e){return this.buffers.get(e)||""}getState(e){return{depth:this.depths.get(e)||0,inString:this.inStrings.get(e)||!1,escape:this.escapes.get(e)||!1}}hasIncompleteToolCalls(){for(let[e,t]of this.buffers.entries()){let n=this.toolCallMeta.get(e),r=this.depths.get(e)||0,o=this.inStrings.get(e)||!1;if(r>0||o)return!0;if(!n?.name&&t.trim())try{JSON.parse(t)}catch{return!0}}return!1}};var Ae=16e3,Pe=`[Earlier content omitted to fit Matilda Core external API limits]
|
|
6
6
|
`,B=class extends Error{constructor(e){super(e),this.name="StreamContentError"}},_=class{constructor(e){this.config=e;this.contentGeneratorConfig=e.contentGeneratorConfig,this.client=this.config.provider.buildClient()}client;contentGeneratorConfig;async execute(e,t){return this.executeWithErrorHandling(e,t,!1,async(n,r)=>{let o=e.config?.abortSignal,a=o?z(o):void 0,s=this.reportedOperationHeaders();try{let l=await this.client.chat.completions.create(n,{signal:a?.signal,...s?{headers:s}:{}});return P.convertOpenAIResponseToGemini(l,r)}finally{a?.abort()}})}async executeStream(e,t){return this.executeWithErrorHandling(e,t,!0,async(n,r)=>{let o=e.config?.abortSignal,a=o?z(o):void 0,s=this.reportedOperationHeaders(),l;try{l=await this.client.chat.completions.create(n,{signal:a?.signal,...s?{headers:s}:{}})}catch(g){throw a?.abort(),g}if(!a)return this.processStreamWithLogging(l,r,e);let c=a,m=this.processStreamWithLogging(l,r,e);async function*d(){try{yield*m}finally{c.abort()}}return d()})}reportedOperationHeaders(){if(!k(this.contentGeneratorConfig))return;let e=j();return Object.keys(e).length>0?e:void 0}async*processStreamWithLogging(e,t,n){let r=[],o=null,a=!1;try{for await(let s of e){if(s.choices?.[0]?.finish_reason==="error_finish"){let m=s.choices?.[0]?.delta?.content?.trim()||"Unknown stream error";throw new B(m)}let l=P.convertOpenAIChunkToGemini(s,t);if(l.candidates?.[0]?.content?.parts?.length===0&&!l.candidates?.[0]?.finishReason&&!l.usageMetadata)continue;if(a){if(l.usageMetadata){let m=o;m&&(m.usageMetadata=l.usageMetadata)}r.push(l);continue}this.handleChunkMerging(l,r,m=>{o=m})&&(o?(yield o,a=!0):yield l)}if(!o&&!a){let s=P.flushOpenAIStreamToGemini(t);s&&(yield s,a=!0)}o&&!a&&(yield o)}catch(s){if(s instanceof B)throw O(s);await this.handleError(s,t,n)}}handleChunkMerging(e,t,n){let r=e.candidates?.[0]?.finishReason,o=t.length>0&&t[t.length-1].candidates?.[0]?.finishReason;if(r){if(o){let a=t[t.length-1];e.usageMetadata&&(a.usageMetadata=e.usageMetadata),n(a)}else t.push(e),n(e);return!1}else if(o){let a=t[t.length-1],s=new ne;return s.candidates=a.candidates,e.usageMetadata?s.usageMetadata=e.usageMetadata:s.usageMetadata=a.usageMetadata,s.responseId=e.responseId,s.createTime=e.createTime,s.modelVersion=e.modelVersion,s.promptFeedback=e.promptFeedback,t[t.length-1]=s,n(s),!0}return t.push(e),!0}async buildRequest(e,t,n,r){let o=P.convertGeminiRequestToOpenAI(e,n),a=this.shouldUseMatildaCoreRequestProfile(),s=a?this.toMatildaCoreUserMessages(o):o,l={model:n.model,messages:s,...this.buildGenerateContentConfig(e)};r?(l.stream=!0,l.stream_options={include_usage:!0}):l.stream=!1,!a&&e.config?.tools&&e.config.tools.length>0&&(l.tools=await P.convertGeminiToolsToOpenAI(e.config.tools,this.contentGeneratorConfig.schemaCompliance??"auto"));let c=this.config.provider.buildRequest(l,t);if(e.config?.thinkingConfig?.includeThoughts===!1||this.contentGeneratorConfig.reasoning===!1){let d=c,g=(n.model??"").toLowerCase();if(b.isMatildaCompatibleProvider(this.contentGeneratorConfig)&&(g.startsWith("matilda")||g==="coder-model")){d.enable_thinking=!1;let h=d.chat_template_kwargs;typeof h=="object"&&h!==null&&"enable_thinking"in h&&(d.chat_template_kwargs={...h,enable_thinking:!1})}"reasoning"in d&&delete d.reasoning,"reasoning_effort"in d&&delete d.reasoning_effort,E(this.contentGeneratorConfig)&&(d.thinking={type:"disabled"})}return c}toMatildaCoreUserMessages(e){let t=e.filter(n=>n.role==="user").map(n=>({role:"user",content:this.sanitizeMatildaUserContent(this.toPlainUserContent(n.content))})).filter(n=>n.content.trim().length>0);return t.length>0?t:[{role:"user",content:""}]}shouldUseMatildaCoreRequestProfile(){let e=this.contentGeneratorConfig.openAIRequestProfile,t=(this.contentGeneratorConfig.baseUrl??"").toLowerCase().replace(/\/+$/,"");if(e==="matilda-code"||t.endsWith("/api/v1/code"))return!1;if(e==="matilda-core")return!0;let n=this.contentGeneratorConfig.customHeaders??{};return Object.entries(n).some(([o,a])=>o.toLowerCase()==="x-matilda-client"&&a.toLowerCase()==="matilda-code")?!0:t==="https://matilda.maincode.com/api/v1"||t==="http://localhost:8080/api/v1"||t==="http://core-api.matilda:3001/api/v1"}toPlainUserContent(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>t.type==="text"?t.text:t.type==="image_url"?"[image omitted: Matilda Core OpenAI shim accepts text only]":"").filter(Boolean).join(`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{l as k}from"./chunk-
|
|
3
|
+
import{l as k}from"./chunk-YQNGLSJG.js";import{Lb as It,Rb as St}from"./chunk-FV4IIIXN.js";import{c as Tt}from"./chunk-FRL6KOLY.js";import{m as Ct}from"./chunk-S7G6QPEP.js";import{Cc as ht,h as nt}from"./chunk-B3NVKOSU.js";import{p as st}from"./chunk-6B5BDE7S.js";import{b as C}from"./chunk-GZPNIYVZ.js";import{d as gt,f as Bt}from"./chunk-OWGSC52X.js";var Mt=gt(i=>{"use strict";C();var at=Symbol.for("react.transitional.element"),$t=Symbol.for("react.portal"),Gt=Symbol.for("react.fragment"),jt=Symbol.for("react.strict_mode"),Wt=Symbol.for("react.profiler"),qt=Symbol.for("react.consumer"),Ft=Symbol.for("react.context"),Yt=Symbol.for("react.forward_ref"),Kt=Symbol.for("react.suspense"),Jt=Symbol.for("react.memo"),kt=Symbol.for("react.lazy"),zt=Symbol.for("react.activity"),xt=Symbol.iterator;function Qt(t){return t===null||typeof t!="object"?null:(t=xt&&t[xt]||t["@@iterator"],typeof t=="function"?t:null)}var Rt={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},vt=Object.assign,Et={};function v(t,e,s){this.props=t,this.context=e,this.refs=Et,this.updater=s||Rt}v.prototype.isReactComponent={};v.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};v.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function At(){}At.prototype=v.prototype;function ut(t,e,s){this.props=t,this.context=e,this.refs=Et,this.updater=s||Rt}var mt=ut.prototype=new At;mt.constructor=ut;vt(mt,v.prototype);mt.isPureReactComponent=!0;var bt=Array.isArray;function it(){}var p={H:null,A:null,T:null,S:null},wt=Object.prototype.hasOwnProperty;function lt(t,e,s){var o=s.ref;return{$$typeof:at,type:t,key:e,ref:o!==void 0?o:null,props:s}}function Vt(t,e){return lt(t.type,e,t.props)}function pt(t){return typeof t=="object"&&t!==null&&t.$$typeof===at}function Xt(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(s){return e[s]})}var _t=/\/+/g;function rt(t,e){return typeof t=="object"&&t!==null&&t.key!=null?Xt(""+t.key):e.toString(36)}function Zt(t){switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:switch(typeof t.status=="string"?t.then(it,it):(t.status="pending",t.then(function(e){t.status==="pending"&&(t.status="fulfilled",t.value=e)},function(e){t.status==="pending"&&(t.status="rejected",t.reason=e)})),t.status){case"fulfilled":return t.value;case"rejected":throw t.reason}}throw t}function R(t,e,s,o,n){var a=typeof t;(a==="undefined"||a==="boolean")&&(t=null);var m=!1;if(t===null)m=!0;else switch(a){case"bigint":case"string":case"number":m=!0;break;case"object":switch(t.$$typeof){case at:case $t:m=!0;break;case kt:return m=t._init,R(m(t._payload),e,s,o,n)}}if(m)return n=n(t),m=o===""?"."+rt(t,0):o,bt(n)?(s="",m!=null&&(s=m.replace(_t,"$&/")+"/"),R(n,e,s,"",function(g){return g})):n!=null&&(pt(n)&&(n=Vt(n,s+(n.key==null||t&&t.key===n.key?"":(""+n.key).replace(_t,"$&/")+"/")+m)),e.push(n)),1;m=0;var d=o===""?".":o+":";if(bt(t))for(var c=0;c<t.length;c++)o=t[c],a=d+rt(o,c),m+=R(o,e,s,a,n);else if(c=Qt(t),typeof c=="function")for(t=c.call(t),c=0;!(o=t.next()).done;)o=o.value,a=d+rt(o,c++),m+=R(o,e,s,a,n);else if(a==="object"){if(typeof t.then=="function")return R(Zt(t),e,s,o,n);throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.")}return m}function B(t,e,s){if(t==null)return t;var o=[],n=0;return R(t,o,"","",function(a){return e.call(s,a,n++)}),o}function te(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(s){(t._status===0||t._status===-1)&&(t._status=1,t._result=s)},function(s){(t._status===0||t._status===-1)&&(t._status=2,t._result=s)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var Ht=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var e=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(e))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},ee={map:B,forEach:function(t,e,s){B(t,function(){e.apply(this,arguments)},s)},count:function(t){var e=0;return B(t,function(){e++}),e},toArray:function(t){return B(t,function(e){return e})||[]},only:function(t){if(!pt(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};i.Activity=zt;i.Children=ee;i.Component=v;i.Fragment=Gt;i.Profiler=Wt;i.PureComponent=ut;i.StrictMode=jt;i.Suspense=Kt;i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=p;i.__COMPILER_RUNTIME={__proto__:null,c:function(t){return p.H.useMemoCache(t)}};i.cache=function(t){return function(){return t.apply(null,arguments)}};i.cacheSignal=function(){return null};i.cloneElement=function(t,e,s){if(t==null)throw Error("The argument must be a React element, but you passed "+t+".");var o=vt({},t.props),n=t.key;if(e!=null)for(a in e.key!==void 0&&(n=""+e.key),e)!wt.call(e,a)||a==="key"||a==="__self"||a==="__source"||a==="ref"&&e.ref===void 0||(o[a]=e[a]);var a=arguments.length-2;if(a===1)o.children=s;else if(1<a){for(var m=Array(a),d=0;d<a;d++)m[d]=arguments[d+2];o.children=m}return lt(t.type,n,o)};i.createContext=function(t){return t={$$typeof:Ft,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null},t.Provider=t,t.Consumer={$$typeof:qt,_context:t},t};i.createElement=function(t,e,s){var o,n={},a=null;if(e!=null)for(o in e.key!==void 0&&(a=""+e.key),e)wt.call(e,o)&&o!=="key"&&o!=="__self"&&o!=="__source"&&(n[o]=e[o]);var m=arguments.length-2;if(m===1)n.children=s;else if(1<m){for(var d=Array(m),c=0;c<m;c++)d[c]=arguments[c+2];n.children=d}if(t&&t.defaultProps)for(o in m=t.defaultProps,m)n[o]===void 0&&(n[o]=m[o]);return lt(t,a,n)};i.createRef=function(){return{current:null}};i.forwardRef=function(t){return{$$typeof:Yt,render:t}};i.isValidElement=pt;i.lazy=function(t){return{$$typeof:kt,_payload:{_status:-1,_result:t},_init:te}};i.memo=function(t,e){return{$$typeof:Jt,type:t,compare:e===void 0?null:e}};i.startTransition=function(t){var e=p.T,s={};p.T=s;try{var o=t(),n=p.S;n!==null&&n(s,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(it,Ht)}catch(a){Ht(a)}finally{e!==null&&s.types!==null&&(e.types=s.types),p.T=e}};i.unstable_useCacheRefresh=function(){return p.H.useCacheRefresh()};i.use=function(t){return p.H.use(t)};i.useActionState=function(t,e,s){return p.H.useActionState(t,e,s)};i.useCallback=function(t,e){return p.H.useCallback(t,e)};i.useContext=function(t){return p.H.useContext(t)};i.useDebugValue=function(){};i.useDeferredValue=function(t,e){return p.H.useDeferredValue(t,e)};i.useEffect=function(t,e){return p.H.useEffect(t,e)};i.useEffectEvent=function(t){return p.H.useEffectEvent(t)};i.useId=function(){return p.H.useId()};i.useImperativeHandle=function(t,e,s){return p.H.useImperativeHandle(t,e,s)};i.useInsertionEffect=function(t,e){return p.H.useInsertionEffect(t,e)};i.useLayoutEffect=function(t,e){return p.H.useLayoutEffect(t,e)};i.useMemo=function(t,e){return p.H.useMemo(t,e)};i.useOptimistic=function(t,e){return p.H.useOptimistic(t,e)};i.useReducer=function(t,e,s){return p.H.useReducer(t,e,s)};i.useRef=function(t){return p.H.useRef(t)};i.useState=function(t){return p.H.useState(t)};i.useSyncExternalStore=function(t,e,s){return p.H.useSyncExternalStore(t,e,s)};i.useTransition=function(){return p.H.useTransition()};i.version="19.2.4"});var Dt=gt((de,Pt)=>{"use strict";C();Pt.exports=Mt()});C();C();C();var fe=Bt(Dt(),1);var oe=["achieved","aborted","failed"];function ge(t){return oe.includes(t)}function ne(t,e){return t>=e.hard?"hard":t>=e.auto?"auto":t>=e.warn?"warn":"safe"}function T(t){if(!t||t.length===0)return 0;let e=0,s=0;for(let o=0;o<t.length;o++)t.charCodeAt(o)<128?e++:s++;return Math.ceil(e/4+s*1.5)}function se(t){if(!t||t.trim().length===0)return[];let e=[],s=/--- Context from: (.+?) ---\n([\s\S]*?)--- End of Context from: \1 ---/g,o;for(;(o=s.exec(t))!==null;){let n=o[1],a=o[2];e.push({path:n,tokens:T(a)})}return e.length===0&&t.trim().length>0&&e.push({path:k("memory"),tokens:T(t)}),e}async function re(t,e){let s=t.getModelDisplayName()||"unknown",o=t.getContentGeneratorConfig(),n=o.contextWindowSize??131072,a=nt.getLastPromptTokenCount(),m=nt.getLastCachedContentTokenCount(),d=It(void 0,s),c=T(d),g=t.getToolRegistry(),M=g?g.getAllTools():[],r=g?g.getFunctionDeclarations():[],P=JSON.stringify(r),_=T(P),H=[],x=[];for(let u of M){if(u.shouldDefer&&!u.alwaysLoad&&!g?.isDeferredToolRevealed(u.name))continue;let h=JSON.stringify(u.schema),S=T(h);u instanceof ht?x.push({name:`${u.serverName}__${u.serverToolName||u.name}`,tokens:S}):u.name!==st.SKILL&&H.push({name:u.name,tokens:S})}let l=t.getUserMemory(),y=se(l),$=y.reduce((u,h)=>u+h.tokens,0),E=M.find(u=>u.name===st.SKILL),G=E?T(JSON.stringify(E.schema)):0,Nt=E&&"getLoadedSkillNames"in E?E.getLoadedSkillNames():new Set,dt=t.getSkillManager(),Ut=dt?await dt.listSkills():[],D=0,j=Ut.map(u=>{let h=T(`<skill>
|
|
4
4
|
<name>
|
|
5
5
|
${u.name}
|
|
6
6
|
</name>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{M as D,N as L,O as j,g as I,la as _}from"./chunk-
|
|
3
|
+
import{M as D,N as L,O as j,g as I,la as _}from"./chunk-6D5M34RS.js";import{b as m,e as w}from"./chunk-4J6DC24J.js";import{k as F,n as U}from"./chunk-SDTWBD62.js";import{q as b,s as $,t as x,u as O}from"./chunk-VLYRNOD3.js";import{b as G}from"./chunk-GZPNIYVZ.js";G();var V="2026-06-23",X="auto",K="instant",z=12e4,h=18e4,Y=5e4,R=16e3,S=class extends Error{code="EMATILDA_STREAM_INCOMPLETE";constructor(){super("Matilda agent stream ended without an authoritative done signal."),this.name="MatildaAgentStreamProtocolError"}},Q=["Treat this as Matilda Code traffic.","Prefer the code specialist path for implementation, debugging, refactoring, tests, repo edits, and code review.","Use the fast instruct path for simple coordination, status, clarification, or non-code conversational replies.","Keep the response concise and action-oriented."].join(" "),Z=["You are powering Matilda Code, an interactive terminal coding agent.","Matilda Code owns the local agent loop: codebase reads, edits, shell commands, approvals, memory, subagents, skills, and MCP tools run through the CLI.","Use the conversation context and tool results as facts. Do not claim to have inspected files, run commands, or edited code unless that action appears in the provided context.",`When the user gives a vague starter such as "let's code" without a concrete development task, ask a concise clarifying question instead of inventing an app or dumping code.`].join(" ");function q(n){let e=(n||"https://matilda.maincode.com/api/v1").trim().replace(/\/+$/,"");return/\/api\/v1$/i.test(e)?e.replace(/\/api\/v1$/i,"/api"):/\/api$/i.test(e)?e:`${e}/api`}function y(n){try{let e=JSON.parse(n);return e&&typeof e=="object"?e:void 0}catch{return}}var ee="Your message was blocked by our content safety system.";function te(n){let e=y(n);if(!e||e.error!=="content_blocked")return;let t=Array.isArray(e.categories)?e.categories.filter(o=>typeof o=="string"):[],s=typeof e.assistant_message=="string"&&e.assistant_message.trim().length>0?e.assistant_message:typeof e.message=="string"?e.message:ee;return{categories:t,severity:typeof e.severity=="string"?e.severity:void 0,assistantMessage:s}}function u(n,e){let s=y(n)?.[e];return typeof s=="string"?s:void 0}function W(n){return P(n)}function P(n){return typeof n=="string"?n:Array.isArray(n)?n.map(e=>{if(typeof e=="string")return e;if(!e||typeof e!="object")return"";let t=e;return typeof t.text=="string"?t.text:t.image_url?"[image omitted: Matilda native chat accepts text only]":t.input_audio?"[audio omitted: Matilda native chat accepts text only]":t.file?"[file omitted: Matilda native chat accepts text only]":""}).filter(Boolean).join(`
|
|
4
4
|
`):""}function f(n,e){if(n.length<=e)return n;let t=`
|
|
5
5
|
[...omitted to fit Matilda native agent context...]
|
|
6
6
|
`,s=e-t.length,o=Math.floor(s*.6),i=s-o;return`${n.slice(0,o)}${t}${n.slice(-i)}`}function ne(n){return(n.candidates?.[0]?.content?.parts??[]).map(t=>typeof t=="string"?t:"thought"in t&&t.thought?"":"text"in t&&t.text||"").join("")}function se(n){let e=y(n),t=typeof e?.output_tokens=="number"?e.output_tokens:void 0;if(t!==void 0)return{promptTokenCount:0,candidatesTokenCount:t,totalTokenCount:t,usageIsIncomplete:!0}}function C(n){return JSON.stringify(n).length}function oe(n){if(C(n)<=h)return n;let e=`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{Rh as T}from"./chunk-
|
|
3
|
+
import{Rh as T}from"./chunk-FV4IIIXN.js";import{P as b}from"./chunk-VLYRNOD3.js";import{b as o}from"./chunk-GZPNIYVZ.js";import{b as w}from"./chunk-OWGSC52X.js";o();var B=e=>{process.stdout.write(e.endsWith(`
|
|
4
4
|
`)?e:`${e}
|
|
5
5
|
`)},m=e=>{process.stderr.write(e.endsWith(`
|
|
6
6
|
`)?e:`${e}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{Af as X,Cf as H,Mi as K}from"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{i as S}from"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as B,i as G}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as d}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";d();d();d();import{homedir as ye}from"node:os";d();import{join as I}from"node:path";import{homedir as R}from"node:os";var l="0.5.2",ue="https://matilda.maincode.com/assets/computer-use",me="https://github.com/trycua/cua/releases/download";function E(e=process.platform,t=process.arch,o=l){let r=o;if(e==="darwin"){let n=`cua-driver-rs-${r}-${t==="arm64"?"darwin-arm64":"darwin-x86_64"}`;return{asset:`${n}.tar.gz`,extractDir:n,binaryRelPath:"CuaDriver.app/Contents/MacOS/cua-driver",hasApp:!0}}if(e==="linux"){if(t!=="x64")throw new Error(`Computer Use: unsupported Linux arch '${t}' (only x64).`);return{asset:`cua-driver-rs-${r}-linux-x86_64-binary.tar.gz`,extractDir:".",binaryRelPath:"cua-driver",hasApp:!1}}if(e==="win32"){let n=`cua-driver-rs-${r}-${t==="arm64"?"windows-arm64":"windows-x86_64"}`;return{asset:`${n}.zip`,extractDir:n,binaryRelPath:"cua-driver.exe",hasApp:!1}}throw new Error(`Computer Use: unsupported platform '${e}'.`)}function U(e,t=process.env,o=l){let r=[],i=t.MATILDA_COMPUTER_USE_DOWNLOAD_HOST;return i&&r.push(`${ge(i)}/cua-driver-rs/v${o}/${e}`),r.push(`${ue}/cua-driver-rs/v${o}/${e}`),r.push(`${me}/cua-driver-rs-v${o}/${e}`),r}function J(e=process.env,t=l){return U("checksums.txt",e,t)}var he="MATILDA_COMPUTER_USE_MAX_IMAGE_DIMENSION";function V(e){if(e===void 0||typeof e=="string"&&e.trim()==="")return;let t=typeof e=="number"?e:Number(e);if(!(!Number.isInteger(t)||t<0))return t}function Y(e,t=process.env){let o=V(t[he]);return o!==void 0?o:V(e)}function fe(e=R()){return I(e,".matilda","computer-use")}function N(e=R(),t=l){return I(fe(e),`cua-driver-rs-${t}`)}function u(e=R(),t=process.platform,o=process.arch,r=l){let i=E(t,o,r);return I(N(e,r),i.extractDir,i.binaryRelPath)}function h(e=l){return`cua-driver-rs@${e}`}function ge(e){return e.endsWith("/")?e.slice(0,-1):e}var f=class e{static singleton;binary;onProgress;maxImageDimension;client;startPromise;constructor(t){this.binary=t.binary,this.onProgress=t.onProgress??(()=>{}),this.maxImageDimension=t.maxImageDimension}setMaxImageDimension(t){this.maxImageDimension=t}static shared(){return e.singleton||(e.singleton=new e({binary:u(ye())})),e.singleton}static setSharedForTest(t){e.singleton=t}isStarted(){return this.client!==void 0}async start(t){if(!this.client)return this.startPromise?this.startPromise:(this.startPromise=this.doStart(t).finally(()=>{this.startPromise=void 0}),this.startPromise)}async doStart(t){let o=t??this.onProgress;o("Starting Computer Use driver...");let r=new H({command:this.binary,args:["mcp"],env:{...process.env}}),i=new X({name:"matilda-code-computer-use",version:"1.0.0"},{capabilities:{}});await i.connect(r),this.client=i,await this.applyRuntimeConfig(i,o)}async applyRuntimeConfig(t,o){if(this.maxImageDimension!==void 0)try{await t.callTool({name:"set_config",arguments:{max_image_dimension:this.maxImageDimension}})}catch(r){let i=r instanceof Error?r.message:String(r);o(`Computer Use: could not apply max_image_dimension=${this.maxImageDimension} (${i}); using driver default.`)}}async listTools(){if(!this.client)throw new Error("ComputerUseClient not started");return this.client.listTools()}async callTool(t,o){if(!this.client)throw new Error("ComputerUseClient not started");try{return await this.client.callTool({name:t,arguments:o})}catch(r){if(!Q(r))throw r;let i=r;for(let n=0;n<3;n++){if(await this.stop(),await this.start(),!this.client)throw new Error("ComputerUseClient reconnect failed");try{return await this.client.callTool({name:t,arguments:o})}catch(s){if(!Q(s))throw s;i=s,await new Promise(a=>setTimeout(a,1e3))}}throw i}}async stop(){let t=this.client;if(this.client=void 0,t)try{await t.close()}catch{}}};function Q(e){let t=e instanceof Error?e.message:String(e);return/connection closed|not connected|connection refused|daemon transport error|os error 61/i.test(t)}d();var M=["bring_to_front","check_for_update","check_permissions","click","double_click","drag","end_session","get_accessibility_tree","get_agent_cursor_state","get_config","get_cursor_position","get_recording_state","get_screen_size","get_window_state","hotkey","kill_app","launch_app","list_apps","list_windows","move_cursor","page","press_key","replay_trajectory","right_click","scroll","set_agent_cursor_enabled","set_agent_cursor_motion","set_agent_cursor_style","set_config","set_value","start_recording","start_session","stop_recording","type_text","zoom"],g={bring_to_front:{description:'Activate a window so subsequent input tools with `dispatch:"foreground"` land on it without a per-call SetForegroundWindow flash. **Windows-only:** on macOS this tool returns an error pointing to the platform-native `NSRunningApplication.activate` (which the macOS input tools don\'t need because CGEvent.postToPid reaches backgrounded windows). On Linux this tool also stubs out; use `wmctrl -a` or `xdotool windowactivate` if you need explicit activation.',parameterSchema:{additionalProperties:!1,properties:{pid:{type:"integer"},window_id:{type:"integer"}},required:["pid"],type:"object"}},check_for_update:{description:"Check whether a newer cua-driver-rs release is available on GitHub. Returns the current and latest versions, an `update_available` boolean, the install one-liner, and the release notes URL. Read-only \u2014 never installs. Mirror of `cua-driver check-update --json`.",parameterSchema:{additionalProperties:!1,properties:{},type:"object"}},check_permissions:{description:"Report TCC permission status for Accessibility and Screen Recording. By default also raises the system permission dialogs for any missing grants \u2014 Apple's request APIs are no-ops when the grant is already active, so this is safe to call repeatedly. Pass {\"prompt\": false} for a purely read-only status check.\n\nReturns: `accessibility` + `screen_recording` (booleans from the TCC preflight APIs), `screen_recording_capturable` (a live ScreenCaptureKit probe \u2014 if it disagrees with `screen_recording`, the preflight grant belongs to a different process), and `source` (which TCC identity the booleans reflect: the CuaDriver daemon vs the launching terminal/IDE). macOS attributes grants to the responsible process, so a standalone call from a terminal reports the terminal's grants, not the driver's.",parameterSchema:{additionalProperties:!1,properties:{prompt:{description:"Raise the system permission prompts for missing grants. Default true.",type:"boolean"}},type:"object"}},click:{description:`Left-click against a target pid. **Prefer \`element_index\` over pixel coordinates** \u2014 element_index works on backgrounded / minimized / hidden / off-Space windows, surfaces a stable handle that survives rebuilds, and tells you what you're clicking via the cached element's role + label. Reach for \`x, y\` only when the target is a canvas / video / WebGL / custom-drawn surface that doesn't appear in the AX tree.
|
|
4
4
|
|
|
5
5
|
Two addressing modes:
|
|
6
6
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{c as a,d as b,e as c}from"./chunk-
|
|
3
|
+
import{c as a,d as b,e as c}from"./chunk-W6CQYQAL.js";import"./chunk-YQNGLSJG.js";import"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{a as collectContextData,c as contextCommand,b as formatContextUsageText};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as y}from"./chunk-5PMMY47S.js";import{
|
|
3
|
+
import{a as y}from"./chunk-5PMMY47S.js";import{$e as Q,Ce as K,Qe as R,Re as x,Xe as X,Ye as V,cf as Y,ka as I,ue as A,ve as G,wc as q}from"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{Lb as z,Oa as j,_c as H,ca as U,ha as N,wc as D}from"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{w as B}from"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{i as k,p as P,q as W}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{D as w,E as S,G as M,aa as $,b as C}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as T}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";T();import*as m from"node:fs";import*as u from"node:path";T();var se={"\u2010":"-","\u2011":"-","\u2012":"-","\u2013":"-","\u2014":"-","\u2015":"-","\u2212":"-","\u2018":"'","\u2019":"'","\u201A":"'","\u201B":"'","\u201C":'"',"\u201D":'"',"\u201E":'"',"\u201F":'"',"\xA0":" ","\u2002":" ","\u2003":" ","\u2004":" ","\u2005":" ","\u2006":" ","\u2007":" ","\u2008":" ","\u2009":" ","\u200A":" ","\u202F":" ","\u205F":" ","\u3000":" "};function L(n){if(n==="")return n;let t="";for(let i of n)t+=se[i]??i;return t}var ae=[n=>n,n=>n.trimEnd()];function ce(n){return L(n).trimEnd()}function J(n,t,i){if(t.length===0)return 0;if(t.length>n.length)return null;e:for(let e=0;e<=n.length-t.length;e++){for(let r=0;r<t.length;r++)if(i(n[e+r])!==i(t[r]))continue e;return e}return null}function fe(n){let t=n.split(`
|
|
4
4
|
`),i=new Array(t.length+1),e=0;for(let r=0;r<t.length;r++)i[r]=e,e+=t[r].length,r<t.length-1&&(e+=1);return i[t.length]=n.length,{lines:t,offsets:i}}function Z(n,t,i,e,r,o){if(r===0)return o?`
|
|
5
5
|
`:"";let f=t[e]??0,l=e+r-1,c=(t[l]??0)+(i[l]?.length??0);if(o){let g=t[e+r];g!==void 0?c=g:n.endsWith(`
|
|
6
6
|
`)&&(c=n.length)}return n.slice(f,c)}function de(n,t){let{lines:i,offsets:e}=fe(n),r=t.split(`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{Tj as T,Yf as W,eg as s}from"./chunk-
|
|
3
|
+
import{Tj as T,Yf as W,eg as s}from"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as $,i as E,p as m,q as R}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as b}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();var o=b("ENTER_WORKTREE"),P=`Creates an isolated git worktree at \`<projectRoot>/.matilda/worktrees/<slug>\` and returns its absolute path so subsequent file edits, shell commands, and other tools can operate inside it.
|
|
4
4
|
|
|
5
5
|
## When to Use
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{I as r}from"./chunk-
|
|
3
|
+
import{I as r}from"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as m,i as u,p as d,q as c}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as p}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as l}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";l();var y=p("ENTER_PLAN_MODE"),g=`Use this tool to lower into plan mode before doing uncertain or complex work. Entering plan mode is a privilege reduction, so it does not require user confirmation.
|
|
4
4
|
|
|
5
5
|
## When to Use This Tool
|
|
6
6
|
Use this tool when the task is not yet clear enough to safely execute, for example when it requires multi-file changes, design choices, investigation before a plan can be summarized, or when requirements are ambiguous. While investigating, if complexity rises or you find yourself repeatedly needing to ask the user, enter plan mode and consolidate a plan.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{Sj as C,Uj as x,Wf as k,Zf as W,eg as l}from"./chunk-
|
|
3
|
+
import{Sj as C,Uj as x,Wf as k,Zf as W,eg as l}from"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as E,i as R,p as c,q as T}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as b,b as $}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();import*as S from"node:fs/promises";var h=b("EXIT_WORKTREE"),O=`Exits a worktree previously created by ${c.ENTER_WORKTREE}.
|
|
4
4
|
|
|
5
5
|
## Behavior
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as k}from"./chunk-ILBTI4K5.js";import{I as w,
|
|
3
|
+
import{a as k}from"./chunk-ILBTI4K5.js";import{I as w,Mf as M,pg as $}from"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as G,i as R,p as T,q as _}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as f}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as h}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";h();h();h();var E=f("GATE_REVIEW_AGENTS");function L(n){return`You are a Plan Design Reviewer for the Plan Approval Gate. Review the plan across three dimensions:
|
|
4
4
|
|
|
5
5
|
1. **Request Fit** \u2014 Does the plan fulfill every part of the user's original request and respect all explicit constraints? Does it do anything the user explicitly asked NOT to do?
|
|
6
6
|
2. **System Fit** \u2014 Does the plan align with the codebase structure, file paths, function names, permission model, and integration boundaries found during investigation?
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as g}from"./chunk-Q2I3ARPJ.js";import{g as u}from"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{f as d}from"./chunk-SDTWBD62.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as m}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";m();m();var p=class{googleGenAI;contentGeneratorConfig;constructor(e,t){let r=t?.customHeaders,n=r?(()=>{let i=e.httpOptions,s=i?.headers??{},l=Object.fromEntries(Object.entries(r).filter(([a])=>!d(a)));return{...e,httpOptions:{...i??{},headers:{...s,...l}}}})():e;this.googleGenAI=new u(n),this.contentGeneratorConfig=t}buildGenerateContentConfig(e){let t=this.contentGeneratorConfig?.samplingParams,r=e.config||{},n=(i,s,l)=>{let a=r[s];return i!==void 0?i:a!==void 0?a:l};return{...r,temperature:n(t?.temperature,"temperature",1),topP:n(t?.top_p,"topP",.95),topK:n(t?.top_k,"topK",64),maxOutputTokens:n(t?.max_tokens,"maxOutputTokens"),presencePenalty:n(t?.presence_penalty,"presencePenalty"),frequencyPenalty:n(t?.frequency_penalty,"frequencyPenalty"),thinkingConfig:n(this.buildThinkingConfig(),"thinkingConfig",{includeThoughts:!0,thinkingLevel:"THINKING_LEVEL_UNSPECIFIED"})}}buildThinkingConfig(){let e=this.contentGeneratorConfig?.reasoning;if(e===!1)return{includeThoughts:!1};if(e)return{includeThoughts:!0,thinkingLevel:e.effort==="low"?"LOW":e.effort==="high"||e.effort==="max"?"HIGH":"THINKING_LEVEL_UNSPECIFIED"}}async generateContent(e,t){let r={...e,contents:this.stripUnsupportedFields(e.contents),config:this.buildGenerateContentConfig(e)};return this.googleGenAI.models.generateContent(r)}async generateContentStream(e,t){let r={...e,contents:this.stripUnsupportedFields(e.contents),config:this.buildGenerateContentConfig(e)};return this.googleGenAI.models.generateContentStream(r)}stripUnsupportedFields(e){return!e||typeof e=="string"?e:Array.isArray(e)?e.map(t=>this.stripContentFields(t)):this.stripContentFields(e)}stripContentFields(e){if(typeof e=="string")return e;if(!("role"in e)&&!("parts"in e))return this.stripPartFields(e);let t=e;return t.parts?{...t,parts:t.parts.map(r=>this.stripPartFields(r))}:t}stripPartFields(e){if(typeof e=="string")return e;let t={...e};if(t.inlineData){let{displayName:r,...n}=t.inlineData;t.inlineData=n}if(t.fileData){let{displayName:r,...n}=t.fileData;t.fileData=n}if(t.functionResponse?.parts){let r=t.functionResponse.parts.map(n=>{let i=this.convertUnsupportedMediaToText(n);return this.stripPartFields(i)});t.functionResponse={...t.functionResponse,parts:r}}return t}convertUnsupportedMediaToText(e){if(typeof e=="string")return e;let t=e.inlineData?.mimeType||"",r=e.fileData?.mimeType||"";if(t.startsWith("audio/")||t.startsWith("video/")){let n=e.inlineData?.displayName,i=n?` (${n})`:"";return{text:`Unsupported media type for Gemini: ${t}${i}.`}}if(r.startsWith("audio/")||r.startsWith("video/")){let n=e.fileData?.displayName,i=n?` (${n})`:"";return{text:`Unsupported media type for Gemini: ${r}${i}.`}}return e}async countTokens(e){return this.googleGenAI.models.countTokens(e)}async embedContent(e){return this.googleGenAI.models.embedContent(e)}useSummarizedThinking(){return!0}};function T(o,e){let i={...{"User-Agent":o.userAgent||`MatildaCode/0.21.
|
|
3
|
+
import{a as g}from"./chunk-Q2I3ARPJ.js";import{g as u}from"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{f as d}from"./chunk-SDTWBD62.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-FWDMPRKU.js";import{b as m}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";m();m();var p=class{googleGenAI;contentGeneratorConfig;constructor(e,t){let r=t?.customHeaders,n=r?(()=>{let i=e.httpOptions,s=i?.headers??{},l=Object.fromEntries(Object.entries(r).filter(([a])=>!d(a)));return{...e,httpOptions:{...i??{},headers:{...s,...l}}}})():e;this.googleGenAI=new u(n),this.contentGeneratorConfig=t}buildGenerateContentConfig(e){let t=this.contentGeneratorConfig?.samplingParams,r=e.config||{},n=(i,s,l)=>{let a=r[s];return i!==void 0?i:a!==void 0?a:l};return{...r,temperature:n(t?.temperature,"temperature",1),topP:n(t?.top_p,"topP",.95),topK:n(t?.top_k,"topK",64),maxOutputTokens:n(t?.max_tokens,"maxOutputTokens"),presencePenalty:n(t?.presence_penalty,"presencePenalty"),frequencyPenalty:n(t?.frequency_penalty,"frequencyPenalty"),thinkingConfig:n(this.buildThinkingConfig(),"thinkingConfig",{includeThoughts:!0,thinkingLevel:"THINKING_LEVEL_UNSPECIFIED"})}}buildThinkingConfig(){let e=this.contentGeneratorConfig?.reasoning;if(e===!1)return{includeThoughts:!1};if(e)return{includeThoughts:!0,thinkingLevel:e.effort==="low"?"LOW":e.effort==="high"||e.effort==="max"?"HIGH":"THINKING_LEVEL_UNSPECIFIED"}}async generateContent(e,t){let r={...e,contents:this.stripUnsupportedFields(e.contents),config:this.buildGenerateContentConfig(e)};return this.googleGenAI.models.generateContent(r)}async generateContentStream(e,t){let r={...e,contents:this.stripUnsupportedFields(e.contents),config:this.buildGenerateContentConfig(e)};return this.googleGenAI.models.generateContentStream(r)}stripUnsupportedFields(e){return!e||typeof e=="string"?e:Array.isArray(e)?e.map(t=>this.stripContentFields(t)):this.stripContentFields(e)}stripContentFields(e){if(typeof e=="string")return e;if(!("role"in e)&&!("parts"in e))return this.stripPartFields(e);let t=e;return t.parts?{...t,parts:t.parts.map(r=>this.stripPartFields(r))}:t}stripPartFields(e){if(typeof e=="string")return e;let t={...e};if(t.inlineData){let{displayName:r,...n}=t.inlineData;t.inlineData=n}if(t.fileData){let{displayName:r,...n}=t.fileData;t.fileData=n}if(t.functionResponse?.parts){let r=t.functionResponse.parts.map(n=>{let i=this.convertUnsupportedMediaToText(n);return this.stripPartFields(i)});t.functionResponse={...t.functionResponse,parts:r}}return t}convertUnsupportedMediaToText(e){if(typeof e=="string")return e;let t=e.inlineData?.mimeType||"",r=e.fileData?.mimeType||"";if(t.startsWith("audio/")||t.startsWith("video/")){let n=e.inlineData?.displayName,i=n?` (${n})`:"";return{text:`Unsupported media type for Gemini: ${t}${i}.`}}if(r.startsWith("audio/")||r.startsWith("video/")){let n=e.fileData?.displayName,i=n?` (${n})`:"";return{text:`Unsupported media type for Gemini: ${r}${i}.`}}return e}async countTokens(e){return this.googleGenAI.models.countTokens(e)}async embedContent(e){return this.googleGenAI.models.embedContent(e)}useSummarizedThinking(){return!0}};function T(o,e){let i={...{"User-Agent":o.userAgent||`MatildaCode/0.21.8 (${process.platform}; ${process.arch})`}};if(e?.getUsageStatisticsEnabled()){let f=new g().getInstallationId();i={...i,"x-gemini-api-privileged-user-id":`${f}`}}let s=o.baseUrl?{headers:i,baseUrl:o.baseUrl}:{headers:i};return new p({apiKey:o.apiKey===""?void 0:o.apiKey,vertexai:o.vertexai,httpOptions:s},o)}export{p as GeminiContentGenerator,T as createGeminiContentGenerator};
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2025 Google LLC
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{Ue as _,Ve as j}from"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import{b as D}from"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{g as k}from"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as M,i as C,p as N,q as A}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{G as $,J as O,N as v,aa as R,d as x}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as L}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";L();import z from"node:fs";import T from"node:path";var V=R("GLOB"),Y=100,B=2e4,W=15e3,q=500;function K(u,g,t){let e=[...u];return e.sort((r,s)=>{let c=r.mtimeMs??0,a=s.mtimeMs??0,o=g-c<t,l=g-a<t;return o&&l?a-c:o?-1:l?1:r.fullpath().localeCompare(s.fullpath())}),e}var S=class extends M{constructor(t,e){super(e);this.config=t;this.fileService=t.getFileService()}fileService;getDescription(){let t=`'${this.params.pattern}'`;return this.params.path&&(t+=` in path '${this.params.path}'`),t}async getDefaultPermission(){if(!this.params.path)return"allow";let t=this.config.getWorkspaceContext(),e=T.resolve(this.config.getTargetDir(),this.params.path);return t.isPathWithinWorkspace(e)||O(k(),e)?"allow":"ask"}async globInDirectory(t,e,r){let s=e,c=T.join(t,s);z.existsSync(c)&&(s=_(s));let a=j(s,{cwd:t,withFileTypes:!0,nodir:!0,stat:!0,nocase:!0,dot:!0,ignore:this.config.getFileExclusions().getGlobExcludes(),follow:!1,signal:r}),o=[],l=Date.now(),p=null;for await(let n of a){if(o.push(n),o.length>=B){p="count";break}if(Date.now()-l>W){p="time";break}o.length%q===0&&await new Promise(b=>setImmediate(b))}p&&a.destroy?.();let d=this.config.getTargetDir(),P=o.map(n=>T.relative(d,n.fullpath())),{filteredPaths:m}=this.fileService.filterFilesWithReport(P,this.getFileFilteringOptions()),h=n=>process.platform==="win32"||process.platform==="darwin"?n.toLowerCase():n,f=new Set(m.map(n=>h(T.resolve(d,n))));return{entries:o.filter(n=>f.has(h(n.fullpath()))),limited:p}}async execute(t){try{let e=[],r;if(this.params.path){let i=v(this.config,this.params.path,{allowExternalPaths:!0});e.push(i),r=`within ${i}`}else{let i=this.config.getWorkspaceContext().getDirectories();e.push(...i),r=i.length>1?`across ${i.length} workspace directories`:"in the workspace directory"}let s=this.params.pattern,c=[],a=new Set,o=null;for(let i of e){let{entries:F,limited:E}=await this.globInDirectory(i,s,t);E&&(o=E);for(let G of F){let I=G.fullpath();a.has(I)||(a.add(I),c.push(G))}}let l=c,p=o==="time"?`
|
|
4
4
|
|
|
5
5
|
[Search stopped after ${W/1e3}s before scanning the whole tree. Results may be incomplete \u2014 narrow the search by passing a more specific 'path' or pattern.]`:o==="count"?`
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{Oj as K,Pj as Y,S as q,
|
|
3
|
+
import{Oj as K,Pj as Y,S as q,Ve as z,id as F}from"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{g as _}from"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as U,i as V,p as H,q as J}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{G as O,J as W,N as S,aa as j,b as I,d as P}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as B}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";B();import tt from"node:fs/promises";import y from"node:path";import{EOL as et}from"node:os";import{spawn as X}from"node:child_process";var k=j("GREP"),M=class extends U{constructor(e,s){super(s);this.config=e;this.fileExclusions=e.getFileExclusions()}fileExclusions;async getDefaultPermission(){if(!this.params.path)return"allow";let e=this.config.getWorkspaceContext(),s=y.resolve(this.config.getTargetDir(),this.params.path);return e.isPathWithinWorkspace(s)||W(_(),s)?"allow":"ask"}async execute(e){try{let s=[],i;if(this.params.path){let t=S(this.config,this.params.path,{allowExternalPaths:!0});s.push(t),i=`in path "${this.params.path}"`}else{let t=this.config.getWorkspaceContext().getDirectories();s.push(...t),i=t.length>1?`across ${t.length} workspace directories`:"in the workspace directory"}let l=[];for(let t of s){let o=await this.performGrepSearch({pattern:this.params.pattern,path:t,glob:this.params.glob,signal:e});if(s.length>1)for(let a of o)y.isAbsolute(a.filePath)||(a.filePath=y.resolve(t,a.filePath));l.push(...o)}if(s.length>1){let t=new Set;l=l.filter(o=>{let a=`${o.filePath}:${o.lineNumber}`;return t.has(a)?!1:(t.add(a),!0)})}let f=this.params.glob?` (filter: "${this.params.glob}")`:"";if(l.length===0)return{llmContent:`No matches found for pattern "${this.params.pattern}" ${i}${f}.`,returnDisplay:"No matches found"};let h=this.config.getTruncateToolOutputThreshold(),w=Math.min(this.config.getTruncateToolOutputLines(),this.params.limit??Number.POSITIVE_INFINITY),$=!1,C=l;l.length>w&&(C=l.slice(0,w),$=!0);let E=l.length,x=E===1?"match":"matches",G=`Found ${E} ${x} for pattern "${this.params.pattern}" ${i}${f}:
|
|
4
4
|
---
|
|
5
5
|
`,v=C.reduce((t,o)=>{let a=o.filePath;return t[a]||(t[a]=[]),t[a].push(o),t[a].sort((L,D)=>L.lineNumber-D.lineNumber),t},{}),n="",g=[],m=!1,c=(t,o)=>Number.isFinite(h)&&n.length+t.length>h?(n+=t.slice(0,Math.max(h-n.length,0)),n+="...",o&&g.push(o),m=!0,!1):(n+=t,o&&g.push(o),!0);for(let t in v){if(!c(`File: ${t}
|
|
6
6
|
`))break;let o=!1;for(let a of v[t]){let L=a.line.trim();if(!c(`L${a.lineNumber}: ${L}
|
package/chunks/{matildaAgentContentGenerator-522K7OVF.js → matildaAgentContentGenerator-UATDDKKZ.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{b as t}from"./chunk-
|
|
3
|
+
import{b as t}from"./chunk-WOH6NLJH.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import"./chunk-6B5BDE7S.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as n}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";n();function a(e,o){return new t(e,o)}export{t as MatildaAgentContentGenerator,a as createMatildaAgentContentGenerator};
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2026 Matilda Team
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as l,i as p}from"./chunk-
|
|
3
|
+
import{a as l,i as p}from"./chunk-QBBPRMPV.js";import"./chunk-LIWYWWOK.js";import"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import{d as u}from"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{k as c}from"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import"./chunk-6B5BDE7S.js";import{c as h}from"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{aa as d,s as i,t as a}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as s}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";s();var m=class extends p{debugLogger=d("MATILDA");matildaClient;sharedManager;currentToken;constructor(e,t,n){let r=new l(t,n);super(t,n,r),this.matildaClient=e,this.sharedManager=h.getInstance(),t?.baseUrl&&t?.apiKey&&(this.pipeline.client.baseURL=t?.baseUrl,this.pipeline.client.apiKey=t?.apiKey)}getCurrentEndpoint(e){let t=e||u,n="/v1",r=t.startsWith("http")?t:`https://${t}`;return r.endsWith(n)||r.endsWith("/api/v1")||r.endsWith("/api/v1/code")?r:`${r}${n}`}shouldSuppressErrorLogging(e,t){return this.isAuthError(e)}async getValidToken(){try{let e=await this.sharedManager.getValidCredentials(this.matildaClient);if(!e.access_token)throw new Error("No access token available");return{token:e.access_token,endpoint:this.getCurrentEndpoint(e.resource_url)}}catch(e){throw this.isAuthError(e)?e:(this.debugLogger.warn("Failed to get token from shared manager:",e),new Error("Failed to obtain a valid legacy OAuth access token. Please re-authenticate with Matilda."))}}async executeWithCredentialManagement(e){let t=async()=>{let{token:n,endpoint:r}=await this.getValidToken();this.pipeline.client.apiKey=n,this.pipeline.client.baseURL=r;try{return await e()}catch(o){throw a(o)?new i:o}};try{return await t()}catch(n){if(this.isAuthError(n))return await this.sharedManager.getValidCredentials(this.matildaClient,!0),await c("retry",t);throw n}}async generateContent(e,t){return this.executeWithCredentialManagement(()=>super.generateContent(e,t))}async generateContentStream(e,t){let n=await this.executeWithCredentialManagement(()=>super.generateContentStream(e,t));return async function*(){try{yield*n}catch(r){throw a(r)?new i:r}}()}async countTokens(e){return super.countTokens(e)}async embedContent(e){return this.executeWithCredentialManagement(()=>super.embedContent(e))}isAuthError(e){if(!e||a(e))return!1;let t=e instanceof Error?e.message.toLowerCase():String(e).toLowerCase(),n=e,r=n?.status||n?.code;return Number(r)===403?!1:r===401||r==="401"||t.includes("unauthorized")||t.includes("invalid api key")||t.includes("invalid access token")||t.includes("token expired")||t.includes("authentication")||t.includes("token")&&t.includes("expired")}getCurrentToken(){return this.currentToken?this.currentToken:this.sharedManager.getCurrentCredentials()?.access_token||null}clearToken(){this.currentToken=void 0,this.sharedManager.clearCache()}};export{m as MatildaContentGenerator};
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2025 Matilda
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{$c as
|
|
3
|
+
import{$c as C,Be as rt,Gc as tt,Ne as st,Sc as et,Se as L,Te as at,Vc as ot,Wc as A,ad as nt,ed as it,ti as P,vi as lt}from"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as Z,i as q,p as Y,q as Q}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{K as J,aa as K,d as m}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as H}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";H();import{spawn as ct}from"node:child_process";import mt from"node:path";import{randomUUID as wt}from"node:crypto";var u=K("MONITOR"),Et=1e3,O=1e4,St=3e5,N=6e5,dt=80,R=4096,ut=5,ft=1e3;function pt(l){return l.length>dt?l.slice(0,dt-1)+"\u2026":l}var kt=new Set(["task-notification","task-id","tool-use-id","kind","status","event-count","summary","result"]),xt=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)>/g;function gt(l){let y="";for(let t=0;t<l.length;t++){let o=l.charCodeAt(t);if(o===9){y+=l[t];continue}o<32||o>=128&&o<=159||(y+=l[t])}return y=y.replace(xt,(t,o,a)=>kt.has(String(a).toLowerCase())?o==="/"?`</\u200B${a}>`:`<\u200B${a}>`:t),y}var U=class extends Z{constructor(t,o){super(o);this.config=t}callId;setCallId(t){this.callId=t}getDescription(){let t=this.params.description||C(this.params.command).spawnCommand;return`Monitor: ${pt(t)}`}async getDefaultPermission(){let t=C(this.params.command).safetyCommand;try{if(await L(t))return"allow"}catch(o){u.warn("AST read-only check failed, falling back to ask:",o)}return"ask"}async getConfirmationDetails(t){let o=C(this.params.command),a=ot(o.safetyCommand),f=[];for(let s of a){let p=!1;try{p=await L(s)}catch(d){u.warn("AST read-only check failed for monitor sub-command, falling back to ask:",d)}p||f.push(s)}let S=f.length>0?f:a,M=[...new Set(S.map(s=>A(s)).filter(s=>!!s))],v=[];try{let s=[];for(let p of S){let d=await at(p);s.push(...d)}v=[...new Set(s)].map(p=>`Monitor(${p})`)}catch(s){u.warn("Failed to extract monitor command rules:",s),v=[`Monitor(${o.safetyCommand})`]}let i=it(o.safetyCommand,this.params.command),c={type:"exec",title:"Monitor",command:o.spawnCommand,rootCommand:M.join(", ")||(A(o.safetyCommand)??o.spawnCommand),permissionRules:v,onConfirm:async(s,p)=>{}};return i&&(c.warnings=i),c}async execute(t){if(t.aborted)return{llmContent:"Monitor was cancelled before it could start.",returnDisplay:"Monitor cancelled."};let o=C(this.params.command),a=o.spawnCommand;o.strippedTrailingAmp&&u.warn("Stripped trailing & from monitor command \u2014 monitor lifecycle handles backgrounding");let f=gt(this.params.description||a),S=pt(f),M=Math.min(this.params.max_events??Et,O),v=Math.min(this.params.idle_timeout_ms??St,N),i=`mon_${wt().replace(/-/g,"").slice(0,16)}`,c=this.config.getMonitorRegistry(),s=tt()??void 0;if(c.getRunning().length>=P)return{llmContent:`Cannot start monitor: maximum concurrent monitors (${P}) reached. Stop an existing monitor first.`,returnDisplay:"Monitor rejected: too many concurrent monitors."};let d=new AbortController,g={monitorId:i,command:a,description:f,status:"running",startTime:Date.now(),abortController:d,toolUseId:this.callId,eventCount:0,lastEventTime:0,maxEvents:M,idleTimeoutMs:v,droppedLines:0,outputFile:lt(this.config.storage.getProjectDir(),this.config.getSessionId(),i),...s?{ownerAgentId:s}:{}},{executable:yt,argsPrefix:vt}=et(),n;try{n=ct(yt,[...vt,a],{cwd:this.params.directory||this.config.getTargetDir(),stdio:["ignore","pipe","pipe"],detached:!0,env:{...process.env,MATILDA_CODE:"1",TERM:"dumb",PAGER:"cat",...st()}})}catch(e){return{llmContent:`Monitor failed to start: ${m(e)}`,returnDisplay:`Monitor failed: ${m(e)}`}}g.pid=n.pid;let b=!1,w,D=e=>{w??=e};n.on("error",D);let B={value:""},G={value:""},k=ut,I=Date.now(),$=e=>{let r=gt(e);if(r.length===0||r.trim().length===0)return;let T=Date.now(),_=T-I;if(_<0)u.warn(`Monitor ${i}: clock moved backwards by ${-_}ms, resetting refill timestamp`),I=T;else{let h=Math.floor(_/ft);h>0&&(k=Math.min(ut,k+h),I+=h*ft)}k>0?(k--,c.emitEvent(i,r)):g.droppedLines++},j=()=>{for(let e of[B,G]){let r=e.value.trim();r.length>0&&$(r),e.value=""}},Tt=()=>{if(!(b||!n.pid))if(process.platform==="win32")ct("taskkill",["/pid",n.pid.toString(),"/f","/t"],{stdio:"ignore"}).on("error",r=>u.warn(`Monitor taskkill failed for pid ${n.pid}: ${m(r)}`));else{try{process.kill(-n.pid,"SIGTERM")}catch(e){u.warn(`Monitor ${i} SIGTERM failed (pid=${n.pid}): ${m(e)}`)}setTimeout(()=>{if(!b&&n.pid)try{process.kill(-n.pid,"SIGKILL")}catch(e){u.warn(`Monitor ${i} SIGKILL escalation failed (pid=${n.pid}): ${m(e)}`)}},200).unref?.()}},E=()=>{j(),Tt()};d.signal.addEventListener("abort",E,{once:!0}),d.signal.aborted&&E();try{c.register(g)}catch(e){return E(),d.signal.removeEventListener("abort",E),n.stdout?.destroy?.(),n.stderr?.destroy?.(),n.removeListener("error",D),n.on("error",()=>{}),{llmContent:`Monitor failed to start: ${m(e)}`,returnDisplay:`Monitor failed: ${m(e)}`}}let z=(e,r)=>{if(g.status!=="running")return;let T=rt(r.toString("utf-8"));if(e.value+=T,!e.value.includes(`
|
|
4
4
|
`)&&e.value.length>R){let h=e.value.trim();h.length>0&&$(h.slice(0,R)+"..."),e.value="";return}let _=e.value.split(`
|
|
5
5
|
`);e.value=_.pop()??"";for(let h of _){let x=h.trim();if(x.length===0)continue;let bt=x.length>R?x.slice(0,R)+"...":x;$(bt)}};n.stdout?.on("data",e=>z(B,e)),n.stderr?.on("data",e=>z(G,e));let F=!1,X=()=>{F||(F=!0,j(),d.signal.removeEventListener("abort",E),g.droppedLines>0&&u.info(`Monitor ${i} dropped ${g.droppedLines} lines due to throttling`))},V=null,_t=(e,r)=>{g.status==="running"&&(d.signal.aborted?c.cancel(i):e!==null&&e!==0?c.fail(i,`Exit code ${e}`):r?c.fail(i,`Killed by signal ${r}`):c.complete(i,e))},Ct=(e,r)=>{b=!0,V={code:e,sig:r}},Mt=(e,r)=>{b=!0,X();let T=V??{code:e,sig:r};_t(T.code,T.sig)},W=e=>{b=!0,X(),g.status==="running"&&c.fail(i,m(e))};return n.on("exit",Ct),n.on("close",Mt),n.on("error",W),n.removeListener("error",D),w?(W(w),{llmContent:`Monitor failed to start: ${m(w)}`,returnDisplay:`Monitor failed: ${m(w)}`}):{llmContent:`Monitor started.
|
|
6
6
|
id: ${i}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{$e as X,Qe as y,cf as Z,ka as R,ue as D,ve as Y,wc as Q}from"./chunk-FV4IIIXN.js";import"./chunk-TZIDSCTF.js";import"./chunk-ROETRE5J.js";import"./chunk-INAZKGGR.js";import"./chunk-DCQKJTAX.js";import"./chunk-LSDMWVW6.js";import"./chunk-MTMU7JYZ.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-VYTYYCBR.js";import"./chunk-TISQNFB5.js";import"./chunk-34DXSYJZ.js";import"./chunk-47XR7IMP.js";import"./chunk-FWIVFCKF.js";import"./chunk-QKYGQLWC.js";import"./chunk-FRL6KOLY.js";import"./chunk-VWWEEU4V.js";import"./chunk-RNKDFE2S.js";import"./chunk-Q2I3ARPJ.js";import"./chunk-WOH6NLJH.js";import"./chunk-QHA3ZBRO.js";import"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{J as B,K as k,L as U,Lb as z,M as K,N as q,O as b,P as W,Q as j,R as C,S as J,T as V,U as w,V as M,_c as H,ca as G}from"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import{g as $,i as L,p as c,q as x}from"./chunk-6B5BDE7S.js";import"./chunk-RJX7DK4Y.js";import"./chunk-XCJYORZX.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import{D as _,E as N,G as T,aa as F}from"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as v}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";v();import*as E from"node:fs";import*as m from"node:path";var ee=F("NOTEBOOK_EDIT");function g(d,r,t){return ee.debug("prior-read-rejected",{path:d,reason:r,type:t.type,displayMessage:t.displayMessage}),t}var u=class extends Error{constructor(t,e){super(t);this.type=e;this.name="NotebookEditError"}};function te(d,r){if(r==="delete")return"";if(typeof d!="string")throw new u(`new_source is required when edit_mode is "${r}".`,"invalid_tool_params");return d}function I(d,r){return d?q(d,r):`cell-${r}`}function oe(d,r,t){if(!r){if(t==="insert")return-1;throw new u("cell_id is required for replace and delete operations.","invalid_tool_params")}if(W(d,r))throw new u(`Cell ID "${r}" is ambiguous in the rendered notebook. Re-read the notebook and target a stable real cell ID before editing.`,"invalid_tool_params");let e=j(d,r);if(e===-1)throw new u(`Cell with ID "${r}" not found in notebook.`,"notebook_cell_not_found");return e}function ie(d,r,t,e){let o={cell_type:r,metadata:{},source:w(t,e)},i=J(d);return i&&(o.id=i),M(o,r),o}function O(d,r){let t;try{t=k(d)}catch(a){throw new u(a instanceof Error?a.message:String(a),"notebook_invalid_json")}let e=r.edit_mode??"replace",o=te(r.new_source,e),i=b(t),n=oe(t,r.cell_id,e),l=C(t),p=U(d),s=(a,f)=>{let h=e==="insert"||e==="delete";return{...f,updatedContent:K(a,p),requiresReadAfterWrite:h&&!(i&&b(a))}};switch(e){case"insert":{let a=r.cell_type??"code",f=n===-1?0:n+1,h=ie(t,a,o,V(t,f));return t.cells.splice(f,0,h),s(t,{editedCellId:I(h,f),editedCellType:a,language:l,mode:e})}case"delete":{let[a]=t.cells.splice(n,1);return s(t,{editedCellId:I(a,n),editedCellType:a?.cell_type,language:l,mode:e})}case"replace":{let a=t.cells[n];if(!a)throw new u(`Cell index ${n} is out of range.`,"notebook_cell_not_found");let f=r.cell_type??a.cell_type;return a.source=w(o,Array.isArray(a.source)),M(a,f),s(t,{editedCellId:I(a,n),editedCellType:f,language:l,mode:e})}default:throw new u(`Unsupported notebook edit mode: ${e}`,"invalid_tool_params")}}function re(d,r,t){let e,o;try{e=k(r),o=k(d)}catch(i){throw new u(i instanceof Error?i.message:String(i),"notebook_invalid_json")}return{updatedContent:r,editedCellId:t.cell_id??"user-modified-notebook",editedCellType:void 0,language:C(e),mode:t.edit_mode??"replace",requiresReadAfterWrite:!b(o)||!b(e)}}async function A(d,r,t={}){if(d.getFileReadCacheDisabled())return{ok:!0};let e;try{e=await E.promises.stat(r)}catch(i){let n=i?.code;return n==="ENOENT"?t.expectExisting?g(r,"missing-after-read",{ok:!1,type:"file_changed_since_read",rawMessage:`Notebook ${r} disappeared after it was read. Re-read it with the ${c.READ_FILE} tool before editing it.`,displayMessage:`notebook disappeared after last read; re-run ${c.READ_FILE} first.`}):{ok:!0}:g(r,"stat-failed",{ok:!1,type:"prior_read_verification_failed",rawMessage:`Could not stat ${r} to verify prior notebook read (${n??"unknown error"}). Re-read it with the ${c.READ_FILE} tool before editing it.`,displayMessage:`cannot verify prior read of ${r}; re-run ${c.READ_FILE} before editing this notebook.`})}if(e.isDirectory())return g(r,"target-is-directory",{ok:!1,type:"target_is_directory",rawMessage:`${r} is a directory. The NotebookEdit tool only operates on .ipynb files.`,displayMessage:"path is a directory; cannot edit as a notebook."});if(!e.isFile())return g(r,"target-not-regular-file",{ok:!1,type:"target_not_regular_file",rawMessage:`${r} is not a regular file. The NotebookEdit tool only operates on .ipynb files.`,displayMessage:"special file; cannot edit as a notebook."});let o=d.getFileReadCache().check(e);return o.state==="fresh"&&o.entry.lastReadAt!==void 0&&o.entry.lastReadWasFull?{ok:!0}:o.state==="fresh"&&o.entry.lastReadAt!==void 0&&!o.entry.lastReadWasFull?g(r,"truncated-cache-entry",{ok:!1,type:"edit_requires_prior_read",rawMessage:`Notebook ${r} is too large for cell-level editing because its rendered output was truncated when read. Reduce the notebook output size or split the notebook before editing cells.`,displayMessage:"notebook too large for cell-level editing."}):o.state==="stale"?g(r,"stale-cache-entry",{ok:!1,type:"file_changed_since_read",rawMessage:`Notebook ${r} has been modified since you last read it. Re-read it with the ${c.READ_FILE} tool before editing it.`,displayMessage:`notebook changed since last read; re-run ${c.READ_FILE} first.`}):g(r,`cache-${o.state}`,{ok:!1,type:"edit_requires_prior_read",rawMessage:`Notebook ${r} has not been fully read in this session. Use the ${c.READ_FILE} tool first, without offset or limit, before editing cells.`,displayMessage:`${c.READ_FILE} required before editing this notebook.`})}var P=class extends ${constructor(t,e,o){super(e);this.config=t;this.modifyMetadata=o}toolLocations(){return[{path:this.params.notebook_path}]}getDescription(){let t=N(this.params.notebook_path,this.config.getTargetDir()),e=this.params.edit_mode??"replace",o=this.params.cell_id??"beginning";return`${e} notebook cell ${o} in ${_(t)}`}async getDefaultPermission(){return"ask"}async getConfirmationDetails(t){let e=await this.prepareEdit(t),o=m.basename(this.params.notebook_path),i=R(o,e.originalContent,e.updatedContent,"Current","Proposed",D);return{type:"edit",title:`Confirm Notebook Edit: ${_(N(this.params.notebook_path,this.config.getTargetDir()))}`,fileName:o,filePath:this.params.notebook_path,fileDiff:i,originalContent:e.originalContent,newContent:e.updatedContent,onConfirm:async l=>{l==="proceed_always"&&this.config.setApprovalMode("auto-edit")}}}async prepareEdit(t){let e=await A(this.config,this.params.notebook_path);if(!e.ok)throw new y(e.rawMessage,e.type);let o,i=!1,n,l="lf";try{let s=await this.config.getFileSystemService().readTextFile({path:this.params.notebook_path});o=s.content,i=s._meta?.bom??!1,n=s._meta?.encoding,l=s._meta?.lineEnding??X(s.content)}catch(s){throw t.aborted?s:s?.code==="ENOENT"?new y(`Notebook file not found: ${this.params.notebook_path}`,"file_not_found"):new y(`Error reading notebook: ${s instanceof Error?s.message:String(s)}`,"read_content_failure")}let p=await A(this.config,this.params.notebook_path,{expectExisting:!0});if(!p.ok)throw new y(p.rawMessage,p.type);try{return this.modifyMetadata?.modifiedNotebookContent!==void 0?{...re(o,this.modifyMetadata.modifiedNotebookContent,this.params),originalContent:o,bom:i,encoding:n,lineEnding:l}:{...O(o,this.params),originalContent:o,bom:i,encoding:n,lineEnding:l}}catch(s){throw s instanceof u?new y(s.message,s.type):s}}async execute(t){let e;try{e=await this.prepareEdit(t)}catch(o){if(t.aborted)throw o;let i=o instanceof y?o.errorType:"notebook_edit_failure",n=o instanceof Error?o.message:String(o);return{llmContent:n,returnDisplay:`Error: ${n}`,error:{message:n,type:i}}}try{try{await this.config.getFileHistoryService().trackEdit(this.params.notebook_path)}catch{}let o=await A(this.config,this.params.notebook_path,{expectExisting:!0});if(!o.ok)return{llmContent:o.rawMessage,returnDisplay:`Error: ${o.displayMessage}`,error:{message:o.rawMessage,type:o.type}};await this.config.getFileSystemService().writeTextFile({path:this.params.notebook_path,content:e.updatedContent,_meta:{bom:e.bom,encoding:e.encoding,lineEnding:e.lineEnding}}),this.modifyMetadata?.modifiedByUser||Q.getInstance().recordEdit(this.params.notebook_path,e.originalContent,e.updatedContent);try{let a=E.statSync(this.params.notebook_path),f=this.config.getFileReadCache();e.requiresReadAfterWrite?f.invalidate(a):f.recordWrite(this.params.notebook_path,a,{cacheable:!1})}catch(a){ee.warn(`[NotebookEdit] post-write cache update failed for ${this.params.notebook_path}: ${a instanceof Error?a.message:String(a)}`)}let i=m.basename(this.params.notebook_path),n=R(i,e.originalContent,e.updatedContent,"Current","Proposed",D),l=Y(i,e.originalContent,this.modifyMetadata?.aiProposedContent??e.updatedContent,e.updatedContent);z(this.config,new H(S.Name,"update",e.updatedContent.split(`
|
|
4
4
|
`).length,G(this.params.notebook_path),".ipynb",e.language));let p={fileDiff:n,fileName:i,originalContent:e.originalContent,newContent:e.updatedContent,diffStat:l},s=this.modifyMetadata?.modifiedNotebookContent!==void 0?`Notebook ${this.params.notebook_path} has been updated. Notebook content was modified by the user before approval; the final saved notebook may differ from the original ${e.mode} cell ${e.editedCellId} proposal.`:`Notebook ${this.params.notebook_path} has been updated. ${e.mode} cell ${e.editedCellId}.${e.mode==="delete"?"":`
|
|
5
5
|
|
|
6
6
|
Updated source:
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m}from"./chunk-
|
|
3
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m}from"./chunk-QBBPRMPV.js";import"./chunk-LIWYWWOK.js";import"./chunk-QHA3ZBRO.js";import{g as a}from"./chunk-6D5M34RS.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-S7G6QPEP.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import"./chunk-B3NVKOSU.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-32PTAACU.js";import"./chunk-32T6RWWT.js";import"./chunk-6B5BDE7S.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-EQEQPZLQ.js";import"./chunk-VLYRNOD3.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{h as ContentGenerationPipeline,c as DeepSeekOpenAICompatibleProvider,i as EnhancedErrorHandler,b as MatildaOpenAICompatibleProvider,k as MatildaOpenAIContentGenerator,g as MiMoOpenAICompatibleProvider,e as MiniMaxOpenAICompatibleProvider,f as MistralOpenAICompatibleProvider,a as OpenAIContentConverter,j as OpenAIContentGenerator,d as OpenRouterOpenAICompatibleProvider,l as createOpenAIContentGenerator,m as determineProvider};
|