@iqai/adk 0.1.4 → 0.1.5

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/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
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
+ import { LanguageModel } from 'ai';
3
4
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
4
5
  import { CreateMessageRequestSchema, CreateMessageResultSchema, Tool } from '@modelcontextprotocol/sdk/types.js';
5
6
  import { z } from 'zod';
@@ -7,6 +8,29 @@ import { Kysely, Generated } from 'kysely';
7
8
  import { StorageOptions } from '@google-cloud/storage';
8
9
  import { Tracer } from '@opentelemetry/api';
9
10
 
11
+ interface LoggerOpts {
12
+ name: string;
13
+ }
14
+ declare class Logger {
15
+ name: string;
16
+ isDebugEnabled: boolean;
17
+ constructor({ name }: LoggerOpts);
18
+ private colorize;
19
+ debug(message: string, ...args: any[]): void;
20
+ info(message: string, ...args: any[]): void;
21
+ warn(message: string, ...args: any[]): void;
22
+ error(message: string, ...args: any[]): void;
23
+ /**
24
+ * Logs structured data in a visually appealing table format.
25
+ * Uses vertical layout for better readability and respects debug settings.
26
+ */
27
+ debugStructured(title: string, data: Record<string, any>): void;
28
+ /**
29
+ * Logs array data in a compact, readable format.
30
+ */
31
+ debugArray(title: string, items: Array<Record<string, any>>): void;
32
+ }
33
+
10
34
  /**
11
35
  * JSON Schema type for function parameters
12
36
  */
@@ -816,6 +840,7 @@ declare abstract class BaseTool {
816
840
  * Maximum delay for retry in ms
817
841
  */
818
842
  maxRetryDelay: number;
843
+ protected logger: Logger;
819
844
  /**
820
845
  * Constructor for BaseTool
821
846
  */
@@ -983,7 +1008,7 @@ declare function createFunctionTool(func: (...args: any[]) => any, options?: {
983
1008
  * Simple GoogleSearch tool implementation
984
1009
  */
985
1010
  declare class GoogleSearch extends BaseTool {
986
- private logger;
1011
+ protected logger: Logger;
987
1012
  /**
988
1013
  * Constructor for GoogleSearch
989
1014
  */
@@ -1126,7 +1151,7 @@ declare class UserInteractionTool extends BaseTool {
1126
1151
  * Tool that allows an agent to exit the current execution loop
1127
1152
  */
1128
1153
  declare class ExitLoopTool extends BaseTool {
1129
- private logger;
1154
+ protected logger: Logger;
1130
1155
  /**
1131
1156
  * Constructor for ExitLoopTool
1132
1157
  */
@@ -1141,7 +1166,7 @@ declare class ExitLoopTool extends BaseTool {
1141
1166
  * Tool that allows an agent to get a choice from the user
1142
1167
  */
1143
1168
  declare class GetUserChoiceTool extends BaseTool {
1144
- private logger;
1169
+ protected logger: Logger;
1145
1170
  /**
1146
1171
  * Constructor for GetUserChoiceTool
1147
1172
  */
@@ -1165,7 +1190,7 @@ declare class GetUserChoiceTool extends BaseTool {
1165
1190
  * Tool that allows an agent to transfer control to another agent
1166
1191
  */
1167
1192
  declare class TransferToAgentTool extends BaseTool {
1168
- private logger;
1193
+ protected logger: Logger;
1169
1194
  /**
1170
1195
  * Constructor for TransferToAgentTool
1171
1196
  */
@@ -1182,7 +1207,7 @@ declare class TransferToAgentTool extends BaseTool {
1182
1207
  * Tool that allows an agent to load memories relevant to a query
1183
1208
  */
1184
1209
  declare class LoadMemoryTool extends BaseTool {
1185
- private logger;
1210
+ protected logger: Logger;
1186
1211
  /**
1187
1212
  * Constructor for LoadMemoryTool
1188
1213
  */
@@ -1307,7 +1332,7 @@ declare class McpClientService {
1307
1332
  private transport;
1308
1333
  private isClosing;
1309
1334
  private mcpSamplingHandler;
1310
- private logger;
1335
+ protected logger: Logger;
1311
1336
  constructor(config: McpConfig);
1312
1337
  /**
1313
1338
  * Initializes and returns an MCP client based on configuration.
@@ -1378,7 +1403,7 @@ declare function mcpSchemaToParameters(mcpTool: Tool): JSONSchema;
1378
1403
  * between MCP format and ADK format
1379
1404
  */
1380
1405
  declare class McpSamplingHandler {
1381
- private logger;
1406
+ protected logger: Logger;
1382
1407
  private samplingHandler;
1383
1408
  constructor(samplingHandler: SamplingHandler);
1384
1409
  /**
@@ -1442,8 +1467,8 @@ declare function createSamplingHandler(handler: SamplingHandler): SamplingHandle
1442
1467
  * ```typescript
1443
1468
  * // Old verbose way:
1444
1469
  * const toolset = new McpToolset({
1445
- * name: "Near Intent Swaps MCP Client",
1446
- * description: "Client for Near Intent Swaps",
1470
+ * name: "Near Intents Swaps MCP Client",
1471
+ * description: "Client for Near Intents Swaps",
1447
1472
  * debug: env.DEBUG,
1448
1473
  * retryOptions: { maxRetries: 2, initialDelay: 200 },
1449
1474
  * transport: {
@@ -1590,7 +1615,7 @@ declare function McpIqWiki(config?: McpServerConfig): McpToolset;
1590
1615
  */
1591
1616
  declare function McpNearAgent(config?: McpServerConfig): McpToolset;
1592
1617
  /**
1593
- * MCP NEAR Intent Swaps - NEAR Protocol intent swaps functionality
1618
+ * MCP Near Intents Swaps - NEAR Protocol intent swaps functionality
1594
1619
  *
1595
1620
  * Required env vars: ACCOUNT_ID, ACCOUNT_KEY
1596
1621
  * Optional env vars: NEAR_NETWORK_ID, NEAR_NODE_URL, NEAR_GAS_LIMIT
@@ -1912,6 +1937,10 @@ declare class LlmResponse {
1912
1937
  * Reason why the model finished generating.
1913
1938
  */
1914
1939
  finishReason?: string;
1940
+ /**
1941
+ * Error object if the response is an error.
1942
+ */
1943
+ error?: Error;
1915
1944
  /**
1916
1945
  * Creates a new LlmResponse.
1917
1946
  */
@@ -1923,6 +1952,19 @@ declare class LlmResponse {
1923
1952
  * @returns The LlmResponse.
1924
1953
  */
1925
1954
  static create(generateContentResponse: GenerateContentResponse): LlmResponse;
1955
+ /**
1956
+ * Creates an LlmResponse from an error.
1957
+ *
1958
+ * @param error The error object or message.
1959
+ * @param options Additional options for the error response.
1960
+ * @param options.errorCode A specific error code for the response.
1961
+ * @param options.model The model that was being used when the error occurred.
1962
+ * @returns The LlmResponse.
1963
+ */
1964
+ static fromError(error: unknown, options?: {
1965
+ errorCode?: string;
1966
+ model?: string;
1967
+ }): LlmResponse;
1926
1968
  }
1927
1969
 
1928
1970
  /**
@@ -1978,6 +2020,7 @@ declare abstract class BaseLlm {
1978
2020
  * The name of the LLM, e.g. gemini-1.5-flash or gemini-1.5-flash-001.
1979
2021
  */
1980
2022
  model: string;
2023
+ protected logger: Logger;
1981
2024
  /**
1982
2025
  * Constructor for BaseLlm
1983
2026
  */
@@ -2035,7 +2078,6 @@ declare class GoogleLlm extends BaseLlm {
2035
2078
  private _liveApiClient?;
2036
2079
  private _apiBackend?;
2037
2080
  private _trackingHeaders?;
2038
- private logger;
2039
2081
  /**
2040
2082
  * Constructor for Gemini
2041
2083
  */
@@ -2076,14 +2118,6 @@ declare class GoogleLlm extends BaseLlm {
2076
2118
  * Builds function declaration log string.
2077
2119
  */
2078
2120
  private buildFunctionDeclarationLog;
2079
- /**
2080
- * Builds request log string.
2081
- */
2082
- private buildRequestLog;
2083
- /**
2084
- * Builds response log string.
2085
- */
2086
- private buildResponseLog;
2087
2121
  /**
2088
2122
  * Provides the api client.
2089
2123
  */
@@ -2111,6 +2145,7 @@ declare class GoogleLlm extends BaseLlm {
2111
2145
  */
2112
2146
  declare class AnthropicLlm extends BaseLlm {
2113
2147
  private _client?;
2148
+ protected logger: Logger;
2114
2149
  /**
2115
2150
  * Constructor for Anthropic LLM
2116
2151
  */
@@ -2233,17 +2268,48 @@ declare class OpenAiLlm extends BaseLlm {
2233
2268
  */
2234
2269
  private hasInlineData;
2235
2270
  /**
2236
- * Build request log string for debugging (similar to Google LLM)
2271
+ * Gets the OpenAI client
2272
+ */
2273
+ private get client();
2274
+ }
2275
+
2276
+ /**
2277
+ * AI SDK integration that accepts a pre-configured LanguageModel.
2278
+ * Enables ADK to work with any provider supported by Vercel's AI SDK.
2279
+ */
2280
+ declare class AiSdkLlm extends BaseLlm {
2281
+ private modelInstance;
2282
+ protected logger: Logger;
2283
+ /**
2284
+ * Constructor accepts a pre-configured LanguageModel instance
2285
+ * @param model - Pre-configured LanguageModel from provider(modelName)
2237
2286
  */
2238
- private buildRequestLog;
2287
+ constructor(modelInstance: LanguageModel);
2239
2288
  /**
2240
- * Build response log string for debugging (similar to Google LLM)
2289
+ * Returns empty array - following Python ADK pattern
2241
2290
  */
2242
- private buildResponseLog;
2291
+ static supportedModels(): string[];
2292
+ protected generateContentAsyncImpl(request: LlmRequest, stream?: boolean): AsyncGenerator<LlmResponse, void, unknown>;
2243
2293
  /**
2244
- * Gets the OpenAI client
2294
+ * Convert ADK LlmRequest to AI SDK CoreMessage format
2245
2295
  */
2246
- private get client();
2296
+ private convertToAiSdkMessages;
2297
+ /**
2298
+ * Convert ADK tools to AI SDK tools format
2299
+ */
2300
+ private convertToAiSdkTools;
2301
+ /**
2302
+ * Convert ADK Content to AI SDK CoreMessage
2303
+ */
2304
+ private contentToAiSdkMessage;
2305
+ /**
2306
+ * Map ADK role to AI SDK role
2307
+ */
2308
+ private mapRole;
2309
+ /**
2310
+ * Map AI SDK finish reason to ADK finish reason
2311
+ */
2312
+ private mapFinishReason;
2247
2313
  }
2248
2314
 
2249
2315
  /**
@@ -2261,6 +2327,7 @@ declare class LLMRegistry {
2261
2327
  * Map of model name regex to LLM class
2262
2328
  */
2263
2329
  private static llmRegistry;
2330
+ private static logger;
2264
2331
  /**
2265
2332
  * Creates a new LLM instance
2266
2333
  *
@@ -2793,6 +2860,8 @@ declare class OAuth2Credential extends AuthCredential {
2793
2860
  * Models module exports - consolidated to match Python structure
2794
2861
  */
2795
2862
 
2863
+ type index$5_AiSdkLlm = AiSdkLlm;
2864
+ declare const index$5_AiSdkLlm: typeof AiSdkLlm;
2796
2865
  type index$5_AnthropicLlm = AnthropicLlm;
2797
2866
  declare const index$5_AnthropicLlm: typeof AnthropicLlm;
2798
2867
  type index$5_ApiKeyCredential = ApiKeyCredential;
@@ -2850,7 +2919,7 @@ declare const index$5_State: typeof State;
2850
2919
  type index$5_ThinkingConfig = ThinkingConfig;
2851
2920
  declare const index$5_registerProviders: typeof registerProviders;
2852
2921
  declare namespace index$5 {
2853
- export { index$5_AnthropicLlm as AnthropicLlm, index$5_ApiKeyCredential as ApiKeyCredential, index$5_ApiKeyScheme as ApiKeyScheme, index$5_AuthConfig as AuthConfig, index$5_AuthCredential as AuthCredential, index$5_AuthCredentialType as AuthCredentialType, index$5_AuthHandler as AuthHandler, index$5_AuthScheme as AuthScheme, index$5_AuthSchemeType as AuthSchemeType, index$5_BaseLLMConnection as BaseLLMConnection, index$5_BaseLlm as BaseLlm, type index$5_BaseMemoryService as BaseMemoryService, index$5_BasicAuthCredential as BasicAuthCredential, index$5_BearerTokenCredential as BearerTokenCredential, index$5_Blob as Blob, Content$1 as Content, type index$5_FunctionDeclaration as FunctionDeclaration, index$5_GoogleLlm as GoogleLlm, index$5_HttpScheme as HttpScheme, type index$5_JSONSchema as JSONSchema, index$5_LLMRegistry as LLMRegistry, index$5_LlmRequest as LlmRequest, index$5_LlmResponse as LlmResponse, index$5_OAuth2Credential as OAuth2Credential, index$5_OAuth2Scheme as OAuth2Scheme, type index$5_OAuthFlow as OAuthFlow, type index$5_OAuthFlows as OAuthFlows, index$5_OpenAiLlm as OpenAiLlm, index$5_OpenIdConnectScheme as OpenIdConnectScheme, type index$5_SearchMemoryResponse as SearchMemoryResponse, type index$5_Session as Session, index$5_State as State, type index$5_ThinkingConfig as ThinkingConfig, index$5_registerProviders as registerProviders };
2922
+ export { index$5_AiSdkLlm as AiSdkLlm, index$5_AnthropicLlm as AnthropicLlm, index$5_ApiKeyCredential as ApiKeyCredential, index$5_ApiKeyScheme as ApiKeyScheme, index$5_AuthConfig as AuthConfig, index$5_AuthCredential as AuthCredential, index$5_AuthCredentialType as AuthCredentialType, index$5_AuthHandler as AuthHandler, index$5_AuthScheme as AuthScheme, index$5_AuthSchemeType as AuthSchemeType, index$5_BaseLLMConnection as BaseLLMConnection, index$5_BaseLlm as BaseLlm, type index$5_BaseMemoryService as BaseMemoryService, index$5_BasicAuthCredential as BasicAuthCredential, index$5_BearerTokenCredential as BearerTokenCredential, index$5_Blob as Blob, Content$1 as Content, type index$5_FunctionDeclaration as FunctionDeclaration, index$5_GoogleLlm as GoogleLlm, index$5_HttpScheme as HttpScheme, type index$5_JSONSchema as JSONSchema, index$5_LLMRegistry as LLMRegistry, index$5_LlmRequest as LlmRequest, index$5_LlmResponse as LlmResponse, index$5_OAuth2Credential as OAuth2Credential, index$5_OAuth2Scheme as OAuth2Scheme, type index$5_OAuthFlow as OAuthFlow, type index$5_OAuthFlows as OAuthFlows, index$5_OpenAiLlm as OpenAiLlm, index$5_OpenIdConnectScheme as OpenIdConnectScheme, type index$5_SearchMemoryResponse as SearchMemoryResponse, type index$5_Session as Session, index$5_State as State, type index$5_ThinkingConfig as ThinkingConfig, index$5_registerProviders as registerProviders };
2854
2923
  }
2855
2924
 
2856
2925
  /**
@@ -3084,6 +3153,101 @@ declare abstract class BaseAgent {
3084
3153
  private setParentAgentForSubAgents;
3085
3154
  }
3086
3155
 
3156
+ interface File {
3157
+ /** The name of the file with file extension (e.g., "file.csv") */
3158
+ name: string;
3159
+ /** The base64-encoded bytes of the file content */
3160
+ content: string;
3161
+ /** The mime type of the file (e.g., "image/png") */
3162
+ mimeType: string;
3163
+ }
3164
+ interface CodeExecutionInput {
3165
+ /** The code to execute */
3166
+ code: string;
3167
+ /** The input files available to the code */
3168
+ inputFiles: File[];
3169
+ /** The execution ID for the stateful code execution */
3170
+ executionId?: string;
3171
+ }
3172
+ interface CodeExecutionResult {
3173
+ /** The standard output of the code execution */
3174
+ stdout: string;
3175
+ /** The standard error of the code execution */
3176
+ stderr: string;
3177
+ /** The output files from the code execution */
3178
+ outputFiles: File[];
3179
+ }
3180
+ declare class CodeExecutionUtils {
3181
+ /**
3182
+ * Gets the file content as a base64-encoded string
3183
+ */
3184
+ static getEncodedFileContent(data: string | ArrayBuffer): string;
3185
+ private static isBase64Encoded;
3186
+ /**
3187
+ * Extracts the first code block from the content and truncates everything after it
3188
+ */
3189
+ static extractCodeAndTruncateContent(content: Content$1, codeBlockDelimiters: Array<[string, string]>): string | null;
3190
+ private static escapeRegex;
3191
+ /**
3192
+ * Builds an executable code part with code string
3193
+ */
3194
+ static buildExecutableCodePart(code: string): Part;
3195
+ /**
3196
+ * Builds the code execution result part from the code execution result
3197
+ */
3198
+ static buildCodeExecutionResultPart(codeExecutionResult: CodeExecutionResult): Part;
3199
+ /**
3200
+ * Converts the code execution parts to text parts in a Content
3201
+ */
3202
+ static convertCodeExecutionParts(content: Content$1, codeBlockDelimiter: [string, string], executionResultDelimiters: [string, string]): void;
3203
+ }
3204
+
3205
+ interface BaseCodeExecutorConfig {
3206
+ /**
3207
+ * If true, extract and process data files from the model request
3208
+ * and attach them to the code executor.
3209
+ * Supported data file MimeTypes are [text/csv].
3210
+ * Default to false.
3211
+ */
3212
+ optimizeDataFile?: boolean;
3213
+ /**
3214
+ * Whether the code executor is stateful. Default to false.
3215
+ */
3216
+ stateful?: boolean;
3217
+ /**
3218
+ * The number of attempts to retry on consecutive code execution errors.
3219
+ * Default to 2.
3220
+ */
3221
+ errorRetryAttempts?: number;
3222
+ /**
3223
+ * The list of the enclosing delimiters to identify the code blocks.
3224
+ * For example, the delimiter ['```python\n', '\n```'] can be
3225
+ * used to identify code blocks with the following format:
3226
+ *
3227
+ * ```python
3228
+ * print("hello")
3229
+ * ```
3230
+ */
3231
+ codeBlockDelimiters?: Array<[string, string]>;
3232
+ /**
3233
+ * The delimiters to format the code execution result.
3234
+ */
3235
+ executionResultDelimiters?: [string, string];
3236
+ }
3237
+ declare abstract class BaseCodeExecutor {
3238
+ protected readonly config: Required<BaseCodeExecutorConfig>;
3239
+ constructor(config?: BaseCodeExecutorConfig);
3240
+ /**
3241
+ * Executes code and returns the code execution result.
3242
+ */
3243
+ abstract executeCode(invocationContext: InvocationContext, codeExecutionInput: CodeExecutionInput): Promise<CodeExecutionResult>;
3244
+ get optimizeDataFile(): boolean;
3245
+ get stateful(): boolean;
3246
+ get errorRetryAttempts(): number;
3247
+ get codeBlockDelimiters(): Array<[string, string]>;
3248
+ get executionResultDelimiters(): [string, string];
3249
+ }
3250
+
3087
3251
  /**
3088
3252
  * Abstract base class for all planners.
3089
3253
  *
@@ -3119,7 +3283,7 @@ type ToolUnion = BaseTool | ((...args: any[]) => any);
3119
3283
  /**
3120
3284
  * Configuration for LlmAgent
3121
3285
  */
3122
- interface LlmAgentConfig {
3286
+ interface LlmAgentConfig<T extends BaseLlm = BaseLlm> {
3123
3287
  /**
3124
3288
  * Name of the agent
3125
3289
  */
@@ -3132,7 +3296,7 @@ interface LlmAgentConfig {
3132
3296
  * The LLM model to use
3133
3297
  * When not set, the agent will inherit the model from its ancestor
3134
3298
  */
3135
- model?: string | BaseLlm;
3299
+ model?: string | T | LanguageModel;
3136
3300
  /**
3137
3301
  * Instructions for the LLM model, guiding the agent's behavior
3138
3302
  */
@@ -3146,6 +3310,10 @@ interface LlmAgentConfig {
3146
3310
  * Tools available to this agent
3147
3311
  */
3148
3312
  tools?: ToolUnion[];
3313
+ /**
3314
+ * Code executor for this agent
3315
+ */
3316
+ codeExecutor?: BaseCodeExecutor;
3149
3317
  /**
3150
3318
  * Disallows LLM-controlled transferring to the parent agent
3151
3319
  */
@@ -3205,12 +3373,12 @@ interface LlmAgentConfig {
3205
3373
  /**
3206
3374
  * LLM-based Agent
3207
3375
  */
3208
- declare class LlmAgent extends BaseAgent {
3376
+ declare class LlmAgent<T extends BaseLlm = BaseLlm> extends BaseAgent {
3209
3377
  /**
3210
3378
  * The model to use for the agent
3211
3379
  * When not set, the agent will inherit the model from its ancestor
3212
3380
  */
3213
- model: string | BaseLlm;
3381
+ model: string | T | LanguageModel;
3214
3382
  /**
3215
3383
  * Instructions for the LLM model, guiding the agent's behavior
3216
3384
  */
@@ -3224,6 +3392,10 @@ declare class LlmAgent extends BaseAgent {
3224
3392
  * Tools available to this agent
3225
3393
  */
3226
3394
  tools: ToolUnion[];
3395
+ /**
3396
+ * Code executor for this agent
3397
+ */
3398
+ codeExecutor?: BaseCodeExecutor;
3227
3399
  /**
3228
3400
  * Disallows LLM-controlled transferring to the parent agent
3229
3401
  */
@@ -3276,11 +3448,11 @@ declare class LlmAgent extends BaseAgent {
3276
3448
  * The output schema when agent replies
3277
3449
  */
3278
3450
  outputSchema?: any;
3279
- private logger;
3451
+ protected logger: Logger;
3280
3452
  /**
3281
3453
  * Constructor for LlmAgent
3282
3454
  */
3283
- constructor(config: LlmAgentConfig);
3455
+ constructor(config: LlmAgentConfig<T>);
3284
3456
  /**
3285
3457
  * The resolved model field as BaseLLM
3286
3458
  * This method is only for use by Agent Development Kit
@@ -3515,7 +3687,7 @@ declare class LangGraphAgent extends BaseAgent {
3515
3687
  * Results from node executions
3516
3688
  */
3517
3689
  private results;
3518
- private logger;
3690
+ protected logger: Logger;
3519
3691
  /**
3520
3692
  * Constructor for LangGraphAgent
3521
3693
  */
@@ -3576,7 +3748,7 @@ declare class LangGraphAgent extends BaseAgent {
3576
3748
  * processing, event generation, and interaction with various services like
3577
3749
  * artifact storage, session management, and memory.
3578
3750
  */
3579
- declare class Runner {
3751
+ declare class Runner<T extends BaseAgent = BaseAgent> {
3580
3752
  /**
3581
3753
  * The app name of the runner.
3582
3754
  */
@@ -3584,7 +3756,7 @@ declare class Runner {
3584
3756
  /**
3585
3757
  * The root agent to run.
3586
3758
  */
3587
- agent: BaseAgent;
3759
+ agent: T;
3588
3760
  /**
3589
3761
  * The artifact service for the runner.
3590
3762
  */
@@ -3597,12 +3769,13 @@ declare class Runner {
3597
3769
  * The memory service for the runner.
3598
3770
  */
3599
3771
  memoryService?: BaseMemoryService;
3772
+ protected logger: Logger;
3600
3773
  /**
3601
3774
  * Initializes the Runner.
3602
3775
  */
3603
3776
  constructor({ appName, agent, artifactService, sessionService, memoryService, }: {
3604
3777
  appName: string;
3605
- agent: BaseAgent;
3778
+ agent: T;
3606
3779
  artifactService?: BaseArtifactService;
3607
3780
  sessionService: BaseSessionService;
3608
3781
  memoryService?: BaseMemoryService;
@@ -3647,7 +3820,7 @@ declare class Runner {
3647
3820
  /**
3648
3821
  * An in-memory Runner for testing and development.
3649
3822
  */
3650
- declare class InMemoryRunner extends Runner {
3823
+ declare class InMemoryRunner<T extends BaseAgent = BaseAgent> extends Runner<T> {
3651
3824
  /**
3652
3825
  * Deprecated. Please don't use. The in-memory session service for the runner.
3653
3826
  */
@@ -3655,7 +3828,7 @@ declare class InMemoryRunner extends Runner {
3655
3828
  /**
3656
3829
  * Initializes the InMemoryRunner.
3657
3830
  */
3658
- constructor(agent: BaseAgent, { appName }?: {
3831
+ constructor(agent: T, { appName }?: {
3659
3832
  appName?: string;
3660
3833
  });
3661
3834
  }
@@ -3665,7 +3838,7 @@ declare class InMemoryRunner extends Runner {
3665
3838
  */
3666
3839
  interface AgentBuilderConfig {
3667
3840
  name: string;
3668
- model?: string;
3841
+ model?: string | BaseLlm | LanguageModel;
3669
3842
  description?: string;
3670
3843
  instruction?: string;
3671
3844
  tools?: BaseTool[];
@@ -3724,6 +3897,10 @@ type AgentType = "llm" | "sequential" | "parallel" | "loop" | "langgraph";
3724
3897
  * .withModel("gemini-2.5-flash")
3725
3898
  * .withSession(sessionService, "user123", "myApp")
3726
3899
  * .build();
3900
+ *
3901
+ * // Using an AI SDK provider directly
3902
+ * import { google } from "@ai-sdk/google";
3903
+ * const response = await AgentBuilder.withModel(google()).ask("Hi");
3727
3904
  * ```
3728
3905
  */
3729
3906
  declare class AgentBuilder {
@@ -3745,13 +3922,13 @@ declare class AgentBuilder {
3745
3922
  * @param model The model identifier (e.g., "gemini-2.5-flash")
3746
3923
  * @returns New AgentBuilder instance with model set
3747
3924
  */
3748
- static withModel(model: string): AgentBuilder;
3925
+ static withModel(model: string | BaseLlm | LanguageModel): AgentBuilder;
3749
3926
  /**
3750
3927
  * Set the model for the agent
3751
3928
  * @param model The model identifier (e.g., "gemini-2.5-flash")
3752
3929
  * @returns This builder instance for chaining
3753
3930
  */
3754
- withModel(model: string): this;
3931
+ withModel(model: string | BaseLlm | LanguageModel): this;
3755
3932
  /**
3756
3933
  * Set the description for the agent
3757
3934
  * @param description Agent description
@@ -3855,9 +4032,9 @@ type index$4_LangGraphAgent = LangGraphAgent;
3855
4032
  declare const index$4_LangGraphAgent: typeof LangGraphAgent;
3856
4033
  type index$4_LangGraphAgentConfig = LangGraphAgentConfig;
3857
4034
  type index$4_LangGraphNode = LangGraphNode;
3858
- type index$4_LlmAgent = LlmAgent;
4035
+ type index$4_LlmAgent<T extends BaseLlm = BaseLlm> = LlmAgent<T>;
3859
4036
  declare const index$4_LlmAgent: typeof LlmAgent;
3860
- type index$4_LlmAgentConfig = LlmAgentConfig;
4037
+ type index$4_LlmAgentConfig<T extends BaseLlm = BaseLlm> = LlmAgentConfig<T>;
3861
4038
  type index$4_LlmCallsLimitExceededError = LlmCallsLimitExceededError;
3862
4039
  declare const index$4_LlmCallsLimitExceededError: typeof LlmCallsLimitExceededError;
3863
4040
  type index$4_LoopAgent = LoopAgent;
@@ -4253,7 +4430,7 @@ declare namespace index$1 {
4253
4430
  declare abstract class BaseLlmFlow {
4254
4431
  requestProcessors: Array<any>;
4255
4432
  responseProcessors: Array<any>;
4256
- private logger;
4433
+ protected logger: Logger;
4257
4434
  runAsync(invocationContext: InvocationContext): AsyncGenerator<Event>;
4258
4435
  runLive(invocationContext: InvocationContext): AsyncGenerator<Event>;
4259
4436
  _runOneStepAsync(invocationContext: InvocationContext): AsyncGenerator<Event>;
@@ -4267,6 +4444,15 @@ declare abstract class BaseLlmFlow {
4267
4444
  _handleBeforeModelCallback(invocationContext: InvocationContext, llmRequest: LlmRequest, modelResponseEvent: Event): Promise<LlmResponse | undefined>;
4268
4445
  _handleAfterModelCallback(invocationContext: InvocationContext, llmResponse: LlmResponse, modelResponseEvent: Event): Promise<LlmResponse | undefined>;
4269
4446
  _finalizeModelResponseEvent(llmRequest: LlmRequest, llmResponse: LlmResponse, modelResponseEvent: Event): Event;
4447
+ /**
4448
+ * Logs data in a visually appealing format that works well in any terminal size.
4449
+ * Uses vertical layout for better readability and respects debug settings.
4450
+ */
4451
+ _formatContentPreview(content: any): string;
4452
+ /**
4453
+ * Formats response content preview for debug logging
4454
+ */
4455
+ _formatResponsePreview(llmResponse: LlmResponse): string;
4270
4456
  __getLlm(invocationContext: InvocationContext): BaseLlm;
4271
4457
  }
4272
4458
 
@@ -4405,39 +4591,83 @@ declare const requestProcessor$1: NlPlanningRequestProcessor;
4405
4591
  */
4406
4592
  declare const responseProcessor$1: NlPlanningResponseProcessor;
4407
4593
 
4594
+ /**
4595
+ * The persistent context used to configure the code executor.
4596
+ */
4597
+ declare class CodeExecutorContext {
4598
+ private readonly context;
4599
+ private readonly sessionState;
4600
+ constructor(sessionState: State);
4601
+ /**
4602
+ * Gets the state delta to update in the persistent session state.
4603
+ */
4604
+ getStateDelta(): Record<string, any>;
4605
+ /**
4606
+ * Gets the session ID for the code executor.
4607
+ */
4608
+ getExecutionId(): string | null;
4609
+ /**
4610
+ * Sets the session ID for the code executor.
4611
+ */
4612
+ setExecutionId(sessionId: string): void;
4613
+ /**
4614
+ * Gets the processed file names from the session state.
4615
+ */
4616
+ getProcessedFileNames(): string[];
4617
+ /**
4618
+ * Adds the processed file names to the session state.
4619
+ */
4620
+ addProcessedFileNames(fileNames: string[]): void;
4621
+ /**
4622
+ * Gets the code executor input files from the session state.
4623
+ */
4624
+ getInputFiles(): File[];
4625
+ /**
4626
+ * Adds the input files to the code executor context.
4627
+ */
4628
+ addInputFiles(inputFiles: File[]): void;
4629
+ /**
4630
+ * Removes the input files and processed file names from the code executor context.
4631
+ */
4632
+ clearInputFiles(): void;
4633
+ /**
4634
+ * Gets the error count from the session state.
4635
+ */
4636
+ getErrorCount(invocationId: string): number;
4637
+ /**
4638
+ * Increments the error count for the given invocation ID.
4639
+ */
4640
+ incrementErrorCount(invocationId: string): void;
4641
+ /**
4642
+ * Resets the error count for the given invocation ID.
4643
+ */
4644
+ resetErrorCount(invocationId: string): void;
4645
+ /**
4646
+ * Updates the code execution result.
4647
+ */
4648
+ updateCodeExecutionResult(invocationId: string, code: string, resultStdout: string, resultStderr: string): void;
4649
+ /**
4650
+ * Gets the code executor context from the session state.
4651
+ */
4652
+ private getCodeExecutorContext;
4653
+ }
4654
+
4408
4655
  /**
4409
4656
  * Request processor for code execution
4410
- * This is a placeholder implementation that will be enhanced when code-executors are ready
4411
4657
  */
4412
4658
  declare class CodeExecutionRequestProcessor extends BaseLlmRequestProcessor {
4413
4659
  runAsync(invocationContext: InvocationContext, llmRequest: LlmRequest): AsyncGenerator<Event>;
4414
- /**
4415
- * Placeholder for pre-processor logic
4416
- * TODO: Implement when code-executors are ready
4417
- */
4418
- private runPreProcessor;
4419
4660
  }
4420
4661
  /**
4421
4662
  * Response processor for code execution
4422
- * This is a placeholder implementation that will be enhanced when code-executors are ready
4423
4663
  */
4424
4664
  declare class CodeExecutionResponseProcessor extends BaseLlmResponseProcessor {
4425
4665
  runAsync(invocationContext: InvocationContext, llmResponse: LlmResponse): AsyncGenerator<Event>;
4426
- /**
4427
- * Placeholder for post-processor logic
4428
- * TODO: Implement when code-executors are ready
4429
- */
4430
- private runPostProcessor;
4431
4666
  }
4432
4667
  /**
4433
- * Exported request processor instance for use in flow configurations
4434
- * Ready to be connected when code-executors module is implemented
4668
+ * Exported processor instances
4435
4669
  */
4436
4670
  declare const requestProcessor: CodeExecutionRequestProcessor;
4437
- /**
4438
- * Exported response processor instance for use in flow configurations
4439
- * Ready to be connected when code-executors module is implemented
4440
- */
4441
4671
  declare const responseProcessor: CodeExecutionResponseProcessor;
4442
4672
 
4443
4673
  declare const AF_FUNCTION_CALL_ID_PREFIX = "adk-";
@@ -4530,6 +4760,21 @@ declare namespace index {
4530
4760
  */
4531
4761
  declare function injectSessionState(template: string, readonlyContext: ReadonlyContext): Promise<string>;
4532
4762
 
4763
+ /**
4764
+ * A code executor that uses the Model's built-in code executor.
4765
+ *
4766
+ * Currently only supports Gemini 2.0+ models, but will be expanded to
4767
+ * other models.
4768
+ */
4769
+ declare class BuiltInCodeExecutor extends BaseCodeExecutor {
4770
+ constructor(config?: BaseCodeExecutorConfig);
4771
+ executeCode(invocationContext: InvocationContext, codeExecutionInput: CodeExecutionInput): Promise<CodeExecutionResult>;
4772
+ /**
4773
+ * Pre-process the LLM request for Gemini 2.0+ models to use the code execution tool
4774
+ */
4775
+ processLlmRequest(llmRequest: LlmRequest): void;
4776
+ }
4777
+
4533
4778
  /**
4534
4779
  * The built-in planner that uses model's built-in thinking features.
4535
4780
  */
@@ -4668,4 +4913,4 @@ declare const traceLlmCall: (invocationContext: InvocationContext, eventId: stri
4668
4913
 
4669
4914
  declare const VERSION = "0.1.0";
4670
4915
 
4671
- export { AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentType, index$4 as Agents, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BaseSessionService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInPlanner, CallbackContext, DatabaseSessionService, EnhancedAuthConfig, Event, EventActions, index$1 as Events, ExitLoopTool, FileOperationsTool, index as Flows, 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, type McpConfig, 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, 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, adkToMcpToolType, requestProcessor$2 as agentTransferRequestProcessor, requestProcessor$6 as basicRequestProcessor, buildFunctionDeclaration, requestProcessor as codeExecutionRequestProcessor, responseProcessor as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, createAuthToolArguments, 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, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor$1 as nlPlanningRequestProcessor, responseProcessor$1 as nlPlanningResponseProcessor, normalizeJsonSchema, populateClientFunctionCallId, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, shutdownTelemetry, telemetryService, traceLlmCall, traceToolCall, tracer };
4916
+ 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, Event, EventActions, index$1 as Events, ExitLoopTool, type File, FileOperationsTool, index as Flows, 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, type McpConfig, 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, 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, adkToMcpToolType, requestProcessor$2 as agentTransferRequestProcessor, requestProcessor$6 as basicRequestProcessor, buildFunctionDeclaration, requestProcessor as codeExecutionRequestProcessor, responseProcessor as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, createAuthToolArguments, 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, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor$1 as nlPlanningRequestProcessor, responseProcessor$1 as nlPlanningResponseProcessor, normalizeJsonSchema, populateClientFunctionCallId, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, shutdownTelemetry, telemetryService, traceLlmCall, traceToolCall, tracer };