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,139 @@
|
|
|
1
|
+
# Haltija Agent Quick-Start
|
|
2
|
+
|
|
3
|
+
Copy this prompt to give an AI agent browser control via Haltija.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The Prompt
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
# Haltija - Browser Control
|
|
11
|
+
|
|
12
|
+
## What is this?
|
|
13
|
+
You have browser control via the `hj` command.
|
|
14
|
+
It returns semantic structure — what's clickable, what's hidden and why, what inputs exist.
|
|
15
|
+
Not screenshots, not HTML dumps. The page as an agent should see it.
|
|
16
|
+
|
|
17
|
+
The server auto-starts if needed. All commands: `hj <verb> [target] [args]`
|
|
18
|
+
|
|
19
|
+
## Key Concepts
|
|
20
|
+
|
|
21
|
+
- **Tree** (`hj tree`): Your eyes. A text list of elements with IDs and flags.
|
|
22
|
+
- **Refs**: Every element has a numeric ID (e.g. 5, 42). Use these to target elements.
|
|
23
|
+
Refs are stable — they survive re-renders. Always prefer refs over CSS selectors.
|
|
24
|
+
- **Flags**: Check these before acting:
|
|
25
|
+
[interactive] — clickable/typeable
|
|
26
|
+
[hidden:display] — invisible, don't interact
|
|
27
|
+
[disabled] — form field is disabled
|
|
28
|
+
[required] — must be filled
|
|
29
|
+
- **Quoting**: Only needed for spaces: `hj type 5 "hello world"`. Simple args need no quotes.
|
|
30
|
+
|
|
31
|
+
## Sample Output (`hj tree`)
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
( 1 body
|
|
35
|
+
2 h1 "Sign Up"
|
|
36
|
+
( 3 div.form-row
|
|
37
|
+
4 label "Email:"
|
|
38
|
+
5 input#email-input type=email placeholder=you@example.com interactive
|
|
39
|
+
)
|
|
40
|
+
( 6 div.form-row
|
|
41
|
+
7 label "Password:"
|
|
42
|
+
8 input type=password interactive
|
|
43
|
+
)
|
|
44
|
+
9 button#btn-submit interactive "Create Account"
|
|
45
|
+
( 10 p
|
|
46
|
+
11 a href=/login interactive "Already have an account?"
|
|
47
|
+
)
|
|
48
|
+
12 div hidden:display "Error: invalid email"
|
|
49
|
+
)
|
|
50
|
+
---
|
|
51
|
+
hj tree --json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Reading this:
|
|
55
|
+
- `(` = children follow (push), `)` = end children (pop)
|
|
56
|
+
- Refs are the numbers (e.g. 5, 9, 11)
|
|
57
|
+
- `interactive` means you can click/type it
|
|
58
|
+
- `hidden:display` means it exists but is invisible
|
|
59
|
+
- Attributes (type, placeholder, href) shown inline
|
|
60
|
+
- Text content in quotes
|
|
61
|
+
- `---` footer shows the command for JSON output
|
|
62
|
+
|
|
63
|
+
To fill this form:
|
|
64
|
+
- Type email: `hj type 5 "user@example.com"`
|
|
65
|
+
- Type password: `hj type 8 s3cret`
|
|
66
|
+
- Submit: `hj click 9`
|
|
67
|
+
- Check if error appeared: `hj tree` (see if ref 12 lost [hidden])
|
|
68
|
+
|
|
69
|
+
## Workflow
|
|
70
|
+
|
|
71
|
+
1. **Inspect**: `hj tree` to see what's on the page
|
|
72
|
+
2. **Plan**: Find the target ref. Confirm it shows [interactive].
|
|
73
|
+
3. **Act**: `hj click`/`hj type`/`hj navigate`
|
|
74
|
+
4. **Verify**: `hj tree` or `hj console` to confirm the result
|
|
75
|
+
|
|
76
|
+
## Commands
|
|
77
|
+
|
|
78
|
+
### See the page
|
|
79
|
+
hj tree Semantic page structure with refs and flags
|
|
80
|
+
hj tree --visible Only visible elements
|
|
81
|
+
hj tree -d 5 Deeper tree
|
|
82
|
+
hj tree form Subtree rooted at selector
|
|
83
|
+
hj console Recent console logs/errors
|
|
84
|
+
hj screenshot Capture page as image
|
|
85
|
+
hj location Current URL and title
|
|
86
|
+
hj events Recent semantic events
|
|
87
|
+
|
|
88
|
+
### Inspect
|
|
89
|
+
hj inspect 3 Deep details on one element
|
|
90
|
+
hj query input Quick element lookup
|
|
91
|
+
hj call 5 value Get element property
|
|
92
|
+
hj eval document.title Run arbitrary JavaScript
|
|
93
|
+
|
|
94
|
+
### Interact
|
|
95
|
+
hj click 9 Click by ref (preferred)
|
|
96
|
+
hj click "Submit" Click by text content
|
|
97
|
+
hj click "#btn" Click by selector (fragile)
|
|
98
|
+
hj type 5 hello Type into element
|
|
99
|
+
hj key Enter Press key
|
|
100
|
+
hj key s --ctrl Keyboard shortcut
|
|
101
|
+
hj scroll 20 Scroll element into view
|
|
102
|
+
hj navigate https://... Go to URL
|
|
103
|
+
|
|
104
|
+
### Show the user
|
|
105
|
+
hj highlight 5 "Here" Draw a labeled box on their screen
|
|
106
|
+
hj unhighlight Remove highlight
|
|
107
|
+
|
|
108
|
+
### Wait
|
|
109
|
+
hj wait .modal Wait for element to appear
|
|
110
|
+
hj wait .loading 10000 Wait up to 10s
|
|
111
|
+
|
|
112
|
+
### Multiple tabs
|
|
113
|
+
hj windows List connected tabs
|
|
114
|
+
hj click 5 --window abc Target specific tab
|
|
115
|
+
|
|
116
|
+
## Tips
|
|
117
|
+
|
|
118
|
+
- Start with `hj tree` — look for [interactive] to find actionable elements
|
|
119
|
+
- Always prefer refs over selectors — refs survive DOM changes
|
|
120
|
+
- After async actions: `hj wait .spinner` then `hj tree`
|
|
121
|
+
- Show the user what you found: `hj highlight 5 "This button"`
|
|
122
|
+
- If a click fails: `hj console` for JS errors
|
|
123
|
+
- Hidden elements can't be clicked — check [hidden] flag first
|
|
124
|
+
- Some apps use clickable divs: try `hj eval "document.querySelector('#el').click()"` as fallback
|
|
125
|
+
- Forms need proper events: use `hj type` (not eval) to fire input events correctly
|
|
126
|
+
|
|
127
|
+
## More info
|
|
128
|
+
|
|
129
|
+
`hj api` for full reference, `hj docs` for quick start.
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Notes
|
|
135
|
+
|
|
136
|
+
- The sample output block is the most important part — agents learn the format by example.
|
|
137
|
+
- Refs are bare numbers. The command verb determines how arguments are parsed,
|
|
138
|
+
so there's no ambiguity between `hj click 5` (ref) and `hj scroll 300` (pixels).
|
|
139
|
+
- Only quote arguments that contain spaces.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Haltija App
|
|
2
|
+
|
|
3
|
+
You're running Haltija in the desktop app. This gives you a browser with superpowers - the Haltija widget is automatically injected into every page you visit, bypassing security restrictions that would normally block it.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
1. **Navigate to any website** using the address bar above
|
|
8
|
+
2. **Look for the widget** in the bottom-right corner (the elf icon)
|
|
9
|
+
3. **Connect your AI agent** using the REST API at `http://localhost:8700`
|
|
10
|
+
|
|
11
|
+
## For Your AI Agent
|
|
12
|
+
|
|
13
|
+
Give your agent this prompt to get started:
|
|
14
|
+
|
|
15
|
+
```prompt
|
|
16
|
+
I have Haltija running at http://localhost:8700. You can see and control my browser.
|
|
17
|
+
|
|
18
|
+
**Quick start:**
|
|
19
|
+
1. Check server: curl http://localhost:8700/status
|
|
20
|
+
2. Find tabs: curl http://localhost:8700/windows
|
|
21
|
+
3. See what's on page: curl -X POST http://localhost:8700/tree -d '{"selector":"body","mode":"actionable"}'
|
|
22
|
+
4. Do something: curl -X POST http://localhost:8700/click -d '{"selector":"button"}'
|
|
23
|
+
|
|
24
|
+
**Key endpoints:**
|
|
25
|
+
- GET /status - check connection, list tabs
|
|
26
|
+
- GET /windows - list connected tabs with IDs
|
|
27
|
+
- GET /location?window=ID - current URL
|
|
28
|
+
- GET /endpoints - compact JSON list of all capabilities
|
|
29
|
+
- POST /tree - see page structure (use mode:"actionable" for summary of buttons/links/inputs)
|
|
30
|
+
- POST /click - click an element
|
|
31
|
+
- POST /type - type into a field
|
|
32
|
+
- POST /scroll - smooth scroll to element or position
|
|
33
|
+
- POST /highlight - show the user an element (with optional label)
|
|
34
|
+
- POST /wait - wait for element to appear/disappear or fixed delay
|
|
35
|
+
- POST /eval - run JavaScript (escape hatch)
|
|
36
|
+
- POST /screenshot - capture page image (see options below)
|
|
37
|
+
- GET /events - recent events including network errors
|
|
38
|
+
- GET /console - recent console logs/errors
|
|
39
|
+
- GET /select/result - get elements user has selected in browser
|
|
40
|
+
|
|
41
|
+
**Screenshot options:**
|
|
42
|
+
- format: "png" (default), "webp", "jpeg"
|
|
43
|
+
- quality: 0.0-1.0 (for webp/jpeg, default 0.8)
|
|
44
|
+
- scale: 0.5 = half size (saves bandwidth)
|
|
45
|
+
- maxWidth/maxHeight: constrain dimensions (great for vision models)
|
|
46
|
+
- selector: capture specific element instead of full page
|
|
47
|
+
|
|
48
|
+
Example: curl -X POST http://localhost:8700/screenshot -d '{"scale":0.5,"format":"webp"}'
|
|
49
|
+
|
|
50
|
+
**Wait for async UI:**
|
|
51
|
+
- curl -X POST http://localhost:8700/wait -d '{"forElement":".modal"}' # Wait for element
|
|
52
|
+
- curl -X POST http://localhost:8700/wait -d '{"forElement":".loading","hidden":true}' # Wait for disappear
|
|
53
|
+
- curl -X POST http://localhost:8700/wait -d '{"ms":500}' # Simple delay
|
|
54
|
+
|
|
55
|
+
**Showing things to the user:**
|
|
56
|
+
When explaining something or pointing out an issue, use /highlight to visually show the user:
|
|
57
|
+
- curl -X POST http://localhost:8700/highlight -d '{"selector":"#login-btn","label":"Click here"}'
|
|
58
|
+
- curl -X POST http://localhost:8700/highlight -d '{"selector":".error","label":"This is the problem","color":"#ef4444"}'
|
|
59
|
+
The highlight stays until you call /unhighlight or set a duration in ms.
|
|
60
|
+
|
|
61
|
+
**Target a specific tab:** Add ?window=<id> or include "window":"id" in POST body
|
|
62
|
+
|
|
63
|
+
All POST endpoints return: {"success": true, "data": ...} or {"success": false, "error": "..."}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
For the full agent prompt with more examples, see [agent-prompt.md](../agent-prompt.md).
|
|
67
|
+
|
|
68
|
+
## Useful Commands
|
|
69
|
+
|
|
70
|
+
Check if the server is running:
|
|
71
|
+
```bash
|
|
72
|
+
curl http://localhost:8700/status
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Get the page structure:
|
|
76
|
+
```bash
|
|
77
|
+
curl -X POST http://localhost:8700/tree -d '{"selector": "body", "depth": 3}'
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Take a screenshot:
|
|
81
|
+
```bash
|
|
82
|
+
curl -X POST http://localhost:8700/screenshot -d '{"scale": 0.5}'
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Click a button:
|
|
86
|
+
```bash
|
|
87
|
+
curl -X POST http://localhost:8700/click -d '{"selector": "button"}'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Keyboard Shortcuts
|
|
91
|
+
|
|
92
|
+
- **Cmd+T** - New tab
|
|
93
|
+
- **Cmd+W** - Close tab
|
|
94
|
+
- **Cmd+1-9** - Switch to tab
|
|
95
|
+
- **Cmd+L** - Focus address bar
|
|
96
|
+
- **Cmd+R** - Refresh page
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Playground
|
|
2
|
+
|
|
3
|
+
This is a sandbox for testing Haltija commands. The elements below are designed for agents to practice interacting with web pages.
|
|
4
|
+
|
|
5
|
+
## Interactive Elements
|
|
6
|
+
|
|
7
|
+
Use these to test clicking, typing, and reading page content.
|
|
8
|
+
|
|
9
|
+
### Buttons
|
|
10
|
+
|
|
11
|
+
<div class="test-buttons">
|
|
12
|
+
<button id="btn-primary" class="btn-test primary">Primary Button</button>
|
|
13
|
+
<button id="btn-secondary" class="btn-test secondary">Secondary Button</button>
|
|
14
|
+
<button id="btn-danger" class="btn-test danger">Danger Button</button>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
### Form Inputs
|
|
18
|
+
|
|
19
|
+
<div class="test-form">
|
|
20
|
+
<div class="form-row">
|
|
21
|
+
<label for="text-input">Text Input:</label>
|
|
22
|
+
<input type="text" id="text-input" placeholder="Type something here...">
|
|
23
|
+
</div>
|
|
24
|
+
<div class="form-row">
|
|
25
|
+
<label for="email-input">Email:</label>
|
|
26
|
+
<input type="email" id="email-input" placeholder="you@example.com">
|
|
27
|
+
</div>
|
|
28
|
+
<div class="form-row">
|
|
29
|
+
<label for="select-input">Dropdown:</label>
|
|
30
|
+
<select id="select-input">
|
|
31
|
+
<option value="">Choose an option...</option>
|
|
32
|
+
<option value="a">Option A</option>
|
|
33
|
+
<option value="b">Option B</option>
|
|
34
|
+
<option value="c">Option C</option>
|
|
35
|
+
</select>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="form-row">
|
|
38
|
+
<label>Checkboxes:</label>
|
|
39
|
+
<div class="checkbox-group">
|
|
40
|
+
<label><input type="checkbox" id="check-1"> Option 1</label>
|
|
41
|
+
<label><input type="checkbox" id="check-2"> Option 2</label>
|
|
42
|
+
<label><input type="checkbox" id="check-3"> Option 3</label>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
### Output Area
|
|
48
|
+
|
|
49
|
+
<div id="output" class="output-box">
|
|
50
|
+
Click buttons or type in fields to see results here.
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
## Test Commands
|
|
54
|
+
|
|
55
|
+
Try these commands to interact with the playground:
|
|
56
|
+
|
|
57
|
+
Click the primary button:
|
|
58
|
+
```bash
|
|
59
|
+
curl -X POST http://localhost:8700/click -H "Content-Type: application/json" -d '{"selector": "#btn-primary"}'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Type in the text input:
|
|
63
|
+
```bash
|
|
64
|
+
curl -X POST http://localhost:8700/type -H "Content-Type: application/json" -d '{"selector": "#text-input", "text": "Hello from the agent!"}'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Read the output area:
|
|
68
|
+
```bash
|
|
69
|
+
curl -X POST http://localhost:8700/query -H "Content-Type: application/json" -d '{"selector": "#output"}'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Get all form values:
|
|
73
|
+
```bash
|
|
74
|
+
curl -X POST http://localhost:8700/eval -H "Content-Type: application/json" -d '{"code": "JSON.stringify({text: document.getElementById(\"text-input\").value, email: document.getElementById(\"email-input\").value})"}'
|
|
75
|
+
```
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Haltija Service
|
|
2
|
+
|
|
3
|
+
You're running the Haltija server. To give your AI agent browser control, inject the widget into a web page.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
1. **Drag the bookmarklet** below to your bookmarks bar
|
|
8
|
+
2. **Open any website** in your browser
|
|
9
|
+
3. **Click the bookmarklet** to inject the widget
|
|
10
|
+
4. **Use hj commands** to control the browser
|
|
11
|
+
|
|
12
|
+
## The Bookmarklet
|
|
13
|
+
|
|
14
|
+
Drag this to your bookmarks bar:
|
|
15
|
+
|
|
16
|
+
```bookmarklet
|
|
17
|
+
Haltija
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or copy this JavaScript URL manually:
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
javascript:(function(){var s=document.createElement('script');s.src='http://localhost:8700/inject.js';document.body.appendChild(s);})()
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## For Your AI Agent
|
|
27
|
+
|
|
28
|
+
Give your agent this prompt:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
I have Haltija running. Use the hj command to control my browser:
|
|
32
|
+
|
|
33
|
+
hj status # Check connection
|
|
34
|
+
hj tree # See page structure
|
|
35
|
+
hj click <ref> # Click by ref ID from tree
|
|
36
|
+
hj click "#selector" # Click by CSS selector
|
|
37
|
+
hj type <ref> "text" # Type into input
|
|
38
|
+
hj key Enter # Press keys
|
|
39
|
+
hj screenshot # Capture page
|
|
40
|
+
hj docs # Full command reference
|
|
41
|
+
|
|
42
|
+
Example workflow:
|
|
43
|
+
1. hj tree # See what's on page
|
|
44
|
+
2. hj click 42 # Click element with ref 42
|
|
45
|
+
3. hj type 15 "hello" # Type into input ref 15
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Commands
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Check status
|
|
52
|
+
hj status # Server running?
|
|
53
|
+
hj windows # Browser tabs connected?
|
|
54
|
+
|
|
55
|
+
# See the page
|
|
56
|
+
hj tree # DOM structure with ref IDs
|
|
57
|
+
hj tree -d 5 # Deeper tree
|
|
58
|
+
hj console # Browser console output
|
|
59
|
+
|
|
60
|
+
# Interact
|
|
61
|
+
hj click 42 # Click by ref
|
|
62
|
+
hj click "#submit" # Click by selector
|
|
63
|
+
hj type 10 "hello" # Type text
|
|
64
|
+
hj key Enter # Press key
|
|
65
|
+
hj key s --ctrl # Keyboard shortcut
|
|
66
|
+
|
|
67
|
+
# Navigate
|
|
68
|
+
hj navigate example.com
|
|
69
|
+
hj refresh
|
|
70
|
+
hj location
|
|
71
|
+
|
|
72
|
+
# Show the user
|
|
73
|
+
hj highlight 5 "Look here"
|
|
74
|
+
hj unhighlight
|
|
75
|
+
|
|
76
|
+
# Capture
|
|
77
|
+
hj screenshot
|
|
78
|
+
hj events # Recent activity
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Run `hj --help` for all commands, or `hj docs` for full reference.
|
|
82
|
+
|
|
83
|
+
## Troubleshooting
|
|
84
|
+
|
|
85
|
+
**Widget not appearing?**
|
|
86
|
+
- Some sites have strict CSP that blocks the widget
|
|
87
|
+
- Try the Haltija desktop app: `bunx haltija`
|
|
88
|
+
|
|
89
|
+
**Agent can't connect?**
|
|
90
|
+
- Click the bookmarklet after the page loads
|
|
91
|
+
- Check widget shows green status (connected)
|
|
92
|
+
- Run `hj status` to verify server
|
|
93
|
+
|
|
94
|
+
## REST API
|
|
95
|
+
|
|
96
|
+
For direct HTTP integration, see [REST-API.md](../REST-API.md).
|
package/docs/recipes.md
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# Haltija Recipes
|
|
2
|
+
|
|
3
|
+
Common workflows with copy-paste examples.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Testing a Login Flow
|
|
8
|
+
|
|
9
|
+
**Goal**: Verify login works end-to-end.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Navigate to login page
|
|
13
|
+
curl -X POST localhost:8700/navigate -d '{"url":"http://localhost:3000/login"}'
|
|
14
|
+
|
|
15
|
+
# See what's on the form
|
|
16
|
+
curl -X POST localhost:8700/tree -d '{"mode":"actionable"}'
|
|
17
|
+
|
|
18
|
+
# Fill credentials
|
|
19
|
+
curl -X POST localhost:8700/type -d '{"selector":"#email","text":"test@example.com"}'
|
|
20
|
+
curl -X POST localhost:8700/type -d '{"selector":"#password","text":"secret123"}'
|
|
21
|
+
|
|
22
|
+
# Submit
|
|
23
|
+
curl -X POST localhost:8700/click -d '{"selector":"button[type=submit]"}'
|
|
24
|
+
|
|
25
|
+
# Wait for redirect
|
|
26
|
+
curl -X POST localhost:8700/wait -d '{"selector":".dashboard","timeout":5000}'
|
|
27
|
+
|
|
28
|
+
# Verify we landed on dashboard
|
|
29
|
+
curl localhost:8700/location
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Or just tell the agent**: "Log in with test@example.com / secret123 and verify the dashboard loads"
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Exploring a New Codebase UI
|
|
37
|
+
|
|
38
|
+
**Goal**: Understand what's on the page without reading source code.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Get high-level structure
|
|
42
|
+
curl -X POST localhost:8700/tree -d '{"depth":2,"compact":true}'
|
|
43
|
+
|
|
44
|
+
# Find all interactive elements
|
|
45
|
+
curl -X POST localhost:8700/tree -d '{"mode":"actionable"}'
|
|
46
|
+
|
|
47
|
+
# Inspect a specific component
|
|
48
|
+
curl -X POST localhost:8700/inspect -d '{"selector":"nav","fullStyles":true}'
|
|
49
|
+
|
|
50
|
+
# See what CSS rules apply
|
|
51
|
+
curl -X POST localhost:8700/inspect -d '{"selector":".header","matchedRules":true}'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Or just tell the agent**: "What's on this page? Walk me through the main sections."
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Recording a Bug Reproduction
|
|
59
|
+
|
|
60
|
+
**Goal**: Capture steps to reproduce a bug for the team.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Start watching events
|
|
64
|
+
curl -X POST localhost:8700/events/watch -d '{"preset":"interactive"}'
|
|
65
|
+
|
|
66
|
+
# ... user reproduces the bug manually ...
|
|
67
|
+
|
|
68
|
+
# Get what happened
|
|
69
|
+
curl localhost:8700/events
|
|
70
|
+
|
|
71
|
+
# Take a screenshot of the broken state
|
|
72
|
+
curl -X POST localhost:8700/screenshot -d '{"scale":0.5}'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Output**: Semantic events like "user clicked Settings", "user typed 'admin'", "error: 500 from /api/users"
|
|
76
|
+
|
|
77
|
+
**Or just tell the agent**: "Watch what I do and write up repro steps"
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Generating Tests from Manual Exploration
|
|
82
|
+
|
|
83
|
+
**Goal**: Turn a manual walkthrough into an automated test.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Start recording
|
|
87
|
+
curl -X POST localhost:8700/recording/start -d '{"name":"checkout-flow"}'
|
|
88
|
+
|
|
89
|
+
# ... click around manually ...
|
|
90
|
+
|
|
91
|
+
# Stop and generate test
|
|
92
|
+
curl -X POST localhost:8700/recording/stop
|
|
93
|
+
curl -X POST localhost:8700/recording/generate -d '{"name":"checkout-flow"}'
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Output**: JSON test file ready for CI.
|
|
97
|
+
|
|
98
|
+
**Or just tell the agent**: "Watch me go through checkout, then write a test for it"
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Debugging a Customer Issue
|
|
103
|
+
|
|
104
|
+
**Goal**: See exactly what a customer described.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Navigate to where they were
|
|
108
|
+
curl -X POST localhost:8700/navigate -d '{"url":"https://app.example.com/settings"}'
|
|
109
|
+
|
|
110
|
+
# Get the current state
|
|
111
|
+
curl -X POST localhost:8700/tree -d '{"mode":"actionable"}'
|
|
112
|
+
|
|
113
|
+
# Check for errors
|
|
114
|
+
curl localhost:8700/events
|
|
115
|
+
|
|
116
|
+
# Highlight what might be wrong
|
|
117
|
+
curl -X POST localhost:8700/highlight -d '{"selector":".error-message","label":"This error"}'
|
|
118
|
+
|
|
119
|
+
# Screenshot for the ticket
|
|
120
|
+
curl -X POST localhost:8700/screenshot -d '{"maxWidth":1200}'
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Or just tell the agent**: "Customer says Settings page is broken. Check it out."
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Checking Accessibility
|
|
128
|
+
|
|
129
|
+
**Goal**: Audit a page for accessibility issues.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Get all interactive elements with ARIA info
|
|
133
|
+
curl -X POST localhost:8700/tree -d '{"mode":"actionable","depth":-1}'
|
|
134
|
+
|
|
135
|
+
# Inspect specific element for ARIA attributes
|
|
136
|
+
curl -X POST localhost:8700/inspect -d '{"selector":"button.icon-only"}'
|
|
137
|
+
|
|
138
|
+
# Check all buttons have accessible names
|
|
139
|
+
curl -X POST localhost:8700/find -d '{"selector":"button","text":""}'
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Look for**: Missing `aria-label`, buttons with only icons, form inputs without labels.
|
|
143
|
+
|
|
144
|
+
**Or just tell the agent**: "Check this page for accessibility issues"
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Multi-Tab Testing (OAuth, Admin/User)
|
|
149
|
+
|
|
150
|
+
**Goal**: Test flows that span multiple windows.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# See all connected tabs
|
|
154
|
+
curl localhost:8700/windows
|
|
155
|
+
|
|
156
|
+
# Returns: {"windows":[{"windowId":"abc","url":"..."},{"windowId":"def","url":"..."}]}
|
|
157
|
+
|
|
158
|
+
# Click in specific tab
|
|
159
|
+
curl -X POST "localhost:8700/click?window=abc" -d '{"selector":"#authorize"}'
|
|
160
|
+
|
|
161
|
+
# Check other tab updated
|
|
162
|
+
curl "localhost:8700/location?window=def"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Use case**: OAuth popups, admin + customer side-by-side, multi-tenant testing.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Waiting for Dynamic Content
|
|
170
|
+
|
|
171
|
+
**Goal**: Handle SPAs where content loads async.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# Wait for element to appear
|
|
175
|
+
curl -X POST localhost:8700/wait -d '{"selector":".results","timeout":10000}'
|
|
176
|
+
|
|
177
|
+
# Wait for element to disappear (loading spinner)
|
|
178
|
+
curl -X POST localhost:8700/wait -d '{"selector":".loading","appear":false}'
|
|
179
|
+
|
|
180
|
+
# Wait for text content
|
|
181
|
+
curl -X POST localhost:8700/wait -d '{"selector":".status","text":"Complete"}'
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Or just tell the agent**: "Click Search and wait for results to load"
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Pointing Things Out to Users
|
|
189
|
+
|
|
190
|
+
**Goal**: Show users what you're talking about.
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Highlight with label
|
|
194
|
+
curl -X POST localhost:8700/highlight -d '{"selector":"#save-btn","label":"Click here"}'
|
|
195
|
+
|
|
196
|
+
# Highlight problem area in red
|
|
197
|
+
curl -X POST localhost:8700/highlight -d '{"selector":".broken","label":"Bug","color":"#ef4444"}'
|
|
198
|
+
|
|
199
|
+
# Auto-dismiss after 3 seconds
|
|
200
|
+
curl -X POST localhost:8700/highlight -d '{"selector":"nav","duration":3000}'
|
|
201
|
+
|
|
202
|
+
# Clear highlight
|
|
203
|
+
curl -X POST localhost:8700/unhighlight
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Best practice**: Always highlight when explaining something visual.
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## User Selection (Point at Problem)
|
|
211
|
+
|
|
212
|
+
**Goal**: Let user show you what's wrong.
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# Start selection mode
|
|
216
|
+
curl -X POST localhost:8700/select/start
|
|
217
|
+
|
|
218
|
+
# ... user drags rectangle over problem area ...
|
|
219
|
+
|
|
220
|
+
# Get what they selected
|
|
221
|
+
curl localhost:8700/select/result
|
|
222
|
+
|
|
223
|
+
# Returns: elements in selection with selectors, HTML, bounding boxes
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**Or just tell the agent**: "Let me show you which element is broken"
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Quick Health Check
|
|
231
|
+
|
|
232
|
+
**Goal**: Verify Haltija is working.
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# Server running?
|
|
236
|
+
curl localhost:8700/status
|
|
237
|
+
|
|
238
|
+
# Browser connected?
|
|
239
|
+
curl localhost:8700/windows
|
|
240
|
+
|
|
241
|
+
# Can we see the page?
|
|
242
|
+
curl -X POST localhost:8700/tree -d '{"depth":1}'
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
If all three work, you're ready to go.
|