feat: add open-operator — AI agent browser automation#614
Open
feat: add open-operator — AI agent browser automation#614
Conversation
68e5e94 to
7fde454
Compare
Complete AI agent browser automation system for OpenCLI: Core Agent (src/agent/): - LLM-driven browser control loop with 14 action types - Planning system with plan CRUD and replan nudges - Sliding-window loop detection with page fingerprinting - Autocomplete field detection with 3-layer protocol - Value mismatch detection (post-type readback) - Final response after failure (captures partial results) - Message compaction with epistemic guard (unverified labels) - Sensitive data masking before LLM Multi-Provider LLM: - OPENCLI_PROVIDER (anthropic/openai) + OPENCLI_MODEL + OPENCLI_API_KEY - Model aliases: sonnet, opus, haiku, gpt-5.4, gpt-4.1, o3 - HTML proxy detection with actionable error messages - Prompt caching for Anthropic, token tracking for both Browser Control: - CDP passthrough with method allowlist (22 permitted methods) - scrollIntoView before click/type (fixes off-viewport elements) - Three-strategy click fallback: CDP → page.click → evaluate JS - Two-layer retry for extension interference (operate: 5x/1.5s, normal: 2x/500ms) - about:blank for blank tabs (prevents extension hijacking) - opencli browse commands for Claude Code skill integration Skill Generation: - Rich trace capture (network interceptor + auth context + thinking log) - API discovery: score requests to find golden API, recommend strategy - LLM-powered TS adapter generation with validation + self-repair - node_modules symlink for user TS adapter package resolution AutoResearch: - 59-task eval framework (49 train + 10 test, 8 categories) - Claude Code research instructions (program.md) - Baseline: 56/59 (95%), train 48/49 (98%) Documentation: - OPERATE.md: full user guide with configuration, costs, troubleshooting - SKILL.md split into 3 specialized skills (cli, operate, adapter-dev) - README updated with AI Agent section New CLI commands: - opencli operate|op <task> — AI agent browser automation - opencli browse open/state/click/type/eval/screenshot/scroll/back/close - opencli doctor — now shows LLM provider status Dependencies: zod, @anthropic-ai/sdk, openai
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
opencli operatecommand — an AI agent that autonomously controls the browser to complete tasks described in natural language, then saves successful operations as reusable TypeScript CLI skills.End-to-end verified: Successfully tested on example.com (data extraction) and Twitter/X (DM listing with login state reuse).
Key capabilities
opencli operate "task"— LLM-driven browser control loop (observe → reason → act → repeat)opencli operate --save-as site/name— Saves successful operations as.tsadapters via LLM code generationInput.dispatchMouseEvent/KeyEventforisTrusted:trueevents, with automatic JS injection fallbackArchitecture
New files
src/agent/agent-loop.tssrc/agent/action-executor.tssrc/agent/dom-context.tssrc/agent/prompts.tssrc/agent/llm-client.tsANTHROPIC_BASE_URL)src/agent/types.tssrc/agent/trace-recorder.tssrc/agent/api-discovery.tssrc/agent/skill-saver.tsSecurity
--save-asnames validated against path traversal ([a-zA-Z0-9_-]only)Dependencies
zod— Runtime validation of LLM structured output@anthropic-ai/sdk— Anthropic API clientTest plan
opencli operate --helpshows correct usageopencli operate --url https://example.com "extract heading"— completes in 1 stepopencli operate --url https://x.com "get my DMs"— navigates, extracts 10 DMs with login stateopencli operate --save-as test/heading "extract heading"— generates.tsadapternpm run buildsucceeds (392 manifest entries)opencli test heading