-
Notifications
You must be signed in to change notification settings - Fork 6
Integate browseros config #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # Required | ||
| BROWSEROS_CONFIG_URL= | ||
| ANTHROPIC_API_KEY= | ||
|
|
||
| # Server Ports | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 BrowserOS | ||
| */ | ||
|
|
||
| import {logger} from './logger.js'; | ||
|
|
||
| export interface BrowserOSConfig { | ||
| model: string; | ||
| apiKey: string; | ||
| } | ||
|
|
||
| export async function fetchBrowserOSConfig( | ||
| configUrl: string, | ||
| ): Promise<BrowserOSConfig> { | ||
| logger.debug('Fetching BrowserOS config', {configUrl}); | ||
|
|
||
| try { | ||
| const response = await fetch(configUrl, { | ||
| method: 'GET', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| const errorText = await response.text(); | ||
| throw new Error( | ||
| `Failed to fetch config: ${response.status} ${response.statusText} - ${errorText}`, | ||
| ); | ||
| } | ||
|
|
||
| const config = (await response.json()) as BrowserOSConfig; | ||
|
|
||
| if (!config.model || !config.apiKey) { | ||
| throw new Error('Invalid config response: missing model or apiKey'); | ||
| } | ||
|
Comment on lines
+33
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Type assertion bypasses validation. The response could contain unexpected data types (e.g., Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/common/src/gateway.ts
Line: 33:37
Comment:
**logic:** Type assertion bypasses validation. The response could contain unexpected data types (e.g., `model: 123` instead of string) which would pass this check but fail later.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| logger.info('✅ BrowserOS config fetched'); | ||
|
|
||
| return config; | ||
| } catch (error) { | ||
| logger.error('❌ Failed to fetch BrowserOS config', { | ||
| configUrl, | ||
| error: error instanceof Error ? error.message : String(error), | ||
| }); | ||
|
Comment on lines
+43
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Error log includes the full Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/common/src/gateway.ts
Line: 43:46
Comment:
**logic:** Error log includes the full `configUrl` which may contain sensitive information like API keys or tokens in query parameters.
How can I resolve this? If you propose a fix, please make it concise. |
||
| throw error; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: fetch() call has no timeout or retry logic. If the config URL is slow or unresponsive, this will hang indefinitely and block server startup.
Prompt To Fix With AI