@voyager-0x/agent-mcp
Version:
Voyager MCP Agent - A powerful Model Context Protocol agent
34 lines (33 loc) • 986 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.util = void 0;
const log_1 = require("./log");
exports.util = {
parseJson(json) {
if (json) {
try {
return JSON.parse(json);
}
catch (error) {
log_1.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_1.log.info('方法未找到', error);
}
else {
// 其他错误重新抛出
throw error;
}
},
};