diff options
Diffstat (limited to 'packages/cli/src/tools/tool-registry.ts')
| -rw-r--r-- | packages/cli/src/tools/tool-registry.ts | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/packages/cli/src/tools/tool-registry.ts b/packages/cli/src/tools/tool-registry.ts index a2723557..1c82aa12 100644 --- a/packages/cli/src/tools/tool-registry.ts +++ b/packages/cli/src/tools/tool-registry.ts @@ -25,28 +25,38 @@ class ToolRegistry { } /** - * Retrieves the list of tool schemas in the format required by Gemini. - * @returns A ToolListUnion containing the function declarations. + * Retrieves the list of tool schemas (FunctionDeclaration array). + * Extracts the declarations from the ToolListUnion structure. + * @returns An array of FunctionDeclarations. */ - getToolSchemas(): ToolListUnion { + getFunctionDeclarations(): FunctionDeclaration[] { const declarations: FunctionDeclaration[] = []; this.tools.forEach((tool) => { declarations.push(tool.schema); }); + return declarations; + } - // Return Gemini's expected format. Handle the case of no tools. + /** + * Deprecated/Internal? Retrieves schemas in the ToolListUnion format. + * Kept for reference, prefer getFunctionDeclarations. + */ + getToolSchemas(): ToolListUnion { + const declarations = this.getFunctionDeclarations(); if (declarations.length === 0) { - // Depending on the SDK version, you might need `undefined`, `[]`, or `[{ functionDeclarations: [] }]` - // Check the documentation for your @google/genai version. - // Let's assume an empty array works or signifies no tools. return []; - // Or if it requires the structure: - // return [{ functionDeclarations: [] }]; } return [{ functionDeclarations: declarations }]; } /** + * Returns an array of all registered tool instances. + */ + getAllTools(): Tool[] { + return Array.from(this.tools.values()); + } + + /** * Optional: Get a list of registered tool names. */ listAvailableTools(): string[] { |
