Skip to content

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

breaking: rename /tab/lock → /lock, move server metrics to /api/metrics

Data4ebe738f1ead
diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.ts
index 5f59ec93..847fdfab 100644
--- a/dashboard/src/services/api.ts
+++ b/dashboard/src/services/api.ts
@@ -315,7 +315,9 @@ export async function fetchAgent(
}
export async function fetchServerMetrics(): Promise<MonitoringServerMetrics> {
- const res = await request<{ metrics: MonitoringServerMetrics }>("/metrics");
+ const res = await request<{ metrics: MonitoringServerMetrics }>(
+ "/api/metrics",
+ );
return res.metrics;
}
diff --git a/docs/endpoints.md b/docs/endpoints.md
index 4faa16a5..7c2d0b5a 100644
--- a/docs/endpoints.md
+++ b/docs/endpoints.md
@@ -10,6 +10,7 @@ POST /ensure-chrome
GET /openapi.json
GET /help (alias for /openapi.json)
GET /metrics
+GET /api/metrics
POST /shutdown
GET /api/events
```
@@ -18,7 +19,8 @@ Notes:
- in bridge mode, `/health` reports bridge health and tab count
- in full server mode, `/health` reports dashboard health, auth state, and instance count
-- `/metrics` in full server mode is a server metrics snapshot, not the bridge memory view
+- `/metrics` proxies to the bridge instance (per-instance runtime metrics)
+- `/api/metrics` in full server mode is a server-level metrics snapshot (aggregated)
## Dashboard Auth And Config
@@ -73,8 +75,8 @@ Important behavior:
## Tab Locking
```text
-POST /tab/lock
-POST /tab/unlock
+POST /lock
+POST /unlock
POST /tabs/{id}/lock
POST /tabs/{id}/unlock
```
diff --git a/docs/reference/tabs.md b/docs/reference/tabs.md
index f9891af7..003db277 100644
--- a/docs/reference/tabs.md
+++ b/docs/reference/tabs.md
@@ -212,7 +212,7 @@ curl -X POST http://localhost:9867/tabs/<tabId>/unlock \
-d '{"owner":"my-agent"}'
```
-There are also active-tab forms at `POST /tab/lock` and `POST /tab/unlock`.
+There are also active-tab forms at `POST /lock` and `POST /unlock`.
## Important Limits
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go
index dde8c426..d511ffd3 100644
--- a/internal/handlers/handlers.go
+++ b/internal/handlers/handlers.go
@@ -168,8 +168,8 @@ func (h *Handlers) RegisterRoutes(mux *http.ServeMux, doShutdown func()) {
mux.HandleFunc("POST /actions", h.HandleActions)
mux.HandleFunc("POST /macro", h.HandleMacro)
mux.HandleFunc("POST /tab", h.HandleTab)
- mux.HandleFunc("POST /tab/lock", h.HandleTabLock)
- mux.HandleFunc("POST /tab/unlock", h.HandleTabUnlock)
+ mux.HandleFunc("POST /lock", h.HandleTabLock)
+ mux.HandleFunc("POST /unlock", h.HandleTabUnlock)
mux.HandleFunc("POST /tabs/{id}/lock", h.HandleTabLockByID)
mux.HandleFunc("POST /tabs/{id}/unlock", h.HandleTabUnlockByID)
mux.HandleFunc("GET /tabs/{id}/cookies", h.HandleTabGetCookies)
diff --git a/internal/handlers/lock_shutdown_test.go b/internal/handlers/lock_shutdown_test.go
index 7f151c70..f233b1e5 100644
--- a/internal/handlers/lock_shutdown_test.go
+++ b/internal/handlers/lock_shutdown_test.go
@@ -19,7 +19,7 @@ func TestHandleTabLock(t *testing.T) {
body, _ := json.Marshal(map[string]any{"tabId": "t1", "owner": "agent-a", "timeoutSec": 10})
w := httptest.NewRecorder()
- r, _ := http.NewRequest("POST", "/tab/lock", bytes.NewReader(body))
+ r, _ := http.NewRequest("POST", "/lock", bytes.NewReader(body))
h.HandleTabLock(w, r)
if w.Code != 200 {
@@ -37,7 +37,7 @@ func TestHandleTabLock(t *testing.T) {
body, _ = json.Marshal(map[string]any{"tabId": "t1", "owner": "agent-b"})
w = httptest.NewRecorder()
- r, _ = http.NewRequest("POST", "/tab/lock", bytes.NewReader(body))
+ r, _ = http.NewRequest("POST", "/lock", bytes.NewReader(body))
h.HandleTabLock(w, r)
if w.Code != 409 {
@@ -52,7 +52,7 @@ func TestHandleTabUnlock(t *testing.T) {
body, _ := json.Marshal(map[string]any{"tabId": "t1", "owner": "agent-b"})
w := httptest.NewRecorder()
- r, _ := http.NewRequest("POST", "/tab/unlock", bytes.NewReader(body))
+ r, _ := http.NewRequest("POST", "/unlock", bytes.NewReader(body))
h.HandleTabUnlock(w, r)
if w.Code != 409 {
t.Fatalf("expected 409, got %d", w.Code)
@@ -60,7 +60,7 @@ func TestHandleTabUnlock(t *testing.T) {
body, _ = json.Marshal(map[string]any{"tabId": "t1", "owner": "agent-a"})
w = httptest.NewRecorder()
- r, _ = http.NewRequest("POST", "/tab/unlock", bytes.NewReader(body))
+ r, _ = http.NewRequest("POST", "/unlock", bytes.NewReader(body))
h.HandleTabUnlock(w, r)
if w.Code != 200 {
t.Fatalf("expected 200, got %d", w.Code)
@@ -73,7 +73,7 @@ func TestHandleTabLockValidation(t *testing.T) {
body, _ := json.Marshal(map[string]any{"tabId": "t1"})
w := httptest.NewRecorder()
- r, _ := http.NewRequest("POST", "/tab/lock", bytes.NewReader(body))
+ r, _ := http.NewRequest("POST", "/lock", bytes.NewReader(body))
h.HandleTabLock(w, r)
if w.Code != 400 {
t.Fatalf("expected 400, got %d", w.Code)
diff --git a/internal/handlers/middleware.go b/internal/handlers/middleware.go
index 1482a3fa..080c2acd 100644
--- a/internal/handlers/middleware.go
+++ b/internal/handlers/middleware.go
@@ -189,6 +189,7 @@ func cookieAuthAllowed(r *http.Request) bool {
switch {
case path == "/health",
path == "/metrics",
+ path == "/api/metrics",
path == "/api/activity",
path == "/api/agents",
path == "/api/events",
diff --git a/internal/routes/routes.go b/internal/routes/routes.go
index 600b0916..476a6153 100644
--- a/internal/routes/routes.go
+++ b/internal/routes/routes.go
@@ -66,13 +66,16 @@ var Core = []Endpoint{
// Tab management
{"POST", "/tab", "Open or switch tab", CapNone, false},
- {"POST", "/tab/lock", "Lock tab", CapNone, true},
- {"POST", "/tab/unlock", "Unlock tab", CapNone, true},
+ {"POST", "/lock", "Lock tab", CapNone, true},
+ {"POST", "/unlock", "Unlock tab", CapNone, true},
// Cookies
{"GET", "/cookies", "Get cookies", CapNone, true},
{"POST", "/cookies", "Set cookies", CapNone, true},
+ // Metrics
+ {"GET", "/metrics", "Runtime metrics", CapNone, true},
+
// Network
{"GET", "/network", "Network log", CapNone, true},
{"GET", "/network/stream", "Network SSE stream", CapNone, true},
diff --git a/internal/server/activity_recorder.go b/internal/server/activity_recorder.go
index a4d86449..369b092d 100644
--- a/internal/server/activity_recorder.go
+++ b/internal/server/activity_recorder.go
@@ -51,7 +51,7 @@ func shouldBroadcastDashboardActivity(evt activity.Event) bool {
return true
}
switch evt.Path {
- case "/health", "/tabs", "/metrics":
+ case "/health", "/tabs", "/metrics", "/api/metrics":
return false
default:
return true
diff --git a/internal/server/helpers.go b/internal/server/helpers.go
index 721fd553..8aa212a9 100644
--- a/internal/server/helpers.go
+++ b/internal/server/helpers.go
@@ -40,7 +40,7 @@ func RegisterDefaultProxyRoutes(mux *http.ServeMux, orch *orchestrator.Orchestra
proxyEndpoints := []string{
"GET /snapshot", "GET /screenshot", "GET /text",
"POST /navigate", "POST /action", "POST /actions", "POST /evaluate",
- "POST /tab", "POST /tab/lock", "POST /tab/unlock",
+ "POST /tab", "POST /lock", "POST /unlock",
"GET /cookies", "POST /cookies",
"GET /download", "POST /upload",
"GET /stealth/status", "POST /fingerprint/rotate",
diff --git a/internal/server/server.go b/internal/server/server.go
index e9cd928e..537097e0 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -218,7 +218,7 @@ func RunDashboard(cfg *config.RuntimeConfig, version string) {
}
mux.HandleFunc("GET /health", configAPI.HandleHealth)
- mux.HandleFunc("GET /metrics", func(w http.ResponseWriter, r *http.Request) {
+ mux.HandleFunc("GET /api/metrics", func(w http.ResponseWriter, r *http.Request) {
httpx.JSON(w, 200, map[string]any{"metrics": handlers.SnapshotMetrics()})
})
diff --git a/npm/src/index.ts b/npm/src/index.ts
index bb50e763..29f64420 100644
--- a/npm/src/index.ts
+++ b/npm/src/index.ts
@@ -141,14 +141,14 @@ export class Pinchtab {
* Lock a tab
*/
async lock(params: TabLockParams): Promise<void> {
- await this.request('/tab/lock', params);
+ await this.request('/lock', params);
}
/**
* Unlock a tab
*/
async unlock(params: TabUnlockParams): Promise<void> {
- await this.request('/tab/unlock', params);
+ await this.request('/unlock', params);
}
/**
diff --git a/skills/pinchtab/references/api.md b/skills/pinchtab/references/api.md
index 618e9792..dc03911a 100644
--- a/skills/pinchtab/references/api.md
+++ b/skills/pinchtab/references/api.md
@@ -325,11 +325,11 @@ These are equivalent to using `?tabId=TARGET_ID` on top-level endpoints but foll
```bash
# Lock a tab (default 30s timeout, max 5min)
-curl -X POST /tab/lock -H 'Content-Type: application/json' \
+curl -X POST /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' \
+curl -X POST /unlock -H 'Content-Type: application/json' \
-d '{"tabId": "TARGET_ID", "owner": "agent-1"}'
```
diff --git a/tests/e2e/scenarios-api/tabs-full.sh b/tests/e2e/scenarios-api/tabs-full.sh
index ff5e5586..00616ce5 100644
--- a/tests/e2e/scenarios-api/tabs-full.sh
+++ b/tests/e2e/scenarios-api/tabs-full.sh
@@ -246,12 +246,12 @@ start_test "tab lock: lock and unlock"
pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"
TAB_ID=$(get_tab_id)
-pt_post /tab/lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-agent\"}"
+pt_post /lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-agent\"}"
assert_ok "lock tab"
assert_json_eq "$RESULT" '.locked' 'true' "tab is locked"
assert_json_eq "$RESULT" '.owner' 'test-agent' "owner matches"
-pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-agent\"}"
+pt_post /unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-agent\"}"
assert_ok "unlock tab"
assert_json_eq "$RESULT" '.unlocked' 'true' "tab is unlocked"
@@ -263,13 +263,13 @@ start_test "tab lock: wrong owner cannot unlock"
pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"
TAB_ID=$(get_tab_id)
-pt_post /tab/lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-a\"}"
+pt_post /lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-a\"}"
assert_ok "lock tab"
-pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-b\"}"
+pt_post /unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-b\"}"
assert_not_ok "wrong owner rejected"
-pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-a\"}"
+pt_post /unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"agent-a\"}"
end_test
@@ -281,11 +281,11 @@ start_test "tab lock: lock with timeoutSec"
pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"
TAB_ID=$(get_tab_id)
-pt_post /tab/lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-ttl\",\"timeoutSec\":60}"
+pt_post /lock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-ttl\",\"timeoutSec\":60}"
assert_ok "lock with timeout"
assert_json_exists "$RESULT" '.expiresAt' "has expiration time"
-pt_post /tab/unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-ttl\"}"
+pt_post /unlock -d "{\"tabId\":\"${TAB_ID}\",\"owner\":\"test-ttl\"}"
end_test