surf-cli 2.2.0 → 2.4.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/README.md +125 -3
- package/dist/service-worker/index.js +11 -11
- package/dist/service-worker/index.js.map +1 -1
- package/native/chatgpt-client.cjs +29 -22
- package/native/cli.cjs +184 -3
- package/native/config.cjs +12 -0
- package/native/do-executor.cjs +273 -0
- package/native/do-parser.cjs +232 -0
- package/native/grok-client.cjs +906 -0
- package/native/host-helpers.cjs +58 -1
- package/native/host.cjs +198 -0
- package/native/perplexity-client.cjs +26 -22
- package/package.json +1 -1
- package/native/CHANGELOG.md +0 -136
- package/native/README.md +0 -141
package/README.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
<p>
|
|
2
|
+
<img src="surf-banner.png" alt="surf" width="1100">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# Surf
|
|
2
6
|
|
|
3
|
-
The CLI for AI agents to control Chrome. Zero config, agent-agnostic, battle-tested
|
|
7
|
+
**The CLI for AI agents to control Chrome. Zero config, agent-agnostic, battle-tested.**
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/surf-cli)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[]()
|
|
4
12
|
|
|
5
13
|
```bash
|
|
6
14
|
surf go "https://example.com"
|
|
@@ -23,7 +31,7 @@ Surf takes a different approach:
|
|
|
23
31
|
|
|
24
32
|
**Smart Defaults** - Screenshots auto-resize to 1200px (saves tokens). Actions auto-capture screenshots (saves round-trips). Errors on restricted pages warn instead of fail.
|
|
25
33
|
|
|
26
|
-
**AI Without API Keys** - Query ChatGPT, Gemini, and
|
|
34
|
+
**AI Without API Keys** - Query ChatGPT, Gemini, Perplexity, and Grok using your existing browser logins. No API keys needed.
|
|
27
35
|
|
|
28
36
|
**Network Capture** - Automatically logs all network requests while active. Filter, search, and replay API calls without manually setting up request interception.
|
|
29
37
|
|
|
@@ -298,9 +306,20 @@ surf perplexity "what is quantum computing"
|
|
|
298
306
|
surf perplexity "explain this page" --with-page # Include page context
|
|
299
307
|
surf perplexity "deep dive" --mode research # Research mode (Pro)
|
|
300
308
|
surf perplexity "latest news" --model sonar # Model selection (Pro)
|
|
309
|
+
|
|
310
|
+
# Grok (queries x.com/i/grok using your X.com login)
|
|
311
|
+
surf grok "what are the latest AI agent trends on X" # Search X posts
|
|
312
|
+
surf grok "analyze @username recent activity" # Profile analysis
|
|
313
|
+
surf grok "summarize this page" --with-page # Include page context
|
|
314
|
+
surf grok "find viral AI posts" --deep-search # DeepSearch mode
|
|
315
|
+
surf grok "quick question" --model fast # Models: auto, fast, expert, thinking
|
|
316
|
+
surf grok --validate # Check UI and available models
|
|
317
|
+
surf grok --validate --save-models # Save discovered models to settings
|
|
301
318
|
```
|
|
302
319
|
|
|
303
|
-
|
|
320
|
+
Each AI tool uses your existing browser login - no API keys needed. Just be logged into the respective service in Chrome (chatgpt.com, gemini.google.com, perplexity.ai, or x.com).
|
|
321
|
+
|
|
322
|
+
**Grok troubleshooting:** If queries fail, run `surf grok --validate` to check if the UI structure changed. Use `--save-models` to update the model cache in `surf.json`. Default model is "thinking" (Grok 4.1 Thinking).
|
|
304
323
|
|
|
305
324
|
### Waiting
|
|
306
325
|
|
|
@@ -354,6 +373,55 @@ surf network.stats # Capture statistics
|
|
|
354
373
|
Storage location: `/tmp/surf/` (override with `--network-path` or `SURF_NETWORK_PATH` env).
|
|
355
374
|
Auto-cleanup: 24 hours TTL, 200MB max.
|
|
356
375
|
|
|
376
|
+
### Workflows
|
|
377
|
+
|
|
378
|
+
Execute multi-step browser automation as a single command:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# Inline workflow (newline-separated commands)
|
|
382
|
+
surf do 'go "https://example.com/login"
|
|
383
|
+
type "user@example.com" --selector "input[name=email]"
|
|
384
|
+
type "password123" --selector "input[name=password]"
|
|
385
|
+
click --selector "button[type=submit]"
|
|
386
|
+
screenshot --output /tmp/after-login.png'
|
|
387
|
+
|
|
388
|
+
# From JSON file (same format as --script)
|
|
389
|
+
surf do --file login-workflow.json
|
|
390
|
+
|
|
391
|
+
# Validate without executing
|
|
392
|
+
surf do 'go "url"\nclick e5\nscreenshot' --dry-run
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Why workflows?** Instead of 6-8 separate CLI calls with LLM orchestration between each step, a workflow executes deterministically with smart auto-waits. Faster, cheaper, and more reliable.
|
|
396
|
+
|
|
397
|
+
**Options:**
|
|
398
|
+
- `--file`, `-f` - Load workflow from JSON file
|
|
399
|
+
- `--dry-run` - Parse and validate without executing
|
|
400
|
+
- `--on-error stop|continue` - Error handling (default: stop)
|
|
401
|
+
- `--step-delay <ms>` - Delay between steps (default: 100, use 0 to disable)
|
|
402
|
+
- `--no-auto-wait` - Disable automatic waits between steps
|
|
403
|
+
- `--json` - Output structured JSON result
|
|
404
|
+
|
|
405
|
+
**Auto-waits:** Commands that trigger page changes automatically wait for completion:
|
|
406
|
+
- Navigation (`go`, `back`, `forward`) → waits for page load
|
|
407
|
+
- Clicks, key presses, form fills → waits for DOM stability
|
|
408
|
+
- Tab switches → waits for tab to load
|
|
409
|
+
|
|
410
|
+
**JSON file format:**
|
|
411
|
+
```json
|
|
412
|
+
{
|
|
413
|
+
"name": "Login Flow",
|
|
414
|
+
"steps": [
|
|
415
|
+
{ "tool": "navigate", "args": { "url": "https://example.com/login" } },
|
|
416
|
+
{ "tool": "type", "args": { "text": "user@example.com", "selector": "input[name=email]" } },
|
|
417
|
+
{ "tool": "click", "args": { "selector": "button[type=submit]" } },
|
|
418
|
+
{ "tool": "screenshot", "args": {} }
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
**Supported commands:** All surf commands work in workflows. Use aliases (`go`, `snap`, `read`) or full names (`navigate`, `screenshot`, `page.read`).
|
|
424
|
+
|
|
357
425
|
## Global Options
|
|
358
426
|
|
|
359
427
|
```bash
|
|
@@ -374,10 +442,50 @@ For programmatic integration, send JSON to `/tmp/surf.sock`:
|
|
|
374
442
|
echo '{"type":"tool_request","method":"execute_tool","params":{"tool":"tab.list","args":{}},"id":"1"}' | nc -U /tmp/surf.sock
|
|
375
443
|
```
|
|
376
444
|
|
|
445
|
+
### Protocol Reference
|
|
446
|
+
|
|
447
|
+
**Request:**
|
|
448
|
+
```json
|
|
449
|
+
{
|
|
450
|
+
"type": "tool_request",
|
|
451
|
+
"method": "execute_tool",
|
|
452
|
+
"params": {
|
|
453
|
+
"tool": "click",
|
|
454
|
+
"args": { "ref": "e5" }
|
|
455
|
+
},
|
|
456
|
+
"id": "unique-request-id",
|
|
457
|
+
"tabId": 123,
|
|
458
|
+
"windowId": 456
|
|
459
|
+
}
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
**Success Response:**
|
|
463
|
+
```json
|
|
464
|
+
{
|
|
465
|
+
"type": "tool_response",
|
|
466
|
+
"id": "unique-request-id",
|
|
467
|
+
"result": {
|
|
468
|
+
"content": [{ "type": "text", "text": "Result message" }]
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
**Error Response:**
|
|
474
|
+
```json
|
|
475
|
+
{
|
|
476
|
+
"type": "tool_response",
|
|
477
|
+
"id": "unique-request-id",
|
|
478
|
+
"error": {
|
|
479
|
+
"content": [{ "type": "text", "text": "Error message" }]
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
```
|
|
483
|
+
|
|
377
484
|
## Command Groups
|
|
378
485
|
|
|
379
486
|
| Group | Commands |
|
|
380
487
|
|-------|----------|
|
|
488
|
+
| `workflow` | `do` |
|
|
381
489
|
| `window.*` | `new`, `list`, `focus`, `close`, `resize` |
|
|
382
490
|
| `tab.*` | `list`, `new`, `switch`, `close`, `name`, `unname`, `named`, `group`, `ungroup`, `groups`, `reload` |
|
|
383
491
|
| `scroll.*` | `top`, `bottom`, `to`, `info` |
|
|
@@ -438,6 +546,20 @@ surf install <extension-id> --browser chromium
|
|
|
438
546
|
- Screenshot resize uses ImageMagick instead of macOS `sips`
|
|
439
547
|
- Headless servers need Xvfb + VNC for initial login setup
|
|
440
548
|
|
|
549
|
+
## AI Agent Integration
|
|
550
|
+
|
|
551
|
+
Surf includes a skill file for AI coding agents like [Pi](https://github.com/badlogic/pi-mono):
|
|
552
|
+
|
|
553
|
+
```bash
|
|
554
|
+
# Symlink for auto-updates
|
|
555
|
+
ln -s "$(pwd)/skills/surf" ~/.pi/agent/skills/surf
|
|
556
|
+
|
|
557
|
+
# Or copy
|
|
558
|
+
cp -r skills/surf ~/.pi/agent/skills/
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
See [`skills/README.md`](skills/README.md) for details.
|
|
562
|
+
|
|
441
563
|
## Development
|
|
442
564
|
|
|
443
565
|
```bash
|