@maincode-ai/matilda-code 0.22.1-nightly.20261105.01f208d6a → 0.22.1-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chunks/{agent-F6Y3FBPC.js → agent-BXVCIBXW.js} +1 -1
- package/chunks/agent-headless-64NUELGA.js +3 -0
- package/chunks/{ca-KK3CSNJV.js → ca-JKEHLTNL.js} +1 -1
- package/chunks/{chunk-54K2GMNG.js → chunk-6T25BBKH.js} +2 -2
- package/chunks/{chunk-D6ATZU24.js → chunk-7AEOFDY3.js} +1 -1
- package/chunks/{chunk-YR3OUNU7.js → chunk-7YEKK577.js} +543 -545
- package/chunks/chunk-A5QKQKJW.js +56 -0
- package/chunks/{chunk-A3UGYH47.js → chunk-BSSOFLAZ.js} +29 -29
- package/chunks/{chunk-I2Q4WRE6.js → chunk-DEN6RR3B.js} +1 -1
- package/chunks/{chunk-VD5XR455.js → chunk-FI2FSW7J.js} +1 -1
- package/chunks/{chunk-B5O45YRW.js → chunk-HRCRNKY2.js} +1 -1
- package/chunks/{chunk-ZZGHDGL2.js → chunk-LONWTJOE.js} +1 -1
- package/chunks/{chunk-V2U6MNOB.js → chunk-RH3AEZWO.js} +1 -1
- package/chunks/chunk-S6SR7XG2.js +121 -0
- package/chunks/chunk-SMTY6M3W.js +10 -0
- package/chunks/{chunk-7WLO2FTP.js → chunk-UICLGQTV.js} +1 -1
- package/chunks/{computer-use-QWVA4ZRO.js → computer-use-2YIT7SIT.js} +1 -1
- package/chunks/{cron-create-PTIXAISF.js → cron-create-JINCFLKY.js} +1 -1
- package/chunks/{cron-delete-LML4BH5C.js → cron-delete-RF6JLUAV.js} +1 -1
- package/chunks/{cron-list-AKUDRXAB.js → cron-list-VXLBAXZ3.js} +1 -1
- package/chunks/{de-KAVSNPR3.js → de-GMGNR5CZ.js} +1 -1
- package/chunks/{edit-ZCITLTVJ.js → edit-6S3DRURW.js} +1 -1
- package/chunks/{en-73P6V3X4.js → en-3NQMLVKW.js} +2 -2
- package/chunks/{enter-worktree-XKEF7LJ5.js → enter-worktree-57EOUOC4.js} +1 -1
- package/chunks/{enterPlanMode-JD5EMTXK.js → enterPlanMode-EWO2LZ5G.js} +1 -1
- package/chunks/{exit-worktree-SQT3GPQF.js → exit-worktree-T7IHIQX5.js} +1 -1
- package/chunks/{exitPlanMode-WDPXP5GY.js → exitPlanMode-YW7MKP6A.js} +1 -1
- package/chunks/{fr-7MHU2PHX.js → fr-WS3EBB36.js} +1 -1
- package/chunks/{glob-L2ROPIKH.js → glob-EYNPF6KD.js} +1 -1
- package/chunks/{goal-tools-SGHCW7AA.js → goal-tools-F2V2CXAF.js} +1 -1
- package/chunks/{grep-TRNYLXUE.js → grep-CDC2COXY.js} +1 -1
- package/chunks/{ja-SEGM4PXR.js → ja-GBCDQ43R.js} +1 -1
- package/chunks/{mcp-client-AFWXY5V7.js → mcp-client-3GTPI6IS.js} +1 -1
- package/chunks/{monitor-XBFBTRP3.js → monitor-AHLS4MYF.js} +1 -1
- package/chunks/{notebook-edit-FVSA2KZF.js → notebook-edit-6HEQYPZ3.js} +1 -1
- package/chunks/openaiContentGenerator-CQQ7EBHB.js +47 -0
- package/chunks/{pt-THNGLRFB.js → pt-VID6J2CM.js} +1 -1
- package/chunks/{read-file-54P2W2NY.js → read-file-EWNDGS3Y.js} +1 -1
- package/chunks/ripGrep-6BXNDTIT.js +3 -0
- package/chunks/{ru-2L5KSVTY.js → ru-EB6V6EAN.js} +1 -1
- package/chunks/{scheduler-YUNHWHAL.js → scheduler-FLVTLJFY.js} +1 -1
- package/chunks/{shell-R7UGVVVV.js → shell-FVBBSL2E.js} +1 -1
- package/chunks/{skill-WZWTSRCS.js → skill-AR3SRFYF.js} +4 -4
- package/chunks/{task-create-MCGSNOWH.js → task-create-QP44DKH4.js} +1 -1
- package/chunks/{task-detach-VSCQRKSV.js → task-detach-AUTU6C4G.js} +1 -1
- package/chunks/{task-list-ZD2T73HE.js → task-list-U2WAGMM7.js} +1 -1
- package/chunks/{task-update-C56UMB2O.js → task-update-26N2AUQT.js} +1 -1
- package/chunks/{team-create-TEP6Y27B.js → team-create-RPZE626O.js} +1 -1
- package/chunks/{team-delete-6P2O7TRJ.js → team-delete-XCKD5FBZ.js} +1 -1
- package/chunks/{todoWrite-U5AYK4GF.js → todoWrite-JN3ZV5O2.js} +1 -1
- package/chunks/{tool-search-462NI7DC.js → tool-search-RDU7B45X.js} +1 -1
- package/chunks/{web-search-6QHTZ35S.js → web-search-3IXDQD7D.js} +5 -3
- package/chunks/{workflow-OOFJGV3R.js → workflow-P6YL6ZHY.js} +2 -2
- package/chunks/{write-file-SF445TAM.js → write-file-BYAPFQ5P.js} +1 -1
- package/cli.js +444 -446
- package/locales/ca.js +0 -4
- package/locales/de.js +0 -4
- package/locales/en.js +0 -33
- package/locales/fr.js +0 -4
- package/locales/ja.js +0 -4
- package/locales/pt.js +0 -4
- package/locales/ru.js +0 -4
- package/package.json +2 -2
- package/chunks/agent-headless-RKIG74AU.js +0 -3
- package/chunks/chunk-5TTIBD3W.js +0 -10
- package/chunks/chunk-MIOXSKFZ.js +0 -56
- package/chunks/chunk-RUMEGWK4.js +0 -121
- package/chunks/openaiContentGenerator-MZIEWJKV.js +0 -52
- package/chunks/ripGrep-QFOHUYTD.js +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as N}from"./chunk-
|
|
3
|
+
import{a as N}from"./chunk-FI2FSW7J.js";import{a as h,b as f,e as $,f as y,g,h as v,i as I}from"./chunk-HRCRNKY2.js";import"./chunk-UICLGQTV.js";import{b as k,d as j,e as P}from"./chunk-QXSBPCBA.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-7AEOFDY3.js";import{f as T,g as C,m as b,n as D}from"./chunk-KYNP66YS.js";import"./chunk-AEYNMLMW.js";import"./chunk-HEJO7OBH.js";import{b as w}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";w();async function A(u,n,e,s){let i=await I(u),d=new Map,l=(t,r)=>{let a=d.get(t);a||(a=new Set,d.set(t,a)),a.add(r)};for(let t of i){for(let r of t.blocks)l(t.id,r);for(let r of t.blockedBy)l(r,t.id)}for(let t of e)l(n,t);for(let t of s)l(t,n);let o=[],c=new Set,p=t=>{o.push(t);for(let r of d.get(t)??[]){if(r===n)return[...o,n];if(c.has(r))continue;c.add(r);let a=p(r);if(a)return a}return o.pop(),null};return c.add(n),p(n)}var B=class extends T{constructor(e,s){super(s);this.config=e}getDescription(){let e=[`Task #${this.params.taskId}`];return this.params.status&&e.push(`\u2192 ${this.params.status}`),this.params.owner&&e.push(`owner: ${this.params.owner}`),e.join(" ")}async getDefaultPermission(){return"ask"}getConfirmationDetails(e){let s=[this.getDescription()];this.params.subject!==void 0&&s.push(`subject: ${this.params.subject}`),this.params.addBlocks?.length&&s.push(`blocks: ${this.params.addBlocks.join(", ")}`),this.params.addBlockedBy?.length&&s.push(`blocked by: ${this.params.addBlockedBy.join(", ")}`),this.params.description!==void 0&&s.push("",N(this.params.description));let i={type:"info",title:"Confirm TaskUpdate",prompt:s.join(`
|
|
4
4
|
`),onConfirm:async()=>{}};return Promise.resolve(i)}async execute(){let e=j(this.config.getTeamContext()?.teamName);if(!e){let t="No active team. Create a team first.";return{llmContent:t,returnDisplay:t,error:{message:t}}}let{taskId:s}=this.params;try{f(s);for(let t of this.params.addBlocks??[])f(t);for(let t of this.params.addBlockedBy??[])f(t)}catch(t){let r=t instanceof Error?t.message:String(t);return{llmContent:r,returnDisplay:r,error:{message:r}}}let i=P()?k():void 0;if(this.params.status==="deleted"){let t;try{t=await v(e,s,i!==void 0?{callerName:i}:void 0)}catch(a){if(a instanceof y)return{llmContent:a.message,returnDisplay:a.message,error:{message:a.message}};throw a}if(!t){let a=`Task #${s} not found.`;return{llmContent:a,returnDisplay:a,error:{message:a}}}let r=`Task #${s} deleted.`;return{llmContent:r,returnDisplay:r}}if(this.params.addBlocks?.includes(s)||this.params.addBlockedBy?.includes(s)){let t=`Cannot update task #${s}: a task cannot block or be blocked by itself.`;return{llmContent:t,returnDisplay:t,error:{message:t}}}let d=new Set;for(let t of this.params.addBlocks??[])t!==s&&d.add(t);for(let t of this.params.addBlockedBy??[])t!==s&&d.add(t);if(d.size>0){let t=[];if(await Promise.all(Array.from(d).map(async a=>{await $(e,a)||t.push(a)})),t.length>0){let a=t.sort().map(U=>`#${U}`).join(", "),m=`Cannot update task #${s}: referenced task${t.length===1?"":"s"} ${a} not found.`;return{llmContent:m,returnDisplay:m,error:{message:m}}}let r=await A(e,s,this.params.addBlocks??[],this.params.addBlockedBy??[]);if(r){let a=`Cannot update task #${s}: this would create a dependency cycle (${r.map(m=>`#${m}`).join(" \u2192 ")}).`;return{llmContent:a,returnDisplay:a,error:{message:a}}}}let l=this.params.status==="in_progress"&&this.params.owner===void 0?k():void 0;if(this.params.status==="in_progress"&&!this.params.owner&&!l){let t=`Cannot move task #${s} to in_progress without an owner. Specify the "owner" parameter.`;return{llmContent:t,returnDisplay:t,error:{message:t}}}let o;try{o=await g(e,s,{status:this.params.status,owner:this.params.owner??l,subject:this.params.subject,description:this.params.description,activeForm:this.params.activeForm,metadata:this.params.metadata,addBlocks:this.params.addBlocks,addBlockedBy:this.params.addBlockedBy},i!==void 0?{callerName:i}:void 0)}catch(t){if(t instanceof y)return{llmContent:t.message,returnDisplay:t.message,error:{message:t.message}};throw t}if(!o){let t=`Task #${s} not found.`;return{llmContent:t,returnDisplay:t,error:{message:t}}}let c=[];if(this.params.addBlocks?.length&&this.params.status!=="completed")for(let t of this.params.addBlocks)t!==s&&c.push(g(e,t,{addBlockedBy:[s]},{callerName:h}));if(this.params.addBlockedBy?.length)for(let t of this.params.addBlockedBy)t!==s&&c.push(g(e,t,{addBlocks:[s]},{callerName:h}));c.length>0&&await Promise.all(c);let p=`Task #${s} updated (status: ${o.status}`+(o.owner?`, owner: ${o.owner}`:"")+").";return{llmContent:p,returnDisplay:p}}},S=class u extends C{constructor(e){super(u.Name,D.TASK_UPDATE,'Update an existing task. Can change status, owner, subject, description, and blocking relationships. Set status to "deleted" to remove a task. Setting status to "in_progress" auto-assigns you as owner if no owner is set.',"other",{type:"object",properties:{taskId:{type:"string",description:"ID of the task to update."},status:{type:"string",enum:["pending","in_progress","completed","deleted"],description:"New task status."},owner:{type:"string",description:"New owner agent name. Set to empty string to unassign."},subject:{type:"string",maxLength:200,description:"Updated task title."},description:{type:"string",maxLength:1e4,description:"Updated task description."},activeForm:{type:"string",maxLength:200,description:"Present tense label for UI."},metadata:{type:"object",description:"Metadata to merge. Set a key to null to delete it."},addBlocks:{type:"array",items:{type:"string"},description:"Task IDs that this task blocks."},addBlockedBy:{type:"array",items:{type:"string"},description:"Task IDs that block this task."}},required:["taskId"],additionalProperties:!1});this.config=e}static Name=b.TASK_UPDATE;createInvocation(e){return new B(this.config,e)}toAutoClassifierInput(e){return{taskId:e.taskId,status:e.status,owner:e.owner,subject:e.subject,description:e.description,addBlocks:e.addBlocks,addBlockedBy:e.addBlockedBy}}};export{S as TaskUpdateTool};
|
|
5
5
|
/**
|
|
6
6
|
* @license
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{Nc as u,Oc as C}from"./chunk-7YEKK577.js";import{j as A}from"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import{i as v}from"./chunk-RH3AEZWO.js";import{b as y,d as w,e as T,f as k,l as o,m as b}from"./chunk-UICLGQTV.js";import"./chunk-A5QKQKJW.js";import"./chunk-YY64FVJG.js";import"./chunk-SMTY6M3W.js";import{g as f}from"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-BSSOFLAZ.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-S6SR7XG2.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-FPGKJJJY.js";import"./chunk-6T25BBKH.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as c,g,m as h,n as p}from"./chunk-KYNP66YS.js";import{c as d}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.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=T(this.params.team_name);if(!e){let t="Team name is required.";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=k(f,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 b(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 "${y(e)}" "${w(e)}"`;return{llmContent:n,returnDisplay:n,error:{message:n}}}await o(e,s)}else throw t}await A(e),await v(e);let m=new u(this.config);await m.init();let x=new C(m,s,this.config.getSubagentManager(),{maxTeammates:this.config.getAgentsSettings().team?.maxTeammates});this.config.setTeamManager(x);let M={teamName:e,leadAgentId:a,teammates:{}};this.config.setTeamContext(M);let N={type:"team_result",teamName:e,action:"created"};return{llmContent:`Team "${e}" created.`+(this.params.description?` Description: ${this.params.description}`:""),returnDisplay:N}}},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{a as T,d as f}from"./chunk-
|
|
3
|
+
import{a as T,d as f}from"./chunk-RH3AEZWO.js";import{n as o}from"./chunk-UICLGQTV.js";import{e as g}from"./chunk-QXSBPCBA.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-7AEOFDY3.js";import{f as l,g as c,m as p,n as u}from"./chunk-KYNP66YS.js";import{Y as i}from"./chunk-AEYNMLMW.js";import"./chunk-HEJO7OBH.js";import{b as m}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";m();var E=i("TEAM_DELETE"),r=class extends l{constructor(t,n){super(n);this.config=t}getDescription(){return"Delete current team"}async execute(){if(g()){let e="Only the team leader can delete the team.";return{llmContent:e,returnDisplay:e,error:{message:e}}}let t=this.config.getTeamManager();if(!t){let e="No active team to delete.";return{llmContent:e,returnDisplay:e,error:{message:e}}}let a=t.getTeamFile().name;try{await t.cleanup()}catch(e){E.warn("Team cleanup failed; resetting team state anyway:",e)}await o(a),await new Promise(e=>setTimeout(e,250)),await o(a),f(a),this.config.setTeamManager(null),this.config.setTeamContext(null),T();let y={type:"team_result",teamName:a,action:"deleted"};return{llmContent:`Team "${a}" deleted.`,returnDisplay:y}}},d=class s extends c{constructor(t){super(s.Name,u.TEAM_DELETE,"Delete the current team. Stops all teammates, cleans up team files, tasks, and inboxes. Only the team leader can use this.","delete",{type:"object",properties:{},additionalProperties:!1});this.config=t}static Name=p.TEAM_DELETE;createInvocation(t){return new r(this.config,t)}};export{d as TeamDeleteTool};
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2025 Matilda
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a,b,c}from"./chunk-
|
|
3
|
+
import{a,b,c}from"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import"./chunk-KYNP66YS.js";import"./chunk-AEYNMLMW.js";import"./chunk-HEJO7OBH.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{c as TodoWriteTool,b as listTodoSessions,a as readTodosForSession};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{lb as N}from"./chunk-
|
|
3
|
+
import{lb as N}from"./chunk-6T25BBKH.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as v,g as R,m as E,n as L}from"./chunk-KYNP66YS.js";import{Y as S}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as C}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";C();var y=S("TOOL_SEARCH"),D=5,A=20,b=10,x=5,$=4,k=2,q=12,M=6,P=`Fetches function declarations for deferred tools and registers them with the active session so subsequent turns can call them.
|
|
4
4
|
|
|
5
5
|
Deferred tools appear by name in the deferred-tools startup reminder. Until fetched, only the name is known \u2014 there is no parameter schema, so the tool cannot be invoked. This tool takes a query, matches it against the deferred tool list, and returns the matched tools' function declarations (name + description + parameter schema) inside a <functions> block.
|
|
6
6
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
4
|
-
`)}function
|
|
3
|
+
import{Z as w,o as y,v as b}from"./chunk-S6SR7XG2.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-FPGKJJJY.js";import"./chunk-6T25BBKH.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as m,g as h,m as c,n as g}from"./chunk-KYNP66YS.js";import{Y as f}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as d}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";d();var C=f("WEB_SEARCH");function v(r){return r.getContentGeneratorConfig?.()?.baseUrl||process.env.OPENAI_BASE_URL||b()}function T(r){return process.env.MATILDA_WEB_SEARCH_URL?process.env.MATILDA_WEB_SEARCH_URL:`${y(v(r))}/api/v1/tools/web_search`}function R(r){let o=r.getContentGeneratorConfig?.();return w({baseUrl:v(r),fallbackAccessToken:o?.apiKey,apiKeyEnvKey:o?.apiKeyEnvKey,channel:r.getChannel?.()})}function _(r,o,a,n){let i=[];if(a&&i.push(a,""),o.length===0)i.push(`No web results for "${r}".`);else{i.push(`Web results for "${r}":`);for(let[t,e]of o.entries())i.push(`${t+1}. ${e.title??"(untitled)"}`,` ${e.url??""}`,e.snippet?` ${e.snippet}`:"")}return n&&i.push("",n),i.filter(t=>t!==void 0).join(`
|
|
4
|
+
`)}function P(r){if(!r||typeof r!="object")return;let o=[],a=r.mode;typeof a=="string"&&o.push(`mode=${a}`);let n=r.external_providers;Array.isArray(n)&&n.length&&o.push(`discovery=${n.join(",")}`);let i=r.local_providers;Array.isArray(i)&&i.length&&o.push(`local=${i.join(",")}`);let t=r.firecrawl_successes,e=r.firecrawl_attempts;return(typeof t=="number"||typeof e=="number")&&o.push(`firecrawl_extract=${typeof t=="number"?t:0}/${typeof e=="number"?e:"?"}`),o.length===0?"Pipeline: Matilda Core mcp-search (Exa discovery + self-hosted Firecrawl extract when enabled).":`Pipeline: Core mcp-search (${o.join("; ")}).`}var S=`
|
|
5
5
|
|
|
6
6
|
IMPORTANT \u2014 DO NOT STOP:
|
|
7
7
|
The user needs web-grounded evidence. Keep working until you can answer with sources:
|
|
8
8
|
1. Call web_search again with a clearer query (quotes around names, full context). Prefer mode "deep" for people/research questions.
|
|
9
9
|
2. If Core is still failing, say so clearly and use web_fetch only when you already have a concrete URL.
|
|
10
10
|
3. Do NOT switch to the firecrawl-search skill / local firecrawl CLI \u2014 Matilda's Exa + self-hosted Firecrawl path is only via Core web_search.
|
|
11
|
-
4. Only after those retries fail may you tell the user search is unavailable.`,u=class extends m{constructor(a,n){super(n);this.config=a}async getDefaultPermission(){return"allow"}getDescription(){return`Web search (${this.params.mode??"auto"}): ${this.params.query}`}async callCore(a,n,i,t){let e=
|
|
11
|
+
4. Only after those retries fail may you tell the user search is unavailable.`,u=class extends m{constructor(a,n){super(n);this.config=a}async getDefaultPermission(){return"allow"}getDescription(){return`Web search (${this.params.mode??"auto"}): ${this.params.query}`}async callCore(a,n,i,t){let e=T(this.config),l;try{l=await R(this.config)}catch(s){return{ok:!1,message:s instanceof Error?s.message:String(s)}}if(!l)return{ok:!1,message:"web_search requires Matilda authentication (MATILDA_API_KEY or signed-in session)."};try{let s=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({query:a,max_results:n,mode:i}),signal:t});if(!s.ok){let E=await s.text().catch(()=>"");return{ok:!1,status:s.status,message:s.status===404?"web_search endpoint not found on Core (deploy core-api tools route)":`HTTP ${s.status}: ${E.slice(0,300)}`}}return{ok:!0,data:await s.json()}}catch(s){return{ok:!1,message:s instanceof Error?s.message:String(s)}}}async execute(a){let n=this.params.query?.trim();if(!n)return{llmContent:"Error: query is required",returnDisplay:"Error: query is required",error:{message:"query is required",type:"invalid_tool_params"}};let i=this.params.max_results??5,t=this.params.mode??"auto";t!=="auto"&&t!=="fast"&&t!=="deep"&&(t="auto");let e=await this.callCore(n,i,t,a);if(!a.aborted&&t!=="deep"&&e.ok&&(!e.data.results||e.data.results.length===0)&&!e.data.answer&&(C.debug("web_search empty under mode=%s; escalating to deep",t),e=await this.callCore(n,i,"deep",a),t="deep"),!e.ok)return C.debug(`web_search failed: ${e.message}`),{llmContent:`web_search failed: ${e.message}`+S,returnDisplay:e.status===404?"web_search unavailable (404)":"web_search failed",error:{message:e.message,type:"execution_failed"}};let l=Array.isArray(e.data.results)?e.data.results:[],s=P({mode:t,...e.data.metadata??{}});return l.length===0&&!e.data.answer?{llmContent:_(n,l,e.data.answer,s)+S,returnDisplay:"No results"}:{llmContent:_(n,l,e.data.answer,s),returnDisplay:`Found ${l.length} result(s) via Core (${t})`}}},A=class extends h{constructor(a){super(c.WEB_SEARCH,g.WEB_SEARCH,"Search the public web via Matilda Core mcp-search: Exa for discovery (entity/neural when configured) and self-hosted Firecrawl for page extraction. Prefer this for open-web questions. Modes: auto (default), fast, deep. On empty auto results the tool escalates to deep once. Keep working until you have sources \u2014 do not stop after one failed search, and do not use the firecrawl skill/CLI.","search",{type:"object",properties:{query:{type:"string",description:"Search query"},max_results:{type:"number",description:"Maximum results to return (default 5)"},mode:{type:"string",enum:["auto","fast","deep"],description:"Retrieval depth on Core (auto default). deep forces multi-query + Firecrawl extract; use for people/research when auto is thin."}},required:["query"]});this.config=a}static Name=c.WEB_SEARCH;createInvocation(a){return new u(this.config,a)}};export{A as WebSearchTool};
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
14
14
|
* Copyright 2026 Matilda Team
|
|
@@ -21,4 +21,6 @@ The user needs web-grounded evidence. Keep working until you can answer with sou
|
|
|
21
21
|
* mcp-search already composes both backends (no CLI Firecrawl skill path):
|
|
22
22
|
* - **Exa** (when SEARCH_PROVIDER=exa): neural discovery / entity search
|
|
23
23
|
* - **Self-hosted Firecrawl**: page extract on fast top-N + deep retrieval
|
|
24
|
+
*
|
|
25
|
+
* Override with MATILDA_WEB_SEARCH_URL when Core path differs.
|
|
24
26
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{Ac as Q,Bc as W,Cc as Z,Dc as ee,Jc as te,sc as V,yc as q}from"./chunk-7YEKK577.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-A5QKQKJW.js";import"./chunk-YY64FVJG.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-BSSOFLAZ.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import{Q as z}from"./chunk-S6SR7XG2.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-FPGKJJJY.js";import"./chunk-6T25BBKH.js";import"./chunk-IV6PS6DB.js";import{b as Y}from"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as K,g as X,m as v,n as H}from"./chunk-KYNP66YS.js";import{Y as G}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.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-
|
|
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-64NUELGA.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 _}from"./chunk-TDFF4ZGY.js";import{
|
|
3
|
+
import{a as _}from"./chunk-TDFF4ZGY.js";import{Nb as k,Ob as q,Yb as C,Zb as u,bc as G,cc as Q,dc as V,ec as Y,gb as Z,ya as S}from"./chunk-7YEKK577.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-A5QKQKJW.js";import"./chunk-YY64FVJG.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-BSSOFLAZ.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-S6SR7XG2.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-FPGKJJJY.js";import{C as w,Db as K,H as B,xa as z,z as U}from"./chunk-6T25BBKH.js";import{l as H}from"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as $,g as N,m as L,n as j}from"./chunk-KYNP66YS.js";import{C as R,D as b,F as O,Y as M,c as d,e as D}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as I}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";I();import P from"node:fs";import y from"node:path";var F=M("WRITE_FILE"),ae=["filePath","filepath","path","file","filename"];function le(f){if(!(typeof f.file_path=="string"&&f.file_path.trim()))for(let a of ae){let o=f[a];if(typeof o=="string"&&o.trim()){f.file_path=o,delete f[a];return}}}function ce(f){let a=f.content;if(typeof a!="string"||!a.includes("<arg_")&&!a.includes("</arg_"))return;let o={},e=/<arg_key>\s*([A-Za-z_][\w]*)\s*<\/arg_key>\s*<arg_value>\s*([\s\S]+?)(?:<\/arg_value>|(?=<arg_key\b)|$)/gi,r;for(;(r=e.exec(a))!==null;){let i=r[1].toLowerCase(),n=r[2].trim();n&&(o[i]=n)}let l=/(?:^|[^>])([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(;(r=l.exec(a))!==null;){let i=r[1].toLowerCase(),n=r[2].trim();(n&&!o[i]||n&&n.length>=(o[i]?.length??0))&&(o[i]=n)}let h=[a.search(/<arg_key\b/i),a.search(/<\/arg_key\b/i),a.search(/<arg_value\b/i)].filter(i=>i>=0),g=h.length>0?Math.min(...h):-1;if(g>=0&&a.slice(g,g+10).startsWith("</arg_key")){let i=a.slice(0,g),n=/([A-Za-z_][\w]*)\s*$/.exec(i);n&&(g=n.index)}let c=g>=0?a.slice(0,g).trimEnd():a;c=c.replace(/<\/?arg_(?:key|value)\b[^>]*>/gi,"").trimEnd(),f.content=c;let m=new Set(["file_path","filepath","path","file","filename"]);for(let[i,n]of Object.entries(o))!m.has(i)||!n||!n.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(n)||(typeof f.file_path!="string"||!String(f.file_path).trim()||n.length>String(f.file_path).length)&&(f.file_path=n)}var A=class extends ${constructor(o,e){super(e);this.config=o}toolLocations(){return[{path:this.params.file_path}]}getDescription(){let o=b(this.params.file_path,this.config.getTargetDir());return`Writing to ${R(o)}`}async getDefaultPermission(){let o=this.config.getProjectRoot();return H(y.resolve(this.params.file_path),o)?"allow":"ask"}async getConfirmationDetails(o){let e=_(this.config,this.params.file_path);if(e)throw new C(e,"path_not_in_workspace");let r="",l=await w(this.params.file_path);if(!this.config.getFileReadCacheDisabled()){let i=await u(this.config.getFileReadCache(),this.params.file_path,"overwriting");if(!i.ok)throw new C(i.rawMessage,i.type)}if(l)try{let{content:i}=await this.config.getFileSystemService().readTextFile({path:this.params.file_path});r=i}catch(i){if(d(i)&&i.code==="ENOENT")l=!1;else throw new Error(`Error reading existing file for confirmation: ${D(i)}`)}if(l&&!this.config.getFileReadCacheDisabled()){let i=await u(this.config.getFileReadCache(),this.params.file_path,"overwriting",{expectExisting:!0});if(!i.ok)throw F.warn("post-read TOCTOU rejection (confirmation)",{path:this.params.file_path,reason:i.type}),new C(i.rawMessage,i.type)}let h=b(this.params.file_path,this.config.getTargetDir()),g=y.basename(this.params.file_path),c=S(g,r,this.params.content,"Current","Proposed",k);return{type:"edit",title:`Confirm Write: ${R(h)}`,fileName:g,filePath:this.params.file_path,fileDiff:c,originalContent:r,newContent:this.params.content,onConfirm:async i=>{i==="proceed_always"&&this.config.setApprovalMode("auto-edit")}}}async execute(o){let{file_path:e,content:r,ai_proposed_content:l,modified_by_user:h}=this.params,g=_(this.config,e);if(g)return{llmContent:g,returnDisplay:g,error:{message:g,type:"path_not_in_workspace"}};let c=await w(e),m="",i=!1,n,W,J=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(c)try{let t=await this.config.getFileSystemService().readTextFile({path:e});t._meta?.bom!==void 0?i=t._meta.bom:i=t.content.length>0&&t.content.codePointAt(0)===65279,n=t._meta?.encoding||"utf-8",W=V(t.content),m=t.content,c=!0}catch(t){if(d(t)&&t.code==="ENOENT")c=!1;else{let s={message:D(t),code:d(t)?t.code:void 0},p=s.code?`Error checking existing file '${e}': ${s.message} (${s.code})`:`Error checking existing file: ${s.message}`;return{llmContent:p,returnDisplay:p,error:{message:p,type:"file_write_failure"}}}}if(c&&!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting",{expectExisting:!0});if(!t.ok)return F.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(!c){let t=this.config.getDefaultFileEncoding();t===G.UTF8_BOM?i=!0:t===void 0&&(i=Q(e)),n=void 0}try{await this.config.getFileHistoryService().trackEdit(e)}catch{}if(!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting",{expectExisting:c});if(!t.ok)return F.warn("pre-write TOCTOU rejection",{path:e,reason:t.type}),{llmContent:t.rawMessage,returnDisplay:`Error: ${t.displayMessage}`,error:{message:t.rawMessage,type:t.type}}}let E=_(this.config,e);if(E)return{llmContent:E,returnDisplay:E,error:{message:E,type:"path_not_in_workspace"}};c||P.mkdirSync(J,{recursive:!0});try{let t=_(this.config,e);if(t)return{llmContent:t,returnDisplay:t,error:{message:t,type:"path_not_in_workspace"}};await this.config.getFileSystemService().writeTextFile({path:e,content:r,_meta:{bom:i,encoding:n,lineEnding:W}}),h||Z.getInstance().recordEdit(e,c?m:null,r);try{let T=P.statSync(e);this.config.getFileReadCache().recordWrite(e,T)}catch{}let s=y.basename(e),p=m,X=S(s,p,r,"Original","Written",k),ee=q(s,p,l||r,r),v=[c?`Successfully overwrote file: ${e}.`:`Successfully created and wrote to new file: ${e}.`];h&&v.push(`User modified the \`content\` to be: ${r}`);let te=U(e),ie=B(e),oe=y.extname(e),re=c?"update":"create",ne=r.split(`
|
|
4
4
|
`).length;z(this.config,new K(x.Name,re,ne,te,oe,ie));let se={fileDiff:X,fileName:s,originalContent:m,newContent:r,diffStat:ee};try{let T=await Y(this.config,e);T&&v.push(`
|
|
5
5
|
|
|
6
6
|
${T}`)}catch{}return{llmContent:v.join(" "),returnDisplay:se}}catch(t){let s,p="file_write_failure";return d(t)?(s=`Error writing to file '${e}': ${t.message} (${t.code})`,t.code==="EACCES"?(s=`Permission denied writing to file: ${e} (${t.code})`,p="permission_denied"):t.code==="ENOSPC"?(s=`No space left on device: ${e} (${t.code})`,p="no_space_left"):t.code==="EISDIR"&&(s=`Target is a directory, not a file: ${e} (${t.code})`,p="target_is_directory"),this.config.getDebugMode()&&t.stack&&F.debug("Write file error stack:",t.stack)):t instanceof Error?s=`Error writing to file: ${t.message}`:s=`Error writing to file: ${String(t)}`,{llmContent:s,returnDisplay:s,error:{message:s,type:p}}}}},x=class f extends N{constructor(o){super(f.Name,j.WRITE_FILE,`Writes content to a specified file in the local filesystem.
|