The Integuru integration provides a powerful API reverse-engineering system that analyzes HAR (HTTP Archive) files to generate executable Python code for automating web interactions. This integration offers 8-15x speed improvements over traditional browser automation by directly calling APIs instead of simulating user interactions.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ HAR Files │───▶│ HarProcessor │───▶│ InteguruWrapper │
│ │ │ │ │ │
│ - Network logs │ │ - Validation │ │ - Code gen │
│ - API calls │ │ - Extraction │ │ - Execution │
│ - Cookies │ │ - Analysis │ │ - Error handling│
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ CodeExecutor │◀───│ DependencyAnalyzer│◀───│ Generated Code │
│ │ │ │ │ │
│ - Sandbox │ │ - Graph build │ │ - Python │
│ - Security │ │ - Critical path │ │ - APIs │
│ - Timeouts │ │ - Optimization │ │ - Auth │
└─────────────────┘ └─────────────────┘ └─────────────────┘
The main wrapper class that orchestrates the entire analysis and execution process.
Key Features:
- HAR file analysis and preprocessing
- Cookie extraction and management
- Python code generation via Integuru
- Safe code execution in isolated environment
- Error handling and timeout management
- Confidence scoring and optimization
Basic Usage:
const InteguruWrapper = require('./src/lib/integuru-wrapper');
const integuru = new InteguruWrapper({
model: 'gpt-4o',
timeout: 30000,
tempDir: './temp'
});
// Analyze HAR file and generate code
const result = await integuru.analyzeHAR(
'./network_requests.har',
'Download the generated image from KlingAI',
true // generate code
);
console.log(`Confidence: ${result.confidence}`);
console.log(`Generated code:\n${result.code}`);
// Execute the generated code
const execution = await integuru.executeCode(result.code);
console.log(`Execution successful: ${execution.success}`);Handles HAR file validation, preprocessing, and analysis.
Key Features:
- HAR format validation
- API endpoint identification
- Cookie extraction and processing
- Dynamic parameter detection
- Authentication token extraction
- Dependency graph building
- Complexity scoring
Usage:
const HarProcessor = require('./src/lib/har-processor');
const processor = new HarProcessor();
const analysis = await processor.process('./network_requests.har');
console.log(`Found ${analysis.apiEndpoints.length} API endpoints`);
console.log(`Complexity score: ${analysis.complexity.score}`);Provides secure Python code execution in an isolated environment.
Key Features:
- Sandboxed execution with resource limits
- Security restrictions and module blocking
- Timeout management
- Output capture and error handling
- Memory and CPU limits
- Temporary file management
Usage:
const CodeExecutor = require('./src/lib/code-executor');
const executor = new CodeExecutor({
timeout: 10000,
maxMemory: '256m'
});
const result = await executor.execute(pythonCode);
console.log(`Success: ${result.success}`);
console.log(`Output: ${result.output}`);Analyzes API call dependencies and builds execution graphs.
Key Features:
- Dependency graph construction
- Critical path identification
- Authentication flow analysis
- Session dependency detection
- Execution order optimization
- Performance recommendations
Usage:
const DependencyAnalyzer = require('./src/lib/dependency-analyzer');
const analyzer = new DependencyAnalyzer();
const analysis = await analyzer.analyze(processedHarData);
console.log(`Critical paths: ${analysis.criticalPaths.length}`);
console.log(`Auth flow: ${analysis.authFlow.hasAuth}`);- Node.js 18.0+
- Python 3.8+
- Poetry (for Python dependency management)
- Git
# Run the installation script
./scripts/install-integuru.sh
# This will:
# 1. Install Python dependencies
# 2. Install Poetry
# 3. Clone Integuru repository
# 4. Set up Python environment
# 5. Create helper scripts# 1. Install Node.js dependencies
npm install
# 2. Install Poetry
curl -sSL https://install.python-poetry.org | python3 -
# 3. Clone Integuru
git clone https://github.com/Integuru-AI/Integuru.git
cd Integuru
poetry install
cd ..
# 4. Set up environment
cp .env.example .env
# Edit .env with your OpenAI API keyCreate a .env file in the project root:
# OpenAI API Configuration
OPENAI_API_KEY=your_openai_api_key_here
# Integuru Configuration
INTEGURU_MODEL=gpt-4o
INTEGURU_TIMEOUT=30
INTEGURU_TEMP_DIR=./temp
# Code Execution Configuration
CODE_EXECUTOR_TIMEOUT=10
CODE_EXECUTOR_MAX_MEMORY=256m
# HAR Processing Configuration
HAR_PROCESSOR_MAX_ENTRIES=1000
HAR_PROCESSOR_EXCLUDE_EXTENSIONS=.js,.css,.png,.jpg,.gifYou can also use a JSON configuration file:
{
"integuru": {
"model": "gpt-4o",
"timeout": 30000,
"tempDir": "./temp",
"integuruDir": "./Integuru"
},
"codeExecutor": {
"timeout": 10000,
"maxMemory": "256m",
"maxCpuTime": 5,
"allowedModules": ["requests", "json", "time", "datetime"],
"blockedModules": ["os", "sys", "subprocess", "socket"]
},
"harProcessor": {
"apiPatterns": ["/api/", "/v1/", "/graphql"],
"excludeExtensions": [".js", ".css", ".png", ".jpg", ".gif"]
}
}const InteguruWrapper = require('./src/lib/integuru-wrapper');
async function downloadKlingAIImage() {
const integuru = new InteguruWrapper();
// Analyze HAR file from KlingAI image generation
const result = await integuru.analyzeHAR(
'./src/test/sample-hars/klingai-image-download.har',
'Download the generated image from KlingAI',
true
);
if (result.confidence > 0.8) {
console.log('High confidence in generated code!');
console.log('Generated Python code:');
console.log(result.code);
// Execute the code
const execution = await integuru.executeCode(result.code);
if (execution.success) {
console.log('Image downloaded successfully!');
console.log(`Output: ${execution.output}`);
} else {
console.error('Execution failed:', execution.error);
}
} else {
console.log('Low confidence, manual review recommended');
}
}
downloadKlingAIImage();const InteguruWrapper = require('./src/lib/integuru-wrapper');
async function automateCheckout() {
const integuru = new InteguruWrapper({
model: 'gpt-4o',
timeout: 60000 // Longer timeout for complex workflow
});
// Analyze checkout workflow
const result = await integuru.analyzeHAR(
'./src/test/sample-hars/ecommerce-checkout.har',
'Complete e-commerce checkout process',
true
);
console.log(`Dependency graph depth: ${result.dependency_graph.depth}`);
console.log(`API endpoints: ${result.api_endpoints.length}`);
console.log(`Confidence: ${result.confidence}`);
// Check for authentication requirements
if (result.auth_flow.hasAuth) {
console.log('Authentication flow detected');
console.log('Auth endpoints:', result.auth_flow.authEndpoints);
}
// Execute with custom environment
const execution = await integuru.executeCode(result.code, {
env: {
USER_EMAIL: 'user@example.com',
USER_PASSWORD: 'secure_password'
}
});
return execution;
}const fs = require('fs').promises;
const path = require('path');
const InteguruWrapper = require('./src/lib/integuru-wrapper');
async function batchProcessHARFiles(harDirectory) {
const integuru = new InteguruWrapper();
const files = await fs.readdir(harDirectory);
const harFiles = files.filter(file => file.endsWith('.har'));
const results = [];
for (const harFile of harFiles) {
const harPath = path.join(harDirectory, harFile);
const taskPrompt = `Automate the workflow captured in ${harFile}`;
try {
const result = await integuru.analyzeHAR(harPath, taskPrompt, true);
results.push({
file: harFile,
success: true,
confidence: result.confidence,
endpoints: result.api_endpoints.length
});
} catch (error) {
results.push({
file: harFile,
success: false,
error: error.message
});
}
}
return results;
}# Run all tests
npm run test
# Run Integuru-specific tests
npm run test:integuru
# Run code validation
npm run test:validateThe test suite includes:
- Unit Tests: Individual component testing
- Integration Tests: End-to-end workflow testing
- Security Tests: Sandbox and security validation
- Performance Tests: Timeout and resource limit testing
- Edge Case Tests: Error handling and malformed input
Sample HAR files are provided in src/test/sample-hars/:
klingai-image-download.har: Image download workflowecommerce-checkout.har: Complete checkout process
Validate generated Python code:
node src/test/validate-generated-code.js generated_code.py network.harThe CodeExecutor implements multiple security layers:
- Sandboxing: Code runs in isolated process with resource limits
- Module Restrictions: Only allowed modules can be imported
- API Blocking: Dangerous functions like
eval()andexec()are blocked - Resource Limits: Memory and CPU time are constrained
- File System Isolation: Limited file system access
- HAR files may contain sensitive data (cookies, tokens)
- Temporary files are automatically cleaned up
- No data is sent to external services except Integuru API
- Consider sanitizing HAR files before processing
- Review Generated Code: Always review generated code before execution
- Use Sandboxes: Execute in isolated environments
- Limit Permissions: Run with minimal required permissions
- Monitor Resources: Watch for excessive resource usage
- Validate Inputs: Validate all inputs and outputs
# Check Python version
python3 --version # Should be 3.8+
# Install Poetry manually
curl -sSL https://install.python-poetry.org | python3 -
# Verify Poetry installation
poetry --version// Increase timeout
const executor = new CodeExecutor({
timeout: 30000, // 30 seconds
maxMemory: '512m'
});# Validate HAR format
node -e "console.log(JSON.parse(require('fs').readFileSync('test.har', 'utf8')))"- Check HAR file quality (complete requests/responses)
- Ensure authentication flows are captured
- Verify API calls are not obfuscated
- Consider providing more specific task prompts
Enable debug logging:
const integuru = new InteguruWrapper({
debug: true,
verbose: true
});- Use Appropriate Models:
o1-minifor simple tasks,gpt-4ofor complex ones - Optimize HAR Files: Remove unnecessary requests
- Cache Results: Reuse successful analyses
- Parallel Processing: Process independent workflows in parallel
// Clean up temporary files
await integuru.cleanup();
// Get execution statistics
const stats = await integuru.getStats();
console.log('Memory usage:', stats.memoryUsed);| Option | Type | Default | Description |
|---|---|---|---|
| model | string | 'gpt-4o' | OpenAI model to use |
| apiKey | string | process.env.OPENAI_API_KEY | OpenAI API key |
| timeout | number | 30000 | Request timeout in ms |
| tempDir | string | './temp' | Temporary directory |
Analyzes a HAR file and generates automation code.
Parameters:
harFile(string): Path to HAR filetaskPrompt(string): Description of the taskgenerateCode(boolean): Whether to generate executable code
Returns: Promise with analysis results
Executes Python code in isolated environment.
Parameters:
code(string): Python code to executeoptions(Object): Execution options
Returns: Promise with execution results
Processes and analyzes HAR file.
Returns: Promise with processed data
Extracts cookies from HAR file.
Returns: Promise of cookie objects
| Option | Type | Default | Description |
|---|---|---|---|
| timeout | number | 10000 | Execution timeout in ms |
| maxMemory | string | '256m' | Memory limit |
| allowedModules | Array | ['requests', 'json'] | Allowed Python modules |
Executes Python code securely.
Returns: Promise with execution results
Validates code for security issues.
Returns: Object with validation results
Analyzes dependencies in processed HAR data.
Returns: Promise with dependency analysis
# Clone repository
git clone <repository-url>
cd cdp-integuru-automation
# Install dependencies
npm install
# Run tests
npm test
# Start development server
npm run dev- Use ESLint configuration
- Follow JavaScript Standard Style
- Add JSDoc comments for public methods
- Write unit tests for new features
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
MIT License - see LICENSE file for details.
- Issues: GitHub Issues
- Documentation: Wiki
- Discussions: GitHub Discussions
- Initial release
- Integuru integration
- HAR processing and analysis
- Secure code execution
- Dependency analysis
- Comprehensive test suite
- Documentation and examples