High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
refactor: rename /api/agent-sessions to /api/sessions
Boschb41d0e58de1b
diff --git a/cmd/pinchtab/cmd_cli_runtime.go b/cmd/pinchtab/cmd_cli_runtime.goindex 426b2d48..acf9b2af 100644--- a/cmd/pinchtab/cmd_cli_runtime.go+++ b/cmd/pinchtab/cmd_cli_runtime.go@@ -57,7 +57,6 @@ func resolveCLIBase(cfg *config.RuntimeConfig) string {}func resolveCLIToken(cfg *config.RuntimeConfig) string {- // PINCHTAB_SESSION takes precedence: use session authif sessionToken := os.Getenv("PINCHTAB_SESSION"); sessionToken != "" {return sessionToken}diff --git a/cmd/pinchtab/cmd_session.go b/cmd/pinchtab/cmd_session.goindex baec73e6..32a14695 100644--- a/cmd/pinchtab/cmd_session.go+++ b/cmd/pinchtab/cmd_session.go@@ -16,7 +16,7 @@ func init() {Short: "Show current agent session details",Run: func(cmd *cobra.Command, args []string) {runCLI(func(rt cliRuntime) {- apiclient.DoGet(rt.client, rt.base, rt.token, "/api/agent-sessions/me", nil)+ apiclient.DoGet(rt.client, rt.base, rt.token, "/api/sessions/me", nil)})},}diff --git a/dashboard/src/activities/ActivityPage.test.tsx b/dashboard/src/activities/ActivityPage.test.tsxindex 09f49085..75b0dedc 100644--- a/dashboard/src/activities/ActivityPage.test.tsx+++ b/dashboard/src/activities/ActivityPage.test.tsx@@ -11,11 +11,11 @@ vi.mock("./api", () => ({vi.mock("../services/api", () => ({fetchAllTabs: vi.fn(),- fetchAgentSessions: vi.fn(),+ fetchSessions: vi.fn(),}));import { fetchActivity } from "./api";-import { fetchAgentSessions, fetchAllTabs } from "../services/api";+import { fetchSessions, fetchAllTabs } from "../services/api";describe("ActivityPage", () => {beforeEach(() => {@@ -65,7 +65,7 @@ describe("ActivityPage", () => {],},});- vi.mocked(fetchAgentSessions).mockResolvedValue([]);+ vi.mocked(fetchSessions).mockResolvedValue([]);vi.mocked(fetchAllTabs).mockResolvedValue([{id: "tab_123",diff --git a/dashboard/src/activities/AgentActivityWorkspace.tsx b/dashboard/src/activities/AgentActivityWorkspace.tsxindex 898ec7e0..11b26b37 100644--- a/dashboard/src/activities/AgentActivityWorkspace.tsx+++ b/dashboard/src/activities/AgentActivityWorkspace.tsx@@ -164,7 +164,7 @@ export default function AgentActivityWorkspace({const [tabs, setTabs] = useState<InstanceTab[]>([]);const [activityLoading, setActivityLoading] = useState(false);const [agentLoading, setAgentLoading] = useState(false);- const [agentSessions, setAgentSessions] = useState<api.AgentSession[]>([]);+ const [agentSessions, setSessions] = useState<api.Session[]>([]);const [error, setError] = useState("");const [refreshNonce, setRefreshNonce] = useState(0);@@ -190,9 +190,9 @@ export default function AgentActivityWorkspace({useEffect(() => {let cancelled = false;void api- .fetchAgentSessions()+ .fetchSessions().then((sessions) => {- if (!cancelled) setAgentSessions(sessions);+ if (!cancelled) setSessions(sessions);}).catch(() => {});return () => {@@ -346,7 +346,7 @@ export default function AgentActivityWorkspace({? agentThreadEvents: visibleEvents;- const derivedSessions = useMemo<api.AgentSession[]>(() => {+ const derivedSessions = useMemo<api.Session[]>(() => {const bySession = new Map<string,{@@ -429,9 +429,9 @@ export default function AgentActivityWorkspace({let cancelled = false;const timer = setTimeout(() => {void api- .fetchAgentSessions()+ .fetchSessions().then((sessions) => {- if (!cancelled) setAgentSessions(sessions);+ if (!cancelled) setSessions(sessions);}).catch(() => {});}, 500);diff --git a/dashboard/src/activities/AgentStreamPanel.tsx b/dashboard/src/activities/AgentStreamPanel.tsxindex 56914366..7deff35f 100644--- a/dashboard/src/activities/AgentStreamPanel.tsx+++ b/dashboard/src/activities/AgentStreamPanel.tsx@@ -1,6 +1,6 @@import { useLayoutEffect, useRef } from "react";import { EmptyState } from "../components/atoms";-import type { AgentSession } from "../services/api";+import type { Session } from "../services/api";import ActiveFilterBar from "./ActiveFilterBar";import SessionDivider from "./SessionDivider";import StreamRow from "./StreamRow";@@ -9,7 +9,7 @@ import type { ActivityFilters, DashboardActivityEvent } from "./types";interface AgentStreamPanelProps {filters: ActivityFilters;events: DashboardActivityEvent[];- sessions?: AgentSession[];+ sessions?: Session[];summary: string;error: string;loading: boolean;diff --git a/dashboard/src/activities/AgentWorkspaceSidebar.tsx b/dashboard/src/activities/AgentWorkspaceSidebar.tsxindex ac17876f..2499870d 100644--- a/dashboard/src/activities/AgentWorkspaceSidebar.tsx+++ b/dashboard/src/activities/AgentWorkspaceSidebar.tsx@@ -1,7 +1,7 @@import { useMemo } from "react";import { AgentItem } from "../components/molecules";import type { Agent, Instance, InstanceTab, Profile } from "../types";-import type { AgentSession } from "../services/api";+import type { Session } from "../services/api";import ActivityFilterMenu from "./ActivityFilterMenu";import type { ActivityFilters } from "./types";@@ -12,7 +12,7 @@ interface AgentWorkspaceSidebarProps {visibleAgents: Agent[];activeAgentId: string;filters: ActivityFilters;- sessions: AgentSession[];+ sessions: Session[];showAllAgentsOption?: boolean;showAgentFilter?: boolean;profiles: Profile[];@@ -51,7 +51,7 @@ export default function AgentWorkspaceSidebar({onInstanceChange,}: AgentWorkspaceSidebarProps) {const sessionsByAgent = useMemo(() => {- const map = new Map<string, AgentSession[]>();+ const map = new Map<string, Session[]>();for (const session of sessions) {const agentId = session.agentId || "";if (!agentId) continue;diff --git a/dashboard/src/activities/AgentsPage.test.tsx b/dashboard/src/activities/AgentsPage.test.tsxindex 50c11def..7a3667f7 100644--- a/dashboard/src/activities/AgentsPage.test.tsx+++ b/dashboard/src/activities/AgentsPage.test.tsx@@ -12,11 +12,11 @@ vi.mock("./api", () => ({vi.mock("../services/api", () => ({fetchAllTabs: vi.fn(),fetchAgent: vi.fn(),- fetchAgentSessions: vi.fn(),+ fetchSessions: vi.fn(),}));import { fetchActivity } from "./api";-import { fetchAgent, fetchAgentSessions, fetchAllTabs } from "../services/api";+import { fetchAgent, fetchSessions, fetchAllTabs } from "../services/api";describe("AgentsPage", () => {beforeEach(() => {@@ -37,7 +37,7 @@ describe("AgentsPage", () => {currentTabs: {},});vi.mocked(fetchAllTabs).mockResolvedValue([]);- vi.mocked(fetchAgentSessions).mockResolvedValue([]);+ vi.mocked(fetchSessions).mockResolvedValue([]);vi.mocked(fetchAgent).mockResolvedValue({agent: {id: "cli",diff --git a/dashboard/src/activities/SessionDivider.tsx b/dashboard/src/activities/SessionDivider.tsxindex 3a4e3272..175f7f7b 100644--- a/dashboard/src/activities/SessionDivider.tsx+++ b/dashboard/src/activities/SessionDivider.tsx@@ -1,7 +1,7 @@-import type { AgentSession } from "../services/api";+import type { Session } from "../services/api";interface SessionDividerProps {- session?: AgentSession;+ session?: Session;sessionId: string;timestamp: string;}diff --git a/dashboard/src/components/molecules/AgentItem.tsx b/dashboard/src/components/molecules/AgentItem.tsxindex 0b886a1a..0d76d1a3 100644--- a/dashboard/src/components/molecules/AgentItem.tsx+++ b/dashboard/src/components/molecules/AgentItem.tsx@@ -1,10 +1,10 @@import type { Agent } from "../../types";-import type { AgentSession } from "../../services/api";+import type { Session } from "../../services/api";interface Props {agent: Agent;selected: boolean;- sessions: AgentSession[];+ sessions: Session[];activeSessionId?: string;onClick: (autoSessionId?: string) => void;onSelectSession: (sessionId: string) => void;@@ -27,7 +27,7 @@ function formatSessionTime(ts: string): string {});}-function sessionDisplayName(session: AgentSession): string {+function sessionDisplayName(session: Session): string {if (session.label) return session.label;const start = formatSessionTime(session.createdAt);const end = formatSessionTime(session.lastSeenAt || session.createdAt);diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.tsindex 2ebb82fa..5f59ec93 100644--- a/dashboard/src/services/api.ts+++ b/dashboard/src/services/api.ts@@ -288,7 +288,7 @@ export async function fetchAgents(): Promise<Agent[]> {return request<Agent[]>("/api/agents");}-export interface AgentSession {+export interface Session {id: string;agentId: string;label?: string;@@ -298,8 +298,8 @@ export interface AgentSession {status: string;}-export async function fetchAgentSessions(): Promise<AgentSession[]> {- return request<AgentSession[]>("/api/agent-sessions");+export async function fetchSessions(): Promise<Session[]> {+ return request<Session[]>("/api/sessions");}export async function fetchAgent(diff --git a/docs/guides/agent-identity.md b/docs/guides/agent-identity.mdindex 6281276c..bb4fc5fa 100644--- a/docs/guides/agent-identity.md+++ b/docs/guides/agent-identity.md@@ -79,7 +79,7 @@ Modes:### Create a Session```bash-curl -X POST http://localhost:9867/api/agent-sessions \+curl -X POST http://localhost:9867/api/sessions \-H "Authorization: Bearer $PINCHTAB_TOKEN" \-H "Content-Type: application/json" \-d '{"agentId": "bosch", "label": "research task"}'@@ -123,15 +123,15 @@ No need to set `--agent-id` — the session carries the agent identity.```bash# List all sessions-curl http://localhost:9867/api/agent-sessions \+curl http://localhost:9867/api/sessions \-H "Authorization: Bearer $PINCHTAB_TOKEN"# Rotate token (old token invalidated, new one returned)-curl -X POST http://localhost:9867/api/agent-sessions/ses_e6ac8132fe7e7016/rotate \+curl -X POST http://localhost:9867/api/sessions/ses_e6ac8132fe7e7016/rotate \-H "Authorization: Bearer $PINCHTAB_TOKEN"# Revoke-curl -X POST http://localhost:9867/api/agent-sessions/ses_e6ac8132fe7e7016/revoke \+curl -X POST http://localhost:9867/api/sessions/ses_e6ac8132fe7e7016/revoke \-H "Authorization: Bearer $PINCHTAB_TOKEN"```diff --git a/docs/reference/sessions.md b/docs/reference/sessions.mdindex 910159a7..11f90479 100644--- a/docs/reference/sessions.md+++ b/docs/reference/sessions.md@@ -36,10 +36,10 @@ In `config.json`:## Lifecycle-1. **Create** — via dashboard API: `POST /api/agent-sessions`+1. **Create** — via dashboard API: `POST /api/sessions`2. **Use** — agent sends `Authorization: Session ses_...` with each request-3. **Rotate** — generate a new token, old one invalidated: `POST /api/agent-sessions/{id}/rotate`-4. **Revoke** — permanently disable: `POST /api/agent-sessions/{id}/revoke`+3. **Rotate** — generate a new token, old one invalidated: `POST /api/sessions/{id}/rotate`+4. **Revoke** — permanently disable: `POST /api/sessions/{id}/revoke`## Securitydiff --git a/internal/dashboard/agent_session_api.go b/internal/dashboard/agent_session_api.goindex c1f4e23c..bb73ba55 100644--- a/internal/dashboard/agent_session_api.go+++ b/internal/dashboard/agent_session_api.go@@ -22,12 +22,12 @@ func NewAgentSessionAPI(store *agentsession.Store) *AgentSessionAPI {// RegisterHandlers registers agent session API routes.func (a *AgentSessionAPI) RegisterHandlers(mux *http.ServeMux) {- mux.HandleFunc("POST /api/agent-sessions", a.handleCreate)- mux.HandleFunc("GET /api/agent-sessions", a.handleList)- mux.HandleFunc("GET /api/agent-sessions/me", a.handleMe)- mux.HandleFunc("GET /api/agent-sessions/{id}", a.handleGet)- mux.HandleFunc("POST /api/agent-sessions/{id}/rotate", a.handleRotate)- mux.HandleFunc("POST /api/agent-sessions/{id}/revoke", a.handleRevoke)+ mux.HandleFunc("POST /api/sessions", a.handleCreate)+ mux.HandleFunc("GET /api/sessions", a.handleList)+ mux.HandleFunc("GET /api/sessions/me", a.handleMe)+ mux.HandleFunc("GET /api/sessions/{id}", a.handleGet)+ mux.HandleFunc("POST /api/sessions/{id}/rotate", a.handleRotate)+ mux.HandleFunc("POST /api/sessions/{id}/revoke", a.handleRevoke)}func (a *AgentSessionAPI) handleCreate(w http.ResponseWriter, r *http.Request) {diff --git a/internal/handlers/middleware.go b/internal/handlers/middleware.goindex e3b333f5..1482a3fa 100644--- a/internal/handlers/middleware.go+++ b/internal/handlers/middleware.go@@ -193,8 +193,8 @@ func cookieAuthAllowed(r *http.Request) bool {path == "/api/agents",path == "/api/events",path == "/api/config",- path == "/api/agent-sessions",- strings.HasPrefix(path, "/api/agent-sessions/"),+ path == "/api/sessions",+ strings.HasPrefix(path, "/api/sessions/"),path == "/profiles",path == "/instances",path == "/instances/tabs",@@ -214,9 +214,9 @@ func cookieAuthAllowed(r *http.Request) bool {switch {case path == "/api/auth/elevate":return true- case path == "/api/agent-sessions":+ case path == "/api/sessions":return true- case strings.HasPrefix(path, "/api/agent-sessions/"):+ case strings.HasPrefix(path, "/api/sessions/"):return truecase strings.HasPrefix(path, "/api/agents/") && strings.HasSuffix(path, "/events"):return truediff --git a/internal/profiles/profiles_test.go b/internal/profiles/profiles_test.goindex 513a145e..e69b9410 100644--- a/internal/profiles/profiles_test.go+++ b/internal/profiles/profiles_test.go@@ -309,7 +309,7 @@ func TestProfileManagerDelete(t *testing.T) {func TestProfileManagerLogsAndAnalyticsUseActivityRecorder(t *testing.T) {pm := NewProfileManager(t.TempDir())- store, err := activity.NewStore(t.TempDir(), 30*time.Minute, 1)+ store, err := activity.NewStore(t.TempDir(), 1)if err != nil {t.Fatalf("NewStore: %v", err)}diff --git a/internal/server/server.go b/internal/server/server.goindex 163759ed..e9cd928e 100644--- a/internal/server/server.go+++ b/internal/server/server.go@@ -76,7 +76,7 @@ func RunDashboard(cfg *config.RuntimeConfig, version string) {Mode: cfg.Sessions.Agent.Mode,IdleTimeout: cfg.Sessions.Agent.IdleTimeout,MaxLifetime: cfg.Sessions.Agent.MaxLifetime,- PersistPath: filepath.Join(cfg.StateDir, "agent-sessions.json"),+ PersistPath: filepath.Join(cfg.StateDir, "sessions.json"),})agentSessionAPI := dashboard.NewAgentSessionAPI(agentSessionStore)diff --git a/skills/pinchtab/SKILL.md b/skills/pinchtab/SKILL.mdindex 06ce7163..0f27a514 100644--- a/skills/pinchtab/SKILL.md+++ b/skills/pinchtab/SKILL.md@@ -258,7 +258,7 @@ curl -X POST http://localhost:9868/action \If the server is exposed beyond localhost, require a token and use a dedicated automation profile. See [TRUST.md](./TRUST.md).-**Agent sessions**: Instead of sharing the server bearer token, each agent can get its own revocable session token. Set `PINCHTAB_SESSION=ses_...` or send `Authorization: Session ses_...`. Create via `POST /api/agent-sessions` with `{"agentId":"...", "label":"..."}`. Sessions have idle timeout (default 12h) and max lifetime (default 24h). Manage with rotate (`POST /api/agent-sessions/{id}/rotate`) and revoke (`POST /api/agent-sessions/{id}/revoke`).+**Agent sessions**: Instead of sharing the server bearer token, each agent can get its own revocable session token. Set `PINCHTAB_SESSION=ses_...` or send `Authorization: Session ses_...`. Create via `POST /api/sessions` with `{"agentId":"...", "label":"..."}`. Sessions have idle timeout (default 12h) and max lifetime (default 24h). Manage with rotate (`POST /api/sessions/{id}/rotate`) and revoke (`POST /api/sessions/{id}/revoke`).## Essential Commandsdiff --git a/skills/pinchtab/references/api.md b/skills/pinchtab/references/api.mdindex 98c41870..618e9792 100644--- a/skills/pinchtab/references/api.md+++ b/skills/pinchtab/references/api.md@@ -450,17 +450,17 @@ curl /health```bash# Create agent session (requires bearer/cookie auth)-curl -X POST /api/agent-sessions -d '{"agentId":"my-agent","label":"dev"}'+curl -X POST /api/sessions -d '{"agentId":"my-agent","label":"dev"}'# List sessions-curl /api/agent-sessions+curl /api/sessions# Get current session (requires Session auth)-curl -H "Authorization: Session ses_..." /api/agent-sessions/me+curl -H "Authorization: Session ses_..." /api/sessions/me# Rotate token-curl -X POST /api/agent-sessions/{id}/rotate+curl -X POST /api/sessions/{id}/rotate# Revoke session-curl -X POST /api/agent-sessions/{id}/revoke+curl -X POST /api/sessions/{id}/revoke```