33 * This eliminates duplication between stdio.ts and processParamsGetTools.
44 */
55
6+ import type { ValidateFunction } from 'ajv' ;
67import type { ApifyClient } from 'apify' ;
78
89import log from '@apify/log' ;
@@ -14,7 +15,6 @@ import { addTool } from '../tools/helpers.js';
1415import { getActorsAsTools , toolCategories , toolCategoriesEnabledByDefault } from '../tools/index.js' ;
1516import type { Input , InternalTool , InternalToolArgs , ToolCategory , ToolEntry } from '../types.js' ;
1617import { getExpectedToolsByCategories } from './tools.js' ;
17- import { ValidateFunction } from 'ajv' ;
1818
1919// Lazily-computed cache of internal tools by name to avoid circular init issues.
2020let INTERNAL_TOOL_BY_NAME_CACHE : Map < string , ToolEntry > | null = null ;
@@ -141,12 +141,12 @@ export async function loadToolsFromInput(
141141 // De-duplicate by tool name for safety
142142 const seen = new Set < string > ( ) ;
143143 const filtered = result . filter ( ( entry ) => ! seen . has ( entry . tool . name ) && seen . add ( entry . tool . name ) ) ;
144-
144+
145145 // TODO: rework this solition as it was quickly hacked together for hotfix
146146 // Deep clone except ajvValidate and call functions
147-
147+
148148 // holds the original functions of the tools
149- const toolFunctions = new Map < string , { ajvValidate ?: ValidateFunction < unknown > ; call ?: ( args : InternalToolArgs ) => Promise < object > } > ( ) ;
149+ const toolFunctions = new Map < string , { ajvValidate ?: ValidateFunction < unknown > ; call ?:( args : InternalToolArgs ) => Promise < object > } > ( ) ;
150150 for ( const entry of filtered ) {
151151 if ( entry . type === 'internal' ) {
152152 toolFunctions . set ( entry . tool . name , { ajvValidate : entry . tool . ajvValidate , call : ( entry . tool as InternalTool ) . call } ) ;
@@ -159,7 +159,7 @@ export async function loadToolsFromInput(
159159 if ( key === 'ajvValidate' || key === 'call' ) return undefined ;
160160 return value ;
161161 } ) ) as ToolEntry [ ] ;
162-
162+
163163 // restore the original functions
164164 for ( const entry of cloned ) {
165165 const funcs = toolFunctions . get ( entry . tool . name ) ;
0 commit comments