Files
hapi/cli/src/agent/AgentRegistry.ts
T
weishu 56ae2c85a2 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.
2025-12-21 18:40:04 +08:00

25 lines
783 B
TypeScript

import type { AgentBackend, AgentBackendFactory } from './types';
export class AgentRegistry {
private static readonly factories = new Map<string, AgentBackendFactory>();
static register(agentType: string, factory: AgentBackendFactory): void {
if (!agentType || typeof agentType !== 'string') {
throw new Error('Agent type must be a non-empty string');
}
this.factories.set(agentType, factory);
}
static create(agentType: string): AgentBackend {
const factory = this.factories.get(agentType);
if (!factory) {
throw new Error(`Unknown agent type: ${agentType}`);
}
return factory();
}
static list(): string[] {
return Array.from(this.factories.keys()).sort();
}
}