feat: persist settings and enrich conversation context
This commit is contained in:
1 parent
a36723a325
commit
2c100d72b6
84 files changed
+2248
-644
No files matched your search
+22
-42
@@ -74,8 +74,8 @@ rateLimit:
|
||||
jitterMs: 15000
|
||||
|
||||
browser:
|
||||
headless: true
|
||||
userDataDir: "./data/browser"
|
||||
sessionDir: "./data/browser-session"
|
||||
dryRun: true
|
||||
|
||||
database:
|
||||
path: "./data/reddit-bot.db"
|
||||
@@ -89,23 +89,13 @@ dryRun: true # Start in dry run mode
|
||||
Set environment variables:
|
||||
|
||||
```bash
|
||||
export REDDIT_USERNAME="your-username"
|
||||
export REDDIT_PASSWORD="your-password"
|
||||
export OPENROUTER_API_KEY="sk-or-v1-your-key"
|
||||
export WEB_DASHBOARD_TOKEN="long-random-secret"
|
||||
```
|
||||
|
||||
### 3. Initial Login
|
||||
### 3. Import account session
|
||||
|
||||
Run the login script to establish a browser session:
|
||||
|
||||
```bash
|
||||
npm run login
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Open a browser window
|
||||
2. Navigate to Reddit login
|
||||
3. Wait for you to complete login (including 2FA if enabled)
|
||||
4. Save cookies to `data/browser/`
|
||||
Start the dashboard, then upload a combined Reddit and Matrix dump created by the local Chrome extension. Until both identities verify, account work remains paused.
|
||||
|
||||
### 4. Start the Bot
|
||||
|
||||
@@ -144,23 +134,19 @@ docker run -d \
|
||||
-p 3000:3000 \
|
||||
-v $(pwd)/data:/app/data \
|
||||
-e OPENROUTER_API_KEY=sk-or-v1-your-key \
|
||||
-e REDDIT_USERNAME=your-username \
|
||||
-e REDDIT_PASSWORD=your-password \
|
||||
-e BROWSER_HEADLESS=true \
|
||||
-e WEB_DASHBOARD_TOKEN=long-random-secret \
|
||||
reddit-bot:latest
|
||||
```
|
||||
|
||||
### Dockerfile behavior
|
||||
|
||||
The image is based on the Playwright Jammy image rather than Alpine because the
|
||||
runtime needs Chromium and its system libraries. It installs Xvfb, x11vnc,
|
||||
noVNC, Fluxbox, and Websockify for interactive Reddit login; installs the locked
|
||||
Node dependencies; copies the repository; and runs `npm run build`.
|
||||
The image is based on the Playwright Jammy image because the remaining
|
||||
authenticated browser operations need Chromium and its system libraries. It
|
||||
does not install a display server, VNC, or consumer Google Chrome.
|
||||
|
||||
That build produces both `dist/` for the Express server and
|
||||
`apps/dashboard/dist/` for Vite assets. Ports 3000 (dashboard/API) and 6080
|
||||
(noVNC) are exposed, and `docker/entrypoint.sh` starts the display services and
|
||||
application. This is a single-stage image and retains development dependencies
|
||||
`apps/dashboard/dist/` for Vite assets. Port 3000 serves the dashboard/API and
|
||||
the container starts the Node process directly. This is a single-stage image and retains development dependencies
|
||||
needed by the current build/runtime layout.
|
||||
|
||||
---
|
||||
@@ -182,9 +168,7 @@ services:
|
||||
- ./data:/app/data
|
||||
environment:
|
||||
- OPENROUTER_API_KEY=${OPENROUTER_API_KEY}
|
||||
- REDDIT_USERNAME=${REDDIT_USERNAME}
|
||||
- REDDIT_PASSWORD=${REDDIT_PASSWORD}
|
||||
- BROWSER_HEADLESS=true
|
||||
- WEB_DASHBOARD_TOKEN=${WEB_DASHBOARD_TOKEN}
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "http://localhost:3000/api/stats"]
|
||||
@@ -225,9 +209,7 @@ Dokploy is a self-hosted platform for deploying applications. See `DOKPLOY_DEPLO
|
||||
1. **Create Application**: In Dokploy dashboard, create a new Docker application
|
||||
2. **Set Environment Variables**:
|
||||
- `OPENROUTER_API_KEY`
|
||||
- `REDDIT_USERNAME`
|
||||
- `REDDIT_PASSWORD`
|
||||
- `BROWSER_HEADLESS`
|
||||
- `WEB_DASHBOARD_TOKEN`
|
||||
3. **Mount Volume**: Mount `./data` for persistent storage
|
||||
4. **Set Port**: Map container port 3000 to host port
|
||||
5. **Deploy**: Push to repository and trigger deployment
|
||||
@@ -244,9 +226,7 @@ app:
|
||||
|
||||
environment:
|
||||
OPENROUTER_API_KEY: $OPENROUTER_API_KEY
|
||||
REDDIT_USERNAME: $REDDIT_USERNAME
|
||||
REDDIT_PASSWORD: $REDDIT_PASSWORD
|
||||
BROWSER_HEADLESS: "true"
|
||||
WEB_DASHBOARD_TOKEN: $WEB_DASHBOARD_TOKEN
|
||||
|
||||
ports:
|
||||
- container: 3000
|
||||
@@ -276,7 +256,7 @@ app:
|
||||
|
||||
### Performance
|
||||
|
||||
1. **Browser Headless**: Always use headless mode in production
|
||||
1. **Account dumps**: Delete downloaded dumps after the dashboard verifies them
|
||||
2. **WAL Mode**: SQLite WAL mode is enabled by default for concurrent reads
|
||||
3. **Rate Limiting**: Adjust based on Reddit account age and trust level
|
||||
4. **Message Volume**: Start low (10-20/hour) and increase gradually
|
||||
@@ -359,15 +339,15 @@ docker compose start
|
||||
3. Verify environment variables are set
|
||||
4. Check for Zod validation errors in logs
|
||||
|
||||
### Browser Login Fails
|
||||
### Account Import Fails
|
||||
|
||||
**Symptom**: "Browser session expired" or login fails.
|
||||
**Symptom**: Account work stays paused or import verification fails.
|
||||
|
||||
**Steps**:
|
||||
1. Delete browser data: `rm -rf data/browser/`
|
||||
2. Re-run login: `npm run login`
|
||||
3. Check Reddit account is not locked
|
||||
4. Try `BROWSER_HEADLESS=false` for debugging
|
||||
1. Sign in to Reddit in local Chrome
|
||||
2. Open Reddit Chat and wait for the extension badge to show `OK`
|
||||
3. Export and upload a new combined session dump
|
||||
4. Check logs for Reddit or Matrix identity errors
|
||||
|
||||
### AI Analysis Fails
|
||||
|
||||
|
||||
Reference in new issue
Block a user