@maincode-ai/matilda-code 0.21.13-preview.0 → 0.22.0-nightly.20261101.b0ad315a4

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 (108) hide show
  1. package/chunks/agent-IUINB66G.js +3 -0
  2. package/chunks/agent-headless-YA2RKYEZ.js +3 -0
  3. package/chunks/{askUserQuestion-6WS5ZWRA.js → askUserQuestion-RZYBOPLR.js} +1 -1
  4. package/chunks/ca-JKEHLTNL.js +23 -0
  5. package/chunks/{chunk-LVDDFAK4.js → chunk-225CZWD7.js} +1 -1
  6. package/chunks/{chunk-G4XYQR6C.js → chunk-2XSB5XHX.js} +1 -1
  7. package/chunks/{chunk-QFGR7ORH.js → chunk-453BANK3.js} +1 -1
  8. package/chunks/{chunk-3KKFNVI6.js → chunk-4UGPARBR.js} +1 -1
  9. package/chunks/{chunk-AH4W5RL2.js → chunk-5ETLURI6.js} +1 -1
  10. package/chunks/chunk-6NXVLJ3X.js +56 -0
  11. package/chunks/{chunk-OFP2ROZ7.js → chunk-7B65UIHB.js} +1 -1
  12. package/chunks/{chunk-XYAIE36G.js → chunk-7E2YCGHS.js} +9 -9
  13. package/chunks/{chunk-VW6Q43PZ.js → chunk-ARAB5QTM.js} +59 -59
  14. package/chunks/chunk-DUB7JMQV.js +13 -0
  15. package/chunks/{chunk-VENUGZ5L.js → chunk-G3F3ZCH2.js} +1 -1
  16. package/chunks/{chunk-RBGGCVWD.js → chunk-IHWAOFCQ.js} +1 -1
  17. package/chunks/{chunk-E2WUZZFL.js → chunk-ILHNCXBC.js} +1 -1
  18. package/chunks/{chunk-5WRYWBB4.js → chunk-J3ZCE3TA.js} +1 -1
  19. package/chunks/{chunk-VTBFOUDI.js → chunk-LM6OIN4B.js} +1 -1
  20. package/chunks/{chunk-JD4JPY2P.js → chunk-LMZBADPW.js} +1 -1
  21. package/chunks/{chunk-IR3O4MBT.js → chunk-MGRXOZAG.js} +1 -1
  22. package/chunks/{chunk-LQYPJU36.js → chunk-NBLBE7PE.js} +970 -976
  23. package/chunks/{chunk-R5KAUFJR.js → chunk-POGNX7U3.js} +1 -1
  24. package/chunks/{chunk-WLB26FDD.js → chunk-PQZ6HKKW.js} +32 -30
  25. package/chunks/{chunk-DP2GG4BM.js → chunk-RHSUTILA.js} +1 -1
  26. package/chunks/{chunk-QBGN32YW.js → chunk-RPXRN7E6.js} +1 -1
  27. package/chunks/chunk-V2VUANFI.js +120 -0
  28. package/chunks/{chunk-OIJ6FGWD.js → chunk-V4VILMIK.js} +1 -1
  29. package/chunks/{computer-use-YXOX3Q5O.js → computer-use-PBCWDTJR.js} +1 -1
  30. package/chunks/{cron-create-OCYM4HNG.js → cron-create-PHQ43NYA.js} +1 -1
  31. package/chunks/{cron-delete-LAWZU6LE.js → cron-delete-7RCQIU2U.js} +1 -1
  32. package/chunks/{cron-list-BCIXV7CX.js → cron-list-KKNLLMNN.js} +1 -1
  33. package/chunks/de-GMGNR5CZ.js +23 -0
  34. package/chunks/{edit-YZ6XRSXL.js → edit-ELHNQB5E.js} +1 -1
  35. package/chunks/en-3NQMLVKW.js +23 -0
  36. package/chunks/{enter-worktree-GZPML7CR.js → enter-worktree-UZIBOBV3.js} +1 -1
  37. package/chunks/{enterPlanMode-CVXXBWOO.js → enterPlanMode-UHY3DZXE.js} +1 -1
  38. package/chunks/{exit-worktree-JXDNEOAW.js → exit-worktree-HLG4PDMX.js} +1 -1
  39. package/chunks/{exitPlanMode-TFVL2QJO.js → exitPlanMode-V4HYNH3J.js} +1 -1
  40. package/chunks/fr-WS3EBB36.js +23 -0
  41. package/chunks/{glob-5L6T2OAD.js → glob-C5CTWXLP.js} +1 -1
  42. package/chunks/{goal-tools-DBHXH5DG.js → goal-tools-BGIWEJ3K.js} +1 -1
  43. package/chunks/{grep-J7T4EXPY.js → grep-BEFTGKHW.js} +1 -1
  44. package/chunks/ja-GBCDQ43R.js +23 -0
  45. package/chunks/{keychain-token-storage-RQFXZUKF.js → keychain-token-storage-FEJZYJBB.js} +1 -1
  46. package/chunks/{ls-LVWC7JN2.js → ls-XH55NAD3.js} +1 -1
  47. package/chunks/{lsp-5VYXJ3SM.js → lsp-BKDCR37G.js} +1 -1
  48. package/chunks/mcp-client-GAQG7MCT.js +3 -0
  49. package/chunks/monitor-NSVUUKCM.js +32 -0
  50. package/chunks/notebook-edit-AXKYC64C.js +17 -0
  51. package/chunks/openaiContentGenerator-66YY6CIM.js +47 -0
  52. package/chunks/pt-VID6J2CM.js +23 -0
  53. package/chunks/read-file-YFJMLS7V.js +3 -0
  54. package/chunks/ripGrep-BEHEB23R.js +3 -0
  55. package/chunks/ru-EB6V6EAN.js +23 -0
  56. package/chunks/scheduler-GKQOREMS.js +8 -0
  57. package/chunks/{send-message-YR63X46X.js → send-message-GJSEMAZB.js} +1 -1
  58. package/chunks/shell-J5Q2UEXH.js +3 -0
  59. package/chunks/{skill-UQMCUAST.js → skill-3RWNSUNE.js} +1 -1
  60. package/chunks/{symbol-search-UTRGJAO2.js → symbol-search-4VM6J5Y4.js} +1 -1
  61. package/chunks/{syntheticOutput-653VCVMY.js → syntheticOutput-O7LEF3AM.js} +1 -1
  62. package/chunks/{task-create-TAKTFQSW.js → task-create-N4IRJBTF.js} +1 -1
  63. package/chunks/{task-detach-H3FZKL54.js → task-detach-RGNQUX3H.js} +1 -1
  64. package/chunks/{task-list-ICQNSQZS.js → task-list-Z7JUB4QK.js} +1 -1
  65. package/chunks/{task-stop-4I3A3RGM.js → task-stop-L2OWK2PJ.js} +1 -1
  66. package/chunks/{task-update-COPYWCFV.js → task-update-H5AXVXDS.js} +1 -1
  67. package/chunks/{team-create-RVBZSB6O.js → team-create-FWTIQ2FT.js} +3 -3
  68. package/chunks/{team-delete-CCIBYEVZ.js → team-delete-D45ALROH.js} +1 -1
  69. package/chunks/todoWrite-LCQOQBI7.js +3 -0
  70. package/chunks/{tool-search-EJ4DEPVO.js → tool-search-X6UUCSPU.js} +1 -1
  71. package/chunks/{web-fetch-WCGA252Q.js → web-fetch-244KUWSX.js} +1 -1
  72. package/chunks/web-search-YRZ3BZ3X.js +26 -0
  73. package/chunks/{workflow-F5KP553F.js → workflow-EP4AFR24.js} +2 -2
  74. package/chunks/write-file-EXWGRN4Q.js +15 -0
  75. package/cli.js +463 -468
  76. package/locales/ca.js +2 -52
  77. package/locales/de.js +2 -51
  78. package/locales/en.js +2 -50
  79. package/locales/fr.js +2 -51
  80. package/locales/ja.js +2 -52
  81. package/locales/pt.js +2 -52
  82. package/locales/ru.js +2 -51
  83. package/package.json +2 -2
  84. package/chunks/agent-4WVOGPYV.js +0 -3
  85. package/chunks/agent-headless-KZCTMP7N.js +0 -3
  86. package/chunks/ca-GTBBJB6L.js +0 -25
  87. package/chunks/chunk-4OWMT5UV.js +0 -120
  88. package/chunks/chunk-EVIJ4V55.js +0 -56
  89. package/chunks/chunk-EYZPVR7N.js +0 -13
  90. package/chunks/chunk-FKHUEFMK.js +0 -8
  91. package/chunks/chunk-WYUJ36HZ.js +0 -8
  92. package/chunks/de-CEHU2QRR.js +0 -25
  93. package/chunks/en-Y755FYW7.js +0 -25
  94. package/chunks/fr-PCCFNMP6.js +0 -25
  95. package/chunks/ja-C4IJKHYL.js +0 -25
  96. package/chunks/mcp-client-EZSMZWGS.js +0 -3
  97. package/chunks/monitor-HJCMPNDI.js +0 -32
  98. package/chunks/notebook-edit-62T7J5RF.js +0 -17
  99. package/chunks/openaiContentGenerator-SPSIXCCZ.js +0 -52
  100. package/chunks/pt-GM4GVS7E.js +0 -25
  101. package/chunks/read-file-PMRIGC6D.js +0 -3
  102. package/chunks/ripGrep-MFGKGCKA.js +0 -3
  103. package/chunks/ru-FGESI6LX.js +0 -25
  104. package/chunks/scheduler-3O76VPWP.js +0 -8
  105. package/chunks/shell-44X3D7YA.js +0 -3
  106. package/chunks/todoWrite-RKNGMZ5N.js +0 -3
  107. package/chunks/web-search-RHTJAF72.js +0 -26
  108. package/chunks/write-file-3GA55J4D.js +0 -15
@@ -1,8 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{b as E}from"./chunk-7ZATDBWL.js";import{sa as P}from"./chunk-LQYPJU36.js";import"./chunk-IR3O4MBT.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-AH4W5RL2.js";import"./chunk-VENUGZ5L.js";import"./chunk-OIJ6FGWD.js";import"./chunk-EVIJ4V55.js";import"./chunk-3KKFNVI6.js";import"./chunk-OFP2ROZ7.js";import"./chunk-QXSBPCBA.js";import"./chunk-JD4JPY2P.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-QFGR7ORH.js";import"./chunk-WLB26FDD.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-4OWMT5UV.js";import"./chunk-WYUJ36HZ.js";import"./chunk-LVDDFAK4.js";import"./chunk-LBQNFSZ2.js";import"./chunk-EYZPVR7N.js";import"./chunk-FKHUEFMK.js";import"./chunk-VW6Q43PZ.js";import"./chunk-E2WUZZFL.js";import"./chunk-VTBFOUDI.js";import"./chunk-QBGN32YW.js";import"./chunk-DP2GG4BM.js";import"./chunk-5WRYWBB4.js";import"./chunk-R5KAUFJR.js";import{I as l,S as c}from"./chunk-XYAIE36G.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.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
- /**
5
- * @license
6
- * Copyright 2025 Google LLC
7
- * SPDX-License-Identifier: Apache-2.0
8
- */
@@ -1,3 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{mc as a,nc as b,oc as c,pc as d,qc as e,rc as f,sc as g}from"./chunk-LQYPJU36.js";import"./chunk-IR3O4MBT.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-AH4W5RL2.js";import"./chunk-VENUGZ5L.js";import"./chunk-OIJ6FGWD.js";import"./chunk-EVIJ4V55.js";import"./chunk-3KKFNVI6.js";import"./chunk-OFP2ROZ7.js";import"./chunk-QXSBPCBA.js";import"./chunk-JD4JPY2P.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-QFGR7ORH.js";import"./chunk-WLB26FDD.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-4OWMT5UV.js";import"./chunk-WYUJ36HZ.js";import"./chunk-LVDDFAK4.js";import"./chunk-LBQNFSZ2.js";import"./chunk-EYZPVR7N.js";import"./chunk-FKHUEFMK.js";import"./chunk-VW6Q43PZ.js";import"./chunk-E2WUZZFL.js";import"./chunk-VTBFOUDI.js";import"./chunk-QBGN32YW.js";import"./chunk-DP2GG4BM.js";import"./chunk-5WRYWBB4.js";import"./chunk-R5KAUFJR.js";import"./chunk-XYAIE36G.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.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,3 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a,b,c}from"./chunk-QBGN32YW.js";import"./chunk-DP2GG4BM.js";import"./chunk-5WRYWBB4.js";import"./chunk-R5KAUFJR.js";import"./chunk-XYAIE36G.js";import"./chunk-HEJO7OBH.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{c as TodoWriteTool,b as listTodoSessions,a as readTodosForSession};
@@ -1,26 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{b as g,f as y}from"./chunk-WYUJ36HZ.js";import"./chunk-FKHUEFMK.js";import{f,g as h,m as c,n as m}from"./chunk-R5KAUFJR.js";import{S as d}from"./chunk-XYAIE36G.js";import"./chunk-HEJO7OBH.js";import{b as p}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";p();var b=d("WEB_SEARCH");function v(o){if(process.env.MATILDA_WEB_SEARCH_URL)return process.env.MATILDA_WEB_SEARCH_URL;let t=o.getContentGeneratorConfig?.()?.baseUrl||process.env.OPENAI_BASE_URL||y();return`${g(t)}/api/v1/tools/web_search`}function T(o){let a=o.getContentGeneratorConfig?.();return typeof a?.apiKey=="string"&&a.apiKey.length>0?a.apiKey:process.env.MATILDA_API_KEY}function w(o,a,t,s){let n=[];if(t&&n.push(t,""),a.length===0)n.push(`No web results for "${o}".`);else{n.push(`Web results for "${o}":`);for(let[r,e]of a.entries())n.push(`${r+1}. ${e.title??"(untitled)"}`,` ${e.url??""}`,e.snippet?` ${e.snippet}`:"")}return s&&n.push("",s),n.filter(r=>r!==void 0).join(`
4
- `)}function E(o){if(!o||typeof o!="object")return;let a=[],t=o.mode;typeof t=="string"&&a.push(`mode=${t}`);let s=o.external_providers;Array.isArray(s)&&s.length&&a.push(`discovery=${s.join(",")}`);let n=o.local_providers;Array.isArray(n)&&n.length&&a.push(`local=${n.join(",")}`);let r=o.firecrawl_successes,e=o.firecrawl_attempts;return(typeof r=="number"||typeof e=="number")&&a.push(`firecrawl_extract=${typeof r=="number"?r:0}/${typeof e=="number"?e:"?"}`),a.length===0?"Pipeline: Matilda Core mcp-search (Exa discovery + self-hosted Firecrawl extract when enabled).":`Pipeline: Core mcp-search (${a.join("; ")}).`}var C=`
5
-
6
- IMPORTANT \u2014 DO NOT STOP:
7
- The user needs web-grounded evidence. Keep working until you can answer with sources:
8
- 1. Call web_search again with a clearer query (quotes around names, full context). Prefer mode "deep" for people/research questions.
9
- 2. If Core is still failing, say so clearly and use web_fetch only when you already have a concrete URL.
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 f{constructor(t,s){super(s);this.config=t}async getDefaultPermission(){return"allow"}getDescription(){return`Web search (${this.params.mode??"auto"}): ${this.params.query}`}async callCore(t,s,n,r){let e=v(this.config),l=T(this.config);if(!l)return{ok:!1,message:"web_search requires Matilda authentication (MATILDA_API_KEY or signed-in session)."};try{let i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({query:t,max_results:s,mode:n}),signal:r});if(!i.ok){let A=await i.text().catch(()=>"");return{ok:!1,status:i.status,message:i.status===404?"web_search endpoint not found on Core (deploy core-api tools route)":`HTTP ${i.status}: ${A.slice(0,300)}`}}return{ok:!0,data:await i.json()}}catch(i){return{ok:!1,message:i instanceof Error?i.message:String(i)}}}async execute(t){let s=this.params.query?.trim();if(!s)return{llmContent:"Error: query is required",returnDisplay:"Error: query is required",error:{message:"query is required",type:"invalid_tool_params"}};let n=this.params.max_results??5,r=this.params.mode??"auto";r!=="auto"&&r!=="fast"&&r!=="deep"&&(r="auto");let e=await this.callCore(s,n,r,t);if(!t.aborted&&r!=="deep"&&e.ok&&(!e.data.results||e.data.results.length===0)&&!e.data.answer&&(b.debug("web_search empty under mode=%s; escalating to deep",r),e=await this.callCore(s,n,"deep",t),r="deep"),!e.ok)return b.debug(`web_search failed: ${e.message}`),{llmContent:`web_search failed: ${e.message}`+C,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:[],i=E({mode:r,...e.data.metadata??{}});return l.length===0&&!e.data.answer?{llmContent:w(s,l,e.data.answer,i)+C,returnDisplay:"No results"}:{llmContent:w(s,l,e.data.answer,i),returnDisplay:`Found ${l.length} result(s) via Core (${r})`}}},_=class extends h{constructor(t){super(c.WEB_SEARCH,m.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=t}static Name=c.WEB_SEARCH;createInvocation(t){return new u(this.config,t)}};export{_ as WebSearchTool};
12
- /**
13
- * @license
14
- * Copyright 2026 Matilda Team
15
- * SPDX-License-Identifier: Apache-2.0
16
- *
17
- * First-party web_search via Matilda Core only:
18
- * POST {authBase}/api/v1/tools/web_search
19
- * → core-api → mcp-gateway → mcp-search `websearch`
20
- *
21
- * mcp-search already composes both backends (no CLI Firecrawl skill path):
22
- * - **Exa** (when SEARCH_PROVIDER=exa): neural discovery / entity search
23
- * - **Self-hosted Firecrawl**: page extract on fast top-N + deep retrieval
24
- *
25
- * Override with MATILDA_WEB_SEARCH_URL when Core path differs.
26
- */
@@ -1,15 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a as _}from"./chunk-RBGGCVWD.js";import{Rb as k,Sb as q,_a as Z,dc as C,ec as u,ic as G,jc as Q,kc as V,lc as Y,pa as S}from"./chunk-LQYPJU36.js";import"./chunk-IR3O4MBT.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-AH4W5RL2.js";import"./chunk-VENUGZ5L.js";import"./chunk-OIJ6FGWD.js";import"./chunk-EVIJ4V55.js";import"./chunk-3KKFNVI6.js";import"./chunk-OFP2ROZ7.js";import"./chunk-QXSBPCBA.js";import"./chunk-JD4JPY2P.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-QFGR7ORH.js";import"./chunk-WLB26FDD.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-4OWMT5UV.js";import"./chunk-WYUJ36HZ.js";import"./chunk-LVDDFAK4.js";import"./chunk-LBQNFSZ2.js";import"./chunk-EYZPVR7N.js";import"./chunk-FKHUEFMK.js";import{E as U,Gb as K,H as w,L as B,xa as z}from"./chunk-VW6Q43PZ.js";import{l as H}from"./chunk-E2WUZZFL.js";import"./chunk-VTBFOUDI.js";import"./chunk-QBGN32YW.js";import"./chunk-DP2GG4BM.js";import"./chunk-5WRYWBB4.js";import{f as $,g as N,m as L,n as j}from"./chunk-R5KAUFJR.js";import{S as M,b as d,d as D,w as R,x as b,z as O}from"./chunk-XYAIE36G.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
- `).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
-
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.
7
-
8
- CRITICAL: Always emit file_path FIRST (absolute path), then content. Never omit file_path. Construct absolute paths from the project root + relative path (e.g. '/path/to/project/' + 'foo/bar.txt'). Relative paths are not supported.
9
-
10
- The user has the ability to modify \`content\`. If modified, this will be stated in the response.`,"edit",{properties:{file_path:{description:"REQUIRED. Absolute path to write (e.g. '/home/user/project/src/auth.ts'). Emit this BEFORE content.",type:"string"},content:{description:"The full file contents to write. Only after file_path is set.",type:"string"}},required:["file_path","content"],type:"object"});this.config=o}static Name=L.WRITE_FILE;validateToolParams(o){let e=o;return ce(e),le(e),(typeof o.file_path!="string"||!o.file_path.trim())&&typeof o.content=="string"&&o.content.length>0?'WriteFile requires absolute "file_path" (emit file_path first, then content). Retry with both file_path and content.':super.validateToolParams(o)}validateToolParamValues(o){let e=O(o.file_path.trim());if(o.file_path=e,!e)return'Missing or empty "file_path"';if(!y.isAbsolute(e))return`File path must be absolute: ${e}`;try{if(P.existsSync(e)&&P.lstatSync(e).isDirectory())return`Path is a directory, not a file: ${e}`}catch(r){return`Error accessing path properties for validation: ${e}. Reason: ${r instanceof Error?r.message:String(r)}`}return null}createInvocation(o){return new A(this.config,o)}toAutoClassifierInput(o){let e=o.content??"";return{file_path:o.file_path,byte_count:Buffer.byteLength(e,"utf8"),content_preview:e.slice(0,300),content_truncated:e.length>300}}getModifyContext(o){return{getFilePath:e=>e.file_path,getCurrentContent:async e=>{if(await w(e.file_path))try{let{content:l}=await this.config.getFileSystemService().readTextFile({path:e.file_path});return l}catch(l){if(!d(l)||l.code!=="ENOENT")throw l;return""}else return""},getProposedContent:async e=>e.content,createUpdatedParams:(e,r,l)=>{let h=l.content;return{...l,ai_proposed_content:h,content:r,modified_by_user:!0}}}}};export{x as WriteFileTool,le as normalizeWriteFilePathAliases,ce as repairLeakedWriteFileToolArgMarkup};
11
- /**
12
- * @license
13
- * Copyright 2025 Google LLC
14
- * SPDX-License-Identifier: Apache-2.0
15
- */