Metadata-Version: 2.4
Name: helixwright
Version: 0.3.0
Summary: Python automation SDK for Helix Browser Local API and the private Helix RPC page-control plane.
Author: Helix Browser
License-Expression: LicenseRef-Proprietary
Project-URL: Homepage, https://pypi.org/project/helixwright/
Project-URL: Documentation, https://pypi.org/project/helixwright/
Keywords: automation,browser,fingerprint,chromium,local-api,helix
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Typing :: Typed
Classifier: Intended Audience :: Developers
Classifier: Operating System :: Microsoft :: Windows
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# Helixwright

Helixwright is the Python automation SDK for Helix Browser.

Version `0.2.5` is a breaking V5-only architecture. It does not use CDP,
WebDriver, Playwright, Selenium, direct `chrome.exe` launch, local profile
folders, or local fingerprint generation.

## Runtime Model

`Client` talks to Helix Browser Desktop Local API. Local API creates or reuses a
server-owned profile, starts an automation session, and returns the private
Browser RPC endpoint.

`Page` is returned by `hw.launch()`. Page actions use Browser RPC V5 only:

- `/rpc` is used only for `rpc.hello` discovery.
- Runtime page control must switch to `/rpc/v5`.
- Required V5 methods are `input.action`, `input.pointer_path`,
  `element.resolve`, `element.action`, and `frames.list`.
- Older RPC V1/V2/V3/V4 cores are rejected.

## Install

```bash
pip install helixwright
```

Local source development:

```powershell
cd "G:\Helix Browser\repos\helixwright"
pip install -e .
python tests\ci.py
```

## Quick Start

```python
import helixwright as hw

with hw.launch("https://example.com", name="demo") as page:
    page.wait_for("body")
    print(page.title())
    page.locator("body").click()
```

Pass only the metadata you actually need. In the common case, URL and optional
proxy are enough; profile identity and fingerprint are owned by Helix.

```python
with hw.launch(
    "https://example.com",
    proxy="http://user:pass@127.0.0.1:7890",
) as page:
    print(page.profile_id, page.session_id)
```

Reuse an existing Helix profile explicitly:

```python
with hw.launch("https://example.com", reuse_profile_id="p_existing") as page:
    print(page.url)
```

## Public Objects

- `Client`: Local API client and managers.
- `Page`: primary page/session object returned by `launch()`.
- `Locator`: selector-bound element action object.
- `Input`: low-level trusted mouse/keyboard/path injection.
- `MotionProfile`: Python-visible motion policy for browser-core trajectories.
- `TraceController`: AI/debug trace support, available as `page.trace`.

The retired pre-V5 public element model, manual fingerprint object, account
lookup launch, and old RPC fallback model are not part of this API.

## Launch API

```python
hw.launch(
    url=None,
    *,
    reuse_profile_id=None,
    name=None,
    group=None,
    tags=None,
    start_pages=None,
    proxy=None,
    client=None,
    base_url=None,
    headless=False,
    timeout_ms=30000,
    humanize=None,
    motion=None,
)
```

Reusable config:

```python
cfg = hw.LaunchConfig(
    name="shop",
    url="https://example.com",
    proxy="http://127.0.0.1:7890",
    motion=hw.MotionProfile.balanced(),
)

with hw.launch(config=cfg) as page:
    page.locator("body").wait()
```

Unsupported old arguments raise `TypeError`, including `account_id`,
`profile_id`, `fingerprint`, `chrome`, `user_data_dir`, `persona`, `seed`, and
`extra_args`.

## Locator Actions

Default actions are trusted browser-core actions. Eligible root-page locators
use the V5 frame-flat element path, so clicks can auto-scroll the correct root,
iframe/OOPIF, or scroll container target before clicking.

Frame-flat locator selectors supported by the current core:

- Plain CSS.
- Interactive `text=...` / `text:"..."` selectors.
- `role=button@@name:...` and other role+name selectors.
- `placeholder=...`, `aria-label=...`, `aria=...`, `title=...`, `alt=...`.
- `testid=...`, matching `data-testid`, `data-test`, `data-qa`, and `data-cy`.
- Simple positive Drission text filters when they compile to one CSS scope plus
  one text filter.

```python
email = page.locator("input[type=email]")
email.fill("user@example.com")

page.locator("button[type=submit]").click()
page.locator("#result").wait("visible")
print(page.locator("#result").text())
```

Nested locators:

```python
page.locator("form").locator("button[type=submit]").click()
```

Diagnostics:

```python
print(page.locator("#login").resolve())
print(page.locator("#login").explain())
print(page.targets())  # browser tab/WebContents inventory
print(page.frames())   # document frame/OOPIF inventory
```

`targets()` is not a frame list. Use `frames()` when diagnosing iframe or OOPIF
visibility. `Locator.exists()`, `Locator.count()`, and `page.probe` prefer V5
frame-flat evidence for eligible selectors, so they should agree with the
trusted `Locator.click()` path on the same core.

## Low-Level Input

Use `page.input` only when you intentionally need raw control. For normal
automation, prefer `Locator.click()` and `Locator.fill()`.

```python
page.input.click(100, 200)
page.input.wheel(600)
page.input.key("Enter")

page.input.pointer_path([
    {"x": 10, "y": 20, "dt": 0, "kind": "move"},
    {"x": 12, "y": 22, "dt": 16, "kind": "down", "buttons": 1},
    {"x": 40, "y": 55, "dt": 80, "kind": "up", "buttons": 0},
])
```

`pointer_path()` is one atomic Browser RPC V5 call. It does not emulate a path
with many SDK round trips.

## Humanize And Trajectory

`humanize` controls action-to-action timing. `MotionProfile` controls compact
Python-visible motion policy. Browser core generates default trusted pointer
paths from that policy.

```python
with hw.launch("https://example.com", humanize="default") as page:
    page.locator("#email").fill("user@example.com")
    page.locator("#submit").click()
```

Implemented timing behavior:

- `humanize=True` and `humanize="default"` enable deterministic per-profile
  think-time.
- `humanize="careful"` uses a slower, more deliberate timing profile.
- Timing is seeded from server-returned profile behavior data, so different
  profiles get different pacing distributions.
- Session nonce adds small run-to-run variation without using per-call random
  jitter.

Motion behavior:

- `Locator.click()` uses Browser RPC V5 `element.action`; the browser core owns
  the trusted click path, frame/OOPIF coordinates, auto-scroll, and receipt.
- `hw.MotionProfile` exposes presets such as `fast`, `balanced`, `careful`, and
  `slider`.
- `hw.launch(..., motion=...)` sets the default motion profile for `Locator`,
  `page.input`, and `Page.scroll()`.
- `page.input.drag()` uses the page motion profile when profile/duration/hold/
  overshoot/tremor are not explicitly provided.
- `page.input.pointer_path(points)` is the public low-level way to inject a full
  custom trajectory as one atomic core RPC.

```python
motion = hw.MotionProfile.slider(seed=123)

with hw.launch("https://example.com", motion=motion, humanize="careful") as page:
    page.input.drag(120, 350, 380, 350)
    page.input.pointer_path([
        {"x": 120, "y": 350, "dt": 0, "kind": "down", "buttons": 1},
        {"x": 190, "y": 351, "dt": 90, "kind": "drag", "buttons": 1},
        {"x": 300, "y": 349, "dt": 130, "kind": "drag", "buttons": 1},
        {"x": 380, "y": 350, "dt": 90, "kind": "up", "buttons": 0},
    ])
```

`MotionProfile` is intentionally the Python-side policy object, not a
trajectory generator. Browser RPC V5 owns default element actions, frame/OOPIF
routing, trusted event dispatch, and default path generation.

## Trace

Trace is a debug and AI authoring surface, separate from normal runtime actions.
Use `TraceRecorder` for new work; it writes an append-only evidence directory
with canonical `events.jsonl`, `actions.jsonl`, `probes.jsonl`,
`channels/*.jsonl`, content-hashed assets, screenshots, and a report.

```python
with hw.launch("https://example.com") as page:
    with page.trace.start_session("trace-example", mode="authoring") as trace:
        page.locator("body").wait()
        page.probe.interactables()
        page.probe.locator("button[type=submit]").candidates()
        page.locator("button[type=submit]").click()
        page.probe.state({"loaded": lambda p: "example.com" in p.url})
    trace.report()
```

For deep failure analysis, opt in to heavier evidence:

```python
with page.trace.start_session("trace-debug", mode="failure_debug", network_bodies=True) as trace:
    page.probe.cookies()
    page.probe.storage()
    page.probe.listener_hints("button[type=submit]")
```

CLI capture for an already-running automation session:

```powershell
python -m helixwright trace --session auto_123 --duration 15 --output trace-example
python -m helixwright trace --session auto_123 --mode failure_debug --network-bodies --output trace-debug
```

## Client Managers

```python
client = hw.Client()
print(client.health())
print(client.session())

profile = client.profiles.create(name="demo", proxy="http://127.0.0.1:7890")
profile.update(name="renamed")
profile.clone(count=2)
profile.sync_up()
profile.sync_down()

client.proxy.check("http://127.0.0.1:7890")
client.cores.list()
client.cores.ensure("chromium", "149.0.7827.156")
client.browser.active()
client.browser.start(profile.id)
client.browser.stop(profile.id)
client.browser.stop_all()
client.automation.list()
client.automation.stop("auto_123")
```

The SDK no longer exposes `client.fingerprint` or `client.automation.start()`.
Use `hw.launch()` / `client.automation.launch()` so profile creation and session
start remain one server-owned operation.

## Errors

Common error types:

| Error | Meaning |
| --- | --- |
| `LocalApiUnavailable` | Desktop Local API is unreachable. |
| `DesktopNotLoggedIn` | Desktop is reachable but not logged in. |
| `LocalApiError` | Local API returned a business error. |
| `ProfileNotFound` | The requested profile id does not exist. |
| `AutomationEndpointUnavailable` | Local API/core did not return a usable V5 RPC endpoint. |
| `AutomationSessionNotFound` | The requested automation session does not exist. |
| `RpcError` | Browser RPC returned a structured error. |
| `TransportError` | Browser RPC transport failed, usually because the browser exited. |
| `WaitTimeoutError` | A page wait condition timed out. |

## Examples

```powershell
cd "G:\Helix Browser\repos\helixwright"
python examples\99_offline_mock_demo.py
python examples\00_helixwright_quickstart.py
python examples\01_client_managers.py
python examples\02_launch_config_and_actions.py
python examples\03_native_trace_state_machine.py
```
