-
Notifications
You must be signed in to change notification settings - Fork 18
fix: gate OpenCode listener (port 10004) on explicit AWF_ENABLE_OPENCODE flag #2337
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
19ddd12
f7a6633
db88f48
c4b5177
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 |
|---|---|---|
|
|
@@ -707,6 +707,16 @@ export function validateRateLimitFlags(enableApiProxy: boolean, options: { | |
| return { valid: true }; | ||
| } | ||
|
|
||
| /** | ||
| * Validates that --enable-opencode is not used without --enable-api-proxy. | ||
| */ | ||
| export function validateEnableOpenCodeFlag(enableApiProxy: boolean, enableOpenCode: boolean): FlagValidationResult { | ||
| if (enableOpenCode && !enableApiProxy) { | ||
| return { valid: false, error: '--enable-opencode requires --enable-api-proxy' }; | ||
| } | ||
| return { valid: true }; | ||
| } | ||
|
|
||
| /** | ||
| * Result of validating flag combinations | ||
| */ | ||
|
|
@@ -1513,6 +1523,12 @@ program | |
| '--gemini-api-base-path <path>', | ||
| 'Base path prefix for Gemini API requests', | ||
| ) | ||
| .option( | ||
| '--enable-opencode', | ||
| 'Enable OpenCode API proxy listener on port 10004 (requires --enable-api-proxy).\n' + | ||
| ' Only start this when the workflow uses the OpenCode engine.', | ||
| false | ||
| ) | ||
| .option( | ||
| '--rate-limit-rpm <n>', | ||
| 'Max requests per minute per provider (requires --enable-api-proxy)', | ||
|
|
@@ -1966,6 +1982,7 @@ program | |
| enableDlp: options.enableDlp, | ||
| allowedUrls, | ||
| enableApiProxy: options.enableApiProxy, | ||
| enableOpenCode: options.enableOpencode, | ||
| modelAliases, | ||
|
Comment on lines
1984
to
1986
|
||
| openaiApiKey: process.env.OPENAI_API_KEY, | ||
| anthropicApiKey: process.env.ANTHROPIC_API_KEY, | ||
|
|
@@ -2017,6 +2034,13 @@ program | |
| process.exit(1); | ||
| } | ||
|
|
||
| // Error if --enable-opencode is used without --enable-api-proxy | ||
| const enableOpenCodeValidation = validateEnableOpenCodeFlag(config.enableApiProxy ?? false, config.enableOpenCode ?? false); | ||
| if (!enableOpenCodeValidation.valid) { | ||
| logger.error(enableOpenCodeValidation.error!); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| // Warn if --env-all is used | ||
| if (config.envAll) { | ||
| logger.warn('⚠️ Using --env-all: All host environment variables will be passed to container'); | ||
|
|
||
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.
This change adds coverage for the disabled-by-default case, but there’s no corresponding test asserting that setting
AWF_ENABLE_OPENCODE=trueat module load time flipsopencode.configuredto true when a credential is present. Add a test that sets the env var before importing the module (e.g., viajest.resetModules()/jest.isolateModules()), so regressions in the enable flag wiring are caught.