@iqai/adk 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iqai/adk
2
2
 
3
+ ## 0.1.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 83e8a58: Add create tool function to easily create tools with zod schema
8
+
3
9
  ## 0.1.9
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -58,7 +58,7 @@ npm install @iqai/adk
58
58
  import { AgentBuilder } from '@iqai/adk';
59
59
 
60
60
  const response = await AgentBuilder
61
- .withModel("gpt-4")
61
+ .withModel("gpt-4.1")
62
62
  .ask("What is the primary function of an AI agent?");
63
63
 
64
64
  console.log(response);
@@ -129,7 +129,6 @@ async function quickQuery() {
129
129
  .create("query_assistant")
130
130
  .withModel("gemini-2.5-flash")
131
131
  .withInstruction("You are a helpful AI. Respond clearly and concisely.")
132
- .withQuickSession("my-app", "user-123")
133
132
  .ask("What is the capital of France?");
134
133
 
135
134
  console.log(response);
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Part, Content as Content$1, Blob, SpeechConfig, AudioTranscriptionConfig, RealtimeInputConfig, ProactivityConfig, GenerateContentConfig, LiveConnectConfig, GroundingMetadata, GenerateContentResponseUsageMetadata, GoogleGenAI, FunctionCall } from '@google/genai';
2
2
  export { Blob, Content } from '@google/genai';
3
3
  import { LanguageModel } from 'ai';
4
+ import * as z from 'zod/v4';
4
5
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
5
6
  import { CreateMessageRequestSchema, CreateMessageResultSchema, Tool } from '@modelcontextprotocol/sdk/types.js';
6
- import { z } from 'zod';
7
+ import { z as z$1 } from 'zod';
7
8
  import { Kysely, Generated } from 'kysely';
8
9
  import { StorageOptions } from '@google-cloud/storage';
9
10
  import { Tracer } from '@opentelemetry/api';
@@ -904,6 +905,65 @@ declare abstract class BaseTool {
904
905
  private findToolWithFunctionDeclarations;
905
906
  }
906
907
 
908
+ /**
909
+ * Configuration for creating a tool
910
+ */
911
+ interface CreateToolConfig<T extends Record<string, any>> {
912
+ /** The name of the tool */
913
+ name: string;
914
+ /** A description of what the tool does */
915
+ description: string;
916
+ /** Zod schema for validating tool arguments */
917
+ schema: z.ZodSchema<T>;
918
+ /** The function to execute (can be sync or async) */
919
+ fn: (args: T, context?: ToolContext) => any;
920
+ /** Whether the tool is a long running operation */
921
+ isLongRunning?: boolean;
922
+ /** Whether the tool execution should be retried on failure */
923
+ shouldRetryOnFailure?: boolean;
924
+ /** Maximum retry attempts */
925
+ maxRetryAttempts?: number;
926
+ }
927
+ /**
928
+ * Creates a tool from a configuration object.
929
+ *
930
+ * This is a more user-friendly alternative to FunctionTool that provides:
931
+ * - Automatic argument validation using Zod schemas
932
+ * - Clear error messages for invalid inputs
933
+ * - Automatic JSON Schema generation for LLM function declarations
934
+ * - Support for both sync and async functions
935
+ * - Optional ToolContext parameter support
936
+ *
937
+ * @param config The tool configuration object
938
+ * @returns A BaseTool instance ready for use with agents
939
+ *
940
+ * @example
941
+ * ```typescript
942
+ * import { createTool } from '@iqai/adk';
943
+ * import { z } from 'zod';
944
+ *
945
+ * const calculatorTool = createTool({
946
+ * name: 'calculator',
947
+ * description: 'Performs basic arithmetic operations',
948
+ * schema: z.object({
949
+ * operation: z.enum(['add', 'subtract', 'multiply', 'divide']),
950
+ * a: z.number().describe('First number'),
951
+ * b: z.number().describe('Second number')
952
+ * }),
953
+ * fn: ({ operation, a, b }) => {
954
+ * switch (operation) {
955
+ * case 'add': return { result: a + b };
956
+ * case 'subtract': return { result: a - b };
957
+ * case 'multiply': return { result: a * b };
958
+ * case 'divide': return { result: b !== 0 ? a / b : 'Cannot divide by zero' };
959
+ * default: return { error: 'Unknown operation' };
960
+ * }
961
+ * }
962
+ * });
963
+ * ```
964
+ */
965
+ declare function createTool<T extends Record<string, any>>(config: CreateToolConfig<T>): BaseTool;
966
+
907
967
  /**
908
968
  * A tool that wraps a user-defined TypeScript function.
909
969
  *
@@ -1322,8 +1382,8 @@ declare class McpError extends Error {
1322
1382
  originalError?: Error;
1323
1383
  constructor(message: string, type: McpErrorType, originalError?: Error);
1324
1384
  }
1325
- type McpSamplingRequest = z.infer<typeof CreateMessageRequestSchema>;
1326
- type McpSamplingResponse = z.infer<typeof CreateMessageResultSchema>;
1385
+ type McpSamplingRequest = z$1.infer<typeof CreateMessageRequestSchema>;
1386
+ type McpSamplingResponse = z$1.infer<typeof CreateMessageResultSchema>;
1327
1387
  type SamplingHandler = (request: LlmRequest) => Promise<string | LlmResponse>;
1328
1388
 
1329
1389
  declare class McpClientService {
@@ -1752,6 +1812,7 @@ declare function getMcpTools(config: McpConfig, toolFilter?: string[] | ((tool:
1752
1812
  type index$6_BaseTool = BaseTool;
1753
1813
  declare const index$6_BaseTool: typeof BaseTool;
1754
1814
  type index$6_BuildFunctionDeclarationOptions = BuildFunctionDeclarationOptions;
1815
+ type index$6_CreateToolConfig<T extends Record<string, any>> = CreateToolConfig<T>;
1755
1816
  type index$6_ExitLoopTool = ExitLoopTool;
1756
1817
  declare const index$6_ExitLoopTool: typeof ExitLoopTool;
1757
1818
  type index$6_FileOperationsTool = FileOperationsTool;
@@ -1807,12 +1868,13 @@ declare const index$6_adkToMcpToolType: typeof adkToMcpToolType;
1807
1868
  declare const index$6_buildFunctionDeclaration: typeof buildFunctionDeclaration;
1808
1869
  declare const index$6_createFunctionTool: typeof createFunctionTool;
1809
1870
  declare const index$6_createSamplingHandler: typeof createSamplingHandler;
1871
+ declare const index$6_createTool: typeof createTool;
1810
1872
  declare const index$6_getMcpTools: typeof getMcpTools;
1811
1873
  declare const index$6_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
1812
1874
  declare const index$6_mcpSchemaToParameters: typeof mcpSchemaToParameters;
1813
1875
  declare const index$6_normalizeJsonSchema: typeof normalizeJsonSchema;
1814
1876
  declare namespace index$6 {
1815
- export { index$6_BaseTool as BaseTool, type index$6_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$6_ExitLoopTool as ExitLoopTool, index$6_FileOperationsTool as FileOperationsTool, index$6_FunctionTool as FunctionTool, index$6_GetUserChoiceTool as GetUserChoiceTool, index$6_GoogleSearch as GoogleSearch, index$6_HttpRequestTool as HttpRequestTool, index$6_LoadArtifactsTool as LoadArtifactsTool, index$6_LoadMemoryTool as LoadMemoryTool, index$6_McpAbi as McpAbi, index$6_McpAtp as McpAtp, index$6_McpBamm as McpBamm, index$6_McpCoinGecko as McpCoinGecko, type index$6_McpConfig as McpConfig, index$6_McpDiscord as McpDiscord, index$6_McpError as McpError, index$6_McpErrorType as McpErrorType, index$6_McpFilesystem as McpFilesystem, index$6_McpFraxlend as McpFraxlend, index$6_McpGeneric as McpGeneric, index$6_McpIqWiki as McpIqWiki, index$6_McpMemory as McpMemory, index$6_McpNearAgent as McpNearAgent, index$6_McpNearIntentSwaps as McpNearIntentSwaps, index$6_McpOdos as McpOdos, index$6_McpSamplingHandler as McpSamplingHandler, type index$6_McpSamplingRequest as McpSamplingRequest, type index$6_McpSamplingResponse as McpSamplingResponse, type index$6_McpServerConfig as McpServerConfig, index$6_McpTelegram as McpTelegram, index$6_McpToolset as McpToolset, type index$6_McpTransportType as McpTransportType, type index$6_SamplingHandler as SamplingHandler, type index$6_ToolConfig as ToolConfig, index$6_ToolContext as ToolContext, index$6_TransferToAgentTool as TransferToAgentTool, index$6_UserInteractionTool as UserInteractionTool, index$6_adkToMcpToolType as adkToMcpToolType, index$6_buildFunctionDeclaration as buildFunctionDeclaration, index$6_createFunctionTool as createFunctionTool, index$6_createSamplingHandler as createSamplingHandler, index$6_getMcpTools as getMcpTools, index$6_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$6_mcpSchemaToParameters as mcpSchemaToParameters, index$6_normalizeJsonSchema as normalizeJsonSchema };
1877
+ export { index$6_BaseTool as BaseTool, type index$6_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, type index$6_CreateToolConfig as CreateToolConfig, index$6_ExitLoopTool as ExitLoopTool, index$6_FileOperationsTool as FileOperationsTool, index$6_FunctionTool as FunctionTool, index$6_GetUserChoiceTool as GetUserChoiceTool, index$6_GoogleSearch as GoogleSearch, index$6_HttpRequestTool as HttpRequestTool, index$6_LoadArtifactsTool as LoadArtifactsTool, index$6_LoadMemoryTool as LoadMemoryTool, index$6_McpAbi as McpAbi, index$6_McpAtp as McpAtp, index$6_McpBamm as McpBamm, index$6_McpCoinGecko as McpCoinGecko, type index$6_McpConfig as McpConfig, index$6_McpDiscord as McpDiscord, index$6_McpError as McpError, index$6_McpErrorType as McpErrorType, index$6_McpFilesystem as McpFilesystem, index$6_McpFraxlend as McpFraxlend, index$6_McpGeneric as McpGeneric, index$6_McpIqWiki as McpIqWiki, index$6_McpMemory as McpMemory, index$6_McpNearAgent as McpNearAgent, index$6_McpNearIntentSwaps as McpNearIntentSwaps, index$6_McpOdos as McpOdos, index$6_McpSamplingHandler as McpSamplingHandler, type index$6_McpSamplingRequest as McpSamplingRequest, type index$6_McpSamplingResponse as McpSamplingResponse, type index$6_McpServerConfig as McpServerConfig, index$6_McpTelegram as McpTelegram, index$6_McpToolset as McpToolset, type index$6_McpTransportType as McpTransportType, type index$6_SamplingHandler as SamplingHandler, type index$6_ToolConfig as ToolConfig, index$6_ToolContext as ToolContext, index$6_TransferToAgentTool as TransferToAgentTool, index$6_UserInteractionTool as UserInteractionTool, index$6_adkToMcpToolType as adkToMcpToolType, index$6_buildFunctionDeclaration as buildFunctionDeclaration, index$6_createFunctionTool as createFunctionTool, index$6_createSamplingHandler as createSamplingHandler, index$6_createTool as createTool, index$6_getMcpTools as getMcpTools, index$6_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$6_mcpSchemaToParameters as mcpSchemaToParameters, index$6_normalizeJsonSchema as normalizeJsonSchema };
1816
1878
  }
1817
1879
 
1818
1880
  /**
@@ -4427,15 +4489,6 @@ declare abstract class BaseLlmFlow {
4427
4489
  _handleBeforeModelCallback(invocationContext: InvocationContext, llmRequest: LlmRequest, modelResponseEvent: Event): Promise<LlmResponse | undefined>;
4428
4490
  _handleAfterModelCallback(invocationContext: InvocationContext, llmResponse: LlmResponse, modelResponseEvent: Event): Promise<LlmResponse | undefined>;
4429
4491
  _finalizeModelResponseEvent(llmRequest: LlmRequest, llmResponse: LlmResponse, modelResponseEvent: Event): Event;
4430
- /**
4431
- * Logs data in a visually appealing format that works well in any terminal size.
4432
- * Uses vertical layout for better readability and respects debug settings.
4433
- */
4434
- _formatContentPreview(content: any): string;
4435
- /**
4436
- * Formats response content preview for debug logging
4437
- */
4438
- _formatResponsePreview(llmResponse: LlmResponse): string;
4439
4492
  __getLlm(invocationContext: InvocationContext): BaseLlm;
4440
4493
  }
4441
4494
 
@@ -4991,4 +5044,4 @@ declare const traceLlmCall: (invocationContext: InvocationContext, eventId: stri
4991
5044
 
4992
5045
  declare const VERSION = "0.1.0";
4993
5046
 
4994
- export { AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentType, index$4 as Agents, AiSdkLlm, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, BaseCodeExecutor, type BaseCodeExecutorConfig, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BaseSessionService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInCodeExecutor, BuiltInPlanner, CallbackContext, type CodeExecutionInput, type CodeExecutionResult, CodeExecutionUtils, CodeExecutorContext, DatabaseSessionService, EnhancedAuthConfig, type EnhancedRunner, Event, EventActions, index$1 as Events, ExitLoopTool, type File, FileOperationsTool, index as Flows, type FullMessage, type FunctionDeclaration, FunctionTool, GcsArtifactService, type GetSessionConfig, GetUserChoiceTool, GoogleLlm, GoogleSearch, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, InvocationContext, type JSONSchema, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmRequest, LlmResponse, LoadArtifactsTool, LoadMemoryTool, LoopAgent, type LoopAgentConfig, McpAbi, McpAtp, McpBamm, McpCoinGecko, type McpConfig, McpDiscord, McpError, McpErrorType, McpFilesystem, McpFraxlend, McpGeneric, McpIqWiki, McpMemory, McpNearAgent, McpNearIntentSwaps, McpOdos, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, type McpServerConfig, McpTelegram, McpToolset, type McpTransportType, index$3 as Memory, type MessagePart, index$5 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PlanReActPlanner, REQUEST_EUC_FUNCTION_CALL_NAME, ReadonlyContext, RunConfig, Runner, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionConfig, index$2 as Sessions, type SingleAgentCallback, SingleFlow, State, StreamingMode, type TelemetryConfig, TelemetryService, type ThinkingConfig, type ToolConfig, ToolContext, type ToolUnion, index$6 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiSessionService, _findFunctionCallEventIfLastEventIsFunctionResponse, adkToMcpToolType, requestProcessor$2 as agentTransferRequestProcessor, requestProcessor$6 as basicRequestProcessor, buildFunctionDeclaration, requestProcessor as codeExecutionRequestProcessor, responseProcessor as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, createAuthToolArguments, createBranchContextForSubAgent, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, generateAuthEvent, generateClientFunctionCallId, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$5 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$4 as instructionsRequestProcessor, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeAgentRun, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor$1 as nlPlanningRequestProcessor, responseProcessor$1 as nlPlanningResponseProcessor, normalizeJsonSchema, populateClientFunctionCallId, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, shutdownTelemetry, telemetryService, traceLlmCall, traceToolCall, tracer };
5047
+ export { AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentType, index$4 as Agents, AiSdkLlm, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, BaseCodeExecutor, type BaseCodeExecutorConfig, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BaseSessionService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInCodeExecutor, BuiltInPlanner, CallbackContext, type CodeExecutionInput, type CodeExecutionResult, CodeExecutionUtils, CodeExecutorContext, type CreateToolConfig, DatabaseSessionService, EnhancedAuthConfig, type EnhancedRunner, Event, EventActions, index$1 as Events, ExitLoopTool, type File, FileOperationsTool, index as Flows, type FullMessage, type FunctionDeclaration, FunctionTool, GcsArtifactService, type GetSessionConfig, GetUserChoiceTool, GoogleLlm, GoogleSearch, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, InvocationContext, type JSONSchema, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmRequest, LlmResponse, LoadArtifactsTool, LoadMemoryTool, LoopAgent, type LoopAgentConfig, McpAbi, McpAtp, McpBamm, McpCoinGecko, type McpConfig, McpDiscord, McpError, McpErrorType, McpFilesystem, McpFraxlend, McpGeneric, McpIqWiki, McpMemory, McpNearAgent, McpNearIntentSwaps, McpOdos, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, type McpServerConfig, McpTelegram, McpToolset, type McpTransportType, index$3 as Memory, type MessagePart, index$5 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PlanReActPlanner, REQUEST_EUC_FUNCTION_CALL_NAME, ReadonlyContext, RunConfig, Runner, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionConfig, index$2 as Sessions, type SingleAgentCallback, SingleFlow, State, StreamingMode, type TelemetryConfig, TelemetryService, type ThinkingConfig, type ToolConfig, ToolContext, type ToolUnion, index$6 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiSessionService, _findFunctionCallEventIfLastEventIsFunctionResponse, adkToMcpToolType, requestProcessor$2 as agentTransferRequestProcessor, requestProcessor$6 as basicRequestProcessor, buildFunctionDeclaration, requestProcessor as codeExecutionRequestProcessor, responseProcessor as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, createAuthToolArguments, createBranchContextForSubAgent, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, createTool, generateAuthEvent, generateClientFunctionCallId, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$5 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$4 as instructionsRequestProcessor, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeAgentRun, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor$1 as nlPlanningRequestProcessor, responseProcessor$1 as nlPlanningResponseProcessor, normalizeJsonSchema, populateClientFunctionCallId, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, shutdownTelemetry, telemetryService, traceLlmCall, traceToolCall, tracer };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Part, Content as Content$1, Blob, SpeechConfig, AudioTranscriptionConfig, RealtimeInputConfig, ProactivityConfig, GenerateContentConfig, LiveConnectConfig, GroundingMetadata, GenerateContentResponseUsageMetadata, GoogleGenAI, FunctionCall } from '@google/genai';
2
2
  export { Blob, Content } from '@google/genai';
3
3
  import { LanguageModel } from 'ai';
4
+ import * as z from 'zod/v4';
4
5
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
5
6
  import { CreateMessageRequestSchema, CreateMessageResultSchema, Tool } from '@modelcontextprotocol/sdk/types.js';
6
- import { z } from 'zod';
7
+ import { z as z$1 } from 'zod';
7
8
  import { Kysely, Generated } from 'kysely';
8
9
  import { StorageOptions } from '@google-cloud/storage';
9
10
  import { Tracer } from '@opentelemetry/api';
@@ -904,6 +905,65 @@ declare abstract class BaseTool {
904
905
  private findToolWithFunctionDeclarations;
905
906
  }
906
907
 
908
+ /**
909
+ * Configuration for creating a tool
910
+ */
911
+ interface CreateToolConfig<T extends Record<string, any>> {
912
+ /** The name of the tool */
913
+ name: string;
914
+ /** A description of what the tool does */
915
+ description: string;
916
+ /** Zod schema for validating tool arguments */
917
+ schema: z.ZodSchema<T>;
918
+ /** The function to execute (can be sync or async) */
919
+ fn: (args: T, context?: ToolContext) => any;
920
+ /** Whether the tool is a long running operation */
921
+ isLongRunning?: boolean;
922
+ /** Whether the tool execution should be retried on failure */
923
+ shouldRetryOnFailure?: boolean;
924
+ /** Maximum retry attempts */
925
+ maxRetryAttempts?: number;
926
+ }
927
+ /**
928
+ * Creates a tool from a configuration object.
929
+ *
930
+ * This is a more user-friendly alternative to FunctionTool that provides:
931
+ * - Automatic argument validation using Zod schemas
932
+ * - Clear error messages for invalid inputs
933
+ * - Automatic JSON Schema generation for LLM function declarations
934
+ * - Support for both sync and async functions
935
+ * - Optional ToolContext parameter support
936
+ *
937
+ * @param config The tool configuration object
938
+ * @returns A BaseTool instance ready for use with agents
939
+ *
940
+ * @example
941
+ * ```typescript
942
+ * import { createTool } from '@iqai/adk';
943
+ * import { z } from 'zod';
944
+ *
945
+ * const calculatorTool = createTool({
946
+ * name: 'calculator',
947
+ * description: 'Performs basic arithmetic operations',
948
+ * schema: z.object({
949
+ * operation: z.enum(['add', 'subtract', 'multiply', 'divide']),
950
+ * a: z.number().describe('First number'),
951
+ * b: z.number().describe('Second number')
952
+ * }),
953
+ * fn: ({ operation, a, b }) => {
954
+ * switch (operation) {
955
+ * case 'add': return { result: a + b };
956
+ * case 'subtract': return { result: a - b };
957
+ * case 'multiply': return { result: a * b };
958
+ * case 'divide': return { result: b !== 0 ? a / b : 'Cannot divide by zero' };
959
+ * default: return { error: 'Unknown operation' };
960
+ * }
961
+ * }
962
+ * });
963
+ * ```
964
+ */
965
+ declare function createTool<T extends Record<string, any>>(config: CreateToolConfig<T>): BaseTool;
966
+
907
967
  /**
908
968
  * A tool that wraps a user-defined TypeScript function.
909
969
  *
@@ -1322,8 +1382,8 @@ declare class McpError extends Error {
1322
1382
  originalError?: Error;
1323
1383
  constructor(message: string, type: McpErrorType, originalError?: Error);
1324
1384
  }
1325
- type McpSamplingRequest = z.infer<typeof CreateMessageRequestSchema>;
1326
- type McpSamplingResponse = z.infer<typeof CreateMessageResultSchema>;
1385
+ type McpSamplingRequest = z$1.infer<typeof CreateMessageRequestSchema>;
1386
+ type McpSamplingResponse = z$1.infer<typeof CreateMessageResultSchema>;
1327
1387
  type SamplingHandler = (request: LlmRequest) => Promise<string | LlmResponse>;
1328
1388
 
1329
1389
  declare class McpClientService {
@@ -1752,6 +1812,7 @@ declare function getMcpTools(config: McpConfig, toolFilter?: string[] | ((tool:
1752
1812
  type index$6_BaseTool = BaseTool;
1753
1813
  declare const index$6_BaseTool: typeof BaseTool;
1754
1814
  type index$6_BuildFunctionDeclarationOptions = BuildFunctionDeclarationOptions;
1815
+ type index$6_CreateToolConfig<T extends Record<string, any>> = CreateToolConfig<T>;
1755
1816
  type index$6_ExitLoopTool = ExitLoopTool;
1756
1817
  declare const index$6_ExitLoopTool: typeof ExitLoopTool;
1757
1818
  type index$6_FileOperationsTool = FileOperationsTool;
@@ -1807,12 +1868,13 @@ declare const index$6_adkToMcpToolType: typeof adkToMcpToolType;
1807
1868
  declare const index$6_buildFunctionDeclaration: typeof buildFunctionDeclaration;
1808
1869
  declare const index$6_createFunctionTool: typeof createFunctionTool;
1809
1870
  declare const index$6_createSamplingHandler: typeof createSamplingHandler;
1871
+ declare const index$6_createTool: typeof createTool;
1810
1872
  declare const index$6_getMcpTools: typeof getMcpTools;
1811
1873
  declare const index$6_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
1812
1874
  declare const index$6_mcpSchemaToParameters: typeof mcpSchemaToParameters;
1813
1875
  declare const index$6_normalizeJsonSchema: typeof normalizeJsonSchema;
1814
1876
  declare namespace index$6 {
1815
- export { index$6_BaseTool as BaseTool, type index$6_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$6_ExitLoopTool as ExitLoopTool, index$6_FileOperationsTool as FileOperationsTool, index$6_FunctionTool as FunctionTool, index$6_GetUserChoiceTool as GetUserChoiceTool, index$6_GoogleSearch as GoogleSearch, index$6_HttpRequestTool as HttpRequestTool, index$6_LoadArtifactsTool as LoadArtifactsTool, index$6_LoadMemoryTool as LoadMemoryTool, index$6_McpAbi as McpAbi, index$6_McpAtp as McpAtp, index$6_McpBamm as McpBamm, index$6_McpCoinGecko as McpCoinGecko, type index$6_McpConfig as McpConfig, index$6_McpDiscord as McpDiscord, index$6_McpError as McpError, index$6_McpErrorType as McpErrorType, index$6_McpFilesystem as McpFilesystem, index$6_McpFraxlend as McpFraxlend, index$6_McpGeneric as McpGeneric, index$6_McpIqWiki as McpIqWiki, index$6_McpMemory as McpMemory, index$6_McpNearAgent as McpNearAgent, index$6_McpNearIntentSwaps as McpNearIntentSwaps, index$6_McpOdos as McpOdos, index$6_McpSamplingHandler as McpSamplingHandler, type index$6_McpSamplingRequest as McpSamplingRequest, type index$6_McpSamplingResponse as McpSamplingResponse, type index$6_McpServerConfig as McpServerConfig, index$6_McpTelegram as McpTelegram, index$6_McpToolset as McpToolset, type index$6_McpTransportType as McpTransportType, type index$6_SamplingHandler as SamplingHandler, type index$6_ToolConfig as ToolConfig, index$6_ToolContext as ToolContext, index$6_TransferToAgentTool as TransferToAgentTool, index$6_UserInteractionTool as UserInteractionTool, index$6_adkToMcpToolType as adkToMcpToolType, index$6_buildFunctionDeclaration as buildFunctionDeclaration, index$6_createFunctionTool as createFunctionTool, index$6_createSamplingHandler as createSamplingHandler, index$6_getMcpTools as getMcpTools, index$6_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$6_mcpSchemaToParameters as mcpSchemaToParameters, index$6_normalizeJsonSchema as normalizeJsonSchema };
1877
+ export { index$6_BaseTool as BaseTool, type index$6_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, type index$6_CreateToolConfig as CreateToolConfig, index$6_ExitLoopTool as ExitLoopTool, index$6_FileOperationsTool as FileOperationsTool, index$6_FunctionTool as FunctionTool, index$6_GetUserChoiceTool as GetUserChoiceTool, index$6_GoogleSearch as GoogleSearch, index$6_HttpRequestTool as HttpRequestTool, index$6_LoadArtifactsTool as LoadArtifactsTool, index$6_LoadMemoryTool as LoadMemoryTool, index$6_McpAbi as McpAbi, index$6_McpAtp as McpAtp, index$6_McpBamm as McpBamm, index$6_McpCoinGecko as McpCoinGecko, type index$6_McpConfig as McpConfig, index$6_McpDiscord as McpDiscord, index$6_McpError as McpError, index$6_McpErrorType as McpErrorType, index$6_McpFilesystem as McpFilesystem, index$6_McpFraxlend as McpFraxlend, index$6_McpGeneric as McpGeneric, index$6_McpIqWiki as McpIqWiki, index$6_McpMemory as McpMemory, index$6_McpNearAgent as McpNearAgent, index$6_McpNearIntentSwaps as McpNearIntentSwaps, index$6_McpOdos as McpOdos, index$6_McpSamplingHandler as McpSamplingHandler, type index$6_McpSamplingRequest as McpSamplingRequest, type index$6_McpSamplingResponse as McpSamplingResponse, type index$6_McpServerConfig as McpServerConfig, index$6_McpTelegram as McpTelegram, index$6_McpToolset as McpToolset, type index$6_McpTransportType as McpTransportType, type index$6_SamplingHandler as SamplingHandler, type index$6_ToolConfig as ToolConfig, index$6_ToolContext as ToolContext, index$6_TransferToAgentTool as TransferToAgentTool, index$6_UserInteractionTool as UserInteractionTool, index$6_adkToMcpToolType as adkToMcpToolType, index$6_buildFunctionDeclaration as buildFunctionDeclaration, index$6_createFunctionTool as createFunctionTool, index$6_createSamplingHandler as createSamplingHandler, index$6_createTool as createTool, index$6_getMcpTools as getMcpTools, index$6_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$6_mcpSchemaToParameters as mcpSchemaToParameters, index$6_normalizeJsonSchema as normalizeJsonSchema };
1816
1878
  }
1817
1879
 
1818
1880
  /**
@@ -4427,15 +4489,6 @@ declare abstract class BaseLlmFlow {
4427
4489
  _handleBeforeModelCallback(invocationContext: InvocationContext, llmRequest: LlmRequest, modelResponseEvent: Event): Promise<LlmResponse | undefined>;
4428
4490
  _handleAfterModelCallback(invocationContext: InvocationContext, llmResponse: LlmResponse, modelResponseEvent: Event): Promise<LlmResponse | undefined>;
4429
4491
  _finalizeModelResponseEvent(llmRequest: LlmRequest, llmResponse: LlmResponse, modelResponseEvent: Event): Event;
4430
- /**
4431
- * Logs data in a visually appealing format that works well in any terminal size.
4432
- * Uses vertical layout for better readability and respects debug settings.
4433
- */
4434
- _formatContentPreview(content: any): string;
4435
- /**
4436
- * Formats response content preview for debug logging
4437
- */
4438
- _formatResponsePreview(llmResponse: LlmResponse): string;
4439
4492
  __getLlm(invocationContext: InvocationContext): BaseLlm;
4440
4493
  }
4441
4494
 
@@ -4991,4 +5044,4 @@ declare const traceLlmCall: (invocationContext: InvocationContext, eventId: stri
4991
5044
 
4992
5045
  declare const VERSION = "0.1.0";
4993
5046
 
4994
- export { AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentType, index$4 as Agents, AiSdkLlm, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, BaseCodeExecutor, type BaseCodeExecutorConfig, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BaseSessionService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInCodeExecutor, BuiltInPlanner, CallbackContext, type CodeExecutionInput, type CodeExecutionResult, CodeExecutionUtils, CodeExecutorContext, DatabaseSessionService, EnhancedAuthConfig, type EnhancedRunner, Event, EventActions, index$1 as Events, ExitLoopTool, type File, FileOperationsTool, index as Flows, type FullMessage, type FunctionDeclaration, FunctionTool, GcsArtifactService, type GetSessionConfig, GetUserChoiceTool, GoogleLlm, GoogleSearch, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, InvocationContext, type JSONSchema, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmRequest, LlmResponse, LoadArtifactsTool, LoadMemoryTool, LoopAgent, type LoopAgentConfig, McpAbi, McpAtp, McpBamm, McpCoinGecko, type McpConfig, McpDiscord, McpError, McpErrorType, McpFilesystem, McpFraxlend, McpGeneric, McpIqWiki, McpMemory, McpNearAgent, McpNearIntentSwaps, McpOdos, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, type McpServerConfig, McpTelegram, McpToolset, type McpTransportType, index$3 as Memory, type MessagePart, index$5 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PlanReActPlanner, REQUEST_EUC_FUNCTION_CALL_NAME, ReadonlyContext, RunConfig, Runner, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionConfig, index$2 as Sessions, type SingleAgentCallback, SingleFlow, State, StreamingMode, type TelemetryConfig, TelemetryService, type ThinkingConfig, type ToolConfig, ToolContext, type ToolUnion, index$6 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiSessionService, _findFunctionCallEventIfLastEventIsFunctionResponse, adkToMcpToolType, requestProcessor$2 as agentTransferRequestProcessor, requestProcessor$6 as basicRequestProcessor, buildFunctionDeclaration, requestProcessor as codeExecutionRequestProcessor, responseProcessor as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, createAuthToolArguments, createBranchContextForSubAgent, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, generateAuthEvent, generateClientFunctionCallId, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$5 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$4 as instructionsRequestProcessor, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeAgentRun, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor$1 as nlPlanningRequestProcessor, responseProcessor$1 as nlPlanningResponseProcessor, normalizeJsonSchema, populateClientFunctionCallId, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, shutdownTelemetry, telemetryService, traceLlmCall, traceToolCall, tracer };
5047
+ export { AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentType, index$4 as Agents, AiSdkLlm, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, BaseCodeExecutor, type BaseCodeExecutorConfig, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BaseSessionService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInCodeExecutor, BuiltInPlanner, CallbackContext, type CodeExecutionInput, type CodeExecutionResult, CodeExecutionUtils, CodeExecutorContext, type CreateToolConfig, DatabaseSessionService, EnhancedAuthConfig, type EnhancedRunner, Event, EventActions, index$1 as Events, ExitLoopTool, type File, FileOperationsTool, index as Flows, type FullMessage, type FunctionDeclaration, FunctionTool, GcsArtifactService, type GetSessionConfig, GetUserChoiceTool, GoogleLlm, GoogleSearch, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, InvocationContext, type JSONSchema, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmRequest, LlmResponse, LoadArtifactsTool, LoadMemoryTool, LoopAgent, type LoopAgentConfig, McpAbi, McpAtp, McpBamm, McpCoinGecko, type McpConfig, McpDiscord, McpError, McpErrorType, McpFilesystem, McpFraxlend, McpGeneric, McpIqWiki, McpMemory, McpNearAgent, McpNearIntentSwaps, McpOdos, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, type McpServerConfig, McpTelegram, McpToolset, type McpTransportType, index$3 as Memory, type MessagePart, index$5 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PlanReActPlanner, REQUEST_EUC_FUNCTION_CALL_NAME, ReadonlyContext, RunConfig, Runner, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionConfig, index$2 as Sessions, type SingleAgentCallback, SingleFlow, State, StreamingMode, type TelemetryConfig, TelemetryService, type ThinkingConfig, type ToolConfig, ToolContext, type ToolUnion, index$6 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiSessionService, _findFunctionCallEventIfLastEventIsFunctionResponse, adkToMcpToolType, requestProcessor$2 as agentTransferRequestProcessor, requestProcessor$6 as basicRequestProcessor, buildFunctionDeclaration, requestProcessor as codeExecutionRequestProcessor, responseProcessor as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, createAuthToolArguments, createBranchContextForSubAgent, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, createTool, generateAuthEvent, generateClientFunctionCallId, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$5 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$4 as instructionsRequestProcessor, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeAgentRun, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor$1 as nlPlanningRequestProcessor, responseProcessor$1 as nlPlanningResponseProcessor, normalizeJsonSchema, populateClientFunctionCallId, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, shutdownTelemetry, telemetryService, traceLlmCall, traceToolCall, tracer };