Skip to content

Commit f84addf

Browse files
committed
docs: restore env vars, troubleshooting, and boundaries sections to AGENTS.md
1 parent e99788a commit f84addf

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,93 @@ See `.cursor/rules/post-change-checks.mdc` for the full decision tree.
172172
Deployed on GCP. See `terraform/` for all infra-as-code.
173173
See `.cursor/rules/terraform-makefile.mdc` — always use `make` targets, never raw `terraform`.
174174
See `docs/deploy-from-scratch.md` for the full deploy guide.
175+
176+
---
177+
178+
## Environment Variables
179+
180+
| Variable | Required | Default | Purpose |
181+
| -------------------- | ---------- | --------------- | -------------------------------------------------- |
182+
| `TELEGRAM_BOT_TOKEN` | Yes (prod) || Bot API token from @BotFather |
183+
| `TELEGRAM_CHAT_ID` | Yes (prod) || Target chat for briefings |
184+
| `AGENTMAIL_API_KEY` | No || For email-based sources (Daily Degen, OpenSea) |
185+
| `TIMEZONE` | No | `Europe/Berlin` | Briefing timezone |
186+
| `USE_MOCK_DATA` | No | `false` | Use mock sources |
187+
| `LOG_LEVEL` | No | `info` | Logging verbosity |
188+
| `PORT` | No | `8080` | HTTP server port |
189+
| `GCS_DATA_BUCKET` | No || GCS bucket for rankings history (set by Terraform) |
190+
191+
---
192+
193+
## Troubleshooting
194+
195+
### "gcloud: command not found"
196+
197+
The gcloud CLI isn't installed. If you're on a clawd-provisioned server, it should be pre-installed via cloud-init. Otherwise:
198+
199+
```bash
200+
# Debian/Ubuntu — install from Google's apt repo
201+
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/cloud.google.gpg
202+
echo "deb [signed-by=/etc/apt/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
203+
sudo apt-get update && sudo apt-get install -y google-cloud-cli
204+
```
205+
206+
### "Permission denied" on `gcloud run services logs read`
207+
208+
You need a GCP service account with read-only access. Run the bootstrap script from the `clawd` repo:
209+
210+
```bash
211+
# From a machine with GCP admin access:
212+
./scripts/gcp-setup.sh <gcp-project-id> <bot-name>
213+
```
214+
215+
This creates a `<bot-name>-readonly` service account with `roles/run.viewer` + `roles/logging.viewer`, stores the key in `pass`, and activates it. The key lives at `pass bot-<bot-name>/gcp/<project-id>/sa-key`.
216+
217+
If the key is in pass but not activated (e.g. after server rebuild):
218+
219+
```bash
220+
# Re-activate from pass
221+
TMPKEY=$(mktemp) && pass show bot-<bot-name>/gcp/<project-id>/sa-key > "$TMPKEY" \
222+
&& gcloud auth activate-service-account --key-file="$TMPKEY" --project=<project-id> \
223+
&& rm "$TMPKEY"
224+
```
225+
226+
### "bun: command not found"
227+
228+
This project uses Bun, not Node. Install:
229+
230+
```bash
231+
curl -fsSL https://bun.sh/install | bash
232+
```
233+
234+
### Tests fail with "Cannot find module" after git pull
235+
236+
```bash
237+
bun install # Reinstall deps after lockfile changes
238+
```
239+
240+
### Terraform errors / missing variables
241+
242+
Never run `terraform` directly — always use the Makefile from `terraform/`:
243+
244+
```bash
245+
cd terraform && make plan # Loads secrets from ../.env.local automatically
246+
```
247+
248+
### Cloud Run logs show "Container failed to start"
249+
250+
Check memory limits (Puppeteer needs 2Gi) and environment variables:
251+
252+
```bash
253+
bun run logs # Tail Cloud Run logs
254+
bun run healthcheck # Hit /health endpoint
255+
```
256+
257+
---
258+
259+
## Boundaries
260+
261+
-**Do:** Add sources, fix formatting, improve tests, update Terraform
262+
-**Do:** Run `bun dev --dry-run` to verify changes locally
263+
- ⚠️ **Ask first:** Changing Telegram message format (user-facing), adding new GCP services, modifying CI pipeline
264+
- 🚫 **Never:** Raw `gcloud` infra commands, hardcode secrets, modify `.env.local` without asking, bypass trunk/typecheck

0 commit comments

Comments
 (0)