Overview
OpenCode mode integrates the OpenCode AI coding agent with HAPI through the Anthropic Code Plugins (ACP) protocol and OpenCode’s plugin hook system. Run OpenCode sessions with remote control via web and Telegram.OpenCode supports both local and remote modes. Local mode streams via OpenCode plugins.
Requirements
- OpenCode CLI installed (
opencodeon PATH) - HAPI CLI installed (
hapicommand available) - Authenticated with HAPI hub (
hapi auth login)
Starting a Session
Basic Usage
With Options
Available Flags
| Flag | Description |
|---|---|
--resume <sessionId> | Resume a specific OpenCode session |
--yolo | Bypass approval prompts |
--hapi-starting-mode | Set initial mode: local or remote |
--started-by | Internal flag for runner management |
Permission Modes
OpenCode supports these permission modes:Default
Standard behavior with approval prompts
Yolo
Bypass all approval prompts (use with caution)
shared/src/modes.ts:10-11 for mode definitions.
OpenCode currently supports a simplified permission model with
default and yolo modes.Session Modes
Local Mode
Full interactive experience from terminal:- Direct terminal interaction with OpenCode
- Streams via OpenCode plugins
- Real-time responses
- Messages from web/phone are queued
- Full plugin hook system available
Remote Mode
Control entirely from web/phone:- Session waits for messages from hub UI/Telegram
- No terminal interaction required
- Uses ACP protocol
- OpenCode plugin hooks available
Resume Functionality
OpenCode sessions can be resumed by session ID:- Check the web UI session list
- Use
hapi runner listto see active sessions - Session IDs are displayed when starting a session
ACP Integration
OpenCode integrates via the ACP (Anthropic Code Plugins) protocol:- Runs as an ACP-compatible agent
- Uses OpenCode’s plugin hook system
- Supports standard coding tools and operations
- Managed by the HAPI agent runner system
- See
cli/src/opencode/runOpencode.tsfor implementation
Plugin Hook System
OpenCode uses a plugin hook system for extensibility:- Hooks into OpenCode’s plugin architecture
- Streams events in local mode
- Integrates with HAPI’s remote control
- Supports custom plugin development
Examples
Start New Session
Resume Existing Session
Start in Remote Mode
Start with Yolo Mode
Integration
Once running, your OpenCode session appears in:- HAPI web app
- Telegram Mini App
- Monitor session activity in real-time
- Approve operations 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
Workflow
Local Mode Workflow
-
Start Session
-
Interact in Terminal
- Type your coding requests
- OpenCode responds interactively
- Approve operations as needed
-
Monitor in Web UI
- View session in web app
- See real-time updates
- Queue messages for later
Remote Mode Workflow
-
Start Session
-
Open Web UI
- Navigate to your HAPI hub URL
- Find the new OpenCode session
-
Send Messages
- Type your coding request
- OpenCode processes and responds
- Approve any required operations
-
Monitor Progress
- View real-time updates
- Check file changes
- Review diffs
Mode Switching
Switch between local and remote modes anytime:- From Local to Remote: Use the web UI to switch
- From Remote to Local: Rejoin the terminal session
Related Commands
OpenCode CLI
HAPI wraps the OpenCode CLI. For OpenCode-specific options:Source Reference
- Command implementation:
cli/src/commands/opencode.ts - Session runner:
cli/src/opencode/runOpencode.ts - Permission modes:
shared/src/modes.ts:10-11