Document connecting OpenHands to Forgejo

Cover the Forgejo/Gitea provider (token + Docker DNS) and the workspace
clone path used with SANDBOX_VOLUMES for day-to-day coding.
This commit is contained in:
tim 2026-07-22 06:36:41 -07:00
parent 112cf3a2bf
commit 84902d5cb5

View file

@ -100,22 +100,41 @@ Root folders: `/data/media/tv`, `/data/media/movies`, `/data/media/music` (hardl
**Bonsai** — No UI login. Smoke test: `curl -s http://192.168.8.123:8081/v1/models`. Needs GGUF in `models/bonsai/` and `docker compose build bonsai` once.
**OpenHands** — On the server (`/opt/stack`): `docker compose --profile coding up -d openhands`.
Settings → Advanced: base URL `http://bonsai:8080/v1`, API key `sk-local-bonsai` (or `.env` value), model `openai/<id from /v1/models>`.
UI: http://192.168.8.123:3001
**Forgejo** — First visit http://192.168.8.123:3002 → install wizard (SQLite is pre-selected via env) → create **admin**.
If connection refused: container crash-looped (built-in SSH + image OpenSSH both on :22). Compose sets `START_SSH_SERVER=false`; recreate with `docker compose up -d forgejo --force-recreate`.
Then: **+ → New Repository** → clone into workspace:
**LLM (required once)**
Settings → Advanced: base URL `http://bonsai:8080/v1`, API key `sk-local-bonsai`, model `openai/<id from /v1/models>`.
**Connect to Forgejo (pick A and/or B)**
**A — Provider (browse / open repos in OpenHands)**
1. Forgejo → avatar → **Settings → Applications** → generate a token (scopes: `read:repository`, `write:repository`, `read:user` — or full access on a trusted LAN).
2. OpenHands → **Settings → Git / Integrations** (or **Secrets** / provider list):
- Provider: **Forgejo** or **Gitea** (same API)
- Base URL: `http://forgejo:3000` (Docker DNS on `arr-net`; use this from OpenHands)
From a browser on your PC you use `http://192.168.8.123:3002` — that is *not* what the OpenHands container should use.
- Token: paste the Forgejo token
3. Start a conversation → choose repository → `tim/stack`.
**B — Workspace mount (most reliable for editing + git push)**
Compose already mounts `${AI_WORKSPACE_DIR}` (default `/opt/stack/workspace`) into the agent sandbox as `/workspace`.
On the **server**:
```bash
# HTTPS
git clone http://192.168.8.123:3002/YOU/repo.git /opt/stack/workspace/repo
# HTTPS with token (one-time; token in URL — prefer SSH below)
# git clone http://tim:TOKEN@192.168.8.123:3002/tim/stack.git /opt/stack/workspace/stack
# SSH (port 2222 — host :22 stays for machine login)
git clone ssh://git@192.168.8.123:2222/YOU/repo.git /opt/stack/workspace/repo
# or: git remote add origin ssh://git@192.168.8.123:2222/YOU/repo.git
# SSH (key already on Forgejo for user tim)
git clone ssh://git@192.168.8.123:2222/tim/stack.git /opt/stack/workspace/stack
```
Point OpenHands / Open WebUI `AI_WORKSPACE_DIR` at those clones. After admin exists, set `FORGEJO_DISABLE_REGISTRATION=true` in `.env` and recreate: `docker compose up -d forgejo`.
Then in OpenHands: work in `/workspace/stack` (or set the conversation workspace to that path).
Agent can `git commit` / `git push` if the host clone has credentials (SSH agent or stored remote URL).
If OpenHands cannot reach `forgejo` by name, ensure both services are on `arr-net` (`docker compose up -d forgejo openhands`).
**Forgejo** — http://192.168.8.123:3002
If connection refused: crash-loop from dual SSH; compose uses `START_SSH_SERVER=false`. Recreate: `docker compose up -d forgejo --force-recreate`.
---