pyforge-method.jsā¢1.31 kB
// PyForge IDE method to add to SimpleEGWDatabase class
// This method provides Python execution capabilities for AI agents
export async function pyforgeExecute(code, action = 'execute', packageName = null, toolName = 'pyforgeExecute-function') {
console.error(`š PyForge IDE executing action: ${action}`);
try {
// Import PyForge integration
const { PyForgeIntegration } = await import('./pyforge-integration.js');
const pyforge = new PyForgeIntegration();
// Check if PyForge IDE is available
if (!pyforge.isAvailable()) {
throw new Error('ā PyForge IDE not found. Please ensure PyForge IDE is properly installed in packages/shared/src/database-utils');
}
switch (action) {
case 'execute':
return await pyforge.executePythonCode(code);
case 'install_package':
if (!packageName) {
throw new Error('ā Package name required for install_package action');
}
return await pyforge.installPackage(packageName);
case 'list_files':
return await pyforge.listFiles();
default:
throw new Error(`ā Unknown action: ${action}`);
}
} catch (error) {
console.error('ā PyForge IDE execution error:', error.message);
throw error;
}
}