Skip to main content

๐Ÿš€ agent2win

Universal Bridge Between Web / Cloud AI Agents & Windows OS

Control your Windows PC or Server directly from AI agents (Arena.ai, ChatGPT Custom Actions, Claude, Grok, LangChain, CrewAI) via secure REST API & WebSocket.

PyPI Version License: MIT Python 3.9+ Platform: Windows Only API: REST & WebSocket


โš ๏ธ Platform Requirement:
agent2win is designed exclusively for Microsoft Windows (Windows 10, Windows 11, and Windows Server 2016+). It utilizes native Win32 APIs, COM interfaces (pyvda, pycaw), and Windows system controls.


[!WARNING] Never expose agent2win to the public internet without an API key.
Unrestricted mode permits remote command execution, filesystem access, input control, and system administration without interactive approval. Use --unrestricted only in trusted environments and stop the server immediately after use. Do not share your real API keys in public prompts, screenshots, or GitHub issues.


๐Ÿ“– Overview

agent2win is a lightweight, high-performance middleware server for Windows. It exposes a unified REST & WebSocket API, instantly accessible over the public internet through automatic Cloudflare or ngrok tunnels with zero router configuration.

Whether you are using AI environments executing curl requests in their sandboxes (like Arena.ai), connecting Custom Actions via ChatGPT, or driving automation loops with Claude, agent2win gives external models complete programmatic control over your Windows desktop.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Web & Cloud AI Ecosystem                                         โ”‚
โ”‚ โ€ข Arena.ai & curl-capable agents        โ€ข chatgpt.com (Actions)  โ”‚
โ”‚ โ€ข grok.com / xAI                        โ€ข claude.ai / Anthropic  โ”‚
โ”‚ โ€ข Autonomous Frameworks (LangChain, CrewAI, AutoGen, AutoGPT)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                  โ”‚ HTTPS / WSS (API Key Auth)
                                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Cloudflare / ngrok Public Tunnel (Zero Port-Forwarding)          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                  โ”‚
                                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ agent2win Server (:7770)                                         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ โ€ข Screen & Window Capture       โ”‚ โ€ข Mouse & Keyboard Emulation   โ”‚
โ”‚ โ€ข Shell & Command Runner        โ”‚ โ€ข Virtual Desktop Isolation    โ”‚
โ”‚ โ€ข Filesystem & Registry         โ”‚ โ€ข Process & Service Manager    โ”‚
โ”‚ โ€ข Clipboard & Audio Controls    โ”‚ โ€ข Security & Approval Layer    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Key Features

  • ๐ŸŒ Web AI Compatibility: Connect web-based models (ChatGPT Actions, Claude, Grok, Arena.ai) to operate your Windows machines.
  • โšก Zero-Config Public Tunnel: Instant public HTTPS endpoint generated automatically using Cloudflare Tunnel (cloudflared) or ngrok. No static IP or port forwarding required.
  • ๐Ÿ–ฅ๏ธ Virtual Desktop Isolation: Create dedicated secondary virtual desktops (/api/desktops). The agent works autonomously on Desktop 2 without interfering with your active tasks on Desktop 1.
  • ๐Ÿ“ธ Vision & Window Capture: Full display screenshots or targeted window-handle (hwnd) captures in Base64 format for visual reasoning.
  • ๐Ÿ–ฑ๏ธ Hardware Input Emulation: Mouse click, drag, scroll, and keyboard typing with complete Unicode / international character support.
  • ๐Ÿ’ป OS & System Administration: Run PowerShell/CMD scripts, manage filesystem (read/write/search/mkdir), list/kill processes, inspect Windows Services, and edit Registry keys.
  • ๐Ÿ”’ Security Layer: Bearer token authentication (Authorization: Bearer <key>), real-time desktop approval prompts for risky commands, system tray killswitch, and audit logging.

โšก Quick Start

1. Install from PyPI

pip install agent2win

2. Run Server (Recommended Secure Public Tunnel)

agent2win --key YOUR_STRONG_RANDOM_API_KEY --tunnel cloudflared

The console displays your live public HTTPS tunnel:

๐ŸŒ Public Tunnel : https://xxxx.trycloudflare.com

Local-Only Usage (No Public Tunnel)

agent2win --no-tunnel

๐Ÿค– Using With AI Agents & curl-Capable Platforms (Arena.ai, ChatGPT, Claude, Grok)

๐Ÿ“‹ Direct Prompt to Connect Any AI / Agent

Copy and paste this prompt directly into Arena.ai, ChatGPT, Claude, Grok, or any AI capable of web fetching or executing curl requests:

Read the official agent2win control protocol from this URL:
https://raw.githubusercontent.com/harikasinkaya/agent2win/refs/heads/main/AGENT_PROTOCOL.md

You are now an autonomous Windows controller agent.
My agent2win server URL is: <PASTE_YOUR_TUNNEL_URL_HERE>
My API key is: <PASTE_YOUR_API_KEY_HERE>

Always include the header `Authorization: Bearer <API_KEY>` in all requests.
Please inspect the system info, capture the screen, and follow my instructions to control my Windows machine.

โšก Example curl Commands (With Authentication)

# 1. Get system info
curl "https://xxxx.trycloudflare.com/api/info" \
  -H "Authorization: Bearer YOUR_API_KEY"

# 2. Capture desktop screenshot (Base64 JPEG)
curl "https://xxxx.trycloudflare.com/api/screen" \
  -H "Authorization: Bearer YOUR_API_KEY"

# 3. Execute command
curl -X POST "https://xxxx.trycloudflare.com/api/command" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cmd":"whoami"}'

# 4. Click at screen coordinates
curl -X POST "https://xxxx.trycloudflare.com/api/mouse/click" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"x": 500, "y": 300, "button": "left"}'

# 5. Type Unicode text
curl -X POST "https://xxxx.trycloudflare.com/api/keyboard/type" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello from AI Agent ๐Ÿš€", "unicode": true}'

# 6. Write file (supports forward and backslashes)
curl -X POST "https://xxxx.trycloudflare.com/api/files/write" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"path": "C:\\Users\\Public\\test.txt", "content": "agent2win test"}'

๐Ÿค– WebAPI Agent Mode (OpenAI-Compatible Gateways & GUI)

agent2win includes an autonomous agent runtime that transforms any standard OpenAI-compatible LLM gateway (DeepSeek Web, Gemini Web, vLLM, LiteLLM, Ollama) into a full Windows automation agent using plain JSON tool calling (no native function calling required).

Launch WebAPI Control Panel

agent2win --webapi

Features:

  1. Interactive Settings GUI: Configure API Base URL, API Key, Model dropdown (with auto /models discovery), timeout settings, and step limits.
  2. Allowed Folders Containment: Restrict file tools strictly to specified directories with canonical path resolution.
  3. Encrypted Storage: API keys are encrypted at rest using native Windows DPAPI (CryptProtectData).
  4. OpenAI-Compatible Endpoints:
    • POST /v1/chat/completions โ€” Standard Chat Completion endpoint executing autonomous multi-step agent loops.
    • POST /v1/responses โ€” Unified response format endpoint.
    • GET /v1/models โ€” Proxied model listing.
    • GET /api/webapi/status, POST /api/webapi/start, POST /api/webapi/stop โ€” Runtime lifecycle control.

๐Ÿ› ๏ธ CLI Options

Option Description
--webapi Open WebAPI Agent GUI to configure & connect OpenAI-compatible LLMs
--port <PORT> Server port (Default: 7770)
--host <IP> Bind IP address (Default: 0.0.0.0)
--key <SECRET> Set Bearer token for API authentication
--tunnel <PROVIDER> Tunnel provider (cloudflared or ngrok, default: cloudflared)
--no-tunnel Local-only mode (disables public tunnel)
--no-tray Disable Windows system tray icon
--unrestricted Disable action approval prompts (โš ๏ธ use carefully)
--settings Open graphical configuration GUI

โš ๏ธ Advanced / High Risk: Unrestricted Mode

For automated benchmarks and continuous integration pipelines where interactive desktop approval dialogs are not possible:

agent2win --key YOUR_STRONG_RANDOM_API_KEY --unrestricted

๐Ÿšจ Security Notice: In unrestricted mode, all valid command execution, file modifications, and OS actions are executed without confirmation prompts. Never run unrestricted mode on public networks without an API key.


๐Ÿ“ก API Reference Overview

Full protocol specifications available in AGENT_PROTOCOL.md.

๐Ÿ–ฅ๏ธ Virtual Desktops (Background Mode)

  • GET /api/desktops โ€” List all virtual desktops.
  • POST /api/desktops/setup โ€” One-click create agent virtual desktop.
  • POST /api/desktops/switch_agent โ€” Shift active view to agent desktop.
  • POST /api/desktops/switch_user โ€” Switch active view back to user primary desktop.
  • POST /api/desktops/create โ€” Create virtual desktop {"name": "Agent"}.
  • POST /api/desktops/switch โ€” Switch desktop {"index": 2}.
  • POST /api/desktops/remove โ€” Remove desktop {"index": 2}.

๐Ÿ“ธ Screen & Windows

  • GET /api/screen โ€” Full desktop screenshot (Base64 JPEG).
  • GET /api/screen/info โ€” Monitor resolutions and coordinates.
  • GET /api/windows โ€” List active windows with HWND handles, titles, and processes.
  • GET /api/windows/foreground โ€” Get active foreground window.
  • POST /api/windows/screenshot โ€” Capture specific window by hwnd.
  • POST /api/windows/focus โ€” Bring window to foreground {"hwnd": 12345}.
  • POST /api/windows/close โ€” Close window {"hwnd": 12345}.

๐Ÿ–ฑ๏ธ Mouse & Keyboard

  • POST /api/mouse/click โ€” {"x": 500, "y": 300, "button": "left"}
  • POST /api/mouse/move โ€” {"x": 500, "y": 300}
  • POST /api/mouse/scroll โ€” {"clicks": -5}
  • POST /api/keyboard/type โ€” {"text": "Hello World", "unicode": true}
  • POST /api/keyboard/press โ€” {"key": "enter"}
  • POST /api/keyboard/hotkey โ€” {"keys": ["ctrl", "c"]}

๐Ÿ’ป Shell & Filesystem

  • POST /api/command โ€” {"cmd": "whoami", "timeout": 15} (persistent server: {"cmd": "npm start", "background": true})
  • GET /api/files/list?path=C:\Users โ€” List directory contents.
  • GET /api/files/read?path=C:\test.txt โ€” Read text file.
  • POST /api/files/write โ€” Write file {"path": "C:\\test.txt", "content": "..."}.
  • POST /api/files/mkdir โ€” Create directory {"path": "C:\\folder"}.
  • POST /api/files/delete โ€” Delete file or directory {"path": "C:\\test.txt"}.
  • GET /api/files/drives โ€” List available drive letters and free space.
  • GET /api/files/search?dir=C:\&pattern=*.txt โ€” Search files matching pattern.

๐Ÿ”Š Audio & System

  • GET /api/audio/volume โ€” Get volume level {"level": 50, "muted": false}.
  • POST /api/audio/volume โ€” Set volume {"level": 50}.
  • POST /api/audio/mute / POST /api/audio/unmute โ€” Mute/unmute master audio.
  • GET /api/audio/devices โ€” List playback and recording audio devices (active, disabled, unplugged, not_present).
  • GET /api/services?filter=spooler โ€” List Windows services.
  • GET /api/clipboard / POST /api/clipboard โ€” Read/write clipboard.

๐Ÿ”ง Development Installation

To install from source for development:

git clone https://github.com/harikasinkaya/agent2win.git
cd agent2win
pip install -e .

๐Ÿ“„ License

Distributed under the MIT License. See LICENSE for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent2win-1.1.1.tar.gz (75.2 kB view details)

Uploaded Source

Built Distribution

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

agent2win-1.1.1-py3-none-any.whl (87.1 kB view details)

Uploaded Python 3

File details

Details for the file agent2win-1.1.1.tar.gz.

File metadata

  • Download URL: agent2win-1.1.1.tar.gz
  • Upload date:
  • Size: 75.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for agent2win-1.1.1.tar.gz
Algorithm Hash digest
SHA256 753aaf1f331328ee5398cd3bf583f0e85521d591a0217d44e95e5f9ee5945f79
MD5 ce1176fa460c72c30e63e92d40dbf09f
BLAKE2b-256 bf3b42726a07ae5038c73258c4dfe367209b26cecd1e29fb0add5f840c80a8ed

See more details on using hashes here.

File details

Details for the file agent2win-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: agent2win-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 87.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for agent2win-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a7b968959dfa6008dbafd394472dfceb6853fccf991bd6455ac789d244ec6f3
MD5 30036388a5d2c80c94aa51ac603befa2
BLAKE2b-256 bb6b366e4bfb383310fdaa581b576834605c2fe09d4bd4d4f2a943c0edb3967a

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

This release

1.1.1 This release

2 files

1.1.0

2 files

1.0.15

2 files

1.0.14

2 files

1.0.13

2 files

1.0.12

2 files

1.0.11

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

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