@morphllm/morphmcp 0.8.203 → 0.8.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/log-utils.js +1 -1
- package/dist/logger.js +1 -1
- package/dist/path-utils.js +1 -1
- package/dist/path-validation.js +1 -1
- package/dist/reflex-tools.d.ts +71 -0
- package/dist/reflex-tools.js +1 -0
- package/dist/roots-utils.js +1 -1
- package/dist/tool-definitions.d.ts +3 -0
- package/dist/tool-definitions.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const a0_0x2a3250=a0_0x3b4c;(function(_0x3276d0,_0x1a27a2){const _0xb0fe13=a0_0x3b4c,_0x416e47=_0x3276d0();while(!![]){try{const _0xa31551=parseInt(_0xb0fe13(0x24e))/0x1*(-parseInt(_0xb0fe13(0x1cf))/0x2)+parseInt(_0xb0fe13(0x16a))/0x3*(parseInt(_0xb0fe13(0x18d))/0x4)+-parseInt(_0xb0fe13(0x219))/0x5*(-parseInt(_0xb0fe13(0x1d5))/0x6)+parseInt(_0xb0fe13(0x22f))/0x7+-parseInt(_0xb0fe13(0x211))/0x8+parseInt(_0xb0fe13(0x23a))/0x9*(parseInt(_0xb0fe13(0x23c))/0xa)+-parseInt(_0xb0fe13(0x273))/0xb;if(_0xa31551===_0x1a27a2)break;else _0x416e47['push'](_0x416e47['shift']());}catch(_0x3b6dbd){_0x416e47['push'](_0x416e47['shift']());}}}(a0_0x292b,0x881c9));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_0x5e0960 from'fs/promises';import a0_0x5373b1 from'path';import a0_0x43429b from'os';import{createRequire}from'module';import{z}from'zod';import{zodToJsonSchema}from'zod-to-json-schema';import{getValidRootDirectories}from'./roots-utils.js';import{getOperatingSystemType,logMcpStderr}from'./log-utils.js';import{logger}from'./logger.js';import{executeEditFile}from'@morphllm/morphsdk/tools/fastapply';import{runWarpGrep,LocalRipgrepProvider,GITHUB_SEARCH_TOOL_NAME,GITHUB_SEARCH_DESCRIPTION}from'@morphllm/morphsdk/tools/warp-grep';function a0_0x3b4c(_0x2cfc27,_0x4d9484){_0x2cfc27=_0x2cfc27-0x165;const _0x292bdd=a0_0x292b();let _0x3b4c7f=_0x292bdd[_0x2cfc27];return _0x3b4c7f;}import{WarpGrepClient,formatResult}from'@morphllm/morphsdk/tools/warp-grep/client';import{compactFileContexts}from'@morphllm/morphsdk/tools/compact';import a0_0x533768 from'axios';import{KNOWN_TOOL_NAMES,TOOL_NAMES}from'./tool-definitions.js';function a0_0x292b(){const _0x25c457=['sk-','MORPH_API_URL','-\x20Grepped\x20\x27','File\x20read\x20error:','false','Use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code\x20blocks.\x20Include\x20just\x20enough\x20surrounding\x20context\x20to\x20locate\x20each\x20edit\x20precisely.\x0a\x0a','finish','github_url','937978ZGIEoA','-\x20Listed\x20directory\x20`','listRoots','Parent\x20directory\x20does\x20not\x20exist:\x20','length','ENABLE_WORKSPACE_MODE','768VlPyUw','SymlinkError','Parameters:\x0a','files','status','At\x20least\x20one\x20directory\x20must\x20be\x20provided\x20by\x20EITHER\x20method\x20for\x20the\x20server\x20to\x20operate.','file_read_failed','basename','[github_codebase_search]\x20Done\x20in\x20','tool_calls','added\x20','timeout','BinaryFile','Applied','Secure\x20MCP\x20Filesystem\x20Server\x20running\x20on\x20stdio','https://morphllm.com/api/error-report','-\x20instruction:\x20Brief\x20first-person\x20description\x20of\x20what\x20you\x27re\x20changing\x0a','tool_call_complete','default','env','stack','safeParse','`\x20in\x20`','slice','PathError','repo_path','MCP','indexOf','code_edit','\x0aUsage:\x20morph-mcp\x20[options]\x20[allowed-directory\x20...]','\x20tool\x20unavailable\x20-\x20MORPH_API_KEY\x20not\x20provided\x20in\x20MCP\x20config','Fill\x20out\x20extra\x20details\x20that\x20you\x20as\x20a\x20smart\x20model\x20can\x20infer\x20in\x20the\x20question\x20to\x20aid\x20the\x20toolin\x20its\x20search.\x20','\x20\x201.\x20Command-line\x20arguments\x20(shown\x20above)','tool_call_error','number','WarpGrepError','Unknown\x20tool:\x20','text','Failed\x20to\x20request\x20roots\x20from\x20client:','-\x20Read\x20file\x20`','errors','\x22>\x0a','map','readFile','target_filepath','source','sep','join','access','MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.','Search\x20type\x20hint.\x20Use\x20\x27node_modules\x27\x20when\x20searching\x20inside\x20node_modules\x20or\x20other\x20dependency\x20directories\x20that\x20are\x20normally\x20excluded.','Morph\x20FastApply\x20failed\x20without\x20error\x20message','Morph\x20Edit\x20','Warning:\x20','isArray','pyproject.toml','-\x20code_edit:\x20Only\x20the\x20changed\x20lines\x20with\x20//\x20...\x20existing\x20code\x20...\x20markers\x0a\x0a','warn','lines','constructor','4405408UXmaWB','.vscode','Disabled\x20tools:\x20','SubToolError','command','\x20\x202.\x20MCP\x20roots\x20protocol\x20(if\x20client\x20supports\x20it)','\x20\x20-h,\x20--help\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help\x20message\x20and\x20exit','-\x20ALWAYS\x20use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20for\x20unchanged\x20sections\x20(omitting\x20this\x20marker\x20will\x20cause\x20deletions)\x0a','40720YlUOsi','now','name','resolve','No\x20valid\x20root\x20directories\x20provided\x20by\x20client','Error\x20running\x20fast\x20context\x20search:\x20','morph-warp-grep-v2.1','stat','file','A\x20brief\x20single\x20first-person\x20sentence\x20instruction\x20describing\x20changes\x20being\x20made\x20to\x20this\x20file.\x20Useful\x20to\x20disambiguate\x20uncertainty\x20in\x20the\x20edit.','requiresApiKey','glob','branch','path_validation_resolved','Unknown\x20error','search_string','Example\x20format:\x0a','unknown','You\x20should\x20ALWAYS\x20use\x20this\x20tool\x20to\x20start\x20your\x20search.\x20','message','Error:\x20','.\x20Changes:\x20','3157070RNoUic','morph-v3-fast','<file\x20path=\x22','Authentication\x20failed:\x20Your\x20Morph\x20API\x20key\x20is\x20invalid\x20or\x20has\x20been\x20revoked.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20a\x20valid\x20API\x20key,\x20then\x20update\x20your\x20MCP\x20configuration.','instructions','toLowerCase','0.2.0','role','UnknownError','payload','code','950688cTieTf','stringify','20NmOyJT','composer.json','EDIT_FILE','includes','substring','searchGitHub','terminationReason','every','completionId','Fatal\x20error\x20running\x20server:','Rate\x20limited:\x20You\x27ve\x20exceeded\x20your\x20Morph\x20API\x20usage\x20limits.\x20Please\x20visit\x20https://morphllm.com\x20to\x20check\x20your\x20plan\x20and\x20purchase\x20additional\x20credits.','list_directory','//\x20...\x20existing\x20code\x20...\x0aFIRST_EDIT\x0a//\x20...\x20existing\x20code\x20...\x0aSECOND_EDIT\x0a//\x20...\x20existing\x20code\x20...\x0a\x0a','\x20\x20morph-mcp','Repository\x20owner/repo\x20shorthand\x20(e.g.\x20\x27vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.','Please\x20provide\x20github\x20search\x20url\x20or\x20owner/repo\x20id','grep_search','Fallback:\x20Using\x20workspace\x20root\x20','2ZcsJKa','tsconfig.json','edit','has','\x20\x203.\x20Workspace\x20mode\x20(default\x20behavior,\x20set\x20ENABLE_WORKSPACE_MODE=false\x20to\x20disable)','error','tool_call_received','metadata','Specific\x20commit\x20hash\x20to\x20search','TimeoutError','instruction','Morph\x20Edit\x20Preview','log','version','ENOENT','provider_created','inputSchema','messages','Preview\x20changes\x20without\x20applying\x20them.','some','data','search_type','setNotificationHandler','Created\x20File','\x20as\x20allowed\x20directory','Changed\x20lines\x20with\x20minimal\x20context.\x20Use\x20placeholders\x20intelligently\x20like\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code.','filePath','GITHUB_CODEBASE_SEARCH','package.json','arguments','compaction_failed','RipgrepError','linesRemoved','Client\x20returned\x20no\x20roots\x20set,\x20keeping\x20current\x20settings','warp_grep_start','path','.git','6332392IkRBiE','optional','Repository\x20identifier','dryRun','object','getClientCapabilities','read\x20','Branch\x20to\x20search\x20(defaults\x20to\x20repo\x27s\x20default\x20branch)','\x20\x20--api-key\x20<key>\x20\x20Morph\x20API\x20key\x20(takes\x20priority\x20over\x20MORPH_API_KEY\x20env\x20var)','github_codebase_search','Error\x20accessing\x20directory\x20','match','array','node_modules','codebase_search','\x0aExamples:','path_validation_failed','parse','application/json','WarpGrep\x20sub-tool\x20errors:\x20','\x20chars)','\x0aOptions:','Agent\x20completed\x20but\x20did\x20not\x20call\x20finish\x20tool.','post','Warning:\x20Could\x20not\x20initialize\x20workspace\x20mode:\x20','No\x20relevant\x20code\x20found\x20for\x20the\x20query.','file_read_complete','new_string','startsWith','Failed\x20to\x20read\x20file:\x20','realpath','MORPH_WARP_GREP_TIMEOUT','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','read','mcp-filesystem','edit_file','filter','1071cdEygv','\x0a</file>','dirname','toISOString','ms:','etimedout','LocalRipgrepProvider','--help','turns','floor','exit','PWD','changes','Tool\x20\x22','string','Natural-language\x20question/description\x20about\x20the\x20code\x20you\x20want\x20to\x20understand.\x20Good\x20example:\x20\x22Where\x20does\x20auth\x20get\x20handled,\x20what\x20are\x20the\x20different\x20oauth\x20methods\x20supported?\x22,\x20\x22Trace\x20all\x20code\x20that\x20relates\x20to\x20how\x20data\x20is\x20injested\x20and\x20processed\x22.\x20Bad\x20example:\x20\x22auth()\x22,\x20\x22auth\x20login\x20dashoard\x20google\x20email\x22.\x20This\x20tool\x20does\x20NOT\x20accept\x20regex,\x20keyword\x20dumps,\x20or\x20symbol-only\x20queries.','**PRIMARY\x20TOOL\x20FOR\x20EDITING\x20FILES.**\x20Fast,\x20accurate,\x20and\x20prevents\x20context\x20pollution.\x20Especially\x20useful\x20when\x20making\x20multiple\x20edits\x20in\x20one\x20file:\x20describe\x20all\x20changes\x20in\x20a\x20single\x20call\x20and\x20the\x20semantic\x20edit\x20applies\x20them\x20all\x20at\x20once,\x20more\x20accurately\x20and\x20faster\x20than\x20sequential\x20edits.\x20Unlike\x20search-and-replace\x20or\x20patch\x20edits\x20which\x20do\x20narrow\x20edits\x20one\x20at\x20a\x20time,\x20with\x20this\x20tool\x20you\x20should\x20do\x20all\x20your\x20code\x20changes\x20in\x20one\x20go\x20separated\x20by\x20`//\x20...\x20existing\x20code\x20...`\x20markers.\x20This\x20saves\x20tokens\x20and\x20improves\x20performance\x20because\x20you\x20do\x20not\x20need\x20to\x20reread\x20files\x20before\x20edits.\x20All\x20three\x20parameters\x20are\x20required.\x0a\x0a','\x20is\x20not\x20a\x20directory','ReadError','runWarpGrep_call','linesModified','pattern','assistant','catch','timings','Warning:\x20Workspace\x20fallback\x20failed:\x20','homedir','Here\x20is\x20the\x20content\x20of\x20files:\x0a','morph-mcp','DISABLED_TOOLS','warp_grep_complete','user','morph-v3-large','split','go.mod','10276wQNgsm','debug','describe','connect','Failed\x20to\x20request\x20initial\x20roots\x20from\x20client:','Warning:\x20DISABLED_TOOLS\x20contains\x20unknown\x20tool\x20\x22','API\x20error\x20(auth/rate-limit)','Filter\x20to\x20specific\x20directories,\x20empty\x20for\x20all','Max\x20results\x20to\x20return','\x20valid\x20directories','\x20-\x20','ToolException','\x22>\x0aError\x20reading\x20file:\x20','params','utf-8','grep','Note:\x20Allowed\x20directories\x20can\x20be\x20provided\x20via:','response','Cargo.toml','[could\x20not\x20read\x20file:\x20','Bearer\x20','CODEBASE_SEARCH','Warning:\x20Unable\x20to\x20determine\x20package\x20version:','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20workspace\x20mode','oninitialized','--api-key=','description','success','.\x20Path:\x20','api-key','roots','function','\x20disabled\x20via\x20DISABLED_TOOLS','size','WHEN\x20TO\x20USE\x20vs\x20native\x20edit/patch\x20tools:\x20prefer\x20this\x20tool\x20for\x20large\x20files,\x20multiple\x20or\x20scattered\x20edits,\x20refactors,\x20and\x20whitespace-sensitive\x20changes.\x20A\x20single\x20tiny\x20exact-string\x20replacement\x20can\x20use\x20the\x20native\x20edit/patch\x20tool.\x20If\x20this\x20tool\x20errors\x20or\x20times\x20out,\x20fall\x20back\x20to\x20native\x20edit\x20with\x20exact\x20string\x20matching.\x0a\x0a','Warning:\x20API\x20key\x20format\x20may\x20be\x20incorrect.\x20Morph\x20API\x20keys\x20typically\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27','../package.json','grep\x20\x27','all','content','Invalid\x20arguments\x20for\x20morph_edit_file:\x20','FileNotFound','boolean','path_validation_start','@morphllm/morphmcp\x20','tool_call_id','push','Usage:\x20mcp-server-filesystem\x20[allowed-directory]\x20[additional-directories...]','unknown\x20error','Morph\x20Fast\x20Context\x20subagent\x20performed\x20search\x20on\x20repository:','github_search_start','target_file','glob\x20\x27','linesAdded','completed','\x20error(s)','cwd','-\x20Glob\x20search\x20`'];a0_0x292b=function(){return _0x25c457;};return a0_0x292b();}function fixPathRepetition(_0x40d33b){const _0x158137=a0_0x3b4c,_0x167aa2=_0x40d33b[_0x158137(0x18b)](a0_0x5373b1[_0x158137(0x203)])[_0x158137(0x169)](Boolean);if(_0x167aa2['length']<0x2)return null;for(let _0x94e8aa=Math[_0x158137(0x173)](_0x167aa2[_0x158137(0x1d3)]/0x2);_0x94e8aa>=0x1;_0x94e8aa--){for(let _0x223c59=0x0;_0x223c59<=_0x167aa2[_0x158137(0x1d3)]-0x2*_0x94e8aa;_0x223c59++){const _0x410778=_0x167aa2[_0x158137(0x1ec)](_0x223c59,_0x223c59+_0x94e8aa),_0x46bb36=_0x167aa2[_0x158137(0x1ec)](_0x223c59+_0x94e8aa,_0x223c59+0x2*_0x94e8aa);if(_0x410778[_0x158137(0x243)]((_0x35410c,_0x51dabe)=>_0x35410c===_0x46bb36[_0x51dabe])){const _0x4c05d1=[..._0x167aa2[_0x158137(0x1ec)](0x0,_0x223c59),..._0x167aa2[_0x158137(0x1ec)](_0x223c59+_0x94e8aa)];return a0_0x5373b1[_0x158137(0x203)]+_0x4c05d1[_0x158137(0x204)](a0_0x5373b1['sep']);}}}return null;}const require=createRequire(import.meta.url);function getPackageVersion(){const _0x7a9c37=a0_0x3b4c;try{const _0x19bf7a=require(_0x7a9c37(0x1b1));return _0x19bf7a[_0x7a9c37(0x25b)]??'unknown';}catch(_0x36b3a9){return logMcpStderr(_0x7a9c37(0x1a3),_0x36b3a9),_0x7a9c37(0x22a);}}function printHelp(){const _0x5e8292=a0_0x3b4c;console[_0x5e8292(0x25a)](_0x5e8292(0x1b9)+getPackageVersion()),console[_0x5e8292(0x25a)](_0x5e8292(0x1f2)),console[_0x5e8292(0x25a)](_0x5e8292(0x288)),console['log'](_0x5e8292(0x27b)),console[_0x5e8292(0x25a)](_0x5e8292(0x217)),console['log']('\x20\x20-v,\x20--version\x20\x20\x20\x20Print\x20version\x20and\x20exit'),console[_0x5e8292(0x25a)](_0x5e8292(0x282)),console[_0x5e8292(0x25a)](_0x5e8292(0x249)),console[_0x5e8292(0x25a)]('\x20\x20morph-mcp\x20--api-key\x20sk-xxx\x20~/repo');}const cliArgs=process['argv'][a0_0x2a3250(0x1ec)](0x2),VERSION_FLAGS=new Set(['--version','-v','-V']),HELP_FLAGS=new Set([a0_0x2a3250(0x171),'-h']);cliArgs['some'](_0x226aa0=>VERSION_FLAGS['has'](_0x226aa0))&&(console[a0_0x2a3250(0x25a)](a0_0x2a3250(0x1b9)+getPackageVersion()),process[a0_0x2a3250(0x174)](0x0));cliArgs[a0_0x2a3250(0x261)](_0x5e0a89=>HELP_FLAGS[a0_0x2a3250(0x251)](_0x5e0a89))&&(printHelp(),process[a0_0x2a3250(0x174)](0x0));function getCliArg(_0x1ec5f8){const _0x5d5b8d=a0_0x2a3250;for(let _0x4ad9d6=0x0;_0x4ad9d6<cliArgs[_0x5d5b8d(0x1d3)];_0x4ad9d6++){const _0x4110ee=cliArgs[_0x4ad9d6];if(_0x4110ee[_0x5d5b8d(0x28f)]('--'+_0x1ec5f8+'='))return _0x4110ee[_0x5d5b8d(0x1ec)](('--'+_0x1ec5f8+'=')[_0x5d5b8d(0x1d3)]);if(_0x4110ee==='--'+_0x1ec5f8&&_0x4ad9d6+0x1<cliArgs[_0x5d5b8d(0x1d3)])return cliArgs[_0x4ad9d6+0x1];}return undefined;}const args=[];for(let i=0x0;i<cliArgs[a0_0x2a3250(0x1d3)];i++){const arg=cliArgs[i];if(VERSION_FLAGS[a0_0x2a3250(0x251)](arg)||HELP_FLAGS[a0_0x2a3250(0x251)](arg))continue;if(arg[a0_0x2a3250(0x28f)](a0_0x2a3250(0x1a6)))continue;if(arg==='--api-key'){i++;continue;}args['push'](arg);}const WORKSPACE_ROOT=process['env']['WORKSPACE_ROOT']||process['env'][a0_0x2a3250(0x175)]||process[a0_0x2a3250(0x1c5)](),ENABLE_WORKSPACE_MODE=process[a0_0x2a3250(0x1e8)][a0_0x2a3250(0x1d4)]!==a0_0x2a3250(0x1cb),MORPH_API_KEY=getCliArg(a0_0x2a3250(0x1aa))??process[a0_0x2a3250(0x1e8)]['MORPH_API_KEY'],MORPH_API_URL=process[a0_0x2a3250(0x1e8)][a0_0x2a3250(0x1c8)],MORPH_LARGE_APPLY=process[a0_0x2a3250(0x1e8)]['MORPH_LARGE_APPLY']!=='false',MORPH_WARP_GREP_TIMEOUT=process[a0_0x2a3250(0x1e8)][a0_0x2a3250(0x292)]?parseInt(process[a0_0x2a3250(0x1e8)][a0_0x2a3250(0x292)],0xa):undefined,OPERATING_SYSTEM_TYPE=getOperatingSystemType(),DEFAULT_DISABLED_TOOLS=new Set(),DISABLED_TOOLS=process[a0_0x2a3250(0x1e8)][a0_0x2a3250(0x187)]?new Set(process['env'][a0_0x2a3250(0x187)][a0_0x2a3250(0x18b)](',')['map'](_0x469eb5=>_0x469eb5['trim']())['filter'](_0x2bfbb1=>_0x2bfbb1['length']>0x0)):DEFAULT_DISABLED_TOOLS;if(DISABLED_TOOLS[a0_0x2a3250(0x1ae)]>0x0){for(const tool of DISABLED_TOOLS){!KNOWN_TOOL_NAMES['has'](tool)&&console[a0_0x2a3250(0x253)](a0_0x2a3250(0x192)+tool+'\x22.\x20Known\x20tools:\x20'+[...KNOWN_TOOL_NAMES]['join'](',\x20'));}console[a0_0x2a3250(0x253)](a0_0x2a3250(0x213)+[...DISABLED_TOOLS][a0_0x2a3250(0x204)](',\x20'));}MORPH_API_KEY&&!MORPH_API_KEY['startsWith'](a0_0x2a3250(0x1c7))&&!MORPH_API_KEY[a0_0x2a3250(0x28f)]('morph-')&&logMcpStderr(a0_0x2a3250(0x1b0));async function reportMorphError(_0x38d631){const _0x41aac5=a0_0x2a3250;try{await a0_0x533768[_0x41aac5(0x28a)](_0x41aac5(0x1e4),{..._0x38d631,'timestamp':new Date()[_0x41aac5(0x16d)](),'source':_0x38d631[_0x41aac5(0x202)]||_0x41aac5(0x167),'os_type':OPERATING_SYSTEM_TYPE,'context':{'os_type':OPERATING_SYSTEM_TYPE,..._0x38d631['context']}},{'timeout':0x1388,'headers':{'Content-Type':_0x41aac5(0x285),'Authorization':_0x41aac5(0x1a1)+MORPH_API_KEY}});}catch{}}function extractStatusCode(_0x23c9a7,_0x36d804){const _0x4a7743=a0_0x2a3250;if(_0x23c9a7&&typeof _0x23c9a7==='object'&&_0x4a7743(0x1d9)in _0x23c9a7)return _0x23c9a7[_0x4a7743(0x1d9)];if(_0x23c9a7&&typeof _0x23c9a7===_0x4a7743(0x277)&&_0x4a7743(0x19e)in _0x23c9a7)return _0x23c9a7[_0x4a7743(0x19e)]?.[_0x4a7743(0x1d9)];const _0x4251f1=_0x36d804[_0x4a7743(0x27e)](/\b(401|429)\b/);return _0x4251f1?parseInt(_0x4251f1[0x1],0xa):null;}function handleMorphAPIError(_0x17e063){const _0x2784eb=a0_0x2a3250,_0x2fc4cd=_0x17e063 instanceof Error?_0x17e063[_0x2784eb(0x22c)]:String(_0x17e063),_0x132c01=extractStatusCode(_0x17e063,_0x2fc4cd);switch(_0x132c01){case 0x191:return{'content':[{'type':_0x2784eb(0x1fa),'text':_0x2784eb(0x232)}],'isError':!![]};case 0x1ad:return{'content':[{'type':_0x2784eb(0x1fa),'text':_0x2784eb(0x246)}],'isError':!![]};default:return null;}}args[a0_0x2a3250(0x1d3)]===0x0&&!ENABLE_WORKSPACE_MODE&&(logMcpStderr(a0_0x2a3250(0x1bc)),logMcpStderr(a0_0x2a3250(0x19d)),logMcpStderr(a0_0x2a3250(0x1f5)),logMcpStderr(a0_0x2a3250(0x216)),logMcpStderr(a0_0x2a3250(0x252)),logMcpStderr(a0_0x2a3250(0x1da)));function normalizePath(_0xf5f9dd){return a0_0x5373b1['normalize'](_0xf5f9dd);}function expandHome(_0x466452){const _0xc77507=a0_0x2a3250;if(_0x466452[_0xc77507(0x28f)]('~/')||_0x466452==='~')return a0_0x5373b1[_0xc77507(0x204)](a0_0x43429b[_0xc77507(0x184)](),_0x466452[_0xc77507(0x1ec)](0x1));return _0x466452;}let allowedDirectories=await Promise[a0_0x2a3250(0x1b3)](args['map'](async _0x21bc2c=>{const _0x2a5a1d=a0_0x2a3250,_0x1a3b0e=expandHome(_0x21bc2c),_0x44ed7a=a0_0x5373b1[_0x2a5a1d(0x21c)](_0x1a3b0e);try{const _0x17c965=await a0_0x5e0960['realpath'](_0x44ed7a);return normalizePath(_0x17c965);}catch(_0x2bf26b){return normalizePath(_0x44ed7a);}}));if(ENABLE_WORKSPACE_MODE&&args['length']===0x0)try{const workspaceDir=await detectWorkspaceRoot(WORKSPACE_ROOT);workspaceDir&&(allowedDirectories['push'](workspaceDir),logMcpStderr('Workspace\x20mode\x20enabled:\x20Using\x20'+workspaceDir+a0_0x2a3250(0x266)));}catch(a0_0x5a2e43){logMcpStderr(a0_0x2a3250(0x28b)+a0_0x5a2e43);}async function detectWorkspaceRoot(_0x4ff7f4){const _0x5e3a6f=a0_0x2a3250;let _0x880647=a0_0x5373b1[_0x5e3a6f(0x21c)](_0x4ff7f4);const _0x30a591=[_0x5e3a6f(0x272),_0x5e3a6f(0x212),_0x5e3a6f(0x26a),_0x5e3a6f(0x19f),_0x5e3a6f(0x20c),_0x5e3a6f(0x18c),'.cursor',_0x5e3a6f(0x24f),_0x5e3a6f(0x23d)];while(_0x880647!==a0_0x5373b1[_0x5e3a6f(0x16c)](_0x880647)){for(const _0x30ab5e of _0x30a591){const _0x14e7bc=a0_0x5373b1[_0x5e3a6f(0x204)](_0x880647,_0x30ab5e);try{return await a0_0x5e0960[_0x5e3a6f(0x205)](_0x14e7bc),normalizePath(_0x880647);}catch{}}_0x880647=a0_0x5373b1['dirname'](_0x880647);}return normalizePath(_0x4ff7f4);}await Promise[a0_0x2a3250(0x1b3)](args[a0_0x2a3250(0x1ff)](async _0x4e3c8f=>{const _0x328bec=a0_0x2a3250;try{const _0x7dc7a=await a0_0x5e0960[_0x328bec(0x220)](expandHome(_0x4e3c8f));!_0x7dc7a['isDirectory']()&&(logMcpStderr('Error:\x20'+_0x4e3c8f+_0x328bec(0x17b)),process[_0x328bec(0x174)](0x1));}catch(_0x36624b){logMcpStderr(_0x328bec(0x27d)+_0x4e3c8f+':',_0x36624b),process[_0x328bec(0x174)](0x1);}}));async function validatePath(_0x160c0f){const _0x19b7d6=a0_0x2a3250,_0x57b8c3=expandHome(_0x160c0f),_0x437fbf=a0_0x5373b1[_0x19b7d6(0x21c)](_0x57b8c3);logger[_0x19b7d6(0x18e)](_0x19b7d6(0x1ef),_0x19b7d6(0x1b8),{'raw_path':_0x160c0f,'absolute':_0x437fbf});try{const _0x497705=await a0_0x5e0960[_0x19b7d6(0x291)](_0x437fbf);return logger[_0x19b7d6(0x18e)](_0x19b7d6(0x1ef),_0x19b7d6(0x226),{'resolved':_0x497705,'symlink':_0x497705!==_0x437fbf}),_0x497705;}catch(_0x185d7e){if(_0x185d7e[_0x19b7d6(0x239)]===_0x19b7d6(0x25c)){const _0x318fc5=a0_0x5373b1[_0x19b7d6(0x16c)](_0x437fbf);try{const _0x1535b1=await a0_0x5e0960['realpath'](_0x318fc5),_0x37073b=a0_0x5373b1['join'](_0x1535b1,a0_0x5373b1['basename'](_0x437fbf));return logger[_0x19b7d6(0x18e)](_0x19b7d6(0x1ef),_0x19b7d6(0x226),{'resolved':_0x37073b,'new_file':!![]}),_0x37073b;}catch{logger['error']('MCP',_0x19b7d6(0x283),{'raw_path':_0x160c0f,'error':_0x19b7d6(0x1d2)+_0x318fc5});throw new Error(_0x19b7d6(0x1d2)+_0x318fc5);}}logger['error']('MCP',_0x19b7d6(0x283),{'raw_path':_0x160c0f,'error':_0x185d7e[_0x19b7d6(0x22c)]});throw _0x185d7e;}}const MorphEditFileArgsSchema=z[a0_0x2a3250(0x277)]({'path':z[a0_0x2a3250(0x178)](),'code_edit':z[a0_0x2a3250(0x178)]()['describe'](a0_0x2a3250(0x267)),'instruction':z[a0_0x2a3250(0x178)]()[a0_0x2a3250(0x18f)](a0_0x2a3250(0x222)),'dryRun':z[a0_0x2a3250(0x1b7)]()[a0_0x2a3250(0x1e7)](![])[a0_0x2a3250(0x18f)](a0_0x2a3250(0x260))}),CODEBASE_SEARCH_QUERY_DESCRIPTION=a0_0x2a3250(0x179),WarpGrepArgsSchema=z['object']({'search_string':z[a0_0x2a3250(0x178)]()[a0_0x2a3250(0x18f)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repo_path':z[a0_0x2a3250(0x178)]()[a0_0x2a3250(0x18f)](a0_0x2a3250(0x165)),'search_type':z['enum']([a0_0x2a3250(0x1e7),a0_0x2a3250(0x280)])[a0_0x2a3250(0x274)]()[a0_0x2a3250(0x18f)](a0_0x2a3250(0x207))}),WarpGrepGitHubArgsSchema=z[a0_0x2a3250(0x277)]({'search_string':z['string']()['describe'](CODEBASE_SEARCH_QUERY_DESCRIPTION),'github_url':z[a0_0x2a3250(0x178)]()[a0_0x2a3250(0x274)]()[a0_0x2a3250(0x18f)]('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[a0_0x2a3250(0x178)]()[a0_0x2a3250(0x274)]()[a0_0x2a3250(0x18f)](a0_0x2a3250(0x24a)),'branch':z[a0_0x2a3250(0x178)]()[a0_0x2a3250(0x274)]()[a0_0x2a3250(0x18f)](a0_0x2a3250(0x27a))}),CodebaseSearchArgsSchema=z[a0_0x2a3250(0x277)]({'query':z[a0_0x2a3250(0x178)]()[a0_0x2a3250(0x18f)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repoId':z['string']()[a0_0x2a3250(0x18f)](a0_0x2a3250(0x275)),'branch':z[a0_0x2a3250(0x178)]()[a0_0x2a3250(0x274)]()['describe']('Branch\x20to\x20search\x20(uses\x20latest\x20commit)'),'commitHash':z[a0_0x2a3250(0x178)]()[a0_0x2a3250(0x274)]()[a0_0x2a3250(0x18f)](a0_0x2a3250(0x256)),'targetDirectories':z[a0_0x2a3250(0x27f)](z[a0_0x2a3250(0x178)]())[a0_0x2a3250(0x1e7)]([])[a0_0x2a3250(0x18f)](a0_0x2a3250(0x194)),'limit':z[a0_0x2a3250(0x1f7)]()[a0_0x2a3250(0x274)]()[a0_0x2a3250(0x1e7)](0xa)[a0_0x2a3250(0x18f)](a0_0x2a3250(0x195))}),server=new Server({'name':a0_0x2a3250(0x186),'version':a0_0x2a3250(0x235)},{'capabilities':{'tools':{}}});server['setRequestHandler'](ListToolsRequestSchema,async()=>{const _0x439013=a0_0x2a3250,_0x1ad444=[{'name':TOOL_NAMES['EDIT_FILE'],'description':_0x439013(0x17a)+_0x439013(0x1af)+_0x439013(0x1d7)+'-\x20path:\x20Absolute\x20file\x20path\x20to\x20edit\x0a'+_0x439013(0x1e5)+_0x439013(0x20d)+_0x439013(0x1cc)+_0x439013(0x229)+_0x439013(0x248)+'Rules:\x0a'+_0x439013(0x218)+'-\x20Preserve\x20exact\x20indentation\x0a'+'-\x20For\x20deletions:\x20show\x20context\x20before\x20and\x20after,\x20omit\x20the\x20deleted\x20lines\x0a'+'-\x20Batch\x20multiple\x20edits\x20to\x20the\x20same\x20file\x20in\x20one\x20call\x0a','inputSchema':zodToJsonSchema(MorphEditFileArgsSchema),'requiresApiKey':!![]},{'name':TOOL_NAMES['CODEBASE_SEARCH'],'description':'A\x20code\x20exploration\x20tool,\x20use\x20this\x20tool\x20when\x20exploring\x20an\x20unfamiliar\x20codebase,\x20and\x20you\x27re\x20unsure\x20of\x20the\x20exact\x20file\x20or\x20string\x20to\x20look\x20for.\x20This\x20tool\x20will\x20find\x20all\x20relevant\x20bits\x20of\x20code\x20given\x20a\x20natural\x20lanugage\x20description,\x20or\x20questin\x20of\x20the\x20thing\x20you\x27re\x20looking\x20for.\x20'+CODEBASE_SEARCH_QUERY_DESCRIPTION+'\x20'+_0x439013(0x1f4)+_0x439013(0x22b)+'','inputSchema':zodToJsonSchema(WarpGrepArgsSchema),'requiresApiKey':!![]},{'name':GITHUB_SEARCH_TOOL_NAME,'description':GITHUB_SEARCH_DESCRIPTION,'inputSchema':zodToJsonSchema(WarpGrepGitHubArgsSchema),'requiresApiKey':!![]}],_0x321b29=_0x1ad444[_0x439013(0x169)](_0x58673f=>{const _0x4e1da7=_0x439013;if(DISABLED_TOOLS[_0x4e1da7(0x251)](_0x58673f['name']))return console[_0x4e1da7(0x253)]('Tool\x20'+_0x58673f[_0x4e1da7(0x21b)]+_0x4e1da7(0x1ad)),![];if('requiresApiKey'in _0x58673f&&_0x58673f[_0x4e1da7(0x223)]&&!MORPH_API_KEY)return logMcpStderr(_0x4e1da7(0x20a)+_0x58673f[_0x4e1da7(0x21b)]+_0x4e1da7(0x1f3)),![];return!![];});return{'tools':_0x321b29['map'](_0x164967=>({'name':_0x164967['name'],'description':_0x164967[_0x439013(0x1a7)],'inputSchema':_0x164967[_0x439013(0x25e)]}))};}),server['setRequestHandler'](CallToolRequestSchema,async _0x5cb12a=>{const _0x2bf1b8=a0_0x2a3250,{name:_0x3208b7,arguments:_0x4fb7d9}=_0x5cb12a[_0x2bf1b8(0x19a)],_0x4a2180=Date[_0x2bf1b8(0x21a)]();logger[_0x2bf1b8(0x18e)]('MCP',_0x2bf1b8(0x254),{'tool':_0x3208b7,'args':_0x3208b7==='edit_file'?{'path':_0x4fb7d9?.[_0x2bf1b8(0x271)],'instruction':_0x4fb7d9?.[_0x2bf1b8(0x258)]||_0x4fb7d9?.[_0x2bf1b8(0x233)],'dryRun':_0x4fb7d9?.[_0x2bf1b8(0x276)]}:_0x4fb7d9});try{if(!MORPH_API_KEY)return{'content':[{'type':_0x2bf1b8(0x1fa),'text':'No\x20Morph\x20API\x20key\x20configured.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20an\x20API\x20key,\x20then\x20set\x20MORPH_API_KEY\x20in\x20your\x20MCP\x20configuration.'}],'isError':!![]};if(!MORPH_API_KEY[_0x2bf1b8(0x28f)](_0x2bf1b8(0x1c7))&&!MORPH_API_KEY['startsWith']('morph-'))return{'content':[{'type':_0x2bf1b8(0x1fa),'text':'Invalid\x20Morph\x20API\x20key\x20format.\x20API\x20keys\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20a\x20valid\x20API\x20key.'}],'isError':!![]};if(DISABLED_TOOLS[_0x2bf1b8(0x251)](_0x3208b7))return{'content':[{'type':'text','text':_0x2bf1b8(0x177)+_0x3208b7+'\x22\x20is\x20disabled\x20via\x20the\x20DISABLED_TOOLS\x20environment\x20variable\x20in\x20your\x20MCP\x20configuration.\x20Please\x20use\x20an\x20alternative\x20approach.'}],'isError':![]};switch(_0x3208b7){case TOOL_NAMES[_0x2bf1b8(0x23e)]:{let _0x9a4886=_0x4fb7d9;if(_0x9a4886&&typeof _0x9a4886===_0x2bf1b8(0x277)){if(!(_0x2bf1b8(0x271)in _0x9a4886)){const _0x17966c=_0x9a4886[_0x2bf1b8(0x1c0)]??_0x9a4886[_0x2bf1b8(0x268)]??_0x9a4886[_0x2bf1b8(0x201)]??_0x9a4886['file_path']??_0x9a4886[_0x2bf1b8(0x221)];if(_0x17966c)_0x9a4886={..._0x9a4886,'path':_0x17966c};}_0x2bf1b8(0x233)in _0x9a4886&&!(_0x2bf1b8(0x258)in _0x9a4886)&&(_0x9a4886={..._0x9a4886,'instruction':_0x9a4886['instructions']});if(!(_0x2bf1b8(0x1f1)in _0x9a4886)){const _0x5edcd0=_0x9a4886[_0x2bf1b8(0x239)]??_0x9a4886[_0x2bf1b8(0x28e)]??_0x9a4886[_0x2bf1b8(0x1b4)]??_0x9a4886[_0x2bf1b8(0x250)];if(_0x5edcd0)_0x9a4886={..._0x9a4886,'code_edit':_0x5edcd0};}}const _0x1531e5=MorphEditFileArgsSchema[_0x2bf1b8(0x1ea)](_0x9a4886);if(!_0x1531e5['success'])throw new Error(_0x2bf1b8(0x1b5)+_0x1531e5[_0x2bf1b8(0x253)]);const _0x21adee=await validatePath(_0x1531e5[_0x2bf1b8(0x262)]['path']);let _0x4f023f=null,_0x17f74e=!![],_0x2990a7=null;try{_0x4f023f=await a0_0x5e0960['readFile'](_0x21adee,_0x2bf1b8(0x19b)),logger[_0x2bf1b8(0x18e)]('MCP','file_read_complete',{'path':_0x21adee,'size_bytes':_0x4f023f[_0x2bf1b8(0x1d3)]});}catch(_0x2fd173){const _0x38e345=_0x2fd173[_0x2bf1b8(0x239)];_0x38e345===_0x2bf1b8(0x25c)?(_0x17f74e=![],_0x4f023f='',logger[_0x2bf1b8(0x18e)](_0x2bf1b8(0x1ef),_0x2bf1b8(0x28d),{'path':_0x21adee,'exists':![]})):(_0x2990a7=_0x2bf1b8(0x290)+(_0x38e345||'unknown')+_0x2bf1b8(0x197)+(_0x2fd173 instanceof Error?_0x2fd173[_0x2bf1b8(0x22c)]:String(_0x2fd173)),logger[_0x2bf1b8(0x253)](_0x2bf1b8(0x1ef),_0x2bf1b8(0x1db),{'path':_0x21adee,'error':_0x2990a7}),logMcpStderr('Warning:\x20'+_0x2990a7));}let _0x2cf959;try{const _0x5367e3=MORPH_API_KEY;if(!_0x5367e3)throw new Error(_0x2bf1b8(0x206));const _0x55768a=a0_0x5373b1['dirname'](_0x21adee),_0x29b140=a0_0x5373b1[_0x2bf1b8(0x1dc)](_0x21adee);logger[_0x2bf1b8(0x18e)](_0x2bf1b8(0x1ef),'api_request_start',{'model':_0x2bf1b8(0x230),'path':_0x1531e5[_0x2bf1b8(0x262)][_0x2bf1b8(0x271)],'instruction_len':_0x1531e5['data'][_0x2bf1b8(0x258)][_0x2bf1b8(0x1d3)],'code_edit_len':_0x1531e5[_0x2bf1b8(0x262)][_0x2bf1b8(0x1f1)][_0x2bf1b8(0x1d3)],'original_code_len':_0x4f023f?.[_0x2bf1b8(0x1d3)]??0x0,'dry_run':_0x1531e5[_0x2bf1b8(0x262)][_0x2bf1b8(0x276)]});const _0x160914=Date[_0x2bf1b8(0x21a)](),_0x3ffb8c=await executeEditFile({'target_filepath':_0x29b140,'code_edit':_0x1531e5['data'][_0x2bf1b8(0x1f1)],'instruction':_0x1531e5[_0x2bf1b8(0x262)][_0x2bf1b8(0x258)]},{'morphApiKey':_0x5367e3,'morphApiUrl':MORPH_API_URL,'large':MORPH_LARGE_APPLY,'baseDir':_0x55768a,'autoWrite':!_0x1531e5[_0x2bf1b8(0x262)][_0x2bf1b8(0x276)],'generateUdiff':![],'debug':![]}),_0x5873ec=Date[_0x2bf1b8(0x21a)]()-_0x160914;_0x2cf959=_0x3ffb8c[_0x2bf1b8(0x244)];if(!_0x3ffb8c[_0x2bf1b8(0x1a8)])throw new Error(_0x3ffb8c['error']||_0x2bf1b8(0x208));const _0x3ccbc8=_0x3ffb8c[_0x2bf1b8(0x176)],_0x34c5ee=_0x2bf1b8(0x1df)+_0x3ccbc8[_0x2bf1b8(0x1c2)]+',\x20removed\x20'+_0x3ccbc8['linesRemoved']+',\x20modified\x20'+_0x3ccbc8[_0x2bf1b8(0x17e)];logger['debug']('MCP',_0x2bf1b8(0x1e6),{'tool':'edit_file','success':!![],'latency_ms':Date[_0x2bf1b8(0x21a)]()-_0x4a2180,'edit_latency_ms':_0x5873ec,'changes':{'added':_0x3ccbc8[_0x2bf1b8(0x1c2)],'removed':_0x3ccbc8[_0x2bf1b8(0x26e)],'modified':_0x3ccbc8['linesModified']},'completion_id':_0x2cf959});if(_0x1531e5[_0x2bf1b8(0x262)]['dryRun'])return{'content':[{'type':'text','text':_0x2bf1b8(0x259)+(_0x17f74e?'':'\x20(new\x20file)')+':\x20'+_0x1531e5['data'][_0x2bf1b8(0x258)]+_0x2bf1b8(0x22e)+_0x34c5ee+_0x2bf1b8(0x1a9)+_0x1531e5[_0x2bf1b8(0x262)]['path']+'.'}]};return{'content':[{'type':_0x2bf1b8(0x1fa),'text':_0x2bf1b8(0x209)+(_0x17f74e?_0x2bf1b8(0x1e2):_0x2bf1b8(0x265))+':\x20'+_0x1531e5[_0x2bf1b8(0x262)][_0x2bf1b8(0x258)]+'.\x20Changes:\x20'+_0x34c5ee+_0x2bf1b8(0x1a9)+_0x1531e5['data'][_0x2bf1b8(0x271)]+'.'}]};}catch(_0x5bea91){const _0x160eef=handleMorphAPIError(_0x5bea91);if(_0x160eef)return logger[_0x2bf1b8(0x253)]('MCP','tool_call_error',{'tool':_0x2bf1b8(0x168),'error':_0x2bf1b8(0x193),'latency_ms':Date[_0x2bf1b8(0x21a)]()-_0x4a2180}),_0x160eef;const _0x18416d=_0x5bea91 instanceof Error?_0x5bea91['message']:String(_0x5bea91);return logger[_0x2bf1b8(0x253)](_0x2bf1b8(0x1ef),_0x2bf1b8(0x1f6),{'tool':'edit_file','error':_0x18416d,'path':_0x1531e5['data'][_0x2bf1b8(0x271)],'validated_path':_0x21adee,'latency_ms':Date[_0x2bf1b8(0x21a)]()-_0x4a2180,'stack':_0x5bea91 instanceof Error?_0x5bea91[_0x2bf1b8(0x1e9)]:undefined}),reportMorphError({'error_message':_0x18416d,'error_type':_0x5bea91 instanceof Error?_0x5bea91[_0x2bf1b8(0x210)][_0x2bf1b8(0x21b)]:_0x2bf1b8(0x237),'context':{'tool':_0x2bf1b8(0x168),'completion_id':_0x2cf959,'file_path':_0x1531e5[_0x2bf1b8(0x262)]['path'],'validated_path':_0x21adee,'instruction':_0x1531e5[_0x2bf1b8(0x262)][_0x2bf1b8(0x258)],'model':MORPH_LARGE_APPLY?'morph-v3-large':_0x2bf1b8(0x230),'dry_run':_0x1531e5[_0x2bf1b8(0x262)][_0x2bf1b8(0x276)],'file_exists':_0x17f74e,'file_read_error':_0x2990a7,'file_readable':_0x4f023f!==null,'request_content':{'path':_0x1531e5['data']['path'],'code_edit':_0x1531e5[_0x2bf1b8(0x262)][_0x2bf1b8(0x1f1)],'instruction':_0x1531e5[_0x2bf1b8(0x262)]['instruction'],'original_code':_0x4f023f!==null?_0x4f023f[_0x2bf1b8(0x1d3)]>0xc350?_0x4f023f[_0x2bf1b8(0x240)](0x0,0xc350)+'\x0a...\x20(truncated,\x20total:\x20'+_0x4f023f[_0x2bf1b8(0x1d3)]+_0x2bf1b8(0x287):_0x4f023f:_0x2bf1b8(0x1a0)+(_0x2990a7||_0x2bf1b8(0x1bd))+']','original_code_length':_0x4f023f?.[_0x2bf1b8(0x1d3)]??0x0,'model':MORPH_LARGE_APPLY?_0x2bf1b8(0x18a):_0x2bf1b8(0x230),'dry_run':_0x1531e5['data'][_0x2bf1b8(0x276)]}},'stack_trace':_0x5bea91 instanceof Error?_0x5bea91[_0x2bf1b8(0x1e9)]:undefined,'source':_0x2bf1b8(0x167)})[_0x2bf1b8(0x181)](()=>{}),{'content':[{'type':_0x2bf1b8(0x1fa),'text':'❌\x20Morph\x20Edit\x20Failed:\x20'+_0x18416d}],'isError':!![]};}}case TOOL_NAMES[_0x2bf1b8(0x1a2)]:{const _0x1efd85=WarpGrepArgsSchema[_0x2bf1b8(0x1ea)](_0x4fb7d9);if(!_0x1efd85[_0x2bf1b8(0x1a8)])return{'content':[{'type':'text','text':'Invalid\x20arguments:\x20'+_0x1efd85[_0x2bf1b8(0x253)]}],'isError':!![]};const _0x10e56f=_0x5e6bfb=>{const _0x1d7c58=_0x2bf1b8,_0x2ebdc7=[];for(const _0x27be34 of _0x5e6bfb||[]){if(_0x27be34[_0x1d7c58(0x236)]==='assistant'&&Array[_0x1d7c58(0x20b)](_0x27be34[_0x1d7c58(0x1de)]))for(const _0x2eb91a of _0x27be34[_0x1d7c58(0x1de)]){try{const _0x4af098=_0x2eb91a[_0x1d7c58(0x1ac)]?.[_0x1d7c58(0x21b)],_0xbb19b1=JSON[_0x1d7c58(0x284)](_0x2eb91a[_0x1d7c58(0x1ac)]?.[_0x1d7c58(0x26b)]||'{}');if(_0x4af098===_0x1d7c58(0x24c))_0x2ebdc7[_0x1d7c58(0x1bb)](_0x1d7c58(0x1b2)+_0xbb19b1[_0x1d7c58(0x17f)]+'\x27\x20'+(_0xbb19b1[_0x1d7c58(0x271)]||'.'));else{if(_0x4af098===_0x1d7c58(0x166))_0x2ebdc7['push'](_0x1d7c58(0x279)+_0xbb19b1[_0x1d7c58(0x271)]);else{if(_0x4af098===_0x1d7c58(0x247))_0x2ebdc7[_0x1d7c58(0x1bb)]('list_directory\x20'+(_0xbb19b1['command']||'.'));else{if(_0x4af098==='glob')_0x2ebdc7[_0x1d7c58(0x1bb)](_0x1d7c58(0x1c1)+_0xbb19b1[_0x1d7c58(0x17f)]+'\x27\x20'+(_0xbb19b1[_0x1d7c58(0x271)]||'.'));else _0x4af098===_0x1d7c58(0x1cd)&&_0x2ebdc7[_0x1d7c58(0x1bb)](_0x1d7c58(0x1cd));}}}}catch{}}}return _0x2ebdc7;},_0x2b29be=_0x5db2df=>{const _0x5e32ba=_0x2bf1b8,_0x48a1a8=[];if(!_0x5db2df||!Array[_0x5e32ba(0x20b)](_0x5db2df))return _0x48a1a8;const _0x5c1a3b=[{'pattern':/\[FILE NOT FOUND\]/,'error_type':_0x5e32ba(0x1b6),'tool':'read'},{'pattern':/\[PATH ERROR\]/,'error_type':_0x5e32ba(0x1ed),'tool':_0x5e32ba(0x166)},{'pattern':/\[READ ERROR\]/,'error_type':_0x5e32ba(0x17c),'tool':'read'},{'pattern':/\[UNREADABLE FILE\]/,'error_type':_0x5e32ba(0x1e1),'tool':_0x5e32ba(0x166)},{'pattern':/\[RIPGREP ERROR\]/,'error_type':_0x5e32ba(0x26d),'tool':_0x5e32ba(0x19c)},{'pattern':/\[RIPGREP NOT AVAILABLE\]/,'error_type':'RipgrepNotAvailable','tool':_0x5e32ba(0x19c)},{'pattern':/\[BINARY FILE\]/,'error_type':_0x5e32ba(0x1e1),'tool':_0x5e32ba(0x166)},{'pattern':/\[SYMLINK\]/,'error_type':_0x5e32ba(0x1d6),'tool':_0x5e32ba(0x166)},{'pattern':/not a text file/,'error_type':_0x5e32ba(0x1e1),'tool':_0x5e32ba(0x166)},{'pattern':/symbolic link/,'error_type':'SymlinkError','tool':_0x5e32ba(0x166)},{'pattern':/Error reading file:/,'error_type':_0x5e32ba(0x17c),'tool':'read'},{'pattern':/status="error"/,'error_type':_0x5e32ba(0x198),'tool':'unknown'}];let _0x2a7e9c=0x0;for(const _0x192625 of _0x5db2df){_0x192625['role']==='assistant'&&Array['isArray'](_0x192625[_0x5e32ba(0x1de)])&&_0x2a7e9c++;const _0x3d0689=_0x192625['content'];if((_0x192625[_0x5e32ba(0x236)]==='tool'||_0x192625[_0x5e32ba(0x236)]===_0x5e32ba(0x189))&&_0x3d0689&&typeof _0x3d0689===_0x5e32ba(0x178))for(const {pattern:_0x725cbc,error_type:_0x3ad4cd,tool:_0x5a9da5}of _0x5c1a3b){const _0x50248f=_0x3d0689[_0x5e32ba(0x27e)](new RegExp(_0x725cbc[_0x5e32ba(0x202)],'g'));if(_0x50248f)for(const _0x46309d of _0x50248f){const _0x15f9b2=_0x3d0689[_0x5e32ba(0x1f0)](_0x46309d),_0x3e04af=_0x3d0689[_0x5e32ba(0x240)](_0x15f9b2,Math['min'](_0x15f9b2+0xc8,_0x3d0689[_0x5e32ba(0x1d3)]));_0x48a1a8[_0x5e32ba(0x1bb)]({'tool':_0x5a9da5,'error_type':_0x3ad4cd,'error_message':_0x3e04af[_0x5e32ba(0x18b)]('\x0a')[0x0],'turn':_0x2a7e9c});}}}return _0x48a1a8;};try{const _0x4ffaf3=a0_0x5373b1[_0x2bf1b8(0x21c)](_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x1ee)]),_0x170448=_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x263)],_0x56d277=_0x170448===_0x2bf1b8(0x280)?{'allowNames':[_0x2bf1b8(0x280)]}:undefined,_0x1e1044=new LocalRipgrepProvider(_0x4ffaf3,undefined,_0x56d277);logger[_0x2bf1b8(0x18e)](_0x2bf1b8(0x1ef),_0x2bf1b8(0x25d),{'type':_0x2bf1b8(0x170),'repo_root':_0x4ffaf3,'search_type':_0x170448||_0x2bf1b8(0x1e7)}),logger[_0x2bf1b8(0x18e)](_0x2bf1b8(0x1ef),_0x2bf1b8(0x270),{'query':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x228)],'repo_root':_0x4ffaf3,'timeout_ms':MORPH_WARP_GREP_TIMEOUT});const _0x5f38f9=Date[_0x2bf1b8(0x21a)](),_0x16c16a=await runWarpGrep({'searchTerm':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x228)],'repoRoot':_0x4ffaf3,'morphApiKey':MORPH_API_KEY,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT,'provider':_0x1e1044,'search_type':_0x170448}),_0x451726=Date[_0x2bf1b8(0x21a)]()-_0x5f38f9,_0x454b3f=_0x16c16a['finish']?.[_0x2bf1b8(0x255)]?.[_0x2bf1b8(0x1d8)]?.[_0x2bf1b8(0x1d3)]??0x0;logger[_0x2bf1b8(0x18e)](_0x2bf1b8(0x1ef),_0x2bf1b8(0x188),{'termination':_0x16c16a[_0x2bf1b8(0x242)],'turns':_0x16c16a[_0x2bf1b8(0x182)]?.[_0x2bf1b8(0x172)]??0x0,'files_found':_0x454b3f,'latency_ms':_0x451726});const _0x4e9933=_0x2b29be(_0x16c16a[_0x2bf1b8(0x25f)]);_0x4e9933['length']>0x0&&reportMorphError({'error_message':_0x2bf1b8(0x286)+_0x4e9933['length']+_0x2bf1b8(0x1c4),'error_type':_0x2bf1b8(0x214),'level':'warn','tool':_0x2bf1b8(0x281),'context':{'repo_path':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x1ee)],'query':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x228)],'model':_0x2bf1b8(0x21f),'termination_reason':_0x16c16a['terminationReason'],'sub_tool_errors':_0x4e9933,'timings':_0x16c16a[_0x2bf1b8(0x182)],'tool_calls':_0x10e56f(_0x16c16a[_0x2bf1b8(0x25f)]),'messages':_0x16c16a[_0x2bf1b8(0x25f)]?.['map'](_0x36c6b5=>({'role':_0x36c6b5['role'],'content':_0x36c6b5[_0x2bf1b8(0x1b4)],..._0x36c6b5['tool_calls']?{'tool_calls':_0x36c6b5['tool_calls'][_0x2bf1b8(0x1d3)]}:{},..._0x36c6b5[_0x2bf1b8(0x1ba)]?{'tool_call_id':_0x36c6b5[_0x2bf1b8(0x1ba)]}:{}}))},'source':'mcp-filesystem'})[_0x2bf1b8(0x181)](()=>{});let _0xf95e62='';if(_0x16c16a[_0x2bf1b8(0x242)]===_0x2bf1b8(0x1c3)&&_0x16c16a[_0x2bf1b8(0x1cd)]?.['metadata']?.['files']){const _0x4e963e=_0x16c16a[_0x2bf1b8(0x1cd)][_0x2bf1b8(0x255)][_0x2bf1b8(0x1d8)];if(_0x4e963e['length']===0x0)return _0xf95e62=_0x16c16a[_0x2bf1b8(0x1cd)][_0x2bf1b8(0x238)]||_0x2bf1b8(0x28c),{'content':[{'type':_0x2bf1b8(0x1fa),'text':_0xf95e62}]};const _0x5f599d=[],_0x22ff45=[_0x2bf1b8(0x1be)];for(const _0x29b6ac of _0x16c16a[_0x2bf1b8(0x25f)]){if(_0x29b6ac[_0x2bf1b8(0x236)]===_0x2bf1b8(0x180)&&Array[_0x2bf1b8(0x20b)](_0x29b6ac['tool_calls']))for(const _0x5e9191 of _0x29b6ac[_0x2bf1b8(0x1de)]){try{const _0x38f0d8=_0x5e9191['function']?.['name'],_0x330c7d=JSON['parse'](_0x5e9191[_0x2bf1b8(0x1ac)]?.[_0x2bf1b8(0x26b)]||'{}');if(_0x38f0d8==='grep_search')_0x22ff45[_0x2bf1b8(0x1bb)](_0x2bf1b8(0x1c9)+_0x330c7d[_0x2bf1b8(0x17f)]+'\x27\x20in\x20`'+(_0x330c7d[_0x2bf1b8(0x271)]||'.')+'`');else{if(_0x38f0d8===_0x2bf1b8(0x166))_0x22ff45[_0x2bf1b8(0x1bb)](_0x2bf1b8(0x1fc)+_0x330c7d[_0x2bf1b8(0x271)]+'`');else{if(_0x38f0d8===_0x2bf1b8(0x247))_0x22ff45[_0x2bf1b8(0x1bb)](_0x2bf1b8(0x1d0)+(_0x330c7d[_0x2bf1b8(0x215)]||'.')+'`');else _0x38f0d8===_0x2bf1b8(0x224)&&_0x22ff45[_0x2bf1b8(0x1bb)](_0x2bf1b8(0x1c6)+_0x330c7d[_0x2bf1b8(0x17f)]+_0x2bf1b8(0x1eb)+(_0x330c7d['path']||'.')+'`');}}}catch{}}}_0x5f599d[_0x2bf1b8(0x1bb)](_0x22ff45[_0x2bf1b8(0x204)]('\x0a'));const _0x16bf28=['','Relevant\x20context\x20found:'];for(const _0x51f4fd of _0x4e963e){if(_0x51f4fd[_0x2bf1b8(0x20f)]==='*')_0x16bf28[_0x2bf1b8(0x1bb)]('-\x20'+_0x51f4fd[_0x2bf1b8(0x271)]+':*');else{if(Array[_0x2bf1b8(0x20b)](_0x51f4fd[_0x2bf1b8(0x20f)])){const _0x7d5759=_0x51f4fd[_0x2bf1b8(0x20f)]['map'](([_0x4a13a6,_0x1251dc])=>{if(_0x4a13a6===_0x1251dc)return''+_0x4a13a6;return _0x4a13a6+'-'+_0x1251dc;});_0x16bf28['push']('-\x20'+_0x51f4fd[_0x2bf1b8(0x271)]+':'+_0x7d5759[_0x2bf1b8(0x204)](','));}else _0x16bf28[_0x2bf1b8(0x1bb)]('-\x20'+_0x51f4fd['path']+':*');}}_0x16bf28[_0x2bf1b8(0x1bb)](''),_0x5f599d[_0x2bf1b8(0x1bb)](_0x16bf28[_0x2bf1b8(0x204)]('\x0a')),_0x5f599d[_0x2bf1b8(0x1bb)](_0x2bf1b8(0x185));const _0x5cccce=[],_0x86d90d=[];for(const _0x437b66 of _0x4e963e){let _0x1f7677=a0_0x5373b1['resolve'](_0x1efd85[_0x2bf1b8(0x262)]['repo_path'],_0x437b66[_0x2bf1b8(0x271)]),_0x6043e2=null,_0x533010=null;try{_0x6043e2=await a0_0x5e0960[_0x2bf1b8(0x200)](_0x1f7677,{'encoding':_0x2bf1b8(0x19b)});}catch(_0x34c85d){const _0x51f6b0=fixPathRepetition(_0x1f7677);if(_0x51f6b0)try{_0x6043e2=await a0_0x5e0960[_0x2bf1b8(0x200)](_0x51f6b0,{'encoding':_0x2bf1b8(0x19b)}),_0x1f7677=_0x51f6b0;}catch{_0x533010=_0x34c85d instanceof Error?_0x34c85d:new Error(String(_0x34c85d));}else _0x533010=_0x34c85d instanceof Error?_0x34c85d:new Error(String(_0x34c85d));}if(_0x6043e2!==null){const _0x5049af=_0x6043e2['split'](/\r?\n/),_0x5cbe35=[];if(_0x437b66[_0x2bf1b8(0x20f)]==='*'||!Array[_0x2bf1b8(0x20b)](_0x437b66['lines']))for(let _0xede4e5=0x1;_0xede4e5<=_0x5049af[_0x2bf1b8(0x1d3)];_0xede4e5++){const _0x5c4b1c=_0x5049af[_0xede4e5-0x1];_0x5cbe35[_0x2bf1b8(0x1bb)](_0xede4e5+'|\x20'+_0x5c4b1c);}else for(const [_0x4fb071,_0x2b2e76]of _0x437b66[_0x2bf1b8(0x20f)]){_0x5cbe35[_0x2bf1b8(0x1d3)]>0x0&&_0x5cbe35['push']('');for(let _0x186122=_0x4fb071;_0x186122<=_0x2b2e76&&_0x186122<=_0x5049af['length'];_0x186122++){const _0x5517c8=_0x5049af[_0x186122-0x1];_0x5cbe35['push'](_0x186122+'|\x20'+_0x5517c8);}}_0x86d90d[_0x2bf1b8(0x1bb)]({'path':_0x437b66[_0x2bf1b8(0x271)],'content':_0x5cbe35['join']('\x0a')});}else _0x5cccce[_0x2bf1b8(0x1bb)](_0x2bf1b8(0x231)+_0x437b66[_0x2bf1b8(0x271)]+_0x2bf1b8(0x199)+(_0x533010?.[_0x2bf1b8(0x22c)]||_0x2bf1b8(0x227))+'\x0a</file>');}try{const _0xf9ce4b=await compactFileContexts(_0x86d90d,_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x228)],MORPH_API_KEY,MORPH_API_URL);for(const _0x57930b of _0xf9ce4b){_0x5cccce[_0x2bf1b8(0x1bb)](_0x2bf1b8(0x231)+_0x57930b[_0x2bf1b8(0x271)]+_0x2bf1b8(0x1fe)+_0x57930b[_0x2bf1b8(0x1b4)]+'\x0a</file>');}}catch(_0x2508b1){logger[_0x2bf1b8(0x20e)](_0x2bf1b8(0x1ef),_0x2bf1b8(0x26c),{'error':_0x2508b1 instanceof Error?_0x2508b1[_0x2bf1b8(0x22c)]:String(_0x2508b1),'files_count':_0x86d90d['length']});for(const _0x4fa556 of _0x86d90d){_0x5cccce[_0x2bf1b8(0x1bb)]('<file\x20path=\x22'+_0x4fa556['path']+'\x22>\x0a'+_0x4fa556['content']+_0x2bf1b8(0x16b));}}_0x5f599d[_0x2bf1b8(0x1bb)](_0x5cccce[_0x2bf1b8(0x204)]('\x0a\x0a')),_0xf95e62=_0x5f599d[_0x2bf1b8(0x204)]('\x0a');const _0x3a4006=_0x16c16a[_0x2bf1b8(0x1fd)]?.[_0x2bf1b8(0x169)](_0x50d1aa=>_0x50d1aa[_0x2bf1b8(0x22c)]?.[_0x2bf1b8(0x28f)](_0x2bf1b8(0x1ca)))||[];if(_0x3a4006['length']>0x0){const _0x22e635=_0x3a4006[_0x2bf1b8(0x1ff)](_0x53b41f=>_0x53b41f['message'])['join'](';\x20');reportMorphError({'error_message':_0x22e635,'error_type':'FileReadError','context':{'tool':_0x2bf1b8(0x281),'repo_path':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x1ee)],'query':_0x1efd85[_0x2bf1b8(0x262)]['search_string'],'model':_0x2bf1b8(0x21f),'termination_reason':'completed_with_file_errors','error_count':_0x3a4006[_0x2bf1b8(0x1d3)],'is_timeout':![],'timings':_0x16c16a[_0x2bf1b8(0x182)],'files_attempted':_0x4e963e[_0x2bf1b8(0x1ff)](_0xdd245c=>({'path':_0xdd245c[_0x2bf1b8(0x271)],'lines':_0xdd245c['lines']})),'tool_calls':_0x10e56f(_0x16c16a[_0x2bf1b8(0x25f)]),'messages':_0x16c16a[_0x2bf1b8(0x25f)]?.['map'](_0x4da5cd=>({'role':_0x4da5cd['role'],'content':_0x4da5cd[_0x2bf1b8(0x1b4)],..._0x4da5cd['tool_calls']?{'tool_calls':_0x4da5cd[_0x2bf1b8(0x1de)][_0x2bf1b8(0x1d3)]}:{},..._0x4da5cd[_0x2bf1b8(0x1ba)]?{'tool_call_id':_0x4da5cd[_0x2bf1b8(0x1ba)]}:{}})),'request_content':{'query':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x228)],'repo_path':_0x1efd85['data'][_0x2bf1b8(0x1ee)],'repoRoot':a0_0x5373b1['resolve'](_0x1efd85['data'][_0x2bf1b8(0x1ee)]),'model':'morph-warp-grep-v2.1'}},'source':_0x2bf1b8(0x167)})[_0x2bf1b8(0x181)](()=>{});}}else{if(_0x16c16a[_0x2bf1b8(0x242)]==='terminated'&&_0x16c16a[_0x2bf1b8(0x1fd)][_0x2bf1b8(0x1d3)]>0x0){const _0x4eac79=_0x16c16a['errors'][_0x2bf1b8(0x1ff)](_0x649925=>_0x649925[_0x2bf1b8(0x22c)])[_0x2bf1b8(0x204)](';\x20');_0xf95e62=_0x2bf1b8(0x22d)+_0x4eac79;const _0x288fa6=_0x4eac79[_0x2bf1b8(0x234)]()[_0x2bf1b8(0x23f)](_0x2bf1b8(0x1e0))||_0x4eac79[_0x2bf1b8(0x234)]()['includes']('timed\x20out')||_0x4eac79[_0x2bf1b8(0x234)]()[_0x2bf1b8(0x23f)](_0x2bf1b8(0x16f)),_0x571e90=_0x16c16a[_0x2bf1b8(0x1cd)]?.[_0x2bf1b8(0x255)]?.[_0x2bf1b8(0x1d8)],_0xf5c9a6=_0x16c16a['errors'][0x0];reportMorphError({'error_message':_0x4eac79,'error_type':_0x288fa6?_0x2bf1b8(0x257):_0xf5c9a6?.[_0x2bf1b8(0x210)]?.[_0x2bf1b8(0x21b)]||_0x2bf1b8(0x1f8),'context':{'tool':'codebase_search','repo_path':_0x1efd85[_0x2bf1b8(0x262)]['repo_path'],'query':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x228)],'model':_0x2bf1b8(0x21f),'termination_reason':_0x16c16a[_0x2bf1b8(0x242)],'error_count':_0x16c16a[_0x2bf1b8(0x1fd)]['length'],'is_timeout':_0x288fa6,'timings':_0x16c16a[_0x2bf1b8(0x182)],'files_attempted':_0x571e90?.[_0x2bf1b8(0x1ff)](_0x221d36=>({'path':_0x221d36[_0x2bf1b8(0x271)],'lines':_0x221d36[_0x2bf1b8(0x20f)]})),'tool_calls':_0x10e56f(_0x16c16a[_0x2bf1b8(0x25f)]),'messages':_0x16c16a[_0x2bf1b8(0x25f)]?.['map'](_0x100fa1=>({'role':_0x100fa1['role'],'content':_0x100fa1[_0x2bf1b8(0x1b4)],..._0x100fa1[_0x2bf1b8(0x1de)]?{'tool_calls':_0x100fa1[_0x2bf1b8(0x1de)]['length']}:{},..._0x100fa1[_0x2bf1b8(0x1ba)]?{'tool_call_id':_0x100fa1[_0x2bf1b8(0x1ba)]}:{}})),'request_content':{'query':_0x1efd85['data'][_0x2bf1b8(0x228)],'repo_path':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x1ee)],'repoRoot':a0_0x5373b1[_0x2bf1b8(0x21c)](_0x1efd85[_0x2bf1b8(0x262)]['repo_path']),'model':_0x2bf1b8(0x21f)}},'stack_trace':_0xf5c9a6?.['stack']||undefined,'source':'mcp-filesystem'})['catch'](()=>{});}else _0xf95e62=_0x2bf1b8(0x289);}return{'content':[{'type':'text','text':_0xf95e62}]};}catch(_0x24fd81){const _0x405a37=handleMorphAPIError(_0x24fd81);if(_0x405a37)return logger[_0x2bf1b8(0x253)](_0x2bf1b8(0x1ef),_0x2bf1b8(0x1f6),{'tool':_0x2bf1b8(0x281),'error':_0x2bf1b8(0x193),'latency_ms':Date[_0x2bf1b8(0x21a)]()-_0x4a2180}),_0x405a37;const _0x4c8e76=_0x24fd81 instanceof Error?_0x24fd81[_0x2bf1b8(0x22c)]:String(_0x24fd81);logger[_0x2bf1b8(0x253)](_0x2bf1b8(0x1ef),_0x2bf1b8(0x1f6),{'tool':_0x2bf1b8(0x281),'error':_0x4c8e76,'repo_path':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x1ee)],'query':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x228)],'latency_ms':Date[_0x2bf1b8(0x21a)]()-_0x4a2180});const _0x3c7016=_0x4c8e76[_0x2bf1b8(0x234)]()[_0x2bf1b8(0x23f)](_0x2bf1b8(0x1e0))||_0x4c8e76[_0x2bf1b8(0x234)]()['includes']('timed\x20out')||_0x4c8e76[_0x2bf1b8(0x234)]()[_0x2bf1b8(0x23f)](_0x2bf1b8(0x16f))||_0x24fd81 instanceof Error&&_0x24fd81[_0x2bf1b8(0x21b)]===_0x2bf1b8(0x257);return reportMorphError({'error_message':_0x4c8e76,'error_type':_0x3c7016?_0x2bf1b8(0x257):_0x24fd81 instanceof Error?_0x24fd81['constructor'][_0x2bf1b8(0x21b)]:_0x2bf1b8(0x237),'context':{'tool':_0x2bf1b8(0x281),'repo_path':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x1ee)],'query':_0x1efd85['data'][_0x2bf1b8(0x228)],'model':_0x2bf1b8(0x21f),'is_timeout':_0x3c7016,'exception_phase':_0x2bf1b8(0x17d),'request_content':{'query':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x228)],'repo_path':_0x1efd85[_0x2bf1b8(0x262)][_0x2bf1b8(0x1ee)],'repoRoot':a0_0x5373b1[_0x2bf1b8(0x21c)](_0x1efd85['data'][_0x2bf1b8(0x1ee)]),'model':'morph-warp-grep-v2.1'}},'stack_trace':_0x24fd81 instanceof Error?_0x24fd81[_0x2bf1b8(0x1e9)]:undefined,'source':_0x2bf1b8(0x167)})[_0x2bf1b8(0x181)](()=>{}),{'content':[{'type':_0x2bf1b8(0x1fa),'text':_0x2bf1b8(0x21e)+_0x4c8e76}],'isError':![]};}}case TOOL_NAMES[_0x2bf1b8(0x269)]:{const _0x3f7e8a=WarpGrepGitHubArgsSchema[_0x2bf1b8(0x1ea)](_0x4fb7d9);if(!_0x3f7e8a['success'])return{'content':[{'type':_0x2bf1b8(0x1fa),'text':'Invalid\x20arguments:\x20'+_0x3f7e8a[_0x2bf1b8(0x253)]}],'isError':!![]};const _0x3499be=_0x3f7e8a[_0x2bf1b8(0x262)][_0x2bf1b8(0x1ce)]||_0x3f7e8a[_0x2bf1b8(0x262)]['owner_repo'];if(!_0x3499be)return{'content':[{'type':'text','text':_0x2bf1b8(0x24b)}],'isError':!![]};const _0x11b3de=MORPH_API_KEY;if(!_0x11b3de)throw new Error(_0x2bf1b8(0x206));const _0x173aeb=Date[_0x2bf1b8(0x21a)]();logger[_0x2bf1b8(0x18e)]('MCP',_0x2bf1b8(0x1bf),{'identifier':_0x3499be,'query':_0x3f7e8a['data'][_0x2bf1b8(0x228)],'branch':_0x3f7e8a[_0x2bf1b8(0x262)][_0x2bf1b8(0x225)]});try{const _0x3688f9=new WarpGrepClient({'morphApiKey':_0x11b3de,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT}),_0x5e1ac1=await _0x3688f9[_0x2bf1b8(0x241)]({'searchTerm':_0x3f7e8a[_0x2bf1b8(0x262)][_0x2bf1b8(0x228)],'github':_0x3499be,'branch':_0x3f7e8a[_0x2bf1b8(0x262)][_0x2bf1b8(0x225)]}),_0x4cef6f=Date[_0x2bf1b8(0x21a)]()-_0x173aeb;logMcpStderr(_0x2bf1b8(0x1dd)+_0x4cef6f+'ms.\x20Success:\x20'+_0x5e1ac1[_0x2bf1b8(0x1a8)]);const _0x3a9397=formatResult(_0x5e1ac1);return{'content':[{'type':_0x2bf1b8(0x1fa),'text':_0x3a9397}]};}catch(_0xde95c2){const _0x3780fc=handleMorphAPIError(_0xde95c2);if(_0x3780fc)return _0x3780fc;const _0x4f5f35=Date[_0x2bf1b8(0x21a)]()-_0x173aeb,_0xefd03a=_0xde95c2 instanceof Error?_0xde95c2[_0x2bf1b8(0x22c)]:String(_0xde95c2);return logMcpStderr('[github_codebase_search]\x20Failed\x20in\x20'+_0x4f5f35+_0x2bf1b8(0x16e),_0xefd03a),reportMorphError({'error_message':_0xefd03a,'error_type':_0xde95c2 instanceof Error?_0xde95c2[_0x2bf1b8(0x210)][_0x2bf1b8(0x21b)]:'UnknownError','context':{'tool':_0x2bf1b8(0x27c),'github_url':_0x3499be,'search_string':_0x3f7e8a[_0x2bf1b8(0x262)]['search_string'],'branch':_0x3f7e8a['data'][_0x2bf1b8(0x225)]},'stack_trace':_0xde95c2 instanceof Error?_0xde95c2[_0x2bf1b8(0x1e9)]:undefined,'source':'mcp-filesystem','tool':_0x2bf1b8(0x27c),'latency_ms':_0x4f5f35})['catch'](()=>{}),{'content':[{'type':_0x2bf1b8(0x1fa),'text':'GitHub\x20search\x20failed:\x20'+_0xefd03a}],'isError':![]};}}default:throw new Error(_0x2bf1b8(0x1f9)+_0x3208b7);}}catch(_0xba8649){const _0x594a3d=_0xba8649 instanceof Error?_0xba8649[_0x2bf1b8(0x22c)]:String(_0xba8649);return reportMorphError({'error_message':_0x594a3d,'error_type':_0xba8649 instanceof Error?_0xba8649[_0x2bf1b8(0x210)]['name']:_0x2bf1b8(0x237),'context':{'tool':_0x3208b7,'arguments':_0x4fb7d9?JSON[_0x2bf1b8(0x23b)](_0x4fb7d9)[_0x2bf1b8(0x240)](0x0,0x1f4):undefined,'mcp_server_version':_0x2bf1b8(0x235)},'stack_trace':_0xba8649 instanceof Error?_0xba8649[_0x2bf1b8(0x1e9)]:undefined,'source':_0x2bf1b8(0x167)})[_0x2bf1b8(0x181)](()=>{}),{'content':[{'type':_0x2bf1b8(0x1fa),'text':_0x2bf1b8(0x22d)+_0x594a3d}],'isError':!![]};}});async function updateAllowedDirectoriesFromRoots(_0x38355b){const _0x1f2c1b=a0_0x2a3250,_0x2e88f8=await getValidRootDirectories(_0x38355b);if(_0x2e88f8[_0x1f2c1b(0x1d3)]>0x0)allowedDirectories=[..._0x2e88f8],logMcpStderr('Updated\x20allowed\x20directories\x20from\x20MCP\x20roots:\x20'+_0x2e88f8[_0x1f2c1b(0x1d3)]+_0x1f2c1b(0x196));else{logMcpStderr(_0x1f2c1b(0x21d));if(ENABLE_WORKSPACE_MODE)try{const _0x37b8a3=await detectWorkspaceRoot(WORKSPACE_ROOT);_0x37b8a3&&(allowedDirectories=[_0x37b8a3],logMcpStderr(_0x1f2c1b(0x24d)+_0x37b8a3));}catch(_0x8deba9){logMcpStderr(_0x1f2c1b(0x183)+_0x8deba9);}}}server[a0_0x2a3250(0x264)](RootsListChangedNotificationSchema,async()=>{const _0x3ca3d7=a0_0x2a3250;try{const _0x4219e0=await server[_0x3ca3d7(0x1d1)]();_0x4219e0&&_0x3ca3d7(0x1ab)in _0x4219e0&&await updateAllowedDirectoriesFromRoots(_0x4219e0[_0x3ca3d7(0x1ab)]);}catch(_0x5e5139){logMcpStderr(_0x3ca3d7(0x1fb),_0x5e5139 instanceof Error?_0x5e5139[_0x3ca3d7(0x22c)]:String(_0x5e5139));}}),server[a0_0x2a3250(0x1a5)]=async()=>{const _0x5e1795=a0_0x2a3250,_0x1de2d0=server[_0x5e1795(0x278)]();if(_0x1de2d0?.[_0x5e1795(0x1ab)])try{const _0x36f47d=await server[_0x5e1795(0x1d1)]();_0x36f47d&&_0x5e1795(0x1ab)in _0x36f47d?await updateAllowedDirectoriesFromRoots(_0x36f47d[_0x5e1795(0x1ab)]):logMcpStderr(_0x5e1795(0x26f));}catch(_0xba802a){logMcpStderr(_0x5e1795(0x191),_0xba802a instanceof Error?_0xba802a[_0x5e1795(0x22c)]:String(_0xba802a));}else{if(allowedDirectories[_0x5e1795(0x1d3)]>0x0)logMcpStderr('Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20allowed\x20directories\x20set\x20from\x20server\x20args:',allowedDirectories);else{if(ENABLE_WORKSPACE_MODE)logMcpStderr(_0x5e1795(0x1a4));else throw new Error('Server\x20cannot\x20operate:\x20No\x20allowed\x20directories\x20available.\x20Server\x20was\x20started\x20without\x20command-line\x20directories\x20and\x20client\x20either\x20does\x20not\x20support\x20MCP\x20roots\x20protocol\x20or\x20provided\x20empty\x20roots.\x20Please\x20either:\x201)\x20Start\x20server\x20with\x20directory\x20arguments,\x202)\x20Use\x20a\x20client\x20that\x20supports\x20MCP\x20roots\x20protocol\x20and\x20provides\x20valid\x20root\x20directories,\x20or\x203)\x20Enable\x20workspace\x20mode\x20with\x20ENABLE_WORKSPACE_MODE=true.');}}};async function runServer(){const _0x2821e4=a0_0x2a3250,_0x2fa0ed=new StdioServerTransport();await server[_0x2821e4(0x190)](_0x2fa0ed),logMcpStderr(_0x2821e4(0x1e3)),allowedDirectories[_0x2821e4(0x1d3)]===0x0&&logMcpStderr('Started\x20without\x20allowed\x20directories\x20-\x20waiting\x20for\x20client\x20to\x20provide\x20roots\x20via\x20MCP\x20protocol');}runServer()['catch'](_0x27df6b=>{const _0xb1395c=a0_0x2a3250;logMcpStderr(_0xb1395c(0x245),_0x27df6b),process[_0xb1395c(0x174)](0x1);});
|
|
2
|
+
const a0_0x1bd0c4=a0_0x1a5e;(function(_0x4a1d43,_0x17da32){const _0x3bf7ae=a0_0x1a5e,_0x15cbf4=_0x4a1d43();while(!![]){try{const _0x40ace3=parseInt(_0x3bf7ae(0x2d7))/0x1*(parseInt(_0x3bf7ae(0x2c0))/0x2)+parseInt(_0x3bf7ae(0x28e))/0x3*(parseInt(_0x3bf7ae(0x213))/0x4)+-parseInt(_0x3bf7ae(0x2e2))/0x5+-parseInt(_0x3bf7ae(0x231))/0x6*(-parseInt(_0x3bf7ae(0x2ee))/0x7)+parseInt(_0x3bf7ae(0x207))/0x8*(parseInt(_0x3bf7ae(0x244))/0x9)+parseInt(_0x3bf7ae(0x293))/0xa*(-parseInt(_0x3bf7ae(0x265))/0xb)+-parseInt(_0x3bf7ae(0x260))/0xc;if(_0x40ace3===_0x17da32)break;else _0x15cbf4['push'](_0x15cbf4['shift']());}catch(_0x813bf0){_0x15cbf4['push'](_0x15cbf4['shift']());}}}(a0_0x4f2f,0x892ca));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_0x5d80a6 from'fs/promises';import a0_0x2a77ef from'path';import a0_0x485af4 from'os';import{createRequire}from'module';import{z}from'zod';import{zodToJsonSchema}from'zod-to-json-schema';import{getValidRootDirectories}from'./roots-utils.js';import{getOperatingSystemType,logMcpStderr}from'./log-utils.js';import{logger}from'./logger.js';import{executeEditFile}from'@morphllm/morphsdk/tools/fastapply';import{runWarpGrep,LocalRipgrepProvider,GITHUB_SEARCH_TOOL_NAME,GITHUB_SEARCH_DESCRIPTION}from'@morphllm/morphsdk/tools/warp-grep';import{WarpGrepClient,formatResult}from'@morphllm/morphsdk/tools/warp-grep/client';function a0_0x4f2f(){const _0x47e3=['RipgrepNotAvailable','new_string','Example\x20format:\x0a','LIST_REFLEXES','GitHub\x20search\x20failed:\x20','.git','Error\x20accessing\x20directory\x20','FileReadError','Rules:\x0a','2452Kmlhfr','toLowerCase','terminated','@morphllm/morphmcp\x20','instruction','Failed\x20to\x20request\x20initial\x20roots\x20from\x20client:','tool_call_id','enum','.cursor','Fill\x20out\x20extra\x20details\x20that\x20you\x20as\x20a\x20smart\x20model\x20can\x20infer\x20in\x20the\x20question\x20to\x20aid\x20the\x20toolin\x20its\x20search.\x20','morph-v3-fast','-\x20ALWAYS\x20use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20for\x20unchanged\x20sections\x20(omitting\x20this\x20marker\x20will\x20cause\x20deletions)\x0a','text','ENOENT','UnknownError','REFLEX_SUMMARY','metadata','status','toISOString','pattern','ToolException','content','Usage:\x20mcp-server-filesystem\x20[allowed-directory]\x20[additional-directories...]','function','Use\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code\x20blocks.\x20Include\x20just\x20enough\x20surrounding\x20context\x20to\x20locate\x20each\x20edit\x20precisely.\x0a\x0a','<file\x20path=\x22','path_validation_failed','params','BinaryFile','Parent\x20directory\x20does\x20not\x20exist:\x20','2952FjcmpQ','pyproject.toml','debug','searchGitHub','API\x20error\x20(auth/rate-limit)','name','object','has','\x20\x20morph-mcp','glob\x20\x27','You\x20should\x20ALWAYS\x20use\x20this\x20tool\x20to\x20start\x20your\x20search.\x20','No\x20Morph\x20API\x20key\x20configured.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20an\x20API\x20key,\x20then\x20set\x20MORPH_API_KEY\x20in\x20your\x20MCP\x20configuration.','Branch\x20to\x20search\x20(uses\x20latest\x20commit)','\x20\x20--api-key\x20<key>\x20\x20Morph\x20API\x20key\x20(takes\x20priority\x20over\x20MORPH_API_KEY\x20env\x20var)','default','file_path','floor','Changed\x20lines\x20with\x20minimal\x20context.\x20Use\x20placeholders\x20intelligently\x20like\x20\x22//\x20...\x20existing\x20code\x20...\x22\x20to\x20represent\x20unchanged\x20code.','startsWith','869895qLKUeu','GITHUB_CODEBASE_SEARCH','MORPH_API_URL','\x20\x20-v,\x20--version\x20\x20\x20\x20Print\x20version\x20and\x20exit','match','`\x20in\x20`','file_read_failed','search_type','[could\x20not\x20read\x20file:\x20','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20workspace\x20mode','package.json','Natural-language\x20question/description\x20about\x20the\x20code\x20you\x20want\x20to\x20understand.\x20Good\x20example:\x20\x22Where\x20does\x20auth\x20get\x20handled,\x20what\x20are\x20the\x20different\x20oauth\x20methods\x20supported?\x22,\x20\x22Trace\x20all\x20code\x20that\x20relates\x20to\x20how\x20data\x20is\x20injested\x20and\x20processed\x22.\x20Bad\x20example:\x20\x22auth()\x22,\x20\x22auth\x20login\x20dashoard\x20google\x20email\x22.\x20This\x20tool\x20does\x20NOT\x20accept\x20regex,\x20keyword\x20dumps,\x20or\x20symbol-only\x20queries.','stack','completed_with_file_errors','PWD','target_filepath','source','Started\x20without\x20allowed\x20directories\x20-\x20waiting\x20for\x20client\x20to\x20provide\x20roots\x20via\x20MCP\x20protocol','boolean','Search\x20type\x20hint.\x20Use\x20\x27node_modules\x27\x20when\x20searching\x20inside\x20node_modules\x20or\x20other\x20dependency\x20directories\x20that\x20are\x20normally\x20excluded.','version','morph-warp-grep-v2.1','WarpGrep\x20sub-tool\x20errors:\x20','arguments','exit','array','Unknown\x20tool:\x20','Repository\x20identifier','14912172PfaTDm','File\x20read\x20error:','ReadError','catch','now','4114583xSgGkw','morph-mcp','lines','some','api-key','listRoots','\x22>\x0a','success','added\x20','roots','readFile','mcp-filesystem','message','isDirectory','min','tool_call_error','isArray','filter','number','oninitialized','tool_call_received','basename','morph-','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.','Agent\x20completed\x20but\x20did\x20not\x20call\x20finish\x20tool.','changes','\x20(new\x20file)','path','Rate\x20limited:\x20You\x27ve\x20exceeded\x20your\x20Morph\x20API\x20usage\x20limits.\x20Please\x20visit\x20https://morphllm.com\x20to\x20check\x20your\x20plan\x20and\x20purchase\x20additional\x20credits.','normalize','join','includes','\x20valid\x20directories','Invalid\x20arguments\x20for\x20morph_edit_file:\x20','path_validation_start','push','list_directory','--api-key=','\x0aExamples:','files','Authentication\x20failed:\x20Your\x20Morph\x20API\x20key\x20is\x20invalid\x20or\x20has\x20been\x20revoked.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20a\x20valid\x20API\x20key,\x20then\x20update\x20your\x20MCP\x20configuration.','4827GoaiNz','CODEBASE_SEARCH','\x0aOptions:','edit','role','10YqiOse','file','Invalid\x20arguments:\x20','map','completionId','Error\x20running\x20fast\x20context\x20search:\x20','terminationReason','every','GET_REFLEX_TRACES','-\x20Glob\x20search\x20`','application/json','optional','Filter\x20to\x20specific\x20directories,\x20empty\x20for\x20all','-\x20path:\x20Absolute\x20file\x20path\x20to\x20edit\x0a','unknown\x20error','\x20-\x20','stringify','setNotificationHandler','branch','MCP','constructor','string','homedir','all','inputSchema','read','indexOf','❌\x20Morph\x20Edit\x20Failed:\x20','Specific\x20commit\x20hash\x20to\x20search','grep\x20\x27','timings','completed','setRequestHandler','user','At\x20least\x20one\x20directory\x20must\x20be\x20provided\x20by\x20EITHER\x20method\x20for\x20the\x20server\x20to\x20operate.','timed\x20out','\x20as\x20allowed\x20directory',']\x20Done\x20in\x20','0.2.0','--help','go.mod','\x20failed:\x20','length','.vscode','\x20disabled\x20via\x20DISABLED_TOOLS','676ftlDyv','Disabled\x20tools:\x20','describe','safeParse','Warning:\x20API\x20key\x20format\x20may\x20be\x20incorrect.\x20Morph\x20API\x20keys\x20typically\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27','post','\x0aUsage:\x20morph-mcp\x20[options]\x20[allowed-directory\x20...]','warp_grep_complete','DISABLED_TOOLS','cwd','\x20\x20morph-mcp\x20--api-key\x20sk-xxx\x20~/repo','payload','//\x20...\x20existing\x20code\x20...\x0aFIRST_EDIT\x0a//\x20...\x20existing\x20code\x20...\x0aSECOND_EDIT\x0a//\x20...\x20existing\x20code\x20...\x0a\x0a','connect','instructions','ENABLE_WORKSPACE_MODE','getClientCapabilities','node_modules','ms.\x20Success:\x20','\x20\x201.\x20Command-line\x20arguments\x20(shown\x20above)','SubToolError','Tool\x20','code','2036wcDIog','split','Parameters:\x0a','Relevant\x20context\x20found:','utf-8','Client\x20does\x20not\x20support\x20MCP\x20Roots,\x20using\x20allowed\x20directories\x20set\x20from\x20server\x20args:','-\x20Read\x20file\x20`','Branch\x20to\x20search\x20(defaults\x20to\x20repo\x27s\x20default\x20branch)','Warning:\x20Unable\x20to\x20determine\x20package\x20version:','Created\x20File','runWarpGrep_call','1588510hAJCeW','MORPH_WARP_GREP_TIMEOUT','resolve','dryRun','\x20\x202.\x20MCP\x20roots\x20protocol\x20(if\x20client\x20supports\x20it)','search_string','\x0a</file>','file_read_complete','A\x20brief\x20single\x20first-person\x20sentence\x20instruction\x20describing\x20changes\x20being\x20made\x20to\x20this\x20file.\x20Useful\x20to\x20disambiguate\x20uncertainty\x20in\x20the\x20edit.','substring','\x22>\x0aError\x20reading\x20file:\x20','https://morphllm.com/api/error-report','7567veDIij','\x20tool\x20unavailable\x20-\x20MORPH_API_KEY\x20not\x20provided\x20in\x20MCP\x20config','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.','sep','filePath','assistant','error','target_file','trim','Warning:\x20Workspace\x20fallback\x20failed:\x20','read\x20','.\x20Path:\x20','MORPH_API_KEY','-\x20Preserve\x20exact\x20indentation\x0a',',\x20modified\x20','compaction_failed','dirname','requiresApiKey','code_edit','Morph\x20Fast\x20Context\x20subagent\x20performed\x20search\x20on\x20repository:','env','Warning:\x20DISABLED_TOOLS\x20contains\x20unknown\x20tool\x20\x22','grep','\x27\x20in\x20`','--version','path_validation_resolved','realpath','Applied','finish','morph-v3-large','Failed\x20to\x20request\x20roots\x20from\x20client:','ms:','edit_file','Fatal\x20error\x20running\x20server:','Tool\x20\x22','repo_path','tool_calls','.\x20Changes:\x20','WORKSPACE_ROOT','false','Failed\x20to\x20read\x20file:\x20','EDIT_FILE','sk-','MORPH_LARGE_APPLY','No\x20relevant\x20code\x20found\x20for\x20the\x20query.','Warning:\x20Could\x20not\x20initialize\x20workspace\x20mode:\x20','\x22.\x20Known\x20tools:\x20','messages','SymlinkError','Warning:\x20','tool','[github_codebase_search]\x20Done\x20in\x20','owner_repo','glob','errors','No\x20valid\x20root\x20directories\x20provided\x20by\x20client','response','-\x20For\x20deletions:\x20show\x20context\x20before\x20and\x20after,\x20omit\x20the\x20deleted\x20lines\x0a','slice','linesModified','RipgrepError','github_codebase_search','argv','command','A\x20code\x20exploration\x20tool,\x20use\x20this\x20tool\x20when\x20exploring\x20an\x20unfamiliar\x20codebase,\x20and\x20you\x27re\x20unsure\x20of\x20the\x20exact\x20file\x20or\x20string\x20to\x20look\x20for.\x20This\x20tool\x20will\x20find\x20all\x20relevant\x20bits\x20of\x20code\x20given\x20a\x20natural\x20lanugage\x20description,\x20or\x20questin\x20of\x20the\x20thing\x20you\x27re\x20looking\x20for.\x20','log','\x20chars)','WHEN\x20TO\x20USE\x20vs\x20native\x20edit/patch\x20tools:\x20prefer\x20this\x20tool\x20for\x20large\x20files,\x20multiple\x20or\x20scattered\x20edits,\x20refactors,\x20and\x20whitespace-sensitive\x20changes.\x20A\x20single\x20tiny\x20exact-string\x20replacement\x20can\x20use\x20the\x20native\x20edit/patch\x20tool.\x20If\x20this\x20tool\x20errors\x20or\x20times\x20out,\x20fall\x20back\x20to\x20native\x20edit\x20with\x20exact\x20string\x20matching.\x0a\x0a','warn','grep_search','TimeoutError','FileNotFound','access','-\x20code_edit:\x20Only\x20the\x20changed\x20lines\x20with\x20//\x20...\x20existing\x20code\x20...\x20markers\x0a\x0a','unknown','timeout','--api-key','Error:\x20','-\x20Grepped\x20\x27','Secure\x20MCP\x20Filesystem\x20Server\x20running\x20on\x20stdio','\x20\x20-h,\x20--help\x20\x20\x20\x20\x20\x20\x20Show\x20this\x20help\x20message\x20and\x20exit','codebase_search','Client\x20returned\x20no\x20roots\x20set,\x20keeping\x20current\x20settings','24fpTeHC','data','Repository\x20owner/repo\x20shorthand\x20(e.g.\x20\x27vercel/next.js\x27).\x20You\x20must\x20provide\x20either\x20github_url\x20or\x20owner_repo.'];a0_0x4f2f=function(){return _0x47e3;};return a0_0x4f2f();}import{compactFileContexts}from'@morphllm/morphsdk/tools/compact';import a0_0x169a3e from'axios';import{KNOWN_TOOL_NAMES,TOOL_NAMES}from'./tool-definitions.js';import{ListReflexesArgsSchema,ReflexSummaryArgsSchema,GetReflexTracesArgsSchema,LIST_REFLEXES_DESCRIPTION,REFLEX_SUMMARY_DESCRIPTION,GET_REFLEX_TRACES_DESCRIPTION,createReflexApi,runListReflexes,runReflexSummary,runGetReflexTraces}from'./reflex-tools.js';function fixPathRepetition(_0x48ebc1){const _0x3d98f2=a0_0x1a5e,_0x406235=_0x48ebc1[_0x3d98f2(0x2d8)](a0_0x2a77ef[_0x3d98f2(0x2f1)])['filter'](Boolean);if(_0x406235[_0x3d98f2(0x2bd)]<0x2)return null;for(let _0x4903ef=Math[_0x3d98f2(0x241)](_0x406235[_0x3d98f2(0x2bd)]/0x2);_0x4903ef>=0x1;_0x4903ef--){for(let _0x3b343b=0x0;_0x3b343b<=_0x406235[_0x3d98f2(0x2bd)]-0x2*_0x4903ef;_0x3b343b++){const _0xed6cbc=_0x406235[_0x3d98f2(0x1ee)](_0x3b343b,_0x3b343b+_0x4903ef),_0x11025c=_0x406235['slice'](_0x3b343b+_0x4903ef,_0x3b343b+0x2*_0x4903ef);if(_0xed6cbc[_0x3d98f2(0x29a)]((_0x44bf3a,_0x4e6a85)=>_0x44bf3a===_0x11025c[_0x4e6a85])){const _0x5d1196=[..._0x406235[_0x3d98f2(0x1ee)](0x0,_0x3b343b),..._0x406235[_0x3d98f2(0x1ee)](_0x3b343b+_0x4903ef)];return a0_0x2a77ef[_0x3d98f2(0x2f1)]+_0x5d1196[_0x3d98f2(0x283)](a0_0x2a77ef['sep']);}}}return null;}const require=createRequire(import.meta.url);function getPackageVersion(){const _0xf744d4=a0_0x1a5e;try{const _0x396260=require('../package.json');return _0x396260[_0xf744d4(0x258)]??_0xf744d4(0x1fe);}catch(_0x2e4729){return logMcpStderr(_0xf744d4(0x2df),_0x2e4729),_0xf744d4(0x1fe);}}function printHelp(){const _0xf11ed9=a0_0x1a5e;console[_0xf11ed9(0x1f5)](_0xf11ed9(0x216)+getPackageVersion()),console[_0xf11ed9(0x1f5)](_0xf11ed9(0x2c6)),console[_0xf11ed9(0x1f5)](_0xf11ed9(0x290)),console[_0xf11ed9(0x1f5)](_0xf11ed9(0x23e)),console[_0xf11ed9(0x1f5)](_0xf11ed9(0x204)),console[_0xf11ed9(0x1f5)](_0xf11ed9(0x247)),console[_0xf11ed9(0x1f5)](_0xf11ed9(0x28b)),console[_0xf11ed9(0x1f5)](_0xf11ed9(0x239)),console[_0xf11ed9(0x1f5)](_0xf11ed9(0x2ca));}const cliArgs=process[a0_0x1bd0c4(0x1f2)]['slice'](0x2),VERSION_FLAGS=new Set([a0_0x1bd0c4(0x306),'-v','-V']),HELP_FLAGS=new Set([a0_0x1bd0c4(0x2ba),'-h']);cliArgs[a0_0x1bd0c4(0x268)](_0x359190=>VERSION_FLAGS[a0_0x1bd0c4(0x238)](_0x359190))&&(console[a0_0x1bd0c4(0x1f5)](a0_0x1bd0c4(0x216)+getPackageVersion()),process[a0_0x1bd0c4(0x25c)](0x0));cliArgs[a0_0x1bd0c4(0x268)](_0x5e7889=>HELP_FLAGS['has'](_0x5e7889))&&(printHelp(),process[a0_0x1bd0c4(0x25c)](0x0));function a0_0x1a5e(_0xf9165b,_0xc6522e){_0xf9165b=_0xf9165b-0x1d1;const _0x4f2f57=a0_0x4f2f();let _0x1a5e05=_0x4f2f57[_0xf9165b];return _0x1a5e05;}function getCliArg(_0x435079){const _0x3b19ea=a0_0x1bd0c4;for(let _0x540002=0x0;_0x540002<cliArgs['length'];_0x540002++){const _0x1b5e86=cliArgs[_0x540002];if(_0x1b5e86['startsWith']('--'+_0x435079+'='))return _0x1b5e86[_0x3b19ea(0x1ee)](('--'+_0x435079+'=')[_0x3b19ea(0x2bd)]);if(_0x1b5e86==='--'+_0x435079&&_0x540002+0x1<cliArgs['length'])return cliArgs[_0x540002+0x1];}return undefined;}const args=[];for(let i=0x0;i<cliArgs[a0_0x1bd0c4(0x2bd)];i++){const arg=cliArgs[i];if(VERSION_FLAGS['has'](arg)||HELP_FLAGS[a0_0x1bd0c4(0x238)](arg))continue;if(arg[a0_0x1bd0c4(0x243)](a0_0x1bd0c4(0x28a)))continue;if(arg===a0_0x1bd0c4(0x200)){i++;continue;}args['push'](arg);}const WORKSPACE_ROOT=process[a0_0x1bd0c4(0x302)][a0_0x1bd0c4(0x1da)]||process['env'][a0_0x1bd0c4(0x252)]||process[a0_0x1bd0c4(0x2c9)](),ENABLE_WORKSPACE_MODE=process[a0_0x1bd0c4(0x302)][a0_0x1bd0c4(0x2cf)]!=='false',MORPH_API_KEY=getCliArg(a0_0x1bd0c4(0x269))??process[a0_0x1bd0c4(0x302)][a0_0x1bd0c4(0x2fa)],MORPH_API_URL=process[a0_0x1bd0c4(0x302)][a0_0x1bd0c4(0x246)],MORPH_LARGE_APPLY=process[a0_0x1bd0c4(0x302)][a0_0x1bd0c4(0x1df)]!==a0_0x1bd0c4(0x1db),MORPH_WARP_GREP_TIMEOUT=process[a0_0x1bd0c4(0x302)][a0_0x1bd0c4(0x2e3)]?parseInt(process[a0_0x1bd0c4(0x302)]['MORPH_WARP_GREP_TIMEOUT'],0xa):undefined,OPERATING_SYSTEM_TYPE=getOperatingSystemType(),DEFAULT_DISABLED_TOOLS=new Set(),DISABLED_TOOLS=process[a0_0x1bd0c4(0x302)][a0_0x1bd0c4(0x2c8)]?new Set(process[a0_0x1bd0c4(0x302)][a0_0x1bd0c4(0x2c8)][a0_0x1bd0c4(0x2d8)](',')[a0_0x1bd0c4(0x296)](_0x16037c=>_0x16037c[a0_0x1bd0c4(0x2f6)]())[a0_0x1bd0c4(0x276)](_0x46c0af=>_0x46c0af[a0_0x1bd0c4(0x2bd)]>0x0)):DEFAULT_DISABLED_TOOLS;if(DISABLED_TOOLS['size']>0x0){for(const tool of DISABLED_TOOLS){!KNOWN_TOOL_NAMES[a0_0x1bd0c4(0x238)](tool)&&console[a0_0x1bd0c4(0x2f4)](a0_0x1bd0c4(0x303)+tool+a0_0x1bd0c4(0x1e2)+[...KNOWN_TOOL_NAMES][a0_0x1bd0c4(0x283)](',\x20'));}console[a0_0x1bd0c4(0x2f4)](a0_0x1bd0c4(0x2c1)+[...DISABLED_TOOLS][a0_0x1bd0c4(0x283)](',\x20'));}MORPH_API_KEY&&!MORPH_API_KEY[a0_0x1bd0c4(0x243)](a0_0x1bd0c4(0x1de))&&!MORPH_API_KEY['startsWith'](a0_0x1bd0c4(0x27b))&&logMcpStderr(a0_0x1bd0c4(0x2c4));async function reportMorphError(_0x2b0f11){const _0x35ca82=a0_0x1bd0c4;try{await a0_0x169a3e[_0x35ca82(0x2c5)](_0x35ca82(0x2ed),{..._0x2b0f11,'timestamp':new Date()[_0x35ca82(0x225)](),'source':_0x2b0f11[_0x35ca82(0x254)]||_0x35ca82(0x270),'os_type':OPERATING_SYSTEM_TYPE,'context':{'os_type':OPERATING_SYSTEM_TYPE,..._0x2b0f11['context']}},{'timeout':0x1388,'headers':{'Content-Type':_0x35ca82(0x29d),'Authorization':'Bearer\x20'+MORPH_API_KEY}});}catch{}}function extractStatusCode(_0x238b42,_0x5195ef){const _0xbc8d05=a0_0x1bd0c4;if(_0x238b42&&typeof _0x238b42===_0xbc8d05(0x237)&&_0xbc8d05(0x224)in _0x238b42)return _0x238b42[_0xbc8d05(0x224)];if(_0x238b42&&typeof _0x238b42===_0xbc8d05(0x237)&&_0xbc8d05(0x1ec)in _0x238b42)return _0x238b42[_0xbc8d05(0x1ec)]?.['status'];const _0x15c30f=_0x5195ef[_0xbc8d05(0x248)](/\b(401|429)\b/);return _0x15c30f?parseInt(_0x15c30f[0x1],0xa):null;}function handleMorphAPIError(_0x195d2f){const _0x365f2b=a0_0x1bd0c4,_0x137284=_0x195d2f instanceof Error?_0x195d2f[_0x365f2b(0x271)]:String(_0x195d2f),_0x258a9c=extractStatusCode(_0x195d2f,_0x137284);switch(_0x258a9c){case 0x191:return{'content':[{'type':_0x365f2b(0x21f),'text':_0x365f2b(0x28d)}],'isError':!![]};case 0x1ad:return{'content':[{'type':'text','text':_0x365f2b(0x281)}],'isError':!![]};default:return null;}}let reflexApi=null;function getReflexApi(){if(!reflexApi)reflexApi=createReflexApi(MORPH_API_KEY,MORPH_API_URL);return reflexApi;}async function runReflexTool(_0x4e9713,_0x178c1c){const _0x368776=a0_0x1bd0c4,_0x19f192=Date['now']();try{const _0xfe7a9d=await _0x178c1c();return logMcpStderr('['+_0x4e9713+_0x368776(0x2b8)+(Date['now']()-_0x19f192)+'ms'),{'content':[{'type':'text','text':_0xfe7a9d}]};}catch(_0x3855cc){const _0x4bf6b9=handleMorphAPIError(_0x3855cc);if(_0x4bf6b9)return _0x4bf6b9;const _0x341c50=Date[_0x368776(0x264)]()-_0x19f192,_0x28c485=_0x3855cc instanceof Error?_0x3855cc[_0x368776(0x271)]:String(_0x3855cc);return logMcpStderr('['+_0x4e9713+']\x20Failed\x20in\x20'+_0x341c50+_0x368776(0x1d3),_0x28c485),reportMorphError({'error_message':_0x28c485,'error_type':_0x3855cc instanceof Error?_0x3855cc[_0x368776(0x2a7)][_0x368776(0x236)]:'UnknownError','context':{'tool':_0x4e9713},'stack_trace':_0x3855cc instanceof Error?_0x3855cc[_0x368776(0x250)]:undefined,'source':_0x368776(0x270),'tool':_0x4e9713,'latency_ms':_0x341c50})[_0x368776(0x263)](()=>{}),{'content':[{'type':'text','text':_0x4e9713+_0x368776(0x2bc)+_0x28c485}],'isError':!![]};}}args[a0_0x1bd0c4(0x2bd)]===0x0&&!ENABLE_WORKSPACE_MODE&&(logMcpStderr(a0_0x1bd0c4(0x229)),logMcpStderr('Note:\x20Allowed\x20directories\x20can\x20be\x20provided\x20via:'),logMcpStderr(a0_0x1bd0c4(0x2d3)),logMcpStderr(a0_0x1bd0c4(0x2e6)),logMcpStderr('\x20\x203.\x20Workspace\x20mode\x20(default\x20behavior,\x20set\x20ENABLE_WORKSPACE_MODE=false\x20to\x20disable)'),logMcpStderr(a0_0x1bd0c4(0x2b5)));function normalizePath(_0x1c07ca){const _0x4db27d=a0_0x1bd0c4;return a0_0x2a77ef[_0x4db27d(0x282)](_0x1c07ca);}function expandHome(_0x17217e){const _0x377a9c=a0_0x1bd0c4;if(_0x17217e[_0x377a9c(0x243)]('~/')||_0x17217e==='~')return a0_0x2a77ef[_0x377a9c(0x283)](a0_0x485af4[_0x377a9c(0x2a9)](),_0x17217e['slice'](0x1));return _0x17217e;}let allowedDirectories=await Promise[a0_0x1bd0c4(0x2aa)](args[a0_0x1bd0c4(0x296)](async _0x51d840=>{const _0x3a0569=a0_0x1bd0c4,_0x5f3651=expandHome(_0x51d840),_0x8ef0d6=a0_0x2a77ef['resolve'](_0x5f3651);try{const _0x1759f5=await a0_0x5d80a6[_0x3a0569(0x308)](_0x8ef0d6);return normalizePath(_0x1759f5);}catch(_0x523006){return normalizePath(_0x8ef0d6);}}));if(ENABLE_WORKSPACE_MODE&&args[a0_0x1bd0c4(0x2bd)]===0x0)try{const workspaceDir=await detectWorkspaceRoot(WORKSPACE_ROOT);workspaceDir&&(allowedDirectories[a0_0x1bd0c4(0x288)](workspaceDir),logMcpStderr('Workspace\x20mode\x20enabled:\x20Using\x20'+workspaceDir+a0_0x1bd0c4(0x2b7)));}catch(a0_0x597fed){logMcpStderr(a0_0x1bd0c4(0x1e1)+a0_0x597fed);}async function detectWorkspaceRoot(_0x37c901){const _0x29f480=a0_0x1bd0c4;let _0x5e650c=a0_0x2a77ef['resolve'](_0x37c901);const _0xac15e2=[_0x29f480(0x20f),_0x29f480(0x2be),_0x29f480(0x24e),'Cargo.toml',_0x29f480(0x232),_0x29f480(0x2bb),_0x29f480(0x21b),'tsconfig.json','composer.json'];while(_0x5e650c!==a0_0x2a77ef['dirname'](_0x5e650c)){for(const _0x4919eb of _0xac15e2){const _0x1e88cf=a0_0x2a77ef['join'](_0x5e650c,_0x4919eb);try{return await a0_0x5d80a6[_0x29f480(0x1fc)](_0x1e88cf),normalizePath(_0x5e650c);}catch{}}_0x5e650c=a0_0x2a77ef[_0x29f480(0x2fe)](_0x5e650c);}return normalizePath(_0x37c901);}await Promise[a0_0x1bd0c4(0x2aa)](args['map'](async _0x7d120b=>{const _0x56b71d=a0_0x1bd0c4;try{const _0x56efe5=await a0_0x5d80a6['stat'](expandHome(_0x7d120b));!_0x56efe5[_0x56b71d(0x272)]()&&(logMcpStderr('Error:\x20'+_0x7d120b+'\x20is\x20not\x20a\x20directory'),process['exit'](0x1));}catch(_0x2e526a){logMcpStderr(_0x56b71d(0x210)+_0x7d120b+':',_0x2e526a),process[_0x56b71d(0x25c)](0x1);}}));async function validatePath(_0x26c4a8){const _0x5467af=a0_0x1bd0c4,_0x34bd18=expandHome(_0x26c4a8),_0x27c362=a0_0x2a77ef[_0x5467af(0x2e4)](_0x34bd18);logger[_0x5467af(0x233)](_0x5467af(0x2a6),_0x5467af(0x287),{'raw_path':_0x26c4a8,'absolute':_0x27c362});try{const _0x1c68de=await a0_0x5d80a6[_0x5467af(0x308)](_0x27c362);return logger['debug'](_0x5467af(0x2a6),'path_validation_resolved',{'resolved':_0x1c68de,'symlink':_0x1c68de!==_0x27c362}),_0x1c68de;}catch(_0x50eb0d){if(_0x50eb0d[_0x5467af(0x2d6)]==='ENOENT'){const _0x267747=a0_0x2a77ef[_0x5467af(0x2fe)](_0x27c362);try{const _0x4418e0=await a0_0x5d80a6[_0x5467af(0x308)](_0x267747),_0x3b4244=a0_0x2a77ef[_0x5467af(0x283)](_0x4418e0,a0_0x2a77ef[_0x5467af(0x27a)](_0x27c362));return logger['debug'](_0x5467af(0x2a6),_0x5467af(0x307),{'resolved':_0x3b4244,'new_file':!![]}),_0x3b4244;}catch{logger['error'](_0x5467af(0x2a6),_0x5467af(0x22d),{'raw_path':_0x26c4a8,'error':_0x5467af(0x230)+_0x267747});throw new Error('Parent\x20directory\x20does\x20not\x20exist:\x20'+_0x267747);}}logger[_0x5467af(0x2f4)](_0x5467af(0x2a6),_0x5467af(0x22d),{'raw_path':_0x26c4a8,'error':_0x50eb0d[_0x5467af(0x271)]});throw _0x50eb0d;}}const MorphEditFileArgsSchema=z[a0_0x1bd0c4(0x237)]({'path':z['string'](),'code_edit':z[a0_0x1bd0c4(0x2a8)]()[a0_0x1bd0c4(0x2c2)](a0_0x1bd0c4(0x242)),'instruction':z[a0_0x1bd0c4(0x2a8)]()['describe'](a0_0x1bd0c4(0x2ea)),'dryRun':z[a0_0x1bd0c4(0x256)]()[a0_0x1bd0c4(0x23f)](![])[a0_0x1bd0c4(0x2c2)]('Preview\x20changes\x20without\x20applying\x20them.')}),CODEBASE_SEARCH_QUERY_DESCRIPTION=a0_0x1bd0c4(0x24f),WarpGrepArgsSchema=z['object']({'search_string':z[a0_0x1bd0c4(0x2a8)]()['describe'](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repo_path':z[a0_0x1bd0c4(0x2a8)]()['describe']('The\x20absolute\x20path\x20of\x20the\x20folder\x20where\x20the\x20search\x20should\x20be\x20performed.\x20In\x20multi-repo\x20workspaces,\x20you\x20have\x20to\x20specify\x20a\x20subfolder\x20where\x20the\x20search\x20should\x20be\x20performed,\x20to\x20avoid\x20searching\x20across\x20all\x20repos'),'search_type':z[a0_0x1bd0c4(0x21a)]([a0_0x1bd0c4(0x23f),a0_0x1bd0c4(0x2d1)])[a0_0x1bd0c4(0x29e)]()['describe'](a0_0x1bd0c4(0x257))}),WarpGrepGitHubArgsSchema=z[a0_0x1bd0c4(0x237)]({'search_string':z[a0_0x1bd0c4(0x2a8)]()[a0_0x1bd0c4(0x2c2)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'github_url':z[a0_0x1bd0c4(0x2a8)]()[a0_0x1bd0c4(0x29e)]()[a0_0x1bd0c4(0x2c2)](a0_0x1bd0c4(0x2f0)),'owner_repo':z[a0_0x1bd0c4(0x2a8)]()[a0_0x1bd0c4(0x29e)]()[a0_0x1bd0c4(0x2c2)](a0_0x1bd0c4(0x209)),'branch':z[a0_0x1bd0c4(0x2a8)]()[a0_0x1bd0c4(0x29e)]()['describe'](a0_0x1bd0c4(0x2de))}),CodebaseSearchArgsSchema=z[a0_0x1bd0c4(0x237)]({'query':z[a0_0x1bd0c4(0x2a8)]()[a0_0x1bd0c4(0x2c2)](CODEBASE_SEARCH_QUERY_DESCRIPTION),'repoId':z[a0_0x1bd0c4(0x2a8)]()[a0_0x1bd0c4(0x2c2)](a0_0x1bd0c4(0x25f)),'branch':z['string']()[a0_0x1bd0c4(0x29e)]()[a0_0x1bd0c4(0x2c2)](a0_0x1bd0c4(0x23d)),'commitHash':z[a0_0x1bd0c4(0x2a8)]()[a0_0x1bd0c4(0x29e)]()['describe'](a0_0x1bd0c4(0x2af)),'targetDirectories':z[a0_0x1bd0c4(0x25d)](z[a0_0x1bd0c4(0x2a8)]())[a0_0x1bd0c4(0x23f)]([])[a0_0x1bd0c4(0x2c2)](a0_0x1bd0c4(0x29f)),'limit':z[a0_0x1bd0c4(0x277)]()[a0_0x1bd0c4(0x29e)]()[a0_0x1bd0c4(0x23f)](0xa)[a0_0x1bd0c4(0x2c2)]('Max\x20results\x20to\x20return')}),server=new Server({'name':a0_0x1bd0c4(0x266),'version':a0_0x1bd0c4(0x2b9)},{'capabilities':{'tools':{}}});server[a0_0x1bd0c4(0x2b3)](ListToolsRequestSchema,async()=>{const _0x2c51cb=a0_0x1bd0c4,_0x2a890e=[{'name':TOOL_NAMES['EDIT_FILE'],'description':'**PRIMARY\x20TOOL\x20FOR\x20EDITING\x20FILES.**\x20Fast,\x20accurate,\x20and\x20prevents\x20context\x20pollution.\x20Especially\x20useful\x20when\x20making\x20multiple\x20edits\x20in\x20one\x20file:\x20describe\x20all\x20changes\x20in\x20a\x20single\x20call\x20and\x20the\x20semantic\x20edit\x20applies\x20them\x20all\x20at\x20once,\x20more\x20accurately\x20and\x20faster\x20than\x20sequential\x20edits.\x20Unlike\x20search-and-replace\x20or\x20patch\x20edits\x20which\x20do\x20narrow\x20edits\x20one\x20at\x20a\x20time,\x20with\x20this\x20tool\x20you\x20should\x20do\x20all\x20your\x20code\x20changes\x20in\x20one\x20go\x20separated\x20by\x20`//\x20...\x20existing\x20code\x20...`\x20markers.\x20This\x20saves\x20tokens\x20and\x20improves\x20performance\x20because\x20you\x20do\x20not\x20need\x20to\x20reread\x20files\x20before\x20edits.\x20All\x20three\x20parameters\x20are\x20required.\x0a\x0a'+_0x2c51cb(0x1f7)+_0x2c51cb(0x2d9)+_0x2c51cb(0x2a0)+'-\x20instruction:\x20Brief\x20first-person\x20description\x20of\x20what\x20you\x27re\x20changing\x0a'+_0x2c51cb(0x1fd)+_0x2c51cb(0x22b)+_0x2c51cb(0x20c)+_0x2c51cb(0x2cc)+_0x2c51cb(0x212)+_0x2c51cb(0x21e)+_0x2c51cb(0x2fb)+_0x2c51cb(0x1ed)+'-\x20Batch\x20multiple\x20edits\x20to\x20the\x20same\x20file\x20in\x20one\x20call\x0a','inputSchema':zodToJsonSchema(MorphEditFileArgsSchema),'requiresApiKey':!![]},{'name':TOOL_NAMES[_0x2c51cb(0x28f)],'description':_0x2c51cb(0x1f4)+CODEBASE_SEARCH_QUERY_DESCRIPTION+'\x20'+_0x2c51cb(0x21c)+_0x2c51cb(0x23b)+'','inputSchema':zodToJsonSchema(WarpGrepArgsSchema),'requiresApiKey':!![]},{'name':GITHUB_SEARCH_TOOL_NAME,'description':GITHUB_SEARCH_DESCRIPTION,'inputSchema':zodToJsonSchema(WarpGrepGitHubArgsSchema),'requiresApiKey':!![]},{'name':TOOL_NAMES[_0x2c51cb(0x20d)],'description':LIST_REFLEXES_DESCRIPTION,'inputSchema':zodToJsonSchema(ListReflexesArgsSchema),'requiresApiKey':!![]},{'name':TOOL_NAMES[_0x2c51cb(0x222)],'description':REFLEX_SUMMARY_DESCRIPTION,'inputSchema':zodToJsonSchema(ReflexSummaryArgsSchema),'requiresApiKey':!![]},{'name':TOOL_NAMES[_0x2c51cb(0x29b)],'description':GET_REFLEX_TRACES_DESCRIPTION,'inputSchema':zodToJsonSchema(GetReflexTracesArgsSchema),'requiresApiKey':!![]}],_0x5752c7=_0x2a890e[_0x2c51cb(0x276)](_0x191c23=>{const _0x9e57e6=_0x2c51cb;if(DISABLED_TOOLS[_0x9e57e6(0x238)](_0x191c23[_0x9e57e6(0x236)]))return console[_0x9e57e6(0x2f4)](_0x9e57e6(0x2d5)+_0x191c23[_0x9e57e6(0x236)]+_0x9e57e6(0x2bf)),![];if(_0x9e57e6(0x2ff)in _0x191c23&&_0x191c23['requiresApiKey']&&!MORPH_API_KEY)return logMcpStderr(_0x9e57e6(0x1e5)+_0x191c23[_0x9e57e6(0x236)]+_0x9e57e6(0x2ef)),![];return!![];});return{'tools':_0x5752c7[_0x2c51cb(0x296)](_0x26c2ba=>({'name':_0x26c2ba[_0x2c51cb(0x236)],'description':_0x26c2ba['description'],'inputSchema':_0x26c2ba[_0x2c51cb(0x2ab)]}))};}),server[a0_0x1bd0c4(0x2b3)](CallToolRequestSchema,async _0x17905e=>{const _0x54599f=a0_0x1bd0c4,{name:_0x336537,arguments:_0x5980ef}=_0x17905e[_0x54599f(0x22e)],_0xfdf9fd=Date[_0x54599f(0x264)]();logger['debug'](_0x54599f(0x2a6),_0x54599f(0x279),{'tool':_0x336537,'args':_0x336537===_0x54599f(0x1d4)?{'path':_0x5980ef?.['path'],'instruction':_0x5980ef?.[_0x54599f(0x217)]||_0x5980ef?.['instructions'],'dryRun':_0x5980ef?.['dryRun']}:_0x5980ef});try{if(!MORPH_API_KEY)return{'content':[{'type':_0x54599f(0x21f),'text':_0x54599f(0x23c)}],'isError':!![]};if(!MORPH_API_KEY['startsWith'](_0x54599f(0x1de))&&!MORPH_API_KEY['startsWith'](_0x54599f(0x27b)))return{'content':[{'type':_0x54599f(0x21f),'text':'Invalid\x20Morph\x20API\x20key\x20format.\x20API\x20keys\x20start\x20with\x20\x27sk-\x27\x20or\x20\x27morph-\x27.\x20Please\x20visit\x20https://morphllm.com\x20to\x20get\x20a\x20valid\x20API\x20key.'}],'isError':!![]};if(DISABLED_TOOLS[_0x54599f(0x238)](_0x336537))return{'content':[{'type':_0x54599f(0x21f),'text':_0x54599f(0x1d6)+_0x336537+'\x22\x20is\x20disabled\x20via\x20the\x20DISABLED_TOOLS\x20environment\x20variable\x20in\x20your\x20MCP\x20configuration.\x20Please\x20use\x20an\x20alternative\x20approach.'}],'isError':![]};switch(_0x336537){case TOOL_NAMES[_0x54599f(0x1dd)]:{let _0x32b370=_0x5980ef;if(_0x32b370&&typeof _0x32b370==='object'){if(!('path'in _0x32b370)){const _0x256a73=_0x32b370[_0x54599f(0x2f5)]??_0x32b370[_0x54599f(0x2f2)]??_0x32b370[_0x54599f(0x253)]??_0x32b370[_0x54599f(0x240)]??_0x32b370[_0x54599f(0x294)];if(_0x256a73)_0x32b370={..._0x32b370,'path':_0x256a73};}_0x54599f(0x2ce)in _0x32b370&&!(_0x54599f(0x217)in _0x32b370)&&(_0x32b370={..._0x32b370,'instruction':_0x32b370[_0x54599f(0x2ce)]});if(!('code_edit'in _0x32b370)){const _0xa3c6a4=_0x32b370[_0x54599f(0x2d6)]??_0x32b370[_0x54599f(0x20b)]??_0x32b370[_0x54599f(0x228)]??_0x32b370[_0x54599f(0x291)];if(_0xa3c6a4)_0x32b370={..._0x32b370,'code_edit':_0xa3c6a4};}}const _0x349d38=MorphEditFileArgsSchema['safeParse'](_0x32b370);if(!_0x349d38[_0x54599f(0x26c)])throw new Error(_0x54599f(0x286)+_0x349d38[_0x54599f(0x2f4)]);const _0x46fe47=await validatePath(_0x349d38[_0x54599f(0x208)][_0x54599f(0x280)]);let _0x499044=null,_0x301025=!![],_0x9d21b7=null;try{_0x499044=await a0_0x5d80a6[_0x54599f(0x26f)](_0x46fe47,_0x54599f(0x2db)),logger[_0x54599f(0x233)](_0x54599f(0x2a6),_0x54599f(0x2e9),{'path':_0x46fe47,'size_bytes':_0x499044[_0x54599f(0x2bd)]});}catch(_0x3817ae){const _0x2330ca=_0x3817ae[_0x54599f(0x2d6)];_0x2330ca===_0x54599f(0x220)?(_0x301025=![],_0x499044='',logger[_0x54599f(0x233)](_0x54599f(0x2a6),_0x54599f(0x2e9),{'path':_0x46fe47,'exists':![]})):(_0x9d21b7=_0x54599f(0x1dc)+(_0x2330ca||_0x54599f(0x1fe))+_0x54599f(0x2a2)+(_0x3817ae instanceof Error?_0x3817ae[_0x54599f(0x271)]:String(_0x3817ae)),logger[_0x54599f(0x2f4)](_0x54599f(0x2a6),_0x54599f(0x24a),{'path':_0x46fe47,'error':_0x9d21b7}),logMcpStderr(_0x54599f(0x1e5)+_0x9d21b7));}let _0x575329;try{const _0x4bfa75=MORPH_API_KEY;if(!_0x4bfa75)throw new Error('MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.');const _0x2f9794=a0_0x2a77ef[_0x54599f(0x2fe)](_0x46fe47),_0x12bb71=a0_0x2a77ef[_0x54599f(0x27a)](_0x46fe47);logger['debug'](_0x54599f(0x2a6),'api_request_start',{'model':'morph-v3-fast','path':_0x349d38[_0x54599f(0x208)][_0x54599f(0x280)],'instruction_len':_0x349d38[_0x54599f(0x208)]['instruction'][_0x54599f(0x2bd)],'code_edit_len':_0x349d38[_0x54599f(0x208)][_0x54599f(0x300)][_0x54599f(0x2bd)],'original_code_len':_0x499044?.[_0x54599f(0x2bd)]??0x0,'dry_run':_0x349d38[_0x54599f(0x208)]['dryRun']});const _0x226854=Date['now'](),_0x3022b4=await executeEditFile({'target_filepath':_0x12bb71,'code_edit':_0x349d38['data']['code_edit'],'instruction':_0x349d38[_0x54599f(0x208)][_0x54599f(0x217)]},{'morphApiKey':_0x4bfa75,'morphApiUrl':MORPH_API_URL,'large':MORPH_LARGE_APPLY,'baseDir':_0x2f9794,'autoWrite':!_0x349d38[_0x54599f(0x208)][_0x54599f(0x2e5)],'generateUdiff':![],'debug':![]}),_0x1ebf9d=Date['now']()-_0x226854;_0x575329=_0x3022b4[_0x54599f(0x297)];if(!_0x3022b4[_0x54599f(0x26c)])throw new Error(_0x3022b4['error']||'Morph\x20FastApply\x20failed\x20without\x20error\x20message');const _0x515e5d=_0x3022b4[_0x54599f(0x27e)],_0x3e6e9b=_0x54599f(0x26d)+_0x515e5d['linesAdded']+',\x20removed\x20'+_0x515e5d['linesRemoved']+_0x54599f(0x2fc)+_0x515e5d[_0x54599f(0x1ef)];logger[_0x54599f(0x233)](_0x54599f(0x2a6),'tool_call_complete',{'tool':'edit_file','success':!![],'latency_ms':Date['now']()-_0xfdf9fd,'edit_latency_ms':_0x1ebf9d,'changes':{'added':_0x515e5d['linesAdded'],'removed':_0x515e5d['linesRemoved'],'modified':_0x515e5d['linesModified']},'completion_id':_0x575329});if(_0x349d38['data'][_0x54599f(0x2e5)])return{'content':[{'type':_0x54599f(0x21f),'text':'Morph\x20Edit\x20Preview'+(_0x301025?'':_0x54599f(0x27f))+':\x20'+_0x349d38[_0x54599f(0x208)][_0x54599f(0x217)]+_0x54599f(0x1d9)+_0x3e6e9b+_0x54599f(0x2f9)+_0x349d38[_0x54599f(0x208)][_0x54599f(0x280)]+'.'}]};return{'content':[{'type':_0x54599f(0x21f),'text':'Morph\x20Edit\x20'+(_0x301025?_0x54599f(0x309):_0x54599f(0x2e0))+':\x20'+_0x349d38[_0x54599f(0x208)]['instruction']+_0x54599f(0x1d9)+_0x3e6e9b+_0x54599f(0x2f9)+_0x349d38['data'][_0x54599f(0x280)]+'.'}]};}catch(_0x4cd6ae){const _0x4b913c=handleMorphAPIError(_0x4cd6ae);if(_0x4b913c)return logger[_0x54599f(0x2f4)](_0x54599f(0x2a6),_0x54599f(0x274),{'tool':_0x54599f(0x1d4),'error':'API\x20error\x20(auth/rate-limit)','latency_ms':Date[_0x54599f(0x264)]()-_0xfdf9fd}),_0x4b913c;const _0x18736c=_0x4cd6ae instanceof Error?_0x4cd6ae[_0x54599f(0x271)]:String(_0x4cd6ae);return logger[_0x54599f(0x2f4)](_0x54599f(0x2a6),_0x54599f(0x274),{'tool':'edit_file','error':_0x18736c,'path':_0x349d38[_0x54599f(0x208)][_0x54599f(0x280)],'validated_path':_0x46fe47,'latency_ms':Date[_0x54599f(0x264)]()-_0xfdf9fd,'stack':_0x4cd6ae instanceof Error?_0x4cd6ae[_0x54599f(0x250)]:undefined}),reportMorphError({'error_message':_0x18736c,'error_type':_0x4cd6ae instanceof Error?_0x4cd6ae['constructor'][_0x54599f(0x236)]:_0x54599f(0x221),'context':{'tool':'edit_file','completion_id':_0x575329,'file_path':_0x349d38[_0x54599f(0x208)]['path'],'validated_path':_0x46fe47,'instruction':_0x349d38[_0x54599f(0x208)][_0x54599f(0x217)],'model':MORPH_LARGE_APPLY?'morph-v3-large':_0x54599f(0x21d),'dry_run':_0x349d38[_0x54599f(0x208)][_0x54599f(0x2e5)],'file_exists':_0x301025,'file_read_error':_0x9d21b7,'file_readable':_0x499044!==null,'request_content':{'path':_0x349d38['data'][_0x54599f(0x280)],'code_edit':_0x349d38['data'][_0x54599f(0x300)],'instruction':_0x349d38[_0x54599f(0x208)][_0x54599f(0x217)],'original_code':_0x499044!==null?_0x499044[_0x54599f(0x2bd)]>0xc350?_0x499044[_0x54599f(0x2eb)](0x0,0xc350)+'\x0a...\x20(truncated,\x20total:\x20'+_0x499044['length']+_0x54599f(0x1f6):_0x499044:_0x54599f(0x24c)+(_0x9d21b7||_0x54599f(0x2a1))+']','original_code_length':_0x499044?.[_0x54599f(0x2bd)]??0x0,'model':MORPH_LARGE_APPLY?_0x54599f(0x1d1):_0x54599f(0x21d),'dry_run':_0x349d38[_0x54599f(0x208)][_0x54599f(0x2e5)]}},'stack_trace':_0x4cd6ae instanceof Error?_0x4cd6ae[_0x54599f(0x250)]:undefined,'source':_0x54599f(0x270)})[_0x54599f(0x263)](()=>{}),{'content':[{'type':_0x54599f(0x21f),'text':_0x54599f(0x2ae)+_0x18736c}],'isError':!![]};}}case TOOL_NAMES[_0x54599f(0x28f)]:{const _0x11cfee=WarpGrepArgsSchema[_0x54599f(0x2c3)](_0x5980ef);if(!_0x11cfee['success'])return{'content':[{'type':'text','text':_0x54599f(0x295)+_0x11cfee[_0x54599f(0x2f4)]}],'isError':!![]};const _0x13aa1d=_0x113e69=>{const _0xd82d36=_0x54599f,_0x3a8f95=[];for(const _0xf4164b of _0x113e69||[]){if(_0xf4164b[_0xd82d36(0x292)]==='assistant'&&Array['isArray'](_0xf4164b[_0xd82d36(0x1d8)]))for(const _0x31b523 of _0xf4164b['tool_calls']){try{const _0x355e5c=_0x31b523[_0xd82d36(0x22a)]?.[_0xd82d36(0x236)],_0x2b7233=JSON['parse'](_0x31b523['function']?.[_0xd82d36(0x25b)]||'{}');if(_0x355e5c===_0xd82d36(0x1f9))_0x3a8f95['push'](_0xd82d36(0x2b0)+_0x2b7233[_0xd82d36(0x226)]+'\x27\x20'+(_0x2b7233[_0xd82d36(0x280)]||'.'));else{if(_0x355e5c===_0xd82d36(0x2ac))_0x3a8f95[_0xd82d36(0x288)](_0xd82d36(0x2f8)+_0x2b7233[_0xd82d36(0x280)]);else{if(_0x355e5c==='list_directory')_0x3a8f95[_0xd82d36(0x288)]('list_directory\x20'+(_0x2b7233[_0xd82d36(0x1f3)]||'.'));else{if(_0x355e5c===_0xd82d36(0x1e9))_0x3a8f95['push'](_0xd82d36(0x23a)+_0x2b7233[_0xd82d36(0x226)]+'\x27\x20'+(_0x2b7233[_0xd82d36(0x280)]||'.'));else _0x355e5c===_0xd82d36(0x30a)&&_0x3a8f95[_0xd82d36(0x288)](_0xd82d36(0x30a));}}}}catch{}}}return _0x3a8f95;},_0x503346=_0x58eb02=>{const _0xde4561=_0x54599f,_0x257604=[];if(!_0x58eb02||!Array[_0xde4561(0x275)](_0x58eb02))return _0x257604;const _0x5ec8c7=[{'pattern':/\[FILE NOT FOUND\]/,'error_type':_0xde4561(0x1fb),'tool':'read'},{'pattern':/\[PATH ERROR\]/,'error_type':'PathError','tool':'read'},{'pattern':/\[READ ERROR\]/,'error_type':'ReadError','tool':_0xde4561(0x2ac)},{'pattern':/\[UNREADABLE FILE\]/,'error_type':'BinaryFile','tool':_0xde4561(0x2ac)},{'pattern':/\[RIPGREP ERROR\]/,'error_type':_0xde4561(0x1f0),'tool':_0xde4561(0x304)},{'pattern':/\[RIPGREP NOT AVAILABLE\]/,'error_type':_0xde4561(0x20a),'tool':_0xde4561(0x304)},{'pattern':/\[BINARY FILE\]/,'error_type':_0xde4561(0x22f),'tool':_0xde4561(0x2ac)},{'pattern':/\[SYMLINK\]/,'error_type':_0xde4561(0x1e4),'tool':_0xde4561(0x2ac)},{'pattern':/not a text file/,'error_type':_0xde4561(0x22f),'tool':_0xde4561(0x2ac)},{'pattern':/symbolic link/,'error_type':_0xde4561(0x1e4),'tool':_0xde4561(0x2ac)},{'pattern':/Error reading file:/,'error_type':_0xde4561(0x262),'tool':_0xde4561(0x2ac)},{'pattern':/status="error"/,'error_type':_0xde4561(0x227),'tool':_0xde4561(0x1fe)}];let _0xc037c4=0x0;for(const _0x56a3b6 of _0x58eb02){_0x56a3b6[_0xde4561(0x292)]===_0xde4561(0x2f3)&&Array[_0xde4561(0x275)](_0x56a3b6[_0xde4561(0x1d8)])&&_0xc037c4++;const _0x5775f1=_0x56a3b6['content'];if((_0x56a3b6[_0xde4561(0x292)]===_0xde4561(0x1e6)||_0x56a3b6[_0xde4561(0x292)]===_0xde4561(0x2b4))&&_0x5775f1&&typeof _0x5775f1===_0xde4561(0x2a8))for(const {pattern:_0x459331,error_type:_0x4c89b3,tool:_0x2fa292}of _0x5ec8c7){const _0x24ac6f=_0x5775f1[_0xde4561(0x248)](new RegExp(_0x459331[_0xde4561(0x254)],'g'));if(_0x24ac6f)for(const _0x4e7562 of _0x24ac6f){const _0x37a560=_0x5775f1[_0xde4561(0x2ad)](_0x4e7562),_0x14f07e=_0x5775f1[_0xde4561(0x2eb)](_0x37a560,Math[_0xde4561(0x273)](_0x37a560+0xc8,_0x5775f1[_0xde4561(0x2bd)]));_0x257604[_0xde4561(0x288)]({'tool':_0x2fa292,'error_type':_0x4c89b3,'error_message':_0x14f07e['split']('\x0a')[0x0],'turn':_0xc037c4});}}}return _0x257604;};try{const _0x5e1dde=a0_0x2a77ef['resolve'](_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)]),_0x3a64d7=_0x11cfee[_0x54599f(0x208)][_0x54599f(0x24b)],_0x3a29af=_0x3a64d7===_0x54599f(0x2d1)?{'allowNames':[_0x54599f(0x2d1)]}:undefined,_0x10f73f=new LocalRipgrepProvider(_0x5e1dde,undefined,_0x3a29af);logger['debug']('MCP','provider_created',{'type':'LocalRipgrepProvider','repo_root':_0x5e1dde,'search_type':_0x3a64d7||_0x54599f(0x23f)}),logger[_0x54599f(0x233)](_0x54599f(0x2a6),'warp_grep_start',{'query':_0x11cfee[_0x54599f(0x208)]['search_string'],'repo_root':_0x5e1dde,'timeout_ms':MORPH_WARP_GREP_TIMEOUT});const _0x51ee09=Date[_0x54599f(0x264)](),_0x55d2b1=await runWarpGrep({'searchTerm':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x2e7)],'repoRoot':_0x5e1dde,'morphApiKey':MORPH_API_KEY,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT,'provider':_0x10f73f,'search_type':_0x3a64d7}),_0xb3f290=Date[_0x54599f(0x264)]()-_0x51ee09,_0x58f27c=_0x55d2b1[_0x54599f(0x30a)]?.[_0x54599f(0x223)]?.[_0x54599f(0x28c)]?.[_0x54599f(0x2bd)]??0x0;logger['debug'](_0x54599f(0x2a6),_0x54599f(0x2c7),{'termination':_0x55d2b1[_0x54599f(0x299)],'turns':_0x55d2b1[_0x54599f(0x2b1)]?.['turns']??0x0,'files_found':_0x58f27c,'latency_ms':_0xb3f290});const _0x40d664=_0x503346(_0x55d2b1['messages']);_0x40d664[_0x54599f(0x2bd)]>0x0&&reportMorphError({'error_message':_0x54599f(0x25a)+_0x40d664['length']+'\x20error(s)','error_type':_0x54599f(0x2d4),'level':_0x54599f(0x1f8),'tool':_0x54599f(0x205),'context':{'repo_path':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)],'query':_0x11cfee[_0x54599f(0x208)]['search_string'],'model':'morph-warp-grep-v2.1','termination_reason':_0x55d2b1[_0x54599f(0x299)],'sub_tool_errors':_0x40d664,'timings':_0x55d2b1[_0x54599f(0x2b1)],'tool_calls':_0x13aa1d(_0x55d2b1['messages']),'messages':_0x55d2b1[_0x54599f(0x1e3)]?.[_0x54599f(0x296)](_0x1a94d9=>({'role':_0x1a94d9[_0x54599f(0x292)],'content':_0x1a94d9[_0x54599f(0x228)],..._0x1a94d9[_0x54599f(0x1d8)]?{'tool_calls':_0x1a94d9[_0x54599f(0x1d8)][_0x54599f(0x2bd)]}:{},..._0x1a94d9[_0x54599f(0x219)]?{'tool_call_id':_0x1a94d9[_0x54599f(0x219)]}:{}}))},'source':_0x54599f(0x270)})['catch'](()=>{});let _0x1a9189='';if(_0x55d2b1[_0x54599f(0x299)]===_0x54599f(0x2b2)&&_0x55d2b1[_0x54599f(0x30a)]?.[_0x54599f(0x223)]?.[_0x54599f(0x28c)]){const _0x148533=_0x55d2b1[_0x54599f(0x30a)][_0x54599f(0x223)][_0x54599f(0x28c)];if(_0x148533[_0x54599f(0x2bd)]===0x0)return _0x1a9189=_0x55d2b1[_0x54599f(0x30a)][_0x54599f(0x2cb)]||_0x54599f(0x1e0),{'content':[{'type':_0x54599f(0x21f),'text':_0x1a9189}]};const _0x4a7e2e=[],_0xde2eb6=[_0x54599f(0x301)];for(const _0x35fae5 of _0x55d2b1[_0x54599f(0x1e3)]){if(_0x35fae5['role']===_0x54599f(0x2f3)&&Array[_0x54599f(0x275)](_0x35fae5[_0x54599f(0x1d8)]))for(const _0x4f2bf9 of _0x35fae5[_0x54599f(0x1d8)]){try{const _0x14a838=_0x4f2bf9[_0x54599f(0x22a)]?.[_0x54599f(0x236)],_0x4ce728=JSON['parse'](_0x4f2bf9[_0x54599f(0x22a)]?.[_0x54599f(0x25b)]||'{}');if(_0x14a838===_0x54599f(0x1f9))_0xde2eb6[_0x54599f(0x288)](_0x54599f(0x202)+_0x4ce728['pattern']+_0x54599f(0x305)+(_0x4ce728[_0x54599f(0x280)]||'.')+'`');else{if(_0x14a838===_0x54599f(0x2ac))_0xde2eb6['push'](_0x54599f(0x2dd)+_0x4ce728[_0x54599f(0x280)]+'`');else{if(_0x14a838===_0x54599f(0x289))_0xde2eb6[_0x54599f(0x288)]('-\x20Listed\x20directory\x20`'+(_0x4ce728[_0x54599f(0x1f3)]||'.')+'`');else _0x14a838===_0x54599f(0x1e9)&&_0xde2eb6[_0x54599f(0x288)](_0x54599f(0x29c)+_0x4ce728['pattern']+_0x54599f(0x249)+(_0x4ce728[_0x54599f(0x280)]||'.')+'`');}}}catch{}}}_0x4a7e2e['push'](_0xde2eb6[_0x54599f(0x283)]('\x0a'));const _0x15d250=['',_0x54599f(0x2da)];for(const _0x3c2d63 of _0x148533){if(_0x3c2d63[_0x54599f(0x267)]==='*')_0x15d250[_0x54599f(0x288)]('-\x20'+_0x3c2d63['path']+':*');else{if(Array['isArray'](_0x3c2d63[_0x54599f(0x267)])){const _0x4c58d8=_0x3c2d63[_0x54599f(0x267)][_0x54599f(0x296)](([_0x172379,_0x43c462])=>{if(_0x172379===_0x43c462)return''+_0x172379;return _0x172379+'-'+_0x43c462;});_0x15d250[_0x54599f(0x288)]('-\x20'+_0x3c2d63[_0x54599f(0x280)]+':'+_0x4c58d8[_0x54599f(0x283)](','));}else _0x15d250[_0x54599f(0x288)]('-\x20'+_0x3c2d63[_0x54599f(0x280)]+':*');}}_0x15d250[_0x54599f(0x288)](''),_0x4a7e2e['push'](_0x15d250[_0x54599f(0x283)]('\x0a')),_0x4a7e2e['push']('Here\x20is\x20the\x20content\x20of\x20files:\x0a');const _0x54929c=[],_0x2d3e94=[];for(const _0x45a559 of _0x148533){let _0x4bbaeb=a0_0x2a77ef[_0x54599f(0x2e4)](_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)],_0x45a559[_0x54599f(0x280)]),_0x1b5c1e=null,_0x2419c8=null;try{_0x1b5c1e=await a0_0x5d80a6[_0x54599f(0x26f)](_0x4bbaeb,{'encoding':_0x54599f(0x2db)});}catch(_0x4fb02f){const _0x42b575=fixPathRepetition(_0x4bbaeb);if(_0x42b575)try{_0x1b5c1e=await a0_0x5d80a6[_0x54599f(0x26f)](_0x42b575,{'encoding':_0x54599f(0x2db)}),_0x4bbaeb=_0x42b575;}catch{_0x2419c8=_0x4fb02f instanceof Error?_0x4fb02f:new Error(String(_0x4fb02f));}else _0x2419c8=_0x4fb02f instanceof Error?_0x4fb02f:new Error(String(_0x4fb02f));}if(_0x1b5c1e!==null){const _0x17c323=_0x1b5c1e[_0x54599f(0x2d8)](/\r?\n/),_0x475634=[];if(_0x45a559[_0x54599f(0x267)]==='*'||!Array['isArray'](_0x45a559[_0x54599f(0x267)]))for(let _0x3543a9=0x1;_0x3543a9<=_0x17c323[_0x54599f(0x2bd)];_0x3543a9++){const _0x42496a=_0x17c323[_0x3543a9-0x1];_0x475634[_0x54599f(0x288)](_0x3543a9+'|\x20'+_0x42496a);}else for(const [_0x3573c3,_0x5afb6f]of _0x45a559[_0x54599f(0x267)]){_0x475634[_0x54599f(0x2bd)]>0x0&&_0x475634[_0x54599f(0x288)]('');for(let _0x27cf6b=_0x3573c3;_0x27cf6b<=_0x5afb6f&&_0x27cf6b<=_0x17c323[_0x54599f(0x2bd)];_0x27cf6b++){const _0x263fd5=_0x17c323[_0x27cf6b-0x1];_0x475634[_0x54599f(0x288)](_0x27cf6b+'|\x20'+_0x263fd5);}}_0x2d3e94[_0x54599f(0x288)]({'path':_0x45a559['path'],'content':_0x475634[_0x54599f(0x283)]('\x0a')});}else _0x54929c[_0x54599f(0x288)](_0x54599f(0x22c)+_0x45a559['path']+_0x54599f(0x2ec)+(_0x2419c8?.[_0x54599f(0x271)]||'Unknown\x20error')+_0x54599f(0x2e8));}try{const _0x4eb1bd=await compactFileContexts(_0x2d3e94,_0x11cfee['data'][_0x54599f(0x2e7)],MORPH_API_KEY,MORPH_API_URL);for(const _0x15b850 of _0x4eb1bd){_0x54929c[_0x54599f(0x288)]('<file\x20path=\x22'+_0x15b850['path']+_0x54599f(0x26b)+_0x15b850[_0x54599f(0x228)]+_0x54599f(0x2e8));}}catch(_0x1086b9){logger[_0x54599f(0x1f8)]('MCP',_0x54599f(0x2fd),{'error':_0x1086b9 instanceof Error?_0x1086b9['message']:String(_0x1086b9),'files_count':_0x2d3e94[_0x54599f(0x2bd)]});for(const _0x488348 of _0x2d3e94){_0x54929c[_0x54599f(0x288)]('<file\x20path=\x22'+_0x488348['path']+'\x22>\x0a'+_0x488348[_0x54599f(0x228)]+_0x54599f(0x2e8));}}_0x4a7e2e[_0x54599f(0x288)](_0x54929c['join']('\x0a\x0a')),_0x1a9189=_0x4a7e2e[_0x54599f(0x283)]('\x0a');const _0x418d95=_0x55d2b1[_0x54599f(0x1ea)]?.['filter'](_0x34efbb=>_0x34efbb['message']?.['startsWith'](_0x54599f(0x261)))||[];if(_0x418d95['length']>0x0){const _0x335271=_0x418d95[_0x54599f(0x296)](_0x4cdba0=>_0x4cdba0['message'])['join'](';\x20');reportMorphError({'error_message':_0x335271,'error_type':_0x54599f(0x211),'context':{'tool':_0x54599f(0x205),'repo_path':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)],'query':_0x11cfee['data'][_0x54599f(0x2e7)],'model':_0x54599f(0x259),'termination_reason':_0x54599f(0x251),'error_count':_0x418d95[_0x54599f(0x2bd)],'is_timeout':![],'timings':_0x55d2b1[_0x54599f(0x2b1)],'files_attempted':_0x148533[_0x54599f(0x296)](_0x5bfc92=>({'path':_0x5bfc92[_0x54599f(0x280)],'lines':_0x5bfc92['lines']})),'tool_calls':_0x13aa1d(_0x55d2b1['messages']),'messages':_0x55d2b1['messages']?.[_0x54599f(0x296)](_0x4f710e=>({'role':_0x4f710e[_0x54599f(0x292)],'content':_0x4f710e[_0x54599f(0x228)],..._0x4f710e[_0x54599f(0x1d8)]?{'tool_calls':_0x4f710e[_0x54599f(0x1d8)][_0x54599f(0x2bd)]}:{},..._0x4f710e[_0x54599f(0x219)]?{'tool_call_id':_0x4f710e[_0x54599f(0x219)]}:{}})),'request_content':{'query':_0x11cfee[_0x54599f(0x208)]['search_string'],'repo_path':_0x11cfee[_0x54599f(0x208)]['repo_path'],'repoRoot':a0_0x2a77ef[_0x54599f(0x2e4)](_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)]),'model':_0x54599f(0x259)}},'source':_0x54599f(0x270)})['catch'](()=>{});}}else{if(_0x55d2b1[_0x54599f(0x299)]===_0x54599f(0x215)&&_0x55d2b1[_0x54599f(0x1ea)][_0x54599f(0x2bd)]>0x0){const _0x4a7824=_0x55d2b1['errors']['map'](_0x375b65=>_0x375b65['message'])[_0x54599f(0x283)](';\x20');_0x1a9189='Error:\x20'+_0x4a7824;const _0x24d498=_0x4a7824[_0x54599f(0x214)]()[_0x54599f(0x284)](_0x54599f(0x1ff))||_0x4a7824[_0x54599f(0x214)]()[_0x54599f(0x284)](_0x54599f(0x2b6))||_0x4a7824[_0x54599f(0x214)]()[_0x54599f(0x284)]('etimedout'),_0x31d85d=_0x55d2b1[_0x54599f(0x30a)]?.[_0x54599f(0x223)]?.['files'],_0x38d616=_0x55d2b1[_0x54599f(0x1ea)][0x0];reportMorphError({'error_message':_0x4a7824,'error_type':_0x24d498?_0x54599f(0x1fa):_0x38d616?.[_0x54599f(0x2a7)]?.[_0x54599f(0x236)]||'WarpGrepError','context':{'tool':'codebase_search','repo_path':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)],'query':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x2e7)],'model':_0x54599f(0x259),'termination_reason':_0x55d2b1[_0x54599f(0x299)],'error_count':_0x55d2b1[_0x54599f(0x1ea)]['length'],'is_timeout':_0x24d498,'timings':_0x55d2b1['timings'],'files_attempted':_0x31d85d?.['map'](_0x38b4e4=>({'path':_0x38b4e4[_0x54599f(0x280)],'lines':_0x38b4e4[_0x54599f(0x267)]})),'tool_calls':_0x13aa1d(_0x55d2b1[_0x54599f(0x1e3)]),'messages':_0x55d2b1[_0x54599f(0x1e3)]?.[_0x54599f(0x296)](_0x374361=>({'role':_0x374361[_0x54599f(0x292)],'content':_0x374361[_0x54599f(0x228)],..._0x374361['tool_calls']?{'tool_calls':_0x374361[_0x54599f(0x1d8)][_0x54599f(0x2bd)]}:{},..._0x374361[_0x54599f(0x219)]?{'tool_call_id':_0x374361[_0x54599f(0x219)]}:{}})),'request_content':{'query':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x2e7)],'repo_path':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)],'repoRoot':a0_0x2a77ef[_0x54599f(0x2e4)](_0x11cfee['data']['repo_path']),'model':_0x54599f(0x259)}},'stack_trace':_0x38d616?.[_0x54599f(0x250)]||undefined,'source':_0x54599f(0x270)})[_0x54599f(0x263)](()=>{});}else _0x1a9189=_0x54599f(0x27d);}return{'content':[{'type':_0x54599f(0x21f),'text':_0x1a9189}]};}catch(_0x233b4e){const _0x5e2a47=handleMorphAPIError(_0x233b4e);if(_0x5e2a47)return logger[_0x54599f(0x2f4)](_0x54599f(0x2a6),_0x54599f(0x274),{'tool':_0x54599f(0x205),'error':_0x54599f(0x235),'latency_ms':Date['now']()-_0xfdf9fd}),_0x5e2a47;const _0x2a4c39=_0x233b4e instanceof Error?_0x233b4e[_0x54599f(0x271)]:String(_0x233b4e);logger[_0x54599f(0x2f4)](_0x54599f(0x2a6),_0x54599f(0x274),{'tool':_0x54599f(0x205),'error':_0x2a4c39,'repo_path':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)],'query':_0x11cfee[_0x54599f(0x208)]['search_string'],'latency_ms':Date['now']()-_0xfdf9fd});const _0x2db249=_0x2a4c39[_0x54599f(0x214)]()[_0x54599f(0x284)](_0x54599f(0x1ff))||_0x2a4c39[_0x54599f(0x214)]()[_0x54599f(0x284)]('timed\x20out')||_0x2a4c39['toLowerCase']()[_0x54599f(0x284)]('etimedout')||_0x233b4e instanceof Error&&_0x233b4e[_0x54599f(0x236)]===_0x54599f(0x1fa);return reportMorphError({'error_message':_0x2a4c39,'error_type':_0x2db249?_0x54599f(0x1fa):_0x233b4e instanceof Error?_0x233b4e[_0x54599f(0x2a7)][_0x54599f(0x236)]:'UnknownError','context':{'tool':_0x54599f(0x205),'repo_path':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)],'query':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x2e7)],'model':_0x54599f(0x259),'is_timeout':_0x2db249,'exception_phase':_0x54599f(0x2e1),'request_content':{'query':_0x11cfee[_0x54599f(0x208)]['search_string'],'repo_path':_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)],'repoRoot':a0_0x2a77ef[_0x54599f(0x2e4)](_0x11cfee[_0x54599f(0x208)][_0x54599f(0x1d7)]),'model':_0x54599f(0x259)}},'stack_trace':_0x233b4e instanceof Error?_0x233b4e[_0x54599f(0x250)]:undefined,'source':_0x54599f(0x270)})[_0x54599f(0x263)](()=>{}),{'content':[{'type':_0x54599f(0x21f),'text':_0x54599f(0x298)+_0x2a4c39}],'isError':![]};}}case TOOL_NAMES[_0x54599f(0x245)]:{const _0x423efb=WarpGrepGitHubArgsSchema[_0x54599f(0x2c3)](_0x5980ef);if(!_0x423efb[_0x54599f(0x26c)])return{'content':[{'type':'text','text':_0x54599f(0x295)+_0x423efb[_0x54599f(0x2f4)]}],'isError':!![]};const _0x14598e=_0x423efb[_0x54599f(0x208)]['github_url']||_0x423efb[_0x54599f(0x208)][_0x54599f(0x1e8)];if(!_0x14598e)return{'content':[{'type':'text','text':'Please\x20provide\x20github\x20search\x20url\x20or\x20owner/repo\x20id'}],'isError':!![]};const _0x47c968=MORPH_API_KEY;if(!_0x47c968)throw new Error('MORPH_API_KEY\x20environment\x20variable\x20must\x20be\x20set\x20in\x20MCP\x20config.\x20Check\x20your\x20global\x20MCP\x20configuration.');const _0x1018b5=Date[_0x54599f(0x264)]();logger[_0x54599f(0x233)]('MCP','github_search_start',{'identifier':_0x14598e,'query':_0x423efb[_0x54599f(0x208)]['search_string'],'branch':_0x423efb['data'][_0x54599f(0x2a5)]});try{const _0x1ed2f6=new WarpGrepClient({'morphApiKey':_0x47c968,'morphApiUrl':MORPH_API_URL,'timeout':MORPH_WARP_GREP_TIMEOUT}),_0x4a7917=await _0x1ed2f6[_0x54599f(0x234)]({'searchTerm':_0x423efb[_0x54599f(0x208)]['search_string'],'github':_0x14598e,'branch':_0x423efb['data'][_0x54599f(0x2a5)]}),_0x23f9df=Date[_0x54599f(0x264)]()-_0x1018b5;logMcpStderr(_0x54599f(0x1e7)+_0x23f9df+_0x54599f(0x2d2)+_0x4a7917[_0x54599f(0x26c)]);const _0x10b0db=formatResult(_0x4a7917);return{'content':[{'type':_0x54599f(0x21f),'text':_0x10b0db}]};}catch(_0x1ae2f4){const _0x3d8ada=handleMorphAPIError(_0x1ae2f4);if(_0x3d8ada)return _0x3d8ada;const _0x13e5c7=Date[_0x54599f(0x264)]()-_0x1018b5,_0x367467=_0x1ae2f4 instanceof Error?_0x1ae2f4[_0x54599f(0x271)]:String(_0x1ae2f4);return logMcpStderr('[github_codebase_search]\x20Failed\x20in\x20'+_0x13e5c7+_0x54599f(0x1d3),_0x367467),reportMorphError({'error_message':_0x367467,'error_type':_0x1ae2f4 instanceof Error?_0x1ae2f4['constructor']['name']:_0x54599f(0x221),'context':{'tool':'github_codebase_search','github_url':_0x14598e,'search_string':_0x423efb['data']['search_string'],'branch':_0x423efb['data'][_0x54599f(0x2a5)]},'stack_trace':_0x1ae2f4 instanceof Error?_0x1ae2f4['stack']:undefined,'source':_0x54599f(0x270),'tool':_0x54599f(0x1f1),'latency_ms':_0x13e5c7})[_0x54599f(0x263)](()=>{}),{'content':[{'type':_0x54599f(0x21f),'text':_0x54599f(0x20e)+_0x367467}],'isError':![]};}}case TOOL_NAMES[_0x54599f(0x20d)]:{const _0x41a05f=ListReflexesArgsSchema['safeParse'](_0x5980ef??{});if(!_0x41a05f[_0x54599f(0x26c)])return{'content':[{'type':_0x54599f(0x21f),'text':'Invalid\x20arguments:\x20'+_0x41a05f['error']}],'isError':!![]};return runReflexTool(TOOL_NAMES['LIST_REFLEXES'],()=>runListReflexes(getReflexApi()));}case TOOL_NAMES[_0x54599f(0x222)]:{const _0x5b21e3=ReflexSummaryArgsSchema[_0x54599f(0x2c3)](_0x5980ef??{});if(!_0x5b21e3[_0x54599f(0x26c)])return{'content':[{'type':'text','text':_0x54599f(0x295)+_0x5b21e3[_0x54599f(0x2f4)]}],'isError':!![]};return runReflexTool(TOOL_NAMES[_0x54599f(0x222)],()=>runReflexSummary(getReflexApi(),_0x5b21e3['data']));}case TOOL_NAMES[_0x54599f(0x29b)]:{const _0x1e5b01=GetReflexTracesArgsSchema[_0x54599f(0x2c3)](_0x5980ef??{});if(!_0x1e5b01['success'])return{'content':[{'type':_0x54599f(0x21f),'text':_0x54599f(0x295)+_0x1e5b01[_0x54599f(0x2f4)]}],'isError':!![]};return runReflexTool(TOOL_NAMES[_0x54599f(0x29b)],()=>runGetReflexTraces(getReflexApi(),_0x1e5b01[_0x54599f(0x208)]));}default:throw new Error(_0x54599f(0x25e)+_0x336537);}}catch(_0x2aa5de){const _0x227d79=_0x2aa5de instanceof Error?_0x2aa5de[_0x54599f(0x271)]:String(_0x2aa5de);return reportMorphError({'error_message':_0x227d79,'error_type':_0x2aa5de instanceof Error?_0x2aa5de[_0x54599f(0x2a7)][_0x54599f(0x236)]:_0x54599f(0x221),'context':{'tool':_0x336537,'arguments':_0x5980ef?JSON[_0x54599f(0x2a3)](_0x5980ef)['substring'](0x0,0x1f4):undefined,'mcp_server_version':_0x54599f(0x2b9)},'stack_trace':_0x2aa5de instanceof Error?_0x2aa5de[_0x54599f(0x250)]:undefined,'source':_0x54599f(0x270)})[_0x54599f(0x263)](()=>{}),{'content':[{'type':_0x54599f(0x21f),'text':_0x54599f(0x201)+_0x227d79}],'isError':!![]};}});async function updateAllowedDirectoriesFromRoots(_0x26db5f){const _0x1c7478=a0_0x1bd0c4,_0x14b4fd=await getValidRootDirectories(_0x26db5f);if(_0x14b4fd['length']>0x0)allowedDirectories=[..._0x14b4fd],logMcpStderr('Updated\x20allowed\x20directories\x20from\x20MCP\x20roots:\x20'+_0x14b4fd['length']+_0x1c7478(0x285));else{logMcpStderr(_0x1c7478(0x1eb));if(ENABLE_WORKSPACE_MODE)try{const _0x320a18=await detectWorkspaceRoot(WORKSPACE_ROOT);_0x320a18&&(allowedDirectories=[_0x320a18],logMcpStderr('Fallback:\x20Using\x20workspace\x20root\x20'+_0x320a18));}catch(_0xa0e892){logMcpStderr(_0x1c7478(0x2f7)+_0xa0e892);}}}server[a0_0x1bd0c4(0x2a4)](RootsListChangedNotificationSchema,async()=>{const _0x4d8fbf=a0_0x1bd0c4;try{const _0x495315=await server['listRoots']();_0x495315&&_0x4d8fbf(0x26e)in _0x495315&&await updateAllowedDirectoriesFromRoots(_0x495315[_0x4d8fbf(0x26e)]);}catch(_0xfe5d37){logMcpStderr(_0x4d8fbf(0x1d2),_0xfe5d37 instanceof Error?_0xfe5d37[_0x4d8fbf(0x271)]:String(_0xfe5d37));}}),server[a0_0x1bd0c4(0x278)]=async()=>{const _0x45f510=a0_0x1bd0c4,_0x31b59d=server[_0x45f510(0x2d0)]();if(_0x31b59d?.[_0x45f510(0x26e)])try{const _0x250465=await server[_0x45f510(0x26a)]();_0x250465&&_0x45f510(0x26e)in _0x250465?await updateAllowedDirectoriesFromRoots(_0x250465[_0x45f510(0x26e)]):logMcpStderr(_0x45f510(0x206));}catch(_0x319138){logMcpStderr(_0x45f510(0x218),_0x319138 instanceof Error?_0x319138[_0x45f510(0x271)]:String(_0x319138));}else{if(allowedDirectories[_0x45f510(0x2bd)]>0x0)logMcpStderr(_0x45f510(0x2dc),allowedDirectories);else{if(ENABLE_WORKSPACE_MODE)logMcpStderr(_0x45f510(0x24d));else throw new Error(_0x45f510(0x27c));}}};async function runServer(){const _0x3d1c85=a0_0x1bd0c4,_0x381e8f=new StdioServerTransport();await server[_0x3d1c85(0x2cd)](_0x381e8f),logMcpStderr(_0x3d1c85(0x203)),allowedDirectories[_0x3d1c85(0x2bd)]===0x0&&logMcpStderr(_0x3d1c85(0x255));}runServer()[a0_0x1bd0c4(0x263)](_0x2e2353=>{const _0x30d03a=a0_0x1bd0c4;logMcpStderr(_0x30d03a(0x1d5),_0x2e2353),process[_0x30d03a(0x25c)](0x1);});
|
package/dist/log-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
function a1_0x3b1e(_0x588b7c,_0x86cfa9){_0x588b7c=_0x588b7c-0x1e7;var _0xc3a7d=a1_0xc3a7();var _0x3b1e9d=_0xc3a7d[_0x588b7c];return _0x3b1e9d;}var a1_0x564578=a1_0x3b1e;function a1_0xc3a7(){var _0x41b700=['1622488UWQRNa','darwin','info','9498kwlEYr','[os=','1081584UzDFwE','MCP','win32','linux','1TSaRwv','204648IhPzjP','length','695CFCglc','2472147fFkOnT','Unknown','3thIfyN','669163NaFYDE','10xQbFgL','macOS','map','platform','360964bPMeXu'];a1_0xc3a7=function(){return _0x41b700;};return a1_0xc3a7();}(function(_0x5cfac3,_0x447796){var _0x178acf=a1_0x3b1e,_0x5ecd5d=_0x5cfac3();while(!![]){try{var _0x118814=parseInt(_0x178acf(0x1ee))/0x1*(parseInt(_0x178acf(0x1ef))/0x2)+parseInt(_0x178acf(0x1f4))/0x3*(parseInt(_0x178acf(0x1fa))/0x4)+parseInt(_0x178acf(0x1f1))/0x5*(-parseInt(_0x178acf(0x1e8))/0x6)+parseInt(_0x178acf(0x1ea))/0x7+-parseInt(_0x178acf(0x1fb))/0x8+parseInt(_0x178acf(0x1f2))/0x9+-parseInt(_0x178acf(0x1f6))/0xa*(parseInt(_0x178acf(0x1f5))/0xb);if(_0x118814===_0x447796)break;else _0x5ecd5d['push'](_0x5ecd5d['shift']());}catch(_0x1f8f2e){_0x5ecd5d['push'](_0x5ecd5d['shift']());}}}(a1_0xc3a7,0x21b5f));import a1_0x49e0e7 from'os';import{logger}from'./logger.js';export function getOperatingSystemType(_0x3e40e8=a1_0x49e0e7['platform']()){var _0x5acd6b=a1_0x3b1e;switch(_0x3e40e8){case _0x5acd6b(0x1fc):return _0x5acd6b(0x1f7);case _0x5acd6b(0x1ec):return'Windows';case _0x5acd6b(0x1ed):return'Linux';default:return _0x5acd6b(0x1f3);}}export function formatMcpLogMessage(_0x50e566,_0x4fdc06=a1_0x49e0e7[a1_0x564578(0x1f9)]()){var _0xacbbc3=a1_0x564578;return _0xacbbc3(0x1e9)+getOperatingSystemType(_0x4fdc06)+']\x20'+_0x50e566;}export function logMcpStderr(_0x101153,..._0x532fa6){var _0x44f76f=a1_0x564578;console['error'](formatMcpLogMessage(_0x101153),..._0x532fa6),logger[_0x44f76f(0x1e7)](_0x44f76f(0x1eb),_0x101153,_0x532fa6[_0x44f76f(0x1f0)]?{'args':_0x532fa6[_0x44f76f(0x1f8)](_0x4f4d30=>String(_0x4f4d30))}:undefined);}
|
package/dist/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a2_0x51a6(){const _0x2474e4=['1978346yCRyCj','22601650PiZNZI','env','_log','21xAygRb','41514OeoBAS','write',']\x20[','info','warn','stringify','612khUDSz','7465xSnqmn','enable','toUpperCase','8AQKtzu','debug','error','toISOString','isEnabled','MORPH_LOG_FILE','1051746InatFN','MORPH_DEBUG','fileStream','8299854OjQqSP','2484915TgZXfy','enabled'];a2_0x51a6=function(){return _0x2474e4;};return a2_0x51a6();}const a2_0x46c7fe=a2_0x231a;(function(_0xa4c17a,_0x20563c){const _0xd552a=a2_0x231a,_0x1613e9=_0xa4c17a();while(!![]){try{const _0x2bcd7e=-parseInt(_0xd552a(0x192))/0x1+-parseInt(_0xd552a(0x18d))/0x2+-parseInt(_0xd552a(0x18b))/0x3+-parseInt(_0xd552a(0x198))/0x4*(parseInt(_0xd552a(0x199))/0x5)+-parseInt(_0xd552a(0x1a2))/0x6*(parseInt(_0xd552a(0x191))/0x7)+-parseInt(_0xd552a(0x19c))/0x8*(-parseInt(_0xd552a(0x18a))/0x9)+parseInt(_0xd552a(0x18e))/0xa;if(_0x2bcd7e===_0x20563c)break;else _0x1613e9['push'](_0x1613e9['shift']());}catch(_0xbe3cac){_0x1613e9['push'](_0x1613e9['shift']());}}}(a2_0x51a6,0x8aef5));import{createWriteStream}from'fs';function a2_0x231a(_0x58202f,_0xba75e0){_0x58202f=_0x58202f-0x188;const _0x51a601=a2_0x51a6();let _0x231a8b=_0x51a601[_0x58202f];return _0x231a8b;}class MorphLogger{['enabled'];['fileStream'];constructor(){const _0x47ac76=a2_0x231a;this[_0x47ac76(0x18c)]=process[_0x47ac76(0x18f)][_0x47ac76(0x188)]==='1'||!!process[_0x47ac76(0x18f)][_0x47ac76(0x1a1)];const _0x413bd5=process[_0x47ac76(0x18f)]['MORPH_LOG_FILE'];this['fileStream']=_0x413bd5?createWriteStream(_0x413bd5,{'flags':'a'}):null;}[a2_0x46c7fe(0x19d)](_0x4d7041,_0x2abb6d,_0x589295){this['_log']('debug',_0x4d7041,_0x2abb6d,_0x589295);}[a2_0x46c7fe(0x195)](_0x212bed,_0x1232ea,_0x197af0){const _0x30b1b0=a2_0x46c7fe;this[_0x30b1b0(0x190)](_0x30b1b0(0x195),_0x212bed,_0x1232ea,_0x197af0);}[a2_0x46c7fe(0x196)](_0x2fc629,_0x46fdb8,_0x1af55e){const _0x5b308e=a2_0x46c7fe;this['_log'](_0x5b308e(0x196),_0x2fc629,_0x46fdb8,_0x1af55e);}['error'](_0x260416,_0x107786,_0x163d2d){const _0x1bfe18=a2_0x46c7fe;this['_log'](_0x1bfe18(0x19e),_0x260416,_0x107786,_0x163d2d);}[a2_0x46c7fe(0x19a)](){const _0x43bb6a=a2_0x46c7fe;this[_0x43bb6a(0x18c)]=!![];}get[a2_0x46c7fe(0x1a0)](){const _0x1b0015=a2_0x46c7fe;return this[_0x1b0015(0x18c)];}[a2_0x46c7fe(0x190)](_0x4cbe06,_0x33f286,_0x17f024,_0x4b9710){const _0x287da0=a2_0x46c7fe;if(_0x4cbe06!==_0x287da0(0x19e)&&!this[_0x287da0(0x18c)])return;const _0xae44b6=new Date()[_0x287da0(0x19f)](),_0x3ce593='['+_0xae44b6+_0x287da0(0x194)+_0x4cbe06[_0x287da0(0x19b)]()+_0x287da0(0x194)+_0x33f286+']';console[_0x287da0(0x19e)](_0x4b9710?_0x3ce593+'\x20'+_0x17f024+'\x20'+JSON[_0x287da0(0x197)](_0x4b9710):_0x3ce593+'\x20'+_0x17f024),this[_0x287da0(0x189)]?.[_0x287da0(0x193)](JSON[_0x287da0(0x197)]({'ts':_0xae44b6,'level':_0x4cbe06,'component':_0x33f286,'msg':_0x17f024,..._0x4b9710&&{'data':_0x4b9710}})+'\x0a');}}export const logger=new MorphLogger();
|
package/dist/path-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x344800,_0x3f01a2){const _0x4b366e=a3_0x3310,_0x455363=_0x344800();while(!![]){try{const _0x56b15b=-parseInt(_0x4b366e(0x155))/0x1+parseInt(_0x4b366e(0x154))/0x2+-parseInt(_0x4b366e(0x14f))/0x3+parseInt(_0x4b366e(0x150))/0x4*(-parseInt(_0x4b366e(0x15e))/0x5)+-parseInt(_0x4b366e(0x152))/0x6+parseInt(_0x4b366e(0x161))/0x7+parseInt(_0x4b366e(0x14e))/0x8;if(_0x56b15b===_0x3f01a2)break;else _0x455363['push'](_0x455363['shift']());}catch(_0x215dda){_0x455363['push'](_0x455363['shift']());}}}(a3_0x43d7,0xdae9f));import a3_0x165f4b from'path';import a3_0x5e5f17 from'os';export function convertToWindowsPath(_0x4c189c){const _0x210b03=a3_0x3310;if(_0x4c189c[_0x210b03(0x160)](_0x210b03(0x156))){const _0x2772ec=_0x4c189c[_0x210b03(0x157)](0x5)[_0x210b03(0x15d)](),_0x51b354=_0x4c189c[_0x210b03(0x15c)](0x6)['replace'](/\//g,'\x5c');return _0x2772ec+':'+_0x51b354;}if(_0x4c189c[_0x210b03(0x158)](/^\/[a-zA-Z]\//)){const _0x3c90b=_0x4c189c[_0x210b03(0x157)](0x1)['toUpperCase'](),_0x2e5df4=_0x4c189c['slice'](0x2)[_0x210b03(0x151)](/\//g,'\x5c');return _0x3c90b+':'+_0x2e5df4;}if(_0x4c189c[_0x210b03(0x158)](/^[a-zA-Z]:/))return _0x4c189c[_0x210b03(0x151)](/\//g,'\x5c');return _0x4c189c;}function a3_0x3310(_0x4de169,_0x561a2b){_0x4de169=_0x4de169-0x14e;const _0x43d705=a3_0x43d7();let _0x3310d8=_0x43d705[_0x4de169];return _0x3310d8;}export function normalizePath(_0x54804b){const _0x2cae56=a3_0x3310;_0x54804b=_0x54804b[_0x2cae56(0x153)]()['replace'](/^["']|["']$/g,'');const _0x518a27=_0x54804b[_0x2cae56(0x160)]('/')&&!_0x54804b[_0x2cae56(0x158)](/^\/mnt\/[a-z]\//i)&&!_0x54804b[_0x2cae56(0x158)](/^\/[a-zA-Z]\//);if(_0x518a27)return _0x54804b[_0x2cae56(0x151)](/\/+/g,'/')['replace'](/\/+$/,'');_0x54804b=convertToWindowsPath(_0x54804b);if(_0x54804b[_0x2cae56(0x160)]('\x5c\x5c')){let _0x27f362=_0x54804b;_0x27f362=_0x27f362[_0x2cae56(0x151)](/^\\{2,}/,'\x5c\x5c');const _0x23d1e0=_0x27f362['substring'](0x2)[_0x2cae56(0x151)](/\\\\/g,'\x5c');_0x54804b='\x5c\x5c'+_0x23d1e0;}else _0x54804b=_0x54804b[_0x2cae56(0x151)](/\\\\/g,'\x5c');let _0x580320=a3_0x165f4b[_0x2cae56(0x15a)](_0x54804b);_0x54804b['startsWith']('\x5c\x5c')&&!_0x580320[_0x2cae56(0x160)]('\x5c\x5c')&&(_0x580320='\x5c'+_0x580320);if(_0x580320[_0x2cae56(0x158)](/^[a-zA-Z]:/)){let _0x3d6d50=_0x580320[_0x2cae56(0x151)](/\//g,'\x5c');return/^[a-z]:/[_0x2cae56(0x15b)](_0x3d6d50)&&(_0x3d6d50=_0x3d6d50['charAt'](0x0)[_0x2cae56(0x15d)]()+_0x3d6d50[_0x2cae56(0x15c)](0x1)),_0x3d6d50;}return _0x580320['replace'](/\//g,'\x5c');}export function expandHome(_0x35511e){const _0x4a1c04=a3_0x3310;if(_0x35511e['startsWith']('~/')||_0x35511e==='~')return a3_0x165f4b[_0x4a1c04(0x159)](a3_0x5e5f17[_0x4a1c04(0x15f)](),_0x35511e[_0x4a1c04(0x15c)](0x1));return _0x35511e;}function a3_0x43d7(){const _0x4799f2=['344429iDrHUi','/mnt/','charAt','match','join','normalize','test','slice','toUpperCase','50WIdLMy','homedir','startsWith','10794371gFLZqV','32969272pJCTAo','5359488SoCKaJ','628692jdybuo','replace','6814818SgUvAQ','trim','143834dzYEUJ'];a3_0x43d7=function(){return _0x4799f2;};return a3_0x43d7();}
|
package/dist/path-validation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a4_0x3fa8(){const _0x33aa91=['string','308790RyiOhz','535468GuJFSR','7psUHJF','normalize','4ddQsVV','sep','1237784sLPlnX','startsWith','isAbsolute','length','10phWpqX','includes','isArray','8826804lfOTHj','Path\x20must\x20be\x20absolute\x20after\x20normalization','resolve','2207336XjhTfo','2767881GNGSxp','some','5082066sVaEAE'];a4_0x3fa8=function(){return _0x33aa91;};return a4_0x3fa8();}(function(_0x5869e4,_0x41efcb){const _0x7086de=a4_0x3609,_0x115448=_0x5869e4();while(!![]){try{const _0x5d4ca5=-parseInt(_0x7086de(0x126))/0x1+-parseInt(_0x7086de(0x12b))/0x2+parseInt(_0x7086de(0x121))/0x3*(parseInt(_0x7086de(0x129))/0x4)+-parseInt(_0x7086de(0x125))/0x5+parseInt(_0x7086de(0x132))/0x6*(parseInt(_0x7086de(0x127))/0x7)+parseInt(_0x7086de(0x120))/0x8+parseInt(_0x7086de(0x123))/0x9*(-parseInt(_0x7086de(0x12f))/0xa);if(_0x5d4ca5===_0x41efcb)break;else _0x115448['push'](_0x115448['shift']());}catch(_0xcfe59b){_0x115448['push'](_0x115448['shift']());}}}(a4_0x3fa8,0xd9036));import a4_0x549f58 from'path';function a4_0x3609(_0x17ef5c,_0x33dcb6){_0x17ef5c=_0x17ef5c-0x11e;const _0x3fa83c=a4_0x3fa8();let _0x360993=_0x3fa83c[_0x17ef5c];return _0x360993;}export function isPathWithinAllowedDirectories(_0x26ec0d,_0x4fe4c1){const _0x3f10fb=a4_0x3609;if(typeof _0x26ec0d!==_0x3f10fb(0x124)||!Array[_0x3f10fb(0x131)](_0x4fe4c1))return![];if(!_0x26ec0d||_0x4fe4c1[_0x3f10fb(0x12e)]===0x0)return![];if(_0x26ec0d[_0x3f10fb(0x130)]('\x00'))return![];let _0x39de0a;try{_0x39de0a=a4_0x549f58[_0x3f10fb(0x11f)](a4_0x549f58[_0x3f10fb(0x128)](_0x26ec0d));}catch{return![];}if(!a4_0x549f58[_0x3f10fb(0x12d)](_0x39de0a))throw new Error(_0x3f10fb(0x11e));return _0x4fe4c1[_0x3f10fb(0x122)](_0x45ab1f=>{const _0x363905=_0x3f10fb;if(typeof _0x45ab1f!==_0x363905(0x124)||!_0x45ab1f)return![];if(_0x45ab1f[_0x363905(0x130)]('\x00'))return![];let _0x17e759;try{_0x17e759=a4_0x549f58[_0x363905(0x11f)](a4_0x549f58[_0x363905(0x128)](_0x45ab1f));}catch{return![];}if(!a4_0x549f58[_0x363905(0x12d)](_0x17e759))throw new Error('Allowed\x20directories\x20must\x20be\x20absolute\x20paths\x20after\x20normalization');if(_0x39de0a===_0x17e759)return!![];if(_0x17e759===a4_0x549f58[_0x363905(0x12a)])return _0x39de0a[_0x363905(0x12c)](a4_0x549f58[_0x363905(0x12a)]);return _0x39de0a[_0x363905(0x12c)](_0x17e759+a4_0x549f58[_0x363905(0x12a)]);});}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reflex MCP tools: read production Reflex results back into a coding agent.
|
|
3
|
+
*
|
|
4
|
+
* Three read-only tools over the public Reflex API:
|
|
5
|
+
* - list_reflexes the built-in catalog + GET /v1/fine_tuning/jobs
|
|
6
|
+
* - reflex_summary GET /v1/reflex/traces, aggregated into per-model firing rates
|
|
7
|
+
* - get_reflex_traces GET /v1/reflex/traces, individual turns with labels + snippets
|
|
8
|
+
*
|
|
9
|
+
* Only trace-linked results are readable (turns shipped via `morphTracing()`);
|
|
10
|
+
* direct /v1/reflex/predict calls have no public read-back endpoint. Output is
|
|
11
|
+
* budgeted to stay under MCP clients' tool-output caps (~12k tokens).
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { TracesClient } from '@morphllm/morphsdk/tools/traces';
|
|
15
|
+
import { ReflexClient } from '@morphllm/morphsdk/tools/reflex';
|
|
16
|
+
export declare const ListReflexesArgsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
17
|
+
export declare const ReflexSummaryArgsSchema: z.ZodObject<{
|
|
18
|
+
since_hours: z.ZodDefault<z.ZodNumber>;
|
|
19
|
+
max_events: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
since_hours: number;
|
|
22
|
+
max_events: number;
|
|
23
|
+
}, {
|
|
24
|
+
since_hours?: number | undefined;
|
|
25
|
+
max_events?: number | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const GetReflexTracesArgsSchema: z.ZodObject<{
|
|
28
|
+
convo_id: z.ZodOptional<z.ZodString>;
|
|
29
|
+
model: z.ZodOptional<z.ZodString>;
|
|
30
|
+
reflex: z.ZodOptional<z.ZodString>;
|
|
31
|
+
label: z.ZodOptional<z.ZodString>;
|
|
32
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
33
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
limit: number;
|
|
36
|
+
offset: number;
|
|
37
|
+
convo_id?: string | undefined;
|
|
38
|
+
model?: string | undefined;
|
|
39
|
+
reflex?: string | undefined;
|
|
40
|
+
label?: string | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
convo_id?: string | undefined;
|
|
43
|
+
model?: string | undefined;
|
|
44
|
+
reflex?: string | undefined;
|
|
45
|
+
label?: string | undefined;
|
|
46
|
+
limit?: number | undefined;
|
|
47
|
+
offset?: number | undefined;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const LIST_REFLEXES_DESCRIPTION: string;
|
|
50
|
+
export declare const REFLEX_SUMMARY_DESCRIPTION: string;
|
|
51
|
+
export declare const GET_REFLEX_TRACES_DESCRIPTION: string;
|
|
52
|
+
export interface ReflexApi {
|
|
53
|
+
traces: TracesClient;
|
|
54
|
+
reflex: ReflexClient;
|
|
55
|
+
}
|
|
56
|
+
export declare function createReflexApi(apiKey: string, baseUrl?: string): ReflexApi;
|
|
57
|
+
export declare function runListReflexes(api: ReflexApi): Promise<string>;
|
|
58
|
+
export interface ReflexSummaryArgs {
|
|
59
|
+
since_hours: number;
|
|
60
|
+
max_events: number;
|
|
61
|
+
}
|
|
62
|
+
export declare function runReflexSummary(api: ReflexApi, args: ReflexSummaryArgs): Promise<string>;
|
|
63
|
+
export interface GetReflexTracesArgs {
|
|
64
|
+
convo_id?: string;
|
|
65
|
+
model?: string;
|
|
66
|
+
reflex?: string;
|
|
67
|
+
label?: string;
|
|
68
|
+
limit: number;
|
|
69
|
+
offset: number;
|
|
70
|
+
}
|
|
71
|
+
export declare function runGetReflexTraces(api: ReflexApi, args: GetReflexTracesArgs): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a5_0x2d65c7=a5_0x486c;(function(_0x17b3f1,_0x339d47){const _0x35fb38=a5_0x486c,_0x21671d=_0x17b3f1();while(!![]){try{const _0x4777f5=parseInt(_0x35fb38(0x15b))/0x1+-parseInt(_0x35fb38(0x118))/0x2*(parseInt(_0x35fb38(0x181))/0x3)+-parseInt(_0x35fb38(0x197))/0x4*(-parseInt(_0x35fb38(0x10d))/0x5)+-parseInt(_0x35fb38(0x19a))/0x6*(-parseInt(_0x35fb38(0x10a))/0x7)+-parseInt(_0x35fb38(0x123))/0x8+parseInt(_0x35fb38(0x111))/0x9*(parseInt(_0x35fb38(0x183))/0xa)+-parseInt(_0x35fb38(0xeb))/0xb*(parseInt(_0x35fb38(0x199))/0xc);if(_0x4777f5===_0x339d47)break;else _0x21671d['push'](_0x21671d['shift']());}catch(_0x4fe0b0){_0x21671d['push'](_0x21671d['shift']());}}}(a5_0x362c,0xe0814));import{z}from'zod';import{MorphAPIClient}from'@morphllm/morphsdk';import{TracesClient}from'@morphllm/morphsdk/tools/traces';import{ReflexClient}from'@morphllm/morphsdk/tools/reflex';const OUTPUT_CHAR_BUDGET=0x9c40,SNIPPET_CHARS=0x190,TRACES_PAGE_SIZE=0x1f4,FILTER_SCAN_BOUND=0x1f4,TOP_CONVERSATIONS=0xa,TRACING_DOCS_URL=a5_0x2d65c7(0x17a),DEFAULT_REFLEXES=[{'alias':a5_0x2d65c7(0x166),'classes':a5_0x2d65c7(0x142),'catches':'Prompt-injection\x20and\x20jailbreak\x20attempts'},{'alias':a5_0x2d65c7(0xe7),'classes':a5_0x2d65c7(0xe6),'catches':a5_0x2d65c7(0x14b)},{'alias':a5_0x2d65c7(0x129),'classes':a5_0x2d65c7(0x193),'catches':a5_0x2d65c7(0x119)},{'alias':a5_0x2d65c7(0x135),'classes':a5_0x2d65c7(0x116),'catches':a5_0x2d65c7(0x138)},{'alias':a5_0x2d65c7(0x108),'classes':'complete\x20/\x20incomplete','catches':a5_0x2d65c7(0x12c)},{'alias':a5_0x2d65c7(0x15a),'classes':a5_0x2d65c7(0x107),'catches':'User\x20is\x20frustrated\x20with\x20the\x20agent'},{'alias':'user-joy','classes':a5_0x2d65c7(0x17b),'catches':a5_0x2d65c7(0xea)},{'alias':a5_0x2d65c7(0x11e),'classes':a5_0x2d65c7(0x16f),'catches':'How\x20underspecified\x20a\x20prompt\x20is'},{'alias':a5_0x2d65c7(0x105),'classes':a5_0x2d65c7(0x164),'catches':a5_0x2d65c7(0x17e)},{'alias':a5_0x2d65c7(0x196),'classes':a5_0x2d65c7(0x16b),'catches':a5_0x2d65c7(0x190)},{'alias':'health-emergency','classes':a5_0x2d65c7(0x1a0),'catches':a5_0x2d65c7(0x128)}],POSITIVE_LABELS_BY_ALIAS={'jailbreak':[a5_0x2d65c7(0x166)],'guardrail':[a5_0x2d65c7(0x131)],'user-frustrated':[a5_0x2d65c7(0x112)],'user-joy':[a5_0x2d65c7(0x1a2)],'incomplete-thought':[a5_0x2d65c7(0x17d)],'difficulty':[a5_0x2d65c7(0x125),'needs_info'],'ambiguity':[a5_0x2d65c7(0x19e)],'leaked-thinking':[a5_0x2d65c7(0x12b)],'stuck-in-a-loop':[a5_0x2d65c7(0xf3)],'health-emergency':[a5_0x2d65c7(0x12d)]},CATEGORY_ALIASES=new Set([a5_0x2d65c7(0x196)]),BASELINE_LABELS=new Set(['benign',a5_0x2d65c7(0xdf),a5_0x2d65c7(0x100),a5_0x2d65c7(0x149),a5_0x2d65c7(0x192),'ok',a5_0x2d65c7(0x103),a5_0x2d65c7(0x14a),'no',a5_0x2d65c7(0x179),a5_0x2d65c7(0x15e),a5_0x2d65c7(0x13e),'low','easy','progressing',a5_0x2d65c7(0x14f),a5_0x2d65c7(0x1a1),a5_0x2d65c7(0xf6)]),NEGATION_PREFIX=/^(not|non|no)[ _-]/;function isFiringLabel(_0xdaab9,_0x117919){const _0xa98ddb=a5_0x2d65c7;if(CATEGORY_ALIASES[_0xa98ddb(0xf4)](_0xdaab9))return![];const _0x496722=_0x117919['trim']()[_0xa98ddb(0x194)](),_0x3c2651=POSITIVE_LABELS_BY_ALIAS[_0xdaab9];if(_0x3c2651)return _0x3c2651[_0xa98ddb(0x178)](_0x496722);return!BASELINE_LABELS[_0xa98ddb(0xf4)](_0x496722)&&!NEGATION_PREFIX[_0xa98ddb(0x104)](_0x496722);}function labelsOf(_0x1ce626){const _0xc1a4cc=a5_0x2d65c7;if(_0x1ce626[_0xc1a4cc(0xe4)]['length']>0x0)return _0x1ce626[_0xc1a4cc(0xe4)];return _0x1ce626[_0xc1a4cc(0x173)]?[_0x1ce626[_0xc1a4cc(0x173)]]:[];}export const ListReflexesArgsSchema=z[a5_0x2d65c7(0xf7)]({});export const ReflexSummaryArgsSchema=z[a5_0x2d65c7(0xf7)]({'since_hours':z[a5_0x2d65c7(0x18b)]()[a5_0x2d65c7(0x15d)]()[a5_0x2d65c7(0x177)](0x1)[a5_0x2d65c7(0xe9)](0xa8)[a5_0x2d65c7(0x122)](0x18)[a5_0x2d65c7(0xfd)](a5_0x2d65c7(0x13b)),'max_events':z[a5_0x2d65c7(0x18b)]()['int']()['min'](0x1)[a5_0x2d65c7(0xe9)](0x7d0)[a5_0x2d65c7(0x122)](0x3e8)['describe'](a5_0x2d65c7(0x159))});function a5_0x486c(_0x55039f,_0x1f2d68){_0x55039f=_0x55039f-0xd8;const _0x362c18=a5_0x362c();let _0x486cb6=_0x362c18[_0x55039f];return _0x486cb6;}export const GetReflexTracesArgsSchema=z[a5_0x2d65c7(0xf7)]({'convo_id':z[a5_0x2d65c7(0x154)]()[a5_0x2d65c7(0x144)]()[a5_0x2d65c7(0xfd)](a5_0x2d65c7(0x143)),'model':z['string']()[a5_0x2d65c7(0x144)]()['describe'](a5_0x2d65c7(0xee)),'reflex':z[a5_0x2d65c7(0x154)]()[a5_0x2d65c7(0x144)]()['describe']('Only\x20turns\x20classified\x20by\x20this\x20Reflex,\x20e.g.\x20\x22user-frustrated\x22.'),'label':z[a5_0x2d65c7(0x154)]()[a5_0x2d65c7(0x144)]()[a5_0x2d65c7(0xfd)](a5_0x2d65c7(0x150)),'limit':z[a5_0x2d65c7(0x18b)]()['int']()[a5_0x2d65c7(0x177)](0x1)[a5_0x2d65c7(0xe9)](0x32)[a5_0x2d65c7(0x122)](0x14)[a5_0x2d65c7(0xfd)]('Turns\x20to\x20return\x20(default\x2020,\x20max\x2050).'),'offset':z[a5_0x2d65c7(0x18b)]()[a5_0x2d65c7(0x15d)]()['min'](0x0)[a5_0x2d65c7(0x122)](0x0)[a5_0x2d65c7(0xfd)](a5_0x2d65c7(0x12e))});export const LIST_REFLEXES_DESCRIPTION=a5_0x2d65c7(0x12f)+a5_0x2d65c7(0x121)+a5_0x2d65c7(0x16a)+a5_0x2d65c7(0x126)+'results\x20with\x20reflex_summary\x20or\x20get_reflex_traces.';export const REFLEX_SUMMARY_DESCRIPTION=a5_0x2d65c7(0x1a3)+'Returns\x20firing\x20rates\x20per\x20traced\x20model\x20per\x20Reflex\x20—\x20the\x20fastest\x20way\x20to\x20compare\x20how\x20two\x20'+a5_0x2d65c7(0x13d)+a5_0x2d65c7(0xdb)+a5_0x2d65c7(0x136);function a5_0x362c(){const _0x3a37d9=['\x20had\x20a\x20firing\x20label.','offset','##\x20','benign\x20/\x20jailbreak','Only\x20turns\x20from\x20this\x20conversation\x20(ids\x20appear\x20in\x20reflex_summary\x20output).','optional','convoId','\x20—\x20','entries','h.\x0a','none','negative','Harassment\x20or\x20NSFW\x20content','More\x20turns\x20available:\x20repeat\x20with\x20offset=','\x20pending','get','allowed','Only\x20turns\x20where\x20a\x20Reflex\x20assigned\x20this\x20label,\x20e.g.\x20\x22frustrated\x22,\x20\x22looping\x22,\x20\x22jailbreak\x22.','\x20traced\x20turns\x20(window\x20not\x20fully\x20covered\x20—\x20raise\x20max_events)\x20across\x20','##\x20Built-in\x20(callable\x20by\x20every\x20account)','message','string','#\x20Traced\x20turns\x20(newest\x20first)','some','Note:\x20direct\x20/v1/reflex/predict\x20calls\x20are\x20not\x20returned\x20here;\x20only\x20traced\x20turns\x20are.','trim','Maximum\x20traced\x20turns\x20to\x20scan,\x20newest\x20first\x20(default\x201000).','user-frustrated','42588ZQCjWr','These\x20turns\x20have\x20no\x20Reflex\x20labels\x20yet.\x20Pass\x20evals:\x20{\x20user:\x20[...],\x20assistant:\x20[...]\x20}\x20to\x20','int','neutral','convo_id=','h,\x20but\x20older\x20traces\x20exist\x20','reflexes','isNaN','status','easy\x20/\x20medium\x20/\x20hard','localeCompare','jailbreak','[output\x20truncated\x20after\x20','\x20turns','model','custom\x20classifiers\x20trained\x20through\x20the\x20fine-tuning\x20API.\x20Reflexes\x20label\x20production\x20LLM\x20','general\x20/\x20summary\x20/\x20coding\x20/\x20design\x20/\x20data','-\x20(','\x20results\x20still\x20pending)','time','low\x20/\x20med\x20/\x20high','\x20event=','Read\x20recent\x20traced\x20turns\x20from\x20production\x20with\x20their\x20Reflex\x20labels\x20and\x20input/output\x20','begin()\x20so\x20every\x20turn\x20is\x20labeled\x20off\x20the\x20request\x20path\x20—\x20','label','\x20still\x20in\x20progress)',']\x20convo=','labelCounts','min','includes','false','https://docs.morphllm.com/guides/reflex-tracing','joy\x20/\x20not_joy','labels','incomplete','Prompt\x20difficulty,\x20for\x20model\x20routing','##\x20Top\x20firing\x20conversations','hasMore','3FmZTDP','startTime','190mPNZQx',':\x20fired\x20','catches','createdAt','Next:\x20reflex_summary\x20aggregates\x20recent\x20production\x20results;\x20get_reflex_traces\x20reads\x20individual\x20turns.','(none)','startup\x20and\x20wrap\x20each\x20turn\x20in\x20begin()/finish()\x20—\x20','No\x20traced\x20turns\x20in\x20the\x20last\x20','number','max_events','set','now','size','Topic\x20of\x20a\x20request','inputText','clean','clean\x20/\x20leaked','toLowerCase','firedTurns','domain','2086412VQnrpj','length','14147688FJtAsN','18864tFQKjF','Loosen\x20the\x20filters,\x20or\x20run\x20reflex_summary\x20to\x20see\x20what\x20labels\x20exist.','add','since_hours','high','getTime','emergency\x20/\x20non-emergency','pass','joy','Aggregate\x20recent\x20production\x20Reflex\x20results\x20from\x20traced\x20LLM\x20traffic\x20(morphTracing).\x20','classes','push','job','the\x20top\x20firing\x20conversations\x20to\x20drill\x20into\x20with\x20get_reflex_traces.\x20Use\x20this\x20before\x20','\x20—\x20trained\x20','turns','trimEnd','safe','eventId','\x20—\x20or\x20run\x20','No\x20traced\x20turns\x20match\x20','jobs','selected','Drill\x20in:\x20get_reflex_traces\x20with\x20{\x20convo_id\x20}\x20for\x20a\x20conversation,\x20or\x20{\x20model,\x20label\x20}\x20for\x20one\x20failure\x20mode.','true\x20/\x20false','guardrail','convo_id','max','User\x20is\x20delighted\x20with\x20the\x20agent','11ybruOR','\x20—\x20classes:\x20','#\x20Reflex\x20summary\x20—\x20last\x20','Only\x20turns\x20traced\x20from\x20this\x20LLM,\x20e.g.\x20\x22morph-glm52-744b\x22\x20or\x20your\x20previous\x20provider\x27s\x20model\x20name.','validating_files','Snippets\x20are\x20truncated;\x20page\x20with\x20limit/offset.','#\x20Reflexes\x20on\x20this\x20account','sort','looping','has','\x20\x20in:\x20\x20','healthy','object','reflex_summary),\x20traced\x20model,\x20Reflex\x20name,\x20or\x20assigned\x20label\x20(e.g.\x20label:\x20\x22looping\x22).\x20','toFixed','\x20\x20out:\x20','Reflexes\x20over\x20existing\x20traces\x20at\x20https://morphllm.com/dashboard/traces.','##\x20Custom\x20(trained\x20via\x20/v1/fine_tuning/jobs)','describe','reflex','(no\x20completed\x20results)','normal','model=','\x20turns\x20—\x20narrow\x20with\x20convo_id/model/label\x20or\x20lower\x20limit]','okay','test','difficulty','limit','frustrated\x20/\x20not','incomplete-thought','score','3962uwqVhD','fineTunedModel','list','5uDbcjn','hits','succeeded','reflexResults','782991fSOZxA','frustrated','slice','filter','\x20model(s);\x20','progressing\x20/\x20looping','\x20model=','3603454FipSIz','Agent\x20leaking\x20its\x20internal\x20thinking','map','pendingResults','traces','data','ambiguity','-\x20none\x20yet\x20—\x20train\x20one:\x20https://docs.morphllm.com/sdk/components/reflexes/custom','No\x20traced\x20turns\x20found.\x20Reflex\x20read-back\x20requires\x20tracing:\x20call\x20morphTracing()\x20once\x20at\x20','(jailbreak,\x20guardrail,\x20leaked-thinking,\x20stuck-in-a-loop,\x20user-frustrated,\x20...)\x20plus\x20any\x20','default','771224dDMErL','join','hard','traffic\x20per\x20turn.\x20Call\x20this\x20first\x20to\x20see\x20which\x20signals\x20exist,\x20then\x20pull\x20production\x20','\x20—\x20labels:\x20','Patient-portal\x20message\x20needs\x20urgent\x20attention','leaked-thinking','(no\x20model)','leaked','User\x20sent\x20a\x20truncated\x20prompt','emergency','Skip\x20this\x20many\x20matching\x20turns\x20(pagination).','List\x20the\x20Reflex\x20classifiers\x20available\x20on\x20this\x20Morph\x20account:\x20the\x2011\x20built-in\x20defaults\x20','\x20of\x20','true','Scanned\x20the\x20newest\x20','reflex=','turnsWithResult','stuck-in-a-loop','reading\x20individual\x20turns.','outputText','Agent\x20blocked,\x20not\x20trying\x20new\x20things','queued','\x20in\x20the\x20newest\x20','Look-back\x20window\x20in\x20hours\x20(default\x2024,\x20max\x20168).','toISOString','models\x20or\x20providers\x20behave\x20in\x20production\x20(e.g.\x20a\x20canary\x20vs.\x20the\x20current\x20model)\x20—\x20plus\x20','complete'];a5_0x362c=function(){return _0x3a37d9;};return a5_0x362c();}export const GET_REFLEX_TRACES_DESCRIPTION=a5_0x2d65c7(0x171)+'snippets,\x20newest\x20first.\x20Filter\x20by\x20convo_id\x20(drill\x20into\x20a\x20conversation\x20surfaced\x20by\x20'+a5_0x2d65c7(0xf8)+a5_0x2d65c7(0xf0);export function createReflexApi(_0x51ad05,_0x2e4180){const _0x12a176=new MorphAPIClient({'apiKey':_0x51ad05,'baseURL':_0x2e4180});return{'traces':new TracesClient(_0x12a176),'reflex':new ReflexClient(_0x12a176)};}function parseTraceTime(_0x47a134){const _0x2eb6a5=a5_0x2d65c7;if(!_0x47a134)return null;const _0x38bd10=_0x47a134[_0x2eb6a5(0x178)]('T')?_0x47a134:_0x47a134['replace']('\x20','T'),_0x15a4a9=new Date(/Z|[+-]\d\d:?\d\d$/[_0x2eb6a5(0x104)](_0x38bd10)?_0x38bd10:_0x38bd10+'Z');return Number[_0x2eb6a5(0x162)](_0x15a4a9[_0x2eb6a5(0x19f)]())?null:_0x15a4a9;}function truncate(_0x177386,_0x1762cb){const _0x3e03aa=a5_0x2d65c7,_0x45973f=_0x177386['replace'](/\s+/g,'\x20')[_0x3e03aa(0x158)]();return _0x45973f[_0x3e03aa(0x198)]<=_0x1762cb?_0x45973f:_0x45973f[_0x3e03aa(0x113)](0x0,_0x1762cb)+'…';}function formatRate(_0x4b8e4f,_0x9743bc){const _0x40c446=a5_0x2d65c7;if(_0x9743bc===0x0)return'—';return(_0x4b8e4f/_0x9743bc*0x64)[_0x40c446(0xf9)](0x1)+'%';}const NO_TRACES_MESSAGE=a5_0x2d65c7(0x120)+(a5_0x2d65c7(0x189)+TRACING_DOCS_URL+'\x0a')+a5_0x2d65c7(0x157);export async function runListReflexes(_0x3d1911){const _0x514ffc=a5_0x2d65c7,_0x2d2d09=[_0x514ffc(0xf1),'',_0x514ffc(0x152)];for(const _0x13c876 of DEFAULT_REFLEXES){_0x2d2d09['push']('-\x20'+_0x13c876['alias']+_0x514ffc(0xec)+_0x13c876[_0x514ffc(0xd8)]+_0x514ffc(0x146)+_0x13c876[_0x514ffc(0x185)]);}_0x2d2d09['push']('',_0x514ffc(0xfc));try{const _0x1d133a=await _0x3d1911[_0x514ffc(0xfe)][_0x514ffc(0xe3)][_0x514ffc(0x10c)]({'limit':0x32}),_0xf49e4a=_0x1d133a[_0x514ffc(0x11d)][_0x514ffc(0x114)](_0xb871c8=>_0xb871c8[_0x514ffc(0x163)]===_0x514ffc(0x10f)&&_0xb871c8[_0x514ffc(0x10b)]);_0xf49e4a[_0x514ffc(0x198)]===0x0&&_0x2d2d09[_0x514ffc(0xd9)](_0x514ffc(0x11f));for(const _0x5ebbd1 of _0xf49e4a){const _0x4b655c=new Date(_0x5ebbd1[_0x514ffc(0x186)]*0x3e8)[_0x514ffc(0x13c)]()[_0x514ffc(0x113)](0x0,0xa),_0x368c14=_0x5ebbd1[_0x514ffc(0x17c)]['length']>0x0?_0x514ffc(0x127)+_0x5ebbd1['labels'][_0x514ffc(0x124)]('\x20/\x20'):'';_0x2d2d09['push']('-\x20'+_0x5ebbd1[_0x514ffc(0x10b)]+_0x368c14+_0x514ffc(0xdc)+_0x4b655c);}const _0x12c35f=_0x1d133a[_0x514ffc(0x11d)][_0x514ffc(0x114)](_0x1c95dc=>_0x1c95dc[_0x514ffc(0x163)]===_0x514ffc(0x139)||_0x1c95dc[_0x514ffc(0x163)]==='running'||_0x1c95dc['status']===_0x514ffc(0xef));_0x12c35f[_0x514ffc(0x198)]>0x0&&_0x2d2d09[_0x514ffc(0xd9)](_0x514ffc(0x16c)+_0x12c35f[_0x514ffc(0x198)]+'\x20training\x20'+(_0x12c35f[_0x514ffc(0x198)]===0x1?_0x514ffc(0xda):_0x514ffc(0xe3))+_0x514ffc(0x174));}catch(_0x4645c6){const _0x12e31b=_0x4645c6 instanceof Error?_0x4645c6[_0x514ffc(0x153)]:String(_0x4645c6);_0x2d2d09['push']('-\x20(could\x20not\x20list\x20custom\x20reflexes:\x20'+_0x12e31b+')');}return _0x2d2d09[_0x514ffc(0xd9)]('',_0x514ffc(0x187)),_0x2d2d09[_0x514ffc(0x124)]('\x0a');}async function fetchTracesWindow(_0x73f7e6,_0x3031aa,_0x38c53a){const _0x1900c9=a5_0x2d65c7,_0x37c4ff=Date[_0x1900c9(0x18e)]()-_0x3031aa*0x36ee80,_0x382621=[];let _0x3b35ce=0x0;for(;;){const _0x2f5a53=_0x38c53a-_0x382621['length'];if(_0x2f5a53<=0x0)return{'events':_0x382621,'coveredWindow':![]};const _0x4b153a=await _0x73f7e6['traces'][_0x1900c9(0x10c)]({'limit':Math[_0x1900c9(0x177)](TRACES_PAGE_SIZE,_0x2f5a53),'offset':_0x3b35ce});for(const _0x1f7571 of _0x4b153a[_0x1900c9(0x11d)]){const _0x5791d0=parseTraceTime(_0x1f7571[_0x1900c9(0x182)]);if(_0x5791d0&&_0x5791d0[_0x1900c9(0x19f)]()<_0x37c4ff)return{'events':_0x382621,'coveredWindow':!![]};_0x382621[_0x1900c9(0xd9)](_0x1f7571);}if(!_0x4b153a[_0x1900c9(0x180)]||_0x4b153a[_0x1900c9(0x11d)][_0x1900c9(0x198)]===0x0)return{'events':_0x382621,'coveredWindow':!![]};_0x3b35ce+=_0x4b153a[_0x1900c9(0x11d)]['length'];}}export async function runReflexSummary(_0x1f52f2,_0x2757d8){const _0x8b9d95=a5_0x2d65c7,{events:_0x1e49d6,coveredWindow:_0x5f1694}=await fetchTracesWindow(_0x1f52f2,_0x2757d8[_0x8b9d95(0x19d)],_0x2757d8[_0x8b9d95(0x18c)]);if(_0x1e49d6[_0x8b9d95(0x198)]===0x0){const _0x519b8a=await _0x1f52f2[_0x8b9d95(0x11c)][_0x8b9d95(0x10c)]({'limit':0x1});if(_0x519b8a['data'][_0x8b9d95(0x198)]>0x0)return _0x8b9d95(0x18a)+_0x2757d8['since_hours']+_0x8b9d95(0x160)+('(newest:\x20'+_0x519b8a[_0x8b9d95(0x11d)][0x0][_0x8b9d95(0x182)]+').\x20Retry\x20with\x20a\x20larger\x20since_hours\x20(max\x20168).');return _0x8b9d95(0x18a)+_0x2757d8['since_hours']+_0x8b9d95(0x148)+NO_TRACES_MESSAGE;}const _0x5b50ec=new Map(),_0x1742ba=new Map();let _0x52242f=0x0,_0x331821=0x0;for(const _0x313e7a of _0x1e49d6){const _0x586f85=_0x313e7a['model']||'(no\x20model)';let _0x368d69=_0x5b50ec[_0x8b9d95(0x14e)](_0x586f85);!_0x368d69&&(_0x368d69={'turns':0x0,'reflexes':new Map(),'pendingResults':0x0},_0x5b50ec[_0x8b9d95(0x18d)](_0x586f85,_0x368d69));_0x368d69['turns']+=0x1;const _0x22be4e=_0x313e7a[_0x8b9d95(0x110)][_0x8b9d95(0x114)](_0x14c512=>_0x14c512[_0x8b9d95(0x163)]==='completed');_0x368d69[_0x8b9d95(0x11b)]+=_0x313e7a[_0x8b9d95(0x110)]['filter'](_0x5c03f3=>_0x5c03f3['status']==='pending')[_0x8b9d95(0x198)];if(_0x22be4e[_0x8b9d95(0x198)]>0x0)_0x331821+=0x1;let _0x40499b=![];for(const _0x459869 of _0x22be4e){let _0x2b09c6=_0x368d69[_0x8b9d95(0x161)]['get'](_0x459869[_0x8b9d95(0x169)]);!_0x2b09c6&&(_0x2b09c6={'turnsWithResult':0x0,'firedTurns':0x0,'labelCounts':new Map()},_0x368d69[_0x8b9d95(0x161)][_0x8b9d95(0x18d)](_0x459869[_0x8b9d95(0x169)],_0x2b09c6));_0x2b09c6[_0x8b9d95(0x134)]+=0x1;const _0x47c64d=labelsOf(_0x459869);let _0x2d52d1=![];for(const _0x5e025c of _0x47c64d[_0x8b9d95(0x198)]>0x0?_0x47c64d:[_0x8b9d95(0x188)]){_0x2b09c6[_0x8b9d95(0x176)]['set'](_0x5e025c,(_0x2b09c6[_0x8b9d95(0x176)]['get'](_0x5e025c)??0x0)+0x1);if(_0x5e025c!==_0x8b9d95(0x188)&&isFiringLabel(_0x459869['model'],_0x5e025c)){_0x2d52d1=!![];const _0xc4fd70=_0x1742ba[_0x8b9d95(0x14e)](_0x313e7a[_0x8b9d95(0x145)])??{'time':_0x313e7a[_0x8b9d95(0x182)],'model':_0x586f85,'hits':new Set()};_0xc4fd70[_0x8b9d95(0x10e)][_0x8b9d95(0x19c)](_0x459869['model']+':\x20'+_0x5e025c),_0x1742ba['set'](_0x313e7a[_0x8b9d95(0x145)],_0xc4fd70);}}_0x2d52d1&&(_0x2b09c6[_0x8b9d95(0x195)]+=0x1,_0x40499b=!![]);}if(_0x40499b)_0x52242f+=0x1;}const _0xd177df=[_0x8b9d95(0xed)+_0x2757d8[_0x8b9d95(0x19d)]+'h',_0x5f1694?'Scanned\x20'+_0x1e49d6[_0x8b9d95(0x198)]+'\x20traced\x20turns\x20across\x20'+_0x5b50ec[_0x8b9d95(0x18f)]+_0x8b9d95(0x115)+_0x52242f+_0x8b9d95(0x13f):_0x8b9d95(0x132)+_0x1e49d6[_0x8b9d95(0x198)]+_0x8b9d95(0x151)+_0x5b50ec[_0x8b9d95(0x18f)]+_0x8b9d95(0x115)+_0x52242f+_0x8b9d95(0x13f)];if(_0x331821===0x0)return _0xd177df['push']('',_0x8b9d95(0x15c)+(_0x8b9d95(0x172)+TRACING_DOCS_URL+_0x8b9d95(0xe1))+_0x8b9d95(0xfb)),_0xd177df['join']('\x0a');const _0x285b07=[..._0x5b50ec[_0x8b9d95(0x147)]()]['sort']((_0x584085,_0x554d57)=>_0x554d57[0x1][_0x8b9d95(0xdd)]-_0x584085[0x1][_0x8b9d95(0xdd)]);for(const [_0x303919,_0x2721fd]of _0x285b07){_0xd177df[_0x8b9d95(0xd9)]('',_0x8b9d95(0x141)+_0x303919+'\x20—\x20'+_0x2721fd[_0x8b9d95(0xdd)]+_0x8b9d95(0x168));_0x2721fd[_0x8b9d95(0x161)]['size']===0x0&&_0xd177df['push']('-\x20no\x20completed\x20Reflex\x20results\x20on\x20these\x20turns');const _0x3fcce1=[..._0x2721fd[_0x8b9d95(0x161)][_0x8b9d95(0x147)]()][_0x8b9d95(0xf2)]((_0x4f2412,_0x3d77d1)=>_0x3d77d1[0x1][_0x8b9d95(0x195)]-_0x4f2412[0x1]['firedTurns']);for(const [_0x4bd1be,_0x580c27]of _0x3fcce1){const _0x2150e6=[..._0x580c27[_0x8b9d95(0x176)][_0x8b9d95(0x147)]()][_0x8b9d95(0xf2)]((_0x184b57,_0x581c0d)=>_0x581c0d[0x1]-_0x184b57[0x1])[_0x8b9d95(0x11a)](([_0x5c4743,_0x1d832f])=>_0x5c4743+'\x20'+_0x1d832f)['join'](',\x20');_0xd177df[_0x8b9d95(0xd9)]('-\x20'+_0x4bd1be+_0x8b9d95(0x184)+_0x580c27[_0x8b9d95(0x195)]+'/'+_0x580c27[_0x8b9d95(0x134)]+'\x20'+('('+formatRate(_0x580c27[_0x8b9d95(0x195)],_0x580c27['turnsWithResult'])+')\x20—\x20'+_0x2150e6));}_0x2721fd[_0x8b9d95(0x11b)]>0x0&&_0xd177df[_0x8b9d95(0xd9)](_0x8b9d95(0x16c)+_0x2721fd[_0x8b9d95(0x11b)]+_0x8b9d95(0x16d));}const _0x35ca2f=[..._0x1742ba['entries']()]['sort']((_0x574378,_0x5036e3)=>_0x5036e3[0x1][_0x8b9d95(0x10e)][_0x8b9d95(0x18f)]-_0x574378[0x1]['hits']['size']||_0x5036e3[0x1]['time'][_0x8b9d95(0x165)](_0x574378[0x1][_0x8b9d95(0x16e)]))[_0x8b9d95(0x113)](0x0,TOP_CONVERSATIONS);if(_0x35ca2f[_0x8b9d95(0x198)]>0x0){_0xd177df['push']('',_0x8b9d95(0x17f));for(const [_0x30329b,_0x29a666]of _0x35ca2f){_0xd177df[_0x8b9d95(0xd9)]('-\x20'+_0x30329b+'\x20—\x20'+_0x29a666[_0x8b9d95(0x16e)]+_0x8b9d95(0x146)+_0x29a666[_0x8b9d95(0x169)]+_0x8b9d95(0x146)+[..._0x29a666[_0x8b9d95(0x10e)]][_0x8b9d95(0x124)](',\x20'));}_0xd177df[_0x8b9d95(0xd9)]('',_0x8b9d95(0xe5));}return _0xd177df['join']('\x0a');}function formatTraceEvent(_0x161fc6){const _0x511287=a5_0x2d65c7,_0x46b4a5=_0x161fc6[_0x511287(0x110)]['filter'](_0x322c57=>_0x322c57[_0x511287(0x163)]==='completed'),_0x33dc74=_0x161fc6[_0x511287(0x110)][_0x511287(0x198)]-_0x46b4a5['length'],_0x29974a=_0x46b4a5[_0x511287(0x11a)](_0x1fd499=>{const _0x372aae=_0x511287,_0x59365c=labelsOf(_0x1fd499)[_0x372aae(0x124)](',\x20')||_0x372aae(0x188);return _0x1fd499[_0x372aae(0x169)]+'='+_0x59365c+'\x20('+_0x1fd499[_0x372aae(0x109)][_0x372aae(0xf9)](0x2)+')';})[_0x511287(0x124)](';\x20'),_0x32f4bb=['['+_0x161fc6[_0x511287(0x182)]+_0x511287(0x175)+_0x161fc6['convoId']+_0x511287(0x170)+_0x161fc6[_0x511287(0xe0)]+_0x511287(0x117)+(_0x161fc6[_0x511287(0x169)]||_0x511287(0x12a)),'\x20\x20reflexes:\x20'+(_0x29974a||_0x511287(0xff))+(_0x33dc74>0x0?_0x511287(0x146)+_0x33dc74+_0x511287(0x14d):'')];if(_0x161fc6['inputText'])_0x32f4bb[_0x511287(0xd9)](_0x511287(0xf5)+truncate(_0x161fc6[_0x511287(0x191)],SNIPPET_CHARS));if(_0x161fc6['outputText'])_0x32f4bb[_0x511287(0xd9)](_0x511287(0xfa)+truncate(_0x161fc6[_0x511287(0x137)],SNIPPET_CHARS));return _0x32f4bb['join']('\x0a');}export async function runGetReflexTraces(_0x5d12c6,_0x6920c5){const _0xd83384=a5_0x2d65c7,_0x3ea205=_0x6920c5[_0xd83384(0x173)]?.['trim']()[_0xd83384(0x194)](),_0x535cd2=Boolean(_0x6920c5[_0xd83384(0x169)]||_0x6920c5['reflex']||_0x3ea205),_0x3cd03f=_0x2dcd5b=>{const _0x1b0f9c=_0xd83384;if(_0x6920c5[_0x1b0f9c(0x169)]&&_0x2dcd5b['model']!==_0x6920c5[_0x1b0f9c(0x169)])return![];if(_0x6920c5[_0x1b0f9c(0xfe)]&&!_0x2dcd5b[_0x1b0f9c(0x110)]['some'](_0x3f8675=>_0x3f8675['model']===_0x6920c5[_0x1b0f9c(0xfe)]))return![];if(_0x3ea205&&!_0x2dcd5b['reflexResults'][_0x1b0f9c(0x156)](_0x3fd743=>labelsOf(_0x3fd743)[_0x1b0f9c(0x156)](_0x46b089=>_0x46b089[_0x1b0f9c(0x194)]()===_0x3ea205)))return![];return!![];};let _0x3c022f=[],_0x2a9fc7=!![];if(!_0x535cd2){const _0x319778=await _0x5d12c6[_0xd83384(0x11c)][_0xd83384(0x10c)]({'convoId':_0x6920c5[_0xd83384(0xe8)],'limit':_0x6920c5[_0xd83384(0x106)],'offset':_0x6920c5[_0xd83384(0x140)]});_0x3c022f=_0x319778[_0xd83384(0x11d)],_0x2a9fc7=!_0x319778['hasMore'];}else{const _0x2980c9=_0x6920c5[_0xd83384(0x140)]+_0x6920c5[_0xd83384(0x106)];let _0x2ea7dc=0x0,_0x3175cf=0x0,_0x4d7337=!![];while(_0x3c022f[_0xd83384(0x198)]<_0x2980c9&&_0x4d7337&&_0x3175cf<FILTER_SCAN_BOUND){const _0xd2f5a3=await _0x5d12c6[_0xd83384(0x11c)][_0xd83384(0x10c)]({'convoId':_0x6920c5[_0xd83384(0xe8)],'limit':0x64,'offset':_0x2ea7dc});for(const _0x3a9e9e of _0xd2f5a3[_0xd83384(0x11d)]){_0x3175cf+=0x1;if(_0x3cd03f(_0x3a9e9e))_0x3c022f[_0xd83384(0xd9)](_0x3a9e9e);}_0x4d7337=_0xd2f5a3[_0xd83384(0x180)]&&_0xd2f5a3[_0xd83384(0x11d)][_0xd83384(0x198)]>0x0,_0x2ea7dc+=_0xd2f5a3[_0xd83384(0x11d)][_0xd83384(0x198)];}_0x2a9fc7=!_0x4d7337,_0x3c022f=_0x3c022f[_0xd83384(0x113)](_0x6920c5['offset'],_0x6920c5[_0xd83384(0x140)]+_0x6920c5[_0xd83384(0x106)]);}const _0x1a7bbb=[_0x6920c5['convo_id']&&_0xd83384(0x15f)+_0x6920c5[_0xd83384(0xe8)],_0x6920c5[_0xd83384(0x169)]&&_0xd83384(0x101)+_0x6920c5[_0xd83384(0x169)],_0x6920c5[_0xd83384(0xfe)]&&_0xd83384(0x133)+_0x6920c5[_0xd83384(0xfe)],_0x6920c5['label']&&'label='+_0x6920c5[_0xd83384(0x173)]][_0xd83384(0x114)](Boolean)[_0xd83384(0x124)](',\x20');if(_0x3c022f[_0xd83384(0x198)]===0x0){if(_0x1a7bbb)return _0xd83384(0xe2)+_0x1a7bbb+(_0x2a9fc7?'':_0xd83384(0x13a)+FILTER_SCAN_BOUND+'\x20turns')+'.\x20'+_0xd83384(0x19b);return NO_TRACES_MESSAGE;}const _0xe65999=[_0xd83384(0x155)+(_0x1a7bbb?_0xd83384(0x146)+_0x1a7bbb:''),''];let _0x15e48d=_0xe65999[_0xd83384(0x124)]('\x0a')['length'],_0x4c9dc9=0x0;for(const _0x991bb9 of _0x3c022f){const _0x22352c=formatTraceEvent(_0x991bb9);if(_0x15e48d+_0x22352c['length']>OUTPUT_CHAR_BUDGET){_0xe65999['push'](_0xd83384(0x167)+_0x4c9dc9+_0xd83384(0x130)+_0x3c022f[_0xd83384(0x198)]+_0xd83384(0x102));break;}_0xe65999[_0xd83384(0xd9)](_0x22352c,''),_0x15e48d+=_0x22352c[_0xd83384(0x198)]+0x2,_0x4c9dc9+=0x1;}return _0x4c9dc9===_0x3c022f[_0xd83384(0x198)]&&!_0x2a9fc7&&_0xe65999['push'](_0xd83384(0x14c)+(_0x6920c5['offset']+_0x3c022f['length'])+'.'),_0xe65999['join']('\x0a')[_0xd83384(0xde)]();}
|
package/dist/roots-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x307190,_0x2d66fe){const _0x4b52cb=a6_0x4ef4,_0x27fbb0=_0x307190();while(!![]){try{const _0x2f3419=parseInt(_0x4b52cb(0x7c))/0x1+-parseInt(_0x4b52cb(0x68))/0x2*(-parseInt(_0x4b52cb(0x76))/0x3)+parseInt(_0x4b52cb(0x70))/0x4+parseInt(_0x4b52cb(0x6e))/0x5+-parseInt(_0x4b52cb(0x6d))/0x6+parseInt(_0x4b52cb(0x7a))/0x7*(-parseInt(_0x4b52cb(0x79))/0x8)+parseInt(_0x4b52cb(0x7d))/0x9;if(_0x2f3419===_0x2d66fe)break;else _0x27fbb0['push'](_0x27fbb0['shift']());}catch(_0x4d16db){_0x27fbb0['push'](_0x27fbb0['shift']());}}}(a6_0x366c,0x33340));import{promises as a6_0x11afe4}from'fs';function a6_0x366c(){const _0x2ed0b5=['90LzVWID','join','file://','56DuYcSY','197925YFyQgd','homedir','148189SxsoVa','961047KJOVWv','message','push','130CbGdrV','invalid\x20path\x20or\x20inaccessible','Skipping\x20','non-directory\x20root','isDirectory','935724UdDURF','1479490qrLaNa','realpath','43148TkpgAA','\x20due\x20to\x20error:\x20','Skipping\x20invalid\x20directory:\x20','uri','resolve','slice'];a6_0x366c=function(){return _0x2ed0b5;};return a6_0x366c();}import a6_0x59682d from'path';function a6_0x4ef4(_0x6155eb,_0x138128){_0x6155eb=_0x6155eb-0x67;const _0x366caf=a6_0x366c();let _0x4ef423=_0x366caf[_0x6155eb];return _0x4ef423;}import a6_0x3026d8 from'os';import{normalizePath}from'./path-utils.js';import{logMcpStderr}from'./log-utils.js';async function parseRootUri(_0x4ed520){const _0x3f0cdb=a6_0x4ef4;try{const _0x555819=_0x4ed520['startsWith'](_0x3f0cdb(0x78))?_0x4ed520[_0x3f0cdb(0x75)](0x7):_0x4ed520,_0x673f97=_0x555819['startsWith']('~/')||_0x555819==='~'?a6_0x59682d[_0x3f0cdb(0x77)](a6_0x3026d8[_0x3f0cdb(0x7b)](),_0x555819[_0x3f0cdb(0x75)](0x1)):_0x555819,_0x54c439=a6_0x59682d[_0x3f0cdb(0x74)](_0x673f97),_0x512754=await a6_0x11afe4[_0x3f0cdb(0x6f)](_0x54c439);return normalizePath(_0x512754);}catch{return null;}}function formatDirectoryError(_0x398150,_0x56653f,_0x727b00){const _0x2279e6=a6_0x4ef4;if(_0x727b00)return _0x2279e6(0x6a)+_0x727b00+':\x20'+_0x398150;const _0x444ed7=_0x56653f instanceof Error?_0x56653f[_0x2279e6(0x7e)]:String(_0x56653f);return _0x2279e6(0x72)+_0x398150+_0x2279e6(0x71)+_0x444ed7;}export async function getValidRootDirectories(_0x49418e){const _0x54cdaa=a6_0x4ef4,_0x1a717d=[];for(const _0x1fa9d2 of _0x49418e){const _0x2c2441=await parseRootUri(_0x1fa9d2[_0x54cdaa(0x73)]);if(!_0x2c2441){logMcpStderr(formatDirectoryError(_0x1fa9d2[_0x54cdaa(0x73)],undefined,_0x54cdaa(0x69)));continue;}try{const _0x1ea465=await a6_0x11afe4['stat'](_0x2c2441);_0x1ea465[_0x54cdaa(0x6c)]()?_0x1a717d[_0x54cdaa(0x67)](_0x2c2441):logMcpStderr(formatDirectoryError(_0x2c2441,undefined,_0x54cdaa(0x6b)));}catch(_0x4d9baa){logMcpStderr(formatDirectoryError(_0x2c2441,_0x4d9baa));}}return _0x1a717d;}
|
|
@@ -8,6 +8,9 @@ export declare const TOOL_NAMES: {
|
|
|
8
8
|
readonly EDIT_FILE: "edit_file";
|
|
9
9
|
readonly CODEBASE_SEARCH: "codebase_search";
|
|
10
10
|
readonly GITHUB_CODEBASE_SEARCH: "github_codebase_search";
|
|
11
|
+
readonly LIST_REFLEXES: "list_reflexes";
|
|
12
|
+
readonly REFLEX_SUMMARY: "reflex_summary";
|
|
13
|
+
readonly GET_REFLEX_TRACES: "get_reflex_traces";
|
|
11
14
|
};
|
|
12
15
|
export type ToolName = (typeof TOOL_NAMES)[keyof typeof TOOL_NAMES];
|
|
13
16
|
export declare const ALL_TOOL_NAMES: readonly ToolName[];
|
package/dist/tool-definitions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a7_0xcb5983=a7_0x481e;(function(_0xc74c80,_0x2b3262){const _0x167c82=a7_0x481e,_0xe8fac9=_0xc74c80();while(!![]){try{const _0x6f00a1=-parseInt(_0x167c82(0x164))/0x1+-parseInt(_0x167c82(0x16a))/0x2*(-parseInt(_0x167c82(0x161))/0x3)+-parseInt(_0x167c82(0x165))/0x4*(parseInt(_0x167c82(0x16c))/0x5)+-parseInt(_0x167c82(0x167))/0x6+-parseInt(_0x167c82(0x15f))/0x7+parseInt(_0x167c82(0x166))/0x8*(-parseInt(_0x167c82(0x169))/0x9)+parseInt(_0x167c82(0x163))/0xa;if(_0x6f00a1===_0x2b3262)break;else _0xe8fac9['push'](_0xe8fac9['shift']());}catch(_0x3ba75c){_0xe8fac9['push'](_0xe8fac9['shift']());}}}(a7_0x1a01,0xdf453));export const TOOL_NAMES={'EDIT_FILE':a7_0xcb5983(0x16b),'CODEBASE_SEARCH':a7_0xcb5983(0x16e),'GITHUB_CODEBASE_SEARCH':'github_codebase_search','LIST_REFLEXES':a7_0xcb5983(0x168),'REFLEX_SUMMARY':a7_0xcb5983(0x160),'GET_REFLEX_TRACES':a7_0xcb5983(0x16d)};function a7_0x481e(_0x461047,_0x2261ab){_0x461047=_0x461047-0x15f;const _0x1a01a2=a7_0x1a01();let _0x481e09=_0x1a01a2[_0x461047];return _0x481e09;}export const ALL_TOOL_NAMES=Object[a7_0xcb5983(0x162)](TOOL_NAMES);export const KNOWN_TOOL_NAMES=new Set(ALL_TOOL_NAMES);function a7_0x1a01(){const _0x1855c7=['9200uTIIlY','4412340mxdQPA','list_reflexes','13428YttAqD','30JkdjMq','edit_file','100ItyrFb','get_reflex_traces','codebase_search','7268072PKXIwW','reflex_summary','169287ACiCvw','values','46172630lhKQSf','248417DUSqIT','162256PkxgDB'];a7_0x1a01=function(){return _0x1855c7;};return a7_0x1a01();}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morphllm/morphmcp",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.205",
|
|
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)",
|