surf-cli 2.4.2 → 2.5.1
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 +84 -6
- package/native/cli.cjs +521 -19
- package/native/do-executor.cjs +333 -73
- package/native/gemini-client.cjs +74 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -387,6 +387,9 @@ surf do 'go "https://example.com/login" | type "user@example.com" --selector "#e
|
|
|
387
387
|
# From JSON file
|
|
388
388
|
surf do --file workflow.json
|
|
389
389
|
|
|
390
|
+
# Run named workflow with arguments
|
|
391
|
+
surf do my-workflow --url "https://example.com" --max_items 10
|
|
392
|
+
|
|
390
393
|
# Validate without executing
|
|
391
394
|
surf do 'go "url" | click e5 | screenshot' --dry-run
|
|
392
395
|
```
|
|
@@ -400,25 +403,100 @@ surf do 'go "url" | click e5 | screenshot' --dry-run
|
|
|
400
403
|
- `--step-delay <ms>` - Delay between steps (default: 100, use 0 to disable)
|
|
401
404
|
- `--no-auto-wait` - Disable automatic waits between steps
|
|
402
405
|
- `--json` - Output structured JSON result
|
|
406
|
+
- `--<arg> <value>` - Pass arguments to workflow (e.g., `--url "..."`)
|
|
403
407
|
|
|
404
408
|
**Auto-waits:** Commands that trigger page changes automatically wait for completion:
|
|
405
409
|
- Navigation (`go`, `back`, `forward`) → waits for page load
|
|
406
410
|
- Clicks, key presses, form fills → waits for DOM stability
|
|
407
411
|
- Tab switches → waits for tab to load
|
|
408
412
|
|
|
409
|
-
|
|
413
|
+
#### Workflow Files
|
|
414
|
+
|
|
415
|
+
Workflows can be saved as JSON files and run by name. Place them in `~/.surf/workflows/` (user) or `./.surf/workflows/` (project).
|
|
416
|
+
|
|
417
|
+
**Basic format:**
|
|
410
418
|
```json
|
|
411
419
|
{
|
|
412
|
-
"name": "
|
|
420
|
+
"name": "login-flow",
|
|
421
|
+
"description": "Log into example.com",
|
|
422
|
+
"args": {
|
|
423
|
+
"email": { "required": true, "desc": "Login email" },
|
|
424
|
+
"password": { "required": true, "desc": "Login password" }
|
|
425
|
+
},
|
|
413
426
|
"steps": [
|
|
414
427
|
{ "tool": "navigate", "args": { "url": "https://example.com/login" } },
|
|
415
|
-
{ "tool": "type", "args": { "text": "
|
|
416
|
-
{ "tool": "
|
|
417
|
-
{ "tool": "
|
|
428
|
+
{ "tool": "type", "args": { "text": "%{email}", "selector": "input[name=email]" } },
|
|
429
|
+
{ "tool": "type", "args": { "text": "%{password}", "selector": "input[name=password]" } },
|
|
430
|
+
{ "tool": "click", "args": { "selector": "button[type=submit]" } }
|
|
431
|
+
]
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**Step outputs** - Capture results for use in later steps:
|
|
436
|
+
```json
|
|
437
|
+
{
|
|
438
|
+
"steps": [
|
|
439
|
+
{ "tool": "js", "args": { "code": "return document.title" }, "as": "title" },
|
|
440
|
+
{ "tool": "js", "args": { "code": "return 'Page: ' + '%{title}'" } }
|
|
441
|
+
]
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
**Loops** - `repeat` for fixed iterations, `each` for arrays:
|
|
446
|
+
```json
|
|
447
|
+
{
|
|
448
|
+
"steps": [
|
|
449
|
+
{ "tool": "js", "args": { "code": "return ['a', 'b', 'c']" }, "as": "items" },
|
|
450
|
+
{
|
|
451
|
+
"each": "%{items}",
|
|
452
|
+
"as": "item",
|
|
453
|
+
"steps": [
|
|
454
|
+
{ "tool": "js", "args": { "code": "return 'Processing: %{item}'" } }
|
|
455
|
+
]
|
|
456
|
+
}
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
```json
|
|
462
|
+
{
|
|
463
|
+
"steps": [
|
|
464
|
+
{
|
|
465
|
+
"repeat": 5,
|
|
466
|
+
"steps": [
|
|
467
|
+
{ "tool": "scroll", "args": { "direction": "down" } },
|
|
468
|
+
{ "tool": "wait", "args": { "duration": 500 } }
|
|
469
|
+
]
|
|
470
|
+
}
|
|
418
471
|
]
|
|
419
472
|
}
|
|
420
473
|
```
|
|
421
474
|
|
|
475
|
+
**Loop with exit condition** - Stop early when condition is met:
|
|
476
|
+
```json
|
|
477
|
+
{
|
|
478
|
+
"repeat": 20,
|
|
479
|
+
"until": { "tool": "js", "args": { "code": "return !document.querySelector('.next-page')" } },
|
|
480
|
+
"steps": [
|
|
481
|
+
{ "tool": "click", "args": { "selector": ".next-page" } },
|
|
482
|
+
{ "tool": "wait.load" }
|
|
483
|
+
]
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
#### Workflow Management
|
|
488
|
+
|
|
489
|
+
```bash
|
|
490
|
+
# List available workflows
|
|
491
|
+
surf workflow.list
|
|
492
|
+
|
|
493
|
+
# Show workflow details and arguments
|
|
494
|
+
surf workflow.info my-workflow
|
|
495
|
+
|
|
496
|
+
# Validate workflow JSON
|
|
497
|
+
surf workflow.validate ./my-workflow.json
|
|
498
|
+
```
|
|
499
|
+
|
|
422
500
|
**Supported commands:** All surf commands work in workflows. Use aliases (`go`, `snap`, `read`) or full names (`navigate`, `screenshot`, `page.read`).
|
|
423
501
|
|
|
424
502
|
## Global Options
|
|
@@ -484,7 +562,7 @@ echo '{"type":"tool_request","method":"execute_tool","params":{"tool":"tab.list"
|
|
|
484
562
|
|
|
485
563
|
| Group | Commands |
|
|
486
564
|
|-------|----------|
|
|
487
|
-
| `workflow` | `do` |
|
|
565
|
+
| `workflow` | `do`, `workflow.list`, `workflow.info`, `workflow.validate` |
|
|
488
566
|
| `window.*` | `new`, `list`, `focus`, `close`, `resize` |
|
|
489
567
|
| `tab.*` | `list`, `new`, `switch`, `close`, `name`, `unname`, `named`, `group`, `ungroup`, `groups`, `reload` |
|
|
490
568
|
| `scroll.*` | `top`, `bottom`, `to`, `info` |
|