From 87399c1484698349a168d44a31967684558c82b0 Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 12 Jul 2026 20:55:32 -0500 Subject: [PATCH] feat: kimi.com support, prompt_file for rich prompts, response capture fixes, docs - Add kimi.com agent alongside grok.com - Support per-task agent overrides - Support prompt_file for multi-line/rich prompts - Fix response capture for streaming completions - Add GrokAuto_User_Guide.html and README examples --- DISCOVERY.md | 375 +++++++++++++++++ GrokAuto_Email_Guide.html | 12 +- GrokAuto_User_Guide.html | 690 ++++++++++++++++++++++++++++++++ README.md | 77 +++- SECURITY.md | 6 +- examples/config.json | 34 ++ examples/prompts/gmail_check.md | 15 + main.py | 58 ++- modules/agents/__init__.py | 33 ++ modules/agents/base.py | 65 +++ modules/agents/grok.py | 171 ++++++++ modules/agents/kimi.py | 190 +++++++++ modules/browser_ctl.py | 108 ++++- modules/config_validator.py | 107 ++++- modules/login_validator.py | 164 +------- modules/prompt_resolver.py | 137 +++++++ modules/task_executor.py | 134 +++---- modules/types.py | 27 ++ pytest.ini | 3 + tests/test_agents.py | 146 +++++++ tests/test_browser_ctl.py | 137 +++++++ tests/test_config_validator.py | 448 +++++++++++++++++++++ tests/test_deps_checker.py | 169 ++++++++ tests/test_login_validator.py | 61 +++ tests/test_prompt_resolver.py | 118 ++++++ tests/test_response_writer.py | 108 +++++ tests/test_task_executor.py | 231 +++++++++++ 27 files changed, 3574 insertions(+), 250 deletions(-) create mode 100644 DISCOVERY.md create mode 100644 GrokAuto_User_Guide.html create mode 100644 examples/config.json create mode 100644 examples/prompts/gmail_check.md create mode 100644 modules/agents/__init__.py create mode 100644 modules/agents/base.py create mode 100644 modules/agents/grok.py create mode 100644 modules/agents/kimi.py create mode 100644 modules/prompt_resolver.py create mode 100644 modules/types.py create mode 100644 pytest.ini create mode 100644 tests/test_agents.py create mode 100644 tests/test_browser_ctl.py create mode 100644 tests/test_config_validator.py create mode 100644 tests/test_deps_checker.py create mode 100644 tests/test_login_validator.py create mode 100644 tests/test_prompt_resolver.py create mode 100644 tests/test_response_writer.py create mode 100644 tests/test_task_executor.py diff --git a/DISCOVERY.md b/DISCOVERY.md new file mode 100644 index 0000000..5ed4ca4 --- /dev/null +++ b/DISCOVERY.md @@ -0,0 +1,375 @@ +# GrokAuto Discovery Notes + +**Host:** `dsd.890.be` +**User:** `grok` +**Project path:** `/home/grok/grokauto` +**Local mirror:** `/Users/martin/dsd_890_be/grokauto` + +GrokAuto is a headless-browser automation tool that drives `grok.com` through the Chrome DevTools Protocol (CDP). It reads tasks from a JSON config, sends each prompt to Grok, waits for the streaming response to finish, and writes the results to timestamped Markdown files. + +--- + +## 1. Architecture + +``` +main.py +├── modules/deps_checker.py System dependency checks (Chrome, Python, pip, Xvfb, cron) +├── modules/config_validator.py JSON config parsing and validation +├── modules/browser_ctl.py Launch Chromium and talk CDP over WebSocket +├── modules/login_validator.py Heuristic grok.com login detection +├── modules/task_executor.py Send prompts, wait for streaming, capture response text +└── modules/response_writer.py Format and persist Markdown output files +``` + +### 1.1 `main.py` + +CLI orchestrator. Sub-commands: + +| Flag | Purpose | +|------|---------| +| `--diagnose` | Full dependency + configuration diagnostic | +| `--check-deps` | Dependency report only | +| `--validate-config` | Config report only | +| `--run` | Execute tasks from config (default action) | +| `--prompt "..."` | Run a single inline prompt | +| `--task-id ID` | Run only one task from config | +| `--setup-cron "SCHEDULE"` | Install a crontab entry | +| `--remove-cron` | Remove the crontab entry | +| `--list-outputs` | List saved `.md` outputs | + +The default action is `--run`. Execution flow: + +1. Validate dependencies. +2. Validate and load config. +3. Launch Chrome with `--remote-debugging-port=9222`. +4. Check grok.com login state; abort if not authenticated. +5. Run selected tasks. +6. Save responses to `output_dir` with mode `0o600`. +7. Print summary and close browser. + +### 1.2 `modules/browser_ctl.py` + +- Launches Chromium with `--remote-debugging-port`, `--user-data-dir`, `--headless=new`, and anti-automation flags. +- Connects to CDP via `websocket-client`. +- Exposes `navigate_to`, `execute_js`, `wait_for_element`, `get_page_source`, `close_browser`. +- Pre-flight port check: refuses to launch if `127.0.0.1:debug_port` is already open. +- Registers an `atexit` cleanup handler. + +### 1.3 `modules/task_executor.py` + +- Navigates to `https://grok.com`, waits 4s for React hydration. +- Finds the chat input using a fallback selector chain (`contenteditable`, `textarea`, etc.). +- Handles both ProseMirror/tiptap `contenteditable` inputs and plain `