feat(cli): add Agent Client Protocol (ACP) integration for external agent support

Implements comprehensive ACP backend enabling integration with ACP-compliant agents like Gemini. Includes stdio transport, message handling, permission flow, and registry for agent management. Adds new 'hapi gemini' command to launch ACP agent sessions.
This commit is contained in:
weishu
2025-12-21 18:40:04 +08:00
parent 76a82c27c5
commit 56ae2c85a2
23 changed files with 1254 additions and 12 deletions
+7 -2
View File
@@ -241,7 +241,7 @@ export async function startDaemon(): Promise<void> {
extraEnv = {
CODEX_HOME: codexHomeDir
};
} else { // Assuming claude
} else if (options.agent === 'claude' || !options.agent) {
extraEnv = {
CLAUDE_CODE_OAUTH_TOKEN: options.token
};
@@ -249,8 +249,13 @@ export async function startDaemon(): Promise<void> {
}
// Construct arguments for the CLI
const agentCommand = options.agent === 'codex'
? 'codex'
: options.agent === 'gemini'
? 'gemini'
: 'claude';
const args = [
options.agent === 'claude' ? 'claude' : 'codex',
agentCommand,
'--hapi-starting-mode', 'remote',
'--started-by', 'daemon'
];