2.3 KiB
2.3 KiB
TASK METADATA
- Target Files:
server/db.tsserver/main.tsserver/auth-session.tsui/components/SessionsPage.tsxui/mod.tsserver/main.test.ts
- Core Objective: Implement frictionless Child Session Delegation with Agent Labeling, Scoped Permissions (read-only, operator, custom app grants), custom TTLs, and live observability cards.
- Dependencies:
server/auth-session.ts,server/db.ts,ui/components/SessionsPage.tsx - Additional Important Notes: Zero-dependency SDK compatibility; instant Valkey RESP3 push invalidation; progressive disclosure for advanced scope customization.
1. Architectural Considerations & Risks
- Security & Session Isolation:
- Child sessions must have isolated session IDs so revoking an agent session does not invalidate the user's primary interactive browser session.
- When custom scopes are defined,
getAuthenticatedUser(c)orAuthMiddlewareverifies that the requested action/app matches the session's permitted scope list.
- Progressive Disclosure UX:
- Default simple presets: Lifespan (
1h,12h,7d) and Access Mode (Read-Only,Operator,Full Admin). - Optional expandable drawer for granular app-level permissions.
- Default simple presets: Lifespan (
- Observability:
- Track
last_activity_atandlast_activity_actionfor real-time visibility in the session cards.
- Track
2. Proposed Implementation
- Database Schema & Migrations (
server/db.ts):- Add
label,is_agent,custom_scopes,last_activity_at,last_activity_actiontosessionstable.
- Add
- Backend API Endpoints (
server/main.ts):POST /api/sessions/delegate: Mints a child session with custom label, lifespan, and scopes.PUT /api/sessions/:id/scopes: Updates permissions on an active session.POST /api/sessions/:id/extend: Extends session TTL.
- UI Implementation (
ui/components/SessionsPage.tsx):- Add "Delegate Agent Session" top action and expandable modal.
- Hand-off card with 1-tap copy for token, CLI export, and cURL header.
- Distinct 🤖 Agent session cards with live countdown,
[Extend +1h],[Edit Scopes], and[Revoke].
- Automated Tests (
server/main.test.ts):- Verify delegation, custom scope restrictions, and extension.