mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-25 05:07:05 +00:00
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:
@@ -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()
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user