diff --git a/.DS_Store b/.DS_Store
deleted file mode 100644
index 3fd6e1a80801e0b9b905f9cbb02dba1312010192..0000000000000000000000000000000000000000
Binary files a/.DS_Store and /dev/null differ
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..1897a03383ca43a0f673ec004f510e8fb4d96441
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,119 @@
+# Environment variables and secrets (CRITICAL - NEVER COMMIT)
+.env
+.env.*
+*.env
+.env.local
+.env.development
+.env.production
+
+# API Keys and credentials (CRITICAL)
+secrets.json
+credentials.json
+config.json
+.secrets
+
+# Python Virtual Environments (Regenerable)
+venv/
+.venv/
+env/
+.env/
+ENV/
+env.bak/
+venv.bak/
+
+# Python cache and compiled files (Regenerable)
+__pycache__/
+*.py[cod]
+*$py.class
+*.so
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# IDE and Editor files (Personal preference)
+.vscode/
+.idea/
+*.swp
+*.swo
+*~
+
+# Operating System files (System artifacts)
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
+Desktop.ini
+
+# Logs and temporary files (Regenerable)
+*.log
+logs/
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Testing and coverage (Regenerable)
+.pytest_cache/
+.coverage
+.coverage.*
+htmlcov/
+.tox/
+.nox/
+coverage.xml
+*.cover
+.hypothesis/
+
+# Documentation builds (Regenerable)
+docs/_build/
+site/
+
+# Build and distribution (Regenerable)
+build/
+dist/
+*.egg-info/
+.eggs/
+*.whl
+
+# Application-specific folders (May contain sensitive data)
+local_trajectories/
+screenshots/
+gifs/
+uploads/
+downloads/
+
+# Backup files
+*.bak
+*.backup
+*.old
+*.orig
+
+# Temporary files
+tmp/
+temp/
+.tmp/
+
+# Node modules (if any Node.js is used)
+node_modules/
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Jupyter Notebook checkpoints
+.ipynb_checkpoints
+
+# macOS specific
+.AppleDouble
+.LSOverride
+
+# Windows specific
+$RECYCLE.BIN/
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# Linux specific
+*~
\ No newline at end of file
diff --git a/README.md b/README.md
index 676382120b7cb8cd88520043d091bf5d8ab59ea1..7a751d1972edfabd375089fbede5b752ddb324fa 100644
--- a/README.md
+++ b/README.md
@@ -7,4 +7,73 @@ sdk: docker
pinned: false
---
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
+# Proxy-lite Salesforce Automation with Single-Browser Login
+
+This is a modernized proxy-lite Salesforce automation system that uses a streamlined single-browser login approach.
+
+## Key Features
+
+✅ **Single-Browser Login**: No more cookie injection complexity
+✅ **Dual API Support**: Works with both Gemini and Convergence AI
+✅ **Automatic Authentication**: Handles Salesforce login seamlessly
+✅ **Efficient Architecture**: One browser instance for login and task execution
+
+## Quick Start
+
+### Environment Setup
+
+1. Install dependencies:
+```bash
+pip install -r requirements.txt
+```
+
+2. Set environment variables:
+```bash
+# API Keys (set at least one)
+export GEMINI_API_KEY=your_gemini_api_key
+export HF_API_TOKEN=your_hf_token
+
+# Salesforce Credentials
+export SALESFORCE_USERNAME=your_salesforce_username
+export SALESFORCE_PASSWORD=your_salesforce_password
+```
+
+3. Run the Flask app:
+```bash
+python app.py
+```
+
+### Usage
+
+Send a POST request to `/run_proxy_task`:
+
+```json
+{
+ "task": "Navigate to the permission set and assign it to the user",
+ "url": "https://your-org.salesforce.com/lightning/setup/AccountForecastSettings/home"
+}
+```
+
+## Architecture
+
+The system automatically:
+1. Initializes a browser session
+2. Performs Salesforce login using provided credentials
+3. Navigates to the target URL
+4. Executes the requested task
+5. Returns structured results
+
+## API Priority
+
+- **Gemini API** (preferred if `GEMINI_API_KEY` is set)
+- **Convergence AI** (fallback if only `HF_API_TOKEN` is set)
+
+## Benefits over Cookie Injection
+
+- Eliminates cookie extraction/injection complexity
+- More efficient (no separate browser instance)
+- Better session management
+- More reliable navigation
+- Easier to maintain and debug
+
+See `SINGLE_BROWSER_LOGIN_GUIDE.md` for detailed documentation.
diff --git a/app.py b/app.py
index 821421667e768130e307e1fd7bdcc690fe8116c9..ce72d4916b2ff2fa2ce1f904258253b352741cae 100644
--- a/app.py
+++ b/app.py
@@ -7,89 +7,67 @@ from proxy_lite import Runner, RunnerConfig
import os
import logging
from datetime import datetime
-from playwright.async_api import async_playwright, TimeoutError as PlaywrightTimeoutError
+
+# Load environment variables from .env file
+try:
+ from dotenv import load_dotenv
+ load_dotenv() # This loads .env from current directory
+ # Also try loading from subdirectory if it exists
+ if os.path.exists('proxy-lite-demo-v2/.env'):
+ load_dotenv('proxy-lite-demo-v2/.env')
+ print("✅ Environment variables loaded from .env file")
+except ImportError:
+ print("⚠️ python-dotenv not installed. Install with: pip install python-dotenv")
+except Exception as e:
+ print(f"⚠️ Could not load .env file: {e}")
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
app = Flask(__name__)
-_runner = None
-
-async def perform_hardcoded_salesforce_login_and_get_cookies(username, password, login_url, target_url):
- logger.info("Attempting hardcoded Salesforce login with Playwright to obtain cookies...")
- async with async_playwright() as p:
- browser = await p.chromium.launch(headless=True, args=["--no-sandbox", "--disable-setuid-sandbox"])
- context = await browser.new_context()
- page = await context.new_page()
-
- try:
- await page.goto(login_url, wait_until="domcontentloaded", timeout=60000)
- logger.info(f"Playwright: Navigated to Salesforce login page: {page.url}")
-
- await page.fill("#username", username)
- await page.fill("#password", password)
- await page.click("#Login")
- logger.info("Playwright: Filled credentials and clicked Login. Waiting for post-login state...")
-
- try:
- await page.wait_for_url(lambda url: "login.salesforce.com" not in url and "unauthorized" not in url.lower(), timeout=60000)
- logger.info(f"Playwright: Successfully redirected from login page. Current URL: {page.url}")
- await page.wait_for_selector('button[title="App Launcher"]', timeout=30000)
- logger.info("Playwright: Main Salesforce Lightning UI (e.g., App Launcher) detected after login.")
-
- except PlaywrightTimeoutError:
- logger.error(f"Playwright: Did not detect main UI or expected URL change within timeout after login. Current URL: {page.url}. Login might have failed or stuck on a redirect loop.")
- raise Exception("Salesforce login redirection failed or main UI not detected.")
-
- logger.info(f"Playwright: Navigating to target URL: {target_url} to ensure all relevant cookies are captured.")
- await page.goto(target_url, wait_until="domcontentloaded", timeout=60000)
-
- try:
- # Wait for generic Salesforce setup page elements to load
- await page.wait_for_selector('.setupPage, .slds-page-header, .slds-card, [data-aura-class*="setup"], .forcePageBlockSectionView', timeout=30000)
- logger.info("Playwright: Detected Salesforce setup page elements loaded successfully.")
- except PlaywrightTimeoutError:
- logger.warning("Playwright: Specific setup page elements not found. Trying generic page load check...")
- try:
- # Fallback: wait for page to reach network idle state
- await page.wait_for_load_state("networkidle", timeout=10000)
- logger.info("Playwright: Page reached network idle state - proceeding with task.")
- except PlaywrightTimeoutError:
- logger.info("Playwright: Page load validation timed out, but continuing as page may still be functional.")
-
- await asyncio.sleep(2)
- logger.info(f"Playwright: Successfully navigated to and confirmed content on {page.url}")
-
- cookies = await context.cookies()
- logger.info(f"Playwright: Extracted {len(cookies)} cookies after successful login and navigation.")
- return cookies
-
- except PlaywrightTimeoutError as e:
- logger.error(f"Playwright login/navigation failed (Timeout): {e}. Current URL: {page.url}")
- raise
- except Exception as e:
- logger.error(f"Playwright login/navigation failed (General Error): {e}. Current URL: {page.url}")
- raise
- finally:
- if browser:
- await browser.close()
-
-
-async def initialize_runner_with_cookies(cookies: list, target_url: str):
+_runner: Runner | None = None
+
+async def initialize_runner_with_single_browser_login(username: str, password: str, target_url: str):
+ """Initialize Proxy-lite Runner with single-browser login approach."""
global _runner
- logger.info("Initializing Proxy-lite Runner with provided cookies...")
+ logger.info("Initializing Proxy-lite Runner with single-browser login approach...")
+ # Check for required API keys with debugging
gemini_api_key = os.environ.get("GEMINI_API_KEY")
- if not gemini_api_key:
- logger.error("GEMINI_API_KEY environment variable not set. Cannot initialize Runner.")
- raise ValueError("GEMINI_API_KEY environment variable not set. Please set it as a Space secret.")
+ hf_api_token = os.environ.get("HF_API_TOKEN")
+
+ logger.info(f"🔍 Environment check: GEMINI_API_KEY={'SET' if gemini_api_key else 'NOT SET'}")
+ logger.info(f"🔍 Environment check: HF_API_TOKEN={'SET' if hf_api_token else 'NOT SET'}")
+
+ if not gemini_api_key and not hf_api_token:
+ logger.error("Neither GEMINI_API_KEY nor HF_API_TOKEN environment variable is set")
+ raise ValueError("Either GEMINI_API_KEY or HF_API_TOKEN must be set")
+
+ # Prefer Gemini if both are available
+ if gemini_api_key:
+ client_config = {
+ "name": "gemini",
+ "model_id": "gemini-2.0-flash-001",
+ "api_key": gemini_api_key,
+ }
+ logger.info("🤖 Using Gemini API for inference")
+ else:
+ client_config = {
+ "name": "convergence",
+ "model_id": "convergence-ai/proxy-lite-3b",
+ "api_base": "https://convergence-ai-demo-api.hf.space/v1",
+ "api_key": hf_api_token,
+ "http_timeout": 50.0,
+ "http_concurrent_connections": 50,
+ }
+ logger.info("🤖 Using Convergence AI for inference")
config_dict = {
"environment": {
"name": "webbrowser",
- "homepage": "about:blank", # Safe startup, we'll open new tab programmatically
- "headless": True,
+ "homepage": "about:blank", # Will be skipped due to login
+ "headless": False,
"launch_args": ["--no-sandbox", "--disable-setuid-sandbox"],
"screenshot_delay": 0.5,
"include_html": True,
@@ -100,19 +78,19 @@ async def initialize_runner_with_cookies(cookies: list, target_url: str):
"browserbase_timeout": 7200,
"keep_original_image": False,
"no_pois_in_image": False,
- "initial_cookies": cookies
+ # --- SINGLE-BROWSER LOGIN CONFIG ---
+ "perform_login": True,
+ "salesforce_login_url": "https://login.salesforce.com/",
+ "salesforce_username": username,
+ "salesforce_password": password,
+ "target_url": target_url
+ # --- END SINGLE-BROWSER LOGIN CONFIG ---
},
"solver": {
"name": "simple",
"agent": {
"name": "proxy_lite",
- "client": {
- "name": "gemini",
- "model_id": "gemini-2.0-flash-001",
- "api_key": gemini_api_key,
- "http_timeout": 50.0,
- "http_concurrent_connections": 50,
- },
+ "client": client_config,
"history_messages_limit": {
"screenshot": 1
},
@@ -129,15 +107,18 @@ async def initialize_runner_with_cookies(cookies: list, target_url: str):
}
config = RunnerConfig.from_dict(config_dict)
- logger.info(f"DEBUG: app.py - Initializing Proxy-lite Runner with Gemini Flash 2.0 configuration.")
+ logger.info(f"DEBUG: app.py - Initializing Proxy-lite Runner with single-browser login approach")
_runner = Runner(config=config)
- logger.info("Proxy-lite Runner initialized successfully with Gemini Flash 2.0 and injected cookies.")
+ logger.info("Proxy-lite Runner initialized successfully with single-browser login")
return _runner
@app.route('/run_proxy_task', methods=['POST'])
async def run_proxy_task_endpoint():
data = request.json
+ if not data:
+ return jsonify({"error": "No JSON data provided"}), 400
+
request_task_instruction = data.get('task')
target_url = data.get('url')
@@ -165,24 +146,90 @@ async def run_proxy_task_endpoint():
logger.error("Salesforce credentials (SALESFORCE_USERNAME, SALESFORCE_PASSWORD) environment variables not set.")
return jsonify({"error": "Salesforce credentials not configured. Please set SALESFORCE_USERNAME and SALESFORCE_PASSWORD as Space secrets."}), 500
- salesforce_login_url = "https://login.salesforce.com/"
- logger.info("Executing hardcoded login via Playwright to get session cookies...")
- session_cookies = await perform_hardcoded_salesforce_login_and_get_cookies(
- salesforce_username, salesforce_password, salesforce_login_url, target_url
- )
- logger.info(f"Successfully obtained {len(session_cookies)} cookies. These will be injected into the agent's browser.")
+ runner = await initialize_runner_with_single_browser_login(salesforce_username, salesforce_password, target_url)
+ logger.info("Proxy-lite Runner initialized with cookies." if salesforce_username and salesforce_password else "Proxy-lite Runner initialized for general web browsing.")
+
+ logger.info("Agent will use mandatory new tab tool to bypass loading issues.")
+
+ # MANDATORY new tab navigation task - this is critical to avoid loading issues
+ agent_task = f"""
+CRITICAL FIRST STEP - MANDATORY:
+Your VERY FIRST action must be to use the open_new_tab_and_go_to tool to navigate to {target_url}
+
+DO NOT skip this step. DO NOT use goto. You MUST use: open_new_tab_and_go_to(url='{target_url}')
+
+This is necessary because direct navigation to this URL gets stuck loading. The new tab approach bypasses this issue.
+
+STEP 1: Use open_new_tab_and_go_to(url='{target_url}')
+STEP 2: Wait for the page to be fully loaded (no loading spinners visible)
+STEP 3: {request_task_instruction}
+
+CRITICAL WORKFLOW - FOLLOW THESE EXACT STEPS IN SEQUENCE:
+
+STEP A: Select Permission Set
+- Use select_option_by_text tool to find and select the target permission set from Available list
+- Wait for "[ACTION COMPLETED]" response before proceeding
+
+STEP B: Click Add Button
+- After successful selection, immediately click the "Add" button to move permission set to Enabled list
+- Do NOT repeat the selection - proceed directly to Add button
+
+STEP C: Click Save Button
+- After clicking Add, immediately click "Save" to persist the changes
+- After Save, Salesforce redirects to User page indicating SUCCESS
+
+CRITICAL: Do NOT repeat actions. Each step should happen exactly once in sequence.
+
+GENERAL INSTRUCTIONS:
+- You must EXECUTE all actions immediately - do NOT just describe what you plan to do
+- Do NOT wait for user input or ask "what should I do next?"
+- Complete the entire task autonomously using the available tools
+- After completing all steps, use the return_value tool to provide your final response
+- If you make a plan, IMMEDIATELY execute it step by step using the appropriate tools
+ """
+
+ logger.info("Executing agent task with mandatory new tab navigation...")
+ result = await runner.run(task=agent_task)
+
+ # Extract the actual result value from the Run object
+ task_result = str(getattr(result, "value", None) or getattr(result, "result", None) or result)
+
+ logger.info(f"Proxy-lite task completed. Output (truncated for log): {task_result[:500]}...")
+
+ # Structure response for LWC integration
+ response = {
+ "status": "success",
+ "message": "Task completed successfully",
+ "data": {
+ "task_result": task_result,
+ "steps_completed": [
+ "Hardcoded Salesforce login completed",
+ "Browser session initialized with cookies",
+ "New tab navigation executed",
+ "Target Salesforce setup page accessed",
+ "Task execution completed successfully"
+ ],
+ "environment": {
+ "target_url": target_url,
+ "cookies_count": 0, # No explicit cookie count for single-browser login
+ "navigation_method": "new_tab_bypass"
+ }
+ },
+ "timestamp": datetime.now().isoformat(),
+ "task_request": request_task_instruction
+ }
+
+ return jsonify(response)
else:
# General web browsing - no login required
logger.info("Non-Salesforce URL detected. Skipping Salesforce login.")
- session_cookies = []
-
- runner = await initialize_runner_with_cookies(session_cookies, target_url)
- logger.info("Proxy-lite Runner initialized with cookies." if session_cookies else "Proxy-lite Runner initialized for general web browsing.")
+ runner = await initialize_runner_with_single_browser_login("", "", target_url)
+ logger.info("Proxy-lite Runner initialized for general web browsing.")
- logger.info("Agent will use mandatory new tab tool to bypass loading issues.")
-
- # MANDATORY new tab navigation task - this is critical to avoid loading issues
- agent_task = f"""
+ logger.info("Agent will use mandatory new tab tool to bypass loading issues.")
+
+ # MANDATORY new tab navigation task - this is critical to avoid loading issues
+ agent_task = f"""
CRITICAL FIRST STEP - MANDATORY:
Your VERY FIRST action must be to use the open_new_tab_and_go_to tool to navigate to {target_url}
@@ -216,61 +263,39 @@ GENERAL INSTRUCTIONS:
- Complete the entire task autonomously using the available tools
- After completing all steps, use the return_value tool to provide your final response
- If you make a plan, IMMEDIATELY execute it step by step using the appropriate tools
- """
-
- logger.info("Executing agent task with mandatory new tab navigation...")
- result = await runner.run(task=agent_task)
-
- # Extract the actual result value from the Run object
- if hasattr(result, 'value') and result.value:
- task_result = str(result.value)
- elif hasattr(result, 'result') and result.result:
- task_result = str(result.result)
- else:
- task_result = str(result)
+ """
- logger.info(f"Proxy-lite task completed. Output (truncated for log): {task_result[:500]}...")
-
- # Structure response for LWC integration
- response = {
- "status": "success",
- "message": "Task completed successfully",
- "data": {
- "task_result": task_result,
- "steps_completed": [
- "Hardcoded Salesforce login completed",
- "Browser session initialized with cookies",
- "New tab navigation executed",
- "Target Salesforce setup page accessed",
- "Task execution completed successfully"
- ],
- "environment": {
- "target_url": target_url,
- "cookies_count": len(session_cookies),
- "navigation_method": "new_tab_bypass"
- }
- },
- "timestamp": datetime.now().isoformat(),
- "task_request": request_task_instruction
- }
-
- return jsonify(response)
-
- except PlaywrightTimeoutError as e:
- logger.exception(f"Playwright timeout during login/navigation: {e}")
- error_response = {
- "status": "error",
- "error_type": "navigation_timeout",
- "message": "Page loading timed out during login or navigation",
- "data": {
- "error_details": str(e),
- "suggested_action": "Retry the request - network issues may be temporary",
- "steps_completed": ["Login attempted", "Navigation failed due to timeout"]
- },
- "timestamp": datetime.now().isoformat(),
- "task_request": request_task_instruction
- }
- return jsonify(error_response), 500
+ logger.info("Executing agent task with mandatory new tab navigation...")
+ result = await runner.run(task=agent_task)
+
+ # Extract the actual result value from the Run object
+ task_result = str(getattr(result, "value", None) or getattr(result, "result", None) or result)
+
+ logger.info(f"Proxy-lite task completed. Output (truncated for log): {task_result[:500]}...")
+
+ # Structure response for LWC integration
+ response = {
+ "status": "success",
+ "message": "Task completed successfully",
+ "data": {
+ "task_result": task_result,
+ "steps_completed": [
+ "Browser session initialized with cookies",
+ "New tab navigation executed",
+ "Target Salesforce setup page accessed",
+ "Task execution completed successfully"
+ ],
+ "environment": {
+ "target_url": target_url,
+ "cookies_count": 0, # No explicit cookie count for single-browser login
+ "navigation_method": "new_tab_bypass"
+ }
+ },
+ "timestamp": datetime.now().isoformat(),
+ "task_request": request_task_instruction
+ }
+
+ return jsonify(response)
except ValueError as e:
logger.exception(f"Configuration error: {e}")
@@ -318,6 +343,7 @@ def health_check():
# Check environment variables
env_status = {
"GEMINI_API_KEY": "✓" if os.environ.get("GEMINI_API_KEY") else "✗",
+ "HF_API_TOKEN": "✓" if os.environ.get("HF_API_TOKEN") else "✗",
"SALESFORCE_USERNAME": "✓" if os.environ.get("SALESFORCE_USERNAME") else "✗",
"SALESFORCE_PASSWORD": "✓" if os.environ.get("SALESFORCE_PASSWORD") else "✗"
}
@@ -342,9 +368,8 @@ def health_check():
}
return jsonify(health_response)
-
if __name__ == '__main__':
- if not os.environ.get("GEMINI_API_KEY"):
- logger.error("GEMINI_API_KEY environment variable is not set. Please set it for local testing.")
+ if not os.environ.get("GEMINI_API_KEY") and not os.environ.get("HF_API_TOKEN"):
+ logger.error("Neither GEMINI_API_KEY nor HF_API_TOKEN environment variable is set. Please set at least one for local testing.")
logger.info("Starting Flask development server on 0.0.0.0:6101...")
- app.run(host='0.0.0.0', port=6101, debug=True)
\ No newline at end of file
+ app.run(host='0.0.0.0', port=6101, debug=True)
diff --git a/env.example b/env.example
new file mode 100644
index 0000000000000000000000000000000000000000..f190e152bd854f60d4a70517db7a6fe97fbf8958
--- /dev/null
+++ b/env.example
@@ -0,0 +1,17 @@
+# Copy this file to .env and fill in your actual values
+# DO NOT commit the .env file with real values!
+
+# API Token for Hugging Face (for Convergence AI model)
+HF_API_TOKEN=your_huggingface_token_here
+
+# Salesforce credentials for automation
+SALESFORCE_USERNAME=your_salesforce_username@company.com
+SALESFORCE_PASSWORD=your_salesforce_password
+
+# Google Gemini API Key (alternative to HF_API_TOKEN)
+GEMINI_API_KEY=your_gemini_api_key_here
+
+# Usage Instructions:
+# 1. Copy this file: cp env.example .env
+# 2. Replace the placeholder values with your actual credentials
+# 3. The .env file is automatically ignored by git for security
diff --git a/proxy-lite-demo-v2/.gitattributes b/proxy-lite-demo-v2/.gitattributes
deleted file mode 100644
index a6344aac8c09253b3b630fb776ae94478aa0275b..0000000000000000000000000000000000000000
--- a/proxy-lite-demo-v2/.gitattributes
+++ /dev/null
@@ -1,35 +0,0 @@
-*.7z filter=lfs diff=lfs merge=lfs -text
-*.arrow filter=lfs diff=lfs merge=lfs -text
-*.bin filter=lfs diff=lfs merge=lfs -text
-*.bz2 filter=lfs diff=lfs merge=lfs -text
-*.ckpt filter=lfs diff=lfs merge=lfs -text
-*.ftz filter=lfs diff=lfs merge=lfs -text
-*.gz filter=lfs diff=lfs merge=lfs -text
-*.h5 filter=lfs diff=lfs merge=lfs -text
-*.joblib filter=lfs diff=lfs merge=lfs -text
-*.lfs.* filter=lfs diff=lfs merge=lfs -text
-*.mlmodel filter=lfs diff=lfs merge=lfs -text
-*.model filter=lfs diff=lfs merge=lfs -text
-*.msgpack filter=lfs diff=lfs merge=lfs -text
-*.npy filter=lfs diff=lfs merge=lfs -text
-*.npz filter=lfs diff=lfs merge=lfs -text
-*.onnx filter=lfs diff=lfs merge=lfs -text
-*.ot filter=lfs diff=lfs merge=lfs -text
-*.parquet filter=lfs diff=lfs merge=lfs -text
-*.pb filter=lfs diff=lfs merge=lfs -text
-*.pickle filter=lfs diff=lfs merge=lfs -text
-*.pkl filter=lfs diff=lfs merge=lfs -text
-*.pt filter=lfs diff=lfs merge=lfs -text
-*.pth filter=lfs diff=lfs merge=lfs -text
-*.rar filter=lfs diff=lfs merge=lfs -text
-*.safetensors filter=lfs diff=lfs merge=lfs -text
-saved_model/**/* filter=lfs diff=lfs merge=lfs -text
-*.tar.* filter=lfs diff=lfs merge=lfs -text
-*.tar filter=lfs diff=lfs merge=lfs -text
-*.tflite filter=lfs diff=lfs merge=lfs -text
-*.tgz filter=lfs diff=lfs merge=lfs -text
-*.wasm filter=lfs diff=lfs merge=lfs -text
-*.xz filter=lfs diff=lfs merge=lfs -text
-*.zip filter=lfs diff=lfs merge=lfs -text
-*.zst filter=lfs diff=lfs merge=lfs -text
-*tfevents* filter=lfs diff=lfs merge=lfs -text
diff --git a/proxy-lite-demo-v2/.gitignore b/proxy-lite-demo-v2/.gitignore
deleted file mode 100644
index fa40ca0b0c1d2d315a3000c99ad5a07a6e54d020..0000000000000000000000000000000000000000
--- a/proxy-lite-demo-v2/.gitignore
+++ /dev/null
@@ -1,177 +0,0 @@
-# Byte-compiled / optimized / DLL files
-__pycache__/
-*.py[cod]
-*$py.class
-
-# C extensions
-*.so
-
-# Distribution / packaging
-.Python
-build/
-develop-eggs/
-dist/
-downloads/
-eggs/
-.eggs/
-lib/
-lib64/
-parts/
-sdist/
-var/
-wheels/
-share/python-wheels/
-*.egg-info/
-.installed.cfg
-*.egg
-MANIFEST
-
-# PyInstaller
-# Usually these files are written by a python script from a template
-# before PyInstaller builds the exe, so as to inject date/other infos into it.
-*.manifest
-*.spec
-
-# Installer logs
-pip-log.txt
-pip-delete-this-directory.txt
-
-# Unit test / coverage reports
-htmlcov/
-.tox/
-.nox/
-.coverage
-.coverage.*
-.cache
-nosetests.xml
-coverage.xml
-*.cover
-*.py,cover
-.hypothesis/
-.pytest_cache/
-cover/
-
-# Translations
-*.mo
-*.pot
-
-# Django stuff:
-*.log
-local_settings.py
-db.sqlite3
-db.sqlite3-journal
-
-# Flask stuff:
-instance/
-.webassets-cache
-
-# Scrapy stuff:
-.scrapy
-
-# Sphinx documentation
-docs/_build/
-
-# PyBuilder
-.pybuilder/
-target/
-
-# Jupyter Notebook
-.ipynb_checkpoints
-
-# IPython
-profile_default/
-ipython_config.py
-
-# pyenv
-# For a library or package, you might want to ignore these files since the code is
-# intended to run in multiple environments; otherwise, check them in:
-# .python-version
-
-# pipenv
-# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
-# However, in case of collaboration, if having platform-specific dependencies or dependencies
-# having no cross-platform support, pipenv may install dependencies that don't work, or not
-# install all needed dependencies.
-#Pipfile.lock
-
-# UV
-# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
-# This is especially recommended for binary packages to ensure reproducibility, and is more
-# commonly ignored for libraries.
-#uv.lock
-
-# poetry
-# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
-# This is especially recommended for binary packages to ensure reproducibility, and is more
-# commonly ignored for libraries.
-# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
-#poetry.lock
-
-# pdm
-# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
-#pdm.lock
-# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
-# in version control.
-# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
-.pdm.toml
-.pdm-python
-.pdm-build/
-
-# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
-__pypackages__/
-
-# Celery stuff
-celerybeat-schedule
-celerybeat.pid
-
-# SageMath parsed files
-*.sage.py
-
-# Environments
-.env
-.venv
-env/
-venv/
-ENV/
-env.bak/
-venv.bak/
-
-# Spyder project settings
-.spyderproject
-.spyproject
-
-# Rope project settings
-.ropeproject
-
-# mkdocs documentation
-/site
-
-# mypy
-.mypy_cache/
-.dmypy.json
-dmypy.json
-
-# Pyre type checker
-.pyre/
-
-# pytype static type analyzer
-.pytype/
-
-# Cython debug symbols
-cython_debug/
-
-# PyCharm
-# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
-# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
-# and can be added to the global gitignore or merged into this file. For a more nuclear
-# option (not recommended) you can uncomment the following to ignore the entire idea folder.
-#.idea/
-
-# PyPI configuration file
-.pypirc
-
-logs/
-local_trajectories/
-screenshots/
-gifs/
-.DS_Store
diff --git a/proxy-lite-demo-v2/.idea/.gitignore b/proxy-lite-demo-v2/.idea/.gitignore
deleted file mode 100644
index 01700225ee5014fa8c9f414d40d7d2158510aab7..0000000000000000000000000000000000000000
--- a/proxy-lite-demo-v2/.idea/.gitignore
+++ /dev/null
@@ -1,14 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Environment-dependent path to Maven home directory
-/mavenHomeManager.xml
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
-# Core Dev Booster ignored files
-/compile.flag
-/coreModuleDependants.csv
-/.mavenCleaned
diff --git a/proxy-lite-demo-v2/src/proxy_lite/agents/agent_base.py b/proxy-lite-demo-v2/src/proxy_lite/agents/agent_base.py
index b66a8782f771b51f92e9e496bf6c70d3fa9ed338..7d6ac60272493626d2f4d471f91d9e0b00918a6c 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/agents/agent_base.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/agents/agent_base.py
@@ -96,7 +96,11 @@ class BaseAgent(BaseModel, ABC):
use_tool: bool = False,
response_format: Optional[type[BaseModel]] = None,
append_assistant_message: bool = True,
+ label: Optional[MessageLabel] = None,
) -> AssistantMessage:
+ if self.client is None:
+ raise RuntimeError("Client not initialized")
+
messages: MessageHistory = await self.get_history_view()
response_content = (
await self.client.create_completion(
@@ -109,45 +113,44 @@ class BaseAgent(BaseModel, ABC):
).model_dump()
response_content = response_content["choices"][0]["message"]
assistant_message = AssistantMessage(
- role=response_content["role"],
content=[Text(text=response_content["content"])] if response_content["content"] else [],
- tool_calls=response_content["tool_calls"],
+ tool_calls=response_content["tool_calls"] or [],
)
if append_assistant_message:
- self.history.append(message=assistant_message, label=self.message_label)
+ self.history.append(message=assistant_message, label=label)
return assistant_message
def receive_user_message(
self,
text: Optional[str] = None,
- image: list[bytes] = None,
- label: MessageLabel = None,
+ image: Optional[list[bytes]] = None,
+ label: Optional[MessageLabel] = None,
is_base64: bool = False,
) -> None:
message = UserMessage.from_media(
text=text,
- image=image,
+ image=image[0] if image else None,
is_base64=is_base64,
)
- self.history.append(message=message, label=label)
+ self.history.append(message=cast(UserMessage, message), label=label)
def receive_system_message(
self,
text: Optional[str] = None,
- label: MessageLabel = None,
+ label: Optional[MessageLabel] = None,
) -> None:
message = SystemMessage.from_media(text=text)
- self.history.append(message=message, label=label)
+ self.history.append(message=cast(SystemMessage, message), label=label)
def receive_assistant_message(
self,
content: Optional[str] = None,
tool_calls: Optional[list[ToolCall]] = None,
- label: MessageLabel = None,
+ label: Optional[MessageLabel] = None,
) -> None:
message = AssistantMessage(
content=[Text(text=content)] if content else [],
- tool_calls=tool_calls,
+ tool_calls=tool_calls or [],
)
self.history.append(message=message, label=label)
@@ -165,7 +168,7 @@ class BaseAgent(BaseModel, ABC):
self,
text: str,
tool_id: str,
- label: MessageLabel = None,
+ label: Optional[MessageLabel] = None,
) -> None:
self.history.append(
message=ToolMessage(content=[Text(text=text)], tool_call_id=tool_id),
diff --git a/proxy-lite-demo-v2/src/proxy_lite/app.py b/proxy-lite-demo-v2/src/proxy_lite/app.py
index cec8c5b4185efc26a41c85685b9d68785a083fe4..1489a1208a1b40dfe9f410646bfb4f82cf5aba60 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/app.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/app.py
@@ -115,12 +115,12 @@ async def run_task_async(
config: dict,
):
try:
- config = RunnerConfig.from_dict(config)
+ runner_config = RunnerConfig.from_dict(config)
except Exception as e:
st.error(f"Error loading RunnerConfig: {e!s}")
return
- print(config)
- runner = Runner(config=config)
+ print(runner_config)
+ runner = Runner(config=runner_config)
# Add the spinning animation using HTML
status_placeholder.markdown(
@@ -150,13 +150,14 @@ async def run_task_async(
async for run in runner.run_generator(task):
# Update status with latest step
if run.actions:
- latest_step = run.actions[-1].text
- latest_step += "".join(
- [
- f'{{"name": {tool_call.function["name"]}, "arguments": {tool_call.function["arguments"]}}}' # noqa: E501
- for tool_call in run.actions[-1].tool_calls
- ]
- )
+ latest_step = run.actions[-1].text or ""
+ if run.actions[-1].tool_calls:
+ latest_step += "".join(
+ [
+ f'{{"name": {tool_call.function["name"]}, "arguments": {tool_call.function["arguments"]}}}' # noqa: E501
+ for tool_call in run.actions[-1].tool_calls
+ ]
+ )
action_placeholder.write(f"⚡ **Latest Step:** {latest_step}")
all_steps.append(latest_step)
diff --git a/proxy-lite-demo-v2/src/proxy_lite/browser/__init__.py b/proxy-lite-demo-v2/src/proxy_lite/browser/__init__.py
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d0ef4c2594b8df549dac414b4a49fc34f4b1694b 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/browser/__init__.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/browser/__init__.py
@@ -0,0 +1,5 @@
+from .browser import BrowserSession
+from .bounding_boxes import BoundingBox, POI, Point
+
+__all__ = ["BrowserSession", "BoundingBox", "POI", "Point"]
+
diff --git a/proxy-lite-demo-v2/src/proxy_lite/browser/bounding_boxes.py b/proxy-lite-demo-v2/src/proxy_lite/browser/bounding_boxes.py
index 31ee9e36fe6bb1cb0665f597951d4087d363cb8c..5cc763939f0a41f238c02cb95e0b74026a0c9bba 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/browser/bounding_boxes.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/browser/bounding_boxes.py
@@ -114,12 +114,12 @@ def draw_dashed_rectangle(
# Draw all lines at once
if all_points:
- all_points = np.array(all_points).reshape((-1, 2, 2))
- cv2.polylines(img, all_points, False, color, thickness)
+ all_points = np.array(all_points, dtype=np.int32).reshape((-1, 2, 2))
+ cv2.polylines(img, [all_points[i] for i in range(len(all_points))], False, color, thickness)
# @time_it(name='Annotate bounding box')
-def annotate_bounding_box(image: bytes, bbox: BoundingBox) -> None:
+def annotate_bounding_box(image: np.ndarray, bbox: BoundingBox) -> None:
# Draw dashed bounding box
draw_dashed_rectangle(
image,
@@ -194,6 +194,8 @@ def annotate_bounding_boxes(image: bytes, bounding_boxes: list[BoundingBox]) ->
nparr = np.frombuffer(image, np.uint8)
# Decode the image
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
+ if img is None:
+ raise ValueError("Failed to decode image")
padded_img = cv2.copyMakeBorder(
img,
top=25, # Value chosen based on label size
diff --git a/proxy-lite-demo-v2/src/proxy_lite/browser/browser.py b/proxy-lite-demo-v2/src/proxy_lite/browser/browser.py
index 455f65d0029f579bdf96e9193f5309ac6670fe08..c9b3c3737f8afb4b53d4c6a9a7a5f8cd7e86cf67 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/browser/browser.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/browser/browser.py
@@ -15,7 +15,6 @@ from tenacity import before_sleep_log, retry, stop_after_delay, wait_exponential
from proxy_lite.browser.bounding_boxes import POI, BoundingBox, Point, annotate_bounding_boxes
from proxy_lite.logger import logger
-import base64
SELF_CONTAINED_TAGS = [
# many of these are non-interactive but keeping them anyway
@@ -58,7 +57,7 @@ def element_as_text(
attributes.append(f'{k}="{v}"')
attributes = " ".join(attributes)
attributes = (" " + attributes).rstrip()
- tag = tag.lower()
+ tag = tag.lower() if tag else ""
if text is None:
text = ""
if len(text) > 2500:
@@ -111,8 +110,11 @@ class BrowserSession:
await self.context.new_page()
self.context.set_default_timeout(60_000)
- self.current_page.set_default_timeout(60_000)
- await stealth_async(self.current_page, StealthConfig(navigator_user_agent=False))
+ if self.current_page:
+ self.current_page.set_default_timeout(60_000)
+ await stealth_async(self.current_page, StealthConfig(navigator_user_agent=False))
+ else:
+ raise RuntimeError("No page available after browser initialization")
await self.context.add_init_script(
path=Path(__file__).with_name("add_custom_select.js"),
)
@@ -186,6 +188,9 @@ class BrowserSession:
before_sleep=before_sleep_log(logger, logging.ERROR),
)
async def update_poi(self) -> None:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for POI update")
+
try:
# Wait for basic page load states to ensure the DOM is ready.
# This is a fundamental wait that should always apply.
@@ -251,8 +256,10 @@ class BrowserSession:
logger.info(f"INFO: Detected intermediate Salesforce Lightning app loading page: {current_url}. Waiting for network idle and app spinner.")
# This is the /one/one.app page or similar. Don't wait for specific content, just general load.
try:
- await self.current_page.wait_for_load_state("networkidle", timeout=30000) # Give it more time for network to settle
- logger.debug(f"DEBUG: Network idle detected on intermediate app page: {current_url}.")
+ # Give it more time for network to settle
+ await self.current_page.wait_for_load_state("networkidle", timeout=30000)
+ logger.debug(
+ f"DEBUG: Network idle detected on intermediate app page: {current_url}.")
except PlaywrightTimeoutError:
logger.warning(f"DEBUGGING: Network idle timeout on intermediate app page: {current_url}. Proceeding anyway.")
@@ -350,9 +357,12 @@ class BrowserSession:
self,
delay: float = 0.0,
quality: int = 70,
- type: str = "jpeg",
- scale: str = "css",
+ type: Literal["jpeg", "png"] = "jpeg",
+ scale: Literal["css", "device"] = "css",
) -> tuple[bytes, bytes]:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for screenshot")
+
if delay > 0.0:
await asyncio.sleep(delay)
await self.update_poi()
@@ -365,22 +375,32 @@ class BrowserSession:
return img, annotated_img
async def goto(self, url: str) -> None:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for goto")
await self.current_page.goto(url, wait_until="domcontentloaded")
async def reload(self) -> None:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for reload")
await self.current_page.reload(wait_until="domcontentloaded")
async def click_tab(self, mark_id: int) -> None:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for click_tab")
point: Point = self.poi_centroids[mark_id]
await self.hover(point)
await self.current_page.mouse.click(*point, button="middle")
async def click(self, mark_id: int) -> None:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for click")
point: Point = self.poi_centroids[mark_id]
await self.hover(point)
await self.current_page.mouse.click(*point)
async def enter_text(self, mark_id: int, text: str, submit: bool = False) -> None:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for enter_text")
await self.clear_text_field(mark_id)
await self.click(mark_id)
await self.current_page.keyboard.type(text)
@@ -393,6 +413,9 @@ class BrowserSession:
direction: Literal["up", "down", "left", "right"],
mark_id: Optional[int] = None,
) -> None:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for scroll")
+
if mark_id is None:
point = Point(x=-1, y=-1)
max_scroll_x = self.viewport_width
@@ -418,6 +441,9 @@ class BrowserSession:
if not self.current_page:
return
+ if self.context is None:
+ raise RuntimeError("No browser context available for go_back")
+
await self.current_page.go_back(wait_until="domcontentloaded")
if self.current_page.url == "about:blank":
if not len(self.context.pages) > 1:
@@ -426,9 +452,13 @@ class BrowserSession:
await self.current_page.close()
async def hover(self, point: Point) -> None:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for hover")
await self.current_page.mouse.move(*point)
async def focus(self, point: Point) -> None:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for focus")
# Focus on the element on the page at point (x, y)
await self.current_page.evaluate(
"""
@@ -442,6 +472,8 @@ class BrowserSession:
)
async def get_text(self, mark_id: int) -> str:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for get_text")
return await self.current_page.evaluate(
"""
(mark_id) => {
@@ -456,6 +488,9 @@ class BrowserSession:
)
async def clear_text_field(self, mark_id: int) -> None:
+ if self.current_page is None:
+ raise RuntimeError("No current page available for clear_text_field")
+
existing_text = await self.get_text(mark_id)
if existing_text.strip():
# Clear existing text only if it exists
@@ -474,6 +509,9 @@ class BrowserSession:
Opens a new browser tab/page and navigates to the specified URL.
Closes the old page if it's not the last one remaining.
"""
+ if self.context is None:
+ raise RuntimeError("No browser context available for open_new_tab_and_go_to")
+
logger.info(f"Attempting to open a new tab and navigate to: {url}")
new_page = await self.context.new_page()
@@ -496,6 +534,8 @@ if __name__ == "__main__":
async def dummy_test():
async with BrowserSession(headless=False) as s:
+ if s.context is None:
+ raise RuntimeError("No browser context available in dummy_test")
page = await s.context.new_page()
await page.goto("http://google.co.uk")
await asyncio.sleep(5)
diff --git a/proxy-lite-demo-v2/src/proxy_lite/cli.py b/proxy-lite-demo-v2/src/proxy_lite/cli.py
index 22af28e927bf4ae5e4359babc87f4e5d295ffa8a..1d2f28b730d771d820e353a920b93a6002fdab64 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/cli.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/cli.py
@@ -14,10 +14,12 @@ def update_config_from_env(config: RunnerConfig) -> RunnerConfig:
config.solver.agent.client.api_base = os.getenv("PROXY_LITE_API_BASE")
if os.getenv("PROXY_LITE_MODEL"):
config.solver.agent.client.model_id = os.getenv("PROXY_LITE_MODEL")
- if os.getenv("PROXY_LITE_VIEWPORT_WIDTH"):
- config.environment.viewport_width = int(os.getenv("PROXY_LITE_VIEWPORT_WIDTH"))
- if os.getenv("PROXY_LITE_VIEWPORT_HEIGHT"):
- config.environment.viewport_height = int(os.getenv("PROXY_LITE_VIEWPORT_HEIGHT"))
+ viewport_width = os.getenv("PROXY_LITE_VIEWPORT_WIDTH")
+ if viewport_width:
+ config.environment.viewport_width = int(viewport_width)
+ viewport_height = os.getenv("PROXY_LITE_VIEWPORT_HEIGHT")
+ if viewport_height:
+ config.environment.viewport_height = int(viewport_height)
return config
@@ -42,18 +44,20 @@ def do_command(args):
o = Runner(config=config)
result = asyncio.run(o.run(do_text))
- final_screenshot = result.observations[-1].info["original_image"]
- folder_path = Path(__file__).parent.parent.parent / "screenshots"
- folder_path.mkdir(parents=True, exist_ok=True)
- path = folder_path / f"{result.run_id}.png"
- with open(path, "wb") as f:
- f.write(base64.b64decode(final_screenshot))
- logger.info(f"🤖 Final screenshot saved to {path}")
+ # Check if we have observations and info data
+ if result.observations and result.observations[-1].info:
+ final_screenshot = result.observations[-1].info["original_image"]
+ folder_path = Path(__file__).parent.parent.parent / "screenshots"
+ folder_path.mkdir(parents=True, exist_ok=True)
+ path = folder_path / f"{result.run_id}.png"
+ with open(path, "wb") as f:
+ f.write(base64.b64decode(final_screenshot))
+ logger.info(f"🤖 Final screenshot saved to {path}")
gif_folder_path = Path(__file__).parent.parent.parent / "gifs"
gif_folder_path.mkdir(parents=True, exist_ok=True)
gif_path = gif_folder_path / f"{result.run_id}.gif"
- create_run_gif(result, gif_path, duration=1500)
+ create_run_gif(result, str(gif_path), duration=1500)
logger.info(f"🤖 GIF saved to {gif_path}")
diff --git a/proxy-lite-demo-v2/src/proxy_lite/client.py b/proxy-lite-demo-v2/src/proxy_lite/client.py
index a8a1b34c8fee79b8770c812db90489344ede2c67..f2f28c4e486e3e5d25fa77a6ff45c700fe39af92 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/client.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/client.py
@@ -38,7 +38,6 @@ class BaseClient(BaseModel, ABC):
tools: Optional[list[Tool]] = None,
response_format: Optional[type[BaseModel]] = None,
) -> ChatCompletion: ...
-
"""
Create completion from model.
Expect subclasses to adapt from various endpoints that will handle
@@ -56,10 +55,12 @@ class BaseClient(BaseModel, ABC):
"convergence": ConvergenceClient,
"gemini": GeminiClient,
}
- if config.name not in supported_clients:
- error_message = f"Unsupported model: {config.name}."
+ # Type assertion - we know the config will have a name attribute from subclasses
+ config_name = getattr(config, 'name', None)
+ if config_name not in supported_clients:
+ error_message = f"Unsupported model: {config_name}."
raise ValueError(error_message)
- return supported_clients[config.name](config=config)
+ return supported_clients[config_name](config=config)
@property
def http_client(self) -> httpx.AsyncClient:
@@ -75,7 +76,7 @@ class BaseClient(BaseModel, ABC):
class OpenAIClientConfig(BaseClientConfig):
name: Literal["openai"] = "openai"
model_id: str = "gpt-4o"
- api_key: str = os.environ.get("OPENAI_API_KEY")
+ api_key: str = os.environ.get("OPENAI_API_KEY", "")
api_base: Optional[str] = None
@@ -112,7 +113,8 @@ class OpenAIClient(BaseClient):
"tool_choice": "required" if tools else None,
"response_format": {"type": "json_object"} if response_format else {"type": "text"},
}
- base_params.update({k: v for k, v in optional_params.items() if v is not None})
+ base_params.update(
+ {k: v for k, v in optional_params.items() if v is not None})
return await self.external_client.chat.completions.create(**base_params)
@@ -259,7 +261,7 @@ class GeminiClient(BaseClient):
from openai.types.chat.chat_completion import ChatCompletion, Choice
from openai.types.chat.chat_completion_message import ChatCompletionMessage
from openai.types.completion_usage import CompletionUsage
- from openai.types.chat.chat_completion_message_tool_call import ChatCompletionMessageToolCall
+ from openai.types.chat.chat_completion_message_tool_call import ChatCompletionMessageToolCall, Function
# Convert messages to format expected by Gemini
serialized_messages = self.serializer.serialize_messages(messages)
@@ -365,10 +367,10 @@ class GeminiClient(BaseClient):
tool_call = ChatCompletionMessageToolCall(
id=f"call_{hash(str(func_call))}"[:16],
type="function",
- function={
- "name": func_call["name"],
- "arguments": json.dumps(func_call.get("args", {}))
- }
+ function=Function(
+ name=func_call["name"],
+ arguments=json.dumps(func_call.get("args", {}))
+ )
)
tool_calls.append(tool_call)
diff --git a/proxy-lite-demo-v2/src/proxy_lite/environments/webbrowser.py b/proxy-lite-demo-v2/src/proxy_lite/environments/webbrowser.py
index 69b5df087e9775cb3dfb5a8f8dc12f5edf72fffd..ad840375f42840a18b9fb3a96e26075bf233a274 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/environments/webbrowser.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/environments/webbrowser.py
@@ -32,6 +32,12 @@ class WebBrowserEnvironmentConfig(BaseEnvironmentConfig):
# --- MODIFICATION START ---
# Added to accept initial cookies from the RunnerConfig
initial_cookies: Optional[List[dict]] = None
+ # Added for automatic login functionality
+ perform_login: bool = False
+ salesforce_login_url: Optional[str] = None
+ salesforce_username: Optional[str] = None
+ salesforce_password: Optional[str] = None
+ target_url: Optional[str] = None
# --- MODIFICATION END ---
@@ -46,25 +52,31 @@ class WebBrowserEnvironment(BaseEnvironment):
async def __aenter__(self) -> Self:
# Initialize the BrowserSession
+ # Type cast to access WebBrowserEnvironmentConfig attributes
+ config = self.config # type: WebBrowserEnvironmentConfig
self.browser = self.browser_session(
- viewport_width=self.config.viewport_width,
- viewport_height=self.config.viewport_height,
- headless=self.config.headless,
+ viewport_width=config.viewport_width, # type: ignore
+ viewport_height=config.viewport_height, # type: ignore
+ headless=config.headless, # type: ignore
)
await self.browser.__aenter__()
# Initialize other resources if necessary
# --- MODIFICATION START ---
# Changed to use self.config.initial_cookies
- if self.config.initial_cookies:
- self.logger.info(f"🌐 [bold blue]Adding {len(self.config.initial_cookies)} initial cookies to browser context.[/]")
- await self.browser.context.add_cookies(self.config.initial_cookies)
+ if config.initial_cookies: # type: ignore
+ if self.logger:
+ self.logger.info(f"🌐 [bold blue]Adding {len(config.initial_cookies)} initial cookies to browser context.[/]") # type: ignore
+ if self.browser.context:
+ await self.browser.context.add_cookies(config.initial_cookies) # type: ignore
# --- MODIFICATION END ---
- self.logger.info("🌐 [bold blue]Browser session started.[/]")
+ if self.logger:
+ self.logger.info("🌐 [bold blue]Browser session started.[/]")
return self
async def __aexit__(self, exc_type, exc_value, traceback):
# Clean up the BrowserSession
- await self.browser.__aexit__(exc_type, exc_value, traceback)
+ if self.browser:
+ await self.browser.__aexit__(exc_type, exc_value, traceback)
@property
def info_for_user(self) -> str:
@@ -72,7 +84,9 @@ class WebBrowserEnvironment(BaseEnvironment):
@cached_property
def tools(self) -> list[Tool]:
- return [BrowserTool(session=self.browser)]
+ if self.browser is None:
+ raise RuntimeError("Browser session not initialized")
+ return [BrowserTool(session=self.browser)] # type: ignore
@cached_property
def browser_session(self) -> type[BrowserSession]:
@@ -83,39 +97,118 @@ class WebBrowserEnvironment(BaseEnvironment):
# It was previously hardcoded to return an empty list.
@property
def cookies(self) -> list[dict]:
- return self.config.initial_cookies if self.config.initial_cookies is not None else []
+ config = self.config # type: WebBrowserEnvironmentConfig
+ return config.initial_cookies if config.initial_cookies is not None else [] # type: ignore
# --- MODIFICATION END ---
async def initialise(self) -> Observation:
- self.logger.debug(f"DEBUG: Initialising WebBrowserEnvironment. Homepage: {self.config.homepage}")
- try:
- await self.browser.goto(self.config.homepage)
- self.logger.debug(f"DEBUG: Browser navigated to homepage. Current URL: {self.browser.current_url}")
- except Exception as e:
- self.logger.error(f"ERROR: Failed to navigate to homepage {self.config.homepage}: {e}")
- raise # Re-raise to propagate the error
+ if self.browser is None:
+ raise RuntimeError("Browser session not initialized")
+
+ config = self.config # type: WebBrowserEnvironmentConfig
+
+ if self.logger:
+ self.logger.debug(f"DEBUG: Initialising WebBrowserEnvironment. Homepage: {config.homepage}") # type: ignore
+
+ # Check if automatic login is required
+ if config.perform_login and config.salesforce_login_url and config.salesforce_username and config.salesforce_password: # type: ignore
+ if self.logger:
+ self.logger.info(f"🔑 Performing automatic Salesforce login to {config.salesforce_login_url}") # type: ignore
+
+ try:
+ # Navigate to login page
+ await self.browser.goto(config.salesforce_login_url) # type: ignore
+ if self.logger:
+ self.logger.debug(f"🔑 Navigated to login page: {self.browser.current_url}")
+
+ # Wait for login elements to be available
+ if self.browser.current_page:
+ # Use more robust selectors that match actual Salesforce login page structure
+ # Try primary selectors first, with fallbacks
+ try:
+ await self.browser.current_page.wait_for_selector('#username', timeout=10000)
+ username_selector = '#username'
+ except:
+ # Fallback selectors for username
+ await self.browser.current_page.wait_for_selector('input[name="username"], input[type="email"]', timeout=10000)
+ username_selector = 'input[name="username"], input[type="email"]'
+
+ try:
+ await self.browser.current_page.wait_for_selector('#password', timeout=10000)
+ password_selector = '#password'
+ except:
+ # Fallback selectors for password
+ await self.browser.current_page.wait_for_selector('input[name="password"], input[type="password"]', timeout=10000)
+ password_selector = 'input[name="password"], input[type="password"]'
+
+ # Fill in credentials
+ await self.browser.current_page.fill(username_selector, config.salesforce_username) # type: ignore
+ await self.browser.current_page.fill(password_selector, config.salesforce_password) # type: ignore
+
+ if self.logger:
+ self.logger.debug("🔑 Credentials filled, submitting login form")
+
+ # Submit login form - use more robust selector for login button
+ try:
+ await self.browser.current_page.click('#Login')
+ except:
+ # Fallback selectors for login button
+ await self.browser.current_page.click('input[type="submit"], button[type="submit"], .btn-primary')
+
+ # Wait for login to complete (check for successful redirect)
+ await self.browser.current_page.wait_for_load_state('networkidle', timeout=30000)
+
+ if self.logger:
+ self.logger.info(f"🔑 Login completed successfully. Current URL: {self.browser.current_url}")
+
+ # Navigate to target URL if specified
+ if config.target_url: # type: ignore
+ if self.logger:
+ self.logger.debug(f"🔑 Navigating to target URL: {config.target_url}") # type: ignore
+ await self.browser.goto(config.target_url) # type: ignore
+ if self.browser.current_page:
+ await self.browser.current_page.wait_for_load_state('networkidle', timeout=30000)
+ if self.logger:
+ self.logger.info(f"🔑 Successfully navigated to target URL: {self.browser.current_url}")
+
+ except Exception as e:
+ if self.logger:
+ self.logger.error(f"ERROR: Automatic login failed: {e}")
+ raise # Re-raise to propagate the error
+
+ else:
+ # No automatic login, navigate to homepage normally
+ try:
+ await self.browser.goto(config.homepage) # type: ignore
+ if self.logger:
+ self.logger.debug(f"DEBUG: Browser navigated to homepage. Current URL: {self.browser.current_url}")
+ except Exception as e:
+ if self.logger:
+ self.logger.error(f"ERROR: Failed to navigate to homepage {config.homepage}: {e}") # type: ignore
+ raise # Re-raise to propagate the error
original_img, annotated_img = await self.browser.screenshot(
- delay=self.config.screenshot_delay,
+ delay=config.screenshot_delay, # type: ignore
)
- if self.config.no_pois_in_image:
+ if config.no_pois_in_image: # type: ignore
base64_image = base64.b64encode(original_img).decode("utf-8")
else:
base64_image = base64.b64encode(annotated_img).decode("utf-8")
- html_content = await self.browser.current_page.content() if self.config.include_html else None
+ html_content = await self.browser.current_page.content() if config.include_html else None # type: ignore
- info = {"url": self.browser.current_url}
- if self.config.record_pois:
+ info: dict[str, Any] = {"url": self.browser.current_url}
+ if config.record_pois: # type: ignore
info["pois"] = self.browser.pois
- if self.config.keep_original_image:
+ if config.keep_original_image: # type: ignore
info["original_image"] = base64.b64encode(original_img).decode("utf-8")
- self.logger.debug(f"DEBUG: Initial observation captured. URL: {self.browser.current_url}")
+ if self.logger:
+ self.logger.debug(f"DEBUG: Initial observation captured. URL: {self.browser.current_url}")
return Observation(
state=State(
text=f"URL: {self.browser.current_url}"
- + (f"\n{self.browser.poi_text}" if self.config.include_poi_text else ""),
+ + (f"\n{self.browser.poi_text}" if config.include_poi_text else ""), # type: ignore
image=base64_image,
html=html_content,
),
@@ -131,6 +224,9 @@ class WebBrowserEnvironment(BaseEnvironment):
return True
# check for page changes
+ if self.browser is None:
+ return False
+
old_points = [tuple(point) for point in self.browser.poi_centroids]
await self.browser.update_poi()
new_points = [tuple(point) for point in self.browser.poi_centroids]
@@ -143,48 +239,59 @@ class WebBrowserEnvironment(BaseEnvironment):
return True
async def execute_action(self, action: Action) -> Observation:
+ if self.browser is None:
+ raise RuntimeError("Browser session not initialized")
+
+ config = self.config # type: WebBrowserEnvironmentConfig
responses = []
cancelled_tools_flag = False
+
if await self.should_perform_action():
- for tool_call in action.tool_calls:
+ tool_calls = action.tool_calls or []
+ for tool_call in tool_calls:
# Perform the chosen action
try:
- tool_response: ToolExecutionResponse = await self.execute_tool(
- tool_call,
- )
- tool_response.id = tool_call.id
+ tool_response = await self.execute_tool(tool_call)
+ if tool_response is None:
+ tool_response = ToolExecutionResponse(content="Tool execution returned None", id=tool_call.id)
+ else:
+ tool_response.id = tool_call.id
responses.append(tool_response)
except Exception as e: # noqa: PERF203
- self.logger.warning("🌐 An error occurred taking action: %s", str(e), exc_info=False)
+ if self.logger:
+ self.logger.warning("🌐 An error occurred taking action: %s", str(e), exc_info=False)
tool_response = ToolExecutionResponse(content=str(e), id=tool_call.id)
responses.append(tool_response)
else:
- self.logger.warning("🌐 Page changed since last observation, cancelling action.")
+ if self.logger:
+ self.logger.warning("🌐 Page changed since last observation, cancelling action.")
self.cancelled_last_action = True
- for tool_call in action.tool_calls:
+ tool_calls = action.tool_calls or []
+ for tool_call in tool_calls:
tool_response = ToolExecutionResponse(
content="The page changed before the action could be executed, instead of being ran it was cancelled.", # noqa: E501
id=tool_call.id,
)
responses.append(tool_response)
cancelled_tools_flag = True
+
original_img, annotated_img = await self.browser.screenshot(
- delay=self.config.screenshot_delay,
+ delay=config.screenshot_delay, # type: ignore
)
base64_image = base64.b64encode(annotated_img).decode("utf-8")
- info = {"url": self.browser.current_url, "cancelled_tools": cancelled_tools_flag}
- if self.config.record_pois:
+ info: dict[str, Any] = {"url": self.browser.current_url, "cancelled_tools": cancelled_tools_flag}
+ if config.record_pois: # type: ignore
info["pois"] = self.browser.pois
- if self.config.keep_original_image:
+ if config.keep_original_image: # type: ignore
info["original_image"] = base64.b64encode(original_img).decode("utf-8")
- html_content = await self.browser.current_page.content() if self.config.include_html else None
+ html_content = await self.browser.current_page.content() if config.include_html else None # type: ignore
return Observation(
state=State(
text=f"URL: {self.browser.current_url}"
- + (f"\n{self.browser.poi_text}" if self.config.include_poi_text else ""),
+ + (f"\n{self.browser.poi_text}" if config.include_poi_text else ""), # type: ignore
image=base64_image,
html=html_content,
tool_responses=responses,
@@ -195,7 +302,11 @@ class WebBrowserEnvironment(BaseEnvironment):
)
async def observe(self) -> Observation:
- return await self.browser.observe()
+ if self.browser is None:
+ raise RuntimeError("Browser session not initialized")
+ # Note: observe method may not exist on BrowserSession - implement basic observation
+ # return await self.browser.observe() # type: ignore
+ raise NotImplementedError("Observe method not implemented")
async def evaluate(self, **kwargs: dict[str, Any]) -> dict[str, Any]:
return {}
diff --git a/proxy-lite-demo-v2/src/proxy_lite/gif_maker.py b/proxy-lite-demo-v2/src/proxy_lite/gif_maker.py
index f5dbaa1a9417cff9ee3c42e004e7d36283229d0e..8e598611a8d6801fab01a7a95c8d519b0a961ed1 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/gif_maker.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/gif_maker.py
@@ -33,8 +33,9 @@ def create_run_gif(
history = run.history
i = 0
while i < len(history):
- if isinstance(history[i], Observation):
- observation = history[i]
+ current_record = history[i]
+ if isinstance(current_record, Observation):
+ observation = current_record
image_data = observation.state.image
if not image_data:
i += 1
@@ -48,10 +49,12 @@ def create_run_gif(
# Check if the next record is an Action and extract its text if available
action_text = ""
- if i + 1 < len(history) and isinstance(history[i + 1], Action):
- action = history[i + 1]
- if action.text:
- action_text = action.text
+ if i + 1 < len(history):
+ next_record = history[i + 1]
+ if isinstance(next_record, Action):
+ action = next_record
+ if hasattr(action, 'text') and action.text:
+ action_text = action.text
# extract observation and thinking from tags in the action text
observation_match = re.search(r"(.*?)", action_text, re.DOTALL)
@@ -81,9 +84,17 @@ def create_run_gif(
except AttributeError:
# Fallback for older Pillow versions: compute size for each line
lines = wrapped_text.splitlines() or [wrapped_text]
- line_sizes = [draw.textsize(line, font=font) for line in lines]
- text_width = max(width for width, _ in line_sizes)
- text_height = sum(height for _, height in line_sizes)
+ try:
+ # Try textbbox first (newer method)
+ line_sizes = [draw.textbbox((0, 0), line, font=font) for line in lines]
+ text_width = max(bbox[2] - bbox[0] for bbox in line_sizes)
+ text_height = sum(bbox[3] - bbox[1] for bbox in line_sizes)
+ except AttributeError:
+ # Final fallback: estimate based on font size
+ estimated_char_width = 8 # Rough estimate
+ estimated_line_height = 16 # Rough estimate
+ text_width = max(len(line) * estimated_char_width for line in lines)
+ text_height = len(lines) * estimated_line_height
text_x = (white_panel_width - text_width) // 2
text_y = (obs_img.height - text_height) // 2
draw.multiline_text((text_x, text_y), wrapped_text, fill="black", font=font, align="center")
diff --git a/proxy-lite-demo-v2/src/proxy_lite/history.py b/proxy-lite-demo-v2/src/proxy_lite/history.py
index 13e2d98b27233177e9be17a672037f05382bb03d..b75e45a38c383e7f6fd2d1d6aa5b4d400acdcbff 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/history.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/history.py
@@ -71,15 +71,30 @@ class Message(BaseModel):
image: Optional[bytes | str] = None,
is_base64: bool = False,
) -> Message:
+ content: list[Union[Text, Image]] = []
+
if text is not None:
- text = Text(text=text)
+ text_content = Text(text=text)
+ content.append(text_content)
+
if image is not None:
- base64_image = image if is_base64 else base64.b64encode(image).decode("utf-8")
+ if is_base64:
+ if isinstance(image, str):
+ base64_image = image
+ else:
+ # If image is bytes, convert to base64
+ base64_image = base64.b64encode(image).decode("utf-8")
+ else:
+ if isinstance(image, str):
+ image_bytes = image.encode("utf-8")
+ else:
+ image_bytes = image
+ base64_image = base64.b64encode(image_bytes).decode("utf-8")
+
data_url = f"data:image/jpeg;base64,{base64_image}"
- image = Image(image_url=ImageUrl(url=data_url))
- content = [text, image] if text is not None else [image]
- else:
- content = [text]
+ image_content = Image(image_url=ImageUrl(url=data_url))
+ content.append(image_content)
+
return cls(content=content)
@@ -127,7 +142,12 @@ class MessageHistory(BaseModel):
def append(self, message: MessageTypes, label: Optional[str] = None):
if label is not None:
- message.label = label
+ # Convert string to MessageLabel if it's a valid enum value
+ try:
+ message.label = MessageLabel(label)
+ except ValueError:
+ # If not a valid MessageLabel, keep as None
+ message.label = None
self.messages.append(message)
def pop(self) -> MessageTypes:
@@ -170,7 +190,7 @@ class MessageHistory(BaseModel):
label_counts[message.label] += 1
else:
filtered_messages.append(message)
- return MessageHistory(messages=reversed(filtered_messages))
+ return MessageHistory(messages=list(reversed(filtered_messages)))
def __add__(self, other: MessageHistory) -> MessageHistory:
new_history = MessageHistory()
diff --git a/proxy-lite-demo-v2/src/proxy_lite/logger.py b/proxy-lite-demo-v2/src/proxy_lite/logger.py
index 075768d5e36f6c361e0c5962849ec6c15ea9f53f..370bcdc9520cb9b87e823aeb137d6b0d86ef823f 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/logger.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/logger.py
@@ -22,8 +22,8 @@ class StructuredLogger(logging.Logger):
def _log(
self,
- level,
- msg,
+ level: int,
+ msg: str,
args,
exc_info=None,
extra=None,
@@ -33,9 +33,15 @@ class StructuredLogger(logging.Logger):
if extra is None:
extra = {}
- json_fields = {
+ # Safe string formatting
+ try:
+ formatted_msg = msg % args if args else msg
+ except (TypeError, ValueError):
+ formatted_msg = str(msg)
+
+ json_fields: dict[str, str] = {
"logger_name": self.name,
- "message": msg % args if args else msg,
+ "message": formatted_msg,
}
exc_type, exc_value, exc_traceback = sys.exc_info()
@@ -43,7 +49,10 @@ class StructuredLogger(logging.Logger):
json_fields["exception_class"] = exc_type.__name__
json_fields["exception_message"] = str(exc_value)
- json_fields.update(extra)
+ # Ensure extra is a dict and merge with json_fields
+ if isinstance(extra, dict):
+ for key, value in extra.items():
+ json_fields[key] = str(value)
super()._log(
level,
diff --git a/proxy-lite-demo-v2/src/proxy_lite/recorder.py b/proxy-lite-demo-v2/src/proxy_lite/recorder.py
index 11bb34644b81d53b133be78b56ed92a175927535..03a54d3b2bfc3b864637f5c479a8018f946256dd 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/recorder.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/recorder.py
@@ -40,7 +40,8 @@ class Run(BaseModel):
@classmethod
def load(cls, run_id: str) -> Self:
- with open(Path(__file__).parent.parent.parent / "local_trajectories" / f"{run_id}.json", "r") as f:
+ trajectories_path = Path(__file__).parent.parent.parent / "local_trajectories"
+ with open(trajectories_path / f"{run_id}.json", "r") as f:
return cls(**json.load(f))
@property
@@ -80,8 +81,8 @@ class Run(BaseModel):
class DataRecorder:
- def __init__(self, local_folder: str | None = None):
- self.local_folder = local_folder
+ def __init__(self, local_folder: str | Path | None = None):
+ self.local_folder = Path(local_folder) if local_folder else None
def initialise_run(self, task: str) -> Run:
self.local_folder = Path(__file__).parent.parent.parent / "local_trajectories"
@@ -99,5 +100,7 @@ class DataRecorder:
async def save(self, run: Run) -> None:
json_payload = run.model_dump()
+ if self.local_folder is None:
+ raise ValueError("local_folder is not set. Call initialise_run first.")
with open(self.local_folder / f"{run.run_id}.json", "w") as f:
json.dump(json_payload, f)
diff --git a/proxy-lite-demo-v2/src/proxy_lite/runner.py b/proxy-lite-demo-v2/src/proxy_lite/runner.py
index 3430567c34b29676c670ab9dbe80fa5872ed35db..0bfc19cc10451fe14e7a73bb76a951034be9714c 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/runner.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/runner.py
@@ -65,14 +65,16 @@ class RunnerConfig(BaseModel):
@classmethod
def from_dict(cls, config_dict: dict) -> Self:
conf = OmegaConf.create(config_dict)
- config_dict = OmegaConf.to_container(conf, resolve=True)
- return cls(**config_dict)
+ resolved_config = OmegaConf.to_container(conf, resolve=True)
+ # Type cast to satisfy linter - OmegaConf.to_container with resolve=True returns dict for dict inputs
+ return cls(**dict(resolved_config)) # type: ignore
@classmethod
def from_yaml(cls, yaml_path: str) -> Self:
conf = OmegaConf.load(yaml_path)
- config_dict = OmegaConf.to_container(conf, resolve=True)
- return cls(**config_dict)
+ resolved_config = OmegaConf.to_container(conf, resolve=True)
+ # Type cast to satisfy linter - OmegaConf.to_container with resolve=True returns dict for dict inputs
+ return cls(**dict(resolved_config)) # type: ignore
class Runner(BaseModel):
@@ -98,9 +100,13 @@ class Runner(BaseModel):
)
async def run_generator(self, task: str) -> AsyncIterator[Run]:
- async with (
- async_timeout(self.config.task_timeout, "Task"),
- ):
+ # Assert that attributes are initialized (they are set in model_post_init)
+ assert self.logger is not None, "Logger not initialized"
+ assert self.recorder is not None, "Recorder not initialized"
+ assert self.environment is not None, "Environment not initialized"
+ assert self.solver is not None, "Solver not initialized"
+
+ async with async_timeout(self.config.task_timeout, "Task"):
if self.config.logger_level is not None:
self.logger.setLevel(self.config.logger_level)
run = self.recorder.initialise_run(task)
@@ -122,9 +128,9 @@ class Runner(BaseModel):
environment.info_for_user,
)
self.logger.debug("Solver initialised.")
- run.solver_history = solver.history
- observation: Observation = await environment.initialise()
- await event_queue.put(observation)
+ run.solver_history = solver.history # type: ignore
+ initial_observation: Observation = await environment.initialise()
+ await event_queue.put(initial_observation)
self.logger.debug("Environment initialised.")
step_count = 0
while step_count < self.config.max_steps:
@@ -132,26 +138,26 @@ class Runner(BaseModel):
self.logger.debug(f"🤖 [bold purple]Processing event:[/] {event.type}")
match event.type:
case EventType.OBSERVATION:
- observation: Observation = event
+ current_observation: Observation = event
run.record(
- observation=observation,
- solver_history=solver.history,
+ observation=current_observation,
+ solver_history=solver.history, #type: ignore
)
async with async_timeout(
self.config.action_timeout,
"Action decision",
):
- action: Action = await solver.act(observation)
- await event_queue.put(action)
+ action_result: Action = await solver.act(current_observation)
+ await event_queue.put(action_result)
case EventType.ACTION:
- action: Action = event
- self.logger.debug(f"Tool calls: {action.tool_calls}")
- run.record(action=action, solver_history=solver.history)
- run.complete = await solver.is_complete(observation)
+ current_action: Action = event
+ self.logger.debug(f"Tool calls: {current_action.tool_calls}")
+ run.record(action=current_action, solver_history=solver.history) # type: ignore
+ run.complete = await solver.is_complete(current_observation)
if self.config.save_every_step:
await self.recorder.save(run)
if run.complete:
- run.result = action.text
+ run.result = current_action.text
self.logger.info(f"🤖 [bold purple]Task complete.[/] ✨ \n{run.result}")
break
self.logger.debug(f"DEBUG: Using environment_timeout: {self.config.environment_timeout} seconds")
@@ -159,9 +165,9 @@ class Runner(BaseModel):
self.config.environment_timeout,
"Environment response",
):
- observation: Observation = await environment.execute_action(action)
+ next_observation: Observation = await environment.execute_action(current_action)
step_count += 1
- await event_queue.put(observation)
+ await event_queue.put(next_observation)
yield run
if not run.complete:
self.logger.warning("🤖 [bold purple]Ran out of steps!")
@@ -173,7 +179,7 @@ class Runner(BaseModel):
self._run = run
return run
- def run_concurrent(self, tasks: list[str]) -> list[Run]:
+ def run_concurrent(self, tasks: list[str]) -> list[Run | BaseException]:
async def gather_runs():
return await asyncio.gather(
*[self.run(task) for task in tasks],
@@ -198,7 +204,7 @@ class Runner(BaseModel):
def run_result(self) -> str:
if self._run is None:
raise RuntimeError("Run not initialised")
- return self._run.result
+ return self._run.result or ""
if __name__ == "__main__":
diff --git a/proxy-lite-demo-v2/src/proxy_lite/solvers/simple_solver.py b/proxy-lite-demo-v2/src/proxy_lite/solvers/simple_solver.py
index c1b67f42fb3a5e59c7be9a77f815dc3bdc15109c..da668df111f6928f3dcf5174d32a8445137d6382 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/solvers/simple_solver.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/solvers/simple_solver.py
@@ -27,6 +27,7 @@ class SimpleSolverConfig(BaseSolverConfig):
class SimpleSolver(BaseSolver):
task: Optional[str] = None
complete: bool = False
+ config: SimpleSolverConfig # Proper typing
@cached_property
def tools(self) -> list[Tool]:
@@ -36,15 +37,16 @@ class SimpleSolver(BaseSolver):
def agent(self) -> BaseAgent:
if self.logger:
self.logger.debug(f"Tools: {self.tools}")
- return Agents.get(self.config.agent.name)(
- config=self.config.agent,
+ # Type ignore: config is actually SimpleSolverConfig at runtime
+ return Agents.get(self.config.agent.name)( # type: ignore
+ config=self.config.agent, # type: ignore
env_tools=self.tools,
)
@property
def history(self) -> MessageHistory:
return MessageHistory(
- messages=[SystemMessage.from_media(text=self.agent.system_prompt)] + self.agent.history.messages,
+ messages=[SystemMessage.from_media(text=self.agent.system_prompt)] + self.agent.history.messages, # type: ignore
)
async def initialise(self, task: str, env_tools: list[Tool], env_info: str) -> None:
@@ -54,7 +56,8 @@ class SimpleSolver(BaseSolver):
text=f"Task: {task}",
label=MessageLabel.USER_INPUT,
)
- self.logger.debug(f"Initialised with task: {task}")
+ if self.logger:
+ self.logger.debug(f"Initialised with task: {task}")
async def act(self, observation: Observation) -> Action:
# Send tool responses to agent as tool messages if they exist
@@ -70,8 +73,18 @@ class SimpleSolver(BaseSolver):
else:
print("🔧 DEBUG: No tool responses to process")
+ # Handle image parameter - convert to list of bytes if needed
+ image_data = None
+ if observation.state.image:
+ if isinstance(observation.state.image, str):
+ # If it's a base64 string, convert it to bytes
+ import base64
+ image_data = [base64.b64decode(observation.state.image)]
+ else:
+ image_data = observation.state.image
+
self.agent.receive_user_message(
- image=observation.state.image,
+ image=image_data or [],
text=observation.state.text,
label=MessageLabel.SCREENSHOT,
is_base64=True,
@@ -79,7 +92,8 @@ class SimpleSolver(BaseSolver):
message = await self.agent.generate_output(use_tool=True)
- self.logger.debug(f"Assistant message generated: {message}")
+ if self.logger:
+ self.logger.debug(f"Assistant message generated: {message}")
# check tool calls for return_value
if any(tool_call.function["name"] == "return_value" for tool_call in message.tool_calls):
@@ -92,23 +106,28 @@ class SimpleSolver(BaseSolver):
# Handle empty content array from API response
if not message.content or len(message.content) == 0:
- self.logger.warning("Message content is empty, using empty string as fallback")
+ if self.logger:
+ self.logger.warning("Message content is empty, using empty string as fallback")
text_content = ""
else:
- text_content = message.content[0].text
+ # Handle both text and image content types
+ first_content = message.content[0]
+ text_content = getattr(first_content, 'text', str(first_content))
observation_match = re.search(r"(.*?)", text_content, re.DOTALL)
observation_content = observation_match.group(1).strip() if observation_match else ""
- self.logger.info("🌐 [bold blue]Observation:[/]")
- await self.logger.stream_message(observation_content)
+ if self.logger:
+ self.logger.info("🌐 [bold blue]Observation:[/]")
+ self.logger.info(observation_content)
# Extract text between thinking tags if present
thinking_match = re.search(r"(.*?)", text_content, re.DOTALL)
thinking_content = thinking_match.group(1).strip() if thinking_match else text_content
- self.logger.info("🧠 [bold purple]Thinking:[/]")
- await self.logger.stream_message(thinking_content)
+ if self.logger:
+ self.logger.info("🧠 [bold purple]Thinking:[/]")
+ self.logger.info(thinking_content)
return Action(tool_calls=message.tool_calls, text=text_content)
diff --git a/proxy-lite-demo-v2/src/proxy_lite/tools/browser_tool.py b/proxy-lite-demo-v2/src/proxy_lite/tools/browser_tool.py
index da27f6afe737d186fc2b47acccfee7e005b5606c..c0bee3ccaa27a7052fd88759283bffaf48a71f35 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/tools/browser_tool.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/tools/browser_tool.py
@@ -50,7 +50,7 @@ def element_as_text(
attributes.append(f'{k}="{v}"')
attributes = " ".join(attributes)
attributes = (" " + attributes).rstrip()
- tag = tag.lower()
+ tag = tag.lower() if tag else ""
if text is None:
text = ""
if len(text) > 2500:
@@ -58,8 +58,7 @@ def element_as_text(
if tag in SELF_CONTAINED_TAGS:
if text:
logger.warning(
- f"Got self-contained element '{tag}' which contained text '{text}'.",
- )
+ f"Got self-contained element '{tag}' which contained text '{text}'.", )
else:
return f"<{tag} id={mark_id}{attributes}/>"
return f"<{tag} id={mark_id}{attributes}>{text}{tag}>"
@@ -220,7 +219,7 @@ class BrowserTool(Tool):
)
@attach_param_schema(ScrollParams)
- async def scroll(self, direction: str, mark_id: int) -> ToolExecutionResponse:
+ async def scroll(self, direction: Literal["up", "down", "left", "right"], mark_id: int) -> ToolExecutionResponse:
"""Scroll the page (or a scrollable element) up, down, left or right."""
try:
if mark_id == -1:
@@ -247,7 +246,6 @@ class BrowserTool(Tool):
logger.error(f"Go back failed: {e}")
return ToolExecutionResponse(content=f"Failed to go back: {e}")
-
@attach_param_schema(WaitParams)
async def wait(self) -> ToolExecutionResponse:
"""Wait three seconds. Useful when the page appears to still be loading, or if there are any unfinished webpage processes.""" # noqa: E501
@@ -306,6 +304,9 @@ class BrowserTool(Tool):
# This bypasses CORS restrictions that prevent JavaScript access
# Find all frames on the page
+ if not self.browser.current_page:
+ return ToolExecutionResponse(content=f"No active page found. Cannot select option '{option_text}'.")
+
main_frame = self.browser.current_page.main_frame
all_frames = [main_frame] + main_frame.child_frames
diff --git a/proxy-lite-demo-v2/src/proxy_lite/tools/tool_base.py b/proxy-lite-demo-v2/src/proxy_lite/tools/tool_base.py
index a6c37bd9f6b39306a5e814bd41b33fa42ba3f552..bfeccc4562545a6a83523c561a9c21c4013e6ddb 100644
--- a/proxy-lite-demo-v2/src/proxy_lite/tools/tool_base.py
+++ b/proxy-lite-demo-v2/src/proxy_lite/tools/tool_base.py
@@ -43,7 +43,8 @@ def attach_param_schema(param_model: type[BaseModel]):
validated_params = param_model(**kwargs)
return func(self, **validated_params.model_dump())
- wrapper.param_model = param_model
+ # Use setattr to avoid linter errors about unknown attributes
+ setattr(wrapper, 'param_model', param_model)
return wrapper
return decorator
diff --git a/proxy-lite-demo-v2/test_tool_calling.py b/proxy-lite-demo-v2/test_tool_calling.py
deleted file mode 100644
index 29723d964a5ae3d5f144db02fbc798e82d63baf6..0000000000000000000000000000000000000000
--- a/proxy-lite-demo-v2/test_tool_calling.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env python3
-import asyncio
-import os
-import sys
-sys.path.insert(0, 'src')
-
-from proxy_lite.client import GeminiClient, GeminiClientConfig
-from proxy_lite.history import MessageHistory, UserMessage, Text
-from proxy_lite.tools.browser_tool import BrowserTool
-from proxy_lite.browser.browser import BrowserSession
-
-async def test_tool_calling():
- # Setup client
- api_key = os.environ.get("GEMINI_API_KEY")
- if not api_key:
- print("❌ GEMINI_API_KEY not set")
- return
-
- config = GeminiClientConfig(api_key=api_key)
- client = GeminiClient(config=config)
-
- # Create a dummy browser tool
- class DummyBrowserSession:
- async def __aenter__(self):
- return self
- async def __aexit__(self, *args):
- pass
- async def open_new_tab_and_go_to(self, url):
- print(f"✅ Would open new tab and go to: {url}")
- return True
-
- browser_tool = BrowserTool(DummyBrowserSession())
-
- # Create message history
- messages = MessageHistory()
- messages.append(UserMessage(content=[Text(text="Please use the open_new_tab_and_go_to tool to navigate to https://google.com")]))
-
- print("🚀 Testing Gemini tool calling...")
-
- try:
- # Test tool calling
- response = await client.create_completion(
- messages=messages,
- tools=[browser_tool],
- temperature=0.7
- )
-
- print(f"✅ Response received: {response}")
-
- if response.choices[0].message.tool_calls:
- print(f"✅ Tool calls found: {len(response.choices[0].message.tool_calls)}")
- for tool_call in response.choices[0].message.tool_calls:
- print(f" - Tool: {tool_call.function.name}")
- print(f" - Args: {tool_call.function.arguments}")
- else:
- print("❌ No tool calls found")
- print(f"Content: {response.choices[0].message.content}")
-
- except Exception as e:
- print(f"❌ Error: {e}")
- import traceback
- traceback.print_exc()
-
-if __name__ == "__main__":
- asyncio.run(test_tool_calling())
\ No newline at end of file
diff --git a/proxy-lite-work/.gitignore b/proxy-lite-work/.gitignore
deleted file mode 100644
index f5f33ebd8cc353b189b301ddc03c94fd41cc3640..0000000000000000000000000000000000000000
--- a/proxy-lite-work/.gitignore
+++ /dev/null
@@ -1,45 +0,0 @@
-# This file is used for Git repositories to specify intentionally untracked files that Git should ignore.
-# If you are not using git, you can delete this file. For more information see: https://git-scm.com/docs/gitignore
-# For useful gitignore templates see: https://github.com/github/gitignore
-
-# Salesforce cache
-.sf/
-.sfdx/
-.localdevserver/
-deploy-options.json
-
-# LWC VSCode autocomplete
-**/lwc/jsconfig.json
-
-# LWC Jest coverage reports
-coverage/
-
-# Logs
-logs
-*.log
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-
-# Dependency directories
-node_modules/
-
-# Eslint cache
-.eslintcache
-
-# MacOS system files
-.DS_Store
-
-# Windows system files
-Thumbs.db
-ehthumbs.db
-[Dd]esktop.ini
-$RECYCLE.BIN/
-
-# Local environment variables
-.env
-
-# Python Salesforce Functions
-**/__pycache__/
-**/.venv/
-**/venv/
diff --git a/proxy-lite-work/.sf/orgs/00DWd000006jIa1MAE/localSourceTracking/HEAD b/proxy-lite-work/.sf/orgs/00DWd000006jIa1MAE/localSourceTracking/HEAD
new file mode 100644
index 0000000000000000000000000000000000000000..b870d82622c1a9ca6bcaf5df639680424a1904b0
--- /dev/null
+++ b/proxy-lite-work/.sf/orgs/00DWd000006jIa1MAE/localSourceTracking/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/main
diff --git a/proxy-lite-work/.sf/orgs/00DWd000006jIa1MAE/localSourceTracking/config b/proxy-lite-work/.sf/orgs/00DWd000006jIa1MAE/localSourceTracking/config
new file mode 100644
index 0000000000000000000000000000000000000000..d545cdabdbddafca3501d2114506fc86e50e9824
--- /dev/null
+++ b/proxy-lite-work/.sf/orgs/00DWd000006jIa1MAE/localSourceTracking/config
@@ -0,0 +1,7 @@
+[core]
+ repositoryformatversion = 0
+ filemode = false
+ bare = false
+ logallrefupdates = true
+ symlinks = false
+ ignorecase = true
diff --git a/proxy-lite-work/.sfdx/indexes/lwc/custom-components.json b/proxy-lite-work/.sfdx/indexes/lwc/custom-components.json
new file mode 100644
index 0000000000000000000000000000000000000000..0637a088a01e8ddab3bf3fa98dbe804cbde1a0dc
--- /dev/null
+++ b/proxy-lite-work/.sfdx/indexes/lwc/custom-components.json
@@ -0,0 +1 @@
+[]
\ No newline at end of file
diff --git a/proxy-lite-work/.sfdx/sfdx-config.json b/proxy-lite-work/.sfdx/sfdx-config.json
new file mode 100644
index 0000000000000000000000000000000000000000..2b72b019a9251871116a6ab077c9632886f8a6f5
--- /dev/null
+++ b/proxy-lite-work/.sfdx/sfdx-config.json
@@ -0,0 +1,3 @@
+{
+ "defaultusername": "vscodeOrg"
+}
\ No newline at end of file
diff --git a/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Account.cls b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Account.cls
new file mode 100644
index 0000000000000000000000000000000000000000..8b0e3e474ecf00652aff54dd016cec639622ab03
--- /dev/null
+++ b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Account.cls
@@ -0,0 +1,196 @@
+// This file is generated as an Apex representation of the
+// corresponding sObject and its fields.
+// This read-only file is used by the Apex Language Server to
+// provide code smartness, and is deleted each time you
+// refresh your sObject definitions.
+// To edit your sObjects and their fields, edit the corresponding
+// .object-meta.xml and .field-meta.xml files.
+
+global class Account {
+ global Id Id;
+ global Boolean IsDeleted;
+ global Account MasterRecord;
+ global Id MasterRecordId;
+ global String Name;
+ global String Type;
+ global Account Parent;
+ global Id ParentId;
+ global String BillingStreet;
+ global String BillingCity;
+ global String BillingState;
+ global String BillingPostalCode;
+ global String BillingCountry;
+ global Double BillingLatitude;
+ global Double BillingLongitude;
+ global String BillingGeocodeAccuracy;
+ global Address BillingAddress;
+ global String ShippingStreet;
+ global String ShippingCity;
+ global String ShippingState;
+ global String ShippingPostalCode;
+ global String ShippingCountry;
+ global Double ShippingLatitude;
+ global Double ShippingLongitude;
+ global String ShippingGeocodeAccuracy;
+ global Address ShippingAddress;
+ global String Phone;
+ global String Fax;
+ global String AccountNumber;
+ global String Website;
+ global String PhotoUrl;
+ global String Sic;
+ global String Industry;
+ global Decimal AnnualRevenue;
+ global Integer NumberOfEmployees;
+ global String Ownership;
+ global String TickerSymbol;
+ global String Description;
+ global String Rating;
+ global String Site;
+ global User Owner;
+ global Id OwnerId;
+ global Datetime CreatedDate;
+ global User CreatedBy;
+ global Id CreatedById;
+ global Datetime LastModifiedDate;
+ global User LastModifiedBy;
+ global Id LastModifiedById;
+ global Datetime SystemModstamp;
+ global Date LastActivityDate;
+ global Datetime LastViewedDate;
+ global Datetime LastReferencedDate;
+ global String Jigsaw;
+ global String JigsawCompanyId;
+ global String CleanStatus;
+ global String AccountSource;
+ global String DunsNumber;
+ global String Tradestyle;
+ global String NaicsCode;
+ global String NaicsDesc;
+ global String YearStarted;
+ global String SicDesc;
+ global DandBCompany DandbCompany;
+ global Id DandbCompanyId;
+ global OperatingHours OperatingHours;
+ global Id OperatingHoursId;
+ global List ChildAccounts;
+ global List AccountCleanInfos;
+ global List AccountContactRoles;
+ global List Feeds;
+ global List Histories;
+ global List AccountPartnersFrom;
+ global List AccountPartnersTo;
+ global List Shares;
+ global List ActivityHistories;
+ global List AlternativePaymentMethods;
+ global List Assets;
+ global List ProvidedAssets;
+ global List ServicedAssets;
+ global List AssociatedLocations;
+ global List AttachedContentDocuments;
+ global List Attachments;
+ global List AuthorizationFormConsents;
+ global List RelatedAuthorizationFormConsents;
+ global List CardPaymentMethods;
+ global List Cases;
+ global List RecordAssociatedGroups;
+ global List CombinedAttachments;
+ global List CommSubscriptionConsents;
+ global List Contacts;
+ global List ContactPointAddresses;
+ global List ContactPointEmails;
+ global List ContactPointPhones;
+ global List ContactRequests;
+ global List ContentDocumentLinks;
+ global List Contracts;
+ global List CreditMemos;
+ global List DigitalWallets;
+ global List DuplicateRecordItems;
+ global List Emails;
+ global List Entitlements;
+ global List FeedSubscriptionsForEntity;
+ global List Events;
+ global List Expenses;
+ global List FinanceBalanceSnapshots;
+ global List FinanceTransactions;
+ global List Invoices;
+ global List MaintenancePlans;
+ global List MessagingEndUsers;
+ global List MessagingSessions;
+ global List Notes;
+ global List NotesAndAttachments;
+ global List OpenActivities;
+ global List Opportunities;
+ global List OpportunityPartnersTo;
+ global List Orders;
+ global List PartnersFrom;
+ global List PartnersTo;
+ global List Payments;
+ global List PaymentAuthAdjustments;
+ global List PaymentAuthorizations;
+ global List PaymentLinesInvoice;
+ global List ProcessInstances;
+ global List ProcessSteps;
+ global List ProductRequests;
+ global List ProductRequestLineItems;
+ global List RecordActions;
+ global List RecordActionHistories;
+ global List Refunds;
+ global List RefundLinePayments;
+ global List ResourcePreferences;
+ global List ReturnOrders;
+ global List ScorecardAssociations;
+ global List ServiceAppointmentAccount;
+ global List ServiceAppointments;
+ global List ServiceContracts;
+ global List ServiceResources;
+ global List Swarms;
+ global List SwarmMembers;
+ global List Tasks;
+ global List TopicAssignments;
+ global List Users;
+ global List WorkOrders;
+ global List WorkPlanSelectionRules;
+ global List SobjectLookupValue;
+ global List Target;
+ global List Parent;
+ global List Account;
+ global List AssetProvidedBy;
+ global List AssetServicedBy;
+ global List ConsentGiver;
+ global List RelatedRecord;
+ global List LeadOrContact;
+ global List Account;
+ global List ConsentGiver;
+ global List Account;
+ global List Parent;
+ global List RelatedRecord;
+ global List LinkedEntity;
+ global List FirstPublishLocation;
+ global List Account;
+ global List RelatedTo;
+ global List Account;
+ global List What;
+ global List Relation;
+ global List Account;
+ global List Parent;
+ global List Account;
+ global List ContextRecord;
+ global List RelatedRecord;
+ global List ConvertedAccount;
+ global List Account;
+ global List RelatedTo;
+ global List Account;
+ global List RelatedRecord;
+ global List Account;
+ global List ParentRecord;
+ global List Account;
+ global List What;
+ global List Account;
+ global List PortalAccount;
+ global List Account;
+
+ global Account ()
+ {
+ }
+}
\ No newline at end of file
diff --git a/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/AccountHistory.cls b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/AccountHistory.cls
new file mode 100644
index 0000000000000000000000000000000000000000..c5539edfd4c0e24d9c612ab7f070557fbeb12e2a
--- /dev/null
+++ b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/AccountHistory.cls
@@ -0,0 +1,25 @@
+// This file is generated as an Apex representation of the
+// corresponding sObject and its fields.
+// This read-only file is used by the Apex Language Server to
+// provide code smartness, and is deleted each time you
+// refresh your sObject definitions.
+// To edit your sObjects and their fields, edit the corresponding
+// .object-meta.xml and .field-meta.xml files.
+
+global class AccountHistory {
+ global Id Id;
+ global Boolean IsDeleted;
+ global Account Account;
+ global Id AccountId;
+ global User CreatedBy;
+ global Id CreatedById;
+ global Datetime CreatedDate;
+ global String Field;
+ global String DataType;
+ global Object OldValue;
+ global Object NewValue;
+
+ global AccountHistory ()
+ {
+ }
+}
\ No newline at end of file
diff --git a/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Asset.cls b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Asset.cls
new file mode 100644
index 0000000000000000000000000000000000000000..4942adc390141f6983ff44cff3fd6a28ba43345c
--- /dev/null
+++ b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Asset.cls
@@ -0,0 +1,138 @@
+// This file is generated as an Apex representation of the
+// corresponding sObject and its fields.
+// This read-only file is used by the Apex Language Server to
+// provide code smartness, and is deleted each time you
+// refresh your sObject definitions.
+// To edit your sObjects and their fields, edit the corresponding
+// .object-meta.xml and .field-meta.xml files.
+
+global class Asset {
+ global Id Id;
+ global Contact Contact;
+ global Id ContactId;
+ global Account Account;
+ global Id AccountId;
+ global Asset Parent;
+ global Id ParentId;
+ global Asset RootAsset;
+ global Id RootAssetId;
+ global Product2 Product2;
+ global Id Product2Id;
+ global String ProductCode;
+ global Boolean IsCompetitorProduct;
+ global Datetime CreatedDate;
+ global User CreatedBy;
+ global Id CreatedById;
+ global Datetime LastModifiedDate;
+ global User LastModifiedBy;
+ global Id LastModifiedById;
+ global Datetime SystemModstamp;
+ global Boolean IsDeleted;
+ global String Name;
+ global String SerialNumber;
+ global Date InstallDate;
+ global Date PurchaseDate;
+ global Date UsageEndDate;
+ global Datetime LifecycleStartDate;
+ global Datetime LifecycleEndDate;
+ global String Status;
+ global Decimal Price;
+ global Double Quantity;
+ global String Description;
+ global User Owner;
+ global Id OwnerId;
+ global Location Location;
+ global Id LocationId;
+ global Account AssetProvidedBy;
+ global Id AssetProvidedById;
+ global Account AssetServicedBy;
+ global Id AssetServicedById;
+ global Boolean IsInternal;
+ global Integer AssetLevel;
+ global String StockKeepingUnit;
+ global Boolean HasLifecycleManagement;
+ global Decimal CurrentMrr;
+ global Datetime CurrentLifecycleEndDate;
+ global Double CurrentQuantity;
+ global Decimal CurrentAmount;
+ global Decimal TotalLifecycleAmount;
+ global String Street;
+ global String City;
+ global String State;
+ global String PostalCode;
+ global String Country;
+ global Double Latitude;
+ global Double Longitude;
+ global String GeocodeAccuracy;
+ global Address Address;
+ global Datetime LastViewedDate;
+ global Datetime LastReferencedDate;
+ global List ActivityHistories;
+ global List ChildAssets;
+ global List AssetActions;
+ global List AssetAttributes;
+ global List AssetDowntimePeriods;
+ global List Feeds;
+ global List Histories;
+ global List PrimaryAssets;
+ global List RelatedAssets;
+ global List Shares;
+ global List AssetStatePeriods;
+ global List WarrantyAssets;
+ global List AttachedContentDocuments;
+ global List Attachments;
+ global List Cases;
+ global List CombinedAttachments;
+ global List ContentDocumentLinks;
+ global List ContractLineItems;
+ global List Emails;
+ global List Entitlements;
+ global List FeedSubscriptionsForEntity;
+ global List Events;
+ global List MaintenanceAssets;
+ global List Notes;
+ global List NotesAndAttachments;
+ global List OpenActivities;
+ global List ProcessInstances;
+ global List ProcessSteps;
+ global List ProductServiceCampaignItems;
+ global List RecordActions;
+ global List RecordActionHistories;
+ global List RecordsetFltrCritMonitors;
+ global List ResourcePreferences;
+ global List ReturnOrderLineItems;
+ global List SerializedProducts;
+ global List ServiceAppointments;
+ global List Tasks;
+ global List TopicAssignments;
+ global List WorkOrders;
+ global List WorkOrderLineItems;
+ global List WorkPlanSelectionRules;
+ global List SobjectLookupValue;
+ global List Target;
+ global List RootAsset;
+ global List Asset;
+ global List Parent;
+ global List RootAsset;
+ global List Asset;
+ global List LinkedEntity;
+ global List FirstPublishLocation;
+ global List Asset;
+ global List RelatedTo;
+ global List Asset;
+ global List What;
+ global List Relation;
+ global List Parent;
+ global List ContextRecord;
+ global List RelatedRecord;
+ global List Asset;
+ global List RelatedTo;
+ global List Asset;
+ global List ParentRecord;
+ global List What;
+ global List Asset;
+
+ global Asset ()
+ {
+ }
+}
\ No newline at end of file
diff --git a/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Attachment.cls b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Attachment.cls
new file mode 100644
index 0000000000000000000000000000000000000000..5d1468a7b314e7b3c82bb9db5e3947da81badba8
--- /dev/null
+++ b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Attachment.cls
@@ -0,0 +1,35 @@
+// This file is generated as an Apex representation of the
+// corresponding sObject and its fields.
+// This read-only file is used by the Apex Language Server to
+// provide code smartness, and is deleted each time you
+// refresh your sObject definitions.
+// To edit your sObjects and their fields, edit the corresponding
+// .object-meta.xml and .field-meta.xml files.
+
+global class Attachment {
+ global Id Id;
+ global Boolean IsDeleted;
+ global SObject Parent;
+ global Id ParentId;
+ global String Name;
+ global Boolean IsPrivate;
+ global String ContentType;
+ global Integer BodyLength;
+ global Blob Body;
+ global SObject Owner;
+ global Id OwnerId;
+ global Datetime CreatedDate;
+ global User CreatedBy;
+ global Id CreatedById;
+ global Datetime LastModifiedDate;
+ global User LastModifiedBy;
+ global Id LastModifiedById;
+ global Datetime SystemModstamp;
+ global String Description;
+ global List ContextRecord;
+ global List RelatedRecord;
+
+ global Attachment ()
+ {
+ }
+}
\ No newline at end of file
diff --git a/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Case.cls b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Case.cls
new file mode 100644
index 0000000000000000000000000000000000000000..c24c8b966305336874ab7b480d8eba46f9d44366
--- /dev/null
+++ b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Case.cls
@@ -0,0 +1,111 @@
+// This file is generated as an Apex representation of the
+// corresponding sObject and its fields.
+// This read-only file is used by the Apex Language Server to
+// provide code smartness, and is deleted each time you
+// refresh your sObject definitions.
+// To edit your sObjects and their fields, edit the corresponding
+// .object-meta.xml and .field-meta.xml files.
+
+global class Case {
+ global Id Id;
+ global Boolean IsDeleted;
+ global Case MasterRecord;
+ global Id MasterRecordId;
+ global String CaseNumber;
+ global Contact Contact;
+ global Id ContactId;
+ global Account Account;
+ global Id AccountId;
+ global Asset Asset;
+ global Id AssetId;
+ global Case Parent;
+ global Id ParentId;
+ global String SuppliedName;
+ global String SuppliedEmail;
+ global String SuppliedPhone;
+ global String SuppliedCompany;
+ global String Type;
+ global String Status;
+ global String Reason;
+ global String Origin;
+ global String Subject;
+ global String Priority;
+ global String Description;
+ global Boolean IsClosed;
+ global Datetime ClosedDate;
+ global Boolean IsEscalated;
+ global SObject Owner;
+ global Id OwnerId;
+ global Datetime CreatedDate;
+ global User CreatedBy;
+ global Id CreatedById;
+ global Datetime LastModifiedDate;
+ global User LastModifiedBy;
+ global Id LastModifiedById;
+ global Datetime SystemModstamp;
+ global String ContactPhone;
+ global String ContactMobile;
+ global String ContactEmail;
+ global String ContactFax;
+ global String Comments;
+ global Datetime LastViewedDate;
+ global Datetime LastReferencedDate;
+ global List ActivityHistories;
+ global List AttachedContentDocuments;
+ global List Attachments;
+ global List Cases;
+ global List CaseComments;
+ global List CaseContactRoles;
+ global List Feeds;
+ global List Histories;
+ global List CaseMilestones;
+ global List Shares;
+ global List CaseSolutions;
+ global List TeamMembers;
+ global List TeamTemplateRecords;
+ global List RecordAssociatedGroups;
+ global List CombinedAttachments;
+ global List ContactRequests;
+ global List ContentDocumentLinks;
+ global List EmailMessages;
+ global List Emails;
+ global List FeedSubscriptionsForEntity;
+ global List Events;
+ global List MessagingSessions;
+ global List OpenActivities;
+ global List ProcessExceptions;
+ global List ProcessInstances;
+ global List ProcessSteps;
+ global List ProductRequests;
+ global List ProductRequestLineItems;
+ global List RecordActions;
+ global List RecordActionHistories;
+ global List ReturnOrders;
+ global List ServiceAppointments;
+ global List Swarms;
+ global List SwarmMembers;
+ global List Tasks;
+ global List TopicAssignments;
+ global List WorkOrders;
+ global List SobjectLookupValue;
+ global List Target;
+ global List Parent;
+ global List RelatedRecord;
+ global List LinkedEntity;
+ global List FirstPublishLocation;
+ global List Parent;
+ global List RelatedTo;
+ global List What;
+ global List Relation;
+ global List Parent;
+ global List ContextRecord;
+ global List RelatedRecord;
+ global List Case;
+ global List ParentRecord;
+ global List What;
+ global List Case;
+
+ global Case ()
+ {
+ }
+}
\ No newline at end of file
diff --git a/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Contact.cls b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Contact.cls
new file mode 100644
index 0000000000000000000000000000000000000000..5d8964fb61fda6d413f28bd5ead3f30d9ea86850
--- /dev/null
+++ b/proxy-lite-work/.sfdx/tools/sobjects/standardObjects/Contact.cls
@@ -0,0 +1,167 @@
+// This file is generated as an Apex representation of the
+// corresponding sObject and its fields.
+// This read-only file is used by the Apex Language Server to
+// provide code smartness, and is deleted each time you
+// refresh your sObject definitions.
+// To edit your sObjects and their fields, edit the corresponding
+// .object-meta.xml and .field-meta.xml files.
+
+global class Contact {
+ global Id Id;
+ global Boolean IsDeleted;
+ global Contact MasterRecord;
+ global Id MasterRecordId;
+ global Account Account;
+ global Id AccountId;
+ global String LastName;
+ global String FirstName;
+ global String Salutation;
+ global String Name;
+ global String OtherStreet;
+ global String OtherCity;
+ global String OtherState;
+ global String OtherPostalCode;
+ global String OtherCountry;
+ global Double OtherLatitude;
+ global Double OtherLongitude;
+ global String OtherGeocodeAccuracy;
+ global Address OtherAddress;
+ global String MailingStreet;
+ global String MailingCity;
+ global String MailingState;
+ global String MailingPostalCode;
+ global String MailingCountry;
+ global Double MailingLatitude;
+ global Double MailingLongitude;
+ global String MailingGeocodeAccuracy;
+ global Address MailingAddress;
+ global String Phone;
+ global String Fax;
+ global String MobilePhone;
+ global String HomePhone;
+ global String OtherPhone;
+ global String AssistantPhone;
+ global Contact ReportsTo;
+ global Id ReportsToId;
+ global String Email;
+ global String Title;
+ global String Department;
+ global String AssistantName;
+ global String LeadSource;
+ global Date Birthdate;
+ global String Description;
+ global User Owner;
+ global Id OwnerId;
+ global Datetime CreatedDate;
+ global User CreatedBy;
+ global Id CreatedById;
+ global Datetime LastModifiedDate;
+ global User LastModifiedBy;
+ global Id LastModifiedById;
+ global Datetime SystemModstamp;
+ global Date LastActivityDate;
+ global Datetime LastCURequestDate;
+ global Datetime LastCUUpdateDate;
+ global Datetime LastViewedDate;
+ global Datetime LastReferencedDate;
+ global String EmailBouncedReason;
+ global Datetime EmailBouncedDate;
+ global Boolean IsEmailBounced;
+ global String PhotoUrl;
+ global String Jigsaw;
+ global String JigsawContactId;
+ global String CleanStatus;
+ global Individual Individual;
+ global Id IndividualId;
+ global List AcceptedEventRelations;
+ global List AccountContactRoles;
+ global List ActivityHistories;
+ global List Assets;
+ global List AttachedContentDocuments;
+ global List Attachments;
+ global List AuthorizationFormConsents;
+ global List CampaignMembers;
+ global List Cases;
+ global List CaseContactRoles;
+ global List RecordAssociatedGroups;
+ global List CombinedAttachments;
+ global List CommSubscriptionConsents;
+ global List ContactCleanInfos;
+ global List Feeds;
+ global List Histories;
+ global List ContactRequests;
+ global List Shares;
+ global List