Skip to content

Commit

Permalink
use plugin-node from main
Browse files Browse the repository at this point in the history
  • Loading branch information
juanc07 committed Jan 5, 2025
1 parent 7da65a8 commit 9d7d15f
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 194 deletions.
163 changes: 64 additions & 99 deletions packages/plugin-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Core Node.js plugin for Eliza OS that provides essential services and actions fo

The Node plugin serves as a foundational component of Eliza OS, bridging core Node.js capabilities with the Eliza ecosystem. It provides crucial services for file operations, media processing, speech synthesis, and cloud integrations, enabling both local and cloud-based functionality for Eliza agents.


## Features

- **AWS S3 Integration**: File upload and management with AWS S3
Expand All @@ -28,13 +29,11 @@ npm install @elizaos/plugin-node
The plugin requires various environment variables depending on which services you plan to use:

### Core Settings

```env
OPENAI_API_KEY=your_openai_api_key
```

### Voice Settings (Optional)

```env
ELEVENLABS_XI_API_KEY=your_elevenlabs_api_key
ELEVENLABS_MODEL_ID=eleven_monolingual_v1
Expand All @@ -47,7 +46,6 @@ VITS_VOICE=en_US-hfc_female-medium
```

### AWS Settings (Optional)

```env
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
Expand All @@ -71,79 +69,65 @@ elizaOS.registerPlugin(nodePlugin);
## Services

### AwsS3Service

Handles file uploads and management with AWS S3.

### BrowserService

Provides web scraping and content extraction capabilities using Playwright.

### ImageDescriptionService

Processes and analyzes images to generate descriptions.

### LlamaService

Provides local LLM capabilities using LLaMA models.

### PdfService

Extracts and processes text content from PDF files.

### SpeechService

Handles text-to-speech conversion using ElevenLabs and VITS.

### TranscriptionService

Converts speech to text using various providers.

### VideoService

Processes video content, including YouTube video downloads and transcription.

## Actions

### describeImage

Analyzes and generates descriptions for images.

```typescript
// Example usage
const result = await runtime.executeAction("DESCRIBE_IMAGE", {
imageUrl: "path/to/image.jpg",
imageUrl: "path/to/image.jpg"
});
```

## Dependencies

The plugin requires several peer dependencies:

- `onnxruntime-node`: 1.20.1
- `whatwg-url`: 7.1.0

And trusted dependencies:

- `onnxruntime-node`: 1.20.1
- `sharp`: 0.33.5

## Safety & Security

### File Operations

- **Path Sanitization**: All file paths are sanitized to prevent directory traversal attacks
- **File Size Limits**: Enforced limits on upload sizes
- **Type Checking**: Strict file type validation
- **Temporary File Cleanup**: Automatic cleanup of temporary files

### API Keys & Credentials

- **Environment Isolation**: Sensitive credentials are isolated in environment variables
- **Access Scoping**: Services are initialized with minimum required permissions
- **Key Rotation**: Support for credential rotation without service interruption

### Media Processing

- **Resource Limits**: Memory and CPU usage limits for media processing
- **Timeout Controls**: Automatic termination of long-running processes
- **Format Validation**: Strict media format validation before processing
Expand All @@ -153,41 +137,34 @@ And trusted dependencies:
### Common Issues

1. **Service Initialization Failures**

```bash
Error: Service initialization failed
```

- Verify environment variables are properly set
- Check service dependencies are installed
- Ensure sufficient system permissions

2. **Media Processing Errors**

```bash
Error: Failed to process media file
```

- Verify file format is supported
- Check available system memory
- Ensure ffmpeg is properly installed

3. **AWS S3 Connection Issues**

```bash
Error: AWS credentials not configured
```

- Verify AWS credentials are set
- Check S3 bucket permissions
- Ensure correct region configuration

### Debug Mode

Enable debug logging for detailed troubleshooting:

```typescript
process.env.DEBUG = "eliza:plugin-node:*";
process.env.DEBUG = 'eliza:plugin-node:*';
```

### System Requirements
Expand All @@ -200,105 +177,95 @@ process.env.DEBUG = "eliza:plugin-node:*";
### Performance Optimization

1. **Cache Management**

- Regular cleanup of `content_cache` directory
- Implement cache size limits
- Monitor disk usage
- Regular cleanup of `content_cache` directory
- Implement cache size limits
- Monitor disk usage

2. **Memory Usage**

- Configure max buffer sizes
- Implement streaming for large files
- Monitor memory consumption
- Configure max buffer sizes
- Implement streaming for large files
- Monitor memory consumption

3. **Concurrent Operations**
- Adjust queue size limits
- Configure worker threads
- Monitor process pool
- Adjust queue size limits
- Configure worker threads
- Monitor process pool

## Support

For issues and feature requests, please:

1. Check the troubleshooting guide above
2. Review existing GitHub issues
3. Submit a new issue with:
- System information
- Error logs
- Steps to reproduce
- System information
- Error logs
- Steps to reproduce

## Future Enhancements

1. **File Operations**

- Enhanced streaming capabilities
- Advanced compression options
- Batch file processing
- File type detection
- Metadata management
- Version control integration
- Enhanced streaming capabilities
- Advanced compression options
- Batch file processing
- File type detection
- Metadata management
- Version control integration

2. **Media Processing**

- Additional video formats
- Advanced image processing
- Audio enhancement tools
- Real-time processing
- Quality optimization
- Format conversion
- Additional video formats
- Advanced image processing
- Audio enhancement tools
- Real-time processing
- Quality optimization
- Format conversion

3. **Cloud Integration**

- Multi-cloud support
- Advanced caching
- CDN optimization
- Auto-scaling features
- Cost optimization
- Backup automation
- Multi-cloud support
- Advanced caching
- CDN optimization
- Auto-scaling features
- Cost optimization
- Backup automation

4. **Speech Services**

- Additional voice models
- Language expansion
- Emotion detection
- Voice cloning
- Real-time synthesis
- Custom voice training
- Additional voice models
- Language expansion
- Emotion detection
- Voice cloning
- Real-time synthesis
- Custom voice training

5. **Browser Automation**

- Headless optimization
- Parallel processing
- Session management
- Cookie handling
- Proxy support
- Resource optimization
- Headless optimization
- Parallel processing
- Session management
- Cookie handling
- Proxy support
- Resource optimization

6. **Security Features**

- Enhanced encryption
- Access control
- Audit logging
- Threat detection
- Rate limiting
- Compliance tools
- Enhanced encryption
- Access control
- Audit logging
- Threat detection
- Rate limiting
- Compliance tools

7. **Performance Optimization**

- Memory management
- CPU utilization
- Concurrent operations
- Resource pooling
- Cache strategies
- Load balancing
- Memory management
- CPU utilization
- Concurrent operations
- Resource pooling
- Cache strategies
- Load balancing

8. **Developer Tools**
- Enhanced debugging
- Testing framework
- Documentation generator
- CLI improvements
- Monitoring tools
- Integration templates
- Enhanced debugging
- Testing framework
- Documentation generator
- CLI improvements
- Monitoring tools
- Integration templates

We welcome community feedback and contributions to help prioritize these enhancements.

Expand All @@ -322,16 +289,14 @@ This plugin integrates with and builds upon several key technologies:
- [Sharp](https://sharp.pixelplumbing.com/) - Image processing

Special thanks to:

- The Node.js community and all the open-source contributors who make these integrations possible.
- The Eliza community for their contributions and feedback.

For more information about Node.js capabilities:

- [Node.js Documentation](https://nodejs.org/en/docs/)
- [Node.js Developer Portal](https://nodejs.org/en/about/)
- [Node.js GitHub Repository](https://github.com/nodejs/node)

## License

This plugin is part of the Eliza project. See the main project repository for license information.
This plugin is part of the Eliza project. See the main project repository for license information.
3 changes: 2 additions & 1 deletion packages/plugin-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@opendocsg/pdf2md": "0.1.32",
"@types/uuid": "10.0.0",
"alawmulaw": "6.0.0",
"bignumber": "1.1.0",
"bignumber.js": "9.1.2",
"capsolver-npm": "2.0.2",
"cldr-segmentation": "2.2.1",
Expand Down Expand Up @@ -86,7 +87,7 @@
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint --fix --cache .",
"postinstall": "pnpm run build && node scripts/postinstall.js"
"postinstall": "node scripts/postinstall.js"
},
"peerDependencies": {
"onnxruntime-node": "1.20.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-node/scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import os from "os";
import { elizaLogger } from "@elizaos/core";
const platform = os.platform();

if (
platform === "linux" &&
!(os.release().includes("ubuntu") || os.release().includes("debian"))
) {
elizaLogger.log(
console.log(
"Skipping playwright installation on unsupported platform:",
platform
);
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-node/src/services/awsS3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
IAwsS3Service,
Service,
ServiceType,
elizaLogger,
} from "@elizaos/core";
import {
GetObjectCommand,
Expand Down Expand Up @@ -33,7 +32,7 @@ export class AwsS3Service extends Service implements IAwsS3Service {
private runtime: IAgentRuntime | null = null;

async initialize(runtime: IAgentRuntime): Promise<void> {
elizaLogger.log("Initializing AwsS3Service");
console.log("Initializing AwsS3Service");
this.runtime = runtime;
this.fileUploadPath = runtime.getSetting("AWS_S3_UPLOAD_PATH") ?? "";
}
Expand Down
Loading

0 comments on commit 9d7d15f

Please sign in to comment.