21 lines
512 B
TypeScript
21 lines
512 B
TypeScript
import type { ToolSet } from './plugins.js';
|
|
|
|
export class ToolRegistry {
|
|
private tools: ToolSet = {};
|
|
|
|
/**
|
|
* Register a tool.
|
|
* @param name Tool name (must be unique, snake_case recommended)
|
|
* @param def Tool definition created with ai-sdk's tool() helper
|
|
*/
|
|
public register(name: string, def: ToolSet[string]): this {
|
|
this.tools[name] = def;
|
|
return this;
|
|
}
|
|
|
|
/** Get the full ToolSet for passing to runAgent */
|
|
public getTools(): ToolSet {
|
|
return { ...this.tools };
|
|
}
|
|
}
|