# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: OpenAB Gemini
spec:
    description: |
        Open Agent Broker — a lightweight Rust harness that bridges Discord to any ACP-compatible coding CLI (Claude Code, Codex, Gemini, Kiro, Cursor) over stdio JSON-RPC. This template deploys the Gemini variant.
        Source: https://github.com/openabdev/openab
    coverImage: https://cdn-console.zeabur.com/f/Xp0H6/openab-cover.webp
    icon: https://cdn-console.zeabur.com/f/0Ewi6/openab-icon.webp
    variables:
        - key: DISCORD_BOT_TOKEN
          type: STRING
          name: Discord Bot Token
          description: Token from https://discord.com/developers/applications
        - key: GEMINI_API_KEY
          type: STRING
          name: Gemini API Key (optional)
          description: Optional. API key from https://aistudio.google.com/apikey. Leave empty to authenticate via Vertex AI or a personal Google account login — see readme for details.
        - key: OPENAB_ALLOWED_CHANNELS
          type: STRING
          name: Discord Channel IDs (optional)
          description: 'Optional. Comma-separated Discord channel IDs where the bot listens. Leave empty to allow all channels. Example: 123456789012345678,234567890123456789'
        - key: OPENAB_ALLOWED_USERS
          type: STRING
          name: Discord User IDs (optional)
          description: Optional. Comma-separated Discord user IDs allowed to interact with the bot. Leave empty to allow everyone in the allowed channels.
        - key: SLACK_BOT_TOKEN
          type: STRING
          name: Slack Bot Token (optional)
          description: Optional. Bot User OAuth Token (xoxb-...) from Slack App settings. Leave empty to disable Slack adapter.
        - key: SLACK_APP_TOKEN
          type: STRING
          name: Slack App Token (optional)
          description: Optional. App-Level Token (xapp-...) for Socket Mode. Required when Slack Bot Token is set.
        - key: OPENAB_AGENT_COMMAND
          type: STRING
          name: Agent Command (optional)
          description: 'Optional. Override the agent CLI command (default: gemini). Only change if you know what you''re doing.'
        - key: OPENAB_CONFIG_URL
          type: STRING
          name: Config URL (optional)
          description: Optional. URL to a remote config.toml (https://). When set, the local config file is ignored and this URL is used instead.
    tags:
        - AI
        - Developer Tools
        - Discord
    readme: |
        # OpenAB Gemini

        [OpenAB](https://github.com/openabdev/openab) is a lightweight, open-source Rust harness that bridges Discord to any [Agent Client Protocol](https://github.com/anthropics/agent-protocol)-compatible coding CLI over stdio JSON-RPC.

        This template deploys the Gemini variant (`openab-gemini`) which uses `gemini --acp` as the agent backend.

        ## Important Notes

        - **Image tag:** This template uses the floating `beta` tag and auto-updates with each new beta release. Switch to `stable` for production use. To pin a specific version, change the image tag in Zeabur Dashboard -> Service -> Settings. Available tags: [GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab).
        - **Persistent storage:** `/home/node` is mounted as a persistent volume. Plugins, settings, config, and credentials survive restarts.

        ## Setup

        ### 1. Get a Discord Bot Token

        1. Go to https://discord.com/developers/applications and click **New Application**
        2. Navigate to **Bot** tab -> click **Reset Token** -> copy the token
        3. On the same page, scroll down and enable **Message Content Intent** under Privileged Gateway Intents
        4. Go to **OAuth2 -> URL Generator** -> check scope `bot` -> check permissions: Send Messages, Send Messages in Threads, Create Public Threads, Read Message History, Add Reactions, Manage Messages
        5. Copy the generated URL and open it in your browser to invite the bot to your server

        ### 2. Authenticate

        **Quickest:** fill in the `GEMINI_API_KEY` template variable at deploy time and you're done.

        **Otherwise:** after deployment, open Zeabur Dashboard → Service → Exec and run:

        ```
        runuser -u node -- gemini
        ```

        Follow the on-screen prompts to pick and complete an auth method. Credentials are saved on the persistent volume; new conversations apply the new auth automatically — no restart needed.

        > **Wiring API keys to the agent:** openab spawns the agent with `env_clear()`, so the `GEMINI_API_KEY` path requires an env allowlist. After first boot edit `/home/node/.config/openab/config.toml` and add under `[agent]`:
        >
        > ```toml
        > [agent]
        > inherit_env = ["GEMINI_API_KEY", "GOOGLE_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"]
        > ```
        >
        > Interactive login needs no edit — credentials live in `~/.gemini/`.

        ### 3. Get Discord Channel IDs

        1. Open Discord -> go to **User Settings** (gear icon) -> **Advanced** -> enable **Developer Mode**
        2. Right-click the channel where you want the bot to respond -> **Copy Channel ID**
        3. For multiple channels, separate IDs with commas: `123456789012345678,234567890123456789`

        ### 4. Deploy

        Fill in the template variables and click deploy. The service connects to Discord automatically.

        ## Add Messaging Platforms (Telegram / LINE / Feishu / Google Chat / MS Teams / WeCom)

        For Telegram, deploy the [OpenAB Telegram template](https://zeabur.com/templates/12LLKI) and switch its image tag to `beta-gemini` with the matching `OPENAB_AGENT_COMMAND`. Other platforms are enabled by environment variables in unified mode (`LINE_CHANNEL_SECRET`, `FEISHU_APP_ID`, `GOOGLE_CHAT_ENABLED=true`, `TEAMS_APP_ID`, `WECOM_CORP_ID`) — see the [OpenAB docs](https://github.com/openabdev/openab/tree/main/docs). Webhook platforms need a public HTTPS domain on the service (port 8080); Feishu connects outbound via WebSocket and needs no domain.

        ## Usage

        - **@mention the bot** in an allowed channel to start a conversation
        - OpenAB creates a **thread** for multi-turn conversations -- no @mention needed for follow-ups
        - Each thread maps to a persistent Gemini session (24h TTL)

        ## Customization

        | File | Description |
        |------|-------------|
        | `/home/node/.config/openab/config.toml` | OpenAB config (sessions, reactions, STT, etc.) |

        `config.toml` is created from a built-in template on first boot. After that, edit the file directly -- environment variables are only used for initial setup. To reset to defaults, delete the file and restart: `rm /home/node/.config/openab/config.toml`

        For config options, see the [OpenAB documentation](https://github.com/openabdev/openab).

        ## Webhook / Bot Integration

        By default, openab ignores messages from other bots and webhooks. To allow webhook-triggered messages (e.g. automated testing or CI pipelines), add the following to your `config.toml`:

        ```toml
        [discord]
        allow_bot_messages = "mentions"
        ```

        With this setting, openab responds to any bot or webhook message that @mentions it. To restrict to a specific webhook, also add:

        ```toml
        trusted_bot_ids = ["YOUR_WEBHOOK_USER_ID"]
        ```

        The webhook user ID is the numeric ID in the webhook URL: `https://discord.com/api/webhooks/<ID>/...`

        ## Disabling

        Leave `Discord Bot Token` empty. The service sleeps instead of crashing.

        ## Links

        - [OpenAB GitHub](https://github.com/openabdev/openab)
        - [Agent Client Protocol](https://github.com/anthropics/agent-protocol)
        - [Google AI Studio](https://aistudio.google.com/)
    resourceRequirement:
        minConfig:
            cpu: 2
            ram: 4
        recommendedConfig:
            cpu: 4
            ram: 8
    services:
        - name: openab
          icon: https://cdn-console.zeabur.com/f/0Ewi6/openab-icon.webp
          template: PREBUILT_V2
          spec:
            id: openab
            source:
                image: ghcr.io/openabdev/openab:beta-gemini
                command:
                    - /bin/sh
                    - -c
                    - /opt/start-openab.sh
                runAsUserID: 1000
            volumes:
                - id: node-home
                  dir: /home/node
            env:
                DISCORD_BOT_TOKEN:
                    default: ${DISCORD_BOT_TOKEN}
                GEMINI_API_KEY:
                    default: ${GEMINI_API_KEY}
                OPENAB_AGENT_COMMAND:
                    default: gemini
                OPENAB_ALLOWED_CHANNELS:
                    default: ""
                OPENAB_ALLOWED_USERS:
                    default: ""
                OPENAB_CONFIG_URL:
                    default: ""
                SLACK_APP_TOKEN:
                    default: ""
                SLACK_BOT_TOKEN:
                    default: ""
            configs:
                - path: /opt/start-openab.sh
                  template: |
                    #!/bin/sh
                    set -e

                    # Initialize shell config on first boot (volume is empty)
                    if [ ! -f /home/node/.bashrc ]; then
                      cp /etc/skel/.bashrc /etc/skel/.profile /etc/skel/.bash_logout /home/node/ 2>/dev/null || true
                    fi

                    # Fix ownership for persistent volume when startup runs as root
                    if [ "$(id -u)" = "0" ]; then
                      chown -R node:node /home/node
                      chmod 755 /home/node/.config 2>/dev/null || true
                    fi

                    if [ -z "$DISCORD_BOT_TOKEN" ] && [ -z "$SLACK_BOT_TOKEN" ]; then
                      echo "openab: neither DISCORD_BOT_TOKEN nor SLACK_BOT_TOKEN set — sleeping"
                      exec sleep infinity
                    fi

                    CONFIG_DIR=/home/node/.config/openab
                    CONFIG_FILE=$CONFIG_DIR/config.toml
                    mkdir -p "$CONFIG_DIR"

                    # Generate config.toml on first boot only
                    # To regenerate, delete the file and restart
                    if [ ! -f "$CONFIG_FILE" ]; then
                      cp /opt/config.toml.template "$CONFIG_FILE"

                      # Add [discord] section if token provided
                      if [ -n "$DISCORD_BOT_TOKEN" ]; then
                        printf '\n[discord]\nbot_token = "${DISCORD_BOT_TOKEN}"\n' >> "$CONFIG_FILE"
                        if [ -n "$OPENAB_ALLOWED_CHANNELS" ]; then
                          IFS=','; channels=""; for id in $OPENAB_ALLOWED_CHANNELS; do
                            id=$(echo "$id" | tr -d ' '); [ -n "$id" ] && channels="${channels}\"${id}\","; done; unset IFS
                          printf 'allowed_channels = [%s]\n' "$(echo "$channels" | sed 's/,$//')" >> "$CONFIG_FILE"
                        fi
                        if [ -n "$OPENAB_ALLOWED_USERS" ]; then
                          IFS=','; users=""; for id in $OPENAB_ALLOWED_USERS; do
                            id=$(echo "$id" | tr -d ' '); [ -n "$id" ] && users="${users}\"${id}\","; done; unset IFS
                          printf 'allowed_users = [%s]\n' "$(echo "$users" | sed 's/,$//')" >> "$CONFIG_FILE"
                        fi
                      fi

                      # Add [slack] section if tokens provided
                      if [ -n "$SLACK_BOT_TOKEN" ] && [ -n "$SLACK_APP_TOKEN" ]; then
                        printf '\n[slack]\nbot_token = "${SLACK_BOT_TOKEN}"\napp_token = "${SLACK_APP_TOKEN}"\n' >> "$CONFIG_FILE"
                      fi

                      echo "openab: config.toml generated"
                    else
                      echo "openab: using existing config.toml (delete to regenerate)"
                    fi

                    if [ "$(id -u)" = "0" ]; then
                      chown -R node:node "$CONFIG_DIR"
                      exec runuser -u node --preserve-environment -- openab run --config "${OPENAB_CONFIG_URL:-$CONFIG_FILE}"
                    fi

                    exec openab run --config "${OPENAB_CONFIG_URL:-$CONFIG_FILE}"
                  permission: 493
                  envsubst: null
                - path: /opt/config.toml.template
                  template: |
                    [agent]
                    args = ["--acp", "--approval-mode", "yolo"]
                  permission: null
                  envsubst: null
localization:
    es-ES:
        description: |
            Open Agent Broker — un arnes ligero en Rust que conecta Discord con cualquier CLI de coding compatible con ACP (Claude Code, Codex, Gemini, Kiro, Cursor) a traves de stdio JSON-RPC. Esta plantilla despliega la variante Gemini.
            Fuente: https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Token del Bot de Discord
              description: Token obtenido de https://discord.com/developers/applications
            - key: GEMINI_API_KEY
              type: STRING
              name: Clave API de Gemini (opcional)
              description: Opcional. Clave API de https://aistudio.google.com/apikey. Dejar vacio para autenticar mediante Vertex AI o inicio de sesion con cuenta personal de Google — ver readme.
            - key: OPENAB_ALLOWED_CHANNELS
              type: STRING
              name: IDs de Canales de Discord (opcional)
              description: 'Opcional. IDs de canales de Discord donde el bot escucha, separados por comas. Dejar vacio para permitir todos los canales. Ejemplo: 123456789012345678,234567890123456789'
            - key: OPENAB_ALLOWED_USERS
              type: STRING
              name: IDs de Usuarios de Discord (opcional)
              description: Opcional. IDs de usuarios de Discord permitidos para interactuar con el bot, separados por comas. Dejar vacio para permitir a todos en los canales permitidos.
        readme: |
            # OpenAB Gemini

            [OpenAB](https://github.com/openabdev/openab) es un arnes ligero de codigo abierto en Rust que conecta Discord con cualquier CLI de coding compatible con [Agent Client Protocol](https://github.com/anthropics/agent-protocol) a traves de stdio JSON-RPC.

            Esta plantilla despliega la variante Gemini (`openab-gemini`), que utiliza `gemini --acp` como backend de agente.

            ## Notas Importantes

            - **Etiqueta de imagen:** Esta plantilla rastrea la etiqueta flotante `beta`. Para fijar una versión específica, cambie la etiqueta de imagen en Zeabur Dashboard -> Servicio -> Configuración. Etiquetas disponibles: [GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab).
            - **Almacenamiento persistente:** `/home/node` esta montado como volumen persistente. Plugins, configuracion y credenciales se conservan entre reinicios.

            ## Configuracion

            ### 1. Obtener el Discord Bot Token

            1. Ir a https://discord.com/developers/applications y hacer clic en **New Application**
            2. Ir a la pestana **Bot** -> clic en **Reset Token** -> copiar el token
            3. En la misma pagina, bajar y habilitar **Message Content Intent** en Privileged Gateway Intents
            4. Ir a **OAuth2 -> URL Generator** -> marcar scope `bot` -> marcar permisos: Send Messages, Send Messages in Threads, Create Public Threads, Read Message History, Add Reactions, Manage Messages
            5. Copiar la URL generada y abrirla en el navegador para invitar al Bot al servidor

            ### 2. Autenticacion

            **Lo mas rapido:** complete la variable de plantilla `GEMINI_API_KEY` al desplegar y listo.

            **Otros metodos:** despues del despliegue, abra Zeabur Dashboard → Servicio → Exec y ejecute:

            ```
            runuser -u node -- gemini
            ```

            Siga las indicaciones en pantalla para elegir y completar un metodo de autenticacion. Las credenciales se guardan en el volumen persistente y las nuevas conversaciones las aplican automaticamente — sin reinicio.

            > **Conectar las API keys al agente:** openab lanza el agente con `env_clear()`, por lo que la vía de `GEMINI_API_KEY` requiere un allowlist de env. Tras el primer arranque edita `/home/node/.config/openab/config.toml` y añade bajo `[agent]`:
            >
            > ```toml
            > [agent]
            > inherit_env = ["GEMINI_API_KEY", "GOOGLE_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"]
            > ```
            >
            > El login interactivo no requiere edición — las credenciales viven en `~/.gemini/`.

            ### 3. Obtener IDs de canales de Discord

            1. Abrir Discord -> **Ajustes de usuario** (icono de engranaje) -> **Avanzado** -> activar **Modo desarrollador**
            2. Clic derecho en el canal donde quieres que el Bot responda -> **Copiar ID del canal**
            3. Para multiples canales, separar con comas: `123456789012345678,234567890123456789`

            ### 4. Desplegar

            Completar las variables de la plantilla y hacer clic en desplegar. El servicio se conecta a Discord automaticamente.

            ## Añadir plataformas de mensajería (Telegram / LINE / Feishu / Google Chat / MS Teams / WeCom)

            Para Telegram, despliega la [plantilla OpenAB Telegram](https://zeabur.com/templates/12LLKI) y cambia su image tag a `beta-gemini` con el `OPENAB_AGENT_COMMAND` correspondiente. Las demás plataformas se habilitan mediante variables de entorno en modo unified (`LINE_CHANNEL_SECRET`, `FEISHU_APP_ID`, `GOOGLE_CHAT_ENABLED=true`, `TEAMS_APP_ID`, `WECOM_CORP_ID`) — consulta la [documentación de OpenAB](https://github.com/openabdev/openab/tree/main/docs). Las plataformas webhook necesitan un dominio HTTPS público en el servicio (puerto 8080); Feishu se conecta por WebSocket saliente y no necesita dominio.

            ## Uso

            - **@mencionar al bot** en un canal permitido para iniciar una conversacion
            - OpenAB crea un **thread** para conversaciones de multiples turnos -- no se necesita @mencion en los mensajes siguientes
            - Cada thread corresponde a una sesion persistente de Gemini (TTL de 24h por defecto)

            ## Personalizacion

            | Archivo | Descripcion |
            |---------|-------------|
            | `/home/node/.config/openab/config.toml` | Configuracion de OpenAB (sessions, reactions, STT, etc.) |

            `config.toml` se crea a partir de una plantilla integrada en el primer arranque. Despues, edite el archivo directamente -- las variables de entorno solo se usan para la configuracion inicial. Para restablecer los valores predeterminados, elimine y reinicie: `rm /home/node/.config/openab/config.toml`

            Para opciones de configuracion, consulte la [documentacion de OpenAB](https://github.com/openabdev/openab).

            ## Webhook / Integracion con Bots

            Por defecto, openab ignora los mensajes de otros bots y webhooks. Para permitir mensajes activados por webhook (por ejemplo, pruebas automatizadas o pipelines de CI), agregar lo siguiente a `config.toml`:

            ```toml
            [discord]
            allow_bot_messages = "mentions"
            ```

            Con esta configuracion, openab responde a cualquier bot o mensaje de webhook que lo @mencione. Para restringir a un webhook especifico, agregar tambien:

            ```toml
            trusted_bot_ids = ["YOUR_WEBHOOK_USER_ID"]
            ```

            El ID de usuario del webhook es el ID numerico en la URL del webhook: `https://discord.com/api/webhooks/<ID>/...`

            ## Desactivar

            Dejar `Discord Bot Token` vacio al desplegar. El servicio entrara en modo sleep sin fallar.

            ## Enlaces

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [Agent Client Protocol](https://github.com/anthropics/agent-protocol)
            - [Google AI Studio](https://aistudio.google.com/)
    id-ID:
        description: |
            Open Agent Broker — harness Rust yang ringan untuk menjembatani Discord ke CLI coding yang kompatibel dengan ACP (Claude Code, Codex, Gemini, Kiro, Cursor) melalui stdio JSON-RPC. Template ini men-deploy varian Gemini.
            Sumber: https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Token Bot Discord
              description: Token dari https://discord.com/developers/applications
            - key: GEMINI_API_KEY
              type: STRING
              name: Kunci API Gemini (opsional)
              description: Opsional. Kunci API dari https://aistudio.google.com/apikey. Kosongkan untuk autentikasi melalui Vertex AI atau login akun Google pribadi — lihat readme.
            - key: OPENAB_ALLOWED_CHANNELS
              type: STRING
              name: ID Channel Discord (opsional)
              description: 'Opsional. ID channel Discord tempat bot mendengarkan, dipisahkan koma. Kosongkan untuk mengizinkan semua channel. Contoh: 123456789012345678,234567890123456789'
            - key: OPENAB_ALLOWED_USERS
              type: STRING
              name: ID Pengguna Discord (opsional)
              description: Opsional. ID pengguna Discord yang diizinkan berinteraksi dengan bot, dipisahkan koma. Kosongkan untuk mengizinkan semua orang di channel yang diizinkan.
        readme: |
            # OpenAB Gemini

            [OpenAB](https://github.com/openabdev/openab) adalah harness Rust yang ringan dan open-source yang menjembatani Discord ke CLI coding yang kompatibel dengan [Agent Client Protocol](https://github.com/anthropics/agent-protocol) melalui stdio JSON-RPC.

            Template ini men-deploy varian Gemini (`openab-gemini`) yang menggunakan `gemini --acp` sebagai backend agen.

            ## Catatan Penting

            - **Tag image:** Template ini mengikuti tag floating `beta` dan otomatis ikut rilis beta OpenAB terbaru. Untuk pin ke versi tertentu, ubah tag image di Zeabur Dashboard -> Layanan -> Pengaturan. Tag yang tersedia: [GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab).
            - **Penyimpanan persisten:** `/home/node` di-mount sebagai volume persisten. Plugin, pengaturan, config, dan kredensial dipertahankan antar restart.

            ## Pengaturan

            ### 1. Dapatkan Discord Bot Token

            1. Buka https://discord.com/developers/applications dan klik **New Application**
            2. Buka tab **Bot** -> klik **Reset Token** -> salin token
            3. Di halaman yang sama, scroll ke bawah dan aktifkan **Message Content Intent** di Privileged Gateway Intents
            4. Buka **OAuth2 -> URL Generator** -> centang scope `bot` -> centang izin: Send Messages, Send Messages in Threads, Create Public Threads, Read Message History, Add Reactions, Manage Messages
            5. Salin URL yang dihasilkan dan buka di browser untuk mengundang Bot ke server Anda

            ### 2. Autentikasi

            **Tercepat:** isi variabel template `GEMINI_API_KEY` saat deploy, langsung selesai.

            **Cara lain:** setelah deploy, buka Zeabur Dashboard → Layanan → Exec dan jalankan:

            ```
            runuser -u node -- gemini
            ```

            Ikuti petunjuk di layar untuk memilih dan menyelesaikan metode autentikasi. Kredensial tersimpan di volume persisten dan otomatis dipakai oleh percakapan baru — tanpa restart.

            > **Menyambungkan API key ke agent:** openab menjalankan agent dengan `env_clear()`, jadi jalur `GEMINI_API_KEY` memerlukan env allowlist. Setelah boot pertama, edit `/home/node/.config/openab/config.toml` dan tambahkan di bawah `[agent]`:
            >
            > ```toml
            > [agent]
            > inherit_env = ["GEMINI_API_KEY", "GOOGLE_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"]
            > ```
            >
            > Login interaktif tidak perlu diedit — kredensial ada di `~/.gemini/`.

            ### 3. Dapatkan ID Channel Discord

            1. Buka Discord -> **Pengaturan Pengguna** (ikon roda gigi) -> **Lanjutan** -> aktifkan **Mode Pengembang**
            2. Klik kanan channel tempat Anda ingin Bot merespons -> **Salin ID Channel**
            3. Untuk beberapa channel, pisahkan dengan koma: `123456789012345678,234567890123456789`

            ### 4. Deploy

            Isi variabel template dan klik deploy. Layanan akan terhubung ke Discord secara otomatis.

            ## Tambahkan Platform Pesan (Telegram / LINE / Feishu / Google Chat / MS Teams / WeCom)

            Untuk Telegram, deploy [template OpenAB Telegram](https://zeabur.com/templates/12LLKI) dan ganti image tag-nya ke `beta-gemini` dengan `OPENAB_AGENT_COMMAND` yang sesuai. Platform lain diaktifkan lewat variabel lingkungan pada unified mode (`LINE_CHANNEL_SECRET`, `FEISHU_APP_ID`, `GOOGLE_CHAT_ENABLED=true`, `TEAMS_APP_ID`, `WECOM_CORP_ID`) — lihat [dokumentasi OpenAB](https://github.com/openabdev/openab/tree/main/docs). Platform webhook memerlukan domain HTTPS publik pada layanan (port 8080); Feishu terhubung keluar via WebSocket dan tidak butuh domain.

            ## Penggunaan

            - **@mention bot** di channel yang diizinkan untuk memulai percakapan
            - OpenAB membuat **thread** untuk percakapan multi-giliran -- tidak perlu @mention untuk pesan selanjutnya
            - Setiap thread dipetakan ke sesi Gemini yang persisten (TTL 24 jam secara default)

            ## Kustomisasi

            | File | Deskripsi |
            |------|-----------|
            | `/home/node/.config/openab/config.toml` | Konfigurasi OpenAB (sessions, reactions, STT, dll.) |

            `config.toml` dibuat dari template bawaan saat boot pertama. Setelah itu, edit file secara langsung -- variabel lingkungan hanya digunakan untuk pengaturan awal. Untuk mengembalikan ke default, hapus dan restart: `rm /home/node/.config/openab/config.toml`

            Untuk opsi konfigurasi, lihat [dokumentasi OpenAB](https://github.com/openabdev/openab).

            ## Webhook / Integrasi Bot

            Secara default, openab mengabaikan pesan dari bot dan webhook lain. Untuk mengizinkan pesan yang dipicu webhook (misalnya pengujian otomatis atau pipeline CI), tambahkan berikut ke `config.toml`:

            ```toml
            [discord]
            allow_bot_messages = "mentions"
            ```

            Dengan pengaturan ini, openab merespons pesan bot atau webhook apa pun yang @mention-nya. Untuk membatasi ke webhook tertentu, tambahkan juga:

            ```toml
            trusted_bot_ids = ["YOUR_WEBHOOK_USER_ID"]
            ```

            ID pengguna webhook adalah ID numerik dalam URL webhook: `https://discord.com/api/webhooks/<ID>/...`

            ## Menonaktifkan

            Kosongkan `Discord Bot Token` saat deploy. Layanan akan tidur tanpa crash.

            ## Tautan

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [Agent Client Protocol](https://github.com/anthropics/agent-protocol)
            - [Google AI Studio](https://aistudio.google.com/)
    ja-JP:
        description: |
            Open Agent Broker — stdio JSON-RPC を通じて Discord を ACP 対応の coding CLI（Claude Code、Codex、Gemini、Kiro、Cursor）にブリッジする軽量な Rust ハーネス。このテンプレートは Gemini バリアントをデプロイします。
            ソース：https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Discord Bot トークン
              description: https://discord.com/developers/applications から取得したトークン
            - key: GEMINI_API_KEY
              type: STRING
              name: Gemini API キー（オプション）
              description: オプション。https://aistudio.google.com/apikey から取得した API キー。空のままにすると Vertex AI または個人 Google アカウントログインを使用できます — readme を参照してください。
            - key: OPENAB_ALLOWED_CHANNELS
              type: STRING
              name: Discord チャンネル ID（オプション）
              description: オプション。Bot が監視する Discord チャンネル ID（カンマ区切り）。空の場合、全チャンネルで応答。例：123456789012345678,234567890123456789
            - key: OPENAB_ALLOWED_USERS
              type: STRING
              name: Discord ユーザー ID（オプション）
              description: オプション。Bot と対話できるユーザーの Discord ユーザー ID（カンマ区切り）。空の場合、許可チャンネルの全員が利用可能。
        readme: |
            # OpenAB Gemini

            [OpenAB](https://github.com/openabdev/openab) は、stdio JSON-RPC を通じて Discord を [Agent Client Protocol](https://github.com/anthropics/agent-protocol) 対応の coding CLI にブリッジする軽量なオープンソース Rust ハーネスです。

            このテンプレートは Gemini バリアント（`openab-gemini`）をデプロイし、`gemini --acp` をエージェントバックエンドとして使用します。

            ## 注意事項

            - **イメージタグ：** このテンプレートはfloating `beta` タグを追跡しています（OpenAB の新しい beta リリースが公開されると自動更新）。特定のバージョンに pin するには、Zeabur Dashboard → サービス → 設定でイメージタグを変更してください。利用可能なタグ：[GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab)。
            - **永続ストレージ：** `/home/node` が永続ボリュームとしてマウントされます。プラグイン、設定、config、認証情報は再起動後も保持されます。

            ## セットアップ

            ### 1. Discord Bot Token の取得

            1. https://discord.com/developers/applications にアクセスし、**New Application** をクリック
            2. **Bot** タブ → **Reset Token** をクリック → token をコピー
            3. 同じページを下にスクロールし、Privileged Gateway Intents の **Message Content Intent** を有効化
            4. **OAuth2 → URL Generator** → scope `bot` にチェック → 権限にチェック：Send Messages、Send Messages in Threads、Create Public Threads、Read Message History、Add Reactions、Manage Messages
            5. 生成された URL をコピーし、ブラウザで開いて Bot をサーバーに招待

            ### 2. 認証

            **最速:** デプロイ時に `GEMINI_API_KEY` テンプレート変数を入力すれば、サービス起動時にそのまま使えます。

            **その他の方法:** デプロイ後、Zeabur Dashboard → サービス → Exec で実行：

            ```
            runuser -u node -- gemini
            ```

            画面の指示に従って認証方法を選択し、完了させてください。認証情報は永続ボリュームに保存され、新しい会話に自動的に適用されます — 再起動は不要です。

            > **API キーを agent に渡す：** openab は `env_clear()` で agent サブプロセスを分離するため、`GEMINI_API_KEY` ルートには env allowlist が必要です。初回起動後に `/home/node/.config/openab/config.toml` を編集し、`[agent]` セクションに追加：
            >
            > ```toml
            > [agent]
            > inherit_env = ["GEMINI_API_KEY", "GOOGLE_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"]
            > ```
            >
            > インタラクティブログインは編集不要 — 認証情報は `~/.gemini/` に保存されます。

            ### 3. Discord チャンネル ID の取得

            1. Discord を開く → **ユーザー設定**（歯車アイコン）→ **詳細設定** → **開発者モード** を有効化
            2. Bot に応答させたいチャンネルを右クリック → **チャンネル ID をコピー**
            3. 複数チャンネルはカンマで区切る：`123456789012345678,234567890123456789`

            ### 4. デプロイ

            テンプレート変数を入力してデプロイをクリック。サービスは自動的に Discord に接続します。

            ## メッセージプラットフォームを追加（Telegram / LINE / Feishu / Google Chat / MS Teams / WeCom）

            Telegram を使う場合は [OpenAB Telegram テンプレート](https://zeabur.com/templates/12LLKI) をデプロイし、image tag を `beta-gemini` に変更して対応する `OPENAB_AGENT_COMMAND` を設定してください。その他のプラットフォームは unified mode で環境変数から直接有効化できます（`LINE_CHANNEL_SECRET`、`FEISHU_APP_ID`、`GOOGLE_CHAT_ENABLED=true`、`TEAMS_APP_ID`、`WECOM_CORP_ID`）。詳細は [OpenAB ドキュメント](https://github.com/openabdev/openab/tree/main/docs) を参照。Webhook 型プラットフォームはサービスに公開 HTTPS ドメイン（port 8080）が必要です。Feishu は WebSocket でアウトバウンド接続するためドメイン不要です。

            ## 使い方

            - 許可されたチャンネルで **Bot を @mention** して会話を開始
            - OpenAB は自動的に **thread** を作成してマルチターン会話を行います — 以降のメッセージでは @mention 不要
            - 各 thread は永続的な Gemini session に対応（デフォルト 24 時間 TTL）

            ## カスタマイズ

            | ファイル | 説明 |
            |---------|------|
            | `/home/node/.config/openab/config.toml` | OpenAB 設定（sessions、reactions、STT など） |

            `config.toml` は初回起動時に内蔵テンプレートから作成されます。以降の変更はファイルを直接編集してください。環境変数は初期設定時のみ使用されます。デフォルトに戻すにはファイルを削除して再起動：`rm /home/node/.config/openab/config.toml`

            設定オプションは [OpenAB ドキュメント](https://github.com/openabdev/openab) を参照。

            ## Webhook / Bot 連携

            デフォルトでは、openab は他の bot や webhook からのメッセージを無視します。webhook がトリガーするメッセージ（自動テストや CI パイプラインなど）を許可するには、`config.toml` に以下を追加してください：

            ```toml
            [discord]
            allow_bot_messages = "mentions"
            ```

            この設定で、openab は @mention するすべての bot や webhook メッセージに応答します。特定の webhook に制限するには、次も追加：

            ```toml
            trusted_bot_ids = ["YOUR_WEBHOOK_USER_ID"]
            ```

            webhook ユーザー ID は webhook URL 内の数字 ID です：`https://discord.com/api/webhooks/<ID>/...`

            ## 無効化

            デプロイ時に `Discord Bot Token` を空にしてください。サービスはクラッシュせずスリープ状態になります。

            ## リンク

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [Agent Client Protocol](https://github.com/anthropics/agent-protocol)
            - [Google AI Studio](https://aistudio.google.com/)
    zh-CN:
        description: |
            Open Agent Broker — 轻量的 Rust 程序，通过 stdio JSON-RPC 将 Discord 桥接到任何 ACP 兼容的 coding CLI（Claude Code、Codex、Gemini、Kiro、Cursor）。此模板部署 Gemini 变体。
            来源：https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Discord Bot Token
              description: 从 https://discord.com/developers/applications 获取的 Token
            - key: GEMINI_API_KEY
              type: STRING
              name: Gemini API Key（选填）
              description: 选填。从 https://aistudio.google.com/apikey 获取的 API 密钥。留空可改用 Vertex AI 或个人 Google 账号登录 — 详见 readme。
            - key: OPENAB_ALLOWED_CHANNELS
              type: STRING
              name: Discord 频道 ID（选填）
              description: 选填。Bot 监听的 Discord 频道 ID，以逗号分隔。留空则允许所有频道。示例：123456789012345678,234567890123456789
            - key: OPENAB_ALLOWED_USERS
              type: STRING
              name: Discord 用户 ID（选填）
              description: 选填。以逗号分隔的 Discord 用户 ID，限制可与 Bot 互动的用户。留空则允许频道中所有人。
        readme: |
            # OpenAB Gemini

            [OpenAB](https://github.com/openabdev/openab) 是一个轻量的开源 Rust 程序，通过 stdio JSON-RPC 将 Discord 桥接到任何支持 [Agent Client Protocol](https://github.com/anthropics/agent-protocol) 的 coding CLI。

            此模板部署的是 Gemini 变体（`openab-gemini`），使用 `gemini --acp` 作为 agent 后端。

            ## 注意事项

            - **镜像标签：** 此模板追踪 floating `beta` 标签，OpenAB 推出新 beta 版时自动更新。若要 pin 至特定版本，请在 Zeabur Dashboard → 服务 → 设置中更改镜像标签。可用标签：[GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab)。
            - **持久化存储：** `/home/node` 挂载为持久化磁盘。Plugins、设置、config 和认证数据会在重启后保留。

            ## 设置步骤

            ### 1. 获取 Discord Bot Token

            1. 前往 [Discord Developer Portal](https://discord.com/developers/applications)，点击 **New Application**
            2. 进入 **Bot** 页签 → 点击 **Reset Token** → 复制 token
            3. 同一页面往下滑，在 Privileged Gateway Intents 下启用 **Message Content Intent**
            4. 前往 **OAuth2 → URL Generator** → 勾选 scope `bot` → 勾选权限：Send Messages、Send Messages in Threads、Create Public Threads、Read Message History、Add Reactions、Manage Messages
            5. 复制生成的 URL，在浏览器中打开以邀请 Bot 到你的服务器

            ### 2. 认证

            **最快：** 部署时填 `GEMINI_API_KEY` 模板变量即可，服务启动就直接用。

            **其他方式：** 部署完成后，在 Zeabur Dashboard → 服务 → Exec 运行：

            ```
            runuser -u node -- gemini
            ```

            按照屏幕提示选择并完成认证。认证数据会存在持久化磁盘，新对话会自动采用，无需重启。

            > **将 API key 传给 agent：** openab 会以 `env_clear()` 隔离 agent 子进程，因此 `GEMINI_API_KEY` 路径需要 env allowlist。首次启动后编辑 `/home/node/.config/openab/config.toml`，在 `[agent]` 区块加入：
            >
            > ```toml
            > [agent]
            > inherit_env = ["GEMINI_API_KEY", "GOOGLE_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"]
            > ```
            >
            > 交互登录无需修改 — 认证数据存在 `~/.gemini/`。

            ### 3. 获取 Discord 频道 ID

            1. 打开 Discord → 前往 **用户设置**（齿轮图标）→ **高级** → 启用 **开发者模式**
            2. 右键点击你要 Bot 回应的频道 → **复制频道 ID**
            3. 多个频道用逗号分隔：`123456789012345678,234567890123456789`

            ### 4. 部署

            填入模板变量后点击部署即可。服务会自动连接到 Discord。

            ## 添加通讯平台（Telegram / LINE / 飞书 / Google Chat / MS Teams / WeCom）

            若要使用 Telegram，请部署 [OpenAB Telegram 模板](https://zeabur.com/templates/12LLKI)，并把 image tag 换成 `beta-gemini`、设置对应的 `OPENAB_AGENT_COMMAND`。其他平台在 unified mode 下直接以环境变量启用（`LINE_CHANNEL_SECRET`、`FEISHU_APP_ID`、`GOOGLE_CHAT_ENABLED=true`、`TEAMS_APP_ID`、`WECOM_CORP_ID`），详见 [OpenAB 文档](https://github.com/openabdev/openab/tree/main/docs)。Webhook 类平台需要为服务绑定公开 HTTPS 域名（port 8080）；飞书走 WebSocket 对外连接，不需要域名。

            ## 使用方式

            - 在允许的频道中 **@mention Bot** 即可开始对话
            - OpenAB 会自动创建 **thread** 进行多轮对话 — 后续消息不需要再 @mention
            - 每个 thread 对应一个持久的 Gemini session（默认 24 小时 TTL）

            ## 自定义设置

            | 文件 | 说明 |
            |------|------|
            | `/home/node/.config/openab/config.toml` | OpenAB 设置（sessions、reactions、STT 等） |

            `config.toml` 在首次启动时从内建模板创建。之后请直接编辑文件，环境变量仅用于初始设置。要恢复默认值请删除后重启：`rm /home/node/.config/openab/config.toml`

            设置选项请参阅 [OpenAB 文档](https://github.com/openabdev/openab)。

            ## Webhook / Bot 集成

            OpenAB 默认忽略来自其他 bot 和 webhook 的消息。要允许 webhook 触发的消息（例如自动化测试或 CI 流水线），在 `config.toml` 中添加以下配置：

            ```toml
            [discord]
            allow_bot_messages = "mentions"
            ```

            设置后，openab 会响应任何 @mention 它的 bot 或 webhook 消息。若要限制为特定 webhook，还可添加：

            ```toml
            trusted_bot_ids = ["YOUR_WEBHOOK_USER_ID"]
            ```

            Webhook 用户 ID 为 webhook URL 中的数字 ID：`https://discord.com/api/webhooks/<ID>/...`

            ## 停用

            部署时将 `Discord Bot Token` 留空即可。服务会进入 sleep 状态，不会崩溃。

            ## 链接

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [Agent Client Protocol](https://github.com/anthropics/agent-protocol)
            - [Google AI Studio](https://aistudio.google.com/)
    zh-TW:
        description: |
            Open Agent Broker — 輕量的 Rust 程式，透過 stdio JSON-RPC 將 Discord 橋接到任何 ACP 相容的 coding CLI（Claude Code、Codex、Gemini、Kiro、Cursor）。此模板部署 Gemini 變體。
            來源：https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Discord Bot Token
              description: 從 https://discord.com/developers/applications 取得的 Token
            - key: GEMINI_API_KEY
              type: STRING
              name: Gemini API Key（選填）
              description: 選填。從 https://aistudio.google.com/apikey 取得的 API 金鑰。留空可改用 Vertex AI 或個人 Google 帳號登入 — 詳見 readme。
            - key: OPENAB_ALLOWED_CHANNELS
              type: STRING
              name: Discord 頻道 ID（選填）
              description: 選填。Bot 監聽的 Discord 頻道 ID，以逗號分隔。留空則允許所有頻道。範例：123456789012345678,234567890123456789
            - key: OPENAB_ALLOWED_USERS
              type: STRING
              name: Discord 用戶 ID（選填）
              description: 選填。以逗號分隔的 Discord 用戶 ID，限制可與 Bot 互動的用戶。留空則允許頻道中所有人。
        readme: |
            # OpenAB Gemini

            [OpenAB](https://github.com/openabdev/openab) 是一個輕量的開源 Rust 程式，透過 stdio JSON-RPC 將 Discord 橋接到任何支援 [Agent Client Protocol](https://github.com/anthropics/agent-protocol) 的 coding CLI。

            此模板部署的是 Gemini 變體（`openab-gemini`），使用 `gemini --acp` 作為 agent 後端。

            ## 注意事項

            - **映像標籤：** 此模板追蹤 floating `beta` 標籤，OpenAB 推出新 beta 版時自動更新。若要 pin 至特定版本，請在 Zeabur Dashboard → 服務 → 設定中更改映像標籤。可用標籤：[GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab)。
            - **持久化儲存：** `/home/node` 掛載為持久化磁碟。Plugins、設定、config 和認證資料會在重啟後保留。

            ## 設定步驟

            ### 1. 取得 Discord Bot Token

            1. 前往 [Discord Developer Portal](https://discord.com/developers/applications)，點擊 **New Application**
            2. 進入 **Bot** 頁籤 → 點擊 **Reset Token** → 複製 token
            3. 同一頁面往下滑，在 Privileged Gateway Intents 下啟用 **Message Content Intent**
            4. 前往 **OAuth2 → URL Generator** → 勾選 scope `bot` → 勾選權限：Send Messages、Send Messages in Threads、Create Public Threads、Read Message History、Add Reactions、Manage Messages
            5. 複製產生的 URL，在瀏覽器中開啟以邀請 Bot 到你的伺服器

            ### 2. 認證

            **最快:** 部署時填 `GEMINI_API_KEY` 模板變數即可,服務啟動就直接用。

            **其他方式:** 部署完成後,在 Zeabur Dashboard → 服務 → Exec 執行:

            ```
            runuser -u node -- gemini
            ```

            依照畫面提示選擇並完成認證。認證資料會存在持久化磁碟,新對話會自動套用,不需重啟。

            > **將 API key 傳給 agent：** openab 會以 `env_clear()` 隔離 agent 子程序，因此 `GEMINI_API_KEY` 路徑需要 env allowlist。首次啟動後編輯 `/home/node/.config/openab/config.toml`，在 `[agent]` 區塊加入：
            >
            > ```toml
            > [agent]
            > inherit_env = ["GEMINI_API_KEY", "GOOGLE_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"]
            > ```
            >
            > 互動登入不需修改 — 認證資料存在 `~/.gemini/`。

            ### 3. 取得 Discord 頻道 ID

            1. 開啟 Discord → 前往 **使用者設定**（齒輪圖示）→ **進階** → 啟用 **開發者模式**
            2. 對你要 Bot 回應的頻道按右鍵 → **複製頻道 ID**
            3. 多個頻道用逗號分隔：`123456789012345678,234567890123456789`

            ### 4. 部署

            填入模板變數後點擊部署即可。服務會自動連線到 Discord。

            ## 新增通訊平台（Telegram / LINE / Feishu / Google Chat / MS Teams / WeCom）

            若要使用 Telegram，請部署 [OpenAB Telegram 模板](https://zeabur.com/templates/12LLKI)，並把 image tag 換成 `beta-gemini`、設定對應的 `OPENAB_AGENT_COMMAND`。其他平台在 unified mode 下直接以環境變數啟用（`LINE_CHANNEL_SECRET`、`FEISHU_APP_ID`、`GOOGLE_CHAT_ENABLED=true`、`TEAMS_APP_ID`、`WECOM_CORP_ID`），詳見 [OpenAB 文件](https://github.com/openabdev/openab/tree/main/docs)。Webhook 類平台需要為服務綁定公開 HTTPS 網域（port 8080）；Feishu 走 WebSocket 對外連線，不需網域。

            ## 使用方式

            - 在允許的頻道中 **@mention Bot** 即可開始對話
            - OpenAB 會自動建立 **thread** 進行多輪對話 — 後續訊息不需要再 @mention
            - 每個 thread 對應一個持久的 Gemini session（預設 24 小時 TTL）

            ## 自訂設定

            | 檔案 | 說明 |
            |------|------|
            | `/home/node/.config/openab/config.toml` | OpenAB 設定（sessions、reactions、STT 等） |

            `config.toml` 在首次啟動時從內建範本建立。之後請直接編輯檔案，環境變數僅用於初始設定。要恢復預設值請刪除後重啟：`rm /home/node/.config/openab/config.toml`

            設定選項請參閱 [OpenAB 文件](https://github.com/openabdev/openab)。

            ## Webhook / Bot 整合

            OpenAB 預設忽略其他 bot 和 webhook 的訊息。若要允許 webhook 觸發的訊息（例如自動化測試或 CI pipeline），在 `config.toml` 加入以下設定：

            ```toml
            [discord]
            allow_bot_messages = "mentions"
            ```

            設定後，openab 會回應任何 @mention 它的 bot 或 webhook 訊息。若要限制為特定 webhook，也可加入：

            ```toml
            trusted_bot_ids = ["YOUR_WEBHOOK_USER_ID"]
            ```

            Webhook 用戶 ID 為 webhook URL 中的數字 ID：`https://discord.com/api/webhooks/<ID>/...`

            ## 停用

            部署時將 `Discord Bot Token` 留空即可。服務會進入 sleep 狀態，不會崩潰。

            ## 連結

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [Agent Client Protocol](https://github.com/anthropics/agent-protocol)
            - [Google AI Studio](https://aistudio.google.com/)
