# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: HAPI Hub
spec:
    description: HAPI Hub is the central coordinator for HAPI sessions, providing real-time sync and remote access.
    coverImage: https://hapi.run/docs/logo.svg
    icon: https://hapi.run/docs/logo.svg
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Domain
          description: '⚠️ IMPORTANT: Please enter the FULL domain including the suffix (e.g., my-hapi.zeabur.app), do NOT just enter the prefix.'
        - key: TELEGRAM_BOT_TOKEN
          type: STRING
          name: Telegram Bot Token (Optional)
          description: (Optional) Your Telegram Bot Token from @BotFather for notifications and Mini App. Leave blank if not needed.
    tags:
        - Tool
        - AI
    readme: |-
        # HAPI Hub

        [HAPI](https://hapi.run) is a powerful CLI and Hub that wraps AI agents (Claude Code, OpenAI Codex, Gemini, OpenCode).

        This template deploys a self-hosted **HAPI Hub**, which provides:
        - Session persistence
        - Permission management
        - Remote access and control
        - Telegram Bot integration (Optional)

        ### How to connect
        Once deployed, get your `CLI_API_TOKEN` from the service instructions, and set up your local terminal:

        ```bash
        export HAPI_API_URL="[https://your-domain.zeabur.app](https://your-domain.zeabur.app)"
        export CLI_API_TOKEN="your-token"
        hapi
        ```

        ### Telegram Integration
        If you provided a `TELEGRAM_BOT_TOKEN` during deployment, you can message your bot on Telegram with `/start`, open the Mini App, and enter your `CLI_API_TOKEN` to control sessions from your phone.
    services:
        - name: HAPI Hub
          icon: https://hapi.run/docs/logo.svg
          template: PREBUILT
          spec:
            id: hapi-hub
            source:
                image: node:24-slim
                command:
                    - sh
                    - -c
                    - npm install -g @twsxtd/hapi && hapi hub
            ports:
                - id: web
                  port: 3006
                  type: HTTP
            volumes:
                - id: data
                  dir: /data
            instructions:
                - title: Open HAPI Web App
                  content: https://${PUBLIC_DOMAIN}
                - title: CLI_API_TOKEN (Connection Key)
                  content: ${CLI_API_TOKEN}
            env:
                CLI_API_TOKEN:
                    default: ${PASSWORD}
                    expose: true
                HAPI_HOME:
                    default: /data
                HAPI_LISTEN_HOST:
                    default: 0.0.0.0
                HAPI_LISTEN_PORT:
                    default: "3006"
                HAPI_PUBLIC_URL:
                    default: https://${PUBLIC_DOMAIN}
          domainKey: PUBLIC_DOMAIN
