diff options
| author | Olcan <[email protected]> | 2025-06-02 13:41:49 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-02 13:41:49 -0700 |
| commit | 59b6267b2f3f5d971c10eeaaf9c0e7e82f10cf02 (patch) | |
| tree | d9860177c9fcdbbef416cdb02923384150ebdb74 /packages/core/src | |
| parent | 58597c29d30eb0d95e1792f02eb7f1e7edc4218a (diff) | |
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)
Diffstat (limited to 'packages/core/src')
| -rw-r--r-- | packages/core/src/tools/tool-registry.ts | 10 |
1 files changed, 8 insertions, 2 deletions
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) { |
