GitHub Copilot
| 所需密钥 | 覆盖文件 |
|---|---|
DISCORD_BOT_TOKEN |
values-github-copilot.yaml |
TELEGRAM_BOT_TOKEN(同时设置 auth.deviceFlow.notify: telegram) |
values-github-copilot.yaml 加上下方的覆盖设置 |
使用条件¶
需要 Discord 或 Telegram 机器人以及 GitHub Copilot 使用权限。还需要持久存储,以便重复使用登录令牌。
从 Hermes v0.23.0 起,copilot 提供商迁移到了
GitHub Copilot Labs 插件。
如果配置档案选择了 Copilot,Hermes 会自动安装插件。如果限制了出站流量,
除了允许访问 Copilot API,还要确保首次启动时可以访问插件目录和 GitHub 上的插件源代码。
保留 config.model.provider: copilot。Chart 的设备登录仍将 COPILOT_GITHUB_TOKEN
写入 Hermes 卷,插件仍读取同一个键。如果只在另一台机器上通过 GitHub 或 Copilot CLI 登录,
插件无法使用那台机器上的凭据。请改用 Chart 的设备登录。
安装¶
helm upgrade --install hermes-agent ./charts/hermes-agent \
--namespace hermes-agent --create-namespace \
-f charts/hermes-agent/values-github-copilot.yaml \
--set-string env.DISCORD_BOT_TOKEN='<real-value>' --wait
如果示例需要多项凭据,请通过 --set-string 传入所有列出的值,或使用 extraEnvFrom 引用现有的 Secret。
部署时的配置¶
在 GitHub 上批准 Pod 首次启动日志或 Discord 提示中显示的设备代码。
后续启动¶
令牌保存在持久卷中的 HERMES_HOME/.env。下次启动时,初始化容器会通过
https://api.github.com/user 检查令牌。如果令牌仍有效,则跳过登录。
如果验证端点返回 HTTP 401 或 403,初始化容器会重新发起设备登录。此检查不受 Copilot 套餐影响。
Chart 1.18.0 及更早版本使用 copilot_internal/v2/token 进行检查。该端点对 Copilot Free
账号的有效令牌也会返回 403,导致每次重启都要求新的设备代码
(#349)。如果覆盖 validateUrl,
请使用对有效令牌返回 200、仅在需要重新登录时返回 401 或 403 的端点。
使用 Telegram 代替 Discord¶
设置 auth.deviceFlow.notify: telegram,并提供 TELEGRAM_BOT_TOKEN、
TELEGRAM_HOME_CHANNEL 和 TELEGRAM_ALLOWED_USERS,替换 Discord 的对应设置。
设备代码会发送到 Telegram 聊天。设置 readyNotify.enabled: true 后,智能体就绪时也会在同一个聊天中发送通知。
使用 Copilot Free 账号实测时,登录成功,收到了就绪通知,并通过 gpt-4o 得到了回复。
可用模型取决于 GitHub 套餐。
完整覆盖文件¶
# values-github-copilot.yaml
#
# Hermes Agent backed by GitHub Copilot, authenticated at startup via the OAuth
# 2.0 Device Authorization Grant (RFC 8628): no API key to paste. The
# "auth-device-login" init container surfaces a verification link + code to your
# Discord home channel (or Telegram: set `auth.deviceFlow.notify: telegram` and
# pass TELEGRAM_BOT_TOKEN, TELEGRAM_HOME_CHANNEL and TELEGRAM_ALLOWED_USERS
# instead of the Discord values), waits for you to approve it on github.com (phone is
# fine), then persists the resulting token to HERMES_HOME/.env where Hermes
# reads it natively. The token lives on the persistent volume, so restarts are
# fast; re-login only happens when it is missing or revoked.
#
# Copilot's token API rejects PATs: a device-flow `gho_`/`ghu_` token is
# required, which is exactly what this flow produces.
#
# All secrets below are DUMMY placeholders. Do NOT commit real keys: override
# them at install time (--set-string) or inject via a SealedSecret + extraEnvFrom
# (see examples/argocd/).
#
# helm upgrade --install hermes-agent ./charts/hermes-agent \
# --namespace hermes-agent --create-namespace \
# -f charts/hermes-agent/values-github-copilot.yaml \
# --set-string env.DISCORD_BOT_TOKEN='<real-bot-token>' --wait
#
# # then watch the login init container for the verification prompt:
# kubectl logs deploy/hermes-agent -n hermes-agent -c auth-device-login -f
config:
model:
# GitHub Copilot provider. Hermes v0.23.0 auto-installs its Labs plugin.
provider: copilot
# Any model your Copilot subscription can reach. Examples: gpt-4o, gpt-4.1,
# claude-sonnet-4.5, gemini-2.5-pro, gpt-5.
default: gpt-4o
terminal:
backend: local
# Authenticate the Copilot credential via the OAuth device flow at startup.
auth:
deviceFlow:
enabled: true
provider: github-copilot
# Deliver the verification link + code to the agent's Discord home channel
# (reuses DISCORD_BOT_TOKEN + DISCORD_HOME_CHANNEL). It is always also
# printed to the init container logs as a fallback.
notify: discord
env:
# The chart's default placeholder is for OpenAI; this deployment doesn't use
# it (the Copilot token is fetched at runtime via device flow). Set to a clear
# sentinel so no real OpenAI key is implied.
OPENAI_API_KEY: "unused"
# --- Discord bot (secret bits) ------------------------------------------
# Setting the token is enough to auto-enable Discord: no config.yaml change.
# The login init container reuses this same bot to post the verification link.
# Create the bot at https://discord.com/developers/applications, enable the
# "Message Content Intent", and invite it to your server.
DISCORD_BOT_TOKEN: "MTA0DUMMYtoken000000000000.DUMMY.replace_me_with_a_real_token"
# Non-secret Discord knobs go here (plain env, not the Secret). The login init
# container also reads DISCORD_HOME_CHANNEL from here to know where to post.
extraEnv:
- name: DISCORD_HOME_CHANNEL # channel id for cron / notification / login delivery
value: "000000000000000000" # DUMMY - your channel id (18 digits)
- name: DISCORD_ALLOWED_USERS # comma-separated user ids allowed to talk
value: "111111111111111111" # DUMMY - your Discord user id
- name: DISCORD_ALLOW_ALL_USERS # true only for throwaway/dev bots
value: "false"
# Persistence is required for device-flow login: the token is written here so it
# survives restarts (otherwise you would re-approve on every restart). Empty
# storageClass = cluster default; on a Raspberry Pi cluster that is typically
# local-path (k3s) or microk8s-hostpath: both ReadWriteOnce, which is exactly
# what this single-writer workload wants.
persistence:
enabled: true
storageClass: ""
accessModes:
- ReadWriteOnce
size: 5Gi
# Defaults are already tuned for small arm64 nodes; shown here for visibility.
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: "1"
memory: 1Gi