Let language models run code with intelligent action system
Project description
UniShell
AI-powered natural language command execution with cloud gateway integration.
Features
- Natural Language Commands: Execute system operations using plain English
- Gateway Integration: Remote command execution through cloud gateway
- Desktop Agent Mode: Run as background agent for remote management
- Action Registry: 90+ pre-built actions for system, file, app, and network operations
- Multi-LLM Support: Works with OpenAI, Azure OpenAI, and local models
- Safe Execution: Built-in policy engine and rollback capabilities
Installation
pip install unishell-q
Quick Start
Local Interactive Mode
# Basic usage
unishell
# With Azure OpenAI
unishell --model azure/gpt-4o --api_key YOUR_KEY --api_base YOUR_ENDPOINT --api_version 2024-08-01-preview
# With OpenAI
export OPENAI_API_KEY=your-key
unishell --model gpt-4o
# Auto-run mode (skip approval)
unishell -y
Desktop Agent Mode (Gateway Integration)
Run UniShell as a background agent that executes commands from a cloud gateway:
# Start agent with gateway connection
unishell --model azure/gpt-4o --api_key YOUR_KEY --api_base YOUR_ENDPOINT --api_version 2024-08-01-preview --agent
# Configure gateway on first run
Gateway URL: http://192.168.100.227:8000
Device Token: <your-device-token>
# Agent runs in background, CLI accepts commands
> open notepad.exe
> create folder test in C:\Users\Desktop
How Agent Mode Works:
- Agent polls gateway for pending commands
- Executes commands locally on your desktop
- Reports results back to gateway
- Cloud UI shows execution status
Gateway Configuration
Agent credentials are stored in ~/.unishell/gateway_config.json:
{
"gateway_enabled": true,
"gateway_url": "http://192.168.100.227:8000",
"device_token": "your-device-token"
}
To reconfigure, delete the file and restart with --agent flag.
Usage Examples
System Operations
> lock my screen
> shutdown system in 60 seconds
> get system info
> check CPU and RAM usage
File Operations
> create a file named test.txt in desktop
> copy file.txt to backup folder
> delete old_file.txt
> rename document.txt to report.txt
Application Management
> open notepad.exe
> install chrome
> force close firefox
> list installed apps
Network Operations
> ping google.com
> flush DNS cache
> check my IP address
> disconnect wifi
Python API
from unishell import unishell
# Configure LLM
unishell.llm.model = "gpt-4o"
unishell.llm.api_key = "your-key"
# Execute commands
unishell.chat("Create a Python script")
# Use gateway orchestrator
from unishell.core.gateway import ExecutionOrchestrator
from unishell.core.intent import LLMIntentClassifier, LLMParameterExtractor
from unishell.core.action_registry import DynamicActionLoader
loader = DynamicActionLoader()
registry = loader.load_all()
classifier = LLMIntentClassifier(llm_client, model_name="gpt-4o")
extractor = LLMParameterExtractor(llm_client, model_name="gpt-4o")
orchestrator = ExecutionOrchestrator(classifier, extractor, registry)
result = orchestrator.execute("open notepad", dry_run=False)
Architecture
Local Mode
User Input → Intent Classifier → Parameter Extractor → Policy Engine → Executor → Result
Gateway Mode
Cloud UI → Gateway (Redis) → Desktop Agent → Local Executor → Gateway → Cloud UI
↓ ↑
Stores Action Polls & Reports
Command Line Options
# Model Configuration
--model, -m Language model to use
--api_key, -ak API key for LLM
--api_base, -ab API base URL
--api_version, -av API version
--temperature, -t Model temperature
# Agent Mode
--agent, -ag Start desktop agent mode
--gateway_url, -gu Gateway URL for agent
--device_token, -dtoken Device token for authentication
# Execution Options
--auto_run, -y Automatically run generated code
--verbose, -v Print detailed logs
--safe_mode Enable safety mechanisms (off/ask/auto)
# Other Options
--profile, -p Load configuration profile
--offline, -o Disable online features
--version Show version number
Action Registry
UniShell includes 90+ pre-built actions across categories:
- Application: open, install, uninstall, update, force_close, list
- File: create, read, write, delete, copy, move, rename, search
- Folder: create, delete, list
- System: shutdown, restart, sleep, hibernate, lock, info, resources
- Network: ping, check_ip, flush_dns, wifi_connect, wifi_disconnect
- Service: start, stop, restart, enable, disable
- Process: kill, list
- Monitoring: cpu_threshold, ram_spike, disk_full, error_logs
Actions are defined in unishell/core/action_registry/actions/.
Gateway Integration
Desktop Registration
- Access gateway UI:
http://your-gateway:8000 - Login with credentials
- Register desktop to get device token
- Use token with
--agentflag
Remote Command Execution
- Submit command through gateway UI
- Gateway queues action (PENDING)
- Desktop agent polls and retrieves action
- Agent executes locally (RUNNING)
- Agent reports result (COMPLETED/FAILED)
- UI displays result
Agent Configuration
First run prompts for configuration:
🤖 Desktop Agent Configuration
==================================================
Gateway URL: http://192.168.100.227:8000
Device Token: <paste-your-token>
Or provide via command line:
unishell --agent --gateway_url http://gateway:8000 --device_token YOUR_TOKEN
Security
- Policy Engine: Validates permissions before execution
- Dry Run Mode: Preview actions without executing
- Path Validation: Prevents directory traversal attacks
- Safe Mode: Optional code scanning and confirmation
- Device Authentication: Token-based gateway access
Troubleshooting
Agent Not Connecting
# Check gateway URL is accessible
curl http://192.168.100.227:8000/health
# Verify device token is valid
# Delete config and reconfigure
rm ~/.unishell/gateway_config.json
unishell --agent
Command Execution Fails
# Run with verbose logging
unishell --agent --verbose
# Check action exists
# View available actions in unishell/core/action_registry/actions/
Application Not Found
# Use full executable name
> open notepad.exe # ✓ Correct
> open notepad # ✗ May fail
# Check app is installed
> list installed apps
Development
# Clone repository
git clone <repo-url>
cd unishell
# Install in development mode
pip install -e .
# Run tests
pytest tests/
# Add new action
# Create JSON definition in unishell/core/action_registry/actions/
# Implement handler in unishell/core/execution/safe_os_adapter.py
Version
Current Version: 0.5.2
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unishell_q-0.5.2.tar.gz.
File metadata
- Download URL: unishell_q-0.5.2.tar.gz
- Upload date:
- Size: 273.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a37bde10f27867bb2b75b864a2b8dbd08dbcadfd1aec00e2273e872d0ac9e04c
|
|
| MD5 |
d3d1ae1c7c0ef257eeaf41b3e0e03492
|
|
| BLAKE2b-256 |
1b16a1e6ad0647a545dd6c62230f75966323c3ea81d48bfc865ed97c88d485cd
|
File details
Details for the file unishell_q-0.5.2-py3-none-any.whl.
File metadata
- Download URL: unishell_q-0.5.2-py3-none-any.whl
- Upload date:
- Size: 368.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccaeb4f2442e745ae57dbd4b80e0b8a1d63756da1d8692ef8dc4afdcba7f9c64
|
|
| MD5 |
065c238176a739edf9897a8d117f4a05
|
|
| BLAKE2b-256 |
173c3cf23df7ffa6ede8d4fe0c0f098582542e9da81f7e56bb85ca3fa8ad73dc
|