How tiann/hapi works
HAPI runs supported AI-agent sessions on a user’s machine and lets native and web clients control them remotely. The main workflow is to launch an agent through the CLI, synchronize its session through the hub, and view or act on it from a paired client; the README also documents handoff, approvals, files, workspace browsing, voice, and push. The graph preserves those product branches. Some subsystem links are documented capabilities rather than inspected call sites, so those edges are dashed with no evidence path.
Main entry points: server.ts Hub server · syncEngine.ts Session sync · App.tsx Web client · HapiApp.kt Native apps
Components 18
Agent runtime
- CLI launcher
cli/src/bootstrap.ts - Agent sessions
cli/src/agent/sessionFactory.ts - Remote terminal
cli/src/terminal/TerminalManager.ts
Hub and sync
- Hub server
hub/src/web/server.ts - Session sync
hub/src/sync/syncEngine.ts - Session store
hub/src/store/sessions.ts - Live events
hub/src/sse/sseManager.ts - Workspace browser
hub/src/tunnel/tunnelManager.ts
Remote clients
- Web client
web/src/App.tsx - Native apps
android/app/src/main/kotlin/app/hapi/companion/HapiApp.kt - Chat experience
android/app/src/main/kotlin/app/hapi/companion/feature/chat/ChatScreen.kt - Pairing
android/app/src/main/kotlin/app/hapi/companion/feature/pairing/PairingClient.kt - Files and sessions
android/app/src/main/kotlin/app/hapi/companion/feature/files/FilesGateway.kt - Push actions
android/app/src/main/kotlin/app/hapi/companion/fcm/HapiFirebaseMessagingService.kt
Connectivity
- Encrypted relay
relay/src/index.ts
Shared protocol
- Wire protocol
android/core/protocol/src/main/kotlin/app/hapi/protocol/wire/HapiJson.kt - Message windows
ios/Packages/HapiKit/Sources/HapiProtocol/Window/MessageWindowLogic.swift
Other components
- User
Connections 22
- User → CLI launcher: starts session
README.md - CLI launcher → Agent sessions: launches agent
README.md - Agent sessions → Hub server: syncs session
README.md - User → Web client: controls remotely
README.md - User → Native apps: controls remotely
README.md - Hub server → Session sync: routes sessions
- Session sync → Session store: stores sessions
hub/src/sync/syncEngine.ts - Session sync → Live events: publishes events
hub/src/sync/syncEngine.ts - Web client → Live events: receives updates
README.md - Native apps → Live events: receives updates
README.md - User → Pairing: pairs device
README.md - Pairing → Hub server: registers client
README.md - Web client → Chat experience: views sessions
README.md - Native apps → Chat experience: views sessions
README.md - Chat experience → Message windows: renders messages
- Web client → Files and sessions: browses files
README.md - User → Workspace browser: browses workspace
README.md - Remote terminal → Hub server: connects remotely
README.md - Hub server → Encrypted relay: uses relay
README.md - Native apps → Push actions: receives notifications
README.md - Session sync → Wire protocol: uses event format
hub/src/sync/syncEngine.ts - Wire protocol → Message windows: supplies messages