UNPKG

agente-toolkit

Version:

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

157 lines (137 loc) 4.47 kB
import fs from 'fs'; import require$$1 from 'os'; import path from 'path'; import require$$0 from 'child_process'; import { __require as requireCoerce } from '../../semver/functions/coerce.js'; import { __require as requireGte } from '../../semver/functions/gte.js'; import { __require as requirePlatform } from './platform.js'; import require$$7 from '../package.json.js'; var libvips; var hasRequiredLibvips; function requireLibvips () { if (hasRequiredLibvips) return libvips; hasRequiredLibvips = 1; const fs$1 = fs; const os = require$$1; const path$1 = path; const spawnSync = require$$0.spawnSync; const semverCoerce = requireCoerce(); const semverGreaterThanOrEqualTo = requireGte(); const platform = requirePlatform(); const { config } = require$$7; const env = process.env; const minimumLibvipsVersionLabelled = env.npm_package_config_libvips || /* istanbul ignore next */ config.libvips; const minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).version; const spawnSyncOptions = { encoding: 'utf8', shell: true }; const vendorPath = path$1.join(__dirname, '..', 'vendor', minimumLibvipsVersion, platform()); const mkdirSync = function (dirPath) { try { fs$1.mkdirSync(dirPath, { recursive: true }); } catch (err) { /* istanbul ignore next */ if (err.code !== 'EEXIST') { throw err; } } }; const cachePath = function () { const npmCachePath = env.npm_config_cache || /* istanbul ignore next */ (env.APPDATA ? path$1.join(env.APPDATA, 'npm-cache') : path$1.join(os.homedir(), '.npm')); mkdirSync(npmCachePath); const libvipsCachePath = path$1.join(npmCachePath, '_libvips'); mkdirSync(libvipsCachePath); return libvipsCachePath; }; const integrity = function (platformAndArch) { return env[`npm_package_config_integrity_${platformAndArch.replace('-', '_')}`] || config.integrity[platformAndArch]; }; const log = function (item) { if (item instanceof Error) { console.error(`sharp: Installation error: ${item.message}`); } else { console.log(`sharp: ${item}`); } }; const isRosetta = function () { /* istanbul ignore next */ if (process.platform === 'darwin' && process.arch === 'x64') { const translated = spawnSync('sysctl sysctl.proc_translated', spawnSyncOptions).stdout; return (translated || '').trim() === 'sysctl.proc_translated: 1'; } return false; }; const globalLibvipsVersion = function () { if (process.platform !== 'win32') { const globalLibvipsVersion = spawnSync('pkg-config --modversion vips-cpp', { ...spawnSyncOptions, env: { ...env, PKG_CONFIG_PATH: pkgConfigPath() } }).stdout; /* istanbul ignore next */ return (globalLibvipsVersion || '').trim(); } else { return ''; } }; const hasVendoredLibvips = function () { return fs$1.existsSync(vendorPath); }; /* istanbul ignore next */ const removeVendoredLibvips = function () { fs$1.rmSync(vendorPath, { recursive: true, maxRetries: 3, force: true }); }; /* istanbul ignore next */ const pkgConfigPath = function () { if (process.platform !== 'win32') { const brewPkgConfigPath = spawnSync( 'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2', spawnSyncOptions ).stdout || ''; return [ brewPkgConfigPath.trim(), env.PKG_CONFIG_PATH, '/usr/local/lib/pkgconfig', '/usr/lib/pkgconfig', '/usr/local/libdata/pkgconfig', '/usr/libdata/pkgconfig' ].filter(Boolean).join(':'); } else { return ''; } }; const useGlobalLibvips = function () { if (Boolean(env.SHARP_IGNORE_GLOBAL_LIBVIPS) === true) { return false; } /* istanbul ignore next */ if (isRosetta()) { log('Detected Rosetta, skipping search for globally-installed libvips'); return false; } const globalVipsVersion = globalLibvipsVersion(); return !!globalVipsVersion && /* istanbul ignore next */ semverGreaterThanOrEqualTo(globalVipsVersion, minimumLibvipsVersion); }; libvips = { minimumLibvipsVersion, minimumLibvipsVersionLabelled, cachePath, integrity, log, globalLibvipsVersion, hasVendoredLibvips, removeVendoredLibvips, pkgConfigPath, useGlobalLibvips, mkdirSync }; return libvips; } export { requireLibvips as __require }; //# sourceMappingURL=libvips.js.map