refactor: simplify yolo mode implementation by removing env vars

Remove HAPPY_GEMINI_ARGS and HAPPY_GEMINI_COMMAND environment variables.
Refactor gemini.ts to export registerGeminiAgent(yolo) function that
directly configures args instead of reading from environment.
This commit is contained in:
weishu
2025-12-27 21:24:16 +08:00
parent 58e61b3db9
commit 3bdcc14ed0
3 changed files with 11 additions and 34 deletions
+9 -18
View File
@@ -1,12 +1,6 @@
import { AgentRegistry } from '@/agent/AgentRegistry';
import { AcpSdkBackend } from '@/agent/backends/acp';
function parseArgs(value?: string): string[] | null {
if (!value) return null;
const parts = value.split(' ').map((part) => part.trim()).filter(Boolean);
return parts.length > 0 ? parts : null;
}
function buildEnv(): Record<string, string> {
return Object.keys(process.env).reduce((acc, key) => {
const value = process.env[key];
@@ -17,16 +11,13 @@ function buildEnv(): Record<string, string> {
}, {} as Record<string, string>);
}
const command = process.env.HAPPY_GEMINI_COMMAND
|| process.env.GEMINI_ACP_COMMAND
|| 'gemini';
export function registerGeminiAgent(yolo: boolean): void {
const args = ['--experimental-acp'];
if (yolo) args.push('--yolo');
const args = parseArgs(process.env.HAPPY_GEMINI_ARGS)
?? parseArgs(process.env.GEMINI_ACP_ARGS)
?? ['--experimental-acp'];
AgentRegistry.register('gemini', () => new AcpSdkBackend({
command,
args,
env: buildEnv()
}));
AgentRegistry.register('gemini', () => new AcpSdkBackend({
command: 'gemini',
args,
env: buildEnv()
}));
}