From 59b6267b2f3f5d971c10eeaaf9c0e7e82f10cf02 Mon Sep 17 00:00:00 2001 From: Olcan Date: Mon, 2 Jun 2025 13:41:49 -0700 Subject: allow toolDiscoveryCommand to return function declarations with or without a tool wrapper; fully document both toolDiscoveryCommand and toolCallCommand with examples and pointers to API docs (#696) --- packages/core/src/tools/tool-registry.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'packages/core') diff --git a/packages/core/src/tools/tool-registry.ts b/packages/core/src/tools/tool-registry.ts index bce51a93..21aec687 100644 --- a/packages/core/src/tools/tool-registry.ts +++ b/packages/core/src/tools/tool-registry.ts @@ -137,10 +137,16 @@ export class ToolRegistry { // discover tools using discovery command, if configured const discoveryCmd = this.config.getToolDiscoveryCommand(); if (discoveryCmd) { - // execute discovery command and extract function declarations + // execute discovery command and extract function declarations (w/ or w/o "tool" wrappers) const functions: FunctionDeclaration[] = []; for (const tool of JSON.parse(execSync(discoveryCmd).toString().trim())) { - functions.push(...tool['function_declarations']); + if (tool['function_declarations']) { + functions.push(...tool['function_declarations']); + } else if (tool['functionDeclarations']) { + functions.push(...tool['functionDeclarations']); + } else if (tool['name']) { + functions.push(tool); + } } // register each function as a tool for (const func of functions) { -- cgit v1.2.3