# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: OpenAB Copilot
spec:
    description: |
        Open Agent Broker — a lightweight Rust harness that bridges Discord to any ACP-compatible coding CLI (Claude Code, Codex, Gemini, Kiro, Copilot) 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
          description: Token from https://discord.com/developers/applications
        - 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: copilot). 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 Copilot

        [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 Copilot variant (`openab-copilot`) which uses [GitHub Copilot CLI](https://github.com/github/copilot-cli) as the agent backend.

        ## Important Notes

        - **Paid subscription required:** GitHub Copilot CLI requires a **paid** Copilot plan (Pro, Pro+, Business, or Enterprise). The Free tier does not include CLI/ACP access.
        - **Public preview:** Copilot CLI ACP support has been in [public preview](https://github.blog/changelog/2026-01-28-acp-support-in-copilot-cli-is-now-in-public-preview/) since Jan 2026. Behavior may change.
        - **Auth after deploy:** Unlike Claude/Codex, there is no API-key env var for Copilot. You must run `gh auth login` inside the container after the first deploy (see below).
        - **Image tag:** This template tracks the floating `beta` channel and auto-updates with each new OpenAB 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 GitHub OAuth credentials (`~/.config/gh/`) 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. Deploy

        Fill in the Discord bot token and (optional) channel IDs, then click deploy. The container will start in sleep mode until Copilot is authenticated.

        ### 3. Authenticate with GitHub Copilot (device flow)

        After the service starts, open Zeabur Dashboard → Service → **Exec** and run:

        ```bash
        runuser -u node -- gh auth login --hostname github.com --git-protocol https -p https -w
        ```

        Follow the device-code URL in your browser to authorize. The OAuth token is stored under `/home/node/.config/gh/` and persisted across restarts.

        Verify with:

        ```bash
        runuser -u node -- gh auth status
        ```

        Then restart the service so openab picks up the new credentials.

        ### 4. 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`

        ## 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-copilot` 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 Copilot session (24h TTL)
        - Copilot CLI defaults to Claude Sonnet 4.6; other models (Opus 4.6, Haiku 4.5, GPT-5.3-Codex, Gemini 3 Pro) are selected interactively via `/model` and are not controllable in ACP mode

        ## Customization

        | File | Description |
        |------|-------------|
        | `/home/node/.config/openab/config.toml` | OpenAB config (sessions, reactions, STT, etc.) |
        | `/home/node/.config/gh/` | GitHub OAuth credentials (from `gh auth login`) |

        `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) and the [Copilot agent guide](https://github.com/openabdev/openab/blob/main/docs/copilot.md).

        ## 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)
        - [GitHub Copilot CLI](https://github.com/github/copilot-cli)
        - [gh CLI device-flow auth](https://github.com/openabdev/openab/blob/main/docs/gh-auth-device-flow.md)
    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-copilot
                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}
                OPENAB_AGENT_COMMAND:
                    default: copilot
                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
                    chown -R node:node /home/node
                    chmod 755 /home/node/.config 2>/dev/null || true

                    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

                    # Copilot auth check: gh auth must be set up before openab can talk to copilot
                    if ! runuser -u node -- gh auth status >/dev/null 2>&1; then
                      echo "openab: gh CLI is not authenticated — sleeping"
                      echo "openab: exec into the container and run: runuser -u node -- gh auth login --hostname github.com --git-protocol https -p https -w"
                      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

                    chown -R node:node "$CONFIG_DIR"
                    exec runuser -u node --preserve-environment -- openab run --config "${OPENAB_CONFIG_URL:-$CONFIG_FILE}"
                  permission: 493
                  envsubst: null
                - path: /opt/config.toml.template
                  template: |
                    [agent]
                    args = ["--acp", "--stdio"]
                  permission: null
                  envsubst: null
localization:
    es-ES:
        description: |
            Open Agent Broker — un arnés ligero en Rust que conecta Discord con cualquier CLI de coding compatible con ACP (Claude Code, Codex, Gemini, Kiro, Copilot) 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
              description: Token obtenido de https://discord.com/developers/applications
            - 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.
            - 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.
        readme: |
            # OpenAB Copilot

            Esta plantilla despliega la variante Copilot (`openab-copilot`) de [OpenAB](https://github.com/openabdev/openab), usando [GitHub Copilot CLI](https://github.com/github/copilot-cli) como backend de agente.

            ## Notas Importantes

            - **Suscripción de pago requerida:** Copilot CLI requiere un plan de pago (Pro, Pro+, Business o Enterprise). El plan Free no incluye acceso CLI/ACP.
            - **Public preview:** El soporte ACP de Copilot CLI está en public preview desde enero de 2026.
            - **Autenticación después del despliegue:** A diferencia de Claude/Codex, no hay variable de API key. Debe ejecutar `gh auth login` dentro del contenedor tras el primer despliegue.
            - **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.
            - **Almacenamiento persistente:** `/home/node` está montado como volumen persistente e incluye las credenciales OAuth de GitHub.

            ## Configuración

            1. Obtener Discord Bot Token e invitar el bot
            2. Desplegar la plantilla (el servicio dormirá hasta que Copilot esté autenticado)
            3. En Zeabur Dashboard → Servicio → **Exec**, ejecutar:

               ```bash
               runuser -u node -- gh auth login --hostname github.com --git-protocol https -p https -w
               ```

            4. Completar la autorización en el navegador y reiniciar el servicio

            ## 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-copilot` 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 conversación
            - OpenAB crea un thread para conversaciones multi-turno
            - Copilot CLI usa Claude Sonnet 4.6 por defecto (no se puede cambiar en ACP)

            ## Personalización

            | Archivo | Descripción |
            |---------|-------------|
            | `/home/node/.config/openab/config.toml` | Configuración de OpenAB |
            | `/home/node/.config/gh/` | Credenciales OAuth de GitHub |

            `config.toml` se crea a partir de una plantilla integrada en el primer arranque. Después, edite el archivo directamente. Para restablecer los valores predeterminados: `rm /home/node/.config/openab/config.toml`

            ## Webhook / Bot Integration

            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), añada lo siguiente a su `config.toml`:

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

            Con esta configuración, openab responde a cualquier bot o webhook que lo @mencione. Para restringir a un webhook específico, añada también:

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

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

            ## Desactivar

            Deje `Discord Bot Token` vacío. El servicio entra en modo sleep sin fallar.

            ## Enlaces

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [GitHub Copilot CLI](https://github.com/github/copilot-cli)
    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, Copilot) melalui stdio JSON-RPC.
            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: OPENAB_ALLOWED_CHANNELS
              type: STRING
              name: ID Channel Discord (opsional)
              description: Opsional. ID channel Discord tempat bot mendengarkan, dipisahkan koma.
            - key: OPENAB_ALLOWED_USERS
              type: STRING
              name: ID Pengguna Discord (opsional)
              description: Opsional. ID pengguna Discord yang diizinkan berinteraksi dengan bot.
        readme: |
            # OpenAB Copilot

            Template ini men-deploy varian Copilot (`openab-copilot`) dari [OpenAB](https://github.com/openabdev/openab), menggunakan [GitHub Copilot CLI](https://github.com/github/copilot-cli) sebagai backend agen.

            ## Catatan Penting

            - **Butuh langganan berbayar:** Copilot CLI membutuhkan paket Copilot berbayar (Pro, Pro+, Business, atau Enterprise). Paket Free tidak mendukung CLI/ACP.
            - **Public preview:** Dukungan ACP Copilot CLI dalam public preview sejak Januari 2026.
            - **Autentikasi setelah deploy:** Tidak seperti Claude/Codex, tidak ada env var API key. Anda perlu menjalankan `gh auth login` di dalam container setelah deploy pertama.
            - **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.
            - **Penyimpanan persisten:** `/home/node` di-mount sebagai volume persisten, termasuk kredensial OAuth GitHub.

            ## Pengaturan

            1. Dapatkan Discord Bot Token dan undang bot
            2. Deploy template (layanan akan sleep sampai Copilot terotentikasi)
            3. Di Zeabur Dashboard → Layanan → **Exec**, jalankan:

               ```bash
               runuser -u node -- gh auth login --hostname github.com --git-protocol https -p https -w
               ```

            4. Ikuti URL untuk otorisasi di browser, lalu restart layanan

            ## 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-copilot` 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-turn
            - Copilot CLI default menggunakan Claude Sonnet 4.6 (tidak dapat diganti di ACP)

            ## Kustomisasi

            | File | Keterangan |
            |------|-----------|
            | `/home/node/.config/openab/config.toml` | Konfigurasi OpenAB |
            | `/home/node/.config/gh/` | Kredensial OAuth GitHub |

            `config.toml` dibuat dari template bawaan saat pertama kali boot. Setelah itu, edit file langsung. Untuk mereset ke default: `rm /home/node/.config/openab/config.toml`

            ## Webhook / Bot Integration

            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 yang @mention-nya. Untuk membatasi ke webhook tertentu, tambahkan juga:

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

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

            ## Nonaktifkan

            Kosongkan `Discord Bot Token`. Layanan akan masuk mode sleep tanpa crash.

            ## Tautan

            - [OpenAB GitHub](https://github.com/openabdev/openab)
            - [GitHub Copilot CLI](https://github.com/github/copilot-cli)
    ja-JP:
        description: |
            Open Agent Broker — stdio JSON-RPC を通じて Discord を ACP 対応の coding CLI（Claude Code、Codex、Gemini、Kiro、Copilot）にブリッジする軽量な Rust ハーネス。
            ソース：https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Discord Bot トークン
              description: https://discord.com/developers/applications から取得したトークン
            - key: OPENAB_ALLOWED_CHANNELS
              type: STRING
              name: Discord チャンネル ID（オプション）
              description: オプション。Bot が監視する Discord チャンネル ID（カンマ区切り）。空の場合、全チャンネルで応答。
            - key: OPENAB_ALLOWED_USERS
              type: STRING
              name: Discord ユーザー ID（オプション）
              description: オプション。Bot と対話できるユーザーの Discord ユーザー ID（カンマ区切り）。
        readme: |
            # OpenAB Copilot

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

            このテンプレートは Copilot バリアント（`openab-copilot`）をデプロイし、[GitHub Copilot CLI](https://github.com/github/copilot-cli) をエージェントバックエンドとして使用します。

            ## 注意事項

            - **有料サブスクリプション必須：** Copilot CLI には有料 Copilot プラン（Pro、Pro+、Business、Enterprise）が必要です。Free プランでは CLI/ACP が使用できません。
            - **Public preview：** Copilot CLI の ACP サポートは 2026 年 1 月から public preview で、動作が変わる可能性があります。
            - **デプロイ後に認証：** Claude/Codex と異なり、API キー環境変数はありません。初回デプロイ後にコンテナ内で `gh auth login` を実行してください。
            - **イメージタグ：** このテンプレートはfloating `beta` タグを追跡しています（OpenAB の新しい beta リリースが公開されると自動更新）。特定のバージョンに pin するには、Zeabur Dashboard → サービス → 設定でイメージタグを変更してください。
            - **永続ストレージ：** `/home/node` が永続ボリュームで、GitHub OAuth 認証情報（`~/.config/gh/`）も保持されます。

            ## セットアップ

            1. Discord Bot Token を取得して Bot を招待
            2. 本テンプレートをデプロイ（認証前は sleep 状態）
            3. Zeabur Dashboard → サービス → **Exec** で以下を実行：

               ```bash
               runuser -u node -- gh auth login --hostname github.com --git-protocol https -p https -w
               ```

            4. 表示される URL で認証し、サービスを再起動

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

            Telegram を使う場合は [OpenAB Telegram テンプレート](https://zeabur.com/templates/12LLKI) をデプロイし、image tag を `beta-copilot` に変更して対応する `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 を作成してマルチターン会話
            - Copilot CLI はデフォルトで Claude Sonnet 4.6 を使用（ACP モードではモデル切替不可）

            ## カスタマイズ

            | ファイル | 説明 |
            |---------|------|
            | `/home/node/.config/openab/config.toml` | OpenAB 設定 |
            | `/home/node/.config/gh/` | GitHub OAuth 認証情報 |

            `config.toml` は初回起動時に内蔵テンプレートから作成されます。以降は直接ファイルを編集してください。デフォルトにリセットするには：`rm /home/node/.config/openab/config.toml`

            ## 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)
            - [GitHub Copilot CLI](https://github.com/github/copilot-cli)
    zh-CN:
        description: |
            Open Agent Broker — 轻量的 Rust 程序，通过 stdio JSON-RPC 将 Discord 桥接到任何 ACP 兼容的 coding CLI（Claude Code、Codex、Gemini、Kiro、Copilot）。
            来源：https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Discord Bot Token
              description: 从 https://discord.com/developers/applications 获取的 Token
            - key: OPENAB_ALLOWED_CHANNELS
              type: STRING
              name: Discord 频道 ID（选填）
              description: 选填。Bot 监听的 Discord 频道 ID，以逗号分隔。留空则允许所有频道。
            - key: OPENAB_ALLOWED_USERS
              type: STRING
              name: Discord 用户 ID（选填）
              description: 选填。以逗号分隔的 Discord 用户 ID，限制可与 Bot 互动的用户。
        readme: |
            # OpenAB Copilot

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

            此模板部署 Copilot 变体（`openab-copilot`），以 [GitHub Copilot CLI](https://github.com/github/copilot-cli) 作为 agent 后端。

            ## 注意事项

            - **需付费订阅：** GitHub Copilot CLI 需要**付费** Copilot 方案（Pro、Pro+、Business 或 Enterprise），免费版不支持 CLI/ACP。
            - **Public preview：** Copilot CLI 的 ACP 支持自 2026 年 1 月起进入 public preview，行为可能变动。
            - **部署后才认证：** 与 Claude/Codex 不同，Copilot 没有 API key 环境变量。首次部署后需进入容器运行 `gh auth login`（见下方）。
            - **镜像标签：** 此模板使用floating `beta` 標籤。若要 pin 至特定版本，请在 Zeabur Dashboard → 服务 → 设置中更改镜像标签。
            - **持久化存储：** `/home/node` 挂载为持久化磁盘，包括 GitHub OAuth 凭证 `~/.config/gh/`。

            ## 设置步骤

            ### 1. 获取 Discord Bot Token

            参考上游文档建立 Bot 并启用 Message Content Intent，邀请 Bot 加入服务器。

            ### 2. 部署

            填入 Discord Bot Token（及选填频道 ID）后点击部署。尚未认证 Copilot 前，容器会进入 sleep 状态。

            ### 3. 认证 GitHub Copilot（device flow）

            服务启动后，前往 Zeabur Dashboard → 服务 → **Exec** 执行：

            ```bash
            runuser -u node -- gh auth login --hostname github.com --git-protocol https -p https -w
            ```

            按照 device code URL 在浏览器授权。Token 存储在 `/home/node/.config/gh/`。完成后重启服务。

            ### 4. 获取 Discord 频道 ID

            Discord → **用户设置** → **高级** → 启用 **开发者模式** → 右键频道 → **复制频道 ID**。

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

            若要使用 Telegram，请部署 [OpenAB Telegram 模板](https://zeabur.com/templates/12LLKI)，并把 image tag 换成 `beta-copilot`、设置对应的 `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
            - Copilot CLI 默认使用 Claude Sonnet 4.6；ACP 模式下无法切换模型

            ## 自定义设置

            | 文件 | 说明 |
            |------|------|
            | `/home/node/.config/openab/config.toml` | OpenAB 配置 |
            | `/home/node/.config/gh/` | GitHub OAuth 凭据 |

            `config.toml` 在首次启动时由内置模板创建，之后直接编辑文件即可。要恢复默认值：`rm /home/node/.config/openab/config.toml`

            ## 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)
            - [GitHub Copilot CLI](https://github.com/github/copilot-cli)
    zh-TW:
        description: |
            Open Agent Broker — 輕量的 Rust 程式，透過 stdio JSON-RPC 將 Discord 橋接到任何 ACP 相容的 coding CLI（Claude Code、Codex、Gemini、Kiro、Copilot）。
            來源：https://github.com/openabdev/openab
        variables:
            - key: DISCORD_BOT_TOKEN
              type: STRING
              name: Discord Bot Token
              description: 從 https://discord.com/developers/applications 取得的 Token
            - 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 Copilot

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

            此模板部署 Copilot 變體（`openab-copilot`），以 [GitHub Copilot CLI](https://github.com/github/copilot-cli) 作為 agent 後端。

            ## 注意事項

            - **需付費訂閱：** GitHub Copilot CLI 需要**付費** Copilot 方案（Pro、Pro+、Business 或 Enterprise），免費版不支援 CLI/ACP。
            - **Public preview：** Copilot CLI 的 ACP 支援自 2026 年 1 月起進入 [public preview](https://github.blog/changelog/2026-01-28-acp-support-in-copilot-cli-is-now-in-public-preview/)，行為可能變動。
            - **部署後才認證：** 與 Claude/Codex 不同，Copilot 沒有 API key 環境變數。首次部署後需進入容器執行 `gh auth login`（見下方步驟）。
            - **映像標籤：** 此模板追蹤 floating `beta` 標籤，OpenAB 推出新 beta 版時自動更新。若要 pin 至特定版本，請在 Zeabur Dashboard → 服務 → 設定中更改映像標籤。可用標籤：[GitHub Packages](https://github.com/openabdev/openab/pkgs/container/openab)。
            - **持久化儲存：** `/home/node` 掛載為持久化磁碟，plugins、設定、config、GitHub OAuth 認證（`~/.config/gh/`）都會保留。

            ## 設定步驟

            ### 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. 部署

            填入 Discord Bot Token（以及選填的頻道 ID）後點擊部署。尚未認證 Copilot 前，容器會進入 sleep 狀態。

            ### 3. 認證 GitHub Copilot（device flow）

            服務啟動後，前往 Zeabur Dashboard → 服務 → **Exec** 執行：

            ```bash
            runuser -u node -- gh auth login --hostname github.com --git-protocol https -p https -w
            ```

            依照 device code URL 在瀏覽器完成授權。Token 會儲存在 `/home/node/.config/gh/`，重啟後仍保留。

            驗證：

            ```bash
            runuser -u node -- gh auth status
            ```

            完成後重啟服務。

            ### 4. 取得 Discord 頻道 ID

            1. Discord → **使用者設定** → **進階** → 啟用 **開發者模式**
            2. 對頻道按右鍵 → **複製頻道 ID**
            3. 多個頻道用逗號分隔

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

            若要使用 Telegram，請部署 [OpenAB Telegram 模板](https://zeabur.com/templates/12LLKI)，並把 image tag 換成 `beta-copilot`、設定對應的 `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 對應一個持久的 Copilot session（預設 24 小時 TTL）
            - Copilot CLI 預設使用 Claude Sonnet 4.6；ACP 模式下無法切換模型

            ## 自訂設定

            | 檔案 | 說明 |
            |------|------|
            | `/home/node/.config/openab/config.toml` | OpenAB 設定 |
            | `/home/node/.config/gh/` | GitHub OAuth 認證資料 |

            `config.toml` 首次啟動時由內建範本建立，之後直接編輯檔案即可。要恢復預設值：`rm /home/node/.config/openab/config.toml`

            ## 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)
            - [GitHub Copilot CLI](https://github.com/github/copilot-cli)
            - [Copilot agent 指南](https://github.com/openabdev/openab/blob/main/docs/copilot.md)
