mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
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.
25 lines
783 B
TypeScript
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();
|
|
}
|
|
}
|