Skip to content

Latest commit

 

History

History
384 lines (305 loc) · 14.1 KB

installation.md

File metadata and controls

384 lines (305 loc) · 14.1 KB

Installation guide

This guide shows how to install github-agent-bridge for a new OpenClaw deployment.

Prerequisites

Before installing the bridge, have these ready:

  • Python 3.11 or newer.
  • OpenClaw CLI installed with openclaw infer model run --local --prompt --json support for the intent classifier.
  • GitHub CLI (gh) installed and authenticated as the GitHub user/bot that should react to comments.
  • For webhook ingestion: a public HTTPS endpoint, a per-owner webhook secret, and a reverse proxy to the socket-activated ingress.
  • For IMAP ingestion or fallback: an inbox that receives GitHub notifications and IMAP access, usually through an app password.
  • A delivery route for OpenClaw agent work, for example a Telegram chat id, Discord channel, or another OpenClaw-supported channel.
  • Optional but recommended: user-level systemd for the executor, webhook socket, reader timer, and monitor timer.

Install the CLI

Install from GitHub. There is no PyPI publish yet.

python3 -m pip install --user \
  'git+https://github.com/gisce/github-agent-bridge.git'

Make sure the script directory is on PATH and both installed entrypoints are available:

export PATH="$HOME/.local/bin:$PATH"
gab --help
command -v github-agent-bridge-reader-run

For a pinned install, replace vX.Y.Z with a release tag:

python3 -m pip install --user \
  'git+https://github.com/gisce/github-agent-bridge.git@vX.Y.Z'

Create runtime directories

mkdir -p ~/.config/github-agent-bridge
mkdir -p ~/.local/state/github-agent-bridge
chmod 700 ~/.config/github-agent-bridge ~/.local/state/github-agent-bridge

Initialize the SQLite database:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 init-db

Configure policy

Start from the example policy:

curl -fsSL \
  https://raw.githubusercontent.com/gisce/github-agent-bridge/main/policy.example.json \
  -o ~/.config/github-agent-bridge/policy.json
chmod 600 ~/.config/github-agent-bridge/policy.json

Edit at least these fields:

{
  "trustedOrgs": ["your-org"],
  "enabledRepos": ["your-org/your-repo"],
  "orgRoutes": {
    "your-org": {
      "agent": "your-openclaw-agent",
      "channel": "telegram",
      "to": "YOUR_CHAT_ID"
    }
  },
  "repoRoles": {
    "your-org/your-repo": "maintainer"
  }
}

Use enabledRepos as the live canary allowlist. Keep it narrow until behavior is clean.

Configure environment

Create a private environment file:

cat > ~/.config/github-agent-bridge/env <<'EOF_ENV'
GITHUB_AGENT_BRIDGE_MODE=shadow
GITHUB_AGENT_BRIDGE_WORKERS=2
GITHUB_AGENT_BRIDGE_REVIEW_TIMEOUT=900
GITHUB_AGENT_BRIDGE_WORK_TIMEOUT=3600
GITHUB_AGENT_BRIDGE_OPENCLAW_BIN=openclaw
GITHUB_AGENT_BRIDGE_NODE_BIN=
GITHUB_AGENT_BRIDGE_DEFAULT_CHANNEL=telegram
GITHUB_AGENT_BRIDGE_DEFAULT_TO=

# Webhook input starts observationally. Use an absolute policy path.
GITHUB_AGENT_BRIDGE_WEBHOOK_MODE=shadow
GITHUB_AGENT_BRIDGE_WEBHOOK_POLICY=/home/you/.config/github-agent-bridge/policy.json
GITHUB_AGENT_BRIDGE_WEBHOOK_PRIMARY_ACK=
GITHUB_AGENT_BRIDGE_WEBHOOK_SECRETS_BY_OWNER='{"your-org":["replace-with-webhook-secret"]}'

# IMAP input/fallback.
GITHUB_AGENT_BRIDGE_EMAIL=you@example.com
GITHUB_AGENT_BRIDGE_PASSWORD=imap-app-password
GITHUB_AGENT_BRIDGE_IMAP_HOST=imap.gmail.com
GITHUB_AGENT_BRIDGE_IMAP_PORT=993
GITHUB_AGENT_BRIDGE_MAILBOX=INBOX
GITHUB_AGENT_BRIDGE_MARK_SEEN=
EOF_ENV
chmod 600 ~/.config/github-agent-bridge/env

Leave GITHUB_AGENT_BRIDGE_MARK_SEEN empty until the bridge owns GitHub notification handling for that inbox.

Keep GITHUB_AGENT_BRIDGE_WEBHOOK_MODE=shadow until signed deliveries and coverage are visible. canary additionally requires the target repository in policy webhookCanaryRepos; primary additionally requires GITHUB_AGENT_BRIDGE_WEBHOOK_PRIMARY_ACK=true and still honors enabledRepos. Replace /home/you with the deployment user's real absolute home path. See ingestion.md.

If openclaw is not on the systemd PATH, set GITHUB_AGENT_BRIDGE_OPENCLAW_BIN to the absolute path from command -v openclaw.

Check prerequisites explicitly before continuing:

gh auth status
openclaw agent --help >/dev/null
gab --help >/dev/null

Validate without side effects

First confirm the policy parses and the database is readable:

python3 -m json.tool ~/.config/github-agent-bridge/policy.json >/dev/null
gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  monitor --no-systemd

Then enqueue a known GitHub comment URL and process it in shadow mode:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  enqueue-comment-url 'https://github.com/your-org/your-repo/pull/123#issuecomment-456'

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  run --mode shadow --once

Then read the inbox once without marking messages seen:

set -a
. ~/.config/github-agent-bridge/env
set +a

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  read-imap-once \
  --imap-host "$GITHUB_AGENT_BRIDGE_IMAP_HOST" \
  --imap-port "$GITHUB_AGENT_BRIDGE_IMAP_PORT" \
  --email "$GITHUB_AGENT_BRIDGE_EMAIL" \
  --password "$GITHUB_AGENT_BRIDGE_PASSWORD" \
  --mailbox "$GITHUB_AGENT_BRIDGE_MAILBOX"

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 jobs --limit 20

Run manually

Run the executor in shadow mode first:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  run --mode shadow --workers 2

When the canary is clean, switch to live:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  run --mode live --workers 2

To dedicate an executor to a specific class of work, add --work-intent. For example, keep lightweight review/comment jobs moving with:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  run --mode live --workers 2 --work-intent review_only

Use --work-intent work_allowed for implementation-only capacity, or omit the flag for a general pool. The queue still prevents concurrent jobs for the same GitHub issue/PR even when multiple pools are running.

Run the reader separately. Add --mark-seen only when the bridge should consume GitHub notifications from the configured mailbox:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  read-imap-once \
  --email "$GITHUB_AGENT_BRIDGE_EMAIL" \
  --password "$GITHUB_AGENT_BRIDGE_PASSWORD" \
  --mailbox "$GITHUB_AGENT_BRIDGE_MAILBOX" \
  --mark-seen

Install user systemd units

Clone the repository if you did not keep a checkout, because the systemd unit files are not installed by pip:

git clone https://github.com/gisce/github-agent-bridge.git /tmp/github-agent-bridge
cd /tmp/github-agent-bridge

Install the units:

mkdir -p ~/.config/systemd/user
cp systemd/github-agent-bridge.service ~/.config/systemd/user/
cp systemd/github-agent-bridge-reader.service ~/.config/systemd/user/
cp systemd/github-agent-bridge-reader.timer ~/.config/systemd/user/
cp systemd/github-agent-bridge-monitor.service ~/.config/systemd/user/
cp systemd/github-agent-bridge-monitor.timer ~/.config/systemd/user/
cp systemd/github-agent-bridge-feedback.service ~/.config/systemd/user/
cp systemd/github-agent-bridge-feedback.timer ~/.config/systemd/user/
cp systemd/github-agent-bridge-autoupdate.service ~/.config/systemd/user/
cp systemd/github-agent-bridge-autoupdate.timer ~/.config/systemd/user/
# Optional dashboard API for operator tooling:
cp systemd/github-agent-bridge-dashboard.service ~/.config/systemd/user/
# Recommended for public GitHub webhooks. The socket remains owned by systemd
# while the small ingress process restarts.
cp systemd/github-agent-bridge-webhook.service ~/.config/systemd/user/
cp systemd/github-agent-bridge-webhook.socket ~/.config/systemd/user/

systemctl --user daemon-reload
systemctl --user enable --now github-agent-bridge.service
# Enable the webhook socket when using signed GitHub delivery.
systemctl --user enable --now github-agent-bridge-webhook.socket
# Keep the reader timer enabled while IMAP is an input or fallback.
systemctl --user enable --now github-agent-bridge-reader.timer
systemctl --user enable --now github-agent-bridge-monitor.timer
systemctl --user enable --now github-agent-bridge-feedback.timer
systemctl --user enable --now github-agent-bridge-autoupdate.timer
# Optional dashboard:
# systemctl --user enable --now github-agent-bridge-dashboard.service

The reader timer calls the packaged github-agent-bridge-reader-run console script installed by pip. That wrapper reads ~/.config/github-agent-bridge/env through the systemd unit, quotes Gmail mailbox names with spaces for IMAP, and only adds --mark-seen when GITHUB_AGENT_BRIDGE_MARK_SEEN is explicitly enabled.

Inspect status and logs:

systemctl --user status github-agent-bridge.service
systemctl --user status github-agent-bridge-reader.timer
systemctl --user status github-agent-bridge-feedback.timer
journalctl --user -u github-agent-bridge.service -f

The optional dashboard API is separate from the executor and should stay loopback-only by default. Configure GitHub OAuth before enabling it:

cat >> ~/.config/github-agent-bridge/env <<'EOF'
GITHUB_AGENT_BRIDGE_DASHBOARD_SECRET_KEY=replace-with-random-secret
GITHUB_OAUTH_CLIENT_ID=replace-with-github-oauth-client-id
GITHUB_OAUTH_CLIENT_SECRET=replace-with-github-oauth-client-secret
GITHUB_AGENT_BRIDGE_DASHBOARD_ALLOWED_USERS=your-github-login
GITHUB_AGENT_BRIDGE_DASHBOARD_ALLOWED_TEAMS=
GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_USERS=your-github-login
GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_TEAMS=
GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL=https://bridge.example.com
GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_MAX_AGE_SECONDS=28800
GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_VERSION=1
GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PUBLIC_KEY=replace-with-vapid-public-key
GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PRIVATE_KEY=replace-with-vapid-private-key
GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_CONTACT=mailto:admin@example.com
GITHUB_AGENT_BRIDGE_GITHUB_APP_ID=your-github-app-id
GITHUB_AGENT_BRIDGE_GITHUB_APP_SLUG=
GITHUB_AGENT_BRIDGE_WEB_PUSH_ICON_URL=
EOF

Create the GitHub OAuth App with callback URL http://127.0.0.1:8765/auth/callback for local operation, or the same path on the public HTTPS origin when using a reverse proxy. See dashboard-github-oauth.md for the full GitHub setup and security checklist.

Browser push notifications require the public HTTPS origin in GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL, the VAPID key pair above, and a dashboard sign-in from each GitHub user who wants job completion notifications. Set GITHUB_AGENT_BRIDGE_GITHUB_APP_ID or GITHUB_AGENT_BRIDGE_GITHUB_APP_SLUG when notifications should use the image configured on the GitHub App automatically. GITHUB_AGENT_BRIDGE_WEB_PUSH_ICON_URL can still override the notification icon with an explicit URL.

When webhooks are enabled, start github-agent-bridge-webhook.socket and route the exact /api/webhooks/github path to 127.0.0.1:8766. systemd owns the listening socket and keeps a backlog while github-agent-bridge-webhook.service is replaced, so dashboard restarts and short ingress restarts do not produce a connection-refused window. Do not enable the service directly; enabling the socket starts it on demand.

When the dashboard is published through nginx, use the proxy settings from operations.md or start from nginx-dashboard.conf. The example keeps live SSE streams unbuffered and replaces nginx's generic "Bad Gateway" response with an auto-refreshing restart page while github-agent-bridge-dashboard.service is briefly unavailable.

systemctl --user status github-agent-bridge-dashboard.service
systemctl --user status github-agent-bridge-webhook.socket
systemctl --user status github-agent-bridge-webhook.service
curl http://127.0.0.1:8765/api/health
curl http://127.0.0.1:8766/api/health

Monitor health

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  monitor

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 status

A healthy install has no old pending jobs, no blocked dispatches, and no stale running jobs.

Go live safely

  1. Keep the executor in GITHUB_AGENT_BRIDGE_MODE=shadow until jobs look correct.
  2. Run webhook ingress in GITHUB_AGENT_BRIDGE_WEBHOOK_MODE=shadow; keep IMAP non-mutating and compare coverage.
  3. Keep enabledRepos narrow and add only explicit repositories to webhookCanaryRepos.
  4. Switch the executor to live, then switch webhook ingestion to canary.
  5. Investigate every unexplained actionable IMAP-only event or cross-source mismatch before widening the canary.
  6. Switch to primary only with GITHUB_AGENT_BRIDGE_WEBHOOK_PRIMARY_ACK=true; keep the IMAP reader enabled for the stable fallback window.
  7. Disable the IMAP reader only after the second clean window and a tested rollback plan. Setting --mark-seen is independent of webhook mode.

Reusability status

The bridge is reusable by another OpenClaw operator, but it is not a standalone SaaS and it is not yet a one-command installer.

Reusable today:

  • packaged Python CLI (gab),
  • SQLite queue and monitor,
  • signed, socket-activated GitHub webhook ingress,
  • IMAP reader for direct or fallback ingestion,
  • JSON policy model,
  • prompt resources and repository roles,
  • systemd unit templates,
  • shadow/dry-run/live rollout modes.

Deployment-specific setup still required:

  • OpenClaw agent ids and delivery routes,
  • GitHub bot/user authentication through gh,
  • public TLS routing and per-owner webhook secrets,
  • IMAP mailbox credentials while IMAP ingestion/fallback is enabled,
  • trusted org/repo policy,
  • systemd paths and environment values.