Skip to content

Commit 8317469

Browse files
authored
Feat/automation build (#48)
## Summary * **New Features** * Added Automated and Manual modes for Docker builds and runs. * Automated mode bypasses OAuth login UI and auto-enables evaluation by default (when no prior setting exists). * Manual mode preserves standard authentication and manual evaluation controls. * **Documentation** * Updated Docker README with mode-specific build/run instructions, image names, and a sample automated workflow. * Added guidance comparing Automated vs Manual modes, including authentication and evaluation behavior.
1 parent 815c084 commit 8317469

File tree

6 files changed

+79
-18
lines changed

6 files changed

+79
-18
lines changed

docker/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,16 @@ RUN git remote add upstream https://github.com/BrowserOperator/browser-operator-
4747
RUN git fetch upstream
4848
RUN git checkout upstream/main
4949

50-
# Build Browser Operator version
50+
# Allow configurable automated mode
51+
ARG AUTOMATED_MODE=false
52+
53+
# Set build-time flags based on Docker arg
54+
RUN if [ "$AUTOMATED_MODE" = "true" ]; then \
55+
sed -i 's/AUTOMATED_MODE: false/AUTOMATED_MODE: true/' \
56+
front_end/panels/ai_chat/core/BuildConfig.ts; \
57+
fi
58+
59+
# Build Browser Operator version with current changes
5160
RUN npm run build
5261

5362
# Production stage

docker/README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ The Docker setup uses a multi-stage build process:
2222
From the repository root directory:
2323

2424
```bash
25-
# Build the Docker image
26-
docker build -f docker/Dockerfile -t devtools-frontend .
25+
# Build with automated mode (default - bypasses OAuth, auto-enables evaluation)
26+
docker build -f docker/Dockerfile -t browser-operator-automated .
27+
28+
# Build with normal mode (requires manual authentication)
29+
docker build -f docker/Dockerfile --build-arg AUTOMATED_MODE=false -t browser-operator-manual .
2730

2831
# Or use docker-compose (recommended)
2932
docker-compose -f docker/docker-compose.yml build
@@ -32,8 +35,11 @@ docker-compose -f docker/docker-compose.yml build
3235
### Running the Container
3336

3437
```bash
35-
# Using docker run
36-
docker run -d -p 8000:8000 --name devtools-frontend devtools-frontend
38+
# Automated mode (no authentication required, evaluation auto-enabled)
39+
docker run -d -p 8000:8000 --name browser-operator-automated browser-operator-automated
40+
41+
# Manual mode (requires OAuth/API key setup)
42+
docker run -d -p 8000:8000 --name browser-operator-manual browser-operator-manual
3743

3844
# Or using docker-compose (recommended)
3945
docker-compose -f docker/docker-compose.yml up -d
@@ -67,6 +73,29 @@ docker/
6773
└── README.md # This file
6874
```
6975

76+
## Automated Mode vs Manual Mode
77+
78+
### Automated Mode (Default)
79+
- **Purpose**: Optimized for Docker/CI environments and automated workflows
80+
- **Authentication**: Bypasses OAuth panel - no manual setup required
81+
- **Evaluation**: Automatically enables evaluation mode for API wrapper connectivity
82+
- **Use cases**: Production deployments, CI/CD, headless automation, API integration
83+
84+
### Manual Mode
85+
- **Purpose**: Standard interactive usage
86+
- **Authentication**: Requires OAuth setup or API key configuration
87+
- **Evaluation**: Manual enable/disable in settings
88+
- **Use cases**: Development, interactive testing, manual usage
89+
90+
```bash
91+
# Example automated mode workflow
92+
docker build -f docker/Dockerfile -t browser-operator-automated .
93+
docker run -d -p 8000:8000 --name browser-operator browser-operator-automated
94+
95+
# Ready to use immediately - no authentication required!
96+
# Evaluation server can connect automatically via WebSocket (ws://localhost:8080)
97+
```
98+
7099
## Advanced Usage
71100

72101
### Development Mode

front_end/panels/ai_chat/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ devtools_module("ai_chat") {
4848
"core/Types.ts",
4949
"core/AgentService.ts",
5050
"core/Constants.ts",
51+
"core/BuildConfig.ts",
5152
"core/structured_response.ts",
5253
"core/GraphConfigs.ts",
5354
"core/ConfigurableGraph.ts",
@@ -176,6 +177,7 @@ _ai_chat_sources = [
176177
"core/Types.ts",
177178
"core/AgentService.ts",
178179
"core/Constants.ts",
180+
"core/BuildConfig.ts",
179181
"core/structured_response.ts",
180182
"core/GraphConfigs.ts",
181183
"core/ConfigurableGraph.ts",

front_end/panels/ai_chat/common/EvaluationConfig.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import { createLogger } from '../core/Logger.js';
66
import { WebSocketRPCClient } from './WebSocketRPCClient.js';
7+
import { BUILD_CONFIG } from '../core/BuildConfig.js';
78

89
const logger = createLogger('EvaluationConfig');
910

@@ -49,6 +50,13 @@ class EvaluationConfigStore {
4950

5051
private loadFromLocalStorage(): void {
5152
try {
53+
// In automated mode, set default to enabled if not already set
54+
if (BUILD_CONFIG.AUTOMATED_MODE &&
55+
localStorage.getItem('ai_chat_evaluation_enabled') === null) {
56+
localStorage.setItem('ai_chat_evaluation_enabled', 'true');
57+
logger.info('Automated mode: defaulted evaluation to enabled');
58+
}
59+
5260
const enabled = localStorage.getItem('ai_chat_evaluation_enabled') === 'true';
5361
const endpoint = localStorage.getItem('ai_chat_evaluation_endpoint') || 'ws://localhost:8080';
5462
const secretKey = localStorage.getItem('ai_chat_evaluation_secret_key') || '';
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2025 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/**
6+
* Build-time configuration for automated deployments and Docker environments.
7+
*
8+
* This file contains constants that are set during the build process to configure
9+
* behavior for different deployment scenarios.
10+
*/
11+
export const BUILD_CONFIG = {
12+
/**
13+
* Automated mode flag for Docker/CI deployments.
14+
* When true:
15+
* - Bypasses OAuth authentication panel
16+
* - Automatically enables evaluation mode
17+
* - Optimized for headless/automated usage
18+
*/
19+
AUTOMATED_MODE: false, // Will be set to true during Docker build
20+
} as const;

front_end/panels/ai_chat/ui/AIChatPanel.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { OpenRouterProvider } from '../LLM/OpenRouterProvider.js';
2020
import { createLogger } from '../core/Logger.js';
2121
import { isEvaluationEnabled, getEvaluationConfig } from '../common/EvaluationConfig.js';
2222
import { EvaluationAgent } from '../evaluation/remote/EvaluationAgent.js';
23+
import { BUILD_CONFIG } from '../core/BuildConfig.js';
2324
// Import of LiveAgentSessionComponent is not required here; the element is
2425
// registered by ChatView where it is used.
2526

@@ -1395,9 +1396,8 @@ export class AIChatPanel extends UI.Panel.Panel {
13951396
* @returns true if at least one provider has valid credentials
13961397
*/
13971398
#hasAnyProviderCredentials(): boolean {
1398-
logger.info('=== CHECKING ALL PROVIDER CREDENTIALS ===');
1399+
13991400
const selectedProvider = localStorage.getItem(PROVIDER_SELECTION_KEY) || 'openai';
1400-
logger.info('Currently selected provider:', selectedProvider);
14011401

14021402
// Check all providers except LiteLLM (unless LiteLLM is selected)
14031403
const providers = ['openai', 'groq', 'openrouter'];
@@ -1407,19 +1407,13 @@ export class AIChatPanel extends UI.Panel.Panel {
14071407
providers.push('litellm');
14081408
}
14091409

1410-
logger.info('Providers to check:', providers);
1411-
14121410
for (const provider of providers) {
1413-
logger.info(`Checking provider: ${provider}`);
14141411
const validation = LLMClient.validateProviderCredentials(provider);
1415-
logger.info(`Provider ${provider} validation result:`, validation);
14161412
if (validation.isValid) {
1417-
logger.info(`✅ Found valid credentials for provider: ${provider}`);
14181413
return true;
14191414
}
14201415
}
14211416

1422-
logger.info('❌ No valid credentials found for any provider');
14231417
return false;
14241418
}
14251419

@@ -1997,12 +1991,11 @@ export class AIChatPanel extends UI.Panel.Panel {
19971991
inputPlaceholder: this.#getInputPlaceholderText(),
19981992
// Add OAuth login state
19991993
showOAuthLogin: (() => {
1994+
if (BUILD_CONFIG.AUTOMATED_MODE) {
1995+
return false;
1996+
}
20001997
const hasCredentials = this.#hasAnyProviderCredentials();
2001-
const showOAuth = !hasCredentials;
2002-
logger.info('=== OAUTH LOGIN UI DECISION ===');
2003-
logger.info('hasAnyProviderCredentials:', hasCredentials);
2004-
logger.info('showOAuthLogin will be set to:', showOAuth);
2005-
return showOAuth;
1998+
return !hasCredentials;
20061999
})(),
20072000
onOAuthLogin: this.#handleOAuthLogin.bind(this),
20082001
};

0 commit comments

Comments
 (0)