@2501-ai/cli
Version:
[](https://www.npmjs.com/package/@2501-ai/cli) [](https://www.2501.ai/research/full-humaneval-benchmark) [); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AgentManager = exports.ACTION_FNS = void 0;
const fs_1 = __importDefault(require("fs"));
const actions_1 = require("../helpers/actions");
const logger_1 = __importDefault(require("../utils/logger"));
const actions_2 = require("../utils/actions");
exports.ACTION_FNS = {
browse_url: actions_1.browse_url,
read_file: actions_1.read_file,
run_shell: actions_1.run_shell,
write_file: actions_1.write_file,
update_file: actions_1.update_file,
task_completed: actions_1.task_completed,
};
class AgentManager {
constructor(options) {
this.workspace = options.workspace;
this.agentConfig = options.agentConfig;
}
executeAction(action, args) {
return __awaiter(this, void 0, void 0, function* () {
const functionName = (0, actions_2.getFunctionName)(action);
if (!exports.ACTION_FNS[functionName]) {
return {
tool_call_id: action.id,
output: `Function '${functionName}' not found. Please verify the function name and try again.`,
success: false,
};
}
let taskTitle = args.answer || args.command || '';
if (args.url) {
taskTitle = 'Browsing: ' + args.url;
}
logger_1.default.debug(` Processing action: ${taskTitle} | On function ${functionName}`);
try {
let output = (yield exports.ACTION_FNS[functionName](args));
if (output.length > 50000) {
output = `
ERROR: The output is too large to display to prevent performance issues.
Use an alternative method to retrieve the relevant information for the user (for example grep, an another command or sample the content first).
`;
return {
tool_call_id: action.id,
output,
success: false,
};
}
return {
tool_call_id: action.id,
output,
success: true,
};
}
catch (e) {
logger_1.default.debug('Error processing action:', e);
let content = '';
if (args.path) {
try {
content = `
File concerned: \`${args.path}\`
File content:
\`\`\`
${fs_1.default.readFileSync(args.path, 'utf8')}
\`\`\``;
}
catch (_a) {
}
}
return {
tool_call_id: action.id,
output: `I failed to run ${functionName}, please fix the situation or files. Feel free to explore the files again (excluding ignored files) if necessary.
Error message :
\`\`\`
${e.message}
\`\`\`${content}`,
success: false,
};
}
});
}
}
exports.AgentManager = AgentManager;