@maincode-ai/matilda-code 0.22.2 → 0.22.3-nightly.20261110.cb1234773

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 (123) hide show
  1. package/README.md +1 -1
  2. package/chunks/agent-7LLN72GU.js +3 -0
  3. package/chunks/agent-headless-APBRBFN3.js +3 -0
  4. package/chunks/{askUserQuestion-DHYKAZWH.js → askUserQuestion-76LPP5ST.js} +1 -1
  5. package/chunks/{chunk-MZ73LBEY.js → chunk-3EQIOCSJ.js} +1 -1
  6. package/chunks/chunk-4SDFTVQW.js +62 -0
  7. package/chunks/chunk-B7BF33U4.js +31 -0
  8. package/chunks/chunk-BEP4F3GO.js +2556 -0
  9. package/chunks/chunk-DERMLVT6.js +68 -0
  10. package/chunks/{chunk-OWEBLTAN.js → chunk-EEPSTT7K.js} +1 -1
  11. package/chunks/{chunk-OF7ORAN6.js → chunk-GDRS4OWI.js} +71 -67
  12. package/chunks/chunk-HK3QQSM7.js +18 -0
  13. package/chunks/{chunk-PFXCFIHY.js → chunk-J6NYCXUR.js} +1 -1
  14. package/chunks/chunk-JVQHQDDE.js +10 -0
  15. package/chunks/chunk-JZMGEGR6.js +12 -0
  16. package/chunks/{chunk-HJK3NKAR.js → chunk-M5ABGGE7.js} +1 -1
  17. package/chunks/chunk-N3AQRPV5.js +207 -0
  18. package/chunks/{chunk-DZKI2CAC.js → chunk-NO6BFSGG.js} +1 -1
  19. package/chunks/chunk-QKAKC34Q.js +8 -0
  20. package/chunks/{chunk-VWM3GUBH.js → chunk-QUITDDTB.js} +1 -1
  21. package/chunks/{chunk-ZUQRP3N6.js → chunk-R373GBK6.js} +1 -1
  22. package/chunks/{chunk-BS7Q7KA6.js → chunk-T6MRYRLI.js} +1 -1
  23. package/chunks/{chunk-REUZDMLM.js → chunk-TVNM3PQ7.js} +25 -25
  24. package/chunks/chunk-VBZS7ARJ.js +8 -0
  25. package/chunks/{chunk-FY3LL4OC.js → chunk-VNSW4TSX.js} +1 -1
  26. package/chunks/{chunk-HRD7WD3P.js → chunk-WAZCC4SE.js} +1 -1
  27. package/chunks/chunk-YUCEPXGG.js +12 -0
  28. package/chunks/{computer-use-5T3ZH24D.js → computer-use-RIDTFLYZ.js} +5 -17
  29. package/chunks/cron-create-T5QOBRRU.js +38 -0
  30. package/chunks/cron-delete-JXDOHSJF.js +3 -0
  31. package/chunks/cron-list-ZQ76A2FW.js +5 -0
  32. package/chunks/{edit-Y7YSDGLT.js → edit-LDTYXEVU.js} +1 -1
  33. package/chunks/en-SCZAH2YB.js +23 -0
  34. package/chunks/{enter-worktree-5ZGIYDUE.js → enter-worktree-FOFQXTPW.js} +1 -1
  35. package/chunks/enterPlanMode-2GHHILQY.js +18 -0
  36. package/chunks/{exit-worktree-3F5UY76U.js → exit-worktree-OK7AD7DC.js} +1 -1
  37. package/chunks/{exitPlanMode-HWK5EUVS.js → exitPlanMode-EANVOWTX.js} +30 -27
  38. package/chunks/{glob-H7DNNPJ4.js → glob-VZD7TOML.js} +1 -1
  39. package/chunks/{goal-tools-CJINJJ3Y.js → goal-tools-REBEAKVP.js} +1 -1
  40. package/chunks/{grep-5MCMGW6A.js → grep-JPEHWEM3.js} +1 -1
  41. package/chunks/ls-EP4ZVFNW.js +15 -0
  42. package/chunks/{lsp-Y46R5DO5.js → lsp-ULZTGWC4.js} +1 -1
  43. package/chunks/monitor-5WDGSYNZ.js +33 -0
  44. package/chunks/notebook-edit-W42S562V.js +17 -0
  45. package/chunks/openaiContentGenerator-QLDLWN4P.js +52 -0
  46. package/chunks/read-file-4M76GCWT.js +3 -0
  47. package/chunks/ripGrep-LF2E2V6N.js +3 -0
  48. package/chunks/scheduler-G4LEIBL4.js +8 -0
  49. package/chunks/send-message-TDOMZHNJ.js +8 -0
  50. package/chunks/shell-NUMSSUOV.js +3 -0
  51. package/chunks/{skill-5EMGSWRM.js → skill-IVESDHGG.js} +1 -1
  52. package/chunks/symbol-search-BLJAKP7C.js +19 -0
  53. package/chunks/syntheticOutput-5SCRQCXN.js +3 -0
  54. package/chunks/task-create-T4DIVG5X.js +3 -0
  55. package/chunks/task-detach-ES3IMGJ4.js +9 -0
  56. package/chunks/task-list-LYK4TOBS.js +9 -0
  57. package/chunks/{task-stop-OEAEE5R7.js → task-stop-FETAYKFU.js} +1 -1
  58. package/chunks/{task-update-4ANRU74G.js → task-update-I6PVT46S.js} +1 -1
  59. package/chunks/{team-create-G4N2NCFN.js → team-create-QQD472XN.js} +1 -1
  60. package/chunks/team-delete-P5F32IYK.js +8 -0
  61. package/chunks/todoWrite-ADAGHJLI.js +3 -0
  62. package/chunks/tool-call-W6PAJOF6.js +3 -0
  63. package/chunks/tool-search-LGTQYGTC.js +26 -0
  64. package/chunks/{web-fetch-VA2BZ4VR.js → web-fetch-5X37JMDH.js} +1 -1
  65. package/chunks/{web-search-OVFXJQDS.js → web-search-62YZTP3D.js} +1 -1
  66. package/chunks/{workflow-6VMVM5BG.js → workflow-OT4I6TMY.js} +2 -2
  67. package/chunks/write-file-GMIHG7AP.js +15 -0
  68. package/cli.js +472 -486
  69. package/locales/en.js +45 -113
  70. package/npm-postinstall.js +2 -2
  71. package/package.json +2 -2
  72. package/chunks/agent-IJOGVY62.js +0 -3
  73. package/chunks/agent-headless-FZGKJCVK.js +0 -3
  74. package/chunks/ca-HHQCT6S2.js +0 -23
  75. package/chunks/chunk-225CZWD7.js +0 -89
  76. package/chunks/chunk-3BT7ZYAM.js +0 -121
  77. package/chunks/chunk-3IG6LNQ3.js +0 -2581
  78. package/chunks/chunk-46FFWNRO.js +0 -12
  79. package/chunks/chunk-55YW6EUC.js +0 -8
  80. package/chunks/chunk-BQDEPKIG.js +0 -46
  81. package/chunks/chunk-E2KMVG7F.js +0 -8
  82. package/chunks/chunk-FPGKJJJY.js +0 -13
  83. package/chunks/chunk-L2FKLLEC.js +0 -12
  84. package/chunks/chunk-N2BE647T.js +0 -10
  85. package/chunks/chunk-P24OL22U.js +0 -31
  86. package/chunks/chunk-VWE5BSHV.js +0 -56
  87. package/chunks/chunk-WL27X35X.js +0 -44
  88. package/chunks/cron-create-5RRFCP36.js +0 -38
  89. package/chunks/cron-delete-7DTRWCSV.js +0 -3
  90. package/chunks/cron-list-HY6XJD7D.js +0 -5
  91. package/chunks/de-MJBGC47E.js +0 -23
  92. package/chunks/en-JITX7JKV.js +0 -23
  93. package/chunks/enterPlanMode-TWD4MXCW.js +0 -18
  94. package/chunks/fr-WT3R2JCR.js +0 -23
  95. package/chunks/ja-OEXP6Z3S.js +0 -23
  96. package/chunks/keychain-token-storage-BCODB632.js +0 -3
  97. package/chunks/ls-JORGCXES.js +0 -15
  98. package/chunks/mcp-client-54J5M542.js +0 -3
  99. package/chunks/monitor-BRJR6PR3.js +0 -32
  100. package/chunks/notebook-edit-UCCVQ4JP.js +0 -17
  101. package/chunks/openaiContentGenerator-H6JOS3XU.js +0 -52
  102. package/chunks/pt-PCVIFK7H.js +0 -23
  103. package/chunks/read-file-LVMBCRCT.js +0 -3
  104. package/chunks/ripGrep-F6AJSDKU.js +0 -3
  105. package/chunks/ru-CB5SIZZM.js +0 -23
  106. package/chunks/scheduler-XAOD6LG6.js +0 -8
  107. package/chunks/send-message-VY4DP63A.js +0 -8
  108. package/chunks/shell-QUDC6MJK.js +0 -3
  109. package/chunks/symbol-search-YNGX4Z5T.js +0 -19
  110. package/chunks/syntheticOutput-4JANVS4D.js +0 -3
  111. package/chunks/task-create-NRBVXURQ.js +0 -3
  112. package/chunks/task-detach-VHDDAO2K.js +0 -9
  113. package/chunks/task-list-T2IET466.js +0 -9
  114. package/chunks/team-delete-M4ORNSTT.js +0 -8
  115. package/chunks/todoWrite-RN2OP46T.js +0 -3
  116. package/chunks/tool-search-WEUURHFZ.js +0 -28
  117. package/chunks/write-file-5ZAZVXBB.js +0 -15
  118. package/locales/ca.js +0 -1895
  119. package/locales/de.js +0 -1935
  120. package/locales/fr.js +0 -1936
  121. package/locales/ja.js +0 -1698
  122. package/locales/pt.js +0 -1921
  123. package/locales/ru.js +0 -1911
@@ -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{ma as P}from"./chunk-3IG6LNQ3.js";import"./chunk-FY3LL4OC.js";import"./chunk-BQDEPKIG.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DZKI2CAC.js";import"./chunk-ZUQRP3N6.js";import"./chunk-OWEBLTAN.js";import"./chunk-VWE5BSHV.js";import"./chunk-L2FKLLEC.js";import"./chunk-N2BE647T.js";import"./chunk-QXSBPCBA.js";import"./chunk-HRD7WD3P.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-55YW6EUC.js";import"./chunk-REUZDMLM.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-3BT7ZYAM.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-FPGKJJJY.js";import"./chunk-OF7ORAN6.js";import"./chunk-HJK3NKAR.js";import"./chunk-46FFWNRO.js";import"./chunk-BS7Q7KA6.js";import"./chunk-MZ73LBEY.js";import"./chunk-PFXCFIHY.js";import"./chunk-XPVKH5TC.js";import"./chunk-P24OL22U.js";import{P as l,ea as c}from"./chunk-WL27X35X.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,8 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{b as n,e as h,g as i}from"./chunk-QXSBPCBA.js";import{f as g,g as p,m as c,n as l}from"./chunk-P24OL22U.js";import"./chunk-WL27X35X.js";import"./chunk-HEJO7OBH.js";import{b as d}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";d();var m=class extends g{constructor(s,a){super(a);this.config=s}getDescription(){if(this.params.task_id)return`Send message to task ${this.params.task_id}`;let s=this.params.summary??this.params.message.slice(0,50);return`Send to ${this.params.to}: ${s}`}async getDefaultPermission(){return"ask"}async execute(s){if(this.params.task_id){let e=this.config.getBackgroundTaskRegistry(),t=e.get(this.params.task_id);return t?t.status==="paused"?await this.config.resumeBackgroundAgent(this.params.task_id,this.params.message)?{llmContent:`Background task "${this.params.task_id}" resumed with your message as the first continuation instruction.`,returnDisplay:`Resumed ${t.description}`}:{llmContent:`Error: Background task "${this.params.task_id}" could not be resumed.`,returnDisplay:"Task could not be resumed.",error:{message:`Task could not be resumed: ${this.params.task_id}`,type:"send_message_not_running"}}:t.status!=="running"?{llmContent:`Error: Background task "${this.params.task_id}" is not running (status: ${t.status}). Cannot send messages to stopped tasks.`,returnDisplay:`Task not running (${t.status}).`,error:{message:`Task is ${t.status}: ${this.params.task_id}`,type:"send_message_not_running"}}:(e.queueMessage(this.params.task_id,this.params.message),{llmContent:`Message queued for delivery to background task "${this.params.task_id}". The task will receive it at the next tool-round boundary.`,returnDisplay:`Message queued for ${t.description}`}):{llmContent:`Error: No background task found with ID "${this.params.task_id}".`,returnDisplay:"Task not found.",error:{message:`Task not found: ${this.params.task_id}`,type:"send_message_not_found"}}}let a=this.config.getTeamManager();if(!a){let e="No active team and no task_id provided. Either create a team first, or pass `task_id` to message a background task.";return{llmContent:e,returnDisplay:e,error:{message:e}}}let o=this.params.to;if(!o){let e='Recipient "to" is required.';return{llmContent:e,returnDisplay:e,error:{message:e}}}try{if(this.params.type==="shutdown_request"){if(h()){let r="Only the team leader can request shutdowns.";return{llmContent:r,returnDisplay:r,error:{message:r}}}await a.requestShutdown(o);let t=`Shutdown requested for "${o}".`;return{llmContent:t,returnDisplay:t}}if(o==="*"){let t=n()??i;await a.broadcast(this.params.message,t);let r="Message broadcast to all teammates.";return{llmContent:r,returnDisplay:r}}await a.sendMessage(o,this.params.message,n()??i,this.params.summary);let e=`Message sent to "${o}".`;return{llmContent:e,returnDisplay:e}}catch(e){let t=e instanceof Error?e.message:String(e);return{llmContent:`Failed to send message: ${t}`,returnDisplay:`Failed to send message: ${t}`,error:{message:t}}}}},k=class u extends p{constructor(s){super(u.Name,l.SEND_MESSAGE,'Send a message to a teammate (use "to") or to a running background task (use "task_id"). For teams, set "to" to a bare teammate name (no @) or "*" to broadcast. For background tasks, set "task_id" to the id from the launch response or a recovered paused task. Running tasks receive it at the next tool-round boundary; paused recovered tasks are resumed with the message as their first continuation instruction. Your text output is NOT visible to other agents \u2014 use this tool to communicate.',"other",{type:"object",properties:{to:{type:"string",description:'Recipient teammate name, or "*" for broadcast.'},task_id:{type:"string",description:"The ID of the background task (from the launch response or a recovered paused task)."},message:{type:"string",description:"Message text to send.",maxLength:65536},summary:{type:"string",description:"Optional 5-10 word summary for UI display."},type:{type:"string",enum:["shutdown_request"],description:"Structured message type for control flow. When set, routes through the mailbox instead of plain text delivery."}},required:["message"],oneOf:[{required:["to"]},{required:["task_id"]}],additionalProperties:!1},!0,!1,!0,!1,"send message task teammate team communicate notify");this.config=s}static Name=c.SEND_MESSAGE;createInvocation(s){return new m(this.config,s)}toAutoClassifierInput(s){return{to:s.to,task_id:s.task_id,message:s.message,type:s.type}}};export{k as SendMessageTool};
4
- /**
5
- * @license
6
- * Copyright 2025 Matilda
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{$b as f,Wb as a,Xb as b,Yb as c,Zb as d,_b as e,ac as g}from"./chunk-3IG6LNQ3.js";import"./chunk-FY3LL4OC.js";import"./chunk-BQDEPKIG.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DZKI2CAC.js";import"./chunk-ZUQRP3N6.js";import"./chunk-OWEBLTAN.js";import"./chunk-VWE5BSHV.js";import"./chunk-L2FKLLEC.js";import"./chunk-N2BE647T.js";import"./chunk-QXSBPCBA.js";import"./chunk-HRD7WD3P.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-55YW6EUC.js";import"./chunk-REUZDMLM.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-3BT7ZYAM.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-FPGKJJJY.js";import"./chunk-OF7ORAN6.js";import"./chunk-HJK3NKAR.js";import"./chunk-46FFWNRO.js";import"./chunk-BS7Q7KA6.js";import"./chunk-MZ73LBEY.js";import"./chunk-PFXCFIHY.js";import"./chunk-XPVKH5TC.js";import"./chunk-P24OL22U.js";import"./chunk-WL27X35X.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,19 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{ya as w,za as A}from"./chunk-BQDEPKIG.js";import{f as h,g as x,m as d,n as S}from"./chunk-P24OL22U.js";import{ea as g}from"./chunk-WL27X35X.js";import"./chunk-HEJO7OBH.js";import{b as u}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";u();import C from"node:path";u();import k from"node:fs/promises";import f from"node:path";u();var D={".ts":"typescript",".tsx":"typescript",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".go":"go",".rs":"rust",".java":"java"},T={typescript:[{kind:"interface",re:/^\s*(?:export\s+)?interface\s+([A-Za-z_$][\w$]*)/},{kind:"type",re:/^\s*(?:export\s+)?type\s+([A-Za-z_$][\w$]*)\s*=/},{kind:"enum",re:/^\s*(?:export\s+)?enum\s+([A-Za-z_$][\w$]*)/},{kind:"class",re:/^\s*(?:export\s+)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/},{kind:"function",re:/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/},{kind:"const",re:/^\s*(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:async\s*)?(?:\(|function\b)/},{kind:"method",re:/^\s+(?:public|private|protected|async|static|readonly|\s)*([A-Za-z_$][\w$]*)\s*\([^;]*\)\s*[:{]/}],javascript:[{kind:"class",re:/^\s*(?:export\s+)?class\s+([A-Za-z_$][\w$]*)/},{kind:"function",re:/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/},{kind:"const",re:/^\s*(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:async\s*)?(?:\(|function\b)/}],python:[{kind:"class",re:/^\s*class\s+([A-Za-z_][\w]*)\s*[(:]/},{kind:"function",re:/^\s*(?:async\s+)?def\s+([A-Za-z_][\w]*)\s*\(/}],go:[{kind:"function",re:/^func\s+(?:\([^)]+\)\s+)?([A-Za-z_][\w]*)\s*\(/},{kind:"type",re:/^type\s+([A-Za-z_][\w]*)\s+(?:struct|interface|func|=)/}],rust:[{kind:"function",re:/^\s*(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z_][\w]*)/},{kind:"class",re:/^\s*(?:pub(?:\([^)]*\))?\s+)?(?:struct|enum|trait)\s+([A-Za-z_][\w]*)/}],java:[{kind:"class",re:/^\s*(?:public|private|protected)?\s*(?:abstract|final)?\s*class\s+([A-Za-z_][\w]*)/},{kind:"interface",re:/^\s*(?:public|private|protected)?\s*interface\s+([A-Za-z_][\w]*)/},{kind:"method",re:/^\s+(?:public|private|protected)\s+(?:static\s+)?[\w<>,\s[\]]+\s+([A-Za-z_][\w]*)\s*\(/}]};function y(m){let i=m.toLowerCase(),t=i.lastIndexOf(".");if(!(t<0))return D[i.slice(t)]}function _(m,i){let t=y(m);if(!t)return[];let o=T[t];if(!o)return[];let a=[],r=i.split(/\r?\n/);for(let e=0;e<r.length;e++){let s=r[e];for(let{kind:c,re:n}of o){let l=n.exec(s);if(l?.[1]&&!(l[1]==="if"||l[1]==="for"||l[1]==="while"||l[1]==="switch")){a.push({name:l[1],kind:c,filePath:m,line:e+1,snippet:s.trim().slice(0,200)});break}}}return a}var z=2e3,E=512*1024,p=class{constructor(i,t,o={}){this.rootDir=i;this.filePaths=t;this.opts=o}symbols=[];built=!1;async build(i){let t=this.opts.maxFiles??z,o=this.opts.maxFileBytes??E,a=[],r=0;for(let e of this.filePaths){if(i?.aborted||r>=t)break;let s=f.isAbsolute(e)?e:f.join(this.rootDir,e);if(!y(s))continue;let c;try{let l=await k.stat(s);if(!l.isFile()||l.size>o)continue;c=await k.readFile(s,"utf8")}catch{continue}let n=f.relative(this.rootDir,s)||s;a.push(..._(n,c)),r+=1}return this.symbols=a,this.built=!0,this.symbols.length}isBuilt(){return this.built}size(){return this.symbols.length}search(i){let t=i.query.trim().toLowerCase();if(!t)return[];let o=i.maxResults??25,a=i.pathPrefix?.replace(/\\/g,"/").toLowerCase(),r=[];for(let e of this.symbols){if(i.kind&&e.kind!==i.kind||a&&!e.filePath.replace(/\\/g,"/").toLowerCase().includes(a))continue;let s=e.name.toLowerCase(),c=0;if(s===t)c=100;else if(s.startsWith(t))c=80;else if(s.includes(t))c=50;else if(e.snippet.toLowerCase().includes(t))c=20;else continue;r.push({s:e,score:c})}return r.sort((e,s)=>s.score-e.score||e.s.filePath.localeCompare(s.s.filePath)),r.slice(0,o).map(e=>e.s)}};var $=g("SYMBOL_SEARCH"),v=new Map,F=6e4,b=class extends h{constructor(t,o){super(o);this.config=t}async getDefaultPermission(){return"allow"}getDescription(){return`Find symbol \`${this.params.query}\``}async execute(t){let o=this.params.query?.trim();if(!o)return{llmContent:"Error: query is required",returnDisplay:"Error: query is required",error:{message:"query is required",type:"invalid_tool_params"}};let a=this.config.getTargetDir();try{let r=await this.getOrBuildIndex(a,t),e=r.search({query:o,pathPrefix:this.params.path,kind:this.params.kind,maxResults:this.params.max_results??25});if(e.length===0)return{llmContent:`No symbols matching "${o}". Try grep_search for textual matches.`,returnDisplay:"No symbols found"};let s=e.map(n=>`${n.kind} ${n.name} \u2014 ${n.filePath}:${n.line}
4
- ${n.snippet}`);return{llmContent:[`Found ${e.length} symbol(s) for "${o}" (index size ${r.size()}):`,...s].join(`
5
- `),returnDisplay:`Found ${e.length} symbol(s)`}}catch(r){let e=r instanceof Error?r.message:String(r);return $.debug(`symbol_search failed: ${e}`),{llmContent:`symbol_search failed: ${e}`,returnDisplay:"symbol_search failed",error:{message:e,type:"execution_failed"}}}}async getOrBuildIndex(t,o){let a=v.get(t);if(a&&Date.now()-a.builtAt<F&&a.index.isBuilt())return a.index;let r=A({projectRoot:t,useGitignore:!0,useMatildaignore:!0,ignoreDirs:["node_modules","dist",".git","coverage","vendor"]}),e=[];try{e=await w({crawlDirectory:t,cwd:t,ignore:r,useGitignore:!0,maxDepth:12,maxFiles:5e3,cache:!0,cacheTtl:60})}catch(n){$.debug(`crawl failed, indexing empty: ${n instanceof Error?n.message:String(n)}`),e=[]}if(o.aborted)throw new Error("symbol_search aborted");let s=e.map(n=>C.isAbsolute(n)&&C.relative(t,n)||n),c=new p(t,s);return await c.build(o),v.set(t,{index:c,builtAt:Date.now()}),c}},P=class extends x{constructor(t){super(d.SYMBOL_SEARCH,S.SYMBOL_SEARCH,"Search the workspace for code symbols (functions, classes, types, methods) by name. Prefer this over blind grep when looking for definitions. Falls back gracefully when a language is not indexed.","search",{type:"object",properties:{query:{type:"string",description:"Symbol name or substring to find"},path:{type:"string",description:"Optional path prefix to limit the search"},kind:{type:"string",enum:["function","class","method","interface","type","const","enum"],description:"Optional symbol kind filter"},max_results:{type:"number",description:"Maximum results to return (default 25)"}},required:["query"]});this.config=t}static Name=d.SYMBOL_SEARCH;createInvocation(t){return new b(this.config,t)}};export{P as SymbolSearchTool};
6
- /**
7
- * @license
8
- * Copyright 2026 Matilda Team
9
- * SPDX-License-Identifier: Apache-2.0
10
- *
11
- * Lightweight symbol extraction for the symbol_search tool.
12
- * Regex-based MVP — tree-sitter grammars can replace per language later
13
- * without changing the CodeIndex / tool surface.
14
- */
15
- /**
16
- * @license
17
- * Copyright 2026 Matilda Team
18
- * SPDX-License-Identifier: Apache-2.0
19
- */
@@ -1,3 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a,b}from"./chunk-46FFWNRO.js";import"./chunk-P24OL22U.js";import"./chunk-WL27X35X.js";import"./chunk-HEJO7OBH.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{a as STRUCTURED_OUTPUT_REDACTED_ARGS,b as SyntheticOutputTool};
@@ -1,3 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a,b}from"./chunk-VWM3GUBH.js";import"./chunk-FY3LL4OC.js";import"./chunk-OWEBLTAN.js";import"./chunk-QXSBPCBA.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-PFXCFIHY.js";import"./chunk-P24OL22U.js";import"./chunk-WL27X35X.js";import"./chunk-HEJO7OBH.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{b as TaskCreateTool,a as truncateForConfirmation};
@@ -1,9 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a as d}from"./chunk-N2BE647T.js";import"./chunk-V6UPUMP3.js";import{f as i,g as c,m as n,n as u}from"./chunk-P24OL22U.js";import"./chunk-WL27X35X.js";import"./chunk-HEJO7OBH.js";import{b as a}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";a();var o=class extends i{constructor(r,e){super(e);this.config=r}getDescription(){return`Detach background task ${this.params.task_id}`}async execute(r){let e=this.params.task_id,t=this.config.getBackgroundTaskRegistry().get(e)??this.config.getBackgroundShellRegistry().get(e)??this.config.getMonitorRegistry().get(e);return t?t.status!=="running"?{llmContent:`Error: Background ${t.kind} "${e}" is not running (status: ${t.status}).`,returnDisplay:`Task not running (${t.status}).`,error:{message:`${t.kind} is ${t.status}: ${e}`,type:"task_detach_not_running"}}:{llmContent:(d.detach(t)?`Detached background ${t.kind} "${e}". It keeps running after the current request ends and reports its completion separately. Stop it with ${n.TASK_STOP} when it is no longer needed.`:`Background ${t.kind} "${e}" is not holding a request open; it keeps running.`)+`
4
- Description: ${t.description}`,returnDisplay:`Detached: ${t.description}`}:{llmContent:`Error: No background task found with ID "${e}".`,returnDisplay:"Task not found.",error:{message:`Task not found: ${e}`,type:"task_detach_not_found"}}}},l=class s extends c{constructor(r){super(s.Name,u.TASK_DETACH,"Let a running background task keep running after the current request ends. Background tasks join the request that started them by default, and the request cannot finish until they do. Detach servers, watchers and other work that should outlive the request; its completion is reported separately.","other",{type:"object",properties:{task_id:{type:"string",description:"The ID of the background task to detach (from the launch response or notification)."}},required:["task_id"],additionalProperties:!1},!0,!1,!0,!1,"task detach background server watcher keep running");this.config=r}static Name=n.TASK_DETACH;createInvocation(r){return new o(this.config,r)}};export{l as TaskDetachTool};
5
- /**
6
- * @license
7
- * Copyright 2026 Matilda Team
8
- * SPDX-License-Identifier: Apache-2.0
9
- */
@@ -1,9 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{i as d}from"./chunk-FY3LL4OC.js";import"./chunk-OWEBLTAN.js";import{c as u,d as g}from"./chunk-QXSBPCBA.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-PFXCFIHY.js";import{f as l,g as m,m as p,n as c}from"./chunk-P24OL22U.js";import"./chunk-WL27X35X.js";import"./chunk-HEJO7OBH.js";import{b as n}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";n();var r=class extends l{constructor(t,a){super(a);this.config=t}getDescription(){let t=[];return this.params.status&&t.push(`status=${this.params.status}`),this.params.owner&&t.push(`owner=${this.params.owner}`),this.params.blockedBy&&t.push(`blockedBy=${this.params.blockedBy}`),t.length>0?`List tasks (${t.join(", ")})`:"List all tasks"}async execute(){let t=g(this.config.getTeamContext()?.teamName);if(!t){let s="No active team. Create a team first.";return{llmContent:s,returnDisplay:s,error:{message:s}}}let a=await d(t,{status:this.params.status,owner:this.params.owner,blockedBy:this.params.blockedBy});if(a.length===0){let s="No tasks found.";return{llmContent:s,returnDisplay:s}}let e=a.map(s=>`#${s.id} [${s.status}]`+(s.owner?` @${s.owner}`:"")+` \u2014 ${s.subject}`),o=this.config.getTeamManager();if(o&&!u()){try{let s=await o.getLeaderMessages();if(s.length>0){e.push(""),e.push("--- Teammate messages ---");for(let y of o.formatLeaderEnvelope(s))e.push(y)}}catch{}o.hasActiveTeammates()&&(e.push(""),e.push("NOTE: Teammates are still working. Their results will be delivered as messages \u2014 do NOT call task_list again to check. End your turn and wait for teammate messages."))}let h=e.join(`
4
- `),k={type:"task_list",tasks:a.map(s=>({id:s.id,subject:s.subject,status:s.status,owner:s.owner}))};return{llmContent:h,returnDisplay:k}}},f=class i extends m{constructor(t){super(i.Name,c.TASK_LIST,"List tasks in the team task list. All filter parameters are optional.","read",{type:"object",properties:{status:{type:"string",enum:["pending","in_progress","completed"],description:"Filter by task status."},owner:{type:"string",description:"Filter by owner agent name."},blockedBy:{type:"string",description:"Filter for tasks blocked by this task ID."}},additionalProperties:!1});this.config=t}static Name=p.TASK_LIST;createInvocation(t){return new r(this.config,t)}};export{f as TaskListTool};
5
- /**
6
- * @license
7
- * Copyright 2025 Matilda
8
- * SPDX-License-Identifier: Apache-2.0
9
- */
@@ -1,8 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a as T,d as f}from"./chunk-ZUQRP3N6.js";import{n as o}from"./chunk-OWEBLTAN.js";import{e as g}from"./chunk-QXSBPCBA.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-PFXCFIHY.js";import{f as l,g as c,m as p,n as u}from"./chunk-P24OL22U.js";import{ea as i}from"./chunk-WL27X35X.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
- /**
5
- * @license
6
- * Copyright 2025 Matilda
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{a,b,c}from"./chunk-BS7Q7KA6.js";import"./chunk-MZ73LBEY.js";import"./chunk-PFXCFIHY.js";import"./chunk-XPVKH5TC.js";import"./chunk-P24OL22U.js";import"./chunk-WL27X35X.js";import"./chunk-HEJO7OBH.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{c as TodoWriteTool,b as listTodoSessions,a as readTodosForSession};
@@ -1,28 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{lb as N}from"./chunk-OF7ORAN6.js";import"./chunk-HJK3NKAR.js";import"./chunk-46FFWNRO.js";import"./chunk-PFXCFIHY.js";import"./chunk-XPVKH5TC.js";import{f as v,g as R,m as E,n as L}from"./chunk-P24OL22U.js";import{ea as S}from"./chunk-WL27X35X.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
-
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
-
7
- The returned <functions> block is informational \u2014 it shows what the schema looks like. Calling the tool itself happens via the model's normal function-call mechanism on the NEXT turn, after the active session's declaration list has been updated. Tools fetched here remain available for the rest of the session.
8
-
9
- Query forms:
10
- - "select:ToolA,ToolB" \u2014 fetch these exact tools by name
11
- - "keyword phrase" \u2014 keyword search, up to max_results best matches
12
- - "+must-word other" \u2014 require "must-word" in the name, rank remaining terms
13
- `,w=class extends v{constructor(s,t){super(t);this.config=s}getDescription(){return this.params.query}async execute(s){let t=(this.params.query??"").trim();if(!t)return{llmContent:"Error: query is empty. Use `select:ToolName` or free-text keywords.",returnDisplay:"Empty query",error:{message:"Empty query"}};let f=O(this.params.max_results??D,1,A);if(t.toLowerCase().startsWith("select:")){let e=new Set,l=[],T=[];for(let i of t.slice(7).split(",")){let o=U(i.trim());if(!o)continue;let h=o.toLowerCase();if(!e.has(h)){if(e.add(h),l.length>=f){T.push(o);continue}l.push(o)}}return this.loadAndReturnSchemas(l,T)}let m=I(t),d=m.filter(e=>e.startsWith("+")).map(e=>e.slice(1)).filter(e=>e.length>0),u=m.map(e=>e.startsWith("+")?e.slice(1):e).filter(e=>e.length>0);if(u.length===0)return{llmContent:"Error: no search terms extracted from query. Use `select:ToolName` or include keywords.",returnDisplay:"No search terms",error:{message:"No search terms"}};let c=this.collectCandidates(),a=[];for(let e of c){if(!B(e,d))continue;let l=j(e,u);l>0&&a.push({tool:e,score:l})}a.sort((e,l)=>l.score!==e.score?l.score-e.score:e.tool.name.localeCompare(l.tool.name));let p=a.slice(0,f).map(e=>e.tool.name);return p.length===0?{llmContent:`No tools found matching '${t}'. Try broader keywords or use \`select:ToolName\`.`,returnDisplay:`No matches for '${t}'`}:this.loadAndReturnSchemas(p)}collectCandidates(){let s=this.config.getToolRegistry();return s.getAllTools().filter(t=>t.shouldDefer&&!t.alwaysLoad&&!s.isDeferredToolRevealed(t.name))}async loadAndReturnSchemas(s,t=[]){if(s.length===0)return{llmContent:"Error: no tool names provided.",returnDisplay:"No tool names",error:{message:"No tool names"}};let f=this.config.getToolRegistry(),m=[],d=[],u=new Map;for(let i of f.getAllToolNames())u.set(i.toLowerCase(),i);let c=[];for(let i of s){let o=u.get(i.toLowerCase());if(!o){d.push(i);continue}let h;try{h=await f.ensureTool(o)}catch(g){y.warn(`ensureTool failed for ${o}:`,g),process.stderr.write(`[ToolSearch] ensureTool failed for "${o}": ${g instanceof Error?g.message:String(g)}
14
- `)}if(!h){d.push(i);continue}if(h.shouldDefer&&!h.alwaysLoad){let g=f.isDeferredToolRevealed(o);f.revealDeferredTool(o),g||c.push(o)}m.push(h)}let a;if(c.length>0){let i=this.config.getGeminiClient();if(!i)a="GeminiClient not initialised";else{try{await i.setTools()}catch(o){a=o instanceof Error?o.message:String(o),y.warn("setTools() failed while revealing deferred tools:",o),process.stderr.write(`[ToolSearch] setTools() failed while revealing deferred tools: ${a}
15
- `)}if(!a)try{await i.refreshStartupContextReminder()}catch(o){let h=o instanceof Error?o.message:String(o);y.warn("refreshStartupContextReminder() failed after revealing deferred tools:",o),process.stderr.write(`[ToolSearch] refreshStartupContextReminder() failed after revealing deferred tools: ${h}
16
- `)}}if(a)for(let o of c)f.unrevealDeferredTool(o)}if(a)return{llmContent:`Error: tools were located but could not be exposed to the API (setTools failed: ${a}). Retry the search next turn or call ToolSearch again with select:Name1,Name2 \u2014 re-running tool registration usually clears transient init races.`,returnDisplay:`setTools failed: ${a}`,error:{message:`setTools failed while revealing deferred tools: ${a}`}};let p=m.map(i=>`<function>${JSON.stringify(i.schema).replace(/</g,"\\u003c")}</function>`),e="";p.length>0&&(e+=`<functions>
17
- ${p.join(`
18
- `)}
19
- </functions>`),d.length>0&&(e+=`${e?`
20
-
21
- `:""}Not found: ${d.join(", ")}`),t.length>0&&(e+=`${e?`
22
-
23
- `:""}Truncated by max_results \u2014 request these in a follow-up call: ${t.join(", ")}`);let l=[];m.length>0&&l.push(`Loaded ${m.length} tool(s)`),d.length>0&&l.push(`${d.length} missing`),t.length>0&&l.push(`${t.length} truncated`);let T=l.join(", ")||"No tools loaded";return{llmContent:e,returnDisplay:T}}},_=class r extends R{constructor(s){super(r.Name,L.TOOL_SEARCH,P,"other",{type:"object",properties:{query:{type:"string",description:'Query to find deferred tools. Use "select:<tool_name>" for direct selection, or keywords to search.',minLength:1},max_results:{type:"integer",description:"Maximum number of results to return (default: 5)",minimum:1,maximum:A,default:D}},required:["query"],additionalProperties:!1},!0,!1,!1,!0,"tool search discover find schema");this.config=s}static Name=E.TOOL_SEARCH;createInvocation(s){return new w(this.config,s)}};function I(r){return r.toLowerCase().split(/\s+/g).map(n=>n.trim()).filter(n=>n.length>0)}function O(r,n,s){return Number.isFinite(r)?Math.min(s,Math.max(n,Math.floor(r))):n}function U(r){if(r.length<2)return r;let n=r[0],s=r[r.length-1];return n==='"'&&s==='"'||n==="'"&&s==="'"?r.slice(1,-1):r}function B(r,n){if(n.length===0)return!0;let s=r.name.toLowerCase();return n.every(t=>s.includes(t))}function j(r,n){let s=r instanceof N,t=r.name.toLowerCase(),f=(r.description??"").toLowerCase(),m=(r.searchHint??"").toLowerCase(),d=m?m.split(/\s+/g).filter(Boolean):[],u=0;for(let c of n)c.length!==0&&(t===c||t.endsWith("_"+c)||t.endsWith("."+c)?u+=s?q:b:t.includes(c)&&(u+=s?M:x),d.some(a=>a===c)&&(u+=$),f.includes(c)&&(u+=k));return u}export{_ as ToolSearchTool,j as scoreTool,I as tokenize};
24
- /**
25
- * @license
26
- * Copyright 2025 Matilda Team
27
- * SPDX-License-Identifier: Apache-2.0
28
- */
@@ -1,15 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a as _}from"./chunk-E2KMVG7F.js";import{Cb as k,Db as Q,Nb as P,Ob as u,Sb as V,Tb as J,Ub as X,Va as G,Vb as ee,ja as b}from"./chunk-3IG6LNQ3.js";import"./chunk-FY3LL4OC.js";import"./chunk-BQDEPKIG.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DZKI2CAC.js";import"./chunk-ZUQRP3N6.js";import"./chunk-OWEBLTAN.js";import"./chunk-VWE5BSHV.js";import"./chunk-L2FKLLEC.js";import"./chunk-N2BE647T.js";import"./chunk-QXSBPCBA.js";import"./chunk-HRD7WD3P.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-55YW6EUC.js";import"./chunk-REUZDMLM.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-3BT7ZYAM.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-FPGKJJJY.js";import{C,Db as Y,H as z,xa as H,z as B}from"./chunk-OF7ORAN6.js";import{l as K,m as Z,n as q}from"./chunk-HJK3NKAR.js";import"./chunk-46FFWNRO.js";import"./chunk-BS7Q7KA6.js";import"./chunk-MZ73LBEY.js";import"./chunk-PFXCFIHY.js";import"./chunk-XPVKH5TC.js";import{f as $,g as L,m as j,n as U}from"./chunk-P24OL22U.js";import{D as R,E as S,G as M,c as d,e as D,ea as N}from"./chunk-WL27X35X.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as O}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";O();import v from"node:fs";import y from"node:path";var F=N("WRITE_FILE"),fe=["filePath","filepath","path","file","filename"];function ge(f){if(!(typeof f.file_path=="string"&&f.file_path.trim()))for(let s of fe){let o=f[s];if(typeof o=="string"&&o.trim()){f.file_path=o,delete f[s];return}}}function pe(f){let s=f.content;if(typeof s!="string"||!s.includes("<arg_")&&!s.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(s))!==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(s))!==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=[s.search(/<arg_key\b/i),s.search(/<\/arg_key\b/i),s.search(/<arg_value\b/i)].filter(i=>i>=0),g=h.length>0?Math.min(...h):-1;if(g>=0&&s.slice(g,g+10).startsWith("</arg_key")){let i=s.slice(0,g),n=/([A-Za-z_][\w]*)\s*$/.exec(i);n&&(g=n.index)}let c=g>=0?s.slice(0,g).trimEnd():s;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=S(this.params.file_path,this.config.getTargetDir());return`Writing to ${R(o)}`}async getDefaultPermission(){let o=this.config.getProjectRoot();return K(y.resolve(this.params.file_path),o)?"allow":"ask"}async getConfirmationDetails(o){let e=_(this.config,this.params.file_path);if(e)throw new P(e,"path_not_in_workspace");let r="",l=await C(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 P(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 P(i.rawMessage,i.type)}let h=S(this.params.file_path,this.config.getTargetDir()),g=y.basename(this.params.file_path),c=b(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 C(e),m="",i=!1,n,I,te=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",I=X(t.content),m=t.content,c=!0}catch(t){if(d(t)&&t.code==="ENOENT")c=!1;else{let a={message:D(t),code:d(t)?t.code:void 0},p=a.code?`Error checking existing file '${e}': ${a.message} (${a.code})`:`Error checking existing file: ${a.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===V.UTF8_BOM?i=!0:t===void 0&&(i=J(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||v.mkdirSync(te,{recursive:!0});try{let t=_(this.config,e);if(t)return{llmContent:t,returnDisplay:t,error:{message:t,type:"path_not_in_workspace"}};let a=q(e,this.config.getProjectRoot(),r);await this.config.getFileSystemService().writeTextFile({path:e,content:a,_meta:{bom:i,encoding:n,lineEnding:I}}),h||G.getInstance().recordEdit(e,c?m:null,r);try{let w=v.statSync(e);this.config.getFileReadCache().recordWrite(e,w)}catch{}let p=y.basename(e),W=m,ie=b(p,W,r,"Original","Written",k),oe=Q(p,W,l||r,r),T=[c?`Successfully overwrote file: ${e}.`:`Successfully created and wrote to new file: ${e}.`];a!==r&&T.push(Z),h&&T.push(`User modified the \`content\` to be: ${r}`);let re=B(e),ne=z(e),se=y.extname(e),ae=c?"update":"create",le=r.split(`
4
- `).length;H(this.config,new Y(x.Name,ae,le,re,se,ne));let ce={fileDiff:ie,fileName:p,originalContent:m,newContent:r,diffStat:oe};try{let w=await ee(this.config,e);w&&T.push(`
5
-
6
- ${w}`)}catch{}return{llmContent:T.join(" "),returnDisplay:ce}}catch(t){let a,p="file_write_failure";return d(t)?(a=`Error writing to file '${e}': ${t.message} (${t.code})`,t.code==="EACCES"?(a=`Permission denied writing to file: ${e} (${t.code})`,p="permission_denied"):t.code==="ENOSPC"?(a=`No space left on device: ${e} (${t.code})`,p="no_space_left"):t.code==="EISDIR"&&(a=`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?a=`Error writing to file: ${t.message}`:a=`Error writing to file: ${String(t)}`,{llmContent:a,returnDisplay:a,error:{message:a,type:p}}}}},x=class f extends L{constructor(o){super(f.Name,U.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=j.WRITE_FILE;validateToolParams(o){let e=o;return pe(e),ge(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=M(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(v.existsSync(e)&&v.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 C(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,ge as normalizeWriteFilePathAliases,pe as repairLeakedWriteFileToolArgMarkup};
11
- /**
12
- * @license
13
- * Copyright 2025 Google LLC
14
- * SPDX-License-Identifier: Apache-2.0
15
- */