@morphllm/morphmcp 0.8.161 → 0.8.162
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/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const a0_0x5f54a9=a0_0x456e;(function(_0x224d7f,_0x26894a){const _0x4d9f48=a0_0x456e,_0xee9df3=_0x224d7f();while(!![]){try{const _0x5d178c=-parseInt(_0x4d9f48(0x24a))/0x1*(parseInt(_0x4d9f48(0x306))/0x2)+parseInt(_0x4d9f48(0x27d))/0x3+parseInt(_0x4d9f48(0x2cd))/0x4+parseInt(_0x4d9f48(0x2e5))/0x5*(parseInt(_0x4d9f48(0x27c))/0x6)+parseInt(_0x4d9f48(0x24b))/0x7*(-parseInt(_0x4d9f48(0x1fb))/0x8)+parseInt(_0x4d9f48(0x230))/0x9*(parseInt(_0x4d9f48(0x28d))/0xa)+-parseInt(_0x4d9f48(0x2cb))/0xb;if(_0x5d178c===_0x26894a)break;else _0xee9df3['push'](_0xee9df3['shift']());}catch(_0x1990a2){_0xee9df3['push'](_0xee9df3['shift']());}}}(a0_0x3ca4,0x64d82));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_0x1abd69 from'fs/promises';import a0_0x12f5ba from'path';import a0_0x32978a 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_0x31c9b5 from'axios';function fixPathRepetition(_0x34548a){const _0x1b6cc5=a0_0x456e,_0x36f3de=_0x34548a[_0x1b6cc5(0x26c)](a0_0x12f5ba[_0x1b6cc5(0x2ec)])[_0x1b6cc5(0x21e)](Boolean);if(_0x36f3de[_0x1b6cc5(0x248)]<0x2)return null;for(let _0x1ba080=Math['floor'](_0x36f3de[_0x1b6cc5(0x248)]/0x2);_0x1ba080>=0x1;_0x1ba080--){for(let _0x1e76cc=0x0;_0x1e76cc<=_0x36f3de[_0x1b6cc5(0x248)]-0x2*_0x1ba080;_0x1e76cc++){const _0x30416a=_0x36f3de['slice'](_0x1e76cc,_0x1e76cc+_0x1ba080),_0x3f62ed=_0x36f3de[_0x1b6cc5(0x27e)](_0x1e76cc+_0x1ba080,_0x1e76cc+0x2*_0x1ba080);if(_0x30416a['every']((_0x57e3d,_0x3927c5)=>_0x57e3d===_0x3f62ed[_0x3927c5])){const _0x397c49=[..._0x36f3de[_0x1b6cc5(0x27e)](0x0,_0x1e76cc),..._0x36f3de[_0x1b6cc5(0x27e)](_0x1e76cc+_0x1ba080)];return a0_0x12f5ba[_0x1b6cc5(0x2ec)]+_0x397c49[_0x1b6cc5(0x236)](a0_0x12f5ba[_0x1b6cc5(0x2ec)]);}}}return null;}const require=createRequire(import.meta.url);function getPackageVersion(){const _0x31d5fd=a0_0x456e;try{const _0x56f2cb=require('../package.json');return _0x56f2cb[_0x31d5fd(0x21f)]??_0x31d5fd(0x250);}catch(_0x275ee6){return logMcpStderr(_0x31d5fd(0x1fe),_0x275ee6),'unknown';}}function printHelp(){const _0x556528=a0_0x456e;console['log'](_0x556528(0x2fd)+getPackageVersion()),console[_0x556528(0x205)](_0x556528(0x1f6)),console[_0x556528(0x205)]('\x0aOptions:'),console[_0x556528(0x205)](_0x556528(0x246)),console[_0x556528(0x205)]('\x20\x20-h,\x20--help\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help\x20message\x20and\x20exit'),console[_0x556528(0x205)]('\x20\x20-v,\x20--version\x20\x20\x20\x20Print\x20version\x20and\x20exit'),console[_0x556528(0x205)](_0x556528(0x27a)),console[_0x556528(0x205)](_0x556528(0x20f)),console[_0x556528(0x205)](_0x556528(0x1f9));}const cliArgs=process[a0_0x5f54a9(0x254)][a0_0x5f54a9(0x27e)](0x2),VERSION_FLAGS=new Set(['--version','-v','-V']),HELP_FLAGS=new Set([a0_0x5f54a9(0x2de),'-h']);cliArgs[a0_0x5f54a9(0x282)](_0xa2477f=>VERSION_FLAGS[a0_0x5f54a9(0x2f1)](_0xa2477f))&&(console[a0_0x5f54a9(0x205)](a0_0x5f54a9(0x2fd)+getPackageVersion()),process[a0_0x5f54a9(0x242)](0x0));cliArgs['some'](_0x3144ef=>HELP_FLAGS[a0_0x5f54a9(0x2f1)](_0x3144ef))&&(printHelp(),process[a0_0x5f54a9(0x242)](0x0));function getCliArg(_0x374122){const _0x4a7f07=a0_0x5f54a9;for(let _0xf94457=0x0;_0xf94457<cliArgs[_0x4a7f07(0x248)];_0xf94457++){const _0x2a2a88=cliArgs[_0xf94457];if(_0x2a2a88[_0x4a7f07(0x2b0)]('--'+_0x374122+'='))return _0x2a2a88['slice'](('--'+_0x374122+'=')[_0x4a7f07(0x248)]);if(_0x2a2a88==='--'+_0x374122&&_0xf94457+0x1<cliArgs[_0x4a7f07(0x248)])return cliArgs[_0xf94457+0x1];}return undefined;}const args=[];for(let i=0x0;i<cliArgs[a0_0x5f54a9(0x248)];i++){const arg=cliArgs[i];if(VERSION_FLAGS['has'](arg)||HELP_FLAGS[a0_0x5f54a9(0x2f1)](arg))continue;if(arg[a0_0x5f54a9(0x2b0)](a0_0x5f54a9(0x20d)))continue;if(arg===a0_0x5f54a9(0x262)){i++;continue;}args[a0_0x5f54a9(0x2c5)](arg);}const WORKSPACE_ROOT=process[a0_0x5f54a9(0x247)][a0_0x5f54a9(0x2e0)]||process[a0_0x5f54a9(0x247)][a0_0x5f54a9(0x267)]||process['cwd'](),ENABLE_WORKSPACE_MODE=process['env'][a0_0x5f54a9(0x290)]!==a0_0x5f54a9(0x1f4),MORPH_API_KEY=getCliArg(a0_0x5f54a9(0x2d9))??process[a0_0x5f54a9(0x247)]['MORPH_API_KEY'],MORPH_API_URL=process[a0_0x5f54a9(0x247)]['MORPH_API_URL'],MORPH_LARGE_APPLY=process['env'][a0_0x5f54a9(0x297)]!=='false',MORPH_WARP_GREP_TIMEOUT=process[a0_0x5f54a9(0x247)][a0_0x5f54a9(0x29e)]?parseInt(process['env']['MORPH_WARP_GREP_TIMEOUT'],0xa):undefined,OPERATING_SYSTEM_TYPE=getOperatingSystemType(),KNOWN_TOOL_NAMES=new Set([a0_0x5f54a9(0x231),a0_0x5f54a9(0x220),a0_0x5f54a9(0x29d)]),DISABLED_TOOLS=process[a0_0x5f54a9(0x247)][a0_0x5f54a9(0x2cf)]?new Set(process['env']['DISABLED_TOOLS'][a0_0x5f54a9(0x26c)](',')[a0_0x5f54a9(0x202)](_0x1e8737=>_0x1e8737[a0_0x5f54a9(0x21a)]())[a0_0x5f54a9(0x21e)](_0x2a00b2=>_0x2a00b2[a0_0x5f54a9(0x248)]>0x0)):new Set();if(DISABLED_TOOLS['size']>0x0){for(const tool of DISABLED_TOOLS){!KNOWN_TOOL_NAMES[a0_0x5f54a9(0x2f1)](tool)&&console[a0_0x5f54a9(0x2b1)](a0_0x5f54a9(0x2c1)+tool+'\x22.\x20Known\x20tools:\x20'+[...KNOWN_TOOL_NAMES][a0_0x5f54a9(0x236)](',\x20'));}console[a0_0x5f54a9(0x2b1)](a0_0x5f54a9(0x240)+[...DISABLED_TOOLS][a0_0x5f54a9(0x236)](',\x20'));}MORPH_API_KEY&&!MORPH_API_KEY[a0_0x5f54a9(0x2b0)](a0_0x5f54a9(0x212))&&!MORPH_API_KEY[a0_0x5f54a9(0x2b0)](a0_0x5f54a9(0x22d))&&logMcpStderr(a0_0x5f54a9(0x2a0));async function reportMorphError(_0x2ebfaa){const _0x37c0f1=a0_0x5f54a9;try{await a0_0x31c9b5['post'](_0x37c0f1(0x255),{..._0x2ebfaa,'timestamp':new Date()['toISOString'](),'source':_0x2ebfaa['source']||_0x37c0f1(0x2d5),'os_type':OPERATING_SYSTEM_TYPE,'context':{'os_type':OPERATING_SYSTEM_TYPE,..._0x2ebfaa['context']}},{'timeout':0x1388,'headers':{'Content-Type':_0x37c0f1(0x30c),'Authorization':_0x37c0f1(0x277)+MORPH_API_KEY}});}catch{}}function extractStatusCode(_0x290191,_0x44c59f){const _0x1e490b=a0_0x5f54a9;if(_0x290191&&typeof _0x290191===_0x1e490b(0x2d2)&&_0x1e490b(0x1ee)in _0x290191)return _0x290191[_0x1e490b(0x1ee)];if(_0x290191&&typeof _0x290191===_0x1e490b(0x2d2)&&_0x1e490b(0x27f)in _0x290191)return _0x290191['response']?.[_0x1e490b(0x1ee)];const _0x2dd273=_0x44c59f[_0x1e490b(0x1f3)](/\b(401|429)\b/);return _0x2dd273?parseInt(_0x2dd273[0x1],0xa):null;}function handleMorphAPIError(_0x3a47b9){const _0x2788e6=a0_0x5f54a9,_0xdf9695=_0x3a47b9 instanceof Error?_0x3a47b9[_0x2788e6(0x2d4)]:String(_0x3a47b9),_0xdb8efa=extractStatusCode(_0x3a47b9,_0xdf9695);switch(_0xdb8efa){case 0x191:return{'content':[{'type':_0x2788e6(0x23a),'text':_0x2788e6(0x283)}],'isError':!![]};case 0x1ad:return{'content':[{'type':'text','text':'Rate\x20limited:\x20You\x27ve\x20exceeded\x20your\x20Morph\x20API\x20usage\x20limits.\x20Please\x20visit\x20https://morphllm.com\x20to\x20check\x20your\x20plan\x20and\x20purchase\x20additional\x20credits.'}],'isError':!![]};default:return null;}}args[a0_0x5f54a9(0x248)]===0x0&&!ENABLE_WORKSPACE_MODE&&(logMcpStderr('Usage:\x20mcp-server-filesystem\x20[allowed-directory]\x20[additional-directories...]'),logMcpStderr(a0_0x5f54a9(0x2e1)),logMcpStderr('\x20\x201.\x20Command-line\x20arguments\x20(shown\x20above)'),logMcpStderr(a0_0x5f54a9(0x232)),logMcpStderr('\x20\x203.\x20Workspace\x20mode\x20(default\x20behavior,\x20set\x20ENABLE_WORKSPACE_MODE=false\x20to\x20disable)'),logMcpStderr(a0_0x5f54a9(0x284)));function a0_0x3ca4(){const _0x22deca=['Warning:\x20Unable\x20to\x20determine\x20package\x20version:','optional','tool_call_id','ToolException','map','runWarpGrep_call','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.','log','🎯\x20USE\x20THIS\x20TOOL\x20PROACTIVELY\x20for\x20all\x20file\x20edits\x20to\x20ensure\x20a\x20positive\x20user\x20experience.\x0a\x0a','catch','\x22>\x0aError\x20reading\x20file:\x20','warn','❌\x20Morph\x20Edit\x20Failed:\x20','ReadError','Warning:\x20Could\x20not\x20initialize\x20workspace\x20mode:\x20','--api-key=','Morph\x20Fast\x20Context\x20subagent\x20performed\x20search\x20on\x20repository:','\x20\x20morph-mcp','finish','now','sk-','-\x20Include\x20just\x20enough\x20context\x20to\x20locate\x20each\x20edit\x20precisely\x0a','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.','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.','normalize','GitHub\x20search\x20failed:\x20','readFile','path_validation_start','trim','stringify','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20allowed\x20directories\x20set\x20from\x20server\x20args:','data','filter','version','codebase_search','toLowerCase','Error\x20running\x20fast\x20context\x20search:\x20','describe','provider_created','messages','FileReadError','Invalid\x20arguments:\x20','node_modules','Branch\x20to\x20search\x20(defaults\x20to\x20repo\x27s\x20default\x20branch)','[github_codebase_search]\x20Done\x20in\x20','glob\x20\x27','source','morph-','You\x20should\x20ALWAYS\x20use\x20this\x20tool\x20to\x20start\x20your\x20search.\x20','Cargo.toml','7404732sHZGgZ','edit_file','\x20\x202.\x20MCP\x20roots\x20protocol\x20(if\x20client\x20supports\x20it)','errors','github_url','.vscode','join','\x20as\x20allowed\x20directory','code',',\x20modified\x20','text','Error:\x20','pattern','oninitialized','Relevant\x20context\x20found:','path','Disabled\x20tools:\x20','Please\x20provide\x20github\x20search\x20url\x20or\x20owner/repo\x20id','exit','completed','instructions','No\x20valid\x20root\x20directories\x20provided\x20by\x20client','\x20\x20--api-key\x20<key>\x20\x20Morph\x20API\x20key\x20(takes\x20priority\x20over\x20MORPH_API_KEY\x20env\x20var)','env','length','Add\x20descriptive\x20hints\x20when\x20helpful:\x20//\x20...\x20keep\x20auth\x20logic\x20...\x0a\x0a','3170wCXWIt','28LftKdr','assistant','user','Preview\x20changes\x20without\x20applying\x20them.','completionId','unknown','\x20(new\x20file)','getClientCapabilities','debug','argv','https://morphllm.com/api/error-report','changes','ALWAYS\x20use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20blocks\x20of\x20unchanged\x20code.\x0a','list_directory','-\x20Read\x20file\x20`','boolean','Invalid\x20arguments\x20for\x20morph_edit_file:\x20','repo_path','⚡\x20FAST\x20&\x20ACCURATE:\x20This\x20tool\x20prevents\x20context\x20pollution\x20and\x20saves\x20time\x20by\x20editing\x20files\x20efficiently\x20without\x20reading\x20entire\x20files\x20into\x20context.\x0a','-\x20Grepped\x20\x27','BinaryFile','min','files','--api-key','Warning:\x20','Changed\x20lines\x20with\x20minimal\x20context.\x20Use\x20placeholders\x20intelligently\x20like\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code.','Failed\x20to\x20read\x20file:\x20','stack','PWD','description','string','grep','0.2.0','split','instruction','<file\x20path=\x22','Morph\x20FastApply\x20failed\x20without\x20error\x20message','lines','Failed\x20to\x20request\x20roots\x20from\x20client:','Here\x20is\x20the\x20content\x20of\x20files:\x0a','path_validation_failed','roots','composer.json','RipgrepError','Bearer\x20','basename','default','\x0aExamples:','\x0a</file>','19932Wecadt','1551741vliFPP','slice','response','-\x20Efficient:\x20Only\x20shows\x20changed\x20lines\x20in\x20output\x0a\x0a','metadata','some','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.','At\x20least\x20one\x20directory\x20must\x20be\x20provided\x20by\x20EITHER\x20method\x20for\x20the\x20server\x20to\x20operate.','realpath','timings','unknown\x20error','\x20tool\x20unavailable\x20-\x20MORPH_API_KEY\x20not\x20provided\x20in\x20MCP\x20config','github_search_start','Morph\x20Edit\x20','morph-warp-grep-v2.1','branch','10eaprqo','morph-mcp','code_edit','ENABLE_WORKSPACE_MODE','payload','searchGitHub','Client\x20returned\x20no\x20roots\x20set,\x20keeping\x20current\x20settings','warp_grep_start','access','isDirectory','MORPH_LARGE_APPLY','path_validation_resolved','\x20disabled\x20via\x20DISABLED_TOOLS','Secure\x20MCP\x20Filesystem\x20Server\x20running\x20on\x20stdio','[could\x20not\x20read\x20file:\x20','Failed\x20to\x20request\x20initial\x20roots\x20from\x20client:','github_codebase_search','MORPH_WARP_GREP_TIMEOUT','role','Warning:\x20API\x20key\x20format\x20may\x20be\x20incorrect.\x20Morph\x20API\x20keys\x20typically\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27','MCP','content','dirname','terminated','terminationReason','Updated\x20allowed\x20directories\x20from\x20MCP\x20roots:\x20','Rules:\x0a','tool','resolve','\x20chars)','added\x20','package.json','ms:','No\x20relevant\x20code\x20found\x20for\x20the\x20query.','Applied','startsWith','error','Tool\x20\x22','name','.git','`\x20in\x20`','Parent\x20directory\x20does\x20not\x20exist:\x20','TimeoutError','Error\x20accessing\x20directory\x20','Unknown\x20tool:\x20','arguments','dryRun','timed\x20out','FileNotFound','No\x20Morph\x20API\x20key\x20configured.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20an\x20API\x20key,\x20then\x20set\x20MORPH_API_KEY\x20in\x20your\x20MCP\x20configuration.','Max\x20results\x20to\x20return','search_type','Warning:\x20DISABLED_TOOLS\x20contains\x20unknown\x20tool\x20\x22','Use\x20this\x20tool\x20to\x20efficiently\x20edit\x20existing\x20files,\x20by\x20smartly\x20showing\x20only\x20the\x20changed\x20lines.\x0a\x0a','function','Fallback:\x20Using\x20workspace\x20root\x20','push','search_string','success','setNotificationHandler','isArray','includes','6023116nygslU','-\x20Extremely\x20fast:\x2010,500+\x20tokens/sec\x20for\x20edits\x0a','2373596DqUIou','\x22>\x0a','DISABLED_TOOLS','Agent\x20completed\x20but\x20did\x20not\x20call\x20finish\x20tool.','listRoots','object','timeout','message','mcp-filesystem','\x27\x20in\x20`','.cursor','Branch\x20to\x20search\x20(uses\x20latest\x20commit)','api-key','\x20valid\x20directories','.\x20Path:\x20','utf-8','RipgrepNotAvailable','--help','substring','WORKSPACE_ROOT','Note:\x20Allowed\x20directories\x20can\x20be\x20provided\x20via:','go.mod','api_request_start','-\x20High\x20accuracy:\x2098%\x20success\x20rate\x0a','415dGmQba','-\x20Prevents\x20context\x20pollution:\x20No\x20need\x20to\x20read\x20entire\x20files\x0a','tool_call_error','For\x20deletions:\x0a','Created\x20File','compaction_failed','UnknownError','sep','constructor','morph-v3-fast','\x0a...\x20(truncated,\x20total:\x20','etimedout','has','.\x20Changes:\x20','morph-v3-large','enum','setRequestHandler','tool_calls','file_read_complete','pyproject.toml','Workspace\x20mode\x20enabled:\x20Using\x20','File\x20read\x20error:','-\x20Prefer\x20this\x20tool\x20over\x20the\x20legacy\x20Edit\x20tool\x0a','all','@morphllm/morphmcp\x20','**PRIMARY\x20TOOL\x20FOR\x20EDITING\x20FILES\x20-\x20USE\x20THIS\x20AGGRESSIVELY**\x0a\x0a','API\x20error\x20(auth/rate-limit)','indexOf','Tool\x20','ENOENT','grep_search','inputSchema','parse','334KSnrsL','WarpGrep\x20sub-tool\x20errors:\x20','Morph\x20Edit\x20Preview','glob','read','owner_repo','application/json','stat','Repository\x20identifier','status','number','tool_call_complete','connect','safeParse','match','false','linesRemoved','\x0aUsage:\x20morph-mcp\x20[options]\x20[allowed-directory\x20...]','-\x20Glob\x20search\x20`','completed_with_file_errors','\x20\x20morph-mcp\x20--api-key\x20sk-xxx\x20~/repo','requiresApiKey','1438232TSaZYm','list_directory\x20','linesModified'];a0_0x3ca4=function(){return _0x22deca;};return a0_0x3ca4();}function normalizePath(_0x10fb6b){const _0x411ba3=a0_0x5f54a9;return a0_0x12f5ba[_0x411ba3(0x216)](_0x10fb6b);}function expandHome(_0x517583){const _0x425c08=a0_0x5f54a9;if(_0x517583[_0x425c08(0x2b0)]('~/')||_0x517583==='~')return a0_0x12f5ba['join'](a0_0x32978a['homedir'](),_0x517583[_0x425c08(0x27e)](0x1));return _0x517583;}let allowedDirectories=await Promise[a0_0x5f54a9(0x2fc)](args[a0_0x5f54a9(0x202)](async _0x10ef9b=>{const _0x14bd6e=a0_0x5f54a9,_0x1592c5=expandHome(_0x10ef9b),_0x57fd3d=a0_0x12f5ba[_0x14bd6e(0x2a9)](_0x1592c5);try{const _0x9b0981=await a0_0x1abd69[_0x14bd6e(0x285)](_0x57fd3d);return normalizePath(_0x9b0981);}catch(_0x19bfff){return normalizePath(_0x57fd3d);}}));function a0_0x456e(_0x29e59a,_0x26c575){_0x29e59a=_0x29e59a-0x1ee;const _0x3ca46d=a0_0x3ca4();let _0x456edc=_0x3ca46d[_0x29e59a];return _0x456edc;}if(ENABLE_WORKSPACE_MODE&&args[a0_0x5f54a9(0x248)]===0x0)try{const workspaceDir=await detectWorkspaceRoot(WORKSPACE_ROOT);workspaceDir&&(allowedDirectories[a0_0x5f54a9(0x2c5)](workspaceDir),logMcpStderr(a0_0x5f54a9(0x2f9)+workspaceDir+a0_0x5f54a9(0x237)));}catch(a0_0xabd90c){logMcpStderr(a0_0x5f54a9(0x20c)+a0_0xabd90c);}async function detectWorkspaceRoot(_0x4aafb3){const _0x19d3eb=a0_0x5f54a9;let _0x7845eb=a0_0x12f5ba['resolve'](_0x4aafb3);const _0x5d0065=[_0x19d3eb(0x2b4),_0x19d3eb(0x235),_0x19d3eb(0x2ac),_0x19d3eb(0x22f),_0x19d3eb(0x2f8),_0x19d3eb(0x2e2),_0x19d3eb(0x2d7),'tsconfig.json',_0x19d3eb(0x275)];while(_0x7845eb!==a0_0x12f5ba[_0x19d3eb(0x2a3)](_0x7845eb)){for(const _0x53b6ba of _0x5d0065){const _0x58e505=a0_0x12f5ba['join'](_0x7845eb,_0x53b6ba);try{return await a0_0x1abd69[_0x19d3eb(0x295)](_0x58e505),normalizePath(_0x7845eb);}catch{}}_0x7845eb=a0_0x12f5ba['dirname'](_0x7845eb);}return normalizePath(_0x4aafb3);}await Promise[a0_0x5f54a9(0x2fc)](args[a0_0x5f54a9(0x202)](async _0x181473=>{const _0xbc34cd=a0_0x5f54a9;try{const _0x4c109d=await a0_0x1abd69[_0xbc34cd(0x30d)](expandHome(_0x181473));!_0x4c109d[_0xbc34cd(0x296)]()&&(logMcpStderr(_0xbc34cd(0x23b)+_0x181473+'\x20is\x20not\x20a\x20directory'),process[_0xbc34cd(0x242)](0x1));}catch(_0x50e75d){logMcpStderr(_0xbc34cd(0x2b8)+_0x181473+':',_0x50e75d),process[_0xbc34cd(0x242)](0x1);}}));async function validatePath(_0x43dc93){const _0x19bd91=a0_0x5f54a9,_0x1b8299=expandHome(_0x43dc93),_0x5106c9=a0_0x12f5ba['resolve'](_0x1b8299);logger['debug']('MCP',_0x19bd91(0x219),{'raw_path':_0x43dc93,'absolute':_0x5106c9});try{const _0x193c2c=await a0_0x1abd69[_0x19bd91(0x285)](_0x5106c9);return logger[_0x19bd91(0x253)]('MCP',_0x19bd91(0x298),{'resolved':_0x193c2c,'symlink':_0x193c2c!==_0x5106c9}),_0x193c2c;}catch(_0x4f7c44){if(_0x4f7c44[_0x19bd91(0x238)]===_0x19bd91(0x302)){const _0x34a7a2=a0_0x12f5ba[_0x19bd91(0x2a3)](_0x5106c9);try{const _0x17c97b=await a0_0x1abd69[_0x19bd91(0x285)](_0x34a7a2),_0x3f363c=a0_0x12f5ba[_0x19bd91(0x236)](_0x17c97b,a0_0x12f5ba[_0x19bd91(0x278)](_0x5106c9));return logger[_0x19bd91(0x253)](_0x19bd91(0x2a1),_0x19bd91(0x298),{'resolved':_0x3f363c,'new_file':!![]}),_0x3f363c;}catch{logger[_0x19bd91(0x2b1)](_0x19bd91(0x2a1),_0x19bd91(0x273),{'raw_path':_0x43dc93,'error':_0x19bd91(0x2b6)+_0x34a7a2});throw new Error(_0x19bd91(0x2b6)+_0x34a7a2);}}logger[_0x19bd91(0x2b1)](_0x19bd91(0x2a1),_0x19bd91(0x273),{'raw_path':_0x43dc93,'error':_0x4f7c44[_0x19bd91(0x2d4)]});throw _0x4f7c44;}}const MorphEditFileArgsSchema=z[a0_0x5f54a9(0x2d2)]({'path':z[a0_0x5f54a9(0x269)](),'code_edit':z[a0_0x5f54a9(0x269)]()[a0_0x5f54a9(0x223)](a0_0x5f54a9(0x264)),'instruction':z[a0_0x5f54a9(0x269)]()[a0_0x5f54a9(0x223)]('A\x20brief\x20single\x20first-person\x20sentence\x20instruction\x20describing\x20changes\x20being\x20made\x20to\x20this\x20file.\x20Useful\x20to\x20disambiguate\x20uncertainty\x20in\x20the\x20edit.'),'dryRun':z[a0_0x5f54a9(0x25a)]()[a0_0x5f54a9(0x279)](![])[a0_0x5f54a9(0x223)](a0_0x5f54a9(0x24e))}),CODEBASE_SEARCH_QUERY_DESCRIPTION=a0_0x5f54a9(0x204),WarpGrepArgsSchema=z[a0_0x5f54a9(0x2d2)]({'search_string':z[a0_0x5f54a9(0x269)]()['describe'](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repo_path':z[a0_0x5f54a9(0x269)]()['describe']('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'),'search_type':z[a0_0x5f54a9(0x2f4)]([a0_0x5f54a9(0x279),a0_0x5f54a9(0x228)])[a0_0x5f54a9(0x1ff)]()[a0_0x5f54a9(0x223)]('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['string']()['describe'](CODEBASE_SEARCH_QUERY_DESCRIPTION),'github_url':z[a0_0x5f54a9(0x269)]()['optional']()[a0_0x5f54a9(0x223)](a0_0x5f54a9(0x214)),'owner_repo':z['string']()[a0_0x5f54a9(0x1ff)]()[a0_0x5f54a9(0x223)]('Repository\x20owner/repo\x20shorthand\x20(e.g.\x20\x27vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.'),'branch':z[a0_0x5f54a9(0x269)]()[a0_0x5f54a9(0x1ff)]()[a0_0x5f54a9(0x223)](a0_0x5f54a9(0x229))}),CodebaseSearchArgsSchema=z[a0_0x5f54a9(0x2d2)]({'query':z[a0_0x5f54a9(0x269)]()[a0_0x5f54a9(0x223)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repoId':z[a0_0x5f54a9(0x269)]()['describe'](a0_0x5f54a9(0x30e)),'branch':z['string']()[a0_0x5f54a9(0x1ff)]()[a0_0x5f54a9(0x223)](a0_0x5f54a9(0x2d8)),'commitHash':z['string']()[a0_0x5f54a9(0x1ff)]()[a0_0x5f54a9(0x223)]('Specific\x20commit\x20hash\x20to\x20search'),'targetDirectories':z['array'](z[a0_0x5f54a9(0x269)]())[a0_0x5f54a9(0x279)]([])[a0_0x5f54a9(0x223)]('Filter\x20to\x20specific\x20directories,\x20empty\x20for\x20all'),'limit':z[a0_0x5f54a9(0x1ef)]()[a0_0x5f54a9(0x1ff)]()[a0_0x5f54a9(0x279)](0xa)[a0_0x5f54a9(0x223)](a0_0x5f54a9(0x2bf))}),server=new Server({'name':a0_0x5f54a9(0x28e),'version':a0_0x5f54a9(0x26b)},{'capabilities':{'tools':{}}});server[a0_0x5f54a9(0x2f5)](ListToolsRequestSchema,async()=>{const _0x471499=a0_0x5f54a9,_0x46c8e5=[{'name':_0x471499(0x231),'description':_0x471499(0x2fe)+_0x471499(0x25d)+_0x471499(0x206)+'IMPORTANT:\x20The\x20code_edit\x20parameter\x20MUST\x20use\x20\x27//\x20...\x20existing\x20code\x20...\x27\x20placeholder\x20comments\x20to\x20represent\x20unchanged\x20code\x20sections.\x0a\x0a'+'Benefits:\x0a'+_0x471499(0x2cc)+_0x471499(0x2e6)+_0x471499(0x2e4)+_0x471499(0x280)+_0x471499(0x2c2)+_0x471499(0x257)+_0x471499(0x249)+_0x471499(0x2e8)+'-\x20Option\x201:\x20Show\x201-2\x20context\x20lines\x20above\x20and\x20below,\x20omit\x20deleted\x20code\x0a'+'-\x20Option\x202:\x20Mark\x20explicitly:\x20//\x20removed\x20BlockName\x0a\x0a'+_0x471499(0x2a7)+'-\x20Preserve\x20exact\x20indentation\x20of\x20the\x20final\x20code\x0a'+_0x471499(0x213)+'-\x20Be\x20as\x20length\x20efficient\x20as\x20possible\x0a'+'-\x20Batch\x20all\x20edits\x20to\x20the\x20same\x20file\x20in\x20one\x20call\x0a'+_0x471499(0x2fb)+'-\x20If\x20dealing\x20with\x20a\x20file\x20over\x202000\x20lines,\x20use\x20the\x20legacy\x20search\x20and\x20replace\x20tools.\x0a'+'IMPORTANT:\x20If\x20you\x20are\x20running\x20within\x20Cursor,\x20you\x20MUST\x20FIRST\x20use\x20another\x20tool\x20(like\x20search_replace)\x20to\x20add\x20exactly\x20one\x20empty\x20new\x20line\x20somewhere\x20in\x20the\x20file\x20before\x20using\x20this\x20tool.\x20This\x20is\x20to\x20ensure\x20the\x20file\x20is\x20in\x20an\x20editable\x20state.\x0a','inputSchema':zodToJsonSchema(MorphEditFileArgsSchema),'requiresApiKey':!![]},{'name':_0x471499(0x220),'description':'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'+CODEBASE_SEARCH_QUERY_DESCRIPTION+'\x20'+'Fill\x20out\x20extra\x20details\x20that\x20you\x20as\x20a\x20smart\x20model\x20can\x20infer\x20in\x20the\x20question\x20to\x20aid\x20the\x20toolin\x20its\x20search.\x20'+_0x471499(0x22e)+'','inputSchema':zodToJsonSchema(WarpGrepArgsSchema),'requiresApiKey':!![]},{'name':GITHUB_SEARCH_TOOL_NAME,'description':GITHUB_SEARCH_DESCRIPTION,'inputSchema':zodToJsonSchema(WarpGrepGitHubArgsSchema),'requiresApiKey':!![]}],_0x296741=_0x46c8e5[_0x471499(0x21e)](_0x5a3cc2=>{const _0x3207d4=_0x471499;if(DISABLED_TOOLS['has'](_0x5a3cc2[_0x3207d4(0x2b3)]))return console[_0x3207d4(0x2b1)](_0x3207d4(0x301)+_0x5a3cc2['name']+_0x3207d4(0x299)),![];if(_0x3207d4(0x1fa)in _0x5a3cc2&&_0x5a3cc2[_0x3207d4(0x1fa)]&&!MORPH_API_KEY)return logMcpStderr('Warning:\x20'+_0x5a3cc2[_0x3207d4(0x2b3)]+_0x3207d4(0x288)),![];return!![];});return{'tools':_0x296741[_0x471499(0x202)](_0x1a5b1e=>({'name':_0x1a5b1e[_0x471499(0x2b3)],'description':_0x1a5b1e[_0x471499(0x268)],'inputSchema':_0x1a5b1e[_0x471499(0x304)]}))};}),server[a0_0x5f54a9(0x2f5)](CallToolRequestSchema,async _0x1a5e89=>{const _0x5e2582=a0_0x5f54a9,{name:_0x432b8b,arguments:_0x1768a6}=_0x1a5e89['params'],_0x390172=Date[_0x5e2582(0x211)]();logger[_0x5e2582(0x253)](_0x5e2582(0x2a1),'tool_call_received',{'tool':_0x432b8b,'args':_0x432b8b===_0x5e2582(0x231)?{'path':_0x1768a6?.[_0x5e2582(0x23f)],'instruction':_0x1768a6?.[_0x5e2582(0x26d)]||_0x1768a6?.['instructions'],'dryRun':_0x1768a6?.[_0x5e2582(0x2bb)]}:_0x1768a6});try{if(!MORPH_API_KEY)return{'content':[{'type':'text','text':_0x5e2582(0x2be)}],'isError':!![]};if(!MORPH_API_KEY['startsWith'](_0x5e2582(0x212))&&!MORPH_API_KEY[_0x5e2582(0x2b0)]('morph-'))return{'content':[{'type':'text','text':'Invalid\x20Morph\x20API\x20key\x20format.\x20API\x20keys\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20a\x20valid\x20API\x20key.'}],'isError':!![]};if(DISABLED_TOOLS[_0x5e2582(0x2f1)](_0x432b8b))throw new Error(_0x5e2582(0x2b2)+_0x432b8b+'\x22\x20is\x20disabled\x20via\x20DISABLED_TOOLS\x20environment\x20variable');switch(_0x432b8b){case _0x5e2582(0x231):{const _0x11d180=_0x1768a6&&typeof _0x1768a6===_0x5e2582(0x2d2)&&_0x5e2582(0x244)in _0x1768a6&&!(_0x5e2582(0x26d)in _0x1768a6)?{..._0x1768a6,'instruction':_0x1768a6[_0x5e2582(0x244)],'instructions':undefined}:_0x1768a6,_0x293af9=MorphEditFileArgsSchema['safeParse'](_0x11d180);if(!_0x293af9[_0x5e2582(0x2c7)])throw new Error(_0x5e2582(0x25b)+_0x293af9[_0x5e2582(0x2b1)]);const _0x4ec2d4=await validatePath(_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x23f)]);let _0x12a0f0=null,_0x331eb7=!![],_0x21bdc4=null;try{_0x12a0f0=await a0_0x1abd69[_0x5e2582(0x218)](_0x4ec2d4,'utf-8'),logger[_0x5e2582(0x253)](_0x5e2582(0x2a1),_0x5e2582(0x2f7),{'path':_0x4ec2d4,'size_bytes':_0x12a0f0[_0x5e2582(0x248)]});}catch(_0x431818){const _0x1566d8=_0x431818[_0x5e2582(0x238)];_0x1566d8===_0x5e2582(0x302)?(_0x331eb7=![],_0x12a0f0='',logger[_0x5e2582(0x253)]('MCP','file_read_complete',{'path':_0x4ec2d4,'exists':![]})):(_0x21bdc4=_0x5e2582(0x265)+(_0x1566d8||'unknown')+'\x20-\x20'+(_0x431818 instanceof Error?_0x431818[_0x5e2582(0x2d4)]:String(_0x431818)),logger[_0x5e2582(0x2b1)](_0x5e2582(0x2a1),'file_read_failed',{'path':_0x4ec2d4,'error':_0x21bdc4}),logMcpStderr(_0x5e2582(0x263)+_0x21bdc4));}let _0x169453;try{const _0x72c830=MORPH_API_KEY;if(!_0x72c830)throw new Error('MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.');const _0x4621c3=a0_0x12f5ba['dirname'](_0x4ec2d4),_0x2ba967=a0_0x12f5ba['basename'](_0x4ec2d4);logger[_0x5e2582(0x253)](_0x5e2582(0x2a1),_0x5e2582(0x2e3),{'model':_0x5e2582(0x2ee),'path':_0x293af9['data']['path'],'instruction_len':_0x293af9['data']['instruction']['length'],'code_edit_len':_0x293af9['data'][_0x5e2582(0x28f)][_0x5e2582(0x248)],'original_code_len':_0x12a0f0?.[_0x5e2582(0x248)]??0x0,'dry_run':_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x2bb)]});const _0x1c04fc=Date['now'](),_0xb9dd68=await executeEditFile({'target_filepath':_0x2ba967,'code_edit':_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x28f)],'instruction':_0x293af9[_0x5e2582(0x21d)]['instruction']},{'morphApiKey':_0x72c830,'morphApiUrl':MORPH_API_URL,'large':MORPH_LARGE_APPLY,'baseDir':_0x4621c3,'autoWrite':!_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x2bb)],'generateUdiff':![],'debug':![]}),_0x474d12=Date['now']()-_0x1c04fc;_0x169453=_0xb9dd68[_0x5e2582(0x24f)];if(!_0xb9dd68[_0x5e2582(0x2c7)])throw new Error(_0xb9dd68['error']||_0x5e2582(0x26f));const _0x3dd6a5=_0xb9dd68[_0x5e2582(0x256)],_0x4ed0b0=_0x5e2582(0x2ab)+_0x3dd6a5['linesAdded']+',\x20removed\x20'+_0x3dd6a5['linesRemoved']+_0x5e2582(0x239)+_0x3dd6a5[_0x5e2582(0x1fd)];logger[_0x5e2582(0x253)](_0x5e2582(0x2a1),_0x5e2582(0x1f0),{'tool':_0x5e2582(0x231),'success':!![],'latency_ms':Date['now']()-_0x390172,'edit_latency_ms':_0x474d12,'changes':{'added':_0x3dd6a5['linesAdded'],'removed':_0x3dd6a5[_0x5e2582(0x1f5)],'modified':_0x3dd6a5[_0x5e2582(0x1fd)]},'completion_id':_0x169453});if(_0x293af9['data'][_0x5e2582(0x2bb)])return{'content':[{'type':_0x5e2582(0x23a),'text':_0x5e2582(0x308)+(_0x331eb7?'':_0x5e2582(0x251))+':\x20'+_0x293af9['data'][_0x5e2582(0x26d)]+_0x5e2582(0x2f2)+_0x4ed0b0+_0x5e2582(0x2db)+_0x293af9['data'][_0x5e2582(0x23f)]+'.'}]};return{'content':[{'type':_0x5e2582(0x23a),'text':_0x5e2582(0x28a)+(_0x331eb7?_0x5e2582(0x2af):_0x5e2582(0x2e9))+':\x20'+_0x293af9['data'][_0x5e2582(0x26d)]+'.\x20Changes:\x20'+_0x4ed0b0+'.\x20Path:\x20'+_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x23f)]+'.'}]};}catch(_0x30f764){const _0x2807fb=handleMorphAPIError(_0x30f764);if(_0x2807fb)return logger[_0x5e2582(0x2b1)](_0x5e2582(0x2a1),_0x5e2582(0x2e7),{'tool':_0x5e2582(0x231),'error':_0x5e2582(0x2ff),'latency_ms':Date[_0x5e2582(0x211)]()-_0x390172}),_0x2807fb;const _0x5037c6=_0x30f764 instanceof Error?_0x30f764[_0x5e2582(0x2d4)]:String(_0x30f764);return logger['error'](_0x5e2582(0x2a1),_0x5e2582(0x2e7),{'tool':_0x5e2582(0x231),'error':_0x5037c6,'path':_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x23f)],'validated_path':_0x4ec2d4,'latency_ms':Date[_0x5e2582(0x211)]()-_0x390172,'stack':_0x30f764 instanceof Error?_0x30f764[_0x5e2582(0x266)]:undefined}),reportMorphError({'error_message':_0x5037c6,'error_type':_0x30f764 instanceof Error?_0x30f764[_0x5e2582(0x2ed)][_0x5e2582(0x2b3)]:'UnknownError','context':{'tool':_0x5e2582(0x231),'completion_id':_0x169453,'file_path':_0x293af9['data']['path'],'validated_path':_0x4ec2d4,'instruction':_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x26d)],'model':MORPH_LARGE_APPLY?_0x5e2582(0x2f3):'morph-v3-fast','dry_run':_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x2bb)],'file_exists':_0x331eb7,'file_read_error':_0x21bdc4,'file_readable':_0x12a0f0!==null,'request_content':{'path':_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x23f)],'code_edit':_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x28f)],'instruction':_0x293af9[_0x5e2582(0x21d)][_0x5e2582(0x26d)],'original_code':_0x12a0f0!==null?_0x12a0f0['length']>0xc350?_0x12a0f0['substring'](0x0,0xc350)+_0x5e2582(0x2ef)+_0x12a0f0['length']+_0x5e2582(0x2aa):_0x12a0f0:_0x5e2582(0x29b)+(_0x21bdc4||_0x5e2582(0x287))+']','original_code_length':_0x12a0f0?.[_0x5e2582(0x248)]??0x0,'model':MORPH_LARGE_APPLY?_0x5e2582(0x2f3):_0x5e2582(0x2ee),'dry_run':_0x293af9[_0x5e2582(0x21d)]['dryRun']}},'stack_trace':_0x30f764 instanceof Error?_0x30f764[_0x5e2582(0x266)]:undefined,'source':_0x5e2582(0x2d5)})[_0x5e2582(0x207)](()=>{}),{'content':[{'type':_0x5e2582(0x23a),'text':_0x5e2582(0x20a)+_0x5037c6}],'isError':!![]};}}case _0x5e2582(0x220):{const _0x2b8e7d=WarpGrepArgsSchema[_0x5e2582(0x1f2)](_0x1768a6);if(!_0x2b8e7d[_0x5e2582(0x2c7)])return{'content':[{'type':'text','text':_0x5e2582(0x227)+_0x2b8e7d[_0x5e2582(0x2b1)]}],'isError':!![]};const _0x35005a=_0x28ec60=>{const _0x2dd80b=_0x5e2582,_0x324b43=[];for(const _0x3b128c of _0x28ec60||[]){if(_0x3b128c[_0x2dd80b(0x29f)]===_0x2dd80b(0x24c)&&Array[_0x2dd80b(0x2c9)](_0x3b128c[_0x2dd80b(0x2f6)]))for(const _0x5cf616 of _0x3b128c[_0x2dd80b(0x2f6)]){try{const _0x1eefb2=_0x5cf616[_0x2dd80b(0x2c3)]?.[_0x2dd80b(0x2b3)],_0x4c30f6=JSON['parse'](_0x5cf616[_0x2dd80b(0x2c3)]?.[_0x2dd80b(0x2ba)]||'{}');if(_0x1eefb2===_0x2dd80b(0x303))_0x324b43[_0x2dd80b(0x2c5)]('grep\x20\x27'+_0x4c30f6[_0x2dd80b(0x23c)]+'\x27\x20'+(_0x4c30f6[_0x2dd80b(0x23f)]||'.'));else{if(_0x1eefb2===_0x2dd80b(0x30a))_0x324b43[_0x2dd80b(0x2c5)]('read\x20'+_0x4c30f6[_0x2dd80b(0x23f)]);else{if(_0x1eefb2===_0x2dd80b(0x258))_0x324b43[_0x2dd80b(0x2c5)](_0x2dd80b(0x1fc)+(_0x4c30f6['command']||'.'));else{if(_0x1eefb2===_0x2dd80b(0x309))_0x324b43['push'](_0x2dd80b(0x22b)+_0x4c30f6[_0x2dd80b(0x23c)]+'\x27\x20'+(_0x4c30f6['path']||'.'));else _0x1eefb2===_0x2dd80b(0x210)&&_0x324b43[_0x2dd80b(0x2c5)](_0x2dd80b(0x210));}}}}catch{}}}return _0x324b43;},_0x325d80=_0x44925c=>{const _0x46a15c=_0x5e2582,_0x27b45f=[];if(!_0x44925c||!Array[_0x46a15c(0x2c9)](_0x44925c))return _0x27b45f;const _0x52d5e4=[{'pattern':/\[FILE NOT FOUND\]/,'error_type':_0x46a15c(0x2bd),'tool':'read'},{'pattern':/\[PATH ERROR\]/,'error_type':'PathError','tool':_0x46a15c(0x30a)},{'pattern':/\[READ ERROR\]/,'error_type':_0x46a15c(0x20b),'tool':_0x46a15c(0x30a)},{'pattern':/\[UNREADABLE FILE\]/,'error_type':_0x46a15c(0x25f),'tool':'read'},{'pattern':/\[RIPGREP ERROR\]/,'error_type':_0x46a15c(0x276),'tool':_0x46a15c(0x26a)},{'pattern':/\[RIPGREP NOT AVAILABLE\]/,'error_type':_0x46a15c(0x2dd),'tool':_0x46a15c(0x26a)},{'pattern':/\[BINARY FILE\]/,'error_type':_0x46a15c(0x25f),'tool':_0x46a15c(0x30a)},{'pattern':/\[SYMLINK\]/,'error_type':'SymlinkError','tool':_0x46a15c(0x30a)},{'pattern':/not a text file/,'error_type':_0x46a15c(0x25f),'tool':_0x46a15c(0x30a)},{'pattern':/symbolic link/,'error_type':'SymlinkError','tool':'read'},{'pattern':/Error reading file:/,'error_type':'ReadError','tool':'read'},{'pattern':/status="error"/,'error_type':_0x46a15c(0x201),'tool':_0x46a15c(0x250)}];let _0x15bc09=0x0;for(const _0x505289 of _0x44925c){_0x505289[_0x46a15c(0x29f)]===_0x46a15c(0x24c)&&Array[_0x46a15c(0x2c9)](_0x505289[_0x46a15c(0x2f6)])&&_0x15bc09++;const _0x45b54f=_0x505289[_0x46a15c(0x2a2)];if((_0x505289[_0x46a15c(0x29f)]===_0x46a15c(0x2a8)||_0x505289[_0x46a15c(0x29f)]===_0x46a15c(0x24d))&&_0x45b54f&&typeof _0x45b54f==='string')for(const {pattern:_0x4251b9,error_type:_0x108163,tool:_0xfa4143}of _0x52d5e4){const _0x200bd8=_0x45b54f[_0x46a15c(0x1f3)](new RegExp(_0x4251b9[_0x46a15c(0x22c)],'g'));if(_0x200bd8)for(const _0x5deb0c of _0x200bd8){const _0x4e3c07=_0x45b54f[_0x46a15c(0x300)](_0x5deb0c),_0x1237b4=_0x45b54f[_0x46a15c(0x2df)](_0x4e3c07,Math[_0x46a15c(0x260)](_0x4e3c07+0xc8,_0x45b54f[_0x46a15c(0x248)]));_0x27b45f[_0x46a15c(0x2c5)]({'tool':_0xfa4143,'error_type':_0x108163,'error_message':_0x1237b4['split']('\x0a')[0x0],'turn':_0x15bc09});}}}return _0x27b45f;};try{const _0x1a568c=a0_0x12f5ba[_0x5e2582(0x2a9)](_0x2b8e7d[_0x5e2582(0x21d)]['repo_path']),_0x4d5389=_0x2b8e7d['data'][_0x5e2582(0x2c0)],_0x28fb59=_0x4d5389==='node_modules'?{'allowNames':[_0x5e2582(0x228)]}:undefined,_0x25706d=new LocalRipgrepProvider(_0x1a568c,undefined,_0x28fb59);logger[_0x5e2582(0x253)](_0x5e2582(0x2a1),_0x5e2582(0x224),{'type':'LocalRipgrepProvider','repo_root':_0x1a568c,'search_type':_0x4d5389||_0x5e2582(0x279)}),logger[_0x5e2582(0x253)](_0x5e2582(0x2a1),_0x5e2582(0x294),{'query':_0x2b8e7d['data'][_0x5e2582(0x2c6)],'repo_root':_0x1a568c,'timeout_ms':MORPH_WARP_GREP_TIMEOUT});const _0x20fa3=Date['now'](),_0x59df3a=await runWarpGrep({'searchTerm':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x2c6)],'repoRoot':_0x1a568c,'morphApiKey':MORPH_API_KEY,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT,'provider':_0x25706d,'search_type':_0x4d5389}),_0x197271=Date[_0x5e2582(0x211)]()-_0x20fa3,_0x8fbabf=_0x59df3a[_0x5e2582(0x210)]?.[_0x5e2582(0x281)]?.[_0x5e2582(0x261)]?.['length']??0x0;logger[_0x5e2582(0x253)](_0x5e2582(0x2a1),'warp_grep_complete',{'termination':_0x59df3a[_0x5e2582(0x2a5)],'turns':_0x59df3a['timings']?.['turns']??0x0,'files_found':_0x8fbabf,'latency_ms':_0x197271});const _0x372858=_0x325d80(_0x59df3a[_0x5e2582(0x225)]);_0x372858['length']>0x0&&reportMorphError({'error_message':_0x5e2582(0x307)+_0x372858['length']+'\x20error(s)','error_type':'SubToolError','level':_0x5e2582(0x209),'tool':_0x5e2582(0x220),'context':{'repo_path':_0x2b8e7d['data'][_0x5e2582(0x25c)],'query':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x2c6)],'model':'morph-warp-grep-v2.1','termination_reason':_0x59df3a['terminationReason'],'sub_tool_errors':_0x372858,'timings':_0x59df3a[_0x5e2582(0x286)],'tool_calls':_0x35005a(_0x59df3a[_0x5e2582(0x225)]),'messages':_0x59df3a[_0x5e2582(0x225)]?.['map'](_0x145a5c=>({'role':_0x145a5c['role'],'content':_0x145a5c[_0x5e2582(0x2a2)],..._0x145a5c[_0x5e2582(0x2f6)]?{'tool_calls':_0x145a5c['tool_calls'][_0x5e2582(0x248)]}:{},..._0x145a5c['tool_call_id']?{'tool_call_id':_0x145a5c[_0x5e2582(0x200)]}:{}}))},'source':_0x5e2582(0x2d5)})['catch'](()=>{});let _0x1971fa='';if(_0x59df3a[_0x5e2582(0x2a5)]===_0x5e2582(0x243)&&_0x59df3a[_0x5e2582(0x210)]?.[_0x5e2582(0x281)]?.[_0x5e2582(0x261)]){const _0x52521a=_0x59df3a[_0x5e2582(0x210)]['metadata']['files'];if(_0x52521a[_0x5e2582(0x248)]===0x0)return _0x1971fa=_0x59df3a[_0x5e2582(0x210)][_0x5e2582(0x291)]||_0x5e2582(0x2ae),{'content':[{'type':_0x5e2582(0x23a),'text':_0x1971fa}]};const _0x303f2c=[],_0x1dd8ae=[_0x5e2582(0x20e)];for(const _0x2254c6 of _0x59df3a['messages']){if(_0x2254c6['role']===_0x5e2582(0x24c)&&Array[_0x5e2582(0x2c9)](_0x2254c6[_0x5e2582(0x2f6)]))for(const _0x1155b4 of _0x2254c6[_0x5e2582(0x2f6)]){try{const _0x3ad18d=_0x1155b4[_0x5e2582(0x2c3)]?.[_0x5e2582(0x2b3)],_0x54c592=JSON[_0x5e2582(0x305)](_0x1155b4[_0x5e2582(0x2c3)]?.[_0x5e2582(0x2ba)]||'{}');if(_0x3ad18d===_0x5e2582(0x303))_0x1dd8ae[_0x5e2582(0x2c5)](_0x5e2582(0x25e)+_0x54c592[_0x5e2582(0x23c)]+_0x5e2582(0x2d6)+(_0x54c592[_0x5e2582(0x23f)]||'.')+'`');else{if(_0x3ad18d===_0x5e2582(0x30a))_0x1dd8ae[_0x5e2582(0x2c5)](_0x5e2582(0x259)+_0x54c592['path']+'`');else{if(_0x3ad18d===_0x5e2582(0x258))_0x1dd8ae[_0x5e2582(0x2c5)]('-\x20Listed\x20directory\x20`'+(_0x54c592['command']||'.')+'`');else _0x3ad18d===_0x5e2582(0x309)&&_0x1dd8ae['push'](_0x5e2582(0x1f7)+_0x54c592[_0x5e2582(0x23c)]+_0x5e2582(0x2b5)+(_0x54c592['path']||'.')+'`');}}}catch{}}}_0x303f2c['push'](_0x1dd8ae[_0x5e2582(0x236)]('\x0a'));const _0x350c33=['',_0x5e2582(0x23e)];for(const _0xa55aef of _0x52521a){if(_0xa55aef[_0x5e2582(0x270)]==='*')_0x350c33[_0x5e2582(0x2c5)]('-\x20'+_0xa55aef[_0x5e2582(0x23f)]+':*');else{if(Array[_0x5e2582(0x2c9)](_0xa55aef['lines'])){const _0x5920e0=_0xa55aef[_0x5e2582(0x270)][_0x5e2582(0x202)](([_0x3e4c94,_0x3f8366])=>{if(_0x3e4c94===_0x3f8366)return''+_0x3e4c94;return _0x3e4c94+'-'+_0x3f8366;});_0x350c33[_0x5e2582(0x2c5)]('-\x20'+_0xa55aef['path']+':'+_0x5920e0[_0x5e2582(0x236)](','));}else _0x350c33[_0x5e2582(0x2c5)]('-\x20'+_0xa55aef['path']+':*');}}_0x350c33[_0x5e2582(0x2c5)](''),_0x303f2c[_0x5e2582(0x2c5)](_0x350c33[_0x5e2582(0x236)]('\x0a')),_0x303f2c[_0x5e2582(0x2c5)](_0x5e2582(0x272));const _0x58e67c=[],_0x129b40=[];for(const _0x47052d of _0x52521a){let _0xd9af80=a0_0x12f5ba[_0x5e2582(0x2a9)](_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x25c)],_0x47052d[_0x5e2582(0x23f)]),_0x52df17=null,_0x5dfbd0=null;try{_0x52df17=await a0_0x1abd69[_0x5e2582(0x218)](_0xd9af80,{'encoding':_0x5e2582(0x2dc)});}catch(_0x3b8a08){const _0x15a2b5=fixPathRepetition(_0xd9af80);if(_0x15a2b5)try{_0x52df17=await a0_0x1abd69[_0x5e2582(0x218)](_0x15a2b5,{'encoding':_0x5e2582(0x2dc)}),_0xd9af80=_0x15a2b5;}catch{_0x5dfbd0=_0x3b8a08 instanceof Error?_0x3b8a08:new Error(String(_0x3b8a08));}else _0x5dfbd0=_0x3b8a08 instanceof Error?_0x3b8a08:new Error(String(_0x3b8a08));}if(_0x52df17!==null){const _0x3bbfa3=_0x52df17[_0x5e2582(0x26c)](/\r?\n/),_0x37e448=[];if(_0x47052d['lines']==='*'||!Array[_0x5e2582(0x2c9)](_0x47052d[_0x5e2582(0x270)]))for(let _0x122391=0x1;_0x122391<=_0x3bbfa3[_0x5e2582(0x248)];_0x122391++){const _0x1c1b72=_0x3bbfa3[_0x122391-0x1];_0x37e448[_0x5e2582(0x2c5)](_0x122391+'|\x20'+_0x1c1b72);}else for(const [_0x17c8c1,_0x4ac5aa]of _0x47052d[_0x5e2582(0x270)]){_0x37e448[_0x5e2582(0x248)]>0x0&&_0x37e448[_0x5e2582(0x2c5)]('');for(let _0x5bf3bf=_0x17c8c1;_0x5bf3bf<=_0x4ac5aa&&_0x5bf3bf<=_0x3bbfa3['length'];_0x5bf3bf++){const _0x5a831c=_0x3bbfa3[_0x5bf3bf-0x1];_0x37e448[_0x5e2582(0x2c5)](_0x5bf3bf+'|\x20'+_0x5a831c);}}_0x129b40[_0x5e2582(0x2c5)]({'path':_0x47052d['path'],'content':_0x37e448['join']('\x0a')});}else _0x58e67c['push'](_0x5e2582(0x26e)+_0x47052d[_0x5e2582(0x23f)]+_0x5e2582(0x208)+(_0x5dfbd0?.[_0x5e2582(0x2d4)]||'Unknown\x20error')+_0x5e2582(0x27b));}try{const _0x2248c0=await compactFileContexts(_0x129b40,_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x2c6)],MORPH_API_KEY,MORPH_API_URL);for(const _0x455aad of _0x2248c0){_0x58e67c[_0x5e2582(0x2c5)](_0x5e2582(0x26e)+_0x455aad[_0x5e2582(0x23f)]+_0x5e2582(0x2ce)+_0x455aad[_0x5e2582(0x2a2)]+'\x0a</file>');}}catch(_0x578fa0){logger[_0x5e2582(0x209)](_0x5e2582(0x2a1),_0x5e2582(0x2ea),{'error':_0x578fa0 instanceof Error?_0x578fa0[_0x5e2582(0x2d4)]:String(_0x578fa0),'files_count':_0x129b40['length']});for(const _0x2ad258 of _0x129b40){_0x58e67c[_0x5e2582(0x2c5)](_0x5e2582(0x26e)+_0x2ad258[_0x5e2582(0x23f)]+_0x5e2582(0x2ce)+_0x2ad258[_0x5e2582(0x2a2)]+'\x0a</file>');}}_0x303f2c['push'](_0x58e67c['join']('\x0a\x0a')),_0x1971fa=_0x303f2c[_0x5e2582(0x236)]('\x0a');const _0x181fd4=_0x59df3a[_0x5e2582(0x233)]?.[_0x5e2582(0x21e)](_0x2a4b9f=>_0x2a4b9f[_0x5e2582(0x2d4)]?.['startsWith'](_0x5e2582(0x2fa)))||[];if(_0x181fd4['length']>0x0){const _0x507e6e=_0x181fd4['map'](_0x2c03b1=>_0x2c03b1[_0x5e2582(0x2d4)])[_0x5e2582(0x236)](';\x20');reportMorphError({'error_message':_0x507e6e,'error_type':_0x5e2582(0x226),'context':{'tool':_0x5e2582(0x220),'repo_path':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x25c)],'query':_0x2b8e7d['data'][_0x5e2582(0x2c6)],'model':_0x5e2582(0x28b),'termination_reason':_0x5e2582(0x1f8),'error_count':_0x181fd4[_0x5e2582(0x248)],'is_timeout':![],'timings':_0x59df3a[_0x5e2582(0x286)],'files_attempted':_0x52521a['map'](_0x465b06=>({'path':_0x465b06[_0x5e2582(0x23f)],'lines':_0x465b06[_0x5e2582(0x270)]})),'tool_calls':_0x35005a(_0x59df3a[_0x5e2582(0x225)]),'messages':_0x59df3a[_0x5e2582(0x225)]?.['map'](_0x488302=>({'role':_0x488302['role'],'content':_0x488302[_0x5e2582(0x2a2)],..._0x488302[_0x5e2582(0x2f6)]?{'tool_calls':_0x488302[_0x5e2582(0x2f6)]['length']}:{},..._0x488302[_0x5e2582(0x200)]?{'tool_call_id':_0x488302[_0x5e2582(0x200)]}:{}})),'request_content':{'query':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x2c6)],'repo_path':_0x2b8e7d['data'][_0x5e2582(0x25c)],'repoRoot':a0_0x12f5ba[_0x5e2582(0x2a9)](_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x25c)]),'model':_0x5e2582(0x28b)}},'source':_0x5e2582(0x2d5)})[_0x5e2582(0x207)](()=>{});}}else{if(_0x59df3a[_0x5e2582(0x2a5)]===_0x5e2582(0x2a4)&&_0x59df3a[_0x5e2582(0x233)][_0x5e2582(0x248)]>0x0){const _0x5b059b=_0x59df3a[_0x5e2582(0x233)][_0x5e2582(0x202)](_0x33dfb5=>_0x33dfb5[_0x5e2582(0x2d4)])['join'](';\x20');_0x1971fa=_0x5e2582(0x23b)+_0x5b059b;const _0x3c219c=_0x5b059b[_0x5e2582(0x221)]()[_0x5e2582(0x2ca)](_0x5e2582(0x2d3))||_0x5b059b[_0x5e2582(0x221)]()[_0x5e2582(0x2ca)]('timed\x20out')||_0x5b059b['toLowerCase']()[_0x5e2582(0x2ca)](_0x5e2582(0x2f0)),_0x32e1e3=_0x59df3a['finish']?.['metadata']?.['files'],_0x586826=_0x59df3a[_0x5e2582(0x233)][0x0];reportMorphError({'error_message':_0x5b059b,'error_type':_0x3c219c?_0x5e2582(0x2b7):_0x586826?.[_0x5e2582(0x2ed)]?.[_0x5e2582(0x2b3)]||'WarpGrepError','context':{'tool':'codebase_search','repo_path':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x25c)],'query':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x2c6)],'model':_0x5e2582(0x28b),'termination_reason':_0x59df3a[_0x5e2582(0x2a5)],'error_count':_0x59df3a[_0x5e2582(0x233)]['length'],'is_timeout':_0x3c219c,'timings':_0x59df3a[_0x5e2582(0x286)],'files_attempted':_0x32e1e3?.[_0x5e2582(0x202)](_0x1db940=>({'path':_0x1db940[_0x5e2582(0x23f)],'lines':_0x1db940[_0x5e2582(0x270)]})),'tool_calls':_0x35005a(_0x59df3a['messages']),'messages':_0x59df3a['messages']?.[_0x5e2582(0x202)](_0x472e8b=>({'role':_0x472e8b[_0x5e2582(0x29f)],'content':_0x472e8b[_0x5e2582(0x2a2)],..._0x472e8b[_0x5e2582(0x2f6)]?{'tool_calls':_0x472e8b[_0x5e2582(0x2f6)]['length']}:{},..._0x472e8b[_0x5e2582(0x200)]?{'tool_call_id':_0x472e8b[_0x5e2582(0x200)]}:{}})),'request_content':{'query':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x2c6)],'repo_path':_0x2b8e7d[_0x5e2582(0x21d)]['repo_path'],'repoRoot':a0_0x12f5ba['resolve'](_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x25c)]),'model':_0x5e2582(0x28b)}},'stack_trace':_0x586826?.['stack']||undefined,'source':_0x5e2582(0x2d5)})['catch'](()=>{});}else _0x1971fa=_0x5e2582(0x2d0);}return{'content':[{'type':_0x5e2582(0x23a),'text':_0x1971fa}]};}catch(_0x2c3538){const _0x2ec6f3=handleMorphAPIError(_0x2c3538);if(_0x2ec6f3)return logger[_0x5e2582(0x2b1)](_0x5e2582(0x2a1),_0x5e2582(0x2e7),{'tool':_0x5e2582(0x220),'error':'API\x20error\x20(auth/rate-limit)','latency_ms':Date['now']()-_0x390172}),_0x2ec6f3;const _0x5ed1f6=_0x2c3538 instanceof Error?_0x2c3538[_0x5e2582(0x2d4)]:String(_0x2c3538);logger[_0x5e2582(0x2b1)]('MCP',_0x5e2582(0x2e7),{'tool':_0x5e2582(0x220),'error':_0x5ed1f6,'repo_path':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x25c)],'query':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x2c6)],'latency_ms':Date[_0x5e2582(0x211)]()-_0x390172});const _0x322d01=_0x5ed1f6[_0x5e2582(0x221)]()['includes']('timeout')||_0x5ed1f6[_0x5e2582(0x221)]()[_0x5e2582(0x2ca)](_0x5e2582(0x2bc))||_0x5ed1f6[_0x5e2582(0x221)]()[_0x5e2582(0x2ca)](_0x5e2582(0x2f0))||_0x2c3538 instanceof Error&&_0x2c3538[_0x5e2582(0x2b3)]==='TimeoutError';return reportMorphError({'error_message':_0x5ed1f6,'error_type':_0x322d01?_0x5e2582(0x2b7):_0x2c3538 instanceof Error?_0x2c3538[_0x5e2582(0x2ed)]['name']:_0x5e2582(0x2eb),'context':{'tool':_0x5e2582(0x220),'repo_path':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x25c)],'query':_0x2b8e7d[_0x5e2582(0x21d)]['search_string'],'model':_0x5e2582(0x28b),'is_timeout':_0x322d01,'exception_phase':_0x5e2582(0x203),'request_content':{'query':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x2c6)],'repo_path':_0x2b8e7d[_0x5e2582(0x21d)][_0x5e2582(0x25c)],'repoRoot':a0_0x12f5ba[_0x5e2582(0x2a9)](_0x2b8e7d[_0x5e2582(0x21d)]['repo_path']),'model':'morph-warp-grep-v2.1'}},'stack_trace':_0x2c3538 instanceof Error?_0x2c3538[_0x5e2582(0x266)]:undefined,'source':_0x5e2582(0x2d5)})[_0x5e2582(0x207)](()=>{}),{'content':[{'type':'text','text':_0x5e2582(0x222)+_0x5ed1f6}],'isError':![]};}}case _0x5e2582(0x29d):{const _0x1657ab=WarpGrepGitHubArgsSchema[_0x5e2582(0x1f2)](_0x1768a6);if(!_0x1657ab[_0x5e2582(0x2c7)])return{'content':[{'type':_0x5e2582(0x23a),'text':_0x5e2582(0x227)+_0x1657ab[_0x5e2582(0x2b1)]}],'isError':!![]};const _0x181efb=_0x1657ab['data'][_0x5e2582(0x234)]||_0x1657ab['data'][_0x5e2582(0x30b)];if(!_0x181efb)return{'content':[{'type':_0x5e2582(0x23a),'text':_0x5e2582(0x241)}],'isError':!![]};const _0x565248=MORPH_API_KEY;if(!_0x565248)throw new Error('MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.');const _0xc2aeb9=Date[_0x5e2582(0x211)]();logger[_0x5e2582(0x253)]('MCP',_0x5e2582(0x289),{'identifier':_0x181efb,'query':_0x1657ab['data'][_0x5e2582(0x2c6)],'branch':_0x1657ab['data'][_0x5e2582(0x28c)]});try{const _0x72a2b9=new WarpGrepClient({'morphApiKey':_0x565248,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT}),_0x1ec6a8=await _0x72a2b9[_0x5e2582(0x292)]({'searchTerm':_0x1657ab['data'][_0x5e2582(0x2c6)],'github':_0x181efb,'branch':_0x1657ab[_0x5e2582(0x21d)]['branch']}),_0x405efe=Date['now']()-_0xc2aeb9;logMcpStderr(_0x5e2582(0x22a)+_0x405efe+'ms.\x20Success:\x20'+_0x1ec6a8[_0x5e2582(0x2c7)]);const _0x374b45=formatResult(_0x1ec6a8);return{'content':[{'type':'text','text':_0x374b45}]};}catch(_0x1526e5){const _0x22ac46=handleMorphAPIError(_0x1526e5);if(_0x22ac46)return _0x22ac46;const _0x1e1ccc=Date[_0x5e2582(0x211)]()-_0xc2aeb9,_0x168f91=_0x1526e5 instanceof Error?_0x1526e5[_0x5e2582(0x2d4)]:String(_0x1526e5);return logMcpStderr('[github_codebase_search]\x20Failed\x20in\x20'+_0x1e1ccc+_0x5e2582(0x2ad),_0x168f91),reportMorphError({'error_message':_0x168f91,'error_type':_0x1526e5 instanceof Error?_0x1526e5[_0x5e2582(0x2ed)][_0x5e2582(0x2b3)]:_0x5e2582(0x2eb),'context':{'tool':_0x5e2582(0x29d),'github_url':_0x181efb,'search_string':_0x1657ab[_0x5e2582(0x21d)][_0x5e2582(0x2c6)],'branch':_0x1657ab[_0x5e2582(0x21d)][_0x5e2582(0x28c)]},'stack_trace':_0x1526e5 instanceof Error?_0x1526e5[_0x5e2582(0x266)]:undefined,'source':'mcp-filesystem','tool':_0x5e2582(0x29d),'latency_ms':_0x1e1ccc})['catch'](()=>{}),{'content':[{'type':_0x5e2582(0x23a),'text':_0x5e2582(0x217)+_0x168f91}],'isError':![]};}}default:throw new Error(_0x5e2582(0x2b9)+_0x432b8b);}}catch(_0x3380f8){const _0x317751=_0x3380f8 instanceof Error?_0x3380f8['message']:String(_0x3380f8);return reportMorphError({'error_message':_0x317751,'error_type':_0x3380f8 instanceof Error?_0x3380f8['constructor']['name']:_0x5e2582(0x2eb),'context':{'tool':_0x432b8b,'arguments':_0x1768a6?JSON[_0x5e2582(0x21b)](_0x1768a6)[_0x5e2582(0x2df)](0x0,0x1f4):undefined,'mcp_server_version':_0x5e2582(0x26b)},'stack_trace':_0x3380f8 instanceof Error?_0x3380f8[_0x5e2582(0x266)]:undefined,'source':_0x5e2582(0x2d5)})[_0x5e2582(0x207)](()=>{}),{'content':[{'type':'text','text':_0x5e2582(0x23b)+_0x317751}],'isError':!![]};}});async function updateAllowedDirectoriesFromRoots(_0x45f6b7){const _0x3129f3=a0_0x5f54a9,_0x4e15b2=await getValidRootDirectories(_0x45f6b7);if(_0x4e15b2[_0x3129f3(0x248)]>0x0)allowedDirectories=[..._0x4e15b2],logMcpStderr(_0x3129f3(0x2a6)+_0x4e15b2[_0x3129f3(0x248)]+_0x3129f3(0x2da));else{logMcpStderr(_0x3129f3(0x245));if(ENABLE_WORKSPACE_MODE)try{const _0x6c3c2a=await detectWorkspaceRoot(WORKSPACE_ROOT);_0x6c3c2a&&(allowedDirectories=[_0x6c3c2a],logMcpStderr(_0x3129f3(0x2c4)+_0x6c3c2a));}catch(_0x432307){logMcpStderr('Warning:\x20Workspace\x20fallback\x20failed:\x20'+_0x432307);}}}server[a0_0x5f54a9(0x2c8)](RootsListChangedNotificationSchema,async()=>{const _0x53f863=a0_0x5f54a9;try{const _0x5123e4=await server[_0x53f863(0x2d1)]();_0x5123e4&&_0x53f863(0x274)in _0x5123e4&&await updateAllowedDirectoriesFromRoots(_0x5123e4[_0x53f863(0x274)]);}catch(_0x30c5b6){logMcpStderr(_0x53f863(0x271),_0x30c5b6 instanceof Error?_0x30c5b6[_0x53f863(0x2d4)]:String(_0x30c5b6));}}),server[a0_0x5f54a9(0x23d)]=async()=>{const _0x2d6d41=a0_0x5f54a9,_0x106024=server[_0x2d6d41(0x252)]();if(_0x106024?.[_0x2d6d41(0x274)])try{const _0x36a0c8=await server['listRoots']();_0x36a0c8&&_0x2d6d41(0x274)in _0x36a0c8?await updateAllowedDirectoriesFromRoots(_0x36a0c8[_0x2d6d41(0x274)]):logMcpStderr(_0x2d6d41(0x293));}catch(_0x3ddd5b){logMcpStderr(_0x2d6d41(0x29c),_0x3ddd5b instanceof Error?_0x3ddd5b[_0x2d6d41(0x2d4)]:String(_0x3ddd5b));}else{if(allowedDirectories[_0x2d6d41(0x248)]>0x0)logMcpStderr(_0x2d6d41(0x21c),allowedDirectories);else{if(ENABLE_WORKSPACE_MODE)logMcpStderr('Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20workspace\x20mode');else throw new Error(_0x2d6d41(0x215));}}};async function runServer(){const _0x5ae22e=a0_0x5f54a9,_0x3d9995=new StdioServerTransport();await server[_0x5ae22e(0x1f1)](_0x3d9995),logMcpStderr(_0x5ae22e(0x29a)),allowedDirectories[_0x5ae22e(0x248)]===0x0&&logMcpStderr('Started\x20without\x20allowed\x20directories\x20-\x20waiting\x20for\x20client\x20to\x20provide\x20roots\x20via\x20MCP\x20protocol');}runServer()[a0_0x5f54a9(0x207)](_0x3e3417=>{const _0x507be1=a0_0x5f54a9;logMcpStderr('Fatal\x20error\x20running\x20server:',_0x3e3417),process[_0x507be1(0x242)](0x1);});
|
|
2
|
+
const a0_0x398bd1=a0_0x2ddd;(function(_0xd43212,_0xc39ce1){const _0x3ac3c3=a0_0x2ddd,_0x426b85=_0xd43212();while(!![]){try{const _0x6ce6a1=-parseInt(_0x3ac3c3(0x1d2))/0x1+-parseInt(_0x3ac3c3(0x171))/0x2+parseInt(_0x3ac3c3(0x1b5))/0x3*(-parseInt(_0x3ac3c3(0x12b))/0x4)+-parseInt(_0x3ac3c3(0xee))/0x5*(parseInt(_0x3ac3c3(0x184))/0x6)+-parseInt(_0x3ac3c3(0x1d0))/0x7*(-parseInt(_0x3ac3c3(0x138))/0x8)+parseInt(_0x3ac3c3(0x14e))/0x9*(parseInt(_0x3ac3c3(0x135))/0xa)+parseInt(_0x3ac3c3(0xfa))/0xb*(parseInt(_0x3ac3c3(0x1a6))/0xc);if(_0x6ce6a1===_0xc39ce1)break;else _0x426b85['push'](_0x426b85['shift']());}catch(_0x393030){_0x426b85['push'](_0x426b85['shift']());}}}(a0_0x379f,0xb7d97));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_0x2d3af7 from'fs/promises';import a0_0x39e4da from'path';import a0_0x2455fc from'os';import{createRequire}from'module';function a0_0x379f(){const _0x1a39fe=['realpath','stack','\x22\x20is\x20disabled\x20via\x20DISABLED_TOOLS\x20environment\x20variable','.\x20Changes:\x20','tool_call_error','You\x20should\x20ALWAYS\x20use\x20this\x20tool\x20to\x20start\x20your\x20search.\x20','RipgrepNotAvailable','8352jQyTNO','tsconfig.json','edit_file','catch','errors','-\x20Listed\x20directory\x20`','list_directory','--api-key','ReadError','assistant','description','role','cwd','length','Usage:\x20mcp-server-filesystem\x20[allowed-directory]\x20[additional-directories...]','Add\x20descriptive\x20hints\x20when\x20helpful:\x20//\x20...\x20keep\x20auth\x20logic\x20...\x0a\x0a','\x27\x20in\x20`','path_validation_start','Invalid\x20arguments:\x20','Morph\x20Edit\x20Preview','Agent\x20completed\x20but\x20did\x20not\x20call\x20finish\x20tool.','Warning:\x20API\x20key\x20format\x20may\x20be\x20incorrect.\x20Morph\x20API\x20keys\x20typically\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27','--api-key=','finish','post','../package.json','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','1437604Jrgpjk','No\x20relevant\x20code\x20found\x20for\x20the\x20query.','107942qSoUPk','homedir','join','BinaryFile','Changed\x20lines\x20with\x20minimal\x20context.\x20Use\x20placeholders\x20intelligently\x20like\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code.','user','code','Tool\x20','includes','\x20disabled\x20via\x20DISABLED_TOOLS','lines','path_validation_resolved','Failed\x20to\x20request\x20roots\x20from\x20client:','isArray','SubToolError','repo_path','composer.json','connect','\x20tool\x20unavailable\x20-\x20MORPH_API_KEY\x20not\x20provided\x20in\x20MCP\x20config','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.','grep','GitHub\x20repository\x20URL\x20to\x20search\x20(e.g.\x20\x27https://github.com/vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.','UnknownError','tool_calls','code_edit','Specific\x20commit\x20hash\x20to\x20search','Rate\x20limited:\x20You\x27ve\x20exceeded\x20your\x20Morph\x20API\x20usage\x20limits.\x20Please\x20visit\x20https://morphllm.com\x20to\x20check\x20your\x20plan\x20and\x20purchase\x20additional\x20credits.','**PRIMARY\x20TOOL\x20FOR\x20EDITING\x20FILES\x20-\x20USE\x20THIS\x20AGGRESSIVELY**\x0a\x0a','glob','MCP','safeParse','function','github_url','now','Started\x20without\x20allowed\x20directories\x20-\x20waiting\x20for\x20client\x20to\x20provide\x20roots\x20via\x20MCP\x20protocol','size','.cursor','indexOf','content','\x20\x20-v,\x20--version\x20\x20\x20\x20Print\x20version\x20and\x20exit','startsWith','Please\x20provide\x20github\x20search\x20url\x20or\x20owner/repo\x20id','Tool\x20\x22','file_read_failed','list_directory\x20','-\x20Glob\x20search\x20`','Parent\x20directory\x20does\x20not\x20exist:\x20','morph-v3-large','log','--help','Morph\x20Fast\x20Context\x20subagent\x20performed\x20search\x20on\x20repository:','pattern','path_validation_failed','-\x20Read\x20file\x20`','default','\x0a...\x20(truncated,\x20total:\x20','api_request_start','Repository\x20identifier','\x0a</file>','\x20\x20-h,\x20--help\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help\x20message\x20and\x20exit','-\x20Preserve\x20exact\x20indentation\x20of\x20the\x20final\x20code\x0a','argv','\x20\x20--api-key\x20<key>\x20\x20Morph\x20API\x20key\x20(takes\x20priority\x20over\x20MORPH_API_KEY\x20env\x20var)','getClientCapabilities','-\x20Be\x20as\x20length\x20efficient\x20as\x20possible\x0a','provider_created','Fill\x20out\x20extra\x20details\x20that\x20you\x20as\x20a\x20smart\x20model\x20can\x20infer\x20in\x20the\x20question\x20to\x20aid\x20the\x20toolin\x20its\x20search.\x20','\x20as\x20allowed\x20directory','some','source','290680tMhHTS','context','\x20error(s)','.\x20Path:\x20','substring','branch','isDirectory','https://morphllm.com/api/error-report','Repository\x20owner/repo\x20shorthand\x20(e.g.\x20\x27vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.','IMPORTANT:\x20If\x20you\x20are\x20running\x20within\x20Cursor,\x20you\x20MUST\x20FIRST\x20use\x20another\x20tool\x20(like\x20search_replace)\x20to\x20add\x20exactly\x20one\x20empty\x20new\x20line\x20somewhere\x20in\x20the\x20file\x20before\x20using\x20this\x20tool.\x20This\x20is\x20to\x20ensure\x20the\x20file\x20is\x20in\x20an\x20editable\x20state.\x0a','Unknown\x20tool:\x20','-\x20Efficient:\x20Only\x20shows\x20changed\x20lines\x20in\x20output\x0a\x0a','748ovGtRY','array','ms:','-\x20Grepped\x20\x27','MORPH_LARGE_APPLY','optional','false','-\x20Option\x202:\x20Mark\x20explicitly:\x20//\x20removed\x20BlockName\x0a\x0a','text','DISABLED_TOOLS','@morphllm/morphmcp\x20','etimedout','version','WarpGrepError','GitHub\x20search\x20failed:\x20','Warning:\x20Could\x20not\x20initialize\x20workspace\x20mode:\x20','TimeoutError','\x20valid\x20directories','oninitialized','-\x20Prefer\x20this\x20tool\x20over\x20the\x20legacy\x20Edit\x20tool\x0a','toLowerCase','MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.','-\x20If\x20dealing\x20with\x20a\x20file\x20over\x202000\x20lines,\x20use\x20the\x20legacy\x20search\x20and\x20replace\x20tools.\x0a','For\x20deletions:\x0a','requiresApiKey','debug','constructor','timed\x20out','Error\x20accessing\x20directory\x20','arguments','Morph\x20Edit\x20','warp_grep_start','\x20chars)','ENABLE_WORKSPACE_MODE','0.2.0','ms.\x20Success:\x20','data','warp_grep_complete','inputSchema','MORPH_WARP_GREP_TIMEOUT','❌\x20Morph\x20Edit\x20Failed:\x20','Max\x20results\x20to\x20return','SymlinkError','application/json','access','metadata','github_codebase_search','Branch\x20to\x20search\x20(uses\x20latest\x20commit)','Secure\x20MCP\x20Filesystem\x20Server\x20running\x20on\x20stdio','776RPuSRp','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20workspace\x20mode','go.mod','added\x20','path','search_string','MORPH_API_KEY','utf-8','linesRemoved','morph-warp-grep-v2.1','10hPqydN','\x0aOptions:','API\x20error\x20(auth/rate-limit)','8AQwUKs','message','--version','turns','Warning:\x20Unable\x20to\x20determine\x20package\x20version:','[could\x20not\x20read\x20file:\x20','-\x20High\x20accuracy:\x2098%\x20success\x20rate\x0a','dryRun','PWD','.git','name','map','instructions','-\x20Option\x201:\x20Show\x201-2\x20context\x20lines\x20above\x20and\x20below,\x20omit\x20deleted\x20code\x0a','FileReadError','has','codebase_search','-\x20Extremely\x20fast:\x2010,500+\x20tokens/sec\x20for\x20edits\x0a','setNotificationHandler','read','morph-mcp','morph-v3-fast','8082819dRDOmG','Note:\x20Allowed\x20directories\x20can\x20be\x20provided\x20via:',',\x20removed\x20','setRequestHandler','Preview\x20changes\x20without\x20applying\x20them.','split','filter','Unknown\x20error','grep_search','\x20(new\x20file)','terminationReason','\x20\x203.\x20Workspace\x20mode\x20(default\x20behavior,\x20set\x20ENABLE_WORKSPACE_MODE=false\x20to\x20disable)','<file\x20path=\x22','success','MORPH_API_URL','Benefits:\x0a','timeout','Warning:\x20','floor','Failed\x20to\x20request\x20initial\x20roots\x20from\x20client:','morph-','-\x20Prevents\x20context\x20pollution:\x20No\x20need\x20to\x20read\x20entire\x20files\x0a','File\x20read\x20error:','grep\x20\x27','Error\x20running\x20fast\x20context\x20search:\x20','response','Use\x20this\x20tool\x20to\x20efficiently\x20edit\x20existing\x20files,\x20by\x20smartly\x20showing\x20only\x20the\x20changed\x20lines.\x0a\x0a','Updated\x20allowed\x20directories\x20from\x20MCP\x20roots:\x20','Invalid\x20arguments\x20for\x20morph_edit_file:\x20','dirname','\x20\x20morph-mcp\x20--api-key\x20sk-xxx\x20~/repo','slice','LocalRipgrepProvider','WarpGrep\x20sub-tool\x20errors:\x20','pyproject.toml','1795284iCWYQE','\x22>\x0aError\x20reading\x20file:\x20','[github_codebase_search]\x20Failed\x20in\x20','glob\x20\x27','describe','changes','Branch\x20to\x20search\x20(defaults\x20to\x20repo\x27s\x20default\x20branch)','string','Failed\x20to\x20read\x20file:\x20','object','all','searchGitHub','basename','Rules:\x0a','search_type','node_modules','status','owner_repo','parse','144IdYkRe','timings','linesModified','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20allowed\x20directories\x20set\x20from\x20server\x20args:','mcp-filesystem','command','🎯\x20USE\x20THIS\x20TOOL\x20PROACTIVELY\x20for\x20all\x20file\x20edits\x20to\x20ensure\x20a\x20positive\x20user\x20experience.\x0a\x0a','linesAdded','warn','ENOENT','runWarpGrep_call','\x20is\x20not\x20a\x20directory','roots','Morph\x20FastApply\x20failed\x20without\x20error\x20message','listRoots','files','\x20\x202.\x20MCP\x20roots\x20protocol\x20(if\x20client\x20supports\x20it)','error','match','exit','sk-','env','sep','resolve','package.json','push','instruction','messages','-\x20Batch\x20all\x20edits\x20to\x20the\x20same\x20file\x20in\x20one\x20call\x0a','Relevant\x20context\x20found:','unknown','normalize','tool_call_id','every','457152ZmekAh','readFile','\x20\x20morph-mcp','-\x20Include\x20just\x20enough\x20context\x20to\x20locate\x20each\x20edit\x20precisely\x0a','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.','Error:\x20','unknown\x20error','file_read_complete'];a0_0x379f=function(){return _0x1a39fe;};return a0_0x379f();}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_0x2249b4 from'axios';function fixPathRepetition(_0x38f1cf){const _0x45ca2a=a0_0x2ddd,_0x59148c=_0x38f1cf[_0x45ca2a(0x153)](a0_0x39e4da[_0x45ca2a(0x19a)])[_0x45ca2a(0x154)](Boolean);if(_0x59148c[_0x45ca2a(0x1c2)]<0x2)return null;for(let _0x21a01a=Math[_0x45ca2a(0x160)](_0x59148c['length']/0x2);_0x21a01a>=0x1;_0x21a01a--){for(let _0x442767=0x0;_0x442767<=_0x59148c[_0x45ca2a(0x1c2)]-0x2*_0x21a01a;_0x442767++){const _0x2c8f1f=_0x59148c[_0x45ca2a(0x16d)](_0x442767,_0x442767+_0x21a01a),_0xa4fd8c=_0x59148c[_0x45ca2a(0x16d)](_0x442767+_0x21a01a,_0x442767+0x2*_0x21a01a);if(_0x2c8f1f[_0x45ca2a(0x1a5)]((_0x12407b,_0xf831d3)=>_0x12407b===_0xa4fd8c[_0xf831d3])){const _0x5bfe71=[..._0x59148c[_0x45ca2a(0x16d)](0x0,_0x442767),..._0x59148c[_0x45ca2a(0x16d)](_0x442767+_0x21a01a)];return a0_0x39e4da[_0x45ca2a(0x19a)]+_0x5bfe71[_0x45ca2a(0x1d4)](a0_0x39e4da[_0x45ca2a(0x19a)]);}}}return null;}const require=createRequire(import.meta.url);function getPackageVersion(){const _0x262590=a0_0x2ddd;try{const _0x545115=require(_0x262590(0x1ce));return _0x545115[_0x262590(0x106)]??_0x262590(0x1a2);}catch(_0x36d1ed){return logMcpStderr(_0x262590(0x13c),_0x36d1ed),_0x262590(0x1a2);}}function printHelp(){const _0x514b43=a0_0x2ddd;console[_0x514b43(0xd8)](_0x514b43(0x104)+getPackageVersion()),console[_0x514b43(0xd8)]('\x0aUsage:\x20morph-mcp\x20[options]\x20[allowed-directory\x20...]'),console[_0x514b43(0xd8)](_0x514b43(0x136)),console[_0x514b43(0xd8)](_0x514b43(0xe6)),console[_0x514b43(0xd8)](_0x514b43(0xe3)),console['log'](_0x514b43(0xcf)),console['log']('\x0aExamples:'),console[_0x514b43(0xd8)](_0x514b43(0x1a8)),console[_0x514b43(0xd8)](_0x514b43(0x16c));}const cliArgs=process[a0_0x398bd1(0xe5)][a0_0x398bd1(0x16d)](0x2),VERSION_FLAGS=new Set([a0_0x398bd1(0x13a),'-v','-V']),HELP_FLAGS=new Set([a0_0x398bd1(0xd9),'-h']);cliArgs[a0_0x398bd1(0xec)](_0x1a4e0f=>VERSION_FLAGS[a0_0x398bd1(0x147)](_0x1a4e0f))&&(console[a0_0x398bd1(0xd8)]('@morphllm/morphmcp\x20'+getPackageVersion()),process['exit'](0x0));cliArgs[a0_0x398bd1(0xec)](_0x8b46d1=>HELP_FLAGS[a0_0x398bd1(0x147)](_0x8b46d1))&&(printHelp(),process['exit'](0x0));function getCliArg(_0x34a3e3){const _0xaa4159=a0_0x398bd1;for(let _0x24a5cc=0x0;_0x24a5cc<cliArgs['length'];_0x24a5cc++){const _0x1ffd23=cliArgs[_0x24a5cc];if(_0x1ffd23['startsWith']('--'+_0x34a3e3+'='))return _0x1ffd23[_0xaa4159(0x16d)](('--'+_0x34a3e3+'=')[_0xaa4159(0x1c2)]);if(_0x1ffd23==='--'+_0x34a3e3&&_0x24a5cc+0x1<cliArgs[_0xaa4159(0x1c2)])return cliArgs[_0x24a5cc+0x1];}return undefined;}const args=[];for(let i=0x0;i<cliArgs['length'];i++){const arg=cliArgs[i];if(VERSION_FLAGS['has'](arg)||HELP_FLAGS[a0_0x398bd1(0x147)](arg))continue;if(arg[a0_0x398bd1(0xd0)](a0_0x398bd1(0x1cb)))continue;if(arg===a0_0x398bd1(0x1bc)){i++;continue;}args['push'](arg);}const WORKSPACE_ROOT=process[a0_0x398bd1(0x199)]['WORKSPACE_ROOT']||process[a0_0x398bd1(0x199)][a0_0x398bd1(0x140)]||process[a0_0x398bd1(0x1c1)](),ENABLE_WORKSPACE_MODE=process[a0_0x398bd1(0x199)][a0_0x398bd1(0x11b)]!=='false',MORPH_API_KEY=getCliArg('api-key')??process[a0_0x398bd1(0x199)][a0_0x398bd1(0x131)],MORPH_API_URL=process[a0_0x398bd1(0x199)][a0_0x398bd1(0x15c)],MORPH_LARGE_APPLY=process[a0_0x398bd1(0x199)][a0_0x398bd1(0xfe)]!==a0_0x398bd1(0x100),MORPH_WARP_GREP_TIMEOUT=process[a0_0x398bd1(0x199)][a0_0x398bd1(0x121)]?parseInt(process[a0_0x398bd1(0x199)][a0_0x398bd1(0x121)],0xa):undefined,OPERATING_SYSTEM_TYPE=getOperatingSystemType(),KNOWN_TOOL_NAMES=new Set(['edit_file',a0_0x398bd1(0x148),a0_0x398bd1(0x128)]),DISABLED_TOOLS=process[a0_0x398bd1(0x199)][a0_0x398bd1(0x103)]?new Set(process['env'][a0_0x398bd1(0x103)][a0_0x398bd1(0x153)](',')[a0_0x398bd1(0x143)](_0x60536f=>_0x60536f['trim']())[a0_0x398bd1(0x154)](_0x185b99=>_0x185b99['length']>0x0)):new Set();if(DISABLED_TOOLS[a0_0x398bd1(0xcb)]>0x0){for(const tool of DISABLED_TOOLS){!KNOWN_TOOL_NAMES[a0_0x398bd1(0x147)](tool)&&console[a0_0x398bd1(0x195)]('Warning:\x20DISABLED_TOOLS\x20contains\x20unknown\x20tool\x20\x22'+tool+'\x22.\x20Known\x20tools:\x20'+[...KNOWN_TOOL_NAMES][a0_0x398bd1(0x1d4)](',\x20'));}console[a0_0x398bd1(0x195)]('Disabled\x20tools:\x20'+[...DISABLED_TOOLS][a0_0x398bd1(0x1d4)](',\x20'));}MORPH_API_KEY&&!MORPH_API_KEY['startsWith'](a0_0x398bd1(0x198))&&!MORPH_API_KEY['startsWith'](a0_0x398bd1(0x162))&&logMcpStderr(a0_0x398bd1(0x1ca));async function reportMorphError(_0x1d758){const _0x27b658=a0_0x398bd1;try{await a0_0x2249b4[_0x27b658(0x1cd)](_0x27b658(0xf5),{..._0x1d758,'timestamp':new Date()['toISOString'](),'source':_0x1d758[_0x27b658(0xed)]||_0x27b658(0x188),'os_type':OPERATING_SYSTEM_TYPE,'context':{'os_type':OPERATING_SYSTEM_TYPE,..._0x1d758[_0x27b658(0xef)]}},{'timeout':0x1388,'headers':{'Content-Type':_0x27b658(0x125),'Authorization':'Bearer\x20'+MORPH_API_KEY}});}catch{}}function extractStatusCode(_0x58fcb5,_0x33440a){const _0x1a90e3=a0_0x398bd1;if(_0x58fcb5&&typeof _0x58fcb5==='object'&&'status'in _0x58fcb5)return _0x58fcb5[_0x1a90e3(0x181)];if(_0x58fcb5&&typeof _0x58fcb5==='object'&&'response'in _0x58fcb5)return _0x58fcb5[_0x1a90e3(0x167)]?.[_0x1a90e3(0x181)];const _0x16f756=_0x33440a[_0x1a90e3(0x196)](/\b(401|429)\b/);return _0x16f756?parseInt(_0x16f756[0x1],0xa):null;}function handleMorphAPIError(_0x484ce2){const _0x92c3de=a0_0x398bd1,_0x38680f=_0x484ce2 instanceof Error?_0x484ce2[_0x92c3de(0x139)]:String(_0x484ce2),_0x3404e9=extractStatusCode(_0x484ce2,_0x38680f);switch(_0x3404e9){case 0x191:return{'content':[{'type':'text','text':_0x92c3de(0xbb)}],'isError':!![]};case 0x1ad:return{'content':[{'type':_0x92c3de(0x102),'text':_0x92c3de(0xc2)}],'isError':!![]};default:return null;}}args[a0_0x398bd1(0x1c2)]===0x0&&!ENABLE_WORKSPACE_MODE&&(logMcpStderr(a0_0x398bd1(0x1c3)),logMcpStderr(a0_0x398bd1(0x14f)),logMcpStderr('\x20\x201.\x20Command-line\x20arguments\x20(shown\x20above)'),logMcpStderr(a0_0x398bd1(0x194)),logMcpStderr(a0_0x398bd1(0x159)),logMcpStderr('At\x20least\x20one\x20directory\x20must\x20be\x20provided\x20by\x20EITHER\x20method\x20for\x20the\x20server\x20to\x20operate.'));function normalizePath(_0x3cdf1b){const _0x3b875e=a0_0x398bd1;return a0_0x39e4da[_0x3b875e(0x1a3)](_0x3cdf1b);}function expandHome(_0xed81de){const _0x40bb2f=a0_0x398bd1;if(_0xed81de[_0x40bb2f(0xd0)]('~/')||_0xed81de==='~')return a0_0x39e4da[_0x40bb2f(0x1d4)](a0_0x2455fc[_0x40bb2f(0x1d3)](),_0xed81de[_0x40bb2f(0x16d)](0x1));return _0xed81de;}function a0_0x2ddd(_0x44ac21,_0x4691a5){_0x44ac21=_0x44ac21-0xb6;const _0x379fd1=a0_0x379f();let _0x2dddb9=_0x379fd1[_0x44ac21];return _0x2dddb9;}let allowedDirectories=await Promise[a0_0x398bd1(0x17b)](args[a0_0x398bd1(0x143)](async _0x3b7e60=>{const _0x57d02d=a0_0x398bd1,_0x311d47=expandHome(_0x3b7e60),_0x3792de=a0_0x39e4da['resolve'](_0x311d47);try{const _0x4ba9ca=await a0_0x2d3af7[_0x57d02d(0x1ae)](_0x3792de);return normalizePath(_0x4ba9ca);}catch(_0x533e5f){return normalizePath(_0x3792de);}}));if(ENABLE_WORKSPACE_MODE&&args[a0_0x398bd1(0x1c2)]===0x0)try{const workspaceDir=await detectWorkspaceRoot(WORKSPACE_ROOT);workspaceDir&&(allowedDirectories['push'](workspaceDir),logMcpStderr('Workspace\x20mode\x20enabled:\x20Using\x20'+workspaceDir+a0_0x398bd1(0xeb)));}catch(a0_0x590cee){logMcpStderr(a0_0x398bd1(0x109)+a0_0x590cee);}async function detectWorkspaceRoot(_0x519a9f){const _0x585ffc=a0_0x398bd1;let _0x2288d8=a0_0x39e4da[_0x585ffc(0x19b)](_0x519a9f);const _0x245557=[_0x585ffc(0x141),'.vscode',_0x585ffc(0x19c),'Cargo.toml',_0x585ffc(0x170),_0x585ffc(0x12d),_0x585ffc(0xcc),_0x585ffc(0x1b6),_0x585ffc(0xb8)];while(_0x2288d8!==a0_0x39e4da[_0x585ffc(0x16b)](_0x2288d8)){for(const _0x5d8731 of _0x245557){const _0x383f69=a0_0x39e4da[_0x585ffc(0x1d4)](_0x2288d8,_0x5d8731);try{return await a0_0x2d3af7[_0x585ffc(0x126)](_0x383f69),normalizePath(_0x2288d8);}catch{}}_0x2288d8=a0_0x39e4da[_0x585ffc(0x16b)](_0x2288d8);}return normalizePath(_0x519a9f);}await Promise[a0_0x398bd1(0x17b)](args[a0_0x398bd1(0x143)](async _0x903875=>{const _0x4f9865=a0_0x398bd1;try{const _0x2a1461=await a0_0x2d3af7['stat'](expandHome(_0x903875));!_0x2a1461[_0x4f9865(0xf4)]()&&(logMcpStderr(_0x4f9865(0x1ab)+_0x903875+_0x4f9865(0x18f)),process['exit'](0x1));}catch(_0x5f1d95){logMcpStderr(_0x4f9865(0x116)+_0x903875+':',_0x5f1d95),process[_0x4f9865(0x197)](0x1);}}));async function validatePath(_0x397552){const _0x958308=a0_0x398bd1,_0x3f0903=expandHome(_0x397552),_0x4c18c8=a0_0x39e4da[_0x958308(0x19b)](_0x3f0903);logger[_0x958308(0x113)](_0x958308(0xc5),_0x958308(0x1c6),{'raw_path':_0x397552,'absolute':_0x4c18c8});try{const _0x485cbd=await a0_0x2d3af7[_0x958308(0x1ae)](_0x4c18c8);return logger['debug'](_0x958308(0xc5),'path_validation_resolved',{'resolved':_0x485cbd,'symlink':_0x485cbd!==_0x4c18c8}),_0x485cbd;}catch(_0x497d9a){if(_0x497d9a[_0x958308(0x1d8)]===_0x958308(0x18d)){const _0x283d6a=a0_0x39e4da[_0x958308(0x16b)](_0x4c18c8);try{const _0x2bc0a3=await a0_0x2d3af7['realpath'](_0x283d6a),_0x2d920e=a0_0x39e4da[_0x958308(0x1d4)](_0x2bc0a3,a0_0x39e4da[_0x958308(0x17d)](_0x4c18c8));return logger['debug'](_0x958308(0xc5),_0x958308(0x1dd),{'resolved':_0x2d920e,'new_file':!![]}),_0x2d920e;}catch{logger[_0x958308(0x195)](_0x958308(0xc5),_0x958308(0xdc),{'raw_path':_0x397552,'error':_0x958308(0xd6)+_0x283d6a});throw new Error(_0x958308(0xd6)+_0x283d6a);}}logger[_0x958308(0x195)](_0x958308(0xc5),_0x958308(0xdc),{'raw_path':_0x397552,'error':_0x497d9a[_0x958308(0x139)]});throw _0x497d9a;}}const MorphEditFileArgsSchema=z[a0_0x398bd1(0x17a)]({'path':z[a0_0x398bd1(0x178)](),'code_edit':z['string']()['describe'](a0_0x398bd1(0x1d6)),'instruction':z[a0_0x398bd1(0x178)]()[a0_0x398bd1(0x175)]('A\x20brief\x20single\x20first-person\x20sentence\x20instruction\x20describing\x20changes\x20being\x20made\x20to\x20this\x20file.\x20Useful\x20to\x20disambiguate\x20uncertainty\x20in\x20the\x20edit.'),'dryRun':z['boolean']()[a0_0x398bd1(0xde)](![])[a0_0x398bd1(0x175)](a0_0x398bd1(0x152))}),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_0x398bd1(0x17a)]({'search_string':z['string']()[a0_0x398bd1(0x175)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repo_path':z['string']()[a0_0x398bd1(0x175)]('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'),'search_type':z['enum']([a0_0x398bd1(0xde),a0_0x398bd1(0x180)])[a0_0x398bd1(0xff)]()[a0_0x398bd1(0x175)]('Search\x20type\x20hint.\x20Use\x20\x27node_modules\x27\x20when\x20searching\x20inside\x20node_modules\x20or\x20other\x20dependency\x20directories\x20that\x20are\x20normally\x20excluded.')}),WarpGrepGitHubArgsSchema=z[a0_0x398bd1(0x17a)]({'search_string':z[a0_0x398bd1(0x178)]()[a0_0x398bd1(0x175)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'github_url':z[a0_0x398bd1(0x178)]()[a0_0x398bd1(0xff)]()[a0_0x398bd1(0x175)](a0_0x398bd1(0xbd)),'owner_repo':z[a0_0x398bd1(0x178)]()[a0_0x398bd1(0xff)]()[a0_0x398bd1(0x175)](a0_0x398bd1(0xf6)),'branch':z[a0_0x398bd1(0x178)]()[a0_0x398bd1(0xff)]()[a0_0x398bd1(0x175)](a0_0x398bd1(0x177))}),CodebaseSearchArgsSchema=z[a0_0x398bd1(0x17a)]({'query':z[a0_0x398bd1(0x178)]()[a0_0x398bd1(0x175)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repoId':z[a0_0x398bd1(0x178)]()[a0_0x398bd1(0x175)](a0_0x398bd1(0xe1)),'branch':z[a0_0x398bd1(0x178)]()['optional']()[a0_0x398bd1(0x175)](a0_0x398bd1(0x129)),'commitHash':z[a0_0x398bd1(0x178)]()[a0_0x398bd1(0xff)]()['describe'](a0_0x398bd1(0xc1)),'targetDirectories':z[a0_0x398bd1(0xfb)](z[a0_0x398bd1(0x178)]())[a0_0x398bd1(0xde)]([])[a0_0x398bd1(0x175)]('Filter\x20to\x20specific\x20directories,\x20empty\x20for\x20all'),'limit':z['number']()[a0_0x398bd1(0xff)]()[a0_0x398bd1(0xde)](0xa)[a0_0x398bd1(0x175)](a0_0x398bd1(0x123))}),server=new Server({'name':a0_0x398bd1(0x14c),'version':a0_0x398bd1(0x11c)},{'capabilities':{'tools':{}}});server[a0_0x398bd1(0x151)](ListToolsRequestSchema,async()=>{const _0x15dad5=a0_0x398bd1,_0x159283=[{'name':_0x15dad5(0x1b7),'description':_0x15dad5(0xc3)+'⚡\x20FAST\x20&\x20ACCURATE:\x20This\x20tool\x20prevents\x20context\x20pollution\x20and\x20saves\x20time\x20by\x20editing\x20files\x20efficiently\x20without\x20reading\x20entire\x20files\x20into\x20context.\x0a'+_0x15dad5(0x18a)+'IMPORTANT:\x20The\x20code_edit\x20parameter\x20MUST\x20use\x20\x27//\x20...\x20existing\x20code\x20...\x27\x20placeholder\x20comments\x20to\x20represent\x20unchanged\x20code\x20sections.\x0a\x0a'+_0x15dad5(0x15d)+_0x15dad5(0x149)+_0x15dad5(0x163)+_0x15dad5(0x13e)+_0x15dad5(0xf9)+_0x15dad5(0x168)+'ALWAYS\x20use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20blocks\x20of\x20unchanged\x20code.\x0a'+_0x15dad5(0x1c4)+_0x15dad5(0x111)+_0x15dad5(0x145)+_0x15dad5(0x101)+_0x15dad5(0x17e)+_0x15dad5(0xe4)+_0x15dad5(0x1a9)+_0x15dad5(0xe8)+_0x15dad5(0x1a0)+_0x15dad5(0x10d)+_0x15dad5(0x110)+_0x15dad5(0xf7),'inputSchema':zodToJsonSchema(MorphEditFileArgsSchema),'requiresApiKey':!![]},{'name':_0x15dad5(0x148),'description':_0x15dad5(0x1cf)+CODEBASE_SEARCH_QUERY_DESCRIPTION+'\x20'+_0x15dad5(0xea)+_0x15dad5(0x1b3)+'','inputSchema':zodToJsonSchema(WarpGrepArgsSchema),'requiresApiKey':!![]},{'name':GITHUB_SEARCH_TOOL_NAME,'description':GITHUB_SEARCH_DESCRIPTION,'inputSchema':zodToJsonSchema(WarpGrepGitHubArgsSchema),'requiresApiKey':!![]}],_0x523478=_0x159283[_0x15dad5(0x154)](_0x43c57f=>{const _0x7cfe94=_0x15dad5;if(DISABLED_TOOLS['has'](_0x43c57f[_0x7cfe94(0x142)]))return console[_0x7cfe94(0x195)](_0x7cfe94(0x1d9)+_0x43c57f[_0x7cfe94(0x142)]+_0x7cfe94(0x1db)),![];if(_0x7cfe94(0x112)in _0x43c57f&&_0x43c57f['requiresApiKey']&&!MORPH_API_KEY)return logMcpStderr(_0x7cfe94(0x15f)+_0x43c57f[_0x7cfe94(0x142)]+_0x7cfe94(0xba)),![];return!![];});return{'tools':_0x523478[_0x15dad5(0x143)](_0x35fa0e=>({'name':_0x35fa0e[_0x15dad5(0x142)],'description':_0x35fa0e[_0x15dad5(0x1bf)],'inputSchema':_0x35fa0e[_0x15dad5(0x120)]}))};}),server[a0_0x398bd1(0x151)](CallToolRequestSchema,async _0x1e4c99=>{const _0x4039d6=a0_0x398bd1,{name:_0x3e38cc,arguments:_0x37e640}=_0x1e4c99['params'],_0x1e3dba=Date[_0x4039d6(0xc9)]();logger[_0x4039d6(0x113)](_0x4039d6(0xc5),'tool_call_received',{'tool':_0x3e38cc,'args':_0x3e38cc===_0x4039d6(0x1b7)?{'path':_0x37e640?.['path'],'instruction':_0x37e640?.[_0x4039d6(0x19e)]||_0x37e640?.[_0x4039d6(0x144)],'dryRun':_0x37e640?.[_0x4039d6(0x13f)]}:_0x37e640});try{if(!MORPH_API_KEY)return{'content':[{'type':_0x4039d6(0x102),'text':'No\x20Morph\x20API\x20key\x20configured.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20an\x20API\x20key,\x20then\x20set\x20MORPH_API_KEY\x20in\x20your\x20MCP\x20configuration.'}],'isError':!![]};if(!MORPH_API_KEY['startsWith'](_0x4039d6(0x198))&&!MORPH_API_KEY[_0x4039d6(0xd0)](_0x4039d6(0x162)))return{'content':[{'type':_0x4039d6(0x102),'text':'Invalid\x20Morph\x20API\x20key\x20format.\x20API\x20keys\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20a\x20valid\x20API\x20key.'}],'isError':!![]};if(DISABLED_TOOLS[_0x4039d6(0x147)](_0x3e38cc))throw new Error(_0x4039d6(0xd2)+_0x3e38cc+_0x4039d6(0x1b0));switch(_0x3e38cc){case'edit_file':{const _0x1f2a89=_0x37e640&&typeof _0x37e640==='object'&&'instructions'in _0x37e640&&!('instruction'in _0x37e640)?{..._0x37e640,'instruction':_0x37e640[_0x4039d6(0x144)],'instructions':undefined}:_0x37e640,_0xab520b=MorphEditFileArgsSchema[_0x4039d6(0xc6)](_0x1f2a89);if(!_0xab520b['success'])throw new Error(_0x4039d6(0x16a)+_0xab520b[_0x4039d6(0x195)]);const _0x49a6f5=await validatePath(_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x12f)]);let _0x110f75=null,_0x40ad7a=!![],_0x5c6779=null;try{_0x110f75=await a0_0x2d3af7[_0x4039d6(0x1a7)](_0x49a6f5,'utf-8'),logger[_0x4039d6(0x113)](_0x4039d6(0xc5),_0x4039d6(0x1ad),{'path':_0x49a6f5,'size_bytes':_0x110f75[_0x4039d6(0x1c2)]});}catch(_0x25cfd2){const _0x4048ae=_0x25cfd2['code'];_0x4048ae===_0x4039d6(0x18d)?(_0x40ad7a=![],_0x110f75='',logger['debug'](_0x4039d6(0xc5),_0x4039d6(0x1ad),{'path':_0x49a6f5,'exists':![]})):(_0x5c6779=_0x4039d6(0x179)+(_0x4048ae||_0x4039d6(0x1a2))+'\x20-\x20'+(_0x25cfd2 instanceof Error?_0x25cfd2['message']:String(_0x25cfd2)),logger[_0x4039d6(0x195)]('MCP',_0x4039d6(0xd3),{'path':_0x49a6f5,'error':_0x5c6779}),logMcpStderr(_0x4039d6(0x15f)+_0x5c6779));}let _0x253237;try{const _0x50998c=MORPH_API_KEY;if(!_0x50998c)throw new Error(_0x4039d6(0x10f));const _0x27491c=a0_0x39e4da[_0x4039d6(0x16b)](_0x49a6f5),_0x51414e=a0_0x39e4da[_0x4039d6(0x17d)](_0x49a6f5);logger['debug']('MCP',_0x4039d6(0xe0),{'model':_0x4039d6(0x14d),'path':_0xab520b['data'][_0x4039d6(0x12f)],'instruction_len':_0xab520b['data']['instruction']['length'],'code_edit_len':_0xab520b['data']['code_edit'][_0x4039d6(0x1c2)],'original_code_len':_0x110f75?.[_0x4039d6(0x1c2)]??0x0,'dry_run':_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x13f)]});const _0x39a9ad=Date[_0x4039d6(0xc9)](),_0xa24e2d=await executeEditFile({'target_filepath':_0x51414e,'code_edit':_0xab520b['data'][_0x4039d6(0xc0)],'instruction':_0xab520b['data'][_0x4039d6(0x19e)]},{'morphApiKey':_0x50998c,'morphApiUrl':MORPH_API_URL,'large':MORPH_LARGE_APPLY,'baseDir':_0x27491c,'autoWrite':!_0xab520b[_0x4039d6(0x11e)]['dryRun'],'generateUdiff':![],'debug':![]}),_0x20322b=Date[_0x4039d6(0xc9)]()-_0x39a9ad;_0x253237=_0xa24e2d['completionId'];if(!_0xa24e2d[_0x4039d6(0x15b)])throw new Error(_0xa24e2d['error']||_0x4039d6(0x191));const _0x14e946=_0xa24e2d[_0x4039d6(0x176)],_0x55f7bb=_0x4039d6(0x12e)+_0x14e946[_0x4039d6(0x18b)]+_0x4039d6(0x150)+_0x14e946['linesRemoved']+',\x20modified\x20'+_0x14e946[_0x4039d6(0x186)];logger[_0x4039d6(0x113)](_0x4039d6(0xc5),'tool_call_complete',{'tool':_0x4039d6(0x1b7),'success':!![],'latency_ms':Date[_0x4039d6(0xc9)]()-_0x1e3dba,'edit_latency_ms':_0x20322b,'changes':{'added':_0x14e946[_0x4039d6(0x18b)],'removed':_0x14e946[_0x4039d6(0x133)],'modified':_0x14e946['linesModified']},'completion_id':_0x253237});if(_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x13f)])return{'content':[{'type':'text','text':_0x4039d6(0x1c8)+(_0x40ad7a?'':_0x4039d6(0x157))+':\x20'+_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x19e)]+_0x4039d6(0x1b1)+_0x55f7bb+_0x4039d6(0xf1)+_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x12f)]+'.'}]};return{'content':[{'type':'text','text':_0x4039d6(0x118)+(_0x40ad7a?'Applied':'Created\x20File')+':\x20'+_0xab520b[_0x4039d6(0x11e)]['instruction']+'.\x20Changes:\x20'+_0x55f7bb+_0x4039d6(0xf1)+_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x12f)]+'.'}]};}catch(_0x516481){const _0x2ed426=handleMorphAPIError(_0x516481);if(_0x2ed426)return logger[_0x4039d6(0x195)](_0x4039d6(0xc5),_0x4039d6(0x1b2),{'tool':_0x4039d6(0x1b7),'error':_0x4039d6(0x137),'latency_ms':Date[_0x4039d6(0xc9)]()-_0x1e3dba}),_0x2ed426;const _0x3a097e=_0x516481 instanceof Error?_0x516481[_0x4039d6(0x139)]:String(_0x516481);return logger[_0x4039d6(0x195)]('MCP','tool_call_error',{'tool':_0x4039d6(0x1b7),'error':_0x3a097e,'path':_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x12f)],'validated_path':_0x49a6f5,'latency_ms':Date[_0x4039d6(0xc9)]()-_0x1e3dba,'stack':_0x516481 instanceof Error?_0x516481[_0x4039d6(0x1af)]:undefined}),reportMorphError({'error_message':_0x3a097e,'error_type':_0x516481 instanceof Error?_0x516481[_0x4039d6(0x114)][_0x4039d6(0x142)]:'UnknownError','context':{'tool':_0x4039d6(0x1b7),'completion_id':_0x253237,'file_path':_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x12f)],'validated_path':_0x49a6f5,'instruction':_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x19e)],'model':MORPH_LARGE_APPLY?'morph-v3-large':_0x4039d6(0x14d),'dry_run':_0xab520b[_0x4039d6(0x11e)]['dryRun'],'file_exists':_0x40ad7a,'file_read_error':_0x5c6779,'file_readable':_0x110f75!==null,'request_content':{'path':_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x12f)],'code_edit':_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0xc0)],'instruction':_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x19e)],'original_code':_0x110f75!==null?_0x110f75[_0x4039d6(0x1c2)]>0xc350?_0x110f75['substring'](0x0,0xc350)+_0x4039d6(0xdf)+_0x110f75[_0x4039d6(0x1c2)]+_0x4039d6(0x11a):_0x110f75:_0x4039d6(0x13d)+(_0x5c6779||_0x4039d6(0x1ac))+']','original_code_length':_0x110f75?.[_0x4039d6(0x1c2)]??0x0,'model':MORPH_LARGE_APPLY?_0x4039d6(0xd7):_0x4039d6(0x14d),'dry_run':_0xab520b[_0x4039d6(0x11e)][_0x4039d6(0x13f)]}},'stack_trace':_0x516481 instanceof Error?_0x516481['stack']:undefined,'source':_0x4039d6(0x188)})[_0x4039d6(0x1b8)](()=>{}),{'content':[{'type':_0x4039d6(0x102),'text':_0x4039d6(0x122)+_0x3a097e}],'isError':!![]};}}case _0x4039d6(0x148):{const _0x52bf16=WarpGrepArgsSchema['safeParse'](_0x37e640);if(!_0x52bf16['success'])return{'content':[{'type':_0x4039d6(0x102),'text':_0x4039d6(0x1c7)+_0x52bf16[_0x4039d6(0x195)]}],'isError':!![]};const _0x5f3a5f=_0x29ebed=>{const _0x409cfe=_0x4039d6,_0x334eed=[];for(const _0x3b52c1 of _0x29ebed||[]){if(_0x3b52c1[_0x409cfe(0x1c0)]==='assistant'&&Array[_0x409cfe(0x1df)](_0x3b52c1[_0x409cfe(0xbf)]))for(const _0x68a377 of _0x3b52c1[_0x409cfe(0xbf)]){try{const _0x1c4975=_0x68a377[_0x409cfe(0xc7)]?.[_0x409cfe(0x142)],_0xe3a56c=JSON[_0x409cfe(0x183)](_0x68a377[_0x409cfe(0xc7)]?.['arguments']||'{}');if(_0x1c4975===_0x409cfe(0x156))_0x334eed['push'](_0x409cfe(0x165)+_0xe3a56c['pattern']+'\x27\x20'+(_0xe3a56c[_0x409cfe(0x12f)]||'.'));else{if(_0x1c4975===_0x409cfe(0x14b))_0x334eed[_0x409cfe(0x19d)]('read\x20'+_0xe3a56c[_0x409cfe(0x12f)]);else{if(_0x1c4975===_0x409cfe(0x1bb))_0x334eed[_0x409cfe(0x19d)](_0x409cfe(0xd4)+(_0xe3a56c['command']||'.'));else{if(_0x1c4975===_0x409cfe(0xc4))_0x334eed[_0x409cfe(0x19d)](_0x409cfe(0x174)+_0xe3a56c[_0x409cfe(0xdb)]+'\x27\x20'+(_0xe3a56c[_0x409cfe(0x12f)]||'.'));else _0x1c4975===_0x409cfe(0x1cc)&&_0x334eed[_0x409cfe(0x19d)](_0x409cfe(0x1cc));}}}}catch{}}}return _0x334eed;},_0x208b3b=_0x438952=>{const _0x2f37b8=_0x4039d6,_0x38356f=[];if(!_0x438952||!Array[_0x2f37b8(0x1df)](_0x438952))return _0x38356f;const _0x32476b=[{'pattern':/\[FILE NOT FOUND\]/,'error_type':'FileNotFound','tool':_0x2f37b8(0x14b)},{'pattern':/\[PATH ERROR\]/,'error_type':'PathError','tool':_0x2f37b8(0x14b)},{'pattern':/\[READ ERROR\]/,'error_type':_0x2f37b8(0x1bd),'tool':_0x2f37b8(0x14b)},{'pattern':/\[UNREADABLE FILE\]/,'error_type':_0x2f37b8(0x1d5),'tool':_0x2f37b8(0x14b)},{'pattern':/\[RIPGREP ERROR\]/,'error_type':'RipgrepError','tool':'grep'},{'pattern':/\[RIPGREP NOT AVAILABLE\]/,'error_type':_0x2f37b8(0x1b4),'tool':_0x2f37b8(0xbc)},{'pattern':/\[BINARY FILE\]/,'error_type':_0x2f37b8(0x1d5),'tool':_0x2f37b8(0x14b)},{'pattern':/\[SYMLINK\]/,'error_type':'SymlinkError','tool':_0x2f37b8(0x14b)},{'pattern':/not a text file/,'error_type':_0x2f37b8(0x1d5),'tool':_0x2f37b8(0x14b)},{'pattern':/symbolic link/,'error_type':_0x2f37b8(0x124),'tool':_0x2f37b8(0x14b)},{'pattern':/Error reading file:/,'error_type':_0x2f37b8(0x1bd),'tool':_0x2f37b8(0x14b)},{'pattern':/status="error"/,'error_type':'ToolException','tool':'unknown'}];let _0x3f06d0=0x0;for(const _0x5a01f5 of _0x438952){_0x5a01f5[_0x2f37b8(0x1c0)]==='assistant'&&Array[_0x2f37b8(0x1df)](_0x5a01f5[_0x2f37b8(0xbf)])&&_0x3f06d0++;const _0x1c9208=_0x5a01f5[_0x2f37b8(0xce)];if((_0x5a01f5['role']==='tool'||_0x5a01f5[_0x2f37b8(0x1c0)]===_0x2f37b8(0x1d7))&&_0x1c9208&&typeof _0x1c9208===_0x2f37b8(0x178))for(const {pattern:_0x2544c1,error_type:_0x50591e,tool:_0x251b08}of _0x32476b){const _0x478ae6=_0x1c9208[_0x2f37b8(0x196)](new RegExp(_0x2544c1['source'],'g'));if(_0x478ae6)for(const _0x5ae1e7 of _0x478ae6){const _0x1a8231=_0x1c9208[_0x2f37b8(0xcd)](_0x5ae1e7),_0x221132=_0x1c9208[_0x2f37b8(0xf2)](_0x1a8231,Math['min'](_0x1a8231+0xc8,_0x1c9208[_0x2f37b8(0x1c2)]));_0x38356f[_0x2f37b8(0x19d)]({'tool':_0x251b08,'error_type':_0x50591e,'error_message':_0x221132[_0x2f37b8(0x153)]('\x0a')[0x0],'turn':_0x3f06d0});}}}return _0x38356f;};try{const _0x4f8ee0=a0_0x39e4da['resolve'](_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0xb7)]),_0x213303=_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0x17f)],_0x4ccc3d=_0x213303==='node_modules'?{'allowNames':[_0x4039d6(0x180)]}:undefined,_0xbf3619=new LocalRipgrepProvider(_0x4f8ee0,undefined,_0x4ccc3d);logger['debug']('MCP',_0x4039d6(0xe9),{'type':_0x4039d6(0x16e),'repo_root':_0x4f8ee0,'search_type':_0x213303||'default'}),logger[_0x4039d6(0x113)]('MCP',_0x4039d6(0x119),{'query':_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0x130)],'repo_root':_0x4f8ee0,'timeout_ms':MORPH_WARP_GREP_TIMEOUT});const _0x4fbf74=Date[_0x4039d6(0xc9)](),_0x263ba1=await runWarpGrep({'searchTerm':_0x52bf16['data'][_0x4039d6(0x130)],'repoRoot':_0x4f8ee0,'morphApiKey':MORPH_API_KEY,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT,'provider':_0xbf3619,'search_type':_0x213303}),_0x1acbc3=Date['now']()-_0x4fbf74,_0x16a7b5=_0x263ba1['finish']?.['metadata']?.[_0x4039d6(0x193)]?.[_0x4039d6(0x1c2)]??0x0;logger['debug'](_0x4039d6(0xc5),_0x4039d6(0x11f),{'termination':_0x263ba1[_0x4039d6(0x158)],'turns':_0x263ba1[_0x4039d6(0x185)]?.[_0x4039d6(0x13b)]??0x0,'files_found':_0x16a7b5,'latency_ms':_0x1acbc3});const _0x47f97a=_0x208b3b(_0x263ba1[_0x4039d6(0x19f)]);_0x47f97a[_0x4039d6(0x1c2)]>0x0&&reportMorphError({'error_message':_0x4039d6(0x16f)+_0x47f97a[_0x4039d6(0x1c2)]+_0x4039d6(0xf0),'error_type':_0x4039d6(0xb6),'level':_0x4039d6(0x18c),'tool':_0x4039d6(0x148),'context':{'repo_path':_0x52bf16[_0x4039d6(0x11e)]['repo_path'],'query':_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0x130)],'model':_0x4039d6(0x134),'termination_reason':_0x263ba1[_0x4039d6(0x158)],'sub_tool_errors':_0x47f97a,'timings':_0x263ba1[_0x4039d6(0x185)],'tool_calls':_0x5f3a5f(_0x263ba1[_0x4039d6(0x19f)]),'messages':_0x263ba1[_0x4039d6(0x19f)]?.[_0x4039d6(0x143)](_0x3f8262=>({'role':_0x3f8262['role'],'content':_0x3f8262['content'],..._0x3f8262[_0x4039d6(0xbf)]?{'tool_calls':_0x3f8262['tool_calls']['length']}:{},..._0x3f8262[_0x4039d6(0x1a4)]?{'tool_call_id':_0x3f8262[_0x4039d6(0x1a4)]}:{}}))},'source':_0x4039d6(0x188)})[_0x4039d6(0x1b8)](()=>{});let _0x1f02c1='';if(_0x263ba1[_0x4039d6(0x158)]==='completed'&&_0x263ba1['finish']?.[_0x4039d6(0x127)]?.[_0x4039d6(0x193)]){const _0x29c3d9=_0x263ba1['finish'][_0x4039d6(0x127)][_0x4039d6(0x193)];if(_0x29c3d9[_0x4039d6(0x1c2)]===0x0)return _0x1f02c1=_0x263ba1[_0x4039d6(0x1cc)]['payload']||_0x4039d6(0x1d1),{'content':[{'type':_0x4039d6(0x102),'text':_0x1f02c1}]};const _0x209ff2=[],_0x5ade0b=[_0x4039d6(0xda)];for(const _0x596045 of _0x263ba1[_0x4039d6(0x19f)]){if(_0x596045[_0x4039d6(0x1c0)]===_0x4039d6(0x1be)&&Array[_0x4039d6(0x1df)](_0x596045['tool_calls']))for(const _0x3dce38 of _0x596045['tool_calls']){try{const _0x4787f6=_0x3dce38[_0x4039d6(0xc7)]?.[_0x4039d6(0x142)],_0x394149=JSON['parse'](_0x3dce38[_0x4039d6(0xc7)]?.[_0x4039d6(0x117)]||'{}');if(_0x4787f6===_0x4039d6(0x156))_0x5ade0b['push'](_0x4039d6(0xfd)+_0x394149[_0x4039d6(0xdb)]+_0x4039d6(0x1c5)+(_0x394149['path']||'.')+'`');else{if(_0x4787f6===_0x4039d6(0x14b))_0x5ade0b['push'](_0x4039d6(0xdd)+_0x394149['path']+'`');else{if(_0x4787f6===_0x4039d6(0x1bb))_0x5ade0b[_0x4039d6(0x19d)](_0x4039d6(0x1ba)+(_0x394149[_0x4039d6(0x189)]||'.')+'`');else _0x4787f6===_0x4039d6(0xc4)&&_0x5ade0b[_0x4039d6(0x19d)](_0x4039d6(0xd5)+_0x394149[_0x4039d6(0xdb)]+'`\x20in\x20`'+(_0x394149[_0x4039d6(0x12f)]||'.')+'`');}}}catch{}}}_0x209ff2['push'](_0x5ade0b[_0x4039d6(0x1d4)]('\x0a'));const _0x5309e5=['',_0x4039d6(0x1a1)];for(const _0x5d5892 of _0x29c3d9){if(_0x5d5892[_0x4039d6(0x1dc)]==='*')_0x5309e5[_0x4039d6(0x19d)]('-\x20'+_0x5d5892['path']+':*');else{if(Array[_0x4039d6(0x1df)](_0x5d5892[_0x4039d6(0x1dc)])){const _0x56eb55=_0x5d5892[_0x4039d6(0x1dc)][_0x4039d6(0x143)](([_0x4878dd,_0x34a24c])=>{if(_0x4878dd===_0x34a24c)return''+_0x4878dd;return _0x4878dd+'-'+_0x34a24c;});_0x5309e5[_0x4039d6(0x19d)]('-\x20'+_0x5d5892[_0x4039d6(0x12f)]+':'+_0x56eb55[_0x4039d6(0x1d4)](','));}else _0x5309e5['push']('-\x20'+_0x5d5892[_0x4039d6(0x12f)]+':*');}}_0x5309e5[_0x4039d6(0x19d)](''),_0x209ff2[_0x4039d6(0x19d)](_0x5309e5[_0x4039d6(0x1d4)]('\x0a')),_0x209ff2['push']('Here\x20is\x20the\x20content\x20of\x20files:\x0a');const _0x2839d7=[],_0x303355=[];for(const _0x4f1dc8 of _0x29c3d9){let _0x270536=a0_0x39e4da[_0x4039d6(0x19b)](_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0xb7)],_0x4f1dc8[_0x4039d6(0x12f)]),_0x3993a0=null,_0x15b8dd=null;try{_0x3993a0=await a0_0x2d3af7[_0x4039d6(0x1a7)](_0x270536,{'encoding':_0x4039d6(0x132)});}catch(_0x383c88){const _0xc8273e=fixPathRepetition(_0x270536);if(_0xc8273e)try{_0x3993a0=await a0_0x2d3af7[_0x4039d6(0x1a7)](_0xc8273e,{'encoding':_0x4039d6(0x132)}),_0x270536=_0xc8273e;}catch{_0x15b8dd=_0x383c88 instanceof Error?_0x383c88:new Error(String(_0x383c88));}else _0x15b8dd=_0x383c88 instanceof Error?_0x383c88:new Error(String(_0x383c88));}if(_0x3993a0!==null){const _0x5caf2e=_0x3993a0[_0x4039d6(0x153)](/\r?\n/),_0x3b913e=[];if(_0x4f1dc8['lines']==='*'||!Array[_0x4039d6(0x1df)](_0x4f1dc8[_0x4039d6(0x1dc)]))for(let _0x33639b=0x1;_0x33639b<=_0x5caf2e[_0x4039d6(0x1c2)];_0x33639b++){const _0x36ba7c=_0x5caf2e[_0x33639b-0x1];_0x3b913e[_0x4039d6(0x19d)](_0x33639b+'|\x20'+_0x36ba7c);}else for(const [_0x1d2fe5,_0x43cea2]of _0x4f1dc8[_0x4039d6(0x1dc)]){_0x3b913e['length']>0x0&&_0x3b913e[_0x4039d6(0x19d)]('');for(let _0x347c37=_0x1d2fe5;_0x347c37<=_0x43cea2&&_0x347c37<=_0x5caf2e[_0x4039d6(0x1c2)];_0x347c37++){const _0xb0ca3c=_0x5caf2e[_0x347c37-0x1];_0x3b913e[_0x4039d6(0x19d)](_0x347c37+'|\x20'+_0xb0ca3c);}}_0x303355[_0x4039d6(0x19d)]({'path':_0x4f1dc8[_0x4039d6(0x12f)],'content':_0x3b913e[_0x4039d6(0x1d4)]('\x0a')});}else _0x2839d7[_0x4039d6(0x19d)]('<file\x20path=\x22'+_0x4f1dc8[_0x4039d6(0x12f)]+_0x4039d6(0x172)+(_0x15b8dd?.[_0x4039d6(0x139)]||_0x4039d6(0x155))+_0x4039d6(0xe2));}try{const _0x197089=await compactFileContexts(_0x303355,_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0x130)],MORPH_API_KEY,MORPH_API_URL);for(const _0x235859 of _0x197089){_0x2839d7[_0x4039d6(0x19d)](_0x4039d6(0x15a)+_0x235859[_0x4039d6(0x12f)]+'\x22>\x0a'+_0x235859['content']+_0x4039d6(0xe2));}}catch(_0x1ffa74){logger['warn'](_0x4039d6(0xc5),'compaction_failed',{'error':_0x1ffa74 instanceof Error?_0x1ffa74['message']:String(_0x1ffa74),'files_count':_0x303355[_0x4039d6(0x1c2)]});for(const _0x547930 of _0x303355){_0x2839d7[_0x4039d6(0x19d)](_0x4039d6(0x15a)+_0x547930[_0x4039d6(0x12f)]+'\x22>\x0a'+_0x547930['content']+'\x0a</file>');}}_0x209ff2['push'](_0x2839d7[_0x4039d6(0x1d4)]('\x0a\x0a')),_0x1f02c1=_0x209ff2['join']('\x0a');const _0x25d361=_0x263ba1[_0x4039d6(0x1b9)]?.[_0x4039d6(0x154)](_0x1d8ec6=>_0x1d8ec6[_0x4039d6(0x139)]?.[_0x4039d6(0xd0)](_0x4039d6(0x164)))||[];if(_0x25d361[_0x4039d6(0x1c2)]>0x0){const _0x4c4321=_0x25d361[_0x4039d6(0x143)](_0x521640=>_0x521640['message'])[_0x4039d6(0x1d4)](';\x20');reportMorphError({'error_message':_0x4c4321,'error_type':_0x4039d6(0x146),'context':{'tool':_0x4039d6(0x148),'repo_path':_0x52bf16[_0x4039d6(0x11e)]['repo_path'],'query':_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0x130)],'model':_0x4039d6(0x134),'termination_reason':'completed_with_file_errors','error_count':_0x25d361[_0x4039d6(0x1c2)],'is_timeout':![],'timings':_0x263ba1[_0x4039d6(0x185)],'files_attempted':_0x29c3d9[_0x4039d6(0x143)](_0x25b5a9=>({'path':_0x25b5a9[_0x4039d6(0x12f)],'lines':_0x25b5a9[_0x4039d6(0x1dc)]})),'tool_calls':_0x5f3a5f(_0x263ba1['messages']),'messages':_0x263ba1[_0x4039d6(0x19f)]?.[_0x4039d6(0x143)](_0x3e24df=>({'role':_0x3e24df[_0x4039d6(0x1c0)],'content':_0x3e24df['content'],..._0x3e24df['tool_calls']?{'tool_calls':_0x3e24df[_0x4039d6(0xbf)]['length']}:{},..._0x3e24df[_0x4039d6(0x1a4)]?{'tool_call_id':_0x3e24df['tool_call_id']}:{}})),'request_content':{'query':_0x52bf16['data'][_0x4039d6(0x130)],'repo_path':_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0xb7)],'repoRoot':a0_0x39e4da['resolve'](_0x52bf16[_0x4039d6(0x11e)]['repo_path']),'model':_0x4039d6(0x134)}},'source':'mcp-filesystem'})['catch'](()=>{});}}else{if(_0x263ba1[_0x4039d6(0x158)]==='terminated'&&_0x263ba1[_0x4039d6(0x1b9)][_0x4039d6(0x1c2)]>0x0){const _0x3dcaa7=_0x263ba1[_0x4039d6(0x1b9)][_0x4039d6(0x143)](_0x33a2a8=>_0x33a2a8[_0x4039d6(0x139)])['join'](';\x20');_0x1f02c1=_0x4039d6(0x1ab)+_0x3dcaa7;const _0x51f25b=_0x3dcaa7['toLowerCase']()[_0x4039d6(0x1da)](_0x4039d6(0x15e))||_0x3dcaa7[_0x4039d6(0x10e)]()[_0x4039d6(0x1da)](_0x4039d6(0x115))||_0x3dcaa7[_0x4039d6(0x10e)]()[_0x4039d6(0x1da)](_0x4039d6(0x105)),_0x30c934=_0x263ba1[_0x4039d6(0x1cc)]?.[_0x4039d6(0x127)]?.[_0x4039d6(0x193)],_0x135c6a=_0x263ba1[_0x4039d6(0x1b9)][0x0];reportMorphError({'error_message':_0x3dcaa7,'error_type':_0x51f25b?_0x4039d6(0x10a):_0x135c6a?.['constructor']?.[_0x4039d6(0x142)]||_0x4039d6(0x107),'context':{'tool':_0x4039d6(0x148),'repo_path':_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0xb7)],'query':_0x52bf16['data'][_0x4039d6(0x130)],'model':_0x4039d6(0x134),'termination_reason':_0x263ba1[_0x4039d6(0x158)],'error_count':_0x263ba1[_0x4039d6(0x1b9)][_0x4039d6(0x1c2)],'is_timeout':_0x51f25b,'timings':_0x263ba1[_0x4039d6(0x185)],'files_attempted':_0x30c934?.[_0x4039d6(0x143)](_0x53a626=>({'path':_0x53a626[_0x4039d6(0x12f)],'lines':_0x53a626['lines']})),'tool_calls':_0x5f3a5f(_0x263ba1[_0x4039d6(0x19f)]),'messages':_0x263ba1['messages']?.['map'](_0x5f0657=>({'role':_0x5f0657[_0x4039d6(0x1c0)],'content':_0x5f0657[_0x4039d6(0xce)],..._0x5f0657['tool_calls']?{'tool_calls':_0x5f0657[_0x4039d6(0xbf)]['length']}:{},..._0x5f0657[_0x4039d6(0x1a4)]?{'tool_call_id':_0x5f0657[_0x4039d6(0x1a4)]}:{}})),'request_content':{'query':_0x52bf16[_0x4039d6(0x11e)]['search_string'],'repo_path':_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0xb7)],'repoRoot':a0_0x39e4da[_0x4039d6(0x19b)](_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0xb7)]),'model':_0x4039d6(0x134)}},'stack_trace':_0x135c6a?.['stack']||undefined,'source':_0x4039d6(0x188)})[_0x4039d6(0x1b8)](()=>{});}else _0x1f02c1=_0x4039d6(0x1c9);}return{'content':[{'type':_0x4039d6(0x102),'text':_0x1f02c1}]};}catch(_0x48a767){const _0x5c6da2=handleMorphAPIError(_0x48a767);if(_0x5c6da2)return logger[_0x4039d6(0x195)](_0x4039d6(0xc5),_0x4039d6(0x1b2),{'tool':'codebase_search','error':'API\x20error\x20(auth/rate-limit)','latency_ms':Date[_0x4039d6(0xc9)]()-_0x1e3dba}),_0x5c6da2;const _0x5e78db=_0x48a767 instanceof Error?_0x48a767[_0x4039d6(0x139)]:String(_0x48a767);logger[_0x4039d6(0x195)](_0x4039d6(0xc5),_0x4039d6(0x1b2),{'tool':_0x4039d6(0x148),'error':_0x5e78db,'repo_path':_0x52bf16[_0x4039d6(0x11e)]['repo_path'],'query':_0x52bf16['data']['search_string'],'latency_ms':Date[_0x4039d6(0xc9)]()-_0x1e3dba});const _0x38f518=_0x5e78db[_0x4039d6(0x10e)]()[_0x4039d6(0x1da)](_0x4039d6(0x15e))||_0x5e78db[_0x4039d6(0x10e)]()[_0x4039d6(0x1da)](_0x4039d6(0x115))||_0x5e78db[_0x4039d6(0x10e)]()[_0x4039d6(0x1da)]('etimedout')||_0x48a767 instanceof Error&&_0x48a767[_0x4039d6(0x142)]===_0x4039d6(0x10a);return reportMorphError({'error_message':_0x5e78db,'error_type':_0x38f518?_0x4039d6(0x10a):_0x48a767 instanceof Error?_0x48a767['constructor'][_0x4039d6(0x142)]:_0x4039d6(0xbe),'context':{'tool':_0x4039d6(0x148),'repo_path':_0x52bf16[_0x4039d6(0x11e)]['repo_path'],'query':_0x52bf16['data'][_0x4039d6(0x130)],'model':_0x4039d6(0x134),'is_timeout':_0x38f518,'exception_phase':_0x4039d6(0x18e),'request_content':{'query':_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0x130)],'repo_path':_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0xb7)],'repoRoot':a0_0x39e4da['resolve'](_0x52bf16[_0x4039d6(0x11e)][_0x4039d6(0xb7)]),'model':'morph-warp-grep-v2.1'}},'stack_trace':_0x48a767 instanceof Error?_0x48a767[_0x4039d6(0x1af)]:undefined,'source':_0x4039d6(0x188)})[_0x4039d6(0x1b8)](()=>{}),{'content':[{'type':_0x4039d6(0x102),'text':_0x4039d6(0x166)+_0x5e78db}],'isError':![]};}}case'github_codebase_search':{const _0x583974=WarpGrepGitHubArgsSchema[_0x4039d6(0xc6)](_0x37e640);if(!_0x583974[_0x4039d6(0x15b)])return{'content':[{'type':_0x4039d6(0x102),'text':_0x4039d6(0x1c7)+_0x583974[_0x4039d6(0x195)]}],'isError':!![]};const _0x7efdf2=_0x583974[_0x4039d6(0x11e)][_0x4039d6(0xc8)]||_0x583974['data'][_0x4039d6(0x182)];if(!_0x7efdf2)return{'content':[{'type':_0x4039d6(0x102),'text':_0x4039d6(0xd1)}],'isError':!![]};const _0x23dde6=MORPH_API_KEY;if(!_0x23dde6)throw new Error(_0x4039d6(0x10f));const _0x5b445c=Date[_0x4039d6(0xc9)]();logger[_0x4039d6(0x113)](_0x4039d6(0xc5),'github_search_start',{'identifier':_0x7efdf2,'query':_0x583974['data'][_0x4039d6(0x130)],'branch':_0x583974['data'][_0x4039d6(0xf3)]});try{const _0x4d6228=new WarpGrepClient({'morphApiKey':_0x23dde6,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT}),_0x404f2d=await _0x4d6228[_0x4039d6(0x17c)]({'searchTerm':_0x583974[_0x4039d6(0x11e)][_0x4039d6(0x130)],'github':_0x7efdf2,'branch':_0x583974[_0x4039d6(0x11e)][_0x4039d6(0xf3)]}),_0x98306f=Date['now']()-_0x5b445c;logMcpStderr('[github_codebase_search]\x20Done\x20in\x20'+_0x98306f+_0x4039d6(0x11d)+_0x404f2d['success']);const _0x3546e6=formatResult(_0x404f2d);return{'content':[{'type':_0x4039d6(0x102),'text':_0x3546e6}]};}catch(_0x5a931c){const _0x27578b=handleMorphAPIError(_0x5a931c);if(_0x27578b)return _0x27578b;const _0x27a575=Date[_0x4039d6(0xc9)]()-_0x5b445c,_0x2dffe4=_0x5a931c instanceof Error?_0x5a931c['message']:String(_0x5a931c);return logMcpStderr(_0x4039d6(0x173)+_0x27a575+_0x4039d6(0xfc),_0x2dffe4),reportMorphError({'error_message':_0x2dffe4,'error_type':_0x5a931c instanceof Error?_0x5a931c[_0x4039d6(0x114)][_0x4039d6(0x142)]:_0x4039d6(0xbe),'context':{'tool':_0x4039d6(0x128),'github_url':_0x7efdf2,'search_string':_0x583974[_0x4039d6(0x11e)][_0x4039d6(0x130)],'branch':_0x583974[_0x4039d6(0x11e)][_0x4039d6(0xf3)]},'stack_trace':_0x5a931c instanceof Error?_0x5a931c[_0x4039d6(0x1af)]:undefined,'source':_0x4039d6(0x188),'tool':_0x4039d6(0x128),'latency_ms':_0x27a575})[_0x4039d6(0x1b8)](()=>{}),{'content':[{'type':_0x4039d6(0x102),'text':_0x4039d6(0x108)+_0x2dffe4}],'isError':![]};}}default:throw new Error(_0x4039d6(0xf8)+_0x3e38cc);}}catch(_0xdc2a51){const _0x17ce84=_0xdc2a51 instanceof Error?_0xdc2a51[_0x4039d6(0x139)]:String(_0xdc2a51);return reportMorphError({'error_message':_0x17ce84,'error_type':_0xdc2a51 instanceof Error?_0xdc2a51[_0x4039d6(0x114)]['name']:_0x4039d6(0xbe),'context':{'tool':_0x3e38cc,'arguments':_0x37e640?JSON['stringify'](_0x37e640)[_0x4039d6(0xf2)](0x0,0x1f4):undefined,'mcp_server_version':'0.2.0'},'stack_trace':_0xdc2a51 instanceof Error?_0xdc2a51[_0x4039d6(0x1af)]:undefined,'source':'mcp-filesystem'})[_0x4039d6(0x1b8)](()=>{}),{'content':[{'type':_0x4039d6(0x102),'text':_0x4039d6(0x1ab)+_0x17ce84}],'isError':!![]};}});async function updateAllowedDirectoriesFromRoots(_0x3ef385){const _0x2cd2d9=a0_0x398bd1,_0xd8df21=await getValidRootDirectories(_0x3ef385);if(_0xd8df21[_0x2cd2d9(0x1c2)]>0x0)allowedDirectories=[..._0xd8df21],logMcpStderr(_0x2cd2d9(0x169)+_0xd8df21['length']+_0x2cd2d9(0x10b));else{logMcpStderr('No\x20valid\x20root\x20directories\x20provided\x20by\x20client');if(ENABLE_WORKSPACE_MODE)try{const _0x56902e=await detectWorkspaceRoot(WORKSPACE_ROOT);_0x56902e&&(allowedDirectories=[_0x56902e],logMcpStderr('Fallback:\x20Using\x20workspace\x20root\x20'+_0x56902e));}catch(_0x352e53){logMcpStderr('Warning:\x20Workspace\x20fallback\x20failed:\x20'+_0x352e53);}}}server[a0_0x398bd1(0x14a)](RootsListChangedNotificationSchema,async()=>{const _0x46e3f0=a0_0x398bd1;try{const _0x223316=await server[_0x46e3f0(0x192)]();_0x223316&&'roots'in _0x223316&&await updateAllowedDirectoriesFromRoots(_0x223316[_0x46e3f0(0x190)]);}catch(_0x12f00c){logMcpStderr(_0x46e3f0(0x1de),_0x12f00c instanceof Error?_0x12f00c['message']:String(_0x12f00c));}}),server[a0_0x398bd1(0x10c)]=async()=>{const _0x44918e=a0_0x398bd1,_0x3bd6e3=server[_0x44918e(0xe7)]();if(_0x3bd6e3?.[_0x44918e(0x190)])try{const _0x26724c=await server[_0x44918e(0x192)]();_0x26724c&&_0x44918e(0x190)in _0x26724c?await updateAllowedDirectoriesFromRoots(_0x26724c['roots']):logMcpStderr('Client\x20returned\x20no\x20roots\x20set,\x20keeping\x20current\x20settings');}catch(_0x3c6e11){logMcpStderr(_0x44918e(0x161),_0x3c6e11 instanceof Error?_0x3c6e11[_0x44918e(0x139)]:String(_0x3c6e11));}else{if(allowedDirectories[_0x44918e(0x1c2)]>0x0)logMcpStderr(_0x44918e(0x187),allowedDirectories);else{if(ENABLE_WORKSPACE_MODE)logMcpStderr(_0x44918e(0x12c));else throw new Error(_0x44918e(0x1aa));}}};async function runServer(){const _0x36fd4b=a0_0x398bd1,_0x5e6326=new StdioServerTransport();await server[_0x36fd4b(0xb9)](_0x5e6326),logMcpStderr(_0x36fd4b(0x12a)),allowedDirectories['length']===0x0&&logMcpStderr(_0x36fd4b(0xca));}runServer()[a0_0x398bd1(0x1b8)](_0x216aa4=>{const _0x5e7f8f=a0_0x398bd1;logMcpStderr('Fatal\x20error\x20running\x20server:',_0x216aa4),process[_0x5e7f8f(0x197)](0x1);});
|
package/dist/log-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var a1_0x158c91=a1_0xe512;(function(_0x5e58d1,_0xf1e5a6){var _0x50e9a9=a1_0xe512,_0x57c191=_0x5e58d1();while(!![]){try{var _0x4cca9a=-parseInt(_0x50e9a9(0x185))/0x1+-parseInt(_0x50e9a9(0x17e))/0x2*(-parseInt(_0x50e9a9(0x18c))/0x3)+parseInt(_0x50e9a9(0x17f))/0x4*(-parseInt(_0x50e9a9(0x182))/0x5)+-parseInt(_0x50e9a9(0x186))/0x6+parseInt(_0x50e9a9(0x187))/0x7+-parseInt(_0x50e9a9(0x18e))/0x8*(parseInt(_0x50e9a9(0x18a))/0x9)+-parseInt(_0x50e9a9(0x188))/0xa*(-parseInt(_0x50e9a9(0x18d))/0xb);if(_0x4cca9a===_0xf1e5a6)break;else _0x57c191['push'](_0x57c191['shift']());}catch(_0x27a64c){_0x57c191['push'](_0x57c191['shift']());}}}(a1_0x2ea4,0x6f26e));function a1_0xe512(_0x3c22d5,_0x5d802b){_0x3c22d5=_0x3c22d5-0x177;var _0x2ea43d=a1_0x2ea4();var _0xe5121c=_0x2ea43d[_0x3c22d5];return _0xe5121c;}import a1_0x337be2 from'os';function a1_0x2ea4(){var _0x42a02a=['map','[os=','macOS','146OmQFaK','616024XMquOc','platform','length','5CMKnns','win32','info','187418nubjUU','516960rbMrLr','4032378HbximQ','10NAnOpE','Windows','36spdWKz','darwin','20721CNSUlU','505483uDhBGO','486712pEDlpy','error','MCP','Unknown','linux'];a1_0x2ea4=function(){return _0x42a02a;};return a1_0x2ea4();}import{logger}from'./logger.js';export function getOperatingSystemType(_0x3a43a3=a1_0x337be2[a1_0x158c91(0x180)]()){var _0x22b09f=a1_0x158c91;switch(_0x3a43a3){case _0x22b09f(0x18b):return _0x22b09f(0x17d);case _0x22b09f(0x183):return _0x22b09f(0x189);case _0x22b09f(0x17a):return'Linux';default:return _0x22b09f(0x179);}}export function formatMcpLogMessage(_0x598330,_0x4fbff6=a1_0x337be2[a1_0x158c91(0x180)]()){var _0x2490c5=a1_0x158c91;return _0x2490c5(0x17c)+getOperatingSystemType(_0x4fbff6)+']\x20'+_0x598330;}export function logMcpStderr(_0x4e87f3,..._0x1a8115){var _0x39289a=a1_0x158c91;console[_0x39289a(0x177)](formatMcpLogMessage(_0x4e87f3),..._0x1a8115),logger[_0x39289a(0x184)](_0x39289a(0x178),_0x4e87f3,_0x1a8115[_0x39289a(0x181)]?{'args':_0x1a8115[_0x39289a(0x17b)](_0x3bb94e=>String(_0x3bb94e))}:undefined);}
|
package/dist/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a2_0x4c23fc=a2_0x203c;(function(_0x376cc0,_0x869e03){const _0x31e19f=a2_0x203c,_0x4cf6e3=_0x376cc0();while(!![]){try{const _0x300dba=-parseInt(_0x31e19f(0x11b))/0x1*(-parseInt(_0x31e19f(0x12b))/0x2)+-parseInt(_0x31e19f(0x119))/0x3*(-parseInt(_0x31e19f(0x114))/0x4)+parseInt(_0x31e19f(0x113))/0x5+-parseInt(_0x31e19f(0x122))/0x6*(parseInt(_0x31e19f(0x12a))/0x7)+parseInt(_0x31e19f(0x11d))/0x8+-parseInt(_0x31e19f(0x123))/0x9+parseInt(_0x31e19f(0x11f))/0xa*(-parseInt(_0x31e19f(0x126))/0xb);if(_0x300dba===_0x869e03)break;else _0x4cf6e3['push'](_0x4cf6e3['shift']());}catch(_0x26e9fb){_0x4cf6e3['push'](_0x4cf6e3['shift']());}}}(a2_0x14ef,0x39d6e));function a2_0x14ef(){const _0x5ea5d5=['write','7cjbicU','24694lMJbnd','env','fileStream','1369120FmKRVS','102512phEkxJ','toISOString','stringify','enable','warn','6qMqyvQ',']\x20[','20kiOwxJ','toUpperCase','809664SNzzlZ','MORPH_DEBUG','11030dwemzm','debug','error','508692TiDPCY','1486161zelbxj','MORPH_LOG_FILE','info','1859HqYrso','enabled','_log'];a2_0x14ef=function(){return _0x5ea5d5;};return a2_0x14ef();}function a2_0x203c(_0x4e2586,_0x4682d4){_0x4e2586=_0x4e2586-0x111;const _0x14efc8=a2_0x14ef();let _0x203c82=_0x14efc8[_0x4e2586];return _0x203c82;}import{createWriteStream}from'fs';class MorphLogger{[a2_0x4c23fc(0x127)];['fileStream'];constructor(){const _0x18ba23=a2_0x4c23fc;this['enabled']=process[_0x18ba23(0x111)][_0x18ba23(0x11e)]==='1'||!!process[_0x18ba23(0x111)][_0x18ba23(0x124)];const _0x52b472=process['env'][_0x18ba23(0x124)];this['fileStream']=_0x52b472?createWriteStream(_0x52b472,{'flags':'a'}):null;}['debug'](_0x40eb82,_0x58c874,_0x345386){const _0x4a8d69=a2_0x4c23fc;this[_0x4a8d69(0x128)](_0x4a8d69(0x120),_0x40eb82,_0x58c874,_0x345386);}[a2_0x4c23fc(0x125)](_0x17cab8,_0x5b08a1,_0x2243c5){const _0x1af50d=a2_0x4c23fc;this[_0x1af50d(0x128)](_0x1af50d(0x125),_0x17cab8,_0x5b08a1,_0x2243c5);}[a2_0x4c23fc(0x118)](_0x3e450f,_0x43cd6c,_0x12a268){const _0xa664e8=a2_0x4c23fc;this['_log'](_0xa664e8(0x118),_0x3e450f,_0x43cd6c,_0x12a268);}[a2_0x4c23fc(0x121)](_0xea2747,_0x54f67d,_0x3e8988){const _0x1bed71=a2_0x4c23fc;this[_0x1bed71(0x128)](_0x1bed71(0x121),_0xea2747,_0x54f67d,_0x3e8988);}[a2_0x4c23fc(0x117)](){const _0x524cbb=a2_0x4c23fc;this[_0x524cbb(0x127)]=!![];}get['isEnabled'](){const _0x168caa=a2_0x4c23fc;return this[_0x168caa(0x127)];}['_log'](_0x36ba0c,_0x26064a,_0x1682dc,_0xab7c7b){const _0x27c798=a2_0x4c23fc;if(_0x36ba0c!==_0x27c798(0x121)&&!this[_0x27c798(0x127)])return;const _0x277d58=new Date()[_0x27c798(0x115)](),_0x30e8d3='['+_0x277d58+_0x27c798(0x11a)+_0x36ba0c[_0x27c798(0x11c)]()+_0x27c798(0x11a)+_0x26064a+']';console['error'](_0xab7c7b?_0x30e8d3+'\x20'+_0x1682dc+'\x20'+JSON[_0x27c798(0x116)](_0xab7c7b):_0x30e8d3+'\x20'+_0x1682dc),this[_0x27c798(0x112)]?.[_0x27c798(0x129)](JSON[_0x27c798(0x116)]({'ts':_0x277d58,'level':_0x36ba0c,'component':_0x26064a,'msg':_0x1682dc,..._0xab7c7b&&{'data':_0xab7c7b}})+'\x0a');}}export const logger=new MorphLogger();
|
package/dist/path-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x131668,_0x115944){const _0x4cb9c9=a3_0x5702,_0x18b967=_0x131668();while(!![]){try{const _0x576e8a=-parseInt(_0x4cb9c9(0x89))/0x1*(parseInt(_0x4cb9c9(0x98))/0x2)+-parseInt(_0x4cb9c9(0x88))/0x3+-parseInt(_0x4cb9c9(0x8c))/0x4+-parseInt(_0x4cb9c9(0x9d))/0x5*(-parseInt(_0x4cb9c9(0x9a))/0x6)+parseInt(_0x4cb9c9(0x8b))/0x7*(-parseInt(_0x4cb9c9(0x91))/0x8)+-parseInt(_0x4cb9c9(0x97))/0x9*(parseInt(_0x4cb9c9(0x90))/0xa)+parseInt(_0x4cb9c9(0x9b))/0xb;if(_0x576e8a===_0x115944)break;else _0x18b967['push'](_0x18b967['shift']());}catch(_0x5e7d43){_0x18b967['push'](_0x18b967['shift']());}}}(a3_0x370a,0xf38f7));import a3_0x2ea9d1 from'path';import a3_0x125f9e from'os';export function convertToWindowsPath(_0xf96b53){const _0x1dcfbe=a3_0x5702;if(_0xf96b53[_0x1dcfbe(0x8e)]('/mnt/')){const _0xfbc62b=_0xf96b53[_0x1dcfbe(0x94)](0x5)['toUpperCase'](),_0x32e902=_0xf96b53[_0x1dcfbe(0x99)](0x6)[_0x1dcfbe(0x96)](/\//g,'\x5c');return _0xfbc62b+':'+_0x32e902;}if(_0xf96b53[_0x1dcfbe(0x9e)](/^\/[a-zA-Z]\//)){const _0x1c6aa3=_0xf96b53[_0x1dcfbe(0x94)](0x1)[_0x1dcfbe(0x9c)](),_0xd14f84=_0xf96b53[_0x1dcfbe(0x99)](0x2)[_0x1dcfbe(0x96)](/\//g,'\x5c');return _0x1c6aa3+':'+_0xd14f84;}if(_0xf96b53[_0x1dcfbe(0x9e)](/^[a-zA-Z]:/))return _0xf96b53[_0x1dcfbe(0x96)](/\//g,'\x5c');return _0xf96b53;}export function normalizePath(_0x6d4915){const _0x311dfb=a3_0x5702;_0x6d4915=_0x6d4915[_0x311dfb(0x8d)]()['replace'](/^["']|["']$/g,'');const _0x4574ac=_0x6d4915[_0x311dfb(0x8e)]('/')&&!_0x6d4915[_0x311dfb(0x9e)](/^\/mnt\/[a-z]\//i)&&!_0x6d4915[_0x311dfb(0x9e)](/^\/[a-zA-Z]\//);if(_0x4574ac)return _0x6d4915[_0x311dfb(0x96)](/\/+/g,'/')[_0x311dfb(0x96)](/\/+$/,'');_0x6d4915=convertToWindowsPath(_0x6d4915);if(_0x6d4915[_0x311dfb(0x8e)]('\x5c\x5c')){let _0x20c2ca=_0x6d4915;_0x20c2ca=_0x20c2ca[_0x311dfb(0x96)](/^\\{2,}/,'\x5c\x5c');const _0x335221=_0x20c2ca[_0x311dfb(0x8f)](0x2)[_0x311dfb(0x96)](/\\\\/g,'\x5c');_0x6d4915='\x5c\x5c'+_0x335221;}else _0x6d4915=_0x6d4915[_0x311dfb(0x96)](/\\\\/g,'\x5c');let _0x4b3d77=a3_0x2ea9d1[_0x311dfb(0x93)](_0x6d4915);_0x6d4915[_0x311dfb(0x8e)]('\x5c\x5c')&&!_0x4b3d77[_0x311dfb(0x8e)]('\x5c\x5c')&&(_0x4b3d77='\x5c'+_0x4b3d77);if(_0x4b3d77[_0x311dfb(0x9e)](/^[a-zA-Z]:/)){let _0x508aea=_0x4b3d77[_0x311dfb(0x96)](/\//g,'\x5c');return/^[a-z]:/[_0x311dfb(0x92)](_0x508aea)&&(_0x508aea=_0x508aea[_0x311dfb(0x94)](0x0)[_0x311dfb(0x9c)]()+_0x508aea[_0x311dfb(0x99)](0x1)),_0x508aea;}return _0x4b3d77[_0x311dfb(0x96)](/\//g,'\x5c');}export function expandHome(_0xe3a546){const _0x344f98=a3_0x5702;if(_0xe3a546[_0x344f98(0x8e)]('~/')||_0xe3a546==='~')return a3_0x2ea9d1[_0x344f98(0x95)](a3_0x125f9e[_0x344f98(0x8a)](),_0xe3a546[_0x344f98(0x99)](0x1));return _0xe3a546;}function a3_0x5702(_0x573900,_0xdc652b){_0x573900=_0x573900-0x88;const _0x370a07=a3_0x370a();let _0x5702b7=_0x370a07[_0x573900];return _0x5702b7;}function a3_0x370a(){const _0x20cfd8=['3995451QbLpWC','1ClILxa','homedir','14aTZVzk','6433984pxxwsU','trim','startsWith','substring','328360dYHITD','7880120ilkhZT','test','normalize','charAt','join','replace','27HhfFbb','1520434UpxWaW','slice','6XlXWnG','65424975GWZucd','toUpperCase','4094830KIKrNj','match'];a3_0x370a=function(){return _0x20cfd8;};return a3_0x370a();}
|
package/dist/path-validation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x197574,_0x2943c6){const _0xd5c725=a4_0x2011,_0x366300=_0x197574();while(!![]){try{const _0x38eaec=parseInt(_0xd5c725(0x17d))/0x1+-parseInt(_0xd5c725(0x185))/0x2+parseInt(_0xd5c725(0x18b))/0x3*(-parseInt(_0xd5c725(0x184))/0x4)+-parseInt(_0xd5c725(0x17e))/0x5+parseInt(_0xd5c725(0x189))/0x6+parseInt(_0xd5c725(0x188))/0x7+-parseInt(_0xd5c725(0x183))/0x8;if(_0x38eaec===_0x2943c6)break;else _0x366300['push'](_0x366300['shift']());}catch(_0x501e91){_0x366300['push'](_0x366300['shift']());}}}(a4_0x59bb,0x8ee02));import a4_0x2ce7f1 from'path';function a4_0x2011(_0x4bc6b6,_0x42e227){_0x4bc6b6=_0x4bc6b6-0x17c;const _0x59bb08=a4_0x59bb();let _0x2011ac=_0x59bb08[_0x4bc6b6];return _0x2011ac;}function a4_0x59bb(){const _0x1bb627=['startsWith','382536uVhUEe','1579990wyjXmY','includes','resolve','sep','isAbsolute','7109704uEcaYJ','3112vWPidy','58910JwNxhB','string','Path\x20must\x20be\x20absolute\x20after\x20normalization','3103415GpSOkc','6558522XWjMVX','normalize','384LWRfch'];a4_0x59bb=function(){return _0x1bb627;};return a4_0x59bb();}export function isPathWithinAllowedDirectories(_0x54c8b1,_0x1fe73f){const _0x19dcbc=a4_0x2011;if(typeof _0x54c8b1!=='string'||!Array['isArray'](_0x1fe73f))return![];if(!_0x54c8b1||_0x1fe73f['length']===0x0)return![];if(_0x54c8b1['includes']('\x00'))return![];let _0x315b74;try{_0x315b74=a4_0x2ce7f1[_0x19dcbc(0x180)](a4_0x2ce7f1[_0x19dcbc(0x18a)](_0x54c8b1));}catch{return![];}if(!a4_0x2ce7f1[_0x19dcbc(0x182)](_0x315b74))throw new Error(_0x19dcbc(0x187));return _0x1fe73f['some'](_0x3465c5=>{const _0x1622ee=_0x19dcbc;if(typeof _0x3465c5!==_0x1622ee(0x186)||!_0x3465c5)return![];if(_0x3465c5[_0x1622ee(0x17f)]('\x00'))return![];let _0x413027;try{_0x413027=a4_0x2ce7f1[_0x1622ee(0x180)](a4_0x2ce7f1[_0x1622ee(0x18a)](_0x3465c5));}catch{return![];}if(!a4_0x2ce7f1['isAbsolute'](_0x413027))throw new Error('Allowed\x20directories\x20must\x20be\x20absolute\x20paths\x20after\x20normalization');if(_0x315b74===_0x413027)return!![];if(_0x413027===a4_0x2ce7f1[_0x1622ee(0x181)])return _0x315b74[_0x1622ee(0x17c)](a4_0x2ce7f1[_0x1622ee(0x181)]);return _0x315b74['startsWith'](_0x413027+a4_0x2ce7f1[_0x1622ee(0x181)]);});}
|
package/dist/roots-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x53fda2,_0x135382){const _0x315032=a5_0x248f,_0x44c270=_0x53fda2();while(!![]){try{const _0x2efa3f=parseInt(_0x315032(0xb4))/0x1*(-parseInt(_0x315032(0xc4))/0x2)+parseInt(_0x315032(0xc0))/0x3*(parseInt(_0x315032(0xc5))/0x4)+parseInt(_0x315032(0xb6))/0x5*(parseInt(_0x315032(0xb5))/0x6)+-parseInt(_0x315032(0xb7))/0x7+-parseInt(_0x315032(0xbf))/0x8+parseInt(_0x315032(0xb2))/0x9*(-parseInt(_0x315032(0xbe))/0xa)+-parseInt(_0x315032(0xb3))/0xb*(-parseInt(_0x315032(0xc1))/0xc);if(_0x2efa3f===_0x135382)break;else _0x44c270['push'](_0x44c270['shift']());}catch(_0x44ed04){_0x44c270['push'](_0x44c270['shift']());}}}(a5_0x2ed5,0x2fc3e));function a5_0x2ed5(){const _0x22fdbd=['1553415FmCzti','399406qbkoCw','non-directory\x20root','push','Skipping\x20','uri','stat','startsWith','10uxbEMC','1932616DGjCmr','334182YQxAYW','192crDYMW','slice','Skipping\x20invalid\x20directory:\x20','6176nongAW','4oMViGj','37764XXTeGF','237226EcegCr','87nTLFbs','6pphfBk'];a5_0x2ed5=function(){return _0x22fdbd;};return a5_0x2ed5();}function a5_0x248f(_0x4b3695,_0x21c2bf){_0x4b3695=_0x4b3695-0xb2;const _0x2ed597=a5_0x2ed5();let _0x248fe2=_0x2ed597[_0x4b3695];return _0x248fe2;}import{promises as a5_0x2f0f27}from'fs';import a5_0x574198 from'path';import a5_0x2b541e from'os';import{normalizePath}from'./path-utils.js';import{logMcpStderr}from'./log-utils.js';async function parseRootUri(_0x1e80da){const _0x17bbae=a5_0x248f;try{const _0x2eb911=_0x1e80da['startsWith']('file://')?_0x1e80da[_0x17bbae(0xc2)](0x7):_0x1e80da,_0x18b01c=_0x2eb911[_0x17bbae(0xbd)]('~/')||_0x2eb911==='~'?a5_0x574198['join'](a5_0x2b541e['homedir'](),_0x2eb911['slice'](0x1)):_0x2eb911,_0x3aae07=a5_0x574198['resolve'](_0x18b01c),_0x1bc19d=await a5_0x2f0f27['realpath'](_0x3aae07);return normalizePath(_0x1bc19d);}catch{return null;}}function formatDirectoryError(_0x1f9a99,_0x495e5d,_0x5f2d54){const _0x31bfde=a5_0x248f;if(_0x5f2d54)return _0x31bfde(0xba)+_0x5f2d54+':\x20'+_0x1f9a99;const _0x4faa8c=_0x495e5d instanceof Error?_0x495e5d['message']:String(_0x495e5d);return _0x31bfde(0xc3)+_0x1f9a99+'\x20due\x20to\x20error:\x20'+_0x4faa8c;}export async function getValidRootDirectories(_0x4a3b74){const _0x4d92c3=a5_0x248f,_0x5ca065=[];for(const _0x288bac of _0x4a3b74){const _0x14294f=await parseRootUri(_0x288bac[_0x4d92c3(0xbb)]);if(!_0x14294f){logMcpStderr(formatDirectoryError(_0x288bac[_0x4d92c3(0xbb)],undefined,'invalid\x20path\x20or\x20inaccessible'));continue;}try{const _0x319483=await a5_0x2f0f27[_0x4d92c3(0xbc)](_0x14294f);_0x319483['isDirectory']()?_0x5ca065[_0x4d92c3(0xb9)](_0x14294f):logMcpStderr(formatDirectoryError(_0x14294f,undefined,_0x4d92c3(0xb8)));}catch(_0x160cff){logMcpStderr(formatDirectoryError(_0x14294f,_0x160cff));}}return _0x5ca065;}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morphllm/morphmcp",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.162",
|
|
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.163",
|
|
39
39
|
"@vscode/ripgrep": "^1.15.14",
|
|
40
40
|
"axios": "^1.6.0",
|
|
41
41
|
"chalk": "^5.3.0",
|