fix: create env file per package (#141)

* feat: create .env per package

* chore: minor fix to gitignore

* fix: update CLA to use separate repo
This commit is contained in:
Felarof
2025-12-31 10:43:47 -08:00
committed by GitHub
parent 473a7b8ebd
commit 39ce685443
10 changed files with 94 additions and 78 deletions

View File

@@ -1,39 +0,0 @@
# Ports
BROWSEROS_CDP_PORT=9001 # Chromium CDP port (server connects as client)
BROWSEROS_SERVER_PORT=9002 # Main HTTP server (contains MCP endpoint, chat endpoint, health)
BROWSEROS_EXTENSION_PORT=9003 # WebSocket server for controller extension
VITE_BROWSEROS_SERVER_PORT=9002 # Port used by AgentUI to connect to the server (must match SERVER_PORT)
# Directories (optional - defaults to cwd)
# BROWSEROS_RESOURCES_DIR=./resources
# BROWSEROS_EXECUTION_DIR=./out
# BrowserOS config
BROWSEROS_CONFIG_URL=https://llm.browseros.com/api/browseros-server/config
BROWSEROS_BINARY=/Applications/BrowserOS.app/Contents/MacOS/BrowserOS
BROWSEROS_VERSION=
BROWSEROS_INSTALL_ID=
BROWSEROS_CLIENT_ID=
# Agent build
USE_BROWSEROS_BINARY=true
BROWSEROS_DISABLE_SERVER=true
BROWSEROS_USER_DATA_DIR=/tmp/browseros-dev
# Telemetry for BrowserOS-server
POSTHOG_API_KEY=
POSTHOG_ENDPOINT=
SENTRY_DSN=
# Telemetry for Agent UI
VITE_PUBLIC_POSTHOG_KEY=
VITE_PUBLIC_POSTHOG_HOST=
VITE_PUBLIC_SENTRY_DSN=
# Sentry build (source maps upload)
SENTRY_AUTH_TOKEN=
SENTRY_ORG=
SENTRY_PROJECT=
NODE_ENV=development
LOG_LEVEL=info

View File

@@ -25,10 +25,13 @@ jobs:
uses: contributor-assistant/github-action@v2.6.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_SIGNATURES_TOKEN }}
with:
path-to-signatures: '.github/cla-signatures.json'
path-to-signatures: 'cla-signatures.json'
path-to-document: 'https://github.com/${{ github.repository }}/blob/main/CLA.md'
branch: 'main'
remote-organization-name: 'browseros-ai'
remote-repository-name: 'cla-signatures'
allowlist: 'bot*,*[bot],dependabot,renovate,github-actions,snyk-bot,imgbot,greenkeeper,semantic-release-bot,allcontributors'
lock-pullrequest-aftermerge: false
custom-notsigned-prcomment: |

3
.gitignore vendored
View File

@@ -9,8 +9,9 @@ lerna-debug.log*
.env.dev
.env.prod
# Ignore all .env files
# Ignore all .env files except .env.example
**/.env.*
!**/.env.example
# sqlite database

View File

@@ -76,43 +76,45 @@ packages/
# Install dependencies
bun install
# Copy environment file
cp .env.example .env.development
# Copy environment files for each package
cp apps/server/.env.example apps/server/.env.development
cp apps/agent/.env.example apps/agent/.env.development
```
### Environment Variables
Single `.env.development` at root. Key variables:
Each package has its own `.env.development` file:
**Ports**
- `apps/server/.env.development` - Server configuration
- `apps/agent/.env.development` - Agent UI configuration
**Server Variables** (`apps/server/.env.development`)
| Variable | Default | Description |
|----------|---------|-------------|
| `BROWSEROS_SERVER_PORT` | 9100 | Server HTTP port (MCP, chat, health) |
| `BROWSEROS_SERVER_PORT` | 9100 | HTTP server port (MCP, chat, health) |
| `BROWSEROS_CDP_PORT` | 9000 | Chromium CDP port (server connects as client) |
| `BROWSEROS_EXTENSION_PORT` | 9300 | WebSocket port for controller extension |
| `VITE_BROWSEROS_SERVER_PORT` | 9100 | Agent UI uses this to connect to server (must match `BROWSEROS_SERVER_PORT`) |
| `BROWSEROS_CONFIG_URL` | - | Remote config endpoint for rate limits |
| `BROWSEROS_INSTALL_ID` | - | Unique installation identifier (analytics) |
| `BROWSEROS_CLIENT_ID` | - | Client identifier (analytics) |
| `POSTHOG_API_KEY` | - | Server-side PostHog API key |
| `SENTRY_DSN` | - | Server-side Sentry DSN |
**BrowserOS Config**
**Agent Variables** (`apps/agent/.env.development`)
| Variable | Description |
|----------|-------------|
| `BROWSEROS_CONFIG_URL` | Remote config endpoint for rate limits and LLM provider config |
| `BROWSEROS_INSTALL_ID` | Unique installation identifier (for analytics) |
| `BROWSEROS_CLIENT_ID` | Client identifier (for analytics) |
| Variable | Default | Description |
|----------|---------|-------------|
| `BROWSEROS_SERVER_PORT` | 9100 | Passed to BrowserOS via CLI args |
| `BROWSEROS_CDP_PORT` | 9000 | Passed to BrowserOS via CLI args |
| `BROWSEROS_EXTENSION_PORT` | 9300 | Passed to BrowserOS via CLI args |
| `VITE_BROWSEROS_SERVER_PORT` | 9100 | Agent UI connects to server (must match `BROWSEROS_SERVER_PORT`) |
| `BROWSEROS_BINARY` | - | Path to BrowserOS binary |
| `USE_BROWSEROS_BINARY` | true | Use BrowserOS instead of default Chrome |
| `VITE_PUBLIC_POSTHOG_KEY` | - | Agent UI PostHog key |
| `VITE_PUBLIC_SENTRY_DSN` | - | Agent UI Sentry DSN |
**Telemetry**
Server (Bun process) and Agent UI (Chrome extension) run in different environments, so they require separate telemetry configuration. Server uses `posthog-node`, Agent UI uses `posthog-js`. The `VITE_` prefix exposes variables to the browser bundle.
| Variable | Description |
|----------|-------------|
| `POSTHOG_API_KEY` | Server-side PostHog API key |
| `POSTHOG_ENDPOINT` | Server-side PostHog endpoint |
| `SENTRY_DSN` | Server-side Sentry DSN |
| `VITE_PUBLIC_POSTHOG_KEY` | Agent UI PostHog key |
| `VITE_PUBLIC_POSTHOG_HOST` | Agent UI PostHog host |
| `VITE_PUBLIC_SENTRY_DSN` | Agent UI Sentry DSN |
> **Note:** Port variables are duplicated in both files and must be kept in sync when running server and agent together.
### Commands

23
apps/agent/.env.example Normal file
View File

@@ -0,0 +1,23 @@
# Ports (passed to BrowserOS via CLI args)
BROWSEROS_CDP_PORT=9000
BROWSEROS_SERVER_PORT=9100
BROWSEROS_EXTENSION_PORT=9300
VITE_BROWSEROS_SERVER_PORT=9100 # Must match SERVER_PORT
# BrowserOS launch config
BROWSEROS_BINARY=/Applications/BrowserOS.app/Contents/MacOS/BrowserOS
USE_BROWSEROS_BINARY=true
BROWSEROS_DISABLE_SERVER=true
BROWSEROS_USER_DATA_DIR=/tmp/browseros-dev
# Telemetry (browser bundle)
VITE_PUBLIC_POSTHOG_KEY=
VITE_PUBLIC_POSTHOG_HOST=
VITE_PUBLIC_SENTRY_DSN=
# Sentry build (source maps)
SENTRY_AUTH_TOKEN=
SENTRY_ORG=
SENTRY_PROJECT=
NODE_ENV=development

View File

@@ -5,7 +5,7 @@
"version": "0.0.20",
"type": "module",
"scripts": {
"dev": "bun --env-file=../../.env.development wxt",
"dev": "bun --env-file=.env.development wxt",
"dev:firefox": "wxt -b firefox",
"build": "wxt build",
"build:firefox": "wxt build -b firefox",

View File

@@ -50,7 +50,6 @@ export default defineConfig({
],
},
vite: () => ({
envDir: '../..',
build: {
sourcemap: 'hidden',
},

22
apps/server/.env.example Normal file
View File

@@ -0,0 +1,22 @@
# Ports
BROWSEROS_CDP_PORT=9000
BROWSEROS_SERVER_PORT=9100
BROWSEROS_EXTENSION_PORT=9300
# Directories (optional - defaults to cwd)
# BROWSEROS_RESOURCES_DIR=./resources
# BROWSEROS_EXECUTION_DIR=./out
# BrowserOS config
BROWSEROS_CONFIG_URL=https://llm.browseros.com/api/browseros-server/config
BROWSEROS_VERSION=
BROWSEROS_INSTALL_ID=
BROWSEROS_CLIENT_ID=
# Telemetry
POSTHOG_API_KEY=
POSTHOG_ENDPOINT=
SENTRY_DSN=
NODE_ENV=development
LOG_LEVEL=info

View File

@@ -8,9 +8,15 @@
"browseros-server": "./src/index.ts"
},
"scripts": {
"start": "bun src/index.ts",
"typecheck": "tsc --noEmit",
"test": "bun test"
"start": "bun --env-file=.env.development src/index.ts",
"build": "bun ../../scripts/build_server.ts --mode=prod --target=all",
"test": "bun run test:cleanup && bun --env-file=.env.development test tests/tools tests/common",
"test:all": "bun run test:cleanup && bun --env-file=.env.development test",
"test:cdp": "bun run test:cleanup && bun --env-file=.env.development test tests/tools/cdp-based",
"test:controller": "bun run test:cleanup && bun --env-file=.env.development test tests/tools/controller-based",
"test:integration": "bun run test:cleanup && bun --env-file=.env.development test tests/server.integration.test.ts",
"test:cleanup": "./tests/__helpers__/cleanup.sh",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@browseros/shared": "workspace:*",

View File

@@ -9,19 +9,18 @@
"packages/*"
],
"scripts": {
"start:server": "bun --env-file=.env.development apps/server/src/index.ts",
"start:server": "bun run --filter @browseros/server start",
"start:agent": "bun run --filter agent dev",
"build:server": "bun scripts/build_server.ts --mode=prod --target=all",
"build:server": "bun run --filter @browseros/server build",
"build:agent": "bun run --filter agent build",
"build:ext": "bun run --filter browseros-controller build",
"test": "bun run test:cleanup && bun --env-file=.env.development test apps/server/tests/tools apps/server/tests/common",
"test:all": "bun run test:cleanup && bun --env-file=.env.development test",
"test:cdp": "bun run test:cleanup && bun --env-file=.env.development test apps/server/tests/tools/cdp-based",
"test:controller": "bun run test:cleanup && bun --env-file=.env.development test apps/server/tests/tools/controller-based",
"test:integration": "bun run test:cleanup && bun --env-file=.env.development test apps/server/tests/server.integration.test.ts",
"test:cleanup": "./apps/server/tests/__helpers__/cleanup.sh",
"test": "bun run --filter @browseros/server test",
"test:all": "bun run --filter @browseros/server test:all",
"test:cdp": "bun run --filter @browseros/server test:cdp",
"test:controller": "bun run --filter @browseros/server test:controller",
"test:integration": "bun run --filter @browseros/server test:integration",
"typecheck": "tsc --build",
"lint": "bunx biome check",