feat: add session persistence, state management commands, and --new-tab click (#184)
Rebased and fixed implementation of PR #184 features on current main: Session persistence: - --session-name flag and AGENT_BROWSER_SESSION_NAME env var auto-save/restore cookies and localStorage across browser restarts - State files stored in ~/.agent-browser/sessions/ with owner-only permissions - AES-256-GCM encryption via AGENT_BROWSER_ENCRYPTION_KEY env var - Auto-expiration of old state files (AGENT_BROWSER_STATE_EXPIRE_DAYS, default 30) State management commands: - state list: list saved state files with metadata - state show <file>: display state summary (cookies, origins, domains) - state rename <old> <new>: rename state files - state clear [name] [--all]: clear saved states - state clean --older-than <days>: delete expired states New --new-tab flag for click command: - Opens link href in a new tab instead of navigating the current tab Security hardening: - Session name validation prevents path traversal (CLI + daemon) - safeHeaderMerge prevents prototype pollution in header merging - WebSocket stream server binds to 127.0.0.1 only - State files written with 0o600 permissions Fixes applied over the original PR: - Use color.rs module instead of hardcoded ANSI escape codes - Align CLI output field names with daemon response format - Add CLI-level --session-name validation (not just daemon-side) - Avoid adding "DOM" to tsconfig.json lib (use proper typing in evaluate) - Keep version at 0.9.3 (matches current main) - Centralize session name validation in daemon.ts helper - Update all documentation (README, SKILL.md, docs site, --help output) Co-authored-by: Chris Tate <chris@ctate.dev>
This commit is contained in:
co-authored by
Chris Tate
parent
cdd10ebb54
commit
697b788af0
@@ -31,6 +31,8 @@ export interface LaunchCommand extends BaseCommand {
|
||||
provider?: string;
|
||||
ignoreHTTPSErrors?: boolean;
|
||||
allowFileAccess?: boolean; // Enable file:// URL access and cross-origin file requests
|
||||
// Auto-load state file for session persistence
|
||||
autoStateFilePath?: string;
|
||||
}
|
||||
|
||||
export interface NavigateCommand extends BaseCommand {
|
||||
@@ -46,6 +48,7 @@ export interface ClickCommand extends BaseCommand {
|
||||
button?: 'left' | 'right' | 'middle';
|
||||
clickCount?: number;
|
||||
delay?: number;
|
||||
newTab?: boolean;
|
||||
}
|
||||
|
||||
export interface TypeCommand extends BaseCommand {
|
||||
@@ -597,6 +600,33 @@ export interface StorageStateLoadCommand extends BaseCommand {
|
||||
path: string;
|
||||
}
|
||||
|
||||
// State management commands (v2)
|
||||
export interface StateListCommand extends BaseCommand {
|
||||
action: 'state_list';
|
||||
}
|
||||
|
||||
export interface StateClearCommand extends BaseCommand {
|
||||
action: 'state_clear';
|
||||
sessionName?: string;
|
||||
all?: boolean;
|
||||
}
|
||||
|
||||
export interface StateShowCommand extends BaseCommand {
|
||||
action: 'state_show';
|
||||
filename: string;
|
||||
}
|
||||
|
||||
export interface StateCleanCommand extends BaseCommand {
|
||||
action: 'state_clean';
|
||||
days: number;
|
||||
}
|
||||
|
||||
export interface StateRenameCommand extends BaseCommand {
|
||||
action: 'state_rename';
|
||||
oldName: string;
|
||||
newName: string;
|
||||
}
|
||||
|
||||
// Console logs
|
||||
export interface ConsoleCommand extends BaseCommand {
|
||||
action: 'console';
|
||||
@@ -898,6 +928,11 @@ export type Command =
|
||||
| HarStopCommand
|
||||
| StorageStateSaveCommand
|
||||
| StorageStateLoadCommand
|
||||
| StateListCommand
|
||||
| StateClearCommand
|
||||
| StateShowCommand
|
||||
| StateCleanCommand
|
||||
| StateRenameCommand
|
||||
| ConsoleCommand
|
||||
| ErrorsCommand
|
||||
| KeyboardCommand
|
||||
|
||||
Reference in New Issue
Block a user