@morphllm/morphmcp 0.8.116 → 0.8.118
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/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_0xe5ec39=a0_0x58d2;(function(_0x9f9d22,_0x1b1622){const _0x5a2e48=a0_0x58d2,_0x13b4c2=_0x9f9d22();while(!![]){try{const _0x5c49e2=-parseInt(_0x5a2e48(0x138))/0x1+-parseInt(_0x5a2e48(0x21b))/0x2+-parseInt(_0x5a2e48(0x216))/0x3+-parseInt(_0x5a2e48(0x1ba))/0x4+parseInt(_0x5a2e48(0x168))/0x5+-parseInt(_0x5a2e48(0x1d5))/0x6+parseInt(_0x5a2e48(0x1e7))/0x7*(parseInt(_0x5a2e48(0x18b))/0x8);if(_0x5c49e2===_0x1b1622)break;else _0x13b4c2['push'](_0x13b4c2['shift']());}catch(_0x485ee3){_0x13b4c2['push'](_0x13b4c2['shift']());}}}(a0_0x31a6,0x86482));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_0x3c04d7 from'fs/promises';import a0_0x3d8b09 from'path';import a0_0x3e8986 from'os';import{createRequire}from'module';import{z}from'zod';import{zodToJsonSchema}from'zod-to-json-schema';import{getValidRootDirectories}from'./roots-utils.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';function a0_0x58d2(_0xb2f25f,_0x54ce73){_0xb2f25f=_0xb2f25f-0x127;const _0x31a668=a0_0x31a6();let _0x58d254=_0x31a668[_0xb2f25f];return _0x58d254;}import{executeCodebaseSearch}from'@morphllm/morphsdk/tools/codebase-search';import a0_0x99a8c9 from'axios';function fixPathRepetition(_0xa76687){const _0x1abef9=a0_0x58d2,_0x59eecc=_0xa76687[_0x1abef9(0x18d)](a0_0x3d8b09[_0x1abef9(0x134)])[_0x1abef9(0x188)](Boolean);if(_0x59eecc['length']<0x2)return null;for(let _0x2a9b1b=Math[_0x1abef9(0x1f4)](_0x59eecc[_0x1abef9(0x1e5)]/0x2);_0x2a9b1b>=0x1;_0x2a9b1b--){for(let _0x1f1ff4=0x0;_0x1f1ff4<=_0x59eecc[_0x1abef9(0x1e5)]-0x2*_0x2a9b1b;_0x1f1ff4++){const _0xe64b3c=_0x59eecc['slice'](_0x1f1ff4,_0x1f1ff4+_0x2a9b1b),_0x234fec=_0x59eecc[_0x1abef9(0x1c8)](_0x1f1ff4+_0x2a9b1b,_0x1f1ff4+0x2*_0x2a9b1b);if(_0xe64b3c[_0x1abef9(0x1fb)]((_0x4a98d0,_0x449ecc)=>_0x4a98d0===_0x234fec[_0x449ecc])){const _0x14ab04=[..._0x59eecc[_0x1abef9(0x1c8)](0x0,_0x1f1ff4),..._0x59eecc[_0x1abef9(0x1c8)](_0x1f1ff4+_0x2a9b1b)];return a0_0x3d8b09[_0x1abef9(0x134)]+_0x14ab04[_0x1abef9(0x19a)](a0_0x3d8b09[_0x1abef9(0x134)]);}}}return null;}const require=createRequire(import.meta.url);function getPackageVersion(){const _0x5d0378=a0_0x58d2;try{const _0x261785=require(_0x5d0378(0x164));return _0x261785['version']??_0x5d0378(0x236);}catch(_0x2e13a0){return console['error'](_0x5d0378(0x23d),_0x2e13a0),_0x5d0378(0x236);}}function printHelp(){const _0x44939a=a0_0x58d2;console[_0x44939a(0x1b6)](_0x44939a(0x21f)+getPackageVersion()),console[_0x44939a(0x1b6)]('\x0aUsage:\x20morph-mcp\x20[options]\x20[allowed-directory\x20...]'),console[_0x44939a(0x1b6)]('\x0aOptions:'),console[_0x44939a(0x1b6)](_0x44939a(0x1c9)),console[_0x44939a(0x1b6)](_0x44939a(0x178)),console[_0x44939a(0x1b6)](_0x44939a(0x194)),console['log'](_0x44939a(0x13e)),console[_0x44939a(0x1b6)](_0x44939a(0x1ed)),console[_0x44939a(0x1b6)]('\x20\x20morph-mcp\x20--api-key\x20sk-xxx\x20~/repo');}const cliArgs=process['argv'][a0_0xe5ec39(0x1c8)](0x2),VERSION_FLAGS=new Set([a0_0xe5ec39(0x1ee),'-v','-V']),HELP_FLAGS=new Set([a0_0xe5ec39(0x1d4),'-h']);cliArgs['some'](_0x504faf=>VERSION_FLAGS['has'](_0x504faf))&&(console['log'](a0_0xe5ec39(0x21f)+getPackageVersion()),process[a0_0xe5ec39(0x20f)](0x0));cliArgs['some'](_0x5aa037=>HELP_FLAGS[a0_0xe5ec39(0x241)](_0x5aa037))&&(printHelp(),process[a0_0xe5ec39(0x20f)](0x0));function getCliArg(_0x3dc72b){const _0x1a6252=a0_0xe5ec39;for(let _0x34586b=0x0;_0x34586b<cliArgs[_0x1a6252(0x1e5)];_0x34586b++){const _0x32e8a9=cliArgs[_0x34586b];if(_0x32e8a9[_0x1a6252(0x191)]('--'+_0x3dc72b+'='))return _0x32e8a9[_0x1a6252(0x1c8)](('--'+_0x3dc72b+'=')['length']);if(_0x32e8a9==='--'+_0x3dc72b&&_0x34586b+0x1<cliArgs[_0x1a6252(0x1e5)])return cliArgs[_0x34586b+0x1];}return undefined;}const args=[];for(let i=0x0;i<cliArgs['length'];i++){const arg=cliArgs[i];if(VERSION_FLAGS[a0_0xe5ec39(0x241)](arg)||HELP_FLAGS[a0_0xe5ec39(0x241)](arg))continue;if(arg[a0_0xe5ec39(0x191)](a0_0xe5ec39(0x220)))continue;if(arg===a0_0xe5ec39(0x16a)){i++;continue;}args[a0_0xe5ec39(0x17f)](arg);}const WORKSPACE_ROOT=process['env'][a0_0xe5ec39(0x136)]||process['env'][a0_0xe5ec39(0x227)]||process[a0_0xe5ec39(0x1d0)](),ENABLE_WORKSPACE_MODE=process['env'][a0_0xe5ec39(0x170)]!==a0_0xe5ec39(0x14c),MORPH_API_KEY=getCliArg(a0_0xe5ec39(0x1c1))??process[a0_0xe5ec39(0x140)][a0_0xe5ec39(0x18f)],MORPH_API_URL=process['env'][a0_0xe5ec39(0x225)],MORPH_WARP_GREP_TIMEOUT=process[a0_0xe5ec39(0x140)][a0_0xe5ec39(0x1be)]?parseInt(process['env']['MORPH_WARP_GREP_TIMEOUT'],0xa):undefined;MORPH_API_KEY&&!MORPH_API_KEY['startsWith']('sk-')&&!MORPH_API_KEY[a0_0xe5ec39(0x191)](a0_0xe5ec39(0x239))&&console[a0_0xe5ec39(0x1eb)](a0_0xe5ec39(0x1bb));async function reportMorphError(_0x143bae){const _0x370ee7=a0_0xe5ec39;try{await a0_0x99a8c9[_0x370ee7(0x204)](_0x370ee7(0x17c),{..._0x143bae,'timestamp':new Date()[_0x370ee7(0x15d)](),'source':_0x143bae[_0x370ee7(0x1db)]||_0x370ee7(0x205)},{'timeout':0x1388,'headers':{'Content-Type':_0x370ee7(0x137),'Authorization':_0x370ee7(0x18e)+MORPH_API_KEY}});}catch{}}args[a0_0xe5ec39(0x1e5)]===0x0&&!ENABLE_WORKSPACE_MODE&&(console[a0_0xe5ec39(0x1eb)](a0_0xe5ec39(0x148)),console[a0_0xe5ec39(0x1eb)](a0_0xe5ec39(0x1ae)),console[a0_0xe5ec39(0x1eb)](a0_0xe5ec39(0x1e2)),console[a0_0xe5ec39(0x1eb)]('\x20\x202.\x20MCP\x20roots\x20protocol\x20(if\x20client\x20supports\x20it)'),console[a0_0xe5ec39(0x1eb)]('\x20\x203.\x20Workspace\x20mode\x20(default\x20behavior,\x20set\x20ENABLE_WORKSPACE_MODE=false\x20to\x20disable)'),console[a0_0xe5ec39(0x1eb)]('At\x20least\x20one\x20directory\x20must\x20be\x20provided\x20by\x20EITHER\x20method\x20for\x20the\x20server\x20to\x20operate.'));function normalizePath(_0x59aac0){const _0x251299=a0_0xe5ec39;return a0_0x3d8b09[_0x251299(0x1c0)](_0x59aac0);}function expandHome(_0x23db2d){const _0x48cb21=a0_0xe5ec39;if(_0x23db2d[_0x48cb21(0x191)]('~/')||_0x23db2d==='~')return a0_0x3d8b09[_0x48cb21(0x19a)](a0_0x3e8986[_0x48cb21(0x1ce)](),_0x23db2d['slice'](0x1));return _0x23db2d;}function a0_0x31a6(){const _0x33ff6d=['match','substring','.vscode','Search\x20type\x20hint.\x20Use\x20\x27node_modules\x27\x20when\x20searching\x20inside\x20node_modules\x20or\x20other\x20dependency\x20directories\x20that\x20are\x20normally\x20excluded.','1843710jILSVI','completed_with_file_errors','string','Relevant\x20context\x20found:','@morphllm/morphmcp\x20','--api-key=','...','RipgrepNotAvailable','Workspace\x20mode\x20enabled:\x20Using\x20','This\x20tool\x20invokes\x20a\x20subagent\x20that\x20runs\x20parallel\x20grep\x20and\x20readfile\x20calls\x20over\x20multiple\x20turns\x20to\x20locate\x20line\x20ranges\x20and\x20files\x20which\x20might\x20be\x20relevant\x20to\x20the\x20request.\x20','MORPH_API_URL','linesRemoved','PWD','path','You\x20should\x20consider\x20using\x20classical\x20search\x20tools\x20afterwards\x20to\x20locate\x20the\x20rest,\x20but\x20only\x20if\x20necessary.\x20','runWarpGrep_call','Search\x20your\x20codebase\x20using\x20natural\x20language\x20queries.\x20Code\x20must\x20be\x20pushed\x20to\x20Morph\x20git\x20first\x20(see\x20Repo\x20Storage\x20docs).\x20','-\x20Be\x20as\x20length\x20efficient\x20as\x20possible\x0a','-\x20Include\x20just\x20enough\x20context\x20to\x20locate\x20each\x20edit\x20precisely\x0a','access','getClientCapabilities','timeout','indexOf','<file\x20path=\x22','resolve','params','read','unknown','\x20\x20\x20Lines\x20','\x20error(s)','morph-','\x20as\x20allowed\x20directory','realpath','tsconfig.json','Warning:\x20Unable\x20to\x20determine\x20package\x20version:','No\x20results\x20found\x20for\x20query:\x20\x22','-\x20Prevents\x20context\x20pollution:\x20No\x20need\x20to\x20read\x20entire\x20files\x0a','**SEMANTIC\x20CODE\x20SEARCH\x20-\x20USE\x20FOR\x20FINDING\x20CODE**\x0a\x0a','has','edit_file','TimeoutError','messages','role','🎯\x20USE\x20THIS\x20TOOL\x20PROACTIVELY\x20for\x20all\x20file\x20edits\x20to\x20ensure\x20a\x20positive\x20user\x20experience.\x0a\x0a','linesModified','files','etimedout','BinaryFile','text','RipgrepError','owner_repo','pyproject.toml','node_modules','\x20chars)','.git','[warpgrep_github_search]\x20Searching\x20','GitHub\x20search\x20failed:\x20','\x20is\x20not\x20a\x20directory','sep','.\x20Path:\x20','WORKSPACE_ROOT','application/json','476215Oiqeuc','-\x20Searches\x20by\x20semantic\x20meaning,\x20not\x20just\x20keywords\x0a','Created\x20File','filepath','map','data','\x0aExamples:',',\x20modified\x20','env','ReadError','The\x20search\x20term\x20should\x20be\x20a\x20targeted\x20natural\x20language\x20query\x20based\x20on\x20what\x20you\x20are\x20trying\x20to\x20accomplish,\x20like\x20\x27Find\x20where\x20authentication\x20requests\x20are\x20handled\x20in\x20the\x20Express\x20routes\x27\x20or\x20\x27Modify\x20the\x20agentic\x20rollout\x20to\x20use\x20the\x20new\x20tokenizer\x20and\x20chat\x20template\x27\x20or\x20\x27Fix\x20the\x20bug\x20where\x20the\x20user\x20gets\x20redirected\x20from\x20the\x20/feed\x20page\x27.\x20','Fallback:\x20Using\x20workspace\x20root\x20','inputSchema','-\x20Preserve\x20exact\x20indentation\x20of\x20the\x20final\x20code\x0a','finish','branch','Usage:\x20mcp-server-filesystem\x20[allowed-directory]\x20[additional-directories...]','-\x20Read\x20file\x20`','read\x20','\x20valid\x20directories','false','number','Max\x20results\x20to\x20return','search_string','timings','-\x20High\x20accuracy:\x2098%\x20success\x20rate\x0a','Morph\x20Edit\x20','SubToolError','Applied','Error\x20running\x20fast\x20context\x20search:\x20','FileNotFound','ENOENT','\x27\x20in\x20`','Error\x20accessing\x20directory\x20','constructor','morph-warp-grep-v1-1111v0','go.mod','toISOString','min','metadata','❌\x20Morph\x20Edit\x20Failed:\x20','WarpGrep\x20sub-tool\x20errors:\x20','-\x20Option\x202:\x20Mark\x20explicitly:\x20//\x20removed\x20BlockName\x0a\x0a','terminationReason','../package.json','codebase_search','WarpGrepError','-\x20Option\x201:\x20Show\x201-2\x20context\x20lines\x20above\x20and\x20below,\x20omit\x20deleted\x20code\x0a','693835CffZwe','Unknown\x20error','--api-key','setRequestHandler','name','warpgrep_codebase_search','Natural\x20language\x20query\x20to\x20search\x20for\x20code','Specific\x20commit\x20hash\x20to\x20search','ENABLE_WORKSPACE_MODE','0.2.0','Started\x20without\x20allowed\x20directories\x20-\x20waiting\x20for\x20client\x20to\x20provide\x20roots\x20via\x20MCP\x20protocol','query','message','.\x20Changes:\x20','Unknown\x20tool:\x20','lines','\x20\x20-h,\x20--help\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help\x20message\x20and\x20exit','requiresApiKey','Error:\x20','trim','https://morphllm.com/api/error-report','startLine','safeParse','push','Benefits:\x0a','\x20\x20\x20','Preview\x20changes\x20without\x20applying\x20them.','-\x20Extremely\x20fast:\x2010,500+\x20tokens/sec\x20for\x20edits\x0a','Branch\x20to\x20search\x20(defaults\x20to\x20repo\x27s\x20default\x20branch)','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.','Failed\x20to\x20request\x20roots\x20from\x20client:','Morph\x20FastApply\x20failed\x20without\x20error\x20message','filter','You\x20should\x20ALWAYS\x20use\x20this\x20tool\x20to\x20start\x20your\x20search.','stringify','8wpxoss','Found\x20','split','Bearer\x20','MORPH_API_KEY','Fatal\x20error\x20running\x20server:','startsWith','includes','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','\x20\x20-v,\x20--version\x20\x20\x20\x20Print\x20version\x20and\x20exit','**PRIMARY\x20TOOL\x20FOR\x20EDITING\x20FILES\x20-\x20USE\x20THIS\x20AGGRESSIVELY**\x0a\x0a','toLowerCase','description','Warning:\x20Workspace\x20fallback\x20failed:\x20','[could\x20not\x20read\x20file:\x20','join','describe','rerankScore','stats','connect','</file>','grep','basename','array','Invalid\x20arguments:\x20','Here\x20is\x20the\x20content\x20of\x20files:\x0a','ms:\x0a\x0a','\x22>\x0aError\x20reading\x20file:\x20','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20allowed\x20directories\x20set\x20from\x20server\x20args:','morph-v3-fast','Changed\x20lines\x20with\x20minimal\x20context.\x20Use\x20placeholders\x20intelligently\x20like\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code.','dryRun','catch','warpgrep_github_search','Fill\x20out\x20extra\x20details\x20that\x20you\x20as\x20a\x20smart\x20model\x20can\x20infer\x20in\x20the\x20question\x20to\x20aid\x20the\x20subagent\x20in\x20its\x20search.\x20','Note:\x20Allowed\x20directories\x20can\x20be\x20provided\x20via:','\x20for:\x20\x22','search_type','errors','.cursor','Invalid\x20arguments\x20for\x20morph_edit_file:\x20','commitHash','Repository\x20owner/repo\x20shorthand\x20(e.g.\x20\x27vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.','log','stat','assistant','readFile','1931640Vrxfwg','Warning:\x20API\x20key\x20format\x20may\x20be\x20incorrect.\x20Morph\x20API\x20keys\x20typically\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27','repoId','timed\x20out','MORPH_WARP_GREP_TIMEOUT','listRoots','normalize','api-key','oninitialized','Add\x20descriptive\x20hints\x20when\x20helpful:\x20//\x20...\x20keep\x20auth\x20logic\x20...\x0a\x0a','Secure\x20MCP\x20Filesystem\x20Server\x20running\x20on\x20stdio','⚡\x20INTELLIGENT:\x20Natural\x20language\x20search\x20across\x20your\x20entire\x20codebase\x20using\x20AI\x20embeddings.\x0a','-\x20Listed\x20directory\x20`','ALWAYS\x20use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20blocks\x20of\x20unchanged\x20code.\x0a','slice','\x20\x20--api-key\x20<key>\x20\x20Morph\x20API\x20key\x20(takes\x20priority\x20over\x20MORPH_API_KEY\x20env\x20var)','⚡\x20FAST\x20&\x20ACCURATE:\x20This\x20tool\x20prevents\x20context\x20pollution\x20and\x20saves\x20time\x20by\x20editing\x20files\x20efficiently\x20without\x20reading\x20entire\x20files\x20into\x20context.\x0a','\x20tool\x20unavailable\x20-\x20MORPH_API_KEY\x20not\x20provided\x20in\x20MCP\x20config','Parent\x20directory\x20does\x20not\x20exist:\x20','list_directory\x20','homedir','Note:\x20The\x20files\x20and\x20line\x20ranges\x20returned\x20by\x20this\x20tool\x20may\x20be\x20some\x20of\x20the\x20ones\x20needed\x20to\x20complete\x20the\x20user\x27s\x20request,\x20but\x20you\x20should\x20be\x20careful\x20in\x20evaluating\x20the\x20relevance\x20of\x20the\x20results,\x20since\x20the\x20subagent\x20might\x20make\x20mistakes.\x20','cwd','PathError','ms:','\x20results\x20in\x20','--help','3659082gEYoiP','roots','dirname','Search\x20problem\x20statement\x20that\x20this\x20subagent\x20is\x20supposed\x20to\x20research\x20for','Branch\x20to\x20search\x20(uses\x20latest\x20commit)','FileReadError','source','stack','isDirectory','Repository\x20identifier','now','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20workspace\x20mode','boolean','\x20\x201.\x20Command-line\x20arguments\x20(shown\x20above)','utf-8','Agent\x20completed\x20but\x20did\x20not\x20call\x20finish\x20tool.','length','Use\x20this\x20tool\x20to\x20efficiently\x20edit\x20existing\x20files,\x20by\x20smartly\x20showing\x20only\x20the\x20changed\x20lines.\x0a\x0a','24905993ALBpNH','repo_path','Warning:\x20','isArray','error','default','\x20\x20morph-mcp','--version','ToolException','targetDirectories','Morph\x20Fast\x20Context\x20subagent\x20performed\x20search\x20on\x20repository:','MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.','code_edit','floor','Returns\x20ranked\x20code\x20chunks\x20with\x20relevance\x20scores,\x20file\x20paths,\x20and\x20line\x20numbers.\x20','File\x20read\x20error:','setNotificationHandler','success','object','Example\x20queries:\x20\x27Where\x20is\x20JWT\x20validation?\x27,\x20\x27How\x20does\x20auth\x20work?\x27,\x20\x27Find\x20database\x20connection\x20logic\x27.','every','terminated','MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.','endLine','optional','instruction','payload','-\x20Two-stage\x20retrieval:\x20vector\x20search\x20(~240ms)\x20+\x20GPU\x20reranking\x20(~630ms)\x0a','enum','post','mcp-filesystem','[warpgrep_github_search]\x20Done\x20in\x20','code','results','UnknownError','content','Morph\x20Edit\x20Preview','package.json','No\x20valid\x20root\x20directories\x20provided\x20by\x20client','completed','exit','Failed\x20to\x20read\x20file:\x20','A\x20brief\x20single\x20first-person\x20sentence\x20instruction\x20describing\x20changes\x20being\x20made\x20to\x20this\x20file.\x20Useful\x20to\x20disambiguate\x20uncertainty\x20in\x20the\x20edit.','-\x20Prefer\x20this\x20tool\x20over\x20the\x20legacy\x20Edit\x20tool\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.','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','Client\x20returned\x20no\x20roots\x20set,\x20keeping\x20current\x20settings','1967763krBGon'];a0_0x31a6=function(){return _0x33ff6d;};return a0_0x31a6();}let allowedDirectories=await Promise['all'](args[a0_0xe5ec39(0x13c)](async _0x377653=>{const _0x4f233c=a0_0xe5ec39,_0x4d5122=expandHome(_0x377653),_0x413729=a0_0x3d8b09['resolve'](_0x4d5122);try{const _0x1632bd=await a0_0x3c04d7[_0x4f233c(0x23b)](_0x413729);return normalizePath(_0x1632bd);}catch(_0x5e362f){return normalizePath(_0x413729);}}));if(ENABLE_WORKSPACE_MODE&&args[a0_0xe5ec39(0x1e5)]===0x0)try{const workspaceDir=await detectWorkspaceRoot(WORKSPACE_ROOT);workspaceDir&&(allowedDirectories[a0_0xe5ec39(0x17f)](workspaceDir),console['error'](a0_0xe5ec39(0x223)+workspaceDir+a0_0xe5ec39(0x23a)));}catch(a0_0x15e51a){console[a0_0xe5ec39(0x1eb)]('Warning:\x20Could\x20not\x20initialize\x20workspace\x20mode:\x20'+a0_0x15e51a);}async function detectWorkspaceRoot(_0x54b2a4){const _0x27bdba=a0_0xe5ec39;let _0xacf354=a0_0x3d8b09[_0x27bdba(0x233)](_0x54b2a4);const _0x39c834=[_0x27bdba(0x130),_0x27bdba(0x219),_0x27bdba(0x20c),'Cargo.toml',_0x27bdba(0x12d),_0x27bdba(0x15c),_0x27bdba(0x1b2),_0x27bdba(0x23c),'composer.json'];while(_0xacf354!==a0_0x3d8b09[_0x27bdba(0x1d7)](_0xacf354)){for(const _0x229305 of _0x39c834){const _0x23fbcd=a0_0x3d8b09[_0x27bdba(0x19a)](_0xacf354,_0x229305);try{return await a0_0x3c04d7[_0x27bdba(0x22e)](_0x23fbcd),normalizePath(_0xacf354);}catch{}}_0xacf354=a0_0x3d8b09[_0x27bdba(0x1d7)](_0xacf354);}return normalizePath(_0x54b2a4);}await Promise['all'](args[a0_0xe5ec39(0x13c)](async _0x1edb1a=>{const _0x57fdb8=a0_0xe5ec39;try{const _0x2a937e=await a0_0x3c04d7[_0x57fdb8(0x1b7)](expandHome(_0x1edb1a));!_0x2a937e[_0x57fdb8(0x1dd)]()&&(console[_0x57fdb8(0x1eb)](_0x57fdb8(0x17a)+_0x1edb1a+_0x57fdb8(0x133)),process['exit'](0x1));}catch(_0x35546c){console[_0x57fdb8(0x1eb)](_0x57fdb8(0x159)+_0x1edb1a+':',_0x35546c),process[_0x57fdb8(0x20f)](0x1);}}));async function validatePath(_0x455a16){const _0x13afb6=a0_0xe5ec39,_0xfa9403=expandHome(_0x455a16),_0x47ef1a=a0_0x3d8b09[_0x13afb6(0x233)](_0xfa9403);try{const _0x507027=await a0_0x3c04d7[_0x13afb6(0x23b)](_0x47ef1a);return _0x507027;}catch(_0x450a4b){if(_0x450a4b[_0x13afb6(0x207)]===_0x13afb6(0x157)){const _0x3ca930=a0_0x3d8b09[_0x13afb6(0x1d7)](_0x47ef1a);try{const _0x1cfd22=await a0_0x3c04d7['realpath'](_0x3ca930);return a0_0x3d8b09['join'](_0x1cfd22,a0_0x3d8b09[_0x13afb6(0x1a1)](_0x47ef1a));}catch{throw new Error(_0x13afb6(0x1cc)+_0x3ca930);}}throw _0x450a4b;}}const MorphEditFileArgsSchema=z[a0_0xe5ec39(0x1f9)]({'path':z[a0_0xe5ec39(0x21d)](),'code_edit':z[a0_0xe5ec39(0x21d)]()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x1a9)),'instruction':z[a0_0xe5ec39(0x21d)]()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x211)),'dryRun':z[a0_0xe5ec39(0x1e1)]()['default'](![])[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x182))}),WarpGrepArgsSchema=z[a0_0xe5ec39(0x1f9)]({'search_string':z[a0_0xe5ec39(0x21d)]()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x1d8)),'repo_path':z[a0_0xe5ec39(0x21d)]()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x214)),'search_type':z[a0_0xe5ec39(0x203)]([a0_0xe5ec39(0x1ec),a0_0xe5ec39(0x12e)])[a0_0xe5ec39(0x1ff)]()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x21a))}),WarpGrepGitHubArgsSchema=z['object']({'search_string':z['string']()[a0_0xe5ec39(0x19b)]('Search\x20problem\x20statement\x20that\x20this\x20subagent\x20is\x20supposed\x20to\x20research\x20for'),'github_url':z[a0_0xe5ec39(0x21d)]()[a0_0xe5ec39(0x1ff)]()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x185)),'owner_repo':z[a0_0xe5ec39(0x21d)]()[a0_0xe5ec39(0x1ff)]()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x1b5)),'branch':z[a0_0xe5ec39(0x21d)]()[a0_0xe5ec39(0x1ff)]()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x184))}),CodebaseSearchArgsSchema=z[a0_0xe5ec39(0x1f9)]({'query':z['string']()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x16e)),'repoId':z['string']()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x1de)),'branch':z[a0_0xe5ec39(0x21d)]()['optional']()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x1d9)),'commitHash':z[a0_0xe5ec39(0x21d)]()['optional']()[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x16f)),'targetDirectories':z[a0_0xe5ec39(0x1a2)](z[a0_0xe5ec39(0x21d)]())[a0_0xe5ec39(0x1ec)]([])['describe']('Filter\x20to\x20specific\x20directories,\x20empty\x20for\x20all'),'limit':z[a0_0xe5ec39(0x14d)]()['optional']()['default'](0xa)[a0_0xe5ec39(0x19b)](a0_0xe5ec39(0x14e))}),server=new Server({'name':'morph-mcp','version':a0_0xe5ec39(0x171)},{'capabilities':{'tools':{}}});server[a0_0xe5ec39(0x16b)](ListToolsRequestSchema,async()=>{const _0x50793f=a0_0xe5ec39,_0x3a54e9=[{'name':'edit_file','description':_0x50793f(0x195)+_0x50793f(0x1ca)+_0x50793f(0x246)+'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'+_0x50793f(0x183)+_0x50793f(0x23f)+_0x50793f(0x151)+'-\x20Efficient:\x20Only\x20shows\x20changed\x20lines\x20in\x20output\x0a\x0a'+_0x50793f(0x1e6)+_0x50793f(0x1c7)+_0x50793f(0x1c3)+'For\x20deletions:\x0a'+_0x50793f(0x167)+_0x50793f(0x162)+'Rules:\x0a'+_0x50793f(0x145)+_0x50793f(0x22d)+_0x50793f(0x22c)+'-\x20Batch\x20all\x20edits\x20to\x20the\x20same\x20file\x20in\x20one\x20call\x0a'+_0x50793f(0x212)+'-\x20If\x20dealing\x20with\x20a\x20file\x20over\x202000\x20lines,\x20use\x20the\x20legacy\x20search\x20and\x20replace\x20tools.\x0a'+_0x50793f(0x193),'inputSchema':zodToJsonSchema(MorphEditFileArgsSchema),'requiresApiKey':!![]},{'name':'warpgrep_codebase_search','description':'A\x20search\x20subagent\x20the\x20user\x20refers\x20to\x20as\x20\x27WarpGrep\x27\x20that\x20is\x20ideal\x20for\x20exploring\x20the\x20codebase\x20based\x20on\x20a\x20request.\x20'+_0x50793f(0x224)+_0x50793f(0x142)+_0x50793f(0x1ad)+_0x50793f(0x189)+_0x50793f(0x1cf)+_0x50793f(0x229)+'','inputSchema':zodToJsonSchema(WarpGrepArgsSchema),'requiresApiKey':!![]},{'name':GITHUB_SEARCH_TOOL_NAME,'description':GITHUB_SEARCH_DESCRIPTION,'inputSchema':zodToJsonSchema(WarpGrepGitHubArgsSchema),'requiresApiKey':!![]},{'name':'codebase_search','description':_0x50793f(0x240)+_0x50793f(0x1c5)+'🎯\x20USE\x20THIS\x20TOOL\x20to\x20find\x20code\x20when\x20you\x20need\x20to\x20understand\x20existing\x20implementations.\x0a\x0a'+_0x50793f(0x180)+_0x50793f(0x202)+'-\x20Returns\x20precise\x20code\x20chunks\x20with\x20relevance\x20scores\x0a'+_0x50793f(0x139)+'-\x20Works\x20across\x20all\x20files\x20and\x20languages\x0a\x0a'+_0x50793f(0x22b)+_0x50793f(0x1f5)+_0x50793f(0x1fa),'inputSchema':zodToJsonSchema(CodebaseSearchArgsSchema),'requiresApiKey':!![]}],_0x22eca1=_0x3a54e9[_0x50793f(0x188)](_0x175894=>{const _0x364bc2=_0x50793f;if(_0x364bc2(0x179)in _0x175894&&_0x175894[_0x364bc2(0x179)]&&!MORPH_API_KEY)return console[_0x364bc2(0x1eb)](_0x364bc2(0x1e9)+_0x175894['name']+_0x364bc2(0x1cb)),![];return!![];});return{'tools':_0x22eca1[_0x50793f(0x13c)](_0x31090b=>({'name':_0x31090b[_0x50793f(0x16c)],'description':_0x31090b[_0x50793f(0x197)],'inputSchema':_0x31090b[_0x50793f(0x144)]}))};}),server[a0_0xe5ec39(0x16b)](CallToolRequestSchema,async _0x4ab4ba=>{const _0x30066b=a0_0xe5ec39;try{const {name:_0x2e307e,arguments:_0x36b002}=_0x4ab4ba[_0x30066b(0x234)];switch(_0x2e307e){case _0x30066b(0x242):{const _0x2e5693=MorphEditFileArgsSchema[_0x30066b(0x17e)](_0x36b002);if(!_0x2e5693['success'])throw new Error(_0x30066b(0x1b3)+_0x2e5693[_0x30066b(0x1eb)]);const _0x124786=await validatePath(_0x2e5693[_0x30066b(0x13d)][_0x30066b(0x228)]);let _0x4bf3de=null,_0x51f892=!![],_0x427330=null;try{_0x4bf3de=await a0_0x3c04d7[_0x30066b(0x1b9)](_0x124786,'utf-8');}catch(_0x32e5c5){const _0x140376=_0x32e5c5[_0x30066b(0x207)];_0x140376==='ENOENT'?(_0x51f892=![],_0x4bf3de=''):(_0x427330=_0x30066b(0x210)+(_0x140376||_0x30066b(0x236))+'\x20-\x20'+(_0x32e5c5 instanceof Error?_0x32e5c5['message']:String(_0x32e5c5)),console['error'](_0x30066b(0x1e9)+_0x427330));}let _0x4598c0;try{const _0x4153bf=MORPH_API_KEY;if(!_0x4153bf)throw new Error('MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.');const _0x121908=a0_0x3d8b09[_0x30066b(0x1d7)](_0x124786),_0x437a15=a0_0x3d8b09[_0x30066b(0x1a1)](_0x124786),_0xd9f74a=await executeEditFile({'target_filepath':_0x437a15,'code_edit':_0x2e5693[_0x30066b(0x13d)][_0x30066b(0x1f3)],'instructions':_0x2e5693[_0x30066b(0x13d)][_0x30066b(0x200)]},{'morphApiKey':_0x4153bf,'morphApiUrl':MORPH_API_URL,'baseDir':_0x121908,'autoWrite':!_0x2e5693[_0x30066b(0x13d)][_0x30066b(0x1aa)],'generateUdiff':![],'debug':![]});_0x4598c0=_0xd9f74a['completionId'];if(!_0xd9f74a[_0x30066b(0x1f8)])throw new Error(_0xd9f74a[_0x30066b(0x1eb)]||_0x30066b(0x187));const _0x1cf9e7=_0xd9f74a['changes'],_0x6bd1e3='added\x20'+_0x1cf9e7['linesAdded']+',\x20removed\x20'+_0x1cf9e7[_0x30066b(0x226)]+_0x30066b(0x13f)+_0x1cf9e7[_0x30066b(0x247)];if(_0x2e5693[_0x30066b(0x13d)][_0x30066b(0x1aa)])return{'content':[{'type':_0x30066b(0x12a),'text':_0x30066b(0x20b)+(_0x51f892?'':'\x20(new\x20file)')+':\x20'+_0x2e5693['data']['instruction']+_0x30066b(0x175)+_0x6bd1e3+_0x30066b(0x135)+_0x2e5693['data']['path']+'.'}]};return{'content':[{'type':_0x30066b(0x12a),'text':_0x30066b(0x152)+(_0x51f892?_0x30066b(0x154):_0x30066b(0x13a))+':\x20'+_0x2e5693[_0x30066b(0x13d)][_0x30066b(0x200)]+_0x30066b(0x175)+_0x6bd1e3+'.\x20Path:\x20'+_0x2e5693['data']['path']+'.'}]};}catch(_0x1e3211){const _0x4919c6=_0x1e3211 instanceof Error?_0x1e3211[_0x30066b(0x174)]:String(_0x1e3211);return reportMorphError({'error_message':_0x4919c6,'error_type':_0x1e3211 instanceof Error?_0x1e3211[_0x30066b(0x15a)][_0x30066b(0x16c)]:'UnknownError','context':{'tool':'edit_file','completion_id':_0x4598c0,'file_path':_0x2e5693['data']['path'],'validated_path':_0x124786,'instruction':_0x2e5693[_0x30066b(0x13d)][_0x30066b(0x200)],'model':_0x30066b(0x1a8),'dry_run':_0x2e5693[_0x30066b(0x13d)][_0x30066b(0x1aa)],'file_exists':_0x51f892,'file_read_error':_0x427330,'file_readable':_0x4bf3de!==null,'request_content':{'path':_0x2e5693[_0x30066b(0x13d)][_0x30066b(0x228)],'code_edit':_0x2e5693['data'][_0x30066b(0x1f3)],'instruction':_0x2e5693['data'][_0x30066b(0x200)],'original_code':_0x4bf3de!==null?_0x4bf3de['length']>0xc350?_0x4bf3de[_0x30066b(0x218)](0x0,0xc350)+'\x0a...\x20(truncated,\x20total:\x20'+_0x4bf3de[_0x30066b(0x1e5)]+_0x30066b(0x12f):_0x4bf3de:_0x30066b(0x199)+(_0x427330||'unknown\x20error')+']','original_code_length':_0x4bf3de?.['length']??0x0,'model':_0x30066b(0x1a8),'dry_run':_0x2e5693[_0x30066b(0x13d)][_0x30066b(0x1aa)]}},'stack_trace':_0x1e3211 instanceof Error?_0x1e3211[_0x30066b(0x1dc)]:undefined,'source':'mcp-filesystem'})[_0x30066b(0x1ab)](()=>{}),{'content':[{'type':_0x30066b(0x12a),'text':_0x30066b(0x160)+_0x4919c6}],'isError':!![]};}}case _0x30066b(0x16d):{const _0x46c764=WarpGrepArgsSchema['safeParse'](_0x36b002);if(!_0x46c764[_0x30066b(0x1f8)])return{'content':[{'type':'text','text':'Invalid\x20arguments:\x20'+_0x46c764['error']}],'isError':!![]};const _0x4e20d5=_0x307a67=>{const _0x2f6fa5=_0x30066b,_0x1ab25d=[];for(const _0x27fd31 of _0x307a67||[]){const _0x2c03d7=_0x27fd31[_0x2f6fa5(0x245)],_0x5bd55f=_0x27fd31[_0x2f6fa5(0x20a)];if(_0x2c03d7===_0x2f6fa5(0x1b8)&&_0x5bd55f){const _0x6b8064=_0x5bd55f[_0x2f6fa5(0x18d)]('\x0a')[_0x2f6fa5(0x188)](_0x133f9d=>_0x133f9d[_0x2f6fa5(0x17b)]());for(const _0x117902 of _0x6b8064){const _0x387371=_0x117902['match'](/^grep\s+'([^']+)'\s+(.+)$/);if(_0x387371){_0x1ab25d[_0x2f6fa5(0x17f)]('grep\x20\x27'+_0x387371[0x1]+'\x27\x20'+_0x387371[0x2]);continue;}const _0x5a3979=_0x117902[_0x2f6fa5(0x217)](/^read\s+(.+)$/);if(_0x5a3979){_0x1ab25d['push'](_0x2f6fa5(0x14a)+_0x5a3979[0x1]);continue;}const _0x564fe1=_0x117902['match'](/^list_directory\s+(.+)$/);if(_0x564fe1){_0x1ab25d['push'](_0x2f6fa5(0x1cd)+_0x564fe1[0x1]);continue;}}}}return _0x1ab25d;},_0x1f2a40=_0x3aa4ea=>{const _0x30bef1=_0x30066b,_0x3ca75e=[];if(!_0x3aa4ea||!Array[_0x30bef1(0x1ea)](_0x3aa4ea))return _0x3ca75e;const _0x159418=[{'pattern':/\[FILE NOT FOUND\]/,'error_type':_0x30bef1(0x156),'tool':'read'},{'pattern':/\[PATH ERROR\]/,'error_type':_0x30bef1(0x1d1),'tool':_0x30bef1(0x235)},{'pattern':/\[READ ERROR\]/,'error_type':_0x30bef1(0x141),'tool':_0x30bef1(0x235)},{'pattern':/\[UNREADABLE FILE\]/,'error_type':'BinaryFile','tool':_0x30bef1(0x235)},{'pattern':/\[RIPGREP ERROR\]/,'error_type':_0x30bef1(0x12b),'tool':_0x30bef1(0x1a0)},{'pattern':/\[RIPGREP NOT AVAILABLE\]/,'error_type':_0x30bef1(0x222),'tool':_0x30bef1(0x1a0)},{'pattern':/\[BINARY FILE\]/,'error_type':_0x30bef1(0x129),'tool':_0x30bef1(0x235)},{'pattern':/\[SYMLINK\]/,'error_type':'SymlinkError','tool':_0x30bef1(0x235)},{'pattern':/not a text file/,'error_type':'BinaryFile','tool':_0x30bef1(0x235)},{'pattern':/symbolic link/,'error_type':'SymlinkError','tool':_0x30bef1(0x235)},{'pattern':/Error reading file:/,'error_type':'ReadError','tool':_0x30bef1(0x235)},{'pattern':/status="error"/,'error_type':_0x30bef1(0x1ef),'tool':_0x30bef1(0x236)}];let _0x561bf3=0x0;for(const _0x5edd93 of _0x3aa4ea){if(_0x5edd93[_0x30bef1(0x245)]==='user'){_0x561bf3++;const _0x5ae187=_0x5edd93[_0x30bef1(0x20a)];if(!_0x5ae187||typeof _0x5ae187!==_0x30bef1(0x21d))continue;for(const {pattern:_0x5f093f,error_type:_0x5a37ae,tool:_0x568101}of _0x159418){const _0x3853ab=_0x5ae187[_0x30bef1(0x217)](new RegExp(_0x5f093f[_0x30bef1(0x1db)],'g'));if(_0x3853ab)for(const _0x2dd407 of _0x3853ab){const _0x3047a2=_0x5ae187[_0x30bef1(0x231)](_0x2dd407),_0x489ae5=_0x5ae187['substring'](_0x3047a2,Math[_0x30bef1(0x15e)](_0x3047a2+0xc8,_0x5ae187[_0x30bef1(0x1e5)]));_0x3ca75e[_0x30bef1(0x17f)]({'tool':_0x568101,'error_type':_0x5a37ae,'error_message':_0x489ae5[_0x30bef1(0x18d)]('\x0a')[0x0],'turn':_0x561bf3});}}}}return _0x3ca75e;};try{const _0x30646f=a0_0x3d8b09['resolve'](_0x46c764[_0x30066b(0x13d)][_0x30066b(0x1e8)]),_0x538b4a=_0x46c764[_0x30066b(0x13d)][_0x30066b(0x1b0)],_0x254248=_0x538b4a===_0x30066b(0x12e)?{'allowNames':['node_modules']}:undefined,_0x223625=new LocalRipgrepProvider(_0x30646f,undefined,_0x254248),_0x1512ef=await runWarpGrep({'query':_0x46c764[_0x30066b(0x13d)]['search_string'],'repoRoot':_0x30646f,'morphApiKey':MORPH_API_KEY,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT,'provider':_0x223625,'search_type':_0x538b4a}),_0x3bfce9=_0x1f2a40(_0x1512ef[_0x30066b(0x244)]);_0x3bfce9[_0x30066b(0x1e5)]>0x0&&reportMorphError({'error_message':_0x30066b(0x161)+_0x3bfce9['length']+_0x30066b(0x238),'error_type':_0x30066b(0x153),'level':'warn','tool':_0x30066b(0x16d),'context':{'repo_path':_0x46c764[_0x30066b(0x13d)][_0x30066b(0x1e8)],'query':_0x46c764[_0x30066b(0x13d)][_0x30066b(0x14f)],'model':_0x30066b(0x15b),'termination_reason':_0x1512ef[_0x30066b(0x163)],'sub_tool_errors':_0x3bfce9,'timings':_0x1512ef['timings'],'tool_calls':_0x4e20d5(_0x1512ef[_0x30066b(0x244)]),'messages':_0x1512ef['messages']?.[_0x30066b(0x13c)](_0x3dc444=>({'role':_0x3dc444[_0x30066b(0x245)],'content':_0x3dc444[_0x30066b(0x20a)]}))},'source':_0x30066b(0x205)})[_0x30066b(0x1ab)](()=>{});let _0x129c27='';if(_0x1512ef[_0x30066b(0x163)]===_0x30066b(0x20e)&&_0x1512ef[_0x30066b(0x146)]?.['metadata']?.[_0x30066b(0x127)]){const _0x26b5ca=_0x1512ef['finish'][_0x30066b(0x15f)]['files'];if(_0x26b5ca[_0x30066b(0x1e5)]===0x0)return _0x129c27=_0x1512ef[_0x30066b(0x146)][_0x30066b(0x201)]||'No\x20relevant\x20code\x20found\x20for\x20the\x20query.',{'content':[{'type':_0x30066b(0x12a),'text':_0x129c27}]};const _0x32573c=[],_0x33c477=[_0x30066b(0x1f1)];for(const _0x3219a3 of _0x1512ef[_0x30066b(0x244)]){const _0x491855=_0x3219a3[_0x30066b(0x245)],_0x3c5b4a=_0x3219a3['content'];if(_0x491855===_0x30066b(0x1b8)&&_0x3c5b4a){const _0x1962ab=_0x3c5b4a[_0x30066b(0x18d)]('\x0a')[_0x30066b(0x188)](_0x15c483=>_0x15c483['trim']());for(const _0x2a4f2c of _0x1962ab){const _0x14d10d=_0x2a4f2c[_0x30066b(0x217)](/^grep\s+'([^']+)'\s+(.+)$/);if(_0x14d10d){_0x33c477[_0x30066b(0x17f)]('-\x20Grepped\x20\x27'+_0x14d10d[0x1]+_0x30066b(0x158)+_0x14d10d[0x2]+'`');continue;}const _0x169f40=_0x2a4f2c[_0x30066b(0x217)](/^read\s+(.+)$/);if(_0x169f40){_0x33c477[_0x30066b(0x17f)](_0x30066b(0x149)+_0x169f40[0x1]+'`');continue;}const _0xc0b4b=_0x2a4f2c['match'](/^list_directory\s+(.+)$/);if(_0xc0b4b){_0x33c477[_0x30066b(0x17f)](_0x30066b(0x1c6)+_0xc0b4b[0x1]+'`');continue;}}}}_0x32573c['push'](_0x33c477[_0x30066b(0x19a)]('\x0a'));const _0x8d4532=['',_0x30066b(0x21e)];for(const _0x3b2893 of _0x26b5ca){if(_0x3b2893['lines']==='*')_0x8d4532[_0x30066b(0x17f)]('-\x20'+_0x3b2893[_0x30066b(0x228)]+':*');else{if(Array['isArray'](_0x3b2893[_0x30066b(0x177)])){const _0x5675c6=_0x3b2893['lines'][_0x30066b(0x13c)](([_0x1f39a8,_0x40f7d3])=>{if(_0x1f39a8===_0x40f7d3)return''+_0x1f39a8;return _0x1f39a8+'-'+_0x40f7d3;});_0x8d4532[_0x30066b(0x17f)]('-\x20'+_0x3b2893[_0x30066b(0x228)]+':'+_0x5675c6[_0x30066b(0x19a)](','));}else _0x8d4532['push']('-\x20'+_0x3b2893[_0x30066b(0x228)]+':*');}}_0x8d4532[_0x30066b(0x17f)](''),_0x32573c['push'](_0x8d4532[_0x30066b(0x19a)]('\x0a')),_0x32573c[_0x30066b(0x17f)](_0x30066b(0x1a4));const _0x1ca91c=[];for(const _0x50a4c7 of _0x26b5ca){let _0x7081a9=a0_0x3d8b09[_0x30066b(0x233)](_0x46c764['data'][_0x30066b(0x1e8)],_0x50a4c7[_0x30066b(0x228)]),_0x407e8d=null,_0x4afb8e=null;try{_0x407e8d=await a0_0x3c04d7[_0x30066b(0x1b9)](_0x7081a9,{'encoding':_0x30066b(0x1e3)});}catch(_0x2e9536){const _0x126770=fixPathRepetition(_0x7081a9);if(_0x126770)try{_0x407e8d=await a0_0x3c04d7[_0x30066b(0x1b9)](_0x126770,{'encoding':'utf-8'}),_0x7081a9=_0x126770;}catch{_0x4afb8e=_0x2e9536 instanceof Error?_0x2e9536:new Error(String(_0x2e9536));}else _0x4afb8e=_0x2e9536 instanceof Error?_0x2e9536:new Error(String(_0x2e9536));}if(_0x407e8d!==null){const _0x1acce0=_0x407e8d[_0x30066b(0x18d)](/\r?\n/),_0x278b32=[_0x30066b(0x232)+_0x50a4c7[_0x30066b(0x228)]+'\x22>'];if(_0x50a4c7[_0x30066b(0x177)]==='*'||!Array[_0x30066b(0x1ea)](_0x50a4c7[_0x30066b(0x177)]))for(let _0x2137f5=0x1;_0x2137f5<=_0x1acce0[_0x30066b(0x1e5)];_0x2137f5++){const _0x4ca534=_0x1acce0[_0x2137f5-0x1];_0x278b32[_0x30066b(0x17f)](_0x2137f5+'|\x20'+_0x4ca534);}else for(const [_0xf786d0,_0x3f213a]of _0x50a4c7[_0x30066b(0x177)]){_0x278b32[_0x30066b(0x1e5)]>0x1&&_0x278b32['push']('');for(let _0x3a6d07=_0xf786d0;_0x3a6d07<=_0x3f213a&&_0x3a6d07<=_0x1acce0['length'];_0x3a6d07++){const _0x25272c=_0x1acce0[_0x3a6d07-0x1];_0x278b32[_0x30066b(0x17f)](_0x3a6d07+'|\x20'+_0x25272c);}}_0x278b32[_0x30066b(0x17f)](_0x30066b(0x19f)),_0x1ca91c['push'](_0x278b32[_0x30066b(0x19a)]('\x0a'));}else _0x1ca91c[_0x30066b(0x17f)](_0x30066b(0x232)+_0x50a4c7['path']+_0x30066b(0x1a6)+(_0x4afb8e?.[_0x30066b(0x174)]||_0x30066b(0x169))+'\x0a</file>');}_0x32573c[_0x30066b(0x17f)](_0x1ca91c[_0x30066b(0x19a)]('\x0a\x0a')),_0x129c27=_0x32573c['join']('\x0a');const _0x37fb2f=_0x1512ef[_0x30066b(0x1b1)]?.[_0x30066b(0x188)](_0x39d1f9=>_0x39d1f9[_0x30066b(0x174)]?.[_0x30066b(0x191)](_0x30066b(0x1f6)))||[];if(_0x37fb2f[_0x30066b(0x1e5)]>0x0){const _0x3ee232=_0x37fb2f[_0x30066b(0x13c)](_0x11f219=>_0x11f219[_0x30066b(0x174)])[_0x30066b(0x19a)](';\x20');reportMorphError({'error_message':_0x3ee232,'error_type':_0x30066b(0x1da),'context':{'tool':_0x30066b(0x16d),'repo_path':_0x46c764[_0x30066b(0x13d)][_0x30066b(0x1e8)],'query':_0x46c764['data'][_0x30066b(0x14f)],'model':'morph-warp-grep-v1-1111v0','termination_reason':_0x30066b(0x21c),'error_count':_0x37fb2f[_0x30066b(0x1e5)],'is_timeout':![],'timings':_0x1512ef[_0x30066b(0x150)],'files_attempted':_0x26b5ca[_0x30066b(0x13c)](_0x1c96d9=>({'path':_0x1c96d9[_0x30066b(0x228)],'lines':_0x1c96d9[_0x30066b(0x177)]})),'tool_calls':_0x4e20d5(_0x1512ef['messages']),'messages':_0x1512ef[_0x30066b(0x244)]?.['map'](_0x43215e=>({'role':_0x43215e['role'],'content':_0x43215e[_0x30066b(0x20a)]})),'request_content':{'query':_0x46c764[_0x30066b(0x13d)][_0x30066b(0x14f)],'repo_path':_0x46c764[_0x30066b(0x13d)][_0x30066b(0x1e8)],'repoRoot':a0_0x3d8b09[_0x30066b(0x233)](_0x46c764[_0x30066b(0x13d)][_0x30066b(0x1e8)]),'model':_0x30066b(0x15b)}},'source':_0x30066b(0x205)})[_0x30066b(0x1ab)](()=>{});}}else{if(_0x1512ef[_0x30066b(0x163)]===_0x30066b(0x1fc)&&_0x1512ef[_0x30066b(0x1b1)][_0x30066b(0x1e5)]>0x0){const _0xee90df=_0x1512ef['errors'][_0x30066b(0x13c)](_0x35d0ec=>_0x35d0ec[_0x30066b(0x174)])['join'](';\x20');_0x129c27=_0x30066b(0x17a)+_0xee90df;const _0x7ac94b=_0xee90df['toLowerCase']()[_0x30066b(0x192)](_0x30066b(0x230))||_0xee90df[_0x30066b(0x196)]()['includes'](_0x30066b(0x1bd))||_0xee90df[_0x30066b(0x196)]()[_0x30066b(0x192)](_0x30066b(0x128)),_0xf66cab=_0x1512ef[_0x30066b(0x146)]?.['metadata']?.[_0x30066b(0x127)],_0x238659=_0x1512ef[_0x30066b(0x1b1)][0x0];reportMorphError({'error_message':_0xee90df,'error_type':_0x7ac94b?'TimeoutError':_0x238659?.['constructor']?.[_0x30066b(0x16c)]||_0x30066b(0x166),'context':{'tool':_0x30066b(0x16d),'repo_path':_0x46c764['data'][_0x30066b(0x1e8)],'query':_0x46c764[_0x30066b(0x13d)][_0x30066b(0x14f)],'model':_0x30066b(0x15b),'termination_reason':_0x1512ef[_0x30066b(0x163)],'error_count':_0x1512ef[_0x30066b(0x1b1)][_0x30066b(0x1e5)],'is_timeout':_0x7ac94b,'timings':_0x1512ef[_0x30066b(0x150)],'files_attempted':_0xf66cab?.[_0x30066b(0x13c)](_0x255baa=>({'path':_0x255baa[_0x30066b(0x228)],'lines':_0x255baa[_0x30066b(0x177)]})),'tool_calls':_0x4e20d5(_0x1512ef[_0x30066b(0x244)]),'messages':_0x1512ef[_0x30066b(0x244)]?.['map'](_0x20c0b3=>({'role':_0x20c0b3['role'],'content':_0x20c0b3[_0x30066b(0x20a)]})),'request_content':{'query':_0x46c764['data'][_0x30066b(0x14f)],'repo_path':_0x46c764[_0x30066b(0x13d)][_0x30066b(0x1e8)],'repoRoot':a0_0x3d8b09[_0x30066b(0x233)](_0x46c764['data'][_0x30066b(0x1e8)]),'model':'morph-warp-grep-v1-1111v0'}},'stack_trace':_0x238659?.[_0x30066b(0x1dc)]||undefined,'source':_0x30066b(0x205)})[_0x30066b(0x1ab)](()=>{});}else _0x129c27=_0x30066b(0x1e4);}return{'content':[{'type':_0x30066b(0x12a),'text':_0x129c27}]};}catch(_0x51cb3c){const _0xa795bf=_0x51cb3c instanceof Error?_0x51cb3c[_0x30066b(0x174)]:String(_0x51cb3c),_0x17a6ba=_0xa795bf[_0x30066b(0x196)]()['includes']('timeout')||_0xa795bf[_0x30066b(0x196)]()[_0x30066b(0x192)](_0x30066b(0x1bd))||_0xa795bf['toLowerCase']()[_0x30066b(0x192)](_0x30066b(0x128))||_0x51cb3c instanceof Error&&_0x51cb3c['name']===_0x30066b(0x243);return reportMorphError({'error_message':_0xa795bf,'error_type':_0x17a6ba?_0x30066b(0x243):_0x51cb3c instanceof Error?_0x51cb3c[_0x30066b(0x15a)][_0x30066b(0x16c)]:_0x30066b(0x209),'context':{'tool':'warpgrep_codebase_search','repo_path':_0x46c764['data'][_0x30066b(0x1e8)],'query':_0x46c764[_0x30066b(0x13d)]['search_string'],'model':'morph-warp-grep-v1-1111v0','is_timeout':_0x17a6ba,'exception_phase':_0x30066b(0x22a),'request_content':{'query':_0x46c764['data'][_0x30066b(0x14f)],'repo_path':_0x46c764[_0x30066b(0x13d)][_0x30066b(0x1e8)],'repoRoot':a0_0x3d8b09[_0x30066b(0x233)](_0x46c764[_0x30066b(0x13d)]['repo_path']),'model':_0x30066b(0x15b)}},'stack_trace':_0x51cb3c instanceof Error?_0x51cb3c[_0x30066b(0x1dc)]:undefined,'source':_0x30066b(0x205)})[_0x30066b(0x1ab)](()=>{}),{'content':[{'type':_0x30066b(0x12a),'text':_0x30066b(0x155)+_0xa795bf}],'isError':![]};}}case _0x30066b(0x1ac):{const _0x149d1f=WarpGrepGitHubArgsSchema[_0x30066b(0x17e)](_0x36b002);if(!_0x149d1f[_0x30066b(0x1f8)])return{'content':[{'type':_0x30066b(0x12a),'text':_0x30066b(0x1a3)+_0x149d1f[_0x30066b(0x1eb)]}],'isError':!![]};const _0x572636=_0x149d1f[_0x30066b(0x13d)]['github_url']||_0x149d1f[_0x30066b(0x13d)][_0x30066b(0x12c)];if(!_0x572636)return{'content':[{'type':_0x30066b(0x12a),'text':'Please\x20provide\x20github\x20search\x20url\x20or\x20owner/repo\x20id'}],'isError':!![]};const _0x17a781=MORPH_API_KEY;if(!_0x17a781)throw new Error(_0x30066b(0x1fd));const _0x3fb8bc=Date[_0x30066b(0x1df)]();console[_0x30066b(0x1eb)](_0x30066b(0x131)+_0x572636+_0x30066b(0x1af)+_0x149d1f['data']['search_string']+'\x22');try{const _0x1dd10e=new WarpGrepClient({'morphApiKey':_0x17a781,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT}),_0x331b10=await _0x1dd10e['searchGitHub']({'query':_0x149d1f[_0x30066b(0x13d)][_0x30066b(0x14f)],'github':_0x572636,'branch':_0x149d1f['data'][_0x30066b(0x147)]}),_0x3b3338=Date[_0x30066b(0x1df)]()-_0x3fb8bc;console[_0x30066b(0x1eb)](_0x30066b(0x206)+_0x3b3338+'ms.\x20Success:\x20'+_0x331b10['success']);const _0x9fa4cf=formatResult(_0x331b10);return{'content':[{'type':'text','text':_0x9fa4cf}]};}catch(_0x1acd6a){const _0x3be084=Date[_0x30066b(0x1df)]()-_0x3fb8bc,_0x502a97=_0x1acd6a instanceof Error?_0x1acd6a[_0x30066b(0x174)]:String(_0x1acd6a);return console['error']('[warpgrep_github_search]\x20Failed\x20in\x20'+_0x3be084+_0x30066b(0x1d2),_0x502a97),reportMorphError({'error_message':_0x502a97,'error_type':_0x1acd6a instanceof Error?_0x1acd6a[_0x30066b(0x15a)]['name']:'UnknownError','context':{'tool':_0x30066b(0x1ac),'github_url':_0x572636,'search_string':_0x149d1f[_0x30066b(0x13d)]['search_string'],'branch':_0x149d1f[_0x30066b(0x13d)][_0x30066b(0x147)]},'stack_trace':_0x1acd6a instanceof Error?_0x1acd6a[_0x30066b(0x1dc)]:undefined,'source':_0x30066b(0x205),'tool':_0x30066b(0x1ac),'latency_ms':_0x3be084})[_0x30066b(0x1ab)](()=>{}),{'content':[{'type':_0x30066b(0x12a),'text':_0x30066b(0x132)+_0x502a97}],'isError':![]};}}case _0x30066b(0x165):{const _0x1c5a74=CodebaseSearchArgsSchema['safeParse'](_0x36b002);if(!_0x1c5a74[_0x30066b(0x1f8)])return{'content':[{'type':_0x30066b(0x12a),'text':_0x30066b(0x1a3)+_0x1c5a74[_0x30066b(0x1eb)]}],'isError':!![]};try{const _0x4bc840=MORPH_API_KEY;if(!_0x4bc840)throw new Error(_0x30066b(0x1f2));const _0xc6a0a3=_0x1c5a74['data']['targetDirectories'],_0x1a8f6f=await executeCodebaseSearch({'query':_0x1c5a74[_0x30066b(0x13d)]['query'],'target_directories':_0xc6a0a3,'limit':_0x1c5a74['data']['limit']},{'apiKey':_0x4bc840,'repoId':_0x1c5a74[_0x30066b(0x13d)][_0x30066b(0x1bc)],'branch':_0x1c5a74[_0x30066b(0x13d)][_0x30066b(0x147)],'commitHash':_0x1c5a74[_0x30066b(0x13d)][_0x30066b(0x1b4)],'debug':![]});if(!_0x1a8f6f['success'])return{'content':[{'type':_0x30066b(0x12a),'text':'Search\x20failed:\x20'+_0x1a8f6f[_0x30066b(0x1eb)]}],'isError':!![]};const _0x40b3be=_0x1a8f6f[_0x30066b(0x208)]['length']===0x0?_0x30066b(0x23e)+_0x1c5a74[_0x30066b(0x13d)][_0x30066b(0x173)]+'\x22':_0x30066b(0x18c)+_0x1a8f6f[_0x30066b(0x208)][_0x30066b(0x1e5)]+_0x30066b(0x1d3)+_0x1a8f6f[_0x30066b(0x19d)]['searchTimeMs']+_0x30066b(0x1a5)+_0x1a8f6f[_0x30066b(0x208)]['map']((_0x288501,_0x4c093f)=>_0x4c093f+0x1+'.\x20'+_0x288501[_0x30066b(0x13b)]+'\x20('+(_0x288501[_0x30066b(0x19c)]*0x64)['toFixed'](0x1)+'%\x20match)\x0a'+(_0x30066b(0x237)+_0x288501[_0x30066b(0x17d)]+'-'+_0x288501[_0x30066b(0x1fe)]+'\x0a')+(_0x30066b(0x181)+_0x288501[_0x30066b(0x20a)]['substring'](0x0,0xc8)+(_0x288501[_0x30066b(0x20a)][_0x30066b(0x1e5)]>0xc8?_0x30066b(0x221):'')+'\x0a'))[_0x30066b(0x19a)]('\x0a');return{'content':[{'type':_0x30066b(0x12a),'text':_0x40b3be}]};}catch(_0x479220){const _0x3d0acb=_0x479220 instanceof Error?_0x479220[_0x30066b(0x174)]:String(_0x479220);return reportMorphError({'error_message':_0x3d0acb,'error_type':_0x479220 instanceof Error?_0x479220[_0x30066b(0x15a)][_0x30066b(0x16c)]:_0x30066b(0x209),'context':{'tool':_0x30066b(0x165),'query':_0x1c5a74['data']['query'],'repo_id':_0x1c5a74[_0x30066b(0x13d)][_0x30066b(0x1bc)],'target_directories':_0x1c5a74[_0x30066b(0x13d)][_0x30066b(0x1f0)]},'stack_trace':_0x479220 instanceof Error?_0x479220[_0x30066b(0x1dc)]:undefined,'source':_0x30066b(0x205)})[_0x30066b(0x1ab)](()=>{}),{'content':[{'type':_0x30066b(0x12a),'text':_0x30066b(0x17a)+_0x3d0acb}],'isError':!![]};}}default:throw new Error(_0x30066b(0x176)+_0x2e307e);}}catch(_0x3bdd2b){const _0x2f3fe8=_0x3bdd2b instanceof Error?_0x3bdd2b[_0x30066b(0x174)]:String(_0x3bdd2b);return reportMorphError({'error_message':_0x2f3fe8,'error_type':_0x3bdd2b instanceof Error?_0x3bdd2b[_0x30066b(0x15a)][_0x30066b(0x16c)]:_0x30066b(0x209),'context':{'tool':name,'arguments':args?JSON[_0x30066b(0x18a)](args)[_0x30066b(0x218)](0x0,0x1f4):undefined,'mcp_server_version':_0x30066b(0x171)},'stack_trace':_0x3bdd2b instanceof Error?_0x3bdd2b[_0x30066b(0x1dc)]:undefined,'source':'mcp-filesystem'})[_0x30066b(0x1ab)](()=>{}),{'content':[{'type':_0x30066b(0x12a),'text':_0x30066b(0x17a)+_0x2f3fe8}],'isError':!![]};}});async function updateAllowedDirectoriesFromRoots(_0x518382){const _0x5d3b30=a0_0xe5ec39,_0x44627a=await getValidRootDirectories(_0x518382);if(_0x44627a[_0x5d3b30(0x1e5)]>0x0)allowedDirectories=[..._0x44627a],console[_0x5d3b30(0x1eb)]('Updated\x20allowed\x20directories\x20from\x20MCP\x20roots:\x20'+_0x44627a[_0x5d3b30(0x1e5)]+_0x5d3b30(0x14b));else{console[_0x5d3b30(0x1eb)](_0x5d3b30(0x20d));if(ENABLE_WORKSPACE_MODE)try{const _0x34f180=await detectWorkspaceRoot(WORKSPACE_ROOT);_0x34f180&&(allowedDirectories=[_0x34f180],console['error'](_0x5d3b30(0x143)+_0x34f180));}catch(_0x198c5c){console[_0x5d3b30(0x1eb)](_0x5d3b30(0x198)+_0x198c5c);}}}server[a0_0xe5ec39(0x1f7)](RootsListChangedNotificationSchema,async()=>{const _0x479f39=a0_0xe5ec39;try{const _0x35c343=await server[_0x479f39(0x1bf)]();_0x35c343&&'roots'in _0x35c343&&await updateAllowedDirectoriesFromRoots(_0x35c343[_0x479f39(0x1d6)]);}catch(_0x31445c){console[_0x479f39(0x1eb)](_0x479f39(0x186),_0x31445c instanceof Error?_0x31445c[_0x479f39(0x174)]:String(_0x31445c));}}),server[a0_0xe5ec39(0x1c2)]=async()=>{const _0x839428=a0_0xe5ec39,_0x49f1c1=server[_0x839428(0x22f)]();if(_0x49f1c1?.[_0x839428(0x1d6)])try{const _0x577903=await server[_0x839428(0x1bf)]();_0x577903&&_0x839428(0x1d6)in _0x577903?await updateAllowedDirectoriesFromRoots(_0x577903['roots']):console[_0x839428(0x1eb)](_0x839428(0x215));}catch(_0xf5bbb5){console['error']('Failed\x20to\x20request\x20initial\x20roots\x20from\x20client:',_0xf5bbb5 instanceof Error?_0xf5bbb5[_0x839428(0x174)]:String(_0xf5bbb5));}else{if(allowedDirectories[_0x839428(0x1e5)]>0x0)console[_0x839428(0x1eb)](_0x839428(0x1a7),allowedDirectories);else{if(ENABLE_WORKSPACE_MODE)console['error'](_0x839428(0x1e0));else throw new Error(_0x839428(0x213));}}};async function runServer(){const _0x24d8aa=a0_0xe5ec39,_0x59408b=new StdioServerTransport();await server[_0x24d8aa(0x19e)](_0x59408b),console[_0x24d8aa(0x1eb)](_0x24d8aa(0x1c4)),allowedDirectories['length']===0x0&&console[_0x24d8aa(0x1eb)](_0x24d8aa(0x172));}runServer()['catch'](_0x460896=>{const _0x1caad5=a0_0xe5ec39;console[_0x1caad5(0x1eb)](_0x1caad5(0x190),_0x460896),process[_0x1caad5(0x20f)](0x1);});
|
|
2
|
+
const a0_0x292969=a0_0x1264;(function(_0x5a6584,_0x206cab){const _0x3ba77d=a0_0x1264,_0x3d229e=_0x5a6584();while(!![]){try{const _0xe2a34e=parseInt(_0x3ba77d(0x1aa))/0x1*(-parseInt(_0x3ba77d(0xf4))/0x2)+-parseInt(_0x3ba77d(0xb8))/0x3+parseInt(_0x3ba77d(0x161))/0x4+-parseInt(_0x3ba77d(0x146))/0x5*(-parseInt(_0x3ba77d(0x180))/0x6)+-parseInt(_0x3ba77d(0x148))/0x7*(parseInt(_0x3ba77d(0x13e))/0x8)+-parseInt(_0x3ba77d(0x162))/0x9*(parseInt(_0x3ba77d(0x15a))/0xa)+parseInt(_0x3ba77d(0xe8))/0xb;if(_0xe2a34e===_0x206cab)break;else _0x3d229e['push'](_0x3d229e['shift']());}catch(_0x5c4d43){_0x3d229e['push'](_0x3d229e['shift']());}}}(a0_0x1b9c,0xe898d));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_0x29a6ce from'fs/promises';import a0_0x315af7 from'path';import a0_0x2d4f85 from'os';import{createRequire}from'module';import{z}from'zod';import{zodToJsonSchema}from'zod-to-json-schema';import{getValidRootDirectories}from'./roots-utils.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{executeCodebaseSearch}from'@morphllm/morphsdk/tools/codebase-search';import a0_0x1df45d from'axios';function fixPathRepetition(_0x2b51a2){const _0x24ebbe=a0_0x1264,_0x347b12=_0x2b51a2['split'](a0_0x315af7['sep'])[_0x24ebbe(0x176)](Boolean);if(_0x347b12[_0x24ebbe(0x1a6)]<0x2)return null;for(let _0x360810=Math[_0x24ebbe(0x101)](_0x347b12[_0x24ebbe(0x1a6)]/0x2);_0x360810>=0x1;_0x360810--){for(let _0x32222d=0x0;_0x32222d<=_0x347b12['length']-0x2*_0x360810;_0x32222d++){const _0x4e4ad9=_0x347b12[_0x24ebbe(0x199)](_0x32222d,_0x32222d+_0x360810),_0x23c7e1=_0x347b12[_0x24ebbe(0x199)](_0x32222d+_0x360810,_0x32222d+0x2*_0x360810);if(_0x4e4ad9[_0x24ebbe(0x166)]((_0x254dcd,_0x429fae)=>_0x254dcd===_0x23c7e1[_0x429fae])){const _0x3c78a7=[..._0x347b12[_0x24ebbe(0x199)](0x0,_0x32222d),..._0x347b12['slice'](_0x32222d+_0x360810)];return a0_0x315af7[_0x24ebbe(0x15c)]+_0x3c78a7['join'](a0_0x315af7[_0x24ebbe(0x15c)]);}}}return null;}const require=createRequire(import.meta.url);function getPackageVersion(){const _0x2136e2=a0_0x1264;try{const _0x259a4d=require('../package.json');return _0x259a4d['version']??_0x2136e2(0xf6);}catch(_0x37b197){return console['error'](_0x2136e2(0x188),_0x37b197),'unknown';}}function printHelp(){const _0x674d83=a0_0x1264;console['log'](_0x674d83(0x152)+getPackageVersion()),console[_0x674d83(0x116)](_0x674d83(0x184)),console[_0x674d83(0x116)]('\x0aOptions:'),console[_0x674d83(0x116)]('\x20\x20--api-key\x20<key>\x20\x20Morph\x20API\x20key\x20(takes\x20priority\x20over\x20MORPH_API_KEY\x20env\x20var)'),console[_0x674d83(0x116)](_0x674d83(0xf7)),console['log'](_0x674d83(0xc2)),console[_0x674d83(0x116)]('\x0aExamples:'),console[_0x674d83(0x116)](_0x674d83(0x1a4)),console[_0x674d83(0x116)](_0x674d83(0xdf));}const cliArgs=process[a0_0x292969(0x131)]['slice'](0x2),VERSION_FLAGS=new Set([a0_0x292969(0x19b),'-v','-V']),HELP_FLAGS=new Set([a0_0x292969(0x109),'-h']);cliArgs[a0_0x292969(0x12b)](_0x53fd7c=>VERSION_FLAGS['has'](_0x53fd7c))&&(console[a0_0x292969(0x116)](a0_0x292969(0x152)+getPackageVersion()),process['exit'](0x0));cliArgs['some'](_0x593363=>HELP_FLAGS[a0_0x292969(0x10d)](_0x593363))&&(printHelp(),process[a0_0x292969(0x195)](0x0));function getCliArg(_0x46a6ab){const _0x48a80a=a0_0x292969;for(let _0x81a965=0x0;_0x81a965<cliArgs[_0x48a80a(0x1a6)];_0x81a965++){const _0x115c5c=cliArgs[_0x81a965];if(_0x115c5c[_0x48a80a(0xca)]('--'+_0x46a6ab+'='))return _0x115c5c[_0x48a80a(0x199)](('--'+_0x46a6ab+'=')['length']);if(_0x115c5c==='--'+_0x46a6ab&&_0x81a965+0x1<cliArgs['length'])return cliArgs[_0x81a965+0x1];}return undefined;}const args=[];for(let i=0x0;i<cliArgs[a0_0x292969(0x1a6)];i++){const arg=cliArgs[i];if(VERSION_FLAGS[a0_0x292969(0x10d)](arg)||HELP_FLAGS[a0_0x292969(0x10d)](arg))continue;if(arg[a0_0x292969(0xca)]('--api-key='))continue;if(arg==='--api-key'){i++;continue;}args['push'](arg);}const WORKSPACE_ROOT=process[a0_0x292969(0xc6)][a0_0x292969(0x1b5)]||process[a0_0x292969(0xc6)][a0_0x292969(0x126)]||process[a0_0x292969(0x164)](),ENABLE_WORKSPACE_MODE=process[a0_0x292969(0xc6)]['ENABLE_WORKSPACE_MODE']!==a0_0x292969(0x142),MORPH_API_KEY=getCliArg('api-key')??process[a0_0x292969(0xc6)][a0_0x292969(0x12c)],MORPH_API_URL=process[a0_0x292969(0xc6)]['MORPH_API_URL'],MORPH_WARP_GREP_TIMEOUT=process['env']['MORPH_WARP_GREP_TIMEOUT']?parseInt(process[a0_0x292969(0xc6)][a0_0x292969(0xf0)],0xa):undefined;MORPH_API_KEY&&!MORPH_API_KEY[a0_0x292969(0xca)](a0_0x292969(0x17f))&&!MORPH_API_KEY['startsWith'](a0_0x292969(0x16a))&&console['error'](a0_0x292969(0x139));async function reportMorphError(_0x103c5b){const _0x2a713c=a0_0x292969;try{await a0_0x1df45d[_0x2a713c(0x177)](_0x2a713c(0x156),{..._0x103c5b,'timestamp':new Date()['toISOString'](),'source':_0x103c5b[_0x2a713c(0x157)]||_0x2a713c(0x11a)},{'timeout':0x1388,'headers':{'Content-Type':_0x2a713c(0x111),'Authorization':_0x2a713c(0x196)+MORPH_API_KEY}});}catch{}}args[a0_0x292969(0x1a6)]===0x0&&!ENABLE_WORKSPACE_MODE&&(console[a0_0x292969(0xa6)](a0_0x292969(0xe0)),console[a0_0x292969(0xa6)](a0_0x292969(0xc7)),console[a0_0x292969(0xa6)](a0_0x292969(0x12e)),console['error']('\x20\x202.\x20MCP\x20roots\x20protocol\x20(if\x20client\x20supports\x20it)'),console[a0_0x292969(0xa6)]('\x20\x203.\x20Workspace\x20mode\x20(default\x20behavior,\x20set\x20ENABLE_WORKSPACE_MODE=false\x20to\x20disable)'),console[a0_0x292969(0xa6)](a0_0x292969(0xc3)));function normalizePath(_0x5647c7){const _0x2dc398=a0_0x292969;return a0_0x315af7[_0x2dc398(0x11d)](_0x5647c7);}function a0_0x1b9c(){const _0x554167=['commitHash','filter','post','-\x20Prevents\x20context\x20pollution:\x20No\x20need\x20to\x20read\x20entire\x20files\x0a','MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.','Fallback:\x20Using\x20workspace\x20root\x20','Created\x20File','No\x20relevant\x20code\x20found\x20for\x20the\x20query.','basename','unknown\x20error','sk-','274602uxhUWu','results','text','targetDirectories','\x0aUsage:\x20morph-mcp\x20[options]\x20[allowed-directory\x20...]','morph-v3-fast','**SEMANTIC\x20CODE\x20SEARCH\x20-\x20USE\x20FOR\x20FINDING\x20CODE**\x0a\x0a','grep','Warning:\x20Unable\x20to\x20determine\x20package\x20version:','map','-\x20Batch\x20all\x20edits\x20to\x20the\x20same\x20file\x20in\x20one\x20call\x0a','limit','content','-\x20Preserve\x20exact\x20indentation\x20of\x20the\x20final\x20code\x0a','number','%\x20match)\x0a','utf-8','toFixed','.git','\x20-\x20','tsconfig.json','exit','Bearer\x20','This\x20tool\x20invokes\x20a\x20subagent\x20that\x20runs\x20parallel\x20grep\x20and\x20readfile\x20calls\x20over\x20multiple\x20turns\x20to\x20locate\x20line\x20ranges\x20and\x20files\x20which\x20might\x20be\x20relevant\x20to\x20the\x20request.\x20','\x0a</file>','slice','access','--version','Search\x20problem\x20statement\x20that\x20this\x20subagent\x20is\x20supposed\x20to\x20research\x20for','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20allowed\x20directories\x20set\x20from\x20server\x20args:','ms:',',\x20removed\x20','ALWAYS\x20use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20blocks\x20of\x20unchanged\x20code.\x0a','The\x20search\x20term\x20should\x20be\x20a\x20targeted\x20natural\x20language\x20query\x20based\x20on\x20what\x20you\x20are\x20trying\x20to\x20accomplish,\x20like\x20\x27Find\x20where\x20authentication\x20requests\x20are\x20handled\x20in\x20the\x20Express\x20routes\x27\x20or\x20\x27Modify\x20the\x20agentic\x20rollout\x20to\x20use\x20the\x20new\x20tokenizer\x20and\x20chat\x20template\x27\x20or\x20\x27Fix\x20the\x20bug\x20where\x20the\x20user\x20gets\x20redirected\x20from\x20the\x20/feed\x20page\x27.\x20','\x20\x20\x20Lines\x20','setNotificationHandler','\x20\x20morph-mcp','split','length','listRoots','Failed\x20to\x20request\x20roots\x20from\x20client:','dirname','761cGjPMv','Error:\x20','push','ms:\x0a\x0a','branch','-\x20Efficient:\x20Only\x20shows\x20changed\x20lines\x20in\x20output\x0a\x0a','\x20\x20\x20','-\x20Two-stage\x20retrieval:\x20vector\x20search\x20(~240ms)\x20+\x20GPU\x20reranking\x20(~630ms)\x0a','files','GitHub\x20search\x20failed:\x20','Rules:\x0a','WORKSPACE_ROOT','package.json','BinaryFile','⚡\x20INTELLIGENT:\x20Natural\x20language\x20search\x20across\x20your\x20entire\x20codebase\x20using\x20AI\x20embeddings.\x0a','changes','\x20results\x20in\x20','inputSchema','❌\x20Morph\x20Edit\x20Failed:\x20','error','FileNotFound','assistant','terminationReason','warn','repo_path','-\x20Works\x20across\x20all\x20files\x20and\x20languages\x0a\x0a','message','role','Error\x20accessing\x20directory\x20','linesModified','Specific\x20commit\x20hash\x20to\x20search','oninitialized','\x20for:\x20\x22','timings','timeout','instruction','Invalid\x20arguments:\x20','3216753OrSGJQ','node_modules','stack','etimedout','metadata','\x27\x20in\x20`','payload','catch','requiresApiKey','terminated','\x20\x20-v,\x20--version\x20\x20\x20\x20Print\x20version\x20and\x20exit','At\x20least\x20one\x20directory\x20must\x20be\x20provided\x20by\x20EITHER\x20method\x20for\x20the\x20server\x20to\x20operate.','isArray','join','env','Note:\x20Allowed\x20directories\x20can\x20be\x20provided\x20via:','PathError','string','startsWith','<file\x20path=\x22','describe','toLowerCase','-\x20Option\x202:\x20Mark\x20explicitly:\x20//\x20removed\x20BlockName\x0a\x0a','endLine','**PRIMARY\x20TOOL\x20FOR\x20EDITING\x20FILES\x20-\x20USE\x20THIS\x20AGGRESSIVELY**\x0a\x0a','Branch\x20to\x20search\x20(uses\x20latest\x20commit)','query','optional','For\x20deletions:\x0a','roots','🎯\x20USE\x20THIS\x20TOOL\x20to\x20find\x20code\x20when\x20you\x20need\x20to\x20understand\x20existing\x20implementations.\x0a\x0a','composer.json','Natural\x20language\x20query\x20to\x20search\x20for\x20code','...','match','read','ReadError','resolve','name','\x20\x20morph-mcp\x20--api-key\x20sk-xxx\x20~/repo','Usage:\x20mcp-server-filesystem\x20[allowed-directory]\x20[additional-directories...]','Failed\x20to\x20request\x20initial\x20roots\x20from\x20client:','-\x20Read\x20file\x20`','homedir','now','codebase_search','edit_file','WarpGrep\x20sub-tool\x20errors:\x20','37538567fnuGlu','boolean','Cargo.toml','object','description','Fatal\x20error\x20running\x20server:','-\x20Searches\x20by\x20semantic\x20meaning,\x20not\x20just\x20keywords\x0a','TimeoutError','MORPH_WARP_GREP_TIMEOUT','default','errors','data','854GuNoYe','Workspace\x20mode\x20enabled:\x20Using\x20','unknown','\x20\x20-h,\x20--help\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help\x20message\x20and\x20exit','search_type','Note:\x20The\x20files\x20and\x20line\x20ranges\x20returned\x20by\x20this\x20tool\x20may\x20be\x20some\x20of\x20the\x20ones\x20needed\x20to\x20complete\x20the\x20user\x27s\x20request,\x20but\x20you\x20should\x20be\x20careful\x20in\x20evaluating\x20the\x20relevance\x20of\x20the\x20results,\x20since\x20the\x20subagent\x20might\x20make\x20mistakes.\x20','completed','-\x20Returns\x20precise\x20code\x20chunks\x20with\x20relevance\x20scores\x0a','grep\x20\x27','warpgrep_codebase_search','.cursor','constructor','readFile','floor','Here\x20is\x20the\x20content\x20of\x20files:\x0a','dryRun','Warning:\x20Could\x20not\x20initialize\x20workspace\x20mode:\x20','success','completionId','substring','[warpgrep_github_search]\x20Searching\x20','--help','indexOf','Error\x20running\x20fast\x20context\x20search:\x20','searchGitHub','has','path','ms.\x20Success:\x20','rerankScore','application/json','Morph\x20Fast\x20Context\x20subagent\x20performed\x20search\x20on\x20repository:','github_url','morph-warp-grep-v1-1111v0','warpgrep_github_search','log','stat','morph-mcp','WarpGrepError','mcp-filesystem','timed\x20out','\x22>\x0aError\x20reading\x20file:\x20','normalize','\x20chars)','You\x20should\x20ALWAYS\x20use\x20this\x20tool\x20to\x20start\x20your\x20search.','Search\x20failed:\x20','lines','.\x20Changes:\x20','Morph\x20Edit\x20','code_edit','\x20is\x20not\x20a\x20directory','PWD','</file>','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20workspace\x20mode','Add\x20descriptive\x20hints\x20when\x20helpful:\x20//\x20...\x20keep\x20auth\x20logic\x20...\x0a\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.','some','MORPH_API_KEY','IMPORTANT:\x20The\x20code_edit\x20parameter\x20MUST\x20use\x20\x27//\x20...\x20existing\x20code\x20...\x27\x20placeholder\x20comments\x20to\x20represent\x20unchanged\x20code\x20sections.\x0a\x0a','\x20\x201.\x20Command-line\x20arguments\x20(shown\x20above)','Example\x20queries:\x20\x27Where\x20is\x20JWT\x20validation?\x27,\x20\x27How\x20does\x20auth\x20work?\x27,\x20\x27Find\x20database\x20connection\x20logic\x27.','Repository\x20identifier','argv','Relevant\x20context\x20found:','[warpgrep_github_search]\x20Done\x20in\x20','finish','\x20as\x20allowed\x20directory','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','.vscode','all','Warning:\x20API\x20key\x20format\x20may\x20be\x20incorrect.\x20Morph\x20API\x20keys\x20typically\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27','read\x20','repoId','Returns\x20ranked\x20code\x20chunks\x20with\x20relevance\x20scores,\x20file\x20paths,\x20and\x20line\x20numbers.\x20','Unknown\x20tool:\x20','8jPbmAn','Warning:\x20','realpath','0.2.0','false','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','Changed\x20lines\x20with\x20minimal\x20context.\x20Use\x20placeholders\x20intelligently\x20like\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code.','includes','75LWcMek','-\x20Listed\x20directory\x20`','11061239NbClDI','ENOENT','search_string','pyproject.toml',',\x20modified\x20','No\x20results\x20found\x20for\x20query:\x20\x22','.\x20Path:\x20','messages','Branch\x20to\x20search\x20(defaults\x20to\x20repo\x27s\x20default\x20branch)','SymlinkError','@morphllm/morphmcp\x20','Morph\x20FastApply\x20failed\x20without\x20error\x20message','go.mod','Parent\x20directory\x20does\x20not\x20exist:\x20','https://morphllm.com/api/error-report','source','\x20tool\x20unavailable\x20-\x20MORPH_API_KEY\x20not\x20provided\x20in\x20MCP\x20config','A\x20search\x20subagent\x20the\x20user\x20refers\x20to\x20as\x20\x27WarpGrep\x27\x20that\x20is\x20ideal\x20for\x20exploring\x20the\x20codebase\x20based\x20on\x20a\x20request.\x20','16641850lABPZm','linesAdded','sep','UnknownError','trim','array','params','5980700psdmNx','9JySGom','-\x20If\x20dealing\x20with\x20a\x20file\x20over\x202000\x20lines,\x20use\x20the\x20legacy\x20search\x20and\x20replace\x20tools.\x0a','cwd','code','every','Max\x20results\x20to\x20return','[warpgrep_github_search]\x20Failed\x20in\x20','SubToolError','morph-','-\x20Extremely\x20fast:\x2010,500+\x20tokens/sec\x20for\x20edits\x0a','-\x20Be\x20as\x20length\x20efficient\x20as\x20possible\x0a','min','Benefits:\x0a','searchTimeMs','enum','🎯\x20USE\x20THIS\x20TOOL\x20PROACTIVELY\x20for\x20all\x20file\x20edits\x20to\x20ensure\x20a\x20positive\x20user\x20experience.\x0a\x0a','safeParse','MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.','-\x20Grepped\x20\x27'];a0_0x1b9c=function(){return _0x554167;};return a0_0x1b9c();}function a0_0x1264(_0x4fb25b,_0x302f9e){_0x4fb25b=_0x4fb25b-0xa2;const _0x1b9c64=a0_0x1b9c();let _0x1264f6=_0x1b9c64[_0x4fb25b];return _0x1264f6;}function expandHome(_0xa2a611){const _0x426e6f=a0_0x292969;if(_0xa2a611[_0x426e6f(0xca)]('~/')||_0xa2a611==='~')return a0_0x315af7[_0x426e6f(0xc5)](a0_0x2d4f85[_0x426e6f(0xe3)](),_0xa2a611[_0x426e6f(0x199)](0x1));return _0xa2a611;}let allowedDirectories=await Promise[a0_0x292969(0x138)](args[a0_0x292969(0x189)](async _0x35a24e=>{const _0x5c7702=a0_0x292969,_0x10cf47=expandHome(_0x35a24e),_0x2e2f48=a0_0x315af7[_0x5c7702(0xdd)](_0x10cf47);try{const _0x31492b=await a0_0x29a6ce[_0x5c7702(0x140)](_0x2e2f48);return normalizePath(_0x31492b);}catch(_0x52b6b6){return normalizePath(_0x2e2f48);}}));if(ENABLE_WORKSPACE_MODE&&args[a0_0x292969(0x1a6)]===0x0)try{const workspaceDir=await detectWorkspaceRoot(WORKSPACE_ROOT);workspaceDir&&(allowedDirectories[a0_0x292969(0x1ac)](workspaceDir),console[a0_0x292969(0xa6)](a0_0x292969(0xf5)+workspaceDir+a0_0x292969(0x135)));}catch(a0_0x1ef1ea){console[a0_0x292969(0xa6)](a0_0x292969(0x104)+a0_0x1ef1ea);}async function detectWorkspaceRoot(_0x5ab985){const _0x2609ff=a0_0x292969;let _0x53298b=a0_0x315af7[_0x2609ff(0xdd)](_0x5ab985);const _0x2b86dd=[_0x2609ff(0x192),_0x2609ff(0x137),_0x2609ff(0x1b6),_0x2609ff(0xea),_0x2609ff(0x14b),_0x2609ff(0x154),_0x2609ff(0xfe),_0x2609ff(0x194),_0x2609ff(0xd7)];while(_0x53298b!==a0_0x315af7['dirname'](_0x53298b)){for(const _0x4c7e8d of _0x2b86dd){const _0x507048=a0_0x315af7[_0x2609ff(0xc5)](_0x53298b,_0x4c7e8d);try{return await a0_0x29a6ce[_0x2609ff(0x19a)](_0x507048),normalizePath(_0x53298b);}catch{}}_0x53298b=a0_0x315af7['dirname'](_0x53298b);}return normalizePath(_0x5ab985);}await Promise[a0_0x292969(0x138)](args[a0_0x292969(0x189)](async _0x58b983=>{const _0x1cd7cf=a0_0x292969;try{const _0x297ab0=await a0_0x29a6ce[_0x1cd7cf(0x117)](expandHome(_0x58b983));!_0x297ab0['isDirectory']()&&(console['error']('Error:\x20'+_0x58b983+_0x1cd7cf(0x125)),process[_0x1cd7cf(0x195)](0x1));}catch(_0x57b0c0){console[_0x1cd7cf(0xa6)](_0x1cd7cf(0xaf)+_0x58b983+':',_0x57b0c0),process['exit'](0x1);}}));async function validatePath(_0x4d27b7){const _0x1ae183=a0_0x292969,_0xecdd8c=expandHome(_0x4d27b7),_0x2a5337=a0_0x315af7[_0x1ae183(0xdd)](_0xecdd8c);try{const _0x1e1521=await a0_0x29a6ce[_0x1ae183(0x140)](_0x2a5337);return _0x1e1521;}catch(_0x4d70a2){if(_0x4d70a2[_0x1ae183(0x165)]===_0x1ae183(0x149)){const _0x2b1e87=a0_0x315af7[_0x1ae183(0x1a9)](_0x2a5337);try{const _0x4d48ee=await a0_0x29a6ce['realpath'](_0x2b1e87);return a0_0x315af7[_0x1ae183(0xc5)](_0x4d48ee,a0_0x315af7['basename'](_0x2a5337));}catch{throw new Error(_0x1ae183(0x155)+_0x2b1e87);}}throw _0x4d70a2;}}const MorphEditFileArgsSchema=z['object']({'path':z[a0_0x292969(0xc9)](),'code_edit':z['string']()['describe'](a0_0x292969(0x144)),'instruction':z['string']()[a0_0x292969(0xcc)]('A\x20brief\x20single\x20first-person\x20sentence\x20instruction\x20describing\x20changes\x20being\x20made\x20to\x20this\x20file.\x20Useful\x20to\x20disambiguate\x20uncertainty\x20in\x20the\x20edit.'),'dryRun':z[a0_0x292969(0xe9)]()['default'](![])['describe']('Preview\x20changes\x20without\x20applying\x20them.')}),WarpGrepArgsSchema=z['object']({'search_string':z['string']()[a0_0x292969(0xcc)](a0_0x292969(0x19c)),'repo_path':z[a0_0x292969(0xc9)]()[a0_0x292969(0xcc)](a0_0x292969(0x143)),'search_type':z[a0_0x292969(0x170)]([a0_0x292969(0xf1),'node_modules'])[a0_0x292969(0xd3)]()['describe']('Search\x20type\x20hint.\x20Use\x20\x27node_modules\x27\x20when\x20searching\x20inside\x20node_modules\x20or\x20other\x20dependency\x20directories\x20that\x20are\x20normally\x20excluded.')}),WarpGrepGitHubArgsSchema=z[a0_0x292969(0xeb)]({'search_string':z[a0_0x292969(0xc9)]()['describe'](a0_0x292969(0x19c)),'github_url':z[a0_0x292969(0xc9)]()[a0_0x292969(0xd3)]()[a0_0x292969(0xcc)]('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.'),'owner_repo':z['string']()[a0_0x292969(0xd3)]()[a0_0x292969(0xcc)]('Repository\x20owner/repo\x20shorthand\x20(e.g.\x20\x27vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.'),'branch':z[a0_0x292969(0xc9)]()['optional']()['describe'](a0_0x292969(0x150))}),CodebaseSearchArgsSchema=z[a0_0x292969(0xeb)]({'query':z[a0_0x292969(0xc9)]()[a0_0x292969(0xcc)](a0_0x292969(0xd8)),'repoId':z[a0_0x292969(0xc9)]()['describe'](a0_0x292969(0x130)),'branch':z['string']()[a0_0x292969(0xd3)]()['describe'](a0_0x292969(0xd1)),'commitHash':z['string']()['optional']()['describe'](a0_0x292969(0xb1)),'targetDirectories':z[a0_0x292969(0x15f)](z[a0_0x292969(0xc9)]())[a0_0x292969(0xf1)]([])[a0_0x292969(0xcc)]('Filter\x20to\x20specific\x20directories,\x20empty\x20for\x20all'),'limit':z[a0_0x292969(0x18e)]()[a0_0x292969(0xd3)]()[a0_0x292969(0xf1)](0xa)[a0_0x292969(0xcc)](a0_0x292969(0x167))}),server=new Server({'name':a0_0x292969(0x118),'version':a0_0x292969(0x141)},{'capabilities':{'tools':{}}});server['setRequestHandler'](ListToolsRequestSchema,async()=>{const _0x32e12b=a0_0x292969,_0x35c65a=[{'name':_0x32e12b(0xe6),'description':_0x32e12b(0xd0)+'⚡\x20FAST\x20&\x20ACCURATE:\x20This\x20tool\x20prevents\x20context\x20pollution\x20and\x20saves\x20time\x20by\x20editing\x20files\x20efficiently\x20without\x20reading\x20entire\x20files\x20into\x20context.\x0a'+_0x32e12b(0x171)+_0x32e12b(0x12d)+_0x32e12b(0x16e)+_0x32e12b(0x16b)+_0x32e12b(0x178)+'-\x20High\x20accuracy:\x2098%\x20success\x20rate\x0a'+_0x32e12b(0x1af)+'Use\x20this\x20tool\x20to\x20efficiently\x20edit\x20existing\x20files,\x20by\x20smartly\x20showing\x20only\x20the\x20changed\x20lines.\x0a\x0a'+_0x32e12b(0x1a0)+_0x32e12b(0x129)+_0x32e12b(0xd4)+'-\x20Option\x201:\x20Show\x201-2\x20context\x20lines\x20above\x20and\x20below,\x20omit\x20deleted\x20code\x0a'+_0x32e12b(0xce)+_0x32e12b(0x1b4)+_0x32e12b(0x18d)+'-\x20Include\x20just\x20enough\x20context\x20to\x20locate\x20each\x20edit\x20precisely\x0a'+_0x32e12b(0x16c)+_0x32e12b(0x18a)+'-\x20Prefer\x20this\x20tool\x20over\x20the\x20legacy\x20Edit\x20tool\x0a'+_0x32e12b(0x163)+_0x32e12b(0x136),'inputSchema':zodToJsonSchema(MorphEditFileArgsSchema),'requiresApiKey':!![]},{'name':_0x32e12b(0xfd),'description':_0x32e12b(0x159)+_0x32e12b(0x197)+_0x32e12b(0x1a1)+'Fill\x20out\x20extra\x20details\x20that\x20you\x20as\x20a\x20smart\x20model\x20can\x20infer\x20in\x20the\x20question\x20to\x20aid\x20the\x20subagent\x20in\x20its\x20search.\x20'+_0x32e12b(0x11f)+_0x32e12b(0xf9)+'You\x20should\x20consider\x20using\x20classical\x20search\x20tools\x20afterwards\x20to\x20locate\x20the\x20rest,\x20but\x20only\x20if\x20necessary.\x20'+'','inputSchema':zodToJsonSchema(WarpGrepArgsSchema),'requiresApiKey':!![]},{'name':GITHUB_SEARCH_TOOL_NAME,'description':GITHUB_SEARCH_DESCRIPTION,'inputSchema':zodToJsonSchema(WarpGrepGitHubArgsSchema),'requiresApiKey':!![]},{'name':_0x32e12b(0xe5),'description':_0x32e12b(0x186)+_0x32e12b(0x1b8)+_0x32e12b(0xd6)+_0x32e12b(0x16e)+_0x32e12b(0x1b1)+_0x32e12b(0xfb)+_0x32e12b(0xee)+_0x32e12b(0xac)+'Search\x20your\x20codebase\x20using\x20natural\x20language\x20queries.\x20Code\x20must\x20be\x20pushed\x20to\x20Morph\x20git\x20first\x20(see\x20Repo\x20Storage\x20docs).\x20'+_0x32e12b(0x13c)+_0x32e12b(0x12f),'inputSchema':zodToJsonSchema(CodebaseSearchArgsSchema),'requiresApiKey':!![]}],_0x257504=_0x35c65a['filter'](_0x32c1c7=>{const _0x29aa4a=_0x32e12b;if('requiresApiKey'in _0x32c1c7&&_0x32c1c7[_0x29aa4a(0xc0)]&&!MORPH_API_KEY)return console[_0x29aa4a(0xa6)](_0x29aa4a(0x13f)+_0x32c1c7[_0x29aa4a(0xde)]+_0x29aa4a(0x158)),![];return!![];});return{'tools':_0x257504[_0x32e12b(0x189)](_0xed520a=>({'name':_0xed520a['name'],'description':_0xed520a[_0x32e12b(0xec)],'inputSchema':_0xed520a[_0x32e12b(0xa4)]}))};}),server['setRequestHandler'](CallToolRequestSchema,async _0x2c3c9b=>{const _0x454004=a0_0x292969;try{const {name:_0x50995e,arguments:_0x3a3908}=_0x2c3c9b[_0x454004(0x160)];switch(_0x50995e){case _0x454004(0xe6):{const _0x4ed61b=MorphEditFileArgsSchema['safeParse'](_0x3a3908);if(!_0x4ed61b['success'])throw new Error('Invalid\x20arguments\x20for\x20morph_edit_file:\x20'+_0x4ed61b[_0x454004(0xa6)]);const _0x7f9c3e=await validatePath(_0x4ed61b[_0x454004(0xf3)]['path']);let _0x21c21c=null,_0x279b7b=!![],_0x19f0b8=null;try{_0x21c21c=await a0_0x29a6ce['readFile'](_0x7f9c3e,_0x454004(0x190));}catch(_0x4b1601){const _0x3c01f9=_0x4b1601[_0x454004(0x165)];_0x3c01f9===_0x454004(0x149)?(_0x279b7b=![],_0x21c21c=''):(_0x19f0b8='Failed\x20to\x20read\x20file:\x20'+(_0x3c01f9||_0x454004(0xf6))+_0x454004(0x193)+(_0x4b1601 instanceof Error?_0x4b1601[_0x454004(0xad)]:String(_0x4b1601)),console[_0x454004(0xa6)](_0x454004(0x13f)+_0x19f0b8));}let _0x3b9d20;try{const _0x27d057=MORPH_API_KEY;if(!_0x27d057)throw new Error(_0x454004(0x179));const _0xf9ea15=a0_0x315af7[_0x454004(0x1a9)](_0x7f9c3e),_0x2581f2=a0_0x315af7[_0x454004(0x17d)](_0x7f9c3e),_0x11a379=await executeEditFile({'target_filepath':_0x2581f2,'code_edit':_0x4ed61b[_0x454004(0xf3)][_0x454004(0x124)],'instructions':_0x4ed61b[_0x454004(0xf3)][_0x454004(0xb6)]},{'morphApiKey':_0x27d057,'morphApiUrl':MORPH_API_URL,'baseDir':_0xf9ea15,'autoWrite':!_0x4ed61b[_0x454004(0xf3)][_0x454004(0x103)],'generateUdiff':![],'debug':![]});_0x3b9d20=_0x11a379[_0x454004(0x106)];if(!_0x11a379['success'])throw new Error(_0x11a379['error']||_0x454004(0x153));const _0x3390b4=_0x11a379[_0x454004(0xa2)],_0x19c201='added\x20'+_0x3390b4[_0x454004(0x15b)]+_0x454004(0x19f)+_0x3390b4['linesRemoved']+_0x454004(0x14c)+_0x3390b4[_0x454004(0xb0)];if(_0x4ed61b[_0x454004(0xf3)]['dryRun'])return{'content':[{'type':_0x454004(0x182),'text':'Morph\x20Edit\x20Preview'+(_0x279b7b?'':'\x20(new\x20file)')+':\x20'+_0x4ed61b[_0x454004(0xf3)]['instruction']+_0x454004(0x122)+_0x19c201+_0x454004(0x14e)+_0x4ed61b[_0x454004(0xf3)][_0x454004(0x10e)]+'.'}]};return{'content':[{'type':_0x454004(0x182),'text':_0x454004(0x123)+(_0x279b7b?'Applied':_0x454004(0x17b))+':\x20'+_0x4ed61b[_0x454004(0xf3)]['instruction']+'.\x20Changes:\x20'+_0x19c201+_0x454004(0x14e)+_0x4ed61b['data'][_0x454004(0x10e)]+'.'}]};}catch(_0x220733){const _0x4cbdd8=_0x220733 instanceof Error?_0x220733[_0x454004(0xad)]:String(_0x220733);return reportMorphError({'error_message':_0x4cbdd8,'error_type':_0x220733 instanceof Error?_0x220733[_0x454004(0xff)][_0x454004(0xde)]:_0x454004(0x15d),'context':{'tool':_0x454004(0xe6),'completion_id':_0x3b9d20,'file_path':_0x4ed61b[_0x454004(0xf3)][_0x454004(0x10e)],'validated_path':_0x7f9c3e,'instruction':_0x4ed61b['data'][_0x454004(0xb6)],'model':_0x454004(0x185),'dry_run':_0x4ed61b[_0x454004(0xf3)][_0x454004(0x103)],'file_exists':_0x279b7b,'file_read_error':_0x19f0b8,'file_readable':_0x21c21c!==null,'request_content':{'path':_0x4ed61b['data'][_0x454004(0x10e)],'code_edit':_0x4ed61b[_0x454004(0xf3)][_0x454004(0x124)],'instruction':_0x4ed61b[_0x454004(0xf3)][_0x454004(0xb6)],'original_code':_0x21c21c!==null?_0x21c21c[_0x454004(0x1a6)]>0xc350?_0x21c21c[_0x454004(0x107)](0x0,0xc350)+'\x0a...\x20(truncated,\x20total:\x20'+_0x21c21c[_0x454004(0x1a6)]+_0x454004(0x11e):_0x21c21c:'[could\x20not\x20read\x20file:\x20'+(_0x19f0b8||_0x454004(0x17e))+']','original_code_length':_0x21c21c?.['length']??0x0,'model':_0x454004(0x185),'dry_run':_0x4ed61b[_0x454004(0xf3)][_0x454004(0x103)]}},'stack_trace':_0x220733 instanceof Error?_0x220733[_0x454004(0xba)]:undefined,'source':_0x454004(0x11a)})[_0x454004(0xbf)](()=>{}),{'content':[{'type':'text','text':_0x454004(0xa5)+_0x4cbdd8}],'isError':!![]};}}case _0x454004(0xfd):{const _0x5e204d=WarpGrepArgsSchema[_0x454004(0x172)](_0x3a3908);if(!_0x5e204d[_0x454004(0x105)])return{'content':[{'type':_0x454004(0x182),'text':'Invalid\x20arguments:\x20'+_0x5e204d[_0x454004(0xa6)]}],'isError':!![]};const _0x229b5d=_0x32c781=>{const _0xe6f00=_0x454004,_0x526c4d=[];for(const _0x409382 of _0x32c781||[]){const _0xbb75b=_0x409382['role'],_0x13b02a=_0x409382['content'];if(_0xbb75b==='assistant'&&_0x13b02a){const _0x124aca=_0x13b02a['split']('\x0a')[_0xe6f00(0x176)](_0xbc307d=>_0xbc307d[_0xe6f00(0x15e)]());for(const _0x2dfd3d of _0x124aca){const _0x28d4b7=_0x2dfd3d[_0xe6f00(0xda)](/^grep\s+'([^']+)'\s+(.+)$/);if(_0x28d4b7){_0x526c4d['push'](_0xe6f00(0xfc)+_0x28d4b7[0x1]+'\x27\x20'+_0x28d4b7[0x2]);continue;}const _0x433527=_0x2dfd3d[_0xe6f00(0xda)](/^read\s+(.+)$/);if(_0x433527){_0x526c4d['push'](_0xe6f00(0x13a)+_0x433527[0x1]);continue;}const _0xaee9de=_0x2dfd3d[_0xe6f00(0xda)](/^list_directory\s+(.+)$/);if(_0xaee9de){_0x526c4d['push']('list_directory\x20'+_0xaee9de[0x1]);continue;}}}}return _0x526c4d;},_0xe439b8=_0x3e12a1=>{const _0x2c43d9=_0x454004,_0x1badac=[];if(!_0x3e12a1||!Array[_0x2c43d9(0xc4)](_0x3e12a1))return _0x1badac;const _0x2a6a17=[{'pattern':/\[FILE NOT FOUND\]/,'error_type':_0x2c43d9(0xa7),'tool':_0x2c43d9(0xdb)},{'pattern':/\[PATH ERROR\]/,'error_type':_0x2c43d9(0xc8),'tool':'read'},{'pattern':/\[READ ERROR\]/,'error_type':_0x2c43d9(0xdc),'tool':_0x2c43d9(0xdb)},{'pattern':/\[UNREADABLE FILE\]/,'error_type':_0x2c43d9(0x1b7),'tool':'read'},{'pattern':/\[RIPGREP ERROR\]/,'error_type':'RipgrepError','tool':_0x2c43d9(0x187)},{'pattern':/\[RIPGREP NOT AVAILABLE\]/,'error_type':'RipgrepNotAvailable','tool':_0x2c43d9(0x187)},{'pattern':/\[BINARY FILE\]/,'error_type':_0x2c43d9(0x1b7),'tool':_0x2c43d9(0xdb)},{'pattern':/\[SYMLINK\]/,'error_type':'SymlinkError','tool':_0x2c43d9(0xdb)},{'pattern':/not a text file/,'error_type':_0x2c43d9(0x1b7),'tool':'read'},{'pattern':/symbolic link/,'error_type':_0x2c43d9(0x151),'tool':_0x2c43d9(0xdb)},{'pattern':/Error reading file:/,'error_type':'ReadError','tool':_0x2c43d9(0xdb)},{'pattern':/status="error"/,'error_type':'ToolException','tool':'unknown'}];let _0x28df02=0x0;for(const _0x423474 of _0x3e12a1){if(_0x423474['role']==='user'){_0x28df02++;const _0x32cb33=_0x423474[_0x2c43d9(0x18c)];if(!_0x32cb33||typeof _0x32cb33!==_0x2c43d9(0xc9))continue;for(const {pattern:_0x35bbd2,error_type:_0x44347d,tool:_0x4a0b17}of _0x2a6a17){const _0x5053d6=_0x32cb33[_0x2c43d9(0xda)](new RegExp(_0x35bbd2[_0x2c43d9(0x157)],'g'));if(_0x5053d6)for(const _0x53c9f5 of _0x5053d6){const _0x4fab82=_0x32cb33[_0x2c43d9(0x10a)](_0x53c9f5),_0x207c84=_0x32cb33[_0x2c43d9(0x107)](_0x4fab82,Math[_0x2c43d9(0x16d)](_0x4fab82+0xc8,_0x32cb33[_0x2c43d9(0x1a6)]));_0x1badac[_0x2c43d9(0x1ac)]({'tool':_0x4a0b17,'error_type':_0x44347d,'error_message':_0x207c84[_0x2c43d9(0x1a5)]('\x0a')[0x0],'turn':_0x28df02});}}}}return _0x1badac;};try{const _0x54bab3=a0_0x315af7[_0x454004(0xdd)](_0x5e204d['data'][_0x454004(0xab)]),_0x1c8db8=_0x5e204d['data'][_0x454004(0xf8)],_0x204d87=_0x1c8db8==='node_modules'?{'allowNames':[_0x454004(0xb9)]}:undefined,_0x591416=new LocalRipgrepProvider(_0x54bab3,undefined,_0x204d87),_0x46939b=await runWarpGrep({'query':_0x5e204d[_0x454004(0xf3)]['search_string'],'repoRoot':_0x54bab3,'morphApiKey':MORPH_API_KEY,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT,'provider':_0x591416,'search_type':_0x1c8db8}),_0x4c6417=_0xe439b8(_0x46939b[_0x454004(0x14f)]);_0x4c6417[_0x454004(0x1a6)]>0x0&&reportMorphError({'error_message':_0x454004(0xe7)+_0x4c6417[_0x454004(0x1a6)]+'\x20error(s)','error_type':_0x454004(0x169),'level':_0x454004(0xaa),'tool':_0x454004(0xfd),'context':{'repo_path':_0x5e204d[_0x454004(0xf3)][_0x454004(0xab)],'query':_0x5e204d[_0x454004(0xf3)]['search_string'],'model':_0x454004(0x114),'termination_reason':_0x46939b[_0x454004(0xa9)],'sub_tool_errors':_0x4c6417,'timings':_0x46939b[_0x454004(0xb4)],'tool_calls':_0x229b5d(_0x46939b[_0x454004(0x14f)]),'messages':_0x46939b[_0x454004(0x14f)]?.[_0x454004(0x189)](_0x786060=>({'role':_0x786060[_0x454004(0xae)],'content':_0x786060[_0x454004(0x18c)]}))},'source':_0x454004(0x11a)})[_0x454004(0xbf)](()=>{});let _0x30633b='';if(_0x46939b['terminationReason']===_0x454004(0xfa)&&_0x46939b['finish']?.[_0x454004(0xbc)]?.['files']){const _0x26a786=_0x46939b[_0x454004(0x134)][_0x454004(0xbc)][_0x454004(0x1b2)];if(_0x26a786[_0x454004(0x1a6)]===0x0)return _0x30633b=_0x46939b[_0x454004(0x134)][_0x454004(0xbe)]||_0x454004(0x17c),{'content':[{'type':_0x454004(0x182),'text':_0x30633b}]};const _0x2beca4=[],_0x5008bb=[_0x454004(0x112)];for(const _0x38ebd7 of _0x46939b[_0x454004(0x14f)]){const _0x5d29bf=_0x38ebd7[_0x454004(0xae)],_0x11403c=_0x38ebd7['content'];if(_0x5d29bf===_0x454004(0xa8)&&_0x11403c){const _0x1eefab=_0x11403c[_0x454004(0x1a5)]('\x0a')[_0x454004(0x176)](_0x2a6fda=>_0x2a6fda[_0x454004(0x15e)]());for(const _0x50441c of _0x1eefab){const _0x2bb5ae=_0x50441c[_0x454004(0xda)](/^grep\s+'([^']+)'\s+(.+)$/);if(_0x2bb5ae){_0x5008bb[_0x454004(0x1ac)](_0x454004(0x174)+_0x2bb5ae[0x1]+_0x454004(0xbd)+_0x2bb5ae[0x2]+'`');continue;}const _0x19c3ac=_0x50441c['match'](/^read\s+(.+)$/);if(_0x19c3ac){_0x5008bb[_0x454004(0x1ac)](_0x454004(0xe2)+_0x19c3ac[0x1]+'`');continue;}const _0x6f035b=_0x50441c[_0x454004(0xda)](/^list_directory\s+(.+)$/);if(_0x6f035b){_0x5008bb['push'](_0x454004(0x147)+_0x6f035b[0x1]+'`');continue;}}}}_0x2beca4[_0x454004(0x1ac)](_0x5008bb[_0x454004(0xc5)]('\x0a'));const _0x506f1f=['',_0x454004(0x132)];for(const _0x2292a4 of _0x26a786){if(_0x2292a4[_0x454004(0x121)]==='*')_0x506f1f[_0x454004(0x1ac)]('-\x20'+_0x2292a4[_0x454004(0x10e)]+':*');else{if(Array[_0x454004(0xc4)](_0x2292a4[_0x454004(0x121)])){const _0x10e3db=_0x2292a4[_0x454004(0x121)][_0x454004(0x189)](([_0x5436f2,_0x56918b])=>{if(_0x5436f2===_0x56918b)return''+_0x5436f2;return _0x5436f2+'-'+_0x56918b;});_0x506f1f[_0x454004(0x1ac)]('-\x20'+_0x2292a4[_0x454004(0x10e)]+':'+_0x10e3db[_0x454004(0xc5)](','));}else _0x506f1f[_0x454004(0x1ac)]('-\x20'+_0x2292a4[_0x454004(0x10e)]+':*');}}_0x506f1f[_0x454004(0x1ac)](''),_0x2beca4['push'](_0x506f1f['join']('\x0a')),_0x2beca4[_0x454004(0x1ac)](_0x454004(0x102));const _0x5cf1b4=[];for(const _0x154344 of _0x26a786){let _0x528cf7=a0_0x315af7[_0x454004(0xdd)](_0x5e204d['data']['repo_path'],_0x154344[_0x454004(0x10e)]),_0x4b1cd7=null,_0x9cecff=null;try{_0x4b1cd7=await a0_0x29a6ce['readFile'](_0x528cf7,{'encoding':_0x454004(0x190)});}catch(_0x215f08){const _0x4a2e5b=fixPathRepetition(_0x528cf7);if(_0x4a2e5b)try{_0x4b1cd7=await a0_0x29a6ce[_0x454004(0x100)](_0x4a2e5b,{'encoding':_0x454004(0x190)}),_0x528cf7=_0x4a2e5b;}catch{_0x9cecff=_0x215f08 instanceof Error?_0x215f08:new Error(String(_0x215f08));}else _0x9cecff=_0x215f08 instanceof Error?_0x215f08:new Error(String(_0x215f08));}if(_0x4b1cd7!==null){const _0x477de6=_0x4b1cd7[_0x454004(0x1a5)](/\r?\n/),_0x47c927=[_0x454004(0xcb)+_0x154344['path']+'\x22>'];if(_0x154344[_0x454004(0x121)]==='*'||!Array[_0x454004(0xc4)](_0x154344[_0x454004(0x121)]))for(let _0x4bd23f=0x1;_0x4bd23f<=_0x477de6[_0x454004(0x1a6)];_0x4bd23f++){const _0x22801a=_0x477de6[_0x4bd23f-0x1];_0x47c927['push'](_0x4bd23f+'|\x20'+_0x22801a);}else for(const [_0xd1c9d8,_0x406331]of _0x154344['lines']){_0x47c927[_0x454004(0x1a6)]>0x1&&_0x47c927['push']('');for(let _0x10c37e=_0xd1c9d8;_0x10c37e<=_0x406331&&_0x10c37e<=_0x477de6['length'];_0x10c37e++){const _0x3ed209=_0x477de6[_0x10c37e-0x1];_0x47c927[_0x454004(0x1ac)](_0x10c37e+'|\x20'+_0x3ed209);}}_0x47c927[_0x454004(0x1ac)](_0x454004(0x127)),_0x5cf1b4['push'](_0x47c927[_0x454004(0xc5)]('\x0a'));}else _0x5cf1b4[_0x454004(0x1ac)](_0x454004(0xcb)+_0x154344[_0x454004(0x10e)]+_0x454004(0x11c)+(_0x9cecff?.[_0x454004(0xad)]||'Unknown\x20error')+_0x454004(0x198));}_0x2beca4['push'](_0x5cf1b4[_0x454004(0xc5)]('\x0a\x0a')),_0x30633b=_0x2beca4[_0x454004(0xc5)]('\x0a');const _0x2087ad=_0x46939b[_0x454004(0xf2)]?.['filter'](_0x20ce20=>_0x20ce20[_0x454004(0xad)]?.[_0x454004(0xca)]('File\x20read\x20error:'))||[];if(_0x2087ad[_0x454004(0x1a6)]>0x0){const _0x70905d=_0x2087ad[_0x454004(0x189)](_0x38f7af=>_0x38f7af[_0x454004(0xad)])['join'](';\x20');reportMorphError({'error_message':_0x70905d,'error_type':'FileReadError','context':{'tool':_0x454004(0xfd),'repo_path':_0x5e204d['data']['repo_path'],'query':_0x5e204d[_0x454004(0xf3)]['search_string'],'model':_0x454004(0x114),'termination_reason':'completed_with_file_errors','error_count':_0x2087ad[_0x454004(0x1a6)],'is_timeout':![],'timings':_0x46939b[_0x454004(0xb4)],'files_attempted':_0x26a786['map'](_0x51f0d1=>({'path':_0x51f0d1[_0x454004(0x10e)],'lines':_0x51f0d1[_0x454004(0x121)]})),'tool_calls':_0x229b5d(_0x46939b[_0x454004(0x14f)]),'messages':_0x46939b[_0x454004(0x14f)]?.[_0x454004(0x189)](_0x1db9df=>({'role':_0x1db9df[_0x454004(0xae)],'content':_0x1db9df[_0x454004(0x18c)]})),'request_content':{'query':_0x5e204d[_0x454004(0xf3)][_0x454004(0x14a)],'repo_path':_0x5e204d['data'][_0x454004(0xab)],'repoRoot':a0_0x315af7[_0x454004(0xdd)](_0x5e204d[_0x454004(0xf3)][_0x454004(0xab)]),'model':_0x454004(0x114)}},'source':_0x454004(0x11a)})[_0x454004(0xbf)](()=>{});}}else{if(_0x46939b['terminationReason']===_0x454004(0xc1)&&_0x46939b[_0x454004(0xf2)][_0x454004(0x1a6)]>0x0){const _0x3e83c4=_0x46939b['errors'][_0x454004(0x189)](_0x1f4829=>_0x1f4829['message'])[_0x454004(0xc5)](';\x20');_0x30633b=_0x454004(0x1ab)+_0x3e83c4;const _0x48a9bc=_0x3e83c4[_0x454004(0xcd)]()[_0x454004(0x145)]('timeout')||_0x3e83c4[_0x454004(0xcd)]()[_0x454004(0x145)](_0x454004(0x11b))||_0x3e83c4[_0x454004(0xcd)]()[_0x454004(0x145)]('etimedout'),_0x99f225=_0x46939b[_0x454004(0x134)]?.[_0x454004(0xbc)]?.['files'],_0x29e718=_0x46939b[_0x454004(0xf2)][0x0];reportMorphError({'error_message':_0x3e83c4,'error_type':_0x48a9bc?'TimeoutError':_0x29e718?.[_0x454004(0xff)]?.[_0x454004(0xde)]||_0x454004(0x119),'context':{'tool':_0x454004(0xfd),'repo_path':_0x5e204d[_0x454004(0xf3)][_0x454004(0xab)],'query':_0x5e204d[_0x454004(0xf3)][_0x454004(0x14a)],'model':_0x454004(0x114),'termination_reason':_0x46939b['terminationReason'],'error_count':_0x46939b[_0x454004(0xf2)][_0x454004(0x1a6)],'is_timeout':_0x48a9bc,'timings':_0x46939b[_0x454004(0xb4)],'files_attempted':_0x99f225?.[_0x454004(0x189)](_0x3008bf=>({'path':_0x3008bf[_0x454004(0x10e)],'lines':_0x3008bf[_0x454004(0x121)]})),'tool_calls':_0x229b5d(_0x46939b[_0x454004(0x14f)]),'messages':_0x46939b[_0x454004(0x14f)]?.[_0x454004(0x189)](_0x470292=>({'role':_0x470292['role'],'content':_0x470292[_0x454004(0x18c)]})),'request_content':{'query':_0x5e204d[_0x454004(0xf3)][_0x454004(0x14a)],'repo_path':_0x5e204d['data']['repo_path'],'repoRoot':a0_0x315af7[_0x454004(0xdd)](_0x5e204d[_0x454004(0xf3)][_0x454004(0xab)]),'model':_0x454004(0x114)}},'stack_trace':_0x29e718?.['stack']||undefined,'source':_0x454004(0x11a)})['catch'](()=>{});}else _0x30633b='Agent\x20completed\x20but\x20did\x20not\x20call\x20finish\x20tool.';}return{'content':[{'type':'text','text':_0x30633b}]};}catch(_0x4bd863){const _0x15f83d=_0x4bd863 instanceof Error?_0x4bd863[_0x454004(0xad)]:String(_0x4bd863),_0x215c67=_0x15f83d[_0x454004(0xcd)]()[_0x454004(0x145)](_0x454004(0xb5))||_0x15f83d['toLowerCase']()[_0x454004(0x145)](_0x454004(0x11b))||_0x15f83d[_0x454004(0xcd)]()[_0x454004(0x145)](_0x454004(0xbb))||_0x4bd863 instanceof Error&&_0x4bd863['name']===_0x454004(0xef);return reportMorphError({'error_message':_0x15f83d,'error_type':_0x215c67?_0x454004(0xef):_0x4bd863 instanceof Error?_0x4bd863[_0x454004(0xff)][_0x454004(0xde)]:_0x454004(0x15d),'context':{'tool':_0x454004(0xfd),'repo_path':_0x5e204d[_0x454004(0xf3)][_0x454004(0xab)],'query':_0x5e204d[_0x454004(0xf3)][_0x454004(0x14a)],'model':'morph-warp-grep-v1-1111v0','is_timeout':_0x215c67,'exception_phase':'runWarpGrep_call','request_content':{'query':_0x5e204d[_0x454004(0xf3)][_0x454004(0x14a)],'repo_path':_0x5e204d[_0x454004(0xf3)]['repo_path'],'repoRoot':a0_0x315af7[_0x454004(0xdd)](_0x5e204d[_0x454004(0xf3)][_0x454004(0xab)]),'model':_0x454004(0x114)}},'stack_trace':_0x4bd863 instanceof Error?_0x4bd863['stack']:undefined,'source':_0x454004(0x11a)})['catch'](()=>{}),{'content':[{'type':_0x454004(0x182),'text':_0x454004(0x10b)+_0x15f83d}],'isError':![]};}}case _0x454004(0x115):{const _0x16e58b=WarpGrepGitHubArgsSchema[_0x454004(0x172)](_0x3a3908);if(!_0x16e58b[_0x454004(0x105)])return{'content':[{'type':_0x454004(0x182),'text':_0x454004(0xb7)+_0x16e58b[_0x454004(0xa6)]}],'isError':!![]};const _0xf8a78d=_0x16e58b[_0x454004(0xf3)][_0x454004(0x113)]||_0x16e58b[_0x454004(0xf3)]['owner_repo'];if(!_0xf8a78d)return{'content':[{'type':_0x454004(0x182),'text':'Please\x20provide\x20github\x20search\x20url\x20or\x20owner/repo\x20id'}],'isError':!![]};const _0x556126=MORPH_API_KEY;if(!_0x556126)throw new Error(_0x454004(0x179));const _0x46dea0=Date[_0x454004(0xe4)]();console[_0x454004(0xa6)](_0x454004(0x108)+_0xf8a78d+_0x454004(0xb3)+_0x16e58b[_0x454004(0xf3)][_0x454004(0x14a)]+'\x22');try{const _0x1cbada=new WarpGrepClient({'morphApiKey':_0x556126,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT}),_0x43a170=await _0x1cbada[_0x454004(0x10c)]({'query':_0x16e58b[_0x454004(0xf3)][_0x454004(0x14a)],'github':_0xf8a78d,'branch':_0x16e58b[_0x454004(0xf3)]['branch']}),_0x18bf47=Date[_0x454004(0xe4)]()-_0x46dea0;console[_0x454004(0xa6)](_0x454004(0x133)+_0x18bf47+_0x454004(0x10f)+_0x43a170['success']);const _0x51c3b6=formatResult(_0x43a170);return{'content':[{'type':_0x454004(0x182),'text':_0x51c3b6}]};}catch(_0x2be7ca){const _0x2daeb5=Date[_0x454004(0xe4)]()-_0x46dea0,_0x28bfe1=_0x2be7ca instanceof Error?_0x2be7ca[_0x454004(0xad)]:String(_0x2be7ca);return console[_0x454004(0xa6)](_0x454004(0x168)+_0x2daeb5+_0x454004(0x19e),_0x28bfe1),reportMorphError({'error_message':_0x28bfe1,'error_type':_0x2be7ca instanceof Error?_0x2be7ca[_0x454004(0xff)][_0x454004(0xde)]:'UnknownError','context':{'tool':'warpgrep_github_search','github_url':_0xf8a78d,'search_string':_0x16e58b[_0x454004(0xf3)][_0x454004(0x14a)],'branch':_0x16e58b['data'][_0x454004(0x1ae)]},'stack_trace':_0x2be7ca instanceof Error?_0x2be7ca[_0x454004(0xba)]:undefined,'source':_0x454004(0x11a),'tool':_0x454004(0x115),'latency_ms':_0x2daeb5})[_0x454004(0xbf)](()=>{}),{'content':[{'type':_0x454004(0x182),'text':_0x454004(0x1b3)+_0x28bfe1}],'isError':![]};}}case _0x454004(0xe5):{const _0x27d00c=CodebaseSearchArgsSchema[_0x454004(0x172)](_0x3a3908);if(!_0x27d00c['success'])return{'content':[{'type':_0x454004(0x182),'text':'Invalid\x20arguments:\x20'+_0x27d00c['error']}],'isError':!![]};try{const _0x5e8265=MORPH_API_KEY;if(!_0x5e8265)throw new Error(_0x454004(0x173));const _0x1d1586=_0x27d00c[_0x454004(0xf3)][_0x454004(0x183)],_0x546cd7=await executeCodebaseSearch({'query':_0x27d00c[_0x454004(0xf3)][_0x454004(0xd2)],'target_directories':_0x1d1586,'limit':_0x27d00c[_0x454004(0xf3)][_0x454004(0x18b)]},{'apiKey':_0x5e8265,'repoId':_0x27d00c[_0x454004(0xf3)][_0x454004(0x13b)],'branch':_0x27d00c[_0x454004(0xf3)][_0x454004(0x1ae)],'commitHash':_0x27d00c[_0x454004(0xf3)][_0x454004(0x175)],'debug':![]});if(!_0x546cd7[_0x454004(0x105)])return{'content':[{'type':_0x454004(0x182),'text':_0x454004(0x120)+_0x546cd7[_0x454004(0xa6)]}],'isError':!![]};const _0x547e02=_0x546cd7[_0x454004(0x181)][_0x454004(0x1a6)]===0x0?_0x454004(0x14d)+_0x27d00c[_0x454004(0xf3)][_0x454004(0xd2)]+'\x22':'Found\x20'+_0x546cd7[_0x454004(0x181)][_0x454004(0x1a6)]+_0x454004(0xa3)+_0x546cd7['stats'][_0x454004(0x16f)]+_0x454004(0x1ad)+_0x546cd7[_0x454004(0x181)][_0x454004(0x189)]((_0x2edd2c,_0x239065)=>_0x239065+0x1+'.\x20'+_0x2edd2c['filepath']+'\x20('+(_0x2edd2c[_0x454004(0x110)]*0x64)[_0x454004(0x191)](0x1)+_0x454004(0x18f)+(_0x454004(0x1a2)+_0x2edd2c['startLine']+'-'+_0x2edd2c[_0x454004(0xcf)]+'\x0a')+(_0x454004(0x1b0)+_0x2edd2c[_0x454004(0x18c)][_0x454004(0x107)](0x0,0xc8)+(_0x2edd2c['content'][_0x454004(0x1a6)]>0xc8?_0x454004(0xd9):'')+'\x0a'))['join']('\x0a');return{'content':[{'type':_0x454004(0x182),'text':_0x547e02}]};}catch(_0xcb7fec){const _0x55a881=_0xcb7fec instanceof Error?_0xcb7fec[_0x454004(0xad)]:String(_0xcb7fec);return reportMorphError({'error_message':_0x55a881,'error_type':_0xcb7fec instanceof Error?_0xcb7fec[_0x454004(0xff)]['name']:_0x454004(0x15d),'context':{'tool':_0x454004(0xe5),'query':_0x27d00c['data'][_0x454004(0xd2)],'repo_id':_0x27d00c[_0x454004(0xf3)][_0x454004(0x13b)],'target_directories':_0x27d00c[_0x454004(0xf3)]['targetDirectories']},'stack_trace':_0xcb7fec instanceof Error?_0xcb7fec['stack']:undefined,'source':_0x454004(0x11a)})[_0x454004(0xbf)](()=>{}),{'content':[{'type':_0x454004(0x182),'text':_0x454004(0x1ab)+_0x55a881}],'isError':!![]};}}default:throw new Error(_0x454004(0x13d)+_0x50995e);}}catch(_0x395945){const _0x2490c2=_0x395945 instanceof Error?_0x395945[_0x454004(0xad)]:String(_0x395945);return reportMorphError({'error_message':_0x2490c2,'error_type':_0x395945 instanceof Error?_0x395945[_0x454004(0xff)]['name']:_0x454004(0x15d),'context':{'tool':name,'arguments':args?JSON['stringify'](args)[_0x454004(0x107)](0x0,0x1f4):undefined,'mcp_server_version':_0x454004(0x141)},'stack_trace':_0x395945 instanceof Error?_0x395945[_0x454004(0xba)]:undefined,'source':_0x454004(0x11a)})['catch'](()=>{}),{'content':[{'type':'text','text':_0x454004(0x1ab)+_0x2490c2}],'isError':!![]};}});async function updateAllowedDirectoriesFromRoots(_0xae85f2){const _0x5a2c38=a0_0x292969,_0x4ba884=await getValidRootDirectories(_0xae85f2);if(_0x4ba884['length']>0x0)allowedDirectories=[..._0x4ba884],console[_0x5a2c38(0xa6)]('Updated\x20allowed\x20directories\x20from\x20MCP\x20roots:\x20'+_0x4ba884[_0x5a2c38(0x1a6)]+'\x20valid\x20directories');else{console[_0x5a2c38(0xa6)]('No\x20valid\x20root\x20directories\x20provided\x20by\x20client');if(ENABLE_WORKSPACE_MODE)try{const _0x341416=await detectWorkspaceRoot(WORKSPACE_ROOT);_0x341416&&(allowedDirectories=[_0x341416],console[_0x5a2c38(0xa6)](_0x5a2c38(0x17a)+_0x341416));}catch(_0x4e5d5f){console[_0x5a2c38(0xa6)]('Warning:\x20Workspace\x20fallback\x20failed:\x20'+_0x4e5d5f);}}}server[a0_0x292969(0x1a3)](RootsListChangedNotificationSchema,async()=>{const _0x518d0f=a0_0x292969;try{const _0x1f1599=await server[_0x518d0f(0x1a7)]();_0x1f1599&&_0x518d0f(0xd5)in _0x1f1599&&await updateAllowedDirectoriesFromRoots(_0x1f1599[_0x518d0f(0xd5)]);}catch(_0x46fb72){console[_0x518d0f(0xa6)](_0x518d0f(0x1a8),_0x46fb72 instanceof Error?_0x46fb72['message']:String(_0x46fb72));}}),server[a0_0x292969(0xb2)]=async()=>{const _0x463cce=a0_0x292969,_0x511e9e=server['getClientCapabilities']();if(_0x511e9e?.[_0x463cce(0xd5)])try{const _0x4d3361=await server[_0x463cce(0x1a7)]();_0x4d3361&&'roots'in _0x4d3361?await updateAllowedDirectoriesFromRoots(_0x4d3361[_0x463cce(0xd5)]):console[_0x463cce(0xa6)]('Client\x20returned\x20no\x20roots\x20set,\x20keeping\x20current\x20settings');}catch(_0x4557ca){console[_0x463cce(0xa6)](_0x463cce(0xe1),_0x4557ca instanceof Error?_0x4557ca[_0x463cce(0xad)]:String(_0x4557ca));}else{if(allowedDirectories[_0x463cce(0x1a6)]>0x0)console[_0x463cce(0xa6)](_0x463cce(0x19d),allowedDirectories);else{if(ENABLE_WORKSPACE_MODE)console[_0x463cce(0xa6)](_0x463cce(0x128));else throw new Error(_0x463cce(0x12a));}}};async function runServer(){const _0x54a145=a0_0x292969,_0x486fa4=new StdioServerTransport();await server['connect'](_0x486fa4),console[_0x54a145(0xa6)]('Secure\x20MCP\x20Filesystem\x20Server\x20running\x20on\x20stdio'),allowedDirectories['length']===0x0&&console[_0x54a145(0xa6)]('Started\x20without\x20allowed\x20directories\x20-\x20waiting\x20for\x20client\x20to\x20provide\x20roots\x20via\x20MCP\x20protocol');}runServer()[a0_0x292969(0xbf)](_0x3e7e2d=>{const _0x3c623c=a0_0x292969;console[_0x3c623c(0xa6)](_0x3c623c(0xed),_0x3e7e2d),process[_0x3c623c(0x195)](0x1);});
|
package/dist/path-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x459150,_0x401932){const _0x12e921=a1_0x1c62,_0x40bef8=_0x459150();while(!![]){try{const _0x28aaf4=parseInt(_0x12e921(0x9e))/0x1*(parseInt(_0x12e921(0x9b))/0x2)+-parseInt(_0x12e921(0xa3))/0x3*(parseInt(_0x12e921(0xa5))/0x4)+-parseInt(_0x12e921(0x96))/0x5*(parseInt(_0x12e921(0x9d))/0x6)+parseInt(_0x12e921(0xa8))/0x7+-parseInt(_0x12e921(0xa1))/0x8*(-parseInt(_0x12e921(0x9c))/0x9)+-parseInt(_0x12e921(0xa4))/0xa+parseInt(_0x12e921(0x99))/0xb;if(_0x28aaf4===_0x401932)break;else _0x40bef8['push'](_0x40bef8['shift']());}catch(_0x5b5de4){_0x40bef8['push'](_0x40bef8['shift']());}}}(a1_0x4c4b,0xe8786));import a1_0x394043 from'path';import a1_0x22f24 from'os';export function convertToWindowsPath(_0x59d7b7){const _0x159a9b=a1_0x1c62;if(_0x59d7b7[_0x159a9b(0x97)]('/mnt/')){const _0x3590c1=_0x59d7b7[_0x159a9b(0xa6)](0x5)[_0x159a9b(0xaa)](),_0x315b95=_0x59d7b7[_0x159a9b(0x95)](0x6)[_0x159a9b(0xa0)](/\//g,'\x5c');return _0x3590c1+':'+_0x315b95;}if(_0x59d7b7['match'](/^\/[a-zA-Z]\//)){const _0x37fe36=_0x59d7b7[_0x159a9b(0xa6)](0x1)[_0x159a9b(0xaa)](),_0x2bcbbd=_0x59d7b7[_0x159a9b(0x95)](0x2)['replace'](/\//g,'\x5c');return _0x37fe36+':'+_0x2bcbbd;}if(_0x59d7b7[_0x159a9b(0xa7)](/^[a-zA-Z]:/))return _0x59d7b7[_0x159a9b(0xa0)](/\//g,'\x5c');return _0x59d7b7;}export function normalizePath(_0x55a2c5){const _0x18b18e=a1_0x1c62;_0x55a2c5=_0x55a2c5[_0x18b18e(0x98)]()[_0x18b18e(0xa0)](/^["']|["']$/g,'');const _0x32932f=_0x55a2c5[_0x18b18e(0x97)]('/')&&!_0x55a2c5[_0x18b18e(0xa7)](/^\/mnt\/[a-z]\//i)&&!_0x55a2c5['match'](/^\/[a-zA-Z]\//);if(_0x32932f)return _0x55a2c5[_0x18b18e(0xa0)](/\/+/g,'/')[_0x18b18e(0xa0)](/\/+$/,'');_0x55a2c5=convertToWindowsPath(_0x55a2c5);if(_0x55a2c5['startsWith']('\x5c\x5c')){let _0x465c97=_0x55a2c5;_0x465c97=_0x465c97[_0x18b18e(0xa0)](/^\\{2,}/,'\x5c\x5c');const _0x5a388d=_0x465c97[_0x18b18e(0xa2)](0x2)[_0x18b18e(0xa0)](/\\\\/g,'\x5c');_0x55a2c5='\x5c\x5c'+_0x5a388d;}else _0x55a2c5=_0x55a2c5['replace'](/\\\\/g,'\x5c');let _0x3853ae=a1_0x394043[_0x18b18e(0xa9)](_0x55a2c5);_0x55a2c5[_0x18b18e(0x97)]('\x5c\x5c')&&!_0x3853ae[_0x18b18e(0x97)]('\x5c\x5c')&&(_0x3853ae='\x5c'+_0x3853ae);if(_0x3853ae[_0x18b18e(0xa7)](/^[a-zA-Z]:/)){let _0x29dec0=_0x3853ae[_0x18b18e(0xa0)](/\//g,'\x5c');return/^[a-z]:/[_0x18b18e(0xab)](_0x29dec0)&&(_0x29dec0=_0x29dec0['charAt'](0x0)[_0x18b18e(0xaa)]()+_0x29dec0[_0x18b18e(0x95)](0x1)),_0x29dec0;}return _0x3853ae[_0x18b18e(0xa0)](/\//g,'\x5c');}function a1_0x4c4b(){const _0x330a32=['normalize','toUpperCase','test','slice','5CAurhb','startsWith','trim','7523835kkVkUD','homedir','16olVaMq','265257BNmCJT','3721926iZJzKH','191620aGSgcE','join','replace','72jhTdUu','substring','346134OQFeEw','13312800IhQtcL','16hvTmZx','charAt','match','6181763vHNWoo'];a1_0x4c4b=function(){return _0x330a32;};return a1_0x4c4b();}function a1_0x1c62(_0x3f17c3,_0x5b45b3){_0x3f17c3=_0x3f17c3-0x95;const _0x4c4ba0=a1_0x4c4b();let _0x1c62ac=_0x4c4ba0[_0x3f17c3];return _0x1c62ac;}export function expandHome(_0x2067be){const _0x420ded=a1_0x1c62;if(_0x2067be[_0x420ded(0x97)]('~/')||_0x2067be==='~')return a1_0x394043[_0x420ded(0x9f)](a1_0x22f24[_0x420ded(0x9a)](),_0x2067be[_0x420ded(0x95)](0x1));return _0x2067be;}
|
package/dist/path-validation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0xe44bc,_0x27c9da){const _0x1d927d=a2_0x3d8a,_0x18e883=_0xe44bc();while(!![]){try{const _0x1bdfe5=parseInt(_0x1d927d(0x12c))/0x1*(-parseInt(_0x1d927d(0x124))/0x2)+-parseInt(_0x1d927d(0x12d))/0x3+parseInt(_0x1d927d(0x129))/0x4*(-parseInt(_0x1d927d(0x12f))/0x5)+parseInt(_0x1d927d(0x130))/0x6*(-parseInt(_0x1d927d(0x12e))/0x7)+-parseInt(_0x1d927d(0x122))/0x8+parseInt(_0x1d927d(0x133))/0x9+parseInt(_0x1d927d(0x123))/0xa;if(_0x1bdfe5===_0x27c9da)break;else _0x18e883['push'](_0x18e883['shift']());}catch(_0x412b65){_0x18e883['push'](_0x18e883['shift']());}}}(a2_0x5e0d,0x49cde));function a2_0x3d8a(_0x5cc292,_0x526736){_0x5cc292=_0x5cc292-0x122;const _0x5e0da3=a2_0x5e0d();let _0x3d8a24=_0x5e0da3[_0x5cc292];return _0x3d8a24;}import a2_0x50c2ee from'path';function a2_0x5e0d(){const _0x539363=['includes','isArray','17870mQmVjl','70437WySsir','7asfbGy','330930XRMSIE','670260FhRkBW','Path\x20must\x20be\x20absolute\x20after\x20normalization','length','118206zZtkTV','startsWith','136880xdEMFf','13157790TWayUA','46uiMPJS','isAbsolute','resolve','sep','normalize','28LTQIqi'];a2_0x5e0d=function(){return _0x539363;};return a2_0x5e0d();}export function isPathWithinAllowedDirectories(_0x2dcf0b,_0x590321){const _0x207e84=a2_0x3d8a;if(typeof _0x2dcf0b!=='string'||!Array[_0x207e84(0x12b)](_0x590321))return![];if(!_0x2dcf0b||_0x590321[_0x207e84(0x132)]===0x0)return![];if(_0x2dcf0b[_0x207e84(0x12a)]('\x00'))return![];let _0x3db3d6;try{_0x3db3d6=a2_0x50c2ee[_0x207e84(0x126)](a2_0x50c2ee[_0x207e84(0x128)](_0x2dcf0b));}catch{return![];}if(!a2_0x50c2ee[_0x207e84(0x125)](_0x3db3d6))throw new Error(_0x207e84(0x131));return _0x590321['some'](_0x38747e=>{const _0x3aef9d=_0x207e84;if(typeof _0x38747e!=='string'||!_0x38747e)return![];if(_0x38747e[_0x3aef9d(0x12a)]('\x00'))return![];let _0x3f2fad;try{_0x3f2fad=a2_0x50c2ee['resolve'](a2_0x50c2ee['normalize'](_0x38747e));}catch{return![];}if(!a2_0x50c2ee['isAbsolute'](_0x3f2fad))throw new Error('Allowed\x20directories\x20must\x20be\x20absolute\x20paths\x20after\x20normalization');if(_0x3db3d6===_0x3f2fad)return!![];if(_0x3f2fad===a2_0x50c2ee[_0x3aef9d(0x127)])return _0x3db3d6[_0x3aef9d(0x134)](a2_0x50c2ee[_0x3aef9d(0x127)]);return _0x3db3d6[_0x3aef9d(0x134)](_0x3f2fad+a2_0x50c2ee[_0x3aef9d(0x127)]);});}
|
package/dist/roots-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x564929,_0x179eea){const _0x329e1d=a3_0x418e,_0x1e240e=_0x564929();while(!![]){try{const _0x4e0af4=-parseInt(_0x329e1d(0xce))/0x1+parseInt(_0x329e1d(0xc8))/0x2*(parseInt(_0x329e1d(0xd1))/0x3)+-parseInt(_0x329e1d(0xcc))/0x4*(parseInt(_0x329e1d(0xd4))/0x5)+-parseInt(_0x329e1d(0xcf))/0x6+parseInt(_0x329e1d(0xc4))/0x7*(parseInt(_0x329e1d(0xcb))/0x8)+-parseInt(_0x329e1d(0xd6))/0x9*(parseInt(_0x329e1d(0xc1))/0xa)+parseInt(_0x329e1d(0xc0))/0xb;if(_0x4e0af4===_0x179eea)break;else _0x1e240e['push'](_0x1e240e['shift']());}catch(_0x256701){_0x1e240e['push'](_0x1e240e['shift']());}}}(a3_0x5ef4,0x69ddb));import{promises as a3_0x2a8225}from'fs';import a3_0x2eb96c from'path';import a3_0x31056d from'os';import{normalizePath}from'./path-utils.js';async function parseRootUri(_0x47969b){const _0xe6ff92=a3_0x418e;try{const _0x3de267=_0x47969b[_0xe6ff92(0xc7)](_0xe6ff92(0xc6))?_0x47969b['slice'](0x7):_0x47969b,_0x118d84=_0x3de267[_0xe6ff92(0xc7)]('~/')||_0x3de267==='~'?a3_0x2eb96c[_0xe6ff92(0xca)](a3_0x31056d['homedir'](),_0x3de267[_0xe6ff92(0xd2)](0x1)):_0x3de267,_0x27f805=a3_0x2eb96c[_0xe6ff92(0xc2)](_0x118d84),_0x4dd0eb=await a3_0x2a8225['realpath'](_0x27f805);return normalizePath(_0x4dd0eb);}catch{return null;}}function a3_0x5ef4(){const _0x561d9f=['940tTDPXv','1979448FRvzZt','isDirectory','231774ERtiyS','slice','message','20035TYGOZS','Skipping\x20invalid\x20directory:\x20','1022742iNzcGo','push','uri','5758016bCNNWr','40qjkXEv','resolve','invalid\x20path\x20or\x20inaccessible','172970WcXltZ','Skipping\x20','file://','startsWith','22EosRMq','non-directory\x20root','join','120QecGuM','524EPCVMd','error'];a3_0x5ef4=function(){return _0x561d9f;};return a3_0x5ef4();}function a3_0x418e(_0x40e1c2,_0x4ecfa0){_0x40e1c2=_0x40e1c2-0xbf;const _0x5ef41c=a3_0x5ef4();let _0x418e2d=_0x5ef41c[_0x40e1c2];return _0x418e2d;}function formatDirectoryError(_0x3f04b6,_0x598c1d,_0x2a587d){const _0x33a8e9=a3_0x418e;if(_0x2a587d)return _0x33a8e9(0xc5)+_0x2a587d+':\x20'+_0x3f04b6;const _0x201832=_0x598c1d instanceof Error?_0x598c1d[_0x33a8e9(0xd3)]:String(_0x598c1d);return _0x33a8e9(0xd5)+_0x3f04b6+'\x20due\x20to\x20error:\x20'+_0x201832;}export async function getValidRootDirectories(_0xc8c98a){const _0x4f5a4c=a3_0x418e,_0x5bc281=[];for(const _0xfc2fec of _0xc8c98a){const _0x1feadf=await parseRootUri(_0xfc2fec['uri']);if(!_0x1feadf){console[_0x4f5a4c(0xcd)](formatDirectoryError(_0xfc2fec[_0x4f5a4c(0xbf)],undefined,_0x4f5a4c(0xc3)));continue;}try{const _0x487ac7=await a3_0x2a8225['stat'](_0x1feadf);_0x487ac7[_0x4f5a4c(0xd0)]()?_0x5bc281[_0x4f5a4c(0xd7)](_0x1feadf):console[_0x4f5a4c(0xcd)](formatDirectoryError(_0x1feadf,undefined,_0x4f5a4c(0xc9)));}catch(_0x1453b5){console[_0x4f5a4c(0xcd)](formatDirectoryError(_0x1feadf,_0x1453b5));}}return _0x5bc281;}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morphllm/morphmcp",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.118",
|
|
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.133",
|
|
39
39
|
"@vscode/ripgrep": "^1.15.14",
|
|
40
40
|
"axios": "^1.6.0",
|
|
41
41
|
"chalk": "^5.3.0",
|