Skip to main content

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:

  1. Agent polls gateway for pending commands
  2. Executes commands locally on your desktop
  3. Reports results back to gateway
  4. 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

  1. Access gateway UI: http://your-gateway:8000
  2. Login with credentials
  3. Register desktop to get device token
  4. Use token with --agent flag

Remote Command Execution

  1. Submit command through gateway UI
  2. Gateway queues action (PENDING)
  3. Desktop agent polls and retrieves action
  4. Agent executes locally (RUNNING)
  5. Agent reports result (COMPLETED/FAILED)
  6. 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

unishell_q-0.5.2.tar.gz (273.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unishell_q-0.5.2-py3-none-any.whl (368.9 kB view details)

Uploaded Python 3

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

Hashes for unishell_q-0.5.2.tar.gz
Algorithm Hash digest
SHA256 a37bde10f27867bb2b75b864a2b8dbd08dbcadfd1aec00e2273e872d0ac9e04c
MD5 d3d1ae1c7c0ef257eeaf41b3e0e03492
BLAKE2b-256 1b16a1e6ad0647a545dd6c62230f75966323c3ea81d48bfc865ed97c88d485cd

See more details on using hashes here.

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

Hashes for unishell_q-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ccaeb4f2442e745ae57dbd4b80e0b8a1d63756da1d8692ef8dc4afdcba7f9c64
MD5 065c238176a739edf9897a8d117f4a05
BLAKE2b-256 173c3cf23df7ffa6ede8d4fe0c0f098582542e9da81f7e56bb85ca3fa8ad73dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page