Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

refactor: cleaning up strategy

Luigi Agosti205022d0c190
diff --git a/internal/config/config_file.go b/internal/config/config_file.go
index 5d0b56ac..527d0e14 100644
--- a/internal/config/config_file.go
+++ b/internal/config/config_file.go
@@ -68,7 +68,7 @@ func DefaultFileConfig() FileConfig {
DefaultProfile: "default",
},
MultiInstance: MultiInstanceConfig{
- Strategy: "simple",
+ Strategy: "always-on",
AllocationPolicy: "fcfs",
InstancePortStart: &start,
InstancePortEnd: &end,
diff --git a/internal/config/config_file_test.go b/internal/config/config_file_test.go
index c0e01fbc..c762c720 100644
--- a/internal/config/config_file_test.go
+++ b/internal/config/config_file_test.go
@@ -16,8 +16,8 @@ func TestDefaultFileConfig(t *testing.T) {
if fc.InstanceDefaults.Mode != "headless" {
t.Errorf("DefaultFileConfig.InstanceDefaults.Mode = %v, want headless", fc.InstanceDefaults.Mode)
}
- if fc.MultiInstance.Strategy != "simple" {
- t.Errorf("DefaultFileConfig.MultiInstance.Strategy = %v, want simple", fc.MultiInstance.Strategy)
+ if fc.MultiInstance.Strategy != "always-on" {
+ t.Errorf("DefaultFileConfig.MultiInstance.Strategy = %v, want always-on", fc.MultiInstance.Strategy)
}
if len(fc.Security.Attach.AllowSchemes) != 2 || fc.Security.Attach.AllowSchemes[0] != "ws" || fc.Security.Attach.AllowSchemes[1] != "wss" {
t.Errorf("DefaultFileConfig.Security.Attach.AllowSchemes = %v, want [ws wss]", fc.Security.Attach.AllowSchemes)
diff --git a/internal/config/config_load.go b/internal/config/config_load.go
index 7ea7ac3d..ff432163 100644
--- a/internal/config/config_load.go
+++ b/internal/config/config_load.go
@@ -56,7 +56,7 @@ func Load() *RuntimeConfig {
WaitNavDelay: 1 * time.Second,
// Orchestrator defaults
- Strategy: "simple",
+ Strategy: "always-on",
AllocationPolicy: "fcfs",
RestartMaxRestarts: 20,
RestartInitBackoff: 2 * time.Second,
diff --git a/internal/config/config_load_test.go b/internal/config/config_load_test.go
index fabbb035..4fd59a46 100644
--- a/internal/config/config_load_test.go
+++ b/internal/config/config_load_test.go
@@ -59,8 +59,8 @@ func TestLoadConfigDefaults(t *testing.T) {
if cfg.AllowEvaluate {
t.Errorf("default AllowEvaluate = %v, want false", cfg.AllowEvaluate)
}
- if cfg.Strategy != "simple" {
- t.Errorf("default Strategy = %v, want simple", cfg.Strategy)
+ if cfg.Strategy != "always-on" {
+ t.Errorf("default Strategy = %v, want always-on", cfg.Strategy)
}
if cfg.AllocationPolicy != "fcfs" {
t.Errorf("default AllocationPolicy = %v, want fcfs", cfg.AllocationPolicy)
diff --git a/internal/config/config_types.go b/internal/config/config_types.go
index 984e6179..63127ec4 100644
--- a/internal/config/config_types.go
+++ b/internal/config/config_types.go
@@ -49,7 +49,7 @@ type RuntimeConfig struct {
WaitNavDelay time.Duration
// Orchestrator settings (dashboard mode only)
- Strategy string // "simple" (default), "explicit", or "simple-autorestart"
+ Strategy string // "always-on" (default), "simple", "explicit", or "simple-autorestart"
AllocationPolicy string // "fcfs" (default), "round_robin", "random"
RestartMaxRestarts int // Max restart attempts for restart-managed strategies (-1 = unlimited, 0 = strategy default)
RestartInitBackoff time.Duration // Initial restart backoff (0 = strategy default)
diff --git a/internal/server/server.go b/internal/server/server.go
index 68b163e7..eab11024 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -7,8 +7,6 @@ import (
"net/http"
"os"
"os/signal"
- "path/filepath"
- "strings"
"sync"
"syscall"
"time"
@@ -74,24 +72,27 @@ func RunDashboard(cfg *config.RuntimeConfig, version string) {
configAPI.RegisterHandlers(mux)
profMgr.RegisterHandlers(mux)
- var activeStrategy strategy.Strategy
- stratName := "manual"
- if cfg.Strategy != "" {
- strat, err := strategy.New(cfg.Strategy)
+ strategyName := cfg.Strategy
+ if strategyName == "" {
+ strategyName = "always-on"
+ }
+ activeStrategy, err := strategy.New(strategyName)
+ if err != nil {
+ slog.Warn("unknown strategy, falling back to always-on", "strategy", strategyName, "err", err)
+ activeStrategy, err = strategy.New("always-on")
if err != nil {
- slog.Warn("unknown strategy, falling back to default", "strategy", cfg.Strategy, "err", err)
- } else {
- if runtimeAware, ok := strat.(strategy.RuntimeConfigAware); ok {
- runtimeAware.SetRuntimeConfig(cfg)
- }
- if setter, ok := strat.(strategy.OrchestratorAware); ok {
- setter.SetOrchestrator(orch)
- }
- strat.RegisterRoutes(mux)
- activeStrategy = strat
- stratName = strat.Name()
+ slog.Error("failed to initialize fallback strategy", "strategy", "always-on", "err", err)
+ os.Exit(1)
}
}
+ if runtimeAware, ok := activeStrategy.(strategy.RuntimeConfigAware); ok {
+ runtimeAware.SetRuntimeConfig(cfg)
+ }
+ if setter, ok := activeStrategy.(strategy.OrchestratorAware); ok {
+ setter.SetOrchestrator(orch)
+ }
+ activeStrategy.RegisterRoutes(mux)
+ stratName := activeStrategy.Name()
allocPolicy := cfg.AllocationPolicy
if allocPolicy == "" {
@@ -121,11 +122,6 @@ func RunDashboard(cfg *config.RuntimeConfig, version string) {
slog.Info("orchestration", "strategy", stratName, "allocation", allocPolicy)
- if activeStrategy == nil {
- orch.RegisterHandlers(mux)
- RegisterDefaultProxyRoutes(mux, orch)
- }
-
var sched *scheduler.Scheduler
if cfg.Scheduler.Enabled {
schedCfg := scheduler.DefaultConfig()
@@ -176,59 +172,16 @@ func RunDashboard(cfg *config.RuntimeConfig, version string) {
IdleTimeout: 120 * time.Second,
}
- strategyHandlesLaunch := false
- if activeStrategy != nil {
- if err := activeStrategy.Start(context.Background()); err != nil {
- slog.Error("strategy start failed", "strategy", activeStrategy.Name(), "err", err)
- } else if launchAware, ok := activeStrategy.(strategy.LaunchAware); ok && launchAware.HandlesLaunch() {
- strategyHandlesLaunch = true
- }
- }
-
- autoLaunch := strings.EqualFold(os.Getenv("PINCHTAB_AUTO_LAUNCH"), "1") ||
- strings.EqualFold(os.Getenv("PINCHTAB_AUTO_LAUNCH"), "true") ||
- strings.EqualFold(os.Getenv("PINCHTAB_AUTO_LAUNCH"), "yes")
- if autoLaunch && !strategyHandlesLaunch {
- defaultProfile := os.Getenv("PINCHTAB_DEFAULT_PROFILE")
- defaultProfileExplicit := defaultProfile != ""
- defaultPort := os.Getenv("PINCHTAB_DEFAULT_PORT")
-
- go func() {
- time.Sleep(500 * time.Millisecond)
- profileToLaunch := defaultProfile
- if !defaultProfileExplicit {
- list, err := profMgr.List()
- if err != nil {
- slog.Warn("auto-launch profile list failed", "err", err)
- }
- if len(list) > 0 {
- profileToLaunch = list[0].Name
- } else {
- profileToLaunch = "default"
- if err := os.MkdirAll(filepath.Join(profilesDir, profileToLaunch, "Default"), 0755); err != nil {
- slog.Warn("failed to create auto-launch profile dir", "profile", profileToLaunch, "err", err)
- }
- }
- }
-
- headlessDefault := os.Getenv("PINCHTAB_HEADED") == ""
- inst, err := orch.Launch(profileToLaunch, defaultPort, headlessDefault, nil)
- if err != nil {
- slog.Warn("auto-launch failed", "profile", profileToLaunch, "err", err)
- return
- }
- slog.Info("auto-launched instance", "profile", profileToLaunch, "id", inst.ID, "port", inst.Port, "headless", headlessDefault)
- }()
+ if err := activeStrategy.Start(context.Background()); err != nil {
+ slog.Error("strategy start failed", "strategy", activeStrategy.Name(), "err", err)
}
shutdownOnce := &sync.Once{}
doShutdown := func() {
shutdownOnce.Do(func() {
slog.Info("shutting down dashboard...")
- if activeStrategy != nil {
- if err := activeStrategy.Stop(); err != nil {
- slog.Warn("strategy stop failed", "err", err)
- }
+ if err := activeStrategy.Stop(); err != nil {
+ slog.Warn("strategy stop failed", "err", err)
}
if sched != nil {
sched.Stop()
diff --git a/internal/strategy/autorestart/autorestart.go b/internal/strategy/autorestart/autorestart.go
index 579bd99a..f0dfd54f 100644
--- a/internal/strategy/autorestart/autorestart.go
+++ b/internal/strategy/autorestart/autorestart.go
@@ -38,8 +38,6 @@ const (
func init() {
// simple-autorestart uses autorestart defaults (MaxRestarts=3).
- // Both simple-autorestart and always-on implement HandlesLaunch()
- // via the shared Strategy type, suppressing dashboard auto-launch.
strategy.MustRegister("simple-autorestart", func() strategy.Strategy {
return New(AutorestartConfig{})
})
@@ -116,8 +114,7 @@ func New(cfg AutorestartConfig) *Strategy {
}
}
-func (s *Strategy) Name() string { return s.config.StrategyName }
-func (s *Strategy) HandlesLaunch() bool { return true }
+func (s *Strategy) Name() string { return s.config.StrategyName }
func (s *Strategy) SetRuntimeConfig(cfg *config.RuntimeConfig) {
if cfg == nil {
diff --git a/internal/strategy/explicit/explicit.go b/internal/strategy/explicit/explicit.go
index 3eff09cc..1ecdc558 100644
--- a/internal/strategy/explicit/explicit.go
+++ b/internal/strategy/explicit/explicit.go
@@ -26,8 +26,7 @@ type Strategy struct {
orch *orchestrator.Orchestrator
}
-func (s *Strategy) Name() string { return "explicit" }
-func (s *Strategy) HandlesLaunch() bool { return false }
+func (s *Strategy) Name() string { return "explicit" }
// SetOrchestrator injects the orchestrator after construction.
func (s *Strategy) SetOrchestrator(o *orchestrator.Orchestrator) {
diff --git a/internal/strategy/simple/simple.go b/internal/strategy/simple/simple.go
index 9795ccde..e84e9e6f 100644
--- a/internal/strategy/simple/simple.go
+++ b/internal/strategy/simple/simple.go
@@ -33,8 +33,7 @@ type Strategy struct {
orch *orchestrator.Orchestrator
}
-func (s *Strategy) Name() string { return "simple" }
-func (s *Strategy) HandlesLaunch() bool { return false }
+func (s *Strategy) Name() string { return "simple" }
// SetOrchestrator injects the orchestrator after construction.
func (s *Strategy) SetOrchestrator(o *orchestrator.Orchestrator) {
diff --git a/internal/strategy/strategy.go b/internal/strategy/strategy.go
index a7bce6b8..081f50eb 100644
--- a/internal/strategy/strategy.go
+++ b/internal/strategy/strategy.go
@@ -26,13 +26,6 @@ type OrchestratorAware interface {
SetOrchestrator(o *orchestrator.Orchestrator)
}
-// LaunchAware is implemented by strategies that manage instance startup
-// themselves and therefore should suppress the dashboard's separate
-// PINCHTAB_AUTO_LAUNCH fallback.
-type LaunchAware interface {
- HandlesLaunch() bool
-}
-
// RuntimeConfigAware is implemented by strategies that need access to
// runtime configuration at construction time.
type RuntimeConfigAware interface {
diff --git a/internal/strategy/strategy_test.go b/internal/strategy/strategy_test.go
index a9928b4a..dce8d031 100644
--- a/internal/strategy/strategy_test.go
+++ b/internal/strategy/strategy_test.go
@@ -90,26 +90,3 @@ func TestOrchestratorAware_AllStrategies(t *testing.T) {
}
}
}
-
-func TestLaunchAware_Strategies(t *testing.T) {
- tests := map[string]bool{
- "simple": false,
- "explicit": false,
- "simple-autorestart": true,
- "always-on": true,
- }
-
- for name, want := range tests {
- s, err := strategy.New(name)
- if err != nil {
- t.Fatalf("strategy %q not registered: %v", name, err)
- }
- launchAware, ok := s.(strategy.LaunchAware)
- if !ok {
- t.Fatalf("strategy %q does not implement LaunchAware", name)
- }
- if got := launchAware.HandlesLaunch(); got != want {
- t.Errorf("strategy %q HandlesLaunch=%v, want %v", name, got, want)
- }
- }
-}
diff --git a/skills/pinchtab/references/api.md b/skills/pinchtab/references/api.md
new file mode 100644
index 00000000..922ecd8b
--- /dev/null
+++ b/skills/pinchtab/references/api.md
@@ -0,0 +1,297 @@
+# Pinchtab API Reference
+
+Base URL for all examples: `http://localhost:9867`
+
+> **CLI alternative:** All endpoints have CLI equivalents. Use `pinchtab help` for the full list. Examples are shown as `# CLI:` comments below.
+
+## Navigate
+
+```bash
+# CLI: pinchtab nav https://pinchtab.com [--new-tab] [--block-images]
+curl -X POST /navigate \
+ -H 'Content-Type: application/json' \
+ -d '{"url": "https://pinchtab.com"}'
+
+# With options: custom timeout, block images, open in new tab
+curl -X POST /navigate \
+ -H 'Content-Type: application/json' \
+ -d '{"url": "https://pinchtab.com", "timeout": 60, "blockImages": true, "newTab": true}'
+```
+
+## Snapshot (accessibility tree)
+
+```bash
+# CLI: pinchtab snap [-i] [-c] [-d] [-s main] [--max-tokens 2000]
+# Full tree
+curl /snapshot
+
+# Interactive elements only (buttons, links, inputs) — much smaller
+curl "/snapshot?filter=interactive"
+
+# Limit depth
+curl "/snapshot?depth=5"
+
+# Smart diff — only changes since last snapshot (massive token savings)
+curl "/snapshot?diff=true"
+
+# Text format — indented tree, ~40-60% fewer tokens than JSON
+curl "/snapshot?format=text"
+
+# Compact format — one-line-per-node, 56-64% fewer tokens than JSON (recommended)
+curl "/snapshot?format=compact"
+
+# YAML format
+curl "/snapshot?format=yaml"
+
+# Scope to CSS selector (e.g. main content only)
+curl "/snapshot?selector=main"
+
+# Truncate to ~N tokens
+curl "/snapshot?maxTokens=2000"
+
+# Combine for maximum efficiency
+curl "/snapshot?format=compact&selector=main&maxTokens=2000&filter=interactive"
+
+# Disable animations before capture
+curl "/snapshot?noAnimations=true"
+
+# Write to file
+curl "/snapshot?output=file&path=/tmp/snapshot.json"
+```
+
+Returns flat JSON array of nodes with `ref`, `role`, `name`, `depth`, `value`, `nodeId`.
+
+**Token optimization**: Use `?format=compact` for best token efficiency. Add `?filter=interactive` for action-oriented tasks (~75% fewer nodes). Use `?selector=main` to scope to relevant content. Use `?maxTokens=2000` to cap output. Use `?diff=true` on multi-step workflows to see only changes. Combine all params freely.
+
+## Act on elements
+
+```bash
+# CLI: pinchtab click e5 / pinchtab type e12 hello / pinchtab press Enter
+# Click by ref
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "click", "ref": "e5"}'
+
+# Type into focused element (click first, then type)
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "click", "ref": "e12"}'
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "type", "ref": "e12", "text": "hello world"}'
+
+# Press a key
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "press", "key": "Enter"}'
+
+# Focus an element
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "focus", "ref": "e3"}'
+
+# Fill (set value directly, no keystrokes)
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "fill", "selector": "#email", "text": "[email protected]"}'
+
+# Hover (trigger dropdowns/tooltips)
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "hover", "ref": "e8"}'
+
+# Select dropdown option (by value or visible text)
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "select", "ref": "e10", "value": "option2"}'
+
+# Scroll to element
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "scroll", "ref": "e20"}'
+
+# Scroll by pixels (infinite scroll pages)
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "scroll", "scrollY": 800}'
+
+# Click and wait for navigation (link clicks)
+curl -X POST /action -H 'Content-Type: application/json' \
+ -d '{"kind": "click", "ref": "e5", "waitNav": true}'
+```
+
+## Batch actions
+
+```bash
+# Execute multiple actions in sequence
+curl -X POST /actions -H 'Content-Type: application/json' \
+ -d '{"actions":[{"kind":"click","ref":"e3"},{"kind":"type","ref":"e3","text":"hello"},{"kind":"press","key":"Enter"}]}'
+
+# Stop on first error (default: false)
+curl -X POST /actions -H 'Content-Type: application/json' \
+ -d '{"tabId":"TARGET_ID","actions":[...],"stopOnError":true}'
+```
+
+## Extract text
+
+```bash
+# CLI: pinchtab text [--raw]
+# Readability mode (default) — strips nav/footer/ads
+curl /text
+
+# Raw innerText
+curl "/text?mode=raw"
+```
+
+Returns `{url, title, text}`. Cheapest option (~1K tokens for most pages).
+
+## PDF export
+
+```bash
+# CLI: pinchtab pdf --tab TAB_ID [-o file.pdf] [--landscape] [--scale 0.8]
+# Returns base64 JSON
+curl "/tabs/TAB_ID/pdf"
+
+# Raw PDF bytes
+curl "/tabs/TAB_ID/pdf?raw=true" -o page.pdf
+
+# Save to disk
+curl "/tabs/TAB_ID/pdf?output=file&path=/tmp/page.pdf"
+
+# Landscape with custom scale
+curl "/tabs/TAB_ID/pdf?landscape=true&scale=0.8&raw=true" -o page.pdf
+
+# Custom paper size (Letter: 8.5x11, A4: 8.27x11.69)
+curl "/tabs/TAB_ID/pdf?paperWidth=8.5&paperHeight=11&marginTop=0.5&marginLeft=0.5&raw=true" -o custom.pdf
+
+# Export specific pages
+curl "/tabs/TAB_ID/pdf?pageRanges=1-5&raw=true" -o pages.pdf
+
+# With header/footer
+curl "/tabs/TAB_ID/pdf?displayHeaderFooter=true&headerTemplate=%3Cspan%20class=title%3E%3C/span%3E&raw=true" -o header.pdf
+
+# Accessible PDF with document outline
+curl "/tabs/TAB_ID/pdf?generateTaggedPDF=true&generateDocumentOutline=true&raw=true" -o accessible.pdf
+
+# Honor CSS page size
+curl "/tabs/TAB_ID/pdf?preferCSSPageSize=true&raw=true" -o css-sized.pdf
+```
+
+**Query Parameters:**
+
+| Param | Type | Default | Description |
+|-------|------|---------|-------------|
+| `paperWidth` | float | 8.5 | Paper width in inches |
+| `paperHeight` | float | 11.0 | Paper height in inches |
+| `landscape` | bool | false | Landscape orientation |
+| `marginTop` | float | 0.4 | Top margin in inches |
+| `marginBottom` | float | 0.4 | Bottom margin in inches |
+| `marginLeft` | float | 0.4 | Left margin in inches |
+| `marginRight` | float | 0.4 | Right margin in inches |
+| `scale` | float | 1.0 | Print scale (0.1–2.0) |
+| `pageRanges` | string | all | Pages to export (e.g., `1-3,5`) |
+| `displayHeaderFooter` | bool | false | Show header and footer |
+| `headerTemplate` | string | — | HTML template for header |
+| `footerTemplate` | string | — | HTML template for footer |
+| `preferCSSPageSize` | bool | false | Honor CSS `@page` size |
+| `generateTaggedPDF` | bool | false | Generate accessible/tagged PDF |
+| `generateDocumentOutline` | bool | false | Embed document outline |
+| `output` | string | JSON | `file` to save to disk, default returns base64 |
+| `path` | string | auto | Custom file path (with `output=file`) |
+| `raw` | bool | false | Return raw PDF bytes instead of JSON |
+
+Wraps `Page.printToPDF`. Prints background graphics by default.
+
+## Download files
+
+```bash
+# Returns base64 JSON by default (uses browser session/cookies/stealth)
+curl "/download?url=https://site.com/report.pdf"
+
+# Raw bytes (pipe to file)
+curl "/download?url=https://site.com/image.jpg&raw=true" -o image.jpg
+
+# Save directly to disk
+curl "/download?url=https://site.com/export.csv&output=file&path=/tmp/export.csv"
+```
+
+## Upload files
+
+```bash
+# Upload a local file to a file input
+curl -X POST "/upload?tabId=TAB_ID" -H "Content-Type: application/json" \
+ -d '{"selector": "input[type=file]", "paths": ["/tmp/photo.jpg"]}'
+
+# Upload base64-encoded data
+curl -X POST /upload -H "Content-Type: application/json" \
+ -d '{"selector": "#avatar-input", "files": ["data:image/png;base64,iVBOR..."]}'
+```
+
+Sets files on `<input type=file>` elements via CDP. Fires `change` events. Selector defaults to `input[type=file]` if omitted.
+
+## Screenshot
+
+```bash
+# CLI: pinchtab ss [-o file.jpg] [-q 80]
+curl "/screenshot?raw=true" -o screenshot.jpg
+curl "/screenshot?raw=true&quality=50" -o screenshot.jpg
+```
+
+## Evaluate JavaScript
+
+```bash
+# CLI: pinchtab eval "document.title"
+curl -X POST /evaluate -H 'Content-Type: application/json' \
+ -d '{"expression": "document.title"}'
+```
+
+## Tab management
+
+```bash
+# CLI: pinchtab tabs / pinchtab tabs new <url> / pinchtab tabs close <id>
+# List tabs
+curl /tabs
+
+# Open new tab
+curl -X POST /tab -H 'Content-Type: application/json' \
+ -d '{"action": "new", "url": "https://pinchtab.com"}'
+
+# Close tab
+curl -X POST /tab -H 'Content-Type: application/json' \
+ -d '{"action": "close", "tabId": "TARGET_ID"}'
+```
+
+Multi-tab: pass `?tabId=TARGET_ID` to snapshot/screenshot/text, or `"tabId"` in POST body.
+
+## Tab locking (multi-agent)
+
+```bash
+# Lock a tab (default 30s timeout, max 5min)
+curl -X POST /tab/lock -H 'Content-Type: application/json' \
+ -d '{"tabId": "TARGET_ID", "owner": "agent-1", "timeoutSec": 60}'
+
+# Unlock
+curl -X POST /tab/unlock -H 'Content-Type: application/json' \
+ -d '{"tabId": "TARGET_ID", "owner": "agent-1"}'
+```
+
+Locked tabs show `owner` and `lockedUntil` in `/tabs`. Returns 409 on conflict.
+
+## Cookies
+
+```bash
+# Get cookies for current page
+curl /cookies
+
+# Set cookies
+curl -X POST /cookies -H 'Content-Type: application/json' \
+ -d '{"url":"https://pinchtab.com","cookies":[{"name":"session","value":"abc123"}]}'
+```
+
+## Stealth
+
+```bash
+# Check stealth status and score
+curl /stealth/status
+
+# Rotate browser fingerprint
+curl -X POST /fingerprint/rotate -H 'Content-Type: application/json' \
+ -d '{"os":"windows"}'
+# os: "windows", "mac", or omit for random
+```
+
+## Health check
+
+```bash
+curl /health
+```
diff --git a/skills/pinchtab/references/profiles.md b/skills/pinchtab/references/profiles.md
new file mode 100644
index 00000000..8e4b54d1
--- /dev/null
+++ b/skills/pinchtab/references/profiles.md
@@ -0,0 +1,107 @@
+# Profile Management
+
+When running `pinchtab`, profiles are managed via the dashboard API on port 9867.
+
+## List profiles
+
+```bash
+curl http://localhost:9867/profiles
+```
+
+Returns array of profiles with `id`, `name`, `accountEmail`, `useWhen`, etc.
+
+## Start a profile
+
+```bash
+# Auto-allocate port (recommended)
+curl -X POST http://localhost:9867/profiles/<ID>/start
+
+# With specific port and headless mode
+curl -X POST http://localhost:9867/profiles/<ID>/start \
+ -H 'Content-Type: application/json' \
+ -d '{"port": "9868", "headless": true}'
+
+# Short alias
+curl -X POST http://localhost:9867/start/<ID>
+```
+
+Returns instance info including allocated `port`. Use that port for all subsequent API calls.
+
+## Stop a profile
+
+```bash
+curl -X POST http://localhost:9867/profiles/<ID>/stop
+
+# Short alias
+curl -X POST http://localhost:9867/stop/<ID>
+```
+
+## Check instance status
+
+```bash
+# By profile ID (recommended)
+curl http://localhost:9867/profiles/<ID>/instance
+
+# By profile name
+curl http://localhost:9867/profiles/My%20Profile/instance
+```
+
+## Launch by name
+
+```bash
+curl -X POST http://localhost:9867/instances/launch \
+ -H 'Content-Type: application/json' \
+ -d '{"name": "work", "port": "9868"}'
+```
+
+## CLI usage with profiles
+
+The CLI doesn't have profile subcommands yet — use `curl` for profile management.
+Once a profile instance is running, point the CLI at it:
+
+```bash
+# Get the instance port, then use CLI
+PINCHTAB_URL=http://localhost:9868 pinchtab snap -i
+```
+
+## Typical agent flow
+
+```bash
+# 1. List profiles
+PROFILES=$(curl -s http://localhost:9867/profiles)
+
+# 2. Start profile (auto-allocates port)
+INSTANCE=$(curl -s -X POST http://localhost:9867/profiles/$PROFILE_ID/start)
+PORT=$(echo $INSTANCE | jq -r .port)
+
+# 3. Use the instance
+curl -X POST http://localhost:$PORT/navigate -H 'Content-Type: application/json' \
+ -d '{"url": "https://mail.google.com"}'
+curl http://localhost:$PORT/snapshot?maxTokens=4000
+
+# 4. Stop when done
+curl -s -X POST http://localhost:9867/profiles/$PROFILE_ID/stop
+```
+
+## Profile IDs
+
+Each profile gets a stable 12-char hex ID (SHA-256 of name, truncated) stored in `profile.json`. IDs are URL-safe and never change — use them instead of names in automation.
+
+## Headed mode
+
+Headed mode = real visible Chrome window managed by Pinchtab.
+
+- Human can log in, pass 2FA/captcha, validate state
+- Agent calls HTTP APIs against the same running instance
+- Session state persists in profile directory (cookies/storage carry over)
+
+Recommended human + agent flow:
+
+```bash
+# Human starts dashboard and sets up profile
+pinchtab
+
+# Agent resolves the profile endpoint
+PINCHTAB_BASE_URL="$(pinchtab connect <profile-name>)"
+curl "$PINCHTAB_BASE_URL/health"
+```