A robust, record-once / replay-many automation layer designed for legacy banking applications without APIs.
"The model discovers. The artifact becomes a reusable capability. Deterministic replay is how the AI agent invokes it in production."
- Discovery (Model in the Loop): An LLM explores a live application surface using an Observe -> Decide -> Act loop, overcoming hostile legacy quirks (nested
<table>tags, ASP.NET-style control IDs, absence ofdata-testid). - Capability Artifact: The successful execution is compiled into a typed, versioned, agent-invocable capability schema decoupled from the raw model transcript.
- Deterministic Replay (Zero Model in the Loop): In production, the capability replays at 0 token cost and sub-second per DOM interaction (measured ~4.7–4.9 seconds across 5 steps, ~5–6 seconds total wall-clock time including Playwright Chromium browser startup, compared to 15–30+ seconds for multi-turn LLM exploration), resolving elements via multi-strategy locator chains and distinguishing Expected Business Outcomes from Recoverable Interstitials and Hard Failures.
- Human-in-the-Loop Escalation: When unresolvable blockers or irreversible mutations occur, the system pauses on the exact same live browser session, transfers control to a human operator, records their actions, and safely resumes automation. Unattended execution strictly fails closed.
- Python 3.10+ (tested on Python 3.13)
- Playwright with Chromium installed
Clone the repository and install dependencies:
git clone https://github.com/Yashwanth-23/computer-use.git
cd computer-use
pip install -r requirements.txt
playwright install chromium- Running with an LLM Provider:
Set the corresponding environment variable for your target frontier provider:
- Anthropic:
export ANTHROPIC_API_KEY="sk-ant-..."(used for the canonical Claude Sonnet 5 discovery run) - OpenAI:
export OPENAI_API_KEY="sk-proj-..." - Google Gemini:
export GEMINI_API_KEY="AIzaSy..." - Moonshot / Kimi:
export KIMI_API_KEY="..."orexport MOONSHOT_API_KEY="..."
- Anthropic:
- Running Standalone (Simulated Discovery Mode):
- In simulated discovery mode, no external model or banking service is required; the built-in simulated client explores the live mock portal locally.
- Deterministic replay requires zero LLM tokens and no API keys across all scenarios.
In a separate terminal, launch the ApexCore legacy banking mock server:
python -m src.cli serve-mock --port 8000(Server runs at http://127.0.0.1:8000/. Features server-rendered legacy ASP.NET controls, nested tables, member search, account balances, and sub-account opening).
Execute the LLM discovery loop to navigate the portal, identify elements, and compile a reusable capability artifact:
python -m src.cli discover --goal "Look up member 1001 and read savings and checking balances" --target "http://127.0.0.1:8000/portal/member-lookup" --output evidence/capability_member_lookup.jsonOutput: A validated, typed capability artifact written to evidence/capability_member_lookup.json with execution telemetry logged to evidence/discovery_run.log.
Invoke the saved capability with input parameters (0 tokens, deterministic execution).
You can run the self-booting helper (boots mock server automatically in one command):
python -m scripts.run_replay --member 1001 --headlessOr run via the direct CLI (with mock server running):
python -m src.cli replay --artifact evidence/capability_member_lookup.json --input "{\"member_id\": \"1001\"}"Output:
============================================================
REPLAY RESULT: SUCCESS
============================================================
Run ID: run_1d2e6604e095
Capability: cap_bfa2d82803e3 (v1.0.0)
Outputs: {
"savings_balance": 24500.0,
"checking_balance": 4120.0
}
------------------------------------------------------------
Executed 5 steps:
* step_1_navigate ( 990.9ms)
* step_2_type ( 969.3ms) [stable_id index=0]
* step_3_click ( 999.0ms) [stable_id index=0]
* step_4_extract ( 959.0ms) [stable_id index=0]
* step_5_extract ( 935.3ms) [stable_id index=0]
============================================================
Replay with non-existent member 9999:
python -m src.cli replay --artifact evidence/capability_member_lookup.json --input "{\"member_id\": \"9999\"}"Result Contract: Returns status="BUSINESS_OUTCOME" with structured outcome [MEMBER_NOT_FOUND]. This is an expected business result, not an unhandled exception or crash.
Enable the simulated maintenance alert and replay:
# In another terminal or curl:
curl -X POST http://127.0.0.1:8000/admin/maintenance/on
python -m src.cli replay --artifact evidence/capability_member_lookup.json --input "{\"member_id\": \"1001\"}"(The replay engine detects #pnlMaintenanceAlert, executes the recovery step by clicking #btnAckMaintenance, and completes the lookup with status=RECOVERED).
Attempt to execute an irreversible sub-account opening without an operator:
python -m src.cli replay --artifact evidence/capability_open_subaccount.json --input "{\"member_id\": \"1001\", \"product_type\": \"HOLIDAY_CLUB\", \"initial_deposit\": \"50.00\"}"Result:
============================================================
REPLAY RESULT: ESCALATED
============================================================
Run ID: run_7f8c12a04d2e
Capability: cap_open_sub_account (v1.0.0)
Incident ID: esc_31c7f776e0e9
Policy Gate: Unattended execution halted on RISKY_IRREVERSIBLE action.
Rerun with --interactive (and optionally --headed) to provide human operator authorization.
Re-run with human operator authorization on a live headed browser:
python -m src.cli replay --artifact evidence/capability_open_subaccount.json --input "{\"member_id\": \"1001\", \"product_type\": \"HOLIDAY_CLUB\", \"initial_deposit\": \"50.00\"}" --interactive --headed- Automation drives the browser to the review confirmation screen.
- The engine detects Step 5 is
RISKY_IRREVERSIBLE, pauses execution on the live session, captures a screenshot, and cedes control to the operator. - The CLI prompts the operator to inspect the live session and authorize (
resume) or cancel (abort). - Upon confirmation, automation commits the financial mutation to the ledger, verifies the receipt checkpoint, and returns
receipt_id.
Run the full automated test suite (52 tests covering schemas, guardrails, locator fallbacks, error taxonomy, dead-end detection, and escalation state machine):
pytest tests/ -vTo regenerate all audit logs, evidence artifacts, and cryptographically verified manifest in /evidence/:
python scripts/generate_evidence.py├── README.md # Quickstart, architecture, demo commands
├── REPORT.md # Formal 7-section technical design report
├── requirements.txt # Project dependencies
├── evidence/ # Proof of real execution runs
│ ├── capability_member_lookup.json # Discovered canonical capability artifact (cap_bfa2d82803e3)
│ ├── capability_open_subaccount.json # Sub-account creation artifact with RISKY_IRREVERSIBLE gate
│ ├── discovery_run.log # Live Claude Sonnet 5 discovery audit log
│ ├── replay_success.log # Deterministic replay log (Happy path, Member 1001)
│ ├── replay_business_outcome_404.log # Expected business outcome log (Member 9999)
│ ├── replay_interstitial_recovery.log# Recoverable condition log (Maintenance banner dismissed)
│ ├── replay_escalation_handoff.log # Simulated supervisor handoff log (mode: simulated_operator_supervised)
│ ├── replay_hard_failure.log # Sanitized diagnostic failure log with masked screenshot
│ ├── manifest.json # Cryptographic manifest (hashes, run IDs, commit SHA)
│ └── screenshots/ # Active masked failure and escalation screenshots
├── mock_target/ # Legacy core banking application (ApexCore)
│ ├── app.py # FastAPI server with legacy routes & admin toggles
│ ├── core_data.py # In-memory core data records
│ └── templates/ # Hostile nested tables, frames, ASP.NET controls
├── src/ # Core Engine Source
│ ├── agent/ # LLM discovery loop & artifact compiler
│ ├── engine/ # Zero-LLM deterministic replay engine & error diagnostics
│ ├── escalation/ # Live session human escalation & handoff (with DOM visual masking)
│ ├── safety/ # Domain/route guardrails & PII/Secrets sanitizer
│ ├── schemas/ # Pydantic v2 artifact & execution contracts
│ └── cli.py # Unified CLI entry point
└── tests/ # Rigorous unit and integration test suite (52 tests)