@maincode-ai/matilda-code 0.20.8 → 0.20.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/chunks/{agent-3E4OSF2E.js → agent-MR6HBCNC.js} +1 -1
  2. package/chunks/{agent-headless-22O7UBQY.js → agent-headless-Y5AQHZHB.js} +1 -1
  3. package/chunks/anthropicContentGenerator-I3ANKUSE.js +39 -0
  4. package/chunks/{chunk-2FYDKSRH.js → chunk-2D5W3WW7.js} +498 -494
  5. package/chunks/{chunk-LYNJBU6H.js → chunk-2JIJ6PFL.js} +1 -1
  6. package/chunks/chunk-7VBRP4XQ.js +18 -0
  7. package/chunks/chunk-7VE3KGS4.js +8 -0
  8. package/chunks/{chunk-WLZF5HVE.js → chunk-FIUFMVRX.js} +1 -1
  9. package/chunks/{chunk-IRT3RU6X.js → chunk-JFICDNCB.js} +1 -1
  10. package/chunks/{chunk-FXQULW2K.js → chunk-NPLAJOCA.js} +2 -2
  11. package/chunks/chunk-OVZKSZIR.js +101 -0
  12. package/chunks/{computer-use-KS6XCSQU.js → computer-use-5NE6OER4.js} +1 -1
  13. package/chunks/{contextCommand-TNTORBHV.js → contextCommand-TQW3E3L6.js} +1 -1
  14. package/chunks/edit-PMMM4Z57.js +39 -0
  15. package/chunks/{enter-worktree-NF7MA5QG.js → enter-worktree-KOLSAE3N.js} +1 -1
  16. package/chunks/{enterPlanMode-KPWSPCF2.js → enterPlanMode-WIEHROJ4.js} +1 -1
  17. package/chunks/{exit-worktree-XWVGI4HA.js → exit-worktree-5GFNCQCU.js} +1 -1
  18. package/chunks/{exitPlanMode-OS2BGGZK.js → exitPlanMode-4SD3GHP7.js} +1 -1
  19. package/chunks/{geminiContentGenerator-WF3CO3CH.js → geminiContentGenerator-GSNXCP36.js} +1 -1
  20. package/chunks/{glob-Y3XNORZ3.js → glob-6NLJB2GI.js} +1 -1
  21. package/chunks/{grep-NA3SFYUM.js → grep-7TT7XXG2.js} +1 -1
  22. package/chunks/matildaAgentContentGenerator-BZXWJKJ6.js +32 -0
  23. package/chunks/{matildaContentGenerator-4BGLGEWH.js → matildaContentGenerator-BBG5MEI5.js} +1 -1
  24. package/chunks/{monitor-R3FCMPC6.js → monitor-7Z2SKQOD.js} +1 -1
  25. package/chunks/{notebook-edit-4U5TTZFZ.js → notebook-edit-ZWC6PWD3.js} +1 -1
  26. package/chunks/{openaiContentGenerator-DMT4SZML.js → openaiContentGenerator-JACPHIUG.js} +1 -1
  27. package/chunks/{ripGrep-43PC37KD.js → ripGrep-3EJOL3QF.js} +1 -1
  28. package/chunks/{scheduler-SRRKOB5L.js → scheduler-6GFBYAJV.js} +1 -1
  29. package/chunks/{serve-YOJETSOR.js → serve-HI33OSTP.js} +1 -1
  30. package/chunks/{shell-N7HJYZVF.js → shell-6VEGUV5J.js} +1 -1
  31. package/chunks/{skill-YXHHDMLR.js → skill-HOXYLSX3.js} +1 -1
  32. package/chunks/src-3M4GZHJB.js +3 -0
  33. package/chunks/{team-create-EOV7F7EH.js → team-create-PWPR4OKM.js} +1 -1
  34. package/chunks/{workflow-Y5CYLQU7.js → workflow-UMB2MXXJ.js} +2 -2
  35. package/chunks/{write-file-ECUYLTFL.js → write-file-REUJ4LGI.js} +1 -1
  36. package/cli.js +399 -399
  37. package/package.json +2 -2
  38. package/chunks/anthropicContentGenerator-ATLOKYPR.js +0 -39
  39. package/chunks/chunk-2XZIKUB6.js +0 -18
  40. package/chunks/chunk-6V6R7SFP.js +0 -101
  41. package/chunks/chunk-ISW2QC5B.js +0 -8
  42. package/chunks/edit-5OWDNHI4.js +0 -38
  43. package/chunks/matildaAgentContentGenerator-4B4MMKWH.js +0 -32
  44. package/chunks/src-55PQXZJ3.js +0 -3
@@ -0,0 +1,32 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{a as I,b as F,c as U}from"./chunk-7VE3KGS4.js";import{c as E,y as $}from"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import{b as m,e as P}from"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{k as x,n as O}from"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{p as b}from"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as w}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";w();w();var L="2026-06-23",W="auto",H="instant",J=12e4,h=18e4,V=5e4,v=16e3,X=["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(" "),B=["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 K(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 T(n){try{let e=JSON.parse(n);return e&&typeof e=="object"?e:void 0}catch{return}}function u(n,e){let o=T(n)?.[e];return typeof o=="string"?o:void 0}function j(n){return G(n)}function G(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
+ `):""}function g(n,e){if(n.length<=e)return n;let t=`
5
+ [...omitted to fit Matilda native agent context...]
6
+ `,o=e-t.length,s=Math.floor(o*.6),a=o-s;return`${n.slice(0,s)}${t}${n.slice(-a)}`}function z(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 Q(n){let e=T(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 Y(n){if(C(n)<=h)return n;let e=`
7
+ [...omitted to fit Matilda native request limit...]
8
+ `;for(let t=0;t<n.messages.length;t+=1){let o=n.messages[t];!o||o.content.length<=v||(n.messages[t]={...o,content:g(o.content,v)})}if(C(n)<=h)return n;for(;n.messages.length>2&&C(n)>h;){n.messages.splice(1,1);let t=n.messages[0];t&&!t.content.includes(e.trim())&&(n.messages[0]={...t,content:`${t.content}${e}`})}for(;C(n)>h;){let t=n.messages.length>1?n.messages.length-1:0,o=n.messages[t];if(!o||o.content.length<=1e3)break;let s=C(n)-h,a=Math.max(1e3,o.content.length-s-e.length-2e3);n.messages[t]={...o,content:g(o.content,a)}}return C(n)<=h||n.clientTools&&delete n.clientTools,n}function Z(n){let e=T(n.data);if(!e)return;let t=typeof e.name=="string"?e.name:void 0;if(!t)return;let o=e.args&&typeof e.args=="object"?e.args:{};return{id:typeof e.id=="string"?e.id:void 0,name:t,args:o}}function q(n){let e=T(n.data);if(n.event==="thinking"){let t=u(n.data,"content");return t?`**Thinking** ${t}`:void 0}if(n.event==="generation_status"){let t=u(n.data,"phase");return t?`**Planning** ${t}`:void 0}if(n.event==="status"){let t=u(n.data,"state");if(!t)return;let o=typeof e?.position=="number"?` position ${e.position}`:"";return`**Status** ${t}${o}`}if(n.event==="tool_start"){let t=u(n.data,"tool");if(!t)return;let o=u(n.data,"input")??(e?.args?JSON.stringify(e.args):void 0);return`**Remote tool** Starting ${t}${o?` with ${o}`:""}`}if(n.event==="tool_progress"){let t=u(n.data,"tool"),o=u(n.data,"message");return t&&o?`**Remote tool** ${t}: ${o}`:void 0}if(n.event==="tool_result"){let t=u(n.data,"tool"),o=u(n.data,"status"),s=u(n.data,"output")??u(n.data,"result");return t?`**Remote tool** ${t} ${o??"completed"}${s?`: ${g(s,600)}`:""}`:void 0}}function S(n,e,t){let o=new P;return o.candidates=[{content:{parts:n?[{text:n}]:[],role:"model"},index:0,safetyRatings:[]}],o.createTime=Date.now().toString(),o.modelVersion=e,t&&(o.usageMetadata=t),o}function ee(n,e){let t=new P;return t.candidates=[{content:{parts:n?[{text:n,thought:!0}]:[],role:"model"},index:0,safetyRatings:[]}],t.createTime=Date.now().toString(),t.modelVersion=e,t}function te(n,e){let t=new P;return t.candidates=[{content:{parts:[{functionCall:n}],role:"model"},index:0,safetyRatings:[]}],t.createTime=Date.now().toString(),t.modelVersion=e,Object.defineProperty(t,"functionCalls",{value:[n],writable:!0,configurable:!0,enumerable:!0}),t}function D(n,e,t){let o=S("",n,t);return o.candidates=[{content:{parts:[],role:"model"},finishReason:e,index:0,safetyRatings:[]}],o}async function*ne(n,e){let t=n.body?.getReader();if(!t)throw new Error("Matilda agent stream returned no response body");let o=new TextDecoder,s="",a="message",r=[],d=!1,c,i=()=>{e<=0||(c&&clearTimeout(c),c=setTimeout(()=>{d=!0,t.cancel().catch(()=>{})},e))},l=()=>{c&&(clearTimeout(c),c=void 0)},f=()=>{if(r.length===0){a="message";return}let A={event:a,data:r.join(`
9
+ `)};return a="message",r=[],i(),A};i();try{for(;;){let{done:M,value:p}=await t.read();if(M||d)break;s+=o.decode(p,{stream:!0});let N=s.split(`
10
+ `);s=N.pop()??"";for(let k of N){let y=k.endsWith("\r")?k.slice(0,-1):k;if(y.length===0){let _=f();_&&(yield _)}else y.startsWith("event:")?a=y.slice(6).trim():y.startsWith("data:")&&r.push(y.slice(5).trimStart())}}if(s+=o.decode(),s.length>0)for(let M of s.split(`
11
+ `)){let p=M.endsWith("\r")?M.slice(0,-1):M;p.startsWith("event:")?a=p.slice(6).trim():p.startsWith("data:")&&r.push(p.slice(5).trimStart())}let A=f();A&&(yield A)}finally{l()}if(d)throw Object.assign(new Error(`No Matilda agent SSE events for ${e}ms`),{code:"ETIMEDOUT"})}var R=class{constructor(e,t){this.contentGeneratorConfig=e;this.cliConfig=t}async generateContent(e,t){let o=await this.generateContentStream(e,t),s="",a,r=m.STOP,d=!1;for await(let i of o){s+=z(i),i.usageMetadata&&(a=i.usageMetadata);let l=i.candidates?.[0]?.finishReason;l&&(d=!0,r=l)}if(!d)throw new Error("Matilda agent stream ended without an authoritative done signal.");let c=S(s,this.modelFor(e),a);return c.candidates=[{content:{parts:s?[{text:s}]:[],role:"model"},index:0,safetyRatings:[]}],r&&(c.candidates[0].finishReason=r),c}async generateContentStream(e,t){return this.streamNativeChat(e)}async countTokens(e){return{totalTokens:Math.ceil(JSON.stringify(e.contents??"").length/4)}}async embedContent(e){throw new Error("Matilda agent SDK transport does not support embeddings.")}useSummarizedThinking(){return!1}async*streamNativeChat(e){let t=this.modelFor(e),o=await this.fetchNativeChat(e),s=!1,a=!1,r,d,c=!1;for await(let i of ne(o,J))if(i.data!=="[DONE]"){if(i.event==="token"){let l=u(i.data,"content");l&&(a=!0,yield S(l,t))}else if(i.event==="thinking"||i.event==="generation_status"||i.event==="status"||i.event==="tool_start"||i.event==="tool_progress"||i.event==="tool_result"){let l=q(i);l&&(a=!0,yield ee(l,t))}else if(i.event==="client_tool_call"){let l=Z(i);l&&(a=!0,yield te(l,t))}else if(i.event==="usage")d=Q(i.data)??d;else if(i.event==="safety_replace"){let l=u(i.data,"message")??u(i.data,"content");l&&(a=!0,yield S(l,t))}else if(i.event==="truncated")c=!0,r=m.MAX_TOKENS;else if(i.event==="done"){if(c=!0,r=u(i.data,"reason")==="max_tokens"?m.MAX_TOKENS:r??m.STOP,!a)throw new Error("Matilda agent returned an empty response.");yield D(t,r,d),s=!0}else if(i.event==="error"){let l=T(i.data),f=typeof l?.error=="string"?l.error:"Unknown Matilda agent stream error";throw new Error(`Matilda agent stream error: ${f}`)}}if(!s){if(!a)throw new Error("Matilda agent returned an empty response.");c&&(yield D(t,r??m.STOP,d))}}async fetchNativeChat(e){let t=await $({baseUrl:this.contentGeneratorConfig.baseUrl,fallbackAccessToken:this.contentGeneratorConfig.apiKey,signal:e.config?.abortSignal,channel:this.cliConfig.getChannel?.()}),o=await this.postNativeChat(e,t);if(o.status!==401)return this.assertOkResponse(o);let s;try{s=await $({baseUrl:this.contentGeneratorConfig.baseUrl,fallbackAccessToken:t,forceRefresh:!0,signal:e.config?.abortSignal,channel:this.cliConfig.getChannel?.()})}catch(r){throw new b(r instanceof Error?r.message:String(r))}if(!s||s===t)throw new b("Matilda session expired. Please sign in again.");let a=await x("retry",()=>this.postNativeChat(e,s));return this.assertOkResponse(a)}async postNativeChat(e,t){return fetch(`${K(this.contentGeneratorConfig.baseUrl)}/chat`,{method:"POST",headers:this.buildHeaders(t),body:JSON.stringify(this.buildNativeRequest(e)),signal:e.config?.abortSignal})}async assertOkResponse(e){if(e.ok)return e;let t=`Matilda agent request failed (${e.status}): ${await e.text()}`;throw e.status===401?new b(t):new Error(t)}buildHeaders(e){let t={"Content-Type":"application/json",Accept:"text/event-stream","X-Matilda-API-Version":L,"X-Matilda-Client":"matilda-code","User-Agent":`MatildaCode/${this.cliConfig.getCliVersion?.()||"unknown"}`};for(let[o,s]of Object.entries(this.contentGeneratorConfig.customHeaders??{}))o.toLowerCase()!=="x-matilda-response-mode"&&!F(o)&&(t[o]=s);return U(this.contentGeneratorConfig,e)&&Object.assign(t,I(this.cliConfig),O()),e&&(t.Authorization=`Bearer ${e}`),t}buildNativeRequest(e){let t=this.inferPurpose(e),o=this.clientToolsFromRequest(e),s={messages:this.buildNativeMessages(e,t),responseMode:this.responseModeForPurpose(t)};return o.length>0&&(s.clientTools=o),Y(s)}buildNativeMessages(e,t){let o=this.openAIMessagesFromRequest(e),a=[{role:"user",content:this.buildSystemContext(e,t)}];for(let d of o){if(d.role==="system")continue;let c=this.nativeMessageFromOpenAIMessage(d);c&&a.push(c)}a.length===1&&a.push({role:"user",content:`${this.purposeLabel(t)}:
12
+ (empty prompt)`});let r=a[a.length-1];return r?.role!=="user"?a.push({role:"user",content:`${this.purposeLabel(t)}:
13
+ Continue from the previous assistant response.`}):r.content.startsWith(`${this.purposeLabel(t)}:
14
+ `)||(a[a.length-1]={...r,content:`${this.purposeLabel(t)}:
15
+ ${r.content}`}),a}buildSystemContext(e,t){let o=["Agent: Matilda Code",t==="code"?`Routing intent:
16
+ ${X}`:void 0,`Instructions:
17
+ ${this.instructionsFromRequest(e)}`].filter(s=>!!s);return g(o.join(`
18
+
19
+ `),V)}nativeMessageFromOpenAIMessage(e){let t=this.describeMessage(e);if(t.trim())return{role:e.role==="assistant"?"assistant":"user",content:t}}inferPurpose(e){if(this.contentGeneratorConfig.matildaAgentPurpose)return this.contentGeneratorConfig.matildaAgentPurpose;if(this.contentGeneratorConfig.matildaAgentResponseMode==="instant")return"general";if(this.contentGeneratorConfig.matildaAgentResponseMode==="deep")return"analysis";let o=(this.userMessagesFromRequest(e).at(-1)?.trim()??"").toLowerCase().replace(/\s+/g," ");return/^(hi|hey|hello|thanks|thank you|ok|okay|cool|nice|what'?s up)[.!?]*$/.test(o)||/^(ok|okay)?\s*(let'?s|lets)\s+(code|build|start|get started)[.!?]*$/.test(o)?"general":"code"}responseModeForPurpose(e){return this.contentGeneratorConfig.matildaAgentResponseMode?this.contentGeneratorConfig.matildaAgentResponseMode:e==="general"?H:e==="analysis"?"deep":W}purposeLabel(e){return e==="code"?"Code task":e==="analysis"?"Analysis task":"Task"}instructionsFromRequest(e){let t=this.openAIMessagesFromRequest(e).filter(o=>o.role==="system").map(o=>G(o.content)).filter(o=>o.trim().length>0);return[B,...t,this.localAgentContext()].join(`
20
+
21
+ `)}localAgentContext(){let e=["Local agent context:","- CLI: Matilda Code terminal agent."],t=this.cliConfig.getModel?.();t&&e.push(`- Active model: ${t}`);let o=this.cliConfig.getApprovalMode?.();o&&e.push(`- Approval mode: ${o}`);let s=this.cliConfig.getSandbox?.();e.push(s?`- Sandbox: ${s.command} (${s.image}).`:"- Sandbox: disabled.");let a=[["allow",this.cliConfig.getPermissionsAllow?.()??[]],["ask",this.cliConfig.getPermissionsAsk?.()??[]],["deny",this.cliConfig.getPermissionsDeny?.()??[]]];for(let[l,f]of a)f.length>0&&e.push(`- Permission ${l} rules: ${f.join(", ")}`);let r=this.cliConfig.getIdeMode?.()?"IDE/ACP":this.cliConfig.isInteractive?.()?"interactive TUI":"headless";e.push(`- Interface mode: ${r}`);let d=this.cliConfig.getProjectRoot?.();d&&e.push(`- Project root: ${d}`);let c=this.cliConfig.getWorkingDir?.();c&&c!==d&&e.push(`- Working directory: ${c}`);let i=this.cliConfig.getToolRegistry?.()?.getAllToolNames?.().slice(0,30)??[];return i.length>0&&e.push(`- Local tools available through the CLI loop: ${i.join(", ")}`),e.join(`
22
+ `)}clientToolsFromRequest(e){let t=[];for(let o of e.config?.tools??[])"functionDeclarations"in o&&t.push(...(o.functionDeclarations??[]).filter(s=>!!s.name));return t.map(o=>({name:o.name,...o.description?{description:o.description}:{},...o.parametersJsonSchema?{parameters:o.parametersJsonSchema}:o.parameters?{parameters:o.parameters}:{}}))}userMessagesFromRequest(e){return this.openAIMessagesFromRequest(e).filter(t=>t.role==="user").map(t=>j(t.content)).filter(t=>t.trim().length>0)}openAIMessagesFromRequest(e){let t={model:this.modelFor(e),modalities:this.contentGeneratorConfig.modalities??{},startTime:Date.now(),splitToolMedia:this.contentGeneratorConfig.splitToolMedia??!0};return E.convertGeminiRequestToOpenAI(e,t,{cleanOrphanToolCalls:!1})}describeMessage(e){if(e.role==="user")return`User:
23
+ ${g(j(e.content),v)}`;if(e.role==="assistant"){let t=G(e.content),o="tool_calls"in e&&Array.isArray(e.tool_calls)?e.tool_calls.map(s=>`Tool request: ${s.function.name}(${s.function.arguments})`).join(`
24
+ `):"";return`Assistant:
25
+ ${g([t,o].filter(Boolean).join(`
26
+ `),v)}`}return e.role==="tool"?`Tool result ${e.tool_call_id}:
27
+ ${g(G(e.content),v)}`:""}modelFor(e){return e.model||this.contentGeneratorConfig.model}};function fe(n,e){return new R(n,e)}export{R as MatildaAgentContentGenerator,fe as createMatildaAgentContentGenerator};
28
+ /**
29
+ * @license
30
+ * Copyright 2026 Matilda Team
31
+ * SPDX-License-Identifier: Apache-2.0
32
+ */
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as d,i as u}from"./chunk-WLZF5HVE.js";import"./chunk-QCIDUZV6.js";import"./chunk-ISW2QC5B.js";import"./chunk-2FYDKSRH.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import{d as s}from"./chunk-DC7LAFZZ.js";import"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{k as o}from"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import{c}from"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{Y as i}from"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as a}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";a();var l=class extends u{debugLogger=i("MATILDA");matildaClient;sharedManager;currentToken;constructor(e,t,r){let n=new d(t,r);super(t,r,n),this.matildaClient=e,this.sharedManager=c.getInstance(),t?.baseUrl&&t?.apiKey&&(this.pipeline.client.baseURL=t?.baseUrl,this.pipeline.client.apiKey=t?.apiKey)}getCurrentEndpoint(e){let t=e||s,r="/v1",n=t.startsWith("http")?t:`https://${t}`;return n.endsWith(r)||n.endsWith("/api/v1")||n.endsWith("/api/v1/code")?n:`${n}${r}`}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:r,endpoint:n}=await this.getValidToken();return this.pipeline.client.apiKey=r,this.pipeline.client.baseURL=n,await e()};try{return await t()}catch(r){if(this.isAuthError(r))return await this.sharedManager.getValidCredentials(this.matildaClient,!0),await o("retry",t);throw r}}async generateContent(e,t){return this.executeWithCredentialManagement(()=>super.generateContent(e,t))}async generateContentStream(e,t){return this.executeWithCredentialManagement(()=>super.generateContentStream(e,t))}async countTokens(e){return super.countTokens(e)}async embedContent(e){return this.executeWithCredentialManagement(()=>super.embedContent(e))}isAuthError(e){if(!e)return!1;let t=e instanceof Error?e.message.toLowerCase():String(e).toLowerCase(),r=e,n=r?.status||r?.code;return n===401||n===403||n==="401"||n==="403"||t.includes("unauthorized")||t.includes("forbidden")||t.includes("invalid api key")||t.includes("invalid access token")||t.includes("token expired")||t.includes("authentication")||t.includes("access denied")||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{l as MatildaContentGenerator};
3
+ import{a as d,i as u}from"./chunk-FIUFMVRX.js";import"./chunk-QCIDUZV6.js";import"./chunk-7VE3KGS4.js";import"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import{d as s}from"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{k as o}from"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import{c}from"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{Y as i}from"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as a}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";a();var l=class extends u{debugLogger=i("MATILDA");matildaClient;sharedManager;currentToken;constructor(e,t,r){let n=new d(t,r);super(t,r,n),this.matildaClient=e,this.sharedManager=c.getInstance(),t?.baseUrl&&t?.apiKey&&(this.pipeline.client.baseURL=t?.baseUrl,this.pipeline.client.apiKey=t?.apiKey)}getCurrentEndpoint(e){let t=e||s,r="/v1",n=t.startsWith("http")?t:`https://${t}`;return n.endsWith(r)||n.endsWith("/api/v1")||n.endsWith("/api/v1/code")?n:`${n}${r}`}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:r,endpoint:n}=await this.getValidToken();return this.pipeline.client.apiKey=r,this.pipeline.client.baseURL=n,await e()};try{return await t()}catch(r){if(this.isAuthError(r))return await this.sharedManager.getValidCredentials(this.matildaClient,!0),await o("retry",t);throw r}}async generateContent(e,t){return this.executeWithCredentialManagement(()=>super.generateContent(e,t))}async generateContentStream(e,t){return this.executeWithCredentialManagement(()=>super.generateContentStream(e,t))}async countTokens(e){return super.countTokens(e)}async embedContent(e){return this.executeWithCredentialManagement(()=>super.embedContent(e))}isAuthError(e){if(!e)return!1;let t=e instanceof Error?e.message.toLowerCase():String(e).toLowerCase(),r=e,n=r?.status||r?.code;return n===401||n===403||n==="401"||n==="403"||t.includes("unauthorized")||t.includes("forbidden")||t.includes("invalid api key")||t.includes("invalid access token")||t.includes("token expired")||t.includes("authentication")||t.includes("access denied")||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{l 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{Gh as P,Ih as lt,Rd as rt,Yb as tt,ae as st,fe as L,ge as at,hc as et,kc as ot,lc as A,qc as C,rc as nt,vc as it}from"./chunk-2FYDKSRH.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{g as Z,i as q,p as Y,q as Q}from"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{G as J,Y as K,c as m}from"./chunk-QWBNNEV2.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(`
3
+ import{Gh as P,Ih as lt,Rd as rt,Yb as tt,ae as st,fe as L,ge as at,hc as et,kc as ot,lc as A,qc as C,rc as nt,vc as it}from"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{g as Z,i as q,p as Y,q as Q}from"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{G as J,Y as K,c as m}from"./chunk-QWBNNEV2.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{a as Z}from"./chunk-I55PXD4N.js";import{Kd as D,Ld as Y,Ob as Q,de as y,ja as R,oe as X}from"./chunk-2FYDKSRH.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.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-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{g as $,i as L,p as c,q as x}from"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{A as N,C as T,Y as F,z as _}from"./chunk-QWBNNEV2.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(`
3
+ import{a as Z}from"./chunk-I55PXD4N.js";import{Kd as D,Ld as Y,Ob as Q,de as y,ja as R,oe as X}from"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.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-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{g as $,i as L,p as c,q as x}from"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{A as N,C as T,Y as F,z as _}from"./chunk-QWBNNEV2.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-WLZF5HVE.js";import"./chunk-QCIDUZV6.js";import"./chunk-ISW2QC5B.js";import"./chunk-S4K76QPI.js";import{b as a}from"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import"./chunk-QWBNNEV2.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};
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-FIUFMVRX.js";import"./chunk-QCIDUZV6.js";import"./chunk-7VE3KGS4.js";import"./chunk-S4K76QPI.js";import{c as a}from"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import"./chunk-QWBNNEV2.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};
@@ -1,3 +1,3 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{bj as a,cj as b}from"./chunk-2FYDKSRH.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{b as RipGrepTool,a as _resetRipGrepCachesForTest};
3
+ import{bj as a,cj as b}from"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{b as RipGrepTool,a as _resetRipGrepCachesForTest};
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{b as E}from"./chunk-7ZATDBWL.js";import{wa as P}from"./chunk-2FYDKSRH.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{L as l,Y as c}from"./chunk-QWBNNEV2.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();import{stat as V}from"node:fs/promises";import{join as p}from"node:path";s();import{readdir as N,stat as H,rm as F,rmdir as A}from"node:fs/promises";import{join as y}from"node:path";var k=c("HOUSEKEEPING"),U=24*60*60*1e3,$=60*60*1e3,_=20;function T(e){let t=e>0?e*U:$;return new Date(Date.now()-t)}async function b(e){let t={removed:0,errors:0},r=y(l.getGlobalMatildaDir(),P),i=e.excludeSessionIds??new Set,o;try{o=await N(r,{withFileTypes:!0})}catch(n){return G(n)||k.error("readdir failed",n),t}let a=o.filter(n=>n.isDirectory()&&!i.has(n.name)).map(n=>y(r,n.name));for(let n=0;n<a.length;n+=_){let v=a.slice(n,n+_);await Promise.all(v.map(async g=>{try{(await H(g)).mtime<e.cutoffDate&&(await F(g,{recursive:!0,force:!0}),t.removed++)}catch(w){t.errors++,k.error(`failed to sweep ${g}`,w)}}))}return await A(r).catch(()=>{}),t}function G(e){return e?.code==="ENOENT"}s();import{mkdir as Y,open as K,stat as I,unlink as D,writeFile as j}from"node:fs/promises";import{dirname as B}from"node:path";var m=c("HOUSEKEEPING"),q=24*60*60*1e3,J=60*60*1e3;async function R(e,t){let r=e.minIntervalMs??q,i=e.staleLockMs??J;if(await Y(B(e.lockPath),{recursive:!0,mode:448}).catch(()=>{}),await C(e.markerPath,r,e.name))return!1;let o=await h(e.lockPath);if(!o){try{let a=await I(e.lockPath);Date.now()-a.mtimeMs>i&&(await D(e.lockPath).catch(()=>{}),o=await h(e.lockPath))}catch{o=await h(e.lockPath)}if(!o)return m.debug(`${e.name}: skipping, lock held`),!1}try{if(await C(e.markerPath,r,e.name))return!1;let a=!1;try{await t(),a=!0}finally{if(a)try{await j(e.markerPath,new Date().toISOString())}catch(n){m.debug(`${e.name}: marker write failed (cleanup succeeded)`,n)}}return a}finally{await D(e.lockPath).catch(()=>{m.debug(`${e.name}: lock unlink failed (harmless)`)})}}async function C(e,t,r){try{let i=await I(e),o=Date.now()-i.mtimeMs;if(o<t)return m.debug(`${r}: skipping, ran ${o}ms ago`),!0}catch{}return!1}async function h(e){try{return await(await K(e,"wx")).close(),!0}catch(t){if(t?.code==="EEXIST")return!1;throw t}}var u=c("HOUSEKEEPING"),O=10*60*1e3,W=24*60*60*1e3,X=60*1e3,z=7*24*60*60*1e3,Q=60*1e3,f=".file-history-cleanup",d=!1;function pe(e,t){d||(d=!0,Z(e,t).catch(r=>{d=!1,u.error("scheduleFirstPass failed; chain will retry on next start",r)}))}async function Z(e,t){let r=p(l.getGlobalMatildaDir(),f),i=await L(r)?Q:O;u.debug(`first pass in ${i/1e3}s`),setTimeout(()=>S(e,t),i).unref()}async function L(e){try{let t=await V(e);return Date.now()-t.mtimeMs>z}catch{return!0}}async function M(e,t){if(E()<X){u.debug("user active, deferring 10 min"),setTimeout(()=>S(e,t),O).unref();return}try{await x(e,t)}catch(r){u.error("housekeeping pass failed; will retry next cycle",r)}setTimeout(()=>S(e,t),W).unref()}function S(e,t){M(e,t).catch(r=>{u.error("runPass rejected unexpectedly",r)})}async function x(e,t){let r=t.merged.general?.cleanupPeriodDays??30,i=T(r),o=e.getSessionId(),a=l.getGlobalMatildaDir();await R({name:"file-history-cleanup",markerPath:p(a,f),lockPath:p(a,f+".lock")},async()=>{let n=await b({cutoffDate:i,excludeSessionIds:new Set([o])});u.debug(`file-history: removed=${n.removed} errors=${n.errors}`)})}function Se(){d=!1}var we=L,Pe=x,Ee=M,ye=f;export{ye as _FILE_HISTORY_MARKER_FOR_TESTING,we as _needsCatchUpForTesting,Se as _resetForTesting,Pe as _runHousekeepingForTesting,Ee as _runPassForTesting,pe as startBackgroundHousekeeping};
3
+ import{b as E}from"./chunk-7ZATDBWL.js";import{wa as P}from"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{L as l,Y as c}from"./chunk-QWBNNEV2.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();import{stat as V}from"node:fs/promises";import{join as p}from"node:path";s();import{readdir as N,stat as H,rm as F,rmdir as A}from"node:fs/promises";import{join as y}from"node:path";var k=c("HOUSEKEEPING"),U=24*60*60*1e3,$=60*60*1e3,_=20;function T(e){let t=e>0?e*U:$;return new Date(Date.now()-t)}async function b(e){let t={removed:0,errors:0},r=y(l.getGlobalMatildaDir(),P),i=e.excludeSessionIds??new Set,o;try{o=await N(r,{withFileTypes:!0})}catch(n){return G(n)||k.error("readdir failed",n),t}let a=o.filter(n=>n.isDirectory()&&!i.has(n.name)).map(n=>y(r,n.name));for(let n=0;n<a.length;n+=_){let v=a.slice(n,n+_);await Promise.all(v.map(async g=>{try{(await H(g)).mtime<e.cutoffDate&&(await F(g,{recursive:!0,force:!0}),t.removed++)}catch(w){t.errors++,k.error(`failed to sweep ${g}`,w)}}))}return await A(r).catch(()=>{}),t}function G(e){return e?.code==="ENOENT"}s();import{mkdir as Y,open as K,stat as I,unlink as D,writeFile as j}from"node:fs/promises";import{dirname as B}from"node:path";var m=c("HOUSEKEEPING"),q=24*60*60*1e3,J=60*60*1e3;async function R(e,t){let r=e.minIntervalMs??q,i=e.staleLockMs??J;if(await Y(B(e.lockPath),{recursive:!0,mode:448}).catch(()=>{}),await C(e.markerPath,r,e.name))return!1;let o=await h(e.lockPath);if(!o){try{let a=await I(e.lockPath);Date.now()-a.mtimeMs>i&&(await D(e.lockPath).catch(()=>{}),o=await h(e.lockPath))}catch{o=await h(e.lockPath)}if(!o)return m.debug(`${e.name}: skipping, lock held`),!1}try{if(await C(e.markerPath,r,e.name))return!1;let a=!1;try{await t(),a=!0}finally{if(a)try{await j(e.markerPath,new Date().toISOString())}catch(n){m.debug(`${e.name}: marker write failed (cleanup succeeded)`,n)}}return a}finally{await D(e.lockPath).catch(()=>{m.debug(`${e.name}: lock unlink failed (harmless)`)})}}async function C(e,t,r){try{let i=await I(e),o=Date.now()-i.mtimeMs;if(o<t)return m.debug(`${r}: skipping, ran ${o}ms ago`),!0}catch{}return!1}async function h(e){try{return await(await K(e,"wx")).close(),!0}catch(t){if(t?.code==="EEXIST")return!1;throw t}}var u=c("HOUSEKEEPING"),O=10*60*1e3,W=24*60*60*1e3,X=60*1e3,z=7*24*60*60*1e3,Q=60*1e3,f=".file-history-cleanup",d=!1;function pe(e,t){d||(d=!0,Z(e,t).catch(r=>{d=!1,u.error("scheduleFirstPass failed; chain will retry on next start",r)}))}async function Z(e,t){let r=p(l.getGlobalMatildaDir(),f),i=await L(r)?Q:O;u.debug(`first pass in ${i/1e3}s`),setTimeout(()=>S(e,t),i).unref()}async function L(e){try{let t=await V(e);return Date.now()-t.mtimeMs>z}catch{return!0}}async function M(e,t){if(E()<X){u.debug("user active, deferring 10 min"),setTimeout(()=>S(e,t),O).unref();return}try{await x(e,t)}catch(r){u.error("housekeeping pass failed; will retry next cycle",r)}setTimeout(()=>S(e,t),W).unref()}function S(e,t){M(e,t).catch(r=>{u.error("runPass rejected unexpectedly",r)})}async function x(e,t){let r=t.merged.general?.cleanupPeriodDays??30,i=T(r),o=e.getSessionId(),a=l.getGlobalMatildaDir();await R({name:"file-history-cleanup",markerPath:p(a,f),lockPath:p(a,f+".lock")},async()=>{let n=await b({cutoffDate:i,excludeSessionIds:new Set([o])});u.debug(`file-history: removed=${n.removed} errors=${n.errors}`)})}function Se(){d=!1}var we=L,Pe=x,Ee=M,ye=f;export{ye as _FILE_HISTORY_MARKER_FOR_TESTING,we as _needsCatchUpForTesting,Se as _resetForTesting,Pe as _runHousekeepingForTesting,Ee as _runPassForTesting,pe as startBackgroundHousekeeping};
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{a as Ru}from"./chunk-PA6532AY.js";import{a as wv}from"./chunk-XMZIY7XX.js";import{$a as Zi,Aa as or,B as ns,Ba as an,Ca as ar,D as Iu,Da as Mr,Ea as mt,Fa as cr,Ga as Or,Ha as Dr,Ia as cn,Ja as dn,Ka as un,La as ot,Ma as bv,Na as Ki,Oa as ss,Pa as Mu,Qa as ke,Ra as fe,Sa as Sv,Ta as ln,U as xu,Ua as pn,Va as Ou,W as Tt,Wa as Ji,Xa as Xi,Ya as Yi,Za as Qi,_a as Ev,ab as Mt,bb as Du,cb as Fu,fa as _u,ga as Cu,gb as Lu,ha as Pt,hb as Nu,ia as Tu,ja as zi,ka as Ye,la as wt,na as Pu,oa as ie,pa as nn,qa as sn,ra as sr,sa as Cr,ta as on,ua as Tr,va as bt,wa as St,x as Ui,xa as ir,ya as Pr,za as Gi}from"./chunk-FXQULW2K.js";import{a as Su,b as D,d as Eu}from"./chunk-LYNJBU6H.js";import{a as ku,b as rn,d as Au,e as Vi}from"./chunk-JSFA3NEP.js";import{Ak as ts,Bk as rs,Fh as fu,Ma as kr,Oe as du,Pe as uu,Pj as mu,Qe as lu,Sj as gu,Tj as vu,Uj as yu,_h as yv,ce as iu,ef as Ar,ff as Ve,fk as Hi,hh as pu,hk as wu,ij as tt,je as ou,jj as Zn,lk as bu,oe as Wi,pe as au,qe as cu,wl as Rr,yf as Qn,zk as es}from"./chunk-2FYDKSRH.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import{e as hu}from"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import{b as Yd,e as Qd}from"./chunk-S4K76QPI.js";import"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import{A as Kd,D as Jd,E as Xd,c as Fd,d as $i,e as Bi,f as Yn,h as Ld,j as Nd,k as $d,l as qi,m as _r,r as Bd,s as qd,t as jd,u as Wd,v as Hd,w as Ud,x as Vd,y as zd,z as Gd}from"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import{b as Rd}from"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import{Cb as Md,Eb as Od,Fb as Dd,Y as Td,da as xr,ea as Pd,j as He,t as Cd}from"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import{f as Zd,h as ji,i as eu,j as tu,k as ru,m as nu,r as su}from"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{L as Xn,M as Ad}from"./chunk-QWBNNEV2.js";import{a as ht}from"./chunk-G7R2XEEF.js";import{a as vv}from"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as w}from"./chunk-GZPNIYVZ.js";import{a as se,d as L,f as gv}from"./chunk-OWGSC52X.js";var fn=L((k_,ju)=>{w();var Iv=se("path").relative;ju.exports=Rv;var xv=process.cwd();function Bu(t,e){for(var r=t.split(/[ ,]+/),n=String(e).toLowerCase(),s=0;s<r.length;s++){var i=r[s];if(i&&(i==="*"||i.toLowerCase()===n))return!0}return!1}function _v(t,e,r){var n=Object.getOwnPropertyDescriptor(t,e),s=n.value;return n.get=function(){return s},n.writable&&(n.set=function(o){return s=o}),delete n.value,delete n.writable,Object.defineProperty(t,e,n),n}function kv(t){for(var e="",r=0;r<t;r++)e+=", arg"+r;return e.substr(2)}function Av(t){var e=this.name+": "+this.namespace;this.message&&(e+=" deprecated "+this.message);for(var r=0;r<t.length;r++)e+=`
3
+ import{a as Ru}from"./chunk-PA6532AY.js";import{a as wv}from"./chunk-XMZIY7XX.js";import{$a as Zi,Aa as or,B as ns,Ba as an,Ca as ar,D as Iu,Da as Mr,Ea as mt,Fa as cr,Ga as Or,Ha as Dr,Ia as cn,Ja as dn,Ka as un,La as ot,Ma as bv,Na as Ki,Oa as ss,Pa as Mu,Qa as ke,Ra as fe,Sa as Sv,Ta as ln,U as xu,Ua as pn,Va as Ou,W as Tt,Wa as Ji,Xa as Xi,Ya as Yi,Za as Qi,_a as Ev,ab as Mt,bb as Du,cb as Fu,fa as _u,ga as Cu,gb as Lu,ha as Pt,hb as Nu,ia as Tu,ja as zi,ka as Ye,la as wt,na as Pu,oa as ie,pa as nn,qa as sn,ra as sr,sa as Cr,ta as on,ua as Tr,va as bt,wa as St,x as Ui,xa as ir,ya as Pr,za as Gi}from"./chunk-NPLAJOCA.js";import{a as Su,b as D,d as Eu}from"./chunk-2JIJ6PFL.js";import{a as ku,b as rn,d as Au,e as Vi}from"./chunk-JSFA3NEP.js";import{Ck as es,Dk as ts,Ek as rs,Fh as fu,Ma as kr,Oe as du,Pe as uu,Pj as mu,Qe as lu,Sj as gu,Tj as vu,Uj as yu,_h as yv,ce as iu,ef as Ar,ff as Ve,fk as Hi,hh as pu,hk as wu,ij as tt,je as ou,jj as Zn,lk as bu,oe as Wi,pe as au,qe as cu,yf as Qn,zl as Rr}from"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import{e as hu}from"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import{b as Yd,e as Qd}from"./chunk-S4K76QPI.js";import"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import{A as Ud,B as Vd,C as zd,D as Gd,E as Kd,H as Jd,I as Xd,g as Fd,h as $i,i as Bi,j as Yn,l as Ld,n as Nd,o as $d,p as qi,q as _r,v as Bd,w as qd,x as jd,y as Wd,z as Hd}from"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import{b as Rd}from"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import{Cb as Md,Eb as Od,Fb as Dd,Y as Td,da as xr,ea as Pd,j as He,t as Cd}from"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import{f as Zd,h as ji,i as eu,j as tu,k as ru,m as nu,r as su}from"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{L as Xn,M as Ad}from"./chunk-QWBNNEV2.js";import{a as ht}from"./chunk-G7R2XEEF.js";import{a as vv}from"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as w}from"./chunk-GZPNIYVZ.js";import{a as se,d as L,f as gv}from"./chunk-OWGSC52X.js";var fn=L((k_,ju)=>{w();var Iv=se("path").relative;ju.exports=Rv;var xv=process.cwd();function Bu(t,e){for(var r=t.split(/[ ,]+/),n=String(e).toLowerCase(),s=0;s<r.length;s++){var i=r[s];if(i&&(i==="*"||i.toLowerCase()===n))return!0}return!1}function _v(t,e,r){var n=Object.getOwnPropertyDescriptor(t,e),s=n.value;return n.get=function(){return s},n.writable&&(n.set=function(o){return s=o}),delete n.value,delete n.writable,Object.defineProperty(t,e,n),n}function kv(t){for(var e="",r=0;r<t;r++)e+=", arg"+r;return e.substr(2)}function Av(t){var e=this.name+": "+this.namespace;this.message&&(e+=" deprecated "+this.message);for(var r=0;r<t.length;r++)e+=`
4
4
  at `+t[r].toString();return e}function Rv(t){if(!t)throw new TypeError("argument namespace is required");var e=os(),r=Fr(e[1]),n=r[0];function s(i){is.call(s,i)}return s._file=n,s._ignored=Tv(t),s._namespace=t,s._traced=Pv(t),s._warned=Object.create(null),s.function=Fv,s.property=Lv,s}function Cv(t,e){var r=typeof t.listenerCount!="function"?t.listeners(e).length:t.listenerCount(e);return r>0}function Tv(t){if(process.noDeprecation)return!0;var e=process.env.NO_DEPRECATION||"";return Bu(e,t)}function Pv(t){if(process.traceDeprecation)return!0;var e=process.env.TRACE_DEPRECATION||"";return Bu(e,t)}function is(t,e){var r=Cv(process,"deprecation");if(!(!r&&this._ignored)){var n,s,i,o,a=0,c=!1,d=os(),u=this._file;for(e?(o=e,i=Fr(d[1]),i.name=o.name,u=i[0]):(a=2,o=Fr(d[a]),i=o);a<d.length;a++)if(n=Fr(d[a]),s=n[0],s===u)c=!0;else if(s===this._file)u=this._file;else if(c)break;var l=n?o.join(":")+"__"+n.join(":"):void 0;if(!(l!==void 0&&l in this._warned)){this._warned[l]=!0;var p=t;if(p||(p=i===o||!i.name?$u(o):$u(i)),r){var f=qu(this._namespace,p,d.slice(a));process.emit("deprecation",f);return}var g=process.stderr.isTTY?Ov:Mv,v=g.call(this,p,n,d.slice(a));process.stderr.write(v+`
5
5
  `,"utf8")}}}function Fr(t){var e=t.getFileName()||"<anonymous>",r=t.getLineNumber(),n=t.getColumnNumber();t.isEval()&&(e=t.getEvalOrigin()+", "+e);var s=[e,r,n];return s.callSite=t,s.name=t.getFunctionName(),s}function $u(t){var e=t.callSite,r=t.name;r||(r="<anonymous@"+eo(t)+">");var n=e.getThis(),s=n&&e.getTypeName();return s==="Object"&&(s=void 0),s==="Function"&&(s=n.name||s),s&&e.getMethodName()?s+"."+r:r}function Mv(t,e,r){var n=new Date().toUTCString(),s=n+" "+this._namespace+" deprecated "+t;if(this._traced){for(var i=0;i<r.length;i++)s+=`
6
6
  at `+r[i].toString();return s}return e&&(s+=" at "+eo(e)),s}function Ov(t,e,r){var n="\x1B[36;1m"+this._namespace+"\x1B[22;39m \x1B[33;1mdeprecated\x1B[22;39m \x1B[0m"+t+"\x1B[39m";if(this._traced){for(var s=0;s<r.length;s++)n+=`
@@ -1,3 +1,3 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{re as a,se as b,te as c,ue as d,ve as e,we as f,xe as g}from"./chunk-2FYDKSRH.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{b as OUTPUT_UPDATE_INTERVAL_MS,g as ShellTool,f as ShellToolInvocation,c as buildLongRunningForegroundHint,d as detectBlockedSleepPattern,a as parseNumstat,e as repairLeakedShellToolArgMarkup};
3
+ import{re as a,se as b,te as c,ue as d,ve as e,we as f,xe as g}from"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{b as OUTPUT_UPDATE_INTERVAL_MS,g as ShellTool,f as ShellToolInvocation,c as buildLongRunningForegroundHint,d as detectBlockedSleepPattern,a as parseNumstat,e as repairLeakedShellToolArgMarkup};
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{c as p,d as C,f as E,g as I}from"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-2XZIKUB6.js";import{kc as o,ld as a}from"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{g as S,i as v,p as y,q as b}from"./chunk-5U3A6KMU.js";import"./chunk-IOCF4XSR.js";import{Y as f}from"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as u}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";u();import L from"path";var r=f("SKILL"),$=`Execute a skill within the main conversation
3
+ import{c as p,d as C,f as E,g as I}from"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-7VBRP4XQ.js";import{kc as o,ld as a}from"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{g as S,i as v,p as y,q as b}from"./chunk-5U3A6KMU.js";import"./chunk-IOCF4XSR.js";import{Y as f}from"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as u}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";u();import L from"path";var r=f("SKILL"),$=`Execute a skill within the main conversation
4
4
 
5
5
  <skills_instructions>
6
6
  When users ask you to perform tasks, check if any of the available skills can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.
@@ -0,0 +1,3 @@
1
+ // Force strict mode and setup for ESM
2
+ "use strict";
3
+ import{$ as oi,$a as oj,$b as qk,$c as pl,$d as jm,$e as Tm,$f as ap,$g as bq,$h as br,$j as $s,$k as $t,A as Yg,Aa as Pi,Ab as Tj,Ac as Qk,Ad as Ql,Ae as vm,Ag as Cp,Ah as Eq,Ai as zr,Aj as As,Ak as At,Al as zu,B as Zg,Ba as Qi,Bb as Uj,Bc as Rk,Bd as Rl,Be as wm,Bg as Dp,Bh as Fq,Bi as Ar,Bj as Bs,Bk as Bt,Bl as Au,C as _g,Ca as Ri,Cb as Vj,Cc as Sk,Cd as Sl,Ce as xm,Cg as Ep,Ch as Gq,Ci as Br,Cj as Cs,Ck as Ct,Cl as Bu,D as $g,Da as Si,Db as Wj,Dc as Tk,Dd as Tl,De as ym,Dg as Fp,Dh as Hq,Di as Cr,Dj as Ds,Dk as Dt,Dl as Cu,E as ah,Ea as Ti,Eb as Xj,Ec as Uk,Ed as Ul,Ee as zm,Eg as Gp,Eh as Iq,Ei as Dr,Ej as Es,Ek as Et,El as Du,F as bh,Fa as Ui,Fb as Yj,Fc as Vk,Fd as Vl,Fe as Am,Ff as Cn,Fg as Hp,Fh as Jq,Fi as Er,Fj as Fs,Fk as Ft,Fl as Eu,G as ch,Ga as Vi,Gb as Zj,Gc as Wk,Gd as Wl,Ge as Bm,Gf as Dn,Gg as Ip,Gh as Kq,Gi as Fr,Gj as Gs,Gk as Gt,Gl as Fu,H as dh,Ha as Wi,Hb as _j,Hc as Xk,Hd as Xl,He as Cm,Hf as En,Hg as Jp,Hh as Lq,Hi as Gr,Hj as Hs,Hk as Ht,Hl as Gu,Ia as Xi,Ib as $j,Ic as Yk,Id as Yl,Ie as Dm,If as Fn,Ig as Kp,Ih as Mq,Ii as Hr,Ij as Is,Ik as It,Il as Hu,J as eh,Ja as Yi,Jb as ak,Jc as Zk,Jd as Zl,Je as Em,Jf as Gn,Jg as Lp,Jh as Nq,Ji as Ir,Jj as Js,Jk as Jt,Jl as Iu,K as fh,Ka as Zi,Kb as bk,Kc as _k,Ke as Fm,Kf as Hn,Kg as Mp,Kh as Oq,Ki as Jr,Kj as Ks,Kk as Kt,L as gh,La as _i,Lb as ck,Lc as $k,Le as Gm,Lf as In,Lg as Np,Lh as Pq,Li as Kr,Lj as Ls,Lk as Lt,M as $h,Ma as $i,Mb as dk,Mc as al,Md as _l,Me as Hm,Mf as Jn,Mg as Op,Mh as Qq,Mi as Lr,Mj as Ms,Mk as Mt,N as ai,Na as aj,Nb as ek,Nc as bl,Nd as $l,Ne as Im,Nf as Kn,Ng as Pp,Nh as Rq,Ni as Mr,Nj as Ns,Nk as Nt,O as bi,Oa as bj,Oc as cl,Of as Ln,Og as Qp,Oh as Sq,Oi as Nr,Oj as Os,Ok as Ot,P as ci,Pa as cj,Pb as fk,Pc as dl,Pf as Mn,Pg as Rp,Ph as Tq,Pi as Or,Pj as Ps,Pk as Pt,Q as di,Qa as dj,Qb as gk,Qc as el,Qf as Nn,Qg as Sp,Qh as Uq,Qi as Pr,Qj as Qs,Qk as Qt,R as ei,Ra as ej,Rb as hk,Rc as fl,Re as Jm,Rf as On,Rg as Tp,Rh as Vq,Ri as Qr,Rj as Rs,Rk as Rt,S as fi,Sa as fj,Sb as ik,Sc as gl,Sd as am,Se as Km,Sf as Wn,Sg as Up,Sh as Wq,Si as Rr,Sj as Ss,Sk as St,T as gi,Ta as gj,Tb as jk,Tc as hl,Td as bm,Te as Lm,Tf as Xn,Tg as Vp,Th as Xq,Ti as Sr,Tj as Ts,Tk as Tt,U as hi,Ua as hj,Ub as kk,Uc as il,Ud as cm,Ue as Mm,Uf as Vo,Ug as Wp,Uh as Yq,Ui as Tr,Uj as Us,Uk as Ut,V as ii,Va as ij,Vb as lk,Vc as jl,Vd as dm,Ve as Nm,Vf as Wo,Vg as Xp,Vh as Zq,Vi as Ur,Vj as Vs,Vk as Vt,W as ji,Wa as jj,Wb as mk,Wc as kl,Wd as em,We as Om,Wf as Xo,Wg as Yp,Wh as _q,Wi as Vr,Wj as Ws,Wk as Wt,X as ki,Xa as kj,Xb as nk,Xc as ll,Xd as fm,Xe as Pm,Xf as Yo,Xg as Zp,Xh as $q,Xi as Wr,Xj as Xs,Xk as Xt,Y as li,Ya as lj,Yc as ml,Yd as gm,Ye as Qm,Yf as Zo,Yg as _p,Yh as ar,Yi as Xr,Yj as Ys,Yk as Yt,Z as mi,Za as mj,Zb as ok,Zc as nl,Zd as hm,Ze as Rm,Zf as _o,Zg as $p,Zi as Yr,Zj as Zs,Zk as Zt,_ as ni,_a as nj,_b as pk,_c as ol,_d as im,_e as Sm,_f as $o,_g as aq,_i as Zr,_j as _s,_k as _t,a as qa,aa as pi,ab as pj,ac as rk,ad as ql,af as Um,ag as bp,ah as cq,ai as cr,ak as at,al as au,b as ra,ba as qi,bb as qj,bc as sk,bd as rl,be as km,bf as dn,bg as cp,bh as dq,bi as dr,bj as _r,bk as bt,bl as bu,c as sa,ca as ri,cb as rj,cc as tk,cd as sl,ce as lm,cf as en,cg as dp,ch as eq,ci as er,cj as $r,ck as ct,cl as cu,d as ta,da as si,db as sj,dc as uk,dd as tl,df as fn,dg as ep,dh as fq,di as fr,dj as as,dk as dt,dl as du,e as ua,ea as ti,eb as tj,ed as ul,ef as gn,eg as fp,eh as gq,ei as gr,ej as bs,ek as et,el as eu,f as va,fa as vi,fb as uj,fc as vk,fd as vl,ff as hn,fg as gp,fh as hq,fi as hr,fj as cs,fk as ft,fl as fu,g as wa,ga as wi,gb as vj,gc as wk,gd as wl,gf as jn,gg as hp,gh as iq,gi as ir,gj as ds,gk as gt,gl as gu,h as xa,ha as xi,hb as wj,hc as xk,hd as xl,hf as kn,hg as ip,hh as jq,hi as jr,hj as hs,hk as ht,hl as hu,i as ya,ia as yi,ib as xj,ic as yk,id as yl,if as ln,ig as jp,ih as kq,ii as kr,ij as is,ik as it,il as iu,j as Hg,jb as yj,jc as zk,jd as zl,jf as mn,jg as kp,jh as lq,ji as lr,jj as js,jk as jt,jl as ju,k as Ig,ka as zi,kb as zj,kc as Ak,kd as Al,ke as mm,kf as nn,kg as lp,kh as mq,ki as mr,kj as ks,kk as kt,kl as ku,l as Jg,la as Ai,lb as Cj,lc as Bk,ld as Bl,le as nm,lf as on,lg as mp,lh as nq,li as nr,lj as ls,lk as lt,ll as lu,m as Kg,ma as Bi,mb as Fj,mc as Ck,md as Cl,me as om,mf as pn,mg as np,mh as oq,mj as ms,mk as mt,ml as mu,n as Lg,na as Ci,nb as Gj,nc as Dk,nd as Dl,ne as pm,nf as qn,ng as op,nh as pq,ni as or,nj as ns,nk as nt,nl as nu,o as Mg,oa as Di,ob as Hj,oc as Ek,od as El,oe as qm,of as rn,og as pp,oh as qq,oi as pr,oj as os,ok as ot,p as Ng,pa as Ei,pb as Ij,pc as Fk,pd as Fl,pe as rm,pf as sn,pg as qp,ph as rq,pi as qr,pj as ps,pk as pt,pl as ou,q as Og,qa as Fi,qb as Jj,qc as Gk,qd as Gl,qe as sm,qf as tn,qg as rp,qh as sq,qi as rr,qj as qs,qk as qt,ql as pu,r as Pg,ra as Gi,rb as Kj,rc as Hk,rd as Hl,rf as un,rg as sp,rh as tq,ri as sr,rj as rs,rk as rt,rl as qu,s as Qg,sa as Hi,sb as Lj,sc as Ik,sd as Il,sf as vn,sg as tp,sh as uq,si as tr,sj as ss,sk as st,sl as ru,t as Rg,ta as Ii,tb as Mj,tc as Jk,td as Jl,tf as wn,tg as up,th as vq,ti as ur,tj as ts,tk as tt,tl as su,u as Sg,ua as Ji,ub as Nj,uc as Kk,ud as Kl,uf as xn,ug as vp,uh as wq,uj as us,uk as ut,ul as tu,v as Tg,va as Ki,vb as Oj,vc as Lk,vd as Ll,vf as yn,vg as wp,vh as xq,vj as vs,vk as vt,vl as uu,w as Ug,wa as Li,wb as Pj,wc as Mk,wd as Ml,wf as zn,wg as xp,wh as Aq,wi as vr,wj as ws,wk as wt,wl as vu,x as Vg,xa as Mi,xb as Qj,xc as Nk,xd as Nl,xf as An,xg as yp,xh as Bq,xi as wr,xj as xs,xk as xt,xl as wu,y as Wg,ya as Ni,yb as Rj,yc as Ok,yd as Ol,ye as tm,yf as Bn,yg as zp,yh as Cq,yi as xr,yj as ys,yk as yt,yl as xu,z as Xg,za as Oi,zb as Sj,zc as Pk,zd as Pl,ze as um,zg as Bp,zh as Dq,zi as yr,zj as zs,zk as zt,zl as yu}from"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import{a as Yn,b as Zn,c as _n,d as $n,e as ao,f as wo,g as xo,h as yo,i as zo,j as Ao,k as Bo,l as Co,m as Do}from"./chunk-FUNLOUYI.js";import{a as Eo,b as Fo,c as Go,d as Ho,e as Io,f as Jo,g as Ko,h as Lo,i as Mo,j as No,k as Oo,l as Po,m as Qo,n as Ro,o as So,p as To,q as Uo}from"./chunk-R3H6IWFK.js";import{a as bo,b as co,c as eo,d as fo,e as go,f as ho,g as io,h as jo,i as ko,j as lo,k as mo,l as no,m as oo,n as po,o as qo,p as ro,q as so,r as to,s as uo,t as vo}from"./chunk-OMZ5SGMK.js";import{a as ui}from"./chunk-GIIMOLLN.js";import{c as es,e as fs,f as gs}from"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import{b as hh,c as ih,d as jh,e as kh,f as lh,g as mh,h as nh,i as oh,j as ph,k as qh,l as rh,m as sh,n as th,o as Th,p as Uh,q as Vh,r as Wh,s as Xh,t as Yh,u as Zh,v as _h}from"./chunk-SS5WUOSJ.js";import{a as yq,b as zq}from"./chunk-47XR7IMP.js";import{b as Ap}from"./chunk-QEI3OETI.js";import{a as Vm,b as Wm,c as Xm,d as Ym,e as Zm,f as _m,g as $m,h as an,i as bn,j as cn,k as Pn,l as Qn,m as Rn,n as Sn,o as Tn,p as Un,q as Vn}from"./chunk-QKYGQLWC.js";import{c as Dj,f as Ej}from"./chunk-MNGFXISD.js";import{a as uh,b as vh,c as wh,d as xh,e as yh,f as zh,g as Ah,h as Bh,i as Ch,j as Dh,k as Eh,l as Fh,m as Gh,n as Hh,o as Ih,p as Jh,q as Kh,r as Lh,s as Mh,t as Nh,u as Oh,v as Ph,w as Qh,x as Rh,y as Sh}from"./chunk-4R2OFVPK.js";import{a as Aj,b as Bj}from"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import{b as cg,d as dg,e as eg,g as fg,h as gg,i as hg,j as ig,k as jg}from"./chunk-S4K76QPI.js";import{A as Pf,B as Qf,C as Cg,D as Dg,E as Eg,F as Fg,G as Gg,e as ue,f as ve,g as we,i as yf,j as zf,k as Af,n as Bf,p as Cf,q as Df,r as Ef,s as Hf,t as If,u as Jf,v as Kf,w as Lf,x as Mf,y as Nf,z as Of}from"./chunk-OVZKSZIR.js";import{a as ff,b as gf,c as hf,d as jf}from"./chunk-4F4DA5UI.js";import{a as uf,e as vf,f as wf,g as xf}from"./chunk-DC7LAFZZ.js";import{A as Ye,B as Ze,C as _e,D as $e,E as af,F as bf,G as cf,H as df,I as ef,a as qe,b as re,c as se,d as te,e as Ce,f as De,g as Ee,h as Fe,i as Ge,j as He,k as Ie,l as Je,m as Ke,n as Le,o as Me,p as Ne,q as Oe,r as Pe,s as Qe,t as Re,u as Se,v as Te,w as Ue,x as Ve,y as We,z as Xe}from"./chunk-7VBRP4XQ.js";import{c as xe,d as ye,e as ze,f as Ae,g as Be,h as kf,i as lf,j as mf,k as nf,l as of,m as pf,n as qf,o as rf,p as sf,q as tf}from"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import{b as Rf,c as Sf,d as Tf,e as Uf,f as Vf,g as Wf,h as Xf,i as Yf,j as Zf,k as _f,l as $f,m as ag,n as bg}from"./chunk-XJDC3ZQZ.js";import{$ as cb,A as Qa,Aa as Cb,Ab as uc,B as Ra,Ba as Db,Bb as vc,C as Sa,Ca as Eb,Cb as wc,Cc as Ed,D as Ta,Da as Fb,Db as xc,Dc as Fd,E as Ua,Ea as Gb,Eb as yc,Ec as Gd,F as Va,Fa as Hb,Fb as zc,Fc as Hd,G as Wa,Ga as Ib,Gb as Ac,Gc as Id,H as Xa,Ha as Jb,Hb as Bc,Hc as Jd,I as Ya,Ia as Kb,Ib as Cc,Ic as Kd,Ja as Lb,Jb as Dc,Jc as Ld,Ka as Mb,Kb as Ec,Kc as Md,La as Nb,Lc as Nd,Ma as Ob,Mb as Fc,Mc as Od,Na as Pb,Nb as Gc,Nc as Pd,Ob as Hc,Oc as Qd,Pb as Ic,Pc as Rd,Qa as Qb,Qb as Jc,Rb as Kc,Sc as Sd,Ta as Rb,Tc as Td,Ua as Sb,Ub as Lc,Uc as Ud,Va as Tb,Vb as Mc,Vc as Vd,W as Za,Wa as Ub,Wb as Nc,Wc as Wd,X as _a,Xa as Vb,Xb as Oc,Xc as Xd,Y as $a,Ya as Wb,Yb as Pc,Yc as Yd,Z as ab,Za as Xb,Zb as Qc,Zc as Zd,_ as bb,_a as Yb,aa as db,ab as Zb,b as _,ba as eb,bb as _b,c as $,ca as fb,cb as $b,cc as Rc,cd as _d,d as aa,da as gb,db as ac,dd as $d,e as na,ea as hb,eb as bc,ec as Sc,ed as ae,fa as ib,fb as cc,fc as Tc,g as oa,ga as jb,gb as dc,gc as Uc,gd as be,h as pa,ha as kb,hb as ec,hc as Vc,hd as ce,ia as lb,ib as fc,ic as Wc,ja as mb,jb as gc,jc as Xc,jd as de,ka as nb,kb as hc,kc as Yc,la as ob,lb as ic,lc as Zc,ld as ee,ma as pb,mb as jc,mc as _c,md as fe,n as Da,nb as kc,nc as $c,nd as ge,o as Ea,oa as qb,ob as lc,oc as ad,od as he,p as Fa,pa as rb,pb as mc,pc as bd,pd as ie,q as Ga,qa as sb,qb as nc,qc as cd,qd as je,r as Ha,ra as tb,rb as oc,rc as dd,rd as ke,s as Ia,sa as ub,sb as pc,sc as ed,sd as le,t as Ja,ta as vb,tc as fd,td as me,u as Ka,ua as wb,ud as ne,v as La,va as xb,vd as oe,w as Ma,wa as yb,wb as qc,wc as Dd,wd as pe,x as Na,xa as zb,xb as rc,y as Oa,ya as Ab,yb as sc,z as Pa,za as Bb,zb as tc}from"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{a as gd,b as hd,c as id,d as jd,e as kd,f as ld,g as md,h as nd,i as od,j as pd,k as qd,l as rd,m as sd,n as td,o as ud,p as vd,q as wd,r as xd,s as yd,t as zd,u as Ad,v as Bd,w as Cd}from"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{a as ba,e as ca,f as da,g as ea,h as fa,i as ga,j as ha,k as ia,l as ja,m as ka,n as la,o as ma,p as za,q as Aa,r as Ba,s as Ca}from"./chunk-5U3A6KMU.js";import{a as kg,b as lg,d as mg,e as ng,f as og,g as pg,h as qg,i as rg,j as sg,k as tg,l as ug,m as vg,n as wg,o as xg,p as yg,q as zg,r as Ag,t as Bg}from"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import{a as Ff,b as Gf}from"./chunk-3YLXGE6T.js";import{a as V,b as W,c as X,d as Y,e as Z}from"./chunk-IOCF4XSR.js";import{A,B,C,D,E,F,G,H,I,J,L as K,M as L,Q as O,R as P,U as Q,V as R,W as S,X as T,Y as U,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import{c as M,g as N}from"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{Ea as AGENT_CONTEXT_FILENAME,sn as AGENT_WORKTREE_HEX_LENGTH,rn as AGENT_WORKTREE_PREFIX,tn as AGENT_WORKTREE_SLUG_PATTERN,ft as ALL_PROVIDERS,is as APPROVAL_MODES,ks as APPROVAL_MODE_INFO,qa as ARENA_MAX_AGENTS,kd as AUTO_MEMORY_CONSOLIDATION_LOCK_FILENAME,gd as AUTO_MEMORY_DIRNAME,jd as AUTO_MEMORY_EXTRACT_CURSOR_FILENAME,hd as AUTO_MEMORY_INDEX_FILENAME,id as AUTO_MEMORY_METADATA_FILENAME,gk as AUTO_MEMORY_SCHEMA_VERSION,fk as AUTO_MEMORY_TYPES,ul as AUTO_MODE_DENIAL_LIMITS,np as AUTO_SKILL_THRESHOLD,ou as AbortError,fn as AgentCore,Rm as AgentEventEmitter,Qm as AgentEventType,Um as AgentHeadless,Gn as AgentInteractive,da as AgentStatistics,ua as AgentStatus,ta as AgentTerminateMode,Rh as AgentType,Nd as ApiCancelEvent,Md as ApiErrorEvent,Ld as ApiRequestEvent,pb as ApiRequestPhase,Od as ApiResponseEvent,hs as ApprovalMode,ya as ArenaAgentClient,Kn as ArenaEventEmitter,Jn as ArenaEventType,On as ArenaManager,ra as ArenaSessionStatus,Fn as AsyncMessageQueue,de as AuthEvent,ss as AuthProviderType,Cg as AuthType,Yo as BACKGROUND_AGENT_CONCURRENCY_ENV,pn as BASELINE_COMMIT_MESSAGE,Ta as BINARY_EXTENSIONS,La as BINARY_FILE_PATTERNS,yu as BTW_MAX_INPUT_LENGTH,dq as BUNDLE_CHUNK_DIR,dp as BackgroundAgentResumeService,Qq as BackgroundShellRegistry,bp as BackgroundTaskRegistry,q as BadRequestError,ga as BaseDeclarativeTool,ea as BaseToolInvocation,tq as BudgetExhaustedError,Bn as BuiltinAgentRegistry,mf as CAPPED_DEFAULT_MAX_TOKENS,St as CODE_ACTION_KIND_LABELS,Jk as COMMAND_SUBSTITUTION_WARNING,Na as COMMON_DIRECTORY_EXCLUDES,Ka as COMMON_IGNORE_PATTERNS,ma as CONCURRENCY_SAFE_KINDS,ct as CUSTOM_API_KEY_ENV_PREFIX,ij as ChatRecordingService,Im as CloseDiffRequestSchema,em as ColorMode,mj as CompressionStatus,Or as ConditionalRulesRegistry,ts as Config,Sm as ContextState,Yd as ConversationFinishedEvent,Pm as CoreToolScheduler,pg as CredentialsClearRequiredError,wp as CronScheduler,Fe as DAEMON_TRACEPARENT_META_KEY,Ge as DAEMON_TRACESTATE_META_KEY,op as DEFAULT_AUTO_DREAM_MIN_HOURS,pp as DEFAULT_AUTO_DREAM_MIN_SESSIONS,cp as DEFAULT_BACKGROUND_AGENT_CONTINUATION_MESSAGE,An as DEFAULT_BUILTIN_SUBAGENT_TYPE,Da as DEFAULT_CONTEXT_FILENAME,Za as DEFAULT_ENCODING,Qa as DEFAULT_FILE_EXCLUDES,Bj as DEFAULT_FILE_FILTERING_OPTIONS,Kt as DEFAULT_LSP_COMMAND_CHECK_TIMEOUT_MS,Jt as DEFAULT_LSP_DOCUMENT_OPEN_DELAY_MS,Mt as DEFAULT_LSP_DOCUMENT_RETRY_DELAY_MS,Nt as DEFAULT_LSP_MAX_RESTARTS,Ht as DEFAULT_LSP_REQUEST_TIMEOUT_MS,Pt as DEFAULT_LSP_SOCKET_MAX_RETRY_DELAY_MS,Ot as DEFAULT_LSP_SOCKET_RETRY_DELAY_MS,Gt as DEFAULT_LSP_STARTUP_TIMEOUT_MS,It as DEFAULT_LSP_WARMUP_DELAY_MS,Lt as DEFAULT_LSP_WORKSPACE_SYMBOL_WARMUP_DELAY_MS,hf as DEFAULT_MATILDA_EMBEDDING_MODEL,gf as DEFAULT_MATILDA_FLASH_MODEL,ff as DEFAULT_MATILDA_MODEL,Xo as DEFAULT_MAX_CONCURRENT_BACKGROUND_AGENTS,ws as DEFAULT_MAX_INLINE_MEDIA_BYTES,Aj as DEFAULT_MEMORY_FILE_FILTERING_OPTIONS,ef as DEFAULT_OTLP_ENDPOINT,lf as DEFAULT_OUTPUT_TOKEN_LIMIT,ls as DEFAULT_PR_ATTRIBUTION_MESSAGE,$h as DEFAULT_STOP_HOOK_BLOCK_CAP,df as DEFAULT_TELEMETRY_TARGET,kf as DEFAULT_TOKEN_LIMIT,os as DEFAULT_TOOL_OUTPUT_BATCH_BUDGET,gh as DEFAULT_TOOL_RESULTS_TOTAL_CHARS_THRESHOLD,ns as DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,ms as DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,Rt as DIAGNOSTIC_SEVERITY_LABELS,Cn as DISPLAY_MODE,lp as DREAM_TASK_TYPE,fa as DeclarativeTool,Dh as DefaultHookOutput,Ed as DiscoveredMCPTool,wq as DiscoveredTool,nf as ESCALATED_MAX_TOKENS,$ as EVENT_API_ERROR,aa as EVENT_API_RESPONSE,_ as EVENT_TOOL_CALL,dn as EXCLUDED_TOOLS_FOR_SUBAGENTS,Vq as EXTENSIONS_CONFIG_FILENAME,Uq as EXTENSIONS_DIRECTORY_NAME,Xq as EXTENSION_SETTINGS_FILENAME,en as EXTERNAL_MESSAGE_PREFIX,kp as EXTRACT_TASK_TYPE,Hd as EndSessionEvent,ke as ExtensionDisableEvent,be as ExtensionEnableEvent,_d as ExtensionInstallEvent,Dr as ExtensionManager,vr as ExtensionSettingScope,ae as ExtensionUninstallEvent,Cr as ExtensionUpdateState,Li as FILE_HISTORY_DIR,jn as FORK_SUBAGENT_TYPE,g as FatalAuthenticationError,m as FatalBudgetExceededError,n as FatalCancellationError,j as FatalConfigError,f as FatalError,h as FatalInputError,i as FatalSandboxError,l as FatalToolExecutionError,k as FatalTurnLimitedError,xn as FileDiscoveryService,mm as FileEncoding,Ra as FileExclusions,Oi as FileHistoryService,lb as FileOperation,Tq as FileReadCache,Bm as FileSchema,qu as FileSearchFactory,Pd as FlashFallbackEvent,o as ForbiddenError,Wh as GOAL_HOOK_TIMEOUT_MS,Vh as GOAL_HOOK_TIMEOUT_SECONDS,t as GOOGLE_ACCOUNTS_FILENAME,ck as GeminiChat,vp as GeminiClient,lj as GeminiEventType,wn as GitIgnoreParser,vn as GitWorktreeService,xh as HOOKS_CONFIG_FIELDS,vh as HookEventName,wh as HookPhase,Ir as HookRegistry,Kr as HookSystem,yh as HookType,uh as HooksConfigSource,Jm as IDEConnectionStatus,tm as IDE_DEFINITIONS,wm as IDE_MAX_OPEN_FILES,xm as IDE_MAX_SELECTED_TEXT_LENGTH,ym as IDE_REQUEST_TIMEOUT_MS,ju as IDLE_SPECULATION,Un as INBOXES_DIR,au as INITIAL_FOLLOWUP_STATE,Wq as INSTALL_METADATA_FILENAME,En as ITermBackend,Km as IdeClient,Xd as IdeConnectionEvent,Wd as IdeConnectionType,Dm as IdeContextNotificationSchema,Cm as IdeContextSchema,zm as IdeContextStore,Em as IdeDiffAcceptedNotificationSchema,Gm as IdeDiffClosedNotificationSchema,Fm as IdeDiffRejectedNotificationSchema,gs as Ignore,Hn as InProcessBackend,yq as InputFormat,qq as InvalidMcpConfigError,ak as InvalidStreamError,us as JsonFormatter,Ap as KeychainTokenStorage,ka as Kind,Zd as KittySequenceOverflowEvent,Qn as LEADER_NAME,Ti as LITE_READ_BUF_SIZE,Fa as LOCAL_CONTEXT_FILENAME,Is as Logger,Rd as LoopType,Tt as LspConfigLoader,Ut as LspConnectionFactory,Vt as LspResponseNormalizer,Wt as LspServerManager,jf as MAINLINE_CODER_MODEL,na as MAIN_SOURCE,uf as MATILDA_API_KEY_ENV_KEY,vm as MATILDA_CODE_COMPANION_EXTENSION_NAME,At as MATILDA_CODE_SIMPLE_ENV_VAR,zg as MATILDA_CREDENTIAL_FILE_MODE,s as MATILDA_DIR,Bf as MATILDA_OAUTH_MODELS,rc as MATILDA_SESSION_ID_HASH_ATTR,qc as MATILDA_USER_ID_HASH_ATTR,_o as MAX_CONCURRENT_BACKGROUND_AGENTS,Kq as MAX_CONCURRENT_MONITORS,Ai as MAX_DIFF_SIZE_BYTES,zi as MAX_FILES,Ci as MAX_FILES_FOR_DETAILS,Uh as MAX_GOAL_ITERATIONS,Bi as MAX_LINES_PER_FILE,Oq as MAX_NOTIFICATION_OUTPUT_TAIL_BYTES,$o as MAX_RETAINED_TERMINAL_AGENTS,Lq as MAX_RETAINED_TERMINAL_MONITORS,Pq as MAX_RETAINED_TERMINAL_SHELLS,Rq as MAX_RETAINED_TERMINAL_WORKFLOWS,Ki as MAX_SNAPSHOTS,Pn as MAX_TEAMMATES,sl as MAX_TRANSCRIPT_MESSAGES,Ah as MAX_USER_PROMPT_EXPANSION_ADDITIONAL_CONTEXT_LENGTH,Jp as MCPDiscoveryState,Fp as MCPOAuthProvider,Bp as MCPOAuthTokenStorage,qs as MCPServerConfig,Ip as MCPServerStatus,sq as MCP_BUDGET_REARM_FRACTION,rq as MCP_BUDGET_WARN_FRACTION,Gp as MCP_DEFAULT_TIMEOUT_MSEC,Ma as MEDIA_FILE_PATTERNS,Ga as MEMORY_SECTION_HEADER,Eu as MOCK_TOOL_GET_CONFIRMATION_DETAILS,Du as MOCK_TOOL_GET_DEFAULT_PERMISSION,Af as MODEL_GENERATION_CONFIG_FIELDS,la as MUTATOR_KINDS,vg as MatildaOAuth2Client,wg as MatildaOAuth2Event,qg as MatildaOAuthPollError,oq as McpBudgetWouldExceedError,Kp as McpClient,vq as McpClientManager,pq as McpServerSpawnFailedError,Ks as McpTransportPool,oe as MemoryDreamEvent,ne as MemoryExtractEvent,qp as MemoryManager,nb as MemoryMetricType,pe as MemoryRecallEvent,Mr as MessageBus,ok as MessageBusType,Fs as MessageSenderType,Gu as MockModifiableTool,Fu as MockModifiableToolInvocation,Cu as MockTool,Df as ModelRegistry,ce as ModelSlashCommandEvent,Ef as ModelsConfig,Nq as MonitorRegistry,Xt as NativeLspClient,Yt as NativeLspService,Sd as NextSpeakerCheckEvent,Lh as NotificationType,Ep as OAUTH_AUTH_URL_EVENT,Dp as OAUTH_DISPLAY_MESSAGE_EVENT,Cp as OAuthUtils,Ys as OPENROUTER_BASE_URL,Xs as OPENROUTER_ENV_KEY,of as OUTPUT_TOKEN_SAFETY_MARGIN,ve as OpenAILogger,Hm as OpenDiffRequestSchema,zq as OutputFormat,gu as OverlayFs,w as PATH_ARG_KEYS,lq as POOLED_TRANSPORTS_DEFAULT,Os as PROVIDER_METADATA_NS,Oa as PYTHON_EXCLUDES,mb as PerformanceMetricType,Hq as PermissionManager,Nh as PermissionMode,Kh as PermissionRequestHookOutput,Qh as PostCompactTrigger,Ih as PostToolBatchHookOutput,Gh as PostToolUseFailureHookOutput,Fh as PostToolUseHookOutput,Ph as PreCompactTrigger,Eh as PreToolUseHookOutput,le as PromptSuggestionEvent,kt as ProviderInstallError,Eo as RECIPROCAL_CALLER,br as REDACTED_URL_CREDENTIAL,Uf as REPORTED_ATTEMPT_PURPOSES,Sf as REPORTED_ATTEMPT_PURPOSE_HEADER,Tf as REPORTED_OPERATION_HEADER_NAMES,Rf as REPORTED_OPERATION_ID_HEADER,yf as RUNTIME_SNAPSHOT_PREFIX,Pi as RUNTIME_STATUS_SCHEMA_VERSION,Dd as ReadFileTool,Xf as ReportedOperationTracker,$r as RipGrepTool,Qd as RipgrepFallbackEvent,ye as RuntimeDiagnosticsCollector,Fl as SAFE_TOOL_ALLOWLIST,_i as SESSION_TITLE_MAX_LENGTH,v as SHELL_SPECIAL_CHARS,Vk as SHELL_TOOL_NAMES,mp as SKILL_REVIEW_TASK_TYPE,ai as STOP_HOOK_BLOCK_CAP_ENV,cu as SUGGESTION_PROMPT,gg as SUPPORTED_IMAGE_MIME_TYPES,Qt as SYMBOL_KIND_LABELS,Pa as SYSTEM_FILE_EXCLUDES,Gj as SYSTEM_REMINDER_CLOSE,Fj as SYSTEM_REMINDER_OPEN,ca as SchemaValidator,zp as SdkControlClientTransport,Qb as SemanticAttributes,sp as SendMessageType,Oh as SessionEndReason,$i as SessionService,Mh as SessionStartSource,Br as SettingScope,lm as ShellExecutionService,Fq as SkillActivationRegistry,Cq as SkillError,ee as SkillLaunchEvent,Gq as SkillManager,Ud as SlashCommandStatus,xj as SleepInhibitor,N as SpanStatusCode,me as SpeculationEvent,sm as StandardFileSystemService,Gd as StartSessionEvent,Jh as StopHookOutput,K as Storage,Yj as StreamEventType,gn as SubagentError,hn as SubagentErrorCode,Jq as SubagentManager,Iq as SubagentValidator,Sn as TASKS_DIR,Vn as TEAMMATE_COLORS,Rn as TEAMS_DIR,Tn as TEAM_CONFIG_FILENAME,wi as TERMINAL_CSI_REGEX,vi as TERMINAL_OSC_REGEX,xi as TERMINAL_SHIFT_DCS_REGEX,gt as THIRD_PARTY_PROVIDERS,Uk as TOOL_NAME_ALIASES,ot as TOOL_USE_SUMMARY_SYSTEM_PROMPT,Lo as TaskOwnershipError,Xn as TeamEventEmitter,Wn as TeamEventType,Wo as TeamManager,cf as TelemetryTarget,fg as TextTokenizer,Dn as TmuxBackend,Kd as ToolCallEvent,ja as ToolConfirmationOutcome,Aa as ToolDisplayNames,Ca as ToolDisplayNamesMigration,ba as ToolErrorType,ob as ToolExecutionPhase,za as ToolNames,Ba as ToolNamesMigration,$d as ToolOutputTruncatedEvent,xq as ToolRegistry,js as TrustGateError,nj as Turn,ld as USER_AUTO_MEMORY_DIRNAME,oa as UiTelemetryService,p as UnauthorizedError,ge as UserFeedbackEvent,fe as UserFeedbackRating,Id as UserPromptEvent,Hh as UserPromptExpansionHookOutput,Jd as UserRetryEvent,M as ValueType,qn as WORKTREES_DIR,kn as WORKTREE_BRANCH_PREFIX,mn as WORKTREE_SESSION_FILE,Sq as WorkflowRunRegistry,yn as WorkspaceContext,Ls as WorkspaceMcpBudget,Et as WorkspaceMemoryFileTooLargeError,Ct as WorkspaceMemoryWriteTimeoutError,oh as __resetActiveGoalStoreForTests,fi as _recoverObjectsFromLine,Lm as _resetCachedIdeServerHost,ji as _resetEnsuredDirsCacheForTest,_r as _resetRipGrepCachesForTest,u as _resetValidatePathCacheForTest,Xh as abortGoalForStopHookCap,mu as abortSpeculation,lu as acceptSpeculation,zj as acquireSleepInhibitor,hh as activeGoalEquals,Me as addDaemonRequestAttribute,Mp as addMCPStatusChangeListener,Wb as addModelOutputAttributes,Ub as addSystemPromptAttributes,Xb as addToolInputAttributes,Yb as addToolResultAttributes,Vb as addToolSchemaAttributes,Tb as addUserPromptAttributes,zt as aggregateUsage,Wl as allowEditorTypeInSandbox,Xg as appendToLastTextPart,Kl as applyAutoModeDecision,lt as applyProviderInstallPlan,Ej as applySkillAllowedTools,ys as approxBase64Bytes,Fo as assertValidTaskId,ko as assignTeammateColor,W as atomicWriteFile,Z as atomicWriteFileSync,X as atomicWriteJSON,Qo as blockTask,Lj as buildAddedMcpToolsReminder,Oj as buildAddedSkillsReminder,aj as buildApiHistoryFromConversation,Nj as buildAvailableSkillsReminder,ap as buildBackgroundEntryLabel,Au as buildBtwCacheSafeParams,zu as buildBtwPrompt,Kj as buildDeferredToolsReminder,Mn as buildFallbackApproachSummary,bl as buildHumanReadableRuleLabel,Ps as buildInstallPlan,Mj as buildMcpServerInstructionsReminder,xp as buildMissedCronNotification,Ig as buildModelIdContext,jl as buildPermissionCheckContext,al as buildPermissionRules,Ws as buildProviderTemplate,bg as buildReportedOperationHeaders,Lk as buildShellExecWarnings,Dj as buildSkillLlmContent,Pj as buildStartupContextReminder,Vo as buildTeammatePromptAddendum,Ag as cacheMatildaCredentials,jq as canUseRipgrep,Pe as captureDaemonTelemetryContext,Sk as checkArgumentSafety,Mk as checkCommandPermissions,kr as checkForExtensionUpdate,Vl as checkHasEditorType,hr as checkNpmUpdate,Ro as claimTask,As as clampInlineMediaPart,pf as clampOutputToContextWindow,po as classifyShutdownResponse,rt as cleanSummary,Iu as cleanupTmpDir,kh as clearActiveGoal,Co as clearAllInboxes,od as clearAutoMemoryRootCache,gp as clearCacheSafeParams,Bg as clearCachedCredentialFile,qh as clearGoalTerminalObserver,Bo as clearInbox,uc as clearMatildaCorrelationHashes,Kf as clearMatildaCredentials,Si as clearRuntimeStatus,lo as clearTeammateColors,uu as clearWelcomeBackState,cs as clearWorktreeSession,Sr as cliSource,ir as cloneFromGit,yp as collectMemoryDiagnostics,Uj as collectToolCallIdsFromHistory,Ql as commandExists,_j as compactPendingUserContentToBudget,Zj as compactTextMiddle,Qs as computeModelListVersion,wj as computeThresholds,ej as computeUniqueBranchTitle,Wr as computedSource,Wp as connectAndDiscover,aq as connectToMcpServer,mq as connectionIdOf,Ao as consumeUnread,qr as convertClaudeAgentConfig,sr as convertClaudePluginPackage,rr as convertClaudeToMatildaConfig,gm as convertColorToHex,Om as convertToFunctionResponse,or as convertTomlToMarkdown,Er as copyExtension,cb as countFileLines,ni as countLines,es as crawlCache,Gg as createContentGenerator,Fg as createContentGeneratorConfig,Te as createDaemonBridgeTelemetry,U as createDebugLogger,ik as createDefaultAutoMemoryExtractCursor,jk as createDefaultAutoMemoryIndex,hk as createDefaultAutoMemoryMetadata,vl as createDenialState,bu as createFollowupController,hp as createForkedChat,Yh as createGoalStopHookCallback,Ch as createHookOutput,Lr as createInstructionsLoadedCallback,Hp as createStreamableHttpCompatibilityFetch,Jo as createTask,so as createTeamFile,Hu as createTmpDir,nt as createToolUseSummaryMessage,bq as createTransport,et as customProvider,$a as decodeBufferWithEncodingInfo,Hs as decodeTagName,Wj as dedupeToolCallsById,_s as deepseekProvider,Vr as defaultSource,No as deleteTask,uo as deleteTeamDirs,Ni as deserializeSnapshots,_a as detectBOM,In as detectBackend,Ik as detectCommandSubstitution,Ya as detectEncodingFromBuffer,eb as detectFileEncoding,ib as detectFileType,um as detectIdeFromEnv,qm as detectLineEnding,cg as detectRuntime,Sh as detectTodoChanges,Up as discoverMcpTools,Zp as discoverPrompts,Xp as discoverTools,wo as disposeInboxLocks,wk as doesToolInvocationMatch,lr as downloadFromGitHubRelease,gr as downloadFromNpmRegistry,Rl as editorCommands,Oe as emitDaemonLog,Ds as encodeInsightErrorMessage,Bs as encodeInsightProgressMessage,Cs as encodeInsightReadyMessage,Gs as encodeTagName,rm as encodeTextFileContent,lc as endHookSpan,$b as endInteractionSpan,cc as endLLMRequestSpan,oc as endSubagentSpan,jc as endToolBlockedOnUserSpan,hc as endToolExecutionSpan,fc as endToolSpan,kk as ensureAutoMemoryScaffold,pm as ensureCrlfLineEndings,iq as ensureMacBinarySigned,hq as ensureRipgrepHealthy,nu as ensureToolResultPairing,mk as ensureUserAutoMemoryScaffold,Zf as enterReportedOperationContext,Xr as envLayer,B as escapePath,zk as escapeShellArg,qe as estimateTokensFromChars,Ol as evaluateAutoMode,nl as evaluatePermissionFlow,kl as evaluatePermissionRules,hu as evaluateToolCall,Nk as execCommand,Js as executeToolCall,oi as exists,y as expandHomeDir,Se as extractDaemonTraceContext,Sa as extractExtensionsFromPatterns,nr as extractFile,Vi as extractJsonStringField,Xi as extractLastJsonStringField,Wi as extractLastJsonStringFields,tl as extractShellOperations,Nm as extractToolFilePaths,Di as fetchGitDiff,Ei as fetchGitDiffHunks,kb as fileExists,pu as filter,qi as findGitRoot,no as findMemberById,oo as findMemberByName,it as findProviderByCredentials,ht as findProviderById,mr as findReleaseAsset,tk as fireNotificationHook,uk as firePermissionRequestHook,sk as firePostToolUseFailureHook,rk as firePostToolUseHook,qk as firePreToolUseHook,Wg as flatMapTextParts,zc as forceFlushMetrics,io as formatAgentId,Nl as formatClassifierBlockMessage,Hj as formatDateForContext,wl as formatDenialStateLog,Nn as formatLineStats,hm as formatMemoryUsage,di as formatStopHookBlockingCapWarning,P as formatTraceparent,$n as forwardApproval,un as generateAgentWorktreeSlug,ng as generateCodeChallenge,mg as generateCodeVerifier,dt as generateCustomEnvKey,og as generatePKCEPair,du as generatePromptSuggestion,mt as generateSessionRecap,pk as generateToolUseId,pt as generateToolUseSummary,jo as generateUniqueTeammateName,Fd as generateValidName,re as generatedOutputTokens,ih as getActiveGoal,pc as getActiveInteractionSpan,Ym as getAgentName,Uo as getAgentStatuses,Ja as getAllGeminiMdFilenames,Rp as getAllMCPServerStatuses,jt as getAllProviderBaseUrls,uj as getArenaSystemReminder,ud as getAutoMemoryConsolidationLockPath,td as getAutoMemoryExtractCursorPath,xd as getAutoMemoryFilePath,rd as getAutoMemoryIndexPath,sd as getAutoMemoryMetadataPath,pd as getAutoMemoryProjectStateDir,nd as getAutoMemoryRoot,vd as getAutoMemoryTopicFilename,wd as getAutoMemoryTopicPath,Ml as getAutoModePermissionDeniedReason,fq as getBuiltinRipgrep,fp as getCacheSafeParams,Va as getCachedEncodingForBuffer,Bk as getCommandRoot,Ck as getCommandRoots,rj as getCompressionPrompt,qj as getCoreSystemPrompt,Ia as getCurrentGeminiMdFilename,pj as getCustomSystemPrompt,Rs as getDefaultBaseUrlForProtocol,Ts as getDefaultModelIds,Yl as getDiffCommand,Ij as getDirectoryContextString,Sl as getEditorExecutable,pl as getEffectivePermissionForConfirmation,zr as getEnvContents,Jj as getEnvironmentContext,c as getErrorMessage,d as getErrorStatus,e as getErrorType,Fr as getExtensionId,Ul as getExternalEditorCommand,eu as getFilterReason,Cj as getFolderStructure,_g as getFunctionCalls,ah as getFunctionCallsAsJson,$g as getFunctionCallsFromParts,bh as getFunctionCallsFromPartsAsJson,ri as getGitBranch,si as getGitRepoName,zh as getHookKey,Ft as getIdeInstaller,Mm as getIdeServerHost,xo as getInboxPath,fo as getInboxesDir,Qj as getInitialChatHistory,vj as getInsightPrompt,sh as getLastGoalTerminal,Zn as getLeader,Sp as getMCPDiscoveryState,$t as getMCPServerPrompts,Qp as getMCPServerStatus,wf as getMatildaAuthBaseUrl,Lf as getMatildaAuthStatus,tc as getMatildaCorrelationHashes,Hf as getMatildaCredentialsPath,yg as getMatildaOAuthClient,xs as getMaxInlineMediaBytes,md as getMemoryBaseDir,Mq as getMonitorOutputPath,dg as getOrCreateSharedDispatcher,tj as getPlanModeSystemReminder,D as getProjectHash,vu as getProjectSummaryInfo,sj as getProjectSummaryPrompt,Pg as getRateLimitErrorDetails,Qg as getRateLimitRetryDelayMs,ti as getRecentGitStatus,Wf as getReportedOperationContext,Vg as getResponseText,Zg as getResponseTextFromParts,cj as getResumePromptTokenCount,dj as getResumeTokenCounts,$k as getRuleDisplayName,yr as getScopedEnvContents,km as getShellAbortReasonKind,xk as getShellConfiguration,fb as getSpecificMimeType,Xk as getSpecifierKind,Rj as getStartupContextLength,ch as getStructuredResponse,dh as getStructuredResponseFromParts,ig as getSupportedImageFormatsString,Wa as getSystemEncoding,Ko as getTask,Go as getTaskPath,go as getTasksDir,co as getTeamDir,eo as getTeamFilePath,Zm as getTeamName,bn as getTeammateColor,Wm as getTeammateContext,bo as getTeamsRootDir,kj as getThoughtText,yt as getTimeRangeBounds,O as getTraceContext,jg as getUnsupportedImageFormatWarning,zd as getUserAutoMemoryIndexPath,yd as getUserAutoMemoryRoot,Ad as getUserAutoMemoryTopicPath,Nf as getValidMatildaAccessToken,su as getWelcomeBackState,rp as globalMemoryManager,ia as hasCycleInSchema,rf as hasExplicitOutputLimit,$p as hasNetworkTransport,Fk as hasNonFinalTopLevelBackgroundOperator,Kk as hasShellSubstitution,Hk as hasUnsafeMonitorBackgroundOperator,He as hashDaemonWorkspace,Zt as hashMcpServerConfig,Gr as hashValue,Jr as hookEventSupportsMatcher,Zq as hydrateString,Am as ideContextStore,Ue as initializeDaemonMetrics,wc as initializeTelemetry,Re as injectDaemonTraceContext,ll as injectPermissionRulesIfMissing,_p as invokeMcpPrompt,b as isAbortError,Cd as isAnyAutoMemPath,Jg as isApiError,Dl as isApproveOutcome,rl as isAutoEditApproved,qd as isAutoMemPath,Bt as isBareMode,bm as isBinary,hb as isBinaryFile,Ff as isBrowserCommandBlocked,ur as isClaudePluginConfig,Qk as isCommandAllowed,Pk as isCommandAvailable,Rk as isCommandNeedsPermission,Q as isDebugLoggingDegraded,xl as isDenialFallbackReason,rg as isDeviceAuthorizationSuccess,tg as isDeviceTokenPending,sg as isDeviceTokenSuccess,Xl as isEditorAvailable,cq as isEnabled,ug as isErrorResponse,ps as isGatedMcpScope,Mg as isGenericQuotaExceededError,pi as isGitRepository,Xm as isInProcessTeammate,Gl as isInSafeToolAllowlist,ek as isInvalidArgumentError,Ng as isMatildaQuotaExceededError,_l as isModifiableDeclarativeTool,a as isNodeError,zn as isPathWithinRoot,Jb as isPerformanceMonitoringActive,ql as isPlanModeBlocked,Lg as isProQuotaExceededError,Og as isRateLimitError,Vf as isReportedOperationHeaderName,xe as isRuntimeDiagnosticsEnabled,dk as isSchemaDepthError,er as isScopedNpmPackage,rs as isSdkMcpServerConfig,xa as isSettledStatus,Kg as isStructuredError,F as isSubpath,G as isSubpaths,wa as isSuccessStatus,hg as isSupportedImageMimeType,Sj as isSystemReminderContent,an as isTeamLead,$m as isTeammate,vc as isTelemetrySdkInitialized,Tl as isTerminalEditor,va as isTerminalStatus,pr as isTomlFormat,ha as isTool,vk as isToolEnabled,Rg as isTransientCapacityError,Sg as isUnattendedMode,Bd as isUserAutoMemPath,Pl as isValidEditorType,$j as isValidNonThoughtTextPart,yk as isWindows,gb as isWithinRoot,Th as judgeGoal,sf as knownTokenLimit,Yr as layer,Yp as listMcpPrompts,Oo as listTasks,vo as listTeamNames,fs as loadIgnoreRules,Pr as loadServerHierarchicalMemory,xt as loadUsageHistory,Jc as logApiCancel,Ic as logApiError,Fc as logApiRequest,Kc as logApiResponse,$c as logArenaAgentCompleted,ad as logArenaSessionEnded,_c as logArenaSessionStarted,Xc as logAuth,Pc as logChatCompression,Oc as logConversationFinishedEvent,Wc as logExtensionDisable,Vc as logExtensionEnable,Sc as logExtensionInstallEvent,Tc as logExtensionUninstall,Uc as logExtensionUpdateEvent,Gc as logFlashFallback,Nc as logIdeConnection,Qc as logKittySequenceOverflow,ed as logMemoryDream,dd as logMemoryExtract,fd as logMemoryRecall,Rc as logModelSlashCommand,Lc as logNextSpeakerCheck,bd as logPromptSuggestion,Hc as logRipgrepFallback,Yc as logSkillLaunch,Mc as logSlashCommand,cd as logSpeculation,Ac as logStartSession,Dc as logToolCall,Ec as logToolOutputTruncated,Zc as logUserFeedback,Bc as logUserPrompt,Cc as logUserRetry,xf as loginToMatilda,Qf as loginToMatildaWithBrowser,Mf as logoutMatilda,ie as makeArenaAgentCompletedEvent,je as makeArenaSessionEndedEvent,he as makeArenaSessionStartedEvent,Vd as makeChatCompressionEvent,Bu as makeFakeConfig,A as makeRelative,Td as makeSlashCommandEvent,dl as matchesCommandPattern,gl as matchesDomainPattern,hl as matchesMcpPattern,fl as matchesPathPattern,il as matchesRule,xg as matildaOAuth2Events,vf as matildaProvider,wr as maybePromptForSettings,Lp as mcpServerRequiresOAuth,uq as mcpTransportOf,tr as mergeClaudeConfigs,tt as metricsToUsageRecord,$s as minimaxProvider,Ur as modelProvidersSource,Cf as modelRegistryKey,bt as modelscopeProvider,$l as modifyWithEditor,ol as needsConfirmation,nm as needsUtf8Bom,qf as normalize,cm as normalizeContent,Vj as normalizeModelToolCallIds,Gk as normalizeMonitorCommand,Nr as normalizeProxyUrl,Dq as normalizeSkillPriority,bi as normalizeStopHookBlockingCap,te as normalizeStoredModelUsage,ut as normalizeUsageRecord,rh as notifyGoalTerminal,Io as notifyTasksUpdated,Ho as onTasksUpdated,kg as openBrowserSecurely,Zl as openDiff,Zs as openRouterProvider,we as openaiLogger,zs as oversizedMediaPlaceholder,Aq as parse,ei as parseAndFormatApiError,Ce as parseBooleanEnvFlag,nq as parseConnectionId,Ii as parseDeletedFromNameStatus,Gi as parseGitDiff,jr as parseGitHubRepoForReleases,Fi as parseGitNumstat,Es as parseInsightMessage,_t as parseInstallSource,gi as parseLineTolerant,dr as parseNpmPackageSource,Zk as parseRule,_k as parseRules,Hi as parseShortstat,De as parseTelemetryTargetValue,jj as parseThought,vs as partListUnionToString,Ug as partToString,Jl as passesAcceptEditsFastPath,ar as performVariableReplacement,ml as persistPermissionOutcome,st as persistSessionUsage,Vp as populateMcpServerCommand,Yg as prependToFirstTextPart,jb as processSingleFileContent,xr as promptForSetting,im as promptIdContext,Vs as providerMatchesCredentials,ii as read,lk as readAutoMemoryIndex,bb as readFileWithEncoding,ab as readFileWithEncodingInfo,db as readFileWithLineAndLimit,yo as readInbox,Yi as readLastJsonStringFieldSync,Zi as readLastJsonStringFieldsSync,hi as readLines,wu as readManyFiles,If as readMatildaCredentials,ru as readPathFromWorkspace,Ri as readRuntimeStatus,qo as readTeamFile,nk as readUserAutoMemoryIndex,as as readWorktreeSession,on as readWorktreeSessionMarker,yl as recordAllow,tb as recordApiErrorMetrics,Fb as recordApiRequestBreakdown,sb as recordApiResponseMetrics,yb as recordApiRetry,Lb as recordArenaAgentCompletedMetrics,Mb as recordArenaSessionEndedMetrics,Kb as recordArenaSessionStartedMetrics,Ib as recordBaselineComparison,zl as recordBlock,wb as recordContentRetry,xb as recordContentRetryFailure,Bb as recordCpuUsage,$e as recordDaemonBridgeError,af as recordDaemonCancel,Ye as recordDaemonChannelLifecycle,Ne as recordDaemonError,We as recordDaemonHttpRequest,Le as recordDaemonHttpResponse,_e as recordDaemonPromptDuration,Ze as recordDaemonPromptQueueWait,Xe as recordDaemonSessionLifecycle,Cl as recordFallbackApprove,ub as recordFileOperationMetric,lh as recordGoalIteration,vb as recordInvalidChunk,Ob as recordMemoryDreamMetrics,Nb as recordMemoryExtractMetrics,Pb as recordMemoryRecallMetrics,Ab as recordMemoryUsage,Hb as recordPerformanceRegression,Gb as recordPerformanceScore,fh as recordStartupEvent,zb as recordStartupPerformance,Eb as recordTokenEfficiency,rb as recordTokenUsageMetrics,qb as recordToolCallMetrics,Db as recordToolExecutionBreakdown,Cb as recordToolQueueDepth,Al as recordUnavailable,_q as recursivelyHydrateStrings,eg as redactProxyCredentials,Xj as redactStructuredOutputArgsForRecording,cr as redactUrlCredentials,vt as reestimateUsageFromAssistantRecord,Of as refreshMatildaCredentials,xc as refreshSessionContext,Ve as registerDaemonGaugeCallbacks,_h as registerGoalHook,Yn as registerLeader,So as releaseOwnedTask,Pp as removeMCPServerStatus,Np as removeMCPStatusChangeListener,V as renameWithRetry,Y as renameWithRetrySync,bk as repairOrphanedToolUseTurns,bj as replayUiTelemetryFromConversation,bf as reportCliClientEvent,tp as reportedAttemptPurposeForSendMessageType,R as resetDebugLoggingState,El as resetDenialState,Ua as resetEncodingCache,Po as resetTaskList,om as resetUtf8BomCache,_m as resolveActiveTeamName,J as resolveAndValidatePath,Ss as resolveBaseUrl,eq as resolveBundleDir,Ok as resolveCommandPath,Dg as resolveContentGeneratorConfigWithSources,Qr as resolveField,Ji as resolveGitDir,nh as resolveGoalLifecycleStatus,Zo as resolveMaxConcurrentBackgroundAgents,Ns as resolveMetadataKey,Zr as resolveModelConfig,Hg as resolveModelId,fr as resolveNpmRegistry,ue as resolveOpenAILogDir,Rr as resolveOptionalField,Ms as resolveOwnsModel,H as resolvePath,oj as resolvePathFromEnv,el as resolvePathPattern,gq as resolveRipgrep,ci as resolveStopHookBlockingCap,Ee as resolveTelemetrySettings,Wk as resolveToolName,ds as restoreWorktreeContext,Tg as retryWithBackoff,iu as rewritePathArgs,wt as rewriteUsageHistoryFromChats,$f as runAsyncGeneratorWithReportedOperationContext,jp as runForkedAgent,nc as runInSubagentSpanContext,ec as runInToolSpanContext,kq as runRipgrep,ui as runSideQuery,Qe as runWithDaemonTelemetryContext,T as runWithDebugLogSession,ip as runWithForkedChatModel,_f as runWithReportedAttemptPurpose,Yf as runWithReportedOperationContext,cn as runWithTeammateIdentity,ze as runtimeDiagnostics,sa as safeAgentId,am as safeLiteralReplace,E as sanitizeCwd,Rb as sanitizeHookName,ho as sanitizeName,gj as sanitizeTitle,hj as sanitizeToolCallResultForRecording,Bh as sanitizeUserPromptExpansionAdditionalContext,ep as saveCacheSafeParams,tu as saveWelcomeBackRestartChoice,Do as sendStructuredMessage,Mi as serializeSnapshot,fm as serializeTerminalToObject,dm as serializeTerminalToText,jm as sessionIdContext,jh as setActiveGoal,S as setDebugLogSession,Ha as setGeminiMdFilename,ph as setGoalTerminalObserver,th as setLastGoalTerminal,Tp as setMCPDiscoveryState,sc as setMatildaCorrelationHashes,mo as setMemberActive,eh as setStartupEventSink,Tr as settingsSource,z as shortenPath,Gf as shouldAttemptBrowserLaunch,Tk as shouldDefaultToNodePty,Bl as shouldFallback,fu as shouldFilterSuggestion,Ll as shouldFirePermissionDeniedForAutoMode,Il as shouldForceAutoModeReviewForAllow,lg as shouldLaunchBrowser,Hl as shouldRunAutoModeForCall,Us as shouldShowStep,yc as shutdownTelemetry,yj as sleepInhibitor,Ak as splitCommands,cl as splitCompoundCommand,Eq as splitConditionalSkills,kc as startHookSpan,_b as startInteractionSpan,bc as startLLMRequestSpan,ku as startSpeculation,mc as startSubagentSpan,ic as startToolBlockedOnUserSpan,gc as startToolExecutionSpan,dc as startToolSpan,up as startsReportedOperation,Bq as stringify,zf as stripRuntimeSnapshotPrefix,Dk as stripShellWrapper,Tj as stripStartupContext,yi as stripTerminalControlSequences,Ek as stripTrailingBackgroundAmp,xu as subagentGenerator,$q as substituteHookVariables,Be as summarizeAnthropicWireRequest,Ae as summarizeOpenAIWireRequest,Ln as summarizeUnifiedDiff,Vm as teammateIdentityStore,Tm as templateString,x as tildeifyPath,r as toFriendlyError,tf as tokenLimit,Yk as toolMatchesRuleToolName,se as totalTokensFromBuckets,Sb as truncateContent,qt as truncateJson,Zb as truncateSpanError,fj as tryGenerateSessionTitle,to as tryReclaimStaleTeam,pa as uiTelemetryService,To as unassignTeammateTasks,Ui as unescapeJsonString,C as unescapePath,Zh as unregisterGoalHook,_n as unregisterLeader,mh as updateActiveGoalStatus,Op as updateMCPServerStatus,Ar as updateSetting,L as updateSymlink,Mo as updateTask,Eg as validateModelConfig,Hr as validateName,I as validatePath,Yq as validateVariables,Pf as willOpenMatildaAuthBrowser,Xa as windowsCodePageToEncoding,Ke as withDaemonBridgeSpan,Je as withDaemonRequestSpan,Ie as withDaemonSpan,ac as withInteractionSpan,ag as withReportedAttemptPurpose,ln as worktreeBranchForSlug,ao as wrapConfirmWithBadge,mi as write,ki as writeLine,li as writeLineSync,Jf as writeMatildaCredentials,zo as writeMessage,Qi as writeRuntimeStatus,ro as writeTeamFile,Dt as writeWorkspaceContextFile,bs as writeWorktreeSession,nn as writeWorktreeSessionMarker,at as zaiProvider};
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{Kf as u,Vf as D}from"./chunk-2FYDKSRH.js";import"./chunk-TZIDSCTF.js";import{l as A}from"./chunk-FUNLOUYI.js";import{l as C}from"./chunk-R3H6IWFK.js";import{b as w,e as T,f as k,g as b,q as o,r as v}from"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import{k as f,l as y}from"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{g as c,i as g,p as h,q as p}from"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{a as d}from"./chunk-QWBNNEV2.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 i=class extends c{constructor(e,a){super(a);this.config=e}getDescription(){return`Create team "${this.params.team_name}"`}async execute(){let e=k(this.params.team_name);if(!e){let t="Team name is required.";return{llmContent:t,returnDisplay:t,error:{message:t}}}if(this.config.getArenaManager()){let t="Cannot create a team while an Arena session is active. End the Arena session first.";return{llmContent:t,returnDisplay:t,error:{message:t}}}if(this.config.getTeamManager()){let t="A team is already active. Delete it before creating a new one.";return{llmContent:t,returnDisplay:t,error:{message:t}}}let a=b(y,e),s={name:e,description:this.params.description,createdAt:Date.now(),leadAgentId:a,leadSessionId:this.config.getSessionId(),leadPid:process.pid,members:[]};try{await o(e,s)}catch(t){if(d(t)&&t.code==="EEXIST"){if(!await v(e)){let n=`Team "${e}" already exists and appears to be owned by a live matilda-code session. Pick a different name, or \u2014 if you're sure no other session is using it \u2014 remove the on-disk artifacts manually:
3
+ import{Kf as u,Vf as D}from"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import{l as A}from"./chunk-FUNLOUYI.js";import{l as C}from"./chunk-R3H6IWFK.js";import{b as w,e as T,f as k,g as b,q as o,r as v}from"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import{k as f,l as y}from"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{g as c,i as g,p as h,q as p}from"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{a as d}from"./chunk-QWBNNEV2.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 i=class extends c{constructor(e,a){super(a);this.config=e}getDescription(){return`Create team "${this.params.team_name}"`}async execute(){let e=k(this.params.team_name);if(!e){let t="Team name is required.";return{llmContent:t,returnDisplay:t,error:{message:t}}}if(this.config.getArenaManager()){let t="Cannot create a team while an Arena session is active. End the Arena session first.";return{llmContent:t,returnDisplay:t,error:{message:t}}}if(this.config.getTeamManager()){let t="A team is already active. Delete it before creating a new one.";return{llmContent:t,returnDisplay:t,error:{message:t}}}let a=b(y,e),s={name:e,description:this.params.description,createdAt:Date.now(),leadAgentId:a,leadSessionId:this.config.getSessionId(),leadPid:process.pid,members:[]};try{await o(e,s)}catch(t){if(d(t)&&t.code==="EEXIST"){if(!await v(e)){let n=`Team "${e}" already exists and appears to be owned by a live matilda-code session. Pick a different name, or \u2014 if you're sure no other session is using it \u2014 remove the on-disk artifacts manually:
4
4
  rm -rf "${w(e)}" "${T(e)}"`;return{llmContent:n,returnDisplay:n,error:{message:n}}}await o(e,s)}else throw t}await C(e),await A(e);let m=new u(this.config);await m.init();let x=new D(m,s,this.config.getSubagentManager(),{maxTeammates:this.config.getAgentsSettings().team?.maxTeammates});this.config.setTeamManager(x);let N={teamName:e,leadAgentId:a,teammates:{}};this.config.setTeamContext(N);let E={type:"team_result",teamName:e,action:"created"};return{llmContent:`Team "${e}" created.`+(this.params.description?` Description: ${this.params.description}`:""),returnDisplay:E}}},I=class r extends g{constructor(e){super(r.Name,p.TEAM_CREATE,`# TeamCreate
5
5
 
6
6
  ## When to Use
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{Cf as te,Ze as V,kf as q,rf as Q,sf as W,uf as Z,vf as ee}from"./chunk-2FYDKSRH.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import{b as Y}from"./chunk-NDR7ZFUA.js";import{g as K,i as X,p as v,q as H}from"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import{b as z}from"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{Y as G}from"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as k}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";k();k();import{randomBytes as ke}from"node:crypto";import*as ae from"node:os";k();import*as O from"node:vm";function he(e){let r=/^\s*export\s+const\s+meta\s*=\s*\{/.exec(e);if(!r)return null;let n=r.index,a=e.indexOf("{",n),i=1,o=a+1;for(;o<e.length&&i>0;){let l=e[o],c=e[o+1];if(l==="/"&&c==="/"){for(o+=2;o<e.length&&e[o]!==`
3
+ import{Cf as te,Ze as V,kf as q,rf as Q,sf as W,uf as Z,vf as ee}from"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import"./chunk-UY2R3ZQ4.js";import{b as Y}from"./chunk-NDR7ZFUA.js";import{g as K,i as X,p as v,q as H}from"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import{b as z}from"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{Y as G}from"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as k}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";k();k();import{randomBytes as ke}from"node:crypto";import*as ae from"node:os";k();import*as O from"node:vm";function he(e){let r=/^\s*export\s+const\s+meta\s*=\s*\{/.exec(e);if(!r)return null;let n=r.index,a=e.indexOf("{",n),i=1,o=a+1;for(;o<e.length&&i>0;){let l=e[o],c=e[o+1];if(l==="/"&&c==="/"){for(o+=2;o<e.length&&e[o]!==`
4
4
  `;)o++;continue}if(l==="/"&&c==="*"){for(o+=2;o<e.length&&!(e[o]==="*"&&e[o+1]==="/");)o++;o+=2;continue}if(l==="/"&&me(e,o)){o++;let u=!1;for(;o<e.length&&(u||e[o]!=="/")&&e[o]!==`
5
5
  `;)e[o]==="\\"?o+=2:e[o]==="["?(u=!0,o++):(e[o]==="]"&&(u=!1),o++);for(o++;o<e.length&&/[gimsuy]/.test(e[o]);)o++;continue}if(l==='"'||l==="'"||l==="`"){let u=l;for(o++;o<e.length&&e[o]!==u;)e[o]==="\\"&&o++,o++;o++;continue}l==="{"?i++:l==="}"&&i--,o++}if(i!==0)throw new Error("stripExportMeta: unbalanced braces in export const meta declaration \u2014 the workflow script cannot be safely stripped. Check the meta block syntax.");let g=o-1;for(;o<e.length&&/[\s;]/.test(e[o]);)o++;return{exportIdx:n,startBrace:a,endBraceIncl:g,afterMeta:o}}function de(e){let t=he(e);if(!t)return{stripped:e,meta:null};let r=e.slice(t.startBrace,t.endBraceIncl+1),n=e.slice(0,t.exportIdx)+e.slice(t.afterMeta),a=O.createContext(Object.create(null)),i;try{i=new O.Script(`(${r})`).runInContext(a)}catch(g){let l=g instanceof Error?g.message:String(g);throw new Error(`extractAndStripMeta: failed to evaluate meta object literal: ${l}`)}C(i);let o=fe(i);return{stripped:n,meta:o}}function C(e,t=new WeakSet){if(e===null||typeof e!="object"||t.has(e))return;if(t.add(e),typeof e.then=="function"){try{e.catch(()=>{})}catch{}throw new Error("extractAndStripMeta: meta values must not be Promises (no async / dynamic import allowed in meta literal)")}if(Array.isArray(e)){for(let n of e)C(n,t);return}for(let n of Object.values(e))C(n,t)}function fe(e){if(e===null||typeof e!="object")throw new Error("meta must be an object");let t=e;if(typeof t.name!="string"||t.name.length===0)throw new Error("meta.name must be a non-empty string");if(typeof t.description!="string"||t.description.length===0)throw new Error("meta.description must be a non-empty string");if(t.whenToUse!==void 0&&typeof t.whenToUse!="string")throw new Error("meta.whenToUse must be a string");let r;if(t.phases!==void 0){if(!Array.isArray(t.phases))throw new Error("meta.phases must be an array");r=[];for(let a of t.phases){if(a===null||typeof a!="object")throw new Error("meta.phases entries must be objects");let i=a;if(typeof i.title!="string"||i.title.length===0)throw new Error("meta.phases[].title must be a non-empty string");let o={title:i.title};if(i.detail!==void 0){if(typeof i.detail!="string")throw new Error("meta.phases[].detail must be a string");o.detail=i.detail}if(i.model!==void 0){if(typeof i.model!="string")throw new Error("meta.phases[].model must be a string");o.model=i.model}r.push(o)}}let n={name:t.name,description:t.description};return t.whenToUse!==void 0&&(n.whenToUse=t.whenToUse),r!==void 0&&(n.phases=r),n}function me(e,t){let r=t-1;for(;r>=0&&/\s/.test(e[r]);)r--;if(r<0)return!0;let n=e[r];return/[{[(,;:=!&|?+\-*/%^~<>]/.test(n)}var p=G("WORKFLOW"),_=1e4,P=1e4,re=64,we=30*60*1e3;function be(e){if(typeof e.maxWallClockMs=="number"&&e.maxWallClockMs>0)return e.maxWallClockMs;let t=Number(process.env.MATILDA_CODE_MAX_WORKFLOW_SECONDS);return Number.isFinite(t)&&t>0?t*1e3:we}function R(e,t=0,r=new WeakSet){if(t>re)throw new Error(`WorkflowSandbox: args exceeded max nesting depth of ${re}`);if(e===null)return;let n=typeof e;if(n==="function")throw new Error("WorkflowSandbox: args must be JSON-serializable (functions are not allowed).");if(n==="bigint")throw new Error("WorkflowSandbox: args must be JSON-serializable (BigInt is not allowed \u2014 pass as string).");if(n!=="object")return;let a=e;if(r.has(a))throw new Error("WorkflowSandbox: args must be JSON-serializable (circular reference detected).");if(r.add(a),Array.isArray(e))for(let i of e)R(i,t+1,r);else for(let i of Object.values(e))R(i,t+1,r)}function ne(e){let t=[],r=[],n=h=>{if(r.length<_){let s=String(h);r.push(s);try{e.emitter?.logAppended?.(s)}catch(d){p.warn("emitter.logAppended threw:",d)}}else r.length===_&&r.push(`[workflow log truncated at ${_} lines]`)},a=h=>{if(t.length<P){let s=String(h);if(t[t.length-1]===s)return;t.push(s);try{e.emitter?.phaseStarted?.(s)}catch(d){p.warn("emitter.phaseStarted threw:",d)}}else t.length===P&&t.push(`[workflow phases truncated at ${P} entries]`)};e.args!==void 0&&R(e.args);let o={argsJson:e.args===void 0?null:JSON.stringify(e.args),pushPhase:a,pushLog:n,lastPhase:()=>t[t.length-1],hostAgent:e.dispatch,logRevivalFailure:(h,s)=>{p.warn(`Workflow result revival failed at index ${h}: ${s}; slot set to null (non-JSON-serializable thunk return).`)},hasParallel:!!e.parallel,hasPipeline:!!e.pipeline,hasBudget:!!e.budget,hostParallel:e.parallel,hostPipeline:e.pipeline,budgetTotal:e.budget?e.budget.total:null,hostBudgetSpent:e.budget?e.budget.spent.bind(e.budget):null,hostBudgetRemaining:e.budget?e.budget.remaining.bind(e.budget):null};Object.setPrototypeOf(o,null);let g=Object.assign(Object.create(null),{__workflowBridge:o}),l=O.createContext(g);O.runInContext(`(() => {
6
6
  const __b = globalThis.__workflowBridge;
@@ -327,7 +327,7 @@ CRITICAL: You MUST deliver your final answer by calling the \`structured_output\
327
327
  - If validation fails, the error tells you what to fix. Try again with corrected fields.
328
328
  - After two failed attempts, the run terminates \u2014 get the arguments right.
329
329
  - Do NOT use SendUserMessage to deliver your answer.
330
- - Be concise; the script reads only the structured payload, not your prose.`;k();function j(){return new DOMException("Concurrency limiter aborted.","AbortError")}function oe(e,t){if(!Number.isInteger(e)||e<1)throw new Error(`Concurrency limit must be a positive integer, got ${String(e)}.`);let r=0,n=[],a=()=>{for(;r<e&&n.length>0;){let o=n.shift();if(t?.aborted){o.reject(j());continue}r++,Promise.resolve().then(o.thunk).then(o.resolve,o.reject).finally(()=>{r--,a()})}},i=o=>new Promise((g,l)=>{if(t?.aborted){l(j());return}n.push({thunk:o,resolve:g,reject:l}),a()});return t&&!t.aborted&&t.addEventListener("abort",()=>{for(;n.length>0;)n.shift().reject(j())},{once:!0}),{run:i}}var D=1e3,I="MATILDA_CODE_MAX_WORKFLOW_AGENTS",L=1e4;function ye(e=process.env){let t=e[I];if(t===void 0||t.trim()==="")return D;let r=Number(t);return!Number.isInteger(r)||r<1?(p.warn(`Invalid ${I}=${JSON.stringify(t)}, using default (${D})`),D):r>L?(p.warn(`${I}=${r} exceeds hard ceiling (${L}); clamping.`),L):r}var $="MATILDA_CODE_MAX_WORKFLOW_CONCURRENCY",U=64;function ve(e=process.env){let t=e[$];if(t!==void 0&&t.trim()!==""){let r=Number(t);if(Number.isInteger(r)&&r>=1)return r>U?(p.warn(`${$}=${r} exceeds hard ceiling (${U}); clamping.`),U):r;p.warn(`Invalid ${$}=${JSON.stringify(t)}, using cpu-derived default`)}return Math.max(1,Math.min(16,ae.cpus().length-2))}var se=50,ie=10,le=[v.SEND_MESSAGE,v.EXIT_PLAN_MODE],T=class extends Error{constructor(r,n,a,i=null){super(r);this.phases=n;this.logs=a;this.meta=i}name="WorkflowExecutionError"};function Oe(){return`wf_${ke(8).toString("hex")}`}function Se(e){return e.replace(/[\u0000-\u001f\u007f]+/g," ")}function ce(e,t){return async(r,n)=>{let{AgentHeadless:a,ContextState:i}=await import("./agent-headless-22O7UBQY.js"),o=new i;if(o.set("task_prompt",r),n.agentType===void 0&&n.model===void 0&&n.isolation===void 0&&n.schema===void 0){let g=await a.create(n.label??"workflow-agent",e,{systemPrompt:M,initialMessages:[]},{},{max_turns:se,max_time_minutes:ie},{tools:["*"],disallowedTools:le});await g.execute(o,t);let l=g.getTerminateMode();if(l!=="GOAL")throw new Error(`Workflow subagent did not complete (terminate mode: ${l}).`);return g.getFinalText()}return Te(e,o,n,t)}}async function Te(e,t,r,n){if(r.isolation==="remote")throw new Error("agent({isolation:'remote'}) is not available in this build.");let a=e.getSubagentManager(),i;if(r.agentType!==void 0){let s=await a.findSubagentByName(r.agentType);if(!s){let d=Se(r.agentType);throw new Error(`agent({agentType}): agent type '${d}' not found.`)}i=s}else i={name:r.label??"workflow-agent",description:"Default workflow subagent (per-call overrides).",systemPrompt:M,level:"session",isBuiltin:!1};let o;r.schema!==void 0&&(o=r.agentType!==void 0&&i.systemPrompt?`${i.systemPrompt}
330
+ - Be concise; the script reads only the structured payload, not your prose.`;k();function j(){return new DOMException("Concurrency limiter aborted.","AbortError")}function oe(e,t){if(!Number.isInteger(e)||e<1)throw new Error(`Concurrency limit must be a positive integer, got ${String(e)}.`);let r=0,n=[],a=()=>{for(;r<e&&n.length>0;){let o=n.shift();if(t?.aborted){o.reject(j());continue}r++,Promise.resolve().then(o.thunk).then(o.resolve,o.reject).finally(()=>{r--,a()})}},i=o=>new Promise((g,l)=>{if(t?.aborted){l(j());return}n.push({thunk:o,resolve:g,reject:l}),a()});return t&&!t.aborted&&t.addEventListener("abort",()=>{for(;n.length>0;)n.shift().reject(j())},{once:!0}),{run:i}}var D=1e3,I="MATILDA_CODE_MAX_WORKFLOW_AGENTS",L=1e4;function ye(e=process.env){let t=e[I];if(t===void 0||t.trim()==="")return D;let r=Number(t);return!Number.isInteger(r)||r<1?(p.warn(`Invalid ${I}=${JSON.stringify(t)}, using default (${D})`),D):r>L?(p.warn(`${I}=${r} exceeds hard ceiling (${L}); clamping.`),L):r}var $="MATILDA_CODE_MAX_WORKFLOW_CONCURRENCY",U=64;function ve(e=process.env){let t=e[$];if(t!==void 0&&t.trim()!==""){let r=Number(t);if(Number.isInteger(r)&&r>=1)return r>U?(p.warn(`${$}=${r} exceeds hard ceiling (${U}); clamping.`),U):r;p.warn(`Invalid ${$}=${JSON.stringify(t)}, using cpu-derived default`)}return Math.max(1,Math.min(16,ae.cpus().length-2))}var se=50,ie=10,le=[v.SEND_MESSAGE,v.EXIT_PLAN_MODE],T=class extends Error{constructor(r,n,a,i=null){super(r);this.phases=n;this.logs=a;this.meta=i}name="WorkflowExecutionError"};function Oe(){return`wf_${ke(8).toString("hex")}`}function Se(e){return e.replace(/[\u0000-\u001f\u007f]+/g," ")}function ce(e,t){return async(r,n)=>{let{AgentHeadless:a,ContextState:i}=await import("./agent-headless-Y5AQHZHB.js"),o=new i;if(o.set("task_prompt",r),n.agentType===void 0&&n.model===void 0&&n.isolation===void 0&&n.schema===void 0){let g=await a.create(n.label??"workflow-agent",e,{systemPrompt:M,initialMessages:[]},{},{max_turns:se,max_time_minutes:ie},{tools:["*"],disallowedTools:le});await g.execute(o,t);let l=g.getTerminateMode();if(l!=="GOAL")throw new Error(`Workflow subagent did not complete (terminate mode: ${l}).`);return g.getFinalText()}return Te(e,o,n,t)}}async function Te(e,t,r,n){if(r.isolation==="remote")throw new Error("agent({isolation:'remote'}) is not available in this build.");let a=e.getSubagentManager(),i;if(r.agentType!==void 0){let s=await a.findSubagentByName(r.agentType);if(!s){let d=Se(r.agentType);throw new Error(`agent({agentType}): agent type '${d}' not found.`)}i=s}else i={name:r.label??"workflow-agent",description:"Default workflow subagent (per-call overrides).",systemPrompt:M,level:"session",isBuiltin:!1};let o;r.schema!==void 0&&(o=r.agentType!==void 0&&i.systemPrompt?`${i.systemPrompt}
331
331
 
332
332
  ${N}`:N);let g;r.schema!==void 0&&i.tools&&i.tools.length>0&&!i.tools.includes("*")&&!i.tools.includes(v.STRUCTURED_OUTPUT)&&(g=[...i.tools,v.STRUCTURED_OUTPUT]);let l={...i,...r.model!==void 0?{model:r.model}:{},...o!==void 0?{systemPrompt:o}:{},...g!==void 0?{tools:g}:{},disallowedTools:Array.from(new Set([...i.disallowedTools??[],...le]))},c=null,u=e;r.isolation==="worktree"&&(c=await Ee(e),u=Ae(e,c.path));let h;try{let s=null;r.schema!==void 0&&(u=await Pe(u,r.schema),s=xe());let d=n;if(s){let w=new AbortController;n&&(n.aborted?w.abort(n.reason):(h=()=>w.abort(n.reason),n.addEventListener("abort",h))),s.abortController=w,d=w.signal}let b=s?_e(s):void 0,{subagent:f,dispose:m}=await a.createAgentHeadless(l,u,{runConfigOverrides:{max_turns:se,max_time_minutes:ie},eventEmitter:b});try{if(await f.execute(t,d),s){if(s.result!==null){if(c){let E=c;c=null;let A=await J(E);A&&p.info(`[Workflow] Schema-mode subagent preserved worktree at ${A.path??"(directory removed)"} on branch ${A.branch}. The structured payload is returned verbatim; recover the work from the preserved path / branch.`)}return s.result}if(n?.aborted)throw new DOMException("Workflow aborted.","AbortError");let S=f.getTerminateMode();throw S!=="GOAL"&&S!=="CANCELLED"?new Error(`Workflow subagent did not complete (terminate mode: ${S}).`):s.attempts>2?new Error("subagent completed without calling StructuredOutput (after 2 in-conversation nudges)."):new Error("subagent completed without calling structured_output (no validation attempt \u2014 model produced plain-text content).")}let w=f.getTerminateMode();if(w!=="GOAL")throw new Error(`Workflow subagent did not complete (terminate mode: ${w}).`);let y=f.getFinalText();if(c){let S=c;c=null;let E=await J(S);E&&typeof y=="string"&&(y=We(y,E))}return y}finally{await m()}}finally{if(h&&n&&n.removeEventListener("abort",h),c)try{await J(c)}catch(s){p.warn(`Workflow worktree cleanup in fallback finally failed for ${c.path}: ${s instanceof Error?s.message:String(s)}`)}}}async function Ee(e){let t=e.getTargetDir();if(/\.matilda[\\/]worktrees[\\/]/.test(t))throw new Error(`agent({isolation:'worktree'}): parent is already inside a worktree (${t}). Nested isolation worktrees are not supported \u2014 the subagent's inherited paths would still reference the outer worktree.`);let r=new W(t),n=await r.checkGitAvailable();if(!n.available)throw new Error(`agent({isolation:'worktree'}): ${n.error??"git is not available"}.`);if(!await r.isGitRepository())throw new Error(`agent({isolation:'worktree'}): ${t} is not a git repository.`);let a=await r.getRepoTopLevel()??t,i=a===t?r:new W(a),o=!1;try{o=await i.hasWorktreeChanges(a)}catch(u){p.warn(`[Workflow] hasWorktreeChanges failed at ${a}: ${u}`),o=!0}if(o)throw new Error(`agent({isolation:'worktree'}): parent working tree at ${a} has uncommitted changes that would not propagate into the isolated worktree. The subagent would see the prior HEAD instead of the current state. Commit or stash the changes, then re-run.`);let g=Q(),l;try{l=await i.getCurrentBranch()}catch(u){p.warn(`[Workflow] getCurrentBranch failed at ${a}: ${u}`)}let c=await i.createUserWorktree(g,l,{symlinkDirectories:e.getWorktreeSymlinkDirectories()});if(!c.success||!c.worktree)throw new Error(`agent({isolation:'worktree'}): failed to create worktree: ${c.error??"unknown error"}.`);try{await q(c.worktree.path,e.getSessionId())}catch(u){p.warn(`[Workflow] failed to write session marker at ${c.worktree.path}: ${u}`)}return{slug:g,path:c.worktree.path,branch:c.worktree.branch,repoRoot:a}}function Ae(e,t){let r=Object.create(e);r.targetDir=t,r.cwd=t,r.getTargetDir=()=>t,r.getCwd=()=>t,r.getWorkingDir=()=>t,r.getProjectRoot=()=>t;let n=new Z(t);r.fileDiscoveryService=n,r.getFileService=()=>n;let a=new ee(t);return r.workspaceContext=a,r.getWorkspaceContext=()=>a,r}async function J(e){let t=new W(e.repoRoot),[r,n]=await Promise.all([t.hasWorktreeChanges(e.path).catch(a=>(p.warn(`[Workflow] hasWorktreeChanges failed for ${e.path}: ${a}`),!0)),t.hasUnmergedWorktreeCommits(e.slug).catch(a=>(p.warn(`[Workflow] hasUnmergedWorktreeCommits failed for ${e.slug}: ${a}`),!0))]);if(r||n)return p.info(`[Workflow] Preserving isolation worktree ${e.path} (branch ${e.branch}, hasChanges=${r}, hasUnmerged=${n})`),{path:e.path,branch:e.branch};try{let a=await t.removeUserWorktree(e.slug,{deleteBranch:!0});if(!a.success)return p.warn(`[Workflow] Failed to remove ephemeral worktree ${e.path}: ${a.error}`),{path:e.path,branch:e.branch};if(a.branchPreserved)return p.warn(`[Workflow] Removed worktree directory ${e.path} but kept branch ${e.branch} (unmerged commits at delete time)`),{branch:e.branch}}catch(a){return p.warn(`[Workflow] Failed to remove ephemeral worktree ${e.path}: ${a}`),{path:e.path,branch:e.branch}}return null}function We(e,t){let r=e.endsWith(`
333
333
  `)?`
@@ -1,6 +1,6 @@
1
1
  // Force strict mode and setup for ESM
2
2
  "use strict";
3
- import{a as Q}from"./chunk-OCXGNAAT.js";import{a as K}from"./chunk-I55PXD4N.js";import{Kd as b,Ld as Z,Ob as z,de as R,ee as u,ja as D,ke as q,le as G,oe as H}from"./chunk-2FYDKSRH.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-6V6R7SFP.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-2XZIKUB6.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import{Lb as j,Oa as N,_c as B,ca as L,ha as E}from"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{w as U}from"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{g as W,i as $,p as M,q as O}from"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{A as P,C as A,Y as I,a as d,c as C,z as v}from"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as x}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";x();import w from"node:fs";import y from"node:path";var T=I("WRITE_FILE"),re=["filePath","filepath","path","file","filename"];function ne(g){if(!(typeof g.file_path=="string"&&g.file_path.trim()))for(let l of re){let i=g[l];if(typeof i=="string"&&i.trim()){g.file_path=i,delete g[l];return}}}function ae(g){let l=g.content;if(typeof l!="string"||!l.includes("<arg_")&&!l.includes("</arg_"))return;let i={},e=/<arg_key>\s*([A-Za-z_][\w]*)\s*<\/arg_key>\s*<arg_value>\s*([\s\S]+?)(?:<\/arg_value>|(?=<arg_key\b)|$)/gi,o;for(;(o=e.exec(l))!==null;){let f=o[1].toLowerCase(),a=o[2].trim();a&&(i[f]=a)}let s=/(?:^|[^>])([A-Za-z_][\w]*)\s*<\/arg_key>\s*<arg_value>\s*([\s\S]+?)(?:<\/arg_value>|(?=<arg_key\b)|(?=[A-Za-z_][\w]*\s*<\/arg_key>)|$)/gi;for(;(o=s.exec(l))!==null;){let f=o[1].toLowerCase(),a=o[2].trim();(a&&!i[f]||a&&a.length>=(i[f]?.length??0))&&(i[f]=a)}let p=[l.search(/<arg_key\b/i),l.search(/<\/arg_key\b/i),l.search(/<arg_value\b/i)].filter(f=>f>=0),n=p.length>0?Math.min(...p):-1;if(n>=0&&l.slice(n,n+10).startsWith("</arg_key")){let f=l.slice(0,n),a=/([A-Za-z_][\w]*)\s*$/.exec(f);a&&(n=a.index)}let m=n>=0?l.slice(0,n).trimEnd():l;m=m.replace(/<\/?arg_(?:key|value)\b[^>]*>/gi,"").trimEnd(),g.content=m;let r=new Set(["file_path","filepath","path","file","filename"]);for(let[f,a]of Object.entries(i))!r.has(f)||!a||!a.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(a)||(typeof g.file_path!="string"||!String(g.file_path).trim()||a.length>String(g.file_path).length)&&(g.file_path=a)}var S=class extends W{constructor(i,e){super(e);this.config=i}toolLocations(){return[{path:this.params.file_path}]}getDescription(){let i=P(this.params.file_path,this.config.getTargetDir());return`Writing to ${v(i)}`}async getDefaultPermission(){let i=this.config.getProjectRoot();return U(y.resolve(this.params.file_path),i)?"allow":"ask"}async getConfirmationDetails(i){let e="",o=await E(this.params.file_path);if(!this.config.getFileReadCacheDisabled()){let r=await u(this.config.getFileReadCache(),this.params.file_path,"overwriting");if(!r.ok)throw new R(r.rawMessage,r.type)}if(o)try{let{content:r}=await this.config.getFileSystemService().readTextFile({path:this.params.file_path});e=r}catch(r){if(d(r)&&r.code==="ENOENT")o=!1;else throw new Error(`Error reading existing file for confirmation: ${C(r)}`)}if(o&&!this.config.getFileReadCacheDisabled()){let r=await u(this.config.getFileReadCache(),this.params.file_path,"overwriting",{expectExisting:!0});if(!r.ok)throw T.warn("post-read TOCTOU rejection (confirmation)",{path:this.params.file_path,reason:r.type}),new R(r.rawMessage,r.type)}let s=P(this.params.file_path,this.config.getTargetDir()),p=y.basename(this.params.file_path),n=D(p,e,this.params.content,"Current","Proposed",b);return{type:"edit",title:`Confirm Write: ${v(s)}`,fileName:p,filePath:this.params.file_path,fileDiff:n,originalContent:e,newContent:this.params.content,onConfirm:async r=>{r==="proceed_always"&&this.config.setApprovalMode("auto-edit")}}}async execute(i){let{file_path:e,content:o,ai_proposed_content:s,modified_by_user:p}=this.params,n=await E(e),m="",r=!1,f,a,V=y.dirname(e);if(!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting");if(!t.ok)return{llmContent:t.rawMessage,returnDisplay:`Error: ${t.displayMessage}`,error:{message:t.rawMessage,type:t.type}}}if(n)try{let t=await this.config.getFileSystemService().readTextFile({path:e});t._meta?.bom!==void 0?r=t._meta.bom:r=t.content.length>0&&t.content.codePointAt(0)===65279,f=t._meta?.encoding||"utf-8",a=H(t.content),m=t.content,n=!0}catch(t){if(d(t)&&t.code==="ENOENT")n=!1;else{let c={message:C(t),code:d(t)?t.code:void 0},h=c.code?`Error checking existing file '${e}': ${c.message} (${c.code})`:`Error checking existing file: ${c.message}`;return{llmContent:h,returnDisplay:h,error:{message:h,type:"file_write_failure"}}}}if(n&&!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting",{expectExisting:!0});if(!t.ok)return T.warn("post-read TOCTOU rejection (execute)",{path:e,reason:t.type}),{llmContent:t.rawMessage,returnDisplay:`Error: ${t.displayMessage}`,error:{message:t.rawMessage,type:t.type}}}if(!n){let t=this.config.getDefaultFileEncoding();t===q.UTF8_BOM?r=!0:t===void 0&&(r=G(e)),f=void 0}try{await this.config.getFileHistoryService().trackEdit(e)}catch{}if(!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting",{expectExisting:n});if(!t.ok)return T.warn("pre-write TOCTOU rejection",{path:e,reason:t.type}),{llmContent:t.rawMessage,returnDisplay:`Error: ${t.displayMessage}`,error:{message:t.rawMessage,type:t.type}}}n||w.mkdirSync(V,{recursive:!0});try{await this.config.getFileSystemService().writeTextFile({path:e,content:o,_meta:{bom:r,encoding:f,lineEnding:a}}),p||z.getInstance().recordEdit(e,n?m:null,o);try{let _=w.statSync(e);this.config.getFileReadCache().recordWrite(e,_)}catch{}let t=y.basename(e),c=m,h=D(t,c,o,"Original","Written",b),Y=Z(t,c,s||o,o),F=[n?`Successfully overwrote file: ${e}.`:`Successfully created and wrote to new file: ${e}.`];p&&F.push(`User modified the \`content\` to be: ${o}`);let J=L(e),X=N(e),ee=y.extname(e),te=n?"update":"create",ie=o.split(`
3
+ import{a as Q}from"./chunk-OCXGNAAT.js";import{a as K}from"./chunk-I55PXD4N.js";import{Kd as b,Ld as Z,Ob as z,de as R,ee as u,ja as D,ke as q,le as G,oe as H}from"./chunk-2D5W3WW7.js";import"./chunk-TZIDSCTF.js";import"./chunk-FUNLOUYI.js";import"./chunk-R3H6IWFK.js";import"./chunk-OMZ5SGMK.js";import"./chunk-GIIMOLLN.js";import"./chunk-RBG4ERTN.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-LQWORCPO.js";import"./chunk-TISQNFB5.js";import"./chunk-SS5WUOSJ.js";import"./chunk-47XR7IMP.js";import"./chunk-QEI3OETI.js";import"./chunk-QKYGQLWC.js";import"./chunk-MNGFXISD.js";import"./chunk-4R2OFVPK.js";import"./chunk-RNKDFE2S.js";import"./chunk-EMWHQSMS.js";import"./chunk-S4K76QPI.js";import"./chunk-OVZKSZIR.js";import"./chunk-4F4DA5UI.js";import"./chunk-DC7LAFZZ.js";import"./chunk-7VBRP4XQ.js";import"./chunk-XYA3SFGC.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-XJDC3ZQZ.js";import{Lb as j,Oa as N,_c as B,ca as L,ha as E}from"./chunk-CFBZKYFB.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{w as U}from"./chunk-UY2R3ZQ4.js";import"./chunk-NDR7ZFUA.js";import{g as W,i as $,p as M,q as O}from"./chunk-5U3A6KMU.js";import"./chunk-IMYUVCF7.js";import"./chunk-XKDGRW3K.js";import"./chunk-ESSYHTAZ.js";import"./chunk-3YLXGE6T.js";import"./chunk-IOCF4XSR.js";import{A as P,C as A,Y as I,a as d,c as C,z as v}from"./chunk-QWBNNEV2.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as x}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";x();import w from"node:fs";import y from"node:path";var T=I("WRITE_FILE"),re=["filePath","filepath","path","file","filename"];function ne(g){if(!(typeof g.file_path=="string"&&g.file_path.trim()))for(let l of re){let i=g[l];if(typeof i=="string"&&i.trim()){g.file_path=i,delete g[l];return}}}function ae(g){let l=g.content;if(typeof l!="string"||!l.includes("<arg_")&&!l.includes("</arg_"))return;let i={},e=/<arg_key>\s*([A-Za-z_][\w]*)\s*<\/arg_key>\s*<arg_value>\s*([\s\S]+?)(?:<\/arg_value>|(?=<arg_key\b)|$)/gi,o;for(;(o=e.exec(l))!==null;){let f=o[1].toLowerCase(),a=o[2].trim();a&&(i[f]=a)}let s=/(?:^|[^>])([A-Za-z_][\w]*)\s*<\/arg_key>\s*<arg_value>\s*([\s\S]+?)(?:<\/arg_value>|(?=<arg_key\b)|(?=[A-Za-z_][\w]*\s*<\/arg_key>)|$)/gi;for(;(o=s.exec(l))!==null;){let f=o[1].toLowerCase(),a=o[2].trim();(a&&!i[f]||a&&a.length>=(i[f]?.length??0))&&(i[f]=a)}let p=[l.search(/<arg_key\b/i),l.search(/<\/arg_key\b/i),l.search(/<arg_value\b/i)].filter(f=>f>=0),n=p.length>0?Math.min(...p):-1;if(n>=0&&l.slice(n,n+10).startsWith("</arg_key")){let f=l.slice(0,n),a=/([A-Za-z_][\w]*)\s*$/.exec(f);a&&(n=a.index)}let m=n>=0?l.slice(0,n).trimEnd():l;m=m.replace(/<\/?arg_(?:key|value)\b[^>]*>/gi,"").trimEnd(),g.content=m;let r=new Set(["file_path","filepath","path","file","filename"]);for(let[f,a]of Object.entries(i))!r.has(f)||!a||!a.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(a)||(typeof g.file_path!="string"||!String(g.file_path).trim()||a.length>String(g.file_path).length)&&(g.file_path=a)}var S=class extends W{constructor(i,e){super(e);this.config=i}toolLocations(){return[{path:this.params.file_path}]}getDescription(){let i=P(this.params.file_path,this.config.getTargetDir());return`Writing to ${v(i)}`}async getDefaultPermission(){let i=this.config.getProjectRoot();return U(y.resolve(this.params.file_path),i)?"allow":"ask"}async getConfirmationDetails(i){let e="",o=await E(this.params.file_path);if(!this.config.getFileReadCacheDisabled()){let r=await u(this.config.getFileReadCache(),this.params.file_path,"overwriting");if(!r.ok)throw new R(r.rawMessage,r.type)}if(o)try{let{content:r}=await this.config.getFileSystemService().readTextFile({path:this.params.file_path});e=r}catch(r){if(d(r)&&r.code==="ENOENT")o=!1;else throw new Error(`Error reading existing file for confirmation: ${C(r)}`)}if(o&&!this.config.getFileReadCacheDisabled()){let r=await u(this.config.getFileReadCache(),this.params.file_path,"overwriting",{expectExisting:!0});if(!r.ok)throw T.warn("post-read TOCTOU rejection (confirmation)",{path:this.params.file_path,reason:r.type}),new R(r.rawMessage,r.type)}let s=P(this.params.file_path,this.config.getTargetDir()),p=y.basename(this.params.file_path),n=D(p,e,this.params.content,"Current","Proposed",b);return{type:"edit",title:`Confirm Write: ${v(s)}`,fileName:p,filePath:this.params.file_path,fileDiff:n,originalContent:e,newContent:this.params.content,onConfirm:async r=>{r==="proceed_always"&&this.config.setApprovalMode("auto-edit")}}}async execute(i){let{file_path:e,content:o,ai_proposed_content:s,modified_by_user:p}=this.params,n=await E(e),m="",r=!1,f,a,V=y.dirname(e);if(!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting");if(!t.ok)return{llmContent:t.rawMessage,returnDisplay:`Error: ${t.displayMessage}`,error:{message:t.rawMessage,type:t.type}}}if(n)try{let t=await this.config.getFileSystemService().readTextFile({path:e});t._meta?.bom!==void 0?r=t._meta.bom:r=t.content.length>0&&t.content.codePointAt(0)===65279,f=t._meta?.encoding||"utf-8",a=H(t.content),m=t.content,n=!0}catch(t){if(d(t)&&t.code==="ENOENT")n=!1;else{let c={message:C(t),code:d(t)?t.code:void 0},h=c.code?`Error checking existing file '${e}': ${c.message} (${c.code})`:`Error checking existing file: ${c.message}`;return{llmContent:h,returnDisplay:h,error:{message:h,type:"file_write_failure"}}}}if(n&&!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting",{expectExisting:!0});if(!t.ok)return T.warn("post-read TOCTOU rejection (execute)",{path:e,reason:t.type}),{llmContent:t.rawMessage,returnDisplay:`Error: ${t.displayMessage}`,error:{message:t.rawMessage,type:t.type}}}if(!n){let t=this.config.getDefaultFileEncoding();t===q.UTF8_BOM?r=!0:t===void 0&&(r=G(e)),f=void 0}try{await this.config.getFileHistoryService().trackEdit(e)}catch{}if(!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting",{expectExisting:n});if(!t.ok)return T.warn("pre-write TOCTOU rejection",{path:e,reason:t.type}),{llmContent:t.rawMessage,returnDisplay:`Error: ${t.displayMessage}`,error:{message:t.rawMessage,type:t.type}}}n||w.mkdirSync(V,{recursive:!0});try{await this.config.getFileSystemService().writeTextFile({path:e,content:o,_meta:{bom:r,encoding:f,lineEnding:a}}),p||z.getInstance().recordEdit(e,n?m:null,o);try{let _=w.statSync(e);this.config.getFileReadCache().recordWrite(e,_)}catch{}let t=y.basename(e),c=m,h=D(t,c,o,"Original","Written",b),Y=Z(t,c,s||o,o),F=[n?`Successfully overwrote file: ${e}.`:`Successfully created and wrote to new file: ${e}.`];p&&F.push(`User modified the \`content\` to be: ${o}`);let J=L(e),X=N(e),ee=y.extname(e),te=n?"update":"create",ie=o.split(`
4
4
  `).length;j(this.config,new B(k.Name,te,ie,J,ee,X));let oe={fileDiff:h,fileName:t,originalContent:m,newContent:o,diffStat:Y};try{let _=await K(this.config,e);_&&F.push(`
5
5
 
6
6
  ${_}`)}catch{}return{llmContent:F.join(" "),returnDisplay:oe}}catch(t){let c,h="file_write_failure";return d(t)?(c=`Error writing to file '${e}': ${t.message} (${t.code})`,t.code==="EACCES"?(c=`Permission denied writing to file: ${e} (${t.code})`,h="permission_denied"):t.code==="ENOSPC"?(c=`No space left on device: ${e} (${t.code})`,h="no_space_left"):t.code==="EISDIR"&&(c=`Target is a directory, not a file: ${e} (${t.code})`,h="target_is_directory"),this.config.getDebugMode()&&t.stack&&T.debug("Write file error stack:",t.stack)):t instanceof Error?c=`Error writing to file: ${t.message}`:c=`Error writing to file: ${String(t)}`,{llmContent:c,returnDisplay:c,error:{message:c,type:h}}}}},k=class g extends ${constructor(i){super(g.Name,O.WRITE_FILE,`Writes content to a specified file in the local filesystem.