@minded-ai/mindedjs 2.0.26-beta.4 → 2.0.26-beta.6
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.
|
@@ -5,6 +5,8 @@ This script runs browser automation tasks using browser-use and can capture
|
|
|
5
5
|
screenshots at the end of each step, uploading them to S3 when configured.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import boto3
|
|
9
|
+
from botocore.exceptions import ClientError
|
|
8
10
|
import asyncio
|
|
9
11
|
import json
|
|
10
12
|
from typing import List, Optional, Dict, Any, TypedDict
|
|
@@ -42,18 +44,8 @@ class ScreenshotCapture:
|
|
|
42
44
|
self.config = config or {}
|
|
43
45
|
|
|
44
46
|
# Import boto3 only when screenshot capture is needed
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
from botocore.exceptions import ClientError
|
|
48
|
-
self.boto3 = boto3
|
|
49
|
-
self.ClientError = ClientError
|
|
50
|
-
except ImportError:
|
|
51
|
-
raise ImportError(
|
|
52
|
-
"boto3 is required for screenshot capture. "
|
|
53
|
-
"Please install it with: uv pip install boto3 "
|
|
54
|
-
"or run: npx minded setup-local-operator"
|
|
55
|
-
)
|
|
56
|
-
|
|
47
|
+
self.ClientError = ClientError
|
|
48
|
+
|
|
57
49
|
# S3 configuration with defaults
|
|
58
50
|
self.s3_bucket = self.config.get('s3_bucket')
|
|
59
51
|
self.s3_prefix = self.config.get('s3_prefix')
|
|
@@ -69,7 +61,7 @@ class ScreenshotCapture:
|
|
|
69
61
|
self.session_id = self.config.get('session_id', datetime.now().strftime("%Y%m%d_%H%M%S_%f")[:-3])
|
|
70
62
|
|
|
71
63
|
# Initialize S3 client with region
|
|
72
|
-
self.s3_client =
|
|
64
|
+
self.s3_client = boto3.client('s3', region_name=self.aws_region)
|
|
73
65
|
|
|
74
66
|
# Track step counter
|
|
75
67
|
self.step_counter = 0
|
|
@@ -88,8 +80,9 @@ class ScreenshotCapture:
|
|
|
88
80
|
# Get current URL for logging (browser-use might use method instead of property)
|
|
89
81
|
try:
|
|
90
82
|
current_url = page.url if hasattr(page, 'url') else page.url()
|
|
91
|
-
except:
|
|
92
|
-
|
|
83
|
+
except Exception as e:
|
|
84
|
+
logger.warning(f"⚠️ Failed to get current URL: {str(e)}")
|
|
85
|
+
return
|
|
93
86
|
|
|
94
87
|
# Update step counter
|
|
95
88
|
step_number = self.step_counter
|
|
@@ -98,7 +91,8 @@ class ScreenshotCapture:
|
|
|
98
91
|
logger.info(f"📸 Capturing screenshot #{step_number} at: {current_url}")
|
|
99
92
|
|
|
100
93
|
# Take screenshot - browser-use takes viewport by default
|
|
101
|
-
|
|
94
|
+
# Set timeout to prevent hanging (30 seconds)
|
|
95
|
+
screenshot_data = await page.screenshot(timeout=30000)
|
|
102
96
|
|
|
103
97
|
# Ensure we have bytes - browser-use might return base64 string or bytes
|
|
104
98
|
if isinstance(screenshot_data, bytes):
|
|
@@ -155,17 +149,7 @@ class LogsCapture:
|
|
|
155
149
|
self.config = config or {}
|
|
156
150
|
|
|
157
151
|
# Import boto3 only when logs capture is needed
|
|
158
|
-
|
|
159
|
-
import boto3
|
|
160
|
-
from botocore.exceptions import ClientError
|
|
161
|
-
self.boto3 = boto3
|
|
162
|
-
self.ClientError = ClientError
|
|
163
|
-
except ImportError:
|
|
164
|
-
raise ImportError(
|
|
165
|
-
"boto3 is required for logs capture. "
|
|
166
|
-
"Please install it with: uv pip install boto3 "
|
|
167
|
-
"or run: npx minded setup-local-operator"
|
|
168
|
-
)
|
|
152
|
+
self.ClientError = ClientError
|
|
169
153
|
|
|
170
154
|
# S3 configuration
|
|
171
155
|
self.s3_bucket = self.config.get('s3_bucket')
|
|
@@ -183,7 +167,7 @@ class LogsCapture:
|
|
|
183
167
|
self.tool_call_id = self.config.get('tool_call_id', 'unknown')
|
|
184
168
|
|
|
185
169
|
# Initialize S3 client with region
|
|
186
|
-
self.s3_client =
|
|
170
|
+
self.s3_client = boto3.client('s3', region_name=self.aws_region)
|
|
187
171
|
|
|
188
172
|
# Track accumulated logs
|
|
189
173
|
self.log_entries: List[str] = []
|
package/package.json
CHANGED
|
@@ -5,6 +5,8 @@ This script runs browser automation tasks using browser-use and can capture
|
|
|
5
5
|
screenshots at the end of each step, uploading them to S3 when configured.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import boto3
|
|
9
|
+
from botocore.exceptions import ClientError
|
|
8
10
|
import asyncio
|
|
9
11
|
import json
|
|
10
12
|
from typing import List, Optional, Dict, Any, TypedDict
|
|
@@ -42,18 +44,8 @@ class ScreenshotCapture:
|
|
|
42
44
|
self.config = config or {}
|
|
43
45
|
|
|
44
46
|
# Import boto3 only when screenshot capture is needed
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
from botocore.exceptions import ClientError
|
|
48
|
-
self.boto3 = boto3
|
|
49
|
-
self.ClientError = ClientError
|
|
50
|
-
except ImportError:
|
|
51
|
-
raise ImportError(
|
|
52
|
-
"boto3 is required for screenshot capture. "
|
|
53
|
-
"Please install it with: uv pip install boto3 "
|
|
54
|
-
"or run: npx minded setup-local-operator"
|
|
55
|
-
)
|
|
56
|
-
|
|
47
|
+
self.ClientError = ClientError
|
|
48
|
+
|
|
57
49
|
# S3 configuration with defaults
|
|
58
50
|
self.s3_bucket = self.config.get('s3_bucket')
|
|
59
51
|
self.s3_prefix = self.config.get('s3_prefix')
|
|
@@ -69,7 +61,7 @@ class ScreenshotCapture:
|
|
|
69
61
|
self.session_id = self.config.get('session_id', datetime.now().strftime("%Y%m%d_%H%M%S_%f")[:-3])
|
|
70
62
|
|
|
71
63
|
# Initialize S3 client with region
|
|
72
|
-
self.s3_client =
|
|
64
|
+
self.s3_client = boto3.client('s3', region_name=self.aws_region)
|
|
73
65
|
|
|
74
66
|
# Track step counter
|
|
75
67
|
self.step_counter = 0
|
|
@@ -88,8 +80,9 @@ class ScreenshotCapture:
|
|
|
88
80
|
# Get current URL for logging (browser-use might use method instead of property)
|
|
89
81
|
try:
|
|
90
82
|
current_url = page.url if hasattr(page, 'url') else page.url()
|
|
91
|
-
except:
|
|
92
|
-
|
|
83
|
+
except Exception as e:
|
|
84
|
+
logger.warning(f"⚠️ Failed to get current URL: {str(e)}")
|
|
85
|
+
return
|
|
93
86
|
|
|
94
87
|
# Update step counter
|
|
95
88
|
step_number = self.step_counter
|
|
@@ -98,7 +91,8 @@ class ScreenshotCapture:
|
|
|
98
91
|
logger.info(f"📸 Capturing screenshot #{step_number} at: {current_url}")
|
|
99
92
|
|
|
100
93
|
# Take screenshot - browser-use takes viewport by default
|
|
101
|
-
|
|
94
|
+
# Set timeout to prevent hanging (30 seconds)
|
|
95
|
+
screenshot_data = await page.screenshot(timeout=30000)
|
|
102
96
|
|
|
103
97
|
# Ensure we have bytes - browser-use might return base64 string or bytes
|
|
104
98
|
if isinstance(screenshot_data, bytes):
|
|
@@ -155,17 +149,7 @@ class LogsCapture:
|
|
|
155
149
|
self.config = config or {}
|
|
156
150
|
|
|
157
151
|
# Import boto3 only when logs capture is needed
|
|
158
|
-
|
|
159
|
-
import boto3
|
|
160
|
-
from botocore.exceptions import ClientError
|
|
161
|
-
self.boto3 = boto3
|
|
162
|
-
self.ClientError = ClientError
|
|
163
|
-
except ImportError:
|
|
164
|
-
raise ImportError(
|
|
165
|
-
"boto3 is required for logs capture. "
|
|
166
|
-
"Please install it with: uv pip install boto3 "
|
|
167
|
-
"or run: npx minded setup-local-operator"
|
|
168
|
-
)
|
|
152
|
+
self.ClientError = ClientError
|
|
169
153
|
|
|
170
154
|
# S3 configuration
|
|
171
155
|
self.s3_bucket = self.config.get('s3_bucket')
|
|
@@ -183,7 +167,7 @@ class LogsCapture:
|
|
|
183
167
|
self.tool_call_id = self.config.get('tool_call_id', 'unknown')
|
|
184
168
|
|
|
185
169
|
# Initialize S3 client with region
|
|
186
|
-
self.s3_client =
|
|
170
|
+
self.s3_client = boto3.client('s3', region_name=self.aws_region)
|
|
187
171
|
|
|
188
172
|
# Track accumulated logs
|
|
189
173
|
self.log_entries: List[str] = []
|