Skip to content

Commit c16bb8f

Browse files
committed
feat: Implement session logging and workflow execution for Chrome tester
- Add SessionLogger class to handle logging of session details, including steps and results. - Create main.js to orchestrate the agent's execution, including command parsing and decision-making. - Introduce runtime.js for utility functions like sleep, JSON writing, and random ID generation. - Develop workflow.js to manage the execution of defined workflows with error handling. - Implement JSON parsing utilities in json.ts for handling command responses. - Add prompt generation functions in prompt.ts for structured command interaction. - Create safety checks in safety.ts to identify potentially unsafe commands. - Implement truncation logic in truncate.ts for managing output length. - Add unit tests for JSON, safety, prompt, and truncation utilities. - Create build.rs for linking with llama-cpp-ffi common library. - Document testing procedures in testing.md for local and CI environments.
1 parent 5f3e1ab commit c16bb8f

50 files changed

Lines changed: 5653 additions & 641 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
agent-cli-tests:
9+
name: Agent CLI Tests
10+
runs-on: ubuntu-latest
11+
defaults:
12+
run:
13+
working-directory: agent/cli
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
cache: npm
24+
cache-dependency-path: agent/cli/package-lock.json
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run tests
30+
run: npm test
31+
32+
rust-tests:
33+
name: Rust Tests
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Setup Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
43+
- name: Run cargo test --all-targets
44+
run: cargo test --all-targets

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "hugind"
33
version = "0.11.2"
44
edition = "2024"
5+
build = "build.rs"
56

67
[dependencies]
78
rquickjs = { version = "0.11", features = ["loader", "futures", "classes", "macro"] }
@@ -31,7 +32,7 @@ axum = "0.7.7"
3132
tempfile = "3.24.0"
3233
zip = "2.2.0"
3334
semver = "1.0"
34-
llama-cpp = { path = "/Users/adel/Workspace/llama_cpp_rust/llama-cpp", features = ["metal", "mtmd"] }
35+
llama-cpp = { git = "https://github.com/netdur/llama_cpp_rust", package = "llama-cpp", features = ["metal", "mtmd"] }
3536
tower = { version = "0.4", features = ["util", "timeout", "limit"] }
3637
tower-http = { version = "0.5", features = ["trace", "cors"] }
3738
tracing = "0.1"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ more /Users/adel/.hugind/logs/agents/ocr/20260210_122933.526.txt
358358
* [Stdio Bridge](docs/stdio_bridge.md)
359359
NDJSON + MCP protocol reference for desktop/app integration (`hugind stdio`).
360360

361+
* [Testing Guide](docs/testing.md)
362+
Local test commands, CI parity commands, and troubleshooting notes.
363+
361364
* [WASM Runtime](docs/wasm_runtime.md)
362365
Covers WASM execution lifecycle, hostcalls, filesystem modes, and runtime limits.
363366

agent/chrome_tester/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# chrome_tester
2+
3+
Autonomous web tester agent built for Hugind using the official Chrome DevTools MCP server.
4+
5+
## What It Does
6+
- Discovers Chrome MCP tools dynamically via `tools.list()`.
7+
- Uses an LLM loop to choose the next action.
8+
- Acts using Chrome MCP tools (`take_snapshot`, `click`, `fill`, `wait_for`, etc.).
9+
- Detects blocking takeover overlays/ad-like frames (`detect_blocking_overlay`).
10+
- Attempts recovery (`dismiss_blocking_overlay`) by clicking close controls or hiding blockers in test mode.
11+
- Extracts phone numbers from page state (`extract_phone_numbers`) and prints candidates in console.
12+
- Logs every step under `logs/`.
13+
14+
## Prerequisites
15+
- Google Chrome installed.
16+
- `chrome-devtools-mcp` available through npm/npx.
17+
18+
## Run
19+
20+
```bash
21+
./target/release/hugind agent run agent/chrome_tester -- \
22+
--goal "Open example.com and verify the main heading is visible" \
23+
--start-url "https://example.com" \
24+
--max-steps 20
25+
```
26+
27+
## CLI Options
28+
- `--goal <text>`: testing objective.
29+
- `--start-url <url>`: optional initial navigation target.
30+
- `--workflow <path.json>`: run a multi-step workflow file.
31+
- `--max-steps <n>`: max loop iterations.
32+
- `--step-delay <seconds>`: minimum delay between steps.
33+
34+
## Workflow Mode
35+
36+
Run:
37+
38+
```bash
39+
./target/release/hugind agent run agent/chrome_tester -- \
40+
--workflow agent/chrome_tester/examples/wikipedia_complex_workflow.json
41+
```
42+
43+
Marrakech restaurant phone workflow:
44+
45+
```bash
46+
./target/release/hugind agent run agent/chrome_tester -- \
47+
--workflow agent/chrome_tester/examples/marrakech_restaurant_phone_workflow.json
48+
```
49+
50+
Reddit research workflow (Google-block resistant):
51+
52+
```bash
53+
./target/release/hugind agent run agent/chrome_tester -- \
54+
--workflow agent/chrome_tester/examples/reddit_research_workflow.json
55+
```
56+
57+
Deterministic local workflow (no external bot blocking):
58+
59+
1. Start local static test server:
60+
61+
```bash
62+
python3 -m http.server 8787 --directory agent/chrome_tester/test_site
63+
```
64+
65+
2. In another terminal run:
66+
67+
```bash
68+
./target/release/hugind agent run agent/chrome_tester -- \
69+
--workflow agent/chrome_tester/examples/local_restaurant_phone_workflow.json
70+
```
71+
72+
Workflow JSON shape:
73+
74+
```json
75+
{
76+
"name": "workflow_name",
77+
"continueOnFailure": false,
78+
"steps": [
79+
{
80+
"name": "step name",
81+
"startUrl": "https://example.com",
82+
"maxSteps": 15,
83+
"goal": "What to validate",
84+
"checks": ["extra check 1", "extra check 2"],
85+
"instructions": "optional instructions"
86+
}
87+
]
88+
}
89+
```
90+
91+
## Notes
92+
- This agent intentionally uses only MCP browser tools (no shell automation).
93+
- Default mode is visible Chrome (no `--headless`) for easier visual debugging.
94+
- The manifest currently keeps `--isolated`, so it uses a separate profile/session.
95+
- If your environment sandboxes spawned processes heavily, run Chrome with remote debugging and configure MCP with `--browser-url`.
96+
- Tool names can evolve across `chrome-devtools-mcp` versions, so this agent resolves capabilities from runtime discovery instead of hardcoding one exact schema.
97+
- If `tools.list()` is incompatible in your MCP bridge, the agent now falls back to known Chrome tool-name variants automatically.

0 commit comments

Comments
 (0)