Overview
HAPI supports Cursor Agent CLI for running Cursor’s AI coding agent with remote control via web and phone.Requirements
Install Cursor Agent CLI
Verify Installation
Make sure the
agent command is available on your PATH.Starting a Session
Basic Usage
With Options
Available Flags
| Flag | Description |
|---|---|
resume <chatId> | Resume a specific chat by ID |
--continue | Resume the most recent chat |
--resume <chatId> | Alternative resume syntax |
--mode <mode> | Set permission mode: plan or ask |
--plan | Start in Plan mode (shortcut) |
--yolo | Bypass approval prompts (uses --force) |
--force | Explicit force flag |
--model <model> | Specify which model to use |
--hapi-starting-mode | Set initial mode: local or remote |
Additional Cursor Agent flags are passed through. See Cursor CLI docs for all options.
Permission Modes
Cursor Agent supports these permission modes:Default
Standard agent behavior with approval prompts
Plan Mode
Design approach before implementing changes
Ask Mode
Explore code without making edits
Yolo
Bypass all approval prompts (use with caution)
--mode flag or change from the web UI during a session.
See shared/src/modes.ts:13-14 for mode definitions.
Session Modes
Local Mode
Full interactive experience from terminal:- Direct terminal interaction with Cursor Agent
- Real-time responses
- Full feature set available
- Messages from web/phone are queued
Remote Mode
Control entirely from web/phone:- Uses
agent -pwith--output-format stream-json - Includes
--trustflag for tool execution - Each message spawns one agent process
- Session continues via
--resume - No terminal interaction required
Resume Functionality
Cursor Agent has robust session resume capabilities:Finding Chat IDs
To list previous chats and get chat IDs:Examples
Start New Session
Start in Plan Mode
Start in Ask Mode
Resume Specific Chat
Resume Most Recent
Start with Yolo Mode
Specify Model
Integration
Once running, your Cursor Agent session appears in:- HAPI web app
- Telegram Mini App
- Monitor session activity in real-time
- Approve permissions from your phone
- Send messages to the agent
- Switch between local and remote modes
- Change permission modes on the fly
- View file changes and diffs
Limitations
Tool Approval in Remote Mode
In remote mode, the--trust flag is used, which means tools run without per-request approval. This is required for remote operation but reduces granular control.
Workaround: Use permission modes to control overall behavior:
default- Standard behaviorplan- Plan first, then implementask- Read-only explorationyolo- Full bypass (use carefully)
Session Resume
Cursor Agent sessions are chat-based. To resume:- Get the chat ID from
agent lsor the web UI - Pass it to
--resume <chatId>or--continue
Related Commands
External Resources
Source Reference
- Command implementation:
cli/src/commands/cursor.ts - Session runner:
cli/src/cursor/runCursor.ts - Permission modes:
shared/src/modes.ts:13-14 - User guide:
docs/guide/cursor.md