Metadata-Version: 2.3
Name: emllm
Version: 0.1.9
Summary: Large Language Model Email Message registry and interpreter
License: Apache-2.0
Author: Tom Sapletta
Author-email: info@softreck.dev
Requires-Python: >=3.8.1,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.8
Requires-Dist: fastapi (>=0.104.1,<0.105.0)
Requires-Dist: pydantic (>=2.4.2,<3.0.0)
Requires-Dist: uvicorn (>=0.24.0,<0.25.0)
Project-URL: Bug Tracker, https://github.com/emllm/eml/issues
Project-URL: Homepage, https://github.com/emllm/eml
Description-Content-Type: text/markdown

# EMLLM (Email Message Language for LLM)

[![PyPI Version](https://img.shields.io/pypi/v/emllm.svg)](https://pypi.org/project/emllm/)
[![Python Versions](https://img.shields.io/pypi/pyversions/emllm.svg)](https://pypi.org/project/emllm/)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Documentation Status](https://readthedocs.org/projects/emllm/badge/?version=latest)](https://emllm.readthedocs.io/)
[![Tests](https://github.com/emllm/eml/actions/workflows/tests.yml/badge.svg)](https://github.com/emllm/eml/actions)
[![Codecov](https://codecov.io/gh/emllm/eml/branch/main/graph/badge.svg)](https://codecov.io/gh/emllm/eml)

EMLLM is a powerful Python library for parsing, validating, and generating email messages with support for LLM integration. It provides a simple and intuitive API for working with email messages in various formats.

## ✨ Features

- Parse and validate email messages
- Generate email messages programmatically
- Support for MIME messages and attachments
- Integration with Large Language Models
- Command-line interface for easy usage
- REST API for remote processing
- Comprehensive test coverage
- Type hints for better development experience

## 🚀 Quick Start

### Installation

```bash
pip install emllm
```

### Basic Usage

```python
from emllm import EMLLMParser

# Initialize the parser
parser = EMLLMParser()

# Parse an email message
message = """
From: sender@example.com
To: recipient@example.com
Subject: Test Message

Hello, this is a test message.
"""

parsed = parser.parse(message)
print(parsed)
```

## 📚 Documentation

Full documentation is available at [emllm.readthedocs.io](https://emllm.readthedocs.io/).

Key sections:
- [Installation Guide](docs/installation/index.md)
- [Usage Examples](docs/usage/index.md)
- [API Reference](docs/api/index.md)
- [Contributing](CONTRIBUTING.md)

## 🤝 Contributing

Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, or suggest new features.

## 📄 License

This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.

## 📫 Contact

For questions or support, please open an issue on [GitHub](https://github.com/emllm/eml/issues).

---

<p align="center">
  Made with ❤️ by the EMLLM Team
</p>

EMLLM is an advanced system for AI-generated software distribution, using email infrastructure as a transport protocol. The system combines the capabilities of Large Language Models with traditional email infrastructure, enabling the automatic distribution of dynamically generated code/applications.

## 🛠️ Installation

```bash
pip install emllm
```

- Trudność w code signing i verification
- Podatność na email interception

**Problemy ze skalowalnością:**
- Email attachment size limits (zazwyczaj 25-50MB)
- SMTP delivery delays i retry mechanisms
- Brak real-time feedback o deployment status

**Złożoność debugowania:**
- Trudność w śledzeniu błędów deployment
- Ograniczone logging capabilities
- Problemy z dependency resolution

**Compliance i audit issues:**
- Potencjalne konflikty z corporate IT policies
- Trudności w change management tracking
- Legal issues z automated code distribution

## Sposób dystrybucji w praktyce

### **Architektura systemu**

```bash
┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   User Request  │───▶│   LLM Generator │───▶│  SMTP Gateway   │
│  (Webhook/API)  │    │   (Code Gen)    │    │   (Email Send)  │
└─────────────────┘    └─────────────────┘    └─────────────────┘
                                │                       │
                                ▼                       ▼
                       ┌─────────────────┐    ┌─────────────────┐
                       │   Metadata      │    │   User Inbox    │
                       │   Packaging     │    │   (Receive)     │
                       └─────────────────┘    └─────────────────┘
                                │                       │
                                ▼                       ▼
                       ┌─────────────────┐    ┌─────────────────┐
                       │  EML Creation   │    │  Auto Extract   │
                       │  (Self-Extract) │    │   (Execute)     │
                       └─────────────────┘    └─────────────────┘
```

### **Flow procesu:**

1. **Request initiation**: Webhook lub API call z parametrami aplikacji
2. **LLM Processing**: AI generuje kod bazując na input parameters
3. **Metadata enrichment**: Automatyczne dodawanie dependencies, configs
4. **EML Packaging**: Tworzenie samorozpakowującego się email archive
5. **SMTP Delivery**: Wysyłka przez konfigurowany SMTP server
6. **Client Reception**: Otrzymanie i automatyczne przetworzenie
7. **Execution**: Uruchomienie aplikacji w target environment

### **Wykorzystanie webhooków:**

**Inbound webhooks** (triggering generacji):
```json
{
  "app_type": "dashboard",
  "requirements": ["Python", "FastAPI", "Docker"],
  "recipient": "developer@company.com",
  "parameters": {
    "database": "PostgreSQL",
    "auth": "OAuth2",
    "deployment": "containerized"
  }
}
```

**Outbound webhooks** (status notifications):
```json
{
  "status": "email_sent",
  "request_id": "req_12345",
  "recipient": "developer@company.com",
  "timestamp": "2025-06-19T10:30:00Z",
  "tracking_id": "email_67890"
}
```

## Przykłady zastosowań

### **1. Enterprise Internal Tools**
- Automatyczne generowanie admin dashboards
- Custom reporting applications
- One-off automation scripts dla specific tasks

### **2. Client Deliverables**
- Personalized demos dla sales presentations
- Custom integrations dla client environments
- Proof-of-concept applications

### **3. Emergency Deployments**
- Hotfix distribution gdy CI/CD is down
- Disaster recovery tools
- Quick patches dla critical systems

### **4. Training i Development**
- Personalized learning environments
- Custom exercise generators
- Development environment setup

## Techniczne aspekty implementacji

### **LLM Integration considerations:**

**Model selection criteria:**
- Code generation capabilities (Python, JavaScript, Docker)
- Support for structured output (JSON metadata)
- Rate limiting i cost considerations
- Local vs. cloud deployment options

**Prompt engineering patterns:**
```python
GENERATION_PROMPT = """
Generate a complete {app_type} application with the following requirements:
- Technology stack: {tech_stack}
- Deployment target: {deployment_target}
- Features: {features}

Include:
1. Complete source code
2. Dockerfile dla containerization
3. Deployment instructions
4. Configuration files
5. Basic tests

Output as JSON with file paths and contents.
"""
```

### **SMTP Server considerations:**

**Authentication i security:**
- OAuth2 dla Gmail/Office365 integration
- SMTP-AUTH dla dedicated servers
- TLS encryption dla all communications
- Rate limiting dla abuse prevention

**Delivery optimization:**
- Queue management dla bulk operations
- Retry logic dla failed deliveries
- Monitoring i alerting dla SMTP health
- Load balancing across multiple SMTP servers

### **Email formatting strategies:**

**MIME structure optimization:**
```
multipart/mixed
├── text/plain (human readable summary)
├── text/html (rich formatted instructions)
├── application/octet-stream (source_code.zip)
├── application/json (metadata.json)
└── text/x-dockerfile (Dockerfile)
```

**Metadata standardization:**
```json
{
  "version": "1.0",
  "generated_at": "2025-06-19T10:30:00Z",
  "llm_model": "gpt-4",
  "request_id": "req_12345",
  "app_metadata": {
    "name": "Custom Dashboard",
    "type": "web_application",
    "runtime": "python:3.11",
    "dependencies": ["fastapi", "uvicorn", "pydantic"]
  },
  "deployment": {
    "method": "docker",
    "port": 8080,
    "environment_vars": ["DATABASE_URL", "SECRET_KEY"]
  },
  "execution_instructions": [
    "docker build -t custom-dashboard .",
    "docker run -p 8080:8080 custom-dashboard"
  ]
}
```

## Porównanie z alternatywnymi rozwiązaniami

| Aspekt | Email Distribution | GitHub Actions | Docker Registry | Package Managers |
|--------|-------------------|----------------|-----------------|------------------|
| **Setup Complexity** | Niski | Średni | Średni | Wysoki |
| **Infrastructure Deps** | Email only | Git + CI/CD | Registry server | Package repos |
| **Real-time Feedback** | Ograniczony | Excellent | Good | Good |
| **Security** | Podstawowy | Strong | Strong | Excellent |
| **Versioning** | Email history | Git-based | Tag-based | Semantic versioning |
| **Rollback** | Manual resend | Automated | Tag switching | Version downgrade |
| **Enterprise Integration** | Native | Good | Good | Excellent |
| **Debugging** | Limited | Excellent | Good | Good |

## Implementacja referencyjna

System składa się z trzech głównych komponentów:

### **1. AI Code Generator Service**
- REST API dla request handling
- LLM integration (OpenAI/Anthropic/Local)
- Template management system
- Code validation i testing

### **2. Email Distribution Service**  
- SMTP server integration
- Email template generation
- Attachment handling
- Delivery tracking

### **3. Client Integration Tools**
- Email parsing utilities
- Automatic extraction scripts
- Execution wrappers
- Status reporting hooks

## Wnioski i rekomendacje

**Email-based AI software distribution** to interesująca koncepcja dla specific use cases, ale nie zastąpi tradycyjnych methods dla production systems. 

**Zalecane zastosowania:**
- Prototyping i rapid development
- Internal tool distribution w małych teams
- Emergency deployment scenarios
- Educational i training environments

**Nie zalecane dla:**
- Production deployment systems
- Security-critical applications
- High-frequency update cycles
- Applications wymagające complex dependency management

**Kluczowe success factors:**
- Strong email infrastructure
- Proper security protocols
- Clear governance policies
- Comprehensive monitoring
- User education i training



# Uniwersalne launchery dla różnych platform

## 📁 Struktura projektu

```
emllm/
├── src/
│   └── emllm/
│       ├── __init__.py
│       ├── api.py
│       ├── core.py
│       ├── cli.py
│       └── validator.py
├── tests/
├── pyproject.toml
├── Makefile
└── README.md
```

```
universal-webapp/
├── testapp.eml.py          # Główny uniwersalny plik
├── run-windows.bat             # Windows batch launcher  
├── run-macos.command           # macOS double-click launcher
├── run-linux.sh               # Linux shell launcher
├── install-python.md          # Instrukcje instalacji Python
└── README.md                   # Instrukcje użytkowania
```

## 🪟 Windows Batch Launcher (run-windows.bat)

```batch
@echo off
REM Windows Launcher for Universal EML WebApp
REM Automatycznie znajduje Python i uruchamia aplikację

title Universal EML WebApp - Windows

echo.
echo ==========================================
echo    Universal EML WebApp - Windows
echo ==========================================
echo.

REM Sprawdź czy istnieje plik główny
if not exist "testapp.eml.py" (
    echo BLAD: Nie znaleziono pliku testapp.eml.py
    echo Upewnij sie, ze plik znajduje sie w tym samym katalogu.
    pause
    exit /b 1
)

REM Znajdź Python (sprawdź różne możliwe lokalizacje)
set PYTHON_CMD=

REM Sprawdź python3
python3 --version >nul 2>&1
if %errorlevel% == 0 (
    set PYTHON_CMD=python3
    goto :python_found
)

REM Sprawdź python
python --version >nul 2>&1
if %errorlevel% == 0 (
    set PYTHON_CMD=python
    goto :python_found
)

REM Sprawdź py launcher (Windows 10+)
py --version >nul 2>&1
if %errorlevel% == 0 (
    set PYTHON_CMD=py
    goto :python_found
)

REM Sprawdź ścieżki bezpośrednie
if exist "C:\Python3*\python.exe" (
    for /f %%i in ('dir /b "C:\Python3*"') do (
        set PYTHON_CMD="C:\%%i\python.exe"
        goto :python_found
    )
)

REM Python nie znaleziony
echo BLAD: Python nie jest zainstalowany lub nie znajduje sie w PATH
echo.
echo Aby zainstalowac Python:
echo 1. Idz na https://python.org/downloads
echo 2. Pobierz Python 3.8+ dla Windows
echo 3. Podczas instalacji zaznacz "Add Python to PATH"
echo 4. Uruchom ponownie ten plik
echo.
pause
exit /b 1

:python_found
echo Znaleziono Python: %PYTHON_CMD%

REM Sprawdź wersję Python
for /f "tokens=2" %%i in ('%PYTHON_CMD% --version 2^>^&1') do set PYTHON_VERSION=%%i
echo Wersja Python: %PYTHON_VERSION%
echo.

REM Pokaż menu wyboru
echo Wybierz akcje:
echo [1] Otworz w przegladarce (domyslnie)
echo [2] Uruchom w Docker
echo [3] Wyodrebnij pliki
echo [4] Pokaz informacje
echo [5] Pomoc
echo.
set /p choice="Wybor (1-5) lub Enter dla domyslnej akcji: "

if "%choice%"=="" set choice=1
if "%choice%"=="1" set ACTION=browse
if "%choice%"=="2" set ACTION=run
if "%choice%"=="3" set ACTION=extract
if "%choice%"=="4" set ACTION=info
if "%choice%"=="5" set ACTION=help

if not defined ACTION (
    echo Nieprawidlowy wybor: %choice%
    pause
    exit /b 1
)

echo.
echo Uruchamianie: %PYTHON_CMD% testapp.eml.py %ACTION%
echo.

REM Uruchom aplikację
%PYTHON_CMD% testapp.eml.py %ACTION%

if %errorlevel% neq 0 (
    echo.
    echo Wystapil blad podczas uruchamiania aplikacji.
    echo Kod bledu: %errorlevel%
)

echo.
echo Nacisnij dowolny klawisz aby zakonczyc...
pause >nul
```

## 🍎 macOS Command Launcher (run-macos.command)

```bash
#!/bin/bash
#
# macOS Launcher for Universal EML WebApp
# Double-click to run, or use from Terminal
#

# macOS specific setup
export PATH="/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:$PATH"

# Change to script directory
cd "$(dirname "$0")"

echo "🍎 Universal EML WebApp - macOS Launcher"
echo "========================================"
echo

# Check if main file exists
if [ ! -f "testapp.eml.py" ]; then
    echo "❌ Błąd: Nie znaleziono pliku testapp.eml.py"
    echo "Upewnij się, że plik znajduje się w tym samym katalogu."
    
    # Show in Finder
    osascript -e 'tell application "Finder" to reveal POSIX file "'$(pwd)'"' 2>/dev/null
    
    echo "Naciśnij Enter aby zamknąć..."
    read
    exit 1
fi

# Find Python
PYTHON_CMD=""

# Check python3 first (preferred on macOS)
if command -v python3 > /dev/null 2>&1; then
    PYTHON_CMD="python3"
elif command -v python > /dev/null 2>&1; then
    # Check if it's Python 3
    PYTHON_VERSION=$(python --version 2>&1)
    if [[ $PYTHON_VERSION == *"Python 3"* ]]; then
        PYTHON_CMD="python"
    fi
fi

# Check Homebrew Python
if [ -z "$PYTHON_CMD" ] && [ -x "/opt/homebrew/bin/python3" ]; then
    PYTHON_CMD="/opt/homebrew/bin/python3"
elif [ -z "$PYTHON_CMD" ] && [ -x "/usr/local/bin/python3" ]; then
    PYTHON_CMD="/usr/local/bin/python3"
fi

if [ -z "$PYTHON_CMD" ]; then
    echo "❌ Błąd: Python 3 nie jest zainstalowany"
    echo
    echo "Aby zainstalować Python na macOS:"
    echo "1. Zainstaluj Homebrew: https://brew.sh"
    echo "2. Uruchom: brew install python3"
    echo "3. Lub pobierz z: https://python.org/downloads"
    echo
    
    # Offer to open installation page
    osascript -e 'display dialog "Python nie jest zainstalowany. Otworzyć stronę instalacji?" buttons {"Nie", "Tak"} default button "Tak"' 2>/dev/null
    if [ $? -eq 0 ]; then
        open "https://python.org/downloads/macos/"
    fi
    
    echo "Naciśnij Enter aby zamknąć..."
    read
    exit 1
fi

echo "✅ Znaleziono Python: $PYTHON_CMD"
PYTHON_VERSION=$($PYTHON_CMD --version 2>&1)
echo "📍 Wersja: $PYTHON_VERSION"
echo

# Show action menu with macOS styling
if [ "$TERM_PROGRAM" = "" ]; then
    # GUI mode (double-clicked)
    ACTION=$(osascript -e 'choose from list {"browse", "run", "extract", "info", "help"} with prompt "Wybierz akcję:" default items {"browse"}' 2>/dev/null)
    
    if [ "$ACTION" = "false" ]; then
        echo "Anulowano przez użytkownika"
        exit 0
    fi
else
    # Terminal mode
    echo "Wybierz akcję:"
    echo "1) 🌐 browse  - Otwórz w przeglądarce (domyślnie)"
    echo "2) 🐳 run     - Uruchom w Docker"  
    echo "3) 📁 extract - Wyodrębnij pliki"
    echo "4) ℹ️  info    - Pokaż informacje"
    echo "5) ❓ help    - Pomoc"
    echo
    read -p "Wybór (1-5) lub Enter dla domyślnej akcji: " choice
    
    case $choice in
        1|"") ACTION="browse" ;;
        2) ACTION="run" ;;
        3) ACTION="extract" ;;
        4) ACTION="info" ;;
        5) ACTION="help" ;;
        *) 
            echo "❌ Nieprawidłowy wybór: $choice"
            echo "Naciśnij Enter aby zamknąć..."
            read
            exit 1
            ;;
    esac
fi

echo "🚀 Uruchamianie: $PYTHON_CMD testapp.eml.py $ACTION"
echo

# Run the application
$PYTHON_CMD testapp.eml.py $ACTION

# Check exit status
if [ $? -ne 0 ]; then
    echo
    echo "❌ Wystąpił błąd podczas uruchamiania aplikacji."
    
    # Show error dialog in GUI mode
    if [ "$TERM_PROGRAM" = "" ]; then
        osascript -e 'display dialog "Wystąpił błąd podczas uruchamiania aplikacji. Sprawdź Terminal aby zobaczyć szczegóły." buttons {"OK"} default button "OK"' 2>/dev/null
    fi
fi

# Keep terminal open if launched from Finder
if [ "$TERM_PROGRAM" = "" ]; then
    echo
    echo "Naciśnij Enter aby zamknąć..."
    read
fi
```

## 🐧 Linux Shell Launcher (run-linux.sh)

```bash
#!/bin/bash
#
# Linux Launcher for Universal EML WebApp
# Works on Ubuntu, Debian, Fedora, CentOS, Arch, etc.
#

echo "🐧 Universal EML WebApp - Linux Launcher"
echo "========================================"
echo

# Change to script directory
cd "$(dirname "$0")"

# Check if main file exists
if [ ! -f "testapp.eml.py" ]; then
    echo "❌ Błąd: Nie znaleziono pliku testapp.eml.py"
    echo "Upewnij się, że plik znajduje się w tym samym katalogu."
    exit 1
fi

# Detect Linux distribution
if [ -f /etc/os-release ]; then
    . /etc/os-release
    DISTRO=$NAME
else
    DISTRO="Unknown Linux"
fi

echo "🖥️  System: $DISTRO"

# Find Python
PYTHON_CMD=""

# Check python3 first (standard on modern Linux)
if command -v python3 > /dev/null 2>&1; then
    PYTHON_CMD="python3"
elif command -v python > /dev/null 2>&1; then
    # Check if it's Python 3
    PYTHON_VERSION=$(python --version 2>&1)
    if [[ $PYTHON_VERSION == *"Python 3"* ]]; then
        PYTHON_CMD="python"
    fi
fi

# Try alternative locations
if [ -z "$PYTHON_CMD" ]; then
    for py_path in /usr/bin/python3 /usr/local/bin/python3 /opt/python3/bin/python3; do
        if [ -x "$py_path" ]; then
            PYTHON_CMD="$py_path"
            break
        fi
    done
fi

if [ -z "$PYTHON_CMD" ]; then
    echo "❌ Błąd: Python 3 nie jest zainstalowany"
    echo
    echo "Aby zainstalować Python 3:"
    
    # Distribution-specific install commands
    if command -v apt > /dev/null 2>&1; then
        echo "Ubuntu/Debian: sudo apt update && sudo apt install python3"
    elif command -v yum > /dev/null 2>&1; then
        echo "CentOS/RHEL:   sudo yum install python3"
    elif command -v dnf > /dev/null 2>&1; then
        echo "Fedora:        sudo dnf install python3"
    elif command -v pacman > /dev/null 2>&1; then
        echo "Arch Linux:    sudo pacman -S python"
    elif command -v zypper > /dev/null 2>&1; then
        echo "openSUSE:      sudo zypper install python3"
    else
        echo "Użyj menedżera pakietów twojej dystrybucji lub pobierz z python.org"
    fi
    
    exit 1
fi

echo "✅ Znaleziono Python: $PYTHON_CMD"
PYTHON_VERSION=$($PYTHON_CMD --version 2>&1)
echo "📍 Wersja: $PYTHON_VERSION"

# Check for Docker (optional)
if command -v docker > /dev/null 2>&1; then
    echo "🐳 Docker: Dostępny"
else
    echo "🐳 Docker: Niedostępny (opcjonalny - potrzebny tylko dla komendy 'run')"
fi

echo

# Show menu
echo "Wybierz akcję:"
echo "1) 🌐 browse  - Otwórz w przeglądarce (domyślnie)"
echo "2) 🐳 run     - Uruchom w Docker"
echo "3) 📁 extract - Wyodrębnij pliki"  
echo "4) ℹ️  info    - Pokaż informacje"
echo "5) ❓ help    - Pomoc"
echo

read -p "Wybór (1-5) lub Enter dla domyślnej akcji: " choice

case $choice in
    1|"") ACTION="browse" ;;
    2) ACTION="run" ;;
    3) ACTION="extract" ;;
    4) ACTION="info" ;;
    5) ACTION="help" ;;
    *) 
        echo "❌ Nieprawidłowy wybór: $choice"
        exit 1
        ;;
esac

echo
echo "🚀 Uruchamianie: $PYTHON_CMD testapp.eml.py $ACTION"
echo

# Run the application
$PYTHON_CMD testapp.eml.py $ACTION

# Check exit status
if [ $? -ne 0 ]; then
    echo
    echo "❌ Wystąpił błąd podczas uruchamiania aplikacji."
    exit 1
fi

echo
echo "✅ Zakończono pomyślnie"
```

## 📋 Instrukcje instalacji Python (install-python.md)

```markdown
# Instalacja Python dla Universal EML WebApp

## 🪟 Windows

### Opcja 1: Ze strony Python.org (Zalecane)
1. Idź na https://python.org/downloads
2. Pobierz najnowszą wersję Python 3.8+
3. **WAŻNE**: Podczas instalacji zaznacz "Add Python to PATH"
4. Kliknij "Install Now"
5. Po instalacji uruchom `run-windows.bat`

### Opcja 2: Microsoft Store
1. Otwórz Microsoft Store
2. Wyszukaj "Python 3.11" (lub nowszy)
3. Kliknij "Pobierz"
4. Python będzie dostępny jako `python3`

### Opcja 3: Chocolatey
```powershell
choco install python3
```

## 🍎 macOS  

### Opcja 1: Homebrew (Zalecane)
```bash
# Zainstaluj Homebrew jeśli nie masz
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Zainstaluj Python
brew install python3
```

### Opcja 2: Ze strony Python.org
1. Idź na https://python.org/downloads/macos
2. Pobierz installer dla macOS
3. Uruchom installer i podążaj za instrukcjami
4. Python będzie dostępny jako `python3`

### Opcja 3: pyenv (dla zaawansowanych)
```bash
brew install pyenv
pyenv install 3.11.0
pyenv global 3.11.0
```

## 🐧 Linux

### Ubuntu/Debian
```bash
sudo apt update
sudo apt install python3 python3-pip
```

### Fedora
```bash
sudo dnf install python3 python3-pip
```

### CentOS/RHEL 8+
```bash
sudo dnf install python3 python3-pip
```

### CentOS/RHEL 7
```bash
sudo yum install python3 python3-pip
```

### Arch Linux
```bash
sudo pacman -S python python-pip
```

### openSUSE
```bash
sudo zypper install python3 python3-pip
```

## ✅ Weryfikacja instalacji

Po instalacji otwórz terminal/wiersz poleceń i sprawdź:

```bash
python3 --version
# lub
python --version
```

Powinieneś zobaczyć coś jak: `Python 3.8.10` lub nowszy.

## 🐳 Docker (Opcjonalny)

Jeśli chcesz używać komendy `run` (uruchomienie w kontenerze):

### Windows/macOS
1. Pobierz Docker Desktop: https://docker.com/products/docker-desktop
2. Zainstaluj i uruchom
3. Docker będzie dostępny z wiersza poleceń

### Linux
```bash
# Ubuntu/Debian
sudo apt install docker.io
sudo systemctl start docker
sudo usermod -aG docker $USER

# Fedora
sudo dnf install docker
sudo systemctl start docker
sudo usermod -aG docker $USER

# Arch
sudo pacman -S docker
sudo systemctl start docker
sudo usermod -aG docker $USER
```

## 🔧 Rozwiązywanie problemów

### "python nie jest rozpoznany jako polecenie"
- Windows: Reinstaluj Python z opcją "Add to PATH"
- Użyj pełnej ścieżki: `C:\Python311\python.exe`

### "Permission denied" na Linux/macOS
```bash
chmod +x testapp.eml.py
chmod +x run-linux.sh      # Linux
chmod +x run-macos.command # macOS
```

### Python 2 zamiast Python 3
```bash
# Użyj explicit python3
python3 testapp.eml.py browse
```

### Brak uprawnień Docker na Linux
```bash
sudo usermod -aG docker $USER
# Wyloguj się i zaloguj ponownie
```
```

## 📖 README.md - Główne instrukcje

```markdown
# 🌍 Universal EML WebApp - Faktury Maj 2025

**Uniwersalna aplikacja webowa w formacie EML - działa na Windows, macOS i Linux!**

## 🚀 Szybki start

### Automatyczne uruchomienie (Zalecane)

**Windows:**
```
Kliknij dwukrotnie: run-windows.bat
```

**macOS:**
```
Kliknij dwukrotnie: run-macos.command
```

**Linux:**
```bash
./run-linux.sh
```

### Ręczne uruchomienie

```bash
# Wszystkie platformy
python3 testapp.eml.py [komenda]

# Windows (alternatywnie)
python testapp.eml.py [komenda]
```

## 📋 Dostępne komendy

| Komenda | Opis | Przykład |
|---------|------|----------|
| `browse` | Otwórz w przeglądarce (domyślnie) | `python3 testapp.eml.py browse` |
| `run` | Uruchom w Docker na porcie 8080 | `python3 testapp.eml.py run` |
| `extract` | Wyodrębnij pliki do katalogu temp | `python3 testapp.eml.py extract` |
| `info` | Pokaż informacje o pliku | `python3 testapp.eml.py info` |
| `help` | Wyświetl pomoc | `python3 testapp.eml.py help` |

## 🛠️ Instalacja

### Z PyPI

```bash
pip install emllm
```

### Z źródeł

```bash
git clone https://github.com/emllm/eml.git
cd eml
poetry install
```

## 💻 Wymagania systemowe

- **Python 3.8+** (standardowo dostępny)
- **Docker** (opcjonalnie, tylko dla komendy `run`)
- **Przeglądarka** (dowolna nowoczesna)

## 🎯 Funkcje

✅ **Uniwersalność** - jeden plik działa wszędzie  
✅ **Samorozpakowywanie** - wszystko w jednym pliku  
✅ **Kompatybilność email** - prawidłowy format EML  
✅ **Docker ready** - natywne wsparcie kontenerów  
✅ **Responsive design** - działa na wszystkich urządzeniach  
✅ **Zero instalacji** - tylko Python (już zainstalowany)  

## 🔧 Instalacja Python

Jeśli Python nie jest zainstalowany, zobacz: [install-python.md](install-python.md)

## 📝 License

This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.

## 📧 Format EML

Ten plik jest **jednocześnie**:
- Wykonywalnym skryptem Python
- Prawidłowym emailem EML
- Kompletną aplikacją webową

Możesz go:
- Uruchomić jako skrypt
- Otworzyć w kliencie email (Outlook, Thunderbird)
- Wysłać przez email jako załącznik

## 🌐 Wsparcie platform

| Platform | Status | Launcher | Python |
|----------|--------|----------|--------|
| Windows 10/11 | ✅ | `run-windows.bat` | `python3` / `python` |
| macOS 10.15+ | ✅ | `run-macos.command` | `python3` |
| Ubuntu 18.04+ | ✅ | `run-linux.sh` | `python3` |
| Debian 10+ | ✅ | `run-linux.sh` | `python3` |
| Fedora 30+ | ✅ | `run-linux.sh` | `python3` |
| CentOS 8+ | ✅ | `run-linux.sh` | `python3` |
| Arch Linux | ✅ | `run-linux.sh` | `python3` |

## 🐳 Docker

Jeśli masz Docker, możesz uruchomić aplikację w kontenerze:

```bash
python3 testapp.eml.py run
```

Aplikacja będzie dostępna na: http://localhost:8080

## 📱 Mobile

Aplikacja działa również w przeglądarkach mobilnych:
- Safari (iOS)
- Chrome (Android)
- Firefox Mobile

## 🔒 Bezpieczeństwo

- **Transparentny kod** - wszystko widoczne przed uruchomieniem
- **Brak zależności zewnętrznych** - tylko standardowa biblioteka Python
- **Lokalny sandbox** - aplikacja działa lokalnie
- **Docker isolation** - dodatkowa izolacja w kontenerze

## 🎨 Funkcje UI

- **Responsywny design** - dostosowuje się do ekranu
- **Animacje** - płynne przejścia i efekty
- **Powiadomienia systemowe** - natywne notyfikacje
- **Tryb ciemny** - automatyczne wykrywanie preferencji
- **Skróty klawiszowe** - Ctrl/Cmd + 1,2,3,i

## 📊 Dane biznesowe

Dashboard zawiera:
- 5 przykładowych faktur
- Łączna wartość: 13,900 PLN  
- Status płatności: 60% opłacone
- Filtrowanie po statusie
- Statystyki w czasie rzeczywistym

## 🛠️ Dla deweloperów

### Struktura pliku
```
testapp.eml.py
├── Python script (wykonywalna część)
├── EML headers (MIME metadata)
├── HTML (index.html)
├── CSS (style.css)
├── JavaScript (script.js)
├── Images (thumbnails)
├── Dockerfile
└── Metadata (JSON)
```

### Customization
Możesz zmodyfikować:
- Dane biznesowe w `script.js`
- Styling w sekcji CSS
- Layout w sekcji HTML
- Konfigurację Docker w Dockerfile

## 📞 Wsparcie

W przypadku problemów:
1. Sprawdź czy Python 3.6+ jest zainstalowany
2. Użyj odpowiedniego launchera dla swojej platformy
3. Sprawdź [install-python.md](install-python.md) dla instrukcji instalacji

## 📄 Licencja

Ten projekt jest dostępny na licencji Apache 2.0

Możesz go swobodnie używać, modyfikować i dystrybuować.

---

**🌍 Universal EML WebApp - One file, all platforms!**
```

## 🎯 Podsumowanie rozwiązania

Stworzyłem **kompletne uniwersalne rozwiązanie** składające się z:

### 1. **Główny plik** - `testapp.eml.py`
- Działa na **wszystkich platformach** (Windows, macOS, Linux)
- **Python 3.6+** jako wspólny mianownik
- **Automatyczne wykrywanie platformy**
- **GUI fallback** dla Windows (tkinter dialog)
- **Inteligentne znajdowanie Python** na każdym systemie

### 2. **Launchery platformowe**
- `run-windows.bat` - Windows batch z menu wyboru
- `run-macos.command` - macOS z osascript dialogs
- `run-linux.sh` - Linux z wykrywaniem dystrybucji

### 3. **Dokumentacja**
- Kompletne instrukcje instalacji Python
- README z opisem funkcji
- Przykłady użytkowania dla każdej platformy

### 🌟 **Kluczowe zalety:**

✅ **Jedna komenda** - `python3 testapp.eml.py`  
✅ **Zero instalacji** - tylko Python (standardowo dostępny)  
✅ **Inteligentne wykrywanie** - platformy, Python, Docker  
✅ **Graceful degradation** - zawsze znajdzie sposób działania  
✅ **User-friendly** - GUI dialogs, powiadomienia systemowe  
✅ **Cross-platform UX** - dostosowany interfejs do każdej platformy  

Ten format **EML WebApp** to rewolucyjne podejście - **jeden plik uniwersalny**, który działa dosłownie wszędzie gdzie jest Python! 🚀





















# AI LLM Email Distribution: Analiza koncepcji i implementacji

## Wprowadzenie do koncepcji

**Email jako protokół dystrybucji oprogramowania generowanego przez AI** to rewolucyjna koncepcja łącząca możliwości Large Language Models (LLM) z tradycyjną infrastrukturą email. Idea polega na automatycznej dystrybucji dynamicznie generowanego kodu/aplikacji bezpośrednio przez SMTP, wykorzystując email jako medium transportu i metadanych.

### Kluczowe elementy systemu:

- **LLM Generator**: AI model generujący kod na żądanie
- **SMTP Server**: Serwer email jako kanał dystrybucji  
- **Webhook Interface**: API do triggering generacji i wysyłki
- **Metadata Packaging**: Automatyczne tworzenie samorozpakowujących się pakietów
- **Email Parsing**: Automatyczne wyodrębnianie i wykonywanie załączników

## Wady i zalety modelu

### ✅ **Zalety**

**Infrastruktura email jest uniwersalna:**
- Każda organizacja ma już działający system email
- Brak potrzeby dodatkowych narzędzi deployment
- Naturalna kompatybilność z istniejącymi workflow

**AI-driven personalizacja:**
- Kod generowany on-demand na podstawie specyfikacji
- Dynamiczne dostosowanie do środowiska użytkownika
- Automatyczne uwzględnienie dependencies i konfiguracji

**Asynchroniczna dystrybucja:**
- Brak blocking operations podczas generacji
- Kolejkowanie requestów w SMTP queue
- Scalability przez distributed email servers

**Audit trail i wersjonowanie:**
- Naturalny system logowania przez email history
- Możliwość rollback przez resend starszych wersji
- Compliance z corporate email policies

**Zero-dependency deployment:**
- Brak potrzeby CI/CD pipeline'ów
- Nie wymaga VPN ani internal network access
- Działa przez firewall restrictions

## Sposób dystrybucji w praktyce

### **Architektura systemu**

```
┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   User Request  │───▶│   LLM Generator │───▶│  SMTP Gateway   │
│  (Webhook/API)  │    │   (Code Gen)    │    │   (Email Send)  │
└─────────────────┘    └─────────────────┘    └─────────────────┘
                                │                       │
                                ▼                       ▼
                       ┌─────────────────┐    ┌─────────────────┐
                       │   Metadata      │    │   User Inbox    │
                       │   Packaging     │    │   (Receive)     │
                       └─────────────────┘    └─────────────────┘
                                │                       │
                                ▼                       ▼
                       ┌─────────────────┐    ┌─────────────────┐
                       │  EML Creation   │    │  Auto Extract   │
                       │  (Self-Extract) │    │   (Execute)     │
                       └─────────────────┘    └─────────────────┘
```

## Techniczne aspekty implementacji

### **LLM Integration considerations:**

**Model selection criteria:**
- Code generation capabilities (Python, JavaScript, Docker)
- Support for structured output (JSON metadata)
- Rate limiting i cost considerations
- Local vs. cloud deployment options

**Prompt engineering patterns:**
```python
GENERATION_PROMPT = """
Generate a complete {app_type} application with the following requirements:
- Technology stack: {tech_stack}
- Deployment target: {deployment_target}
- Features: {features}

Include:
1. Complete source code
2. Dockerfile dla containerization
3. Deployment instructions
4. Configuration files
5. Basic tests

Output as JSON with file paths and contents.
"""
```

### **SMTP Server considerations:**

**Authentication i security:**
- OAuth2 dla Gmail/Office365 integration
- SMTP-AUTH dla dedicated servers
- TLS encryption dla all communications
- Rate limiting dla abuse prevention

**Delivery optimization:**
- Queue management dla bulk operations
- Retry logic dla failed deliveries
- Monitoring i alerting dla SMTP health
- Load balancing across multiple SMTP servers

### **Email formatting strategies:**

**MIME structure optimization:**
```
multipart/mixed
├── text/plain (human readable summary)
├── text/html (rich formatted instructions)
├── application/octet-stream (source_code.zip)
├── application/json (metadata.json)
└── text/x-dockerfile (Dockerfile)
```


## Porównanie z alternatywnymi rozwiązaniami

| Aspekt | Email Distribution | GitHub Actions | Docker Registry | Package Managers |
|--------|-------------------|----------------|-----------------|------------------|
| **Setup Complexity** | Niski | Średni | Średni | Wysoki |
| **Infrastructure Deps** | Email only | Git + CI/CD | Registry server | Package repos |
| **Real-time Feedback** | Ograniczony | Excellent | Good | Good |
| **Security** | Podstawowy | Strong | Strong | Excellent |
| **Versioning** | Email history | Git-based | Tag-based | Semantic versioning |
| **Rollback** | Manual resend | Automated | Tag switching | Version downgrade |
| **Enterprise Integration** | Native | Good | Good | Excellent |
| **Debugging** | Limited | Excellent | Good | Good |

## Implementacja referencyjna

System składa się z trzech głównych komponentów:

### **1. AI Code Generator Service**
- REST API dla request handling
- LLM integration (OpenAI/Anthropic/Local)
- Template management system
- Code validation i testing

### **2. Email Distribution Service**  
- SMTP server integration
- Email template generation
- Attachment handling
- Delivery tracking

### **3. Client Integration Tools**
- Email parsing utilities
- Automatic extraction scripts
- Execution wrappers
- Status reporting hooks

## Wnioski i rekomendacje

**Email-based AI software distribution** to interesująca koncepcja dla specific use cases, ale nie zastąpi tradycyjnych methods dla production systems. 

**Zalecane zastosowania:**
- Prototyping i rapid development
- Internal tool distribution w małych teams
- Emergency deployment scenarios
- Educational i training environments

**Nie zalecane dla:**
- Production deployment systems
- Security-critical applications
- High-frequency update cycles
- Applications wymagające complex dependency management

**Kluczowe success factors:**
- Strong email infrastructure
- Proper security protocols
- Clear governance policies
- Comprehensive monitoring
- User education i training


