Build extensible agent harness with interactive chat loop

This commit is contained in:
Adolfo Reyna
2026-05-15 14:17:07 -04:00
commit d8d79efe83
16 changed files with 1398 additions and 0 deletions

24
src/tools/registry.ts Normal file
View File

@@ -0,0 +1,24 @@
import type { ToolDefinition } from "../types.js";
import type { EventBus } from "../events.js";
export class ToolRegistry {
private readonly tools = new Map<string, ToolDefinition<any>>();
constructor(private readonly events: EventBus) {}
async register(tool: ToolDefinition<any>): Promise<void> {
if (this.tools.has(tool.name)) {
throw new Error(`Tool already registered: ${tool.name}`);
}
this.tools.set(tool.name, tool);
await this.events.emit("tool.registered", { tool: tool.name });
}
list(): ToolDefinition<any>[] {
return [...this.tools.values()];
}
get(name: string): ToolDefinition<any> | undefined {
return this.tools.get(name);
}
}