cykani-stealth 1.3.4__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.
- cykani_stealth-1.3.4/MANIFEST.in +1 -0
- cykani_stealth-1.3.4/PKG-INFO +137 -0
- cykani_stealth-1.3.4/README.md +119 -0
- cykani_stealth-1.3.4/pyproject.toml +36 -0
- cykani_stealth-1.3.4/setup.cfg +4 -0
- cykani_stealth-1.3.4/src/cykani_sdk/__init__.py +93 -0
- cykani_stealth-1.3.4/src/cykani_sdk/adapters/__init__.py +5 -0
- cykani_stealth-1.3.4/src/cykani_sdk/adapters/playwright.py +27 -0
- cykani_stealth-1.3.4/src/cykani_sdk/agents/__init__.py +5 -0
- cykani_stealth-1.3.4/src/cykani_sdk/agents/autoPilot.py +29 -0
- cykani_stealth-1.3.4/src/cykani_sdk/agents/autonomous.py +34 -0
- cykani_stealth-1.3.4/src/cykani_sdk/agents/diagnostic.py +23 -0
- cykani_stealth-1.3.4/src/cykani_sdk/agents/observer.py +25 -0
- cykani_stealth-1.3.4/src/cykani_sdk/agents/perceptor.py +24 -0
- cykani_stealth-1.3.4/src/cykani_sdk/agents/perceptual.py +22 -0
- cykani_stealth-1.3.4/src/cykani_sdk/agents/realworld.py +28 -0
- cykani_stealth-1.3.4/src/cykani_sdk/agents/strategist.py +61 -0
- cykani_stealth-1.3.4/src/cykani_sdk/agents/telemetry.py +25 -0
- cykani_stealth-1.3.4/src/cykani_sdk/brain/__init__.py +5 -0
- cykani_stealth-1.3.4/src/cykani_sdk/brain/entity.py +26 -0
- cykani_stealth-1.3.4/src/cykani_sdk/core/__init__.py +5 -0
- cykani_stealth-1.3.4/src/cykani_sdk/core/choreographer.py +44 -0
- cykani_stealth-1.3.4/src/cykani_sdk/core/recorder.py +38 -0
- cykani_stealth-1.3.4/src/cykani_sdk/core/sentinel.py +30 -0
- cykani_stealth-1.3.4/src/cykani_sdk/core/weave.py +26 -0
- cykani_stealth-1.3.4/src/cykani_sdk/humor/__init__.py +5 -0
- cykani_stealth-1.3.4/src/cykani_sdk/humor/strike.py +42 -0
- cykani_stealth-1.3.4/src/cykani_sdk/maestro.py +86 -0
- cykani_stealth-1.3.4/src/cykani_sdk/session.py +494 -0
- cykani_stealth-1.3.4/src/cykani_sdk/stealth/__init__.py +5 -0
- cykani_stealth-1.3.4/src/cykani_sdk/stealth/behavior.py +190 -0
- cykani_stealth-1.3.4/src/cykani_sdk/stealth/constellation.py +78 -0
- cykani_stealth-1.3.4/src/cykani_sdk/stealth/cursor.py +28 -0
- cykani_stealth-1.3.4/src/cykani_sdk/stealth/eval.py +61 -0
- cykani_stealth-1.3.4/src/cykani_sdk/stealth/phantom.py +59 -0
- cykani_stealth-1.3.4/src/cykani_sdk/stealth/websocket.py +29 -0
- cykani_stealth-1.3.4/src/cykani_sdk/utils/__init__.py +5 -0
- cykani_stealth-1.3.4/src/cykani_sdk/utils/cookies.py +41 -0
- cykani_stealth-1.3.4/src/cykani_sdk/utils/errors.py +35 -0
- cykani_stealth-1.3.4/src/cykani_sdk/utils/geoip.py +51 -0
- cykani_stealth-1.3.4/src/cykani_sdk/utils/hooks.py +30 -0
- cykani_stealth-1.3.4/src/cykani_sdk/utils/poolize.py +35 -0
- cykani_stealth-1.3.4/src/cykani_sdk/utils/proxy.py +48 -0
- cykani_stealth-1.3.4/src/cykani_sdk/utils/session.py +65 -0
- cykani_stealth-1.3.4/src/cykani_stealth.egg-info/PKG-INFO +137 -0
- cykani_stealth-1.3.4/src/cykani_stealth.egg-info/SOURCES.txt +47 -0
- cykani_stealth-1.3.4/src/cykani_stealth.egg-info/dependency_links.txt +1 -0
- cykani_stealth-1.3.4/src/cykani_stealth.egg-info/requires.txt +9 -0
- cykani_stealth-1.3.4/src/cykani_stealth.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include src/cykani_sdk/py.typed
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cykani-stealth
|
|
3
|
+
Version: 1.3.4
|
|
4
|
+
Summary: Cykani Python SDK — stealth browser automation with fingerprint evasion, human-like behavior, and autonomous browsing
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/cykani/cykani-stealth
|
|
7
|
+
Project-URL: Repository, https://github.com/cykani/cykani-stealth
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: cdp-use>=1.4.5
|
|
11
|
+
Requires-Dist: httpx>=0.27.0
|
|
12
|
+
Requires-Dist: pydantic>=2.0
|
|
13
|
+
Requires-Dist: numpy>=1.26.0
|
|
14
|
+
Requires-Dist: orjson>=3.9.0
|
|
15
|
+
Provides-Extra: geoip
|
|
16
|
+
Requires-Dist: geoip2>=5.0.0; extra == "geoip"
|
|
17
|
+
Requires-Dist: maxminddb>=2.6.0; extra == "geoip"
|
|
18
|
+
|
|
19
|
+
# cykani-sdk
|
|
20
|
+
|
|
21
|
+
**Python SDK — standalone end-to-end stealth browser automation with fingerprint evasion, human-like behavior, and autonomous browsing.**
|
|
22
|
+
|
|
23
|
+
Complete browser automation in Python. Launches Chrome/Chromium directly over CDP, applies fingerprint configuration, and automates with human-like behavioral patterns. No external browser process or Node.js dependency required.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install cykani-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or with geoip support:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install cykani-sdk[geoip]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from cykani_sdk import strike, Maestro
|
|
41
|
+
|
|
42
|
+
# Launch Chrome directly — fully standalone, no Node.js needed
|
|
43
|
+
session = await strike()
|
|
44
|
+
await session.goto("https://example.com")
|
|
45
|
+
await session.close()
|
|
46
|
+
|
|
47
|
+
# Or use Maestro for multi-session control
|
|
48
|
+
maestro = Maestro()
|
|
49
|
+
session = await maestro.launch({"fingerprint": 4242})
|
|
50
|
+
await session.goto("https://example.com")
|
|
51
|
+
await session.close()
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Presets
|
|
55
|
+
|
|
56
|
+
| Preset | Hesitation | Precision | Latency | Humor |
|
|
57
|
+
|---|---|---|---|---|
|
|
58
|
+
| `strike()` | 0.5 | 0.7 | human | off |
|
|
59
|
+
| `highTrust()` | 0.8 | 0.95 | human | off |
|
|
60
|
+
| `aggressive()` | 0.1 | 0.99 | robotic | off |
|
|
61
|
+
| `natural()` | 0.5 | 0.7 | organic | yes |
|
|
62
|
+
| `stealth()` | 0.5 | 0.7 | human | yes |
|
|
63
|
+
|
|
64
|
+
## What the SDK Does (End-to-End)
|
|
65
|
+
|
|
66
|
+
cykani-sdk is a **complete standalone** browser automation SDK. Each preset and launch call handles the full lifecycle:
|
|
67
|
+
|
|
68
|
+
1. **Launch** — spawns a Chrome/Chromium process directly via subprocess
|
|
69
|
+
2. **Configure** — applies fingerprint (platform, GPU, screen, hardware concurrency), proxy, viewport, locale, timezone
|
|
70
|
+
3. **Connect** — establishes CDP WebSocket connection via `cdp-use`
|
|
71
|
+
4. **Act** — navigates, clicks, types with human-like behavioral patterns
|
|
72
|
+
5. **Close** — terminates the browser process and cleans up
|
|
73
|
+
|
|
74
|
+
## Behavioral Engine
|
|
75
|
+
|
|
76
|
+
The Python SDK mirrors `cykani-stealth`'s `behaviors.js` — same anti-detection patterns, independent implementation:
|
|
77
|
+
|
|
78
|
+
| Feature | Description |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `cognitiveHesitation` | Pauses before actions based on page interaction density |
|
|
81
|
+
| `idleMicroMovement` | Random cursor jitter simulating natural idle behavior |
|
|
82
|
+
| `coffeeBreak` | Occasional long pauses (8% chance) simulating distraction |
|
|
83
|
+
| `bezierCurve` / `strikeMove` | Bézier curve mouse movement with drift points and correction curves |
|
|
84
|
+
| `typingDelay` | Per-character typing delays varying by character type (punctuation gets longer) |
|
|
85
|
+
| `microTremor` | Small Gaussian jitter preventing linear cursor tracking |
|
|
86
|
+
| `scrollCurve` | Smooth scrolling with eased acceleration/deceleration |
|
|
87
|
+
| `attentionDrift` | Simulated looking away at the screen, then refocusing |
|
|
88
|
+
|
|
89
|
+
## Connecting to an Existing Browser
|
|
90
|
+
|
|
91
|
+
If you already have a Chrome instance running, connect to it directly:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
session = await Session.create({
|
|
95
|
+
"_cdp_endpoint": "ws://127.0.0.1:9222/devtools/browser",
|
|
96
|
+
"fingerprint": 4242,
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## End-to-End in Two Languages
|
|
101
|
+
|
|
102
|
+
Both SDKs provide complete end-to-end browser automation — choose whichever language fits your team:
|
|
103
|
+
|
|
104
|
+
| | cykani-stealth (Node.js) | cykani-sdk (Python) |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| Browser launching | Native Chromium binary | Spawns Chrome via subprocess |
|
|
107
|
+
| Fingerprint evasion | C++ patches in binary | CDP-level configuration |
|
|
108
|
+
| Behavioral engine | Bézier curves, humanization | Same behavioral patterns |
|
|
109
|
+
| CDP protocol | Direct CDP WebSocket | `cdp-use` library |
|
|
110
|
+
| Auto-detection | Yes | Yes |
|
|
111
|
+
| Standalone | Yes, no Python needed | Yes, no Node.js needed |
|
|
112
|
+
|
|
113
|
+
Both share the same behavioral DNA — same Bézier curves, same typing delays, same cognitive hesitation, same micro-tremor. Pick your language and get the full experience.
|
|
114
|
+
|
|
115
|
+
## Architecture
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
cykani-stealth/
|
|
119
|
+
├── src/ # Node.js stealth engine (C++ patches, CDP)
|
|
120
|
+
│ └── ... # Full standalone browser automation
|
|
121
|
+
├── packages/
|
|
122
|
+
│ └── python/
|
|
123
|
+
│ └── cykani-python/ # Python SDK — complete standalone solution
|
|
124
|
+
│ ├── src/cykani_sdk/
|
|
125
|
+
│ │ ├── maestro.py # Browser session orchestration
|
|
126
|
+
│ │ ├── session.py # Standalone CDP browser session
|
|
127
|
+
│ │ ├── stealth/ # Behavioral engine + stealth
|
|
128
|
+
│ │ ├── agents/ # Autonomous navigation agents
|
|
129
|
+
│ │ └── utils/ # Cookies, proxy, geoip, session
|
|
130
|
+
│ ├── pyproject.toml
|
|
131
|
+
│ └── README.md
|
|
132
|
+
└── README.md
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# cykani-sdk
|
|
2
|
+
|
|
3
|
+
**Python SDK — standalone end-to-end stealth browser automation with fingerprint evasion, human-like behavior, and autonomous browsing.**
|
|
4
|
+
|
|
5
|
+
Complete browser automation in Python. Launches Chrome/Chromium directly over CDP, applies fingerprint configuration, and automates with human-like behavioral patterns. No external browser process or Node.js dependency required.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install cykani-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or with geoip support:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install cykani-sdk[geoip]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from cykani_sdk import strike, Maestro
|
|
23
|
+
|
|
24
|
+
# Launch Chrome directly — fully standalone, no Node.js needed
|
|
25
|
+
session = await strike()
|
|
26
|
+
await session.goto("https://example.com")
|
|
27
|
+
await session.close()
|
|
28
|
+
|
|
29
|
+
# Or use Maestro for multi-session control
|
|
30
|
+
maestro = Maestro()
|
|
31
|
+
session = await maestro.launch({"fingerprint": 4242})
|
|
32
|
+
await session.goto("https://example.com")
|
|
33
|
+
await session.close()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Presets
|
|
37
|
+
|
|
38
|
+
| Preset | Hesitation | Precision | Latency | Humor |
|
|
39
|
+
|---|---|---|---|---|
|
|
40
|
+
| `strike()` | 0.5 | 0.7 | human | off |
|
|
41
|
+
| `highTrust()` | 0.8 | 0.95 | human | off |
|
|
42
|
+
| `aggressive()` | 0.1 | 0.99 | robotic | off |
|
|
43
|
+
| `natural()` | 0.5 | 0.7 | organic | yes |
|
|
44
|
+
| `stealth()` | 0.5 | 0.7 | human | yes |
|
|
45
|
+
|
|
46
|
+
## What the SDK Does (End-to-End)
|
|
47
|
+
|
|
48
|
+
cykani-sdk is a **complete standalone** browser automation SDK. Each preset and launch call handles the full lifecycle:
|
|
49
|
+
|
|
50
|
+
1. **Launch** — spawns a Chrome/Chromium process directly via subprocess
|
|
51
|
+
2. **Configure** — applies fingerprint (platform, GPU, screen, hardware concurrency), proxy, viewport, locale, timezone
|
|
52
|
+
3. **Connect** — establishes CDP WebSocket connection via `cdp-use`
|
|
53
|
+
4. **Act** — navigates, clicks, types with human-like behavioral patterns
|
|
54
|
+
5. **Close** — terminates the browser process and cleans up
|
|
55
|
+
|
|
56
|
+
## Behavioral Engine
|
|
57
|
+
|
|
58
|
+
The Python SDK mirrors `cykani-stealth`'s `behaviors.js` — same anti-detection patterns, independent implementation:
|
|
59
|
+
|
|
60
|
+
| Feature | Description |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `cognitiveHesitation` | Pauses before actions based on page interaction density |
|
|
63
|
+
| `idleMicroMovement` | Random cursor jitter simulating natural idle behavior |
|
|
64
|
+
| `coffeeBreak` | Occasional long pauses (8% chance) simulating distraction |
|
|
65
|
+
| `bezierCurve` / `strikeMove` | Bézier curve mouse movement with drift points and correction curves |
|
|
66
|
+
| `typingDelay` | Per-character typing delays varying by character type (punctuation gets longer) |
|
|
67
|
+
| `microTremor` | Small Gaussian jitter preventing linear cursor tracking |
|
|
68
|
+
| `scrollCurve` | Smooth scrolling with eased acceleration/deceleration |
|
|
69
|
+
| `attentionDrift` | Simulated looking away at the screen, then refocusing |
|
|
70
|
+
|
|
71
|
+
## Connecting to an Existing Browser
|
|
72
|
+
|
|
73
|
+
If you already have a Chrome instance running, connect to it directly:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
session = await Session.create({
|
|
77
|
+
"_cdp_endpoint": "ws://127.0.0.1:9222/devtools/browser",
|
|
78
|
+
"fingerprint": 4242,
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## End-to-End in Two Languages
|
|
83
|
+
|
|
84
|
+
Both SDKs provide complete end-to-end browser automation — choose whichever language fits your team:
|
|
85
|
+
|
|
86
|
+
| | cykani-stealth (Node.js) | cykani-sdk (Python) |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| Browser launching | Native Chromium binary | Spawns Chrome via subprocess |
|
|
89
|
+
| Fingerprint evasion | C++ patches in binary | CDP-level configuration |
|
|
90
|
+
| Behavioral engine | Bézier curves, humanization | Same behavioral patterns |
|
|
91
|
+
| CDP protocol | Direct CDP WebSocket | `cdp-use` library |
|
|
92
|
+
| Auto-detection | Yes | Yes |
|
|
93
|
+
| Standalone | Yes, no Python needed | Yes, no Node.js needed |
|
|
94
|
+
|
|
95
|
+
Both share the same behavioral DNA — same Bézier curves, same typing delays, same cognitive hesitation, same micro-tremor. Pick your language and get the full experience.
|
|
96
|
+
|
|
97
|
+
## Architecture
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
cykani-stealth/
|
|
101
|
+
├── src/ # Node.js stealth engine (C++ patches, CDP)
|
|
102
|
+
│ └── ... # Full standalone browser automation
|
|
103
|
+
├── packages/
|
|
104
|
+
│ └── python/
|
|
105
|
+
│ └── cykani-python/ # Python SDK — complete standalone solution
|
|
106
|
+
│ ├── src/cykani_sdk/
|
|
107
|
+
│ │ ├── maestro.py # Browser session orchestration
|
|
108
|
+
│ │ ├── session.py # Standalone CDP browser session
|
|
109
|
+
│ │ ├── stealth/ # Behavioral engine + stealth
|
|
110
|
+
│ │ ├── agents/ # Autonomous navigation agents
|
|
111
|
+
│ │ └── utils/ # Cookies, proxy, geoip, session
|
|
112
|
+
│ ├── pyproject.toml
|
|
113
|
+
│ └── README.md
|
|
114
|
+
└── README.md
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cykani-stealth"
|
|
7
|
+
version = "1.3.4"
|
|
8
|
+
description = "Cykani Python SDK — stealth browser automation with fingerprint evasion, human-like behavior, and autonomous browsing"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"cdp-use>=1.4.5",
|
|
14
|
+
"httpx>=0.27.0",
|
|
15
|
+
"pydantic>=2.0",
|
|
16
|
+
"numpy>=1.26.0",
|
|
17
|
+
"orjson>=3.9.0",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.optional-dependencies]
|
|
21
|
+
geoip = ["geoip2>=5.0.0", "maxminddb>=2.6.0"]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/cykani/cykani-stealth"
|
|
25
|
+
Repository = "https://github.com/cykani/cykani-stealth"
|
|
26
|
+
|
|
27
|
+
[tool.setuptools.packages.find]
|
|
28
|
+
where = ["src"]
|
|
29
|
+
|
|
30
|
+
[tool.pytest.ini_options]
|
|
31
|
+
testpaths = ["tests"]
|
|
32
|
+
asyncio_mode = "auto"
|
|
33
|
+
|
|
34
|
+
[tool.ruff]
|
|
35
|
+
target-version = "py310"
|
|
36
|
+
line-length = 88
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from cykani_sdk.maestro import Maestro
|
|
2
|
+
from cykani_sdk.session import Session
|
|
3
|
+
from cykani_sdk.stealth.constellation import CdpWorld
|
|
4
|
+
from cykani_sdk.stealth.phantom import Phantom
|
|
5
|
+
from cykani_sdk.stealth.behavior import BehaviorEngine
|
|
6
|
+
from cykani_sdk.agents.strategist import Strategist
|
|
7
|
+
from cykani_sdk.agents.autonomous import Autonomous
|
|
8
|
+
from cykani_sdk.agents.observer import Observer
|
|
9
|
+
from cykani_sdk.agents.diagnostic import Diagnostic
|
|
10
|
+
from cykani_sdk.agents.perceptor import Perceptor
|
|
11
|
+
from cykani_sdk.utils.cookies import CookieJar
|
|
12
|
+
from cykani_sdk.utils.proxy import ProxyManager, resolve_proxy_config
|
|
13
|
+
from cykani_sdk.utils.geoip import resolve_geoip, COUNTRY_LOCALE_MAP
|
|
14
|
+
from cykani_sdk.utils.session import SessionState
|
|
15
|
+
from cykani_sdk.utils.errors import StealthError, ValidationError, SessionError
|
|
16
|
+
from cykani_sdk.utils.hooks import Hooks
|
|
17
|
+
from cykani_sdk.utils.poolize import Poolize
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
async def strike(entity: dict | None = None) -> Session:
|
|
21
|
+
maestro = Maestro()
|
|
22
|
+
return await maestro.launch(entity or {})
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
async def summon(entity: dict | None = None) -> Session:
|
|
26
|
+
return await strike(entity)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
async def unleash(entity: dict | None = None) -> Session:
|
|
30
|
+
return await strike(entity)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
async def launch_persistent_context(entity: dict | None = None) -> Session:
|
|
34
|
+
maestro = Maestro()
|
|
35
|
+
return await maestro.launchPersistentContext(entity or {})
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def create_maestro(opts: dict | None = None) -> Maestro:
|
|
39
|
+
return Maestro(opts or {})
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
async def high_trust(entity: dict | None = None) -> Session:
|
|
43
|
+
maestro = Maestro(strategy="highTrust")
|
|
44
|
+
return await maestro.launch(entity or {})
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
async def aggressive(entity: dict | None = None) -> Session:
|
|
48
|
+
maestro = Maestro(strategy="aggressive")
|
|
49
|
+
return await maestro.launch(entity or {})
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async def natural(entity: dict | None = None) -> Session:
|
|
53
|
+
maestro = Maestro(strategy="natural")
|
|
54
|
+
return await maestro.launch(entity or {})
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
async def stealth_launch(entity: dict | None = None) -> Session:
|
|
58
|
+
maestro = Maestro(strategy="stealth")
|
|
59
|
+
return await maestro.launch(entity or {})
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
__all__ = [
|
|
63
|
+
"Maestro",
|
|
64
|
+
"Session",
|
|
65
|
+
"CdpWorld",
|
|
66
|
+
"Phantom",
|
|
67
|
+
"BehaviorEngine",
|
|
68
|
+
"Strategist",
|
|
69
|
+
"Autonomous",
|
|
70
|
+
"Observer",
|
|
71
|
+
"Diagnostic",
|
|
72
|
+
"Perceptor",
|
|
73
|
+
"CookieJar",
|
|
74
|
+
"ProxyManager",
|
|
75
|
+
"resolve_proxy_config",
|
|
76
|
+
"resolve_geoip",
|
|
77
|
+
"COUNTRY_LOCALE_MAP",
|
|
78
|
+
"SessionState",
|
|
79
|
+
"StealthError",
|
|
80
|
+
"ValidationError",
|
|
81
|
+
"SessionError",
|
|
82
|
+
"Hooks",
|
|
83
|
+
"Poolize",
|
|
84
|
+
"strike",
|
|
85
|
+
"summon",
|
|
86
|
+
"unleash",
|
|
87
|
+
"launch_persistent_context",
|
|
88
|
+
"create_maestro",
|
|
89
|
+
"high_trust",
|
|
90
|
+
"aggressive",
|
|
91
|
+
"natural",
|
|
92
|
+
"stealth_launch",
|
|
93
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("cykani.adapters.playwright")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def adapt_to_playwright(session: Any) -> Any:
|
|
10
|
+
"""Adapt cykani-sdk session to Playwright-compatible interface."""
|
|
11
|
+
return session
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PlaywrightAdapter:
|
|
15
|
+
"""Adapter for Playwright-compatible session interface."""
|
|
16
|
+
|
|
17
|
+
def __init__(self, session: Any) -> None:
|
|
18
|
+
self._session = session
|
|
19
|
+
|
|
20
|
+
async def goto(self, url: str, **kwargs) -> Any:
|
|
21
|
+
return await self._session.goto(url, kwargs)
|
|
22
|
+
|
|
23
|
+
async def click(self, selector: str, **kwargs) -> Any:
|
|
24
|
+
return await self._session.click(selector, kwargs)
|
|
25
|
+
|
|
26
|
+
async def type(self, selector: str, text: str, **kwargs) -> Any:
|
|
27
|
+
return await self._session.type(selector, text, kwargs)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("cykani.agents.autoPilot")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AutoPilot:
|
|
10
|
+
"""AutoPilot agent for automated browsing."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, session: Any) -> None:
|
|
13
|
+
self._session = session
|
|
14
|
+
|
|
15
|
+
async def go(self, url: str) -> Any:
|
|
16
|
+
return await self._session.goto(url)
|
|
17
|
+
|
|
18
|
+
async def interact(self, action: str, target: str, value: str | None = None) -> Any:
|
|
19
|
+
if action == "click":
|
|
20
|
+
return await self._session.click(target)
|
|
21
|
+
elif action == "type":
|
|
22
|
+
return await self._session.type(target, value or "")
|
|
23
|
+
elif action == "fill":
|
|
24
|
+
return await self._session.fill(target, value or "")
|
|
25
|
+
elif action == "hover":
|
|
26
|
+
return await self._session.hover(target)
|
|
27
|
+
elif action == "goto":
|
|
28
|
+
return await self._session.goto(target)
|
|
29
|
+
return None
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("cykani.agents.autonomous")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Autonomous:
|
|
10
|
+
"""Autonomous browsing agent."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, session: Any) -> None:
|
|
13
|
+
self._session = session
|
|
14
|
+
|
|
15
|
+
async def signIn(self, email: str, password: str, **opts: Any) -> Any:
|
|
16
|
+
return await self._session.evaluate(
|
|
17
|
+
"(email, password) => { /* sign in logic */ }", email, password
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
async def fillForm(self, selector: str, data: dict) -> Any:
|
|
21
|
+
return await self._session.evaluate(
|
|
22
|
+
"(data) => { /* form fill logic */ }", data
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
async def navigateFlow(self, steps: list) -> Any:
|
|
26
|
+
for step in steps:
|
|
27
|
+
action = step.get("action")
|
|
28
|
+
if action == "goto":
|
|
29
|
+
await self._session.goto(step["url"])
|
|
30
|
+
elif action == "click":
|
|
31
|
+
await self._session.click(step["selector"])
|
|
32
|
+
elif action == "type":
|
|
33
|
+
await self._session.type(step["selector"], step["text"])
|
|
34
|
+
return {"steps_completed": len(steps)}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("cykani.agents.diagnostic")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Diagnostic:
|
|
10
|
+
"""Diagnostic agent for page analysis."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, session: Any) -> None:
|
|
13
|
+
self._session = session
|
|
14
|
+
|
|
15
|
+
async def scanForDetections(self) -> dict:
|
|
16
|
+
return await self._session.evaluate(
|
|
17
|
+
"() => ({ "
|
|
18
|
+
"navigator_webdriver: navigator.webdriver, "
|
|
19
|
+
"plugins_count: navigator.plugins.length, "
|
|
20
|
+
"languages: navigator.languages, "
|
|
21
|
+
"webgl_renderer: (() => { try { return document.createElement('canvas').getContext('webgl').getParameter(document.createElement('canvas').getContext('webgl').RENDERER); } catch(e) { return null; } })(), "
|
|
22
|
+
"})"
|
|
23
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("cykani.agents.observer")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Observer:
|
|
10
|
+
"""Observes page state and DOM changes."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, session: Any) -> None:
|
|
13
|
+
self._session = session
|
|
14
|
+
|
|
15
|
+
async def captureSnapshot(self) -> dict:
|
|
16
|
+
return await self._session.evaluate("() => ({ url: location.href, title: document.title })")
|
|
17
|
+
|
|
18
|
+
async def observe(self, selector: str) -> Any:
|
|
19
|
+
return await self._session.evaluate("(sel) => { const el = document.querySelector(sel); return el ? el.textContent : null; }", selector)
|
|
20
|
+
|
|
21
|
+
async def onMutation(self, callback) -> None:
|
|
22
|
+
await self._session.evaluate(
|
|
23
|
+
"(cb) => { new MutationObserver(cb).observe(document.body, {childList: true, subtree: true}); }",
|
|
24
|
+
callback,
|
|
25
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("cykani.agents.perceptor")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Perceptor:
|
|
10
|
+
"""Perceptor agent for visual understanding."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, session: Any) -> None:
|
|
13
|
+
self._session = session
|
|
14
|
+
|
|
15
|
+
async def captureVisual(self) -> bytes:
|
|
16
|
+
return await self._session.screenshot()
|
|
17
|
+
|
|
18
|
+
async def readPageContent(self) -> str:
|
|
19
|
+
return await self._session.content()
|
|
20
|
+
|
|
21
|
+
async def extractLinks(self) -> list[dict]:
|
|
22
|
+
return await self._session.evaluate(
|
|
23
|
+
"() => Array.from(document.querySelectorAll('a')).map(a => ({href: a.href, text: a.textContent.trim()}))"
|
|
24
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("cykani.agents.perceptual")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Perceptual:
|
|
10
|
+
"""Perceptual agent for cognitive modeling."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, session: Any) -> None:
|
|
13
|
+
self._session = session
|
|
14
|
+
|
|
15
|
+
async def assessPage(self) -> dict:
|
|
16
|
+
return await self._session.evaluate(
|
|
17
|
+
"() => ({ "
|
|
18
|
+
"isLoginPage: !!document.querySelector('input[type=password]'), "
|
|
19
|
+
"hasForm: !!document.querySelector('form'), "
|
|
20
|
+
"mainContent: document.querySelector('main') ? document.querySelector('main').textContent.substring(0, 500) : '', "
|
|
21
|
+
"})"
|
|
22
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("cykani.agents.realworld")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RealWorld:
|
|
10
|
+
"""Real-world interaction agent."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, session: Any) -> None:
|
|
13
|
+
self._session = session
|
|
14
|
+
|
|
15
|
+
async def simulateHumanJourney(self, steps: list[dict]) -> Any:
|
|
16
|
+
results = []
|
|
17
|
+
for step in steps:
|
|
18
|
+
action = step.get("action")
|
|
19
|
+
if action == "wait":
|
|
20
|
+
import asyncio
|
|
21
|
+
await asyncio.sleep(step.get("duration", 1.0))
|
|
22
|
+
elif action == "goto":
|
|
23
|
+
results.append(await self._session.goto(step["url"]))
|
|
24
|
+
elif action == "click":
|
|
25
|
+
results.append(await self._session.click(step["selector"]))
|
|
26
|
+
elif action == "type":
|
|
27
|
+
results.append(await self._session.type(step["selector"], step["text"]))
|
|
28
|
+
return results
|