UNPKG

agente-toolkit

Version:

A barebones TypeScript library for building AI agents with intelligent tool execution and self-correction capabilities

61 lines (52 loc) 1.32 kB
import fs from 'fs'; var filesystem; var hasRequiredFilesystem; function requireFilesystem () { if (hasRequiredFilesystem) return filesystem; hasRequiredFilesystem = 1; const fs$1 = fs; const LDD_PATH = '/usr/bin/ldd'; const SELF_PATH = '/proc/self/exe'; const MAX_LENGTH = 2048; /** * Read the content of a file synchronous * * @param {string} path * @returns {Buffer} */ const readFileSync = (path) => { const fd = fs$1.openSync(path, 'r'); const buffer = Buffer.alloc(MAX_LENGTH); const bytesRead = fs$1.readSync(fd, buffer, 0, MAX_LENGTH, 0); fs$1.close(fd, () => {}); return buffer.subarray(0, bytesRead); }; /** * Read the content of a file * * @param {string} path * @returns {Promise<Buffer>} */ const readFile = (path) => new Promise((resolve, reject) => { fs$1.open(path, 'r', (err, fd) => { if (err) { reject(err); } else { const buffer = Buffer.alloc(MAX_LENGTH); fs$1.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => { resolve(buffer.subarray(0, bytesRead)); fs$1.close(fd, () => {}); }); } }); }); filesystem = { LDD_PATH, SELF_PATH, readFileSync, readFile }; return filesystem; } export { requireFilesystem as __require }; //# sourceMappingURL=filesystem.js.map