@voyager-0x/agent-mcp
Version:
Voyager MCP Agent - A powerful Model Context Protocol agent
31 lines (30 loc) • 876 B
JavaScript
import { log } from './log';
export const util = {
parseJson(json) {
if (json) {
try {
return JSON.parse(json);
}
catch (error) {
log.error('Error parsing JSON:', error);
return null;
}
}
return null;
},
removeThinkConetnt(content) {
// const idx = content.indexOf("</think>");
// return idx !== -1 ? content.slice(idx + 8).trim() : content.trim();
return content.replace(/([\s\S]*?)<\/think>/, '').trim();
},
handlerNotFoundError(error) {
// 如果是方法未找到错误(-32601),继续处理其他模块
if (error.code === -32601) {
log.info('方法未找到', error);
}
else {
// 其他错误重新抛出
throw error;
}
},
};