feat(MAT-174): Add cron job scheduler and executors
Cron package that syncs jobs from matrixhost portal API, schedules execution with timezone-aware timing, and posts results to Matrix rooms. Includes Brave Search, reminder, and browser scrape (placeholder) executors with formatter. 31 pytest tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
43
cron/browser_executor.py
Normal file
43
cron/browser_executor.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""Browser scrape executor for cron jobs (placeholder for workflow-use integration)."""
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def execute_browser_scrape(job: dict, send_text, **_kwargs) -> dict:
|
||||
"""Execute a browser-based scraping job.
|
||||
|
||||
This is a placeholder that will be fully implemented when workflow-use
|
||||
or Skyvern is deployed. For now, it posts a message indicating the
|
||||
feature is pending setup.
|
||||
"""
|
||||
target_room = job["targetRoom"]
|
||||
config = job.get("config", {})
|
||||
url = config.get("url", "")
|
||||
browser_profile = job.get("browserProfile")
|
||||
|
||||
if not browser_profile:
|
||||
await send_text(
|
||||
target_room,
|
||||
f"**{job['name']}**: Browser scan requires a connected browser profile. "
|
||||
f"Set one up at https://matrixhost.eu/settings/automations",
|
||||
)
|
||||
return {"status": "error", "error": "No browser profile configured"}
|
||||
|
||||
if browser_profile.get("status") == "expired":
|
||||
await send_text(
|
||||
target_room,
|
||||
f"**{job['name']}**: Your browser session has expired. "
|
||||
f"Please re-record at https://matrixhost.eu/settings/automations",
|
||||
)
|
||||
return {"status": "error", "error": "Browser session expired"}
|
||||
|
||||
# TODO: Integrate workflow-use or Skyvern for actual browser replay
|
||||
# For now, fall back to a simple notification
|
||||
await send_text(
|
||||
target_room,
|
||||
f"**{job['name']}**: Browser scan for {url} is configured but browser "
|
||||
f"replay is not yet available. Web Search automations work now.",
|
||||
)
|
||||
return {"status": "error", "error": "Browser executor not yet implemented"}
|
||||
Reference in New Issue
Block a user