haltija 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +220 -0
- package/bin/build-bookmarklet.ts +107 -0
- package/bin/cli-subcommand.mjs +537 -0
- package/bin/format-events.mjs +125 -0
- package/bin/format-test.mjs +183 -0
- package/bin/format-tree.mjs +165 -0
- package/bin/hj.mjs +59 -0
- package/bin/mcp-setup.mjs +288 -0
- package/bin/server.ts +9 -0
- package/bin/tosijs-dev.mjs +591 -0
- package/bin/tosijs-dev.ts +74 -0
- package/dist/client.js +387 -0
- package/dist/component.js +6685 -0
- package/dist/index.js +10201 -0
- package/dist/server.js +9847 -0
- package/docs/CI-INTEGRATION.md +230 -0
- package/docs/EXECUTIVE-SUMMARY.md +213 -0
- package/docs/README.md +67 -0
- package/docs/REST-API.md +123 -0
- package/docs/ROADMAP.md +591 -0
- package/docs/UX-CRIMES.md +599 -0
- package/docs/agent-prompt.md +139 -0
- package/docs/getting-started/app.md +96 -0
- package/docs/getting-started/playground.md +75 -0
- package/docs/getting-started/service.md +96 -0
- package/docs/recipes.md +245 -0
- package/haltija-icon.svg +79 -0
- package/package.json +68 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# E2E Testing with Haltija in CI
|
|
2
|
+
|
|
3
|
+
Run browser tests in GitHub Actions using Haltija. Your tests run against a real Electron browser — same engine your users run, no headless quirks.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
name: E2E Tests
|
|
9
|
+
on: [push, pull_request]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
e2e:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: oven-sh/setup-bun@v2
|
|
17
|
+
|
|
18
|
+
- name: Install Haltija
|
|
19
|
+
run: bun install && bun run build
|
|
20
|
+
|
|
21
|
+
- name: Install display deps
|
|
22
|
+
run: |
|
|
23
|
+
sudo apt-get update
|
|
24
|
+
sudo apt-get install -y xvfb libnss3 libatk1.0-0 libatk-bridge2.0-0 \
|
|
25
|
+
libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \
|
|
26
|
+
libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2
|
|
27
|
+
|
|
28
|
+
- name: Launch Haltija
|
|
29
|
+
run: |
|
|
30
|
+
cd apps/desktop && npm install --omit=dev
|
|
31
|
+
xvfb-run --auto-servernum npx electron . &
|
|
32
|
+
# Wait for ready
|
|
33
|
+
until hj status 2>/dev/null | grep -q '"ok":true'; do sleep 1; done
|
|
34
|
+
|
|
35
|
+
- name: Run tests
|
|
36
|
+
run: hj test-run tests/my-test.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## The hj CLI
|
|
40
|
+
|
|
41
|
+
The `hj` command is the simplest way to interact with Haltija:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Check status
|
|
45
|
+
hj status
|
|
46
|
+
|
|
47
|
+
# See the page
|
|
48
|
+
hj tree
|
|
49
|
+
|
|
50
|
+
# Interact
|
|
51
|
+
hj click "#submit"
|
|
52
|
+
hj type "#email" user@example.com
|
|
53
|
+
hj key Enter
|
|
54
|
+
|
|
55
|
+
# Run tests
|
|
56
|
+
hj test-run tests/login.json
|
|
57
|
+
hj test-suite tests/ # Run all tests in directory
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Run `hj --help` for all commands. The CLI auto-starts the server if needed.
|
|
61
|
+
|
|
62
|
+
## Writing Tests
|
|
63
|
+
|
|
64
|
+
Tests are JSON files with steps:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"version": 1,
|
|
69
|
+
"name": "Login flow",
|
|
70
|
+
"url": "http://localhost:3000/login",
|
|
71
|
+
"steps": [
|
|
72
|
+
{"action": "type", "selector": "#email", "text": "user@example.com"},
|
|
73
|
+
{"action": "type", "selector": "#password", "text": "secret123"},
|
|
74
|
+
{"action": "click", "selector": "button[type=submit]"},
|
|
75
|
+
{"action": "wait", "selector": ".dashboard"},
|
|
76
|
+
{"action": "assert", "assertion": {"type": "url", "pattern": "/dashboard"}}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Step Types
|
|
82
|
+
|
|
83
|
+
| Action | Example | What It Does |
|
|
84
|
+
|--------|---------|--------------|
|
|
85
|
+
| `navigate` | `{"action": "navigate", "url": "..."}` | Load a URL |
|
|
86
|
+
| `click` | `{"action": "click", "selector": "#btn"}` | Click element |
|
|
87
|
+
| `type` | `{"action": "type", "selector": "#input", "text": "..."}` | Type text |
|
|
88
|
+
| `key` | `{"action": "key", "key": "Enter"}` | Press key |
|
|
89
|
+
| `wait` | `{"action": "wait", "selector": ".loaded"}` | Wait for element |
|
|
90
|
+
| `assert` | `{"action": "assert", "assertion": {...}}` | Check condition |
|
|
91
|
+
| `eval` | `{"action": "eval", "code": "..."}` | Run JavaScript |
|
|
92
|
+
|
|
93
|
+
### Assertions
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{"type": "exists", "selector": ".modal"}
|
|
97
|
+
{"type": "not-exists", "selector": ".error"}
|
|
98
|
+
{"type": "text", "selector": "h1", "text": "Welcome"}
|
|
99
|
+
{"type": "url", "pattern": "/dashboard"}
|
|
100
|
+
{"type": "visible", "selector": "#content"}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Step Metadata
|
|
104
|
+
|
|
105
|
+
Add context to improve failure messages:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"action": "click",
|
|
110
|
+
"selector": "#checkout",
|
|
111
|
+
"description": "Click checkout button",
|
|
112
|
+
"purpose": "Button may be disabled if cart is empty"
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Running Tests
|
|
117
|
+
|
|
118
|
+
### Single test
|
|
119
|
+
```bash
|
|
120
|
+
hj test-run tests/login.json
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Multiple tests
|
|
124
|
+
```bash
|
|
125
|
+
hj test-suite tests/
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### With options
|
|
129
|
+
```bash
|
|
130
|
+
# JSON output (default)
|
|
131
|
+
hj test-run tests/login.json
|
|
132
|
+
|
|
133
|
+
# Human-readable output
|
|
134
|
+
hj test-run tests/login.json --format human
|
|
135
|
+
|
|
136
|
+
# GitHub Actions annotations
|
|
137
|
+
hj test-run tests/login.json --format github
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Handling Flaky Tests
|
|
141
|
+
|
|
142
|
+
Use the patience model for CI environments with variable timing:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"test": {...},
|
|
147
|
+
"patience": 5,
|
|
148
|
+
"patienceStreak": 3,
|
|
149
|
+
"timeout": 8000
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- `patience: 5` — allow up to 5 step failures before bailing
|
|
154
|
+
- `patienceStreak: 3` — 3 consecutive failures bails immediately
|
|
155
|
+
- `timeout: 8000` — per-step timeout in ms
|
|
156
|
+
|
|
157
|
+
## Debugging Failures
|
|
158
|
+
|
|
159
|
+
### Capture state on failure
|
|
160
|
+
```yaml
|
|
161
|
+
- name: Debug info
|
|
162
|
+
if: failure()
|
|
163
|
+
run: |
|
|
164
|
+
hj screenshot > failure-screenshot.json
|
|
165
|
+
hj console > console-logs.json
|
|
166
|
+
hj snapshot > failure-state.json
|
|
167
|
+
|
|
168
|
+
- uses: actions/upload-artifact@v4
|
|
169
|
+
if: failure()
|
|
170
|
+
with:
|
|
171
|
+
name: debug
|
|
172
|
+
path: "*.json"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Check what's on the page
|
|
176
|
+
```bash
|
|
177
|
+
hj tree # DOM structure
|
|
178
|
+
hj console # Browser console
|
|
179
|
+
hj screenshot # Visual capture
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Platform Notes
|
|
183
|
+
|
|
184
|
+
### Linux (GitHub Actions)
|
|
185
|
+
Requires xvfb and Electron dependencies:
|
|
186
|
+
```bash
|
|
187
|
+
sudo apt-get install -y xvfb libnss3 libatk1.0-0 libatk-bridge2.0-0 \
|
|
188
|
+
libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \
|
|
189
|
+
libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2
|
|
190
|
+
|
|
191
|
+
xvfb-run --auto-servernum npx electron . &
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### macOS
|
|
195
|
+
No xvfb needed:
|
|
196
|
+
```bash
|
|
197
|
+
npx electron . &
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Testing Your Own App
|
|
201
|
+
|
|
202
|
+
Start your app before running tests:
|
|
203
|
+
|
|
204
|
+
```yaml
|
|
205
|
+
- name: Start app
|
|
206
|
+
run: |
|
|
207
|
+
npm start &
|
|
208
|
+
until curl -sf http://localhost:3000 > /dev/null; do sleep 1; done
|
|
209
|
+
|
|
210
|
+
- name: Run tests
|
|
211
|
+
run: hj test-run tests/app-tests.json
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Tips
|
|
215
|
+
|
|
216
|
+
- **Start simple** — one test, few steps, then expand
|
|
217
|
+
- **Use `purpose`** on steps that might fail — explains intent on failure
|
|
218
|
+
- **Navigate explicitly** — don't rely on default page state
|
|
219
|
+
- **Upload artifacts** — screenshots and snapshots are invaluable for debugging
|
|
220
|
+
|
|
221
|
+
## REST API
|
|
222
|
+
|
|
223
|
+
For direct HTTP integration (scripts, other languages), see [REST-API.md](REST-API.md).
|
|
224
|
+
|
|
225
|
+
## Examples
|
|
226
|
+
|
|
227
|
+
See test files in this repo:
|
|
228
|
+
- [`tests/playground.json`](../tests/playground.json)
|
|
229
|
+
- [`tests/homepage.json`](../tests/homepage.json)
|
|
230
|
+
- [`.github/workflows/test-qa.yml`](../.github/workflows/test-qa.yml)
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Haltija Executive Summary
|
|
2
|
+
|
|
3
|
+
Haltija gives AI agents eyes and hands in the browser. Instead of parsing screenshots or guessing at page structure, agents see the actual DOM, click elements, type text, and watch for changes. One script tag makes any web app AI-controllable.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## For the CEO
|
|
8
|
+
|
|
9
|
+
Haltija is infrastructure for AI-powered quality assurance. It replaces brittle, expensive end-to-end test suites with an AI QA engineer that explores applications, generates test plans, runs tests, and reports failures in plain English.
|
|
10
|
+
|
|
11
|
+
The business case: E2E test maintenance is a significant engineering cost. Tests break when UI changes, produce cryptic errors, and require constant human attention. Haltija shifts that burden to AI, freeing engineering time for product work.
|
|
12
|
+
|
|
13
|
+
- **Reduces QA engineering overhead** by automating test creation and maintenance
|
|
14
|
+
- **Improves bug reports** with human-readable failure explanations, not stack traces
|
|
15
|
+
- **Runs in CI** like existing test infrastructure, no workflow changes required
|
|
16
|
+
- **Aligns with core AI strategy** as a practical application of AI agents doing real work
|
|
17
|
+
- **Potential product opportunity** beyond internal tooling
|
|
18
|
+
|
|
19
|
+
**Limitations**: Requires investment to productionize. Not yet proven at scale. Would need dedicated support if deployed broadly.
|
|
20
|
+
|
|
21
|
+
**Missing**: Cloud-hosted offering, enterprise authentication integrations, usage analytics dashboard.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## For the CTO
|
|
26
|
+
|
|
27
|
+
Haltija is a WebSocket bridge between a browser widget and a REST API. AI agents make HTTP calls; the widget executes them in a real browser context. The architecture is simple: no browser binaries to manage, no protocol complexity, no version mismatches.
|
|
28
|
+
|
|
29
|
+
The technical differentiator is semantic events. Rather than exposing raw DOM events, Haltija aggregates user intent: "user typed email@example.com" not eighteen keydown events. This makes AI reasoning about browser state tractable.
|
|
30
|
+
|
|
31
|
+
- **Zero-dependency deployment**: `bunx haltija` starts the server, one script tag injects the widget
|
|
32
|
+
- **Schema-driven API** with self-documenting endpoints and type-safe handlers
|
|
33
|
+
- **Real browser rendering** via Electron, not headless browser quirks
|
|
34
|
+
- **Extensible**: new endpoints require schema definition + handler, router handles the rest
|
|
35
|
+
- **Built on Bun** for fast startup and minimal resource footprint
|
|
36
|
+
|
|
37
|
+
**Limitations**: Shadow DOM support is workable but not seamless. No iframe traversal for cross-origin content.
|
|
38
|
+
|
|
39
|
+
**Missing**: Node.js support for the server (Bun-only currently), browser extension for persistent injection, pre-built binaries for all platforms (build script works on macOS/Linux, Windows untested).
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## For the UI Engineer
|
|
44
|
+
|
|
45
|
+
Haltija lets you test your components with an AI that actually sees what users see. Point it at your dev server, and it can explore your app, find interactive elements, and verify behavior without you writing selectors or maintaining test fixtures.
|
|
46
|
+
|
|
47
|
+
Integration is one line: `<script src="http://localhost:4000/component.js"></script>`. The widget connects to a local server, and any AI agent with HTTP access can now control your browser tab.
|
|
48
|
+
|
|
49
|
+
- **DOM tree inspection** with configurable depth, text content, and attribute filtering
|
|
50
|
+
- **Visibility heuristics** that match user perception: hidden, off-screen, transparent, and disabled states
|
|
51
|
+
- **Input value tracking** shows current form state without querying each field
|
|
52
|
+
- **Matched CSS rules** option shows which stylesheets affect an element and why
|
|
53
|
+
- **Cursor visualization** shows exactly where clicks land, useful for debugging interaction issues
|
|
54
|
+
|
|
55
|
+
**Limitations**: Cannot pierce cross-origin iframes. Custom elements with closed shadow roots are opaque. Very dynamic UIs (heavy animation, virtual scrolling) may report stale state.
|
|
56
|
+
|
|
57
|
+
**Missing**: React/Vue/Angular devtools integration, component-level boundaries in tree output, performance profiling hooks.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## For the QA Engineer
|
|
62
|
+
|
|
63
|
+
Haltija is a QA engineer in a box. It explores your application, identifies interactive elements, generates test plans, executes them, and reports failures in terms you can act on. When tests break because UI changed, it can often fix them automatically.
|
|
64
|
+
|
|
65
|
+
Unlike Selenium or Playwright, you don't write selectors. You describe intent: "log in as test user, add item to cart, verify checkout total." The AI figures out how to do it on your actual UI.
|
|
66
|
+
|
|
67
|
+
- **Natural language test specs** that survive UI refactors
|
|
68
|
+
- **Failure explanations** like "button not visible because parent has display:none" not "timeout after 30000ms"
|
|
69
|
+
- **Semantic event recording** captures what the user did, not raw browser events
|
|
70
|
+
- **Test JSON format** for version control and CI integration
|
|
71
|
+
- **Actionable summary** lists all buttons, links, inputs on a page with their current state
|
|
72
|
+
|
|
73
|
+
**Limitations**: AI interpretation adds latency compared to direct selector tests. Novel or highly custom UI patterns may confuse the AI. Not a replacement for unit tests or integration tests.
|
|
74
|
+
|
|
75
|
+
**Missing**: Visual regression comparison, accessibility audit integration, performance budget assertions, test coverage reporting.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## For the Security Consultant
|
|
80
|
+
|
|
81
|
+
Haltija runs a WebSocket server on localhost that accepts commands to control browser tabs. The widget self-identifies when active (no silent operation), and users can pause or kill the connection at any time.
|
|
82
|
+
|
|
83
|
+
The threat model assumes a trusted local environment. The server binds to localhost by default. Cross-origin stylesheets cannot be inspected due to browser security. The widget cannot access cross-origin iframe content.
|
|
84
|
+
|
|
85
|
+
- **Localhost-only by default**, no remote connections without explicit configuration
|
|
86
|
+
- **Visible indicator** in browser when agent is connected and operating
|
|
87
|
+
- **User kill switch** to immediately disconnect and remove widget
|
|
88
|
+
- **No credential storage**, authentication is handled by the browser normally
|
|
89
|
+
- **CSP-aware**: widget injection respects Content-Security-Policy where enforced
|
|
90
|
+
|
|
91
|
+
**Limitations**: Bookmarklet injection bypasses CSP on the injecting page. Desktop app strips CSP headers for universal compatibility. No audit logging of commands executed. No authentication on the REST API.
|
|
92
|
+
|
|
93
|
+
**Missing**: API authentication/authorization, command audit log, rate limiting, configurable command allowlists, SOC2 compliance documentation.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## For the Hobbyist / Vibe Coder
|
|
98
|
+
|
|
99
|
+
Haltija lets you tell Claude to browse the web for you. Run the server, open the desktop app or inject the widget, and Claude can see pages, click buttons, fill forms, and tell you what happened.
|
|
100
|
+
|
|
101
|
+
Setup takes two minutes: install Bun, run `bunx haltija`, open the Haltija app, and paste the agent prompt into your conversation. Now Claude has a browser.
|
|
102
|
+
|
|
103
|
+
- **Copy-paste prompt** gets Claude controlling your browser immediately (simpler than MCP)
|
|
104
|
+
- **Visual feedback** shows cursor movement and action subtitles as Claude operates
|
|
105
|
+
- **Explore any website** with the included Electron browser
|
|
106
|
+
- **Record your actions** and let Claude replay or modify them
|
|
107
|
+
- **No coding required** for basic browsing automation
|
|
108
|
+
|
|
109
|
+
**Limitations**: Some sites block the widget (strict CSP). CAPTCHAs and bot detection will stop automation. Sites requiring login need manual authentication first.
|
|
110
|
+
|
|
111
|
+
**Missing**: One-click installer, browser extension for easier injection, mobile support, saved session/cookie management.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## For the AI Enthusiast
|
|
116
|
+
|
|
117
|
+
Haltija is what browser MCP tools should be. Instead of sending screenshots and hoping vision models figure it out, Haltija gives agents structured DOM access. The AI sees elements, attributes, text content, and visibility state directly.
|
|
118
|
+
|
|
119
|
+
The semantic event system is particularly interesting: instead of raw DOM events, Haltija aggregates meaningful actions. This makes it feasible for AI to understand user sessions without drowning in event noise.
|
|
120
|
+
|
|
121
|
+
- **DOM over screenshots**: structured data beats pixel parsing for reliability
|
|
122
|
+
- **Semantic events**: "user typed 'hello'" not 17 keystrokes
|
|
123
|
+
- **Hindsight buffer**: review what happened without recording everything upfront
|
|
124
|
+
- **Mutation watching** with noise filtering for framework-specific chatter
|
|
125
|
+
- **Tool-use optimized**: API returns exactly what agents need, nothing more
|
|
126
|
+
|
|
127
|
+
**Limitations**: Text-heavy UIs work best. Canvas, WebGL, and video content are opaque. Very large DOMs may need pagination or focused queries.
|
|
128
|
+
|
|
129
|
+
**Missing**: Vision model fallback for non-DOM content, multi-modal event capture (audio, video), agent memory/persistence across sessions.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Efficiency & Performance
|
|
134
|
+
|
|
135
|
+
Haltija is designed for efficiency - reducing the data agents need to process while preserving the information they need to act.
|
|
136
|
+
|
|
137
|
+
### Event Reduction: 99%+
|
|
138
|
+
|
|
139
|
+
Raw DOM events are noisy. A user typing "hello@example.com" generates dozens of keydown, keypress, input, and keyup events. Haltija's semantic event system aggregates these into a single `input:typed` event with the final value. Typical reduction: **99%+ fewer events** while preserving user intent.
|
|
140
|
+
|
|
141
|
+
### DOM Reduction
|
|
142
|
+
|
|
143
|
+
Full DOM trees are massive. Haltija filters to what matters:
|
|
144
|
+
- Interactive elements (buttons, inputs, links)
|
|
145
|
+
- Visible content (hidden elements filtered)
|
|
146
|
+
- Interesting attributes (ARIA, data-*, roles)
|
|
147
|
+
- Configurable depth limits
|
|
148
|
+
|
|
149
|
+
A 10,000-node DOM might reduce to 200 relevant nodes for a form-filling task.
|
|
150
|
+
|
|
151
|
+
### Ref IDs: Efficient Re-targeting
|
|
152
|
+
|
|
153
|
+
Every element in `/tree` output includes a ref ID (e.g., `1`, `42`). Agents can use these refs instead of CSS selectors for subsequent commands:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# First, get the tree
|
|
157
|
+
hj tree
|
|
158
|
+
# Response includes: 42: button "Submit" [interactive]
|
|
159
|
+
|
|
160
|
+
# Later, click by ref - no selector matching needed
|
|
161
|
+
hj click 42
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Refs survive DOM changes better than selectors (which break when classes change) and are faster to resolve (direct lookup vs. CSS matching).
|
|
165
|
+
|
|
166
|
+
### Measuring Efficiency
|
|
167
|
+
|
|
168
|
+
Use the `/stats` endpoint or click the 📊 button in the widget to see real metrics:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"events": { "raw": 1847, "semantic": 23, "reductionPercent": 98.8 },
|
|
173
|
+
"dom": { "processed": 3420, "inTree": 156, "reductionPercent": 95.4 },
|
|
174
|
+
"refs": { "assigned": 156, "resolved": 42, "stale": 3, "hitRate": 93.3 }
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Console access: `haltija.copyStats()` copies full stats to clipboard.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## For Existing Puppeteer MCP / Browser Automation Users
|
|
183
|
+
|
|
184
|
+
If you're using Puppeteer MCP, Playwright MCP, or similar tools, Haltija offers a different philosophy: user-centric rather than developer-centric.
|
|
185
|
+
|
|
186
|
+
Puppeteer exposes browser internals. You think in selectors, wait conditions, and protocol commands. When tests fail, you get stack traces. Haltija exposes user-visible state. You think in elements, actions, and outcomes. When tests fail, you get explanations.
|
|
187
|
+
|
|
188
|
+
- **No browser binary management**: widget runs in any browser, server is a single command
|
|
189
|
+
- **Human-readable failures**: "element hidden by ancestor with display:none" vs "timeout"
|
|
190
|
+
- **Semantic events**: understand user intent, not DOM mutations
|
|
191
|
+
- **Real browser rendering**: Electron app has full engine, not headless quirks
|
|
192
|
+
- **Designed for AI agents**: API returns structured, actionable data
|
|
193
|
+
|
|
194
|
+
**Limitations**: Less low-level control than Puppeteer. Cannot intercept network requests or modify browser behavior. No protocol-level access for advanced debugging.
|
|
195
|
+
|
|
196
|
+
**Missing**: Network interception, request mocking, browser console forwarding to agent, multi-browser parallel execution.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Summary
|
|
201
|
+
|
|
202
|
+
| Audience | Primary Value | Key Limitation |
|
|
203
|
+
|----------|--------------|----------------|
|
|
204
|
+
| CEO | Reduced QA costs, AI-native testing | Needs investment to productionize |
|
|
205
|
+
| CTO | Clean architecture, semantic events | Bun-only server, Windows untested |
|
|
206
|
+
| UI Engineer | One-line integration, real DOM access | No cross-origin iframe support |
|
|
207
|
+
| QA Engineer | Natural language tests, auto-fixing | AI latency vs direct selectors |
|
|
208
|
+
| Security | Localhost-only, visible operation | No API auth, CSP bypassed in app |
|
|
209
|
+
| Hobbyist | Easy setup, visual feedback | Some sites block widget |
|
|
210
|
+
| AI Enthusiast | Structured DOM, semantic events | Canvas/WebGL opaque |
|
|
211
|
+
| Puppeteer User | User-centric, human-readable | Less low-level control |
|
|
212
|
+
|
|
213
|
+
Haltija is production-ready for local development and testing workflows. Cloud deployment and enterprise features would require additional investment.
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Haltija Documentation
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
1. **[Getting Started: Service](getting-started/service.md)** - Run `bunx haltija` and inject the widget
|
|
6
|
+
2. **[Getting Started: App](getting-started/app.md)** - Add one script tag to your app
|
|
7
|
+
3. **[Getting Started: Playground](getting-started/playground.md)** - Interactive testing environment
|
|
8
|
+
4. **[CI Integration](CI-INTEGRATION.md)** - Run Haltija in GitHub Actions and other CI systems
|
|
9
|
+
|
|
10
|
+
## Recipes
|
|
11
|
+
|
|
12
|
+
**[Recipes](recipes.md)** - Common workflows with copy-paste examples:
|
|
13
|
+
- Testing login flows
|
|
14
|
+
- Exploring unfamiliar UIs
|
|
15
|
+
- Recording bug reproductions
|
|
16
|
+
- Generating tests from manual exploration
|
|
17
|
+
- Debugging customer issues
|
|
18
|
+
- Accessibility auditing
|
|
19
|
+
- Multi-tab testing (OAuth, admin/user)
|
|
20
|
+
- Waiting for dynamic content
|
|
21
|
+
- User selection ("point at the problem")
|
|
22
|
+
|
|
23
|
+
## Reference
|
|
24
|
+
|
|
25
|
+
- **[API Reference](../API.md)** - Complete endpoint documentation (auto-generated from schema)
|
|
26
|
+
- **[Agent Prompt](agent-prompt.md)** - System prompt for AI agents using Haltija
|
|
27
|
+
- **[UX Crimes](UX-CRIMES.md)** - Anti-patterns Haltija detects automatically
|
|
28
|
+
|
|
29
|
+
## Architecture
|
|
30
|
+
|
|
31
|
+
- **[CLAUDE.md](../CLAUDE.md)** - Build commands, architecture overview, code structure
|
|
32
|
+
- **[Component Patterns](../COMPONENT-PATTERNS.md)** - Design patterns used in the widget
|
|
33
|
+
|
|
34
|
+
## Planning
|
|
35
|
+
|
|
36
|
+
- **[Executive Summary](EXECUTIVE-SUMMARY.md)** - What Haltija is, who it's for
|
|
37
|
+
- **[Roadmap to 10/10](ROADMAP-TO-10.md)** - Where we're going
|
|
38
|
+
- **[Development Roadmap](../ROADMAP.md)** - Completed and planned phases
|
|
39
|
+
- **[TODO](../TODO.md)** - Outstanding issues and ideas
|
|
40
|
+
|
|
41
|
+
## Desktop App
|
|
42
|
+
|
|
43
|
+
- **[Desktop README](../apps/desktop/README.md)** - Electron app setup and building
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Documentation Map
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
README.md # Main entry point, 30-second pitch
|
|
51
|
+
docs/
|
|
52
|
+
README.md # This file - documentation index
|
|
53
|
+
getting-started/
|
|
54
|
+
service.md # Start the server
|
|
55
|
+
app.md # Add to your app
|
|
56
|
+
playground.md # Interactive testing
|
|
57
|
+
CI-INTEGRATION.md # GitHub Actions, CI/CD setup
|
|
58
|
+
recipes.md # Common workflows with examples
|
|
59
|
+
EXECUTIVE-SUMMARY.md # For stakeholders
|
|
60
|
+
ROADMAP.md # Product roadmap (to 11/10)
|
|
61
|
+
agent-prompt.md # AI agent system prompt
|
|
62
|
+
UX-CRIMES.md # Anti-pattern detection
|
|
63
|
+
API.md # Auto-generated API reference
|
|
64
|
+
CLAUDE.md # Developer guide (for AI and humans)
|
|
65
|
+
COMPONENT-PATTERNS.md # Widget architecture patterns
|
|
66
|
+
TODO.md # Issues and ideas
|
|
67
|
+
```
|
package/docs/REST-API.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Haltija REST API Reference
|
|
2
|
+
|
|
3
|
+
> For most use cases, use the `hj` CLI instead. This document is for direct HTTP integration.
|
|
4
|
+
|
|
5
|
+
The Haltija server exposes a REST API at `http://localhost:8700`. All POST endpoints accept JSON bodies and return JSON responses.
|
|
6
|
+
|
|
7
|
+
## Quick Reference
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Health / readiness
|
|
11
|
+
GET /status # Server up?
|
|
12
|
+
GET /windows # Browser connected?
|
|
13
|
+
|
|
14
|
+
# Navigation
|
|
15
|
+
POST /navigate {"url": "..."} # Go to URL
|
|
16
|
+
GET /location # Current URL + title
|
|
17
|
+
|
|
18
|
+
# Interaction
|
|
19
|
+
POST /click {"selector": "..."}
|
|
20
|
+
POST /type {"selector": "...", "text": "..."}
|
|
21
|
+
POST /key {"key": "Enter"}
|
|
22
|
+
|
|
23
|
+
# Inspection
|
|
24
|
+
POST /tree {"depth": 3} # DOM tree with ref IDs
|
|
25
|
+
POST /query {"selector": "..."} # Find element details
|
|
26
|
+
|
|
27
|
+
# Testing
|
|
28
|
+
POST /test/run {"test": {...}} # Run one test
|
|
29
|
+
POST /test/suite {"tests": [...]} # Run multiple tests
|
|
30
|
+
|
|
31
|
+
# Debugging
|
|
32
|
+
GET /console # Browser console output
|
|
33
|
+
POST /screenshot # Page capture (base64 PNG)
|
|
34
|
+
POST /snapshot # Full debug state dump
|
|
35
|
+
|
|
36
|
+
# Tabs
|
|
37
|
+
POST /tabs/open {"url": "..."} # New tab
|
|
38
|
+
POST /tabs/close {"window": "..."} # Close tab
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Response Format
|
|
42
|
+
|
|
43
|
+
All POST endpoints return:
|
|
44
|
+
```json
|
|
45
|
+
{"success": true, "data": ...}
|
|
46
|
+
```
|
|
47
|
+
or on error:
|
|
48
|
+
```json
|
|
49
|
+
{"success": false, "error": "..."}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Targeting Specific Tabs
|
|
53
|
+
|
|
54
|
+
Add `?window=<id>` to any endpoint or include `"window": "id"` in the POST body.
|
|
55
|
+
|
|
56
|
+
Get window IDs from `GET /windows`.
|
|
57
|
+
|
|
58
|
+
## Full API Documentation
|
|
59
|
+
|
|
60
|
+
Run `hj api` or visit `http://localhost:8700/api` for complete endpoint documentation with all parameters and examples.
|
|
61
|
+
|
|
62
|
+
## curl Examples
|
|
63
|
+
|
|
64
|
+
### Check server status
|
|
65
|
+
```bash
|
|
66
|
+
curl http://localhost:8700/status
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### See page structure
|
|
70
|
+
```bash
|
|
71
|
+
curl -X POST http://localhost:8700/tree \
|
|
72
|
+
-H "Content-Type: application/json" \
|
|
73
|
+
-d '{"depth": 3, "mode": "actionable"}'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Click an element
|
|
77
|
+
```bash
|
|
78
|
+
curl -X POST http://localhost:8700/click \
|
|
79
|
+
-H "Content-Type: application/json" \
|
|
80
|
+
-d '{"selector": "#submit"}'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Type text
|
|
84
|
+
```bash
|
|
85
|
+
curl -X POST http://localhost:8700/type \
|
|
86
|
+
-H "Content-Type: application/json" \
|
|
87
|
+
-d '{"selector": "#email", "text": "user@example.com"}'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Navigate
|
|
91
|
+
```bash
|
|
92
|
+
curl -X POST http://localhost:8700/navigate \
|
|
93
|
+
-H "Content-Type: application/json" \
|
|
94
|
+
-d '{"url": "https://example.com"}'
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Take screenshot
|
|
98
|
+
```bash
|
|
99
|
+
curl -X POST http://localhost:8700/screenshot \
|
|
100
|
+
-H "Content-Type: application/json" \
|
|
101
|
+
-d '{"maxWidth": 800}'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Run a test
|
|
105
|
+
```bash
|
|
106
|
+
curl -X POST http://localhost:8700/test/run \
|
|
107
|
+
-H "Content-Type: application/json" \
|
|
108
|
+
-d @tests/my-test.json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## hj Equivalents
|
|
112
|
+
|
|
113
|
+
Every curl command above has a simpler `hj` equivalent:
|
|
114
|
+
|
|
115
|
+
| curl | hj |
|
|
116
|
+
|------|-----|
|
|
117
|
+
| `curl localhost:8700/status` | `hj status` |
|
|
118
|
+
| `curl -X POST localhost:8700/tree -d '{...}'` | `hj tree` |
|
|
119
|
+
| `curl -X POST localhost:8700/click -d '{"selector":"#btn"}'` | `hj click "#btn"` |
|
|
120
|
+
| `curl -X POST localhost:8700/type -d '{"selector":"#email","text":"..."}' | `hj type "#email" user@example.com` |
|
|
121
|
+
| `curl -X POST localhost:8700/navigate -d '{"url":"..."}'` | `hj navigate example.com` |
|
|
122
|
+
|
|
123
|
+
Use `hj --help` for the full command list.
|