@iqai/adk 0.0.7 → 0.0.8

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.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 74ee653: Simplified sampling handler with adk message and response typings
8
+
3
9
  ## 0.0.7
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2684,7 +2684,6 @@ declare class LoadMemoryTool extends BaseTool {
2684
2684
 
2685
2685
  type McpConfig = {
2686
2686
  name: string;
2687
- description: string;
2688
2687
  transport: McpTransportType;
2689
2688
  timeout?: number;
2690
2689
  retryOptions?: {
@@ -2699,7 +2698,6 @@ type McpConfig = {
2699
2698
  maxSize?: number;
2700
2699
  };
2701
2700
  debug?: boolean;
2702
- samplingHandler?: SamplingHandler;
2703
2701
  };
2704
2702
  type McpTransportType = {
2705
2703
  mode: "stdio";
@@ -2733,14 +2731,46 @@ declare class McpError extends Error {
2733
2731
  }
2734
2732
  type SamplingRequest = z.infer<typeof CreateMessageRequestSchema>;
2735
2733
  type SamplingResponse = z.infer<typeof CreateMessageResultSchema>;
2736
- type SamplingHandler = (request: SamplingRequest) => Promise<SamplingResponse>;
2734
+
2735
+ /**
2736
+ * ADK sampling request format - what we pass to the user's handler
2737
+ */
2738
+ interface ADKSamplingRequest {
2739
+ messages: Message[];
2740
+ systemPrompt?: string;
2741
+ modelPreferences?: {
2742
+ hints?: Array<{
2743
+ name?: string;
2744
+ }>;
2745
+ costPriority?: number;
2746
+ speedPriority?: number;
2747
+ intelligencePriority?: number;
2748
+ };
2749
+ includeContext?: "none" | "thisServer" | "allServers";
2750
+ temperature?: number;
2751
+ maxTokens: number;
2752
+ stopSequences?: string[];
2753
+ metadata?: Record<string, unknown>;
2754
+ }
2755
+ /**
2756
+ * ADK sampling response format - what we expect from the user's handler
2757
+ */
2758
+ interface ADKSamplingResponse {
2759
+ model: string;
2760
+ stopReason?: "endTurn" | "stopSequence" | "maxTokens" | string;
2761
+ content: string | null;
2762
+ }
2763
+ /**
2764
+ * ADK sampling handler function type - receives ADK formatted messages
2765
+ */
2766
+ type ADKSamplingHandler = (request: ADKSamplingRequest) => Promise<ADKSamplingResponse>;
2737
2767
 
2738
2768
  declare class McpClientService {
2739
2769
  private config;
2740
2770
  private client;
2741
2771
  private transport;
2742
2772
  private isClosing;
2743
- private samplingHandler;
2773
+ private mcpSamplingHandler;
2744
2774
  private logger;
2745
2775
  constructor(config: McpConfig);
2746
2776
  /**
@@ -2777,7 +2807,13 @@ declare class McpClientService {
2777
2807
  */
2778
2808
  isConnected(): boolean;
2779
2809
  private setupSamplingHandler;
2780
- setSamplingHandler(handler: SamplingHandler): void;
2810
+ /**
2811
+ * Set an ADK sampling handler
2812
+ */
2813
+ setSamplingHandler(handler: ADKSamplingHandler): void;
2814
+ /**
2815
+ * Remove the sampling handler
2816
+ */
2781
2817
  removeSamplingHandler(): void;
2782
2818
  }
2783
2819
 
@@ -2886,7 +2922,6 @@ declare const index$2_McpErrorType: typeof McpErrorType;
2886
2922
  type index$2_McpToolset = McpToolset;
2887
2923
  declare const index$2_McpToolset: typeof McpToolset;
2888
2924
  type index$2_McpTransportType = McpTransportType;
2889
- type index$2_SamplingHandler = SamplingHandler;
2890
2925
  type index$2_SamplingRequest = SamplingRequest;
2891
2926
  type index$2_SamplingResponse = SamplingResponse;
2892
2927
  type index$2_ToolConfig = ToolConfig;
@@ -2904,7 +2939,7 @@ declare const index$2_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
2904
2939
  declare const index$2_mcpSchemaToParameters: typeof mcpSchemaToParameters;
2905
2940
  declare const index$2_normalizeJsonSchema: typeof normalizeJsonSchema;
2906
2941
  declare namespace index$2 {
2907
- export { index$2_BaseTool as BaseTool, type index$2_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$2_ExitLoopTool as ExitLoopTool, index$2_FileOperationsTool as FileOperationsTool, index$2_FunctionTool as FunctionTool, index$2_GetUserChoiceTool as GetUserChoiceTool, index$2_GoogleSearch as GoogleSearch, index$2_HttpRequestTool as HttpRequestTool, type index$2_IToolContext as IToolContext, index$2_LoadMemoryTool as LoadMemoryTool, type index$2_McpConfig as McpConfig, index$2_McpError as McpError, index$2_McpErrorType as McpErrorType, index$2_McpToolset as McpToolset, type index$2_McpTransportType as McpTransportType, type index$2_SamplingHandler as SamplingHandler, type index$2_SamplingRequest as SamplingRequest, type index$2_SamplingResponse as SamplingResponse, type index$2_ToolConfig as ToolConfig, index$2_ToolContext as ToolContext, index$2_TransferToAgentTool as TransferToAgentTool, index$2_UserInteractionTool as UserInteractionTool, index$2_adkToMcpToolType as adkToMcpToolType, index$2_buildFunctionDeclaration as buildFunctionDeclaration, index$2_createFunctionTool as createFunctionTool, index$2_getMcpTools as getMcpTools, index$2_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$2_mcpSchemaToParameters as mcpSchemaToParameters, index$2_normalizeJsonSchema as normalizeJsonSchema };
2942
+ export { index$2_BaseTool as BaseTool, type index$2_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$2_ExitLoopTool as ExitLoopTool, index$2_FileOperationsTool as FileOperationsTool, index$2_FunctionTool as FunctionTool, index$2_GetUserChoiceTool as GetUserChoiceTool, index$2_GoogleSearch as GoogleSearch, index$2_HttpRequestTool as HttpRequestTool, type index$2_IToolContext as IToolContext, index$2_LoadMemoryTool as LoadMemoryTool, type index$2_McpConfig as McpConfig, index$2_McpError as McpError, index$2_McpErrorType as McpErrorType, index$2_McpToolset as McpToolset, type index$2_McpTransportType as McpTransportType, type index$2_SamplingRequest as SamplingRequest, type index$2_SamplingResponse as SamplingResponse, type index$2_ToolConfig as ToolConfig, index$2_ToolContext as ToolContext, index$2_TransferToAgentTool as TransferToAgentTool, index$2_UserInteractionTool as UserInteractionTool, index$2_adkToMcpToolType as adkToMcpToolType, index$2_buildFunctionDeclaration as buildFunctionDeclaration, index$2_createFunctionTool as createFunctionTool, index$2_getMcpTools as getMcpTools, index$2_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$2_mcpSchemaToParameters as mcpSchemaToParameters, index$2_normalizeJsonSchema as normalizeJsonSchema };
2908
2943
  }
2909
2944
 
2910
2945
  /**
@@ -3463,4 +3498,4 @@ declare class InMemoryRunner extends Runner {
3463
3498
 
3464
3499
  declare const VERSION = "0.1.0";
3465
3500
 
3466
- export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, type McpConfig, McpError, McpErrorType, McpToolset, type McpTransportType, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SamplingHandler, type SamplingRequest, type SamplingResponse, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, validateSession };
3501
+ export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, type McpConfig, McpError, McpErrorType, McpToolset, type McpTransportType, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SamplingRequest, type SamplingResponse, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, validateSession };
package/dist/index.d.ts CHANGED
@@ -2684,7 +2684,6 @@ declare class LoadMemoryTool extends BaseTool {
2684
2684
 
2685
2685
  type McpConfig = {
2686
2686
  name: string;
2687
- description: string;
2688
2687
  transport: McpTransportType;
2689
2688
  timeout?: number;
2690
2689
  retryOptions?: {
@@ -2699,7 +2698,6 @@ type McpConfig = {
2699
2698
  maxSize?: number;
2700
2699
  };
2701
2700
  debug?: boolean;
2702
- samplingHandler?: SamplingHandler;
2703
2701
  };
2704
2702
  type McpTransportType = {
2705
2703
  mode: "stdio";
@@ -2733,14 +2731,46 @@ declare class McpError extends Error {
2733
2731
  }
2734
2732
  type SamplingRequest = z.infer<typeof CreateMessageRequestSchema>;
2735
2733
  type SamplingResponse = z.infer<typeof CreateMessageResultSchema>;
2736
- type SamplingHandler = (request: SamplingRequest) => Promise<SamplingResponse>;
2734
+
2735
+ /**
2736
+ * ADK sampling request format - what we pass to the user's handler
2737
+ */
2738
+ interface ADKSamplingRequest {
2739
+ messages: Message[];
2740
+ systemPrompt?: string;
2741
+ modelPreferences?: {
2742
+ hints?: Array<{
2743
+ name?: string;
2744
+ }>;
2745
+ costPriority?: number;
2746
+ speedPriority?: number;
2747
+ intelligencePriority?: number;
2748
+ };
2749
+ includeContext?: "none" | "thisServer" | "allServers";
2750
+ temperature?: number;
2751
+ maxTokens: number;
2752
+ stopSequences?: string[];
2753
+ metadata?: Record<string, unknown>;
2754
+ }
2755
+ /**
2756
+ * ADK sampling response format - what we expect from the user's handler
2757
+ */
2758
+ interface ADKSamplingResponse {
2759
+ model: string;
2760
+ stopReason?: "endTurn" | "stopSequence" | "maxTokens" | string;
2761
+ content: string | null;
2762
+ }
2763
+ /**
2764
+ * ADK sampling handler function type - receives ADK formatted messages
2765
+ */
2766
+ type ADKSamplingHandler = (request: ADKSamplingRequest) => Promise<ADKSamplingResponse>;
2737
2767
 
2738
2768
  declare class McpClientService {
2739
2769
  private config;
2740
2770
  private client;
2741
2771
  private transport;
2742
2772
  private isClosing;
2743
- private samplingHandler;
2773
+ private mcpSamplingHandler;
2744
2774
  private logger;
2745
2775
  constructor(config: McpConfig);
2746
2776
  /**
@@ -2777,7 +2807,13 @@ declare class McpClientService {
2777
2807
  */
2778
2808
  isConnected(): boolean;
2779
2809
  private setupSamplingHandler;
2780
- setSamplingHandler(handler: SamplingHandler): void;
2810
+ /**
2811
+ * Set an ADK sampling handler
2812
+ */
2813
+ setSamplingHandler(handler: ADKSamplingHandler): void;
2814
+ /**
2815
+ * Remove the sampling handler
2816
+ */
2781
2817
  removeSamplingHandler(): void;
2782
2818
  }
2783
2819
 
@@ -2886,7 +2922,6 @@ declare const index$2_McpErrorType: typeof McpErrorType;
2886
2922
  type index$2_McpToolset = McpToolset;
2887
2923
  declare const index$2_McpToolset: typeof McpToolset;
2888
2924
  type index$2_McpTransportType = McpTransportType;
2889
- type index$2_SamplingHandler = SamplingHandler;
2890
2925
  type index$2_SamplingRequest = SamplingRequest;
2891
2926
  type index$2_SamplingResponse = SamplingResponse;
2892
2927
  type index$2_ToolConfig = ToolConfig;
@@ -2904,7 +2939,7 @@ declare const index$2_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
2904
2939
  declare const index$2_mcpSchemaToParameters: typeof mcpSchemaToParameters;
2905
2940
  declare const index$2_normalizeJsonSchema: typeof normalizeJsonSchema;
2906
2941
  declare namespace index$2 {
2907
- export { index$2_BaseTool as BaseTool, type index$2_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$2_ExitLoopTool as ExitLoopTool, index$2_FileOperationsTool as FileOperationsTool, index$2_FunctionTool as FunctionTool, index$2_GetUserChoiceTool as GetUserChoiceTool, index$2_GoogleSearch as GoogleSearch, index$2_HttpRequestTool as HttpRequestTool, type index$2_IToolContext as IToolContext, index$2_LoadMemoryTool as LoadMemoryTool, type index$2_McpConfig as McpConfig, index$2_McpError as McpError, index$2_McpErrorType as McpErrorType, index$2_McpToolset as McpToolset, type index$2_McpTransportType as McpTransportType, type index$2_SamplingHandler as SamplingHandler, type index$2_SamplingRequest as SamplingRequest, type index$2_SamplingResponse as SamplingResponse, type index$2_ToolConfig as ToolConfig, index$2_ToolContext as ToolContext, index$2_TransferToAgentTool as TransferToAgentTool, index$2_UserInteractionTool as UserInteractionTool, index$2_adkToMcpToolType as adkToMcpToolType, index$2_buildFunctionDeclaration as buildFunctionDeclaration, index$2_createFunctionTool as createFunctionTool, index$2_getMcpTools as getMcpTools, index$2_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$2_mcpSchemaToParameters as mcpSchemaToParameters, index$2_normalizeJsonSchema as normalizeJsonSchema };
2942
+ export { index$2_BaseTool as BaseTool, type index$2_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$2_ExitLoopTool as ExitLoopTool, index$2_FileOperationsTool as FileOperationsTool, index$2_FunctionTool as FunctionTool, index$2_GetUserChoiceTool as GetUserChoiceTool, index$2_GoogleSearch as GoogleSearch, index$2_HttpRequestTool as HttpRequestTool, type index$2_IToolContext as IToolContext, index$2_LoadMemoryTool as LoadMemoryTool, type index$2_McpConfig as McpConfig, index$2_McpError as McpError, index$2_McpErrorType as McpErrorType, index$2_McpToolset as McpToolset, type index$2_McpTransportType as McpTransportType, type index$2_SamplingRequest as SamplingRequest, type index$2_SamplingResponse as SamplingResponse, type index$2_ToolConfig as ToolConfig, index$2_ToolContext as ToolContext, index$2_TransferToAgentTool as TransferToAgentTool, index$2_UserInteractionTool as UserInteractionTool, index$2_adkToMcpToolType as adkToMcpToolType, index$2_buildFunctionDeclaration as buildFunctionDeclaration, index$2_createFunctionTool as createFunctionTool, index$2_getMcpTools as getMcpTools, index$2_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$2_mcpSchemaToParameters as mcpSchemaToParameters, index$2_normalizeJsonSchema as normalizeJsonSchema };
2908
2943
  }
2909
2944
 
2910
2945
  /**
@@ -3463,4 +3498,4 @@ declare class InMemoryRunner extends Runner {
3463
3498
 
3464
3499
  declare const VERSION = "0.1.0";
3465
3500
 
3466
- export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, type McpConfig, McpError, McpErrorType, McpToolset, type McpTransportType, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SamplingHandler, type SamplingRequest, type SamplingResponse, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, validateSession };
3501
+ export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, type McpConfig, McpError, McpErrorType, McpToolset, type McpTransportType, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SamplingRequest, type SamplingResponse, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, validateSession };