diff --git a/.env.example b/.env.example deleted file mode 100644 index eecebe30..00000000 --- a/.env.example +++ /dev/null @@ -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 diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index e6f3cd3e..d92ce0cd 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -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: | diff --git a/.gitignore b/.gitignore index 1a64bf91..cecd030b 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/README.md b/README.md index 1c145c7b..6bb44ade 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/apps/agent/.env.example b/apps/agent/.env.example new file mode 100644 index 00000000..aec9e1d2 --- /dev/null +++ b/apps/agent/.env.example @@ -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 diff --git a/apps/agent/package.json b/apps/agent/package.json index c08afa65..3539a1e1 100644 --- a/apps/agent/package.json +++ b/apps/agent/package.json @@ -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", diff --git a/apps/agent/wxt.config.ts b/apps/agent/wxt.config.ts index 1f35bd2f..667b54c1 100644 --- a/apps/agent/wxt.config.ts +++ b/apps/agent/wxt.config.ts @@ -50,7 +50,6 @@ export default defineConfig({ ], }, vite: () => ({ - envDir: '../..', build: { sourcemap: 'hidden', }, diff --git a/apps/server/.env.example b/apps/server/.env.example new file mode 100644 index 00000000..a4d389db --- /dev/null +++ b/apps/server/.env.example @@ -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 diff --git a/apps/server/package.json b/apps/server/package.json index cb4aa88d..2e59e9da 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -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:*", diff --git a/package.json b/package.json index c194b34e..f4316980 100644 --- a/package.json +++ b/package.json @@ -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",