@morphllm/morphmcp 0.8.200 → 0.8.202
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/dist/index.js +1 -1
- package/dist/log-utils.js +1 -1
- package/dist/logger.js +1 -1
- package/dist/path-utils.js +1 -1
- package/dist/path-validation.js +1 -1
- package/dist/roots-utils.js +1 -1
- package/dist/tool-definitions.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const a0_0x503392=a0_0x4413;(function(_0x252f3d,_0x1b6d7d){const _0x478250=a0_0x4413,_0x321c61=_0x252f3d();while(!![]){try{const _0x65e96e=parseInt(_0x478250(0x1aa))/0x1*(parseInt(_0x478250(0x1c6))/0x2)+-parseInt(_0x478250(0x158))/0x3+parseInt(_0x478250(0x19e))/0x4*(-parseInt(_0x478250(0x120))/0x5)+parseInt(_0x478250(0x1fe))/0x6+parseInt(_0x478250(0x186))/0x7+-parseInt(_0x478250(0x13c))/0x8+-parseInt(_0x478250(0x1d1))/0x9;if(_0x65e96e===_0x1b6d7d)break;else _0x321c61['push'](_0x321c61['shift']());}catch(_0x399097){_0x321c61['push'](_0x321c61['shift']());}}}(a0_0x4338,0xd31dd));import{Server}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import{CallToolRequestSchema,ListToolsRequestSchema,RootsListChangedNotificationSchema}from'@modelcontextprotocol/sdk/types.js';import a0_0x306e16 from'fs/promises';import a0_0x43e623 from'path';import a0_0x28c33c from'os';import{createRequire}from'module';import{z}from'zod';import{zodToJsonSchema}from'zod-to-json-schema';import{getValidRootDirectories}from'./roots-utils.js';import{getOperatingSystemType,logMcpStderr}from'./log-utils.js';import{logger}from'./logger.js';import{executeEditFile}from'@morphllm/morphsdk/tools/fastapply';import{runWarpGrep,LocalRipgrepProvider,GITHUB_SEARCH_TOOL_NAME,GITHUB_SEARCH_DESCRIPTION}from'@morphllm/morphsdk/tools/warp-grep';import{WarpGrepClient,formatResult}from'@morphllm/morphsdk/tools/warp-grep/client';import{compactFileContexts}from'@morphllm/morphsdk/tools/compact';import a0_0x21726c from'axios';import{KNOWN_TOOL_NAMES,TOOL_NAMES}from'./tool-definitions.js';function fixPathRepetition(_0x85e325){const _0x593c37=a0_0x4413,_0x3875ba=_0x85e325['split'](a0_0x43e623[_0x593c37(0x1e7)])['filter'](Boolean);if(_0x3875ba[_0x593c37(0x13b)]<0x2)return null;for(let _0x30c086=Math[_0x593c37(0x224)](_0x3875ba[_0x593c37(0x13b)]/0x2);_0x30c086>=0x1;_0x30c086--){for(let _0x55d748=0x0;_0x55d748<=_0x3875ba[_0x593c37(0x13b)]-0x2*_0x30c086;_0x55d748++){const _0x168d18=_0x3875ba[_0x593c37(0x1d3)](_0x55d748,_0x55d748+_0x30c086),_0x12ea2e=_0x3875ba[_0x593c37(0x1d3)](_0x55d748+_0x30c086,_0x55d748+0x2*_0x30c086);if(_0x168d18[_0x593c37(0x189)]((_0x1ec3da,_0x36eb9d)=>_0x1ec3da===_0x12ea2e[_0x36eb9d])){const _0x48904c=[..._0x3875ba[_0x593c37(0x1d3)](0x0,_0x55d748),..._0x3875ba[_0x593c37(0x1d3)](_0x55d748+_0x30c086)];return a0_0x43e623['sep']+_0x48904c[_0x593c37(0x22f)](a0_0x43e623[_0x593c37(0x1e7)]);}}}return null;}function a0_0x4413(_0x26709a,_0x375164){_0x26709a=_0x26709a-0x11a;const _0x433850=a0_0x4338();let _0x441354=_0x433850[_0x26709a];return _0x441354;}const require=createRequire(import.meta.url);function getPackageVersion(){const _0x28c33d=a0_0x4413;try{const _0x33856d=require('../package.json');return _0x33856d['version']??_0x28c33d(0x171);}catch(_0x5d8731){return logMcpStderr(_0x28c33d(0x139),_0x5d8731),_0x28c33d(0x171);}}function printHelp(){const _0x4b8811=a0_0x4413;console[_0x4b8811(0x214)](_0x4b8811(0x192)+getPackageVersion()),console[_0x4b8811(0x214)]('\x0aUsage:\x20morph-mcp\x20[options]\x20[allowed-directory\x20...]'),console[_0x4b8811(0x214)](_0x4b8811(0x163)),console[_0x4b8811(0x214)]('\x20\x20--api-key\x20<key>\x20\x20Morph\x20API\x20key\x20(takes\x20priority\x20over\x20MORPH_API_KEY\x20env\x20var)'),console[_0x4b8811(0x214)](_0x4b8811(0x22d)),console['log']('\x20\x20-v,\x20--version\x20\x20\x20\x20Print\x20version\x20and\x20exit'),console['log']('\x0aExamples:'),console[_0x4b8811(0x214)](_0x4b8811(0x235)),console[_0x4b8811(0x214)](_0x4b8811(0x196));}const cliArgs=process['argv'][a0_0x503392(0x1d3)](0x2),VERSION_FLAGS=new Set([a0_0x503392(0x169),'-v','-V']),HELP_FLAGS=new Set(['--help','-h']);cliArgs[a0_0x503392(0x1ab)](_0x470989=>VERSION_FLAGS[a0_0x503392(0x206)](_0x470989))&&(console[a0_0x503392(0x214)](a0_0x503392(0x192)+getPackageVersion()),process[a0_0x503392(0x131)](0x0));cliArgs[a0_0x503392(0x1ab)](_0x4be42a=>HELP_FLAGS[a0_0x503392(0x206)](_0x4be42a))&&(printHelp(),process[a0_0x503392(0x131)](0x0));function getCliArg(_0x3579cf){const _0x3d2301=a0_0x503392;for(let _0x470ea3=0x0;_0x470ea3<cliArgs[_0x3d2301(0x13b)];_0x470ea3++){const _0x5775bb=cliArgs[_0x470ea3];if(_0x5775bb[_0x3d2301(0x12d)]('--'+_0x3579cf+'='))return _0x5775bb[_0x3d2301(0x1d3)](('--'+_0x3579cf+'=')[_0x3d2301(0x13b)]);if(_0x5775bb==='--'+_0x3579cf&&_0x470ea3+0x1<cliArgs[_0x3d2301(0x13b)])return cliArgs[_0x470ea3+0x1];}return undefined;}const args=[];for(let i=0x0;i<cliArgs['length'];i++){const arg=cliArgs[i];if(VERSION_FLAGS[a0_0x503392(0x206)](arg)||HELP_FLAGS[a0_0x503392(0x206)](arg))continue;if(arg[a0_0x503392(0x12d)](a0_0x503392(0x193)))continue;if(arg===a0_0x503392(0x207)){i++;continue;}args['push'](arg);}const WORKSPACE_ROOT=process[a0_0x503392(0x22c)][a0_0x503392(0x175)]||process[a0_0x503392(0x22c)][a0_0x503392(0x22b)]||process[a0_0x503392(0x129)](),ENABLE_WORKSPACE_MODE=process[a0_0x503392(0x22c)][a0_0x503392(0x160)]!==a0_0x503392(0x145),MORPH_API_KEY=getCliArg(a0_0x503392(0x146))??process[a0_0x503392(0x22c)]['MORPH_API_KEY'],MORPH_API_URL=process[a0_0x503392(0x22c)][a0_0x503392(0x127)],MORPH_LARGE_APPLY=process['env'][a0_0x503392(0x20c)]!==a0_0x503392(0x145),MORPH_WARP_GREP_TIMEOUT=process[a0_0x503392(0x22c)]['MORPH_WARP_GREP_TIMEOUT']?parseInt(process[a0_0x503392(0x22c)][a0_0x503392(0x132)],0xa):undefined,OPERATING_SYSTEM_TYPE=getOperatingSystemType(),DEFAULT_DISABLED_TOOLS=new Set(),DISABLED_TOOLS=process[a0_0x503392(0x22c)][a0_0x503392(0x1bb)]?new Set(process[a0_0x503392(0x22c)][a0_0x503392(0x1bb)][a0_0x503392(0x172)](',')['map'](_0x51e4d2=>_0x51e4d2[a0_0x503392(0x1a0)]())[a0_0x503392(0x14a)](_0x88b6e=>_0x88b6e[a0_0x503392(0x13b)]>0x0)):DEFAULT_DISABLED_TOOLS;if(DISABLED_TOOLS[a0_0x503392(0x1e9)]>0x0){for(const tool of DISABLED_TOOLS){!KNOWN_TOOL_NAMES[a0_0x503392(0x206)](tool)&&console[a0_0x503392(0x180)](a0_0x503392(0x20a)+tool+a0_0x503392(0x228)+[...KNOWN_TOOL_NAMES]['join'](',\x20'));}console[a0_0x503392(0x180)](a0_0x503392(0x216)+[...DISABLED_TOOLS]['join'](',\x20'));}MORPH_API_KEY&&!MORPH_API_KEY[a0_0x503392(0x12d)](a0_0x503392(0x195))&&!MORPH_API_KEY[a0_0x503392(0x12d)](a0_0x503392(0x1ce))&&logMcpStderr(a0_0x503392(0x15e));async function reportMorphError(_0x5ce6c1){const _0x26af4c=a0_0x503392;try{await a0_0x21726c[_0x26af4c(0x1e2)](_0x26af4c(0x170),{..._0x5ce6c1,'timestamp':new Date()[_0x26af4c(0x20f)](),'source':_0x5ce6c1[_0x26af4c(0x191)]||_0x26af4c(0x11e),'os_type':OPERATING_SYSTEM_TYPE,'context':{'os_type':OPERATING_SYSTEM_TYPE,..._0x5ce6c1[_0x26af4c(0x1a3)]}},{'timeout':0x1388,'headers':{'Content-Type':_0x26af4c(0x15c),'Authorization':_0x26af4c(0x12b)+MORPH_API_KEY}});}catch{}}function extractStatusCode(_0x24ed1f,_0x11ba83){const _0x517c9b=a0_0x503392;if(_0x24ed1f&&typeof _0x24ed1f===_0x517c9b(0x1c9)&&'status'in _0x24ed1f)return _0x24ed1f['status'];if(_0x24ed1f&&typeof _0x24ed1f==='object'&&_0x517c9b(0x13f)in _0x24ed1f)return _0x24ed1f[_0x517c9b(0x13f)]?.[_0x517c9b(0x1e6)];const _0x1c4211=_0x11ba83[_0x517c9b(0x1d9)](/\b(401|429)\b/);return _0x1c4211?parseInt(_0x1c4211[0x1],0xa):null;}function handleMorphAPIError(_0x4a328f){const _0x2c989d=a0_0x503392,_0x21d0fc=_0x4a328f instanceof Error?_0x4a328f[_0x2c989d(0x164)]:String(_0x4a328f),_0x19d946=extractStatusCode(_0x4a328f,_0x21d0fc);switch(_0x19d946){case 0x191:return{'content':[{'type':_0x2c989d(0x176),'text':'Authentication\x20failed:\x20Your\x20Morph\x20API\x20key\x20is\x20invalid\x20or\x20has\x20been\x20revoked.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20a\x20valid\x20API\x20key,\x20then\x20update\x20your\x20MCP\x20configuration.'}],'isError':!![]};case 0x1ad:return{'content':[{'type':'text','text':_0x2c989d(0x12e)}],'isError':!![]};default:return null;}}args[a0_0x503392(0x13b)]===0x0&&!ENABLE_WORKSPACE_MODE&&(logMcpStderr(a0_0x503392(0x138)),logMcpStderr(a0_0x503392(0x1b5)),logMcpStderr('\x20\x201.\x20Command-line\x20arguments\x20(shown\x20above)'),logMcpStderr(a0_0x503392(0x213)),logMcpStderr(a0_0x503392(0x1c3)),logMcpStderr(a0_0x503392(0x1d2)));function normalizePath(_0x50fc79){const _0x33f268=a0_0x503392;return a0_0x43e623[_0x33f268(0x14b)](_0x50fc79);}function expandHome(_0xf28e5){const _0x620887=a0_0x503392;if(_0xf28e5['startsWith']('~/')||_0xf28e5==='~')return a0_0x43e623[_0x620887(0x22f)](a0_0x28c33c[_0x620887(0x1cd)](),_0xf28e5[_0x620887(0x1d3)](0x1));return _0xf28e5;}let allowedDirectories=await Promise['all'](args[a0_0x503392(0x197)](async _0x5811cb=>{const _0x1f6819=a0_0x503392,_0x26198a=expandHome(_0x5811cb),_0x23cbb1=a0_0x43e623[_0x1f6819(0x23b)](_0x26198a);try{const _0x274595=await a0_0x306e16['realpath'](_0x23cbb1);return normalizePath(_0x274595);}catch(_0x4cad51){return normalizePath(_0x23cbb1);}}));if(ENABLE_WORKSPACE_MODE&&args['length']===0x0)try{const workspaceDir=await detectWorkspaceRoot(WORKSPACE_ROOT);workspaceDir&&(allowedDirectories[a0_0x503392(0x1bd)](workspaceDir),logMcpStderr('Workspace\x20mode\x20enabled:\x20Using\x20'+workspaceDir+a0_0x503392(0x1bc)));}catch(a0_0x158b75){logMcpStderr(a0_0x503392(0x1df)+a0_0x158b75);}async function detectWorkspaceRoot(_0x10b65c){const _0x386378=a0_0x503392;let _0x96bd7f=a0_0x43e623[_0x386378(0x23b)](_0x10b65c);const _0x421246=[_0x386378(0x1e4),_0x386378(0x179),_0x386378(0x124),_0x386378(0x1f1),_0x386378(0x11a),_0x386378(0x165),_0x386378(0x1dd),_0x386378(0x137),_0x386378(0x16c)];while(_0x96bd7f!==a0_0x43e623['dirname'](_0x96bd7f)){for(const _0x32a925 of _0x421246){const _0x1a8881=a0_0x43e623[_0x386378(0x22f)](_0x96bd7f,_0x32a925);try{return await a0_0x306e16[_0x386378(0x156)](_0x1a8881),normalizePath(_0x96bd7f);}catch{}}_0x96bd7f=a0_0x43e623[_0x386378(0x209)](_0x96bd7f);}return normalizePath(_0x10b65c);}await Promise[a0_0x503392(0x223)](args[a0_0x503392(0x197)](async _0xcf79ec=>{const _0x564aa9=a0_0x503392;try{const _0x4b46df=await a0_0x306e16[_0x564aa9(0x23d)](expandHome(_0xcf79ec));!_0x4b46df[_0x564aa9(0x1fd)]()&&(logMcpStderr(_0x564aa9(0x198)+_0xcf79ec+_0x564aa9(0x13e)),process[_0x564aa9(0x131)](0x1));}catch(_0x2ded06){logMcpStderr(_0x564aa9(0x15b)+_0xcf79ec+':',_0x2ded06),process['exit'](0x1);}}));async function validatePath(_0x18f76f){const _0x18c8aa=a0_0x503392,_0x45cff9=expandHome(_0x18f76f),_0x381818=a0_0x43e623[_0x18c8aa(0x23b)](_0x45cff9);logger[_0x18c8aa(0x226)](_0x18c8aa(0x128),_0x18c8aa(0x1ed),{'raw_path':_0x18f76f,'absolute':_0x381818});try{const _0xeb7a51=await a0_0x306e16[_0x18c8aa(0x1c0)](_0x381818);return logger[_0x18c8aa(0x226)](_0x18c8aa(0x128),_0x18c8aa(0x159),{'resolved':_0xeb7a51,'symlink':_0xeb7a51!==_0x381818}),_0xeb7a51;}catch(_0xabbef8){if(_0xabbef8[_0x18c8aa(0x194)]===_0x18c8aa(0x1e0)){const _0x33e5fd=a0_0x43e623[_0x18c8aa(0x209)](_0x381818);try{const _0x397ec3=await a0_0x306e16[_0x18c8aa(0x1c0)](_0x33e5fd),_0x516f00=a0_0x43e623[_0x18c8aa(0x22f)](_0x397ec3,a0_0x43e623[_0x18c8aa(0x222)](_0x381818));return logger[_0x18c8aa(0x226)](_0x18c8aa(0x128),_0x18c8aa(0x159),{'resolved':_0x516f00,'new_file':!![]}),_0x516f00;}catch{logger[_0x18c8aa(0x180)](_0x18c8aa(0x128),_0x18c8aa(0x1b9),{'raw_path':_0x18f76f,'error':_0x18c8aa(0x238)+_0x33e5fd});throw new Error(_0x18c8aa(0x238)+_0x33e5fd);}}logger[_0x18c8aa(0x180)](_0x18c8aa(0x128),_0x18c8aa(0x1b9),{'raw_path':_0x18f76f,'error':_0xabbef8[_0x18c8aa(0x164)]});throw _0xabbef8;}}const MorphEditFileArgsSchema=z[a0_0x503392(0x1c9)]({'path':z[a0_0x503392(0x18e)](),'code_edit':z[a0_0x503392(0x18e)]()[a0_0x503392(0x187)](a0_0x503392(0x1b6)),'instruction':z[a0_0x503392(0x18e)]()[a0_0x503392(0x187)](a0_0x503392(0x1e1)),'dryRun':z[a0_0x503392(0x22e)]()[a0_0x503392(0x14c)](![])[a0_0x503392(0x187)](a0_0x503392(0x153))}),CODEBASE_SEARCH_QUERY_DESCRIPTION=a0_0x503392(0x140),WarpGrepArgsSchema=z[a0_0x503392(0x1c9)]({'search_string':z[a0_0x503392(0x18e)]()[a0_0x503392(0x187)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repo_path':z[a0_0x503392(0x18e)]()[a0_0x503392(0x187)](a0_0x503392(0x182)),'search_type':z[a0_0x503392(0x1eb)]([a0_0x503392(0x14c),a0_0x503392(0x221)])[a0_0x503392(0x141)]()['describe'](a0_0x503392(0x230))}),WarpGrepGitHubArgsSchema=z[a0_0x503392(0x1c9)]({'search_string':z['string']()[a0_0x503392(0x187)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'github_url':z[a0_0x503392(0x18e)]()['optional']()[a0_0x503392(0x187)](a0_0x503392(0x1a4)),'owner_repo':z['string']()[a0_0x503392(0x141)]()[a0_0x503392(0x187)]('Repository\x20owner/repo\x20shorthand\x20(e.g.\x20\x27vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.'),'branch':z[a0_0x503392(0x18e)]()[a0_0x503392(0x141)]()[a0_0x503392(0x187)](a0_0x503392(0x23a))}),CodebaseSearchArgsSchema=z['object']({'query':z[a0_0x503392(0x18e)]()[a0_0x503392(0x187)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repoId':z[a0_0x503392(0x18e)]()[a0_0x503392(0x187)](a0_0x503392(0x144)),'branch':z[a0_0x503392(0x18e)]()[a0_0x503392(0x141)]()[a0_0x503392(0x187)](a0_0x503392(0x1d7)),'commitHash':z[a0_0x503392(0x18e)]()[a0_0x503392(0x141)]()['describe']('Specific\x20commit\x20hash\x20to\x20search'),'targetDirectories':z[a0_0x503392(0x16a)](z[a0_0x503392(0x18e)]())['default']([])['describe'](a0_0x503392(0x202)),'limit':z[a0_0x503392(0x122)]()[a0_0x503392(0x141)]()['default'](0xa)[a0_0x503392(0x187)](a0_0x503392(0x21d))}),server=new Server({'name':a0_0x503392(0x148),'version':a0_0x503392(0x147)},{'capabilities':{'tools':{}}});server['setRequestHandler'](ListToolsRequestSchema,async()=>{const _0x20a212=a0_0x503392,_0x44c72a=[{'name':TOOL_NAMES[_0x20a212(0x143)],'description':_0x20a212(0x1ca)+_0x20a212(0x1a1)+'Parameters:\x0a'+_0x20a212(0x1b7)+_0x20a212(0x174)+'-\x20code_edit:\x20Only\x20the\x20changed\x20lines\x20with\x20//\x20...\x20existing\x20code\x20...\x20markers\x0a\x0a'+_0x20a212(0x1a6)+_0x20a212(0x155)+_0x20a212(0x21f)+'Rules:\x0a'+'-\x20ALWAYS\x20use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20for\x20unchanged\x20sections\x20(omitting\x20this\x20marker\x20will\x20cause\x20deletions)\x0a'+_0x20a212(0x177)+_0x20a212(0x1d8)+'-\x20Batch\x20multiple\x20edits\x20to\x20the\x20same\x20file\x20in\x20one\x20call\x0a','inputSchema':zodToJsonSchema(MorphEditFileArgsSchema),'requiresApiKey':!![]},{'name':TOOL_NAMES['CODEBASE_SEARCH'],'description':_0x20a212(0x16e)+CODEBASE_SEARCH_QUERY_DESCRIPTION+'\x20'+_0x20a212(0x237)+_0x20a212(0x1d4)+'','inputSchema':zodToJsonSchema(WarpGrepArgsSchema),'requiresApiKey':!![]},{'name':GITHUB_SEARCH_TOOL_NAME,'description':GITHUB_SEARCH_DESCRIPTION,'inputSchema':zodToJsonSchema(WarpGrepGitHubArgsSchema),'requiresApiKey':!![]}],_0x3d303d=_0x44c72a[_0x20a212(0x14a)](_0x321c74=>{const _0x2ed925=_0x20a212;if(DISABLED_TOOLS['has'](_0x321c74[_0x2ed925(0x1b4)]))return console[_0x2ed925(0x180)](_0x2ed925(0x1c2)+_0x321c74[_0x2ed925(0x1b4)]+_0x2ed925(0x1fc)),![];if(_0x2ed925(0x11c)in _0x321c74&&_0x321c74[_0x2ed925(0x11c)]&&!MORPH_API_KEY)return logMcpStderr('Warning:\x20'+_0x321c74[_0x2ed925(0x1b4)]+'\x20tool\x20unavailable\x20-\x20MORPH_API_KEY\x20not\x20provided\x20in\x20MCP\x20config'),![];return!![];});return{'tools':_0x3d303d[_0x20a212(0x197)](_0x2c08e9=>({'name':_0x2c08e9[_0x20a212(0x1b4)],'description':_0x2c08e9[_0x20a212(0x135)],'inputSchema':_0x2c08e9['inputSchema']}))};}),server[a0_0x503392(0x1b3)](CallToolRequestSchema,async _0x5429f6=>{const _0x22f1cc=a0_0x503392,{name:_0x1897bb,arguments:_0x3b0c99}=_0x5429f6[_0x22f1cc(0x1a8)],_0x3fcabd=Date[_0x22f1cc(0x200)]();logger[_0x22f1cc(0x226)](_0x22f1cc(0x128),_0x22f1cc(0x1be),{'tool':_0x1897bb,'args':_0x1897bb===_0x22f1cc(0x1ac)?{'path':_0x3b0c99?.[_0x22f1cc(0x1a2)],'instruction':_0x3b0c99?.[_0x22f1cc(0x185)]||_0x3b0c99?.['instructions'],'dryRun':_0x3b0c99?.[_0x22f1cc(0x134)]}:_0x3b0c99});try{if(!MORPH_API_KEY)return{'content':[{'type':_0x22f1cc(0x176),'text':_0x22f1cc(0x1ff)}],'isError':!![]};if(!MORPH_API_KEY[_0x22f1cc(0x12d)](_0x22f1cc(0x195))&&!MORPH_API_KEY[_0x22f1cc(0x12d)](_0x22f1cc(0x1ce)))return{'content':[{'type':_0x22f1cc(0x176),'text':_0x22f1cc(0x219)}],'isError':!![]};if(DISABLED_TOOLS[_0x22f1cc(0x206)](_0x1897bb))return{'content':[{'type':_0x22f1cc(0x176),'text':'Tool\x20\x22'+_0x1897bb+_0x22f1cc(0x1fa)}],'isError':![]};switch(_0x1897bb){case TOOL_NAMES[_0x22f1cc(0x143)]:{let _0x505e72=_0x3b0c99;if(_0x505e72&&typeof _0x505e72===_0x22f1cc(0x1c9)){if(!(_0x22f1cc(0x1a2)in _0x505e72)){const _0x32bcc4=_0x505e72['target_file']??_0x505e72['filePath']??_0x505e72['target_filepath']??_0x505e72[_0x22f1cc(0x11f)]??_0x505e72[_0x22f1cc(0x1e8)];if(_0x32bcc4)_0x505e72={..._0x505e72,'path':_0x32bcc4};}'instructions'in _0x505e72&&!(_0x22f1cc(0x185)in _0x505e72)&&(_0x505e72={..._0x505e72,'instruction':_0x505e72[_0x22f1cc(0x229)]});if(!(_0x22f1cc(0x21c)in _0x505e72)){const _0x299ea3=_0x505e72[_0x22f1cc(0x194)]??_0x505e72[_0x22f1cc(0x236)]??_0x505e72[_0x22f1cc(0x240)]??_0x505e72[_0x22f1cc(0x11d)];if(_0x299ea3)_0x505e72={..._0x505e72,'code_edit':_0x299ea3};}}const _0x210a2d=MorphEditFileArgsSchema['safeParse'](_0x505e72);if(!_0x210a2d[_0x22f1cc(0x227)])throw new Error('Invalid\x20arguments\x20for\x20morph_edit_file:\x20'+_0x210a2d['error']);const _0x9a06bb=await validatePath(_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x1a2)]);let _0x1e58f0=null,_0x3360df=!![],_0x1d867f=null;try{_0x1e58f0=await a0_0x306e16[_0x22f1cc(0x1af)](_0x9a06bb,'utf-8'),logger[_0x22f1cc(0x226)]('MCP',_0x22f1cc(0x1c8),{'path':_0x9a06bb,'size_bytes':_0x1e58f0[_0x22f1cc(0x13b)]});}catch(_0x480bae){const _0x3e6ed1=_0x480bae[_0x22f1cc(0x194)];_0x3e6ed1===_0x22f1cc(0x1e0)?(_0x3360df=![],_0x1e58f0='',logger[_0x22f1cc(0x226)](_0x22f1cc(0x128),_0x22f1cc(0x1c8),{'path':_0x9a06bb,'exists':![]})):(_0x1d867f='Failed\x20to\x20read\x20file:\x20'+(_0x3e6ed1||'unknown')+_0x22f1cc(0x12a)+(_0x480bae instanceof Error?_0x480bae['message']:String(_0x480bae)),logger[_0x22f1cc(0x180)]('MCP','file_read_failed',{'path':_0x9a06bb,'error':_0x1d867f}),logMcpStderr(_0x22f1cc(0x233)+_0x1d867f));}let _0x1ab077;try{const _0x1f0976=MORPH_API_KEY;if(!_0x1f0976)throw new Error('MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.');const _0x21a7d3=a0_0x43e623[_0x22f1cc(0x209)](_0x9a06bb),_0x58ad1d=a0_0x43e623['basename'](_0x9a06bb);logger['debug'](_0x22f1cc(0x128),'api_request_start',{'model':_0x22f1cc(0x162),'path':_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x1a2)],'instruction_len':_0x210a2d['data'][_0x22f1cc(0x185)]['length'],'code_edit_len':_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x21c)][_0x22f1cc(0x13b)],'original_code_len':_0x1e58f0?.[_0x22f1cc(0x13b)]??0x0,'dry_run':_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x134)]});const _0x3395ea=Date[_0x22f1cc(0x200)](),_0xb39f2=await executeEditFile({'target_filepath':_0x58ad1d,'code_edit':_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x21c)],'instruction':_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x185)]},{'morphApiKey':_0x1f0976,'morphApiUrl':MORPH_API_URL,'large':MORPH_LARGE_APPLY,'baseDir':_0x21a7d3,'autoWrite':!_0x210a2d['data'][_0x22f1cc(0x134)],'generateUdiff':![],'debug':![]}),_0x55d849=Date[_0x22f1cc(0x200)]()-_0x3395ea;_0x1ab077=_0xb39f2[_0x22f1cc(0x1f4)];if(!_0xb39f2[_0x22f1cc(0x227)])throw new Error(_0xb39f2[_0x22f1cc(0x180)]||'Morph\x20FastApply\x20failed\x20without\x20error\x20message');const _0x1257d2=_0xb39f2[_0x22f1cc(0x136)],_0x440ce2=_0x22f1cc(0x1e5)+_0x1257d2[_0x22f1cc(0x188)]+',\x20removed\x20'+_0x1257d2[_0x22f1cc(0x1db)]+_0x22f1cc(0x21b)+_0x1257d2[_0x22f1cc(0x19f)];logger[_0x22f1cc(0x226)](_0x22f1cc(0x128),_0x22f1cc(0x142),{'tool':_0x22f1cc(0x1ac),'success':!![],'latency_ms':Date['now']()-_0x3fcabd,'edit_latency_ms':_0x55d849,'changes':{'added':_0x1257d2['linesAdded'],'removed':_0x1257d2[_0x22f1cc(0x1db)],'modified':_0x1257d2['linesModified']},'completion_id':_0x1ab077});if(_0x210a2d['data']['dryRun'])return{'content':[{'type':'text','text':_0x22f1cc(0x16d)+(_0x3360df?'':_0x22f1cc(0x130))+':\x20'+_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x185)]+_0x22f1cc(0x190)+_0x440ce2+_0x22f1cc(0x199)+_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x1a2)]+'.'}]};return{'content':[{'type':_0x22f1cc(0x176),'text':'Morph\x20Edit\x20'+(_0x3360df?_0x22f1cc(0x1f8):_0x22f1cc(0x1dc))+':\x20'+_0x210a2d['data']['instruction']+_0x22f1cc(0x190)+_0x440ce2+_0x22f1cc(0x199)+_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x1a2)]+'.'}]};}catch(_0x2e2b4){const _0xf7f391=handleMorphAPIError(_0x2e2b4);if(_0xf7f391)return logger[_0x22f1cc(0x180)]('MCP','tool_call_error',{'tool':_0x22f1cc(0x1ac),'error':_0x22f1cc(0x157),'latency_ms':Date[_0x22f1cc(0x200)]()-_0x3fcabd}),_0xf7f391;const _0x591b8a=_0x2e2b4 instanceof Error?_0x2e2b4[_0x22f1cc(0x164)]:String(_0x2e2b4);return logger[_0x22f1cc(0x180)]('MCP',_0x22f1cc(0x1e3),{'tool':_0x22f1cc(0x1ac),'error':_0x591b8a,'path':_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x1a2)],'validated_path':_0x9a06bb,'latency_ms':Date['now']()-_0x3fcabd,'stack':_0x2e2b4 instanceof Error?_0x2e2b4['stack']:undefined}),reportMorphError({'error_message':_0x591b8a,'error_type':_0x2e2b4 instanceof Error?_0x2e2b4[_0x22f1cc(0x17c)][_0x22f1cc(0x1b4)]:_0x22f1cc(0x1bf),'context':{'tool':'edit_file','completion_id':_0x1ab077,'file_path':_0x210a2d['data'][_0x22f1cc(0x1a2)],'validated_path':_0x9a06bb,'instruction':_0x210a2d['data'][_0x22f1cc(0x185)],'model':MORPH_LARGE_APPLY?'morph-v3-large':_0x22f1cc(0x162),'dry_run':_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x134)],'file_exists':_0x3360df,'file_read_error':_0x1d867f,'file_readable':_0x1e58f0!==null,'request_content':{'path':_0x210a2d[_0x22f1cc(0x17a)]['path'],'code_edit':_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x21c)],'instruction':_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x185)],'original_code':_0x1e58f0!==null?_0x1e58f0[_0x22f1cc(0x13b)]>0xc350?_0x1e58f0['substring'](0x0,0xc350)+'\x0a...\x20(truncated,\x20total:\x20'+_0x1e58f0['length']+'\x20chars)':_0x1e58f0:_0x22f1cc(0x20b)+(_0x1d867f||_0x22f1cc(0x17f))+']','original_code_length':_0x1e58f0?.[_0x22f1cc(0x13b)]??0x0,'model':MORPH_LARGE_APPLY?'morph-v3-large':'morph-v3-fast','dry_run':_0x210a2d[_0x22f1cc(0x17a)][_0x22f1cc(0x134)]}},'stack_trace':_0x2e2b4 instanceof Error?_0x2e2b4[_0x22f1cc(0x1ba)]:undefined,'source':_0x22f1cc(0x11e)})['catch'](()=>{}),{'content':[{'type':_0x22f1cc(0x176),'text':_0x22f1cc(0x21e)+_0x591b8a}],'isError':!![]};}}case TOOL_NAMES['CODEBASE_SEARCH']:{const _0x2038da=WarpGrepArgsSchema[_0x22f1cc(0x1cb)](_0x3b0c99);if(!_0x2038da['success'])return{'content':[{'type':'text','text':'Invalid\x20arguments:\x20'+_0x2038da[_0x22f1cc(0x180)]}],'isError':!![]};const _0x1791c9=_0x54f5a9=>{const _0xcab09e=_0x22f1cc,_0x2c7ec0=[];for(const _0x43deb5 of _0x54f5a9||[]){if(_0x43deb5[_0xcab09e(0x121)]===_0xcab09e(0x1ea)&&Array[_0xcab09e(0x217)](_0x43deb5[_0xcab09e(0x126)]))for(const _0x421959 of _0x43deb5[_0xcab09e(0x126)]){try{const _0x4a5c3d=_0x421959[_0xcab09e(0x203)]?.['name'],_0x42bca0=JSON[_0xcab09e(0x19a)](_0x421959[_0xcab09e(0x203)]?.[_0xcab09e(0x1a5)]||'{}');if(_0x4a5c3d===_0xcab09e(0x21a))_0x2c7ec0[_0xcab09e(0x1bd)](_0xcab09e(0x225)+_0x42bca0[_0xcab09e(0x166)]+'\x27\x20'+(_0x42bca0[_0xcab09e(0x1a2)]||'.'));else{if(_0x4a5c3d===_0xcab09e(0x215))_0x2c7ec0[_0xcab09e(0x1bd)](_0xcab09e(0x23c)+_0x42bca0[_0xcab09e(0x1a2)]);else{if(_0x4a5c3d===_0xcab09e(0x17b))_0x2c7ec0[_0xcab09e(0x1bd)](_0xcab09e(0x1cc)+(_0x42bca0[_0xcab09e(0x1f7)]||'.'));else{if(_0x4a5c3d==='glob')_0x2c7ec0[_0xcab09e(0x1bd)](_0xcab09e(0x16f)+_0x42bca0['pattern']+'\x27\x20'+(_0x42bca0[_0xcab09e(0x1a2)]||'.'));else _0x4a5c3d===_0xcab09e(0x1b2)&&_0x2c7ec0[_0xcab09e(0x1bd)](_0xcab09e(0x1b2));}}}}catch{}}}return _0x2c7ec0;},_0x235f34=_0x4c55da=>{const _0x7a3019=_0x22f1cc,_0xe75cb4=[];if(!_0x4c55da||!Array['isArray'](_0x4c55da))return _0xe75cb4;const _0x3fe444=[{'pattern':/\[FILE NOT FOUND\]/,'error_type':_0x7a3019(0x1c5),'tool':_0x7a3019(0x215)},{'pattern':/\[PATH ERROR\]/,'error_type':_0x7a3019(0x150),'tool':_0x7a3019(0x215)},{'pattern':/\[READ ERROR\]/,'error_type':_0x7a3019(0x1a9),'tool':_0x7a3019(0x215)},{'pattern':/\[UNREADABLE FILE\]/,'error_type':_0x7a3019(0x1c4),'tool':_0x7a3019(0x215)},{'pattern':/\[RIPGREP ERROR\]/,'error_type':_0x7a3019(0x151),'tool':_0x7a3019(0x1a7)},{'pattern':/\[RIPGREP NOT AVAILABLE\]/,'error_type':_0x7a3019(0x218),'tool':_0x7a3019(0x1a7)},{'pattern':/\[BINARY FILE\]/,'error_type':_0x7a3019(0x1c4),'tool':_0x7a3019(0x215)},{'pattern':/\[SYMLINK\]/,'error_type':_0x7a3019(0x17e),'tool':_0x7a3019(0x215)},{'pattern':/not a text file/,'error_type':_0x7a3019(0x1c4),'tool':_0x7a3019(0x215)},{'pattern':/symbolic link/,'error_type':_0x7a3019(0x17e),'tool':_0x7a3019(0x215)},{'pattern':/Error reading file:/,'error_type':_0x7a3019(0x1a9),'tool':_0x7a3019(0x215)},{'pattern':/status="error"/,'error_type':'ToolException','tool':_0x7a3019(0x171)}];let _0x18c317=0x0;for(const _0x16a333 of _0x4c55da){_0x16a333['role']===_0x7a3019(0x1ea)&&Array[_0x7a3019(0x217)](_0x16a333[_0x7a3019(0x126)])&&_0x18c317++;const _0x272cee=_0x16a333[_0x7a3019(0x240)];if((_0x16a333[_0x7a3019(0x121)]===_0x7a3019(0x13a)||_0x16a333['role']===_0x7a3019(0x14e))&&_0x272cee&&typeof _0x272cee===_0x7a3019(0x18e))for(const {pattern:_0x3e5458,error_type:_0x167070,tool:_0x1d1a3c}of _0x3fe444){const _0x1bb93b=_0x272cee[_0x7a3019(0x1d9)](new RegExp(_0x3e5458[_0x7a3019(0x191)],'g'));if(_0x1bb93b)for(const _0xfde4cb of _0x1bb93b){const _0x213bb5=_0x272cee[_0x7a3019(0x1f5)](_0xfde4cb),_0x13b855=_0x272cee['substring'](_0x213bb5,Math[_0x7a3019(0x201)](_0x213bb5+0xc8,_0x272cee[_0x7a3019(0x13b)]));_0xe75cb4[_0x7a3019(0x1bd)]({'tool':_0x1d1a3c,'error_type':_0x167070,'error_message':_0x13b855[_0x7a3019(0x172)]('\x0a')[0x0],'turn':_0x18c317});}}}return _0xe75cb4;};try{const _0x36e883=a0_0x43e623[_0x22f1cc(0x23b)](_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x239)]),_0x38ac37=_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x1ae)],_0x3dea03=_0x38ac37===_0x22f1cc(0x221)?{'allowNames':['node_modules']}:undefined,_0x593979=new LocalRipgrepProvider(_0x36e883,undefined,_0x3dea03);logger['debug'](_0x22f1cc(0x128),_0x22f1cc(0x178),{'type':_0x22f1cc(0x11b),'repo_root':_0x36e883,'search_type':_0x38ac37||_0x22f1cc(0x14c)}),logger[_0x22f1cc(0x226)](_0x22f1cc(0x128),'warp_grep_start',{'query':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x14f)],'repo_root':_0x36e883,'timeout_ms':MORPH_WARP_GREP_TIMEOUT});const _0x1a0a08=Date[_0x22f1cc(0x200)](),_0x4edcae=await runWarpGrep({'searchTerm':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x14f)],'repoRoot':_0x36e883,'morphApiKey':MORPH_API_KEY,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT,'provider':_0x593979,'search_type':_0x38ac37}),_0x2d9a33=Date[_0x22f1cc(0x200)]()-_0x1a0a08,_0x1592e9=_0x4edcae['finish']?.[_0x22f1cc(0x208)]?.[_0x22f1cc(0x12f)]?.[_0x22f1cc(0x13b)]??0x0;logger[_0x22f1cc(0x226)](_0x22f1cc(0x128),'warp_grep_complete',{'termination':_0x4edcae['terminationReason'],'turns':_0x4edcae[_0x22f1cc(0x154)]?.[_0x22f1cc(0x231)]??0x0,'files_found':_0x1592e9,'latency_ms':_0x2d9a33});const _0x399005=_0x235f34(_0x4edcae[_0x22f1cc(0x1f9)]);_0x399005[_0x22f1cc(0x13b)]>0x0&&reportMorphError({'error_message':_0x22f1cc(0x205)+_0x399005[_0x22f1cc(0x13b)]+'\x20error(s)','error_type':_0x22f1cc(0x184),'level':_0x22f1cc(0x152),'tool':'codebase_search','context':{'repo_path':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x239)],'query':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x14f)],'model':_0x22f1cc(0x18c),'termination_reason':_0x4edcae['terminationReason'],'sub_tool_errors':_0x399005,'timings':_0x4edcae[_0x22f1cc(0x154)],'tool_calls':_0x1791c9(_0x4edcae[_0x22f1cc(0x1f9)]),'messages':_0x4edcae[_0x22f1cc(0x1f9)]?.[_0x22f1cc(0x197)](_0x17431e=>({'role':_0x17431e[_0x22f1cc(0x121)],'content':_0x17431e['content'],..._0x17431e[_0x22f1cc(0x126)]?{'tool_calls':_0x17431e[_0x22f1cc(0x126)][_0x22f1cc(0x13b)]}:{},..._0x17431e['tool_call_id']?{'tool_call_id':_0x17431e[_0x22f1cc(0x1b8)]}:{}}))},'source':'mcp-filesystem'})[_0x22f1cc(0x14d)](()=>{});let _0x456071='';if(_0x4edcae['terminationReason']===_0x22f1cc(0x23e)&&_0x4edcae[_0x22f1cc(0x1b2)]?.[_0x22f1cc(0x208)]?.[_0x22f1cc(0x12f)]){const _0xf64af2=_0x4edcae[_0x22f1cc(0x1b2)][_0x22f1cc(0x208)][_0x22f1cc(0x12f)];if(_0xf64af2[_0x22f1cc(0x13b)]===0x0)return _0x456071=_0x4edcae[_0x22f1cc(0x1b2)][_0x22f1cc(0x1f6)]||'No\x20relevant\x20code\x20found\x20for\x20the\x20query.',{'content':[{'type':_0x22f1cc(0x176),'text':_0x456071}]};const _0x2549ac=[],_0x21ca76=['Morph\x20Fast\x20Context\x20subagent\x20performed\x20search\x20on\x20repository:'];for(const _0x14c502 of _0x4edcae['messages']){if(_0x14c502[_0x22f1cc(0x121)]===_0x22f1cc(0x1ea)&&Array[_0x22f1cc(0x217)](_0x14c502['tool_calls']))for(const _0x459f10 of _0x14c502[_0x22f1cc(0x126)]){try{const _0x2681f2=_0x459f10[_0x22f1cc(0x203)]?.[_0x22f1cc(0x1b4)],_0x516810=JSON[_0x22f1cc(0x19a)](_0x459f10[_0x22f1cc(0x203)]?.[_0x22f1cc(0x1a5)]||'{}');if(_0x2681f2===_0x22f1cc(0x21a))_0x21ca76[_0x22f1cc(0x1bd)](_0x22f1cc(0x1f0)+_0x516810[_0x22f1cc(0x166)]+'\x27\x20in\x20`'+(_0x516810[_0x22f1cc(0x1a2)]||'.')+'`');else{if(_0x2681f2===_0x22f1cc(0x215))_0x21ca76[_0x22f1cc(0x1bd)](_0x22f1cc(0x13d)+_0x516810[_0x22f1cc(0x1a2)]+'`');else{if(_0x2681f2===_0x22f1cc(0x17b))_0x21ca76[_0x22f1cc(0x1bd)](_0x22f1cc(0x212)+(_0x516810[_0x22f1cc(0x1f7)]||'.')+'`');else _0x2681f2===_0x22f1cc(0x210)&&_0x21ca76['push'](_0x22f1cc(0x15f)+_0x516810[_0x22f1cc(0x166)]+_0x22f1cc(0x1cf)+(_0x516810['path']||'.')+'`');}}}catch{}}}_0x2549ac['push'](_0x21ca76[_0x22f1cc(0x22f)]('\x0a'));const _0x3d820c=['',_0x22f1cc(0x123)];for(const _0x48dcfb of _0xf64af2){if(_0x48dcfb[_0x22f1cc(0x1ee)]==='*')_0x3d820c['push']('-\x20'+_0x48dcfb[_0x22f1cc(0x1a2)]+':*');else{if(Array[_0x22f1cc(0x217)](_0x48dcfb[_0x22f1cc(0x1ee)])){const _0x3d7ff2=_0x48dcfb['lines']['map'](([_0xe16fdc,_0x26bbd8])=>{if(_0xe16fdc===_0x26bbd8)return''+_0xe16fdc;return _0xe16fdc+'-'+_0x26bbd8;});_0x3d820c[_0x22f1cc(0x1bd)]('-\x20'+_0x48dcfb['path']+':'+_0x3d7ff2[_0x22f1cc(0x22f)](','));}else _0x3d820c[_0x22f1cc(0x1bd)]('-\x20'+_0x48dcfb['path']+':*');}}_0x3d820c[_0x22f1cc(0x1bd)](''),_0x2549ac['push'](_0x3d820c[_0x22f1cc(0x22f)]('\x0a')),_0x2549ac[_0x22f1cc(0x1bd)](_0x22f1cc(0x234));const _0x5cfdbc=[],_0x1db517=[];for(const _0x4fc1f8 of _0xf64af2){let _0x109b35=a0_0x43e623[_0x22f1cc(0x23b)](_0x2038da['data'][_0x22f1cc(0x239)],_0x4fc1f8['path']),_0x509d6a=null,_0x2b2239=null;try{_0x509d6a=await a0_0x306e16[_0x22f1cc(0x1af)](_0x109b35,{'encoding':'utf-8'});}catch(_0x408bb9){const _0x2ffd69=fixPathRepetition(_0x109b35);if(_0x2ffd69)try{_0x509d6a=await a0_0x306e16[_0x22f1cc(0x1af)](_0x2ffd69,{'encoding':'utf-8'}),_0x109b35=_0x2ffd69;}catch{_0x2b2239=_0x408bb9 instanceof Error?_0x408bb9:new Error(String(_0x408bb9));}else _0x2b2239=_0x408bb9 instanceof Error?_0x408bb9:new Error(String(_0x408bb9));}if(_0x509d6a!==null){const _0x3727d5=_0x509d6a['split'](/\r?\n/),_0x564483=[];if(_0x4fc1f8['lines']==='*'||!Array['isArray'](_0x4fc1f8['lines']))for(let _0x40ce06=0x1;_0x40ce06<=_0x3727d5['length'];_0x40ce06++){const _0x3e9b5f=_0x3727d5[_0x40ce06-0x1];_0x564483[_0x22f1cc(0x1bd)](_0x40ce06+'|\x20'+_0x3e9b5f);}else for(const [_0x2708a7,_0x22aae3]of _0x4fc1f8[_0x22f1cc(0x1ee)]){_0x564483[_0x22f1cc(0x13b)]>0x0&&_0x564483[_0x22f1cc(0x1bd)]('');for(let _0x2ec0e8=_0x2708a7;_0x2ec0e8<=_0x22aae3&&_0x2ec0e8<=_0x3727d5[_0x22f1cc(0x13b)];_0x2ec0e8++){const _0x25c88f=_0x3727d5[_0x2ec0e8-0x1];_0x564483[_0x22f1cc(0x1bd)](_0x2ec0e8+'|\x20'+_0x25c88f);}}_0x1db517[_0x22f1cc(0x1bd)]({'path':_0x4fc1f8[_0x22f1cc(0x1a2)],'content':_0x564483[_0x22f1cc(0x22f)]('\x0a')});}else _0x5cfdbc[_0x22f1cc(0x1bd)]('<file\x20path=\x22'+_0x4fc1f8['path']+_0x22f1cc(0x18d)+(_0x2b2239?.[_0x22f1cc(0x164)]||_0x22f1cc(0x18f))+_0x22f1cc(0x1ad));}try{const _0x19781a=await compactFileContexts(_0x1db517,_0x2038da[_0x22f1cc(0x17a)]['search_string'],MORPH_API_KEY,MORPH_API_URL);for(const _0x5df196 of _0x19781a){_0x5cfdbc[_0x22f1cc(0x1bd)](_0x22f1cc(0x1d5)+_0x5df196[_0x22f1cc(0x1a2)]+'\x22>\x0a'+_0x5df196[_0x22f1cc(0x240)]+_0x22f1cc(0x1ad));}}catch(_0x1f8003){logger[_0x22f1cc(0x152)](_0x22f1cc(0x128),_0x22f1cc(0x23f),{'error':_0x1f8003 instanceof Error?_0x1f8003[_0x22f1cc(0x164)]:String(_0x1f8003),'files_count':_0x1db517[_0x22f1cc(0x13b)]});for(const _0x308ff6 of _0x1db517){_0x5cfdbc[_0x22f1cc(0x1bd)](_0x22f1cc(0x1d5)+_0x308ff6[_0x22f1cc(0x1a2)]+_0x22f1cc(0x161)+_0x308ff6[_0x22f1cc(0x240)]+_0x22f1cc(0x1ad));}}_0x2549ac[_0x22f1cc(0x1bd)](_0x5cfdbc[_0x22f1cc(0x22f)]('\x0a\x0a')),_0x456071=_0x2549ac['join']('\x0a');const _0x5b6f81=_0x4edcae[_0x22f1cc(0x243)]?.[_0x22f1cc(0x14a)](_0x1abf93=>_0x1abf93[_0x22f1cc(0x164)]?.[_0x22f1cc(0x12d)]('File\x20read\x20error:'))||[];if(_0x5b6f81[_0x22f1cc(0x13b)]>0x0){const _0x45ad57=_0x5b6f81['map'](_0x58a22e=>_0x58a22e[_0x22f1cc(0x164)])[_0x22f1cc(0x22f)](';\x20');reportMorphError({'error_message':_0x45ad57,'error_type':_0x22f1cc(0x133),'context':{'tool':_0x22f1cc(0x167),'repo_path':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x239)],'query':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x14f)],'model':_0x22f1cc(0x18c),'termination_reason':_0x22f1cc(0x1b1),'error_count':_0x5b6f81[_0x22f1cc(0x13b)],'is_timeout':![],'timings':_0x4edcae['timings'],'files_attempted':_0xf64af2[_0x22f1cc(0x197)](_0x388df8=>({'path':_0x388df8[_0x22f1cc(0x1a2)],'lines':_0x388df8[_0x22f1cc(0x1ee)]})),'tool_calls':_0x1791c9(_0x4edcae[_0x22f1cc(0x1f9)]),'messages':_0x4edcae['messages']?.['map'](_0x1a94e4=>({'role':_0x1a94e4[_0x22f1cc(0x121)],'content':_0x1a94e4[_0x22f1cc(0x240)],..._0x1a94e4[_0x22f1cc(0x126)]?{'tool_calls':_0x1a94e4[_0x22f1cc(0x126)][_0x22f1cc(0x13b)]}:{},..._0x1a94e4[_0x22f1cc(0x1b8)]?{'tool_call_id':_0x1a94e4[_0x22f1cc(0x1b8)]}:{}})),'request_content':{'query':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x14f)],'repo_path':_0x2038da['data'][_0x22f1cc(0x239)],'repoRoot':a0_0x43e623[_0x22f1cc(0x23b)](_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x239)]),'model':'morph-warp-grep-v2.1'}},'source':_0x22f1cc(0x11e)})[_0x22f1cc(0x14d)](()=>{});}}else{if(_0x4edcae[_0x22f1cc(0x181)]===_0x22f1cc(0x1ec)&&_0x4edcae[_0x22f1cc(0x243)]['length']>0x0){const _0x5a5c4e=_0x4edcae[_0x22f1cc(0x243)][_0x22f1cc(0x197)](_0x15f9fe=>_0x15f9fe[_0x22f1cc(0x164)])['join'](';\x20');_0x456071=_0x22f1cc(0x198)+_0x5a5c4e;const _0x565f7c=_0x5a5c4e[_0x22f1cc(0x242)]()['includes']('timeout')||_0x5a5c4e[_0x22f1cc(0x242)]()['includes']('timed\x20out')||_0x5a5c4e[_0x22f1cc(0x242)]()[_0x22f1cc(0x1f2)](_0x22f1cc(0x1f3)),_0x445750=_0x4edcae[_0x22f1cc(0x1b2)]?.[_0x22f1cc(0x208)]?.['files'],_0x397ba2=_0x4edcae['errors'][0x0];reportMorphError({'error_message':_0x5a5c4e,'error_type':_0x565f7c?'TimeoutError':_0x397ba2?.['constructor']?.[_0x22f1cc(0x1b4)]||_0x22f1cc(0x1d6),'context':{'tool':_0x22f1cc(0x167),'repo_path':_0x2038da['data']['repo_path'],'query':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x14f)],'model':_0x22f1cc(0x18c),'termination_reason':_0x4edcae['terminationReason'],'error_count':_0x4edcae['errors'][_0x22f1cc(0x13b)],'is_timeout':_0x565f7c,'timings':_0x4edcae[_0x22f1cc(0x154)],'files_attempted':_0x445750?.[_0x22f1cc(0x197)](_0x1c6177=>({'path':_0x1c6177[_0x22f1cc(0x1a2)],'lines':_0x1c6177['lines']})),'tool_calls':_0x1791c9(_0x4edcae[_0x22f1cc(0x1f9)]),'messages':_0x4edcae['messages']?.[_0x22f1cc(0x197)](_0x24c94e=>({'role':_0x24c94e['role'],'content':_0x24c94e[_0x22f1cc(0x240)],..._0x24c94e['tool_calls']?{'tool_calls':_0x24c94e[_0x22f1cc(0x126)]['length']}:{},..._0x24c94e[_0x22f1cc(0x1b8)]?{'tool_call_id':_0x24c94e[_0x22f1cc(0x1b8)]}:{}})),'request_content':{'query':_0x2038da['data'][_0x22f1cc(0x14f)],'repo_path':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x239)],'repoRoot':a0_0x43e623[_0x22f1cc(0x23b)](_0x2038da[_0x22f1cc(0x17a)]['repo_path']),'model':_0x22f1cc(0x18c)}},'stack_trace':_0x397ba2?.[_0x22f1cc(0x1ba)]||undefined,'source':_0x22f1cc(0x11e)})[_0x22f1cc(0x14d)](()=>{});}else _0x456071=_0x22f1cc(0x20d);}return{'content':[{'type':_0x22f1cc(0x176),'text':_0x456071}]};}catch(_0x1b0e85){const _0x4b6b38=handleMorphAPIError(_0x1b0e85);if(_0x4b6b38)return logger[_0x22f1cc(0x180)](_0x22f1cc(0x128),'tool_call_error',{'tool':_0x22f1cc(0x167),'error':'API\x20error\x20(auth/rate-limit)','latency_ms':Date[_0x22f1cc(0x200)]()-_0x3fcabd}),_0x4b6b38;const _0x1eeaed=_0x1b0e85 instanceof Error?_0x1b0e85[_0x22f1cc(0x164)]:String(_0x1b0e85);logger[_0x22f1cc(0x180)](_0x22f1cc(0x128),_0x22f1cc(0x1e3),{'tool':_0x22f1cc(0x167),'error':_0x1eeaed,'repo_path':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x239)],'query':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x14f)],'latency_ms':Date[_0x22f1cc(0x200)]()-_0x3fcabd});const _0x50bdc1=_0x1eeaed[_0x22f1cc(0x242)]()[_0x22f1cc(0x1f2)](_0x22f1cc(0x1de))||_0x1eeaed[_0x22f1cc(0x242)]()[_0x22f1cc(0x1f2)](_0x22f1cc(0x20e))||_0x1eeaed[_0x22f1cc(0x242)]()[_0x22f1cc(0x1f2)](_0x22f1cc(0x1f3))||_0x1b0e85 instanceof Error&&_0x1b0e85['name']===_0x22f1cc(0x149);return reportMorphError({'error_message':_0x1eeaed,'error_type':_0x50bdc1?_0x22f1cc(0x149):_0x1b0e85 instanceof Error?_0x1b0e85[_0x22f1cc(0x17c)][_0x22f1cc(0x1b4)]:_0x22f1cc(0x1bf),'context':{'tool':_0x22f1cc(0x167),'repo_path':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x239)],'query':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x14f)],'model':_0x22f1cc(0x18c),'is_timeout':_0x50bdc1,'exception_phase':'runWarpGrep_call','request_content':{'query':_0x2038da['data'][_0x22f1cc(0x14f)],'repo_path':_0x2038da[_0x22f1cc(0x17a)][_0x22f1cc(0x239)],'repoRoot':a0_0x43e623['resolve'](_0x2038da['data']['repo_path']),'model':_0x22f1cc(0x18c)}},'stack_trace':_0x1b0e85 instanceof Error?_0x1b0e85[_0x22f1cc(0x1ba)]:undefined,'source':_0x22f1cc(0x11e)})[_0x22f1cc(0x14d)](()=>{}),{'content':[{'type':_0x22f1cc(0x176),'text':'Error\x20running\x20fast\x20context\x20search:\x20'+_0x1eeaed}],'isError':![]};}}case TOOL_NAMES[_0x22f1cc(0x204)]:{const _0x597d53=WarpGrepGitHubArgsSchema['safeParse'](_0x3b0c99);if(!_0x597d53[_0x22f1cc(0x227)])return{'content':[{'type':'text','text':'Invalid\x20arguments:\x20'+_0x597d53[_0x22f1cc(0x180)]}],'isError':!![]};const _0x506bb7=_0x597d53[_0x22f1cc(0x17a)]['github_url']||_0x597d53[_0x22f1cc(0x17a)]['owner_repo'];if(!_0x506bb7)return{'content':[{'type':_0x22f1cc(0x176),'text':_0x22f1cc(0x19b)}],'isError':!![]};const _0x5528ce=MORPH_API_KEY;if(!_0x5528ce)throw new Error('MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.');const _0x5e9a30=Date[_0x22f1cc(0x200)]();logger[_0x22f1cc(0x226)](_0x22f1cc(0x128),_0x22f1cc(0x125),{'identifier':_0x506bb7,'query':_0x597d53[_0x22f1cc(0x17a)][_0x22f1cc(0x14f)],'branch':_0x597d53['data']['branch']});try{const _0x5eee10=new WarpGrepClient({'morphApiKey':_0x5528ce,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT}),_0x316106=await _0x5eee10[_0x22f1cc(0x220)]({'searchTerm':_0x597d53[_0x22f1cc(0x17a)]['search_string'],'github':_0x506bb7,'branch':_0x597d53[_0x22f1cc(0x17a)]['branch']}),_0x2282de=Date[_0x22f1cc(0x200)]()-_0x5e9a30;logMcpStderr(_0x22f1cc(0x232)+_0x2282de+'ms.\x20Success:\x20'+_0x316106[_0x22f1cc(0x227)]);const _0xf8b14=formatResult(_0x316106);return{'content':[{'type':_0x22f1cc(0x176),'text':_0xf8b14}]};}catch(_0x1d3b06){const _0x54265b=handleMorphAPIError(_0x1d3b06);if(_0x54265b)return _0x54265b;const _0x22619c=Date[_0x22f1cc(0x200)]()-_0x5e9a30,_0x2be908=_0x1d3b06 instanceof Error?_0x1d3b06['message']:String(_0x1d3b06);return logMcpStderr(_0x22f1cc(0x18a)+_0x22619c+_0x22f1cc(0x1c7),_0x2be908),reportMorphError({'error_message':_0x2be908,'error_type':_0x1d3b06 instanceof Error?_0x1d3b06[_0x22f1cc(0x17c)][_0x22f1cc(0x1b4)]:_0x22f1cc(0x1bf),'context':{'tool':_0x22f1cc(0x16b),'github_url':_0x506bb7,'search_string':_0x597d53[_0x22f1cc(0x17a)][_0x22f1cc(0x14f)],'branch':_0x597d53[_0x22f1cc(0x17a)][_0x22f1cc(0x168)]},'stack_trace':_0x1d3b06 instanceof Error?_0x1d3b06['stack']:undefined,'source':_0x22f1cc(0x11e),'tool':_0x22f1cc(0x16b),'latency_ms':_0x22619c})[_0x22f1cc(0x14d)](()=>{}),{'content':[{'type':'text','text':_0x22f1cc(0x241)+_0x2be908}],'isError':![]};}}default:throw new Error('Unknown\x20tool:\x20'+_0x1897bb);}}catch(_0x4ade17){const _0x1c9830=_0x4ade17 instanceof Error?_0x4ade17[_0x22f1cc(0x164)]:String(_0x4ade17);return reportMorphError({'error_message':_0x1c9830,'error_type':_0x4ade17 instanceof Error?_0x4ade17['constructor'][_0x22f1cc(0x1b4)]:_0x22f1cc(0x1bf),'context':{'tool':_0x1897bb,'arguments':_0x3b0c99?JSON[_0x22f1cc(0x173)](_0x3b0c99)[_0x22f1cc(0x183)](0x0,0x1f4):undefined,'mcp_server_version':'0.2.0'},'stack_trace':_0x4ade17 instanceof Error?_0x4ade17['stack']:undefined,'source':_0x22f1cc(0x11e)})[_0x22f1cc(0x14d)](()=>{}),{'content':[{'type':'text','text':'Error:\x20'+_0x1c9830}],'isError':!![]};}});async function updateAllowedDirectoriesFromRoots(_0x16c686){const _0x506eb5=a0_0x503392,_0x6f5f08=await getValidRootDirectories(_0x16c686);if(_0x6f5f08[_0x506eb5(0x13b)]>0x0)allowedDirectories=[..._0x6f5f08],logMcpStderr(_0x506eb5(0x1d0)+_0x6f5f08['length']+_0x506eb5(0x1ef));else{logMcpStderr(_0x506eb5(0x22a));if(ENABLE_WORKSPACE_MODE)try{const _0x21c341=await detectWorkspaceRoot(WORKSPACE_ROOT);_0x21c341&&(allowedDirectories=[_0x21c341],logMcpStderr(_0x506eb5(0x19c)+_0x21c341));}catch(_0x8db52d){logMcpStderr(_0x506eb5(0x1fb)+_0x8db52d);}}}server[a0_0x503392(0x211)](RootsListChangedNotificationSchema,async()=>{const _0x3c4e94=a0_0x503392;try{const _0x3ebf66=await server[_0x3c4e94(0x17d)]();_0x3ebf66&&_0x3c4e94(0x15d)in _0x3ebf66&&await updateAllowedDirectoriesFromRoots(_0x3ebf66[_0x3c4e94(0x15d)]);}catch(_0x27e603){logMcpStderr(_0x3c4e94(0x19d),_0x27e603 instanceof Error?_0x27e603['message']:String(_0x27e603));}}),server[a0_0x503392(0x1da)]=async()=>{const _0x1d93f5=a0_0x503392,_0x39e24a=server[_0x1d93f5(0x15a)]();if(_0x39e24a?.[_0x1d93f5(0x15d)])try{const _0x5af383=await server[_0x1d93f5(0x17d)]();_0x5af383&&'roots'in _0x5af383?await updateAllowedDirectoriesFromRoots(_0x5af383[_0x1d93f5(0x15d)]):logMcpStderr(_0x1d93f5(0x1b0));}catch(_0x2ba6e7){logMcpStderr(_0x1d93f5(0x18b),_0x2ba6e7 instanceof Error?_0x2ba6e7['message']:String(_0x2ba6e7));}else{if(allowedDirectories[_0x1d93f5(0x13b)]>0x0)logMcpStderr('Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20allowed\x20directories\x20set\x20from\x20server\x20args:',allowedDirectories);else{if(ENABLE_WORKSPACE_MODE)logMcpStderr('Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20workspace\x20mode');else throw new Error('Server\x20cannot\x20operate:\x20No\x20allowed\x20directories\x20available.\x20Server\x20was\x20started\x20without\x20command-line\x20directories\x20and\x20client\x20either\x20does\x20not\x20support\x20MCP\x20roots\x20protocol\x20or\x20provided\x20empty\x20roots.\x20Please\x20either:\x201)\x20Start\x20server\x20with\x20directory\x20arguments,\x202)\x20Use\x20a\x20client\x20that\x20supports\x20MCP\x20roots\x20protocol\x20and\x20provides\x20valid\x20root\x20directories,\x20or\x203)\x20Enable\x20workspace\x20mode\x20with\x20ENABLE_WORKSPACE_MODE=true.');}}};function a0_0x4338(){const _0x4782c6=['normalize','default','catch','user','search_string','PathError','RipgrepError','warn','Preview\x20changes\x20without\x20applying\x20them.','timings','Example\x20format:\x0a','access','API\x20error\x20(auth/rate-limit)','2978667jrGtrF','path_validation_resolved','getClientCapabilities','Error\x20accessing\x20directory\x20','application/json','roots','Warning:\x20API\x20key\x20format\x20may\x20be\x20incorrect.\x20Morph\x20API\x20keys\x20typically\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27','-\x20Glob\x20search\x20`','ENABLE_WORKSPACE_MODE','\x22>\x0a','morph-v3-fast','\x0aOptions:','message','go.mod','pattern','codebase_search','branch','--version','array','github_codebase_search','composer.json','Morph\x20Edit\x20Preview','A\x20code\x20exploration\x20tool,\x20use\x20this\x20tool\x20when\x20exploring\x20an\x20unfamiliar\x20codebase,\x20and\x20you\x27re\x20unsure\x20of\x20the\x20exact\x20file\x20or\x20string\x20to\x20look\x20for.\x20This\x20tool\x20will\x20find\x20all\x20relevant\x20bits\x20of\x20code\x20given\x20a\x20natural\x20lanugage\x20description,\x20or\x20questin\x20of\x20the\x20thing\x20you\x27re\x20looking\x20for.\x20','glob\x20\x27','https://morphllm.com/api/error-report','unknown','split','stringify','-\x20instruction:\x20Brief\x20first-person\x20description\x20of\x20what\x20you\x27re\x20changing\x0a','WORKSPACE_ROOT','text','-\x20Preserve\x20exact\x20indentation\x0a','provider_created','.vscode','data','list_directory','constructor','listRoots','SymlinkError','unknown\x20error','error','terminationReason','The\x20absolute\x20path\x20of\x20the\x20folder\x20where\x20the\x20search\x20should\x20be\x20performed.\x20In\x20multi-repo\x20workspaces,\x20you\x20have\x20to\x20specify\x20a\x20subfolder\x20where\x20the\x20search\x20should\x20be\x20performed,\x20to\x20avoid\x20searching\x20across\x20all\x20repos','substring','SubToolError','instruction','2460927WNMGFS','describe','linesAdded','every','[github_codebase_search]\x20Failed\x20in\x20','Failed\x20to\x20request\x20initial\x20roots\x20from\x20client:','morph-warp-grep-v2.1','\x22>\x0aError\x20reading\x20file:\x20','string','Unknown\x20error','.\x20Changes:\x20','source','@morphllm/morphmcp\x20','--api-key=','code','sk-','\x20\x20morph-mcp\x20--api-key\x20sk-xxx\x20~/repo','map','Error:\x20','.\x20Path:\x20','parse','Please\x20provide\x20github\x20search\x20url\x20or\x20owner/repo\x20id','Fallback:\x20Using\x20workspace\x20root\x20','Failed\x20to\x20request\x20roots\x20from\x20client:','21116hNZoGZ','linesModified','trim','WHEN\x20TO\x20USE\x20vs\x20native\x20edit/patch\x20tools:\x20prefer\x20this\x20tool\x20for\x20large\x20files,\x20multiple\x20or\x20scattered\x20edits,\x20refactors,\x20and\x20whitespace-sensitive\x20changes.\x20A\x20single\x20tiny\x20exact-string\x20replacement\x20can\x20use\x20the\x20native\x20edit/patch\x20tool.\x20If\x20this\x20tool\x20errors\x20or\x20times\x20out,\x20fall\x20back\x20to\x20native\x20edit\x20with\x20exact\x20string\x20matching.\x0a\x0a','path','context','GitHub\x20repository\x20URL\x20to\x20search\x20(e.g.\x20\x27https://github.com/vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.','arguments','Use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code\x20blocks.\x20Include\x20just\x20enough\x20surrounding\x20context\x20to\x20locate\x20each\x20edit\x20precisely.\x0a\x0a','grep','params','ReadError','1GHJtfq','some','edit_file','\x0a</file>','search_type','readFile','Client\x20returned\x20no\x20roots\x20set,\x20keeping\x20current\x20settings','completed_with_file_errors','finish','setRequestHandler','name','Note:\x20Allowed\x20directories\x20can\x20be\x20provided\x20via:','Changed\x20lines\x20with\x20minimal\x20context.\x20Use\x20placeholders\x20intelligently\x20like\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code.','-\x20path:\x20Absolute\x20file\x20path\x20to\x20edit\x0a','tool_call_id','path_validation_failed','stack','DISABLED_TOOLS','\x20as\x20allowed\x20directory','push','tool_call_received','UnknownError','realpath','connect','Tool\x20','\x20\x203.\x20Workspace\x20mode\x20(default\x20behavior,\x20set\x20ENABLE_WORKSPACE_MODE=false\x20to\x20disable)','BinaryFile','FileNotFound','1898674eVjOUg','ms:','file_read_complete','object','**PRIMARY\x20TOOL\x20FOR\x20EDITING\x20FILES.**\x20Fast,\x20accurate,\x20and\x20prevents\x20context\x20pollution.\x20Especially\x20useful\x20when\x20making\x20multiple\x20edits\x20in\x20one\x20file:\x20describe\x20all\x20changes\x20in\x20a\x20single\x20call\x20and\x20the\x20semantic\x20edit\x20applies\x20them\x20all\x20at\x20once,\x20more\x20accurately\x20and\x20faster\x20than\x20sequential\x20edits.\x20Unlike\x20search-and-replace\x20or\x20patch\x20edits\x20which\x20do\x20narrow\x20edits\x20one\x20at\x20a\x20time,\x20with\x20this\x20tool\x20you\x20should\x20do\x20all\x20your\x20code\x20changes\x20in\x20one\x20go\x20separated\x20by\x20`//\x20...\x20existing\x20code\x20...`\x20markers.\x20This\x20saves\x20tokens\x20and\x20improves\x20performance\x20because\x20you\x20do\x20not\x20need\x20to\x20reread\x20files\x20before\x20edits.\x20All\x20three\x20parameters\x20are\x20required.\x0a\x0a','safeParse','list_directory\x20','homedir','morph-','`\x20in\x20`','Updated\x20allowed\x20directories\x20from\x20MCP\x20roots:\x20','7046370kfBfHB','At\x20least\x20one\x20directory\x20must\x20be\x20provided\x20by\x20EITHER\x20method\x20for\x20the\x20server\x20to\x20operate.','slice','You\x20should\x20ALWAYS\x20use\x20this\x20tool\x20to\x20start\x20your\x20search.\x20','<file\x20path=\x22','WarpGrepError','Branch\x20to\x20search\x20(uses\x20latest\x20commit)','-\x20For\x20deletions:\x20show\x20context\x20before\x20and\x20after,\x20omit\x20the\x20deleted\x20lines\x0a','match','oninitialized','linesRemoved','Created\x20File','.cursor','timeout','Warning:\x20Could\x20not\x20initialize\x20workspace\x20mode:\x20','ENOENT','A\x20brief\x20single\x20first-person\x20sentence\x20instruction\x20describing\x20changes\x20being\x20made\x20to\x20this\x20file.\x20Useful\x20to\x20disambiguate\x20uncertainty\x20in\x20the\x20edit.','post','tool_call_error','.git','added\x20','status','sep','file','size','assistant','enum','terminated','path_validation_start','lines','\x20valid\x20directories','-\x20Grepped\x20\x27','Cargo.toml','includes','etimedout','completionId','indexOf','payload','command','Applied','messages','\x22\x20is\x20disabled\x20via\x20the\x20DISABLED_TOOLS\x20environment\x20variable\x20in\x20your\x20MCP\x20configuration.\x20Please\x20use\x20an\x20alternative\x20approach.','Warning:\x20Workspace\x20fallback\x20failed:\x20','\x20disabled\x20via\x20DISABLED_TOOLS','isDirectory','8421882gMXKzc','No\x20Morph\x20API\x20key\x20configured.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20an\x20API\x20key,\x20then\x20set\x20MORPH_API_KEY\x20in\x20your\x20MCP\x20configuration.','now','min','Filter\x20to\x20specific\x20directories,\x20empty\x20for\x20all','function','GITHUB_CODEBASE_SEARCH','WarpGrep\x20sub-tool\x20errors:\x20','has','--api-key','metadata','dirname','Warning:\x20DISABLED_TOOLS\x20contains\x20unknown\x20tool\x20\x22','[could\x20not\x20read\x20file:\x20','MORPH_LARGE_APPLY','Agent\x20completed\x20but\x20did\x20not\x20call\x20finish\x20tool.','timed\x20out','toISOString','glob','setNotificationHandler','-\x20Listed\x20directory\x20`','\x20\x202.\x20MCP\x20roots\x20protocol\x20(if\x20client\x20supports\x20it)','log','read','Disabled\x20tools:\x20','isArray','RipgrepNotAvailable','Invalid\x20Morph\x20API\x20key\x20format.\x20API\x20keys\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20a\x20valid\x20API\x20key.','grep_search',',\x20modified\x20','code_edit','Max\x20results\x20to\x20return','❌\x20Morph\x20Edit\x20Failed:\x20','//\x20...\x20existing\x20code\x20...\x0aFIRST_EDIT\x0a//\x20...\x20existing\x20code\x20...\x0aSECOND_EDIT\x0a//\x20...\x20existing\x20code\x20...\x0a\x0a','searchGitHub','node_modules','basename','all','floor','grep\x20\x27','debug','success','\x22.\x20Known\x20tools:\x20','instructions','No\x20valid\x20root\x20directories\x20provided\x20by\x20client','PWD','env','\x20\x20-h,\x20--help\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help\x20message\x20and\x20exit','boolean','join','Search\x20type\x20hint.\x20Use\x20\x27node_modules\x27\x20when\x20searching\x20inside\x20node_modules\x20or\x20other\x20dependency\x20directories\x20that\x20are\x20normally\x20excluded.','turns','[github_codebase_search]\x20Done\x20in\x20','Warning:\x20','Here\x20is\x20the\x20content\x20of\x20files:\x0a','\x20\x20morph-mcp','new_string','Fill\x20out\x20extra\x20details\x20that\x20you\x20as\x20a\x20smart\x20model\x20can\x20infer\x20in\x20the\x20question\x20to\x20aid\x20the\x20toolin\x20its\x20search.\x20','Parent\x20directory\x20does\x20not\x20exist:\x20','repo_path','Branch\x20to\x20search\x20(defaults\x20to\x20repo\x27s\x20default\x20branch)','resolve','read\x20','stat','completed','compaction_failed','content','GitHub\x20search\x20failed:\x20','toLowerCase','errors','pyproject.toml','LocalRipgrepProvider','requiresApiKey','edit','mcp-filesystem','file_path','15rtlTWD','role','number','Relevant\x20context\x20found:','package.json','github_search_start','tool_calls','MORPH_API_URL','MCP','cwd','\x20-\x20','Bearer\x20','Started\x20without\x20allowed\x20directories\x20-\x20waiting\x20for\x20client\x20to\x20provide\x20roots\x20via\x20MCP\x20protocol','startsWith','Rate\x20limited:\x20You\x27ve\x20exceeded\x20your\x20Morph\x20API\x20usage\x20limits.\x20Please\x20visit\x20https://morphllm.com\x20to\x20check\x20your\x20plan\x20and\x20purchase\x20additional\x20credits.','files','\x20(new\x20file)','exit','MORPH_WARP_GREP_TIMEOUT','FileReadError','dryRun','description','changes','tsconfig.json','Usage:\x20mcp-server-filesystem\x20[allowed-directory]\x20[additional-directories...]','Warning:\x20Unable\x20to\x20determine\x20package\x20version:','tool','length','385248llRSqx','-\x20Read\x20file\x20`','\x20is\x20not\x20a\x20directory','response','Natural-language\x20question/description\x20about\x20the\x20code\x20you\x20want\x20to\x20understand.\x20Good\x20example:\x20\x22Where\x20does\x20auth\x20get\x20handled,\x20what\x20are\x20the\x20different\x20oauth\x20methods\x20supported?\x22,\x20\x22Trace\x20all\x20code\x20that\x20relates\x20to\x20how\x20data\x20is\x20injested\x20and\x20processed\x22.\x20Bad\x20example:\x20\x22auth()\x22,\x20\x22auth\x20login\x20dashoard\x20google\x20email\x22.\x20This\x20tool\x20does\x20NOT\x20accept\x20regex,\x20keyword\x20dumps,\x20or\x20symbol-only\x20queries.','optional','tool_call_complete','EDIT_FILE','Repository\x20identifier','false','api-key','0.2.0','morph-mcp','TimeoutError','filter'];a0_0x4338=function(){return _0x4782c6;};return a0_0x4338();}async function runServer(){const _0x52a2c6=a0_0x503392,_0x4ec963=new StdioServerTransport();await server[_0x52a2c6(0x1c1)](_0x4ec963),logMcpStderr('Secure\x20MCP\x20Filesystem\x20Server\x20running\x20on\x20stdio'),allowedDirectories['length']===0x0&&logMcpStderr(_0x52a2c6(0x12c));}runServer()[a0_0x503392(0x14d)](_0x105de9=>{const _0x382b7c=a0_0x503392;logMcpStderr('Fatal\x20error\x20running\x20server:',_0x105de9),process[_0x382b7c(0x131)](0x1);});
|
|
2
|
+
const a0_0x181a2a=a0_0x5b32;(function(_0x3d5885,_0x47dff3){const _0x284841=a0_0x5b32,_0x3b3458=_0x3d5885();while(!![]){try{const _0x4c57ae=parseInt(_0x284841(0xdb))/0x1+parseInt(_0x284841(0x185))/0x2+-parseInt(_0x284841(0xe8))/0x3*(parseInt(_0x284841(0x18a))/0x4)+parseInt(_0x284841(0x16f))/0x5*(-parseInt(_0x284841(0x19e))/0x6)+parseInt(_0x284841(0x91))/0x7+parseInt(_0x284841(0xd4))/0x8*(parseInt(_0x284841(0x15d))/0x9)+-parseInt(_0x284841(0x153))/0xa;if(_0x4c57ae===_0x47dff3)break;else _0x3b3458['push'](_0x3b3458['shift']());}catch(_0x536cb1){_0x3b3458['push'](_0x3b3458['shift']());}}}(a0_0x5383,0xc1757));import{Server}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import{CallToolRequestSchema,ListToolsRequestSchema,RootsListChangedNotificationSchema}from'@modelcontextprotocol/sdk/types.js';import a0_0x34bf37 from'fs/promises';import a0_0x46f789 from'path';import a0_0x517fde from'os';import{createRequire}from'module';import{z}from'zod';import{zodToJsonSchema}from'zod-to-json-schema';import{getValidRootDirectories}from'./roots-utils.js';import{getOperatingSystemType,logMcpStderr}from'./log-utils.js';import{logger}from'./logger.js';import{executeEditFile}from'@morphllm/morphsdk/tools/fastapply';import{runWarpGrep,LocalRipgrepProvider,GITHUB_SEARCH_TOOL_NAME,GITHUB_SEARCH_DESCRIPTION}from'@morphllm/morphsdk/tools/warp-grep';import{WarpGrepClient,formatResult}from'@morphllm/morphsdk/tools/warp-grep/client';import{compactFileContexts}from'@morphllm/morphsdk/tools/compact';import a0_0x54f02f from'axios';import{KNOWN_TOOL_NAMES,TOOL_NAMES}from'./tool-definitions.js';function fixPathRepetition(_0x20add0){const _0x592a82=a0_0x5b32,_0x5b0499=_0x20add0['split'](a0_0x46f789['sep'])[_0x592a82(0xe7)](Boolean);if(_0x5b0499[_0x592a82(0xa3)]<0x2)return null;for(let _0x4303d5=Math[_0x592a82(0xb1)](_0x5b0499[_0x592a82(0xa3)]/0x2);_0x4303d5>=0x1;_0x4303d5--){for(let _0xdb268=0x0;_0xdb268<=_0x5b0499['length']-0x2*_0x4303d5;_0xdb268++){const _0x5d22d2=_0x5b0499[_0x592a82(0xc1)](_0xdb268,_0xdb268+_0x4303d5),_0x256702=_0x5b0499['slice'](_0xdb268+_0x4303d5,_0xdb268+0x2*_0x4303d5);if(_0x5d22d2[_0x592a82(0x15c)]((_0x4d5485,_0x5816a7)=>_0x4d5485===_0x256702[_0x5816a7])){const _0xa5ccb2=[..._0x5b0499[_0x592a82(0xc1)](0x0,_0xdb268),..._0x5b0499['slice'](_0xdb268+_0x4303d5)];return a0_0x46f789[_0x592a82(0x94)]+_0xa5ccb2[_0x592a82(0x16b)](a0_0x46f789[_0x592a82(0x94)]);}}}return null;}const require=createRequire(import.meta.url);function getPackageVersion(){const _0x26fd28=a0_0x5b32;try{const _0x5ca227=require(_0x26fd28(0xc0));return _0x5ca227[_0x26fd28(0x13a)]??'unknown';}catch(_0xfd651e){return logMcpStderr('Warning:\x20Unable\x20to\x20determine\x20package\x20version:',_0xfd651e),_0x26fd28(0x102);}}function printHelp(){const _0xe7f11c=a0_0x5b32;console[_0xe7f11c(0xca)](_0xe7f11c(0xf8)+getPackageVersion()),console['log'](_0xe7f11c(0x19c)),console[_0xe7f11c(0xca)](_0xe7f11c(0x13f)),console[_0xe7f11c(0xca)](_0xe7f11c(0x1b1)),console[_0xe7f11c(0xca)](_0xe7f11c(0x191)),console['log'](_0xe7f11c(0xd3)),console[_0xe7f11c(0xca)](_0xe7f11c(0x115)),console[_0xe7f11c(0xca)](_0xe7f11c(0xbf)),console[_0xe7f11c(0xca)]('\x20\x20morph-mcp\x20--api-key\x20sk-xxx\x20~/repo');}const cliArgs=process[a0_0x181a2a(0x112)][a0_0x181a2a(0xc1)](0x2),VERSION_FLAGS=new Set([a0_0x181a2a(0xc9),'-v','-V']),HELP_FLAGS=new Set([a0_0x181a2a(0xe0),'-h']);cliArgs['some'](_0x2533a4=>VERSION_FLAGS[a0_0x181a2a(0x142)](_0x2533a4))&&(console[a0_0x181a2a(0xca)](a0_0x181a2a(0xf8)+getPackageVersion()),process[a0_0x181a2a(0x14e)](0x0));cliArgs[a0_0x181a2a(0x10a)](_0x471fba=>HELP_FLAGS[a0_0x181a2a(0x142)](_0x471fba))&&(printHelp(),process[a0_0x181a2a(0x14e)](0x0));function getCliArg(_0x190946){const _0x22615f=a0_0x181a2a;for(let _0xc52008=0x0;_0xc52008<cliArgs['length'];_0xc52008++){const _0xb398a0=cliArgs[_0xc52008];if(_0xb398a0[_0x22615f(0x196)]('--'+_0x190946+'='))return _0xb398a0['slice'](('--'+_0x190946+'=')[_0x22615f(0xa3)]);if(_0xb398a0==='--'+_0x190946&&_0xc52008+0x1<cliArgs[_0x22615f(0xa3)])return cliArgs[_0xc52008+0x1];}return undefined;}const args=[];function a0_0x5383(){const _0x109bfa=['Applied','basename','floor','\x0a</file>','GITHUB_CODEBASE_SEARCH','\x20is\x20not\x20a\x20directory','all','Started\x20without\x20allowed\x20directories\x20-\x20waiting\x20for\x20client\x20to\x20provide\x20roots\x20via\x20MCP\x20protocol','payload','\x22>\x0a','target_file','LocalRipgrepProvider','split','WarpGrep\x20sub-tool\x20errors:\x20','[github_codebase_search]\x20Failed\x20in\x20','text','\x20\x20morph-mcp','../package.json','slice','error','Warning:\x20DISABLED_TOOLS\x20contains\x20unknown\x20tool\x20\x22','Here\x20is\x20the\x20content\x20of\x20files:\x0a','searchGitHub','A\x20brief\x20single\x20first-person\x20sentence\x20instruction\x20describing\x20changes\x20being\x20made\x20to\x20this\x20file.\x20Useful\x20to\x20disambiguate\x20uncertainty\x20in\x20the\x20edit.','indexOf','Authentication\x20failed:\x20Your\x20Morph\x20API\x20key\x20is\x20invalid\x20or\x20has\x20been\x20revoked.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20a\x20valid\x20API\x20key,\x20then\x20update\x20your\x20MCP\x20configuration.','--version','log','-\x20path:\x20Absolute\x20file\x20path\x20to\x20edit\x0a','Invalid\x20arguments:\x20','assistant','name','post','instruction','github_url','constructor','\x20\x20-v,\x20--version\x20\x20\x20\x20Print\x20version\x20and\x20exit','8wxNbrM','Morph\x20Fast\x20Context\x20subagent\x20performed\x20search\x20on\x20repository:','string','warp_grep_start','❌\x20Morph\x20Edit\x20Failed:\x20','path','[could\x20not\x20read\x20file:\x20','169037ukAoVW','Specific\x20commit\x20hash\x20to\x20search','file_path','\x20\x202.\x20MCP\x20roots\x20protocol\x20(if\x20client\x20supports\x20it)','push','--help','Parent\x20directory\x20does\x20not\x20exist:\x20','completed_with_file_errors','compaction_failed','No\x20relevant\x20code\x20found\x20for\x20the\x20query.','path_validation_resolved','TimeoutError','filter','3671970Gumgrg','Error:\x20','completionId','linesRemoved','Morph\x20Edit\x20Preview','enum','ENOENT','env','getClientCapabilities','Cargo.toml','Workspace\x20mode\x20enabled:\x20Using\x20','tool','\x20chars)','morph-mcp','params','-\x20code_edit:\x20Only\x20the\x20changed\x20lines\x20with\x20//\x20...\x20existing\x20code\x20...\x20markers\x0a\x0a','@morphllm/morphmcp\x20','MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.','isArray','grep_search','.\x20Path:\x20','stat','Failed\x20to\x20request\x20roots\x20from\x20client:','file','Error\x20accessing\x20directory\x20','etimedout','unknown','context','warp_grep_complete','Relevant\x20context\x20found:','files','<file\x20path=\x22','tool_call_complete','0.2.0','some','BinaryFile','`\x20in\x20`',',\x20modified\x20','command','Warning:\x20API\x20key\x20format\x20may\x20be\x20incorrect.\x20Morph\x20API\x20keys\x20typically\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27','FileReadError','Invalid\x20arguments\x20for\x20morph_edit_file:\x20','argv','dirname','false','\x0aExamples:','function','changes','glob','No\x20valid\x20root\x20directories\x20provided\x20by\x20client','.vscode','Created\x20File','owner_repo','warn','FileNotFound','timed\x20out','Failed\x20to\x20read\x20file:\x20','tool_call_received','\x27\x20in\x20`','\x20tool\x20unavailable\x20-\x20MORPH_API_KEY\x20not\x20provided\x20in\x20MCP\x20config','linesAdded','edit_file','https://morphllm.com/api/error-report','morph-v3-fast','messages','composer.json','array','list_directory\x20','Warning:\x20Could\x20not\x20initialize\x20workspace\x20mode:\x20','requiresApiKey','MORPH_WARP_GREP_TIMEOUT','roots','Usage:\x20mcp-server-filesystem\x20[allowed-directory]\x20[additional-directories...]','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20workspace\x20mode','Changed\x20lines\x20with\x20minimal\x20context.\x20Use\x20placeholders\x20intelligently\x20like\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code.','Search\x20type\x20hint.\x20Use\x20\x27node_modules\x27\x20when\x20searching\x20inside\x20node_modules\x20or\x20other\x20dependency\x20directories\x20that\x20are\x20normally\x20excluded.','At\x20least\x20one\x20directory\x20must\x20be\x20provided\x20by\x20EITHER\x20method\x20for\x20the\x20server\x20to\x20operate.','size','//\x20...\x20existing\x20code\x20...\x0aFIRST_EDIT\x0a//\x20...\x20existing\x20code\x20...\x0aSECOND_EDIT\x0a//\x20...\x20existing\x20code\x20...\x0a\x0a','Branch\x20to\x20search\x20(defaults\x20to\x20repo\x27s\x20default\x20branch)','\x20\x203.\x20Workspace\x20mode\x20(default\x20behavior,\x20set\x20ENABLE_WORKSPACE_MODE=false\x20to\x20disable)','data','version','toLowerCase','search_string','tsconfig.json','content','\x0aOptions:','now','Use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code\x20blocks.\x20Include\x20just\x20enough\x20surrounding\x20context\x20to\x20locate\x20each\x20edit\x20precisely.\x0a\x0a','has','morph-warp-grep-v2.1','timeout','describe','--api-key=','listRoots','No\x20Morph\x20API\x20key\x20configured.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20an\x20API\x20key,\x20then\x20set\x20MORPH_API_KEY\x20in\x20your\x20MCP\x20configuration.','go.mod','min','repo_path','code','SymlinkError','exit','MCP','A\x20code\x20exploration\x20tool,\x20use\x20this\x20tool\x20when\x20exploring\x20an\x20unfamiliar\x20codebase,\x20and\x20you\x27re\x20unsure\x20of\x20the\x20exact\x20file\x20or\x20string\x20to\x20look\x20for.\x20This\x20tool\x20will\x20find\x20all\x20relevant\x20bits\x20of\x20code\x20given\x20a\x20natural\x20lanugage\x20description,\x20or\x20questin\x20of\x20the\x20thing\x20you\x27re\x20looking\x20for.\x20','dryRun','RipgrepError','5769960MxwBmo','Error\x20running\x20fast\x20context\x20search:\x20','substring','\x20error(s)','default','access','code_edit','PathError','readFile','every','5241285pdRbMi','new_string','list_directory','Natural-language\x20question/description\x20about\x20the\x20code\x20you\x20want\x20to\x20understand.\x20Good\x20example:\x20\x22Where\x20does\x20auth\x20get\x20handled,\x20what\x20are\x20the\x20different\x20oauth\x20methods\x20supported?\x22,\x20\x22Trace\x20all\x20code\x20that\x20relates\x20to\x20how\x20data\x20is\x20injested\x20and\x20processed\x22.\x20Bad\x20example:\x20\x22auth()\x22,\x20\x22auth\x20login\x20dashoard\x20google\x20email\x22.\x20This\x20tool\x20does\x20NOT\x20accept\x20regex,\x20keyword\x20dumps,\x20or\x20symbol-only\x20queries.','Rules:\x0a','.\x20Changes:\x20','morph-','WHEN\x20TO\x20USE\x20vs\x20native\x20edit/patch\x20tools:\x20prefer\x20this\x20tool\x20for\x20large\x20files,\x20multiple\x20or\x20scattered\x20edits,\x20refactors,\x20and\x20whitespace-sensitive\x20changes.\x20A\x20single\x20tiny\x20exact-string\x20replacement\x20can\x20use\x20the\x20native\x20edit/patch\x20tool.\x20If\x20this\x20tool\x20errors\x20or\x20times\x20out,\x20fall\x20back\x20to\x20native\x20edit\x20with\x20exact\x20string\x20matching.\x0a\x0a','arguments','Secure\x20MCP\x20Filesystem\x20Server\x20running\x20on\x20stdio','Morph\x20FastApply\x20failed\x20without\x20error\x20message','EDIT_FILE','-\x20Grepped\x20\x27','Server\x20cannot\x20operate:\x20No\x20allowed\x20directories\x20available.\x20Server\x20was\x20started\x20without\x20command-line\x20directories\x20and\x20client\x20either\x20does\x20not\x20support\x20MCP\x20roots\x20protocol\x20or\x20provided\x20empty\x20roots.\x20Please\x20either:\x201)\x20Start\x20server\x20with\x20directory\x20arguments,\x202)\x20Use\x20a\x20client\x20that\x20supports\x20MCP\x20roots\x20protocol\x20and\x20provides\x20valid\x20root\x20directories,\x20or\x203)\x20Enable\x20workspace\x20mode\x20with\x20ENABLE_WORKSPACE_MODE=true.','join','MORPH_LARGE_APPLY','read','branch','145IsOZRe','source','Failed\x20to\x20request\x20initial\x20roots\x20from\x20client:','parse','tool_call_id','File\x20read\x20error:','mcp-filesystem','SubToolError','completed','\x0a...\x20(truncated,\x20total:\x20','added\x20','stack','includes','timings','homedir','turns','user','ENABLE_WORKSPACE_MODE','Updated\x20allowed\x20directories\x20from\x20MCP\x20roots:\x20','grep\x20\x27','glob\x20\x27','oninitialized','1093254lpzqwe','\x20(new\x20file)','resolve','terminated','message','4nFYsGi','Repository\x20identifier','lines','safeParse','Tool\x20\x22','isDirectory','map','\x20\x20-h,\x20--help\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help\x20message\x20and\x20exit','filePath','github_search_start','search_type','linesModified','startsWith','object','realpath','unknown\x20error','--api-key','finish','\x0aUsage:\x20morph-mcp\x20[options]\x20[allowed-directory\x20...]','morph-v3-large','52098OHtDGv','tool_calls','errors','success','target_filepath','WarpGrepError','application/json','setRequestHandler','Max\x20results\x20to\x20return','**PRIMARY\x20TOOL\x20FOR\x20EDITING\x20FILES.**\x20Fast,\x20accurate,\x20and\x20prevents\x20context\x20pollution.\x20Especially\x20useful\x20when\x20making\x20multiple\x20edits\x20in\x20one\x20file:\x20describe\x20all\x20changes\x20in\x20a\x20single\x20call\x20and\x20the\x20semantic\x20edit\x20applies\x20them\x20all\x20at\x20once,\x20more\x20accurately\x20and\x20faster\x20than\x20sequential\x20edits.\x20Unlike\x20search-and-replace\x20or\x20patch\x20edits\x20which\x20do\x20narrow\x20edits\x20one\x20at\x20a\x20time,\x20with\x20this\x20tool\x20you\x20should\x20do\x20all\x20your\x20code\x20changes\x20in\x20one\x20go\x20separated\x20by\x20`//\x20...\x20existing\x20code\x20...`\x20markers.\x20This\x20saves\x20tokens\x20and\x20improves\x20performance\x20because\x20you\x20do\x20not\x20need\x20to\x20reread\x20files\x20before\x20edits.\x20All\x20three\x20parameters\x20are\x20required.\x0a\x0a','\x22\x20is\x20disabled\x20via\x20the\x20DISABLED_TOOLS\x20environment\x20variable\x20in\x20your\x20MCP\x20configuration.\x20Please\x20use\x20an\x20alternative\x20approach.','\x20as\x20allowed\x20directory','catch','-\x20instruction:\x20Brief\x20first-person\x20description\x20of\x20what\x20you\x27re\x20changing\x0a','ToolException','status','\x20valid\x20directories','Fallback:\x20Using\x20workspace\x20root\x20','role','\x20\x20--api-key\x20<key>\x20\x20Morph\x20API\x20key\x20(takes\x20priority\x20over\x20MORPH_API_KEY\x20env\x20var)','You\x20should\x20ALWAYS\x20use\x20this\x20tool\x20to\x20start\x20your\x20search.\x20','boolean','GitHub\x20repository\x20URL\x20to\x20search\x20(e.g.\x20\x27https://github.com/vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.','UnknownError','The\x20absolute\x20path\x20of\x20the\x20folder\x20where\x20the\x20search\x20should\x20be\x20performed.\x20In\x20multi-repo\x20workspaces,\x20you\x20have\x20to\x20specify\x20a\x20subfolder\x20where\x20the\x20search\x20should\x20be\x20performed,\x20to\x20avoid\x20searching\x20across\x20all\x20repos','node_modules','DISABLED_TOOLS','pattern','.cursor','instructions','Tool\x20','10830197OXPBgX','api-key','read\x20','sep','match','package.json','CODEBASE_SEARCH','stringify','\x22.\x20Known\x20tools:\x20','debug','PWD','toISOString','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20allowed\x20directories\x20set\x20from\x20server\x20args:','-\x20Batch\x20multiple\x20edits\x20to\x20the\x20same\x20file\x20in\x20one\x20call\x0a','file_read_failed','provider_created','\x20disabled\x20via\x20DISABLED_TOOLS','codebase_search','length','terminationReason','\x22>\x0aError\x20reading\x20file:\x20','path_validation_failed','metadata','API\x20error\x20(auth/rate-limit)','Warning:\x20','ReadError','path_validation_start','tool_call_error','sk-','optional'];a0_0x5383=function(){return _0x109bfa;};return a0_0x5383();}for(let i=0x0;i<cliArgs[a0_0x181a2a(0xa3)];i++){const arg=cliArgs[i];if(VERSION_FLAGS[a0_0x181a2a(0x142)](arg)||HELP_FLAGS[a0_0x181a2a(0x142)](arg))continue;if(arg[a0_0x181a2a(0x196)](a0_0x181a2a(0x146)))continue;if(arg===a0_0x181a2a(0x19a)){i++;continue;}args[a0_0x181a2a(0xdf)](arg);}const WORKSPACE_ROOT=process[a0_0x181a2a(0xef)]['WORKSPACE_ROOT']||process['env'][a0_0x181a2a(0x9b)]||process['cwd'](),ENABLE_WORKSPACE_MODE=process[a0_0x181a2a(0xef)][a0_0x181a2a(0x180)]!==a0_0x181a2a(0x114),MORPH_API_KEY=getCliArg(a0_0x181a2a(0x92))??process[a0_0x181a2a(0xef)]['MORPH_API_KEY'],MORPH_API_URL=process[a0_0x181a2a(0xef)]['MORPH_API_URL'],MORPH_LARGE_APPLY=process[a0_0x181a2a(0xef)][a0_0x181a2a(0x16c)]!=='false',MORPH_WARP_GREP_TIMEOUT=process['env'][a0_0x181a2a(0x12e)]?parseInt(process['env'][a0_0x181a2a(0x12e)],0xa):undefined,OPERATING_SYSTEM_TYPE=getOperatingSystemType(),DEFAULT_DISABLED_TOOLS=new Set(),DISABLED_TOOLS=process[a0_0x181a2a(0xef)][a0_0x181a2a(0x1b8)]?new Set(process[a0_0x181a2a(0xef)][a0_0x181a2a(0x1b8)][a0_0x181a2a(0xbb)](',')[a0_0x181a2a(0x190)](_0xe12b7c=>_0xe12b7c['trim']())[a0_0x181a2a(0xe7)](_0xfbc190=>_0xfbc190[a0_0x181a2a(0xa3)]>0x0)):DEFAULT_DISABLED_TOOLS;if(DISABLED_TOOLS[a0_0x181a2a(0x135)]>0x0){for(const tool of DISABLED_TOOLS){!KNOWN_TOOL_NAMES[a0_0x181a2a(0x142)](tool)&&console[a0_0x181a2a(0xc2)](a0_0x181a2a(0xc3)+tool+a0_0x181a2a(0x99)+[...KNOWN_TOOL_NAMES][a0_0x181a2a(0x16b)](',\x20'));}console['error']('Disabled\x20tools:\x20'+[...DISABLED_TOOLS][a0_0x181a2a(0x16b)](',\x20'));}MORPH_API_KEY&&!MORPH_API_KEY[a0_0x181a2a(0x196)]('sk-')&&!MORPH_API_KEY['startsWith'](a0_0x181a2a(0x163))&&logMcpStderr(a0_0x181a2a(0x10f));async function reportMorphError(_0x5209ed){const _0x333000=a0_0x181a2a;try{await a0_0x54f02f[_0x333000(0xcf)](_0x333000(0x126),{..._0x5209ed,'timestamp':new Date()[_0x333000(0x9c)](),'source':_0x5209ed[_0x333000(0x170)]||_0x333000(0x175),'os_type':OPERATING_SYSTEM_TYPE,'context':{'os_type':OPERATING_SYSTEM_TYPE,..._0x5209ed[_0x333000(0x103)]}},{'timeout':0x1388,'headers':{'Content-Type':_0x333000(0x1a4),'Authorization':'Bearer\x20'+MORPH_API_KEY}});}catch{}}function extractStatusCode(_0x1fb794,_0x18ecfa){const _0x2b6430=a0_0x181a2a;if(_0x1fb794&&typeof _0x1fb794===_0x2b6430(0x197)&&_0x2b6430(0x1ad)in _0x1fb794)return _0x1fb794[_0x2b6430(0x1ad)];if(_0x1fb794&&typeof _0x1fb794===_0x2b6430(0x197)&&'response'in _0x1fb794)return _0x1fb794['response']?.[_0x2b6430(0x1ad)];const _0x55efe7=_0x18ecfa[_0x2b6430(0x95)](/\b(401|429)\b/);return _0x55efe7?parseInt(_0x55efe7[0x1],0xa):null;}function handleMorphAPIError(_0x2e560b){const _0xaa335d=a0_0x181a2a,_0x51d6ef=_0x2e560b instanceof Error?_0x2e560b[_0xaa335d(0x189)]:String(_0x2e560b),_0x2dcca4=extractStatusCode(_0x2e560b,_0x51d6ef);switch(_0x2dcca4){case 0x191:return{'content':[{'type':'text','text':_0xaa335d(0xc8)}],'isError':!![]};case 0x1ad:return{'content':[{'type':_0xaa335d(0xbe),'text':'Rate\x20limited:\x20You\x27ve\x20exceeded\x20your\x20Morph\x20API\x20usage\x20limits.\x20Please\x20visit\x20https://morphllm.com\x20to\x20check\x20your\x20plan\x20and\x20purchase\x20additional\x20credits.'}],'isError':!![]};default:return null;}}args[a0_0x181a2a(0xa3)]===0x0&&!ENABLE_WORKSPACE_MODE&&(logMcpStderr(a0_0x181a2a(0x130)),logMcpStderr('Note:\x20Allowed\x20directories\x20can\x20be\x20provided\x20via:'),logMcpStderr('\x20\x201.\x20Command-line\x20arguments\x20(shown\x20above)'),logMcpStderr(a0_0x181a2a(0xde)),logMcpStderr(a0_0x181a2a(0x138)),logMcpStderr(a0_0x181a2a(0x134)));function a0_0x5b32(_0x20fbee,_0x573024){_0x20fbee=_0x20fbee-0x8e;const _0x53835f=a0_0x5383();let _0x5b3206=_0x53835f[_0x20fbee];return _0x5b3206;}function normalizePath(_0x44d515){return a0_0x46f789['normalize'](_0x44d515);}function expandHome(_0x3aa7bb){const _0x32384c=a0_0x181a2a;if(_0x3aa7bb[_0x32384c(0x196)]('~/')||_0x3aa7bb==='~')return a0_0x46f789[_0x32384c(0x16b)](a0_0x517fde[_0x32384c(0x17d)](),_0x3aa7bb[_0x32384c(0xc1)](0x1));return _0x3aa7bb;}let allowedDirectories=await Promise['all'](args['map'](async _0x63901d=>{const _0x38288b=a0_0x181a2a,_0x58cd70=expandHome(_0x63901d),_0x180e47=a0_0x46f789[_0x38288b(0x187)](_0x58cd70);try{const _0x4d78c0=await a0_0x34bf37['realpath'](_0x180e47);return normalizePath(_0x4d78c0);}catch(_0x57f178){return normalizePath(_0x180e47);}}));if(ENABLE_WORKSPACE_MODE&&args['length']===0x0)try{const workspaceDir=await detectWorkspaceRoot(WORKSPACE_ROOT);workspaceDir&&(allowedDirectories[a0_0x181a2a(0xdf)](workspaceDir),logMcpStderr(a0_0x181a2a(0xf2)+workspaceDir+a0_0x181a2a(0x1a9)));}catch(a0_0x201819){logMcpStderr(a0_0x181a2a(0x12c)+a0_0x201819);}async function detectWorkspaceRoot(_0x40a245){const _0x2f9aed=a0_0x181a2a;let _0x20b151=a0_0x46f789[_0x2f9aed(0x187)](_0x40a245);const _0xf7b742=['.git',_0x2f9aed(0x11a),_0x2f9aed(0x96),_0x2f9aed(0xf1),'pyproject.toml',_0x2f9aed(0x149),_0x2f9aed(0x8e),_0x2f9aed(0x13d),_0x2f9aed(0x129)];while(_0x20b151!==a0_0x46f789[_0x2f9aed(0x113)](_0x20b151)){for(const _0x3b8dd5 of _0xf7b742){const _0xcc8969=a0_0x46f789[_0x2f9aed(0x16b)](_0x20b151,_0x3b8dd5);try{return await a0_0x34bf37[_0x2f9aed(0x158)](_0xcc8969),normalizePath(_0x20b151);}catch{}}_0x20b151=a0_0x46f789[_0x2f9aed(0x113)](_0x20b151);}return normalizePath(_0x40a245);}await Promise[a0_0x181a2a(0xb5)](args[a0_0x181a2a(0x190)](async _0x17570a=>{const _0x4a6cc9=a0_0x181a2a;try{const _0x5e28a7=await a0_0x34bf37[_0x4a6cc9(0xfd)](expandHome(_0x17570a));!_0x5e28a7[_0x4a6cc9(0x18f)]()&&(logMcpStderr('Error:\x20'+_0x17570a+_0x4a6cc9(0xb4)),process[_0x4a6cc9(0x14e)](0x1));}catch(_0x416a2d){logMcpStderr(_0x4a6cc9(0x100)+_0x17570a+':',_0x416a2d),process['exit'](0x1);}}));async function validatePath(_0x2ebe5d){const _0x2c950f=a0_0x181a2a,_0x21081c=expandHome(_0x2ebe5d),_0x3e0b6e=a0_0x46f789[_0x2c950f(0x187)](_0x21081c);logger['debug'](_0x2c950f(0x14f),_0x2c950f(0xab),{'raw_path':_0x2ebe5d,'absolute':_0x3e0b6e});try{const _0x8136f9=await a0_0x34bf37['realpath'](_0x3e0b6e);return logger[_0x2c950f(0x9a)](_0x2c950f(0x14f),_0x2c950f(0xe5),{'resolved':_0x8136f9,'symlink':_0x8136f9!==_0x3e0b6e}),_0x8136f9;}catch(_0x495615){if(_0x495615[_0x2c950f(0x14c)]===_0x2c950f(0xee)){const _0x32d95a=a0_0x46f789['dirname'](_0x3e0b6e);try{const _0x48846b=await a0_0x34bf37[_0x2c950f(0x198)](_0x32d95a),_0x14cd8f=a0_0x46f789[_0x2c950f(0x16b)](_0x48846b,a0_0x46f789[_0x2c950f(0xb0)](_0x3e0b6e));return logger[_0x2c950f(0x9a)](_0x2c950f(0x14f),_0x2c950f(0xe5),{'resolved':_0x14cd8f,'new_file':!![]}),_0x14cd8f;}catch{logger[_0x2c950f(0xc2)](_0x2c950f(0x14f),'path_validation_failed',{'raw_path':_0x2ebe5d,'error':_0x2c950f(0xe1)+_0x32d95a});throw new Error('Parent\x20directory\x20does\x20not\x20exist:\x20'+_0x32d95a);}}logger['error'](_0x2c950f(0x14f),_0x2c950f(0xa6),{'raw_path':_0x2ebe5d,'error':_0x495615[_0x2c950f(0x189)]});throw _0x495615;}}const MorphEditFileArgsSchema=z['object']({'path':z[a0_0x181a2a(0xd6)](),'code_edit':z[a0_0x181a2a(0xd6)]()[a0_0x181a2a(0x145)](a0_0x181a2a(0x132)),'instruction':z[a0_0x181a2a(0xd6)]()[a0_0x181a2a(0x145)](a0_0x181a2a(0xc6)),'dryRun':z[a0_0x181a2a(0x1b3)]()[a0_0x181a2a(0x157)](![])[a0_0x181a2a(0x145)]('Preview\x20changes\x20without\x20applying\x20them.')}),CODEBASE_SEARCH_QUERY_DESCRIPTION=a0_0x181a2a(0x160),WarpGrepArgsSchema=z[a0_0x181a2a(0x197)]({'search_string':z['string']()[a0_0x181a2a(0x145)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repo_path':z[a0_0x181a2a(0xd6)]()[a0_0x181a2a(0x145)](a0_0x181a2a(0x1b6)),'search_type':z[a0_0x181a2a(0xed)]([a0_0x181a2a(0x157),'node_modules'])['optional']()[a0_0x181a2a(0x145)](a0_0x181a2a(0x133))}),WarpGrepGitHubArgsSchema=z[a0_0x181a2a(0x197)]({'search_string':z[a0_0x181a2a(0xd6)]()[a0_0x181a2a(0x145)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'github_url':z[a0_0x181a2a(0xd6)]()[a0_0x181a2a(0xae)]()[a0_0x181a2a(0x145)](a0_0x181a2a(0x1b4)),'owner_repo':z[a0_0x181a2a(0xd6)]()[a0_0x181a2a(0xae)]()[a0_0x181a2a(0x145)]('Repository\x20owner/repo\x20shorthand\x20(e.g.\x20\x27vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.'),'branch':z[a0_0x181a2a(0xd6)]()['optional']()[a0_0x181a2a(0x145)](a0_0x181a2a(0x137))}),CodebaseSearchArgsSchema=z[a0_0x181a2a(0x197)]({'query':z['string']()['describe'](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repoId':z[a0_0x181a2a(0xd6)]()[a0_0x181a2a(0x145)](a0_0x181a2a(0x18b)),'branch':z[a0_0x181a2a(0xd6)]()[a0_0x181a2a(0xae)]()[a0_0x181a2a(0x145)]('Branch\x20to\x20search\x20(uses\x20latest\x20commit)'),'commitHash':z[a0_0x181a2a(0xd6)]()[a0_0x181a2a(0xae)]()['describe'](a0_0x181a2a(0xdc)),'targetDirectories':z[a0_0x181a2a(0x12a)](z[a0_0x181a2a(0xd6)]())['default']([])['describe']('Filter\x20to\x20specific\x20directories,\x20empty\x20for\x20all'),'limit':z['number']()['optional']()[a0_0x181a2a(0x157)](0xa)['describe'](a0_0x181a2a(0x1a6))}),server=new Server({'name':a0_0x181a2a(0xf5),'version':'0.2.0'},{'capabilities':{'tools':{}}});server[a0_0x181a2a(0x1a5)](ListToolsRequestSchema,async()=>{const _0xc0c9ef=a0_0x181a2a,_0x2598cf=[{'name':TOOL_NAMES['EDIT_FILE'],'description':_0xc0c9ef(0x1a7)+_0xc0c9ef(0x164)+'Parameters:\x0a'+_0xc0c9ef(0xcb)+_0xc0c9ef(0x1ab)+_0xc0c9ef(0xf7)+_0xc0c9ef(0x141)+'Example\x20format:\x0a'+_0xc0c9ef(0x136)+_0xc0c9ef(0x161)+'-\x20ALWAYS\x20use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20for\x20unchanged\x20sections\x20(omitting\x20this\x20marker\x20will\x20cause\x20deletions)\x0a'+'-\x20Preserve\x20exact\x20indentation\x0a'+'-\x20For\x20deletions:\x20show\x20context\x20before\x20and\x20after,\x20omit\x20the\x20deleted\x20lines\x0a'+_0xc0c9ef(0x9e),'inputSchema':zodToJsonSchema(MorphEditFileArgsSchema),'requiresApiKey':!![]},{'name':TOOL_NAMES[_0xc0c9ef(0x97)],'description':_0xc0c9ef(0x150)+CODEBASE_SEARCH_QUERY_DESCRIPTION+'\x20'+'Fill\x20out\x20extra\x20details\x20that\x20you\x20as\x20a\x20smart\x20model\x20can\x20infer\x20in\x20the\x20question\x20to\x20aid\x20the\x20toolin\x20its\x20search.\x20'+_0xc0c9ef(0x1b2)+'','inputSchema':zodToJsonSchema(WarpGrepArgsSchema),'requiresApiKey':!![]},{'name':GITHUB_SEARCH_TOOL_NAME,'description':GITHUB_SEARCH_DESCRIPTION,'inputSchema':zodToJsonSchema(WarpGrepGitHubArgsSchema),'requiresApiKey':!![]}],_0x58078c=_0x2598cf[_0xc0c9ef(0xe7)](_0x56adb2=>{const _0x512b44=_0xc0c9ef;if(DISABLED_TOOLS[_0x512b44(0x142)](_0x56adb2['name']))return console[_0x512b44(0xc2)](_0x512b44(0x90)+_0x56adb2['name']+_0x512b44(0xa1)),![];if(_0x512b44(0x12d)in _0x56adb2&&_0x56adb2['requiresApiKey']&&!MORPH_API_KEY)return logMcpStderr(_0x512b44(0xa9)+_0x56adb2[_0x512b44(0xce)]+_0x512b44(0x123)),![];return!![];});return{'tools':_0x58078c['map'](_0x3947b0=>({'name':_0x3947b0[_0xc0c9ef(0xce)],'description':_0x3947b0['description'],'inputSchema':_0x3947b0['inputSchema']}))};}),server['setRequestHandler'](CallToolRequestSchema,async _0x488cb5=>{const _0x5671a4=a0_0x181a2a,{name:_0x3ee19b,arguments:_0x5e398b}=_0x488cb5[_0x5671a4(0xf6)],_0x47fae7=Date[_0x5671a4(0x140)]();logger[_0x5671a4(0x9a)](_0x5671a4(0x14f),_0x5671a4(0x121),{'tool':_0x3ee19b,'args':_0x3ee19b===_0x5671a4(0x125)?{'path':_0x5e398b?.['path'],'instruction':_0x5e398b?.['instruction']||_0x5e398b?.[_0x5671a4(0x8f)],'dryRun':_0x5e398b?.['dryRun']}:_0x5e398b});try{if(!MORPH_API_KEY)return{'content':[{'type':_0x5671a4(0xbe),'text':_0x5671a4(0x148)}],'isError':!![]};if(!MORPH_API_KEY['startsWith'](_0x5671a4(0xad))&&!MORPH_API_KEY[_0x5671a4(0x196)]('morph-'))return{'content':[{'type':'text','text':'Invalid\x20Morph\x20API\x20key\x20format.\x20API\x20keys\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20a\x20valid\x20API\x20key.'}],'isError':!![]};if(DISABLED_TOOLS[_0x5671a4(0x142)](_0x3ee19b))return{'content':[{'type':_0x5671a4(0xbe),'text':_0x5671a4(0x18e)+_0x3ee19b+_0x5671a4(0x1a8)}],'isError':![]};switch(_0x3ee19b){case TOOL_NAMES[_0x5671a4(0x168)]:{let _0x43a62a=_0x5e398b;if(_0x43a62a&&typeof _0x43a62a==='object'){if(!('path'in _0x43a62a)){const _0x75ac6b=_0x43a62a[_0x5671a4(0xb9)]??_0x43a62a[_0x5671a4(0x192)]??_0x43a62a[_0x5671a4(0x1a2)]??_0x43a62a[_0x5671a4(0xdd)]??_0x43a62a[_0x5671a4(0xff)];if(_0x75ac6b)_0x43a62a={..._0x43a62a,'path':_0x75ac6b};}_0x5671a4(0x8f)in _0x43a62a&&!(_0x5671a4(0xd0)in _0x43a62a)&&(_0x43a62a={..._0x43a62a,'instruction':_0x43a62a[_0x5671a4(0x8f)]});if(!(_0x5671a4(0x159)in _0x43a62a)){const _0x325036=_0x43a62a['code']??_0x43a62a[_0x5671a4(0x15e)]??_0x43a62a['content']??_0x43a62a['edit'];if(_0x325036)_0x43a62a={..._0x43a62a,'code_edit':_0x325036};}}const _0x1e7d79=MorphEditFileArgsSchema[_0x5671a4(0x18d)](_0x43a62a);if(!_0x1e7d79[_0x5671a4(0x1a1)])throw new Error(_0x5671a4(0x111)+_0x1e7d79[_0x5671a4(0xc2)]);const _0x518766=await validatePath(_0x1e7d79['data']['path']);let _0x5bccaa=null,_0x2dc740=!![],_0x191178=null;try{_0x5bccaa=await a0_0x34bf37[_0x5671a4(0x15b)](_0x518766,'utf-8'),logger[_0x5671a4(0x9a)](_0x5671a4(0x14f),'file_read_complete',{'path':_0x518766,'size_bytes':_0x5bccaa[_0x5671a4(0xa3)]});}catch(_0x1db97e){const _0x4eb3d5=_0x1db97e[_0x5671a4(0x14c)];_0x4eb3d5==='ENOENT'?(_0x2dc740=![],_0x5bccaa='',logger[_0x5671a4(0x9a)](_0x5671a4(0x14f),'file_read_complete',{'path':_0x518766,'exists':![]})):(_0x191178=_0x5671a4(0x120)+(_0x4eb3d5||_0x5671a4(0x102))+'\x20-\x20'+(_0x1db97e instanceof Error?_0x1db97e[_0x5671a4(0x189)]:String(_0x1db97e)),logger[_0x5671a4(0xc2)]('MCP',_0x5671a4(0x9f),{'path':_0x518766,'error':_0x191178}),logMcpStderr('Warning:\x20'+_0x191178));}let _0x5b18c9;try{const _0x241f44=MORPH_API_KEY;if(!_0x241f44)throw new Error(_0x5671a4(0xf9));const _0x2c0481=a0_0x46f789[_0x5671a4(0x113)](_0x518766),_0x4b5039=a0_0x46f789[_0x5671a4(0xb0)](_0x518766);logger[_0x5671a4(0x9a)]('MCP','api_request_start',{'model':_0x5671a4(0x127),'path':_0x1e7d79['data']['path'],'instruction_len':_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0xd0)]['length'],'code_edit_len':_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0x159)]['length'],'original_code_len':_0x5bccaa?.[_0x5671a4(0xa3)]??0x0,'dry_run':_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0x151)]});const _0x1464d8=Date[_0x5671a4(0x140)](),_0x19736a=await executeEditFile({'target_filepath':_0x4b5039,'code_edit':_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0x159)],'instruction':_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0xd0)]},{'morphApiKey':_0x241f44,'morphApiUrl':MORPH_API_URL,'large':MORPH_LARGE_APPLY,'baseDir':_0x2c0481,'autoWrite':!_0x1e7d79[_0x5671a4(0x139)]['dryRun'],'generateUdiff':![],'debug':![]}),_0x31151f=Date[_0x5671a4(0x140)]()-_0x1464d8;_0x5b18c9=_0x19736a[_0x5671a4(0xea)];if(!_0x19736a['success'])throw new Error(_0x19736a[_0x5671a4(0xc2)]||_0x5671a4(0x167));const _0x7c9dc0=_0x19736a[_0x5671a4(0x117)],_0x3eb706=_0x5671a4(0x179)+_0x7c9dc0['linesAdded']+',\x20removed\x20'+_0x7c9dc0['linesRemoved']+_0x5671a4(0x10d)+_0x7c9dc0[_0x5671a4(0x195)];logger['debug'](_0x5671a4(0x14f),_0x5671a4(0x108),{'tool':_0x5671a4(0x125),'success':!![],'latency_ms':Date['now']()-_0x47fae7,'edit_latency_ms':_0x31151f,'changes':{'added':_0x7c9dc0[_0x5671a4(0x124)],'removed':_0x7c9dc0[_0x5671a4(0xeb)],'modified':_0x7c9dc0[_0x5671a4(0x195)]},'completion_id':_0x5b18c9});if(_0x1e7d79[_0x5671a4(0x139)]['dryRun'])return{'content':[{'type':'text','text':_0x5671a4(0xec)+(_0x2dc740?'':_0x5671a4(0x186))+':\x20'+_0x1e7d79[_0x5671a4(0x139)]['instruction']+_0x5671a4(0x162)+_0x3eb706+_0x5671a4(0xfc)+_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0xd9)]+'.'}]};return{'content':[{'type':_0x5671a4(0xbe),'text':'Morph\x20Edit\x20'+(_0x2dc740?_0x5671a4(0xaf):_0x5671a4(0x11b))+':\x20'+_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0xd0)]+_0x5671a4(0x162)+_0x3eb706+_0x5671a4(0xfc)+_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0xd9)]+'.'}]};}catch(_0x2416a4){const _0xd7776f=handleMorphAPIError(_0x2416a4);if(_0xd7776f)return logger['error']('MCP',_0x5671a4(0xac),{'tool':_0x5671a4(0x125),'error':_0x5671a4(0xa8),'latency_ms':Date[_0x5671a4(0x140)]()-_0x47fae7}),_0xd7776f;const _0x783242=_0x2416a4 instanceof Error?_0x2416a4[_0x5671a4(0x189)]:String(_0x2416a4);return logger[_0x5671a4(0xc2)](_0x5671a4(0x14f),_0x5671a4(0xac),{'tool':_0x5671a4(0x125),'error':_0x783242,'path':_0x1e7d79[_0x5671a4(0x139)]['path'],'validated_path':_0x518766,'latency_ms':Date['now']()-_0x47fae7,'stack':_0x2416a4 instanceof Error?_0x2416a4[_0x5671a4(0x17a)]:undefined}),reportMorphError({'error_message':_0x783242,'error_type':_0x2416a4 instanceof Error?_0x2416a4[_0x5671a4(0xd2)]['name']:'UnknownError','context':{'tool':_0x5671a4(0x125),'completion_id':_0x5b18c9,'file_path':_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0xd9)],'validated_path':_0x518766,'instruction':_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0xd0)],'model':MORPH_LARGE_APPLY?_0x5671a4(0x19d):'morph-v3-fast','dry_run':_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0x151)],'file_exists':_0x2dc740,'file_read_error':_0x191178,'file_readable':_0x5bccaa!==null,'request_content':{'path':_0x1e7d79[_0x5671a4(0x139)]['path'],'code_edit':_0x1e7d79[_0x5671a4(0x139)]['code_edit'],'instruction':_0x1e7d79[_0x5671a4(0x139)][_0x5671a4(0xd0)],'original_code':_0x5bccaa!==null?_0x5bccaa[_0x5671a4(0xa3)]>0xc350?_0x5bccaa[_0x5671a4(0x155)](0x0,0xc350)+_0x5671a4(0x178)+_0x5bccaa[_0x5671a4(0xa3)]+_0x5671a4(0xf4):_0x5bccaa:_0x5671a4(0xda)+(_0x191178||_0x5671a4(0x199))+']','original_code_length':_0x5bccaa?.['length']??0x0,'model':MORPH_LARGE_APPLY?_0x5671a4(0x19d):_0x5671a4(0x127),'dry_run':_0x1e7d79['data'][_0x5671a4(0x151)]}},'stack_trace':_0x2416a4 instanceof Error?_0x2416a4[_0x5671a4(0x17a)]:undefined,'source':'mcp-filesystem'})[_0x5671a4(0x1aa)](()=>{}),{'content':[{'type':_0x5671a4(0xbe),'text':_0x5671a4(0xd8)+_0x783242}],'isError':!![]};}}case TOOL_NAMES['CODEBASE_SEARCH']:{const _0x5eb29d=WarpGrepArgsSchema[_0x5671a4(0x18d)](_0x5e398b);if(!_0x5eb29d[_0x5671a4(0x1a1)])return{'content':[{'type':_0x5671a4(0xbe),'text':_0x5671a4(0xcc)+_0x5eb29d[_0x5671a4(0xc2)]}],'isError':!![]};const _0x326cf3=_0x5d0133=>{const _0xaa9158=_0x5671a4,_0x4ab384=[];for(const _0x118ccb of _0x5d0133||[]){if(_0x118ccb['role']===_0xaa9158(0xcd)&&Array['isArray'](_0x118ccb[_0xaa9158(0x19f)]))for(const _0x358cf2 of _0x118ccb[_0xaa9158(0x19f)]){try{const _0x4ed7b0=_0x358cf2[_0xaa9158(0x116)]?.['name'],_0x5936a4=JSON[_0xaa9158(0x172)](_0x358cf2[_0xaa9158(0x116)]?.[_0xaa9158(0x165)]||'{}');if(_0x4ed7b0===_0xaa9158(0xfb))_0x4ab384['push'](_0xaa9158(0x182)+_0x5936a4['pattern']+'\x27\x20'+(_0x5936a4['path']||'.'));else{if(_0x4ed7b0===_0xaa9158(0x16d))_0x4ab384[_0xaa9158(0xdf)](_0xaa9158(0x93)+_0x5936a4[_0xaa9158(0xd9)]);else{if(_0x4ed7b0===_0xaa9158(0x15f))_0x4ab384[_0xaa9158(0xdf)](_0xaa9158(0x12b)+(_0x5936a4[_0xaa9158(0x10e)]||'.'));else{if(_0x4ed7b0===_0xaa9158(0x118))_0x4ab384[_0xaa9158(0xdf)](_0xaa9158(0x183)+_0x5936a4['pattern']+'\x27\x20'+(_0x5936a4['path']||'.'));else _0x4ed7b0===_0xaa9158(0x19b)&&_0x4ab384['push'](_0xaa9158(0x19b));}}}}catch{}}}return _0x4ab384;},_0x4ed05e=_0x5bd462=>{const _0x33968e=_0x5671a4,_0x12125f=[];if(!_0x5bd462||!Array[_0x33968e(0xfa)](_0x5bd462))return _0x12125f;const _0x28a804=[{'pattern':/\[FILE NOT FOUND\]/,'error_type':_0x33968e(0x11e),'tool':'read'},{'pattern':/\[PATH ERROR\]/,'error_type':_0x33968e(0x15a),'tool':_0x33968e(0x16d)},{'pattern':/\[READ ERROR\]/,'error_type':_0x33968e(0xaa),'tool':_0x33968e(0x16d)},{'pattern':/\[UNREADABLE FILE\]/,'error_type':'BinaryFile','tool':_0x33968e(0x16d)},{'pattern':/\[RIPGREP ERROR\]/,'error_type':_0x33968e(0x152),'tool':'grep'},{'pattern':/\[RIPGREP NOT AVAILABLE\]/,'error_type':'RipgrepNotAvailable','tool':'grep'},{'pattern':/\[BINARY FILE\]/,'error_type':_0x33968e(0x10b),'tool':'read'},{'pattern':/\[SYMLINK\]/,'error_type':_0x33968e(0x14d),'tool':_0x33968e(0x16d)},{'pattern':/not a text file/,'error_type':_0x33968e(0x10b),'tool':_0x33968e(0x16d)},{'pattern':/symbolic link/,'error_type':_0x33968e(0x14d),'tool':'read'},{'pattern':/Error reading file:/,'error_type':'ReadError','tool':_0x33968e(0x16d)},{'pattern':/status="error"/,'error_type':_0x33968e(0x1ac),'tool':_0x33968e(0x102)}];let _0x569752=0x0;for(const _0x3a30f4 of _0x5bd462){_0x3a30f4[_0x33968e(0x1b0)]===_0x33968e(0xcd)&&Array[_0x33968e(0xfa)](_0x3a30f4['tool_calls'])&&_0x569752++;const _0x2f5184=_0x3a30f4[_0x33968e(0x13e)];if((_0x3a30f4[_0x33968e(0x1b0)]===_0x33968e(0xf3)||_0x3a30f4[_0x33968e(0x1b0)]===_0x33968e(0x17f))&&_0x2f5184&&typeof _0x2f5184===_0x33968e(0xd6))for(const {pattern:_0x4dd28d,error_type:_0x1e585c,tool:_0x1f639c}of _0x28a804){const _0x40e0df=_0x2f5184['match'](new RegExp(_0x4dd28d[_0x33968e(0x170)],'g'));if(_0x40e0df)for(const _0x55cae2 of _0x40e0df){const _0x2dfaf6=_0x2f5184[_0x33968e(0xc7)](_0x55cae2),_0x3de66b=_0x2f5184[_0x33968e(0x155)](_0x2dfaf6,Math[_0x33968e(0x14a)](_0x2dfaf6+0xc8,_0x2f5184['length']));_0x12125f[_0x33968e(0xdf)]({'tool':_0x1f639c,'error_type':_0x1e585c,'error_message':_0x3de66b[_0x33968e(0xbb)]('\x0a')[0x0],'turn':_0x569752});}}}return _0x12125f;};try{const _0x46b5f9=a0_0x46f789['resolve'](_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x14b)]),_0x42a825=_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x194)],_0xaaf5f=_0x42a825==='node_modules'?{'allowNames':[_0x5671a4(0x1b7)]}:undefined,_0x5dfac0=new LocalRipgrepProvider(_0x46b5f9,undefined,_0xaaf5f);logger[_0x5671a4(0x9a)](_0x5671a4(0x14f),_0x5671a4(0xa0),{'type':_0x5671a4(0xba),'repo_root':_0x46b5f9,'search_type':_0x42a825||'default'}),logger[_0x5671a4(0x9a)](_0x5671a4(0x14f),_0x5671a4(0xd7),{'query':_0x5eb29d[_0x5671a4(0x139)]['search_string'],'repo_root':_0x46b5f9,'timeout_ms':MORPH_WARP_GREP_TIMEOUT});const _0xf170d9=Date[_0x5671a4(0x140)](),_0x83fb48=await runWarpGrep({'searchTerm':_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x13c)],'repoRoot':_0x46b5f9,'morphApiKey':MORPH_API_KEY,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT,'provider':_0x5dfac0,'search_type':_0x42a825}),_0xa48b4=Date[_0x5671a4(0x140)]()-_0xf170d9,_0x28e743=_0x83fb48[_0x5671a4(0x19b)]?.[_0x5671a4(0xa7)]?.[_0x5671a4(0x106)]?.[_0x5671a4(0xa3)]??0x0;logger[_0x5671a4(0x9a)](_0x5671a4(0x14f),_0x5671a4(0x104),{'termination':_0x83fb48[_0x5671a4(0xa4)],'turns':_0x83fb48[_0x5671a4(0x17c)]?.[_0x5671a4(0x17e)]??0x0,'files_found':_0x28e743,'latency_ms':_0xa48b4});const _0x21b6ed=_0x4ed05e(_0x83fb48[_0x5671a4(0x128)]);_0x21b6ed['length']>0x0&&reportMorphError({'error_message':_0x5671a4(0xbc)+_0x21b6ed[_0x5671a4(0xa3)]+_0x5671a4(0x156),'error_type':_0x5671a4(0x176),'level':'warn','tool':'codebase_search','context':{'repo_path':_0x5eb29d['data']['repo_path'],'query':_0x5eb29d['data']['search_string'],'model':_0x5671a4(0x143),'termination_reason':_0x83fb48[_0x5671a4(0xa4)],'sub_tool_errors':_0x21b6ed,'timings':_0x83fb48[_0x5671a4(0x17c)],'tool_calls':_0x326cf3(_0x83fb48[_0x5671a4(0x128)]),'messages':_0x83fb48[_0x5671a4(0x128)]?.[_0x5671a4(0x190)](_0x2818db=>({'role':_0x2818db[_0x5671a4(0x1b0)],'content':_0x2818db[_0x5671a4(0x13e)],..._0x2818db[_0x5671a4(0x19f)]?{'tool_calls':_0x2818db['tool_calls'][_0x5671a4(0xa3)]}:{},..._0x2818db['tool_call_id']?{'tool_call_id':_0x2818db[_0x5671a4(0x173)]}:{}}))},'source':'mcp-filesystem'})[_0x5671a4(0x1aa)](()=>{});let _0x11d1c0='';if(_0x83fb48['terminationReason']===_0x5671a4(0x177)&&_0x83fb48[_0x5671a4(0x19b)]?.[_0x5671a4(0xa7)]?.[_0x5671a4(0x106)]){const _0x494234=_0x83fb48[_0x5671a4(0x19b)][_0x5671a4(0xa7)][_0x5671a4(0x106)];if(_0x494234[_0x5671a4(0xa3)]===0x0)return _0x11d1c0=_0x83fb48['finish'][_0x5671a4(0xb7)]||_0x5671a4(0xe4),{'content':[{'type':'text','text':_0x11d1c0}]};const _0x46514a=[],_0x18cd53=[_0x5671a4(0xd5)];for(const _0x47f309 of _0x83fb48['messages']){if(_0x47f309[_0x5671a4(0x1b0)]===_0x5671a4(0xcd)&&Array[_0x5671a4(0xfa)](_0x47f309['tool_calls']))for(const _0x17cfef of _0x47f309[_0x5671a4(0x19f)]){try{const _0x41139c=_0x17cfef[_0x5671a4(0x116)]?.[_0x5671a4(0xce)],_0x5cb945=JSON['parse'](_0x17cfef['function']?.[_0x5671a4(0x165)]||'{}');if(_0x41139c===_0x5671a4(0xfb))_0x18cd53[_0x5671a4(0xdf)](_0x5671a4(0x169)+_0x5cb945[_0x5671a4(0x1b9)]+_0x5671a4(0x122)+(_0x5cb945['path']||'.')+'`');else{if(_0x41139c==='read')_0x18cd53[_0x5671a4(0xdf)]('-\x20Read\x20file\x20`'+_0x5cb945[_0x5671a4(0xd9)]+'`');else{if(_0x41139c===_0x5671a4(0x15f))_0x18cd53[_0x5671a4(0xdf)]('-\x20Listed\x20directory\x20`'+(_0x5cb945[_0x5671a4(0x10e)]||'.')+'`');else _0x41139c===_0x5671a4(0x118)&&_0x18cd53[_0x5671a4(0xdf)]('-\x20Glob\x20search\x20`'+_0x5cb945[_0x5671a4(0x1b9)]+_0x5671a4(0x10c)+(_0x5cb945['path']||'.')+'`');}}}catch{}}}_0x46514a[_0x5671a4(0xdf)](_0x18cd53[_0x5671a4(0x16b)]('\x0a'));const _0x1d8206=['',_0x5671a4(0x105)];for(const _0x21ba72 of _0x494234){if(_0x21ba72[_0x5671a4(0x18c)]==='*')_0x1d8206[_0x5671a4(0xdf)]('-\x20'+_0x21ba72[_0x5671a4(0xd9)]+':*');else{if(Array[_0x5671a4(0xfa)](_0x21ba72[_0x5671a4(0x18c)])){const _0x37baaf=_0x21ba72[_0x5671a4(0x18c)][_0x5671a4(0x190)](([_0x5c5e19,_0x1a67de])=>{if(_0x5c5e19===_0x1a67de)return''+_0x5c5e19;return _0x5c5e19+'-'+_0x1a67de;});_0x1d8206[_0x5671a4(0xdf)]('-\x20'+_0x21ba72[_0x5671a4(0xd9)]+':'+_0x37baaf['join'](','));}else _0x1d8206['push']('-\x20'+_0x21ba72['path']+':*');}}_0x1d8206['push'](''),_0x46514a['push'](_0x1d8206['join']('\x0a')),_0x46514a[_0x5671a4(0xdf)](_0x5671a4(0xc4));const _0x1d8ca7=[],_0x37c8fc=[];for(const _0x53209c of _0x494234){let _0x15dcd1=a0_0x46f789[_0x5671a4(0x187)](_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x14b)],_0x53209c['path']),_0x1c1bcb=null,_0x2dbfa7=null;try{_0x1c1bcb=await a0_0x34bf37[_0x5671a4(0x15b)](_0x15dcd1,{'encoding':'utf-8'});}catch(_0x433c60){const _0x54265b=fixPathRepetition(_0x15dcd1);if(_0x54265b)try{_0x1c1bcb=await a0_0x34bf37[_0x5671a4(0x15b)](_0x54265b,{'encoding':'utf-8'}),_0x15dcd1=_0x54265b;}catch{_0x2dbfa7=_0x433c60 instanceof Error?_0x433c60:new Error(String(_0x433c60));}else _0x2dbfa7=_0x433c60 instanceof Error?_0x433c60:new Error(String(_0x433c60));}if(_0x1c1bcb!==null){const _0x371da3=_0x1c1bcb['split'](/\r?\n/),_0x183280=[];if(_0x53209c[_0x5671a4(0x18c)]==='*'||!Array[_0x5671a4(0xfa)](_0x53209c[_0x5671a4(0x18c)]))for(let _0x3568df=0x1;_0x3568df<=_0x371da3[_0x5671a4(0xa3)];_0x3568df++){const _0x338652=_0x371da3[_0x3568df-0x1];_0x183280[_0x5671a4(0xdf)](_0x3568df+'|\x20'+_0x338652);}else for(const [_0x1db68d,_0x474999]of _0x53209c[_0x5671a4(0x18c)]){_0x183280[_0x5671a4(0xa3)]>0x0&&_0x183280[_0x5671a4(0xdf)]('');for(let _0x30ad64=_0x1db68d;_0x30ad64<=_0x474999&&_0x30ad64<=_0x371da3['length'];_0x30ad64++){const _0x44e00d=_0x371da3[_0x30ad64-0x1];_0x183280[_0x5671a4(0xdf)](_0x30ad64+'|\x20'+_0x44e00d);}}_0x37c8fc[_0x5671a4(0xdf)]({'path':_0x53209c['path'],'content':_0x183280[_0x5671a4(0x16b)]('\x0a')});}else _0x1d8ca7[_0x5671a4(0xdf)]('<file\x20path=\x22'+_0x53209c[_0x5671a4(0xd9)]+_0x5671a4(0xa5)+(_0x2dbfa7?.['message']||'Unknown\x20error')+_0x5671a4(0xb2));}try{const _0x46debe=await compactFileContexts(_0x37c8fc,_0x5eb29d['data'][_0x5671a4(0x13c)],MORPH_API_KEY,MORPH_API_URL);for(const _0xa3512e of _0x46debe){_0x1d8ca7[_0x5671a4(0xdf)](_0x5671a4(0x107)+_0xa3512e[_0x5671a4(0xd9)]+_0x5671a4(0xb8)+_0xa3512e[_0x5671a4(0x13e)]+_0x5671a4(0xb2));}}catch(_0x424d8c){logger[_0x5671a4(0x11d)](_0x5671a4(0x14f),_0x5671a4(0xe3),{'error':_0x424d8c instanceof Error?_0x424d8c[_0x5671a4(0x189)]:String(_0x424d8c),'files_count':_0x37c8fc[_0x5671a4(0xa3)]});for(const _0x23b655 of _0x37c8fc){_0x1d8ca7[_0x5671a4(0xdf)](_0x5671a4(0x107)+_0x23b655[_0x5671a4(0xd9)]+_0x5671a4(0xb8)+_0x23b655[_0x5671a4(0x13e)]+_0x5671a4(0xb2));}}_0x46514a[_0x5671a4(0xdf)](_0x1d8ca7[_0x5671a4(0x16b)]('\x0a\x0a')),_0x11d1c0=_0x46514a[_0x5671a4(0x16b)]('\x0a');const _0x9fd78d=_0x83fb48[_0x5671a4(0x1a0)]?.['filter'](_0x399035=>_0x399035['message']?.[_0x5671a4(0x196)](_0x5671a4(0x174)))||[];if(_0x9fd78d[_0x5671a4(0xa3)]>0x0){const _0x2e8247=_0x9fd78d[_0x5671a4(0x190)](_0x3d918a=>_0x3d918a[_0x5671a4(0x189)])['join'](';\x20');reportMorphError({'error_message':_0x2e8247,'error_type':_0x5671a4(0x110),'context':{'tool':'codebase_search','repo_path':_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x14b)],'query':_0x5eb29d[_0x5671a4(0x139)]['search_string'],'model':_0x5671a4(0x143),'termination_reason':_0x5671a4(0xe2),'error_count':_0x9fd78d['length'],'is_timeout':![],'timings':_0x83fb48['timings'],'files_attempted':_0x494234[_0x5671a4(0x190)](_0x38aab2=>({'path':_0x38aab2['path'],'lines':_0x38aab2['lines']})),'tool_calls':_0x326cf3(_0x83fb48['messages']),'messages':_0x83fb48[_0x5671a4(0x128)]?.[_0x5671a4(0x190)](_0xc7b6b9=>({'role':_0xc7b6b9['role'],'content':_0xc7b6b9[_0x5671a4(0x13e)],..._0xc7b6b9[_0x5671a4(0x19f)]?{'tool_calls':_0xc7b6b9['tool_calls'][_0x5671a4(0xa3)]}:{},..._0xc7b6b9[_0x5671a4(0x173)]?{'tool_call_id':_0xc7b6b9[_0x5671a4(0x173)]}:{}})),'request_content':{'query':_0x5eb29d['data']['search_string'],'repo_path':_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x14b)],'repoRoot':a0_0x46f789[_0x5671a4(0x187)](_0x5eb29d[_0x5671a4(0x139)]['repo_path']),'model':_0x5671a4(0x143)}},'source':_0x5671a4(0x175)})[_0x5671a4(0x1aa)](()=>{});}}else{if(_0x83fb48[_0x5671a4(0xa4)]===_0x5671a4(0x188)&&_0x83fb48[_0x5671a4(0x1a0)][_0x5671a4(0xa3)]>0x0){const _0x38c23c=_0x83fb48[_0x5671a4(0x1a0)][_0x5671a4(0x190)](_0x1beefc=>_0x1beefc[_0x5671a4(0x189)])[_0x5671a4(0x16b)](';\x20');_0x11d1c0=_0x5671a4(0xe9)+_0x38c23c;const _0x3b900c=_0x38c23c[_0x5671a4(0x13b)]()[_0x5671a4(0x17b)](_0x5671a4(0x144))||_0x38c23c[_0x5671a4(0x13b)]()[_0x5671a4(0x17b)](_0x5671a4(0x11f))||_0x38c23c[_0x5671a4(0x13b)]()['includes']('etimedout'),_0x1adee3=_0x83fb48[_0x5671a4(0x19b)]?.[_0x5671a4(0xa7)]?.[_0x5671a4(0x106)],_0xa1d6fc=_0x83fb48[_0x5671a4(0x1a0)][0x0];reportMorphError({'error_message':_0x38c23c,'error_type':_0x3b900c?'TimeoutError':_0xa1d6fc?.[_0x5671a4(0xd2)]?.[_0x5671a4(0xce)]||_0x5671a4(0x1a3),'context':{'tool':_0x5671a4(0xa2),'repo_path':_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x14b)],'query':_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x13c)],'model':_0x5671a4(0x143),'termination_reason':_0x83fb48[_0x5671a4(0xa4)],'error_count':_0x83fb48['errors'][_0x5671a4(0xa3)],'is_timeout':_0x3b900c,'timings':_0x83fb48[_0x5671a4(0x17c)],'files_attempted':_0x1adee3?.[_0x5671a4(0x190)](_0x550de3=>({'path':_0x550de3[_0x5671a4(0xd9)],'lines':_0x550de3[_0x5671a4(0x18c)]})),'tool_calls':_0x326cf3(_0x83fb48[_0x5671a4(0x128)]),'messages':_0x83fb48[_0x5671a4(0x128)]?.[_0x5671a4(0x190)](_0x553cbd=>({'role':_0x553cbd['role'],'content':_0x553cbd[_0x5671a4(0x13e)],..._0x553cbd[_0x5671a4(0x19f)]?{'tool_calls':_0x553cbd[_0x5671a4(0x19f)][_0x5671a4(0xa3)]}:{},..._0x553cbd[_0x5671a4(0x173)]?{'tool_call_id':_0x553cbd['tool_call_id']}:{}})),'request_content':{'query':_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x13c)],'repo_path':_0x5eb29d['data']['repo_path'],'repoRoot':a0_0x46f789[_0x5671a4(0x187)](_0x5eb29d['data'][_0x5671a4(0x14b)]),'model':_0x5671a4(0x143)}},'stack_trace':_0xa1d6fc?.[_0x5671a4(0x17a)]||undefined,'source':_0x5671a4(0x175)})[_0x5671a4(0x1aa)](()=>{});}else _0x11d1c0='Agent\x20completed\x20but\x20did\x20not\x20call\x20finish\x20tool.';}return{'content':[{'type':'text','text':_0x11d1c0}]};}catch(_0x17ce4b){const _0x54e9af=handleMorphAPIError(_0x17ce4b);if(_0x54e9af)return logger['error']('MCP','tool_call_error',{'tool':_0x5671a4(0xa2),'error':_0x5671a4(0xa8),'latency_ms':Date[_0x5671a4(0x140)]()-_0x47fae7}),_0x54e9af;const _0xa5c2aa=_0x17ce4b instanceof Error?_0x17ce4b[_0x5671a4(0x189)]:String(_0x17ce4b);logger[_0x5671a4(0xc2)](_0x5671a4(0x14f),_0x5671a4(0xac),{'tool':_0x5671a4(0xa2),'error':_0xa5c2aa,'repo_path':_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x14b)],'query':_0x5eb29d[_0x5671a4(0x139)]['search_string'],'latency_ms':Date[_0x5671a4(0x140)]()-_0x47fae7});const _0x5b85dc=_0xa5c2aa[_0x5671a4(0x13b)]()['includes']('timeout')||_0xa5c2aa['toLowerCase']()[_0x5671a4(0x17b)](_0x5671a4(0x11f))||_0xa5c2aa[_0x5671a4(0x13b)]()['includes'](_0x5671a4(0x101))||_0x17ce4b instanceof Error&&_0x17ce4b[_0x5671a4(0xce)]==='TimeoutError';return reportMorphError({'error_message':_0xa5c2aa,'error_type':_0x5b85dc?_0x5671a4(0xe6):_0x17ce4b instanceof Error?_0x17ce4b[_0x5671a4(0xd2)][_0x5671a4(0xce)]:'UnknownError','context':{'tool':_0x5671a4(0xa2),'repo_path':_0x5eb29d['data'][_0x5671a4(0x14b)],'query':_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x13c)],'model':'morph-warp-grep-v2.1','is_timeout':_0x5b85dc,'exception_phase':'runWarpGrep_call','request_content':{'query':_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x13c)],'repo_path':_0x5eb29d[_0x5671a4(0x139)]['repo_path'],'repoRoot':a0_0x46f789[_0x5671a4(0x187)](_0x5eb29d[_0x5671a4(0x139)][_0x5671a4(0x14b)]),'model':'morph-warp-grep-v2.1'}},'stack_trace':_0x17ce4b instanceof Error?_0x17ce4b[_0x5671a4(0x17a)]:undefined,'source':'mcp-filesystem'})['catch'](()=>{}),{'content':[{'type':_0x5671a4(0xbe),'text':_0x5671a4(0x154)+_0xa5c2aa}],'isError':![]};}}case TOOL_NAMES[_0x5671a4(0xb3)]:{const _0x2bc6cb=WarpGrepGitHubArgsSchema[_0x5671a4(0x18d)](_0x5e398b);if(!_0x2bc6cb['success'])return{'content':[{'type':_0x5671a4(0xbe),'text':_0x5671a4(0xcc)+_0x2bc6cb[_0x5671a4(0xc2)]}],'isError':!![]};const _0x1f6438=_0x2bc6cb[_0x5671a4(0x139)][_0x5671a4(0xd1)]||_0x2bc6cb['data'][_0x5671a4(0x11c)];if(!_0x1f6438)return{'content':[{'type':_0x5671a4(0xbe),'text':'Please\x20provide\x20github\x20search\x20url\x20or\x20owner/repo\x20id'}],'isError':!![]};const _0x502413=MORPH_API_KEY;if(!_0x502413)throw new Error(_0x5671a4(0xf9));const _0x23c005=Date[_0x5671a4(0x140)]();logger[_0x5671a4(0x9a)](_0x5671a4(0x14f),_0x5671a4(0x193),{'identifier':_0x1f6438,'query':_0x2bc6cb['data'][_0x5671a4(0x13c)],'branch':_0x2bc6cb[_0x5671a4(0x139)]['branch']});try{const _0x5a8f4f=new WarpGrepClient({'morphApiKey':_0x502413,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT}),_0x4f4d9a=await _0x5a8f4f[_0x5671a4(0xc5)]({'searchTerm':_0x2bc6cb[_0x5671a4(0x139)][_0x5671a4(0x13c)],'github':_0x1f6438,'branch':_0x2bc6cb[_0x5671a4(0x139)][_0x5671a4(0x16e)]}),_0x256d31=Date[_0x5671a4(0x140)]()-_0x23c005;logMcpStderr('[github_codebase_search]\x20Done\x20in\x20'+_0x256d31+'ms.\x20Success:\x20'+_0x4f4d9a['success']);const _0x749b6=formatResult(_0x4f4d9a);return{'content':[{'type':'text','text':_0x749b6}]};}catch(_0x439d74){const _0xf0ddf8=handleMorphAPIError(_0x439d74);if(_0xf0ddf8)return _0xf0ddf8;const _0x2236d1=Date[_0x5671a4(0x140)]()-_0x23c005,_0x284777=_0x439d74 instanceof Error?_0x439d74[_0x5671a4(0x189)]:String(_0x439d74);return logMcpStderr(_0x5671a4(0xbd)+_0x2236d1+'ms:',_0x284777),reportMorphError({'error_message':_0x284777,'error_type':_0x439d74 instanceof Error?_0x439d74[_0x5671a4(0xd2)][_0x5671a4(0xce)]:_0x5671a4(0x1b5),'context':{'tool':'github_codebase_search','github_url':_0x1f6438,'search_string':_0x2bc6cb['data'][_0x5671a4(0x13c)],'branch':_0x2bc6cb[_0x5671a4(0x139)]['branch']},'stack_trace':_0x439d74 instanceof Error?_0x439d74[_0x5671a4(0x17a)]:undefined,'source':_0x5671a4(0x175),'tool':'github_codebase_search','latency_ms':_0x2236d1})[_0x5671a4(0x1aa)](()=>{}),{'content':[{'type':_0x5671a4(0xbe),'text':'GitHub\x20search\x20failed:\x20'+_0x284777}],'isError':![]};}}default:throw new Error('Unknown\x20tool:\x20'+_0x3ee19b);}}catch(_0x41ae87){const _0x1053b6=_0x41ae87 instanceof Error?_0x41ae87['message']:String(_0x41ae87);return reportMorphError({'error_message':_0x1053b6,'error_type':_0x41ae87 instanceof Error?_0x41ae87['constructor'][_0x5671a4(0xce)]:_0x5671a4(0x1b5),'context':{'tool':_0x3ee19b,'arguments':_0x5e398b?JSON[_0x5671a4(0x98)](_0x5e398b)[_0x5671a4(0x155)](0x0,0x1f4):undefined,'mcp_server_version':_0x5671a4(0x109)},'stack_trace':_0x41ae87 instanceof Error?_0x41ae87[_0x5671a4(0x17a)]:undefined,'source':_0x5671a4(0x175)})['catch'](()=>{}),{'content':[{'type':_0x5671a4(0xbe),'text':_0x5671a4(0xe9)+_0x1053b6}],'isError':!![]};}});async function updateAllowedDirectoriesFromRoots(_0x3629f8){const _0x1ca21d=a0_0x181a2a,_0xe88740=await getValidRootDirectories(_0x3629f8);if(_0xe88740[_0x1ca21d(0xa3)]>0x0)allowedDirectories=[..._0xe88740],logMcpStderr(_0x1ca21d(0x181)+_0xe88740['length']+_0x1ca21d(0x1ae));else{logMcpStderr(_0x1ca21d(0x119));if(ENABLE_WORKSPACE_MODE)try{const _0x26d3cb=await detectWorkspaceRoot(WORKSPACE_ROOT);_0x26d3cb&&(allowedDirectories=[_0x26d3cb],logMcpStderr(_0x1ca21d(0x1af)+_0x26d3cb));}catch(_0x463039){logMcpStderr('Warning:\x20Workspace\x20fallback\x20failed:\x20'+_0x463039);}}}server['setNotificationHandler'](RootsListChangedNotificationSchema,async()=>{const _0x212e10=a0_0x181a2a;try{const _0x5e25dc=await server[_0x212e10(0x147)]();_0x5e25dc&&_0x212e10(0x12f)in _0x5e25dc&&await updateAllowedDirectoriesFromRoots(_0x5e25dc[_0x212e10(0x12f)]);}catch(_0x26065f){logMcpStderr(_0x212e10(0xfe),_0x26065f instanceof Error?_0x26065f[_0x212e10(0x189)]:String(_0x26065f));}}),server[a0_0x181a2a(0x184)]=async()=>{const _0x1c8cac=a0_0x181a2a,_0x47ed86=server[_0x1c8cac(0xf0)]();if(_0x47ed86?.[_0x1c8cac(0x12f)])try{const _0x1d73e5=await server[_0x1c8cac(0x147)]();_0x1d73e5&&'roots'in _0x1d73e5?await updateAllowedDirectoriesFromRoots(_0x1d73e5[_0x1c8cac(0x12f)]):logMcpStderr('Client\x20returned\x20no\x20roots\x20set,\x20keeping\x20current\x20settings');}catch(_0x356b5e){logMcpStderr(_0x1c8cac(0x171),_0x356b5e instanceof Error?_0x356b5e[_0x1c8cac(0x189)]:String(_0x356b5e));}else{if(allowedDirectories['length']>0x0)logMcpStderr(_0x1c8cac(0x9d),allowedDirectories);else{if(ENABLE_WORKSPACE_MODE)logMcpStderr(_0x1c8cac(0x131));else throw new Error(_0x1c8cac(0x16a));}}};async function runServer(){const _0x125eb8=a0_0x181a2a,_0x5706aa=new StdioServerTransport();await server['connect'](_0x5706aa),logMcpStderr(_0x125eb8(0x166)),allowedDirectories[_0x125eb8(0xa3)]===0x0&&logMcpStderr(_0x125eb8(0xb6));}runServer()[a0_0x181a2a(0x1aa)](_0x3412cb=>{logMcpStderr('Fatal\x20error\x20running\x20server:',_0x3412cb),process['exit'](0x1);});
|
package/dist/log-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var a1_0x50a085=a1_0x57a3;(function(_0x2d1836,_0x27aaa6){var _0x3e316e=a1_0x57a3,_0x2643a8=_0x2d1836();while(!![]){try{var _0x57308b=-parseInt(_0x3e316e(0x98))/0x1*(-parseInt(_0x3e316e(0x8e))/0x2)+-parseInt(_0x3e316e(0x8b))/0x3+parseInt(_0x3e316e(0x97))/0x4+parseInt(_0x3e316e(0x89))/0x5+parseInt(_0x3e316e(0x8c))/0x6*(-parseInt(_0x3e316e(0x8a))/0x7)+-parseInt(_0x3e316e(0x84))/0x8+parseInt(_0x3e316e(0x96))/0x9;if(_0x57308b===_0x27aaa6)break;else _0x2643a8['push'](_0x2643a8['shift']());}catch(_0x3830ae){_0x2643a8['push'](_0x2643a8['shift']());}}}(a1_0x2de4,0x63015));import a1_0x1cb1fb from'os';function a1_0x2de4(){var _0x3e2ea3=['1bqcRqu','platform','5345168HoUGeq','[os=','MCP','macOS','Windows','190265nTVZkd','14yWXHQn','1962519bUzAVx','1836114IBgEFH','Unknown','1564378AKVrPA','map','error','length','Linux','win32','linux','info','12625155udiGyh','467380dNWTsS'];a1_0x2de4=function(){return _0x3e2ea3;};return a1_0x2de4();}import{logger}from'./logger.js';export function getOperatingSystemType(_0x58ff00=a1_0x1cb1fb[a1_0x50a085(0x83)]()){var _0x38edb4=a1_0x50a085;switch(_0x58ff00){case'darwin':return _0x38edb4(0x87);case _0x38edb4(0x93):return _0x38edb4(0x88);case _0x38edb4(0x94):return _0x38edb4(0x92);default:return _0x38edb4(0x8d);}}export function formatMcpLogMessage(_0x1f0d00,_0x2dec83=a1_0x1cb1fb[a1_0x50a085(0x83)]()){var _0x1fcbb2=a1_0x50a085;return _0x1fcbb2(0x85)+getOperatingSystemType(_0x2dec83)+']\x20'+_0x1f0d00;}function a1_0x57a3(_0x135de4,_0xb8d9aa){_0x135de4=_0x135de4-0x83;var _0x2de476=a1_0x2de4();var _0x57a33e=_0x2de476[_0x135de4];return _0x57a33e;}export function logMcpStderr(_0x352271,..._0x1c5a3f){var _0x16a149=a1_0x50a085;console[_0x16a149(0x90)](formatMcpLogMessage(_0x352271),..._0x1c5a3f),logger[_0x16a149(0x95)](_0x16a149(0x86),_0x352271,_0x1c5a3f[_0x16a149(0x91)]?{'args':_0x1c5a3f[_0x16a149(0x8f)](_0x496ecb=>String(_0x496ecb))}:undefined);}
|
package/dist/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a2_0xf6b6a3=a2_0x2e52;(function(_0x1816cf,_0x237d57){const _0x5c4d1e=a2_0x2e52,_0x512e62=_0x1816cf();while(!![]){try{const _0x37364f=-parseInt(_0x5c4d1e(0x1d4))/0x1+parseInt(_0x5c4d1e(0x1d5))/0x2*(-parseInt(_0x5c4d1e(0x1bd))/0x3)+-parseInt(_0x5c4d1e(0x1c9))/0x4*(parseInt(_0x5c4d1e(0x1be))/0x5)+-parseInt(_0x5c4d1e(0x1d6))/0x6+parseInt(_0x5c4d1e(0x1ca))/0x7*(-parseInt(_0x5c4d1e(0x1d0))/0x8)+-parseInt(_0x5c4d1e(0x1ce))/0x9*(-parseInt(_0x5c4d1e(0x1d3))/0xa)+-parseInt(_0x5c4d1e(0x1c2))/0xb*(-parseInt(_0x5c4d1e(0x1c1))/0xc);if(_0x37364f===_0x237d57)break;else _0x512e62['push'](_0x512e62['shift']());}catch(_0x2a5dee){_0x512e62['push'](_0x512e62['shift']());}}}(a2_0x4037,0x876b7));function a2_0x2e52(_0x55994c,_0x1b5219){_0x55994c=_0x55994c-0x1bd;const _0x40372e=a2_0x4037();let _0x2e521d=_0x40372e[_0x55994c];return _0x2e521d;}import{createWriteStream}from'fs';class MorphLogger{['enabled'];[a2_0xf6b6a3(0x1c8)];constructor(){const _0x18eb74=a2_0xf6b6a3;this['enabled']=process['env']['MORPH_DEBUG']==='1'||!!process[_0x18eb74(0x1cf)][_0x18eb74(0x1c3)];const _0x1619ff=process[_0x18eb74(0x1cf)][_0x18eb74(0x1c3)];this[_0x18eb74(0x1c8)]=_0x1619ff?createWriteStream(_0x1619ff,{'flags':'a'}):null;}[a2_0xf6b6a3(0x1d2)](_0xed90d8,_0x304648,_0x22bc33){const _0x579d2c=a2_0xf6b6a3;this[_0x579d2c(0x1d7)](_0x579d2c(0x1d2),_0xed90d8,_0x304648,_0x22bc33);}[a2_0xf6b6a3(0x1c5)](_0xb9f389,_0x537416,_0x52d220){const _0x2788ef=a2_0xf6b6a3;this[_0x2788ef(0x1d7)](_0x2788ef(0x1c5),_0xb9f389,_0x537416,_0x52d220);}[a2_0xf6b6a3(0x1cd)](_0x330b63,_0x40f437,_0x2a1bf3){const _0x512044=a2_0xf6b6a3;this[_0x512044(0x1d7)](_0x512044(0x1cd),_0x330b63,_0x40f437,_0x2a1bf3);}[a2_0xf6b6a3(0x1d1)](_0x4c5886,_0x15e17a,_0x15fe7b){const _0x5af581=a2_0xf6b6a3;this[_0x5af581(0x1d7)](_0x5af581(0x1d1),_0x4c5886,_0x15e17a,_0x15fe7b);}[a2_0xf6b6a3(0x1c4)](){const _0x587f65=a2_0xf6b6a3;this[_0x587f65(0x1c7)]=!![];}get['isEnabled'](){const _0x30f060=a2_0xf6b6a3;return this[_0x30f060(0x1c7)];}['_log'](_0x59aa7f,_0x2df737,_0x2a6a41,_0x3c093a){const _0x5221be=a2_0xf6b6a3;if(_0x59aa7f!=='error'&&!this['enabled'])return;const _0x643eec=new Date()[_0x5221be(0x1cc)](),_0x286888='['+_0x643eec+_0x5221be(0x1c0)+_0x59aa7f[_0x5221be(0x1cb)]()+']\x20['+_0x2df737+']';console[_0x5221be(0x1d1)](_0x3c093a?_0x286888+'\x20'+_0x2a6a41+'\x20'+JSON[_0x5221be(0x1bf)](_0x3c093a):_0x286888+'\x20'+_0x2a6a41),this[_0x5221be(0x1c8)]?.[_0x5221be(0x1c6)](JSON[_0x5221be(0x1bf)]({'ts':_0x643eec,'level':_0x59aa7f,'component':_0x2df737,'msg':_0x2a6a41,..._0x3c093a&&{'data':_0x3c093a}})+'\x0a');}}function a2_0x4037(){const _0x272475=['stringify',']\x20[','14277252yilSmE','33UekKMZ','MORPH_LOG_FILE','enable','info','write','enabled','fileStream','4hLtQId','7vKWlDu','toUpperCase','toISOString','warn','9QphbUg','env','6919048WShkOE','error','debug','3660530vEoByL','132523cGgbut','2jHyYjf','6083346OdtctR','_log','3066711NaSAgW','1735775DEtFrK'];a2_0x4037=function(){return _0x272475;};return a2_0x4037();}export const logger=new MorphLogger();
|
package/dist/path-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x2efb35,_0x17006b){const _0x16dcac=a3_0x2417,_0xcb760f=_0x2efb35();while(!![]){try{const _0x18cbdc=-parseInt(_0x16dcac(0xff))/0x1+-parseInt(_0x16dcac(0x10a))/0x2*(-parseInt(_0x16dcac(0x112))/0x3)+parseInt(_0x16dcac(0x113))/0x4*(parseInt(_0x16dcac(0x108))/0x5)+parseInt(_0x16dcac(0x110))/0x6*(-parseInt(_0x16dcac(0x10f))/0x7)+-parseInt(_0x16dcac(0x10c))/0x8+-parseInt(_0x16dcac(0x10d))/0x9*(-parseInt(_0x16dcac(0x107))/0xa)+parseInt(_0x16dcac(0x102))/0xb;if(_0x18cbdc===_0x17006b)break;else _0xcb760f['push'](_0xcb760f['shift']());}catch(_0x1380b4){_0xcb760f['push'](_0xcb760f['shift']());}}}(a3_0x413c,0x29f66));function a3_0x413c(){const _0x30da0b=['toUpperCase','startsWith','50qIvENt','110FjlVLa','trim','2JJoLpt','test','3752FGEAig','29034uYtZEH','replace','35973rWHGDp','18isWsQr','join','579873ZoGpRw','2920FLHfgO','normalize','slice','52422kFOEzl','substring','charAt','161755ukotrZ','match','homedir'];a3_0x413c=function(){return _0x30da0b;};return a3_0x413c();}import a3_0x49a5d8 from'path';import a3_0x21abfc from'os';function a3_0x2417(_0x1f1ba6,_0x26fb83){_0x1f1ba6=_0x1f1ba6-0xfe;const _0x413c12=a3_0x413c();let _0x2417f0=_0x413c12[_0x1f1ba6];return _0x2417f0;}export function convertToWindowsPath(_0x55807c){const _0x244d1c=a3_0x2417;if(_0x55807c[_0x244d1c(0x106)]('/mnt/')){const _0xd95427=_0x55807c['charAt'](0x5)[_0x244d1c(0x105)](),_0x615376=_0x55807c[_0x244d1c(0xfe)](0x6)[_0x244d1c(0x10e)](/\//g,'\x5c');return _0xd95427+':'+_0x615376;}if(_0x55807c[_0x244d1c(0x103)](/^\/[a-zA-Z]\//)){const _0x434c37=_0x55807c[_0x244d1c(0x101)](0x1)[_0x244d1c(0x105)](),_0xf4f5e1=_0x55807c['slice'](0x2)[_0x244d1c(0x10e)](/\//g,'\x5c');return _0x434c37+':'+_0xf4f5e1;}if(_0x55807c[_0x244d1c(0x103)](/^[a-zA-Z]:/))return _0x55807c[_0x244d1c(0x10e)](/\//g,'\x5c');return _0x55807c;}export function normalizePath(_0x3a8b8b){const _0x2e40e6=a3_0x2417;_0x3a8b8b=_0x3a8b8b[_0x2e40e6(0x109)]()[_0x2e40e6(0x10e)](/^["']|["']$/g,'');const _0x486f70=_0x3a8b8b[_0x2e40e6(0x106)]('/')&&!_0x3a8b8b[_0x2e40e6(0x103)](/^\/mnt\/[a-z]\//i)&&!_0x3a8b8b[_0x2e40e6(0x103)](/^\/[a-zA-Z]\//);if(_0x486f70)return _0x3a8b8b[_0x2e40e6(0x10e)](/\/+/g,'/')[_0x2e40e6(0x10e)](/\/+$/,'');_0x3a8b8b=convertToWindowsPath(_0x3a8b8b);if(_0x3a8b8b[_0x2e40e6(0x106)]('\x5c\x5c')){let _0x16360c=_0x3a8b8b;_0x16360c=_0x16360c[_0x2e40e6(0x10e)](/^\\{2,}/,'\x5c\x5c');const _0x2d406c=_0x16360c[_0x2e40e6(0x100)](0x2)[_0x2e40e6(0x10e)](/\\\\/g,'\x5c');_0x3a8b8b='\x5c\x5c'+_0x2d406c;}else _0x3a8b8b=_0x3a8b8b[_0x2e40e6(0x10e)](/\\\\/g,'\x5c');let _0x20ff94=a3_0x49a5d8[_0x2e40e6(0x114)](_0x3a8b8b);_0x3a8b8b[_0x2e40e6(0x106)]('\x5c\x5c')&&!_0x20ff94['startsWith']('\x5c\x5c')&&(_0x20ff94='\x5c'+_0x20ff94);if(_0x20ff94[_0x2e40e6(0x103)](/^[a-zA-Z]:/)){let _0x13e0e1=_0x20ff94['replace'](/\//g,'\x5c');return/^[a-z]:/[_0x2e40e6(0x10b)](_0x13e0e1)&&(_0x13e0e1=_0x13e0e1['charAt'](0x0)[_0x2e40e6(0x105)]()+_0x13e0e1[_0x2e40e6(0xfe)](0x1)),_0x13e0e1;}return _0x20ff94[_0x2e40e6(0x10e)](/\//g,'\x5c');}export function expandHome(_0x28786d){const _0x262942=a3_0x2417;if(_0x28786d['startsWith']('~/')||_0x28786d==='~')return a3_0x49a5d8[_0x262942(0x111)](a3_0x21abfc[_0x262942(0x104)](),_0x28786d[_0x262942(0xfe)](0x1));return _0x28786d;}
|
package/dist/path-validation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a4_0xf991(_0x78fb85,_0x5deb64){_0x78fb85=_0x78fb85-0xe9;const _0x131035=a4_0x1310();let _0xf99109=_0x131035[_0x78fb85];return _0xf99109;}(function(_0x557039,_0x478c12){const _0x7574d=a4_0xf991,_0x2f4145=_0x557039();while(!![]){try{const _0x5d99a0=parseInt(_0x7574d(0xf7))/0x1+parseInt(_0x7574d(0xec))/0x2+parseInt(_0x7574d(0xfa))/0x3+parseInt(_0x7574d(0xf8))/0x4+-parseInt(_0x7574d(0xf3))/0x5*(-parseInt(_0x7574d(0xe9))/0x6)+-parseInt(_0x7574d(0xf0))/0x7+-parseInt(_0x7574d(0xf1))/0x8;if(_0x5d99a0===_0x478c12)break;else _0x2f4145['push'](_0x2f4145['shift']());}catch(_0x5e775e){_0x2f4145['push'](_0x2f4145['shift']());}}}(a4_0x1310,0x67fc7));import a4_0x22cd80 from'path';export function isPathWithinAllowedDirectories(_0x1f0497,_0x41b254){const _0x338223=a4_0xf991;if(typeof _0x1f0497!==_0x338223(0xf9)||!Array[_0x338223(0xfb)](_0x41b254))return![];if(!_0x1f0497||_0x41b254[_0x338223(0xeb)]===0x0)return![];if(_0x1f0497['includes']('\x00'))return![];let _0x190e4c;try{_0x190e4c=a4_0x22cd80[_0x338223(0xf5)](a4_0x22cd80[_0x338223(0xea)](_0x1f0497));}catch{return![];}if(!a4_0x22cd80[_0x338223(0xf4)](_0x190e4c))throw new Error(_0x338223(0xf6));return _0x41b254[_0x338223(0xf2)](_0x1592ab=>{const _0x4e7bc8=_0x338223;if(typeof _0x1592ab!==_0x4e7bc8(0xf9)||!_0x1592ab)return![];if(_0x1592ab[_0x4e7bc8(0xef)]('\x00'))return![];let _0x3ccb88;try{_0x3ccb88=a4_0x22cd80[_0x4e7bc8(0xf5)](a4_0x22cd80[_0x4e7bc8(0xea)](_0x1592ab));}catch{return![];}if(!a4_0x22cd80[_0x4e7bc8(0xf4)](_0x3ccb88))throw new Error(_0x4e7bc8(0xed));if(_0x190e4c===_0x3ccb88)return!![];if(_0x3ccb88===a4_0x22cd80['sep'])return _0x190e4c[_0x4e7bc8(0xee)](a4_0x22cd80[_0x4e7bc8(0xfc)]);return _0x190e4c[_0x4e7bc8(0xee)](_0x3ccb88+a4_0x22cd80[_0x4e7bc8(0xfc)]);});}function a4_0x1310(){const _0x3e5aba=['sep','1248ogvIBh','normalize','length','364722faabOa','Allowed\x20directories\x20must\x20be\x20absolute\x20paths\x20after\x20normalization','startsWith','includes','3648540fKtptb','8688848nTtEYq','some','10820uuAIWE','isAbsolute','resolve','Path\x20must\x20be\x20absolute\x20after\x20normalization','658830Poyula','211328WycDVR','string','2067354GiztDV','isArray'];a4_0x1310=function(){return _0x3e5aba;};return a4_0x1310();}
|
package/dist/roots-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x5f5416,_0x5ed252){const _0x46c5ef=a5_0x4476,_0x11fdf1=_0x5f5416();while(!![]){try{const _0x30561d=-parseInt(_0x46c5ef(0x126))/0x1+-parseInt(_0x46c5ef(0x112))/0x2+-parseInt(_0x46c5ef(0x11b))/0x3*(parseInt(_0x46c5ef(0x115))/0x4)+parseInt(_0x46c5ef(0x123))/0x5+parseInt(_0x46c5ef(0x118))/0x6*(parseInt(_0x46c5ef(0x124))/0x7)+parseInt(_0x46c5ef(0x121))/0x8+-parseInt(_0x46c5ef(0x11c))/0x9;if(_0x30561d===_0x5ed252)break;else _0x11fdf1['push'](_0x11fdf1['shift']());}catch(_0x3dcdf5){_0x11fdf1['push'](_0x11fdf1['shift']());}}}(a5_0x4727,0x7eaf7));function a5_0x4727(){const _0x26f799=['uri','3734776WcChNB','realpath','4283985dlrcVa','5691021AePDZL','Skipping\x20invalid\x20directory:\x20','753551lOmZyw','\x20due\x20to\x20error:\x20','resolve','file://','161480dmWWUp','isDirectory','join','747364IsipXS','invalid\x20path\x20or\x20inaccessible','slice','6mymTFC','push','startsWith','9XowkCo','2006370tffvRI','non-directory\x20root','stat','message'];a5_0x4727=function(){return _0x26f799;};return a5_0x4727();}import{promises as a5_0x3f29f1}from'fs';import a5_0x376a89 from'path';function a5_0x4476(_0x1a819a,_0x1af76f){_0x1a819a=_0x1a819a-0x112;const _0x4727ce=a5_0x4727();let _0x4476a8=_0x4727ce[_0x1a819a];return _0x4476a8;}import a5_0x5d6bb5 from'os';import{normalizePath}from'./path-utils.js';import{logMcpStderr}from'./log-utils.js';async function parseRootUri(_0x1e6628){const _0x1d8422=a5_0x4476;try{const _0x4357a1=_0x1e6628[_0x1d8422(0x11a)](_0x1d8422(0x129))?_0x1e6628['slice'](0x7):_0x1e6628,_0x14d71a=_0x4357a1[_0x1d8422(0x11a)]('~/')||_0x4357a1==='~'?a5_0x376a89[_0x1d8422(0x114)](a5_0x5d6bb5['homedir'](),_0x4357a1[_0x1d8422(0x117)](0x1)):_0x4357a1,_0x391def=a5_0x376a89[_0x1d8422(0x128)](_0x14d71a),_0x5e474f=await a5_0x3f29f1[_0x1d8422(0x122)](_0x391def);return normalizePath(_0x5e474f);}catch{return null;}}function formatDirectoryError(_0xcfc213,_0x5a3d61,_0xa4a03c){const _0x314f1a=a5_0x4476;if(_0xa4a03c)return'Skipping\x20'+_0xa4a03c+':\x20'+_0xcfc213;const _0x66dc06=_0x5a3d61 instanceof Error?_0x5a3d61[_0x314f1a(0x11f)]:String(_0x5a3d61);return _0x314f1a(0x125)+_0xcfc213+_0x314f1a(0x127)+_0x66dc06;}export async function getValidRootDirectories(_0x19e1dd){const _0x45ddb1=a5_0x4476,_0x280639=[];for(const _0x5cee3d of _0x19e1dd){const _0x206bfe=await parseRootUri(_0x5cee3d[_0x45ddb1(0x120)]);if(!_0x206bfe){logMcpStderr(formatDirectoryError(_0x5cee3d[_0x45ddb1(0x120)],undefined,_0x45ddb1(0x116)));continue;}try{const _0x19d04c=await a5_0x3f29f1[_0x45ddb1(0x11e)](_0x206bfe);_0x19d04c[_0x45ddb1(0x113)]()?_0x280639[_0x45ddb1(0x119)](_0x206bfe):logMcpStderr(formatDirectoryError(_0x206bfe,undefined,_0x45ddb1(0x11d)));}catch(_0x13ce70){logMcpStderr(formatDirectoryError(_0x206bfe,_0x13ce70));}}return _0x280639;}
|
package/dist/tool-definitions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a6_0x1d3873=a6_0x216e;(function(_0x4d8db6,_0xd30f91){const _0xd39da8=a6_0x216e,_0x28bb54=_0x4d8db6();while(!![]){try{const _0x394ca8=parseInt(_0xd39da8(0x89))/0x1+parseInt(_0xd39da8(0x8b))/0x2+parseInt(_0xd39da8(0x8f))/0x3*(-parseInt(_0xd39da8(0x94))/0x4)+parseInt(_0xd39da8(0x93))/0x5*(parseInt(_0xd39da8(0x92))/0x6)+-parseInt(_0xd39da8(0x91))/0x7+parseInt(_0xd39da8(0x90))/0x8*(-parseInt(_0xd39da8(0x8a))/0x9)+parseInt(_0xd39da8(0x8c))/0xa;if(_0x394ca8===_0xd30f91)break;else _0x28bb54['push'](_0x28bb54['shift']());}catch(_0x4e970f){_0x28bb54['push'](_0x28bb54['shift']());}}}(a6_0x5ddf,0xc9602));export const TOOL_NAMES={'EDIT_FILE':a6_0x1d3873(0x8d),'CODEBASE_SEARCH':'codebase_search','GITHUB_CODEBASE_SEARCH':a6_0x1d3873(0x8e)};export const ALL_TOOL_NAMES=Object['values'](TOOL_NAMES);function a6_0x216e(_0x35c87e,_0x2978fc){_0x35c87e=_0x35c87e-0x89;const _0x5ddf73=a6_0x5ddf();let _0x216e4e=_0x5ddf73[_0x35c87e];return _0x216e4e;}function a6_0x5ddf(){const _0x212952=['635145iDDizS','9YacHMJ','1345160OwgSKC','15425730yDgqWC','edit_file','github_codebase_search','531pwloLU','10499528OhidOZ','1915599ahgzLw','2504946ZNUGyV','5uOPLGT','19364zpHgRv'];a6_0x5ddf=function(){return _0x212952;};return a6_0x5ddf();}export const KNOWN_TOOL_NAMES=new Set(ALL_TOOL_NAMES);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morphllm/morphmcp",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.202",
|
|
4
4
|
"description": "Fast & accurate MCP server with AI-powered file editing and intelligent code search. Prevents context pollution and saves time for a better user experience.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Morph (https://morphllm.com)",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@google/generative-ai": "^0.21.0",
|
|
37
37
|
"@modelcontextprotocol/sdk": "^1.12.3",
|
|
38
|
-
"@morphllm/morphsdk": "0.2.
|
|
38
|
+
"@morphllm/morphsdk": "0.2.190",
|
|
39
39
|
"@vscode/ripgrep": "^1.15.14",
|
|
40
40
|
"axios": "^1.6.0",
|
|
41
41
|
"chalk": "^5.3.0",
|