# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: OpenAB Codex
spec:
    description: |
        Open Agent Broker — a lightweight Rust harness that bridges Discord and Slack to any ACP-compatible coding CLI (Claude Code, Codex, Gemini, Kiro) over stdio JSON-RPC.
        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 (optional)
          description: Optional. Token from https://discord.com/developers/applications. Leave empty if using Slack only.
        - key: OPENAI_API_KEY
          type: STRING
          name: OpenAI API Key (optional)
          description: Optional. API key from https://platform.openai.com/api-keys — or leave empty and use device flow auth after deployment.
        - 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_ALLOW_BOT_MESSAGES
          type: STRING
          name: Allow Bot Messages (optional)
          description: Optional. Set to 'on' to allow messages from bots/webhooks to trigger the agent. Leave empty to disable (default).
        - key: OPENAB_MAX_SESSIONS
          type: STRING
          name: Max Concurrent Sessions (optional)
          description: 'Optional. Maximum number of concurrent agent sessions (default: 10). Oldest idle session is evicted when the limit is reached.'
    tags:
        - AI
        - Developer Tools
        - Discord
        - Slack
    readme: |
        # OpenAB Codex

        [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 Codex variant (`openab-codex`) which uses `codex-acp` as the agent backend.

        ## Important Notes

        - **Image tag:** This template uses a pinned version (`0.8.1-beta.5`). To upgrade, change the image tag in Zeabur Dashboard → Service → Settings. Available tags: [GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab-codex).
        - **Persistent storage:** `/home/node` is mounted as a persistent volume. Plugins, settings, config, and credentials survive restarts.
        - **Config ownership:** The container runs directly as `node` user (uid 1000). If you encounter permission issues on the persistent volume, restart the service.

        ## 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. Authentication (choose one)

        **Option A: OpenAI API Key** (billed per token — [see pricing](https://developers.openai.com/codex/pricing))
        1. Go to [platform.openai.com/api-keys](https://platform.openai.com/api-keys)
        2. Click **Create new secret key** → copy the key
        3. Fill in the `OpenAI API Key` variable when deploying
        4. The service automatically runs `codex login --with-api-key` on first boot — no manual steps needed

        **Option B: ChatGPT Subscription** (Plus/Pro/Business — usage included in plan)
        1. Leave `OpenAI API Key` empty when deploying
        2. After the service starts, go to Zeabur Dashboard → Service → **Exec**
        3. The Exec terminal opens as root. Run with the correct HOME so credentials are saved to the right path:
           ```
           HOME=/home/node codex login --device-auth
           ```
        4. Open the URL shown in the terminal, authorize with your ChatGPT account
        5. Restart the service from the dashboard
        6. Credentials are saved to `/home/node/.codex/auth.json` on the persistent volume and auto-refreshed — this step is only needed once

        ### 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 variables and click deploy. The service connects to Discord and/or Slack automatically.

        ## Slack Setup (Optional)

        OpenAB supports Slack via Socket Mode — no public URL needed.

        1. Go to https://api.slack.com/apps → **Create New App** → **From scratch**
        2. **Socket Mode** → Enable → generate an App-Level Token with scope `connections:write` → copy the `xapp-...` token (`SLACK_APP_TOKEN`)
        3. **Event Subscriptions** → Enable Events → add bot events: `app_mention`, `message.channels`, `message.groups`
        4. **OAuth & Permissions** → Bot Token Scopes → add: `app_mentions:read`, `chat:write`, `channels:history`, `groups:history`, `channels:read`, `groups:read`, `reactions:write`, `files:read`, `users:read`
        5. **Install App** → Install to Workspace → copy the `xoxb-...` token (`SLACK_BOT_TOKEN`)
        6. In each Slack channel you want the bot in, run `/invite @YourAppName`

        Set `SLACK_BOT_TOKEN` and `SLACK_APP_TOKEN` in the template variables before deploying. Both Discord and Slack can run simultaneously.

        ## Usage

        - **@mention the bot** in an allowed channel or Slack 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 Codex 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).

        ## Disabling

        Leave `Discord Bot Token` and `Slack 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)
        - [OpenAI Platform](https://platform.openai.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-codex:0.8.1-beta.5
                command:
                    - /bin/sh
                    - -c
                    - /opt/start-openab.sh
            volumes:
                - id: node-home
                  dir: /home/node
            env:
                DISCORD_BOT_TOKEN:
                    default: ${DISCORD_BOT_TOKEN}
                OPENAB_ALLOW_BOT_MESSAGES:
                    default: ""
                OPENAB_ALLOWED_CHANNELS:
                    default: ""
                OPENAB_ALLOWED_USERS:
                    default: ""
                OPENAB_MAX_SESSIONS:
                    default: ""
                OPENAI_API_KEY:
                    default: ""
                SLACK_APP_TOKEN:
                    default: ""
                SLACK_BOT_TOKEN:
                    default: ""
            configs:
                - path: /opt/start-openab.sh
                  template: |
                    #!/bin/sh
                    set -e

                    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_ALLOW_BOT_MESSAGES" ]; then
                          printf 'allow_bot_messages = "%s"\n' "$OPENAB_ALLOW_BOT_MESSAGES" >> "$CONFIG_FILE"
                        fi
                        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

                      # Add [pool] section if max_sessions provided
                      if [ -n "$OPENAB_MAX_SESSIONS" ]; then
                        printf '\n[pool]\nmax_sessions = %s\n' "$OPENAB_MAX_SESSIONS" >> "$CONFIG_FILE"
                      fi

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

                    # Authenticate codex with API key if not already logged in
                    if [ -n "$OPENAI_API_KEY" ] && [ ! -f "$HOME/.codex/auth.json" ]; then
                      printf '%s' "$OPENAI_API_KEY" | codex login --with-api-key
                    fi

                    exec openab run --config "$CONFIG_FILE"
                  permission: 493
                  envsubst: null
                - path: /opt/config.toml.template
                  template: |
                    [agent]
                    command = "codex-acp"
                    args = []
                    working_dir = "/home/node"
                  permission: null
                  envsubst: null
localization:
    es-ES:
        description: |
            Open Agent Broker — un arnés ligero en Rust que conecta Discord y Slack con cualquier CLI de coding compatible con ACP (Claude Code, Codex, Gemini, Kiro) a través de stdio JSON-RPC.
            Fuente: https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Token del Bot de Discord (opcional)
              description: Opcional. Token obtenido de https://discord.com/developers/applications. Dejar vacío si solo usa Slack.
            - key: OPENAI_API_KEY
              type: STRING
              name: OpenAI API Key (opcional)
              description: Opcional. API key de https://platform.openai.com/api-keys — o dejar vacío y usar device flow después del despliegue.
            - 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 vacío 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 vacío para permitir a todos en los canales permitidos.
            - key: SLACK_BOT_TOKEN
              type: STRING
              name: Slack Bot Token (opcional)
              description: Opcional. Bot User OAuth Token (xoxb-...) de la configuración de Slack App. Dejar vacío para deshabilitar el adaptador de Slack.
            - key: SLACK_APP_TOKEN
              type: STRING
              name: Slack App Token (opcional)
              description: Opcional. App-Level Token (xapp-...) para Socket Mode. Requerido cuando se configura Slack Bot Token.
        readme: |
            # OpenAB Codex

            [OpenAB](https://github.com/openabdev/openab) es un arnés ligero de código abierto en Rust que conecta Discord y Slack con cualquier CLI de coding compatible con [Agent Client Protocol](https://github.com/anthropics/agent-protocol) a través de stdio JSON-RPC.

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

            ## Notas Importantes

            - **Etiqueta de imagen:** Esta plantilla usa una versión fijada (`0.8.1-beta.5`). Para actualizar, cambie la etiqueta de imagen en Zeabur Dashboard → Servicio → Configuración. Etiquetas disponibles: [GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab-codex).
            - **Almacenamiento persistente:** `/home/node` está montado como volumen persistente. Plugins, configuración y credenciales se conservan entre reinicios.
            - **Permisos de archivos:** El contenedor se ejecuta directamente como el usuario node (uid 1000). Si encuentra problemas de permisos en el volumen persistente, reinicie el servicio.

            ## Configuración

            ### 1. Obtener el Discord Bot Token

            1. Ir a https://discord.com/developers/applications y hacer clic en **New Application**
            2. Ir a la pestaña **Bot** → clic en **Reset Token** → copiar el token
            3. En la misma página, 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. Autenticación (elegir una)

            **Opción A: OpenAI API Key** (facturación por token — [ver precios](https://developers.openai.com/codex/pricing))
            1. Ir a [platform.openai.com/api-keys](https://platform.openai.com/api-keys)
            2. Clic en **Create new secret key** → copiar la clave
            3. Completar `OpenAI API Key` al desplegar
            4. El servicio ejecuta `codex login --with-api-key` automáticamente en el primer arranque — no se necesita intervención manual

            **Opción B: Suscripción ChatGPT** (Plus/Pro/Business — uso incluido en el plan)
            1. Dejar `OpenAI API Key` vacío al desplegar
            2. Después de que el servicio inicie, ir a Zeabur Dashboard → Servicio → **Exec**
            3. El terminal Exec se abre como root. Especifica el HOME correcto para guardar las credenciales en el lugar adecuado:
               ```
               HOME=/home/node codex login --device-auth
               ```
            4. Abrir la URL mostrada en el terminal y autorizar con la cuenta de ChatGPT
            5. Reiniciar el servicio desde el Dashboard
            6. Las credenciales se guardan en `/home/node/.codex/auth.json` en el volumen persistente y se actualizan automáticamente — este paso solo es necesario una vez

            ### 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 múltiples canales, separar con comas: `123456789012345678,234567890123456789`

            ### 4. Desplegar

            Completar las variables y hacer clic en desplegar. El servicio se conecta a Discord y/o Slack automáticamente.

            ## Configuración de Slack (Opcional)

            OpenAB soporta Slack mediante Socket Mode — no se necesita URL pública.

            1. Ir a https://api.slack.com/apps → **Create New App** → **From scratch**
            2. **Socket Mode** → Habilitar → generar App-Level Token con scope `connections:write` → copiar el token `xapp-...` (`SLACK_APP_TOKEN`)
            3. **Event Subscriptions** → Habilitar → añadir bot events: `app_mention`, `message.channels`, `message.groups`
            4. **OAuth & Permissions** → Bot Token Scopes → añadir: `app_mentions:read`, `chat:write`, `channels:history`, `groups:history`, `channels:read`, `groups:read`, `reactions:write`, `files:read`, `users:read`
            5. **Install App** → Instalar en el workspace → copiar el token `xoxb-...` (`SLACK_BOT_TOKEN`)
            6. En cada canal de Slack donde quieras usar el bot, ejecuta `/invite @YourAppName`

            Rellena `SLACK_BOT_TOKEN` y `SLACK_APP_TOKEN` antes de desplegar. Discord y Slack pueden funcionar simultáneamente.

            ## Uso

            - **@mencionar al bot** en un canal de Discord o Slack permitido para iniciar una conversación
            - OpenAB crea un **thread** para conversaciones de multiples turnos — no se necesita @mencion en los mensajes siguientes
            - Cada thread corresponde a una sesión persistente de Codex (TTL de 24h por defecto)

            ## Personalización

            | Archivo | Descripción |
            |---------|-------------|
            | `/home/node/.config/openab/config.toml` | Configuración de OpenAB (sessions, reactions, STT, etc.) |

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

            Para opciones de configuración, consulte la [documentación de OpenAB](https://github.com/openabdev/openab).

            ## Desactivar

            Dejar `Discord Bot Token` y `Slack Bot Token` vacios al desplegar. El servicio entrará en modo sleep sin fallar.

            ## Enlaces

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [Agent Client Protocol](https://github.com/anthropics/agent-protocol)
            - [OpenAI Platform](https://platform.openai.com/)
    id-ID:
        description: |
            Open Agent Broker — harness Rust yang ringan untuk menjembatani Discord dan Slack ke CLI coding yang kompatibel dengan ACP (Claude Code, Codex, Gemini, Kiro) melalui stdio JSON-RPC.
            Sumber: https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Token Bot Discord (opsional)
              description: Opsional. Token dari https://discord.com/developers/applications. Kosongkan jika hanya menggunakan Slack.
            - key: OPENAI_API_KEY
              type: STRING
              name: OpenAI API Key (opsional)
              description: Opsional. API key dari https://platform.openai.com/api-keys — atau kosongkan dan gunakan device flow setelah deploy.
            - 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.
            - key: SLACK_BOT_TOKEN
              type: STRING
              name: Slack Bot Token (opsional)
              description: Opsional. Bot User OAuth Token (xoxb-...) dari pengaturan Slack App. Kosongkan untuk menonaktifkan adapter Slack.
            - key: SLACK_APP_TOKEN
              type: STRING
              name: Slack App Token (opsional)
              description: Opsional. App-Level Token (xapp-...) untuk Socket Mode. Diperlukan saat Slack Bot Token diisi.
        readme: |
            # OpenAB Codex

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

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

            ## Catatan Penting

            - **Tag image:** Template ini menggunakan versi yang dipin (`0.8.1-beta.5`). Untuk upgrade, ubah tag image di Zeabur Dashboard → Layanan → Pengaturan. Tag yang tersedia: [GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab-codex).
            - **Penyimpanan persisten:** `/home/node` di-mount sebagai volume persisten. Plugin, pengaturan, config, dan kredensial dipertahankan antar restart.
            - **Izin file:** Container berjalan langsung sebagai pengguna node (uid 1000). Jika mengalami masalah izin pada volume persisten, restart layanan.

            ## 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 (pilih salah satu)

            **Opsi A: OpenAI API Key** (tagihan per token — [lihat harga](https://developers.openai.com/codex/pricing))
            1. Buka [platform.openai.com/api-keys](https://platform.openai.com/api-keys)
            2. Klik **Create new secret key** → salin key
            3. Isi `OpenAI API Key` saat deploy
            4. Layanan otomatis menjalankan `codex login --with-api-key` saat pertama kali boot — tidak perlu langkah manual

            **Opsi B: Langganan ChatGPT** (Plus/Pro/Business — penggunaan termasuk dalam paket)
            1. Kosongkan `OpenAI API Key` saat deploy
            2. Setelah layanan berjalan, buka Zeabur Dashboard → Layanan → **Exec**
            3. Terminal Exec terbuka sebagai root. Tentukan HOME yang benar agar kredensial tersimpan di lokasi yang tepat:
               ```
               HOME=/home/node codex login --device-auth
               ```
            4. Buka URL yang ditampilkan di terminal, otorisasi dengan akun ChatGPT
            5. Restart layanan dari Dashboard
            6. Kredensial disimpan di `/home/node/.codex/auth.json` pada volume persisten dan diperbarui otomatis — langkah ini hanya diperlukan sekali

            ### 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 dan klik deploy. Layanan akan terhubung ke Discord dan/atau Slack secara otomatis.

            ## Pengaturan Slack (Opsional)

            OpenAB mendukung Slack melalui Socket Mode — tidak perlu URL publik.

            1. Buka https://api.slack.com/apps → **Create New App** → **From scratch**
            2. **Socket Mode** → Aktifkan → buat App-Level Token dengan scope `connections:write` → salin token `xapp-...` (`SLACK_APP_TOKEN`)
            3. **Event Subscriptions** → Aktifkan → tambahkan bot events: `app_mention`, `message.channels`, `message.groups`
            4. **OAuth & Permissions** → Bot Token Scopes → tambahkan: `app_mentions:read`, `chat:write`, `channels:history`, `groups:history`, `channels:read`, `groups:read`, `reactions:write`, `files:read`, `users:read`
            5. **Install App** → Install ke workspace → salin token `xoxb-...` (`SLACK_BOT_TOKEN`)
            6. Di setiap channel Slack yang ingin menggunakan bot, jalankan `/invite @YourAppName`

            Isi `SLACK_BOT_TOKEN` dan `SLACK_APP_TOKEN` sebelum deploy. Discord dan Slack dapat berjalan bersamaan.

            ## Penggunaan

            - **@mention bot** di channel Discord atau Slack yang diizinkan untuk memulai percakapan
            - OpenAB membuat **thread** untuk percakapan multi-giliran — tidak perlu @mention untuk pesan selanjutnya
            - Setiap thread dipetakan ke sesi Codex 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).

            ## Menonaktifkan

            Kosongkan `Discord Bot Token` dan `Slack 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)
            - [OpenAI Platform](https://platform.openai.com/)
    ja-JP:
        description: |
            Open Agent Broker — stdio JSON-RPC を通じて Discord と Slack を ACP 対応の coding CLI（Claude Code、Codex、Gemini、Kiro）にブリッジする軽量な Rust ハーネス。
            ソース：https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Discord Bot トークン（オプション）
              description: オプション。https://discord.com/developers/applications から取得したトークン。Slack のみ使用する場合は空のままにしてください。
            - key: OPENAI_API_KEY
              type: STRING
              name: OpenAI API Key（オプション）
              description: オプション。https://platform.openai.com/api-keys から取得した API key。空のまま device flow 認証も可能。
            - 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（カンマ区切り）。空の場合、許可チャンネルの全員が利用可能。
            - key: SLACK_BOT_TOKEN
              type: STRING
              name: Slack Bot トークン（オプション）
              description: オプション。Slack App 設定の Bot User OAuth Token（xoxb-...）。空の場合、Slack アダプターを無効化。
            - key: SLACK_APP_TOKEN
              type: STRING
              name: Slack App トークン（オプション）
              description: オプション。Socket Mode 用の App-Level Token（xapp-...）。Slack Bot Token を設定する場合は必須。
        readme: |
            # OpenAB Codex

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

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

            ## 注意事項

            - **イメージタグ：** このテンプレートは固定バージョン（`0.8.1-beta.5`）を使用します。アップグレードするには、Zeabur Dashboard → サービス → 設定でイメージタグを変更してください。利用可能なタグ：[GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab-codex)。
            - **永続ストレージ：** `/home/node` が永続ボリュームとしてマウントされます。プラグイン、設定、config、認証情報は再起動後も保持されます。
            - **ファイル権限：** コンテナは node ユーザー（uid 1000）として直接実行されます。永続ボリュームの権限問題が発生した場合、サービスを再起動してください。

            ## セットアップ

            ### 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. 認証（いずれか一つ）

            **方法 A：OpenAI API Key**（トークン課金 — [料金を確認](https://developers.openai.com/codex/pricing)）
            1. [platform.openai.com/api-keys](https://platform.openai.com/api-keys) にアクセス
            2. **Create new secret key** をクリック → キーをコピー
            3. デプロイ時に `OpenAI API Key` に入力
            4. サービスの初回起動時に `codex login --with-api-key` が自動実行されます — 手動操作不要

            **方法 B：ChatGPT サブスクリプション**（Plus/Pro/Business — 使用量はプランに含まれます）
            1. デプロイ時に `OpenAI API Key` を空のまま
            2. サービス起動後、Zeabur Dashboard → サービス → **Exec**
            3. Exec ターミナルは root で開きます。認証情報を正しい場所に保存するため HOME を指定して実行：
               ```
               HOME=/home/node codex login --device-auth
               ```
            4. ターミナルに表示された URL を開き、ChatGPT アカウントで認証
            5. Dashboard からサービスを再起動
            6. 認証情報は永続ボリューム `/home/node/.codex/auth.json` に保存され自動更新されます — この手順は一度だけ必要

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

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

            ### 4. デプロイ

            変数を入力してデプロイをクリック。サービスは自動的に Discord および/または Slack に接続します。

            ## Slack セットアップ（オプション）

            OpenAB は Socket Mode 経由で Slack をサポートします — 公開 URL は不要です。

            1. https://api.slack.com/apps → **Create New App** → **From scratch**
            2. **Socket Mode** → 有効化 → scope `connections:write` で App-Level Token を生成 → `xapp-...` token をコピー（`SLACK_APP_TOKEN`）
            3. **Event Subscriptions** → 有効化 → bot events を追加：`app_mention`、`message.channels`、`message.groups`
            4. **OAuth & Permissions** → Bot Token Scopes → 追加：`app_mentions:read`、`chat:write`、`channels:history`、`groups:history`、`channels:read`、`groups:read`、`reactions:write`、`files:read`、`users:read`
            5. **Install App** → ワークスペースにインストール → `xoxb-...` token をコピー（`SLACK_BOT_TOKEN`）
            6. Bot を使用したい各 Slack チャンネルで `/invite @YourAppName` を実行

            デプロイ前に `SLACK_BOT_TOKEN` と `SLACK_APP_TOKEN` 変数を入力してください。Discord と Slack は同時に使用できます。

            ## 使い方

            - 許可された Discord または Slack チャンネルで **Bot を @mention** して会話を開始
            - OpenAB は自動的に **thread** を作成してマルチターン会話を行います — 以降のメッセージでは @mention 不要
            - 各 thread は永続的な Codex 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) を参照。

            ## 無効化

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

            ## リンク

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [Agent Client Protocol](https://github.com/anthropics/agent-protocol)
            - [OpenAI Platform](https://platform.openai.com/)
    zh-CN:
        description: |
            Open Agent Broker — 轻量的 Rust 程序，通过 stdio JSON-RPC 将 Discord 和 Slack 桥接到任何 ACP 兼容的 coding CLI（Claude Code、Codex、Gemini、Kiro）。
            来源：https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Discord Bot Token（选填）
              description: 选填。从 https://discord.com/developers/applications 获取的 Token。只使用 Slack 时可留空。
            - key: OPENAI_API_KEY
              type: STRING
              name: OpenAI API Key（选填）
              description: 选填。从 https://platform.openai.com/api-keys 获取的 API key，或留空后使用 device flow 认证。
            - 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 互动的用户。留空则允许频道中所有人。
            - key: SLACK_BOT_TOKEN
              type: STRING
              name: Slack Bot Token（选填）
              description: 选填。Slack App 设置中的 Bot User OAuth Token（xoxb-...）。留空则停用 Slack 适配器。
            - key: SLACK_APP_TOKEN
              type: STRING
              name: Slack App Token（选填）
              description: 选填。Socket Mode 用的 App-Level Token（xapp-...）。设置 Slack Bot Token 时必填。
        readme: |
            # OpenAB Codex

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

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

            ## 注意事项

            - **镜像标签：** 此模板使用固定版本（`0.8.1-beta.5`）。如需升级，请在 Zeabur Dashboard → 服务 → 设置中更改镜像标签。可用标签：[GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab-codex)。
            - **持久化存储：** `/home/node` 挂载为持久化磁盘。Plugins、设置、config 和认证数据会在重启后保留。
            - **文件权限：** 容器直接以 node 用户（uid 1000）运行。如遇持久化存储权限问题，重启服务即可。

            ## 设置步骤

            ### 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. 认证（任选其一）

            **方式 A：OpenAI API Key**（按 token 计费 — [查看定价](https://developers.openai.com/codex/pricing)）
            1. 前往 [platform.openai.com/api-keys](https://platform.openai.com/api-keys)
            2. 点击 **Create new secret key** → 复制 key
            3. 部署时填入 `OpenAI API Key`
            4. 服务首次启动时会自动执行 `codex login --with-api-key`，无需手动操作

            **方式 B：ChatGPT 订阅**（Plus/Pro/Business — 使用量包含在套餐内）
            1. 部署时将 `OpenAI API Key` 留空
            2. 服务启动后，前往 Zeabur Dashboard → 服务 → **Exec**
            3. Exec 终端以 root 打开，指定正确的 HOME 路径让认证信息存储到正确位置：
               ```
               HOME=/home/node codex login --device-auth
               ```
            4. 打开终端显示的 URL，用 ChatGPT 账号授权
            5. 从 Dashboard 重启服务
            6. 认证信息存储于持久化存储 `/home/node/.codex/auth.json`，会自动刷新，此步骤只需操作一次

            ### 3. 获取 Discord 频道 ID

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

            ### 4. 部署

            填入变量后点击部署即可。服务会自动连接到 Discord 和/或 Slack。

            ## Slack 设置（可选）

            OpenAB 支持通过 Socket Mode 连接 Slack，无需公开 URL。

            1. 前往 https://api.slack.com/apps → **Create New App** → **From scratch**
            2. **Socket Mode** → 启用 → 生成 App-Level Token，scope 选 `connections:write` → 复制 `xapp-...` token（`SLACK_APP_TOKEN`）
            3. **Event Subscriptions** → 启用 → 添加 bot events：`app_mention`、`message.channels`、`message.groups`
            4. **OAuth & Permissions** → Bot Token Scopes → 添加：`app_mentions:read`、`chat:write`、`channels:history`、`groups:history`、`channels:read`、`groups:read`、`reactions:write`、`files:read`、`users:read`
            5. **Install App** → 安装到工作区 → 复制 `xoxb-...` token（`SLACK_BOT_TOKEN`）
            6. 在每个要使用 Bot 的 Slack 频道执行 `/invite @YourAppName`

            部署前填入 `SLACK_BOT_TOKEN` 和 `SLACK_APP_TOKEN` 变量。Discord 和 Slack 可同时运行。

            ## 使用方式

            - 在允许的 Discord 或 Slack 频道中 **@mention Bot** 即可开始对话
            - OpenAB 会自动创建 **thread** 进行多轮对话 — 后续消息不需要再 @mention
            - 每个 thread 对应一个持久的 Codex 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)。

            ## 停用

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

            ## 链接

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [Agent Client Protocol](https://github.com/anthropics/agent-protocol)
            - [OpenAI Platform](https://platform.openai.com/)
    zh-TW:
        description: |
            Open Agent Broker — 輕量的 Rust 程式，透過 stdio JSON-RPC 將 Discord 和 Slack 橋接到任何 ACP 相容的 coding CLI（Claude Code、Codex、Gemini、Kiro）。
            來源：https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Discord Bot Token（選填）
              description: 選填。從 https://discord.com/developers/applications 取得的 Token。只使用 Slack 時可留空。
            - key: OPENAI_API_KEY
              type: STRING
              name: OpenAI API Key（選填）
              description: 選填。從 https://platform.openai.com/api-keys 取得的 API key，或留空後使用 device flow 認證。
            - 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 互動的用戶。留空則允許頻道中所有人。
            - key: SLACK_BOT_TOKEN
              type: STRING
              name: Slack Bot Token（選填）
              description: 選填。Slack App 設定中的 Bot User OAuth Token（xoxb-...）。留空則停用 Slack 介面。
            - key: SLACK_APP_TOKEN
              type: STRING
              name: Slack App Token（選填）
              description: 選填。Socket Mode 用的 App-Level Token（xapp-...）。設定 Slack Bot Token 時必填。
        readme: |
            # OpenAB Codex

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

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

            ## 注意事項

            - **映像標籤：** 此模板使用固定版本（`0.8.1-beta.5`）。如需升級，請在 Zeabur Dashboard → 服務 → 設定中更改映像標籤。可用標籤：[GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab-codex)。
            - **持久化儲存：** `/home/node` 掛載為持久化磁碟。Plugins、設定、config 和認證資料會在重啟後保留。
            - **檔案權限：** 容器直接以 node 用戶（uid 1000）執行。如遇持久化磁碟的權限問題，重啟服務即可。

            ## 設定步驟

            ### 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. 認證（擇一）

            **方式 A：OpenAI API Key**（依 token 計費 — [查看定價](https://developers.openai.com/codex/pricing)）
            1. 前往 [platform.openai.com/api-keys](https://platform.openai.com/api-keys)
            2. 點擊 **Create new secret key** → 複製 key
            3. 部署時填入 `OpenAI API Key`
            4. 服務首次啟動時會自動執行 `codex login --with-api-key`，無需手動操作

            **方式 B：ChatGPT 訂閱**（Plus/Pro/Business — 使用量包含在方案內）
            1. 部署時將 `OpenAI API Key` 留空
            2. 服務啟動後，前往 Zeabur Dashboard → 服務 → **Exec**
            3. Exec 終端機以 root 開啟，指定正確的 HOME 路徑讓認證資料存到正確位置：
               ```
               HOME=/home/node codex login --device-auth
               ```
            4. 開啟終端機顯示的 URL，用 ChatGPT 帳號授權
            5. 從 Dashboard 重啟服務
            6. 認證資料儲存於持久化磁碟 `/home/node/.codex/auth.json`，會自動更新，此步驟只需做一次

            ### 3. 取得 Discord 頻道 ID

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

            ### 4. 部署

            填入變數後點擊部署即可。服務會自動連線到 Discord 和/或 Slack。

            ## Slack 設定（選用）

            OpenAB 支援透過 Socket Mode 連接 Slack，不需要公開 URL。

            1. 前往 https://api.slack.com/apps → **Create New App** → **From scratch**
            2. **Socket Mode** → 啟用 → 產生 App-Level Token，scope 選 `connections:write` → 複製 `xapp-...` token（`SLACK_APP_TOKEN`）
            3. **Event Subscriptions** → 啟用 → 新增 bot events：`app_mention`、`message.channels`、`message.groups`
            4. **OAuth & Permissions** → Bot Token Scopes → 新增：`app_mentions:read`、`chat:write`、`channels:history`、`groups:history`、`channels:read`、`groups:read`、`reactions:write`、`files:read`、`users:read`
            5. **Install App** → 安裝到工作區 → 複製 `xoxb-...` token（`SLACK_BOT_TOKEN`）
            6. 在每個要使用 Bot 的 Slack 頻道執行 `/invite @YourAppName`

            部署前填入 `SLACK_BOT_TOKEN` 和 `SLACK_APP_TOKEN` 變數。Discord 和 Slack 可同時運作。

            ## 使用方式

            - 在允許的 Discord 或 Slack 頻道中 **@mention Bot** 即可開始對話
            - OpenAB 會自動建立 **thread** 進行多輪對話 — 後續訊息不需要再 @mention
            - 每個 thread 對應一個持久的 Codex 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)。

            ## 停用

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

            ## 連結

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [Agent Client Protocol](https://github.com/anthropics/agent-protocol)
            - [OpenAI Platform](https://platform.openai.com/)
