dialoghelper 0.0.28__tar.gz → 0.0.29__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.
Potentially problematic release.
This version of dialoghelper might be problematic. Click here for more details.
- {dialoghelper-0.0.28/dialoghelper.egg-info → dialoghelper-0.0.29}/PKG-INFO +1 -1
- dialoghelper-0.0.29/dialoghelper/__init__.py +2 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper/experimental.py +32 -29
- {dialoghelper-0.0.28 → dialoghelper-0.0.29/dialoghelper.egg-info}/PKG-INFO +1 -1
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/settings.ini +1 -1
- dialoghelper-0.0.28/dialoghelper/__init__.py +0 -2
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/LICENSE +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/MANIFEST.in +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/README.md +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper/_modidx.py +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper/core.py +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper/db_dc.py +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper/screenshot.js +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/SOURCES.txt +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/dependency_links.txt +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/entry_points.txt +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/not-zip-safe +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/requires.txt +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/dialoghelper.egg-info/top_level.txt +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/pyproject.toml +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/setup.cfg +0 -0
- {dialoghelper-0.0.28 → dialoghelper-0.0.29}/setup.py +0 -0
|
@@ -6,22 +6,22 @@
|
|
|
6
6
|
__all__ = ['iife', 'load_screenshot_js', 'start_screen_share', 'stop_screen_share', 'capture_screen']
|
|
7
7
|
|
|
8
8
|
# %% ../nbs/01_experimental.ipynb
|
|
9
|
+
import uuid,json
|
|
9
10
|
from importlib import resources
|
|
10
|
-
import
|
|
11
|
-
from fasthtml.common import Div, Script
|
|
12
|
-
import json
|
|
11
|
+
from fasthtml.common import Div,Script
|
|
13
12
|
from claudette import ToolResult
|
|
14
13
|
from .core import *
|
|
15
14
|
from httpx import post as xpost
|
|
16
15
|
|
|
17
16
|
# %% ../nbs/01_experimental.ipynb
|
|
18
|
-
def _pop_data(data_id, timeout=20
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (data := result.json())
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
def _pop_data(data_id, timeout=20):
|
|
18
|
+
params = {'data_id': data_id, 'timeout':timeout}
|
|
19
|
+
result = xpost('http://localhost:5001/pop_data_blocking_', data=params, timeout=timeout+1)
|
|
20
|
+
if result.status_code==200 and result.text.strip():
|
|
21
|
+
if (data := result.json()): return data
|
|
22
|
+
# except json.JSONDecodeError as e: print(f"JSON decode error: {e}")
|
|
23
|
+
raise RuntimeError("No data received")
|
|
24
|
+
raise RuntimeError(result.status_code)
|
|
25
25
|
|
|
26
26
|
# %% ../nbs/01_experimental.ipynb
|
|
27
27
|
def iife(code: str) -> str:
|
|
@@ -40,13 +40,14 @@ def load_screenshot_js(force=False, timeout=5):
|
|
|
40
40
|
"Load screenshot capability and wait for confirmation it's ready."
|
|
41
41
|
global _js_loaded
|
|
42
42
|
if _js_loaded and not force: return
|
|
43
|
-
|
|
43
|
+
# print("Loading screenshot.js ...")
|
|
44
44
|
status_id = str(uuid.uuid4())
|
|
45
|
-
js_content = (resources.files('dialoghelper')
|
|
45
|
+
js_content = (resources.files('dialoghelper')/'screenshot.js').read_text()
|
|
46
46
|
iife(js_content + f'sendDataToServer("{status_id}", {{"js_status": "ready"}});')
|
|
47
|
-
data = _pop_data(status_id, timeout
|
|
47
|
+
data = _pop_data(status_id, timeout)
|
|
48
|
+
if (stat:=data.get('js_status'))!='ready': raise RuntimeError(f"Failed to load screenshot.js: {stat}")
|
|
48
49
|
_js_loaded = True
|
|
49
|
-
|
|
50
|
+
# print("Screenshot.js loaded and ready")
|
|
50
51
|
|
|
51
52
|
# %% ../nbs/01_experimental.ipynb
|
|
52
53
|
_screen_share_active = False
|
|
@@ -57,23 +58,23 @@ def start_screen_share(timeout=45):
|
|
|
57
58
|
load_screenshot_js()
|
|
58
59
|
status_id = str(uuid.uuid4())
|
|
59
60
|
iife(f'startPersistentScreenShare("{status_id}");')
|
|
60
|
-
|
|
61
|
-
data = _pop_data(status_id, timeout
|
|
61
|
+
# print("Requesting screen share permission ...")
|
|
62
|
+
data = _pop_data(status_id, timeout)
|
|
62
63
|
js_status = data.get('js_status')
|
|
63
|
-
if js_status
|
|
64
|
+
if js_status=='ready':
|
|
64
65
|
_screen_share_active = True
|
|
65
|
-
|
|
66
|
-
elif js_status
|
|
67
|
-
elif js_status
|
|
66
|
+
# print("Screen share started successfully.")
|
|
67
|
+
elif js_status=='error': raise RuntimeError(f"Screen share failed: {data.get('error', 'Unknown error')}")
|
|
68
|
+
elif js_status=='connecting': raise RuntimeError("Screen share timed out after {timeout} seconds.")
|
|
68
69
|
|
|
69
70
|
# %% ../nbs/01_experimental.ipynb
|
|
70
71
|
def stop_screen_share():
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
"Stop persistent screen sharing session."
|
|
73
|
+
global _screen_share_active
|
|
74
|
+
load_screenshot_js()
|
|
75
|
+
iife('stopPersistentScreenShare();')
|
|
76
|
+
_screen_share_active = False
|
|
77
|
+
# print("Screen share stopped.")
|
|
77
78
|
|
|
78
79
|
# %% ../nbs/01_experimental.ipynb
|
|
79
80
|
def capture_screen():
|
|
@@ -81,13 +82,15 @@ def capture_screen():
|
|
|
81
82
|
global _screen_share_active
|
|
82
83
|
load_screenshot_js()
|
|
83
84
|
if not _screen_share_active:
|
|
84
|
-
|
|
85
|
+
# print("🔄 No active screen share, starting one...")
|
|
85
86
|
result = start_screen_share()
|
|
86
87
|
if not _screen_share_active: raise RuntimeError(f"Failed to start screen share: {result}")
|
|
87
88
|
data_id = str(uuid.uuid4())
|
|
88
89
|
screenshot_code = f'captureScreenFromStream("{data_id}");'
|
|
89
|
-
|
|
90
|
+
# print("📸 Capturing from persistent stream...")
|
|
90
91
|
iife(screenshot_code)
|
|
91
|
-
data = _pop_data(data_id, timeout=
|
|
92
|
+
data = _pop_data(data_id, timeout=45)
|
|
92
93
|
if 'error' in data: raise RuntimeError(f"Screenshot failed: {data['error']}")
|
|
94
|
+
if not ('img_data' in data and 'img_type' in data):
|
|
95
|
+
raise RuntimeError("Screenshot capture failed, failed to retrieve data.")
|
|
93
96
|
return ToolResult(data=data['img_data'], result_type=data['img_type'])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|