human-input-kit 0.2.1__py3-none-any.whl
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.
- examples/demo_warmup.py +51 -0
- examples/mlx_warmup_demo.py +200 -0
- human_input_kit/__init__.py +23 -0
- human_input_kit/async_.py +19 -0
- human_input_kit/bezier.py +68 -0
- human_input_kit/cli.py +100 -0
- human_input_kit/deal.py +25 -0
- human_input_kit/gesture_schema.py +90 -0
- human_input_kit/gestures.py +84 -0
- human_input_kit/idle.py +41 -0
- human_input_kit/keyboard.py +31 -0
- human_input_kit/record.py +90 -0
- human_input_kit/replay.py +57 -0
- human_input_kit/rng.py +16 -0
- human_input_kit/scroll.py +28 -0
- human_input_kit/sync_.py +143 -0
- human_input_kit-0.2.1.dist-info/METADATA +272 -0
- human_input_kit-0.2.1.dist-info/RECORD +23 -0
- human_input_kit-0.2.1.dist-info/WHEEL +4 -0
- human_input_kit-0.2.1.dist-info/entry_points.txt +2 -0
- human_input_kit-0.2.1.dist-info/licenses/LICENSE +21 -0
- recipes/scroll_news.py +63 -0
- recipes/youtube_idle.py +69 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
human_input_kit/__init__.py,sha256=6YYhz4aOAoFe-sL-ccatlmOFUhpo5MS-LiUd-Gc-S9Q,690
|
|
2
|
+
human_input_kit/async_.py,sha256=CwMk9EFPdhsi9qDOWLC0e8eosWAAqY23NVIOZA2zAlg,535
|
|
3
|
+
human_input_kit/bezier.py,sha256=BiVrfFW8AGoE71JPHB1ha4SH2FOb0hrMyQHDLAXgA1M,1916
|
|
4
|
+
human_input_kit/cli.py,sha256=-tqvlsfqZn0gvqD56kt1udRj_tA9JhDpTwWLimSFbG8,4040
|
|
5
|
+
human_input_kit/deal.py,sha256=zq3igfmg6sDQmyS9jlB-i0PHdHPgeKAWhMqtZiyUJU0,809
|
|
6
|
+
human_input_kit/gesture_schema.py,sha256=w47T9TMgfZoSm8xz4m55j6VUTc62B_OXZOXOdHYevyk,3402
|
|
7
|
+
human_input_kit/gestures.py,sha256=GvD5yIyRtevYfKNTCIrI8dVzqLn5UEAdjdO51VOWW5w,2723
|
|
8
|
+
human_input_kit/idle.py,sha256=w8yhcytqfAYLXqNn2rda8ixHzVVgXaR72mfcB5sM_jA,1215
|
|
9
|
+
human_input_kit/keyboard.py,sha256=NwtDuSWOsGNBsqSV3oASMLcNNXvd7cj7sJM4hjl_b6o,789
|
|
10
|
+
human_input_kit/record.py,sha256=5SiErR3SrIFB_SqhllCpn4SS4hjjstAhf7x4tKVP1_k,2842
|
|
11
|
+
human_input_kit/replay.py,sha256=_3sjbSoQAGAMFSFSZq2wdMI5KqufiPodfD47Plm0f9Y,1950
|
|
12
|
+
human_input_kit/rng.py,sha256=KRjPggSMyhe8RyJpVdR9VN2x57F8PzBdkjMgVTh2Td0,328
|
|
13
|
+
human_input_kit/scroll.py,sha256=hvVBhyZTIHkPIdD4Vj9cJ7aPF_vbParkfiI_Cyren6U,678
|
|
14
|
+
human_input_kit/sync_.py,sha256=WlW7ODczOXq1uGSCzPIsDaWmk88Jj-bEgqzhuujV-7o,4268
|
|
15
|
+
examples/demo_warmup.py,sha256=MChB32hU0_ydDlQpVDVg1obZ1zs_JxjDAju5nQhOuw4,1750
|
|
16
|
+
examples/mlx_warmup_demo.py,sha256=NQfQcuzZJhZ02KIVNLzx6ZCsf5wwgyczKD1WrDMRV3M,6740
|
|
17
|
+
recipes/scroll_news.py,sha256=Q59XZ22e525NWThiZpro-ALvYaRI3jbsJcRqMcrkuhg,2287
|
|
18
|
+
recipes/youtube_idle.py,sha256=YcA1YCg_UlsP4EC6B9EQEXKpTgoreqrhpzSbkZlIrI8,2345
|
|
19
|
+
human_input_kit-0.2.1.dist-info/METADATA,sha256=sKHrcUMCqcI5mE1G2mUxQv8Zt4La-1efYxO43OEgPDk,11575
|
|
20
|
+
human_input_kit-0.2.1.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
21
|
+
human_input_kit-0.2.1.dist-info/entry_points.txt,sha256=rZbVuriIoBQTzyoM08eiLPkL5S0uMxDWiiy_NYd9dDU,57
|
|
22
|
+
human_input_kit-0.2.1.dist-info/licenses/LICENSE,sha256=m0P4i4pkm_Gu-65pQgOrWMo8VX6-HCZqnUL4Ywc7oGI,1085
|
|
23
|
+
human_input_kit-0.2.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 human-input-kit contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
recipes/scroll_news.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Scroll a news feed with human-like cadence.
|
|
3
|
+
|
|
4
|
+
Run from the package root::
|
|
5
|
+
|
|
6
|
+
python recipes/scroll_news.py --seed 42
|
|
7
|
+
python recipes/scroll_news.py --seed 42 --url https://news.ycombinator.com --bursts 8 --headed
|
|
8
|
+
|
|
9
|
+
Same motion repeats for a given ``--seed`` (uses ``human_input_kit.seed_rng``).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import asyncio
|
|
16
|
+
|
|
17
|
+
from playwright.async_api import async_playwright
|
|
18
|
+
|
|
19
|
+
from human_input_kit import seed_rng
|
|
20
|
+
from human_input_kit.async_ import bezier_mouse_path, idle_jitter, move_mouse_along, random_scroll
|
|
21
|
+
|
|
22
|
+
DEFAULT_URL = "https://news.ycombinator.com"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
async def scroll_news(*, url: str, seed: int, headless: bool, bursts: int) -> None:
|
|
26
|
+
seed_rng(seed)
|
|
27
|
+
async with async_playwright() as playwright:
|
|
28
|
+
browser = await playwright.chromium.launch(headless=headless)
|
|
29
|
+
page = await browser.new_page(viewport={"width": 1280, "height": 900})
|
|
30
|
+
await page.goto(url, wait_until="domcontentloaded", timeout=60_000)
|
|
31
|
+
|
|
32
|
+
# Drift into the feed before scrolling
|
|
33
|
+
path = bezier_mouse_path((120, 160), (640, 420), steps=22)
|
|
34
|
+
await move_mouse_along(page, path)
|
|
35
|
+
await random_scroll(page, bursts=bursts, min_delta=180, max_delta=480)
|
|
36
|
+
await idle_jitter(page, moves=4, radius=14)
|
|
37
|
+
|
|
38
|
+
# Second pass — slower tail read
|
|
39
|
+
await random_scroll(page, bursts=max(2, bursts // 2), min_delta=90, max_delta=260)
|
|
40
|
+
title = await page.title()
|
|
41
|
+
print(f"scroll_news done (seed={seed}, bursts={bursts}): {title}")
|
|
42
|
+
await browser.close()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def main() -> None:
|
|
46
|
+
parser = argparse.ArgumentParser(description="Human-like news feed scroll recipe")
|
|
47
|
+
parser.add_argument("--url", default=DEFAULT_URL, help="News page to open")
|
|
48
|
+
parser.add_argument("--seed", type=int, default=42, help="RNG seed for reproducible motion")
|
|
49
|
+
parser.add_argument("--bursts", type=int, default=6, help="Scroll wheel bursts per pass")
|
|
50
|
+
parser.add_argument("--headed", action="store_true", help="Show browser window")
|
|
51
|
+
args = parser.parse_args()
|
|
52
|
+
asyncio.run(
|
|
53
|
+
scroll_news(
|
|
54
|
+
url=args.url,
|
|
55
|
+
seed=args.seed,
|
|
56
|
+
headless=not args.headed,
|
|
57
|
+
bursts=args.bursts,
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if __name__ == "__main__":
|
|
63
|
+
main()
|
recipes/youtube_idle.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Idle on a YouTube watch surface — micro-moves and occasional scroll.
|
|
3
|
+
|
|
4
|
+
Run from the package root::
|
|
5
|
+
|
|
6
|
+
python recipes/youtube_idle.py --seed 42
|
|
7
|
+
python recipes/youtube_idle.py --seed 7 --seconds 30 --headed
|
|
8
|
+
|
|
9
|
+
Use ``--headed`` for fewer consent / bot interstitials on youtube.com.
|
|
10
|
+
Motion is deterministic per ``--seed``.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import asyncio
|
|
17
|
+
|
|
18
|
+
from playwright.async_api import async_playwright
|
|
19
|
+
|
|
20
|
+
from human_input_kit import seed_rng
|
|
21
|
+
from human_input_kit.async_ import idle_jitter, random_scroll
|
|
22
|
+
from human_input_kit.rng import get_rng
|
|
23
|
+
|
|
24
|
+
DEFAULT_URL = "https://www.youtube.com"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
async def youtube_idle(*, url: str, seed: int, headless: bool, seconds: float) -> None:
|
|
28
|
+
seed_rng(seed)
|
|
29
|
+
rng = get_rng()
|
|
30
|
+
async with async_playwright() as playwright:
|
|
31
|
+
browser = await playwright.chromium.launch(headless=headless)
|
|
32
|
+
page = await browser.new_page(viewport={"width": 1280, "height": 720})
|
|
33
|
+
await page.goto(url, wait_until="domcontentloaded", timeout=60_000)
|
|
34
|
+
|
|
35
|
+
elapsed = 0.0
|
|
36
|
+
cycles = 0
|
|
37
|
+
while elapsed < seconds:
|
|
38
|
+
await idle_jitter(page, moves=rng.randint(3, 6), radius=12)
|
|
39
|
+
if rng.random() < 0.35:
|
|
40
|
+
await random_scroll(page, bursts=1, min_delta=60, max_delta=140)
|
|
41
|
+
pause = rng.uniform(2.0, 5.5)
|
|
42
|
+
await asyncio.sleep(pause)
|
|
43
|
+
elapsed += pause
|
|
44
|
+
cycles += 1
|
|
45
|
+
|
|
46
|
+
title = await page.title()
|
|
47
|
+
print(f"youtube_idle done (seed={seed}, {cycles} cycles, {elapsed:.1f}s): {title}")
|
|
48
|
+
await browser.close()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def main() -> None:
|
|
52
|
+
parser = argparse.ArgumentParser(description="YouTube-style idle watch recipe")
|
|
53
|
+
parser.add_argument("--url", default=DEFAULT_URL, help="YouTube URL (home or watch page)")
|
|
54
|
+
parser.add_argument("--seed", type=int, default=42, help="RNG seed for reproducible motion")
|
|
55
|
+
parser.add_argument("--seconds", type=float, default=20.0, help="Approximate idle duration")
|
|
56
|
+
parser.add_argument("--headed", action="store_true", help="Show browser window")
|
|
57
|
+
args = parser.parse_args()
|
|
58
|
+
asyncio.run(
|
|
59
|
+
youtube_idle(
|
|
60
|
+
url=args.url,
|
|
61
|
+
seed=args.seed,
|
|
62
|
+
headless=not args.headed,
|
|
63
|
+
seconds=args.seconds,
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
main()
|