SkateSpots/ai-proxy/skatespots-ai.service
SkateSpots ec06a63b01 feat(ai-proxy): run the AI proxy on the CVM host, ready to switch over
Same proxy as netlify/functions/ai.mjs, rebuilt as a standalone Bun service on
the CVM host so AI calls stop spending Netlify compute/bandwidth credits and
the sats-paid Routstr key lives on our box.

- ai-proxy/server.ts: Bun.serve on 127.0.0.1:8787 — NIP-98 + Pro gate, model
  allowlist, per-IP throttle, /api/ai + /api/ai/status. Own tsconfig
  (typecheck:ai in npm test); eslint-ignored like cvm-server.
- ai-proxy/{package.json,.env.example,skatespots-ai.service,Caddyfile,DEPLOY.md}.
- scripts/deploy-ai-proxy.sh (npm run deploy:ai): scp + bun install + unit +
  restart, mirroring deploy-cvm.sh.
- Client: one place decides the AI base, src/lib/sasquatchAi.ts (also the NIP-98
  u tag). Defaults unchanged (/api/ai on Netlify); set VITE_SASQUATCH_AI_BASE to
  move it. Fully reversible.

Deployed and verified on the host: /api/ai/status returns the live Routstr
balance. Public TLS (DNS + Caddy) is the remaining step before switching the app
over, so no client behaviour changes yet.
2026-09-28 13:32:05 +07:00

28 lines
1.1 KiB
Desktop File

# ─────────────────────────────────────────────────────────────────────────────
# systemd unit for the SkateSpots AI proxy (Bun, on the CVM host).
# Installed by scripts/deploy-ai-proxy.sh — do not hand-edit on the host.
# ─────────────────────────────────────────────────────────────────────────────
[Unit]
Description=SkateSpots AI proxy (Routstr)
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/skatespots-ai
EnvironmentFile=/home/ubuntu/skatespots-ai/.env
ExecStart=/home/ubuntu/.bun/bin/bun run server.ts
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
SyslogIdentifier=skatespots-ai
# Basic hardening — mirrors the CVM unit (bun stays happy; binds localhost only).
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target