@maincode-ai/matilda-code 0.21.11 → 0.21.13
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/bundled/mainy/docs/configuration/model-providers.md +0 -82
- package/bundled/mainy/docs/configuration/settings.md +46 -7
- package/bundled/mainy/docs/configuration/trusted-folders.md +12 -6
- package/bundled/mainy/docs/features/auto-mode.md +1 -1
- package/bundled/mainy/docs/features/channels/_meta.ts +0 -3
- package/bundled/mainy/docs/features/channels/overview.md +8 -16
- package/bundled/mainy/docs/features/commands.md +4 -4
- package/bundled/mainy/docs/features/hooks.md +9 -7
- package/bundled/mainy/docs/features/language.md +2 -29
- package/bundled/mainy/docs/features/worktree.md +0 -2
- package/bundled/mainy/docs/integration-github-action.md +3 -3
- package/bundled/mainy/docs/quickstart.md +2 -2
- package/bundled/mainy/docs/support/troubleshooting.md +1 -1
- package/chunks/agent-SRAIVZEE.js +3 -0
- package/chunks/agent-headless-XRDOZESG.js +3 -0
- package/chunks/{anthropicContentGenerator-IYZILRDW.js → anthropicContentGenerator-LLDIKDMQ.js} +3 -3
- package/chunks/{askUserQuestion-XWHJY3DM.js → askUserQuestion-BNSWGD26.js} +1 -1
- package/chunks/{ca-EUJBUYX5.js → ca-NPYL24ME.js} +2 -2
- package/chunks/{chunk-4YVN5HXG.js → chunk-27HUYW23.js} +2 -2
- package/chunks/{chunk-MH2P4YXC.js → chunk-27Q5KW3A.js} +2 -2
- package/chunks/{chunk-NYEWHSBL.js → chunk-2HTPVSGT.js} +1 -1
- package/chunks/{chunk-EQGA7LH7.js → chunk-3B2HABK7.js} +1 -1
- package/chunks/chunk-3MTZTNAU.js +101 -0
- package/chunks/{chunk-WHG6N5X2.js → chunk-5OHGYMKP.js} +1 -1
- package/chunks/{chunk-QH7736R5.js → chunk-6EQMZNIY.js} +1 -1
- package/chunks/chunk-6I6VGTKD.js +8 -0
- package/chunks/{chunk-5427BPR2.js → chunk-6M5G5FBH.js} +1 -1
- package/chunks/{chunk-4FVBPNTZ.js → chunk-6T2GIM76.js} +1 -1
- package/chunks/chunk-7ZODGQO6.js +4 -0
- package/chunks/chunk-AOOZREGV.js +9 -0
- package/chunks/{chunk-JXUDKX6D.js → chunk-DE3HKC2W.js} +1 -1
- package/chunks/chunk-DHDD5YJC.js +207 -0
- package/chunks/{chunk-SPW5DXX4.js → chunk-EZDV7A76.js} +1 -1
- package/chunks/{chunk-ODZOYHIC.js → chunk-GOJCMVJJ.js} +1 -1
- package/chunks/{chunk-FFFZ2QMG.js → chunk-GTVCJCHR.js} +1 -1
- package/chunks/{chunk-Q55AVE2N.js → chunk-IJEGHQ7Z.js} +11 -11
- package/chunks/{chunk-SUH3UUWZ.js → chunk-JCE3JAVC.js} +1 -1
- package/chunks/chunk-KHHJYBR5.js +9 -0
- package/chunks/{chunk-GO2GA2GY.js → chunk-LUNDTQ3G.js} +1 -1
- package/chunks/{chunk-NIQK6NX3.js → chunk-LWARA7JY.js} +1 -1
- package/chunks/{chunk-YMIF2DMT.js → chunk-MEV5XQI2.js} +1 -1
- package/chunks/{chunk-4CSSDBOS.js → chunk-P5TG5CON.js} +10 -10
- package/chunks/chunk-PEKAUGYV.js +2621 -0
- package/chunks/chunk-PGUG43HG.js +24 -0
- package/chunks/{chunk-ELH4YHJR.js → chunk-PGXQZVLX.js} +1 -1
- package/chunks/{chunk-SNLH42QJ.js → chunk-QZI2ZGZY.js} +1 -1
- package/chunks/chunk-RI54U73U.js +56 -0
- package/chunks/chunk-RPFSFS7Z.js +39 -0
- package/chunks/chunk-SOEIVSM5.js +113 -0
- package/chunks/{chunk-4J6DC24J.js → chunk-SVSY6AWS.js} +1 -1
- package/chunks/{chunk-T4P4KEDW.js → chunk-TWJLOEAI.js} +2 -2
- package/chunks/{chunk-HYVP4472.js → chunk-V6UPUMP3.js} +1 -1
- package/chunks/chunk-W4QSMIWO.js +9 -0
- package/chunks/chunk-WC2VTVCE.js +27 -0
- package/chunks/{chunk-GUFIMKF5.js → chunk-YV3PUOBU.js} +1 -1
- package/chunks/chunk-ZX34M2GF.js +14 -0
- package/chunks/{computer-use-SXP25RZQ.js → computer-use-J4GAM4M6.js} +1 -1
- package/chunks/contextCommand-5F5M7NA4.js +3 -0
- package/chunks/{cron-create-2UI4AT4Q.js → cron-create-IDWSZENI.js} +1 -1
- package/chunks/{cron-delete-ZB6BOTFF.js → cron-delete-NQCDZDUI.js} +1 -1
- package/chunks/{cron-list-YYAXNHB6.js → cron-list-Z4XMC3TO.js} +1 -1
- package/chunks/{de-DNEPG7S7.js → de-34YZHGC6.js} +3 -3
- package/chunks/{devtools-5JRKK3E7.js → devtools-XRQ4YJ5S.js} +1 -1
- package/chunks/{dist-P6SLWL5V.js → dist-PH6JW7XD.js} +1 -1
- package/chunks/edit-X2S2ZXRN.js +43 -0
- package/chunks/{en-NOD6KQNM.js → en-QLGMD6OS.js} +3 -3
- package/chunks/{enter-worktree-X47BSJLE.js → enter-worktree-TUCGNCLO.js} +1 -1
- package/chunks/{enterPlanMode-F22ZNTYJ.js → enterPlanMode-SQEZAAIR.js} +1 -1
- package/chunks/{exit-worktree-XY5UMDHX.js → exit-worktree-7FLITFZI.js} +1 -1
- package/chunks/exitPlanMode-O5UUJ3GM.js +120 -0
- package/chunks/{fr-2OE5WLJ4.js → fr-EDNBQACJ.js} +3 -3
- package/chunks/geminiContentGenerator-FIZFLPU3.js +8 -0
- package/chunks/glob-GSFTYAS2.js +22 -0
- package/chunks/{goal-tools-6QTC3UI7.js → goal-tools-YQOA6OKU.js} +1 -1
- package/chunks/{grep-6TTPZ524.js → grep-VAB2VSXM.js} +1 -1
- package/chunks/{ja-3B6V5KS7.js → ja-LV4RLM3M.js} +3 -3
- package/chunks/{keychain-token-storage-54BNK6VH.js → keychain-token-storage-KQK6MNOJ.js} +1 -1
- package/chunks/{ls-YWZU3FYL.js → ls-IZJ3CKZY.js} +1 -1
- package/chunks/{lsp-4CJDKEEC.js → lsp-NGLDRHZU.js} +1 -1
- package/chunks/matildaAgentContentGenerator-QQHPCFJ5.js +8 -0
- package/chunks/matildaContentGenerator-W7Z33ONU.js +8 -0
- package/chunks/{matildaOAuth2-WOY7ZS43.js → matildaOAuth2-7COTQQR2.js} +1 -1
- package/chunks/mcp-client-DXUNIEIB.js +3 -0
- package/chunks/monitor-4PFIGAGG.js +32 -0
- package/chunks/notebook-edit-MWJYAATJ.js +17 -0
- package/chunks/{openaiContentGenerator-MGASUFQL.js → openaiContentGenerator-NDVJL6QL.js} +1 -1
- package/chunks/{pt-KP2JCPUY.js → pt-5SQ4DGL7.js} +3 -3
- package/chunks/read-file-WPZKPXWA.js +3 -0
- package/chunks/ripGrep-7LZDZFTX.js +3 -0
- package/chunks/{ru-K7IQQKHC.js → ru-7K24S53N.js} +3 -3
- package/chunks/scheduler-DK2MVKXX.js +8 -0
- package/chunks/{send-message-OO2HAKCC.js → send-message-TCPX5UDU.js} +1 -1
- package/chunks/{serve-ZQX2WBLF.js → serve-GSZPJI2O.js} +59 -48
- package/chunks/shell-PRS47PDP.js +3 -0
- package/chunks/{skill-KDM3UUML.js → skill-ETQM5NI3.js} +1 -1
- package/chunks/src-UB7DZRYK.js +3 -0
- package/chunks/{symbol-search-ALYOX5JN.js → symbol-search-HARHZ5AH.js} +1 -1
- package/chunks/{syntheticOutput-UASKABJH.js → syntheticOutput-WZDPECYS.js} +1 -1
- package/chunks/task-create-XRNIDT4T.js +3 -0
- package/chunks/{task-detach-I67ZE5MX.js → task-detach-TBAVUOTC.js} +1 -1
- package/chunks/task-list-Z6BDZZID.js +9 -0
- package/chunks/{task-stop-ERI5X4AO.js → task-stop-HDSARSJ6.js} +1 -1
- package/chunks/{task-update-CD3W556L.js → task-update-MW2VT2XV.js} +1 -1
- package/chunks/{team-create-F4KQRGMB.js → team-create-VMYNLZCC.js} +1 -1
- package/chunks/team-delete-F7QDC2TE.js +8 -0
- package/chunks/todoWrite-SCF5M24M.js +3 -0
- package/chunks/{tool-search-JFCD5W5M.js → tool-search-WX6FOE35.js} +1 -1
- package/chunks/tree-sitter-bash-2SWKO5B7.js +3 -0
- package/chunks/{web-fetch-REWGIRWQ.js → web-fetch-CKYBHGLF.js} +13 -13
- package/chunks/{web-search-OX2DPEVN.js → web-search-67DFNS5V.js} +1 -1
- package/chunks/{workflow-SEFYGBED.js → workflow-WBSRQG3N.js} +2 -2
- package/chunks/write-file-S5FAX4JJ.js +15 -0
- package/cli.js +462 -455
- package/locales/ca.js +1 -3
- package/locales/de.js +1 -3
- package/locales/en.js +1 -3
- package/locales/fr.js +1 -3
- package/locales/ja.js +1 -3
- package/locales/pt.js +1 -3
- package/locales/ru.js +1 -3
- package/package.json +2 -2
- package/sandbox-macos-permissive-closed.sb +0 -1
- package/sandbox-macos-permissive-open.sb +0 -1
- package/sandbox-macos-permissive-proxied.sb +0 -1
- package/sandbox-macos-restrictive-closed.sb +3 -1
- package/sandbox-macos-restrictive-open.sb +3 -1
- package/sandbox-macos-restrictive-proxied.sb +3 -1
- package/bundled/mainy/docs/features/channels/dingtalk.md +0 -134
- package/bundled/mainy/docs/features/channels/feishu.md +0 -186
- package/bundled/mainy/docs/features/channels/weixin.md +0 -106
- package/chunks/agent-ZFZ4HJQC.js +0 -3
- package/chunks/agent-headless-KH2BKLP7.js +0 -3
- package/chunks/chunk-25NCTG5H.js +0 -184
- package/chunks/chunk-2HQMJ2IU.js +0 -8
- package/chunks/chunk-6GBNB5Z2.js +0 -3
- package/chunks/chunk-GHBKFIHC.js +0 -35
- package/chunks/chunk-HWOQNYAO.js +0 -27
- package/chunks/chunk-LJR4RZZ2.js +0 -3
- package/chunks/chunk-NVM7W7TG.js +0 -101
- package/chunks/chunk-PA6532AY.js +0 -6
- package/chunks/chunk-QFNFLE2I.js +0 -2625
- package/chunks/chunk-QN6WSWMM.js +0 -9
- package/chunks/chunk-RK2AKQAX.js +0 -39
- package/chunks/chunk-U347OO7S.js +0 -9
- package/chunks/chunk-UIRBHC5X.js +0 -3
- package/chunks/chunk-W5CGKUM4.js +0 -15
- package/chunks/chunk-WRQLIPXW.js +0 -113
- package/chunks/chunk-WVY2P6WH.js +0 -26
- package/chunks/chunk-WZ75OGYY.js +0 -14
- package/chunks/chunk-XCFLI3OC.js +0 -9
- package/chunks/chunk-XMZIY7XX.js +0 -13
- package/chunks/contextCommand-3GN5CAOK.js +0 -3
- package/chunks/dist-ME6647DQ.js +0 -195
- package/chunks/dist-VG3ZDJ2A.js +0 -28
- package/chunks/dist-YTCHM57U.js +0 -23
- package/chunks/edit-KX6V4PH3.js +0 -39
- package/chunks/exitPlanMode-G3QLIWJ4.js +0 -90
- package/chunks/geminiContentGenerator-EQEGOXOV.js +0 -8
- package/chunks/glob-KSBEWI3E.js +0 -22
- package/chunks/matildaAgentContentGenerator-OV4U6DJD.js +0 -8
- package/chunks/matildaContentGenerator-ETIAWE22.js +0 -8
- package/chunks/monitor-F4K5HOZX.js +0 -32
- package/chunks/notebook-edit-TL7CI5EA.js +0 -17
- package/chunks/read-file-6EAPS2KG.js +0 -3
- package/chunks/ripGrep-K6SFFUIE.js +0 -3
- package/chunks/scheduler-TKWPD4LP.js +0 -8
- package/chunks/shell-AZRK5GIO.js +0 -3
- package/chunks/src-SGI6VLOS.js +0 -3
- package/chunks/task-create-EBJD55TB.js +0 -3
- package/chunks/task-list-5BGX4G5N.js +0 -9
- package/chunks/team-delete-5U3GBFKJ.js +0 -8
- package/chunks/todoWrite-YGG6AZ3A.js +0 -3
- package/chunks/tree-sitter-bash-XNCMPQBK.js +0 -3
- package/chunks/write-file-UAGVBZMC.js +0 -15
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{b as a}from"./chunk-
|
|
3
|
+
import{b as a}from"./chunk-GTVCJCHR.js";import"./chunk-27Q5KW3A.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{a as KeychainTokenStorage};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{b as d}from"./chunk-RNKDFE2S.js";import{g as N}from"./chunk-
|
|
3
|
+
import{b as d}from"./chunk-RNKDFE2S.js";import{g as N}from"./chunk-PGXQZVLX.js";import{g as C,i as x,p as w,q as F}from"./chunk-TWJLOEAI.js";import{D as E,E as I,G as S,J as u,K as L,Q as R,ba as O}from"./chunk-27Q5KW3A.js";import"./chunk-FWDMPRKU.js";import{b as v}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";v();import y from"node:fs/promises";import s from"node:path";var A=O("LS"),U=100,T=class extends C{constructor(t,e){super(e);this.config=t}shouldIgnore(t,e){if(!e||e.length===0)return!1;for(let i of e){let a=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");if(new RegExp(`^${a}$`).test(t))return!0}return!1}getDescription(){let t=I(this.params.path,this.config.getTargetDir());return E(t)}async getDefaultPermission(){let t=s.resolve(this.params.path),e=this.config.getWorkspaceContext(),i=this.config.storage.getUserSkillsDirs(),a=R.getUserExtensionsDir();return e.isPathWithinWorkspace(t)||L(i,t)||u(a,t)||u(N(),t)?"allow":"ask"}errorResult(t,e,i){return{llmContent:t,returnDisplay:`Error: ${e}`,error:{message:t,type:i}}}async execute(t){try{let e=await y.stat(this.params.path);if(!e)return this.errorResult(`Error: Directory not found or inaccessible: ${this.params.path}`,"Directory not found or inaccessible.","file_not_found");if(!e.isDirectory())return this.errorResult(`Error: Path is not a directory: ${this.params.path}`,"Path is not a directory.","path_is_not_a_directory");let i=await y.readdir(this.params.path);if(i.length===0)return{llmContent:`Directory ${this.params.path} is empty.`,returnDisplay:"Directory is empty."};let a=i.map(r=>s.relative(this.config.getTargetDir(),s.join(this.params.path,r))),_=this.config.getFileService(),{filteredPaths:k,gitIgnoredCount:P,matildaIgnoredCount:b}=_.filterFilesWithReport(a,{respectGitIgnore:this.params.file_filtering_options?.respect_git_ignore??this.config.getFileFilteringOptions().respectGitIgnore??d.respectGitIgnore,respectMatildaIgnore:this.params.file_filtering_options?.respect_matilda_ignore??this.config.getFileFilteringOptions().respectMatildaIgnore??d.respectMatildaIgnore}),l=[];for(let r of k){let o=s.resolve(this.config.getTargetDir(),r);if(!this.shouldIgnore(s.basename(o),this.params.ignore))try{let c=await y.stat(o),$=c.isDirectory();l.push({name:s.basename(o),path:o,isDirectory:$,size:$?0:c.size,modifiedTime:c.mtime})}catch(c){A.warn(`Error accessing ${o}: ${c}`)}}l.sort((r,o)=>r.isDirectory&&!o.isDirectory?-1:!r.isDirectory&&o.isDirectory?1:r.name.localeCompare(o.name));let p=l.length,g=Math.min(U,this.config.getTruncateToolOutputLines()),m=p>g,W=(m?l.slice(0,g):l).map(r=>`${r.isDirectory?"[DIR] ":""}${r.name}`).join(`
|
|
4
4
|
`),h=`Listed ${p} item(s) in ${this.params.path}:
|
|
5
5
|
---
|
|
6
6
|
${W}`;if(m){let r=p-g;h+=`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{g as b,i as D,p as R,q as N}from"./chunk-
|
|
3
|
+
import{g as b,i as D,p as R,q as N}from"./chunk-TWJLOEAI.js";import{G as P}from"./chunk-27Q5KW3A.js";import"./chunk-FWDMPRKU.js";import{b as S}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";S();import $ from"node:path";import{fileURLToPath as L,pathToFileURL as q}from"node:url";var O=new Set(["goToDefinition","findReferences","hover","goToImplementation","prepareCallHierarchy"]),A=new Set(["documentSymbol","diagnostics"]),E=new Set(["workspaceSymbol"]),U=new Set(["incomingCalls","outgoingCalls"]),W=new Set(["codeActions"]),C=class extends b{constructor(t,e){super(e);this.config=t}getDescription(){let t=this.getOperationLabel();return this.params.operation==="workspaceSymbol"?`LSP ${t} for "${this.params.query??""}"`:this.params.operation==="documentSymbol"?this.params.filePath?`LSP ${t} for ${this.params.filePath}`:`LSP ${t}`:this.params.operation==="incomingCalls"||this.params.operation==="outgoingCalls"?`LSP ${t} for ${this.describeCallHierarchyItemShort()}`:this.params.filePath&&this.params.line!==void 0?`LSP ${t} at ${this.params.filePath}:${this.params.line}:${this.params.character??1}`:this.params.filePath?`LSP ${t} for ${this.params.filePath}`:`LSP ${t}`}async execute(t){let e=this.config.getLspClient();if(!e||!this.config.isLspEnabled()){let r=`LSP ${this.getOperationLabel()} is unavailable (LSP disabled or not initialized).`;return{llmContent:r,returnDisplay:r}}switch(this.params.operation){case"goToDefinition":return this.executeDefinitions(e);case"findReferences":return this.executeReferences(e);case"hover":return this.executeHover(e);case"documentSymbol":return this.executeDocumentSymbols(e);case"workspaceSymbol":return this.executeWorkspaceSymbols(e);case"goToImplementation":return this.executeImplementations(e);case"prepareCallHierarchy":return this.executePrepareCallHierarchy(e);case"incomingCalls":return this.executeIncomingCalls(e);case"outgoingCalls":return this.executeOutgoingCalls(e);case"diagnostics":return this.executeDiagnostics(e);case"workspaceDiagnostics":return this.executeWorkspaceDiagnostics(e);case"codeActions":return this.executeCodeActions(e);default:{let r=`Unsupported LSP operation: ${this.params.operation}`;return{llmContent:r,returnDisplay:r}}}}async executeDefinitions(t){let e=this.resolveLocationTarget();if("error"in e)return{llmContent:e.error,returnDisplay:e.error};let r=this.params.limit??20,i=[];try{i=await t.definitions(e.location,this.params.serverName,r)}catch(n){let c=`LSP go-to-definition failed: ${n?.message||String(n)}`;return{llmContent:c,returnDisplay:c}}if(!i.length){let n=`No definitions found for ${e.description}.`;return{llmContent:n,returnDisplay:n}}let s=this.config.getProjectRoot(),a=i.slice(0,r).map((n,c)=>`${c+1}. ${this.formatLocationWithServer(n,s)}`);return{llmContent:[`Definitions for ${e.description}:`,...a].join(`
|
|
4
4
|
`),returnDisplay:a.join(`
|
|
5
5
|
`)}}async executeImplementations(t){let e=this.resolveLocationTarget();if("error"in e)return{llmContent:e.error,returnDisplay:e.error};let r=this.params.limit??20,i=[];try{i=await t.implementations(e.location,this.params.serverName,r)}catch(n){let c=`LSP go-to-implementation failed: ${n?.message||String(n)}`;return{llmContent:c,returnDisplay:c}}if(!i.length){let n=`No implementations found for ${e.description}.`;return{llmContent:n,returnDisplay:n}}let s=this.config.getProjectRoot(),a=i.slice(0,r).map((n,c)=>`${c+1}. ${this.formatLocationWithServer(n,s)}`);return{llmContent:[`Implementations for ${e.description}:`,...a].join(`
|
|
6
6
|
`),returnDisplay:a.join(`
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{b as t}from"./chunk-IJEGHQ7Z.js";import"./chunk-SOEIVSM5.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-3YLXGE6T.js";import"./chunk-JCE3JAVC.js";import"./chunk-SVSY6AWS.js";import"./chunk-AOOZREGV.js";import"./chunk-SDTWBD62.js";import"./chunk-DHDD5YJC.js";import"./chunk-PGXQZVLX.js";import"./chunk-LUNDTQ3G.js";import"./chunk-5OHGYMKP.js";import"./chunk-TWJLOEAI.js";import"./chunk-27Q5KW3A.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as n}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";n();function a(e,o){return new t(e,o)}export{t as MatildaAgentContentGenerator,a as createMatildaAgentContentGenerator};
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2026 Matilda Team
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{a as l,i as p}from"./chunk-RPFSFS7Z.js";import"./chunk-GOJCMVJJ.js";import"./chunk-PEKAUGYV.js";import"./chunk-M53RP3YP.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-2HTPVSGT.js";import"./chunk-W4QSMIWO.js";import"./chunk-6I6VGTKD.js";import"./chunk-ZX34M2GF.js";import"./chunk-47XR7IMP.js";import"./chunk-MTMU7JYZ.js";import"./chunk-QKYGQLWC.js";import"./chunk-EZDV7A76.js";import"./chunk-RNKDFE2S.js";import"./chunk-RI54U73U.js";import"./chunk-6M5G5FBH.js";import"./chunk-QZI2ZGZY.js";import"./chunk-V6UPUMP3.js";import{c as h}from"./chunk-WC2VTVCE.js";import"./chunk-KHHJYBR5.js";import"./chunk-6EQMZNIY.js";import"./chunk-P5TG5CON.js";import"./chunk-DE3HKC2W.js";import"./chunk-GTVCJCHR.js";import"./chunk-IJEGHQ7Z.js";import"./chunk-PGUG43HG.js";import"./chunk-7ZODGQO6.js";import"./chunk-TISQNFB5.js";import"./chunk-VI74YQQO.js";import"./chunk-YV3PUOBU.js";import"./chunk-SOEIVSM5.js";import{d as u}from"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-3YLXGE6T.js";import"./chunk-JCE3JAVC.js";import"./chunk-SVSY6AWS.js";import"./chunk-AOOZREGV.js";import{k as d}from"./chunk-SDTWBD62.js";import"./chunk-DHDD5YJC.js";import"./chunk-PGXQZVLX.js";import"./chunk-LUNDTQ3G.js";import"./chunk-5OHGYMKP.js";import"./chunk-TWJLOEAI.js";import{ba as c,s as i,t as a}from"./chunk-27Q5KW3A.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as s}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";s();var m=class extends p{debugLogger=c("MATILDA");matildaClient;sharedManager;currentToken;constructor(e,t,n){let r=new l(t,n);super(t,n,r),this.matildaClient=e,this.sharedManager=h.getInstance(),t?.baseUrl&&t?.apiKey&&(this.pipeline.client.baseURL=t?.baseUrl,this.pipeline.client.apiKey=t?.apiKey)}getCurrentEndpoint(e){let t=e||u,n="/v1",r=t.startsWith("http")?t:`https://${t}`;return r.endsWith(n)||r.endsWith("/api/v1")||r.endsWith("/api/v1/code")?r:`${r}${n}`}shouldSuppressErrorLogging(e,t){return this.isAuthError(e)}async getValidToken(){try{let e=await this.sharedManager.getValidCredentials(this.matildaClient);if(!e.access_token)throw new Error("No access token available");return{token:e.access_token,endpoint:this.getCurrentEndpoint(e.resource_url)}}catch(e){throw this.isAuthError(e)?e:(this.debugLogger.warn("Failed to get token from shared manager:",e),new Error("Failed to obtain a valid legacy OAuth access token. Please re-authenticate with Matilda."))}}async executeWithCredentialManagement(e){let t=async()=>{let{token:n,endpoint:r}=await this.getValidToken();this.pipeline.client.apiKey=n,this.pipeline.client.baseURL=r;try{return await e()}catch(o){throw a(o)?new i:o}};try{return await t()}catch(n){if(this.isAuthError(n))return await this.sharedManager.getValidCredentials(this.matildaClient,!0),await d("retry",t);throw n}}async generateContent(e,t){return this.executeWithCredentialManagement(()=>super.generateContent(e,t))}async generateContentStream(e,t){let n=await this.executeWithCredentialManagement(()=>super.generateContentStream(e,t));return async function*(){try{yield*n}catch(r){throw a(r)?new i:r}}()}async countTokens(e){return super.countTokens(e)}async embedContent(e){return this.executeWithCredentialManagement(()=>super.embedContent(e))}isAuthError(e){if(!e||a(e))return!1;let t=e instanceof Error?e.message.toLowerCase():String(e).toLowerCase(),n=e,r=n?.status||n?.code;return Number(r)===403?!1:r===401||r==="401"||t.includes("unauthorized")||t.includes("invalid api key")||t.includes("invalid access token")||t.includes("token expired")||t.includes("authentication")||t.includes("token")&&t.includes("expired")}getCurrentToken(){return this.currentToken?this.currentToken:this.sharedManager.getCurrentCredentials()?.access_token||null}clearToken(){this.currentToken=void 0,this.sharedManager.clearCache()}};export{m as MatildaContentGenerator};
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2025 Matilda
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i,m as j,n as k,o as l,p as m,q as n,r as o,s as p,t as q}from"./chunk-
|
|
3
|
+
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i,m as j,n as k,o as l,p as m,q as n,r as o,s as p,t as q}from"./chunk-WC2VTVCE.js";import"./chunk-KHHJYBR5.js";import"./chunk-VI74YQQO.js";import"./chunk-3YLXGE6T.js";import"./chunk-LUNDTQ3G.js";import"./chunk-27Q5KW3A.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{d as CredentialsClearRequiredError,n as MATILDA_CREDENTIAL_FILE_MODE,j as MatildaOAuth2Client,k as MatildaOAuth2Event,e as MatildaOAuthPollError,o as cacheMatildaCredentials,q as clearCachedCredentialFile,p as clearMatildaCredentials,b as generateCodeChallenge,a as generateCodeVerifier,c as generatePKCEPair,m as getMatildaOAuthClient,f as isDeviceAuthorizationSuccess,h as isDeviceTokenPending,g as isDeviceTokenSuccess,i as isErrorResponse,l as matildaOAuth2Events};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{A as e,B as f,C as g,D as h,E as i,F as j,G as k,H as l,I as m,J as n,K as o,L as p,M as q,N as r,O as s,P as t,Q as u,R as v,S as w,T as x,U as y,V as z,W as A,w as a,x as b,y as c,z as d}from"./chunk-PEKAUGYV.js";import"./chunk-M53RP3YP.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-2HTPVSGT.js";import"./chunk-W4QSMIWO.js";import"./chunk-6I6VGTKD.js";import"./chunk-ZX34M2GF.js";import"./chunk-47XR7IMP.js";import"./chunk-MTMU7JYZ.js";import"./chunk-QKYGQLWC.js";import"./chunk-EZDV7A76.js";import"./chunk-RNKDFE2S.js";import"./chunk-RI54U73U.js";import"./chunk-6M5G5FBH.js";import"./chunk-QZI2ZGZY.js";import"./chunk-V6UPUMP3.js";import"./chunk-WC2VTVCE.js";import"./chunk-KHHJYBR5.js";import"./chunk-6EQMZNIY.js";import"./chunk-P5TG5CON.js";import"./chunk-DE3HKC2W.js";import"./chunk-GTVCJCHR.js";import"./chunk-IJEGHQ7Z.js";import"./chunk-PGUG43HG.js";import"./chunk-7ZODGQO6.js";import"./chunk-TISQNFB5.js";import"./chunk-VI74YQQO.js";import"./chunk-YV3PUOBU.js";import"./chunk-SOEIVSM5.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-3YLXGE6T.js";import"./chunk-JCE3JAVC.js";import"./chunk-SVSY6AWS.js";import"./chunk-AOOZREGV.js";import"./chunk-SDTWBD62.js";import"./chunk-DHDD5YJC.js";import"./chunk-PGXQZVLX.js";import"./chunk-LUNDTQ3G.js";import"./chunk-5OHGYMKP.js";import"./chunk-TWJLOEAI.js";import"./chunk-27Q5KW3A.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{d as MCPDiscoveryState,c as MCPServerStatus,a as MCP_DEFAULT_TIMEOUT_MSEC,e as McpClient,g as addMCPStatusChangeListener,s as connectAndDiscover,y as connectToMcpServer,b as createStreamableHttpCompatibilityFetch,z as createTransport,q as discoverMcpTools,v as discoverPrompts,t as discoverTools,m as getAllMCPServerStatuses,n as getMCPDiscoveryState,k as getMCPServerStatus,l as getMCPServerStderrTail,p as handleAutomaticOAuth,x as hasNetworkTransport,w as invokeMcpPrompt,A as isEnabled,u as listMcpPrompts,f as mcpServerRequiresOAuth,r as populateMcpServerCommand,j as removeMCPServerStatus,h as removeMCPStatusChangeListener,o as setMCPDiscoveryState,i as updateMCPServerStatus};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{Ad as it,Ed as rt,Nd as st,Od as at,gf as mt,nd as ot,qd as D,rf as ct,td as nt,te as P,ti as O,u as et,ud as L,ue as lt,vi as dt,zd as _}from"./chunk-PEKAUGYV.js";import"./chunk-M53RP3YP.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-2HTPVSGT.js";import"./chunk-W4QSMIWO.js";import"./chunk-6I6VGTKD.js";import"./chunk-ZX34M2GF.js";import"./chunk-47XR7IMP.js";import"./chunk-MTMU7JYZ.js";import"./chunk-QKYGQLWC.js";import"./chunk-EZDV7A76.js";import"./chunk-RNKDFE2S.js";import"./chunk-RI54U73U.js";import"./chunk-6M5G5FBH.js";import"./chunk-QZI2ZGZY.js";import"./chunk-V6UPUMP3.js";import"./chunk-WC2VTVCE.js";import"./chunk-KHHJYBR5.js";import"./chunk-6EQMZNIY.js";import"./chunk-P5TG5CON.js";import"./chunk-DE3HKC2W.js";import"./chunk-GTVCJCHR.js";import"./chunk-IJEGHQ7Z.js";import"./chunk-PGUG43HG.js";import"./chunk-7ZODGQO6.js";import"./chunk-TISQNFB5.js";import"./chunk-VI74YQQO.js";import"./chunk-YV3PUOBU.js";import"./chunk-SOEIVSM5.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-3YLXGE6T.js";import"./chunk-JCE3JAVC.js";import"./chunk-SVSY6AWS.js";import"./chunk-AOOZREGV.js";import"./chunk-SDTWBD62.js";import"./chunk-DHDD5YJC.js";import"./chunk-PGXQZVLX.js";import"./chunk-LUNDTQ3G.js";import"./chunk-5OHGYMKP.js";import{g as q,i as Y,p as Q,q as tt}from"./chunk-TWJLOEAI.js";import{K,ba as Z,d as u}from"./chunk-27Q5KW3A.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as J}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";J();import{spawn as ut}from"node:child_process";import ft from"node:path";import{randomUUID as kt}from"node:crypto";var p=Z("MONITOR"),xt=1e3,N=1e4,Dt=3e5,U=6e5,pt=80,R=4096,gt=5,ht=1e3;function yt(c){return c.length>pt?c.slice(0,pt-1)+"\u2026":c}var Rt=new Set(["task-notification","task-id","tool-use-id","kind","status","event-count","summary","result"]),It=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)>/g;function vt(c){let g="";for(let t=0;t<c.length;t++){let n=c.charCodeAt(t);if(n===9){g+=c[t];continue}n<32||n>=128&&n<=159||(g+=c[t])}return g=g.replace(It,(t,n,i)=>Rt.has(String(i).toLowerCase())?n==="/"?`</\u200B${i}>`:`<\u200B${i}>`:t),g}var B=class extends q{constructor(t,n){super(n);this.config=t}callId;setCallId(t){this.callId=t}getDescription(){let t=this.params.description||_(this.params.command).spawnCommand;return`Monitor: ${yt(t)}`}async getDefaultPermission(){if(D().shell!=="bash")return"ask";let t=_(this.params.command).spawnCommand;return await P(t,{cwd:this.params.directory||this.config.getTargetDir(),workspace:this.config.getWorkspaceContext()})?"allow":"ask"}async getConfirmationDetails(t){let n=D(),i=_(this.params.command);if(n.shell==="bash"&&await st(),n.shell!=="bash"||!lt(i.safetyCommand,this.params.directory||this.config.getTargetDir()))return{type:"exec",title:"Monitor",command:i.spawnCommand,rootCommand:n.executable,permissionRules:[],hideAlwaysAllow:!0,onConfirm:async()=>{}};let h=nt(i.safetyCommand),C=[];for(let l of h){let a=!1;try{a=await P(l,{cwd:this.params.directory||this.config.getTargetDir(),workspace:this.config.getWorkspaceContext()})}catch(m){p.warn("AST read-only check failed for monitor sub-command, falling back to ask:",m)}a||C.push(l)}let v=C.length>0?C:h,w=[...new Set(v.map(l=>L(l)).filter(l=>!!l))],r=[];try{let l=[];for(let a of v){let m=await at(a);l.push(...m)}r=[...new Set(l)].map(a=>`Monitor(${a})`)}catch(l){p.warn("Failed to extract monitor command rules:",l),r=[`Monitor(${i.safetyCommand})`]}let d=rt(i.safetyCommand,this.params.command),b={type:"exec",title:"Monitor",command:i.spawnCommand,rootCommand:w.join(", ")||(L(i.safetyCommand)??i.spawnCommand),permissionRules:r,onConfirm:async(l,a)=>{}};return d&&(b.warnings=d),b}async execute(t){if(t.aborted)return{llmContent:"Monitor was cancelled before it could start.",returnDisplay:"Monitor cancelled."};let n=_(this.params.command),i=n.spawnCommand;n.strippedTrailingAmp&&p.warn("Stripped trailing & from monitor command \u2014 monitor lifecycle handles backgrounding");let h=vt(this.params.description||i),C=yt(h),v=Math.min(this.params.max_events??xt,N),w=Math.min(this.params.idle_timeout_ms??Dt,U),r=`mon_${kt().replace(/-/g,"").slice(0,16)}`,d=this.config.getMonitorRegistry(),b=ot()??void 0;if(d.getRunning().length>=O)return{llmContent:`Cannot start monitor: maximum concurrent monitors (${O}) reached. Stop an existing monitor first.`,returnDisplay:"Monitor rejected: too many concurrent monitors."};let a=new AbortController,m={monitorId:r,command:i,description:h,status:"running",startTime:Date.now(),abortController:a,toolUseId:this.callId,eventCount:0,lastEventTime:0,maxEvents:v,idleTimeoutMs:w,droppedLines:0,outputFile:dt(this.config.storage.getProjectDir(),this.config.getSessionId(),r),...b?{ownerAgentId:b}:{}},{executable:_t,argsPrefix:Ct}=D(),o;try{o=ut(_t,[...Ct,i],{cwd:this.params.directory||this.config.getTargetDir(),stdio:["ignore","pipe","pipe"],detached:!0,env:{...et(),MATILDA_CODE:"1",TERM:"dumb",PAGER:"cat",...ct()}})}catch(e){return{llmContent:`Monitor failed to start: ${u(e)}`,returnDisplay:`Monitor failed: ${u(e)}`}}m.pid=o.pid;let M=!1,E,I=e=>{E??=e};o.on("error",I);let G={value:""},z={value:""},k=gt,A=Date.now(),$=e=>{let s=vt(e);if(s.length===0||s.trim().length===0)return;let y=Date.now(),T=y-A;if(T<0)p.warn(`Monitor ${r}: clock moved backwards by ${-T}ms, resetting refill timestamp`),A=y;else{let f=Math.floor(T/ht);f>0&&(k=Math.min(gt,k+f),A+=f*ht)}k>0?(k--,d.emitEvent(r,s)):m.droppedLines++},W=()=>{for(let e of[G,z]){let s=e.value.trim();s.length>0&&$(s),e.value=""}},wt=()=>{if(!(M||!o.pid))if(process.platform==="win32")ut("taskkill",["/pid",o.pid.toString(),"/f","/t"],{stdio:"ignore"}).on("error",s=>p.warn(`Monitor taskkill failed for pid ${o.pid}: ${u(s)}`));else{try{process.kill(-o.pid,"SIGTERM")}catch(e){p.warn(`Monitor ${r} SIGTERM failed (pid=${o.pid}): ${u(e)}`)}setTimeout(()=>{if(!M&&o.pid)try{process.kill(-o.pid,"SIGKILL")}catch(e){p.warn(`Monitor ${r} SIGKILL escalation failed (pid=${o.pid}): ${u(e)}`)}},200).unref?.()}},S=()=>{W(),wt()};a.signal.addEventListener("abort",S,{once:!0}),a.signal.aborted&&S();try{d.register(m)}catch(e){return S(),a.signal.removeEventListener("abort",S),o.stdout?.destroy?.(),o.stderr?.destroy?.(),o.removeListener("error",I),o.on("error",()=>{}),{llmContent:`Monitor failed to start: ${u(e)}`,returnDisplay:`Monitor failed: ${u(e)}`}}let j=(e,s)=>{if(m.status!=="running")return;let y=mt(s.toString("utf-8"));if(e.value+=y,!e.value.includes(`
|
|
4
|
+
`)&&e.value.length>R){let f=e.value.trim();f.length>0&&$(f.slice(0,R)+"..."),e.value="";return}let T=e.value.split(`
|
|
5
|
+
`);e.value=T.pop()??"";for(let f of T){let x=f.trim();if(x.length===0)continue;let St=x.length>R?x.slice(0,R)+"...":x;$(St)}};o.stdout?.on("data",e=>j(G,e)),o.stderr?.on("data",e=>j(z,e));let F=!1,X=()=>{F||(F=!0,W(),a.signal.removeEventListener("abort",S),m.droppedLines>0&&p.info(`Monitor ${r} dropped ${m.droppedLines} lines due to throttling`))},V=null,bt=(e,s)=>{m.status==="running"&&(a.signal.aborted?d.cancel(r):e!==null&&e!==0?d.fail(r,`Exit code ${e}`):s?d.fail(r,`Killed by signal ${s}`):d.complete(r,e))},Mt=(e,s)=>{M=!0,V={code:e,sig:s}},Et=(e,s)=>{M=!0,X();let y=V??{code:e,sig:s};bt(y.code,y.sig)},H=e=>{M=!0,X(),m.status==="running"&&d.fail(r,u(e))};return o.on("exit",Mt),o.on("close",Et),o.on("error",H),o.removeListener("error",I),E?(H(E),{llmContent:`Monitor failed to start: ${u(E)}`,returnDisplay:`Monitor failed: ${u(E)}`}):{llmContent:`Monitor started.
|
|
6
|
+
id: ${r}
|
|
7
|
+
command: ${i}
|
|
8
|
+
description: ${h}
|
|
9
|
+
max_events: ${v}
|
|
10
|
+
idle_timeout: ${w}ms
|
|
11
|
+
Events will be delivered as notifications. The monitor auto-stops after ${v} events or ${w}ms of silence.
|
|
12
|
+
To inspect: /tasks (text) or the interactive Background tasks dialog (focus the footer Background tasks pill, then Enter \u2014 detail view + live updates).`,returnDisplay:`Monitor started: ${C} (${r})`}}},Tt=class c extends Y{constructor(t){super(c.Name,tt.MONITOR,`Starts a long-running shell command and streams its stdout/stderr as event notifications back to you.
|
|
13
|
+
|
|
14
|
+
Use this tool for:
|
|
15
|
+
- Watching log files: \`tail -f /var/log/app.log\`
|
|
16
|
+
- Monitoring build output: \`npm run build --watch\`
|
|
17
|
+
- Polling for state changes: \`while true; do curl -s http://localhost:8080/health; sleep 1; done\`
|
|
18
|
+
- Watching file changes: \`fswatch -r ./src\`
|
|
19
|
+
|
|
20
|
+
Each output line from the command becomes a notification event delivered to you. The monitor runs in the background \u2014 you can continue working while it streams events.
|
|
21
|
+
|
|
22
|
+
**Auto-stop:** The monitor automatically stops after max_events (default 1000) events or after idle_timeout_ms (default 5 minutes) of silence. The process is killed when the monitor stops.
|
|
23
|
+
|
|
24
|
+
**Do NOT use this tool for:**
|
|
25
|
+
- One-shot commands (use run_shell_command instead)
|
|
26
|
+
- Commands you need the full output from (use run_shell_command instead)
|
|
27
|
+
- Commands with no output (use run_shell_command with is_background: true instead)`,"execute",{type:"object",properties:{command:{type:"string",description:"Shell command to run and monitor. Each output line (stdout and stderr) becomes an event notification."},description:{type:"string",description:'Brief description of what this monitor watches (e.g., "webpack build output"). Truncated to 80 characters in display.'},max_events:{type:"number",description:"Stop the monitor after this many events. Default 1000. Max 10000."},idle_timeout_ms:{type:"number",description:"Stop the monitor if no output for this many milliseconds. Default 300000 (5 min). Max 600000."},directory:{type:"string",description:"(OPTIONAL) The absolute path of the directory to run the command in. If not provided, the project root directory is used. Must be within the workspace."}},required:["command"],additionalProperties:!1},!0,!1,!0,!1,"monitor watch tail log stream background");this.config=t}static Name=Q.MONITOR;validateToolParamValues(t){if(typeof t.command!="string"||!_(t.command).analysisCommand)return"Command cannot be empty.";if(it(t.command))return'Monitor commands must not contain non-final top-level background operators. Remove "&" and let the monitor manage process lifetime.';if(t.max_events!==void 0){if(typeof t.max_events!="number"||!Number.isInteger(t.max_events)||t.max_events<=0)return"max_events must be a positive integer.";if(t.max_events>N)return`max_events cannot exceed ${N}.`}if(t.idle_timeout_ms!==void 0){if(typeof t.idle_timeout_ms!="number"||!Number.isInteger(t.idle_timeout_ms)||t.idle_timeout_ms<=0)return"idle_timeout_ms must be a positive integer.";if(t.idle_timeout_ms>U)return`idle_timeout_ms cannot exceed ${U}ms (10 minutes).`}if(t.directory){if(!ft.isAbsolute(t.directory))return"Directory must be an absolute path.";let n=ft.resolve(t.directory),i=this.config.storage.getUserSkillsDirs();if(K(i,n))return"Explicitly running monitor commands from within the user skills directory is not allowed. Please use absolute paths for command parameter instead.";if(!this.config.getWorkspaceContext().isPathWithinWorkspace(t.directory))return`Directory '${t.directory}' is not within any of the registered workspace directories.`}return null}createInvocation(t){return new B(this.config,t)}toAutoClassifierInput(t){let n={command:t.command};return t.directory&&(n.directory=t.directory),n}};export{Tt as MonitorTool,vt as sanitizeMonitorLine};
|
|
28
|
+
/**
|
|
29
|
+
* @license
|
|
30
|
+
* Copyright 2025 Matilda
|
|
31
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
32
|
+
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{$e as D,Ef as X,Hf as Z,Ia as R,af as Y,dd as Q,vf as y}from"./chunk-PEKAUGYV.js";import"./chunk-M53RP3YP.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-2HTPVSGT.js";import"./chunk-W4QSMIWO.js";import"./chunk-6I6VGTKD.js";import"./chunk-ZX34M2GF.js";import"./chunk-47XR7IMP.js";import"./chunk-MTMU7JYZ.js";import"./chunk-QKYGQLWC.js";import"./chunk-EZDV7A76.js";import"./chunk-RNKDFE2S.js";import"./chunk-RI54U73U.js";import"./chunk-6M5G5FBH.js";import"./chunk-QZI2ZGZY.js";import"./chunk-V6UPUMP3.js";import"./chunk-WC2VTVCE.js";import"./chunk-KHHJYBR5.js";import"./chunk-6EQMZNIY.js";import"./chunk-P5TG5CON.js";import"./chunk-DE3HKC2W.js";import"./chunk-GTVCJCHR.js";import"./chunk-IJEGHQ7Z.js";import"./chunk-PGUG43HG.js";import"./chunk-7ZODGQO6.js";import"./chunk-TISQNFB5.js";import"./chunk-VI74YQQO.js";import"./chunk-YV3PUOBU.js";import"./chunk-SOEIVSM5.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-3YLXGE6T.js";import"./chunk-JCE3JAVC.js";import"./chunk-SVSY6AWS.js";import"./chunk-AOOZREGV.js";import"./chunk-SDTWBD62.js";import{J as B,K as k,L as U,M as K,N as q,O as b,Ob as z,P as W,Q as j,R as C,S as J,T as V,U as w,V as M,ca as G,ed as H}from"./chunk-DHDD5YJC.js";import"./chunk-PGXQZVLX.js";import"./chunk-LUNDTQ3G.js";import"./chunk-5OHGYMKP.js";import{g as $,i as L,p as c,q as x}from"./chunk-TWJLOEAI.js";import{D as _,E as N,G as T,ba as F}from"./chunk-27Q5KW3A.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as v}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";v();import*as E from"node:fs";import*as m from"node:path";var ee=F("NOTEBOOK_EDIT");function g(d,r,t){return ee.debug("prior-read-rejected",{path:d,reason:r,type:t.type,displayMessage:t.displayMessage}),t}var u=class extends Error{constructor(t,e){super(t);this.type=e;this.name="NotebookEditError"}};function te(d,r){if(r==="delete")return"";if(typeof d!="string")throw new u(`new_source is required when edit_mode is "${r}".`,"invalid_tool_params");return d}function I(d,r){return d?q(d,r):`cell-${r}`}function oe(d,r,t){if(!r){if(t==="insert")return-1;throw new u("cell_id is required for replace and delete operations.","invalid_tool_params")}if(W(d,r))throw new u(`Cell ID "${r}" is ambiguous in the rendered notebook. Re-read the notebook and target a stable real cell ID before editing.`,"invalid_tool_params");let e=j(d,r);if(e===-1)throw new u(`Cell with ID "${r}" not found in notebook.`,"notebook_cell_not_found");return e}function ie(d,r,t,e){let o={cell_type:r,metadata:{},source:w(t,e)},i=J(d);return i&&(o.id=i),M(o,r),o}function O(d,r){let t;try{t=k(d)}catch(a){throw new u(a instanceof Error?a.message:String(a),"notebook_invalid_json")}let e=r.edit_mode??"replace",o=te(r.new_source,e),i=b(t),n=oe(t,r.cell_id,e),l=C(t),p=U(d),s=(a,f)=>{let h=e==="insert"||e==="delete";return{...f,updatedContent:K(a,p),requiresReadAfterWrite:h&&!(i&&b(a))}};switch(e){case"insert":{let a=r.cell_type??"code",f=n===-1?0:n+1,h=ie(t,a,o,V(t,f));return t.cells.splice(f,0,h),s(t,{editedCellId:I(h,f),editedCellType:a,language:l,mode:e})}case"delete":{let[a]=t.cells.splice(n,1);return s(t,{editedCellId:I(a,n),editedCellType:a?.cell_type,language:l,mode:e})}case"replace":{let a=t.cells[n];if(!a)throw new u(`Cell index ${n} is out of range.`,"notebook_cell_not_found");let f=r.cell_type??a.cell_type;return a.source=w(o,Array.isArray(a.source)),M(a,f),s(t,{editedCellId:I(a,n),editedCellType:f,language:l,mode:e})}default:throw new u(`Unsupported notebook edit mode: ${e}`,"invalid_tool_params")}}function re(d,r,t){let e,o;try{e=k(r),o=k(d)}catch(i){throw new u(i instanceof Error?i.message:String(i),"notebook_invalid_json")}return{updatedContent:r,editedCellId:t.cell_id??"user-modified-notebook",editedCellType:void 0,language:C(e),mode:t.edit_mode??"replace",requiresReadAfterWrite:!b(o)||!b(e)}}async function A(d,r,t={}){if(d.getFileReadCacheDisabled())return{ok:!0};let e;try{e=await E.promises.stat(r)}catch(i){let n=i?.code;return n==="ENOENT"?t.expectExisting?g(r,"missing-after-read",{ok:!1,type:"file_changed_since_read",rawMessage:`Notebook ${r} disappeared after it was read. Re-read it with the ${c.READ_FILE} tool before editing it.`,displayMessage:`notebook disappeared after last read; re-run ${c.READ_FILE} first.`}):{ok:!0}:g(r,"stat-failed",{ok:!1,type:"prior_read_verification_failed",rawMessage:`Could not stat ${r} to verify prior notebook read (${n??"unknown error"}). Re-read it with the ${c.READ_FILE} tool before editing it.`,displayMessage:`cannot verify prior read of ${r}; re-run ${c.READ_FILE} before editing this notebook.`})}if(e.isDirectory())return g(r,"target-is-directory",{ok:!1,type:"target_is_directory",rawMessage:`${r} is a directory. The NotebookEdit tool only operates on .ipynb files.`,displayMessage:"path is a directory; cannot edit as a notebook."});if(!e.isFile())return g(r,"target-not-regular-file",{ok:!1,type:"target_not_regular_file",rawMessage:`${r} is not a regular file. The NotebookEdit tool only operates on .ipynb files.`,displayMessage:"special file; cannot edit as a notebook."});let o=d.getFileReadCache().check(e);return o.state==="fresh"&&o.entry.lastReadAt!==void 0&&o.entry.lastReadWasFull?{ok:!0}:o.state==="fresh"&&o.entry.lastReadAt!==void 0&&!o.entry.lastReadWasFull?g(r,"truncated-cache-entry",{ok:!1,type:"edit_requires_prior_read",rawMessage:`Notebook ${r} is too large for cell-level editing because its rendered output was truncated when read. Reduce the notebook output size or split the notebook before editing cells.`,displayMessage:"notebook too large for cell-level editing."}):o.state==="stale"?g(r,"stale-cache-entry",{ok:!1,type:"file_changed_since_read",rawMessage:`Notebook ${r} has been modified since you last read it. Re-read it with the ${c.READ_FILE} tool before editing it.`,displayMessage:`notebook changed since last read; re-run ${c.READ_FILE} first.`}):g(r,`cache-${o.state}`,{ok:!1,type:"edit_requires_prior_read",rawMessage:`Notebook ${r} has not been fully read in this session. Use the ${c.READ_FILE} tool first, without offset or limit, before editing cells.`,displayMessage:`${c.READ_FILE} required before editing this notebook.`})}var P=class extends ${constructor(t,e,o){super(e);this.config=t;this.modifyMetadata=o}toolLocations(){return[{path:this.params.notebook_path}]}getDescription(){let t=N(this.params.notebook_path,this.config.getTargetDir()),e=this.params.edit_mode??"replace",o=this.params.cell_id??"beginning";return`${e} notebook cell ${o} in ${_(t)}`}async getDefaultPermission(){return"ask"}async getConfirmationDetails(t){let e=await this.prepareEdit(t),o=m.basename(this.params.notebook_path),i=R(o,e.originalContent,e.updatedContent,"Current","Proposed",D);return{type:"edit",title:`Confirm Notebook Edit: ${_(N(this.params.notebook_path,this.config.getTargetDir()))}`,fileName:o,filePath:this.params.notebook_path,fileDiff:i,originalContent:e.originalContent,newContent:e.updatedContent,onConfirm:async l=>{l==="proceed_always"&&this.config.setApprovalMode("auto-edit")}}}async prepareEdit(t){let e=await A(this.config,this.params.notebook_path);if(!e.ok)throw new y(e.rawMessage,e.type);let o,i=!1,n,l="lf";try{let s=await this.config.getFileSystemService().readTextFile({path:this.params.notebook_path});o=s.content,i=s._meta?.bom??!1,n=s._meta?.encoding,l=s._meta?.lineEnding??X(s.content)}catch(s){throw t.aborted?s:s?.code==="ENOENT"?new y(`Notebook file not found: ${this.params.notebook_path}`,"file_not_found"):new y(`Error reading notebook: ${s instanceof Error?s.message:String(s)}`,"read_content_failure")}let p=await A(this.config,this.params.notebook_path,{expectExisting:!0});if(!p.ok)throw new y(p.rawMessage,p.type);try{return this.modifyMetadata?.modifiedNotebookContent!==void 0?{...re(o,this.modifyMetadata.modifiedNotebookContent,this.params),originalContent:o,bom:i,encoding:n,lineEnding:l}:{...O(o,this.params),originalContent:o,bom:i,encoding:n,lineEnding:l}}catch(s){throw s instanceof u?new y(s.message,s.type):s}}async execute(t){let e;try{e=await this.prepareEdit(t)}catch(o){if(t.aborted)throw o;let i=o instanceof y?o.errorType:"notebook_edit_failure",n=o instanceof Error?o.message:String(o);return{llmContent:n,returnDisplay:`Error: ${n}`,error:{message:n,type:i}}}try{try{await this.config.getFileHistoryService().trackEdit(this.params.notebook_path)}catch{}let o=await A(this.config,this.params.notebook_path,{expectExisting:!0});if(!o.ok)return{llmContent:o.rawMessage,returnDisplay:`Error: ${o.displayMessage}`,error:{message:o.rawMessage,type:o.type}};await this.config.getFileSystemService().writeTextFile({path:this.params.notebook_path,content:e.updatedContent,_meta:{bom:e.bom,encoding:e.encoding,lineEnding:e.lineEnding}}),this.modifyMetadata?.modifiedByUser||Q.getInstance().recordEdit(this.params.notebook_path,e.originalContent,e.updatedContent);try{let a=E.statSync(this.params.notebook_path),f=this.config.getFileReadCache();e.requiresReadAfterWrite?f.invalidate(a):f.recordWrite(this.params.notebook_path,a,{cacheable:!1})}catch(a){ee.warn(`[NotebookEdit] post-write cache update failed for ${this.params.notebook_path}: ${a instanceof Error?a.message:String(a)}`)}let i=m.basename(this.params.notebook_path),n=R(i,e.originalContent,e.updatedContent,"Current","Proposed",D),l=Y(i,e.originalContent,this.modifyMetadata?.aiProposedContent??e.updatedContent,e.updatedContent);z(this.config,new H(S.Name,"update",e.updatedContent.split(`
|
|
4
|
+
`).length,G(this.params.notebook_path),".ipynb",e.language));let p={fileDiff:n,fileName:i,originalContent:e.originalContent,newContent:e.updatedContent,diffStat:l},s=this.modifyMetadata?.modifiedNotebookContent!==void 0?`Notebook ${this.params.notebook_path} has been updated. Notebook content was modified by the user before approval; the final saved notebook may differ from the original ${e.mode} cell ${e.editedCellId} proposal.`:`Notebook ${this.params.notebook_path} has been updated. ${e.mode} cell ${e.editedCellId}.${e.mode==="delete"?"":`
|
|
5
|
+
|
|
6
|
+
Updated source:
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
${B(this.params.new_source??"")}`}`;try{let a=await Z(this.config,this.params.notebook_path);a&&(s+=`
|
|
11
|
+
|
|
12
|
+
${a}`)}catch{}return{llmContent:s,returnDisplay:p,resultFilePaths:[this.params.notebook_path]}}catch(o){let i=o instanceof Error?o.message:String(o);return{llmContent:`Error writing notebook: ${i}`,returnDisplay:`Error writing notebook: ${i}`,error:{message:i,type:"file_write_failure"}}}}},S=class d extends L{constructor(t){super(d.Name,x.NOTEBOOK_EDIT,`Edits a Jupyter notebook (.ipynb) safely at the cell level. Use this instead of ${c.EDIT} or ${c.WRITE_FILE} for notebook cells. Supports replacing, inserting, and deleting cells. Always read the notebook first with ${c.READ_FILE}; then use the cell IDs shown in that output.`,"edit",{properties:{notebook_path:{description:"Absolute path to the Jupyter notebook file to edit. Must end with .ipynb.",type:"string"},cell_id:{description:"Target cell ID from read_file output, or cell-N 0-based fallback. Required for replace and delete. For insert, the new cell is inserted after this cell; if omitted, inserted at the beginning.",type:"string"},new_source:{description:"New source content for replace and insert operations. Not required for delete.",type:"string"},cell_type:{description:"Cell type for inserted cells or type conversion on replace.",type:"string",enum:["code","markdown"]},edit_mode:{description:"Notebook edit operation. Defaults to replace.",type:"string",enum:["replace","insert","delete"]}},required:["notebook_path"],additionalProperties:!1,type:"object"});this.config=t}static Name=c.NOTEBOOK_EDIT;modifyMetadataByParams=new WeakMap;modifyMetadataByKey=new Map;validateToolParamValues(t){if(t.notebook_path=T(t.notebook_path.trim()),!t.notebook_path)return"The 'notebook_path' parameter must be non-empty.";if(!m.isAbsolute(t.notebook_path))return`Notebook path must be absolute: ${t.notebook_path}`;if(m.extname(t.notebook_path).toLowerCase()!==".ipynb")return"File must be a Jupyter notebook (.ipynb). Use the edit tool for other file types.";let e=t.edit_mode??"replace";return["replace","insert","delete"].includes(e)?t.cell_type&&!["code","markdown"].includes(t.cell_type)?"cell_type must be 'code' or 'markdown'.":e!=="insert"&&!t.cell_id?"cell_id is required for replace and delete operations.":e!=="delete"&&typeof t.new_source!="string"?`new_source is required when edit_mode is "${e}".`:this.config.getFileService().shouldMatildaIgnoreFile(t.notebook_path)?`File path '${t.notebook_path}' is ignored by .matildaignore pattern(s).`:null:"edit_mode must be 'replace', 'insert', or 'delete'."}createInvocation(t){return new P(this.config,t,this.consumeModifyMetadata(t))}getModifyMetadataKey(t){return JSON.stringify({notebook_path:T(t.notebook_path.trim()),cell_id:t.cell_id,new_source:t.new_source,cell_type:t.cell_type,edit_mode:t.edit_mode})}rememberModifyMetadata(t,e){this.modifyMetadataByParams.set(t,e);let o=this.getModifyMetadataKey(t),i=this.modifyMetadataByKey.get(o)??[];i.push(e),this.modifyMetadataByKey.set(o,i)}consumeModifyMetadata(t){let e=this.modifyMetadataByParams.get(t);if(e)return this.modifyMetadataByParams.delete(t),this.removeQueuedModifyMetadata(t,e),e;let o=this.getModifyMetadataKey(t),i=this.modifyMetadataByKey.get(o),n=i?.shift();return i&&i.length===0&&this.modifyMetadataByKey.delete(o),n}removeQueuedModifyMetadata(t,e){let o=this.getModifyMetadataKey(t),i=this.modifyMetadataByKey.get(o);if(!i)return;let n=i.indexOf(e);n!==-1&&i.splice(n,1),i.length===0&&this.modifyMetadataByKey.delete(o)}getModifyContext(t){let e=new Map,o=async i=>{let n=e.get(i.notebook_path);if(n!==void 0)return n;let{content:l}=await this.config.getFileSystemService().readTextFile({path:i.notebook_path});return e.set(i.notebook_path,l),l};return{getFilePath:i=>i.notebook_path,getCurrentContent:async i=>o(i),getProposedContent:async i=>{let n=await o(i);return O(n,i).updatedContent},createUpdatedParams:(i,n,l)=>{let p=this.modifyMetadataByParams.get(l)?.aiProposedContent;if(p===void 0)try{p=O(i,l).updatedContent}catch{p=n}let s={...l};return this.rememberModifyMetadata(s,{aiProposedContent:p,modifiedByUser:!0,modifiedNotebookContent:n}),s}}}};export{S as NotebookEditTool,O as applyNotebookEdit};
|
|
13
|
+
/**
|
|
14
|
+
* @license
|
|
15
|
+
* Copyright 2026 Matilda Team
|
|
16
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
*/
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m}from"./chunk-
|
|
3
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m}from"./chunk-RPFSFS7Z.js";import"./chunk-GOJCMVJJ.js";import"./chunk-PGUG43HG.js";import"./chunk-7ZODGQO6.js";import"./chunk-TISQNFB5.js";import"./chunk-VI74YQQO.js";import"./chunk-YV3PUOBU.js";import{g as a}from"./chunk-SOEIVSM5.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-3YLXGE6T.js";import"./chunk-JCE3JAVC.js";import"./chunk-SVSY6AWS.js";import"./chunk-AOOZREGV.js";import"./chunk-SDTWBD62.js";import"./chunk-DHDD5YJC.js";import"./chunk-PGXQZVLX.js";import"./chunk-LUNDTQ3G.js";import"./chunk-5OHGYMKP.js";import"./chunk-TWJLOEAI.js";import"./chunk-27Q5KW3A.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{h as ContentGenerationPipeline,c as DeepSeekOpenAICompatibleProvider,i as EnhancedErrorHandler,b as MatildaOpenAICompatibleProvider,k as MatildaOpenAIContentGenerator,g as MiMoOpenAICompatibleProvider,e as MiniMaxOpenAICompatibleProvider,f as MistralOpenAICompatibleProvider,a as OpenAIContentConverter,j as OpenAIContentGenerator,d as OpenRouterOpenAICompatibleProvider,l as createOpenAIContentGenerator,m as determineProvider};
|