@morphllm/morphmcp 0.8.200 → 0.8.201
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_0x534994=a0_0x2237;(function(_0x261f87,_0xd91f5){const _0x521083=a0_0x2237,_0x9e47c9=_0x261f87();while(!![]){try{const _0x5e1abe=parseInt(_0x521083(0x1e2))/0x1*(-parseInt(_0x521083(0x171))/0x2)+-parseInt(_0x521083(0x227))/0x3+-parseInt(_0x521083(0x260))/0x4*(-parseInt(_0x521083(0x186))/0x5)+parseInt(_0x521083(0x16a))/0x6+-parseInt(_0x521083(0x14e))/0x7+-parseInt(_0x521083(0x194))/0x8+parseInt(_0x521083(0x1c5))/0x9*(parseInt(_0x521083(0x256))/0xa);if(_0x5e1abe===_0xd91f5)break;else _0x9e47c9['push'](_0x9e47c9['shift']());}catch(_0x196ddd){_0x9e47c9['push'](_0x9e47c9['shift']());}}}(a0_0x58b4,0x8a7c9));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_0xc8c656 from'fs/promises';import a0_0x21938c from'path';import a0_0x2d6412 from'os';import{createRequire}from'module';import{z}from'zod';import{zodToJsonSchema}from'zod-to-json-schema';function a0_0x58b4(){const _0x307ecb=['post','-\x20Read\x20file\x20`','.\x20Changes:\x20','requiresApiKey','\x20(new\x20file)','new_string','data','Rules:\x0a','tool_call_id','GITHUB_CODEBASE_SEARCH','assistant','File\x20read\x20error:','resolve','edit','text','Repository\x20identifier','inputSchema','Invalid\x20arguments:\x20','[github_codebase_search]\x20Done\x20in\x20','debug','Unknown\x20error','-\x20Preserve\x20exact\x20indentation\x0a','-\x20Grepped\x20\x27','-\x20code_edit:\x20Only\x20the\x20changed\x20lines\x20with\x20//\x20...\x20existing\x20code\x20...\x20markers\x0a\x0a','tool','dirname','❌\x20Morph\x20Edit\x20Failed:\x20','PathError','\x20-\x20','node_modules','stat','setNotificationHandler','Note:\x20Allowed\x20directories\x20can\x20be\x20provided\x20via:','path_validation_start','-\x20Batch\x20multiple\x20edits\x20to\x20the\x20same\x20file\x20in\x20one\x20call\x0a','composer.json','boolean','push','PWD','\x20\x20--api-key\x20<key>\x20\x20Morph\x20API\x20key\x20(takes\x20priority\x20over\x20MORPH_API_KEY\x20env\x20var)','indexOf','false','api_request_start','WarpGrepError','content','isArray','timings','MORPH_WARP_GREP_TIMEOUT','Morph\x20Fast\x20Context\x20subagent\x20performed\x20search\x20on\x20repository:','BinaryFile','sk-','\x20\x20morph-mcp','turns','all','oninitialized','Bearer\x20','\x20\x201.\x20Command-line\x20arguments\x20(shown\x20above)','178881WnQJjh','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20allowed\x20directories\x20set\x20from\x20server\x20args:','-\x20Glob\x20search\x20`','Error:\x20','MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.','isDirectory','function','Max\x20results\x20to\x20return','Error\x20running\x20fast\x20context\x20search:\x20','timed\x20out','Warning:\x20Workspace\x20fallback\x20failed:\x20','source','toLowerCase','Parent\x20directory\x20does\x20not\x20exist:\x20','stack','Fatal\x20error\x20running\x20server:','exit','search_type','Workspace\x20mode\x20enabled:\x20Using\x20','Failed\x20to\x20request\x20initial\x20roots\x20from\x20client:','--api-key','normalize','provider_created','tool_call_received','Filter\x20to\x20specific\x20directories,\x20empty\x20for\x20all','GitHub\x20search\x20failed:\x20','completed_with_file_errors','linesAdded','Client\x20returned\x20no\x20roots\x20set,\x20keeping\x20current\x20settings','cwd','No\x20valid\x20root\x20directories\x20provided\x20by\x20client','Branch\x20to\x20search\x20(uses\x20latest\x20commit)','payload','\x22>\x0a','default','substring','https://morphllm.com/api/error-report','filter','MORPH_API_KEY','tool_call_error','setRequestHandler','Usage:\x20mcp-server-filesystem\x20[allowed-directory]\x20[additional-directories...]','.\x20Path:\x20','trim','application/json','lines','--help','30TqnCJn','ToolException','string','user','\x0a...\x20(truncated,\x20total:\x20','path_validation_failed','Morph\x20Edit\x20','Disabled\x20tools:\x20','Here\x20is\x20the\x20content\x20of\x20files:\x0a','\x22\x20is\x20disabled\x20via\x20the\x20DISABLED_TOOLS\x20environment\x20variable\x20in\x20your\x20MCP\x20configuration.\x20Please\x20use\x20an\x20alternative\x20approach.','161032eTahBl','changes','ms.\x20Success:\x20','tsconfig.json','\x20disabled\x20via\x20DISABLED_TOOLS','Invalid\x20arguments\x20for\x20morph_edit_file:\x20','Updated\x20allowed\x20directories\x20from\x20MCP\x20roots:\x20','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.','target_file','Fill\x20out\x20extra\x20details\x20that\x20you\x20as\x20a\x20smart\x20model\x20can\x20infer\x20in\x20the\x20question\x20to\x20aid\x20the\x20toolin\x20its\x20search.\x20','compaction_failed','stringify','size','SubToolError','-\x20For\x20deletions:\x20show\x20context\x20before\x20and\x20after,\x20omit\x20the\x20deleted\x20lines\x0a','morph-','tool_calls','completed','//\x20...\x20existing\x20code\x20...\x0aFIRST_EDIT\x0a//\x20...\x20existing\x20code\x20...\x0aSECOND_EDIT\x0a//\x20...\x20existing\x20code\x20...\x0a\x0a','message','warn','@morphllm/morphmcp\x20','**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','grep_search','At\x20least\x20one\x20directory\x20must\x20be\x20provided\x20by\x20EITHER\x20method\x20for\x20the\x20server\x20to\x20operate.','SymlinkError','file_read_complete','constructor','messages','readFile','.cursor','\x20\x203.\x20Workspace\x20mode\x20(default\x20behavior,\x20set\x20ENABLE_WORKSPACE_MODE=false\x20to\x20disable)','3525319ibQyTk','You\x20should\x20ALWAYS\x20use\x20this\x20tool\x20to\x20start\x20your\x20search.\x20','match','object','listRoots','Cargo.toml','[github_codebase_search]\x20Failed\x20in\x20','../package.json','startsWith','files','catch','grep','morph-v3-large','number','Unknown\x20tool:\x20','<file\x20path=\x22','\x0aExamples:','version','connect','Secure\x20MCP\x20Filesystem\x20Server\x20running\x20on\x20stdio','TimeoutError','map','branch','pyproject.toml','MORPH_API_URL','status','Failed\x20to\x20request\x20roots\x20from\x20client:','optional','6762972NRWytl','\x22.\x20Known\x20tools:\x20','linesModified','path','code','Applied','errors','3416YGFXQg','Preview\x20changes\x20without\x20applying\x20them.','codebase_search','split','Warning:\x20','join','\x22>\x0aError\x20reading\x20file:\x20','realpath','slice','\x0a</file>','MCP','mcp-filesystem','Started\x20without\x20allowed\x20directories\x20-\x20waiting\x20for\x20client\x20to\x20provide\x20roots\x20via\x20MCP\x20protocol','\x20is\x20not\x20a\x20directory','morph-mcp','\x20tool\x20unavailable\x20-\x20MORPH_API_KEY\x20not\x20provided\x20in\x20MCP\x20config','-\x20path:\x20Absolute\x20file\x20path\x20to\x20edit\x0a','Failed\x20to\x20read\x20file:\x20','\x27\x20in\x20`','env','toISOString','10KeMPMT','RipgrepNotAvailable','floor','list_directory','WORKSPACE_ROOT','instructions','basename','has','UnknownError','timeout','min','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','pattern','7251392vKtmRw','DISABLED_TOOLS',',\x20modified\x20','runWarpGrep_call','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.','access','unknown','success','context','read','Rate\x20limited:\x20You\x27ve\x20exceeded\x20your\x20Morph\x20API\x20usage\x20limits.\x20Please\x20visit\x20https://morphllm.com\x20to\x20check\x20your\x20plan\x20and\x20purchase\x20additional\x20credits.','package.json','arguments','response','No\x20relevant\x20code\x20found\x20for\x20the\x20query.','terminated','glob\x20\x27','0.2.0','search_string','describe','github_search_start','RipgrepError','\x20\x202.\x20MCP\x20roots\x20protocol\x20(if\x20client\x20supports\x20it)','tool_call_complete','metadata','morph-warp-grep-v2.1','role','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.','ENABLE_WORKSPACE_MODE','edit_file','github_codebase_search','roots','instruction','Tool\x20\x22','Changed\x20lines\x20with\x20minimal\x20context.\x20Use\x20placeholders\x20intelligently\x20like\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code.','Parameters:\x0a','EDIT_FILE','linesRemoved','\x20as\x20allowed\x20directory','grep\x20\x27','name','Tool\x20','filePath','.vscode','file_path','log','target_filepath','repo_path','A\x20brief\x20single\x20first-person\x20sentence\x20instruction\x20describing\x20changes\x20being\x20made\x20to\x20this\x20file.\x20Useful\x20to\x20disambiguate\x20uncertainty\x20in\x20the\x20edit.','5695317BcnJKi','ReadError','glob','No\x20Morph\x20API\x20key\x20configured.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20an\x20API\x20key,\x20then\x20set\x20MORPH_API_KEY\x20in\x20your\x20MCP\x20configuration.','api-key','ENOENT','terminationReason','now','includes','sep','finish','--version','FileReadError','FileNotFound','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','argv','length','Warning:\x20Could\x20not\x20initialize\x20workspace\x20mode:\x20','command','code_edit','utf-8','Warning:\x20Unable\x20to\x20determine\x20package\x20version:','error','parse','Warning:\x20DISABLED_TOOLS\x20contains\x20unknown\x20tool\x20\x22','\x20valid\x20directories','added\x20','etimedout','getClientCapabilities','626fCpdfZ','morph-v3-fast','LocalRipgrepProvider','-\x20Listed\x20directory\x20`','\x0aUsage:\x20morph-mcp\x20[options]\x20[allowed-directory\x20...]','file','Error\x20accessing\x20directory\x20','Specific\x20commit\x20hash\x20to\x20search','Agent\x20completed\x20but\x20did\x20not\x20call\x20finish\x20tool.','-\x20ALWAYS\x20use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20for\x20unchanged\x20sections\x20(omitting\x20this\x20marker\x20will\x20cause\x20deletions)\x0a','-\x20instruction:\x20Brief\x20first-person\x20description\x20of\x20what\x20you\x27re\x20changing\x0a','every'];a0_0x58b4=function(){return _0x307ecb;};return a0_0x58b4();}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_0x54681d from'axios';import{KNOWN_TOOL_NAMES,TOOL_NAMES}from'./tool-definitions.js';function fixPathRepetition(_0x5a6436){const _0x4e0477=a0_0x2237,_0x47cde5=_0x5a6436[_0x4e0477(0x174)](a0_0x21938c[_0x4e0477(0x1ce)])[_0x4e0477(0x24c)](Boolean);if(_0x47cde5[_0x4e0477(0x1d5)]<0x2)return null;for(let _0x34ddbc=Math[_0x4e0477(0x188)](_0x47cde5[_0x4e0477(0x1d5)]/0x2);_0x34ddbc>=0x1;_0x34ddbc--){for(let _0x32fcdd=0x0;_0x32fcdd<=_0x47cde5[_0x4e0477(0x1d5)]-0x2*_0x34ddbc;_0x32fcdd++){const _0x3a46ea=_0x47cde5[_0x4e0477(0x179)](_0x32fcdd,_0x32fcdd+_0x34ddbc),_0x4b2d65=_0x47cde5[_0x4e0477(0x179)](_0x32fcdd+_0x34ddbc,_0x32fcdd+0x2*_0x34ddbc);if(_0x3a46ea[_0x4e0477(0x1ed)]((_0x281fcb,_0x12d399)=>_0x281fcb===_0x4b2d65[_0x12d399])){const _0x324994=[..._0x47cde5[_0x4e0477(0x179)](0x0,_0x32fcdd),..._0x47cde5['slice'](_0x32fcdd+_0x34ddbc)];return a0_0x21938c['sep']+_0x324994[_0x4e0477(0x176)](a0_0x21938c[_0x4e0477(0x1ce)]);}}}return null;}const require=createRequire(import.meta.url);function getPackageVersion(){const _0x37398b=a0_0x2237;try{const _0x1d056f=require(_0x37398b(0x155));return _0x1d056f[_0x37398b(0x15f)]??_0x37398b(0x19a);}catch(_0x5dcd26){return logMcpStderr(_0x37398b(0x1da),_0x5dcd26),'unknown';}}function printHelp(){const _0xeb6d83=a0_0x2237;console[_0xeb6d83(0x1c1)](_0xeb6d83(0x142)+getPackageVersion()),console[_0xeb6d83(0x1c1)](_0xeb6d83(0x1e6)),console['log']('\x0aOptions:'),console[_0xeb6d83(0x1c1)](_0xeb6d83(0x215)),console['log']('\x20\x20-h,\x20--help\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help\x20message\x20and\x20exit'),console['log']('\x20\x20-v,\x20--version\x20\x20\x20\x20Print\x20version\x20and\x20exit'),console['log'](_0xeb6d83(0x15e)),console['log'](_0xeb6d83(0x221)),console[_0xeb6d83(0x1c1)]('\x20\x20morph-mcp\x20--api-key\x20sk-xxx\x20~/repo');}const cliArgs=process[a0_0x534994(0x1d4)][a0_0x534994(0x179)](0x2),VERSION_FLAGS=new Set([a0_0x534994(0x1d0),'-v','-V']),HELP_FLAGS=new Set([a0_0x534994(0x255),'-h']);cliArgs['some'](_0x3aff75=>VERSION_FLAGS[a0_0x534994(0x18d)](_0x3aff75))&&(console[a0_0x534994(0x1c1)](a0_0x534994(0x142)+getPackageVersion()),process['exit'](0x0));cliArgs['some'](_0x33eb87=>HELP_FLAGS[a0_0x534994(0x18d)](_0x33eb87))&&(printHelp(),process[a0_0x534994(0x237)](0x0));function getCliArg(_0x36fa4a){const _0x1809fd=a0_0x534994;for(let _0x2905f9=0x0;_0x2905f9<cliArgs[_0x1809fd(0x1d5)];_0x2905f9++){const _0x1e1a41=cliArgs[_0x2905f9];if(_0x1e1a41['startsWith']('--'+_0x36fa4a+'='))return _0x1e1a41[_0x1809fd(0x179)](('--'+_0x36fa4a+'=')[_0x1809fd(0x1d5)]);if(_0x1e1a41==='--'+_0x36fa4a&&_0x2905f9+0x1<cliArgs[_0x1809fd(0x1d5)])return cliArgs[_0x2905f9+0x1];}return undefined;}const args=[];for(let i=0x0;i<cliArgs[a0_0x534994(0x1d5)];i++){const arg=cliArgs[i];if(VERSION_FLAGS[a0_0x534994(0x18d)](arg)||HELP_FLAGS['has'](arg))continue;if(arg[a0_0x534994(0x156)]('--api-key='))continue;if(arg===a0_0x534994(0x23b)){i++;continue;}args[a0_0x534994(0x213)](arg);}const WORKSPACE_ROOT=process[a0_0x534994(0x184)][a0_0x534994(0x18a)]||process[a0_0x534994(0x184)][a0_0x534994(0x214)]||process[a0_0x534994(0x244)](),ENABLE_WORKSPACE_MODE=process[a0_0x534994(0x184)][a0_0x534994(0x1b0)]!==a0_0x534994(0x217),MORPH_API_KEY=getCliArg(a0_0x534994(0x1c9))??process[a0_0x534994(0x184)][a0_0x534994(0x24d)],MORPH_API_URL=process[a0_0x534994(0x184)][a0_0x534994(0x166)],MORPH_LARGE_APPLY=process['env']['MORPH_LARGE_APPLY']!==a0_0x534994(0x217),MORPH_WARP_GREP_TIMEOUT=process[a0_0x534994(0x184)][a0_0x534994(0x21d)]?parseInt(process['env'][a0_0x534994(0x21d)],0xa):undefined,OPERATING_SYSTEM_TYPE=getOperatingSystemType(),DEFAULT_DISABLED_TOOLS=new Set(),DISABLED_TOOLS=process[a0_0x534994(0x184)][a0_0x534994(0x195)]?new Set(process['env'][a0_0x534994(0x195)][a0_0x534994(0x174)](',')['map'](_0x38d560=>_0x38d560[a0_0x534994(0x252)]())[a0_0x534994(0x24c)](_0x401887=>_0x401887[a0_0x534994(0x1d5)]>0x0)):DEFAULT_DISABLED_TOOLS;if(DISABLED_TOOLS[a0_0x534994(0x26c)]>0x0){for(const tool of DISABLED_TOOLS){!KNOWN_TOOL_NAMES[a0_0x534994(0x18d)](tool)&&console['error'](a0_0x534994(0x1dd)+tool+a0_0x534994(0x16b)+[...KNOWN_TOOL_NAMES][a0_0x534994(0x176)](',\x20'));}console[a0_0x534994(0x1db)](a0_0x534994(0x25d)+[...DISABLED_TOOLS]['join'](',\x20'));}function a0_0x2237(_0x21dea5,_0x3107fc){_0x21dea5=_0x21dea5-0x13e;const _0x58b473=a0_0x58b4();let _0x2237f3=_0x58b473[_0x21dea5];return _0x2237f3;}MORPH_API_KEY&&!MORPH_API_KEY[a0_0x534994(0x156)](a0_0x534994(0x220))&&!MORPH_API_KEY[a0_0x534994(0x156)]('morph-')&&logMcpStderr('Warning:\x20API\x20key\x20format\x20may\x20be\x20incorrect.\x20Morph\x20API\x20keys\x20typically\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27');async function reportMorphError(_0x1d25a6){const _0x221750=a0_0x534994;try{await a0_0x54681d[_0x221750(0x1ee)](_0x221750(0x24b),{..._0x1d25a6,'timestamp':new Date()[_0x221750(0x185)](),'source':_0x1d25a6[_0x221750(0x232)]||_0x221750(0x17c),'os_type':OPERATING_SYSTEM_TYPE,'context':{'os_type':OPERATING_SYSTEM_TYPE,..._0x1d25a6[_0x221750(0x19c)]}},{'timeout':0x1388,'headers':{'Content-Type':_0x221750(0x253),'Authorization':_0x221750(0x225)+MORPH_API_KEY}});}catch{}}function extractStatusCode(_0x1271c6,_0x569142){const _0x10d0ab=a0_0x534994;if(_0x1271c6&&typeof _0x1271c6==='object'&&_0x10d0ab(0x167)in _0x1271c6)return _0x1271c6[_0x10d0ab(0x167)];if(_0x1271c6&&typeof _0x1271c6===_0x10d0ab(0x151)&&_0x10d0ab(0x1a1)in _0x1271c6)return _0x1271c6[_0x10d0ab(0x1a1)]?.[_0x10d0ab(0x167)];const _0x3c6f9e=_0x569142[_0x10d0ab(0x150)](/\b(401|429)\b/);return _0x3c6f9e?parseInt(_0x3c6f9e[0x1],0xa):null;}function handleMorphAPIError(_0x4d3132){const _0x267c7f=a0_0x534994,_0x177040=_0x4d3132 instanceof Error?_0x4d3132[_0x267c7f(0x140)]:String(_0x4d3132),_0x3fcc3d=extractStatusCode(_0x4d3132,_0x177040);switch(_0x3fcc3d){case 0x191:return{'content':[{'type':_0x267c7f(0x1fc),'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':_0x267c7f(0x19e)}],'isError':!![]};default:return null;}}args[a0_0x534994(0x1d5)]===0x0&&!ENABLE_WORKSPACE_MODE&&(logMcpStderr(a0_0x534994(0x250)),logMcpStderr(a0_0x534994(0x20e)),logMcpStderr(a0_0x534994(0x226)),logMcpStderr(a0_0x534994(0x1aa)),logMcpStderr(a0_0x534994(0x14d)),logMcpStderr(a0_0x534994(0x146)));function normalizePath(_0x301632){const _0xf065cb=a0_0x534994;return a0_0x21938c[_0xf065cb(0x23c)](_0x301632);}function expandHome(_0x2e8468){const _0x2ff46c=a0_0x534994;if(_0x2e8468[_0x2ff46c(0x156)]('~/')||_0x2e8468==='~')return a0_0x21938c['join'](a0_0x2d6412['homedir'](),_0x2e8468['slice'](0x1));return _0x2e8468;}let allowedDirectories=await Promise['all'](args[a0_0x534994(0x163)](async _0x21f380=>{const _0x196d12=a0_0x534994,_0x1a2e51=expandHome(_0x21f380),_0x29959c=a0_0x21938c[_0x196d12(0x1fa)](_0x1a2e51);try{const _0x4f76fc=await a0_0xc8c656[_0x196d12(0x178)](_0x29959c);return normalizePath(_0x4f76fc);}catch(_0x4e646d){return normalizePath(_0x29959c);}}));if(ENABLE_WORKSPACE_MODE&&args[a0_0x534994(0x1d5)]===0x0)try{const workspaceDir=await detectWorkspaceRoot(WORKSPACE_ROOT);workspaceDir&&(allowedDirectories[a0_0x534994(0x213)](workspaceDir),logMcpStderr(a0_0x534994(0x239)+workspaceDir+a0_0x534994(0x1ba)));}catch(a0_0x27677b){logMcpStderr(a0_0x534994(0x1d6)+a0_0x27677b);}async function detectWorkspaceRoot(_0x11d327){const _0x460fab=a0_0x534994;let _0x462660=a0_0x21938c[_0x460fab(0x1fa)](_0x11d327);const _0x201090=['.git',_0x460fab(0x1bf),_0x460fab(0x19f),_0x460fab(0x153),_0x460fab(0x165),'go.mod',_0x460fab(0x14c),_0x460fab(0x263),_0x460fab(0x211)];while(_0x462660!==a0_0x21938c[_0x460fab(0x207)](_0x462660)){for(const _0x47519a of _0x201090){const _0x46e91d=a0_0x21938c[_0x460fab(0x176)](_0x462660,_0x47519a);try{return await a0_0xc8c656[_0x460fab(0x199)](_0x46e91d),normalizePath(_0x462660);}catch{}}_0x462660=a0_0x21938c[_0x460fab(0x207)](_0x462660);}return normalizePath(_0x11d327);}await Promise[a0_0x534994(0x223)](args[a0_0x534994(0x163)](async _0x38bdfb=>{const _0x5a5205=a0_0x534994;try{const _0xe06816=await a0_0xc8c656[_0x5a5205(0x20c)](expandHome(_0x38bdfb));!_0xe06816[_0x5a5205(0x22c)]()&&(logMcpStderr(_0x5a5205(0x22a)+_0x38bdfb+_0x5a5205(0x17e)),process[_0x5a5205(0x237)](0x1));}catch(_0x3a90ac){logMcpStderr(_0x5a5205(0x1e8)+_0x38bdfb+':',_0x3a90ac),process[_0x5a5205(0x237)](0x1);}}));async function validatePath(_0x479308){const _0x2a71f3=a0_0x534994,_0x474365=expandHome(_0x479308),_0x5cf524=a0_0x21938c[_0x2a71f3(0x1fa)](_0x474365);logger[_0x2a71f3(0x201)](_0x2a71f3(0x17b),_0x2a71f3(0x20f),{'raw_path':_0x479308,'absolute':_0x5cf524});try{const _0x5c36ba=await a0_0xc8c656[_0x2a71f3(0x178)](_0x5cf524);return logger['debug'](_0x2a71f3(0x17b),'path_validation_resolved',{'resolved':_0x5c36ba,'symlink':_0x5c36ba!==_0x5cf524}),_0x5c36ba;}catch(_0x1c9c92){if(_0x1c9c92[_0x2a71f3(0x16e)]===_0x2a71f3(0x1ca)){const _0x4f1489=a0_0x21938c[_0x2a71f3(0x207)](_0x5cf524);try{const _0x191bed=await a0_0xc8c656[_0x2a71f3(0x178)](_0x4f1489),_0x296d00=a0_0x21938c[_0x2a71f3(0x176)](_0x191bed,a0_0x21938c[_0x2a71f3(0x18c)](_0x5cf524));return logger[_0x2a71f3(0x201)](_0x2a71f3(0x17b),'path_validation_resolved',{'resolved':_0x296d00,'new_file':!![]}),_0x296d00;}catch{logger['error'](_0x2a71f3(0x17b),_0x2a71f3(0x25b),{'raw_path':_0x479308,'error':'Parent\x20directory\x20does\x20not\x20exist:\x20'+_0x4f1489});throw new Error(_0x2a71f3(0x234)+_0x4f1489);}}logger[_0x2a71f3(0x1db)](_0x2a71f3(0x17b),_0x2a71f3(0x25b),{'raw_path':_0x479308,'error':_0x1c9c92[_0x2a71f3(0x140)]});throw _0x1c9c92;}}const MorphEditFileArgsSchema=z[a0_0x534994(0x151)]({'path':z[a0_0x534994(0x258)](),'code_edit':z[a0_0x534994(0x258)]()[a0_0x534994(0x1a7)](a0_0x534994(0x1b6)),'instruction':z[a0_0x534994(0x258)]()[a0_0x534994(0x1a7)](a0_0x534994(0x1c4)),'dryRun':z[a0_0x534994(0x212)]()[a0_0x534994(0x249)](![])[a0_0x534994(0x1a7)](a0_0x534994(0x172))}),CODEBASE_SEARCH_QUERY_DESCRIPTION='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.',WarpGrepArgsSchema=z[a0_0x534994(0x151)]({'search_string':z[a0_0x534994(0x258)]()[a0_0x534994(0x1a7)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repo_path':z[a0_0x534994(0x258)]()[a0_0x534994(0x1a7)](a0_0x534994(0x1d3)),'search_type':z['enum']([a0_0x534994(0x249),'node_modules'])[a0_0x534994(0x169)]()['describe']('Search\x20type\x20hint.\x20Use\x20\x27node_modules\x27\x20when\x20searching\x20inside\x20node_modules\x20or\x20other\x20dependency\x20directories\x20that\x20are\x20normally\x20excluded.')}),WarpGrepGitHubArgsSchema=z['object']({'search_string':z[a0_0x534994(0x258)]()[a0_0x534994(0x1a7)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'github_url':z[a0_0x534994(0x258)]()[a0_0x534994(0x169)]()[a0_0x534994(0x1a7)](a0_0x534994(0x267)),'owner_repo':z[a0_0x534994(0x258)]()['optional']()[a0_0x534994(0x1a7)]('Repository\x20owner/repo\x20shorthand\x20(e.g.\x20\x27vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.'),'branch':z[a0_0x534994(0x258)]()['optional']()['describe']('Branch\x20to\x20search\x20(defaults\x20to\x20repo\x27s\x20default\x20branch)')}),CodebaseSearchArgsSchema=z[a0_0x534994(0x151)]({'query':z[a0_0x534994(0x258)]()['describe'](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repoId':z[a0_0x534994(0x258)]()[a0_0x534994(0x1a7)](a0_0x534994(0x1fd)),'branch':z[a0_0x534994(0x258)]()[a0_0x534994(0x169)]()[a0_0x534994(0x1a7)](a0_0x534994(0x246)),'commitHash':z[a0_0x534994(0x258)]()[a0_0x534994(0x169)]()[a0_0x534994(0x1a7)](a0_0x534994(0x1e9)),'targetDirectories':z['array'](z[a0_0x534994(0x258)]())[a0_0x534994(0x249)]([])[a0_0x534994(0x1a7)](a0_0x534994(0x23f)),'limit':z[a0_0x534994(0x15b)]()[a0_0x534994(0x169)]()['default'](0xa)[a0_0x534994(0x1a7)](a0_0x534994(0x22e))}),server=new Server({'name':a0_0x534994(0x17f),'version':a0_0x534994(0x1a5)},{'capabilities':{'tools':{}}});server[a0_0x534994(0x24f)](ListToolsRequestSchema,async()=>{const _0x236d93=a0_0x534994,_0x161732=[{'name':TOOL_NAMES['EDIT_FILE'],'description':_0x236d93(0x143)+'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'+_0x236d93(0x1b7)+_0x236d93(0x181)+_0x236d93(0x1ec)+_0x236d93(0x205)+'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'+'Example\x20format:\x0a'+_0x236d93(0x13f)+_0x236d93(0x1f5)+_0x236d93(0x1eb)+_0x236d93(0x203)+_0x236d93(0x26e)+_0x236d93(0x210),'inputSchema':zodToJsonSchema(MorphEditFileArgsSchema),'requiresApiKey':!![]},{'name':TOOL_NAMES['CODEBASE_SEARCH'],'description':_0x236d93(0x191)+CODEBASE_SEARCH_QUERY_DESCRIPTION+'\x20'+_0x236d93(0x269)+_0x236d93(0x14f)+'','inputSchema':zodToJsonSchema(WarpGrepArgsSchema),'requiresApiKey':!![]},{'name':GITHUB_SEARCH_TOOL_NAME,'description':GITHUB_SEARCH_DESCRIPTION,'inputSchema':zodToJsonSchema(WarpGrepGitHubArgsSchema),'requiresApiKey':!![]}],_0x31d976=_0x161732[_0x236d93(0x24c)](_0x138ceb=>{const _0x15eeed=_0x236d93;if(DISABLED_TOOLS[_0x15eeed(0x18d)](_0x138ceb['name']))return console['error'](_0x15eeed(0x1bd)+_0x138ceb[_0x15eeed(0x1bc)]+_0x15eeed(0x264)),![];if(_0x15eeed(0x1f1)in _0x138ceb&&_0x138ceb[_0x15eeed(0x1f1)]&&!MORPH_API_KEY)return logMcpStderr(_0x15eeed(0x175)+_0x138ceb[_0x15eeed(0x1bc)]+_0x15eeed(0x180)),![];return!![];});return{'tools':_0x31d976['map'](_0x3252d1=>({'name':_0x3252d1[_0x236d93(0x1bc)],'description':_0x3252d1['description'],'inputSchema':_0x3252d1[_0x236d93(0x1fe)]}))};}),server[a0_0x534994(0x24f)](CallToolRequestSchema,async _0x121ff2=>{const _0x37ee59=a0_0x534994,{name:_0x277f27,arguments:_0x38f454}=_0x121ff2['params'],_0x14a1f7=Date['now']();logger['debug'](_0x37ee59(0x17b),_0x37ee59(0x23e),{'tool':_0x277f27,'args':_0x277f27===_0x37ee59(0x1b1)?{'path':_0x38f454?.['path'],'instruction':_0x38f454?.[_0x37ee59(0x1b4)]||_0x38f454?.[_0x37ee59(0x18b)],'dryRun':_0x38f454?.[_0x37ee59(0x192)]}:_0x38f454});try{if(!MORPH_API_KEY)return{'content':[{'type':'text','text':_0x37ee59(0x1c8)}],'isError':!![]};if(!MORPH_API_KEY[_0x37ee59(0x156)](_0x37ee59(0x220))&&!MORPH_API_KEY['startsWith'](_0x37ee59(0x26f)))return{'content':[{'type':'text','text':_0x37ee59(0x1af)}],'isError':!![]};if(DISABLED_TOOLS['has'](_0x277f27))return{'content':[{'type':_0x37ee59(0x1fc),'text':_0x37ee59(0x1b5)+_0x277f27+_0x37ee59(0x25f)}],'isError':![]};switch(_0x277f27){case TOOL_NAMES[_0x37ee59(0x1b8)]:{let _0x2e361a=_0x38f454;if(_0x2e361a&&typeof _0x2e361a==='object'){if(!('path'in _0x2e361a)){const _0x40d146=_0x2e361a[_0x37ee59(0x268)]??_0x2e361a[_0x37ee59(0x1be)]??_0x2e361a[_0x37ee59(0x1c2)]??_0x2e361a[_0x37ee59(0x1c0)]??_0x2e361a[_0x37ee59(0x1e7)];if(_0x40d146)_0x2e361a={..._0x2e361a,'path':_0x40d146};}_0x37ee59(0x18b)in _0x2e361a&&!(_0x37ee59(0x1b4)in _0x2e361a)&&(_0x2e361a={..._0x2e361a,'instruction':_0x2e361a[_0x37ee59(0x18b)]});if(!(_0x37ee59(0x1d8)in _0x2e361a)){const _0x43cb17=_0x2e361a[_0x37ee59(0x16e)]??_0x2e361a[_0x37ee59(0x1f3)]??_0x2e361a[_0x37ee59(0x21a)]??_0x2e361a[_0x37ee59(0x1fb)];if(_0x43cb17)_0x2e361a={..._0x2e361a,'code_edit':_0x43cb17};}}const _0x1f33f0=MorphEditFileArgsSchema[_0x37ee59(0x144)](_0x2e361a);if(!_0x1f33f0[_0x37ee59(0x19b)])throw new Error(_0x37ee59(0x265)+_0x1f33f0[_0x37ee59(0x1db)]);const _0xb7db55=await validatePath(_0x1f33f0[_0x37ee59(0x1f4)][_0x37ee59(0x16d)]);let _0x3c8908=null,_0x39b01a=!![],_0x3b9efa=null;try{_0x3c8908=await a0_0xc8c656[_0x37ee59(0x14b)](_0xb7db55,_0x37ee59(0x1d9)),logger[_0x37ee59(0x201)](_0x37ee59(0x17b),_0x37ee59(0x148),{'path':_0xb7db55,'size_bytes':_0x3c8908[_0x37ee59(0x1d5)]});}catch(_0x22f874){const _0x1d7333=_0x22f874[_0x37ee59(0x16e)];_0x1d7333===_0x37ee59(0x1ca)?(_0x39b01a=![],_0x3c8908='',logger[_0x37ee59(0x201)](_0x37ee59(0x17b),'file_read_complete',{'path':_0xb7db55,'exists':![]})):(_0x3b9efa=_0x37ee59(0x182)+(_0x1d7333||_0x37ee59(0x19a))+_0x37ee59(0x20a)+(_0x22f874 instanceof Error?_0x22f874[_0x37ee59(0x140)]:String(_0x22f874)),logger[_0x37ee59(0x1db)]('MCP','file_read_failed',{'path':_0xb7db55,'error':_0x3b9efa}),logMcpStderr('Warning:\x20'+_0x3b9efa));}let _0x1a105c;try{const _0x492a5c=MORPH_API_KEY;if(!_0x492a5c)throw new Error(_0x37ee59(0x22b));const _0x137f8e=a0_0x21938c[_0x37ee59(0x207)](_0xb7db55),_0x25be7a=a0_0x21938c[_0x37ee59(0x18c)](_0xb7db55);logger[_0x37ee59(0x201)](_0x37ee59(0x17b),_0x37ee59(0x218),{'model':_0x37ee59(0x1e3),'path':_0x1f33f0[_0x37ee59(0x1f4)][_0x37ee59(0x16d)],'instruction_len':_0x1f33f0['data'][_0x37ee59(0x1b4)][_0x37ee59(0x1d5)],'code_edit_len':_0x1f33f0[_0x37ee59(0x1f4)]['code_edit'][_0x37ee59(0x1d5)],'original_code_len':_0x3c8908?.[_0x37ee59(0x1d5)]??0x0,'dry_run':_0x1f33f0[_0x37ee59(0x1f4)][_0x37ee59(0x192)]});const _0x5ef903=Date[_0x37ee59(0x1cc)](),_0x1857f7=await executeEditFile({'target_filepath':_0x25be7a,'code_edit':_0x1f33f0['data'][_0x37ee59(0x1d8)],'instruction':_0x1f33f0[_0x37ee59(0x1f4)]['instruction']},{'morphApiKey':_0x492a5c,'morphApiUrl':MORPH_API_URL,'large':MORPH_LARGE_APPLY,'baseDir':_0x137f8e,'autoWrite':!_0x1f33f0[_0x37ee59(0x1f4)][_0x37ee59(0x192)],'generateUdiff':![],'debug':![]}),_0x314119=Date['now']()-_0x5ef903;_0x1a105c=_0x1857f7['completionId'];if(!_0x1857f7[_0x37ee59(0x19b)])throw new Error(_0x1857f7['error']||'Morph\x20FastApply\x20failed\x20without\x20error\x20message');const _0x432a01=_0x1857f7[_0x37ee59(0x261)],_0xaa8175=_0x37ee59(0x1df)+_0x432a01['linesAdded']+',\x20removed\x20'+_0x432a01[_0x37ee59(0x1b9)]+_0x37ee59(0x196)+_0x432a01[_0x37ee59(0x16c)];logger['debug'](_0x37ee59(0x17b),_0x37ee59(0x1ab),{'tool':'edit_file','success':!![],'latency_ms':Date[_0x37ee59(0x1cc)]()-_0x14a1f7,'edit_latency_ms':_0x314119,'changes':{'added':_0x432a01[_0x37ee59(0x242)],'removed':_0x432a01['linesRemoved'],'modified':_0x432a01[_0x37ee59(0x16c)]},'completion_id':_0x1a105c});if(_0x1f33f0[_0x37ee59(0x1f4)][_0x37ee59(0x192)])return{'content':[{'type':'text','text':'Morph\x20Edit\x20Preview'+(_0x39b01a?'':_0x37ee59(0x1f2))+':\x20'+_0x1f33f0['data']['instruction']+_0x37ee59(0x1f0)+_0xaa8175+_0x37ee59(0x251)+_0x1f33f0[_0x37ee59(0x1f4)]['path']+'.'}]};return{'content':[{'type':_0x37ee59(0x1fc),'text':_0x37ee59(0x25c)+(_0x39b01a?_0x37ee59(0x16f):'Created\x20File')+':\x20'+_0x1f33f0[_0x37ee59(0x1f4)]['instruction']+_0x37ee59(0x1f0)+_0xaa8175+'.\x20Path:\x20'+_0x1f33f0[_0x37ee59(0x1f4)][_0x37ee59(0x16d)]+'.'}]};}catch(_0x553554){const _0x540393=handleMorphAPIError(_0x553554);if(_0x540393)return logger[_0x37ee59(0x1db)](_0x37ee59(0x17b),_0x37ee59(0x24e),{'tool':_0x37ee59(0x1b1),'error':'API\x20error\x20(auth/rate-limit)','latency_ms':Date[_0x37ee59(0x1cc)]()-_0x14a1f7}),_0x540393;const _0x4c8fbd=_0x553554 instanceof Error?_0x553554[_0x37ee59(0x140)]:String(_0x553554);return logger[_0x37ee59(0x1db)](_0x37ee59(0x17b),_0x37ee59(0x24e),{'tool':'edit_file','error':_0x4c8fbd,'path':_0x1f33f0['data'][_0x37ee59(0x16d)],'validated_path':_0xb7db55,'latency_ms':Date[_0x37ee59(0x1cc)]()-_0x14a1f7,'stack':_0x553554 instanceof Error?_0x553554[_0x37ee59(0x235)]:undefined}),reportMorphError({'error_message':_0x4c8fbd,'error_type':_0x553554 instanceof Error?_0x553554[_0x37ee59(0x149)][_0x37ee59(0x1bc)]:_0x37ee59(0x18e),'context':{'tool':'edit_file','completion_id':_0x1a105c,'file_path':_0x1f33f0[_0x37ee59(0x1f4)][_0x37ee59(0x16d)],'validated_path':_0xb7db55,'instruction':_0x1f33f0[_0x37ee59(0x1f4)]['instruction'],'model':MORPH_LARGE_APPLY?_0x37ee59(0x15a):_0x37ee59(0x1e3),'dry_run':_0x1f33f0[_0x37ee59(0x1f4)][_0x37ee59(0x192)],'file_exists':_0x39b01a,'file_read_error':_0x3b9efa,'file_readable':_0x3c8908!==null,'request_content':{'path':_0x1f33f0[_0x37ee59(0x1f4)][_0x37ee59(0x16d)],'code_edit':_0x1f33f0['data'][_0x37ee59(0x1d8)],'instruction':_0x1f33f0[_0x37ee59(0x1f4)]['instruction'],'original_code':_0x3c8908!==null?_0x3c8908[_0x37ee59(0x1d5)]>0xc350?_0x3c8908['substring'](0x0,0xc350)+_0x37ee59(0x25a)+_0x3c8908['length']+'\x20chars)':_0x3c8908:'[could\x20not\x20read\x20file:\x20'+(_0x3b9efa||'unknown\x20error')+']','original_code_length':_0x3c8908?.[_0x37ee59(0x1d5)]??0x0,'model':MORPH_LARGE_APPLY?'morph-v3-large':'morph-v3-fast','dry_run':_0x1f33f0[_0x37ee59(0x1f4)][_0x37ee59(0x192)]}},'stack_trace':_0x553554 instanceof Error?_0x553554[_0x37ee59(0x235)]:undefined,'source':'mcp-filesystem'})[_0x37ee59(0x158)](()=>{}),{'content':[{'type':'text','text':_0x37ee59(0x208)+_0x4c8fbd}],'isError':!![]};}}case TOOL_NAMES['CODEBASE_SEARCH']:{const _0xeb0149=WarpGrepArgsSchema[_0x37ee59(0x144)](_0x38f454);if(!_0xeb0149[_0x37ee59(0x19b)])return{'content':[{'type':_0x37ee59(0x1fc),'text':'Invalid\x20arguments:\x20'+_0xeb0149[_0x37ee59(0x1db)]}],'isError':!![]};const _0x3e1948=_0x4c1041=>{const _0x42aa6=_0x37ee59,_0x2334c3=[];for(const _0x3c561d of _0x4c1041||[]){if(_0x3c561d[_0x42aa6(0x1ae)]===_0x42aa6(0x1f8)&&Array[_0x42aa6(0x21b)](_0x3c561d[_0x42aa6(0x270)]))for(const _0x98cb9f of _0x3c561d[_0x42aa6(0x270)]){try{const _0x475f0c=_0x98cb9f['function']?.[_0x42aa6(0x1bc)],_0x42bd61=JSON[_0x42aa6(0x1dc)](_0x98cb9f[_0x42aa6(0x22d)]?.['arguments']||'{}');if(_0x475f0c===_0x42aa6(0x145))_0x2334c3['push'](_0x42aa6(0x1bb)+_0x42bd61[_0x42aa6(0x193)]+'\x27\x20'+(_0x42bd61[_0x42aa6(0x16d)]||'.'));else{if(_0x475f0c===_0x42aa6(0x19d))_0x2334c3[_0x42aa6(0x213)]('read\x20'+_0x42bd61[_0x42aa6(0x16d)]);else{if(_0x475f0c===_0x42aa6(0x189))_0x2334c3[_0x42aa6(0x213)]('list_directory\x20'+(_0x42bd61[_0x42aa6(0x1d7)]||'.'));else{if(_0x475f0c==='glob')_0x2334c3[_0x42aa6(0x213)](_0x42aa6(0x1a4)+_0x42bd61[_0x42aa6(0x193)]+'\x27\x20'+(_0x42bd61[_0x42aa6(0x16d)]||'.'));else _0x475f0c===_0x42aa6(0x1cf)&&_0x2334c3[_0x42aa6(0x213)](_0x42aa6(0x1cf));}}}}catch{}}}return _0x2334c3;},_0xdb5fba=_0x1d4a00=>{const _0x584067=_0x37ee59,_0x2cdad7=[];if(!_0x1d4a00||!Array['isArray'](_0x1d4a00))return _0x2cdad7;const _0x20dabc=[{'pattern':/\[FILE NOT FOUND\]/,'error_type':_0x584067(0x1d2),'tool':_0x584067(0x19d)},{'pattern':/\[PATH ERROR\]/,'error_type':_0x584067(0x209),'tool':'read'},{'pattern':/\[READ ERROR\]/,'error_type':_0x584067(0x1c6),'tool':_0x584067(0x19d)},{'pattern':/\[UNREADABLE FILE\]/,'error_type':'BinaryFile','tool':_0x584067(0x19d)},{'pattern':/\[RIPGREP ERROR\]/,'error_type':_0x584067(0x1a9),'tool':'grep'},{'pattern':/\[RIPGREP NOT AVAILABLE\]/,'error_type':_0x584067(0x187),'tool':_0x584067(0x159)},{'pattern':/\[BINARY FILE\]/,'error_type':_0x584067(0x21f),'tool':'read'},{'pattern':/\[SYMLINK\]/,'error_type':_0x584067(0x147),'tool':'read'},{'pattern':/not a text file/,'error_type':_0x584067(0x21f),'tool':_0x584067(0x19d)},{'pattern':/symbolic link/,'error_type':_0x584067(0x147),'tool':_0x584067(0x19d)},{'pattern':/Error reading file:/,'error_type':_0x584067(0x1c6),'tool':_0x584067(0x19d)},{'pattern':/status="error"/,'error_type':_0x584067(0x257),'tool':_0x584067(0x19a)}];let _0xdf9d47=0x0;for(const _0x33e548 of _0x1d4a00){_0x33e548[_0x584067(0x1ae)]===_0x584067(0x1f8)&&Array['isArray'](_0x33e548[_0x584067(0x270)])&&_0xdf9d47++;const _0x16c2b0=_0x33e548[_0x584067(0x21a)];if((_0x33e548['role']===_0x584067(0x206)||_0x33e548[_0x584067(0x1ae)]===_0x584067(0x259))&&_0x16c2b0&&typeof _0x16c2b0===_0x584067(0x258))for(const {pattern:_0x5ae0d9,error_type:_0x53ac94,tool:_0x305ce3}of _0x20dabc){const _0x1f8a1c=_0x16c2b0[_0x584067(0x150)](new RegExp(_0x5ae0d9[_0x584067(0x232)],'g'));if(_0x1f8a1c)for(const _0x34f6e2 of _0x1f8a1c){const _0x3ca3d8=_0x16c2b0[_0x584067(0x216)](_0x34f6e2),_0x508f4a=_0x16c2b0[_0x584067(0x24a)](_0x3ca3d8,Math[_0x584067(0x190)](_0x3ca3d8+0xc8,_0x16c2b0[_0x584067(0x1d5)]));_0x2cdad7[_0x584067(0x213)]({'tool':_0x305ce3,'error_type':_0x53ac94,'error_message':_0x508f4a[_0x584067(0x174)]('\x0a')[0x0],'turn':_0xdf9d47});}}}return _0x2cdad7;};try{const _0x11c815=a0_0x21938c[_0x37ee59(0x1fa)](_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1c3)]),_0x280b0d=_0xeb0149['data'][_0x37ee59(0x238)],_0x4f0f47=_0x280b0d===_0x37ee59(0x20b)?{'allowNames':[_0x37ee59(0x20b)]}:undefined,_0x358157=new LocalRipgrepProvider(_0x11c815,undefined,_0x4f0f47);logger[_0x37ee59(0x201)]('MCP',_0x37ee59(0x23d),{'type':_0x37ee59(0x1e4),'repo_root':_0x11c815,'search_type':_0x280b0d||_0x37ee59(0x249)}),logger['debug'](_0x37ee59(0x17b),'warp_grep_start',{'query':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1a6)],'repo_root':_0x11c815,'timeout_ms':MORPH_WARP_GREP_TIMEOUT});const _0x5707d0=Date[_0x37ee59(0x1cc)](),_0x37d84d=await runWarpGrep({'searchTerm':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1a6)],'repoRoot':_0x11c815,'morphApiKey':MORPH_API_KEY,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT,'provider':_0x358157,'search_type':_0x280b0d}),_0x3b2d51=Date[_0x37ee59(0x1cc)]()-_0x5707d0,_0x184584=_0x37d84d['finish']?.[_0x37ee59(0x1ac)]?.['files']?.['length']??0x0;logger[_0x37ee59(0x201)](_0x37ee59(0x17b),'warp_grep_complete',{'termination':_0x37d84d[_0x37ee59(0x1cb)],'turns':_0x37d84d['timings']?.[_0x37ee59(0x222)]??0x0,'files_found':_0x184584,'latency_ms':_0x3b2d51});const _0x36ff2b=_0xdb5fba(_0x37d84d[_0x37ee59(0x14a)]);_0x36ff2b[_0x37ee59(0x1d5)]>0x0&&reportMorphError({'error_message':'WarpGrep\x20sub-tool\x20errors:\x20'+_0x36ff2b['length']+'\x20error(s)','error_type':_0x37ee59(0x26d),'level':_0x37ee59(0x141),'tool':_0x37ee59(0x173),'context':{'repo_path':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1c3)],'query':_0xeb0149['data']['search_string'],'model':'morph-warp-grep-v2.1','termination_reason':_0x37d84d['terminationReason'],'sub_tool_errors':_0x36ff2b,'timings':_0x37d84d[_0x37ee59(0x21c)],'tool_calls':_0x3e1948(_0x37d84d[_0x37ee59(0x14a)]),'messages':_0x37d84d['messages']?.[_0x37ee59(0x163)](_0x1ad4d2=>({'role':_0x1ad4d2[_0x37ee59(0x1ae)],'content':_0x1ad4d2[_0x37ee59(0x21a)],..._0x1ad4d2[_0x37ee59(0x270)]?{'tool_calls':_0x1ad4d2[_0x37ee59(0x270)][_0x37ee59(0x1d5)]}:{},..._0x1ad4d2[_0x37ee59(0x1f6)]?{'tool_call_id':_0x1ad4d2[_0x37ee59(0x1f6)]}:{}}))},'source':_0x37ee59(0x17c)})[_0x37ee59(0x158)](()=>{});let _0x14f891='';if(_0x37d84d[_0x37ee59(0x1cb)]===_0x37ee59(0x13e)&&_0x37d84d[_0x37ee59(0x1cf)]?.[_0x37ee59(0x1ac)]?.[_0x37ee59(0x157)]){const _0x4c2e9f=_0x37d84d[_0x37ee59(0x1cf)][_0x37ee59(0x1ac)][_0x37ee59(0x157)];if(_0x4c2e9f[_0x37ee59(0x1d5)]===0x0)return _0x14f891=_0x37d84d['finish'][_0x37ee59(0x247)]||_0x37ee59(0x1a2),{'content':[{'type':'text','text':_0x14f891}]};const _0x5ebea7=[],_0x9043a5=[_0x37ee59(0x21e)];for(const _0x56df82 of _0x37d84d['messages']){if(_0x56df82[_0x37ee59(0x1ae)]==='assistant'&&Array['isArray'](_0x56df82[_0x37ee59(0x270)]))for(const _0x2fbf22 of _0x56df82[_0x37ee59(0x270)]){try{const _0x4b97ee=_0x2fbf22['function']?.[_0x37ee59(0x1bc)],_0x4b2580=JSON[_0x37ee59(0x1dc)](_0x2fbf22[_0x37ee59(0x22d)]?.[_0x37ee59(0x1a0)]||'{}');if(_0x4b97ee===_0x37ee59(0x145))_0x9043a5[_0x37ee59(0x213)](_0x37ee59(0x204)+_0x4b2580[_0x37ee59(0x193)]+_0x37ee59(0x183)+(_0x4b2580[_0x37ee59(0x16d)]||'.')+'`');else{if(_0x4b97ee===_0x37ee59(0x19d))_0x9043a5['push'](_0x37ee59(0x1ef)+_0x4b2580[_0x37ee59(0x16d)]+'`');else{if(_0x4b97ee===_0x37ee59(0x189))_0x9043a5['push'](_0x37ee59(0x1e5)+(_0x4b2580[_0x37ee59(0x1d7)]||'.')+'`');else _0x4b97ee===_0x37ee59(0x1c7)&&_0x9043a5[_0x37ee59(0x213)](_0x37ee59(0x229)+_0x4b2580[_0x37ee59(0x193)]+'`\x20in\x20`'+(_0x4b2580[_0x37ee59(0x16d)]||'.')+'`');}}}catch{}}}_0x5ebea7[_0x37ee59(0x213)](_0x9043a5[_0x37ee59(0x176)]('\x0a'));const _0x2a01e8=['','Relevant\x20context\x20found:'];for(const _0x15f765 of _0x4c2e9f){if(_0x15f765[_0x37ee59(0x254)]==='*')_0x2a01e8['push']('-\x20'+_0x15f765[_0x37ee59(0x16d)]+':*');else{if(Array['isArray'](_0x15f765[_0x37ee59(0x254)])){const _0x39c32e=_0x15f765[_0x37ee59(0x254)][_0x37ee59(0x163)](([_0x277e26,_0x3a4466])=>{if(_0x277e26===_0x3a4466)return''+_0x277e26;return _0x277e26+'-'+_0x3a4466;});_0x2a01e8['push']('-\x20'+_0x15f765[_0x37ee59(0x16d)]+':'+_0x39c32e[_0x37ee59(0x176)](','));}else _0x2a01e8[_0x37ee59(0x213)]('-\x20'+_0x15f765[_0x37ee59(0x16d)]+':*');}}_0x2a01e8['push'](''),_0x5ebea7[_0x37ee59(0x213)](_0x2a01e8[_0x37ee59(0x176)]('\x0a')),_0x5ebea7[_0x37ee59(0x213)](_0x37ee59(0x25e));const _0x2c734f=[],_0x2dccbe=[];for(const _0xbd2d99 of _0x4c2e9f){let _0x119c87=a0_0x21938c['resolve'](_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1c3)],_0xbd2d99['path']),_0x3b715a=null,_0x47557e=null;try{_0x3b715a=await a0_0xc8c656[_0x37ee59(0x14b)](_0x119c87,{'encoding':_0x37ee59(0x1d9)});}catch(_0x37c19e){const _0x24c015=fixPathRepetition(_0x119c87);if(_0x24c015)try{_0x3b715a=await a0_0xc8c656[_0x37ee59(0x14b)](_0x24c015,{'encoding':_0x37ee59(0x1d9)}),_0x119c87=_0x24c015;}catch{_0x47557e=_0x37c19e instanceof Error?_0x37c19e:new Error(String(_0x37c19e));}else _0x47557e=_0x37c19e instanceof Error?_0x37c19e:new Error(String(_0x37c19e));}if(_0x3b715a!==null){const _0x2bdb00=_0x3b715a[_0x37ee59(0x174)](/\r?\n/),_0x32ef56=[];if(_0xbd2d99[_0x37ee59(0x254)]==='*'||!Array[_0x37ee59(0x21b)](_0xbd2d99[_0x37ee59(0x254)]))for(let _0x56dcf3=0x1;_0x56dcf3<=_0x2bdb00['length'];_0x56dcf3++){const _0xe46ceb=_0x2bdb00[_0x56dcf3-0x1];_0x32ef56[_0x37ee59(0x213)](_0x56dcf3+'|\x20'+_0xe46ceb);}else for(const [_0x275dd9,_0x3104e3]of _0xbd2d99[_0x37ee59(0x254)]){_0x32ef56['length']>0x0&&_0x32ef56['push']('');for(let _0x1d707b=_0x275dd9;_0x1d707b<=_0x3104e3&&_0x1d707b<=_0x2bdb00[_0x37ee59(0x1d5)];_0x1d707b++){const _0x467c12=_0x2bdb00[_0x1d707b-0x1];_0x32ef56[_0x37ee59(0x213)](_0x1d707b+'|\x20'+_0x467c12);}}_0x2dccbe['push']({'path':_0xbd2d99[_0x37ee59(0x16d)],'content':_0x32ef56[_0x37ee59(0x176)]('\x0a')});}else _0x2c734f[_0x37ee59(0x213)](_0x37ee59(0x15d)+_0xbd2d99[_0x37ee59(0x16d)]+_0x37ee59(0x177)+(_0x47557e?.['message']||_0x37ee59(0x202))+_0x37ee59(0x17a));}try{const _0x531133=await compactFileContexts(_0x2dccbe,_0xeb0149['data']['search_string'],MORPH_API_KEY,MORPH_API_URL);for(const _0x58b2a5 of _0x531133){_0x2c734f[_0x37ee59(0x213)](_0x37ee59(0x15d)+_0x58b2a5[_0x37ee59(0x16d)]+'\x22>\x0a'+_0x58b2a5[_0x37ee59(0x21a)]+_0x37ee59(0x17a));}}catch(_0x430110){logger[_0x37ee59(0x141)](_0x37ee59(0x17b),_0x37ee59(0x26a),{'error':_0x430110 instanceof Error?_0x430110[_0x37ee59(0x140)]:String(_0x430110),'files_count':_0x2dccbe[_0x37ee59(0x1d5)]});for(const _0x85ed3a of _0x2dccbe){_0x2c734f[_0x37ee59(0x213)]('<file\x20path=\x22'+_0x85ed3a['path']+_0x37ee59(0x248)+_0x85ed3a[_0x37ee59(0x21a)]+_0x37ee59(0x17a));}}_0x5ebea7[_0x37ee59(0x213)](_0x2c734f['join']('\x0a\x0a')),_0x14f891=_0x5ebea7[_0x37ee59(0x176)]('\x0a');const _0x22c8d2=_0x37d84d[_0x37ee59(0x170)]?.[_0x37ee59(0x24c)](_0x246750=>_0x246750[_0x37ee59(0x140)]?.[_0x37ee59(0x156)](_0x37ee59(0x1f9)))||[];if(_0x22c8d2[_0x37ee59(0x1d5)]>0x0){const _0x408d04=_0x22c8d2[_0x37ee59(0x163)](_0x289724=>_0x289724['message'])[_0x37ee59(0x176)](';\x20');reportMorphError({'error_message':_0x408d04,'error_type':_0x37ee59(0x1d1),'context':{'tool':_0x37ee59(0x173),'repo_path':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1c3)],'query':_0xeb0149['data'][_0x37ee59(0x1a6)],'model':'morph-warp-grep-v2.1','termination_reason':_0x37ee59(0x241),'error_count':_0x22c8d2['length'],'is_timeout':![],'timings':_0x37d84d[_0x37ee59(0x21c)],'files_attempted':_0x4c2e9f[_0x37ee59(0x163)](_0x4ab6d9=>({'path':_0x4ab6d9[_0x37ee59(0x16d)],'lines':_0x4ab6d9[_0x37ee59(0x254)]})),'tool_calls':_0x3e1948(_0x37d84d[_0x37ee59(0x14a)]),'messages':_0x37d84d[_0x37ee59(0x14a)]?.[_0x37ee59(0x163)](_0x279397=>({'role':_0x279397[_0x37ee59(0x1ae)],'content':_0x279397[_0x37ee59(0x21a)],..._0x279397['tool_calls']?{'tool_calls':_0x279397[_0x37ee59(0x270)]['length']}:{},..._0x279397[_0x37ee59(0x1f6)]?{'tool_call_id':_0x279397[_0x37ee59(0x1f6)]}:{}})),'request_content':{'query':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1a6)],'repo_path':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1c3)],'repoRoot':a0_0x21938c[_0x37ee59(0x1fa)](_0xeb0149['data'][_0x37ee59(0x1c3)]),'model':_0x37ee59(0x1ad)}},'source':_0x37ee59(0x17c)})[_0x37ee59(0x158)](()=>{});}}else{if(_0x37d84d['terminationReason']===_0x37ee59(0x1a3)&&_0x37d84d[_0x37ee59(0x170)][_0x37ee59(0x1d5)]>0x0){const _0x58af63=_0x37d84d[_0x37ee59(0x170)]['map'](_0x71f5fa=>_0x71f5fa[_0x37ee59(0x140)])[_0x37ee59(0x176)](';\x20');_0x14f891=_0x37ee59(0x22a)+_0x58af63;const _0x3e3aec=_0x58af63[_0x37ee59(0x233)]()[_0x37ee59(0x1cd)](_0x37ee59(0x18f))||_0x58af63[_0x37ee59(0x233)]()['includes']('timed\x20out')||_0x58af63['toLowerCase']()[_0x37ee59(0x1cd)](_0x37ee59(0x1e0)),_0x3b3f5b=_0x37d84d[_0x37ee59(0x1cf)]?.[_0x37ee59(0x1ac)]?.[_0x37ee59(0x157)],_0x25e32e=_0x37d84d['errors'][0x0];reportMorphError({'error_message':_0x58af63,'error_type':_0x3e3aec?'TimeoutError':_0x25e32e?.[_0x37ee59(0x149)]?.['name']||_0x37ee59(0x219),'context':{'tool':_0x37ee59(0x173),'repo_path':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1c3)],'query':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1a6)],'model':'morph-warp-grep-v2.1','termination_reason':_0x37d84d[_0x37ee59(0x1cb)],'error_count':_0x37d84d[_0x37ee59(0x170)][_0x37ee59(0x1d5)],'is_timeout':_0x3e3aec,'timings':_0x37d84d[_0x37ee59(0x21c)],'files_attempted':_0x3b3f5b?.[_0x37ee59(0x163)](_0x37f094=>({'path':_0x37f094[_0x37ee59(0x16d)],'lines':_0x37f094['lines']})),'tool_calls':_0x3e1948(_0x37d84d[_0x37ee59(0x14a)]),'messages':_0x37d84d[_0x37ee59(0x14a)]?.[_0x37ee59(0x163)](_0x48262d=>({'role':_0x48262d['role'],'content':_0x48262d[_0x37ee59(0x21a)],..._0x48262d[_0x37ee59(0x270)]?{'tool_calls':_0x48262d[_0x37ee59(0x270)][_0x37ee59(0x1d5)]}:{},..._0x48262d['tool_call_id']?{'tool_call_id':_0x48262d[_0x37ee59(0x1f6)]}:{}})),'request_content':{'query':_0xeb0149[_0x37ee59(0x1f4)]['search_string'],'repo_path':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1c3)],'repoRoot':a0_0x21938c['resolve'](_0xeb0149['data'][_0x37ee59(0x1c3)]),'model':_0x37ee59(0x1ad)}},'stack_trace':_0x25e32e?.[_0x37ee59(0x235)]||undefined,'source':'mcp-filesystem'})[_0x37ee59(0x158)](()=>{});}else _0x14f891=_0x37ee59(0x1ea);}return{'content':[{'type':_0x37ee59(0x1fc),'text':_0x14f891}]};}catch(_0x31849c){const _0x5d767c=handleMorphAPIError(_0x31849c);if(_0x5d767c)return logger[_0x37ee59(0x1db)]('MCP','tool_call_error',{'tool':_0x37ee59(0x173),'error':'API\x20error\x20(auth/rate-limit)','latency_ms':Date['now']()-_0x14a1f7}),_0x5d767c;const _0x5df727=_0x31849c instanceof Error?_0x31849c[_0x37ee59(0x140)]:String(_0x31849c);logger[_0x37ee59(0x1db)](_0x37ee59(0x17b),_0x37ee59(0x24e),{'tool':_0x37ee59(0x173),'error':_0x5df727,'repo_path':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1c3)],'query':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1a6)],'latency_ms':Date[_0x37ee59(0x1cc)]()-_0x14a1f7});const _0x2fd42e=_0x5df727[_0x37ee59(0x233)]()[_0x37ee59(0x1cd)]('timeout')||_0x5df727[_0x37ee59(0x233)]()[_0x37ee59(0x1cd)](_0x37ee59(0x230))||_0x5df727[_0x37ee59(0x233)]()['includes'](_0x37ee59(0x1e0))||_0x31849c instanceof Error&&_0x31849c[_0x37ee59(0x1bc)]===_0x37ee59(0x162);return reportMorphError({'error_message':_0x5df727,'error_type':_0x2fd42e?_0x37ee59(0x162):_0x31849c instanceof Error?_0x31849c['constructor'][_0x37ee59(0x1bc)]:'UnknownError','context':{'tool':_0x37ee59(0x173),'repo_path':_0xeb0149[_0x37ee59(0x1f4)]['repo_path'],'query':_0xeb0149[_0x37ee59(0x1f4)][_0x37ee59(0x1a6)],'model':_0x37ee59(0x1ad),'is_timeout':_0x2fd42e,'exception_phase':_0x37ee59(0x197),'request_content':{'query':_0xeb0149['data'][_0x37ee59(0x1a6)],'repo_path':_0xeb0149['data'][_0x37ee59(0x1c3)],'repoRoot':a0_0x21938c[_0x37ee59(0x1fa)](_0xeb0149['data'][_0x37ee59(0x1c3)]),'model':_0x37ee59(0x1ad)}},'stack_trace':_0x31849c instanceof Error?_0x31849c[_0x37ee59(0x235)]:undefined,'source':_0x37ee59(0x17c)})[_0x37ee59(0x158)](()=>{}),{'content':[{'type':'text','text':_0x37ee59(0x22f)+_0x5df727}],'isError':![]};}}case TOOL_NAMES[_0x37ee59(0x1f7)]:{const _0x568773=WarpGrepGitHubArgsSchema[_0x37ee59(0x144)](_0x38f454);if(!_0x568773[_0x37ee59(0x19b)])return{'content':[{'type':_0x37ee59(0x1fc),'text':_0x37ee59(0x1ff)+_0x568773['error']}],'isError':!![]};const _0x4b9b15=_0x568773[_0x37ee59(0x1f4)]['github_url']||_0x568773[_0x37ee59(0x1f4)]['owner_repo'];if(!_0x4b9b15)return{'content':[{'type':_0x37ee59(0x1fc),'text':'Please\x20provide\x20github\x20search\x20url\x20or\x20owner/repo\x20id'}],'isError':!![]};const _0x18e6a1=MORPH_API_KEY;if(!_0x18e6a1)throw new Error(_0x37ee59(0x22b));const _0x44253b=Date[_0x37ee59(0x1cc)]();logger[_0x37ee59(0x201)]('MCP',_0x37ee59(0x1a8),{'identifier':_0x4b9b15,'query':_0x568773['data'][_0x37ee59(0x1a6)],'branch':_0x568773[_0x37ee59(0x1f4)][_0x37ee59(0x164)]});try{const _0xa0b3b0=new WarpGrepClient({'morphApiKey':_0x18e6a1,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT}),_0x4a6bb4=await _0xa0b3b0['searchGitHub']({'searchTerm':_0x568773[_0x37ee59(0x1f4)][_0x37ee59(0x1a6)],'github':_0x4b9b15,'branch':_0x568773['data'][_0x37ee59(0x164)]}),_0x938485=Date['now']()-_0x44253b;logMcpStderr(_0x37ee59(0x200)+_0x938485+_0x37ee59(0x262)+_0x4a6bb4[_0x37ee59(0x19b)]);const _0x12c8fe=formatResult(_0x4a6bb4);return{'content':[{'type':_0x37ee59(0x1fc),'text':_0x12c8fe}]};}catch(_0x4f076d){const _0x566ec5=handleMorphAPIError(_0x4f076d);if(_0x566ec5)return _0x566ec5;const _0x55ccb9=Date[_0x37ee59(0x1cc)]()-_0x44253b,_0x1c45c4=_0x4f076d instanceof Error?_0x4f076d['message']:String(_0x4f076d);return logMcpStderr(_0x37ee59(0x154)+_0x55ccb9+'ms:',_0x1c45c4),reportMorphError({'error_message':_0x1c45c4,'error_type':_0x4f076d instanceof Error?_0x4f076d[_0x37ee59(0x149)][_0x37ee59(0x1bc)]:_0x37ee59(0x18e),'context':{'tool':_0x37ee59(0x1b2),'github_url':_0x4b9b15,'search_string':_0x568773[_0x37ee59(0x1f4)][_0x37ee59(0x1a6)],'branch':_0x568773['data'][_0x37ee59(0x164)]},'stack_trace':_0x4f076d instanceof Error?_0x4f076d[_0x37ee59(0x235)]:undefined,'source':'mcp-filesystem','tool':_0x37ee59(0x1b2),'latency_ms':_0x55ccb9})[_0x37ee59(0x158)](()=>{}),{'content':[{'type':_0x37ee59(0x1fc),'text':_0x37ee59(0x240)+_0x1c45c4}],'isError':![]};}}default:throw new Error(_0x37ee59(0x15c)+_0x277f27);}}catch(_0x417612){const _0x133c42=_0x417612 instanceof Error?_0x417612[_0x37ee59(0x140)]:String(_0x417612);return reportMorphError({'error_message':_0x133c42,'error_type':_0x417612 instanceof Error?_0x417612[_0x37ee59(0x149)][_0x37ee59(0x1bc)]:_0x37ee59(0x18e),'context':{'tool':_0x277f27,'arguments':_0x38f454?JSON[_0x37ee59(0x26b)](_0x38f454)[_0x37ee59(0x24a)](0x0,0x1f4):undefined,'mcp_server_version':'0.2.0'},'stack_trace':_0x417612 instanceof Error?_0x417612[_0x37ee59(0x235)]:undefined,'source':_0x37ee59(0x17c)})[_0x37ee59(0x158)](()=>{}),{'content':[{'type':'text','text':_0x37ee59(0x22a)+_0x133c42}],'isError':!![]};}});async function updateAllowedDirectoriesFromRoots(_0x6fb7d1){const _0x1ee5af=a0_0x534994,_0x5066b3=await getValidRootDirectories(_0x6fb7d1);if(_0x5066b3['length']>0x0)allowedDirectories=[..._0x5066b3],logMcpStderr(_0x1ee5af(0x266)+_0x5066b3[_0x1ee5af(0x1d5)]+_0x1ee5af(0x1de));else{logMcpStderr(_0x1ee5af(0x245));if(ENABLE_WORKSPACE_MODE)try{const _0x5388cb=await detectWorkspaceRoot(WORKSPACE_ROOT);_0x5388cb&&(allowedDirectories=[_0x5388cb],logMcpStderr('Fallback:\x20Using\x20workspace\x20root\x20'+_0x5388cb));}catch(_0x137d73){logMcpStderr(_0x1ee5af(0x231)+_0x137d73);}}}server[a0_0x534994(0x20d)](RootsListChangedNotificationSchema,async()=>{const _0x4496a1=a0_0x534994;try{const _0x43a74a=await server[_0x4496a1(0x152)]();_0x43a74a&&_0x4496a1(0x1b3)in _0x43a74a&&await updateAllowedDirectoriesFromRoots(_0x43a74a[_0x4496a1(0x1b3)]);}catch(_0x41570e){logMcpStderr(_0x4496a1(0x168),_0x41570e instanceof Error?_0x41570e[_0x4496a1(0x140)]:String(_0x41570e));}}),server[a0_0x534994(0x224)]=async()=>{const _0x4ce05d=a0_0x534994,_0x57f200=server[_0x4ce05d(0x1e1)]();if(_0x57f200?.[_0x4ce05d(0x1b3)])try{const _0x88b236=await server['listRoots']();_0x88b236&&_0x4ce05d(0x1b3)in _0x88b236?await updateAllowedDirectoriesFromRoots(_0x88b236['roots']):logMcpStderr(_0x4ce05d(0x243));}catch(_0x381778){logMcpStderr(_0x4ce05d(0x23a),_0x381778 instanceof Error?_0x381778[_0x4ce05d(0x140)]:String(_0x381778));}else{if(allowedDirectories[_0x4ce05d(0x1d5)]>0x0)logMcpStderr(_0x4ce05d(0x228),allowedDirectories);else{if(ENABLE_WORKSPACE_MODE)logMcpStderr('Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20workspace\x20mode');else throw new Error(_0x4ce05d(0x198));}}};async function runServer(){const _0x375adf=a0_0x534994,_0x3cce06=new StdioServerTransport();await server[_0x375adf(0x160)](_0x3cce06),logMcpStderr(_0x375adf(0x161)),allowedDirectories[_0x375adf(0x1d5)]===0x0&&logMcpStderr(_0x375adf(0x17d));}runServer()[a0_0x534994(0x158)](_0x9135b5=>{const _0x3fdd2f=a0_0x534994;logMcpStderr(_0x3fdd2f(0x236),_0x9135b5),process['exit'](0x1);});
|
package/dist/log-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var a1_0x550d5d=a1_0x5440;(function(_0x5cd576,_0x5db88b){var _0x36b925=a1_0x5440,_0x22dd10=_0x5cd576();while(!![]){try{var _0x4637c6=-parseInt(_0x36b925(0x185))/0x1*(-parseInt(_0x36b925(0x172))/0x2)+-parseInt(_0x36b925(0x173))/0x3*(-parseInt(_0x36b925(0x187))/0x4)+parseInt(_0x36b925(0x17d))/0x5*(parseInt(_0x36b925(0x177))/0x6)+-parseInt(_0x36b925(0x176))/0x7*(-parseInt(_0x36b925(0x170))/0x8)+parseInt(_0x36b925(0x17f))/0x9*(parseInt(_0x36b925(0x175))/0xa)+parseInt(_0x36b925(0x189))/0xb*(parseInt(_0x36b925(0x180))/0xc)+-parseInt(_0x36b925(0x183))/0xd*(parseInt(_0x36b925(0x17c))/0xe);if(_0x4637c6===_0x5db88b)break;else _0x22dd10['push'](_0x22dd10['shift']());}catch(_0x15571b){_0x22dd10['push'](_0x22dd10['shift']());}}}(a1_0x7d65,0xaa994));import a1_0x45801a from'os';import{logger}from'./logger.js';function a1_0x5440(_0x1bb317,_0x297360){_0x1bb317=_0x1bb317-0x170;var _0x7d6529=a1_0x7d65();var _0x544029=_0x7d6529[_0x1bb317];return _0x544029;}function a1_0x7d65(){var _0x14f8e9=['platform','10HsXeDf','1741411FyYYwj','6ynlISH','macOS','linux','info','length','52598tRDWxL','6911005TEJrXA','MCP','10456218QtSVYC','96USxaeW','[os=','darwin','18434lgVGcV','Unknown','1HLRhBw','map','12820QtwSLY','win32','1786576JifAxZ','error','40wkAXye','Linux','1115214vpngWP','357oCvliI'];a1_0x7d65=function(){return _0x14f8e9;};return a1_0x7d65();}export function getOperatingSystemType(_0x55c17c=a1_0x45801a[a1_0x550d5d(0x174)]()){var _0x32cc9a=a1_0x550d5d;switch(_0x55c17c){case _0x32cc9a(0x182):return _0x32cc9a(0x178);case _0x32cc9a(0x188):return'Windows';case _0x32cc9a(0x179):return _0x32cc9a(0x171);default:return _0x32cc9a(0x184);}}export function formatMcpLogMessage(_0x36635b,_0x5d4edb=a1_0x45801a[a1_0x550d5d(0x174)]()){var _0x1976ae=a1_0x550d5d;return _0x1976ae(0x181)+getOperatingSystemType(_0x5d4edb)+']\x20'+_0x36635b;}export function logMcpStderr(_0x21c16e,..._0x462c3c){var _0xab9153=a1_0x550d5d;console[_0xab9153(0x18a)](formatMcpLogMessage(_0x21c16e),..._0x462c3c),logger[_0xab9153(0x17a)](_0xab9153(0x17e),_0x21c16e,_0x462c3c[_0xab9153(0x17b)]?{'args':_0x462c3c[_0xab9153(0x186)](_0x597da9=>String(_0x597da9))}:undefined);}
|
package/dist/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a2_0x446065=a2_0x1d7a;function a2_0x6940(){const _0x322518=['12xoijZb','1337861OmgtQZ','658557TcPqGY','debug','toUpperCase','info','stringify','2012772YMadxS','write','_log','isEnabled','6475110DNBkVB','MORPH_LOG_FILE','enable','136TlHAFZ','env','4oOVHWa','1829855sJncln','error','18810704CJMGXU','MORPH_DEBUG','enabled','warn','toISOString','fileStream','1zaqEBP','1876296ixrOif',']\x20['];a2_0x6940=function(){return _0x322518;};return a2_0x6940();}(function(_0x3eba66,_0x4affba){const _0x57bf1a=a2_0x1d7a,_0xe0efa4=_0x3eba66();while(!![]){try{const _0x244e44=-parseInt(_0x57bf1a(0x189))/0x1*(-parseInt(_0x57bf1a(0x18a))/0x2)+-parseInt(_0x57bf1a(0x177))/0x3*(-parseInt(_0x57bf1a(0x180))/0x4)+-parseInt(_0x57bf1a(0x181))/0x5+parseInt(_0x57bf1a(0x18c))/0x6*(-parseInt(_0x57bf1a(0x18d))/0x7)+-parseInt(_0x57bf1a(0x17e))/0x8*(parseInt(_0x57bf1a(0x18e))/0x9)+-parseInt(_0x57bf1a(0x17b))/0xa+parseInt(_0x57bf1a(0x183))/0xb;if(_0x244e44===_0x4affba)break;else _0xe0efa4['push'](_0xe0efa4['shift']());}catch(_0x21fbcf){_0xe0efa4['push'](_0xe0efa4['shift']());}}}(a2_0x6940,0xa5e2b));function a2_0x1d7a(_0x16c316,_0x50ad1b){_0x16c316=_0x16c316-0x177;const _0x69405e=a2_0x6940();let _0x1d7aaf=_0x69405e[_0x16c316];return _0x1d7aaf;}import{createWriteStream}from'fs';class MorphLogger{[a2_0x446065(0x185)];[a2_0x446065(0x188)];constructor(){const _0x5b847f=a2_0x446065;this[_0x5b847f(0x185)]=process[_0x5b847f(0x17f)][_0x5b847f(0x184)]==='1'||!!process['env'][_0x5b847f(0x17c)];const _0x2ba4a9=process['env'][_0x5b847f(0x17c)];this[_0x5b847f(0x188)]=_0x2ba4a9?createWriteStream(_0x2ba4a9,{'flags':'a'}):null;}[a2_0x446065(0x18f)](_0x4b73df,_0x3a8078,_0x43ac4c){const _0x498880=a2_0x446065;this[_0x498880(0x179)](_0x498880(0x18f),_0x4b73df,_0x3a8078,_0x43ac4c);}[a2_0x446065(0x191)](_0x353cd3,_0x240114,_0x36e9ed){const _0x585d4a=a2_0x446065;this[_0x585d4a(0x179)](_0x585d4a(0x191),_0x353cd3,_0x240114,_0x36e9ed);}[a2_0x446065(0x186)](_0x9d0ac4,_0x528433,_0x469876){const _0x55f258=a2_0x446065;this[_0x55f258(0x179)](_0x55f258(0x186),_0x9d0ac4,_0x528433,_0x469876);}[a2_0x446065(0x182)](_0x1e4adc,_0x39c252,_0x56fd98){const _0x4286bb=a2_0x446065;this['_log'](_0x4286bb(0x182),_0x1e4adc,_0x39c252,_0x56fd98);}[a2_0x446065(0x17d)](){const _0x11c006=a2_0x446065;this[_0x11c006(0x185)]=!![];}get[a2_0x446065(0x17a)](){const _0x36a5ff=a2_0x446065;return this[_0x36a5ff(0x185)];}[a2_0x446065(0x179)](_0x1d64b2,_0x1ac1bb,_0x1500ef,_0xb09210){const _0xf3c9a4=a2_0x446065;if(_0x1d64b2!==_0xf3c9a4(0x182)&&!this[_0xf3c9a4(0x185)])return;const _0x4af845=new Date()[_0xf3c9a4(0x187)](),_0x24c254='['+_0x4af845+_0xf3c9a4(0x18b)+_0x1d64b2[_0xf3c9a4(0x190)]()+_0xf3c9a4(0x18b)+_0x1ac1bb+']';console['error'](_0xb09210?_0x24c254+'\x20'+_0x1500ef+'\x20'+JSON[_0xf3c9a4(0x192)](_0xb09210):_0x24c254+'\x20'+_0x1500ef),this[_0xf3c9a4(0x188)]?.[_0xf3c9a4(0x178)](JSON[_0xf3c9a4(0x192)]({'ts':_0x4af845,'level':_0x1d64b2,'component':_0x1ac1bb,'msg':_0x1500ef,..._0xb09210&&{'data':_0xb09210}})+'\x0a');}}export const logger=new MorphLogger();
|
package/dist/path-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0xca6bb0,_0x2cf845){const _0x29c0e1=a3_0x2608,_0x91dd59=_0xca6bb0();while(!![]){try{const _0x4840cc=parseInt(_0x29c0e1(0x1eb))/0x1+parseInt(_0x29c0e1(0x1f3))/0x2+parseInt(_0x29c0e1(0x1ee))/0x3+parseInt(_0x29c0e1(0x1f4))/0x4+parseInt(_0x29c0e1(0x1f9))/0x5*(parseInt(_0x29c0e1(0x1f2))/0x6)+-parseInt(_0x29c0e1(0x1fa))/0x7*(parseInt(_0x29c0e1(0x1f8))/0x8)+-parseInt(_0x29c0e1(0x1ed))/0x9;if(_0x4840cc===_0x2cf845)break;else _0x91dd59['push'](_0x91dd59['shift']());}catch(_0xb8343b){_0x91dd59['push'](_0x91dd59['shift']());}}}(a3_0x1b63,0x3e2b4));import a3_0x2e7db0 from'path';import a3_0x1f5206 from'os';export function convertToWindowsPath(_0x3a7b05){const _0x24064e=a3_0x2608;if(_0x3a7b05[_0x24064e(0x1f1)](_0x24064e(0x1f0))){const _0x204cdf=_0x3a7b05['charAt'](0x5)[_0x24064e(0x1fb)](),_0x461bdf=_0x3a7b05[_0x24064e(0x1ef)](0x6)[_0x24064e(0x1f5)](/\//g,'\x5c');return _0x204cdf+':'+_0x461bdf;}if(_0x3a7b05['match'](/^\/[a-zA-Z]\//)){const _0x3e2a1c=_0x3a7b05[_0x24064e(0x1f6)](0x1)['toUpperCase'](),_0xb4d157=_0x3a7b05['slice'](0x2)[_0x24064e(0x1f5)](/\//g,'\x5c');return _0x3e2a1c+':'+_0xb4d157;}if(_0x3a7b05['match'](/^[a-zA-Z]:/))return _0x3a7b05[_0x24064e(0x1f5)](/\//g,'\x5c');return _0x3a7b05;}export function normalizePath(_0x4f89b8){const _0x2e4cae=a3_0x2608;_0x4f89b8=_0x4f89b8[_0x2e4cae(0x1ea)]()[_0x2e4cae(0x1f5)](/^["']|["']$/g,'');const _0x5bf0f7=_0x4f89b8[_0x2e4cae(0x1f1)]('/')&&!_0x4f89b8[_0x2e4cae(0x1f7)](/^\/mnt\/[a-z]\//i)&&!_0x4f89b8[_0x2e4cae(0x1f7)](/^\/[a-zA-Z]\//);if(_0x5bf0f7)return _0x4f89b8[_0x2e4cae(0x1f5)](/\/+/g,'/')[_0x2e4cae(0x1f5)](/\/+$/,'');_0x4f89b8=convertToWindowsPath(_0x4f89b8);if(_0x4f89b8['startsWith']('\x5c\x5c')){let _0x4842d5=_0x4f89b8;_0x4842d5=_0x4842d5[_0x2e4cae(0x1f5)](/^\\{2,}/,'\x5c\x5c');const _0x36fd58=_0x4842d5[_0x2e4cae(0x1fd)](0x2)[_0x2e4cae(0x1f5)](/\\\\/g,'\x5c');_0x4f89b8='\x5c\x5c'+_0x36fd58;}else _0x4f89b8=_0x4f89b8['replace'](/\\\\/g,'\x5c');let _0x584131=a3_0x2e7db0[_0x2e4cae(0x1ec)](_0x4f89b8);_0x4f89b8[_0x2e4cae(0x1f1)]('\x5c\x5c')&&!_0x584131[_0x2e4cae(0x1f1)]('\x5c\x5c')&&(_0x584131='\x5c'+_0x584131);if(_0x584131['match'](/^[a-zA-Z]:/)){let _0x3892f3=_0x584131[_0x2e4cae(0x1f5)](/\//g,'\x5c');return/^[a-z]:/['test'](_0x3892f3)&&(_0x3892f3=_0x3892f3[_0x2e4cae(0x1f6)](0x0)[_0x2e4cae(0x1fb)]()+_0x3892f3[_0x2e4cae(0x1ef)](0x1)),_0x3892f3;}return _0x584131['replace'](/\//g,'\x5c');}function a3_0x1b63(){const _0x326156=['571455OEHrBM','slice','/mnt/','startsWith','6dkkeDz','72190gyeckd','441260DLzEIj','replace','charAt','match','4052856wGSFVv','2448065KbLfwS','7wHMhEX','toUpperCase','homedir','substring','trim','231941yoxgyy','normalize','2674782bLuxoZ'];a3_0x1b63=function(){return _0x326156;};return a3_0x1b63();}function a3_0x2608(_0x11a11,_0x18ff81){_0x11a11=_0x11a11-0x1ea;const _0x1b6303=a3_0x1b63();let _0x260863=_0x1b6303[_0x11a11];return _0x260863;}export function expandHome(_0x701fe2){const _0x5d6406=a3_0x2608;if(_0x701fe2['startsWith']('~/')||_0x701fe2==='~')return a3_0x2e7db0['join'](a3_0x1f5206[_0x5d6406(0x1fc)](),_0x701fe2['slice'](0x1));return _0x701fe2;}
|
package/dist/path-validation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x196f78,_0xdaba07){const _0x44889f=a4_0x4699,_0x491e0a=_0x196f78();while(!![]){try{const _0x532da5=-parseInt(_0x44889f(0x18b))/0x1*(-parseInt(_0x44889f(0x18c))/0x2)+parseInt(_0x44889f(0x187))/0x3*(-parseInt(_0x44889f(0x186))/0x4)+parseInt(_0x44889f(0x190))/0x5*(-parseInt(_0x44889f(0x193))/0x6)+-parseInt(_0x44889f(0x194))/0x7+parseInt(_0x44889f(0x17e))/0x8+parseInt(_0x44889f(0x18d))/0x9*(-parseInt(_0x44889f(0x188))/0xa)+-parseInt(_0x44889f(0x17f))/0xb*(-parseInt(_0x44889f(0x182))/0xc);if(_0x532da5===_0xdaba07)break;else _0x491e0a['push'](_0x491e0a['shift']());}catch(_0x16d5a5){_0x491e0a['push'](_0x491e0a['shift']());}}}(a4_0x50cd,0xe7f02));function a4_0x50cd(){const _0x1957a6=['5iHNsIU','resolve','Path\x20must\x20be\x20absolute\x20after\x20normalization','1881918ctEhCe','12422928iDBRFE','some','13234792HjZEwq','143fvkbWB','includes','normalize','3610428gWzHqy','isAbsolute','string','sep','3331920JchOcT','6BidiZT','28790ErgPIN','Allowed\x20directories\x20must\x20be\x20absolute\x20paths\x20after\x20normalization','startsWith','13chcUzl','112870UkchXA','4986nROPuH','isArray','length'];a4_0x50cd=function(){return _0x1957a6;};return a4_0x50cd();}function a4_0x4699(_0x533bb3,_0x15522d){_0x533bb3=_0x533bb3-0x17e;const _0x50cd72=a4_0x50cd();let _0x469995=_0x50cd72[_0x533bb3];return _0x469995;}import a4_0x564c6d from'path';export function isPathWithinAllowedDirectories(_0x4fea0c,_0x1c7119){const _0x4da915=a4_0x4699;if(typeof _0x4fea0c!=='string'||!Array[_0x4da915(0x18e)](_0x1c7119))return![];if(!_0x4fea0c||_0x1c7119[_0x4da915(0x18f)]===0x0)return![];if(_0x4fea0c[_0x4da915(0x180)]('\x00'))return![];let _0x2ca986;try{_0x2ca986=a4_0x564c6d[_0x4da915(0x191)](a4_0x564c6d['normalize'](_0x4fea0c));}catch{return![];}if(!a4_0x564c6d[_0x4da915(0x183)](_0x2ca986))throw new Error(_0x4da915(0x192));return _0x1c7119[_0x4da915(0x195)](_0x3f3dfd=>{const _0x2530c6=_0x4da915;if(typeof _0x3f3dfd!==_0x2530c6(0x184)||!_0x3f3dfd)return![];if(_0x3f3dfd['includes']('\x00'))return![];let _0x2ef141;try{_0x2ef141=a4_0x564c6d[_0x2530c6(0x191)](a4_0x564c6d[_0x2530c6(0x181)](_0x3f3dfd));}catch{return![];}if(!a4_0x564c6d[_0x2530c6(0x183)](_0x2ef141))throw new Error(_0x2530c6(0x189));if(_0x2ca986===_0x2ef141)return!![];if(_0x2ef141===a4_0x564c6d['sep'])return _0x2ca986['startsWith'](a4_0x564c6d['sep']);return _0x2ca986[_0x2530c6(0x18a)](_0x2ef141+a4_0x564c6d[_0x2530c6(0x185)]);});}
|
package/dist/roots-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a5_0x4b3f(_0x5aa376,_0x5a1d7f){_0x5aa376=_0x5aa376-0xbb;const _0x304c1d=a5_0x304c();let _0x4b3f96=_0x304c1d[_0x5aa376];return _0x4b3f96;}(function(_0x14f8ea,_0x337a74){const _0x568150=a5_0x4b3f,_0x3e735b=_0x14f8ea();while(!![]){try{const _0x5ad377=-parseInt(_0x568150(0xcb))/0x1*(-parseInt(_0x568150(0xc0))/0x2)+-parseInt(_0x568150(0xd1))/0x3*(parseInt(_0x568150(0xc7))/0x4)+parseInt(_0x568150(0xca))/0x5+parseInt(_0x568150(0xc8))/0x6*(-parseInt(_0x568150(0xbb))/0x7)+parseInt(_0x568150(0xc5))/0x8+-parseInt(_0x568150(0xbd))/0x9*(-parseInt(_0x568150(0xbe))/0xa)+parseInt(_0x568150(0xbc))/0xb;if(_0x5ad377===_0x337a74)break;else _0x3e735b['push'](_0x3e735b['shift']());}catch(_0x31713a){_0x3e735b['push'](_0x3e735b['shift']());}}}(a5_0x304c,0x66753));import{promises as a5_0x10e913}from'fs';import a5_0x7e6e29 from'path';import a5_0x287a48 from'os';import{normalizePath}from'./path-utils.js';import{logMcpStderr}from'./log-utils.js';async function parseRootUri(_0x38794c){const _0xce2a11=a5_0x4b3f;try{const _0x307d02=_0x38794c[_0xce2a11(0xc4)](_0xce2a11(0xce))?_0x38794c[_0xce2a11(0xc9)](0x7):_0x38794c,_0x191ef7=_0x307d02[_0xce2a11(0xc4)]('~/')||_0x307d02==='~'?a5_0x7e6e29[_0xce2a11(0xc2)](a5_0x287a48[_0xce2a11(0xcf)](),_0x307d02[_0xce2a11(0xc9)](0x1)):_0x307d02,_0x55d8d3=a5_0x7e6e29['resolve'](_0x191ef7),_0x22945f=await a5_0x10e913[_0xce2a11(0xc3)](_0x55d8d3);return normalizePath(_0x22945f);}catch{return null;}}function formatDirectoryError(_0x1b9c75,_0x52e0b8,_0x127e17){const _0x3fc78b=a5_0x4b3f;if(_0x127e17)return _0x3fc78b(0xcc)+_0x127e17+':\x20'+_0x1b9c75;const _0x291129=_0x52e0b8 instanceof Error?_0x52e0b8[_0x3fc78b(0xd0)]:String(_0x52e0b8);return'Skipping\x20invalid\x20directory:\x20'+_0x1b9c75+_0x3fc78b(0xcd)+_0x291129;}function a5_0x304c(){const _0x4d7f3f=['join','realpath','startsWith','4731344baAQeG','isDirectory','6076gTQYTl','48gohqma','slice','717445TDcsse','2KaUpNc','Skipping\x20','\x20due\x20to\x20error:\x20','file://','homedir','message','1542ovrEdt','422002xSKnVu','1355200klNeJu','117BswEBM','591880FmRFRI','invalid\x20path\x20or\x20inaccessible','55170NcEtAm','uri'];a5_0x304c=function(){return _0x4d7f3f;};return a5_0x304c();}export async function getValidRootDirectories(_0x2bbad5){const _0x14b44d=a5_0x4b3f,_0x31b3c5=[];for(const _0x56b449 of _0x2bbad5){const _0x62efe4=await parseRootUri(_0x56b449['uri']);if(!_0x62efe4){logMcpStderr(formatDirectoryError(_0x56b449[_0x14b44d(0xc1)],undefined,_0x14b44d(0xbf)));continue;}try{const _0x3b9747=await a5_0x10e913['stat'](_0x62efe4);_0x3b9747[_0x14b44d(0xc6)]()?_0x31b3c5['push'](_0x62efe4):logMcpStderr(formatDirectoryError(_0x62efe4,undefined,'non-directory\x20root'));}catch(_0x32a328){logMcpStderr(formatDirectoryError(_0x62efe4,_0x32a328));}}return _0x31b3c5;}
|
package/dist/tool-definitions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a6_0x2a7d(){const _0x3bc306=['codebase_search','33885YaBuyR','1868132LqmvPy','4549872KavAoi','1193670WSXlTb','425378QXmDou','3230872lcGwgw','edit_file','7002648pGQxdV','5mhcxTq','1wYIzDE','24GjNoYi'];a6_0x2a7d=function(){return _0x3bc306;};return a6_0x2a7d();}const a6_0x5b1655=a6_0x2cdc;function a6_0x2cdc(_0x901789,_0x44ac7d){_0x901789=_0x901789-0x130;const _0x2a7d2d=a6_0x2a7d();let _0x2cdce2=_0x2a7d2d[_0x901789];return _0x2cdce2;}(function(_0xc1385e,_0x17cc34){const _0xddc234=a6_0x2cdc,_0x59a550=_0xc1385e();while(!![]){try{const _0x2e01d2=-parseInt(_0xddc234(0x13a))/0x1*(-parseInt(_0xddc234(0x135))/0x2)+parseInt(_0xddc234(0x131))/0x3*(parseInt(_0xddc234(0x13b))/0x4)+-parseInt(_0xddc234(0x139))/0x5*(-parseInt(_0xddc234(0x133))/0x6)+-parseInt(_0xddc234(0x132))/0x7+parseInt(_0xddc234(0x136))/0x8+-parseInt(_0xddc234(0x138))/0x9+parseInt(_0xddc234(0x134))/0xa;if(_0x2e01d2===_0x17cc34)break;else _0x59a550['push'](_0x59a550['shift']());}catch(_0x18005a){_0x59a550['push'](_0x59a550['shift']());}}}(a6_0x2a7d,0x7e3b9));export const TOOL_NAMES={'EDIT_FILE':a6_0x5b1655(0x137),'CODEBASE_SEARCH':a6_0x5b1655(0x130),'GITHUB_CODEBASE_SEARCH':'github_codebase_search'};export const ALL_TOOL_NAMES=Object['values'](TOOL_NAMES);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.201",
|
|
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.189",
|
|
39
39
|
"@vscode/ripgrep": "^1.15.14",
|
|
40
40
|
"axios": "^1.6.0",
|
|
41
41
|
"chalk": "^5.3.0",
|