2026-03-06 11:39:01 +00:00
|
|
|
import type { ToolSet } from './plugins.js';
|
2026-01-20 14:39:34 +00:00
|
|
|
|
|
|
|
|
export class ToolRegistry {
|
2026-03-06 11:39:01 +00:00
|
|
|
private tools: ToolSet = {};
|
2026-01-20 14:39:34 +00:00
|
|
|
|
|
|
|
|
/**
|
2026-03-06 11:39:01 +00:00
|
|
|
* Register a tool.
|
|
|
|
|
* @param name Tool name (must be unique, snake_case recommended)
|
|
|
|
|
* @param def Tool definition created with ai-sdk's tool() helper
|
2026-01-20 14:39:34 +00:00
|
|
|
*/
|
2026-03-06 11:39:01 +00:00
|
|
|
public register(name: string, def: ToolSet[string]): this {
|
|
|
|
|
this.tools[name] = def;
|
|
|
|
|
return this;
|
2026-01-20 14:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-06 11:39:01 +00:00
|
|
|
/** Get the full ToolSet for passing to runAgent */
|
|
|
|
|
public getTools(): ToolSet {
|
|
|
|
|
return { ...this.tools };
|
2026-01-20 14:39:34 +00:00
|
|
|
}
|
|
|
|
|
}
|