@iqai/adk 0.1.13 → 0.1.15
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 +21 -0
- package/dist/index.d.mts +1570 -1477
- package/dist/index.d.ts +1570 -1477
- package/dist/index.js +707 -454
- package/dist/index.mjs +548 -295
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Part, Content
|
|
2
|
-
export { Blob, Content } from '@google/genai';
|
|
1
|
+
import { Part, Content, Blob, SpeechConfig, AudioTranscriptionConfig, RealtimeInputConfig, ProactivityConfig, FunctionDeclaration, GroundingMetadata, GenerateContentResponseUsageMetadata, GenerateContentConfig, Schema, LiveConnectConfig, GoogleGenAI, FunctionCall } from '@google/genai';
|
|
2
|
+
export { Blob, Content, FunctionDeclaration, Schema as JSONSchema } from '@google/genai';
|
|
3
3
|
import { LanguageModel } from 'ai';
|
|
4
4
|
import * as z from 'zod/v4';
|
|
5
5
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
@@ -32,41 +32,6 @@ declare class Logger {
|
|
|
32
32
|
debugArray(title: string, items: Array<Record<string, any>>): void;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* JSON Schema type for function parameters
|
|
37
|
-
*/
|
|
38
|
-
interface JSONSchema {
|
|
39
|
-
type: string;
|
|
40
|
-
properties?: Record<string, JSONSchema>;
|
|
41
|
-
items?: JSONSchema;
|
|
42
|
-
required?: string[];
|
|
43
|
-
enum?: string[];
|
|
44
|
-
description?: string;
|
|
45
|
-
format?: string;
|
|
46
|
-
pattern?: string;
|
|
47
|
-
minimum?: number;
|
|
48
|
-
maximum?: number;
|
|
49
|
-
default?: any;
|
|
50
|
-
[key: string]: any;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Represents a function declaration for the LLM
|
|
54
|
-
*/
|
|
55
|
-
interface FunctionDeclaration {
|
|
56
|
-
/**
|
|
57
|
-
* Name of the function
|
|
58
|
-
*/
|
|
59
|
-
name: string;
|
|
60
|
-
/**
|
|
61
|
-
* Description of what the function does
|
|
62
|
-
*/
|
|
63
|
-
description: string;
|
|
64
|
-
/**
|
|
65
|
-
* Parameters schema in JSON Schema format
|
|
66
|
-
*/
|
|
67
|
-
parameters: JSONSchema;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
35
|
/**
|
|
71
36
|
* Represents the actions attached to an event.
|
|
72
37
|
*/
|
|
@@ -206,7 +171,7 @@ interface MemoryEntry {
|
|
|
206
171
|
/**
|
|
207
172
|
* The main content of the memory
|
|
208
173
|
*/
|
|
209
|
-
content: Content
|
|
174
|
+
content: Content;
|
|
210
175
|
/**
|
|
211
176
|
* The author of the memory
|
|
212
177
|
*/
|
|
@@ -366,7 +331,7 @@ declare class LiveRequest {
|
|
|
366
331
|
/**
|
|
367
332
|
* If set, send the content to the model in turn-by-turn mode.
|
|
368
333
|
*/
|
|
369
|
-
content?: Content
|
|
334
|
+
content?: Content;
|
|
370
335
|
/**
|
|
371
336
|
* If set, send the blob to the model in realtime mode.
|
|
372
337
|
*/
|
|
@@ -376,7 +341,7 @@ declare class LiveRequest {
|
|
|
376
341
|
*/
|
|
377
342
|
close: boolean;
|
|
378
343
|
constructor(options?: {
|
|
379
|
-
content?: Content
|
|
344
|
+
content?: Content;
|
|
380
345
|
blob?: Blob;
|
|
381
346
|
close?: boolean;
|
|
382
347
|
});
|
|
@@ -395,7 +360,7 @@ declare class LiveRequestQueue {
|
|
|
395
360
|
/**
|
|
396
361
|
* Send content to the queue.
|
|
397
362
|
*/
|
|
398
|
-
sendContent(content: Content
|
|
363
|
+
sendContent(content: Content): void;
|
|
399
364
|
/**
|
|
400
365
|
* Send realtime blob to the queue.
|
|
401
366
|
*/
|
|
@@ -514,10 +479,10 @@ declare class TranscriptionEntry {
|
|
|
514
479
|
/**
|
|
515
480
|
* The data that can be used for transcription
|
|
516
481
|
*/
|
|
517
|
-
data: Blob | Content
|
|
482
|
+
data: Blob | Content;
|
|
518
483
|
constructor(options: {
|
|
519
484
|
role?: string;
|
|
520
|
-
data: Blob | Content
|
|
485
|
+
data: Blob | Content;
|
|
521
486
|
});
|
|
522
487
|
}
|
|
523
488
|
|
|
@@ -596,7 +561,7 @@ declare class InvocationContext {
|
|
|
596
561
|
/**
|
|
597
562
|
* The user content that started this invocation. Readonly.
|
|
598
563
|
*/
|
|
599
|
-
readonly userContent?: Content
|
|
564
|
+
readonly userContent?: Content;
|
|
600
565
|
/**
|
|
601
566
|
* The current session of this invocation context. Readonly.
|
|
602
567
|
*/
|
|
@@ -638,7 +603,7 @@ declare class InvocationContext {
|
|
|
638
603
|
invocationId?: string;
|
|
639
604
|
branch?: string;
|
|
640
605
|
agent: BaseAgent;
|
|
641
|
-
userContent?: Content
|
|
606
|
+
userContent?: Content;
|
|
642
607
|
session: Session;
|
|
643
608
|
endInvocation?: boolean;
|
|
644
609
|
liveRequestQueue?: LiveRequestQueue;
|
|
@@ -675,7 +640,7 @@ declare class ReadonlyContext {
|
|
|
675
640
|
/**
|
|
676
641
|
* The user content that started this invocation. READONLY field.
|
|
677
642
|
*/
|
|
678
|
-
get userContent(): Content
|
|
643
|
+
get userContent(): Content | undefined;
|
|
679
644
|
/**
|
|
680
645
|
* The current invocation id.
|
|
681
646
|
*/
|
|
@@ -793,17 +758,6 @@ interface ToolConfig {
|
|
|
793
758
|
*/
|
|
794
759
|
maxRetryAttempts?: number;
|
|
795
760
|
}
|
|
796
|
-
/**
|
|
797
|
-
* LLM request interface for processing outgoing requests
|
|
798
|
-
*/
|
|
799
|
-
interface LlmRequest$1 {
|
|
800
|
-
toolsDict: Record<string, BaseTool>;
|
|
801
|
-
config?: {
|
|
802
|
-
tools?: Array<{
|
|
803
|
-
functionDeclarations?: FunctionDeclaration[];
|
|
804
|
-
}>;
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
761
|
/**
|
|
808
762
|
* API variant types
|
|
809
763
|
*/
|
|
@@ -886,7 +840,7 @@ declare abstract class BaseTool {
|
|
|
886
840
|
* @param toolContext The context of the tool
|
|
887
841
|
* @param llmRequest The outgoing LLM request, mutable by this method
|
|
888
842
|
*/
|
|
889
|
-
processLlmRequest(_toolContext: ToolContext, llmRequest: LlmRequest
|
|
843
|
+
processLlmRequest(_toolContext: ToolContext, llmRequest: LlmRequest): Promise<void>;
|
|
890
844
|
/**
|
|
891
845
|
* Gets the API variant for this tool
|
|
892
846
|
*/
|
|
@@ -1009,391 +963,1016 @@ interface CreateToolConfigWithoutSchema {
|
|
|
1009
963
|
declare function createTool<T extends Record<string, any>>(config: CreateToolConfigWithSchema<T>): BaseTool;
|
|
1010
964
|
declare function createTool(config: CreateToolConfigWithoutSchema): BaseTool;
|
|
1011
965
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
*/
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
966
|
+
interface File {
|
|
967
|
+
/** The name of the file with file extension (e.g., "file.csv") */
|
|
968
|
+
name: string;
|
|
969
|
+
/** The base64-encoded bytes of the file content */
|
|
970
|
+
content: string;
|
|
971
|
+
/** The mime type of the file (e.g., "image/png") */
|
|
972
|
+
mimeType: string;
|
|
973
|
+
}
|
|
974
|
+
interface CodeExecutionInput {
|
|
975
|
+
/** The code to execute */
|
|
976
|
+
code: string;
|
|
977
|
+
/** The input files available to the code */
|
|
978
|
+
inputFiles: File[];
|
|
979
|
+
/** The execution ID for the stateful code execution */
|
|
980
|
+
executionId?: string;
|
|
981
|
+
}
|
|
982
|
+
interface CodeExecutionResult {
|
|
983
|
+
/** The standard output of the code execution */
|
|
984
|
+
stdout: string;
|
|
985
|
+
/** The standard error of the code execution */
|
|
986
|
+
stderr: string;
|
|
987
|
+
/** The output files from the code execution */
|
|
988
|
+
outputFiles: File[];
|
|
989
|
+
}
|
|
990
|
+
declare class CodeExecutionUtils {
|
|
1022
991
|
/**
|
|
1023
|
-
*
|
|
1024
|
-
*
|
|
1025
|
-
* @param func The function to wrap
|
|
1026
|
-
* @param options Optional configuration for the tool
|
|
992
|
+
* Gets the file content as a base64-encoded string
|
|
1027
993
|
*/
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
description?: string;
|
|
1031
|
-
isLongRunning?: boolean;
|
|
1032
|
-
shouldRetryOnFailure?: boolean;
|
|
1033
|
-
maxRetryAttempts?: number;
|
|
1034
|
-
parameterTypes?: Record<string, string>;
|
|
1035
|
-
});
|
|
994
|
+
static getEncodedFileContent(data: string | ArrayBuffer): string;
|
|
995
|
+
private static isBase64Encoded;
|
|
1036
996
|
/**
|
|
1037
|
-
*
|
|
997
|
+
* Extracts the first code block from the content and truncates everything after it
|
|
1038
998
|
*/
|
|
1039
|
-
|
|
999
|
+
static extractCodeAndTruncateContent(content: Content, codeBlockDelimiters: Array<[string, string]>): string | null;
|
|
1000
|
+
private static escapeRegex;
|
|
1040
1001
|
/**
|
|
1041
|
-
*
|
|
1002
|
+
* Builds an executable code part with code string
|
|
1042
1003
|
*/
|
|
1043
|
-
|
|
1004
|
+
static buildExecutableCodePart(code: string): Part;
|
|
1044
1005
|
/**
|
|
1045
|
-
*
|
|
1006
|
+
* Builds the code execution result part from the code execution result
|
|
1046
1007
|
*/
|
|
1047
|
-
|
|
1008
|
+
static buildCodeExecutionResultPart(codeExecutionResult: CodeExecutionResult): Part;
|
|
1048
1009
|
/**
|
|
1049
|
-
*
|
|
1010
|
+
* Converts the code execution parts to text parts in a Content
|
|
1050
1011
|
*/
|
|
1051
|
-
|
|
1012
|
+
static convertCodeExecutionParts(content: Content, codeBlockDelimiter: [string, string], executionResultDelimiters: [string, string]): void;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
interface BaseCodeExecutorConfig {
|
|
1052
1016
|
/**
|
|
1053
|
-
*
|
|
1054
|
-
*
|
|
1055
|
-
*
|
|
1017
|
+
* If true, extract and process data files from the model request
|
|
1018
|
+
* and attach them to the code executor.
|
|
1019
|
+
* Supported data file MimeTypes are [text/csv].
|
|
1020
|
+
* Default to false.
|
|
1056
1021
|
*/
|
|
1057
|
-
|
|
1022
|
+
optimizeDataFile?: boolean;
|
|
1058
1023
|
/**
|
|
1059
|
-
*
|
|
1024
|
+
* Whether the code executor is stateful. Default to false.
|
|
1060
1025
|
*/
|
|
1061
|
-
|
|
1026
|
+
stateful?: boolean;
|
|
1062
1027
|
/**
|
|
1063
|
-
*
|
|
1028
|
+
* The number of attempts to retry on consecutive code execution errors.
|
|
1029
|
+
* Default to 2.
|
|
1064
1030
|
*/
|
|
1065
|
-
|
|
1031
|
+
errorRetryAttempts?: number;
|
|
1066
1032
|
/**
|
|
1067
|
-
*
|
|
1033
|
+
* The list of the enclosing delimiters to identify the code blocks.
|
|
1034
|
+
* For example, the delimiter ['```python\n', '\n```'] can be
|
|
1035
|
+
* used to identify code blocks with the following format:
|
|
1036
|
+
*
|
|
1037
|
+
* ```python
|
|
1038
|
+
* print("hello")
|
|
1039
|
+
* ```
|
|
1068
1040
|
*/
|
|
1069
|
-
|
|
1041
|
+
codeBlockDelimiters?: Array<[string, string]>;
|
|
1070
1042
|
/**
|
|
1071
|
-
*
|
|
1043
|
+
* The delimiters to format the code execution result.
|
|
1072
1044
|
*/
|
|
1073
|
-
|
|
1045
|
+
executionResultDelimiters?: [string, string];
|
|
1046
|
+
}
|
|
1047
|
+
declare abstract class BaseCodeExecutor {
|
|
1048
|
+
protected readonly config: Required<BaseCodeExecutorConfig>;
|
|
1049
|
+
constructor(config?: BaseCodeExecutorConfig);
|
|
1050
|
+
/**
|
|
1051
|
+
* Executes code and returns the code execution result.
|
|
1052
|
+
*/
|
|
1053
|
+
abstract executeCode(invocationContext: InvocationContext, codeExecutionInput: CodeExecutionInput): Promise<CodeExecutionResult>;
|
|
1054
|
+
get optimizeDataFile(): boolean;
|
|
1055
|
+
get stateful(): boolean;
|
|
1056
|
+
get errorRetryAttempts(): number;
|
|
1057
|
+
get codeBlockDelimiters(): Array<[string, string]>;
|
|
1058
|
+
get executionResultDelimiters(): [string, string];
|
|
1074
1059
|
}
|
|
1075
1060
|
|
|
1076
1061
|
/**
|
|
1077
|
-
*
|
|
1062
|
+
* Candidate response from the model.
|
|
1078
1063
|
*/
|
|
1079
|
-
interface
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1064
|
+
interface Candidate {
|
|
1065
|
+
content?: Content;
|
|
1066
|
+
groundingMetadata?: GroundingMetadata;
|
|
1067
|
+
finishReason?: string;
|
|
1068
|
+
finishMessage?: string;
|
|
1083
1069
|
}
|
|
1084
1070
|
/**
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
* This utility analyzes the function signature and JSDoc comments to create
|
|
1088
|
-
* a FunctionDeclaration object that can be used with LLMs.
|
|
1089
|
-
*
|
|
1090
|
-
* @param func The function to analyze
|
|
1091
|
-
* @param options Options for customizing the declaration
|
|
1092
|
-
* @returns A FunctionDeclaration representing the function
|
|
1071
|
+
* Prompt feedback in case of blocked or failed prompt.
|
|
1093
1072
|
*/
|
|
1094
|
-
|
|
1095
|
-
|
|
1073
|
+
interface PromptFeedback {
|
|
1074
|
+
blockReason?: string;
|
|
1075
|
+
blockReasonMessage?: string;
|
|
1076
|
+
}
|
|
1096
1077
|
/**
|
|
1097
|
-
*
|
|
1098
|
-
* This is a convenience function for creating a new FunctionTool.
|
|
1099
|
-
*
|
|
1100
|
-
* @param func The function to wrap
|
|
1101
|
-
* @param options Optional configuration for the tool
|
|
1102
|
-
* @returns A new FunctionTool wrapping the function
|
|
1078
|
+
* The response from the model generation API.
|
|
1103
1079
|
*/
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
maxRetryAttempts?: number;
|
|
1110
|
-
}): any;
|
|
1111
|
-
|
|
1080
|
+
interface GenerateContentResponse {
|
|
1081
|
+
candidates?: Candidate[];
|
|
1082
|
+
usageMetadata?: GenerateContentResponseUsageMetadata;
|
|
1083
|
+
promptFeedback?: PromptFeedback;
|
|
1084
|
+
}
|
|
1112
1085
|
/**
|
|
1113
|
-
*
|
|
1086
|
+
* Response from a language model.
|
|
1114
1087
|
*/
|
|
1115
|
-
declare class
|
|
1116
|
-
protected logger: Logger;
|
|
1088
|
+
declare class LlmResponse {
|
|
1117
1089
|
/**
|
|
1118
|
-
*
|
|
1090
|
+
* Unique identifier for the response.
|
|
1119
1091
|
*/
|
|
1120
|
-
|
|
1092
|
+
id?: string;
|
|
1121
1093
|
/**
|
|
1122
|
-
*
|
|
1094
|
+
* The content generated by the model.
|
|
1123
1095
|
*/
|
|
1124
|
-
|
|
1096
|
+
content?: Content;
|
|
1125
1097
|
/**
|
|
1126
|
-
*
|
|
1127
|
-
* This is a simplified implementation that doesn't actually search, just returns mock results
|
|
1098
|
+
* The grounding metadata of the response.
|
|
1128
1099
|
*/
|
|
1129
|
-
|
|
1130
|
-
query: string;
|
|
1131
|
-
num_results?: number;
|
|
1132
|
-
}, _context: ToolContext): Promise<any>;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
interface HttpRequestResult {
|
|
1136
|
-
statusCode: number;
|
|
1137
|
-
headers: Record<string, string>;
|
|
1138
|
-
body: string;
|
|
1139
|
-
error?: string;
|
|
1140
|
-
}
|
|
1141
|
-
/**
|
|
1142
|
-
* Tool for making HTTP requests to external APIs and web services
|
|
1143
|
-
*/
|
|
1144
|
-
declare class HttpRequestTool extends BaseTool {
|
|
1145
|
-
constructor();
|
|
1100
|
+
groundingMetadata?: GroundingMetadata;
|
|
1146
1101
|
/**
|
|
1147
|
-
*
|
|
1102
|
+
* Indicates whether the text content is part of an unfinished text stream.
|
|
1148
1103
|
*/
|
|
1149
|
-
|
|
1104
|
+
partial?: boolean;
|
|
1150
1105
|
/**
|
|
1151
|
-
*
|
|
1106
|
+
* Indicates whether the response from the model is complete.
|
|
1152
1107
|
*/
|
|
1153
|
-
|
|
1154
|
-
url: string;
|
|
1155
|
-
method?: string;
|
|
1156
|
-
headers?: Record<string, string>;
|
|
1157
|
-
body?: string;
|
|
1158
|
-
params?: Record<string, string>;
|
|
1159
|
-
timeout?: number;
|
|
1160
|
-
}, _context: ToolContext): Promise<HttpRequestResult>;
|
|
1108
|
+
turnComplete?: boolean;
|
|
1161
1109
|
/**
|
|
1162
|
-
*
|
|
1110
|
+
* Error code if the response is an error.
|
|
1163
1111
|
*/
|
|
1164
|
-
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
interface FileOperationResult {
|
|
1168
|
-
success: boolean;
|
|
1169
|
-
data?: any;
|
|
1170
|
-
error?: string;
|
|
1171
|
-
}
|
|
1172
|
-
/**
|
|
1173
|
-
* Tool for performing file system operations
|
|
1174
|
-
*/
|
|
1175
|
-
declare class FileOperationsTool extends BaseTool {
|
|
1176
|
-
private basePath;
|
|
1177
|
-
constructor(options?: {
|
|
1178
|
-
basePath?: string;
|
|
1179
|
-
});
|
|
1112
|
+
errorCode?: string;
|
|
1180
1113
|
/**
|
|
1181
|
-
*
|
|
1114
|
+
* Error message if the response is an error.
|
|
1182
1115
|
*/
|
|
1183
|
-
|
|
1116
|
+
errorMessage?: string;
|
|
1184
1117
|
/**
|
|
1185
|
-
*
|
|
1118
|
+
* Flag indicating that LLM was interrupted when generating the content.
|
|
1186
1119
|
*/
|
|
1187
|
-
|
|
1188
|
-
operation: "read" | "write" | "append" | "delete" | "exists" | "list" | "mkdir";
|
|
1189
|
-
filepath: string;
|
|
1190
|
-
content?: string;
|
|
1191
|
-
encoding?: BufferEncoding;
|
|
1192
|
-
}, _context: ToolContext): Promise<FileOperationResult>;
|
|
1193
|
-
/**
|
|
1194
|
-
* Resolve a file path relative to the base path
|
|
1195
|
-
*/
|
|
1196
|
-
private resolvePath;
|
|
1120
|
+
interrupted?: boolean;
|
|
1197
1121
|
/**
|
|
1198
|
-
*
|
|
1122
|
+
* The custom metadata of the LlmResponse.
|
|
1199
1123
|
*/
|
|
1200
|
-
|
|
1124
|
+
customMetadata?: Record<string, any>;
|
|
1201
1125
|
/**
|
|
1202
|
-
*
|
|
1126
|
+
* The usage metadata of the LlmResponse.
|
|
1203
1127
|
*/
|
|
1204
|
-
|
|
1128
|
+
usageMetadata?: GenerateContentResponseUsageMetadata;
|
|
1205
1129
|
/**
|
|
1206
|
-
*
|
|
1130
|
+
* Index of the candidate response.
|
|
1207
1131
|
*/
|
|
1208
|
-
|
|
1132
|
+
candidateIndex?: number;
|
|
1209
1133
|
/**
|
|
1210
|
-
*
|
|
1134
|
+
* Reason why the model finished generating.
|
|
1211
1135
|
*/
|
|
1212
|
-
|
|
1136
|
+
finishReason?: string;
|
|
1213
1137
|
/**
|
|
1214
|
-
*
|
|
1138
|
+
* Error object if the response is an error.
|
|
1215
1139
|
*/
|
|
1216
|
-
|
|
1140
|
+
error?: Error;
|
|
1217
1141
|
/**
|
|
1218
|
-
*
|
|
1142
|
+
* Creates a new LlmResponse.
|
|
1219
1143
|
*/
|
|
1220
|
-
|
|
1144
|
+
constructor(data?: Partial<LlmResponse>);
|
|
1221
1145
|
/**
|
|
1222
|
-
*
|
|
1146
|
+
* Creates an LlmResponse from a GenerateContentResponse.
|
|
1147
|
+
*
|
|
1148
|
+
* @param generateContentResponse The GenerateContentResponse to create the LlmResponse from.
|
|
1149
|
+
* @returns The LlmResponse.
|
|
1223
1150
|
*/
|
|
1224
|
-
|
|
1151
|
+
static create(generateContentResponse: GenerateContentResponse): LlmResponse;
|
|
1225
1152
|
/**
|
|
1226
|
-
*
|
|
1153
|
+
* Creates an LlmResponse from an error.
|
|
1154
|
+
*
|
|
1155
|
+
* @param error The error object or message.
|
|
1156
|
+
* @param options Additional options for the error response.
|
|
1157
|
+
* @param options.errorCode A specific error code for the response.
|
|
1158
|
+
* @param options.model The model that was being used when the error occurred.
|
|
1159
|
+
* @returns The LlmResponse.
|
|
1227
1160
|
*/
|
|
1228
|
-
|
|
1161
|
+
static fromError(error: unknown, options?: {
|
|
1162
|
+
errorCode?: string;
|
|
1163
|
+
model?: string;
|
|
1164
|
+
}): LlmResponse;
|
|
1229
1165
|
}
|
|
1230
1166
|
|
|
1231
|
-
interface UserInteractionResult {
|
|
1232
|
-
success: boolean;
|
|
1233
|
-
userInput?: string;
|
|
1234
|
-
error?: string;
|
|
1235
|
-
}
|
|
1236
1167
|
/**
|
|
1237
|
-
*
|
|
1168
|
+
* The base class for a live model connection.
|
|
1238
1169
|
*/
|
|
1239
|
-
declare class
|
|
1240
|
-
constructor();
|
|
1170
|
+
declare abstract class BaseLLMConnection {
|
|
1241
1171
|
/**
|
|
1242
|
-
*
|
|
1172
|
+
* Sends the conversation history to the model.
|
|
1173
|
+
*
|
|
1174
|
+
* You call this method right after setting up the model connection.
|
|
1175
|
+
* The model will respond if the last content is from user, otherwise it will
|
|
1176
|
+
* wait for new user input before responding.
|
|
1177
|
+
*
|
|
1178
|
+
* @param history The conversation history to send to the model.
|
|
1243
1179
|
*/
|
|
1244
|
-
|
|
1180
|
+
abstract sendHistory(history: Content[]): Promise<void>;
|
|
1245
1181
|
/**
|
|
1246
|
-
*
|
|
1182
|
+
* Sends a user content to the model.
|
|
1183
|
+
*
|
|
1184
|
+
* The model will respond immediately upon receiving the content.
|
|
1185
|
+
* If you send function responses, all parts in the content should be function
|
|
1186
|
+
* responses.
|
|
1187
|
+
*
|
|
1188
|
+
* @param content The content to send to the model.
|
|
1247
1189
|
*/
|
|
1248
|
-
|
|
1249
|
-
prompt: string;
|
|
1250
|
-
options?: string[];
|
|
1251
|
-
defaultValue?: string;
|
|
1252
|
-
}, context: ToolContext): Promise<UserInteractionResult>;
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
/**
|
|
1256
|
-
* Tool that allows an agent to exit the current execution loop
|
|
1257
|
-
*/
|
|
1258
|
-
declare class ExitLoopTool extends BaseTool {
|
|
1259
|
-
protected logger: Logger;
|
|
1190
|
+
abstract sendContent(content: Content): Promise<void>;
|
|
1260
1191
|
/**
|
|
1261
|
-
*
|
|
1192
|
+
* Sends a chunk of audio or a frame of video to the model in realtime.
|
|
1193
|
+
*
|
|
1194
|
+
* The model may not respond immediately upon receiving the blob. It will do
|
|
1195
|
+
* voice activity detection and decide when to respond.
|
|
1196
|
+
*
|
|
1197
|
+
* @param blob The blob to send to the model.
|
|
1262
1198
|
*/
|
|
1263
|
-
|
|
1199
|
+
abstract sendRealtime(blob: Blob): Promise<void>;
|
|
1264
1200
|
/**
|
|
1265
|
-
*
|
|
1201
|
+
* Receives the model response using the llm server connection.
|
|
1202
|
+
*
|
|
1203
|
+
* @returns LlmResponse: The model response.
|
|
1266
1204
|
*/
|
|
1267
|
-
|
|
1205
|
+
abstract receive(): AsyncGenerator<LlmResponse, void, unknown>;
|
|
1206
|
+
/**
|
|
1207
|
+
* Closes the llm server connection.
|
|
1208
|
+
*/
|
|
1209
|
+
abstract close(): Promise<void>;
|
|
1268
1210
|
}
|
|
1269
1211
|
|
|
1270
1212
|
/**
|
|
1271
|
-
*
|
|
1213
|
+
* The BaseLlm class.
|
|
1272
1214
|
*/
|
|
1273
|
-
declare class
|
|
1215
|
+
declare abstract class BaseLlm {
|
|
1216
|
+
/**
|
|
1217
|
+
* The name of the LLM, e.g. gemini-1.5-flash or gemini-1.5-flash-001.
|
|
1218
|
+
*/
|
|
1219
|
+
model: string;
|
|
1274
1220
|
protected logger: Logger;
|
|
1275
1221
|
/**
|
|
1276
|
-
* Constructor for
|
|
1222
|
+
* Constructor for BaseLlm
|
|
1277
1223
|
*/
|
|
1278
|
-
constructor();
|
|
1224
|
+
constructor(model: string);
|
|
1279
1225
|
/**
|
|
1280
|
-
*
|
|
1226
|
+
* Returns a list of supported models in regex for LLMRegistry
|
|
1281
1227
|
*/
|
|
1282
|
-
|
|
1228
|
+
static supportedModels(): string[];
|
|
1283
1229
|
/**
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1286
|
-
*
|
|
1230
|
+
* Generates one content from the given contents and tools.
|
|
1231
|
+
*
|
|
1232
|
+
* @param llmRequest LlmRequest, the request to send to the LLM.
|
|
1233
|
+
* @param stream bool = false, whether to do streaming call.
|
|
1234
|
+
* @returns a generator of LlmResponse.
|
|
1235
|
+
*
|
|
1236
|
+
* For non-streaming call, it will only yield one LlmResponse.
|
|
1237
|
+
*
|
|
1238
|
+
* For streaming call, it may yield more than one response, but all yielded
|
|
1239
|
+
* responses should be treated as one response by merging the
|
|
1240
|
+
* parts list.
|
|
1287
1241
|
*/
|
|
1288
|
-
|
|
1289
|
-
options: string[];
|
|
1290
|
-
question?: string;
|
|
1291
|
-
}, context: ToolContext): Promise<any>;
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
/**
|
|
1295
|
-
* Tool that allows an agent to transfer control to another agent
|
|
1296
|
-
*/
|
|
1297
|
-
declare class TransferToAgentTool extends BaseTool {
|
|
1298
|
-
protected logger: Logger;
|
|
1242
|
+
generateContentAsync(llmRequest: LlmRequest, stream?: boolean): AsyncGenerator<LlmResponse, void, unknown>;
|
|
1299
1243
|
/**
|
|
1300
|
-
*
|
|
1244
|
+
* Implementation method to be overridden by subclasses.
|
|
1245
|
+
* This replaces the abstract generateContentAsync method.
|
|
1301
1246
|
*/
|
|
1302
|
-
|
|
1247
|
+
protected abstract generateContentAsyncImpl(llmRequest: LlmRequest, stream?: boolean): AsyncGenerator<LlmResponse, void, unknown>;
|
|
1303
1248
|
/**
|
|
1304
|
-
*
|
|
1249
|
+
* Appends a user content, so that model can continue to output.
|
|
1250
|
+
*
|
|
1251
|
+
* @param llmRequest LlmRequest, the request to send to the LLM.
|
|
1305
1252
|
*/
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1253
|
+
protected maybeAppendUserContent(llmRequest: LlmRequest): void;
|
|
1254
|
+
/**
|
|
1255
|
+
* Creates a live connection to the LLM.
|
|
1256
|
+
*
|
|
1257
|
+
* @param llmRequest LlmRequest, the request to send to the LLM.
|
|
1258
|
+
* @returns BaseLLMConnection, the connection to the LLM.
|
|
1259
|
+
*/
|
|
1260
|
+
connect(llmRequest: LlmRequest): BaseLLMConnection;
|
|
1309
1261
|
}
|
|
1310
1262
|
|
|
1311
1263
|
/**
|
|
1312
|
-
*
|
|
1264
|
+
* Abstract base class for all planners.
|
|
1265
|
+
*
|
|
1266
|
+
* The planner allows the agent to generate plans for the queries to guide its action.
|
|
1313
1267
|
*/
|
|
1314
|
-
declare class
|
|
1315
|
-
protected logger: Logger;
|
|
1316
|
-
/**
|
|
1317
|
-
* Constructor for LoadMemoryTool
|
|
1318
|
-
*/
|
|
1319
|
-
constructor();
|
|
1268
|
+
declare abstract class BasePlanner {
|
|
1320
1269
|
/**
|
|
1321
|
-
*
|
|
1270
|
+
* Builds the system instruction to be appended to the LLM request for planning.
|
|
1271
|
+
*
|
|
1272
|
+
* @param readonlyContext The readonly context of the invocation
|
|
1273
|
+
* @param llmRequest The LLM request. Readonly.
|
|
1274
|
+
* @returns The planning system instruction, or undefined if no instruction is needed
|
|
1322
1275
|
*/
|
|
1323
|
-
|
|
1276
|
+
abstract buildPlanningInstruction(readonlyContext: ReadonlyContext, llmRequest: LlmRequest): string | undefined;
|
|
1324
1277
|
/**
|
|
1325
|
-
*
|
|
1278
|
+
* Processes the LLM response for planning.
|
|
1279
|
+
*
|
|
1280
|
+
* @param callbackContext The callback context of the invocation
|
|
1281
|
+
* @param responseParts The LLM response parts. Readonly.
|
|
1282
|
+
* @returns The processed response parts, or undefined if no processing is needed
|
|
1326
1283
|
*/
|
|
1327
|
-
|
|
1328
|
-
query: string;
|
|
1329
|
-
}, context: ToolContext): Promise<any>;
|
|
1284
|
+
abstract processPlanningResponse(callbackContext: CallbackContext, responseParts: Part[]): Part[] | undefined;
|
|
1330
1285
|
}
|
|
1331
1286
|
|
|
1332
1287
|
/**
|
|
1333
|
-
*
|
|
1288
|
+
* Type for instruction providers that can be functions
|
|
1334
1289
|
*/
|
|
1335
|
-
|
|
1336
|
-
role: string;
|
|
1337
|
-
parts: Part[];
|
|
1338
|
-
}
|
|
1290
|
+
type InstructionProvider = (ctx: ReadonlyContext) => string | Promise<string>;
|
|
1339
1291
|
/**
|
|
1340
|
-
*
|
|
1292
|
+
* Union type for tools (supporting functions, tools, and toolsets)
|
|
1341
1293
|
*/
|
|
1342
|
-
|
|
1343
|
-
contents?: Content[];
|
|
1344
|
-
appendInstructions?: (instructions: string[]) => void;
|
|
1345
|
-
}
|
|
1294
|
+
type ToolUnion = BaseTool | ((...args: any[]) => any);
|
|
1346
1295
|
/**
|
|
1347
|
-
*
|
|
1296
|
+
* Configuration for LlmAgent
|
|
1348
1297
|
*/
|
|
1349
|
-
|
|
1350
|
-
constructor();
|
|
1298
|
+
interface LlmAgentConfig<T extends BaseLlm = BaseLlm> {
|
|
1351
1299
|
/**
|
|
1352
|
-
*
|
|
1300
|
+
* Name of the agent
|
|
1353
1301
|
*/
|
|
1354
|
-
|
|
1302
|
+
name: string;
|
|
1355
1303
|
/**
|
|
1356
|
-
*
|
|
1304
|
+
* Description of the agent
|
|
1357
1305
|
*/
|
|
1358
|
-
|
|
1359
|
-
artifact_names?: string[];
|
|
1360
|
-
}, context: ToolContext): Promise<{
|
|
1361
|
-
artifact_names: string[];
|
|
1362
|
-
}>;
|
|
1306
|
+
description: string;
|
|
1363
1307
|
/**
|
|
1364
|
-
*
|
|
1308
|
+
* Sub-agents that this agent can delegate to
|
|
1365
1309
|
*/
|
|
1366
|
-
|
|
1310
|
+
subAgents?: BaseAgent[];
|
|
1367
1311
|
/**
|
|
1368
|
-
*
|
|
1312
|
+
* Callback or list of callbacks to be invoked before the agent run
|
|
1369
1313
|
*/
|
|
1370
|
-
|
|
1314
|
+
beforeAgentCallback?: BeforeAgentCallback;
|
|
1371
1315
|
/**
|
|
1372
|
-
*
|
|
1316
|
+
* Callback or list of callbacks to be invoked after the agent run
|
|
1373
1317
|
*/
|
|
1374
|
-
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
type McpConfig = {
|
|
1378
|
-
name: string;
|
|
1379
|
-
description: string;
|
|
1380
|
-
transport: McpTransportType;
|
|
1381
|
-
timeout?: number;
|
|
1382
|
-
retryOptions?: {
|
|
1383
|
-
maxRetries?: number;
|
|
1384
|
-
initialDelay?: number;
|
|
1385
|
-
maxDelay?: number;
|
|
1386
|
-
};
|
|
1387
|
-
headers?: Record<string, string>;
|
|
1388
|
-
cacheConfig?: {
|
|
1389
|
-
enabled?: boolean;
|
|
1390
|
-
maxAge?: number;
|
|
1391
|
-
maxSize?: number;
|
|
1392
|
-
};
|
|
1393
|
-
debug?: boolean;
|
|
1318
|
+
afterAgentCallback?: AfterAgentCallback;
|
|
1394
1319
|
/**
|
|
1395
|
-
*
|
|
1396
|
-
*
|
|
1320
|
+
* The LLM model to use
|
|
1321
|
+
* When not set, the agent will inherit the model from its ancestor
|
|
1322
|
+
*/
|
|
1323
|
+
model?: string | T | LanguageModel;
|
|
1324
|
+
/**
|
|
1325
|
+
* Instructions for the LLM model, guiding the agent's behavior
|
|
1326
|
+
*/
|
|
1327
|
+
instruction?: string | InstructionProvider;
|
|
1328
|
+
/**
|
|
1329
|
+
* Instructions for all the agents in the entire agent tree
|
|
1330
|
+
* ONLY the global_instruction in root agent will take effect
|
|
1331
|
+
*/
|
|
1332
|
+
globalInstruction?: string | InstructionProvider;
|
|
1333
|
+
/**
|
|
1334
|
+
* Tools available to this agent
|
|
1335
|
+
*/
|
|
1336
|
+
tools?: ToolUnion[];
|
|
1337
|
+
/**
|
|
1338
|
+
* Code executor for this agent
|
|
1339
|
+
*/
|
|
1340
|
+
codeExecutor?: BaseCodeExecutor;
|
|
1341
|
+
/**
|
|
1342
|
+
* Disallows LLM-controlled transferring to the parent agent
|
|
1343
|
+
*/
|
|
1344
|
+
disallowTransferToParent?: boolean;
|
|
1345
|
+
/**
|
|
1346
|
+
* Disallows LLM-controlled transferring to the peer agents
|
|
1347
|
+
*/
|
|
1348
|
+
disallowTransferToPeers?: boolean;
|
|
1349
|
+
/**
|
|
1350
|
+
* Whether to include contents in the model request
|
|
1351
|
+
*/
|
|
1352
|
+
includeContents?: "default" | "none";
|
|
1353
|
+
/**
|
|
1354
|
+
* The output key in session state to store the output of the agent
|
|
1355
|
+
*/
|
|
1356
|
+
outputKey?: string;
|
|
1357
|
+
/**
|
|
1358
|
+
* Instructs the agent to make a plan and execute it step by step
|
|
1359
|
+
*/
|
|
1360
|
+
planner?: BasePlanner;
|
|
1361
|
+
/**
|
|
1362
|
+
* Memory service for long-term storage and retrieval
|
|
1363
|
+
*/
|
|
1364
|
+
memoryService?: BaseMemoryService;
|
|
1365
|
+
/**
|
|
1366
|
+
* Session service for managing conversations
|
|
1367
|
+
*/
|
|
1368
|
+
sessionService?: BaseSessionService;
|
|
1369
|
+
/**
|
|
1370
|
+
* Artifact service for file storage and management
|
|
1371
|
+
*/
|
|
1372
|
+
artifactService?: BaseArtifactService;
|
|
1373
|
+
/**
|
|
1374
|
+
* User ID for the session
|
|
1375
|
+
*/
|
|
1376
|
+
userId?: string;
|
|
1377
|
+
/**
|
|
1378
|
+
* Application name
|
|
1379
|
+
*/
|
|
1380
|
+
appName?: string;
|
|
1381
|
+
/**
|
|
1382
|
+
* Additional content generation configurations
|
|
1383
|
+
* NOTE: not all fields are usable, e.g. tools must be configured via `tools`,
|
|
1384
|
+
* thinking_config must be configured via `planner` in LlmAgent.
|
|
1385
|
+
*/
|
|
1386
|
+
generateContentConfig?: GenerateContentConfig;
|
|
1387
|
+
/**
|
|
1388
|
+
* The input schema when agent is used as a tool
|
|
1389
|
+
*/
|
|
1390
|
+
inputSchema?: any;
|
|
1391
|
+
/**
|
|
1392
|
+
* The output schema when agent replies
|
|
1393
|
+
* NOTE: when this is set, agent can ONLY reply and CANNOT use any tools
|
|
1394
|
+
*/
|
|
1395
|
+
outputSchema?: any;
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* LLM-based Agent
|
|
1399
|
+
*/
|
|
1400
|
+
declare class LlmAgent<T extends BaseLlm = BaseLlm> extends BaseAgent {
|
|
1401
|
+
/**
|
|
1402
|
+
* The model to use for the agent
|
|
1403
|
+
* When not set, the agent will inherit the model from its ancestor
|
|
1404
|
+
*/
|
|
1405
|
+
model: string | T | LanguageModel;
|
|
1406
|
+
/**
|
|
1407
|
+
* Instructions for the LLM model, guiding the agent's behavior
|
|
1408
|
+
*/
|
|
1409
|
+
instruction: string | InstructionProvider;
|
|
1410
|
+
/**
|
|
1411
|
+
* Instructions for all the agents in the entire agent tree
|
|
1412
|
+
* ONLY the global_instruction in root agent will take effect
|
|
1413
|
+
*/
|
|
1414
|
+
globalInstruction: string | InstructionProvider;
|
|
1415
|
+
/**
|
|
1416
|
+
* Tools available to this agent
|
|
1417
|
+
*/
|
|
1418
|
+
tools: ToolUnion[];
|
|
1419
|
+
/**
|
|
1420
|
+
* Code executor for this agent
|
|
1421
|
+
*/
|
|
1422
|
+
codeExecutor?: BaseCodeExecutor;
|
|
1423
|
+
/**
|
|
1424
|
+
* Disallows LLM-controlled transferring to the parent agent
|
|
1425
|
+
*/
|
|
1426
|
+
disallowTransferToParent: boolean;
|
|
1427
|
+
/**
|
|
1428
|
+
* Disallows LLM-controlled transferring to the peer agents
|
|
1429
|
+
*/
|
|
1430
|
+
disallowTransferToPeers: boolean;
|
|
1431
|
+
/**
|
|
1432
|
+
* Whether to include contents in the model request
|
|
1433
|
+
*/
|
|
1434
|
+
includeContents: "default" | "none";
|
|
1435
|
+
/**
|
|
1436
|
+
* The output key in session state to store the output of the agent
|
|
1437
|
+
*/
|
|
1438
|
+
outputKey?: string;
|
|
1439
|
+
/**
|
|
1440
|
+
* Instructs the agent to make a plan and execute it step by step
|
|
1441
|
+
*/
|
|
1442
|
+
planner?: BasePlanner;
|
|
1443
|
+
/**
|
|
1444
|
+
* Memory service for long-term storage and retrieval
|
|
1445
|
+
*/
|
|
1446
|
+
private memoryService?;
|
|
1447
|
+
/**
|
|
1448
|
+
* Session service for managing conversations
|
|
1449
|
+
*/
|
|
1450
|
+
private sessionService?;
|
|
1451
|
+
/**
|
|
1452
|
+
* Artifact service for file storage and management
|
|
1453
|
+
*/
|
|
1454
|
+
private artifactService?;
|
|
1455
|
+
/**
|
|
1456
|
+
* User ID for the session
|
|
1457
|
+
*/
|
|
1458
|
+
private userId?;
|
|
1459
|
+
/**
|
|
1460
|
+
* Application name
|
|
1461
|
+
*/
|
|
1462
|
+
private appName?;
|
|
1463
|
+
/**
|
|
1464
|
+
* Additional content generation configurations
|
|
1465
|
+
*/
|
|
1466
|
+
generateContentConfig?: GenerateContentConfig;
|
|
1467
|
+
/**
|
|
1468
|
+
* The input schema when agent is used as a tool
|
|
1469
|
+
*/
|
|
1470
|
+
inputSchema?: any;
|
|
1471
|
+
/**
|
|
1472
|
+
* The output schema when agent replies
|
|
1473
|
+
*/
|
|
1474
|
+
outputSchema?: any;
|
|
1475
|
+
protected logger: Logger;
|
|
1476
|
+
/**
|
|
1477
|
+
* Constructor for LlmAgent
|
|
1478
|
+
*/
|
|
1479
|
+
constructor(config: LlmAgentConfig<T>);
|
|
1480
|
+
/**
|
|
1481
|
+
* The resolved model field as BaseLLM
|
|
1482
|
+
* This method is only for use by Agent Development Kit
|
|
1483
|
+
*/
|
|
1484
|
+
get canonicalModel(): BaseLlm;
|
|
1485
|
+
/**
|
|
1486
|
+
* The resolved instruction field to construct instruction for this agent
|
|
1487
|
+
* This method is only for use by Agent Development Kit
|
|
1488
|
+
*/
|
|
1489
|
+
canonicalInstruction(ctx: ReadonlyContext): Promise<[string, boolean]>;
|
|
1490
|
+
/**
|
|
1491
|
+
* The resolved global_instruction field to construct global instruction
|
|
1492
|
+
* This method is only for use by Agent Development Kit
|
|
1493
|
+
*/
|
|
1494
|
+
canonicalGlobalInstruction(ctx: ReadonlyContext): Promise<[string, boolean]>;
|
|
1495
|
+
/**
|
|
1496
|
+
* The resolved tools field as a list of BaseTool based on the context
|
|
1497
|
+
* This method is only for use by Agent Development Kit
|
|
1498
|
+
*/
|
|
1499
|
+
canonicalTools(ctx?: ReadonlyContext): Promise<BaseTool[]>;
|
|
1500
|
+
/**
|
|
1501
|
+
* Gets the appropriate LLM flow for this agent
|
|
1502
|
+
* This matches the Python implementation's _llm_flow property
|
|
1503
|
+
*/
|
|
1504
|
+
private get llmFlow();
|
|
1505
|
+
/**
|
|
1506
|
+
* Saves the model output to state if needed
|
|
1507
|
+
* This matches the Python implementation's __maybe_save_output_to_state
|
|
1508
|
+
*/
|
|
1509
|
+
private maybeSaveOutputToState;
|
|
1510
|
+
/**
|
|
1511
|
+
* Core logic to run this agent via text-based conversation
|
|
1512
|
+
* This matches the Python implementation's _run_async_impl
|
|
1513
|
+
*/
|
|
1514
|
+
protected runAsyncImpl(context: InvocationContext): AsyncGenerator<Event, void, unknown>;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
/**
|
|
1518
|
+
* Type for agents that can be used as tools
|
|
1519
|
+
*/
|
|
1520
|
+
type BaseAgentType = LlmAgent;
|
|
1521
|
+
/**
|
|
1522
|
+
* Configuration for AgentTool
|
|
1523
|
+
*/
|
|
1524
|
+
interface AgentToolConfig {
|
|
1525
|
+
/**
|
|
1526
|
+
* Name of the tool
|
|
1527
|
+
*/
|
|
1528
|
+
name: string;
|
|
1529
|
+
/**
|
|
1530
|
+
* Description of the tool
|
|
1531
|
+
*/
|
|
1532
|
+
description?: string;
|
|
1533
|
+
/**
|
|
1534
|
+
* The agent that will be used as a tool
|
|
1535
|
+
*/
|
|
1536
|
+
agent: BaseAgentType;
|
|
1537
|
+
/**
|
|
1538
|
+
* Optional function declaration schema override
|
|
1539
|
+
*/
|
|
1540
|
+
functionDeclaration?: FunctionDeclaration;
|
|
1541
|
+
/**
|
|
1542
|
+
* Optional key to store the tool output in the state
|
|
1543
|
+
*/
|
|
1544
|
+
outputKey?: string;
|
|
1545
|
+
/**
|
|
1546
|
+
* Optional flag to skip summarization of the agent's response
|
|
1547
|
+
*/
|
|
1548
|
+
skipSummarization?: boolean;
|
|
1549
|
+
/**
|
|
1550
|
+
* Whether the tool is a long running operation
|
|
1551
|
+
*/
|
|
1552
|
+
isLongRunning?: boolean;
|
|
1553
|
+
/**
|
|
1554
|
+
* Whether the tool execution should be retried on failure
|
|
1555
|
+
*/
|
|
1556
|
+
shouldRetryOnFailure?: boolean;
|
|
1557
|
+
/**
|
|
1558
|
+
* Maximum retry attempts
|
|
1559
|
+
*/
|
|
1560
|
+
maxRetryAttempts?: number;
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* A tool that uses an agent to perform a task.
|
|
1564
|
+
*
|
|
1565
|
+
* This tool allows specialized agents to be used as reusable tools
|
|
1566
|
+
* within other agents, enabling modular agent composition and
|
|
1567
|
+
* domain-specific expertise as services.
|
|
1568
|
+
*/
|
|
1569
|
+
declare class AgentTool extends BaseTool {
|
|
1570
|
+
/**
|
|
1571
|
+
* The agent used by this tool
|
|
1572
|
+
*/
|
|
1573
|
+
private agent;
|
|
1574
|
+
/**
|
|
1575
|
+
* The function declaration schema
|
|
1576
|
+
*/
|
|
1577
|
+
private functionDeclaration?;
|
|
1578
|
+
/**
|
|
1579
|
+
* The key to store the tool output in the state
|
|
1580
|
+
*/
|
|
1581
|
+
outputKey?: string;
|
|
1582
|
+
/**
|
|
1583
|
+
* Whether to skip summarization of the agent's response
|
|
1584
|
+
*/
|
|
1585
|
+
private skipSummarization;
|
|
1586
|
+
protected logger: Logger;
|
|
1587
|
+
/**
|
|
1588
|
+
* Create a new agent tool
|
|
1589
|
+
*/
|
|
1590
|
+
constructor(config: AgentToolConfig);
|
|
1591
|
+
/**
|
|
1592
|
+
* Get the function declaration for the tool
|
|
1593
|
+
*/
|
|
1594
|
+
getDeclaration(): FunctionDeclaration;
|
|
1595
|
+
/**
|
|
1596
|
+
* Execute the tool by running the agent with the provided input
|
|
1597
|
+
*/
|
|
1598
|
+
runAsync(params: Record<string, any>, context: ToolContext): Promise<any>;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
/**
|
|
1602
|
+
* A tool that wraps a user-defined TypeScript function.
|
|
1603
|
+
*
|
|
1604
|
+
* This tool automatically generates a function declaration from the function's
|
|
1605
|
+
* signature and documentation, making it easy to expose functions to agents.
|
|
1606
|
+
*/
|
|
1607
|
+
declare class FunctionTool<T extends Record<string, any>> extends BaseTool {
|
|
1608
|
+
private func;
|
|
1609
|
+
private mandatoryArgs;
|
|
1610
|
+
private parameterTypes;
|
|
1611
|
+
/**
|
|
1612
|
+
* Creates a new FunctionTool wrapping the provided function.
|
|
1613
|
+
*
|
|
1614
|
+
* @param func The function to wrap
|
|
1615
|
+
* @param options Optional configuration for the tool
|
|
1616
|
+
*/
|
|
1617
|
+
constructor(func: (...args: any[]) => any, options?: {
|
|
1618
|
+
name?: string;
|
|
1619
|
+
description?: string;
|
|
1620
|
+
isLongRunning?: boolean;
|
|
1621
|
+
shouldRetryOnFailure?: boolean;
|
|
1622
|
+
maxRetryAttempts?: number;
|
|
1623
|
+
parameterTypes?: Record<string, string>;
|
|
1624
|
+
});
|
|
1625
|
+
/**
|
|
1626
|
+
* Executes the wrapped function with the provided arguments.
|
|
1627
|
+
*/
|
|
1628
|
+
runAsync(args: T, context: ToolContext): Promise<any>;
|
|
1629
|
+
/**
|
|
1630
|
+
* Returns the function declaration for this tool.
|
|
1631
|
+
*/
|
|
1632
|
+
getDeclaration(): FunctionDeclaration;
|
|
1633
|
+
/**
|
|
1634
|
+
* Checks if the wrapped function accepts a toolContext parameter.
|
|
1635
|
+
*/
|
|
1636
|
+
private functionAcceptsToolContext;
|
|
1637
|
+
/**
|
|
1638
|
+
* Checks if the wrapped function is async.
|
|
1639
|
+
*/
|
|
1640
|
+
private isAsyncFunction;
|
|
1641
|
+
/**
|
|
1642
|
+
* Extracts the mandatory arguments from a function.
|
|
1643
|
+
* In TypeScript, we can't easily inspect parameter defaults at runtime,
|
|
1644
|
+
* so this is a best-effort approach.
|
|
1645
|
+
*/
|
|
1646
|
+
private getMandatoryArgs;
|
|
1647
|
+
/**
|
|
1648
|
+
* Checks which mandatory arguments are missing from the provided args.
|
|
1649
|
+
*/
|
|
1650
|
+
private getMissingMandatoryArgs;
|
|
1651
|
+
/**
|
|
1652
|
+
* Extracts the function parameters from the function's signature.
|
|
1653
|
+
*/
|
|
1654
|
+
private getFunctionParameters;
|
|
1655
|
+
/**
|
|
1656
|
+
* Converts an argument to the proper type based on the function signature.
|
|
1657
|
+
*/
|
|
1658
|
+
private convertArgumentType;
|
|
1659
|
+
/**
|
|
1660
|
+
* Extracts the type of a specific parameter from the function signature.
|
|
1661
|
+
*/
|
|
1662
|
+
private getParameterType;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
/**
|
|
1666
|
+
* Options for building a function declaration
|
|
1667
|
+
*/
|
|
1668
|
+
interface BuildFunctionDeclarationOptions {
|
|
1669
|
+
name?: string;
|
|
1670
|
+
description?: string;
|
|
1671
|
+
ignoreParams?: string[];
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Builds a function declaration from a TypeScript function.
|
|
1675
|
+
*
|
|
1676
|
+
* This utility analyzes the function signature and JSDoc comments to create
|
|
1677
|
+
* a FunctionDeclaration object that can be used with LLMs.
|
|
1678
|
+
*
|
|
1679
|
+
* @param func The function to analyze
|
|
1680
|
+
* @param options Options for customizing the declaration
|
|
1681
|
+
* @returns A FunctionDeclaration representing the function
|
|
1682
|
+
*/
|
|
1683
|
+
declare function buildFunctionDeclaration(func: (...args: any[]) => any, options?: BuildFunctionDeclarationOptions): FunctionDeclaration;
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
* Creates a new FunctionTool that wraps a function.
|
|
1687
|
+
* This is a convenience function for creating a new FunctionTool.
|
|
1688
|
+
*
|
|
1689
|
+
* @param func The function to wrap
|
|
1690
|
+
* @param options Optional configuration for the tool
|
|
1691
|
+
* @returns A new FunctionTool wrapping the function
|
|
1692
|
+
*/
|
|
1693
|
+
declare function createFunctionTool(func: (...args: any[]) => any, options?: {
|
|
1694
|
+
name?: string;
|
|
1695
|
+
description?: string;
|
|
1696
|
+
isLongRunning?: boolean;
|
|
1697
|
+
shouldRetryOnFailure?: boolean;
|
|
1698
|
+
maxRetryAttempts?: number;
|
|
1699
|
+
}): any;
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* Simple GoogleSearch tool implementation
|
|
1703
|
+
*/
|
|
1704
|
+
declare class GoogleSearch extends BaseTool {
|
|
1705
|
+
protected logger: Logger;
|
|
1706
|
+
/**
|
|
1707
|
+
* Constructor for GoogleSearch
|
|
1708
|
+
*/
|
|
1709
|
+
constructor();
|
|
1710
|
+
/**
|
|
1711
|
+
* Get the function declaration for the tool
|
|
1712
|
+
*/
|
|
1713
|
+
getDeclaration(): FunctionDeclaration;
|
|
1714
|
+
/**
|
|
1715
|
+
* Execute the search
|
|
1716
|
+
* This is a simplified implementation that doesn't actually search, just returns mock results
|
|
1717
|
+
*/
|
|
1718
|
+
runAsync(args: {
|
|
1719
|
+
query: string;
|
|
1720
|
+
num_results?: number;
|
|
1721
|
+
}, _context: ToolContext): Promise<any>;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
interface HttpRequestResult {
|
|
1725
|
+
statusCode: number;
|
|
1726
|
+
headers: Record<string, string>;
|
|
1727
|
+
body: string;
|
|
1728
|
+
error?: string;
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Tool for making HTTP requests to external APIs and web services
|
|
1732
|
+
*/
|
|
1733
|
+
declare class HttpRequestTool extends BaseTool {
|
|
1734
|
+
constructor();
|
|
1735
|
+
/**
|
|
1736
|
+
* Get the function declaration for the tool
|
|
1737
|
+
*/
|
|
1738
|
+
getDeclaration(): FunctionDeclaration;
|
|
1739
|
+
/**
|
|
1740
|
+
* Execute the HTTP request
|
|
1741
|
+
*/
|
|
1742
|
+
runAsync(args: {
|
|
1743
|
+
url: string;
|
|
1744
|
+
method?: string;
|
|
1745
|
+
headers?: Record<string, string>;
|
|
1746
|
+
body?: string;
|
|
1747
|
+
params?: Record<string, string>;
|
|
1748
|
+
timeout?: number;
|
|
1749
|
+
}, _context: ToolContext): Promise<HttpRequestResult>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Check if a string is valid JSON
|
|
1752
|
+
*/
|
|
1753
|
+
private isValidJson;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
interface FileOperationResult {
|
|
1757
|
+
success: boolean;
|
|
1758
|
+
data?: any;
|
|
1759
|
+
error?: string;
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Tool for performing file system operations
|
|
1763
|
+
*/
|
|
1764
|
+
declare class FileOperationsTool extends BaseTool {
|
|
1765
|
+
private basePath;
|
|
1766
|
+
constructor(options?: {
|
|
1767
|
+
basePath?: string;
|
|
1768
|
+
});
|
|
1769
|
+
/**
|
|
1770
|
+
* Get the function declaration for the tool
|
|
1771
|
+
*/
|
|
1772
|
+
getDeclaration(): FunctionDeclaration;
|
|
1773
|
+
/**
|
|
1774
|
+
* Execute the file operation
|
|
1775
|
+
*/
|
|
1776
|
+
runAsync(args: {
|
|
1777
|
+
operation: "read" | "write" | "append" | "delete" | "exists" | "list" | "mkdir";
|
|
1778
|
+
filepath: string;
|
|
1779
|
+
content?: string;
|
|
1780
|
+
encoding?: BufferEncoding;
|
|
1781
|
+
}, _context: ToolContext): Promise<FileOperationResult>;
|
|
1782
|
+
/**
|
|
1783
|
+
* Resolve a file path relative to the base path
|
|
1784
|
+
*/
|
|
1785
|
+
private resolvePath;
|
|
1786
|
+
/**
|
|
1787
|
+
* Validate that a path is within the base path for security
|
|
1788
|
+
*/
|
|
1789
|
+
private validatePath;
|
|
1790
|
+
/**
|
|
1791
|
+
* Read a file
|
|
1792
|
+
*/
|
|
1793
|
+
private readFile;
|
|
1794
|
+
/**
|
|
1795
|
+
* Write to a file
|
|
1796
|
+
*/
|
|
1797
|
+
private writeFile;
|
|
1798
|
+
/**
|
|
1799
|
+
* Append to a file
|
|
1800
|
+
*/
|
|
1801
|
+
private appendFile;
|
|
1802
|
+
/**
|
|
1803
|
+
* Delete a file
|
|
1804
|
+
*/
|
|
1805
|
+
private deleteFile;
|
|
1806
|
+
/**
|
|
1807
|
+
* Check if a file exists
|
|
1808
|
+
*/
|
|
1809
|
+
private fileExists;
|
|
1810
|
+
/**
|
|
1811
|
+
* List directory contents
|
|
1812
|
+
*/
|
|
1813
|
+
private listDirectory;
|
|
1814
|
+
/**
|
|
1815
|
+
* Create a directory
|
|
1816
|
+
*/
|
|
1817
|
+
private makeDirectory;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
interface UserInteractionResult {
|
|
1821
|
+
success: boolean;
|
|
1822
|
+
userInput?: string;
|
|
1823
|
+
error?: string;
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Tool for prompting the user for input
|
|
1827
|
+
*/
|
|
1828
|
+
declare class UserInteractionTool extends BaseTool {
|
|
1829
|
+
constructor();
|
|
1830
|
+
/**
|
|
1831
|
+
* Get the function declaration for the tool
|
|
1832
|
+
*/
|
|
1833
|
+
getDeclaration(): FunctionDeclaration;
|
|
1834
|
+
/**
|
|
1835
|
+
* Execute the user interaction
|
|
1836
|
+
*/
|
|
1837
|
+
runAsync(args: {
|
|
1838
|
+
prompt: string;
|
|
1839
|
+
options?: string[];
|
|
1840
|
+
defaultValue?: string;
|
|
1841
|
+
}, context: ToolContext): Promise<UserInteractionResult>;
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
/**
|
|
1845
|
+
* Tool that allows an agent to exit the current execution loop
|
|
1846
|
+
*/
|
|
1847
|
+
declare class ExitLoopTool extends BaseTool {
|
|
1848
|
+
protected logger: Logger;
|
|
1849
|
+
/**
|
|
1850
|
+
* Constructor for ExitLoopTool
|
|
1851
|
+
*/
|
|
1852
|
+
constructor();
|
|
1853
|
+
/**
|
|
1854
|
+
* Execute the exit loop action
|
|
1855
|
+
*/
|
|
1856
|
+
runAsync(_args: Record<string, any>, context: ToolContext): Promise<any>;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
/**
|
|
1860
|
+
* Tool that allows an agent to get a choice from the user
|
|
1861
|
+
*/
|
|
1862
|
+
declare class GetUserChoiceTool extends BaseTool {
|
|
1863
|
+
protected logger: Logger;
|
|
1864
|
+
/**
|
|
1865
|
+
* Constructor for GetUserChoiceTool
|
|
1866
|
+
*/
|
|
1867
|
+
constructor();
|
|
1868
|
+
/**
|
|
1869
|
+
* Get the function declaration for the tool
|
|
1870
|
+
*/
|
|
1871
|
+
getDeclaration(): FunctionDeclaration;
|
|
1872
|
+
/**
|
|
1873
|
+
* Execute the user choice action
|
|
1874
|
+
* This is a long running operation that will return null initially
|
|
1875
|
+
* and the actual choice will be provided asynchronously
|
|
1876
|
+
*/
|
|
1877
|
+
runAsync(args: {
|
|
1878
|
+
options: string[];
|
|
1879
|
+
question?: string;
|
|
1880
|
+
}, context: ToolContext): Promise<any>;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
/**
|
|
1884
|
+
* Tool that allows an agent to transfer control to another agent
|
|
1885
|
+
*/
|
|
1886
|
+
declare class TransferToAgentTool extends BaseTool {
|
|
1887
|
+
protected logger: Logger;
|
|
1888
|
+
/**
|
|
1889
|
+
* Constructor for TransferToAgentTool
|
|
1890
|
+
*/
|
|
1891
|
+
constructor();
|
|
1892
|
+
/**
|
|
1893
|
+
* Get the function declaration for the tool
|
|
1894
|
+
*/
|
|
1895
|
+
getDeclaration(): FunctionDeclaration;
|
|
1896
|
+
/**
|
|
1897
|
+
* Execute the transfer to agent action
|
|
1898
|
+
*/
|
|
1899
|
+
runAsync(args: {
|
|
1900
|
+
agent_name: string;
|
|
1901
|
+
}, context: ToolContext): Promise<any>;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
/**
|
|
1905
|
+
* Tool that allows an agent to load memories relevant to a query
|
|
1906
|
+
*/
|
|
1907
|
+
declare class LoadMemoryTool extends BaseTool {
|
|
1908
|
+
protected logger: Logger;
|
|
1909
|
+
/**
|
|
1910
|
+
* Constructor for LoadMemoryTool
|
|
1911
|
+
*/
|
|
1912
|
+
constructor();
|
|
1913
|
+
/**
|
|
1914
|
+
* Get the function declaration for the tool
|
|
1915
|
+
*/
|
|
1916
|
+
getDeclaration(): FunctionDeclaration;
|
|
1917
|
+
/**
|
|
1918
|
+
* Execute the memory loading action
|
|
1919
|
+
*/
|
|
1920
|
+
runAsync(args: {
|
|
1921
|
+
query: string;
|
|
1922
|
+
}, context: ToolContext): Promise<any>;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
/**
|
|
1926
|
+
* A tool that loads the artifacts and adds them to the session.
|
|
1927
|
+
*/
|
|
1928
|
+
declare class LoadArtifactsTool extends BaseTool {
|
|
1929
|
+
constructor();
|
|
1930
|
+
/**
|
|
1931
|
+
* Get the function declaration for the tool
|
|
1932
|
+
*/
|
|
1933
|
+
getDeclaration(): FunctionDeclaration;
|
|
1934
|
+
/**
|
|
1935
|
+
* Execute the load artifacts operation
|
|
1936
|
+
*/
|
|
1937
|
+
runAsync(args: {
|
|
1938
|
+
artifact_names?: string[];
|
|
1939
|
+
}, context: ToolContext): Promise<{
|
|
1940
|
+
artifact_names: string[];
|
|
1941
|
+
}>;
|
|
1942
|
+
/**
|
|
1943
|
+
* Processes the outgoing LLM request for this tool.
|
|
1944
|
+
*/
|
|
1945
|
+
processLlmRequest(toolContext: ToolContext, llmRequest: LlmRequest): Promise<void>;
|
|
1946
|
+
/**
|
|
1947
|
+
* Appends artifacts information to the LLM request
|
|
1948
|
+
*/
|
|
1949
|
+
private appendArtifactsToLlmRequest;
|
|
1950
|
+
/**
|
|
1951
|
+
* Extracts function response from a part if it exists
|
|
1952
|
+
*/
|
|
1953
|
+
private extractFunctionResponse;
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
type McpConfig = {
|
|
1957
|
+
name: string;
|
|
1958
|
+
description: string;
|
|
1959
|
+
transport: McpTransportType;
|
|
1960
|
+
timeout?: number;
|
|
1961
|
+
retryOptions?: {
|
|
1962
|
+
maxRetries?: number;
|
|
1963
|
+
initialDelay?: number;
|
|
1964
|
+
maxDelay?: number;
|
|
1965
|
+
};
|
|
1966
|
+
headers?: Record<string, string>;
|
|
1967
|
+
cacheConfig?: {
|
|
1968
|
+
enabled?: boolean;
|
|
1969
|
+
maxAge?: number;
|
|
1970
|
+
maxSize?: number;
|
|
1971
|
+
};
|
|
1972
|
+
debug?: boolean;
|
|
1973
|
+
/**
|
|
1974
|
+
* Sampling handler for processing MCP sampling requests.
|
|
1975
|
+
* This allows MCP servers to request LLM completions through your ADK agent.
|
|
1397
1976
|
*/
|
|
1398
1977
|
samplingHandler?: SamplingHandler;
|
|
1399
1978
|
};
|
|
@@ -1497,11 +2076,11 @@ declare function jsonSchemaToDeclaration(name: string, description: string, sche
|
|
|
1497
2076
|
* Normalizes a JSON Schema to ensure it's properly formatted
|
|
1498
2077
|
* Handles edge cases and ensures consistency
|
|
1499
2078
|
*/
|
|
1500
|
-
declare function normalizeJsonSchema(schema: Record<string, any>):
|
|
2079
|
+
declare function normalizeJsonSchema(schema: Record<string, any>): Schema;
|
|
1501
2080
|
/**
|
|
1502
2081
|
* Converts MCP tool inputSchema to parameters format expected by BaseTool
|
|
1503
2082
|
*/
|
|
1504
|
-
declare function mcpSchemaToParameters(mcpTool: Tool):
|
|
2083
|
+
declare function mcpSchemaToParameters(mcpTool: Tool): Schema;
|
|
1505
2084
|
|
|
1506
2085
|
/**
|
|
1507
2086
|
* MCP Sampling Handler class that handles message format conversion
|
|
@@ -1854,6 +2433,10 @@ declare function getMcpTools(config: McpConfig, toolFilter?: string[] | ((tool:
|
|
|
1854
2433
|
* Tools module exports
|
|
1855
2434
|
*/
|
|
1856
2435
|
|
|
2436
|
+
type index$6_AgentTool = AgentTool;
|
|
2437
|
+
declare const index$6_AgentTool: typeof AgentTool;
|
|
2438
|
+
type index$6_AgentToolConfig = AgentToolConfig;
|
|
2439
|
+
type index$6_BaseAgentType = BaseAgentType;
|
|
1857
2440
|
type index$6_BaseTool = BaseTool;
|
|
1858
2441
|
declare const index$6_BaseTool: typeof BaseTool;
|
|
1859
2442
|
type index$6_BuildFunctionDeclarationOptions = BuildFunctionDeclarationOptions;
|
|
@@ -1921,7 +2504,7 @@ declare const index$6_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
|
|
|
1921
2504
|
declare const index$6_mcpSchemaToParameters: typeof mcpSchemaToParameters;
|
|
1922
2505
|
declare const index$6_normalizeJsonSchema: typeof normalizeJsonSchema;
|
|
1923
2506
|
declare namespace index$6 {
|
|
1924
|
-
export { index$6_BaseTool as BaseTool, type index$6_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, type index$6_CreateToolConfig as CreateToolConfig, type index$6_CreateToolConfigWithSchema as CreateToolConfigWithSchema, type index$6_CreateToolConfigWithoutSchema as CreateToolConfigWithoutSchema, 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_McpNearIntents as McpNearIntents, 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 };
|
|
2507
|
+
export { index$6_AgentTool as AgentTool, type index$6_AgentToolConfig as AgentToolConfig, type index$6_BaseAgentType as BaseAgentType, index$6_BaseTool as BaseTool, type index$6_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, type index$6_CreateToolConfig as CreateToolConfig, type index$6_CreateToolConfigWithSchema as CreateToolConfigWithSchema, type index$6_CreateToolConfigWithoutSchema as CreateToolConfigWithoutSchema, 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_McpNearIntents as McpNearIntents, 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 };
|
|
1925
2508
|
}
|
|
1926
2509
|
|
|
1927
2510
|
/**
|
|
@@ -1942,7 +2525,7 @@ declare class LlmRequest {
|
|
|
1942
2525
|
/**
|
|
1943
2526
|
* The contents to send to the model.
|
|
1944
2527
|
*/
|
|
1945
|
-
contents: Content
|
|
2528
|
+
contents: Content[];
|
|
1946
2529
|
/**
|
|
1947
2530
|
* Additional config for the generate content request.
|
|
1948
2531
|
* Tools in generate_content_config should not be set.
|
|
@@ -1958,241 +2541,39 @@ declare class LlmRequest {
|
|
|
1958
2541
|
toolsDict: Record<string, BaseTool>;
|
|
1959
2542
|
constructor(data?: {
|
|
1960
2543
|
model?: string;
|
|
1961
|
-
contents?: Content
|
|
2544
|
+
contents?: Content[];
|
|
1962
2545
|
config?: GenerateContentConfig;
|
|
1963
2546
|
liveConnectConfig?: LiveConnectConfig;
|
|
1964
|
-
toolsDict?: Record<string, BaseTool>;
|
|
1965
|
-
});
|
|
1966
|
-
/**
|
|
1967
|
-
* Appends instructions to the system instruction.
|
|
1968
|
-
* @param instructions The instructions to append.
|
|
1969
|
-
*/
|
|
1970
|
-
appendInstructions(instructions: string[]): void;
|
|
1971
|
-
/**
|
|
1972
|
-
* Appends tools to the request.
|
|
1973
|
-
* @param tools The tools to append.
|
|
1974
|
-
*/
|
|
1975
|
-
appendTools(tools: BaseTool[]): void;
|
|
1976
|
-
/**
|
|
1977
|
-
* Sets the output schema for the request.
|
|
1978
|
-
* @param baseModel The base model to set as the output schema.
|
|
1979
|
-
*/
|
|
1980
|
-
setOutputSchema(baseModel: any): void;
|
|
1981
|
-
/**
|
|
1982
|
-
* Extracts the system instruction as plain text from Content or string.
|
|
1983
|
-
* System instructions can be either string or Content type.
|
|
1984
|
-
* @returns The system instruction as a string, or undefined if not set.
|
|
1985
|
-
*/
|
|
1986
|
-
getSystemInstructionText(): string | undefined;
|
|
1987
|
-
/**
|
|
1988
|
-
* Extracts text content from a Content object.
|
|
1989
|
-
* Used for extracting text from message contents.
|
|
1990
|
-
* @param content The Content object to extract text from.
|
|
1991
|
-
* @returns The extracted text as a string.
|
|
1992
|
-
*/
|
|
1993
|
-
static extractTextFromContent(content: any): string;
|
|
1994
|
-
}
|
|
1995
|
-
|
|
1996
|
-
/**
|
|
1997
|
-
* Candidate response from the model.
|
|
1998
|
-
*/
|
|
1999
|
-
interface Candidate {
|
|
2000
|
-
content?: Content$1;
|
|
2001
|
-
groundingMetadata?: GroundingMetadata;
|
|
2002
|
-
finishReason?: string;
|
|
2003
|
-
finishMessage?: string;
|
|
2004
|
-
}
|
|
2005
|
-
/**
|
|
2006
|
-
* Prompt feedback in case of blocked or failed prompt.
|
|
2007
|
-
*/
|
|
2008
|
-
interface PromptFeedback {
|
|
2009
|
-
blockReason?: string;
|
|
2010
|
-
blockReasonMessage?: string;
|
|
2011
|
-
}
|
|
2012
|
-
/**
|
|
2013
|
-
* The response from the model generation API.
|
|
2014
|
-
*/
|
|
2015
|
-
interface GenerateContentResponse {
|
|
2016
|
-
candidates?: Candidate[];
|
|
2017
|
-
usageMetadata?: GenerateContentResponseUsageMetadata;
|
|
2018
|
-
promptFeedback?: PromptFeedback;
|
|
2019
|
-
}
|
|
2020
|
-
/**
|
|
2021
|
-
* Response from a language model.
|
|
2022
|
-
*/
|
|
2023
|
-
declare class LlmResponse {
|
|
2024
|
-
/**
|
|
2025
|
-
* Unique identifier for the response.
|
|
2026
|
-
*/
|
|
2027
|
-
id?: string;
|
|
2028
|
-
/**
|
|
2029
|
-
* The content generated by the model.
|
|
2030
|
-
*/
|
|
2031
|
-
content?: Content$1;
|
|
2032
|
-
/**
|
|
2033
|
-
* The grounding metadata of the response.
|
|
2034
|
-
*/
|
|
2035
|
-
groundingMetadata?: GroundingMetadata;
|
|
2036
|
-
/**
|
|
2037
|
-
* Indicates whether the text content is part of an unfinished text stream.
|
|
2038
|
-
*/
|
|
2039
|
-
partial?: boolean;
|
|
2040
|
-
/**
|
|
2041
|
-
* Indicates whether the response from the model is complete.
|
|
2042
|
-
*/
|
|
2043
|
-
turnComplete?: boolean;
|
|
2044
|
-
/**
|
|
2045
|
-
* Error code if the response is an error.
|
|
2046
|
-
*/
|
|
2047
|
-
errorCode?: string;
|
|
2048
|
-
/**
|
|
2049
|
-
* Error message if the response is an error.
|
|
2050
|
-
*/
|
|
2051
|
-
errorMessage?: string;
|
|
2052
|
-
/**
|
|
2053
|
-
* Flag indicating that LLM was interrupted when generating the content.
|
|
2054
|
-
*/
|
|
2055
|
-
interrupted?: boolean;
|
|
2056
|
-
/**
|
|
2057
|
-
* The custom metadata of the LlmResponse.
|
|
2058
|
-
*/
|
|
2059
|
-
customMetadata?: Record<string, any>;
|
|
2060
|
-
/**
|
|
2061
|
-
* The usage metadata of the LlmResponse.
|
|
2062
|
-
*/
|
|
2063
|
-
usageMetadata?: GenerateContentResponseUsageMetadata;
|
|
2064
|
-
/**
|
|
2065
|
-
* Index of the candidate response.
|
|
2066
|
-
*/
|
|
2067
|
-
candidateIndex?: number;
|
|
2068
|
-
/**
|
|
2069
|
-
* Reason why the model finished generating.
|
|
2070
|
-
*/
|
|
2071
|
-
finishReason?: string;
|
|
2072
|
-
/**
|
|
2073
|
-
* Error object if the response is an error.
|
|
2074
|
-
*/
|
|
2075
|
-
error?: Error;
|
|
2076
|
-
/**
|
|
2077
|
-
* Creates a new LlmResponse.
|
|
2078
|
-
*/
|
|
2079
|
-
constructor(data?: Partial<LlmResponse>);
|
|
2080
|
-
/**
|
|
2081
|
-
* Creates an LlmResponse from a GenerateContentResponse.
|
|
2082
|
-
*
|
|
2083
|
-
* @param generateContentResponse The GenerateContentResponse to create the LlmResponse from.
|
|
2084
|
-
* @returns The LlmResponse.
|
|
2085
|
-
*/
|
|
2086
|
-
static create(generateContentResponse: GenerateContentResponse): LlmResponse;
|
|
2087
|
-
/**
|
|
2088
|
-
* Creates an LlmResponse from an error.
|
|
2089
|
-
*
|
|
2090
|
-
* @param error The error object or message.
|
|
2091
|
-
* @param options Additional options for the error response.
|
|
2092
|
-
* @param options.errorCode A specific error code for the response.
|
|
2093
|
-
* @param options.model The model that was being used when the error occurred.
|
|
2094
|
-
* @returns The LlmResponse.
|
|
2095
|
-
*/
|
|
2096
|
-
static fromError(error: unknown, options?: {
|
|
2097
|
-
errorCode?: string;
|
|
2098
|
-
model?: string;
|
|
2099
|
-
}): LlmResponse;
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
|
-
/**
|
|
2103
|
-
* The base class for a live model connection.
|
|
2104
|
-
*/
|
|
2105
|
-
declare abstract class BaseLLMConnection {
|
|
2106
|
-
/**
|
|
2107
|
-
* Sends the conversation history to the model.
|
|
2108
|
-
*
|
|
2109
|
-
* You call this method right after setting up the model connection.
|
|
2110
|
-
* The model will respond if the last content is from user, otherwise it will
|
|
2111
|
-
* wait for new user input before responding.
|
|
2112
|
-
*
|
|
2113
|
-
* @param history The conversation history to send to the model.
|
|
2114
|
-
*/
|
|
2115
|
-
abstract sendHistory(history: Content$1[]): Promise<void>;
|
|
2116
|
-
/**
|
|
2117
|
-
* Sends a user content to the model.
|
|
2118
|
-
*
|
|
2119
|
-
* The model will respond immediately upon receiving the content.
|
|
2120
|
-
* If you send function responses, all parts in the content should be function
|
|
2121
|
-
* responses.
|
|
2122
|
-
*
|
|
2123
|
-
* @param content The content to send to the model.
|
|
2124
|
-
*/
|
|
2125
|
-
abstract sendContent(content: Content$1): Promise<void>;
|
|
2126
|
-
/**
|
|
2127
|
-
* Sends a chunk of audio or a frame of video to the model in realtime.
|
|
2128
|
-
*
|
|
2129
|
-
* The model may not respond immediately upon receiving the blob. It will do
|
|
2130
|
-
* voice activity detection and decide when to respond.
|
|
2131
|
-
*
|
|
2132
|
-
* @param blob The blob to send to the model.
|
|
2133
|
-
*/
|
|
2134
|
-
abstract sendRealtime(blob: Blob): Promise<void>;
|
|
2135
|
-
/**
|
|
2136
|
-
* Receives the model response using the llm server connection.
|
|
2137
|
-
*
|
|
2138
|
-
* @returns LlmResponse: The model response.
|
|
2139
|
-
*/
|
|
2140
|
-
abstract receive(): AsyncGenerator<LlmResponse, void, unknown>;
|
|
2141
|
-
/**
|
|
2142
|
-
* Closes the llm server connection.
|
|
2143
|
-
*/
|
|
2144
|
-
abstract close(): Promise<void>;
|
|
2145
|
-
}
|
|
2146
|
-
|
|
2147
|
-
/**
|
|
2148
|
-
* The BaseLlm class.
|
|
2149
|
-
*/
|
|
2150
|
-
declare abstract class BaseLlm {
|
|
2151
|
-
/**
|
|
2152
|
-
* The name of the LLM, e.g. gemini-1.5-flash or gemini-1.5-flash-001.
|
|
2153
|
-
*/
|
|
2154
|
-
model: string;
|
|
2155
|
-
protected logger: Logger;
|
|
2156
|
-
/**
|
|
2157
|
-
* Constructor for BaseLlm
|
|
2158
|
-
*/
|
|
2159
|
-
constructor(model: string);
|
|
2160
|
-
/**
|
|
2161
|
-
* Returns a list of supported models in regex for LLMRegistry
|
|
2162
|
-
*/
|
|
2163
|
-
static supportedModels(): string[];
|
|
2164
|
-
/**
|
|
2165
|
-
* Generates one content from the given contents and tools.
|
|
2166
|
-
*
|
|
2167
|
-
* @param llmRequest LlmRequest, the request to send to the LLM.
|
|
2168
|
-
* @param stream bool = false, whether to do streaming call.
|
|
2169
|
-
* @returns a generator of LlmResponse.
|
|
2170
|
-
*
|
|
2171
|
-
* For non-streaming call, it will only yield one LlmResponse.
|
|
2172
|
-
*
|
|
2173
|
-
* For streaming call, it may yield more than one response, but all yielded
|
|
2174
|
-
* responses should be treated as one response by merging the
|
|
2175
|
-
* parts list.
|
|
2547
|
+
toolsDict?: Record<string, BaseTool>;
|
|
2548
|
+
});
|
|
2549
|
+
/**
|
|
2550
|
+
* Appends instructions to the system instruction.
|
|
2551
|
+
* @param instructions The instructions to append.
|
|
2176
2552
|
*/
|
|
2177
|
-
|
|
2553
|
+
appendInstructions(instructions: string[]): void;
|
|
2178
2554
|
/**
|
|
2179
|
-
*
|
|
2180
|
-
*
|
|
2555
|
+
* Appends tools to the request.
|
|
2556
|
+
* @param tools The tools to append.
|
|
2181
2557
|
*/
|
|
2182
|
-
|
|
2558
|
+
appendTools(tools: BaseTool[]): void;
|
|
2183
2559
|
/**
|
|
2184
|
-
*
|
|
2185
|
-
*
|
|
2186
|
-
* @param llmRequest LlmRequest, the request to send to the LLM.
|
|
2560
|
+
* Sets the output schema for the request.
|
|
2561
|
+
* @param baseModel The base model to set as the output schema.
|
|
2187
2562
|
*/
|
|
2188
|
-
|
|
2563
|
+
setOutputSchema(baseModel: any): void;
|
|
2189
2564
|
/**
|
|
2190
|
-
*
|
|
2191
|
-
*
|
|
2192
|
-
* @
|
|
2193
|
-
* @returns BaseLLMConnection, the connection to the LLM.
|
|
2565
|
+
* Extracts the system instruction as plain text from Content or string.
|
|
2566
|
+
* System instructions can be either string or Content type.
|
|
2567
|
+
* @returns The system instruction as a string, or undefined if not set.
|
|
2194
2568
|
*/
|
|
2195
|
-
|
|
2569
|
+
getSystemInstructionText(): string | undefined;
|
|
2570
|
+
/**
|
|
2571
|
+
* Extracts text content from a Content object.
|
|
2572
|
+
* Used for extracting text from message contents.
|
|
2573
|
+
* @param content The Content object to extract text from.
|
|
2574
|
+
* @returns The extracted text as a string.
|
|
2575
|
+
*/
|
|
2576
|
+
static extractTextFromContent(content: any): string;
|
|
2196
2577
|
}
|
|
2197
2578
|
|
|
2198
2579
|
/**
|
|
@@ -2234,10 +2615,6 @@ declare class GoogleLlm extends BaseLlm {
|
|
|
2234
2615
|
* Convert LlmRequest contents to GoogleGenAI format
|
|
2235
2616
|
*/
|
|
2236
2617
|
private convertContents;
|
|
2237
|
-
/**
|
|
2238
|
-
* Convert LlmRequest config to GoogleGenAI format
|
|
2239
|
-
*/
|
|
2240
|
-
private convertConfig;
|
|
2241
2618
|
/**
|
|
2242
2619
|
* Preprocesses the request based on the API backend.
|
|
2243
2620
|
*/
|
|
@@ -2427,1199 +2804,862 @@ declare class AiSdkLlm extends BaseLlm {
|
|
|
2427
2804
|
*/
|
|
2428
2805
|
private convertToAiSdkMessages;
|
|
2429
2806
|
/**
|
|
2430
|
-
* Convert ADK tools to AI SDK tools format
|
|
2431
|
-
*/
|
|
2432
|
-
private convertToAiSdkTools;
|
|
2433
|
-
/**
|
|
2434
|
-
* Convert ADK Content to AI SDK CoreMessage
|
|
2435
|
-
*/
|
|
2436
|
-
private contentToAiSdkMessage;
|
|
2437
|
-
/**
|
|
2438
|
-
* Map ADK role to AI SDK role
|
|
2439
|
-
*/
|
|
2440
|
-
private mapRole;
|
|
2441
|
-
/**
|
|
2442
|
-
* Map AI SDK finish reason to ADK finish reason
|
|
2443
|
-
*/
|
|
2444
|
-
private mapFinishReason;
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
/**
|
|
2448
|
-
* Type for LLM constructor with static methods
|
|
2449
|
-
*/
|
|
2450
|
-
interface LLMClass {
|
|
2451
|
-
new (model: string): BaseLlm;
|
|
2452
|
-
supportedModels(): string[];
|
|
2453
|
-
}
|
|
2454
|
-
/**
|
|
2455
|
-
* Registry for LLMs
|
|
2456
|
-
*/
|
|
2457
|
-
declare class LLMRegistry {
|
|
2458
|
-
/**
|
|
2459
|
-
* Map of model name regex to LLM class
|
|
2460
|
-
*/
|
|
2461
|
-
private static llmRegistry;
|
|
2462
|
-
private static logger;
|
|
2463
|
-
/**
|
|
2464
|
-
* Creates a new LLM instance
|
|
2465
|
-
*
|
|
2466
|
-
* @param model The model name
|
|
2467
|
-
* @returns The LLM instance
|
|
2468
|
-
*/
|
|
2469
|
-
static newLLM(model: string): BaseLlm;
|
|
2470
|
-
/**
|
|
2471
|
-
* Resolves the LLM class from the model name
|
|
2472
|
-
*
|
|
2473
|
-
* @param model The model name
|
|
2474
|
-
* @returns The LLM class
|
|
2475
|
-
*/
|
|
2476
|
-
static resolve(model: string): LLMClass | null;
|
|
2477
|
-
/**
|
|
2478
|
-
* Registers a new LLM class
|
|
2479
|
-
*
|
|
2480
|
-
* @param modelNameRegex The regex to match model names
|
|
2481
|
-
* @param llmClass The LLM class
|
|
2482
|
-
*/
|
|
2483
|
-
static register(modelNameRegex: string, llmClass: LLMClass): void;
|
|
2484
|
-
/**
|
|
2485
|
-
* Registers all model patterns from an LLM class
|
|
2486
|
-
*
|
|
2487
|
-
* @param llmClass The LLM class
|
|
2488
|
-
*/
|
|
2489
|
-
static registerLLM(llmClass: LLMClass): void;
|
|
2490
|
-
/**
|
|
2491
|
-
* Logs all registered models for debugging
|
|
2492
|
-
*/
|
|
2493
|
-
static logRegisteredModels(): void;
|
|
2494
|
-
}
|
|
2495
|
-
|
|
2496
|
-
/**
|
|
2497
|
-
* Register all LLM providers
|
|
2498
|
-
*/
|
|
2499
|
-
declare function registerProviders(): void;
|
|
2500
|
-
|
|
2501
|
-
/**
|
|
2502
|
-
* Configuration for model built-in thinking features
|
|
2503
|
-
* Compatible with google.genai.types.ThinkingConfig
|
|
2504
|
-
*/
|
|
2505
|
-
interface ThinkingConfig {
|
|
2506
|
-
/**
|
|
2507
|
-
* Whether to include the thinking process in the response
|
|
2508
|
-
*/
|
|
2509
|
-
includeThinking?: boolean;
|
|
2510
|
-
/**
|
|
2511
|
-
* Additional thinking configuration options
|
|
2512
|
-
*/
|
|
2513
|
-
[key: string]: any;
|
|
2514
|
-
}
|
|
2515
|
-
|
|
2516
|
-
/**
|
|
2517
|
-
* Authentication scheme types
|
|
2518
|
-
*/
|
|
2519
|
-
declare enum AuthSchemeType {
|
|
2520
|
-
APIKEY = "apiKey",
|
|
2521
|
-
HTTP = "http",
|
|
2522
|
-
OAUTH2 = "oauth2",
|
|
2523
|
-
OPENID_CONNECT = "openIdConnect"
|
|
2524
|
-
}
|
|
2525
|
-
/**
|
|
2526
|
-
* Base class for authentication schemes
|
|
2527
|
-
*/
|
|
2528
|
-
declare abstract class AuthScheme {
|
|
2529
|
-
/**
|
|
2530
|
-
* The type of authentication scheme
|
|
2531
|
-
*/
|
|
2532
|
-
type: AuthSchemeType;
|
|
2533
|
-
constructor(type: AuthSchemeType);
|
|
2534
|
-
}
|
|
2535
|
-
/**
|
|
2536
|
-
* API Key authentication scheme
|
|
2537
|
-
*/
|
|
2538
|
-
declare class ApiKeyScheme extends AuthScheme {
|
|
2539
|
-
/**
|
|
2540
|
-
* Where the API key is sent
|
|
2541
|
-
*/
|
|
2542
|
-
in: "query" | "header" | "cookie";
|
|
2543
|
-
/**
|
|
2544
|
-
* Name of the parameter
|
|
2545
|
-
*/
|
|
2546
|
-
name: string;
|
|
2547
|
-
/**
|
|
2548
|
-
* Description of the API key
|
|
2549
|
-
*/
|
|
2550
|
-
description?: string;
|
|
2551
|
-
/**
|
|
2552
|
-
* Constructor for ApiKeyScheme
|
|
2553
|
-
*/
|
|
2554
|
-
constructor(config: {
|
|
2555
|
-
in: "query" | "header" | "cookie";
|
|
2556
|
-
name: string;
|
|
2557
|
-
description?: string;
|
|
2558
|
-
});
|
|
2559
|
-
}
|
|
2560
|
-
/**
|
|
2561
|
-
* HTTP authentication scheme
|
|
2562
|
-
*/
|
|
2563
|
-
declare class HttpScheme extends AuthScheme {
|
|
2564
|
-
/**
|
|
2565
|
-
* The HTTP authentication scheme
|
|
2566
|
-
*/
|
|
2567
|
-
scheme: "basic" | "bearer" | "digest" | "other";
|
|
2568
|
-
/**
|
|
2569
|
-
* Bearer format when scheme is 'bearer'
|
|
2570
|
-
*/
|
|
2571
|
-
bearerFormat?: string;
|
|
2572
|
-
/**
|
|
2573
|
-
* Description of the scheme
|
|
2574
|
-
*/
|
|
2575
|
-
description?: string;
|
|
2576
|
-
/**
|
|
2577
|
-
* Constructor for HttpScheme
|
|
2578
|
-
*/
|
|
2579
|
-
constructor(config: {
|
|
2580
|
-
scheme: "basic" | "bearer" | "digest" | "other";
|
|
2581
|
-
bearerFormat?: string;
|
|
2582
|
-
description?: string;
|
|
2583
|
-
});
|
|
2584
|
-
}
|
|
2585
|
-
/**
|
|
2586
|
-
* OAuth flow configuration
|
|
2587
|
-
*/
|
|
2588
|
-
interface OAuthFlow {
|
|
2589
|
-
authorizationUrl?: string;
|
|
2590
|
-
tokenUrl?: string;
|
|
2591
|
-
refreshUrl?: string;
|
|
2592
|
-
scopes: Record<string, string>;
|
|
2593
|
-
}
|
|
2594
|
-
/**
|
|
2595
|
-
* OAuth flows configuration
|
|
2596
|
-
*/
|
|
2597
|
-
interface OAuthFlows {
|
|
2598
|
-
implicit?: OAuthFlow;
|
|
2599
|
-
password?: OAuthFlow;
|
|
2600
|
-
clientCredentials?: OAuthFlow;
|
|
2601
|
-
authorizationCode?: OAuthFlow;
|
|
2602
|
-
}
|
|
2603
|
-
/**
|
|
2604
|
-
* OAuth2 authentication scheme
|
|
2605
|
-
*/
|
|
2606
|
-
declare class OAuth2Scheme extends AuthScheme {
|
|
2607
|
-
/**
|
|
2608
|
-
* OAuth flows
|
|
2609
|
-
*/
|
|
2610
|
-
flows: OAuthFlows;
|
|
2611
|
-
/**
|
|
2612
|
-
* Description of the scheme
|
|
2613
|
-
*/
|
|
2614
|
-
description?: string;
|
|
2615
|
-
/**
|
|
2616
|
-
* Constructor for OAuth2Scheme
|
|
2617
|
-
*/
|
|
2618
|
-
constructor(config: {
|
|
2619
|
-
flows: OAuthFlows;
|
|
2620
|
-
description?: string;
|
|
2621
|
-
});
|
|
2622
|
-
}
|
|
2623
|
-
/**
|
|
2624
|
-
* OpenID Connect authentication scheme
|
|
2625
|
-
*/
|
|
2626
|
-
declare class OpenIdConnectScheme extends AuthScheme {
|
|
2627
|
-
/**
|
|
2628
|
-
* OpenID Connect URL
|
|
2629
|
-
*/
|
|
2630
|
-
openIdConnectUrl: string;
|
|
2631
|
-
/**
|
|
2632
|
-
* Description of the scheme
|
|
2633
|
-
*/
|
|
2634
|
-
description?: string;
|
|
2635
|
-
/**
|
|
2636
|
-
* Constructor for OpenIdConnectScheme
|
|
2637
|
-
*/
|
|
2638
|
-
constructor(config: {
|
|
2639
|
-
openIdConnectUrl: string;
|
|
2640
|
-
description?: string;
|
|
2641
|
-
});
|
|
2642
|
-
}
|
|
2643
|
-
|
|
2644
|
-
/**
|
|
2645
|
-
* Authentication configuration for tools
|
|
2646
|
-
*/
|
|
2647
|
-
declare class AuthConfig {
|
|
2807
|
+
* Convert ADK tools to AI SDK tools format
|
|
2808
|
+
*/
|
|
2809
|
+
private convertToAiSdkTools;
|
|
2648
2810
|
/**
|
|
2649
|
-
*
|
|
2811
|
+
* Convert ADK Content to AI SDK CoreMessage
|
|
2650
2812
|
*/
|
|
2651
|
-
|
|
2813
|
+
private contentToAiSdkMessage;
|
|
2652
2814
|
/**
|
|
2653
|
-
*
|
|
2815
|
+
* Map ADK role to AI SDK role
|
|
2654
2816
|
*/
|
|
2655
|
-
|
|
2817
|
+
private mapRole;
|
|
2656
2818
|
/**
|
|
2657
|
-
*
|
|
2819
|
+
* Map AI SDK finish reason to ADK finish reason
|
|
2658
2820
|
*/
|
|
2659
|
-
|
|
2660
|
-
authScheme: AuthScheme;
|
|
2661
|
-
context?: Record<string, any>;
|
|
2662
|
-
});
|
|
2821
|
+
private mapFinishReason;
|
|
2663
2822
|
}
|
|
2664
2823
|
|
|
2665
2824
|
/**
|
|
2666
|
-
*
|
|
2825
|
+
* Type for LLM constructor with static methods
|
|
2667
2826
|
*/
|
|
2668
|
-
|
|
2827
|
+
interface LLMClass {
|
|
2828
|
+
new (model: string): BaseLlm;
|
|
2829
|
+
supportedModels(): string[];
|
|
2830
|
+
}
|
|
2831
|
+
/**
|
|
2832
|
+
* Registry for LLMs
|
|
2833
|
+
*/
|
|
2834
|
+
declare class LLMRegistry {
|
|
2669
2835
|
/**
|
|
2670
|
-
*
|
|
2836
|
+
* Map of model name regex to LLM class
|
|
2671
2837
|
*/
|
|
2672
|
-
|
|
2838
|
+
private static llmRegistry;
|
|
2839
|
+
private static logger;
|
|
2673
2840
|
/**
|
|
2674
|
-
*
|
|
2841
|
+
* Creates a new LLM instance
|
|
2842
|
+
*
|
|
2843
|
+
* @param model The model name
|
|
2844
|
+
* @returns The LLM instance
|
|
2675
2845
|
*/
|
|
2676
|
-
|
|
2846
|
+
static newLLM(model: string): BaseLlm;
|
|
2677
2847
|
/**
|
|
2678
|
-
*
|
|
2848
|
+
* Resolves the LLM class from the model name
|
|
2849
|
+
*
|
|
2850
|
+
* @param model The model name
|
|
2851
|
+
* @returns The LLM class
|
|
2679
2852
|
*/
|
|
2680
|
-
|
|
2681
|
-
authConfig: AuthConfig;
|
|
2682
|
-
credential?: AuthCredential;
|
|
2683
|
-
});
|
|
2853
|
+
static resolve(model: string): LLMClass | null;
|
|
2684
2854
|
/**
|
|
2685
|
-
*
|
|
2855
|
+
* Registers a new LLM class
|
|
2856
|
+
*
|
|
2857
|
+
* @param modelNameRegex The regex to match model names
|
|
2858
|
+
* @param llmClass The LLM class
|
|
2686
2859
|
*/
|
|
2687
|
-
|
|
2860
|
+
static register(modelNameRegex: string, llmClass: LLMClass): void;
|
|
2688
2861
|
/**
|
|
2689
|
-
*
|
|
2862
|
+
* Registers all model patterns from an LLM class
|
|
2863
|
+
*
|
|
2864
|
+
* @param llmClass The LLM class
|
|
2690
2865
|
*/
|
|
2691
|
-
|
|
2866
|
+
static registerLLM(llmClass: LLMClass): void;
|
|
2692
2867
|
/**
|
|
2693
|
-
*
|
|
2868
|
+
* Logs all registered models for debugging
|
|
2694
2869
|
*/
|
|
2695
|
-
|
|
2870
|
+
static logRegisteredModels(): void;
|
|
2696
2871
|
}
|
|
2697
2872
|
|
|
2698
2873
|
/**
|
|
2699
|
-
*
|
|
2700
|
-
*/
|
|
2701
|
-
declare abstract class BaseLlmRequestProcessor {
|
|
2702
|
-
/**
|
|
2703
|
-
* Runs the processor on the given invocation context and LLM request.
|
|
2704
|
-
* @param invocationContext The invocation context
|
|
2705
|
-
* @param llmRequest The LLM request to process
|
|
2706
|
-
* @returns An async generator yielding events
|
|
2707
|
-
*/
|
|
2708
|
-
abstract runAsync(invocationContext: InvocationContext, llmRequest: LlmRequest): AsyncGenerator<Event, void, unknown>;
|
|
2709
|
-
}
|
|
2710
|
-
/**
|
|
2711
|
-
* Base class for LLM response processors.
|
|
2874
|
+
* Register all LLM providers
|
|
2712
2875
|
*/
|
|
2713
|
-
declare
|
|
2714
|
-
/**
|
|
2715
|
-
* Processes the LLM response.
|
|
2716
|
-
* @param invocationContext The invocation context
|
|
2717
|
-
* @param llmResponse The LLM response to process
|
|
2718
|
-
* @returns An async generator yielding events
|
|
2719
|
-
*/
|
|
2720
|
-
abstract runAsync(invocationContext: InvocationContext, llmResponse: LlmResponse): AsyncGenerator<Event, void, unknown>;
|
|
2721
|
-
}
|
|
2876
|
+
declare function registerProviders(): void;
|
|
2722
2877
|
|
|
2723
2878
|
/**
|
|
2724
|
-
*
|
|
2725
|
-
*
|
|
2879
|
+
* Configuration for model built-in thinking features
|
|
2880
|
+
* Compatible with google.genai.types.ThinkingConfig
|
|
2726
2881
|
*/
|
|
2727
|
-
|
|
2882
|
+
interface ThinkingConfig {
|
|
2728
2883
|
/**
|
|
2729
|
-
*
|
|
2730
|
-
* and resumes function calls that required authentication
|
|
2884
|
+
* Whether to include the thinking process in the response
|
|
2731
2885
|
*/
|
|
2732
|
-
|
|
2886
|
+
includeThinking?: boolean;
|
|
2733
2887
|
/**
|
|
2734
|
-
*
|
|
2888
|
+
* Additional thinking configuration options
|
|
2735
2889
|
*/
|
|
2736
|
-
|
|
2890
|
+
[key: string]: any;
|
|
2737
2891
|
}
|
|
2892
|
+
|
|
2738
2893
|
/**
|
|
2739
|
-
*
|
|
2894
|
+
* Authentication scheme types
|
|
2740
2895
|
*/
|
|
2741
|
-
declare
|
|
2742
|
-
|
|
2896
|
+
declare enum AuthSchemeType {
|
|
2897
|
+
APIKEY = "apiKey",
|
|
2898
|
+
HTTP = "http",
|
|
2899
|
+
OAUTH2 = "oauth2",
|
|
2900
|
+
OPENID_CONNECT = "openIdConnect"
|
|
2901
|
+
}
|
|
2743
2902
|
/**
|
|
2744
|
-
*
|
|
2745
|
-
* This extends the basic AuthConfig with raw and exchanged credentials
|
|
2903
|
+
* Base class for authentication schemes
|
|
2746
2904
|
*/
|
|
2747
|
-
declare class
|
|
2748
|
-
/**
|
|
2749
|
-
* The authentication scheme
|
|
2750
|
-
*/
|
|
2751
|
-
authScheme: AuthScheme;
|
|
2905
|
+
declare abstract class AuthScheme {
|
|
2752
2906
|
/**
|
|
2753
|
-
*
|
|
2754
|
-
* Used in auth schemes that need to exchange credentials (e.g. OAuth2, OIDC)
|
|
2907
|
+
* The type of authentication scheme
|
|
2755
2908
|
*/
|
|
2756
|
-
|
|
2909
|
+
type: AuthSchemeType;
|
|
2910
|
+
constructor(type: AuthSchemeType);
|
|
2911
|
+
}
|
|
2912
|
+
/**
|
|
2913
|
+
* API Key authentication scheme
|
|
2914
|
+
*/
|
|
2915
|
+
declare class ApiKeyScheme extends AuthScheme {
|
|
2757
2916
|
/**
|
|
2758
|
-
*
|
|
2759
|
-
* Filled by ADK and client working together
|
|
2917
|
+
* Where the API key is sent
|
|
2760
2918
|
*/
|
|
2761
|
-
|
|
2919
|
+
in: "query" | "header" | "cookie";
|
|
2762
2920
|
/**
|
|
2763
|
-
*
|
|
2921
|
+
* Name of the parameter
|
|
2764
2922
|
*/
|
|
2765
|
-
|
|
2923
|
+
name: string;
|
|
2766
2924
|
/**
|
|
2767
|
-
*
|
|
2925
|
+
* Description of the API key
|
|
2768
2926
|
*/
|
|
2769
|
-
|
|
2927
|
+
description?: string;
|
|
2770
2928
|
/**
|
|
2771
|
-
* Constructor for
|
|
2929
|
+
* Constructor for ApiKeyScheme
|
|
2772
2930
|
*/
|
|
2773
2931
|
constructor(config: {
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
credentialKey?: string;
|
|
2778
|
-
context?: Record<string, any>;
|
|
2932
|
+
in: "query" | "header" | "cookie";
|
|
2933
|
+
name: string;
|
|
2934
|
+
description?: string;
|
|
2779
2935
|
});
|
|
2780
|
-
/**
|
|
2781
|
-
* Generates a credential key based on auth scheme and raw credential
|
|
2782
|
-
* Used for saving/loading credentials from credential service
|
|
2783
|
-
*/
|
|
2784
|
-
private generateCredentialKey;
|
|
2785
|
-
/**
|
|
2786
|
-
* Gets the credential key for storage
|
|
2787
|
-
*/
|
|
2788
|
-
getCredentialKey(): string;
|
|
2789
2936
|
}
|
|
2790
2937
|
/**
|
|
2791
|
-
*
|
|
2792
|
-
* end-user credentials
|
|
2938
|
+
* HTTP authentication scheme
|
|
2793
2939
|
*/
|
|
2794
|
-
|
|
2940
|
+
declare class HttpScheme extends AuthScheme {
|
|
2795
2941
|
/**
|
|
2796
|
-
* The
|
|
2942
|
+
* The HTTP authentication scheme
|
|
2797
2943
|
*/
|
|
2798
|
-
|
|
2944
|
+
scheme: "basic" | "bearer" | "digest" | "other";
|
|
2799
2945
|
/**
|
|
2800
|
-
*
|
|
2946
|
+
* Bearer format when scheme is 'bearer'
|
|
2801
2947
|
*/
|
|
2802
|
-
|
|
2803
|
-
}
|
|
2804
|
-
/**
|
|
2805
|
-
* Auth tool for handling credential requests
|
|
2806
|
-
*/
|
|
2807
|
-
declare class AuthTool {
|
|
2948
|
+
bearerFormat?: string;
|
|
2808
2949
|
/**
|
|
2809
|
-
*
|
|
2950
|
+
* Description of the scheme
|
|
2810
2951
|
*/
|
|
2811
|
-
|
|
2812
|
-
status: string;
|
|
2813
|
-
authConfig?: AuthConfig | EnhancedAuthConfig;
|
|
2814
|
-
credentialKey?: string;
|
|
2815
|
-
}>;
|
|
2952
|
+
description?: string;
|
|
2816
2953
|
/**
|
|
2817
|
-
*
|
|
2954
|
+
* Constructor for HttpScheme
|
|
2818
2955
|
*/
|
|
2819
|
-
|
|
2956
|
+
constructor(config: {
|
|
2957
|
+
scheme: "basic" | "bearer" | "digest" | "other";
|
|
2958
|
+
bearerFormat?: string;
|
|
2959
|
+
description?: string;
|
|
2960
|
+
});
|
|
2820
2961
|
}
|
|
2821
2962
|
/**
|
|
2822
|
-
*
|
|
2823
|
-
*/
|
|
2824
|
-
declare function createAuthToolArguments(functionCallId: string, authConfig: AuthConfig | EnhancedAuthConfig): AuthToolArguments;
|
|
2825
|
-
/**
|
|
2826
|
-
* Type guard to check if an auth config is enhanced
|
|
2827
|
-
*/
|
|
2828
|
-
declare function isEnhancedAuthConfig(config: AuthConfig | EnhancedAuthConfig): config is EnhancedAuthConfig;
|
|
2829
|
-
|
|
2830
|
-
/**
|
|
2831
|
-
* Types of authentication credentials
|
|
2963
|
+
* OAuth flow configuration
|
|
2832
2964
|
*/
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
CUSTOM = "custom"
|
|
2965
|
+
interface OAuthFlow {
|
|
2966
|
+
authorizationUrl?: string;
|
|
2967
|
+
tokenUrl?: string;
|
|
2968
|
+
refreshUrl?: string;
|
|
2969
|
+
scopes: Record<string, string>;
|
|
2839
2970
|
}
|
|
2840
2971
|
/**
|
|
2841
|
-
*
|
|
2972
|
+
* OAuth flows configuration
|
|
2842
2973
|
*/
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
/**
|
|
2849
|
-
* Constructor for AuthCredential
|
|
2850
|
-
*/
|
|
2851
|
-
constructor(type: AuthCredentialType);
|
|
2852
|
-
/**
|
|
2853
|
-
* Gets the authentication token
|
|
2854
|
-
*/
|
|
2855
|
-
abstract getToken(): string | undefined;
|
|
2856
|
-
/**
|
|
2857
|
-
* Gets headers for HTTP requests
|
|
2858
|
-
*/
|
|
2859
|
-
abstract getHeaders(config: AuthConfig): Record<string, string>;
|
|
2860
|
-
/**
|
|
2861
|
-
* Whether the token can be refreshed
|
|
2862
|
-
*/
|
|
2863
|
-
canRefresh(): boolean;
|
|
2864
|
-
/**
|
|
2865
|
-
* Refreshes the token
|
|
2866
|
-
*/
|
|
2867
|
-
refresh(): Promise<void>;
|
|
2974
|
+
interface OAuthFlows {
|
|
2975
|
+
implicit?: OAuthFlow;
|
|
2976
|
+
password?: OAuthFlow;
|
|
2977
|
+
clientCredentials?: OAuthFlow;
|
|
2978
|
+
authorizationCode?: OAuthFlow;
|
|
2868
2979
|
}
|
|
2869
2980
|
/**
|
|
2870
|
-
*
|
|
2981
|
+
* OAuth2 authentication scheme
|
|
2871
2982
|
*/
|
|
2872
|
-
declare class
|
|
2873
|
-
/**
|
|
2874
|
-
* The API key
|
|
2875
|
-
*/
|
|
2876
|
-
apiKey: string;
|
|
2983
|
+
declare class OAuth2Scheme extends AuthScheme {
|
|
2877
2984
|
/**
|
|
2878
|
-
*
|
|
2985
|
+
* OAuth flows
|
|
2879
2986
|
*/
|
|
2880
|
-
|
|
2987
|
+
flows: OAuthFlows;
|
|
2881
2988
|
/**
|
|
2882
|
-
*
|
|
2989
|
+
* Description of the scheme
|
|
2883
2990
|
*/
|
|
2884
|
-
|
|
2991
|
+
description?: string;
|
|
2885
2992
|
/**
|
|
2886
|
-
*
|
|
2993
|
+
* Constructor for OAuth2Scheme
|
|
2887
2994
|
*/
|
|
2888
|
-
|
|
2995
|
+
constructor(config: {
|
|
2996
|
+
flows: OAuthFlows;
|
|
2997
|
+
description?: string;
|
|
2998
|
+
});
|
|
2889
2999
|
}
|
|
2890
3000
|
/**
|
|
2891
|
-
*
|
|
3001
|
+
* OpenID Connect authentication scheme
|
|
2892
3002
|
*/
|
|
2893
|
-
declare class
|
|
2894
|
-
/**
|
|
2895
|
-
* The username
|
|
2896
|
-
*/
|
|
2897
|
-
username: string;
|
|
2898
|
-
/**
|
|
2899
|
-
* The password
|
|
2900
|
-
*/
|
|
2901
|
-
password: string;
|
|
3003
|
+
declare class OpenIdConnectScheme extends AuthScheme {
|
|
2902
3004
|
/**
|
|
2903
|
-
*
|
|
3005
|
+
* OpenID Connect URL
|
|
2904
3006
|
*/
|
|
2905
|
-
|
|
3007
|
+
openIdConnectUrl: string;
|
|
2906
3008
|
/**
|
|
2907
|
-
*
|
|
3009
|
+
* Description of the scheme
|
|
2908
3010
|
*/
|
|
2909
|
-
|
|
3011
|
+
description?: string;
|
|
2910
3012
|
/**
|
|
2911
|
-
*
|
|
3013
|
+
* Constructor for OpenIdConnectScheme
|
|
2912
3014
|
*/
|
|
2913
|
-
|
|
3015
|
+
constructor(config: {
|
|
3016
|
+
openIdConnectUrl: string;
|
|
3017
|
+
description?: string;
|
|
3018
|
+
});
|
|
2914
3019
|
}
|
|
3020
|
+
|
|
2915
3021
|
/**
|
|
2916
|
-
*
|
|
3022
|
+
* Authentication configuration for tools
|
|
2917
3023
|
*/
|
|
2918
|
-
declare class
|
|
2919
|
-
/**
|
|
2920
|
-
* The bearer token
|
|
2921
|
-
*/
|
|
2922
|
-
token: string;
|
|
3024
|
+
declare class AuthConfig {
|
|
2923
3025
|
/**
|
|
2924
|
-
*
|
|
3026
|
+
* The authentication scheme
|
|
2925
3027
|
*/
|
|
2926
|
-
|
|
3028
|
+
authScheme: AuthScheme;
|
|
2927
3029
|
/**
|
|
2928
|
-
*
|
|
3030
|
+
* Additional context properties
|
|
2929
3031
|
*/
|
|
2930
|
-
|
|
3032
|
+
context?: Record<string, any>;
|
|
2931
3033
|
/**
|
|
2932
|
-
*
|
|
3034
|
+
* Constructor for AuthConfig
|
|
2933
3035
|
*/
|
|
2934
|
-
|
|
3036
|
+
constructor(config: {
|
|
3037
|
+
authScheme: AuthScheme;
|
|
3038
|
+
context?: Record<string, any>;
|
|
3039
|
+
});
|
|
2935
3040
|
}
|
|
3041
|
+
|
|
2936
3042
|
/**
|
|
2937
|
-
*
|
|
3043
|
+
* Handler for authentication in tools
|
|
2938
3044
|
*/
|
|
2939
|
-
declare class
|
|
2940
|
-
/**
|
|
2941
|
-
* The access token
|
|
2942
|
-
*/
|
|
2943
|
-
accessToken: string;
|
|
2944
|
-
/**
|
|
2945
|
-
* The refresh token
|
|
2946
|
-
*/
|
|
2947
|
-
refreshToken?: string;
|
|
3045
|
+
declare class AuthHandler {
|
|
2948
3046
|
/**
|
|
2949
|
-
*
|
|
3047
|
+
* The authentication configuration
|
|
2950
3048
|
*/
|
|
2951
|
-
|
|
3049
|
+
authConfig: AuthConfig;
|
|
2952
3050
|
/**
|
|
2953
|
-
*
|
|
3051
|
+
* The authentication credential
|
|
2954
3052
|
*/
|
|
2955
|
-
|
|
3053
|
+
credential?: AuthCredential;
|
|
2956
3054
|
/**
|
|
2957
|
-
* Constructor for
|
|
3055
|
+
* Constructor for AuthHandler
|
|
2958
3056
|
*/
|
|
2959
3057
|
constructor(config: {
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
expiresIn?: number;
|
|
2963
|
-
refreshFunction?: (refreshToken: string) => Promise<{
|
|
2964
|
-
accessToken: string;
|
|
2965
|
-
refreshToken?: string;
|
|
2966
|
-
expiresIn?: number;
|
|
2967
|
-
}>;
|
|
3058
|
+
authConfig: AuthConfig;
|
|
3059
|
+
credential?: AuthCredential;
|
|
2968
3060
|
});
|
|
2969
3061
|
/**
|
|
2970
|
-
* Gets the
|
|
3062
|
+
* Gets the authentication token
|
|
2971
3063
|
*/
|
|
2972
|
-
getToken(): string;
|
|
3064
|
+
getToken(): string | undefined;
|
|
2973
3065
|
/**
|
|
2974
3066
|
* Gets headers for HTTP requests
|
|
2975
3067
|
*/
|
|
2976
3068
|
getHeaders(): Record<string, string>;
|
|
2977
3069
|
/**
|
|
2978
|
-
*
|
|
2979
|
-
*/
|
|
2980
|
-
canRefresh(): boolean;
|
|
2981
|
-
/**
|
|
2982
|
-
* Whether the token is expired
|
|
2983
|
-
*/
|
|
2984
|
-
isExpired(): boolean;
|
|
2985
|
-
/**
|
|
2986
|
-
* Refreshes the token
|
|
3070
|
+
* Refreshes the token if necessary
|
|
2987
3071
|
*/
|
|
2988
|
-
|
|
2989
|
-
}
|
|
2990
|
-
|
|
2991
|
-
/**
|
|
2992
|
-
* Models module exports - consolidated to match Python structure
|
|
2993
|
-
*/
|
|
2994
|
-
|
|
2995
|
-
type index$5_AiSdkLlm = AiSdkLlm;
|
|
2996
|
-
declare const index$5_AiSdkLlm: typeof AiSdkLlm;
|
|
2997
|
-
type index$5_AnthropicLlm = AnthropicLlm;
|
|
2998
|
-
declare const index$5_AnthropicLlm: typeof AnthropicLlm;
|
|
2999
|
-
type index$5_ApiKeyCredential = ApiKeyCredential;
|
|
3000
|
-
declare const index$5_ApiKeyCredential: typeof ApiKeyCredential;
|
|
3001
|
-
type index$5_ApiKeyScheme = ApiKeyScheme;
|
|
3002
|
-
declare const index$5_ApiKeyScheme: typeof ApiKeyScheme;
|
|
3003
|
-
type index$5_AuthConfig = AuthConfig;
|
|
3004
|
-
declare const index$5_AuthConfig: typeof AuthConfig;
|
|
3005
|
-
type index$5_AuthCredential = AuthCredential;
|
|
3006
|
-
declare const index$5_AuthCredential: typeof AuthCredential;
|
|
3007
|
-
type index$5_AuthCredentialType = AuthCredentialType;
|
|
3008
|
-
declare const index$5_AuthCredentialType: typeof AuthCredentialType;
|
|
3009
|
-
type index$5_AuthHandler = AuthHandler;
|
|
3010
|
-
declare const index$5_AuthHandler: typeof AuthHandler;
|
|
3011
|
-
type index$5_AuthScheme = AuthScheme;
|
|
3012
|
-
declare const index$5_AuthScheme: typeof AuthScheme;
|
|
3013
|
-
type index$5_AuthSchemeType = AuthSchemeType;
|
|
3014
|
-
declare const index$5_AuthSchemeType: typeof AuthSchemeType;
|
|
3015
|
-
type index$5_BaseLLMConnection = BaseLLMConnection;
|
|
3016
|
-
declare const index$5_BaseLLMConnection: typeof BaseLLMConnection;
|
|
3017
|
-
type index$5_BaseLlm = BaseLlm;
|
|
3018
|
-
declare const index$5_BaseLlm: typeof BaseLlm;
|
|
3019
|
-
type index$5_BaseMemoryService = BaseMemoryService;
|
|
3020
|
-
type index$5_BasicAuthCredential = BasicAuthCredential;
|
|
3021
|
-
declare const index$5_BasicAuthCredential: typeof BasicAuthCredential;
|
|
3022
|
-
type index$5_BearerTokenCredential = BearerTokenCredential;
|
|
3023
|
-
declare const index$5_BearerTokenCredential: typeof BearerTokenCredential;
|
|
3024
|
-
declare const index$5_Blob: typeof Blob;
|
|
3025
|
-
type index$5_FunctionDeclaration = FunctionDeclaration;
|
|
3026
|
-
type index$5_GoogleLlm = GoogleLlm;
|
|
3027
|
-
declare const index$5_GoogleLlm: typeof GoogleLlm;
|
|
3028
|
-
type index$5_HttpScheme = HttpScheme;
|
|
3029
|
-
declare const index$5_HttpScheme: typeof HttpScheme;
|
|
3030
|
-
type index$5_JSONSchema = JSONSchema;
|
|
3031
|
-
type index$5_LLMRegistry = LLMRegistry;
|
|
3032
|
-
declare const index$5_LLMRegistry: typeof LLMRegistry;
|
|
3033
|
-
type index$5_LlmRequest = LlmRequest;
|
|
3034
|
-
declare const index$5_LlmRequest: typeof LlmRequest;
|
|
3035
|
-
type index$5_LlmResponse = LlmResponse;
|
|
3036
|
-
declare const index$5_LlmResponse: typeof LlmResponse;
|
|
3037
|
-
type index$5_OAuth2Credential = OAuth2Credential;
|
|
3038
|
-
declare const index$5_OAuth2Credential: typeof OAuth2Credential;
|
|
3039
|
-
type index$5_OAuth2Scheme = OAuth2Scheme;
|
|
3040
|
-
declare const index$5_OAuth2Scheme: typeof OAuth2Scheme;
|
|
3041
|
-
type index$5_OAuthFlow = OAuthFlow;
|
|
3042
|
-
type index$5_OAuthFlows = OAuthFlows;
|
|
3043
|
-
type index$5_OpenAiLlm = OpenAiLlm;
|
|
3044
|
-
declare const index$5_OpenAiLlm: typeof OpenAiLlm;
|
|
3045
|
-
type index$5_OpenIdConnectScheme = OpenIdConnectScheme;
|
|
3046
|
-
declare const index$5_OpenIdConnectScheme: typeof OpenIdConnectScheme;
|
|
3047
|
-
type index$5_SearchMemoryResponse = SearchMemoryResponse;
|
|
3048
|
-
type index$5_Session = Session;
|
|
3049
|
-
type index$5_State = State;
|
|
3050
|
-
declare const index$5_State: typeof State;
|
|
3051
|
-
type index$5_ThinkingConfig = ThinkingConfig;
|
|
3052
|
-
declare const index$5_registerProviders: typeof registerProviders;
|
|
3053
|
-
declare namespace index$5 {
|
|
3054
|
-
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 };
|
|
3072
|
+
refreshToken(): Promise<void>;
|
|
3055
3073
|
}
|
|
3056
3074
|
|
|
3057
3075
|
/**
|
|
3058
|
-
*
|
|
3076
|
+
* Base class for LLM request processors.
|
|
3059
3077
|
*/
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
content?: any;
|
|
3069
|
-
partial?: boolean;
|
|
3078
|
+
declare abstract class BaseLlmRequestProcessor {
|
|
3079
|
+
/**
|
|
3080
|
+
* Runs the processor on the given invocation context and LLM request.
|
|
3081
|
+
* @param invocationContext The invocation context
|
|
3082
|
+
* @param llmRequest The LLM request to process
|
|
3083
|
+
* @returns An async generator yielding events
|
|
3084
|
+
*/
|
|
3085
|
+
abstract runAsync(invocationContext: InvocationContext, llmRequest: LlmRequest): AsyncGenerator<Event, void, unknown>;
|
|
3070
3086
|
}
|
|
3071
3087
|
/**
|
|
3072
|
-
*
|
|
3073
|
-
* It is used to store the content of the conversation, as well as the actions
|
|
3074
|
-
* taken by the agents like function calls, etc.
|
|
3088
|
+
* Base class for LLM response processors.
|
|
3075
3089
|
*/
|
|
3076
|
-
declare class
|
|
3077
|
-
/** The invocation ID of the event. */
|
|
3078
|
-
invocationId: string;
|
|
3079
|
-
/** 'user' or the name of the agent, indicating who appended the event to the session. */
|
|
3080
|
-
author: string;
|
|
3081
|
-
/** The actions taken by the agent. */
|
|
3082
|
-
actions: EventActions;
|
|
3083
|
-
/**
|
|
3084
|
-
* Set of ids of the long running function calls.
|
|
3085
|
-
* Agent client will know from this field about which function call is long running.
|
|
3086
|
-
* Only valid for function call event.
|
|
3087
|
-
*/
|
|
3088
|
-
longRunningToolIds?: Set<string>;
|
|
3089
|
-
/**
|
|
3090
|
-
* The branch of the event.
|
|
3091
|
-
* The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of
|
|
3092
|
-
* agent_2, and agent_2 is the parent of agent_3. Branch is used when multiple
|
|
3093
|
-
* sub-agents shouldn't see their peer agents' conversation history.
|
|
3094
|
-
*/
|
|
3095
|
-
branch?: string;
|
|
3096
|
-
/** The unique identifier of the event. */
|
|
3097
|
-
id: string;
|
|
3098
|
-
/** The timestamp of the event (seconds since epoch). */
|
|
3099
|
-
timestamp: number;
|
|
3100
|
-
/**
|
|
3101
|
-
* Constructor for Event.
|
|
3102
|
-
*/
|
|
3103
|
-
constructor(opts: EventOpts);
|
|
3104
|
-
/**
|
|
3105
|
-
* Returns whether the event is the final response of the agent.
|
|
3106
|
-
*/
|
|
3107
|
-
isFinalResponse(): boolean;
|
|
3108
|
-
/**
|
|
3109
|
-
* Returns the function calls in the event.
|
|
3110
|
-
*/
|
|
3111
|
-
getFunctionCalls(): any[];
|
|
3112
|
-
/**
|
|
3113
|
-
* Returns the function responses in the event.
|
|
3114
|
-
*/
|
|
3115
|
-
getFunctionResponses(): any[];
|
|
3116
|
-
/**
|
|
3117
|
-
* Returns whether the event has a trailing code execution result.
|
|
3118
|
-
*/
|
|
3119
|
-
hasTrailingCodeExecutionResult(): boolean;
|
|
3090
|
+
declare abstract class BaseLlmResponseProcessor {
|
|
3120
3091
|
/**
|
|
3121
|
-
*
|
|
3092
|
+
* Processes the LLM response.
|
|
3093
|
+
* @param invocationContext The invocation context
|
|
3094
|
+
* @param llmResponse The LLM response to process
|
|
3095
|
+
* @returns An async generator yielding events
|
|
3122
3096
|
*/
|
|
3123
|
-
|
|
3097
|
+
abstract runAsync(invocationContext: InvocationContext, llmResponse: LlmResponse): AsyncGenerator<Event, void, unknown>;
|
|
3124
3098
|
}
|
|
3125
3099
|
|
|
3126
3100
|
/**
|
|
3127
|
-
*
|
|
3128
|
-
|
|
3129
|
-
type SingleAgentCallback = (callbackContext: CallbackContext) => Promise<Content$1 | undefined> | Content$1 | undefined;
|
|
3130
|
-
/**
|
|
3131
|
-
* Before agent callback type
|
|
3101
|
+
* Auth LLM request processor that handles authentication information
|
|
3102
|
+
* to build the LLM request with credential processing
|
|
3132
3103
|
*/
|
|
3133
|
-
|
|
3104
|
+
declare class AuthLlmRequestProcessor extends BaseLlmRequestProcessor {
|
|
3105
|
+
/**
|
|
3106
|
+
* Processes authentication information from session events
|
|
3107
|
+
* and resumes function calls that required authentication
|
|
3108
|
+
*/
|
|
3109
|
+
runAsync(invocationContext: InvocationContext, llmRequest: LlmRequest): AsyncGenerator<Event>;
|
|
3110
|
+
/**
|
|
3111
|
+
* Parses and stores authentication response in session state
|
|
3112
|
+
*/
|
|
3113
|
+
private parseAndStoreAuthResponse;
|
|
3114
|
+
}
|
|
3134
3115
|
/**
|
|
3135
|
-
*
|
|
3116
|
+
* Exported request processor instance for use in flow configurations
|
|
3136
3117
|
*/
|
|
3137
|
-
|
|
3118
|
+
declare const requestProcessor$7: AuthLlmRequestProcessor;
|
|
3119
|
+
|
|
3138
3120
|
/**
|
|
3139
|
-
*
|
|
3121
|
+
* Enhanced auth configuration with credential handling
|
|
3122
|
+
* This extends the basic AuthConfig with raw and exchanged credentials
|
|
3140
3123
|
*/
|
|
3141
|
-
declare
|
|
3142
|
-
/**
|
|
3143
|
-
* The agent's name.
|
|
3144
|
-
* Agent name must be a valid identifier and unique within the agent tree.
|
|
3145
|
-
* Agent name cannot be "user", since it's reserved for end-user's input.
|
|
3146
|
-
*/
|
|
3147
|
-
name: string;
|
|
3124
|
+
declare class EnhancedAuthConfig {
|
|
3148
3125
|
/**
|
|
3149
|
-
*
|
|
3150
|
-
* The model uses this to determine whether to delegate control to the agent.
|
|
3151
|
-
* One-line description is enough and preferred.
|
|
3126
|
+
* The authentication scheme
|
|
3152
3127
|
*/
|
|
3153
|
-
|
|
3128
|
+
authScheme: AuthScheme;
|
|
3154
3129
|
/**
|
|
3155
|
-
*
|
|
3156
|
-
*
|
|
3157
|
-
* If you want to add one agent twice as sub-agent, consider to create two agent
|
|
3158
|
-
* instances with identical config, but with different name and add them to the
|
|
3159
|
-
* agent tree.
|
|
3130
|
+
* Raw auth credential used to collect credentials
|
|
3131
|
+
* Used in auth schemes that need to exchange credentials (e.g. OAuth2, OIDC)
|
|
3160
3132
|
*/
|
|
3161
|
-
|
|
3133
|
+
rawAuthCredential?: AuthCredential;
|
|
3162
3134
|
/**
|
|
3163
|
-
*
|
|
3135
|
+
* Exchanged auth credential after processing
|
|
3136
|
+
* Filled by ADK and client working together
|
|
3164
3137
|
*/
|
|
3165
|
-
|
|
3138
|
+
exchangedAuthCredential?: AuthCredential;
|
|
3166
3139
|
/**
|
|
3167
|
-
*
|
|
3168
|
-
* When a list of callbacks is provided, the callbacks will be called in the
|
|
3169
|
-
* order they are listed until a callback does not return undefined.
|
|
3170
|
-
*
|
|
3171
|
-
* Args:
|
|
3172
|
-
* callbackContext: The callback context.
|
|
3173
|
-
*
|
|
3174
|
-
* Returns:
|
|
3175
|
-
* Content | undefined: The content to return to the user.
|
|
3176
|
-
* When the content is present, the agent run will be skipped and the
|
|
3177
|
-
* provided content will be returned to user.
|
|
3140
|
+
* User-specified key for credential storage and retrieval
|
|
3178
3141
|
*/
|
|
3179
|
-
|
|
3142
|
+
credentialKey?: string;
|
|
3180
3143
|
/**
|
|
3181
|
-
*
|
|
3182
|
-
* When a list of callbacks is provided, the callbacks will be called in the
|
|
3183
|
-
* order they are listed until a callback does not return undefined.
|
|
3184
|
-
*
|
|
3185
|
-
* Args:
|
|
3186
|
-
* callbackContext: The callback context.
|
|
3187
|
-
*
|
|
3188
|
-
* Returns:
|
|
3189
|
-
* Content | undefined: The content to return to the user.
|
|
3190
|
-
* When the content is present, the provided content will be used as agent
|
|
3191
|
-
* response and appended to event history as agent response.
|
|
3144
|
+
* Additional context properties
|
|
3192
3145
|
*/
|
|
3193
|
-
|
|
3146
|
+
context?: Record<string, any>;
|
|
3194
3147
|
/**
|
|
3195
|
-
* Constructor for
|
|
3148
|
+
* Constructor for EnhancedAuthConfig
|
|
3196
3149
|
*/
|
|
3197
3150
|
constructor(config: {
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3151
|
+
authScheme: AuthScheme;
|
|
3152
|
+
rawAuthCredential?: AuthCredential;
|
|
3153
|
+
exchangedAuthCredential?: AuthCredential;
|
|
3154
|
+
credentialKey?: string;
|
|
3155
|
+
context?: Record<string, any>;
|
|
3203
3156
|
});
|
|
3204
3157
|
/**
|
|
3205
|
-
*
|
|
3206
|
-
|
|
3207
|
-
runAsync(parentContext: InvocationContext): AsyncGenerator<Event, void, unknown>;
|
|
3208
|
-
/**
|
|
3209
|
-
* Entry method to run an agent via video/audio-based conversation.
|
|
3210
|
-
*/
|
|
3211
|
-
runLive(parentContext: InvocationContext): AsyncGenerator<Event, void, unknown>;
|
|
3212
|
-
/**
|
|
3213
|
-
* Internal implementation for runAsync
|
|
3214
|
-
*/
|
|
3215
|
-
private runAsyncInternal;
|
|
3216
|
-
/**
|
|
3217
|
-
* Internal implementation for runLive
|
|
3218
|
-
*/
|
|
3219
|
-
private runLiveInternal;
|
|
3220
|
-
/**
|
|
3221
|
-
* Core logic to run this agent via text-based conversation.
|
|
3222
|
-
*
|
|
3223
|
-
* @param ctx - The invocation context for this agent.
|
|
3224
|
-
* @yields Event - The events generated by the agent.
|
|
3158
|
+
* Generates a credential key based on auth scheme and raw credential
|
|
3159
|
+
* Used for saving/loading credentials from credential service
|
|
3225
3160
|
*/
|
|
3226
|
-
|
|
3161
|
+
private generateCredentialKey;
|
|
3227
3162
|
/**
|
|
3228
|
-
*
|
|
3229
|
-
*
|
|
3230
|
-
* @param ctx - The invocation context for this agent.
|
|
3231
|
-
* @yields Event - The events generated by the agent.
|
|
3163
|
+
* Gets the credential key for storage
|
|
3232
3164
|
*/
|
|
3233
|
-
|
|
3165
|
+
getCredentialKey(): string;
|
|
3166
|
+
}
|
|
3167
|
+
/**
|
|
3168
|
+
* Arguments for the special long-running function tool used to request
|
|
3169
|
+
* end-user credentials
|
|
3170
|
+
*/
|
|
3171
|
+
interface AuthToolArguments extends Record<string, unknown> {
|
|
3234
3172
|
/**
|
|
3235
|
-
*
|
|
3173
|
+
* The ID of the function call that requires authentication
|
|
3236
3174
|
*/
|
|
3237
|
-
|
|
3175
|
+
function_call_id: string;
|
|
3238
3176
|
/**
|
|
3239
|
-
*
|
|
3240
|
-
*
|
|
3241
|
-
* @param name - The name of the agent to find.
|
|
3242
|
-
* @returns The agent with the matching name, or undefined if no such agent is found.
|
|
3177
|
+
* The authentication configuration
|
|
3243
3178
|
*/
|
|
3244
|
-
|
|
3179
|
+
auth_config: AuthConfig | EnhancedAuthConfig;
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* Auth tool for handling credential requests
|
|
3183
|
+
*/
|
|
3184
|
+
declare class AuthTool {
|
|
3245
3185
|
/**
|
|
3246
|
-
*
|
|
3247
|
-
*
|
|
3248
|
-
* @param name - The name of the agent to find.
|
|
3249
|
-
* @returns The agent with the matching name, or undefined if no such agent is found.
|
|
3186
|
+
* Processes auth tool arguments and returns appropriate response
|
|
3250
3187
|
*/
|
|
3251
|
-
|
|
3188
|
+
static processAuthRequest(args: AuthToolArguments): Promise<{
|
|
3189
|
+
status: string;
|
|
3190
|
+
authConfig?: AuthConfig | EnhancedAuthConfig;
|
|
3191
|
+
credentialKey?: string;
|
|
3192
|
+
}>;
|
|
3252
3193
|
/**
|
|
3253
|
-
*
|
|
3194
|
+
* Validates auth tool arguments
|
|
3254
3195
|
*/
|
|
3255
|
-
|
|
3196
|
+
static validateAuthArguments(args: any): args is AuthToolArguments;
|
|
3197
|
+
}
|
|
3198
|
+
/**
|
|
3199
|
+
* Creates an AuthToolArguments object with proper typing
|
|
3200
|
+
*/
|
|
3201
|
+
declare function createAuthToolArguments(functionCallId: string, authConfig: AuthConfig | EnhancedAuthConfig): AuthToolArguments;
|
|
3202
|
+
/**
|
|
3203
|
+
* Type guard to check if an auth config is enhanced
|
|
3204
|
+
*/
|
|
3205
|
+
declare function isEnhancedAuthConfig(config: AuthConfig | EnhancedAuthConfig): config is EnhancedAuthConfig;
|
|
3206
|
+
|
|
3207
|
+
/**
|
|
3208
|
+
* Types of authentication credentials
|
|
3209
|
+
*/
|
|
3210
|
+
declare enum AuthCredentialType {
|
|
3211
|
+
API_KEY = "api_key",
|
|
3212
|
+
BASIC = "basic",
|
|
3213
|
+
BEARER = "bearer",
|
|
3214
|
+
OAUTH2 = "oauth2",
|
|
3215
|
+
CUSTOM = "custom"
|
|
3216
|
+
}
|
|
3217
|
+
/**
|
|
3218
|
+
* Base class for authentication credentials
|
|
3219
|
+
*/
|
|
3220
|
+
declare abstract class AuthCredential {
|
|
3256
3221
|
/**
|
|
3257
|
-
*
|
|
3258
|
-
* This method is only for use by Agent Development Kit.
|
|
3222
|
+
* Type of credential
|
|
3259
3223
|
*/
|
|
3260
|
-
|
|
3224
|
+
type: AuthCredentialType;
|
|
3261
3225
|
/**
|
|
3262
|
-
*
|
|
3263
|
-
* This method is only for use by Agent Development Kit.
|
|
3226
|
+
* Constructor for AuthCredential
|
|
3264
3227
|
*/
|
|
3265
|
-
|
|
3228
|
+
constructor(type: AuthCredentialType);
|
|
3266
3229
|
/**
|
|
3267
|
-
*
|
|
3268
|
-
*
|
|
3269
|
-
* @returns An event if callback provides content or changed state.
|
|
3230
|
+
* Gets the authentication token
|
|
3270
3231
|
*/
|
|
3271
|
-
|
|
3232
|
+
abstract getToken(): string | undefined;
|
|
3272
3233
|
/**
|
|
3273
|
-
*
|
|
3274
|
-
*
|
|
3275
|
-
* @returns An event if callback provides content or changed state.
|
|
3234
|
+
* Gets headers for HTTP requests
|
|
3276
3235
|
*/
|
|
3277
|
-
|
|
3236
|
+
abstract getHeaders(config: AuthConfig): Record<string, string>;
|
|
3278
3237
|
/**
|
|
3279
|
-
*
|
|
3238
|
+
* Whether the token can be refreshed
|
|
3280
3239
|
*/
|
|
3281
|
-
|
|
3240
|
+
canRefresh(): boolean;
|
|
3282
3241
|
/**
|
|
3283
|
-
*
|
|
3242
|
+
* Refreshes the token
|
|
3284
3243
|
*/
|
|
3285
|
-
|
|
3286
|
-
}
|
|
3287
|
-
|
|
3288
|
-
interface File {
|
|
3289
|
-
/** The name of the file with file extension (e.g., "file.csv") */
|
|
3290
|
-
name: string;
|
|
3291
|
-
/** The base64-encoded bytes of the file content */
|
|
3292
|
-
content: string;
|
|
3293
|
-
/** The mime type of the file (e.g., "image/png") */
|
|
3294
|
-
mimeType: string;
|
|
3295
|
-
}
|
|
3296
|
-
interface CodeExecutionInput {
|
|
3297
|
-
/** The code to execute */
|
|
3298
|
-
code: string;
|
|
3299
|
-
/** The input files available to the code */
|
|
3300
|
-
inputFiles: File[];
|
|
3301
|
-
/** The execution ID for the stateful code execution */
|
|
3302
|
-
executionId?: string;
|
|
3303
|
-
}
|
|
3304
|
-
interface CodeExecutionResult {
|
|
3305
|
-
/** The standard output of the code execution */
|
|
3306
|
-
stdout: string;
|
|
3307
|
-
/** The standard error of the code execution */
|
|
3308
|
-
stderr: string;
|
|
3309
|
-
/** The output files from the code execution */
|
|
3310
|
-
outputFiles: File[];
|
|
3244
|
+
refresh(): Promise<void>;
|
|
3311
3245
|
}
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
static getEncodedFileContent(data: string | ArrayBuffer): string;
|
|
3317
|
-
private static isBase64Encoded;
|
|
3246
|
+
/**
|
|
3247
|
+
* API Key credential
|
|
3248
|
+
*/
|
|
3249
|
+
declare class ApiKeyCredential extends AuthCredential {
|
|
3318
3250
|
/**
|
|
3319
|
-
*
|
|
3251
|
+
* The API key
|
|
3320
3252
|
*/
|
|
3321
|
-
|
|
3322
|
-
private static escapeRegex;
|
|
3253
|
+
apiKey: string;
|
|
3323
3254
|
/**
|
|
3324
|
-
*
|
|
3255
|
+
* Constructor for ApiKeyCredential
|
|
3325
3256
|
*/
|
|
3326
|
-
|
|
3257
|
+
constructor(apiKey: string);
|
|
3327
3258
|
/**
|
|
3328
|
-
*
|
|
3259
|
+
* Gets the API key as the token
|
|
3329
3260
|
*/
|
|
3330
|
-
|
|
3261
|
+
getToken(): string;
|
|
3331
3262
|
/**
|
|
3332
|
-
*
|
|
3263
|
+
* Gets headers for HTTP requests
|
|
3333
3264
|
*/
|
|
3334
|
-
|
|
3265
|
+
getHeaders(config: AuthConfig): Record<string, string>;
|
|
3335
3266
|
}
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
* and attach them to the code executor.
|
|
3341
|
-
* Supported data file MimeTypes are [text/csv].
|
|
3342
|
-
* Default to false.
|
|
3343
|
-
*/
|
|
3344
|
-
optimizeDataFile?: boolean;
|
|
3267
|
+
/**
|
|
3268
|
+
* Basic authentication credential
|
|
3269
|
+
*/
|
|
3270
|
+
declare class BasicAuthCredential extends AuthCredential {
|
|
3345
3271
|
/**
|
|
3346
|
-
*
|
|
3272
|
+
* The username
|
|
3347
3273
|
*/
|
|
3348
|
-
|
|
3274
|
+
username: string;
|
|
3349
3275
|
/**
|
|
3350
|
-
* The
|
|
3351
|
-
* Default to 2.
|
|
3276
|
+
* The password
|
|
3352
3277
|
*/
|
|
3353
|
-
|
|
3278
|
+
password: string;
|
|
3354
3279
|
/**
|
|
3355
|
-
*
|
|
3356
|
-
* For example, the delimiter ['```python\n', '\n```'] can be
|
|
3357
|
-
* used to identify code blocks with the following format:
|
|
3358
|
-
*
|
|
3359
|
-
* ```python
|
|
3360
|
-
* print("hello")
|
|
3361
|
-
* ```
|
|
3280
|
+
* Constructor for BasicAuthCredential
|
|
3362
3281
|
*/
|
|
3363
|
-
|
|
3282
|
+
constructor(username: string, password: string);
|
|
3364
3283
|
/**
|
|
3365
|
-
*
|
|
3284
|
+
* Gets the encoded basic auth token
|
|
3366
3285
|
*/
|
|
3367
|
-
|
|
3368
|
-
}
|
|
3369
|
-
declare abstract class BaseCodeExecutor {
|
|
3370
|
-
protected readonly config: Required<BaseCodeExecutorConfig>;
|
|
3371
|
-
constructor(config?: BaseCodeExecutorConfig);
|
|
3286
|
+
getToken(): string;
|
|
3372
3287
|
/**
|
|
3373
|
-
*
|
|
3288
|
+
* Gets headers for HTTP requests
|
|
3374
3289
|
*/
|
|
3375
|
-
|
|
3376
|
-
get optimizeDataFile(): boolean;
|
|
3377
|
-
get stateful(): boolean;
|
|
3378
|
-
get errorRetryAttempts(): number;
|
|
3379
|
-
get codeBlockDelimiters(): Array<[string, string]>;
|
|
3380
|
-
get executionResultDelimiters(): [string, string];
|
|
3290
|
+
getHeaders(): Record<string, string>;
|
|
3381
3291
|
}
|
|
3382
|
-
|
|
3383
3292
|
/**
|
|
3384
|
-
*
|
|
3385
|
-
*
|
|
3386
|
-
* The planner allows the agent to generate plans for the queries to guide its action.
|
|
3293
|
+
* Bearer token credential
|
|
3387
3294
|
*/
|
|
3388
|
-
declare
|
|
3295
|
+
declare class BearerTokenCredential extends AuthCredential {
|
|
3389
3296
|
/**
|
|
3390
|
-
*
|
|
3391
|
-
*
|
|
3392
|
-
* @param readonlyContext The readonly context of the invocation
|
|
3393
|
-
* @param llmRequest The LLM request. Readonly.
|
|
3394
|
-
* @returns The planning system instruction, or undefined if no instruction is needed
|
|
3297
|
+
* The bearer token
|
|
3395
3298
|
*/
|
|
3396
|
-
|
|
3299
|
+
token: string;
|
|
3397
3300
|
/**
|
|
3398
|
-
*
|
|
3399
|
-
*
|
|
3400
|
-
* @param callbackContext The callback context of the invocation
|
|
3401
|
-
* @param responseParts The LLM response parts. Readonly.
|
|
3402
|
-
* @returns The processed response parts, or undefined if no processing is needed
|
|
3301
|
+
* Constructor for BearerTokenCredential
|
|
3403
3302
|
*/
|
|
3404
|
-
|
|
3405
|
-
}
|
|
3406
|
-
|
|
3407
|
-
/**
|
|
3408
|
-
* Type for instruction providers that can be functions
|
|
3409
|
-
*/
|
|
3410
|
-
type InstructionProvider = (ctx: ReadonlyContext) => string | Promise<string>;
|
|
3411
|
-
/**
|
|
3412
|
-
* Union type for tools (supporting functions, tools, and toolsets)
|
|
3413
|
-
*/
|
|
3414
|
-
type ToolUnion = BaseTool | ((...args: any[]) => any);
|
|
3415
|
-
/**
|
|
3416
|
-
* Configuration for LlmAgent
|
|
3417
|
-
*/
|
|
3418
|
-
interface LlmAgentConfig<T extends BaseLlm = BaseLlm> {
|
|
3303
|
+
constructor(token: string);
|
|
3419
3304
|
/**
|
|
3420
|
-
*
|
|
3305
|
+
* Gets the bearer token
|
|
3421
3306
|
*/
|
|
3422
|
-
|
|
3307
|
+
getToken(): string;
|
|
3423
3308
|
/**
|
|
3424
|
-
*
|
|
3309
|
+
* Gets headers for HTTP requests
|
|
3425
3310
|
*/
|
|
3426
|
-
|
|
3311
|
+
getHeaders(): Record<string, string>;
|
|
3312
|
+
}
|
|
3313
|
+
/**
|
|
3314
|
+
* OAuth2 token credential with refresh capability
|
|
3315
|
+
*/
|
|
3316
|
+
declare class OAuth2Credential extends AuthCredential {
|
|
3427
3317
|
/**
|
|
3428
|
-
* The
|
|
3429
|
-
* When not set, the agent will inherit the model from its ancestor
|
|
3318
|
+
* The access token
|
|
3430
3319
|
*/
|
|
3431
|
-
|
|
3320
|
+
accessToken: string;
|
|
3432
3321
|
/**
|
|
3433
|
-
*
|
|
3322
|
+
* The refresh token
|
|
3434
3323
|
*/
|
|
3435
|
-
|
|
3324
|
+
refreshToken?: string;
|
|
3436
3325
|
/**
|
|
3437
|
-
*
|
|
3438
|
-
* ONLY the global_instruction in root agent will take effect
|
|
3326
|
+
* When the token expires
|
|
3439
3327
|
*/
|
|
3440
|
-
|
|
3328
|
+
expiresAt?: Date;
|
|
3441
3329
|
/**
|
|
3442
|
-
*
|
|
3330
|
+
* Function to refresh the token
|
|
3443
3331
|
*/
|
|
3444
|
-
|
|
3332
|
+
private refreshFunction?;
|
|
3445
3333
|
/**
|
|
3446
|
-
*
|
|
3334
|
+
* Constructor for OAuth2Credential
|
|
3447
3335
|
*/
|
|
3448
|
-
|
|
3336
|
+
constructor(config: {
|
|
3337
|
+
accessToken: string;
|
|
3338
|
+
refreshToken?: string;
|
|
3339
|
+
expiresIn?: number;
|
|
3340
|
+
refreshFunction?: (refreshToken: string) => Promise<{
|
|
3341
|
+
accessToken: string;
|
|
3342
|
+
refreshToken?: string;
|
|
3343
|
+
expiresIn?: number;
|
|
3344
|
+
}>;
|
|
3345
|
+
});
|
|
3449
3346
|
/**
|
|
3450
|
-
*
|
|
3347
|
+
* Gets the access token
|
|
3451
3348
|
*/
|
|
3452
|
-
|
|
3349
|
+
getToken(): string;
|
|
3453
3350
|
/**
|
|
3454
|
-
*
|
|
3351
|
+
* Gets headers for HTTP requests
|
|
3455
3352
|
*/
|
|
3456
|
-
|
|
3353
|
+
getHeaders(): Record<string, string>;
|
|
3457
3354
|
/**
|
|
3458
|
-
* Whether
|
|
3355
|
+
* Whether the token can be refreshed
|
|
3459
3356
|
*/
|
|
3460
|
-
|
|
3357
|
+
canRefresh(): boolean;
|
|
3461
3358
|
/**
|
|
3462
|
-
*
|
|
3359
|
+
* Whether the token is expired
|
|
3463
3360
|
*/
|
|
3464
|
-
|
|
3361
|
+
isExpired(): boolean;
|
|
3465
3362
|
/**
|
|
3466
|
-
*
|
|
3363
|
+
* Refreshes the token
|
|
3467
3364
|
*/
|
|
3468
|
-
|
|
3365
|
+
refresh(): Promise<void>;
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3368
|
+
/**
|
|
3369
|
+
* Models module exports - consolidated to match Python structure
|
|
3370
|
+
*/
|
|
3371
|
+
|
|
3372
|
+
type index$5_AiSdkLlm = AiSdkLlm;
|
|
3373
|
+
declare const index$5_AiSdkLlm: typeof AiSdkLlm;
|
|
3374
|
+
type index$5_AnthropicLlm = AnthropicLlm;
|
|
3375
|
+
declare const index$5_AnthropicLlm: typeof AnthropicLlm;
|
|
3376
|
+
type index$5_ApiKeyCredential = ApiKeyCredential;
|
|
3377
|
+
declare const index$5_ApiKeyCredential: typeof ApiKeyCredential;
|
|
3378
|
+
type index$5_ApiKeyScheme = ApiKeyScheme;
|
|
3379
|
+
declare const index$5_ApiKeyScheme: typeof ApiKeyScheme;
|
|
3380
|
+
type index$5_AuthConfig = AuthConfig;
|
|
3381
|
+
declare const index$5_AuthConfig: typeof AuthConfig;
|
|
3382
|
+
type index$5_AuthCredential = AuthCredential;
|
|
3383
|
+
declare const index$5_AuthCredential: typeof AuthCredential;
|
|
3384
|
+
type index$5_AuthCredentialType = AuthCredentialType;
|
|
3385
|
+
declare const index$5_AuthCredentialType: typeof AuthCredentialType;
|
|
3386
|
+
type index$5_AuthHandler = AuthHandler;
|
|
3387
|
+
declare const index$5_AuthHandler: typeof AuthHandler;
|
|
3388
|
+
type index$5_AuthScheme = AuthScheme;
|
|
3389
|
+
declare const index$5_AuthScheme: typeof AuthScheme;
|
|
3390
|
+
type index$5_AuthSchemeType = AuthSchemeType;
|
|
3391
|
+
declare const index$5_AuthSchemeType: typeof AuthSchemeType;
|
|
3392
|
+
type index$5_BaseLLMConnection = BaseLLMConnection;
|
|
3393
|
+
declare const index$5_BaseLLMConnection: typeof BaseLLMConnection;
|
|
3394
|
+
type index$5_BaseLlm = BaseLlm;
|
|
3395
|
+
declare const index$5_BaseLlm: typeof BaseLlm;
|
|
3396
|
+
type index$5_BaseMemoryService = BaseMemoryService;
|
|
3397
|
+
type index$5_BasicAuthCredential = BasicAuthCredential;
|
|
3398
|
+
declare const index$5_BasicAuthCredential: typeof BasicAuthCredential;
|
|
3399
|
+
type index$5_BearerTokenCredential = BearerTokenCredential;
|
|
3400
|
+
declare const index$5_BearerTokenCredential: typeof BearerTokenCredential;
|
|
3401
|
+
declare const index$5_Blob: typeof Blob;
|
|
3402
|
+
declare const index$5_Content: typeof Content;
|
|
3403
|
+
declare const index$5_FunctionDeclaration: typeof FunctionDeclaration;
|
|
3404
|
+
type index$5_GoogleLlm = GoogleLlm;
|
|
3405
|
+
declare const index$5_GoogleLlm: typeof GoogleLlm;
|
|
3406
|
+
type index$5_HttpScheme = HttpScheme;
|
|
3407
|
+
declare const index$5_HttpScheme: typeof HttpScheme;
|
|
3408
|
+
type index$5_LLMRegistry = LLMRegistry;
|
|
3409
|
+
declare const index$5_LLMRegistry: typeof LLMRegistry;
|
|
3410
|
+
type index$5_LlmRequest = LlmRequest;
|
|
3411
|
+
declare const index$5_LlmRequest: typeof LlmRequest;
|
|
3412
|
+
type index$5_LlmResponse = LlmResponse;
|
|
3413
|
+
declare const index$5_LlmResponse: typeof LlmResponse;
|
|
3414
|
+
type index$5_OAuth2Credential = OAuth2Credential;
|
|
3415
|
+
declare const index$5_OAuth2Credential: typeof OAuth2Credential;
|
|
3416
|
+
type index$5_OAuth2Scheme = OAuth2Scheme;
|
|
3417
|
+
declare const index$5_OAuth2Scheme: typeof OAuth2Scheme;
|
|
3418
|
+
type index$5_OAuthFlow = OAuthFlow;
|
|
3419
|
+
type index$5_OAuthFlows = OAuthFlows;
|
|
3420
|
+
type index$5_OpenAiLlm = OpenAiLlm;
|
|
3421
|
+
declare const index$5_OpenAiLlm: typeof OpenAiLlm;
|
|
3422
|
+
type index$5_OpenIdConnectScheme = OpenIdConnectScheme;
|
|
3423
|
+
declare const index$5_OpenIdConnectScheme: typeof OpenIdConnectScheme;
|
|
3424
|
+
type index$5_SearchMemoryResponse = SearchMemoryResponse;
|
|
3425
|
+
type index$5_Session = Session;
|
|
3426
|
+
type index$5_State = State;
|
|
3427
|
+
declare const index$5_State: typeof State;
|
|
3428
|
+
type index$5_ThinkingConfig = ThinkingConfig;
|
|
3429
|
+
declare const index$5_registerProviders: typeof registerProviders;
|
|
3430
|
+
declare namespace index$5 {
|
|
3431
|
+
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, index$5_Content as Content, index$5_FunctionDeclaration as FunctionDeclaration, index$5_GoogleLlm as GoogleLlm, index$5_HttpScheme as HttpScheme, Schema 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 };
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
/**
|
|
3435
|
+
* Options for creating an Event.
|
|
3436
|
+
*/
|
|
3437
|
+
interface EventOpts {
|
|
3438
|
+
invocationId?: string;
|
|
3439
|
+
author: string;
|
|
3440
|
+
actions?: EventActions;
|
|
3441
|
+
longRunningToolIds?: Set<string>;
|
|
3442
|
+
branch?: string;
|
|
3443
|
+
id?: string;
|
|
3444
|
+
timestamp?: number;
|
|
3445
|
+
content?: any;
|
|
3446
|
+
partial?: boolean;
|
|
3447
|
+
}
|
|
3448
|
+
/**
|
|
3449
|
+
* Represents an event in a conversation between agents and users.
|
|
3450
|
+
* It is used to store the content of the conversation, as well as the actions
|
|
3451
|
+
* taken by the agents like function calls, etc.
|
|
3452
|
+
*/
|
|
3453
|
+
declare class Event extends LlmResponse {
|
|
3454
|
+
/** The invocation ID of the event. */
|
|
3455
|
+
invocationId: string;
|
|
3456
|
+
/** 'user' or the name of the agent, indicating who appended the event to the session. */
|
|
3457
|
+
author: string;
|
|
3458
|
+
/** The actions taken by the agent. */
|
|
3459
|
+
actions: EventActions;
|
|
3469
3460
|
/**
|
|
3470
|
-
*
|
|
3461
|
+
* Set of ids of the long running function calls.
|
|
3462
|
+
* Agent client will know from this field about which function call is long running.
|
|
3463
|
+
* Only valid for function call event.
|
|
3471
3464
|
*/
|
|
3472
|
-
|
|
3465
|
+
longRunningToolIds?: Set<string>;
|
|
3473
3466
|
/**
|
|
3474
|
-
*
|
|
3467
|
+
* The branch of the event.
|
|
3468
|
+
* The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of
|
|
3469
|
+
* agent_2, and agent_2 is the parent of agent_3. Branch is used when multiple
|
|
3470
|
+
* sub-agents shouldn't see their peer agents' conversation history.
|
|
3475
3471
|
*/
|
|
3476
|
-
|
|
3472
|
+
branch?: string;
|
|
3473
|
+
/** The unique identifier of the event. */
|
|
3474
|
+
id: string;
|
|
3475
|
+
/** The timestamp of the event (seconds since epoch). */
|
|
3476
|
+
timestamp: number;
|
|
3477
3477
|
/**
|
|
3478
|
-
*
|
|
3478
|
+
* Constructor for Event.
|
|
3479
3479
|
*/
|
|
3480
|
-
|
|
3480
|
+
constructor(opts: EventOpts);
|
|
3481
3481
|
/**
|
|
3482
|
-
*
|
|
3482
|
+
* Returns whether the event is the final response of the agent.
|
|
3483
3483
|
*/
|
|
3484
|
-
|
|
3484
|
+
isFinalResponse(): boolean;
|
|
3485
3485
|
/**
|
|
3486
|
-
*
|
|
3486
|
+
* Returns the function calls in the event.
|
|
3487
3487
|
*/
|
|
3488
|
-
|
|
3488
|
+
getFunctionCalls(): any[];
|
|
3489
3489
|
/**
|
|
3490
|
-
*
|
|
3491
|
-
* NOTE: not all fields are usable, e.g. tools must be configured via `tools`,
|
|
3492
|
-
* thinking_config must be configured via `planner` in LlmAgent.
|
|
3490
|
+
* Returns the function responses in the event.
|
|
3493
3491
|
*/
|
|
3494
|
-
|
|
3492
|
+
getFunctionResponses(): any[];
|
|
3495
3493
|
/**
|
|
3496
|
-
*
|
|
3494
|
+
* Returns whether the event has a trailing code execution result.
|
|
3497
3495
|
*/
|
|
3498
|
-
|
|
3496
|
+
hasTrailingCodeExecutionResult(): boolean;
|
|
3499
3497
|
/**
|
|
3500
|
-
*
|
|
3501
|
-
* NOTE: when this is set, agent can ONLY reply and CANNOT use any tools
|
|
3498
|
+
* Generates a new random ID for an event.
|
|
3502
3499
|
*/
|
|
3503
|
-
|
|
3500
|
+
static newId(): string;
|
|
3504
3501
|
}
|
|
3502
|
+
|
|
3505
3503
|
/**
|
|
3506
|
-
*
|
|
3504
|
+
* Single agent callback type
|
|
3507
3505
|
*/
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
*/
|
|
3522
|
-
globalInstruction: string | InstructionProvider;
|
|
3506
|
+
type SingleAgentCallback = (callbackContext: CallbackContext) => Promise<Content | undefined> | Content | undefined;
|
|
3507
|
+
/**
|
|
3508
|
+
* Before agent callback type
|
|
3509
|
+
*/
|
|
3510
|
+
type BeforeAgentCallback = SingleAgentCallback | SingleAgentCallback[];
|
|
3511
|
+
/**
|
|
3512
|
+
* After agent callback type
|
|
3513
|
+
*/
|
|
3514
|
+
type AfterAgentCallback = SingleAgentCallback | SingleAgentCallback[];
|
|
3515
|
+
/**
|
|
3516
|
+
* Base class for all agents in Agent Development Kit.
|
|
3517
|
+
*/
|
|
3518
|
+
declare abstract class BaseAgent {
|
|
3523
3519
|
/**
|
|
3524
|
-
*
|
|
3520
|
+
* The agent's name.
|
|
3521
|
+
* Agent name must be a valid identifier and unique within the agent tree.
|
|
3522
|
+
* Agent name cannot be "user", since it's reserved for end-user's input.
|
|
3525
3523
|
*/
|
|
3526
|
-
|
|
3524
|
+
name: string;
|
|
3527
3525
|
/**
|
|
3528
|
-
*
|
|
3526
|
+
* Description about the agent's capability.
|
|
3527
|
+
* The model uses this to determine whether to delegate control to the agent.
|
|
3528
|
+
* One-line description is enough and preferred.
|
|
3529
3529
|
*/
|
|
3530
|
-
|
|
3530
|
+
description: string;
|
|
3531
3531
|
/**
|
|
3532
|
-
*
|
|
3532
|
+
* The parent agent of this agent.
|
|
3533
|
+
* Note that an agent can ONLY be added as sub-agent once.
|
|
3534
|
+
* If you want to add one agent twice as sub-agent, consider to create two agent
|
|
3535
|
+
* instances with identical config, but with different name and add them to the
|
|
3536
|
+
* agent tree.
|
|
3533
3537
|
*/
|
|
3534
|
-
|
|
3538
|
+
parentAgent?: BaseAgent;
|
|
3535
3539
|
/**
|
|
3536
|
-
*
|
|
3540
|
+
* The sub-agents of this agent.
|
|
3537
3541
|
*/
|
|
3538
|
-
|
|
3542
|
+
subAgents: BaseAgent[];
|
|
3539
3543
|
/**
|
|
3540
|
-
*
|
|
3544
|
+
* Callback or list of callbacks to be invoked before the agent run.
|
|
3545
|
+
* When a list of callbacks is provided, the callbacks will be called in the
|
|
3546
|
+
* order they are listed until a callback does not return undefined.
|
|
3547
|
+
*
|
|
3548
|
+
* Args:
|
|
3549
|
+
* callbackContext: The callback context.
|
|
3550
|
+
*
|
|
3551
|
+
* Returns:
|
|
3552
|
+
* Content | undefined: The content to return to the user.
|
|
3553
|
+
* When the content is present, the agent run will be skipped and the
|
|
3554
|
+
* provided content will be returned to user.
|
|
3541
3555
|
*/
|
|
3542
|
-
|
|
3556
|
+
beforeAgentCallback?: BeforeAgentCallback;
|
|
3543
3557
|
/**
|
|
3544
|
-
*
|
|
3558
|
+
* Callback or list of callbacks to be invoked after the agent run.
|
|
3559
|
+
* When a list of callbacks is provided, the callbacks will be called in the
|
|
3560
|
+
* order they are listed until a callback does not return undefined.
|
|
3561
|
+
*
|
|
3562
|
+
* Args:
|
|
3563
|
+
* callbackContext: The callback context.
|
|
3564
|
+
*
|
|
3565
|
+
* Returns:
|
|
3566
|
+
* Content | undefined: The content to return to the user.
|
|
3567
|
+
* When the content is present, the provided content will be used as agent
|
|
3568
|
+
* response and appended to event history as agent response.
|
|
3545
3569
|
*/
|
|
3546
|
-
|
|
3570
|
+
afterAgentCallback?: AfterAgentCallback;
|
|
3547
3571
|
/**
|
|
3548
|
-
*
|
|
3572
|
+
* Constructor for BaseAgent
|
|
3549
3573
|
*/
|
|
3550
|
-
|
|
3574
|
+
constructor(config: {
|
|
3575
|
+
name: string;
|
|
3576
|
+
description?: string;
|
|
3577
|
+
subAgents?: BaseAgent[];
|
|
3578
|
+
beforeAgentCallback?: BeforeAgentCallback;
|
|
3579
|
+
afterAgentCallback?: AfterAgentCallback;
|
|
3580
|
+
});
|
|
3551
3581
|
/**
|
|
3552
|
-
*
|
|
3582
|
+
* Entry method to run an agent via text-based conversation.
|
|
3553
3583
|
*/
|
|
3554
|
-
|
|
3584
|
+
runAsync(parentContext: InvocationContext): AsyncGenerator<Event, void, unknown>;
|
|
3555
3585
|
/**
|
|
3556
|
-
*
|
|
3586
|
+
* Entry method to run an agent via video/audio-based conversation.
|
|
3557
3587
|
*/
|
|
3558
|
-
|
|
3588
|
+
runLive(parentContext: InvocationContext): AsyncGenerator<Event, void, unknown>;
|
|
3559
3589
|
/**
|
|
3560
|
-
*
|
|
3590
|
+
* Internal implementation for runAsync
|
|
3561
3591
|
*/
|
|
3562
|
-
private
|
|
3592
|
+
private runAsyncInternal;
|
|
3563
3593
|
/**
|
|
3564
|
-
*
|
|
3594
|
+
* Internal implementation for runLive
|
|
3565
3595
|
*/
|
|
3566
|
-
private
|
|
3596
|
+
private runLiveInternal;
|
|
3567
3597
|
/**
|
|
3568
|
-
*
|
|
3598
|
+
* Core logic to run this agent via text-based conversation.
|
|
3599
|
+
*
|
|
3600
|
+
* @param ctx - The invocation context for this agent.
|
|
3601
|
+
* @yields Event - The events generated by the agent.
|
|
3569
3602
|
*/
|
|
3570
|
-
|
|
3603
|
+
protected runAsyncImpl(_ctx: InvocationContext): AsyncGenerator<Event, void, unknown>;
|
|
3571
3604
|
/**
|
|
3572
|
-
*
|
|
3605
|
+
* Core logic to run this agent via video/audio-based conversation.
|
|
3606
|
+
*
|
|
3607
|
+
* @param ctx - The invocation context for this agent.
|
|
3608
|
+
* @yields Event - The events generated by the agent.
|
|
3573
3609
|
*/
|
|
3574
|
-
|
|
3610
|
+
protected runLiveImpl(_ctx: InvocationContext): AsyncGenerator<Event, void, unknown>;
|
|
3575
3611
|
/**
|
|
3576
|
-
*
|
|
3612
|
+
* Gets the root agent of this agent.
|
|
3577
3613
|
*/
|
|
3578
|
-
|
|
3614
|
+
get rootAgent(): BaseAgent;
|
|
3579
3615
|
/**
|
|
3580
|
-
*
|
|
3616
|
+
* Finds the agent with the given name in this agent and its descendants.
|
|
3617
|
+
*
|
|
3618
|
+
* @param name - The name of the agent to find.
|
|
3619
|
+
* @returns The agent with the matching name, or undefined if no such agent is found.
|
|
3581
3620
|
*/
|
|
3582
|
-
|
|
3583
|
-
protected logger: Logger;
|
|
3621
|
+
findAgent(name: string): BaseAgent | undefined;
|
|
3584
3622
|
/**
|
|
3585
|
-
*
|
|
3623
|
+
* Finds the agent with the given name in this agent's descendants.
|
|
3624
|
+
*
|
|
3625
|
+
* @param name - The name of the agent to find.
|
|
3626
|
+
* @returns The agent with the matching name, or undefined if no such agent is found.
|
|
3586
3627
|
*/
|
|
3587
|
-
|
|
3628
|
+
findSubAgent(name: string): BaseAgent | undefined;
|
|
3588
3629
|
/**
|
|
3589
|
-
*
|
|
3590
|
-
* This method is only for use by Agent Development Kit
|
|
3630
|
+
* Creates a new invocation context for this agent.
|
|
3591
3631
|
*/
|
|
3592
|
-
|
|
3632
|
+
private createInvocationContext;
|
|
3593
3633
|
/**
|
|
3594
|
-
* The resolved
|
|
3595
|
-
* This method is only for use by Agent Development Kit
|
|
3634
|
+
* The resolved beforeAgentCallback field as a list of SingleAgentCallback.
|
|
3635
|
+
* This method is only for use by Agent Development Kit.
|
|
3596
3636
|
*/
|
|
3597
|
-
|
|
3637
|
+
get canonicalBeforeAgentCallbacks(): SingleAgentCallback[];
|
|
3598
3638
|
/**
|
|
3599
|
-
* The resolved
|
|
3600
|
-
* This method is only for use by Agent Development Kit
|
|
3639
|
+
* The resolved afterAgentCallback field as a list of SingleAgentCallback.
|
|
3640
|
+
* This method is only for use by Agent Development Kit.
|
|
3601
3641
|
*/
|
|
3602
|
-
|
|
3642
|
+
get canonicalAfterAgentCallbacks(): SingleAgentCallback[];
|
|
3603
3643
|
/**
|
|
3604
|
-
*
|
|
3605
|
-
*
|
|
3644
|
+
* Runs the beforeAgentCallback if it exists.
|
|
3645
|
+
*
|
|
3646
|
+
* @returns An event if callback provides content or changed state.
|
|
3606
3647
|
*/
|
|
3607
|
-
|
|
3648
|
+
private handleBeforeAgentCallback;
|
|
3608
3649
|
/**
|
|
3609
|
-
*
|
|
3610
|
-
*
|
|
3650
|
+
* Runs the afterAgentCallback if it exists.
|
|
3651
|
+
*
|
|
3652
|
+
* @returns An event if callback provides content or changed state.
|
|
3611
3653
|
*/
|
|
3612
|
-
private
|
|
3654
|
+
private handleAfterAgentCallback;
|
|
3613
3655
|
/**
|
|
3614
|
-
*
|
|
3615
|
-
* This matches the Python implementation's __maybe_save_output_to_state
|
|
3656
|
+
* Validates the agent name.
|
|
3616
3657
|
*/
|
|
3617
|
-
private
|
|
3658
|
+
private validateName;
|
|
3618
3659
|
/**
|
|
3619
|
-
*
|
|
3620
|
-
* This matches the Python implementation's _run_async_impl
|
|
3660
|
+
* Sets parent agent for sub-agents.
|
|
3621
3661
|
*/
|
|
3622
|
-
|
|
3662
|
+
private setParentAgentForSubAgents;
|
|
3623
3663
|
}
|
|
3624
3664
|
|
|
3625
3665
|
/**
|
|
@@ -3895,10 +3935,14 @@ interface AgentBuilderConfig {
|
|
|
3895
3935
|
instruction?: string;
|
|
3896
3936
|
tools?: BaseTool[];
|
|
3897
3937
|
planner?: BasePlanner;
|
|
3938
|
+
codeExecutor?: BaseCodeExecutor;
|
|
3898
3939
|
subAgents?: BaseAgent[];
|
|
3940
|
+
beforeAgentCallback?: BeforeAgentCallback;
|
|
3941
|
+
afterAgentCallback?: AfterAgentCallback;
|
|
3899
3942
|
maxIterations?: number;
|
|
3900
3943
|
nodes?: LangGraphNode[];
|
|
3901
3944
|
rootNode?: string;
|
|
3945
|
+
outputKey?: string;
|
|
3902
3946
|
}
|
|
3903
3947
|
/**
|
|
3904
3948
|
* Session configuration options
|
|
@@ -3906,6 +3950,8 @@ interface AgentBuilderConfig {
|
|
|
3906
3950
|
interface SessionOptions {
|
|
3907
3951
|
userId?: string;
|
|
3908
3952
|
appName?: string;
|
|
3953
|
+
state?: Record<string, any>;
|
|
3954
|
+
sessionId?: string;
|
|
3909
3955
|
}
|
|
3910
3956
|
/**
|
|
3911
3957
|
* Message part interface for flexible message input
|
|
@@ -3916,7 +3962,7 @@ interface MessagePart extends Part {
|
|
|
3916
3962
|
/**
|
|
3917
3963
|
* Full message interface for advanced usage
|
|
3918
3964
|
*/
|
|
3919
|
-
interface FullMessage extends Content
|
|
3965
|
+
interface FullMessage extends Content {
|
|
3920
3966
|
parts?: MessagePart[];
|
|
3921
3967
|
}
|
|
3922
3968
|
/**
|
|
@@ -3962,13 +4008,21 @@ type AgentType = "llm" | "sequential" | "parallel" | "loop" | "langgraph";
|
|
|
3962
4008
|
* .withInstruction("You are a research assistant")
|
|
3963
4009
|
* .build();
|
|
3964
4010
|
*
|
|
4011
|
+
* // With code executor for running code
|
|
4012
|
+
* const { runner } = await AgentBuilder
|
|
4013
|
+
* .create("code-agent")
|
|
4014
|
+
* .withModel("gemini-2.5-flash")
|
|
4015
|
+
* .withCodeExecutor(new ContainerCodeExecutor())
|
|
4016
|
+
* .withInstruction("You can execute code to solve problems")
|
|
4017
|
+
* .build();
|
|
4018
|
+
*
|
|
3965
4019
|
* // With memory and artifact services
|
|
3966
4020
|
* const { runner } = await AgentBuilder
|
|
3967
4021
|
* .create("persistent-agent")
|
|
3968
4022
|
* .withModel("gemini-2.5-flash")
|
|
3969
4023
|
* .withMemory(new RedisMemoryService())
|
|
3970
4024
|
* .withArtifactService(new S3ArtifactService())
|
|
3971
|
-
* .
|
|
4025
|
+
* .withSessionService(new DatabaseSessionService(), { userId: "user123", appName: "myapp" })
|
|
3972
4026
|
* .build();
|
|
3973
4027
|
*
|
|
3974
4028
|
* // Multi-agent workflow
|
|
@@ -3980,10 +4034,12 @@ type AgentType = "llm" | "sequential" | "parallel" | "loop" | "langgraph";
|
|
|
3980
4034
|
*/
|
|
3981
4035
|
declare class AgentBuilder {
|
|
3982
4036
|
private config;
|
|
3983
|
-
private
|
|
4037
|
+
private sessionService?;
|
|
4038
|
+
private sessionOptions?;
|
|
3984
4039
|
private memoryService?;
|
|
3985
4040
|
private artifactService?;
|
|
3986
4041
|
private agentType;
|
|
4042
|
+
private existingSession?;
|
|
3987
4043
|
/**
|
|
3988
4044
|
* Private constructor - use static create() method
|
|
3989
4045
|
*/
|
|
@@ -4030,6 +4086,36 @@ declare class AgentBuilder {
|
|
|
4030
4086
|
* @returns This builder instance for chaining
|
|
4031
4087
|
*/
|
|
4032
4088
|
withPlanner(planner: BasePlanner): this;
|
|
4089
|
+
/**
|
|
4090
|
+
* Set the code executor for the agent
|
|
4091
|
+
* @param codeExecutor The code executor to use for running code
|
|
4092
|
+
* @returns This builder instance for chaining
|
|
4093
|
+
*/
|
|
4094
|
+
withCodeExecutor(codeExecutor: BaseCodeExecutor): this;
|
|
4095
|
+
/**
|
|
4096
|
+
* Set the output key for the agent
|
|
4097
|
+
* @param outputKey The output key in session state to store the output of the agent
|
|
4098
|
+
* @returns This builder instance for chaining
|
|
4099
|
+
*/
|
|
4100
|
+
withOutputKey(outputKey: string): this;
|
|
4101
|
+
/**
|
|
4102
|
+
* Add sub-agents to the agent
|
|
4103
|
+
* @param subAgents Sub-agents to add to the agent
|
|
4104
|
+
* @returns This builder instance for chaining
|
|
4105
|
+
*/
|
|
4106
|
+
withSubAgents(subAgents: BaseAgent[]): this;
|
|
4107
|
+
/**
|
|
4108
|
+
* Set the before agent callback
|
|
4109
|
+
* @param callback Callback to invoke before agent execution
|
|
4110
|
+
* @returns This builder instance for chaining
|
|
4111
|
+
*/
|
|
4112
|
+
withBeforeAgentCallback(callback: BeforeAgentCallback): this;
|
|
4113
|
+
/**
|
|
4114
|
+
* Set the after agent callback
|
|
4115
|
+
* @param callback Callback to invoke after agent execution
|
|
4116
|
+
* @returns This builder instance for chaining
|
|
4117
|
+
*/
|
|
4118
|
+
withAfterAgentCallback(callback: AfterAgentCallback): this;
|
|
4033
4119
|
/**
|
|
4034
4120
|
* Configure as a sequential agent
|
|
4035
4121
|
* @param subAgents Sub-agents to execute in sequence
|
|
@@ -4062,7 +4148,14 @@ declare class AgentBuilder {
|
|
|
4062
4148
|
* @param options Session configuration options (userId and appName)
|
|
4063
4149
|
* @returns This builder instance for chaining
|
|
4064
4150
|
*/
|
|
4065
|
-
|
|
4151
|
+
withSessionService(service: BaseSessionService, options?: SessionOptions): this;
|
|
4152
|
+
/**
|
|
4153
|
+
* Configure with an existing session instance
|
|
4154
|
+
* @param session Existing session to use
|
|
4155
|
+
* @returns This builder instance for chaining
|
|
4156
|
+
* @throws Error if no session service has been configured via withSessionService()
|
|
4157
|
+
*/
|
|
4158
|
+
withSession(session: Session): this;
|
|
4066
4159
|
/**
|
|
4067
4160
|
* Configure memory service for the agent
|
|
4068
4161
|
* @param memoryService Memory service to use for conversation history and context
|
|
@@ -4782,7 +4875,7 @@ declare function populateClientFunctionCallId(modelResponseEvent: Event): void;
|
|
|
4782
4875
|
/**
|
|
4783
4876
|
* Removes client function call IDs from content
|
|
4784
4877
|
*/
|
|
4785
|
-
declare function removeClientFunctionCallId(content: Content
|
|
4878
|
+
declare function removeClientFunctionCallId(content: Content): void;
|
|
4786
4879
|
/**
|
|
4787
4880
|
* Gets long running function call IDs from a list of function calls
|
|
4788
4881
|
*/
|
|
@@ -4990,7 +5083,7 @@ declare class Runner<T extends BaseAgent = BaseAgent> {
|
|
|
4990
5083
|
run({ userId, sessionId, newMessage, runConfig, }: {
|
|
4991
5084
|
userId: string;
|
|
4992
5085
|
sessionId: string;
|
|
4993
|
-
newMessage: Content
|
|
5086
|
+
newMessage: Content;
|
|
4994
5087
|
runConfig?: RunConfig;
|
|
4995
5088
|
}): Generator<Event, void, unknown>;
|
|
4996
5089
|
/**
|
|
@@ -4999,7 +5092,7 @@ declare class Runner<T extends BaseAgent = BaseAgent> {
|
|
|
4999
5092
|
runAsync({ userId, sessionId, newMessage, runConfig, }: {
|
|
5000
5093
|
userId: string;
|
|
5001
5094
|
sessionId: string;
|
|
5002
|
-
newMessage: Content
|
|
5095
|
+
newMessage: Content;
|
|
5003
5096
|
runConfig?: RunConfig;
|
|
5004
5097
|
}): AsyncGenerator<Event, void, unknown>;
|
|
5005
5098
|
/**
|
|
@@ -5107,4 +5200,4 @@ declare const traceLlmCall: (invocationContext: InvocationContext, eventId: stri
|
|
|
5107
5200
|
|
|
5108
5201
|
declare const VERSION = "0.1.0";
|
|
5109
5202
|
|
|
5110
|
-
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, type CreateToolConfigWithSchema, type CreateToolConfigWithoutSchema, DatabaseSessionService, EnhancedAuthConfig, type EnhancedRunner, Event, EventActions, index$1 as Events, ExitLoopTool, type File, FileOperationsTool, index as Flows, type FullMessage,
|
|
5203
|
+
export { AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, AgentTool, type AgentToolConfig, type AgentType, index$4 as Agents, AiSdkLlm, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, type BaseAgentType, 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, type CreateToolConfigWithSchema, type CreateToolConfigWithoutSchema, DatabaseSessionService, EnhancedAuthConfig, type EnhancedRunner, Event, EventActions, index$1 as Events, ExitLoopTool, type File, FileOperationsTool, index as Flows, type FullMessage, FunctionTool, GcsArtifactService, type GetSessionConfig, GetUserChoiceTool, GoogleLlm, GoogleSearch, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, InvocationContext, 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, McpNearIntents, 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 SessionOptions, 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 };
|