webpilot-engine 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- webpilot_engine-2.0.0/PKG-INFO +299 -0
- webpilot_engine-2.0.0/README.md +267 -0
- webpilot_engine-2.0.0/adapters/__init__.py +14 -0
- webpilot_engine-2.0.0/adapters/base.py +34 -0
- webpilot_engine-2.0.0/adapters/browser_adapter.py +300 -0
- webpilot_engine-2.0.0/adapters/dom_scripts.py +518 -0
- webpilot_engine-2.0.0/adapters/envelope_builder.py +108 -0
- webpilot_engine-2.0.0/adapters/live_session_manager.py +326 -0
- webpilot_engine-2.0.0/adapters/upload_adapter.py +77 -0
- webpilot_engine-2.0.0/builder.py +83 -0
- webpilot_engine-2.0.0/cli.py +341 -0
- webpilot_engine-2.0.0/config/__init__.py +23 -0
- webpilot_engine-2.0.0/config/settings.py +339 -0
- webpilot_engine-2.0.0/constants/__init__.py +165 -0
- webpilot_engine-2.0.0/constants/contracts.py +95 -0
- webpilot_engine-2.0.0/constants/selectors.py +27 -0
- webpilot_engine-2.0.0/constants/timeouts.py +25 -0
- webpilot_engine-2.0.0/core/__init__.py +45 -0
- webpilot_engine-2.0.0/core/exceptions.py +33 -0
- webpilot_engine-2.0.0/core/models.py +273 -0
- webpilot_engine-2.0.0/engine.py +199 -0
- webpilot_engine-2.0.0/exceptions.py +23 -0
- webpilot_engine-2.0.0/mcp_server.py +347 -0
- webpilot_engine-2.0.0/models.py +29 -0
- webpilot_engine-2.0.0/orchestration/__init__.py +19 -0
- webpilot_engine-2.0.0/orchestration/context.py +71 -0
- webpilot_engine-2.0.0/orchestration/flow_orchestrator.py +358 -0
- webpilot_engine-2.0.0/orchestration/session_coordinator.py +88 -0
- webpilot_engine-2.0.0/pyproject.toml +77 -0
- webpilot_engine-2.0.0/services/__init__.py +17 -0
- webpilot_engine-2.0.0/services/auth_navigation_service.py +129 -0
- webpilot_engine-2.0.0/services/field_interaction_service.py +174 -0
- webpilot_engine-2.0.0/services/form_filler_service.py +106 -0
- webpilot_engine-2.0.0/services/inspection_formatter_service.py +68 -0
- webpilot_engine-2.0.0/services/inspection_service.py +40 -0
- webpilot_engine-2.0.0/services/reactive_interaction_service.py +174 -0
- webpilot_engine-2.0.0/setup.cfg +4 -0
- webpilot_engine-2.0.0/supervisor/__init__.py +13 -0
- webpilot_engine-2.0.0/supervisor/client.py +171 -0
- webpilot_engine-2.0.0/supervisor/contracts.py +62 -0
- webpilot_engine-2.0.0/supervisor/master_daemon.py +303 -0
- webpilot_engine-2.0.0/supervisor/shell.py +194 -0
- webpilot_engine-2.0.0/supervisor/worker_process.py +400 -0
- webpilot_engine-2.0.0/tests/test_config_and_builder.py +187 -0
- webpilot_engine-2.0.0/tests/test_contracts.py +127 -0
- webpilot_engine-2.0.0/tests/test_engine_facade.py +55 -0
- webpilot_engine-2.0.0/tests/test_live_session.py +77 -0
- webpilot_engine-2.0.0/tests/test_mcp_server.py +79 -0
- webpilot_engine-2.0.0/tests/test_orchestration.py +153 -0
- webpilot_engine-2.0.0/tests/test_redaction.py +76 -0
- webpilot_engine-2.0.0/tests/test_services.py +108 -0
- webpilot_engine-2.0.0/tests/test_supervisor.py +83 -0
- webpilot_engine-2.0.0/validators/__init__.py +9 -0
- webpilot_engine-2.0.0/validators/form_validator.py +28 -0
- webpilot_engine-2.0.0/validators/payload_validator.py +25 -0
- webpilot_engine-2.0.0/webpilot_engine.egg-info/PKG-INFO +299 -0
- webpilot_engine-2.0.0/webpilot_engine.egg-info/SOURCES.txt +59 -0
- webpilot_engine-2.0.0/webpilot_engine.egg-info/dependency_links.txt +1 -0
- webpilot_engine-2.0.0/webpilot_engine.egg-info/entry_points.txt +6 -0
- webpilot_engine-2.0.0/webpilot_engine.egg-info/requires.txt +12 -0
- webpilot_engine-2.0.0/webpilot_engine.egg-info/top_level.txt +14 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: webpilot-engine
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: WebPilot: Enterprise Autonomous Browser Engine, Universal Form Inspector & AI Agent Web Runtime
|
|
5
|
+
Author: Antigravity Engineering
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: webpilot,browser-runtime,ai-agent,web-automation,playwright,form-filler,ats-automation,sap-successfactors,workday,browser-supervisor,process-isolation
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Testing
|
|
11
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Operating System :: MacOS
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: playwright>=1.40.0
|
|
23
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
|
|
29
|
+
Requires-Dist: Faker>=24.0.0; extra == "dev"
|
|
30
|
+
Provides-Extra: mcp
|
|
31
|
+
Requires-Dist: mcp>=1.0.0; extra == "mcp"
|
|
32
|
+
|
|
33
|
+
# WebPilot: Autonomous Multi-Tier Browser Automation Engine & AI Agent Web Runtime
|
|
34
|
+
|
|
35
|
+
[](https://www.python.org/)
|
|
36
|
+
[](https://playwright.dev/)
|
|
37
|
+
[](#-3-tier-multi-process-architecture)
|
|
38
|
+
[-success.svg)](#-zero-elevation-standard-user-security)
|
|
39
|
+
[](#-testing--verification)
|
|
40
|
+
[](#-quick-start-guide)
|
|
41
|
+
|
|
42
|
+
An enterprise-grade, general-purpose autonomous browser engine and AI agent web runtime designed to inspect, interact with, fill, and operate any website, complex Single-Page Application (SPA), or enterprise portal (such as **SAP SuccessFactors**, **Workday**, **Greenhouse**, **Oracle Taleo**, and modern web apps) with zero site-specific selectors or hardcoding.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## ๐๏ธ 3-Tier Multi-Process Architecture
|
|
47
|
+
|
|
48
|
+
To solve the fundamental Windows OS limitation where terminal and subshell runners terminate background child processes upon exit (Windows Job Object `JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE`), WebPilot implements an elevated-resilient **Zero-Elevation Three-Tier Process Architecture**:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
52
|
+
โ WebPilot CLI & REPL Shell (webpilot / wp) โ
|
|
53
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
54
|
+
โ HTTP REST (127.0.0.1:9333)
|
|
55
|
+
โผ
|
|
56
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
57
|
+
โ Layer 1: Master Supervisor Host (Daemon) โ
|
|
58
|
+
โ โข Zero Playwright Imports (~15 MB RAM) โ
|
|
59
|
+
โ โข 30-Minute Inactivity Watchdog (Automatic RAM release) โ
|
|
60
|
+
โ โข Windows WMI Zero-Touch Auto-Spawn (Session 0 Breakout) โ
|
|
61
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
62
|
+
โ stdin / stdout (Isolated JSON-RPC)
|
|
63
|
+
โผ
|
|
64
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
65
|
+
โ Layer 2: Operational Worker Process โ
|
|
66
|
+
โ โข Playwright Runtime + SessionCoordinator โ
|
|
67
|
+
โ โข Persistent in-memory browser session across CLI calls โ
|
|
68
|
+
โ โข DOM Services (Field, Auth, Reactive, Inspection) โ
|
|
69
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
70
|
+
โ Process Tree Attachment
|
|
71
|
+
โผ
|
|
72
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
73
|
+
โ Layer 3: Chromium Browser Engine โ
|
|
74
|
+
โ โข Chromium Main Process + GPU + Renderers โ
|
|
75
|
+
โ โข Immediate Cascading Kill (taskkill /F /T /PID) โ
|
|
76
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### โก Key Architectural Advantages:
|
|
80
|
+
1. **Persistent Browser Session Across CLI Calls**: Run step-by-step sequential commands (`open` -> `fill username` -> `fill password` -> `press submit`) without restarting the browser or losing active DOM state.
|
|
81
|
+
2. **Zero-Elevation / Standard User Mode**: Runs 100% as a standard, unprivileged user. **Zero administrative or UAC prompts required** (no `asudo` or Administrator escalation).
|
|
82
|
+
3. **Cascading Kill & Instant Self-Healing**: Terminating Layer 2 via `taskkill /F /T /PID` instantly eliminates all child Chromium processes with **zero zombie leaks**. Layer 1 survives and automatically respawns a clean Layer 2 in **~300ms**.
|
|
83
|
+
4. **30-Minute Watchdog Supervisor**: Automatically reclaims 100% of browser memory if the session remains idle for 30 minutes.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## ๐ Core Features
|
|
88
|
+
|
|
89
|
+
- **Universal Inspection (`inspect`)**: Navigates to any URL and outputs a token-optimized, clean schema containing text fields, picklists, radio groups, checkboxes, file uploads, and action buttons.
|
|
90
|
+
- **Dynamic Field Population (`apply`)**: Fills fields dynamically via JSON payloads (`--data`) or inline CLI flags (`--fill`), with automatic type detection (text, combobox, radio, select).
|
|
91
|
+
- **Reactive Interaction Service**:
|
|
92
|
+
- Automatically observes button clicks (`--press`).
|
|
93
|
+
- Detects redirects and route transitions (`[๐ Redirect]`) and auto-inspects the resulting page.
|
|
94
|
+
- Detects and switches to newly spawned browser tabs/windows (`[๐ New Window]`).
|
|
95
|
+
- Detects dynamic DOM expansions and section accordions (`[๐ Dynamic Form Expansion]`).
|
|
96
|
+
- **Dynamic Loader Dissolution**:
|
|
97
|
+
- Automatically identifies global blocking overlays (`#loading`, `.sapUiBusy`, `.busyIndicator`, `.modal-backdrop`, `[aria-busy="true"]`) and waits dynamically for their dissolution (`state="hidden"`).
|
|
98
|
+
- Distinguishes between global page-blocking veils and local dropdown loaders.
|
|
99
|
+
- **Modal & Pointer Trap Escape Pipeline**:
|
|
100
|
+
- Resolves modal popups and pointer-locked elements using a 4-stage pipeline: Natural Selection -> Keyboard `Escape` -> Backdrop Click -> DOM Surgical Removal.
|
|
101
|
+
- **Enterprise Picklist Auto-scrolling**:
|
|
102
|
+
- Intelligent scrolling algorithm for virtualized dropdowns (such as SAP picklists with `aria-owns` and scroll containers).
|
|
103
|
+
- **Interactive REPL Shell (`shell`)**:
|
|
104
|
+
- Interactive automation console with real-time feedback, tab switching, and live DOM inspection.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## ๐ฆ Installation & Setup
|
|
109
|
+
|
|
110
|
+
### Option A: Install from PyPI or Editable Mode
|
|
111
|
+
```bash
|
|
112
|
+
# Editable install into environment
|
|
113
|
+
pip install -e .
|
|
114
|
+
|
|
115
|
+
# Or install dependencies directly
|
|
116
|
+
pip install -r requirements.txt
|
|
117
|
+
playwright install chromium
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Option B: Standalone Portable Binary (Windows)
|
|
121
|
+
Download `webpilot.exe` from GitHub Releases and run directly without needing a local Python installation.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## ๐ Quick Start Guide
|
|
126
|
+
|
|
127
|
+
You can use the full `webpilot` command or the ultra-fast shortcut **`wp`** (or `python cli.py`):
|
|
128
|
+
|
|
129
|
+
### 1. Check & Start Background Supervisor Service
|
|
130
|
+
```powershell
|
|
131
|
+
# Check multi-tier service status
|
|
132
|
+
wp service status
|
|
133
|
+
|
|
134
|
+
# Start service (automatically auto-spawns detached host via WMI)
|
|
135
|
+
wp service start
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 2. Inspect Any Web Page
|
|
139
|
+
```powershell
|
|
140
|
+
wp inspect --url "https://example.com/portal" --output "schema.json" --screenshot "page.png"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 3. Step-by-Step Multi-Turn Web Automation
|
|
144
|
+
Execute sequential commands on the **same live persistent browser session**:
|
|
145
|
+
|
|
146
|
+
```powershell
|
|
147
|
+
# Step 1: Open target portal and inspect initial schema
|
|
148
|
+
wp apply --url "https://example.com/login" --screenshot "step1.png"
|
|
149
|
+
|
|
150
|
+
# Step 2: Fill email only on the active persistent page
|
|
151
|
+
wp apply --fill "username=john.doe@example.com" --screenshot "step2.png"
|
|
152
|
+
|
|
153
|
+
# Step 3: Fill password only on the active persistent page
|
|
154
|
+
wp apply --fill "password=MySecurePassword123!" --screenshot "step3.png"
|
|
155
|
+
|
|
156
|
+
# Step 4: Click Sign In, detect redirect, auto-inspect profile, and save cookies
|
|
157
|
+
wp apply --press "Sign In" --cookies "session_cookies.json" --screenshot "step4.png"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### 4. Interactive REPL Shell Mode
|
|
161
|
+
Launch the sub-second interactive REPL shell:
|
|
162
|
+
```powershell
|
|
163
|
+
wp shell
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Inside the shell, enter commands sequentially:
|
|
167
|
+
```text
|
|
168
|
+
webpilot> open https://example.com/login
|
|
169
|
+
webpilot> fill username=john.doe@example.com
|
|
170
|
+
webpilot> fill password=MySecurePassword123!
|
|
171
|
+
webpilot> press Sign In
|
|
172
|
+
webpilot> tabs
|
|
173
|
+
webpilot> screenshot dashboard.png
|
|
174
|
+
webpilot> exit
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## ๐ ๏ธ CLI Reference
|
|
180
|
+
|
|
181
|
+
### Common Global Flags
|
|
182
|
+
- `--host`: Supervisor host address (default: `127.0.0.1`).
|
|
183
|
+
- `--port`: Supervisor port (default: `9333`).
|
|
184
|
+
- `--standalone`: Bypasses Master Supervisor to run in-process via `FlowOrchestrator`.
|
|
185
|
+
|
|
186
|
+
### `python cli.py inspect`
|
|
187
|
+
Inspects a URL or active session and outputs a clean form schema:
|
|
188
|
+
- `--url <URL>`: Target URL (optional if connecting to existing live session).
|
|
189
|
+
- `--output <path>`: Save full JSON schema to disk.
|
|
190
|
+
- `--screenshot <path>`: Capture page screenshot.
|
|
191
|
+
- `--cookies <path>`: Load session cookies.
|
|
192
|
+
- `--unpack-options`: Probe dropdowns to sample options.
|
|
193
|
+
- `--tab <index>`: Inspect specific tab by index.
|
|
194
|
+
- `--list-tabs`: List all open tabs in active session.
|
|
195
|
+
|
|
196
|
+
### `python cli.py apply`
|
|
197
|
+
Fills fields, uploads files, presses buttons, and validates state:
|
|
198
|
+
- `--url <URL>`: Target URL (optional if operating on existing page).
|
|
199
|
+
- `--data <path>`: Load key-value mappings from JSON file.
|
|
200
|
+
- `--fill <key=val>`: Set field value (can be repeated).
|
|
201
|
+
- `--press <btn>`: Click button with reactive observation (can be repeated).
|
|
202
|
+
- `--upload <kw=file>`: Upload document to upload area (can be repeated).
|
|
203
|
+
- `--cookies <path>`: Save or load session cookies.
|
|
204
|
+
- `--submit`: Submit form after filling.
|
|
205
|
+
- `--screenshot <path>`: Capture post-interaction screenshot.
|
|
206
|
+
- `--no-auto-inspect`: Disable automatic post-interaction schema inspection.
|
|
207
|
+
|
|
208
|
+
### `python cli.py service`
|
|
209
|
+
Manages the Master Supervisor daemon:
|
|
210
|
+
- `python cli.py service status`: Query real-time PID telemetry for Layer 1, Layer 2, and Layer 3.
|
|
211
|
+
- `python cli.py service restart`: Trigger cascading kill of Layer 2 & Layer 3, and respawn fresh worker (~300ms).
|
|
212
|
+
- `python cli.py service stop`: Cleanly terminate all tiers and release all memory.
|
|
213
|
+
- `python cli.py service start`: Ensure Layer 1 daemon is running.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## ๐ Project Directory Layout
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
universal_web_applier/
|
|
221
|
+
โโโ adapters/
|
|
222
|
+
โ โโโ browser_adapter.py # Playwright & Chromium connection adapter
|
|
223
|
+
โ โโโ dom_scripts.py # Pure JavaScript DOM manipulation scripts
|
|
224
|
+
โ โโโ live_session_manager.py # Legacy CDP live session fallback
|
|
225
|
+
โ โโโ upload_adapter.py # Intelligent file upload handler
|
|
226
|
+
โโโ config/
|
|
227
|
+
โ โโโ builder.py # Payload & Envelope builders
|
|
228
|
+
โ โโโ settings.py # 3-tier settings resolver (env -> .env -> json)
|
|
229
|
+
โ โโโ settings.json # Active settings
|
|
230
|
+
โ โโโ device_profile.json # Browser fingerprint & viewport settings
|
|
231
|
+
โโโ constants/
|
|
232
|
+
โ โโโ contracts.py # Single Source of Truth for JSON contracts
|
|
233
|
+
โ โโโ timeouts.py # Centralized timeouts and pauses
|
|
234
|
+
โโโ core/
|
|
235
|
+
โ โโโ models.py # Dataclasses & schema models
|
|
236
|
+
โโโ orchestration/
|
|
237
|
+
โ โโโ context.py # Request & session contexts
|
|
238
|
+
โ โโโ flow_orchestrator.py # In-process standalone workflow pipeline
|
|
239
|
+
โ โโโ session_coordinator.py # Session lifecycle coordinator
|
|
240
|
+
โโโ services/
|
|
241
|
+
โ โโโ auth_navigation_service.py # Login detection & portal transitions
|
|
242
|
+
โ โโโ field_interaction_service.py# Field value injection & verification
|
|
243
|
+
โ โโโ inspection_service.py # DOM inspection & schema extraction
|
|
244
|
+
โ โโโ inspection_formatter_service.py # Lean human-readable summary formatter
|
|
245
|
+
โ โโโ reactive_interaction_service.py # Post-click reactive changes observer
|
|
246
|
+
โโโ supervisor/
|
|
247
|
+
โ โโโ contracts.py # Supervisor request/response contracts
|
|
248
|
+
โ โโโ master_daemon.py # Layer 1: Lightweight HTTP Daemon
|
|
249
|
+
โ โโโ worker_process.py # Layer 2: Supervised JSON-RPC Worker
|
|
250
|
+
โ โโโ client.py # Zero-Touch WMI client & HTTP proxy
|
|
251
|
+
โ โโโ shell.py # Interactive REPL automation shell
|
|
252
|
+
โโโ tests/
|
|
253
|
+
โ โโโ test_contracts.py # Wire contract unit tests
|
|
254
|
+
โ โโโ test_engine_facade.py # Engine facade tests
|
|
255
|
+
โ โโโ test_live_session.py # Live session tests
|
|
256
|
+
โ โโโ test_orchestration.py # Pipeline orchestration tests
|
|
257
|
+
โ โโโ test_redaction.py # Security & credential redaction tests
|
|
258
|
+
โ โโโ test_services.py # DOM interaction services tests
|
|
259
|
+
โ โโโ test_supervisor.py # Master supervisor & client unit tests
|
|
260
|
+
โโโ cli.py # Unified CLI entrypoint
|
|
261
|
+
โโโ requirements.txt # Python dependencies
|
|
262
|
+
โโโ pyproject.toml # Modern package specifications
|
|
263
|
+
โโโ README.md # Master documentation
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## ๐งช Testing & Verification
|
|
269
|
+
|
|
270
|
+
Run the comprehensive unit test suite:
|
|
271
|
+
```powershell
|
|
272
|
+
python -m pytest tests/
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
All 27 contract and service tests execute in < 25s:
|
|
276
|
+
```text
|
|
277
|
+
tests\test_contracts.py .... [ 14%]
|
|
278
|
+
tests\test_engine_facade.py ... [ 25%]
|
|
279
|
+
tests\test_live_session.py .. [ 33%]
|
|
280
|
+
tests\test_orchestration.py ... [ 44%]
|
|
281
|
+
tests\test_redaction.py .... [ 59%]
|
|
282
|
+
tests\test_services.py ....... [ 85%]
|
|
283
|
+
tests\test_supervisor.py .... [100%]
|
|
284
|
+
|
|
285
|
+
============================= 27 passed in 22.58s =============================
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## ๐ Security & Privacy
|
|
291
|
+
|
|
292
|
+
- **Credential Redaction**: Passwords, auth tokens, and sensitive inputs are automatically redacted in CLI outputs, telemetry cards, and logs.
|
|
293
|
+
- **Zero Administrative Elevation**: Does not require Administrator rights or elevated Windows tokens.
|
|
294
|
+
- **Local Isolation**: Master Supervisor listens exclusively on loopback `127.0.0.1:9333`.
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## ๐ License
|
|
299
|
+
MIT License. Free for commercial and personal use.
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# WebPilot: Autonomous Multi-Tier Browser Automation Engine & AI Agent Web Runtime
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/)
|
|
4
|
+
[](https://playwright.dev/)
|
|
5
|
+
[](#-3-tier-multi-process-architecture)
|
|
6
|
+
[-success.svg)](#-zero-elevation-standard-user-security)
|
|
7
|
+
[](#-testing--verification)
|
|
8
|
+
[](#-quick-start-guide)
|
|
9
|
+
|
|
10
|
+
An enterprise-grade, general-purpose autonomous browser engine and AI agent web runtime designed to inspect, interact with, fill, and operate any website, complex Single-Page Application (SPA), or enterprise portal (such as **SAP SuccessFactors**, **Workday**, **Greenhouse**, **Oracle Taleo**, and modern web apps) with zero site-specific selectors or hardcoding.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## ๐๏ธ 3-Tier Multi-Process Architecture
|
|
15
|
+
|
|
16
|
+
To solve the fundamental Windows OS limitation where terminal and subshell runners terminate background child processes upon exit (Windows Job Object `JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE`), WebPilot implements an elevated-resilient **Zero-Elevation Three-Tier Process Architecture**:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
20
|
+
โ WebPilot CLI & REPL Shell (webpilot / wp) โ
|
|
21
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
22
|
+
โ HTTP REST (127.0.0.1:9333)
|
|
23
|
+
โผ
|
|
24
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
25
|
+
โ Layer 1: Master Supervisor Host (Daemon) โ
|
|
26
|
+
โ โข Zero Playwright Imports (~15 MB RAM) โ
|
|
27
|
+
โ โข 30-Minute Inactivity Watchdog (Automatic RAM release) โ
|
|
28
|
+
โ โข Windows WMI Zero-Touch Auto-Spawn (Session 0 Breakout) โ
|
|
29
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
30
|
+
โ stdin / stdout (Isolated JSON-RPC)
|
|
31
|
+
โผ
|
|
32
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
33
|
+
โ Layer 2: Operational Worker Process โ
|
|
34
|
+
โ โข Playwright Runtime + SessionCoordinator โ
|
|
35
|
+
โ โข Persistent in-memory browser session across CLI calls โ
|
|
36
|
+
โ โข DOM Services (Field, Auth, Reactive, Inspection) โ
|
|
37
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
38
|
+
โ Process Tree Attachment
|
|
39
|
+
โผ
|
|
40
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
41
|
+
โ Layer 3: Chromium Browser Engine โ
|
|
42
|
+
โ โข Chromium Main Process + GPU + Renderers โ
|
|
43
|
+
โ โข Immediate Cascading Kill (taskkill /F /T /PID) โ
|
|
44
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### โก Key Architectural Advantages:
|
|
48
|
+
1. **Persistent Browser Session Across CLI Calls**: Run step-by-step sequential commands (`open` -> `fill username` -> `fill password` -> `press submit`) without restarting the browser or losing active DOM state.
|
|
49
|
+
2. **Zero-Elevation / Standard User Mode**: Runs 100% as a standard, unprivileged user. **Zero administrative or UAC prompts required** (no `asudo` or Administrator escalation).
|
|
50
|
+
3. **Cascading Kill & Instant Self-Healing**: Terminating Layer 2 via `taskkill /F /T /PID` instantly eliminates all child Chromium processes with **zero zombie leaks**. Layer 1 survives and automatically respawns a clean Layer 2 in **~300ms**.
|
|
51
|
+
4. **30-Minute Watchdog Supervisor**: Automatically reclaims 100% of browser memory if the session remains idle for 30 minutes.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## ๐ Core Features
|
|
56
|
+
|
|
57
|
+
- **Universal Inspection (`inspect`)**: Navigates to any URL and outputs a token-optimized, clean schema containing text fields, picklists, radio groups, checkboxes, file uploads, and action buttons.
|
|
58
|
+
- **Dynamic Field Population (`apply`)**: Fills fields dynamically via JSON payloads (`--data`) or inline CLI flags (`--fill`), with automatic type detection (text, combobox, radio, select).
|
|
59
|
+
- **Reactive Interaction Service**:
|
|
60
|
+
- Automatically observes button clicks (`--press`).
|
|
61
|
+
- Detects redirects and route transitions (`[๐ Redirect]`) and auto-inspects the resulting page.
|
|
62
|
+
- Detects and switches to newly spawned browser tabs/windows (`[๐ New Window]`).
|
|
63
|
+
- Detects dynamic DOM expansions and section accordions (`[๐ Dynamic Form Expansion]`).
|
|
64
|
+
- **Dynamic Loader Dissolution**:
|
|
65
|
+
- Automatically identifies global blocking overlays (`#loading`, `.sapUiBusy`, `.busyIndicator`, `.modal-backdrop`, `[aria-busy="true"]`) and waits dynamically for their dissolution (`state="hidden"`).
|
|
66
|
+
- Distinguishes between global page-blocking veils and local dropdown loaders.
|
|
67
|
+
- **Modal & Pointer Trap Escape Pipeline**:
|
|
68
|
+
- Resolves modal popups and pointer-locked elements using a 4-stage pipeline: Natural Selection -> Keyboard `Escape` -> Backdrop Click -> DOM Surgical Removal.
|
|
69
|
+
- **Enterprise Picklist Auto-scrolling**:
|
|
70
|
+
- Intelligent scrolling algorithm for virtualized dropdowns (such as SAP picklists with `aria-owns` and scroll containers).
|
|
71
|
+
- **Interactive REPL Shell (`shell`)**:
|
|
72
|
+
- Interactive automation console with real-time feedback, tab switching, and live DOM inspection.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## ๐ฆ Installation & Setup
|
|
77
|
+
|
|
78
|
+
### Option A: Install from PyPI or Editable Mode
|
|
79
|
+
```bash
|
|
80
|
+
# Editable install into environment
|
|
81
|
+
pip install -e .
|
|
82
|
+
|
|
83
|
+
# Or install dependencies directly
|
|
84
|
+
pip install -r requirements.txt
|
|
85
|
+
playwright install chromium
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Option B: Standalone Portable Binary (Windows)
|
|
89
|
+
Download `webpilot.exe` from GitHub Releases and run directly without needing a local Python installation.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## ๐ Quick Start Guide
|
|
94
|
+
|
|
95
|
+
You can use the full `webpilot` command or the ultra-fast shortcut **`wp`** (or `python cli.py`):
|
|
96
|
+
|
|
97
|
+
### 1. Check & Start Background Supervisor Service
|
|
98
|
+
```powershell
|
|
99
|
+
# Check multi-tier service status
|
|
100
|
+
wp service status
|
|
101
|
+
|
|
102
|
+
# Start service (automatically auto-spawns detached host via WMI)
|
|
103
|
+
wp service start
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 2. Inspect Any Web Page
|
|
107
|
+
```powershell
|
|
108
|
+
wp inspect --url "https://example.com/portal" --output "schema.json" --screenshot "page.png"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 3. Step-by-Step Multi-Turn Web Automation
|
|
112
|
+
Execute sequential commands on the **same live persistent browser session**:
|
|
113
|
+
|
|
114
|
+
```powershell
|
|
115
|
+
# Step 1: Open target portal and inspect initial schema
|
|
116
|
+
wp apply --url "https://example.com/login" --screenshot "step1.png"
|
|
117
|
+
|
|
118
|
+
# Step 2: Fill email only on the active persistent page
|
|
119
|
+
wp apply --fill "username=john.doe@example.com" --screenshot "step2.png"
|
|
120
|
+
|
|
121
|
+
# Step 3: Fill password only on the active persistent page
|
|
122
|
+
wp apply --fill "password=MySecurePassword123!" --screenshot "step3.png"
|
|
123
|
+
|
|
124
|
+
# Step 4: Click Sign In, detect redirect, auto-inspect profile, and save cookies
|
|
125
|
+
wp apply --press "Sign In" --cookies "session_cookies.json" --screenshot "step4.png"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 4. Interactive REPL Shell Mode
|
|
129
|
+
Launch the sub-second interactive REPL shell:
|
|
130
|
+
```powershell
|
|
131
|
+
wp shell
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Inside the shell, enter commands sequentially:
|
|
135
|
+
```text
|
|
136
|
+
webpilot> open https://example.com/login
|
|
137
|
+
webpilot> fill username=john.doe@example.com
|
|
138
|
+
webpilot> fill password=MySecurePassword123!
|
|
139
|
+
webpilot> press Sign In
|
|
140
|
+
webpilot> tabs
|
|
141
|
+
webpilot> screenshot dashboard.png
|
|
142
|
+
webpilot> exit
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## ๐ ๏ธ CLI Reference
|
|
148
|
+
|
|
149
|
+
### Common Global Flags
|
|
150
|
+
- `--host`: Supervisor host address (default: `127.0.0.1`).
|
|
151
|
+
- `--port`: Supervisor port (default: `9333`).
|
|
152
|
+
- `--standalone`: Bypasses Master Supervisor to run in-process via `FlowOrchestrator`.
|
|
153
|
+
|
|
154
|
+
### `python cli.py inspect`
|
|
155
|
+
Inspects a URL or active session and outputs a clean form schema:
|
|
156
|
+
- `--url <URL>`: Target URL (optional if connecting to existing live session).
|
|
157
|
+
- `--output <path>`: Save full JSON schema to disk.
|
|
158
|
+
- `--screenshot <path>`: Capture page screenshot.
|
|
159
|
+
- `--cookies <path>`: Load session cookies.
|
|
160
|
+
- `--unpack-options`: Probe dropdowns to sample options.
|
|
161
|
+
- `--tab <index>`: Inspect specific tab by index.
|
|
162
|
+
- `--list-tabs`: List all open tabs in active session.
|
|
163
|
+
|
|
164
|
+
### `python cli.py apply`
|
|
165
|
+
Fills fields, uploads files, presses buttons, and validates state:
|
|
166
|
+
- `--url <URL>`: Target URL (optional if operating on existing page).
|
|
167
|
+
- `--data <path>`: Load key-value mappings from JSON file.
|
|
168
|
+
- `--fill <key=val>`: Set field value (can be repeated).
|
|
169
|
+
- `--press <btn>`: Click button with reactive observation (can be repeated).
|
|
170
|
+
- `--upload <kw=file>`: Upload document to upload area (can be repeated).
|
|
171
|
+
- `--cookies <path>`: Save or load session cookies.
|
|
172
|
+
- `--submit`: Submit form after filling.
|
|
173
|
+
- `--screenshot <path>`: Capture post-interaction screenshot.
|
|
174
|
+
- `--no-auto-inspect`: Disable automatic post-interaction schema inspection.
|
|
175
|
+
|
|
176
|
+
### `python cli.py service`
|
|
177
|
+
Manages the Master Supervisor daemon:
|
|
178
|
+
- `python cli.py service status`: Query real-time PID telemetry for Layer 1, Layer 2, and Layer 3.
|
|
179
|
+
- `python cli.py service restart`: Trigger cascading kill of Layer 2 & Layer 3, and respawn fresh worker (~300ms).
|
|
180
|
+
- `python cli.py service stop`: Cleanly terminate all tiers and release all memory.
|
|
181
|
+
- `python cli.py service start`: Ensure Layer 1 daemon is running.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## ๐ Project Directory Layout
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
universal_web_applier/
|
|
189
|
+
โโโ adapters/
|
|
190
|
+
โ โโโ browser_adapter.py # Playwright & Chromium connection adapter
|
|
191
|
+
โ โโโ dom_scripts.py # Pure JavaScript DOM manipulation scripts
|
|
192
|
+
โ โโโ live_session_manager.py # Legacy CDP live session fallback
|
|
193
|
+
โ โโโ upload_adapter.py # Intelligent file upload handler
|
|
194
|
+
โโโ config/
|
|
195
|
+
โ โโโ builder.py # Payload & Envelope builders
|
|
196
|
+
โ โโโ settings.py # 3-tier settings resolver (env -> .env -> json)
|
|
197
|
+
โ โโโ settings.json # Active settings
|
|
198
|
+
โ โโโ device_profile.json # Browser fingerprint & viewport settings
|
|
199
|
+
โโโ constants/
|
|
200
|
+
โ โโโ contracts.py # Single Source of Truth for JSON contracts
|
|
201
|
+
โ โโโ timeouts.py # Centralized timeouts and pauses
|
|
202
|
+
โโโ core/
|
|
203
|
+
โ โโโ models.py # Dataclasses & schema models
|
|
204
|
+
โโโ orchestration/
|
|
205
|
+
โ โโโ context.py # Request & session contexts
|
|
206
|
+
โ โโโ flow_orchestrator.py # In-process standalone workflow pipeline
|
|
207
|
+
โ โโโ session_coordinator.py # Session lifecycle coordinator
|
|
208
|
+
โโโ services/
|
|
209
|
+
โ โโโ auth_navigation_service.py # Login detection & portal transitions
|
|
210
|
+
โ โโโ field_interaction_service.py# Field value injection & verification
|
|
211
|
+
โ โโโ inspection_service.py # DOM inspection & schema extraction
|
|
212
|
+
โ โโโ inspection_formatter_service.py # Lean human-readable summary formatter
|
|
213
|
+
โ โโโ reactive_interaction_service.py # Post-click reactive changes observer
|
|
214
|
+
โโโ supervisor/
|
|
215
|
+
โ โโโ contracts.py # Supervisor request/response contracts
|
|
216
|
+
โ โโโ master_daemon.py # Layer 1: Lightweight HTTP Daemon
|
|
217
|
+
โ โโโ worker_process.py # Layer 2: Supervised JSON-RPC Worker
|
|
218
|
+
โ โโโ client.py # Zero-Touch WMI client & HTTP proxy
|
|
219
|
+
โ โโโ shell.py # Interactive REPL automation shell
|
|
220
|
+
โโโ tests/
|
|
221
|
+
โ โโโ test_contracts.py # Wire contract unit tests
|
|
222
|
+
โ โโโ test_engine_facade.py # Engine facade tests
|
|
223
|
+
โ โโโ test_live_session.py # Live session tests
|
|
224
|
+
โ โโโ test_orchestration.py # Pipeline orchestration tests
|
|
225
|
+
โ โโโ test_redaction.py # Security & credential redaction tests
|
|
226
|
+
โ โโโ test_services.py # DOM interaction services tests
|
|
227
|
+
โ โโโ test_supervisor.py # Master supervisor & client unit tests
|
|
228
|
+
โโโ cli.py # Unified CLI entrypoint
|
|
229
|
+
โโโ requirements.txt # Python dependencies
|
|
230
|
+
โโโ pyproject.toml # Modern package specifications
|
|
231
|
+
โโโ README.md # Master documentation
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## ๐งช Testing & Verification
|
|
237
|
+
|
|
238
|
+
Run the comprehensive unit test suite:
|
|
239
|
+
```powershell
|
|
240
|
+
python -m pytest tests/
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
All 27 contract and service tests execute in < 25s:
|
|
244
|
+
```text
|
|
245
|
+
tests\test_contracts.py .... [ 14%]
|
|
246
|
+
tests\test_engine_facade.py ... [ 25%]
|
|
247
|
+
tests\test_live_session.py .. [ 33%]
|
|
248
|
+
tests\test_orchestration.py ... [ 44%]
|
|
249
|
+
tests\test_redaction.py .... [ 59%]
|
|
250
|
+
tests\test_services.py ....... [ 85%]
|
|
251
|
+
tests\test_supervisor.py .... [100%]
|
|
252
|
+
|
|
253
|
+
============================= 27 passed in 22.58s =============================
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## ๐ Security & Privacy
|
|
259
|
+
|
|
260
|
+
- **Credential Redaction**: Passwords, auth tokens, and sensitive inputs are automatically redacted in CLI outputs, telemetry cards, and logs.
|
|
261
|
+
- **Zero Administrative Elevation**: Does not require Administrator rights or elevated Windows tokens.
|
|
262
|
+
- **Local Isolation**: Master Supervisor listens exclusively on loopback `127.0.0.1:9333`.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## ๐ License
|
|
267
|
+
MIT License. Free for commercial and personal use.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Adapters package for universal web applier."""
|
|
2
|
+
|
|
3
|
+
from adapters.base import BrowserAdapterProtocol, UploadAdapterProtocol
|
|
4
|
+
from adapters.browser_adapter import BrowserAdapter
|
|
5
|
+
from adapters.upload_adapter import UploadAdapter
|
|
6
|
+
import adapters.dom_scripts as dom_scripts
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"BrowserAdapterProtocol",
|
|
10
|
+
"UploadAdapterProtocol",
|
|
11
|
+
"BrowserAdapter",
|
|
12
|
+
"UploadAdapter",
|
|
13
|
+
"dom_scripts",
|
|
14
|
+
]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Adapter protocols and shared interface contracts."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, List, Optional, Protocol
|
|
4
|
+
from playwright.sync_api import BrowserContext, Page
|
|
5
|
+
|
|
6
|
+
class BrowserAdapterProtocol(Protocol):
|
|
7
|
+
"""Protocol for browser runtime management."""
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
def page(self) -> Optional[Page]:
|
|
11
|
+
...
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def context(self) -> Optional[BrowserContext]:
|
|
15
|
+
...
|
|
16
|
+
|
|
17
|
+
def start(self, cookies_path: Optional[str] = None) -> None:
|
|
18
|
+
...
|
|
19
|
+
|
|
20
|
+
def stop(self) -> None:
|
|
21
|
+
...
|
|
22
|
+
|
|
23
|
+
def navigate(self, url: str, wait_timeout: Optional[int] = None) -> None:
|
|
24
|
+
...
|
|
25
|
+
|
|
26
|
+
def capture_screenshot(self, output_path: str, full_page: bool = False) -> None:
|
|
27
|
+
...
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class UploadAdapterProtocol(Protocol):
|
|
31
|
+
"""Protocol for document attachment operations."""
|
|
32
|
+
|
|
33
|
+
def upload_document(self, file_path: str, document_type_keyword: str = "") -> bool:
|
|
34
|
+
...
|