mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
Implements comprehensive token management with intelligent priority resolution. Token sources (highest to lowest priority): environment variable, settings file, interactive prompt. Changes include: - Updated home directory from ~/.happy to ~/.config/hapi (env var: HAPI_HOME_DIR) - Added cliApiToken field to Settings interface for persistent storage - Made cliApiToken mutable in Configuration class (private field with getter/setter) - Created ui/tokenInit.ts module for token initialization with fallback prompt - Enhanced auth command: login (interactive input), logout (clear token), status (show source) - Updated doctor command to correctly identify token source and mask saved token in output - Token initialization called early in startup flow to ensure availability before API use
hapi
Code on the go controlling Claude Code from your mobile device.
Free. Open source. Code anywhere.
Installation
npm install -g hapi
Usage
hapi
This will:
- Start a Claude Code session
- Register the session with your
hapi-serverinstance - Allow real-time session control from the Telegram Mini App
Commands
hapi auth– Manage authenticationhapi codex– Start Codex modehapi connect– Not available in direct-connect modehapi notify– Not available in direct-connect modehapi daemon– Manage background servicehapi doctor– System diagnostics & troubleshooting
Options
-h, --help- Show help-v, --version- Show version-m, --model <model>- Claude model to use (default: sonnet)-p, --permission-mode <mode>- Permission mode: auto, default, or plan--claude-env KEY=VALUE- Set environment variable for Claude Code--claude-arg ARG- Pass additional argument to Claude CLI
Environment Variables
HAPPY_BOT_URL- Bot URL (default: http://localhost:3006)CLI_API_TOKEN- Shared secret for bot authentication (required)HAPPY_HOME_DIR- Custom home directory for hapi data (default: ~/.happy)HAPPY_DISABLE_CAFFEINATE- Disable macOS sleep prevention (set totrue,1, oryes)HAPPY_EXPERIMENTAL- Enable experimental features (set totrue,1, oryes)
Requirements
- Node.js >= 20.0.0
- Required by
eventsource-parser@3.0.5, which is required by@modelcontextprotocol/sdk, which we used to implement permission forwarding to mobile app
- Required by
- Claude CLI installed & logged in (
claudecommand available in PATH)
License
MIT