@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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22; var _class23; var _class24; var _class25; var _class26; var _class27; var _class28; var _class29; var _class30; var _class31; var _class32;var __defProp = Object.defineProperty;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22; var _class23; var _class24; var _class25; var _class26; var _class27; var _class28; var _class29; var _class30; var _class31; var _class32; var _class33;var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
@@ -323,15 +323,17 @@ var init_base_tool = __esm({
|
|
|
323
323
|
if (!llmRequest.config || !llmRequest.config.tools) {
|
|
324
324
|
return null;
|
|
325
325
|
}
|
|
326
|
-
|
|
327
|
-
(tool) => tool.functionDeclarations && tool.functionDeclarations.length > 0
|
|
326
|
+
const toolWithFunctionDeclaration = llmRequest.config.tools.find(
|
|
327
|
+
(tool) => "functionDeclarations" in tool && tool.functionDeclarations && tool.functionDeclarations.length > 0
|
|
328
328
|
) || null;
|
|
329
|
+
return toolWithFunctionDeclaration;
|
|
329
330
|
}
|
|
330
331
|
}, _class2);
|
|
331
332
|
}
|
|
332
333
|
});
|
|
333
334
|
|
|
334
335
|
// src/tools/function/function-utils.ts
|
|
336
|
+
var _genai = require('@google/genai');
|
|
335
337
|
function buildFunctionDeclaration(func, options = {}) {
|
|
336
338
|
const funcStr = func.toString();
|
|
337
339
|
const name = options.name || func.name;
|
|
@@ -352,10 +354,10 @@ function buildFunctionDeclaration(func, options = {}) {
|
|
|
352
354
|
function extractParametersSchema(func, ignoreParams = []) {
|
|
353
355
|
const funcStr = func.toString();
|
|
354
356
|
const paramMatch = funcStr.match(/\(([^)]*)\)/);
|
|
355
|
-
if (!paramMatch) return { type:
|
|
357
|
+
if (!paramMatch) return { type: _genai.Type.OBJECT, properties: {} };
|
|
356
358
|
const paramList = paramMatch[1].split(",").map((param) => param.trim()).filter((param) => param !== "");
|
|
357
359
|
if (paramList.length === 0 || paramList.length === 1 && paramList[0] === "") {
|
|
358
|
-
return { type:
|
|
360
|
+
return { type: _genai.Type.OBJECT, properties: {} };
|
|
359
361
|
}
|
|
360
362
|
const jsDocParams = extractJSDocParams(funcStr);
|
|
361
363
|
const jsDocTypes = extractJSDocTypes(funcStr);
|
|
@@ -395,7 +397,7 @@ function extractParametersSchema(func, ignoreParams = []) {
|
|
|
395
397
|
}
|
|
396
398
|
}
|
|
397
399
|
const schema = {
|
|
398
|
-
type:
|
|
400
|
+
type: _genai.Type.OBJECT,
|
|
399
401
|
properties
|
|
400
402
|
};
|
|
401
403
|
if (required.length > 0) {
|
|
@@ -1364,7 +1366,7 @@ var BaseLLMConnection = class {
|
|
|
1364
1366
|
|
|
1365
1367
|
|
|
1366
1368
|
|
|
1367
|
-
|
|
1369
|
+
|
|
1368
1370
|
var AGENT_ENGINE_TELEMETRY_TAG = "remote_reasoning_engine";
|
|
1369
1371
|
var AGENT_ENGINE_TELEMETRY_ENV_VARIABLE_NAME = "GOOGLE_CLOUD_AGENT_ENGINE_ID";
|
|
1370
1372
|
var GoogleLlm = class extends BaseLlm {
|
|
@@ -1397,7 +1399,7 @@ var GoogleLlm = class extends BaseLlm {
|
|
|
1397
1399
|
this.preprocessRequest(llmRequest);
|
|
1398
1400
|
const model = llmRequest.model || this.model;
|
|
1399
1401
|
const contents = this.convertContents(llmRequest.contents || []);
|
|
1400
|
-
const config =
|
|
1402
|
+
const config = llmRequest.config;
|
|
1401
1403
|
if (stream) {
|
|
1402
1404
|
const responses = await this.apiClient.models.generateContentStream({
|
|
1403
1405
|
model,
|
|
@@ -1491,19 +1493,6 @@ var GoogleLlm = class extends BaseLlm {
|
|
|
1491
1493
|
parts: content.parts || [{ text: content.content || "" }]
|
|
1492
1494
|
}));
|
|
1493
1495
|
}
|
|
1494
|
-
/**
|
|
1495
|
-
* Convert LlmRequest config to GoogleGenAI format
|
|
1496
|
-
*/
|
|
1497
|
-
convertConfig(config) {
|
|
1498
|
-
if (!config) return {};
|
|
1499
|
-
return {
|
|
1500
|
-
temperature: config.temperature,
|
|
1501
|
-
topP: config.top_p,
|
|
1502
|
-
maxOutputTokens: config.max_tokens,
|
|
1503
|
-
tools: config.tools,
|
|
1504
|
-
systemInstruction: config.system_instruction
|
|
1505
|
-
};
|
|
1506
|
-
}
|
|
1507
1496
|
/**
|
|
1508
1497
|
* Preprocesses the request based on the API backend.
|
|
1509
1498
|
*/
|
|
@@ -3295,7 +3284,7 @@ var CallbackContext = class extends ReadonlyContext {
|
|
|
3295
3284
|
constructor(invocationContext, options = {}) {
|
|
3296
3285
|
super(invocationContext);
|
|
3297
3286
|
this._eventActions = options.eventActions || new EventActions();
|
|
3298
|
-
this._state =
|
|
3287
|
+
this._state = State.create(
|
|
3299
3288
|
invocationContext.session.state,
|
|
3300
3289
|
this._eventActions.stateDelta
|
|
3301
3290
|
);
|
|
@@ -3821,6 +3810,7 @@ ${argsStr}
|
|
|
3821
3810
|
// src/tools/index.ts
|
|
3822
3811
|
var tools_exports = {};
|
|
3823
3812
|
__export(tools_exports, {
|
|
3813
|
+
AgentTool: () => AgentTool,
|
|
3824
3814
|
BaseTool: () => BaseTool,
|
|
3825
3815
|
ExitLoopTool: () => ExitLoopTool,
|
|
3826
3816
|
FileOperationsTool: () => FileOperationsTool,
|
|
@@ -3925,6 +3915,283 @@ function createTool(config) {
|
|
|
3925
3915
|
return new CreatedTool(config);
|
|
3926
3916
|
}
|
|
3927
3917
|
|
|
3918
|
+
// src/tools/common/agent-tool.ts
|
|
3919
|
+
init_logger();
|
|
3920
|
+
|
|
3921
|
+
|
|
3922
|
+
|
|
3923
|
+
// src/agents/invocation-context.ts
|
|
3924
|
+
var LlmCallsLimitExceededError = class extends Error {
|
|
3925
|
+
constructor(message) {
|
|
3926
|
+
super(message);
|
|
3927
|
+
this.name = "LlmCallsLimitExceededError";
|
|
3928
|
+
}
|
|
3929
|
+
};
|
|
3930
|
+
var InvocationCostManager = (_class13 = class {constructor() { _class13.prototype.__init22.call(this); }
|
|
3931
|
+
/**
|
|
3932
|
+
* A counter that keeps track of number of llm calls made.
|
|
3933
|
+
*/
|
|
3934
|
+
__init22() {this._numberOfLlmCalls = 0}
|
|
3935
|
+
/**
|
|
3936
|
+
* Increments _numberOfLlmCalls and enforces the limit.
|
|
3937
|
+
*/
|
|
3938
|
+
incrementAndEnforceLlmCallsLimit(runConfig) {
|
|
3939
|
+
this._numberOfLlmCalls += 1;
|
|
3940
|
+
if (runConfig && runConfig.maxLlmCalls > 0 && this._numberOfLlmCalls > runConfig.maxLlmCalls) {
|
|
3941
|
+
throw new LlmCallsLimitExceededError(
|
|
3942
|
+
`Max number of llm calls limit of \`${runConfig.maxLlmCalls}\` exceeded`
|
|
3943
|
+
);
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
}, _class13);
|
|
3947
|
+
function newInvocationContextId() {
|
|
3948
|
+
return `e-${crypto.randomUUID()}`;
|
|
3949
|
+
}
|
|
3950
|
+
var InvocationContext = (_class14 = class _InvocationContext {
|
|
3951
|
+
|
|
3952
|
+
|
|
3953
|
+
|
|
3954
|
+
/**
|
|
3955
|
+
* The id of this invocation context. Readonly.
|
|
3956
|
+
*/
|
|
3957
|
+
|
|
3958
|
+
/**
|
|
3959
|
+
* The branch of the invocation context.
|
|
3960
|
+
*
|
|
3961
|
+
* The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of
|
|
3962
|
+
* agent_2, and agent_2 is the parent of agent_3.
|
|
3963
|
+
*
|
|
3964
|
+
* Branch is used when multiple sub-agents shouldn't see their peer agents'
|
|
3965
|
+
* conversation history.
|
|
3966
|
+
*/
|
|
3967
|
+
|
|
3968
|
+
/**
|
|
3969
|
+
* The current agent of this invocation context. Readonly.
|
|
3970
|
+
*/
|
|
3971
|
+
|
|
3972
|
+
/**
|
|
3973
|
+
* The user content that started this invocation. Readonly.
|
|
3974
|
+
*/
|
|
3975
|
+
|
|
3976
|
+
/**
|
|
3977
|
+
* The current session of this invocation context. Readonly.
|
|
3978
|
+
*/
|
|
3979
|
+
|
|
3980
|
+
/**
|
|
3981
|
+
* Whether to end this invocation.
|
|
3982
|
+
*
|
|
3983
|
+
* Set to True in callbacks or tools to terminate this invocation.
|
|
3984
|
+
*/
|
|
3985
|
+
__init23() {this.endInvocation = false}
|
|
3986
|
+
/**
|
|
3987
|
+
* The queue to receive live requests.
|
|
3988
|
+
*/
|
|
3989
|
+
|
|
3990
|
+
/**
|
|
3991
|
+
* The running streaming tools of this invocation.
|
|
3992
|
+
*/
|
|
3993
|
+
|
|
3994
|
+
/**
|
|
3995
|
+
* Caches necessary, data audio or contents, that are needed by transcription.
|
|
3996
|
+
*/
|
|
3997
|
+
|
|
3998
|
+
/**
|
|
3999
|
+
* Configurations for live agents under this invocation.
|
|
4000
|
+
*/
|
|
4001
|
+
|
|
4002
|
+
/**
|
|
4003
|
+
* A container to keep track of different kinds of costs incurred as a part
|
|
4004
|
+
* of this invocation.
|
|
4005
|
+
*/
|
|
4006
|
+
__init24() {this._invocationCostManager = new InvocationCostManager()}
|
|
4007
|
+
/**
|
|
4008
|
+
* Constructor for InvocationContext
|
|
4009
|
+
*/
|
|
4010
|
+
constructor(options) {;_class14.prototype.__init23.call(this);_class14.prototype.__init24.call(this);
|
|
4011
|
+
this.artifactService = options.artifactService;
|
|
4012
|
+
this.sessionService = options.sessionService;
|
|
4013
|
+
this.memoryService = options.memoryService;
|
|
4014
|
+
this.invocationId = options.invocationId || newInvocationContextId();
|
|
4015
|
+
this.branch = options.branch;
|
|
4016
|
+
this.agent = options.agent;
|
|
4017
|
+
this.userContent = options.userContent;
|
|
4018
|
+
this.session = options.session;
|
|
4019
|
+
this.endInvocation = options.endInvocation || false;
|
|
4020
|
+
this.liveRequestQueue = options.liveRequestQueue;
|
|
4021
|
+
this.activeStreamingTools = options.activeStreamingTools;
|
|
4022
|
+
this.transcriptionCache = options.transcriptionCache;
|
|
4023
|
+
this.runConfig = options.runConfig;
|
|
4024
|
+
}
|
|
4025
|
+
/**
|
|
4026
|
+
* App name from the session
|
|
4027
|
+
*/
|
|
4028
|
+
get appName() {
|
|
4029
|
+
return this.session.appName;
|
|
4030
|
+
}
|
|
4031
|
+
/**
|
|
4032
|
+
* User ID from the session
|
|
4033
|
+
*/
|
|
4034
|
+
get userId() {
|
|
4035
|
+
return this.session.userId;
|
|
4036
|
+
}
|
|
4037
|
+
/**
|
|
4038
|
+
* Tracks number of llm calls made.
|
|
4039
|
+
*
|
|
4040
|
+
* @throws {LlmCallsLimitExceededError} If number of llm calls made exceed the set threshold.
|
|
4041
|
+
*/
|
|
4042
|
+
incrementLlmCallCount() {
|
|
4043
|
+
this._invocationCostManager.incrementAndEnforceLlmCallsLimit(
|
|
4044
|
+
this.runConfig
|
|
4045
|
+
);
|
|
4046
|
+
}
|
|
4047
|
+
/**
|
|
4048
|
+
* Creates a child invocation context for a sub-agent
|
|
4049
|
+
*/
|
|
4050
|
+
createChildContext(agent) {
|
|
4051
|
+
return new _InvocationContext({
|
|
4052
|
+
artifactService: this.artifactService,
|
|
4053
|
+
sessionService: this.sessionService,
|
|
4054
|
+
memoryService: this.memoryService,
|
|
4055
|
+
invocationId: this.invocationId,
|
|
4056
|
+
// Keep same invocation ID
|
|
4057
|
+
branch: this.branch ? `${this.branch}.${agent.name}` : agent.name,
|
|
4058
|
+
// Update branch
|
|
4059
|
+
agent,
|
|
4060
|
+
// Update to the new agent
|
|
4061
|
+
userContent: this.userContent,
|
|
4062
|
+
session: this.session,
|
|
4063
|
+
endInvocation: this.endInvocation,
|
|
4064
|
+
liveRequestQueue: this.liveRequestQueue,
|
|
4065
|
+
activeStreamingTools: this.activeStreamingTools,
|
|
4066
|
+
transcriptionCache: this.transcriptionCache,
|
|
4067
|
+
runConfig: this.runConfig
|
|
4068
|
+
});
|
|
4069
|
+
}
|
|
4070
|
+
}, _class14);
|
|
4071
|
+
|
|
4072
|
+
// src/tools/common/agent-tool.ts
|
|
4073
|
+
init_base_tool();
|
|
4074
|
+
function isLlmAgent(agent) {
|
|
4075
|
+
return true;
|
|
4076
|
+
}
|
|
4077
|
+
var AgentTool = (_class15 = class extends BaseTool {
|
|
4078
|
+
/**
|
|
4079
|
+
* The agent used by this tool
|
|
4080
|
+
*/
|
|
4081
|
+
|
|
4082
|
+
/**
|
|
4083
|
+
* The function declaration schema
|
|
4084
|
+
*/
|
|
4085
|
+
|
|
4086
|
+
/**
|
|
4087
|
+
* The key to store the tool output in the state
|
|
4088
|
+
*/
|
|
4089
|
+
|
|
4090
|
+
/**
|
|
4091
|
+
* Whether to skip summarization of the agent's response
|
|
4092
|
+
*/
|
|
4093
|
+
|
|
4094
|
+
__init25() {this.logger = new Logger({ name: "AgentTool" })}
|
|
4095
|
+
/**
|
|
4096
|
+
* Create a new agent tool
|
|
4097
|
+
*/
|
|
4098
|
+
constructor(config) {
|
|
4099
|
+
super({
|
|
4100
|
+
name: config.name,
|
|
4101
|
+
description: config.description || config.agent.description,
|
|
4102
|
+
isLongRunning: config.isLongRunning || false,
|
|
4103
|
+
shouldRetryOnFailure: config.shouldRetryOnFailure || false,
|
|
4104
|
+
maxRetryAttempts: config.maxRetryAttempts || 3
|
|
4105
|
+
});_class15.prototype.__init25.call(this);;
|
|
4106
|
+
this.agent = config.agent;
|
|
4107
|
+
this.functionDeclaration = config.functionDeclaration;
|
|
4108
|
+
this.outputKey = config.outputKey;
|
|
4109
|
+
this.skipSummarization = config.skipSummarization || false;
|
|
4110
|
+
}
|
|
4111
|
+
/**
|
|
4112
|
+
* Get the function declaration for the tool
|
|
4113
|
+
*/
|
|
4114
|
+
getDeclaration() {
|
|
4115
|
+
if (this.functionDeclaration) {
|
|
4116
|
+
return this.functionDeclaration;
|
|
4117
|
+
}
|
|
4118
|
+
const description = isLlmAgent(this.agent) ? typeof this.agent.instruction === "string" ? this.agent.instruction : this.description : this.description;
|
|
4119
|
+
return {
|
|
4120
|
+
name: this.name,
|
|
4121
|
+
description,
|
|
4122
|
+
parameters: {
|
|
4123
|
+
type: _genai.Type.OBJECT,
|
|
4124
|
+
properties: {
|
|
4125
|
+
input: {
|
|
4126
|
+
type: _genai.Type.STRING,
|
|
4127
|
+
description: "The input to provide to the agent"
|
|
4128
|
+
}
|
|
4129
|
+
},
|
|
4130
|
+
required: ["input"]
|
|
4131
|
+
}
|
|
4132
|
+
};
|
|
4133
|
+
}
|
|
4134
|
+
/**
|
|
4135
|
+
* Execute the tool by running the agent with the provided input
|
|
4136
|
+
*/
|
|
4137
|
+
async runAsync(params, context) {
|
|
4138
|
+
try {
|
|
4139
|
+
const input = params.input || Object.values(params)[0];
|
|
4140
|
+
if (!isLlmAgent(this.agent)) {
|
|
4141
|
+
throw new Error(
|
|
4142
|
+
`Agent ${this.name} does not support running as a tool`
|
|
4143
|
+
);
|
|
4144
|
+
}
|
|
4145
|
+
const parentInvocation = context._invocationContext;
|
|
4146
|
+
const childInvocationContext = new InvocationContext({
|
|
4147
|
+
invocationId: _uuid.v4.call(void 0, ),
|
|
4148
|
+
agent: this.agent,
|
|
4149
|
+
session: parentInvocation.session,
|
|
4150
|
+
artifactService: parentInvocation.artifactService,
|
|
4151
|
+
sessionService: parentInvocation.sessionService,
|
|
4152
|
+
memoryService: parentInvocation.memoryService,
|
|
4153
|
+
runConfig: parentInvocation.runConfig,
|
|
4154
|
+
userContent: {
|
|
4155
|
+
role: "user",
|
|
4156
|
+
parts: [{ text: String(input) }]
|
|
4157
|
+
},
|
|
4158
|
+
branch: parentInvocation.branch ? `${parentInvocation.branch}.${this.agent.name}` : this.agent.name
|
|
4159
|
+
});
|
|
4160
|
+
let lastEvent = null;
|
|
4161
|
+
for await (const event of this.agent.runAsync(childInvocationContext)) {
|
|
4162
|
+
if (!event.partial) {
|
|
4163
|
+
await childInvocationContext.sessionService.appendEvent(
|
|
4164
|
+
childInvocationContext.session,
|
|
4165
|
+
event
|
|
4166
|
+
);
|
|
4167
|
+
}
|
|
4168
|
+
if (event.content && event.author === this.agent.name) {
|
|
4169
|
+
lastEvent = event;
|
|
4170
|
+
}
|
|
4171
|
+
}
|
|
4172
|
+
if (!lastEvent || !lastEvent.content || !lastEvent.content.parts) {
|
|
4173
|
+
return "";
|
|
4174
|
+
}
|
|
4175
|
+
const mergedText = lastEvent.content.parts.filter((part) => part.text !== void 0 && part.text !== null).map((part) => part.text).join("\n");
|
|
4176
|
+
let toolResult;
|
|
4177
|
+
try {
|
|
4178
|
+
toolResult = JSON.parse(mergedText);
|
|
4179
|
+
} catch (e2) {
|
|
4180
|
+
toolResult = mergedText;
|
|
4181
|
+
}
|
|
4182
|
+
if (this.outputKey && _optionalChain([context, 'optionalAccess', _144 => _144.state])) {
|
|
4183
|
+
context.state[this.outputKey] = toolResult;
|
|
4184
|
+
}
|
|
4185
|
+
return toolResult;
|
|
4186
|
+
} catch (error) {
|
|
4187
|
+
this.logger.error(`Error executing agent tool ${this.name}:`, error);
|
|
4188
|
+
throw new Error(
|
|
4189
|
+
`Agent tool execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
4190
|
+
);
|
|
4191
|
+
}
|
|
4192
|
+
}
|
|
4193
|
+
}, _class15);
|
|
4194
|
+
|
|
3928
4195
|
// src/tools/tool-context.ts
|
|
3929
4196
|
var ToolContext = class extends CallbackContext {
|
|
3930
4197
|
/**
|
|
@@ -3992,8 +4259,9 @@ init_function_utils();
|
|
|
3992
4259
|
// src/tools/common/google-search.ts
|
|
3993
4260
|
init_logger();
|
|
3994
4261
|
init_base_tool();
|
|
3995
|
-
|
|
3996
|
-
|
|
4262
|
+
|
|
4263
|
+
var GoogleSearch = (_class16 = class extends BaseTool {
|
|
4264
|
+
__init26() {this.logger = new Logger({ name: "GoogleSearch" })}
|
|
3997
4265
|
/**
|
|
3998
4266
|
* Constructor for GoogleSearch
|
|
3999
4267
|
*/
|
|
@@ -4001,7 +4269,7 @@ var GoogleSearch = (_class13 = class extends BaseTool {
|
|
|
4001
4269
|
super({
|
|
4002
4270
|
name: "google_search",
|
|
4003
4271
|
description: "Search the web using Google"
|
|
4004
|
-
});
|
|
4272
|
+
});_class16.prototype.__init26.call(this);;
|
|
4005
4273
|
}
|
|
4006
4274
|
/**
|
|
4007
4275
|
* Get the function declaration for the tool
|
|
@@ -4011,14 +4279,14 @@ var GoogleSearch = (_class13 = class extends BaseTool {
|
|
|
4011
4279
|
name: this.name,
|
|
4012
4280
|
description: this.description,
|
|
4013
4281
|
parameters: {
|
|
4014
|
-
type:
|
|
4282
|
+
type: _genai.Type.OBJECT,
|
|
4015
4283
|
properties: {
|
|
4016
4284
|
query: {
|
|
4017
|
-
type:
|
|
4285
|
+
type: _genai.Type.STRING,
|
|
4018
4286
|
description: "The search query to execute"
|
|
4019
4287
|
},
|
|
4020
4288
|
num_results: {
|
|
4021
|
-
type:
|
|
4289
|
+
type: _genai.Type.INTEGER,
|
|
4022
4290
|
description: "Number of results to return (max 10)",
|
|
4023
4291
|
default: 5
|
|
4024
4292
|
}
|
|
@@ -4050,10 +4318,11 @@ var GoogleSearch = (_class13 = class extends BaseTool {
|
|
|
4050
4318
|
]
|
|
4051
4319
|
};
|
|
4052
4320
|
}
|
|
4053
|
-
},
|
|
4321
|
+
}, _class16);
|
|
4054
4322
|
|
|
4055
4323
|
// src/tools/common/http-request-tool.ts
|
|
4056
4324
|
init_base_tool();
|
|
4325
|
+
|
|
4057
4326
|
var HttpRequestTool = class extends BaseTool {
|
|
4058
4327
|
constructor() {
|
|
4059
4328
|
super({
|
|
@@ -4069,38 +4338,32 @@ var HttpRequestTool = class extends BaseTool {
|
|
|
4069
4338
|
name: this.name,
|
|
4070
4339
|
description: this.description,
|
|
4071
4340
|
parameters: {
|
|
4072
|
-
type:
|
|
4341
|
+
type: _genai.Type.OBJECT,
|
|
4073
4342
|
properties: {
|
|
4074
4343
|
url: {
|
|
4075
|
-
type:
|
|
4344
|
+
type: _genai.Type.STRING,
|
|
4076
4345
|
description: "The URL to send the request to"
|
|
4077
4346
|
},
|
|
4078
4347
|
method: {
|
|
4079
|
-
type:
|
|
4348
|
+
type: _genai.Type.STRING,
|
|
4080
4349
|
description: "The HTTP method to use (GET, POST, PUT, DELETE, etc.)",
|
|
4081
4350
|
enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
|
|
4082
4351
|
default: "GET"
|
|
4083
4352
|
},
|
|
4084
4353
|
headers: {
|
|
4085
|
-
type:
|
|
4086
|
-
description: "Request headers to include"
|
|
4087
|
-
additionalProperties: {
|
|
4088
|
-
type: "string"
|
|
4089
|
-
}
|
|
4354
|
+
type: _genai.Type.OBJECT,
|
|
4355
|
+
description: "Request headers to include"
|
|
4090
4356
|
},
|
|
4091
4357
|
body: {
|
|
4092
|
-
type:
|
|
4358
|
+
type: _genai.Type.STRING,
|
|
4093
4359
|
description: "Request body content (as string, typically JSON)"
|
|
4094
4360
|
},
|
|
4095
4361
|
params: {
|
|
4096
|
-
type:
|
|
4097
|
-
description: "URL query parameters to include"
|
|
4098
|
-
additionalProperties: {
|
|
4099
|
-
type: "string"
|
|
4100
|
-
}
|
|
4362
|
+
type: _genai.Type.OBJECT,
|
|
4363
|
+
description: "URL query parameters to include"
|
|
4101
4364
|
},
|
|
4102
4365
|
timeout: {
|
|
4103
|
-
type:
|
|
4366
|
+
type: _genai.Type.INTEGER,
|
|
4104
4367
|
description: "Request timeout in milliseconds",
|
|
4105
4368
|
default: 1e4
|
|
4106
4369
|
}
|
|
@@ -4175,6 +4438,7 @@ var HttpRequestTool = class extends BaseTool {
|
|
|
4175
4438
|
init_base_tool();
|
|
4176
4439
|
var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault(_promises);
|
|
4177
4440
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
4441
|
+
|
|
4178
4442
|
var FileOperationsTool = class extends BaseTool {
|
|
4179
4443
|
|
|
4180
4444
|
constructor(options) {
|
|
@@ -4182,7 +4446,7 @@ var FileOperationsTool = class extends BaseTool {
|
|
|
4182
4446
|
name: "file_operations",
|
|
4183
4447
|
description: "Perform file system operations like reading, writing, and managing files"
|
|
4184
4448
|
});
|
|
4185
|
-
this.basePath = _optionalChain([options, 'optionalAccess',
|
|
4449
|
+
this.basePath = _optionalChain([options, 'optionalAccess', _145 => _145.basePath]) || process.cwd();
|
|
4186
4450
|
}
|
|
4187
4451
|
/**
|
|
4188
4452
|
* Get the function declaration for the tool
|
|
@@ -4192,10 +4456,10 @@ var FileOperationsTool = class extends BaseTool {
|
|
|
4192
4456
|
name: this.name,
|
|
4193
4457
|
description: this.description,
|
|
4194
4458
|
parameters: {
|
|
4195
|
-
type:
|
|
4459
|
+
type: _genai.Type.OBJECT,
|
|
4196
4460
|
properties: {
|
|
4197
4461
|
operation: {
|
|
4198
|
-
type:
|
|
4462
|
+
type: _genai.Type.STRING,
|
|
4199
4463
|
description: "The file operation to perform",
|
|
4200
4464
|
enum: [
|
|
4201
4465
|
"read",
|
|
@@ -4208,15 +4472,15 @@ var FileOperationsTool = class extends BaseTool {
|
|
|
4208
4472
|
]
|
|
4209
4473
|
},
|
|
4210
4474
|
filepath: {
|
|
4211
|
-
type:
|
|
4475
|
+
type: _genai.Type.STRING,
|
|
4212
4476
|
description: "Path to the file or directory (relative to the base path)"
|
|
4213
4477
|
},
|
|
4214
4478
|
content: {
|
|
4215
|
-
type:
|
|
4479
|
+
type: _genai.Type.STRING,
|
|
4216
4480
|
description: "Content to write to the file (for write and append operations)"
|
|
4217
4481
|
},
|
|
4218
4482
|
encoding: {
|
|
4219
|
-
type:
|
|
4483
|
+
type: _genai.Type.STRING,
|
|
4220
4484
|
description: "File encoding to use",
|
|
4221
4485
|
default: "utf8"
|
|
4222
4486
|
}
|
|
@@ -4363,7 +4627,7 @@ var FileOperationsTool = class extends BaseTool {
|
|
|
4363
4627
|
success: true,
|
|
4364
4628
|
data: true
|
|
4365
4629
|
};
|
|
4366
|
-
} catch (
|
|
4630
|
+
} catch (e3) {
|
|
4367
4631
|
return {
|
|
4368
4632
|
success: true,
|
|
4369
4633
|
data: false
|
|
@@ -4422,6 +4686,7 @@ var FileOperationsTool = class extends BaseTool {
|
|
|
4422
4686
|
|
|
4423
4687
|
// src/tools/common/user-interaction-tool.ts
|
|
4424
4688
|
init_base_tool();
|
|
4689
|
+
|
|
4425
4690
|
var UserInteractionTool = class extends BaseTool {
|
|
4426
4691
|
constructor() {
|
|
4427
4692
|
super({
|
|
@@ -4438,21 +4703,21 @@ var UserInteractionTool = class extends BaseTool {
|
|
|
4438
4703
|
name: this.name,
|
|
4439
4704
|
description: this.description,
|
|
4440
4705
|
parameters: {
|
|
4441
|
-
type:
|
|
4706
|
+
type: _genai.Type.OBJECT,
|
|
4442
4707
|
properties: {
|
|
4443
4708
|
prompt: {
|
|
4444
|
-
type:
|
|
4709
|
+
type: _genai.Type.STRING,
|
|
4445
4710
|
description: "The prompt message to display to the user"
|
|
4446
4711
|
},
|
|
4447
4712
|
options: {
|
|
4448
|
-
type:
|
|
4713
|
+
type: _genai.Type.ARRAY,
|
|
4449
4714
|
description: "Optional array of choices to present to the user",
|
|
4450
4715
|
items: {
|
|
4451
|
-
type:
|
|
4716
|
+
type: _genai.Type.STRING
|
|
4452
4717
|
}
|
|
4453
4718
|
},
|
|
4454
4719
|
defaultValue: {
|
|
4455
|
-
type:
|
|
4720
|
+
type: _genai.Type.STRING,
|
|
4456
4721
|
description: "Optional default value for the input field"
|
|
4457
4722
|
}
|
|
4458
4723
|
},
|
|
@@ -4499,8 +4764,8 @@ var UserInteractionTool = class extends BaseTool {
|
|
|
4499
4764
|
// src/tools/common/exit-loop-tool.ts
|
|
4500
4765
|
init_logger();
|
|
4501
4766
|
init_base_tool();
|
|
4502
|
-
var ExitLoopTool = (
|
|
4503
|
-
|
|
4767
|
+
var ExitLoopTool = (_class17 = class extends BaseTool {
|
|
4768
|
+
__init27() {this.logger = new Logger({ name: "ExitLoopTool" })}
|
|
4504
4769
|
/**
|
|
4505
4770
|
* Constructor for ExitLoopTool
|
|
4506
4771
|
*/
|
|
@@ -4508,7 +4773,7 @@ var ExitLoopTool = (_class14 = class extends BaseTool {
|
|
|
4508
4773
|
super({
|
|
4509
4774
|
name: "exit_loop",
|
|
4510
4775
|
description: "Exits the loop. Call this function only when you are instructed to do so."
|
|
4511
|
-
});
|
|
4776
|
+
});_class17.prototype.__init27.call(this);;
|
|
4512
4777
|
}
|
|
4513
4778
|
/**
|
|
4514
4779
|
* Execute the exit loop action
|
|
@@ -4517,13 +4782,14 @@ var ExitLoopTool = (_class14 = class extends BaseTool {
|
|
|
4517
4782
|
this.logger.debug("Executing exit loop tool");
|
|
4518
4783
|
context.actions.escalate = true;
|
|
4519
4784
|
}
|
|
4520
|
-
},
|
|
4785
|
+
}, _class17);
|
|
4521
4786
|
|
|
4522
4787
|
// src/tools/common/get-user-choice-tool.ts
|
|
4523
4788
|
init_logger();
|
|
4524
4789
|
init_base_tool();
|
|
4525
|
-
|
|
4526
|
-
|
|
4790
|
+
|
|
4791
|
+
var GetUserChoiceTool = (_class18 = class extends BaseTool {
|
|
4792
|
+
__init28() {this.logger = new Logger({ name: "GetUserChoiceTool" })}
|
|
4527
4793
|
/**
|
|
4528
4794
|
* Constructor for GetUserChoiceTool
|
|
4529
4795
|
*/
|
|
@@ -4532,7 +4798,7 @@ var GetUserChoiceTool = (_class15 = class extends BaseTool {
|
|
|
4532
4798
|
name: "get_user_choice",
|
|
4533
4799
|
description: "This tool provides the options to the user and asks them to choose one. Use this tool when you need the user to make a selection between multiple options. Do not list options in your response - use this tool instead.",
|
|
4534
4800
|
isLongRunning: true
|
|
4535
|
-
});
|
|
4801
|
+
});_class18.prototype.__init28.call(this);;
|
|
4536
4802
|
}
|
|
4537
4803
|
/**
|
|
4538
4804
|
* Get the function declaration for the tool
|
|
@@ -4542,17 +4808,17 @@ var GetUserChoiceTool = (_class15 = class extends BaseTool {
|
|
|
4542
4808
|
name: this.name,
|
|
4543
4809
|
description: this.description,
|
|
4544
4810
|
parameters: {
|
|
4545
|
-
type:
|
|
4811
|
+
type: _genai.Type.OBJECT,
|
|
4546
4812
|
properties: {
|
|
4547
4813
|
options: {
|
|
4548
|
-
type:
|
|
4814
|
+
type: _genai.Type.ARRAY,
|
|
4549
4815
|
description: "List of options for the user to choose from",
|
|
4550
4816
|
items: {
|
|
4551
|
-
type:
|
|
4817
|
+
type: _genai.Type.STRING
|
|
4552
4818
|
}
|
|
4553
4819
|
},
|
|
4554
4820
|
question: {
|
|
4555
|
-
type:
|
|
4821
|
+
type: _genai.Type.STRING,
|
|
4556
4822
|
description: "The question or prompt to show the user before presenting options"
|
|
4557
4823
|
}
|
|
4558
4824
|
},
|
|
@@ -4575,21 +4841,41 @@ var GetUserChoiceTool = (_class15 = class extends BaseTool {
|
|
|
4575
4841
|
context.actions.skipSummarization = true;
|
|
4576
4842
|
return null;
|
|
4577
4843
|
}
|
|
4578
|
-
},
|
|
4844
|
+
}, _class18);
|
|
4579
4845
|
|
|
4580
4846
|
// src/tools/common/transfer-to-agent-tool.ts
|
|
4581
4847
|
init_logger();
|
|
4582
4848
|
init_base_tool();
|
|
4583
|
-
|
|
4584
|
-
|
|
4849
|
+
|
|
4850
|
+
var TransferToAgentTool = (_class19 = class extends BaseTool {
|
|
4851
|
+
__init29() {this.logger = new Logger({ name: "TransferToAgentTool" })}
|
|
4585
4852
|
/**
|
|
4586
4853
|
* Constructor for TransferToAgentTool
|
|
4587
4854
|
*/
|
|
4588
4855
|
constructor() {
|
|
4589
4856
|
super({
|
|
4590
4857
|
name: "transfer_to_agent",
|
|
4591
|
-
description: "Transfer the question to another agent."
|
|
4592
|
-
});
|
|
4858
|
+
description: "Transfer the question to another agent when it's more suitable to answer the user's question according to the agent's description. Use this function when you determine that another agent in the system would be better equipped to handle the user's request based on their specialized capabilities and expertise areas."
|
|
4859
|
+
});_class19.prototype.__init29.call(this);;
|
|
4860
|
+
}
|
|
4861
|
+
/**
|
|
4862
|
+
* Get the function declaration for the tool
|
|
4863
|
+
*/
|
|
4864
|
+
getDeclaration() {
|
|
4865
|
+
return {
|
|
4866
|
+
name: this.name,
|
|
4867
|
+
description: this.description,
|
|
4868
|
+
parameters: {
|
|
4869
|
+
type: _genai.Type.OBJECT,
|
|
4870
|
+
properties: {
|
|
4871
|
+
agent_name: {
|
|
4872
|
+
type: _genai.Type.STRING,
|
|
4873
|
+
description: "The name of the agent to transfer control to"
|
|
4874
|
+
}
|
|
4875
|
+
},
|
|
4876
|
+
required: ["agent_name"]
|
|
4877
|
+
}
|
|
4878
|
+
};
|
|
4593
4879
|
}
|
|
4594
4880
|
/**
|
|
4595
4881
|
* Execute the transfer to agent action
|
|
@@ -4598,13 +4884,14 @@ var TransferToAgentTool = (_class16 = class extends BaseTool {
|
|
|
4598
4884
|
this.logger.debug(`Executing transfer to agent: ${args.agent_name}`);
|
|
4599
4885
|
context.actions.transferToAgent = args.agent_name;
|
|
4600
4886
|
}
|
|
4601
|
-
},
|
|
4887
|
+
}, _class19);
|
|
4602
4888
|
|
|
4603
4889
|
// src/tools/common/load-memory-tool.ts
|
|
4604
4890
|
init_logger();
|
|
4605
4891
|
init_base_tool();
|
|
4606
|
-
|
|
4607
|
-
|
|
4892
|
+
|
|
4893
|
+
var LoadMemoryTool = (_class20 = class extends BaseTool {
|
|
4894
|
+
__init30() {this.logger = new Logger({ name: "LoadMemoryTool" })}
|
|
4608
4895
|
/**
|
|
4609
4896
|
* Constructor for LoadMemoryTool
|
|
4610
4897
|
*/
|
|
@@ -4612,7 +4899,7 @@ var LoadMemoryTool = (_class17 = class extends BaseTool {
|
|
|
4612
4899
|
super({
|
|
4613
4900
|
name: "load_memory",
|
|
4614
4901
|
description: "Loads the memory for the current user based on a query."
|
|
4615
|
-
});
|
|
4902
|
+
});_class20.prototype.__init30.call(this);;
|
|
4616
4903
|
}
|
|
4617
4904
|
/**
|
|
4618
4905
|
* Get the function declaration for the tool
|
|
@@ -4622,10 +4909,10 @@ var LoadMemoryTool = (_class17 = class extends BaseTool {
|
|
|
4622
4909
|
name: this.name,
|
|
4623
4910
|
description: this.description,
|
|
4624
4911
|
parameters: {
|
|
4625
|
-
type:
|
|
4912
|
+
type: _genai.Type.OBJECT,
|
|
4626
4913
|
properties: {
|
|
4627
4914
|
query: {
|
|
4628
|
-
type:
|
|
4915
|
+
type: _genai.Type.STRING,
|
|
4629
4916
|
description: "The query to load memories for"
|
|
4630
4917
|
}
|
|
4631
4918
|
},
|
|
@@ -4642,7 +4929,7 @@ var LoadMemoryTool = (_class17 = class extends BaseTool {
|
|
|
4642
4929
|
const searchResult = await context.searchMemory(args.query);
|
|
4643
4930
|
return {
|
|
4644
4931
|
memories: searchResult.memories || [],
|
|
4645
|
-
count: _optionalChain([searchResult, 'access',
|
|
4932
|
+
count: _optionalChain([searchResult, 'access', _146 => _146.memories, 'optionalAccess', _147 => _147.length]) || 0
|
|
4646
4933
|
};
|
|
4647
4934
|
} catch (error) {
|
|
4648
4935
|
console.error("Error searching memory:", error);
|
|
@@ -4652,10 +4939,11 @@ var LoadMemoryTool = (_class17 = class extends BaseTool {
|
|
|
4652
4939
|
};
|
|
4653
4940
|
}
|
|
4654
4941
|
}
|
|
4655
|
-
},
|
|
4942
|
+
}, _class20);
|
|
4656
4943
|
|
|
4657
4944
|
// src/tools/common/load-artifacts-tool.ts
|
|
4658
4945
|
init_base_tool();
|
|
4946
|
+
|
|
4659
4947
|
var LoadArtifactsTool = class extends BaseTool {
|
|
4660
4948
|
constructor() {
|
|
4661
4949
|
super({
|
|
@@ -4671,12 +4959,12 @@ var LoadArtifactsTool = class extends BaseTool {
|
|
|
4671
4959
|
name: this.name,
|
|
4672
4960
|
description: this.description,
|
|
4673
4961
|
parameters: {
|
|
4674
|
-
type:
|
|
4962
|
+
type: _genai.Type.OBJECT,
|
|
4675
4963
|
properties: {
|
|
4676
4964
|
artifact_names: {
|
|
4677
|
-
type:
|
|
4965
|
+
type: _genai.Type.ARRAY,
|
|
4678
4966
|
items: {
|
|
4679
|
-
type:
|
|
4967
|
+
type: _genai.Type.STRING
|
|
4680
4968
|
},
|
|
4681
4969
|
description: "List of artifact names to load"
|
|
4682
4970
|
}
|
|
@@ -4803,10 +5091,10 @@ var McpError = class extends Error {
|
|
|
4803
5091
|
};
|
|
4804
5092
|
|
|
4805
5093
|
// src/tools/mcp/sampling-handler.ts
|
|
4806
|
-
var McpSamplingHandler = (
|
|
4807
|
-
|
|
5094
|
+
var McpSamplingHandler = (_class21 = class {
|
|
5095
|
+
__init31() {this.logger = new Logger({ name: "McpSamplingHandler" })}
|
|
4808
5096
|
|
|
4809
|
-
constructor(samplingHandler) {;
|
|
5097
|
+
constructor(samplingHandler) {;_class21.prototype.__init31.call(this);
|
|
4810
5098
|
this.samplingHandler = samplingHandler;
|
|
4811
5099
|
}
|
|
4812
5100
|
/**
|
|
@@ -4991,7 +5279,7 @@ var McpSamplingHandler = (_class18 = class {
|
|
|
4991
5279
|
this.samplingHandler = handler;
|
|
4992
5280
|
this.logger.debug("ADK sampling handler updated");
|
|
4993
5281
|
}
|
|
4994
|
-
},
|
|
5282
|
+
}, _class21);
|
|
4995
5283
|
function createSamplingHandler(handler) {
|
|
4996
5284
|
return handler;
|
|
4997
5285
|
}
|
|
@@ -5025,14 +5313,14 @@ function withRetry(fn, instance, reinitMethod, maxRetries = 1) {
|
|
|
5025
5313
|
}
|
|
5026
5314
|
|
|
5027
5315
|
// src/tools/mcp/client.ts
|
|
5028
|
-
var McpClientService = (
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
constructor(config) {;
|
|
5316
|
+
var McpClientService = (_class22 = class {
|
|
5317
|
+
|
|
5318
|
+
__init32() {this.client = null}
|
|
5319
|
+
__init33() {this.transport = null}
|
|
5320
|
+
__init34() {this.isClosing = false}
|
|
5321
|
+
__init35() {this.mcpSamplingHandler = null}
|
|
5322
|
+
__init36() {this.logger = new Logger({ name: "McpClientService" })}
|
|
5323
|
+
constructor(config) {;_class22.prototype.__init32.call(this);_class22.prototype.__init33.call(this);_class22.prototype.__init34.call(this);_class22.prototype.__init35.call(this);_class22.prototype.__init36.call(this);
|
|
5036
5324
|
this.config = config;
|
|
5037
5325
|
if (config.samplingHandler) {
|
|
5038
5326
|
this.mcpSamplingHandler = new McpSamplingHandler(config.samplingHandler);
|
|
@@ -5198,7 +5486,7 @@ var McpClientService = (_class19 = class {
|
|
|
5198
5486
|
},
|
|
5199
5487
|
this,
|
|
5200
5488
|
async (instance) => await instance.reinitialize(),
|
|
5201
|
-
_optionalChain([this, 'access',
|
|
5489
|
+
_optionalChain([this, 'access', _148 => _148.config, 'access', _149 => _149.retryOptions, 'optionalAccess', _150 => _150.maxRetries]) || 2
|
|
5202
5490
|
);
|
|
5203
5491
|
return await wrappedCall();
|
|
5204
5492
|
} catch (error) {
|
|
@@ -5282,19 +5570,20 @@ var McpClientService = (_class19 = class {
|
|
|
5282
5570
|
this.mcpSamplingHandler = null;
|
|
5283
5571
|
if (this.client) {
|
|
5284
5572
|
try {
|
|
5285
|
-
_optionalChain([this, 'access',
|
|
5573
|
+
_optionalChain([this, 'access', _151 => _151.client, 'access', _152 => _152.removeRequestHandler, 'optionalCall', _153 => _153("sampling/createMessage")]);
|
|
5286
5574
|
} catch (error) {
|
|
5287
5575
|
this.logger.error("Failed to remove sampling handler:", error);
|
|
5288
5576
|
}
|
|
5289
5577
|
}
|
|
5290
5578
|
}
|
|
5291
|
-
},
|
|
5579
|
+
}, _class22);
|
|
5292
5580
|
|
|
5293
5581
|
// src/tools/mcp/create-tool.ts
|
|
5294
5582
|
init_logger();
|
|
5295
5583
|
init_base_tool();
|
|
5296
5584
|
|
|
5297
5585
|
// src/tools/mcp/schema-conversion.ts
|
|
5586
|
+
|
|
5298
5587
|
function adkToMcpToolType(tool) {
|
|
5299
5588
|
const declaration = tool.getDeclaration();
|
|
5300
5589
|
const params = declarationToJsonSchema(declaration);
|
|
@@ -5323,13 +5612,13 @@ function jsonSchemaToDeclaration(name, description, schema) {
|
|
|
5323
5612
|
parameters = schema;
|
|
5324
5613
|
} else {
|
|
5325
5614
|
parameters = {
|
|
5326
|
-
type:
|
|
5615
|
+
type: _genai.Type.OBJECT,
|
|
5327
5616
|
properties: schema
|
|
5328
5617
|
};
|
|
5329
5618
|
}
|
|
5330
5619
|
} else {
|
|
5331
5620
|
parameters = {
|
|
5332
|
-
type:
|
|
5621
|
+
type: _genai.Type.OBJECT,
|
|
5333
5622
|
properties: {}
|
|
5334
5623
|
};
|
|
5335
5624
|
}
|
|
@@ -5341,7 +5630,7 @@ function jsonSchemaToDeclaration(name, description, schema) {
|
|
|
5341
5630
|
}
|
|
5342
5631
|
function normalizeJsonSchema(schema) {
|
|
5343
5632
|
if (!schema) {
|
|
5344
|
-
return { type:
|
|
5633
|
+
return { type: _genai.Type.OBJECT, properties: {} };
|
|
5345
5634
|
}
|
|
5346
5635
|
const normalizedSchema = { ...schema };
|
|
5347
5636
|
if (!normalizedSchema.type) {
|
|
@@ -5358,39 +5647,39 @@ function normalizeJsonSchema(schema) {
|
|
|
5358
5647
|
case "integer":
|
|
5359
5648
|
return normalizeNumberSchema(normalizedSchema);
|
|
5360
5649
|
case "boolean":
|
|
5361
|
-
return { type:
|
|
5650
|
+
return { type: _genai.Type.BOOLEAN };
|
|
5362
5651
|
case "null":
|
|
5363
|
-
return { type:
|
|
5652
|
+
return { type: _genai.Type.NULL };
|
|
5364
5653
|
default:
|
|
5365
5654
|
return normalizedSchema;
|
|
5366
5655
|
}
|
|
5367
5656
|
}
|
|
5368
5657
|
function determineSchemaType(schema) {
|
|
5369
5658
|
if (schema.properties || schema.required || schema.additionalProperties !== void 0) {
|
|
5370
|
-
return
|
|
5659
|
+
return _genai.Type.OBJECT;
|
|
5371
5660
|
}
|
|
5372
5661
|
if (schema.items) {
|
|
5373
|
-
return
|
|
5662
|
+
return _genai.Type.ARRAY;
|
|
5374
5663
|
}
|
|
5375
5664
|
if (schema.enum !== void 0) {
|
|
5376
|
-
if (schema.enum.length === 0) return
|
|
5665
|
+
if (schema.enum.length === 0) return _genai.Type.STRING;
|
|
5377
5666
|
const firstItem = schema.enum[0];
|
|
5378
|
-
if (typeof firstItem === "string") return
|
|
5379
|
-
if (typeof firstItem === "number") return
|
|
5380
|
-
if (typeof firstItem === "boolean") return
|
|
5381
|
-
return
|
|
5667
|
+
if (typeof firstItem === "string") return _genai.Type.STRING;
|
|
5668
|
+
if (typeof firstItem === "number") return _genai.Type.NUMBER;
|
|
5669
|
+
if (typeof firstItem === "boolean") return _genai.Type.BOOLEAN;
|
|
5670
|
+
return _genai.Type.STRING;
|
|
5382
5671
|
}
|
|
5383
5672
|
if (schema.minLength !== void 0 || schema.maxLength !== void 0 || schema.pattern) {
|
|
5384
|
-
return
|
|
5673
|
+
return _genai.Type.STRING;
|
|
5385
5674
|
}
|
|
5386
5675
|
if (schema.minimum !== void 0 || schema.maximum !== void 0 || schema.exclusiveMinimum !== void 0 || schema.exclusiveMaximum !== void 0) {
|
|
5387
|
-
return schema.multipleOf === void 0 || schema.multipleOf % 1 === 0 ?
|
|
5676
|
+
return schema.multipleOf === void 0 || schema.multipleOf % 1 === 0 ? _genai.Type.INTEGER : _genai.Type.NUMBER;
|
|
5388
5677
|
}
|
|
5389
|
-
return
|
|
5678
|
+
return _genai.Type.OBJECT;
|
|
5390
5679
|
}
|
|
5391
5680
|
function normalizeObjectSchema(schema) {
|
|
5392
5681
|
const normalizedSchema = {
|
|
5393
|
-
type:
|
|
5682
|
+
type: _genai.Type.OBJECT,
|
|
5394
5683
|
properties: {}
|
|
5395
5684
|
};
|
|
5396
5685
|
if (schema.properties) {
|
|
@@ -5402,15 +5691,13 @@ function normalizeObjectSchema(schema) {
|
|
|
5402
5691
|
}
|
|
5403
5692
|
}
|
|
5404
5693
|
if (schema.required) normalizedSchema.required = schema.required;
|
|
5405
|
-
if (schema.additionalProperties !== void 0)
|
|
5406
|
-
normalizedSchema.additionalProperties = schema.additionalProperties;
|
|
5407
5694
|
if (schema.title) normalizedSchema.title = schema.title;
|
|
5408
5695
|
if (schema.description) normalizedSchema.description = schema.description;
|
|
5409
5696
|
return normalizedSchema;
|
|
5410
5697
|
}
|
|
5411
5698
|
function normalizeArraySchema(schema) {
|
|
5412
5699
|
const normalizedSchema = {
|
|
5413
|
-
type:
|
|
5700
|
+
type: _genai.Type.ARRAY
|
|
5414
5701
|
};
|
|
5415
5702
|
if (schema.items) {
|
|
5416
5703
|
normalizedSchema.items = normalizeJsonSchema(
|
|
@@ -5421,15 +5708,13 @@ function normalizeArraySchema(schema) {
|
|
|
5421
5708
|
normalizedSchema.minItems = schema.minItems;
|
|
5422
5709
|
if (schema.maxItems !== void 0)
|
|
5423
5710
|
normalizedSchema.maxItems = schema.maxItems;
|
|
5424
|
-
if (schema.uniqueItems !== void 0)
|
|
5425
|
-
normalizedSchema.uniqueItems = schema.uniqueItems;
|
|
5426
5711
|
if (schema.title) normalizedSchema.title = schema.title;
|
|
5427
5712
|
if (schema.description) normalizedSchema.description = schema.description;
|
|
5428
5713
|
return normalizedSchema;
|
|
5429
5714
|
}
|
|
5430
5715
|
function normalizeStringSchema(schema) {
|
|
5431
5716
|
const normalizedSchema = {
|
|
5432
|
-
type:
|
|
5717
|
+
type: _genai.Type.STRING
|
|
5433
5718
|
};
|
|
5434
5719
|
if (schema.minLength !== void 0)
|
|
5435
5720
|
normalizedSchema.minLength = schema.minLength;
|
|
@@ -5448,12 +5733,6 @@ function normalizeNumberSchema(schema) {
|
|
|
5448
5733
|
};
|
|
5449
5734
|
if (schema.minimum !== void 0) normalizedSchema.minimum = schema.minimum;
|
|
5450
5735
|
if (schema.maximum !== void 0) normalizedSchema.maximum = schema.maximum;
|
|
5451
|
-
if (schema.exclusiveMinimum !== void 0)
|
|
5452
|
-
normalizedSchema.exclusiveMinimum = schema.exclusiveMinimum;
|
|
5453
|
-
if (schema.exclusiveMaximum !== void 0)
|
|
5454
|
-
normalizedSchema.exclusiveMaximum = schema.exclusiveMaximum;
|
|
5455
|
-
if (schema.multipleOf !== void 0)
|
|
5456
|
-
normalizedSchema.multipleOf = schema.multipleOf;
|
|
5457
5736
|
if (schema.enum) normalizedSchema.enum = schema.enum;
|
|
5458
5737
|
if (schema.title) normalizedSchema.title = schema.title;
|
|
5459
5738
|
if (schema.description) normalizedSchema.description = schema.description;
|
|
@@ -5468,7 +5747,7 @@ function mcpSchemaToParameters(mcpTool) {
|
|
|
5468
5747
|
}
|
|
5469
5748
|
if (!schema) {
|
|
5470
5749
|
return {
|
|
5471
|
-
type:
|
|
5750
|
+
type: _genai.Type.OBJECT,
|
|
5472
5751
|
properties: {}
|
|
5473
5752
|
};
|
|
5474
5753
|
}
|
|
@@ -5490,11 +5769,11 @@ async function createTool2(mcpTool, client) {
|
|
|
5490
5769
|
throw error;
|
|
5491
5770
|
}
|
|
5492
5771
|
}
|
|
5493
|
-
var McpToolAdapter = (
|
|
5772
|
+
var McpToolAdapter = (_class23 = class extends BaseTool {
|
|
5494
5773
|
|
|
5495
5774
|
|
|
5496
|
-
|
|
5497
|
-
|
|
5775
|
+
__init37() {this.clientService = null}
|
|
5776
|
+
__init38() {this.logger = new Logger({ name: "McpToolAdapter" })}
|
|
5498
5777
|
constructor(mcpTool, client) {
|
|
5499
5778
|
const metadata = mcpTool.metadata || {};
|
|
5500
5779
|
super({
|
|
@@ -5503,7 +5782,7 @@ var McpToolAdapter = (_class20 = class extends BaseTool {
|
|
|
5503
5782
|
isLongRunning: _nullishCoalesce(metadata.isLongRunning, () => ( false)),
|
|
5504
5783
|
shouldRetryOnFailure: _nullishCoalesce(metadata.shouldRetryOnFailure, () => ( false)),
|
|
5505
5784
|
maxRetryAttempts: _nullishCoalesce(metadata.maxRetryAttempts, () => ( 3))
|
|
5506
|
-
});
|
|
5785
|
+
});_class23.prototype.__init37.call(this);_class23.prototype.__init38.call(this);;
|
|
5507
5786
|
this.mcpTool = mcpTool;
|
|
5508
5787
|
this.client = client;
|
|
5509
5788
|
if (client.reinitialize && typeof client.reinitialize === "function") {
|
|
@@ -5576,7 +5855,7 @@ var McpToolAdapter = (_class20 = class extends BaseTool {
|
|
|
5576
5855
|
throw error;
|
|
5577
5856
|
}
|
|
5578
5857
|
}
|
|
5579
|
-
},
|
|
5858
|
+
}, _class23);
|
|
5580
5859
|
|
|
5581
5860
|
// src/tools/mcp/servers.ts
|
|
5582
5861
|
function createMcpConfig(name, packageName, config = {}) {
|
|
@@ -5713,13 +5992,13 @@ function McpGeneric(packageName, config = {}, name) {
|
|
|
5713
5992
|
}
|
|
5714
5993
|
|
|
5715
5994
|
// src/tools/mcp/index.ts
|
|
5716
|
-
var McpToolset = (
|
|
5995
|
+
var McpToolset = (_class24 = class {
|
|
5717
5996
|
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
constructor(config, toolFilter = null) {;
|
|
5997
|
+
__init39() {this.clientService = null}
|
|
5998
|
+
__init40() {this.toolFilter = null}
|
|
5999
|
+
__init41() {this.tools = []}
|
|
6000
|
+
__init42() {this.isClosing = false}
|
|
6001
|
+
constructor(config, toolFilter = null) {;_class24.prototype.__init39.call(this);_class24.prototype.__init40.call(this);_class24.prototype.__init41.call(this);_class24.prototype.__init42.call(this);
|
|
5723
6002
|
this.config = config;
|
|
5724
6003
|
this.toolFilter = toolFilter;
|
|
5725
6004
|
this.clientService = new McpClientService(config);
|
|
@@ -5794,7 +6073,7 @@ var McpToolset = (_class21 = class {
|
|
|
5794
6073
|
"resource_closed_error" /* RESOURCE_CLOSED_ERROR */
|
|
5795
6074
|
);
|
|
5796
6075
|
}
|
|
5797
|
-
if (this.tools.length > 0 && !_optionalChain([this, 'access',
|
|
6076
|
+
if (this.tools.length > 0 && !_optionalChain([this, 'access', _154 => _154.config, 'access', _155 => _155.cacheConfig, 'optionalAccess', _156 => _156.enabled]) === false) {
|
|
5798
6077
|
return this.tools;
|
|
5799
6078
|
}
|
|
5800
6079
|
if (!this.clientService) {
|
|
@@ -5820,7 +6099,7 @@ var McpToolset = (_class21 = class {
|
|
|
5820
6099
|
}
|
|
5821
6100
|
}
|
|
5822
6101
|
}
|
|
5823
|
-
if (_optionalChain([this, 'access',
|
|
6102
|
+
if (_optionalChain([this, 'access', _157 => _157.config, 'access', _158 => _158.cacheConfig, 'optionalAccess', _159 => _159.enabled]) !== false) {
|
|
5824
6103
|
this.tools = tools;
|
|
5825
6104
|
}
|
|
5826
6105
|
return tools;
|
|
@@ -5880,7 +6159,7 @@ var McpToolset = (_class21 = class {
|
|
|
5880
6159
|
async dispose() {
|
|
5881
6160
|
await this.close();
|
|
5882
6161
|
}
|
|
5883
|
-
},
|
|
6162
|
+
}, _class24);
|
|
5884
6163
|
async function getMcpTools(config, toolFilter) {
|
|
5885
6164
|
const toolset = new McpToolset(config, toolFilter);
|
|
5886
6165
|
try {
|
|
@@ -5908,12 +6187,12 @@ function populateClientFunctionCallId(modelResponseEvent) {
|
|
|
5908
6187
|
}
|
|
5909
6188
|
}
|
|
5910
6189
|
function removeClientFunctionCallId(content) {
|
|
5911
|
-
if (_optionalChain([content, 'optionalAccess',
|
|
6190
|
+
if (_optionalChain([content, 'optionalAccess', _160 => _160.parts])) {
|
|
5912
6191
|
for (const part of content.parts) {
|
|
5913
|
-
if (_optionalChain([part, 'access',
|
|
6192
|
+
if (_optionalChain([part, 'access', _161 => _161.functionCall, 'optionalAccess', _162 => _162.id, 'optionalAccess', _163 => _163.startsWith, 'call', _164 => _164(AF_FUNCTION_CALL_ID_PREFIX)])) {
|
|
5914
6193
|
part.functionCall.id = void 0;
|
|
5915
6194
|
}
|
|
5916
|
-
if (_optionalChain([part, 'access',
|
|
6195
|
+
if (_optionalChain([part, 'access', _165 => _165.functionResponse, 'optionalAccess', _166 => _166.id, 'optionalAccess', _167 => _167.startsWith, 'call', _168 => _168(AF_FUNCTION_CALL_ID_PREFIX)])) {
|
|
5917
6196
|
part.functionResponse.id = void 0;
|
|
5918
6197
|
}
|
|
5919
6198
|
}
|
|
@@ -5961,7 +6240,7 @@ function generateAuthEvent(invocationContext, functionResponseEvent) {
|
|
|
5961
6240
|
}
|
|
5962
6241
|
async function handleFunctionCallsAsync(invocationContext, functionCallEvent, toolsDict, filters) {
|
|
5963
6242
|
const agent = invocationContext.agent;
|
|
5964
|
-
if (!
|
|
6243
|
+
if (!isLlmAgent2(agent)) {
|
|
5965
6244
|
return null;
|
|
5966
6245
|
}
|
|
5967
6246
|
const functionCalls = functionCallEvent.getFunctionCalls();
|
|
@@ -6058,7 +6337,7 @@ function mergeParallelFunctionResponseEvents(functionResponseEvents) {
|
|
|
6058
6337
|
}
|
|
6059
6338
|
const mergedParts = [];
|
|
6060
6339
|
for (const event of functionResponseEvents) {
|
|
6061
|
-
if (_optionalChain([event, 'access',
|
|
6340
|
+
if (_optionalChain([event, 'access', _169 => _169.content, 'optionalAccess', _170 => _170.parts])) {
|
|
6062
6341
|
for (const part of event.content.parts) {
|
|
6063
6342
|
mergedParts.push(part);
|
|
6064
6343
|
}
|
|
@@ -6085,16 +6364,16 @@ function mergeParallelFunctionResponseEvents(functionResponseEvents) {
|
|
|
6085
6364
|
mergedEvent.timestamp = baseEvent.timestamp;
|
|
6086
6365
|
return mergedEvent;
|
|
6087
6366
|
}
|
|
6088
|
-
function
|
|
6367
|
+
function isLlmAgent2(agent) {
|
|
6089
6368
|
return agent && typeof agent === "object" && "canonicalModel" in agent;
|
|
6090
6369
|
}
|
|
6091
6370
|
|
|
6092
6371
|
// src/flows/llm-flows/base-llm-flow.ts
|
|
6093
6372
|
var _ADK_AGENT_NAME_LABEL_KEY = "adk_agent_name";
|
|
6094
|
-
var BaseLlmFlow = (
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6373
|
+
var BaseLlmFlow = (_class25 = class {constructor() { _class25.prototype.__init43.call(this);_class25.prototype.__init44.call(this);_class25.prototype.__init45.call(this); }
|
|
6374
|
+
__init43() {this.requestProcessors = []}
|
|
6375
|
+
__init44() {this.responseProcessors = []}
|
|
6376
|
+
__init45() {this.logger = new Logger({ name: "BaseLlmFlow" })}
|
|
6098
6377
|
async *runAsync(invocationContext) {
|
|
6099
6378
|
this.logger.info(`Agent '${invocationContext.agent.name}' started.`);
|
|
6100
6379
|
let stepCount = 0;
|
|
@@ -6186,7 +6465,7 @@ var BaseLlmFlow = (_class22 = class {constructor() { _class22.prototype.__init39
|
|
|
6186
6465
|
if (tools.length > 0) {
|
|
6187
6466
|
const toolsData = tools.map((tool) => ({
|
|
6188
6467
|
Name: tool.name,
|
|
6189
|
-
Description: _optionalChain([tool, 'access',
|
|
6468
|
+
Description: _optionalChain([tool, 'access', _171 => _171.description, 'optionalAccess', _172 => _172.substring, 'call', _173 => _173(0, 50)]) + (_optionalChain([tool, 'access', _174 => _174.description, 'optionalAccess', _175 => _175.length]) > 50 ? "..." : ""),
|
|
6190
6469
|
"Long Running": tool.isLongRunning ? "Yes" : "No"
|
|
6191
6470
|
}));
|
|
6192
6471
|
this.logger.debugArray("\u{1F6E0}\uFE0F Available Tools", toolsData);
|
|
@@ -6249,14 +6528,14 @@ var BaseLlmFlow = (_class22 = class {constructor() { _class22.prototype.__init39
|
|
|
6249
6528
|
);
|
|
6250
6529
|
if (functionResponseEvent) {
|
|
6251
6530
|
yield functionResponseEvent;
|
|
6252
|
-
const transferToAgent = _optionalChain([functionResponseEvent, 'access',
|
|
6531
|
+
const transferToAgent = _optionalChain([functionResponseEvent, 'access', _176 => _176.actions, 'optionalAccess', _177 => _177.transferToAgent]);
|
|
6253
6532
|
if (transferToAgent) {
|
|
6254
6533
|
this.logger.info(`\u{1F504} Live transfer to agent '${transferToAgent}'`);
|
|
6255
6534
|
const agentToRun = this._getAgentToRun(
|
|
6256
6535
|
invocationContext,
|
|
6257
6536
|
transferToAgent
|
|
6258
6537
|
);
|
|
6259
|
-
for await (const event of _optionalChain([agentToRun, 'access',
|
|
6538
|
+
for await (const event of _optionalChain([agentToRun, 'access', _178 => _178.runLive, 'optionalCall', _179 => _179(invocationContext)]) || agentToRun.runAsync(invocationContext)) {
|
|
6260
6539
|
yield event;
|
|
6261
6540
|
}
|
|
6262
6541
|
}
|
|
@@ -6288,7 +6567,7 @@ var BaseLlmFlow = (_class22 = class {constructor() { _class22.prototype.__init39
|
|
|
6288
6567
|
yield authEvent;
|
|
6289
6568
|
}
|
|
6290
6569
|
yield functionResponseEvent;
|
|
6291
|
-
const transferToAgent = _optionalChain([functionResponseEvent, 'access',
|
|
6570
|
+
const transferToAgent = _optionalChain([functionResponseEvent, 'access', _180 => _180.actions, 'optionalAccess', _181 => _181.transferToAgent]);
|
|
6292
6571
|
if (transferToAgent) {
|
|
6293
6572
|
this.logger.info(`\u{1F504} Transferring to agent '${transferToAgent}'`);
|
|
6294
6573
|
const agentToRun = this._getAgentToRun(
|
|
@@ -6334,27 +6613,27 @@ var BaseLlmFlow = (_class22 = class {constructor() { _class22.prototype.__init39
|
|
|
6334
6613
|
}
|
|
6335
6614
|
invocationContext.incrementLlmCallCount();
|
|
6336
6615
|
const isStreaming = invocationContext.runConfig.streamingMode === "sse" /* SSE */;
|
|
6337
|
-
const tools = _optionalChain([llmRequest, 'access',
|
|
6616
|
+
const tools = _optionalChain([llmRequest, 'access', _182 => _182.config, 'optionalAccess', _183 => _183.tools]) || [];
|
|
6338
6617
|
const toolNames = tools.map((tool) => {
|
|
6339
6618
|
if (tool.functionDeclarations && Array.isArray(tool.functionDeclarations)) {
|
|
6340
6619
|
return tool.functionDeclarations.map((fn) => fn.name).join(", ");
|
|
6341
6620
|
}
|
|
6342
6621
|
if (tool.name) return tool.name;
|
|
6343
|
-
if (_optionalChain([tool, 'access',
|
|
6344
|
-
if (_optionalChain([tool, 'access',
|
|
6622
|
+
if (_optionalChain([tool, 'access', _184 => _184.function, 'optionalAccess', _185 => _185.name])) return tool.function.name;
|
|
6623
|
+
if (_optionalChain([tool, 'access', _186 => _186.function, 'optionalAccess', _187 => _187.function, 'optionalAccess', _188 => _188.name])) return tool.function.function.name;
|
|
6345
6624
|
return "unknown";
|
|
6346
6625
|
}).join(", ");
|
|
6347
6626
|
const systemInstruction = llmRequest.getSystemInstructionText() || "";
|
|
6348
6627
|
const truncatedSystemInstruction = systemInstruction.length > 100 ? `${systemInstruction.substring(0, 100)}...` : systemInstruction;
|
|
6349
|
-
const contentPreview = _optionalChain([llmRequest, 'access',
|
|
6628
|
+
const contentPreview = _optionalChain([llmRequest, 'access', _189 => _189.contents, 'optionalAccess', _190 => _190.length]) > 0 ? LogFormatter.formatContentPreview(llmRequest.contents[0]) : "none";
|
|
6350
6629
|
this.logger.debugStructured("\u{1F4E4} LLM Request", {
|
|
6351
6630
|
Model: llm.model,
|
|
6352
6631
|
Agent: invocationContext.agent.name,
|
|
6353
|
-
"Content Items": _optionalChain([llmRequest, 'access',
|
|
6632
|
+
"Content Items": _optionalChain([llmRequest, 'access', _191 => _191.contents, 'optionalAccess', _192 => _192.length]) || 0,
|
|
6354
6633
|
"Content Preview": contentPreview,
|
|
6355
6634
|
"System Instruction": truncatedSystemInstruction || "none",
|
|
6356
6635
|
"Available Tools": toolNames || "none",
|
|
6357
|
-
"Tool Count": _optionalChain([llmRequest, 'access',
|
|
6636
|
+
"Tool Count": _optionalChain([llmRequest, 'access', _193 => _193.config, 'optionalAccess', _194 => _194.tools, 'optionalAccess', _195 => _195.length]) || 0,
|
|
6358
6637
|
Streaming: isStreaming ? "Yes" : "No"
|
|
6359
6638
|
});
|
|
6360
6639
|
let responseCount = 0;
|
|
@@ -6369,8 +6648,8 @@ var BaseLlmFlow = (_class22 = class {constructor() { _class22.prototype.__init39
|
|
|
6369
6648
|
llmRequest,
|
|
6370
6649
|
llmResponse
|
|
6371
6650
|
);
|
|
6372
|
-
const tokenCount = _optionalChain([llmResponse, 'access',
|
|
6373
|
-
const functionCalls = _optionalChain([llmResponse, 'access',
|
|
6651
|
+
const tokenCount = _optionalChain([llmResponse, 'access', _196 => _196.usageMetadata, 'optionalAccess', _197 => _197.totalTokenCount]) || "unknown";
|
|
6652
|
+
const functionCalls = _optionalChain([llmResponse, 'access', _198 => _198.content, 'optionalAccess', _199 => _199.parts, 'optionalAccess', _200 => _200.filter, 'call', _201 => _201((part) => part.functionCall)]) || [];
|
|
6374
6653
|
const functionCallsDisplay = LogFormatter.formatFunctionCalls(functionCalls);
|
|
6375
6654
|
const responsePreview = LogFormatter.formatResponsePreview(llmResponse);
|
|
6376
6655
|
this.logger.debugStructured("\u{1F4E5} LLM Response", {
|
|
@@ -6466,7 +6745,7 @@ var BaseLlmFlow = (_class22 = class {constructor() { _class22.prototype.__init39
|
|
|
6466
6745
|
const llm = invocationContext.agent.canonicalModel;
|
|
6467
6746
|
return llm;
|
|
6468
6747
|
}
|
|
6469
|
-
},
|
|
6748
|
+
}, _class25);
|
|
6470
6749
|
|
|
6471
6750
|
// src/flows/llm-flows/base-llm-processor.ts
|
|
6472
6751
|
var BaseLlmRequestProcessor = class {
|
|
@@ -6514,7 +6793,7 @@ var EnhancedAuthConfig = class {
|
|
|
6514
6793
|
*/
|
|
6515
6794
|
generateCredentialKey() {
|
|
6516
6795
|
const schemeKey = this.authScheme.type || "unknown";
|
|
6517
|
-
const credentialKey = _optionalChain([this, 'access',
|
|
6796
|
+
const credentialKey = _optionalChain([this, 'access', _202 => _202.rawAuthCredential, 'optionalAccess', _203 => _203.type]) || "none";
|
|
6518
6797
|
const timestamp = Date.now();
|
|
6519
6798
|
return `adk_${schemeKey}_${credentialKey}_${timestamp}`;
|
|
6520
6799
|
}
|
|
@@ -6671,7 +6950,7 @@ var AuthLlmRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
|
6671
6950
|
*/
|
|
6672
6951
|
parseAndStoreAuthResponse(authHandler, invocationContext) {
|
|
6673
6952
|
try {
|
|
6674
|
-
const credentialKey = _optionalChain([authHandler, 'access',
|
|
6953
|
+
const credentialKey = _optionalChain([authHandler, 'access', _204 => _204.authConfig, 'access', _205 => _205.context, 'optionalAccess', _206 => _206.credentialKey]) || `temp:${Date.now()}`;
|
|
6675
6954
|
const fullCredentialKey = credentialKey.startsWith("temp:") ? credentialKey : `temp:${credentialKey}`;
|
|
6676
6955
|
invocationContext.session.state[fullCredentialKey] = authHandler.credential;
|
|
6677
6956
|
if (authHandler.authConfig.authScheme.type === "oauth2" || authHandler.authConfig.authScheme.type === "openIdConnect") {
|
|
@@ -6779,7 +7058,7 @@ var BuiltInCodeExecutor = class extends BaseCodeExecutor {
|
|
|
6779
7058
|
* Pre-process the LLM request for Gemini 2.0+ models to use the code execution tool
|
|
6780
7059
|
*/
|
|
6781
7060
|
processLlmRequest(llmRequest) {
|
|
6782
|
-
if (!_optionalChain([llmRequest, 'access',
|
|
7061
|
+
if (!_optionalChain([llmRequest, 'access', _207 => _207.model, 'optionalAccess', _208 => _208.startsWith, 'call', _209 => _209("gemini-2")])) {
|
|
6783
7062
|
throw new Error(
|
|
6784
7063
|
`Gemini code execution tool is not supported for model ${llmRequest.model}`
|
|
6785
7064
|
);
|
|
@@ -6816,7 +7095,7 @@ var CodeExecutionUtils = class _CodeExecutionUtils {
|
|
|
6816
7095
|
static isBase64Encoded(str) {
|
|
6817
7096
|
try {
|
|
6818
7097
|
return btoa(atob(str)) === str;
|
|
6819
|
-
} catch (
|
|
7098
|
+
} catch (e4) {
|
|
6820
7099
|
return false;
|
|
6821
7100
|
}
|
|
6822
7101
|
}
|
|
@@ -6824,7 +7103,7 @@ var CodeExecutionUtils = class _CodeExecutionUtils {
|
|
|
6824
7103
|
* Extracts the first code block from the content and truncates everything after it
|
|
6825
7104
|
*/
|
|
6826
7105
|
static extractCodeAndTruncateContent(content, codeBlockDelimiters) {
|
|
6827
|
-
if (!_optionalChain([content, 'optionalAccess',
|
|
7106
|
+
if (!_optionalChain([content, 'optionalAccess', _210 => _210.parts, 'optionalAccess', _211 => _211.length])) {
|
|
6828
7107
|
return null;
|
|
6829
7108
|
}
|
|
6830
7109
|
for (let idx = 0; idx < content.parts.length; idx++) {
|
|
@@ -6910,7 +7189,7 @@ ${fileNames}`);
|
|
|
6910
7189
|
* Converts the code execution parts to text parts in a Content
|
|
6911
7190
|
*/
|
|
6912
7191
|
static convertCodeExecutionParts(content, codeBlockDelimiter, executionResultDelimiters) {
|
|
6913
|
-
if (!_optionalChain([content, 'access',
|
|
7192
|
+
if (!_optionalChain([content, 'access', _212 => _212.parts, 'optionalAccess', _213 => _213.length])) {
|
|
6914
7193
|
return;
|
|
6915
7194
|
}
|
|
6916
7195
|
const lastPart = content.parts[content.parts.length - 1];
|
|
@@ -7303,7 +7582,7 @@ async function* runPostProcessor(invocationContext, llmResponse) {
|
|
|
7303
7582
|
function extractAndReplaceInlineFiles(codeExecutorContext, llmRequest) {
|
|
7304
7583
|
const allInputFiles = codeExecutorContext.getInputFiles();
|
|
7305
7584
|
const savedFileNames = new Set(allInputFiles.map((f) => f.name));
|
|
7306
|
-
for (let i = 0; i < (_optionalChain([llmRequest, 'access',
|
|
7585
|
+
for (let i = 0; i < (_optionalChain([llmRequest, 'access', _214 => _214.contents, 'optionalAccess', _215 => _215.length]) || 0); i++) {
|
|
7307
7586
|
const content = llmRequest.contents[i];
|
|
7308
7587
|
if (content.role !== "user" || !content.parts) {
|
|
7309
7588
|
continue;
|
|
@@ -7335,7 +7614,7 @@ Available file: \`${fileName}\`
|
|
|
7335
7614
|
}
|
|
7336
7615
|
function getOrSetExecutionId(invocationContext, codeExecutorContext) {
|
|
7337
7616
|
const agent = invocationContext.agent;
|
|
7338
|
-
if (!hasCodeExecutor(agent) || !_optionalChain([agent, 'access',
|
|
7617
|
+
if (!hasCodeExecutor(agent) || !_optionalChain([agent, 'access', _216 => _216.codeExecutor, 'optionalAccess', _217 => _217.stateful])) {
|
|
7339
7618
|
return void 0;
|
|
7340
7619
|
}
|
|
7341
7620
|
let executionId = codeExecutorContext.getExecutionId();
|
|
@@ -7566,7 +7845,7 @@ function rearrangeEventsForLatestFunctionResponse(events) {
|
|
|
7566
7845
|
continue;
|
|
7567
7846
|
}
|
|
7568
7847
|
const functionResponses2 = event.getFunctionResponses();
|
|
7569
|
-
if (_optionalChain([functionResponses2, 'optionalAccess',
|
|
7848
|
+
if (_optionalChain([functionResponses2, 'optionalAccess', _218 => _218.some, 'call', _219 => _219((fr) => fr.id && functionResponsesIds.has(fr.id))])) {
|
|
7570
7849
|
functionResponseEvents.push(event);
|
|
7571
7850
|
}
|
|
7572
7851
|
}
|
|
@@ -7665,7 +7944,7 @@ function mergeFunctionResponseEvents(functionResponseEvents) {
|
|
|
7665
7944
|
const partIndicesInMergedEvent = {};
|
|
7666
7945
|
for (let idx = 0; idx < partsInMergedEvent.length; idx++) {
|
|
7667
7946
|
const part = partsInMergedEvent[idx];
|
|
7668
|
-
if (_optionalChain([part, 'access',
|
|
7947
|
+
if (_optionalChain([part, 'access', _220 => _220.functionResponse, 'optionalAccess', _221 => _221.id])) {
|
|
7669
7948
|
partIndicesInMergedEvent[part.functionResponse.id] = idx;
|
|
7670
7949
|
}
|
|
7671
7950
|
}
|
|
@@ -7674,7 +7953,7 @@ function mergeFunctionResponseEvents(functionResponseEvents) {
|
|
|
7674
7953
|
throw new Error("There should be at least one function_response part.");
|
|
7675
7954
|
}
|
|
7676
7955
|
for (const part of event.content.parts) {
|
|
7677
|
-
if (_optionalChain([part, 'access',
|
|
7956
|
+
if (_optionalChain([part, 'access', _222 => _222.functionResponse, 'optionalAccess', _223 => _223.id])) {
|
|
7678
7957
|
const functionCallId = part.functionResponse.id;
|
|
7679
7958
|
if (functionCallId in partIndicesInMergedEvent) {
|
|
7680
7959
|
partsInMergedEvent[partIndicesInMergedEvent[functionCallId]] = part;
|
|
@@ -7924,7 +8203,7 @@ var PlanReActPlanner = class extends BasePlanner {
|
|
|
7924
8203
|
let firstFcPartIndex = -1;
|
|
7925
8204
|
for (let i = 0; i < responseParts.length; i++) {
|
|
7926
8205
|
if (responseParts[i].functionCall) {
|
|
7927
|
-
if (!_optionalChain([responseParts, 'access',
|
|
8206
|
+
if (!_optionalChain([responseParts, 'access', _224 => _224[i], 'access', _225 => _225.functionCall, 'optionalAccess', _226 => _226.name])) {
|
|
7928
8207
|
continue;
|
|
7929
8208
|
}
|
|
7930
8209
|
preservedParts.push(responseParts[i]);
|
|
@@ -7963,7 +8242,7 @@ var PlanReActPlanner = class extends BasePlanner {
|
|
|
7963
8242
|
* Handles non-function-call parts of the response
|
|
7964
8243
|
*/
|
|
7965
8244
|
_handleNonFunctionCallParts(responsePart, preservedParts) {
|
|
7966
|
-
if (_optionalChain([responsePart, 'access',
|
|
8245
|
+
if (_optionalChain([responsePart, 'access', _227 => _227.text, 'optionalAccess', _228 => _228.includes, 'call', _229 => _229(FINAL_ANSWER_TAG)])) {
|
|
7967
8246
|
const [reasoningText, finalAnswerText] = this._splitByLastPattern(
|
|
7968
8247
|
responsePart.text,
|
|
7969
8248
|
FINAL_ANSWER_TAG
|
|
@@ -8133,6 +8412,42 @@ function removeThoughtFromRequest(llmRequest) {
|
|
|
8133
8412
|
var requestProcessor7 = new NlPlanningRequestProcessor();
|
|
8134
8413
|
var responseProcessor2 = new NlPlanningResponseProcessor();
|
|
8135
8414
|
|
|
8415
|
+
// src/flows/llm-flows/shared-memory.ts
|
|
8416
|
+
var SharedMemoryRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
8417
|
+
async *runAsync(invocationContext, llmRequest) {
|
|
8418
|
+
const memoryService = invocationContext.memoryService;
|
|
8419
|
+
if (!memoryService) return;
|
|
8420
|
+
const lastUserEvent = invocationContext.session.events.findLast((e) => e.author === "user" && _optionalChain([e, 'access', _230 => _230.content, 'optionalAccess', _231 => _231.parts, 'optionalAccess', _232 => _232.length]));
|
|
8421
|
+
if (!lastUserEvent) return;
|
|
8422
|
+
const query = (_nullishCoalesce(lastUserEvent.content.parts, () => ( []))).map((p) => p.text || "").join(" ");
|
|
8423
|
+
const results = await memoryService.searchMemory({
|
|
8424
|
+
appName: invocationContext.appName,
|
|
8425
|
+
userId: invocationContext.userId,
|
|
8426
|
+
query
|
|
8427
|
+
});
|
|
8428
|
+
const sessionTexts = new Set(
|
|
8429
|
+
(llmRequest.contents || []).flatMap(
|
|
8430
|
+
(c) => _optionalChain([c, 'access', _233 => _233.parts, 'optionalAccess', _234 => _234.map, 'call', _235 => _235((p) => p.text)]) || []
|
|
8431
|
+
)
|
|
8432
|
+
);
|
|
8433
|
+
for (const memory of results.memories) {
|
|
8434
|
+
const memoryText = (_nullishCoalesce(memory.content.parts, () => ( []))).map((p) => p.text || "").join(" ");
|
|
8435
|
+
if (!sessionTexts.has(memoryText)) {
|
|
8436
|
+
llmRequest.contents = llmRequest.contents || [];
|
|
8437
|
+
llmRequest.contents.push({
|
|
8438
|
+
role: "user",
|
|
8439
|
+
parts: [
|
|
8440
|
+
{
|
|
8441
|
+
text: `[${memory.author}] said: ${memoryText}`
|
|
8442
|
+
}
|
|
8443
|
+
]
|
|
8444
|
+
});
|
|
8445
|
+
}
|
|
8446
|
+
}
|
|
8447
|
+
}
|
|
8448
|
+
};
|
|
8449
|
+
var sharedMemoryRequestProcessor = new SharedMemoryRequestProcessor();
|
|
8450
|
+
|
|
8136
8451
|
// src/flows/llm-flows/single-flow.ts
|
|
8137
8452
|
var SingleFlow = class extends BaseLlmFlow {
|
|
8138
8453
|
/**
|
|
@@ -8147,6 +8462,7 @@ var SingleFlow = class extends BaseLlmFlow {
|
|
|
8147
8462
|
requestProcessor6,
|
|
8148
8463
|
requestProcessor5,
|
|
8149
8464
|
requestProcessor4,
|
|
8465
|
+
sharedMemoryRequestProcessor,
|
|
8150
8466
|
// Some implementations of NL Planning mark planning contents as thoughts
|
|
8151
8467
|
// in the post processor. Since these need to be unmarked, NL Planning
|
|
8152
8468
|
// should be after contents.
|
|
@@ -8168,12 +8484,12 @@ var SingleFlow = class extends BaseLlmFlow {
|
|
|
8168
8484
|
};
|
|
8169
8485
|
|
|
8170
8486
|
// src/flows/llm-flows/agent-transfer.ts
|
|
8487
|
+
var _dedent = require('dedent'); var _dedent2 = _interopRequireDefault(_dedent);
|
|
8171
8488
|
var AgentTransferLlmRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
8172
8489
|
/**
|
|
8173
8490
|
* Processes agent transfer by adding transfer instructions and tools
|
|
8174
8491
|
* if the agent has transfer targets available
|
|
8175
8492
|
*/
|
|
8176
|
-
// eslint-disable-next-line @typescript-eslint/require-yield
|
|
8177
8493
|
async *runAsync(invocationContext, llmRequest) {
|
|
8178
8494
|
const agent = invocationContext.agent;
|
|
8179
8495
|
if (!("subAgents" in agent) || typeof agent.subAgents !== "object") {
|
|
@@ -8187,71 +8503,65 @@ var AgentTransferLlmRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
|
8187
8503
|
agent,
|
|
8188
8504
|
transferTargets
|
|
8189
8505
|
);
|
|
8190
|
-
|
|
8191
|
-
llmRequest.appendInstructions([transferInstructions]);
|
|
8192
|
-
} else {
|
|
8193
|
-
const existingInstructions = llmRequest.instructions || "";
|
|
8194
|
-
llmRequest.instructions = `${existingInstructions}
|
|
8195
|
-
|
|
8196
|
-
${transferInstructions}`;
|
|
8197
|
-
}
|
|
8506
|
+
llmRequest.appendInstructions([transferInstructions]);
|
|
8198
8507
|
const transferToAgentTool = new TransferToAgentTool();
|
|
8199
8508
|
const toolContext = new ToolContext(invocationContext);
|
|
8200
8509
|
await transferToAgentTool.processLlmRequest(toolContext, llmRequest);
|
|
8201
|
-
|
|
8202
|
-
|
|
8510
|
+
const shouldYield = false;
|
|
8511
|
+
if (shouldYield) {
|
|
8512
|
+
yield {};
|
|
8203
8513
|
}
|
|
8204
8514
|
}
|
|
8205
8515
|
};
|
|
8206
8516
|
function buildTargetAgentsInfo(targetAgent) {
|
|
8207
|
-
return `
|
|
8208
|
-
Agent name: ${targetAgent.name}
|
|
8209
|
-
Agent description: ${targetAgent.description}
|
|
8210
|
-
`;
|
|
8517
|
+
return _dedent2.default`
|
|
8518
|
+
Agent name: ${targetAgent.name}
|
|
8519
|
+
Agent description: ${targetAgent.description}
|
|
8520
|
+
`;
|
|
8211
8521
|
}
|
|
8212
8522
|
function buildTargetAgentsInstructions(agent, targetAgents) {
|
|
8213
8523
|
const lineBreak = "\n";
|
|
8214
8524
|
const transferFunctionName = "transfer_to_agent";
|
|
8215
|
-
let instructions = `
|
|
8216
|
-
You have a list of other agents to transfer to:
|
|
8525
|
+
let instructions = _dedent2.default`
|
|
8526
|
+
You have a list of other agents to transfer to:
|
|
8217
8527
|
|
|
8218
|
-
${targetAgents.map((targetAgent) => buildTargetAgentsInfo(targetAgent)).join(lineBreak)}
|
|
8528
|
+
${targetAgents.map((targetAgent) => buildTargetAgentsInfo(targetAgent)).join(lineBreak)}
|
|
8219
8529
|
|
|
8220
|
-
If you are the best to answer the question according to your description, you
|
|
8221
|
-
can answer it.
|
|
8530
|
+
If you are the best to answer the question according to your description, you
|
|
8531
|
+
can answer it.
|
|
8222
8532
|
|
|
8223
|
-
If another agent is better for answering the question according to its
|
|
8224
|
-
description, call \`${transferFunctionName}\` function to transfer the
|
|
8225
|
-
question to that agent. When transferring, do not generate any text other than
|
|
8226
|
-
the function call.
|
|
8533
|
+
If another agent is better for answering the question according to its
|
|
8534
|
+
description, call \`${transferFunctionName}\` function to transfer the
|
|
8535
|
+
question to that agent. When transferring, do not generate any text other than
|
|
8536
|
+
the function call.
|
|
8227
8537
|
`;
|
|
8228
8538
|
if (agent.parentAgent && !agent.disallowTransferToParent) {
|
|
8229
|
-
instructions += `
|
|
8230
|
-
Your parent agent is ${agent.parentAgent.name}. If neither the other agents nor
|
|
8231
|
-
you are best for answering the question according to the descriptions, transfer
|
|
8232
|
-
to your parent agent.
|
|
8233
|
-
`;
|
|
8539
|
+
instructions += _dedent2.default`
|
|
8540
|
+
Your parent agent is ${agent.parentAgent.name}. If neither the other agents nor
|
|
8541
|
+
you are best for answering the question according to the descriptions, transfer
|
|
8542
|
+
to your parent agent.
|
|
8543
|
+
`;
|
|
8234
8544
|
}
|
|
8235
8545
|
return instructions;
|
|
8236
8546
|
}
|
|
8237
8547
|
function getTransferTargets(agent) {
|
|
8238
|
-
const
|
|
8548
|
+
const targets = [];
|
|
8239
8549
|
if (agent.subAgents && Array.isArray(agent.subAgents)) {
|
|
8240
|
-
|
|
8550
|
+
targets.push(...agent.subAgents);
|
|
8241
8551
|
}
|
|
8242
8552
|
if (!agent.parentAgent || !("subAgents" in agent.parentAgent)) {
|
|
8243
|
-
return
|
|
8553
|
+
return targets;
|
|
8244
8554
|
}
|
|
8245
8555
|
if (!agent.disallowTransferToParent) {
|
|
8246
|
-
|
|
8556
|
+
targets.push(agent.parentAgent);
|
|
8247
8557
|
}
|
|
8248
8558
|
if (!agent.disallowTransferToPeers && agent.parentAgent.subAgents) {
|
|
8249
8559
|
const peerAgents = agent.parentAgent.subAgents.filter(
|
|
8250
8560
|
(peerAgent) => peerAgent.name !== agent.name
|
|
8251
8561
|
);
|
|
8252
|
-
|
|
8562
|
+
targets.push(...peerAgents);
|
|
8253
8563
|
}
|
|
8254
|
-
return
|
|
8564
|
+
return targets;
|
|
8255
8565
|
}
|
|
8256
8566
|
var requestProcessor8 = new AgentTransferLlmRequestProcessor();
|
|
8257
8567
|
|
|
@@ -8269,7 +8579,7 @@ var AutoFlow = class extends SingleFlow {
|
|
|
8269
8579
|
|
|
8270
8580
|
// src/agents/llm-agent.ts
|
|
8271
8581
|
init_function_tool();
|
|
8272
|
-
var LlmAgent = (
|
|
8582
|
+
var LlmAgent = (_class26 = class _LlmAgent extends BaseAgent {
|
|
8273
8583
|
/**
|
|
8274
8584
|
* The model to use for the agent
|
|
8275
8585
|
* When not set, the agent will inherit the model from its ancestor
|
|
@@ -8346,15 +8656,18 @@ var LlmAgent = (_class23 = class _LlmAgent extends BaseAgent {
|
|
|
8346
8656
|
*/
|
|
8347
8657
|
|
|
8348
8658
|
// Schema type - depends on specific implementation
|
|
8349
|
-
|
|
8659
|
+
__init46() {this.logger = new Logger({ name: "LlmAgent" })}
|
|
8350
8660
|
/**
|
|
8351
8661
|
* Constructor for LlmAgent
|
|
8352
8662
|
*/
|
|
8353
8663
|
constructor(config) {
|
|
8354
8664
|
super({
|
|
8355
8665
|
name: config.name,
|
|
8356
|
-
description: config.description
|
|
8357
|
-
|
|
8666
|
+
description: config.description,
|
|
8667
|
+
subAgents: config.subAgents,
|
|
8668
|
+
beforeAgentCallback: config.beforeAgentCallback,
|
|
8669
|
+
afterAgentCallback: config.afterAgentCallback
|
|
8670
|
+
});_class26.prototype.__init46.call(this);;
|
|
8358
8671
|
this.model = config.model || "";
|
|
8359
8672
|
this.instruction = config.instruction || "";
|
|
8360
8673
|
this.globalInstruction = config.globalInstruction || "";
|
|
@@ -8440,7 +8753,7 @@ var LlmAgent = (_class23 = class _LlmAgent extends BaseAgent {
|
|
|
8440
8753
|
* This matches the Python implementation's _llm_flow property
|
|
8441
8754
|
*/
|
|
8442
8755
|
get llmFlow() {
|
|
8443
|
-
if (this.disallowTransferToParent && this.disallowTransferToPeers && !_optionalChain([this, 'access',
|
|
8756
|
+
if (this.disallowTransferToParent && this.disallowTransferToPeers && !_optionalChain([this, 'access', _236 => _236.subAgents, 'optionalAccess', _237 => _237.length])) {
|
|
8444
8757
|
return new SingleFlow();
|
|
8445
8758
|
}
|
|
8446
8759
|
return new AutoFlow();
|
|
@@ -8450,7 +8763,7 @@ var LlmAgent = (_class23 = class _LlmAgent extends BaseAgent {
|
|
|
8450
8763
|
* This matches the Python implementation's __maybe_save_output_to_state
|
|
8451
8764
|
*/
|
|
8452
8765
|
maybeSaveOutputToState(event) {
|
|
8453
|
-
if (this.outputKey && event.isFinalResponse() && _optionalChain([event, 'access',
|
|
8766
|
+
if (this.outputKey && event.isFinalResponse() && _optionalChain([event, 'access', _238 => _238.content, 'optionalAccess', _239 => _239.parts])) {
|
|
8454
8767
|
const result = event.content.parts.map((part) => part.text || "").join("");
|
|
8455
8768
|
if (result) {
|
|
8456
8769
|
if (!event.actions.stateDelta) {
|
|
@@ -8490,7 +8803,7 @@ var LlmAgent = (_class23 = class _LlmAgent extends BaseAgent {
|
|
|
8490
8803
|
yield errorEvent;
|
|
8491
8804
|
}
|
|
8492
8805
|
}
|
|
8493
|
-
},
|
|
8806
|
+
}, _class26);
|
|
8494
8807
|
|
|
8495
8808
|
// src/agents/sequential-agent.ts
|
|
8496
8809
|
var SequentialAgent = class extends BaseAgent {
|
|
@@ -8549,155 +8862,6 @@ do not generate any text other than the function call.`;
|
|
|
8549
8862
|
}
|
|
8550
8863
|
};
|
|
8551
8864
|
|
|
8552
|
-
// src/agents/invocation-context.ts
|
|
8553
|
-
var LlmCallsLimitExceededError = class extends Error {
|
|
8554
|
-
constructor(message) {
|
|
8555
|
-
super(message);
|
|
8556
|
-
this.name = "LlmCallsLimitExceededError";
|
|
8557
|
-
}
|
|
8558
|
-
};
|
|
8559
|
-
var InvocationCostManager = (_class24 = class {constructor() { _class24.prototype.__init43.call(this); }
|
|
8560
|
-
/**
|
|
8561
|
-
* A counter that keeps track of number of llm calls made.
|
|
8562
|
-
*/
|
|
8563
|
-
__init43() {this._numberOfLlmCalls = 0}
|
|
8564
|
-
/**
|
|
8565
|
-
* Increments _numberOfLlmCalls and enforces the limit.
|
|
8566
|
-
*/
|
|
8567
|
-
incrementAndEnforceLlmCallsLimit(runConfig) {
|
|
8568
|
-
this._numberOfLlmCalls += 1;
|
|
8569
|
-
if (runConfig && runConfig.maxLlmCalls > 0 && this._numberOfLlmCalls > runConfig.maxLlmCalls) {
|
|
8570
|
-
throw new LlmCallsLimitExceededError(
|
|
8571
|
-
`Max number of llm calls limit of \`${runConfig.maxLlmCalls}\` exceeded`
|
|
8572
|
-
);
|
|
8573
|
-
}
|
|
8574
|
-
}
|
|
8575
|
-
}, _class24);
|
|
8576
|
-
function newInvocationContextId() {
|
|
8577
|
-
return `e-${crypto.randomUUID()}`;
|
|
8578
|
-
}
|
|
8579
|
-
var InvocationContext = (_class25 = class _InvocationContext {
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
/**
|
|
8584
|
-
* The id of this invocation context. Readonly.
|
|
8585
|
-
*/
|
|
8586
|
-
|
|
8587
|
-
/**
|
|
8588
|
-
* The branch of the invocation context.
|
|
8589
|
-
*
|
|
8590
|
-
* The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of
|
|
8591
|
-
* agent_2, and agent_2 is the parent of agent_3.
|
|
8592
|
-
*
|
|
8593
|
-
* Branch is used when multiple sub-agents shouldn't see their peer agents'
|
|
8594
|
-
* conversation history.
|
|
8595
|
-
*/
|
|
8596
|
-
|
|
8597
|
-
/**
|
|
8598
|
-
* The current agent of this invocation context. Readonly.
|
|
8599
|
-
*/
|
|
8600
|
-
|
|
8601
|
-
/**
|
|
8602
|
-
* The user content that started this invocation. Readonly.
|
|
8603
|
-
*/
|
|
8604
|
-
|
|
8605
|
-
/**
|
|
8606
|
-
* The current session of this invocation context. Readonly.
|
|
8607
|
-
*/
|
|
8608
|
-
|
|
8609
|
-
/**
|
|
8610
|
-
* Whether to end this invocation.
|
|
8611
|
-
*
|
|
8612
|
-
* Set to True in callbacks or tools to terminate this invocation.
|
|
8613
|
-
*/
|
|
8614
|
-
__init44() {this.endInvocation = false}
|
|
8615
|
-
/**
|
|
8616
|
-
* The queue to receive live requests.
|
|
8617
|
-
*/
|
|
8618
|
-
|
|
8619
|
-
/**
|
|
8620
|
-
* The running streaming tools of this invocation.
|
|
8621
|
-
*/
|
|
8622
|
-
|
|
8623
|
-
/**
|
|
8624
|
-
* Caches necessary, data audio or contents, that are needed by transcription.
|
|
8625
|
-
*/
|
|
8626
|
-
|
|
8627
|
-
/**
|
|
8628
|
-
* Configurations for live agents under this invocation.
|
|
8629
|
-
*/
|
|
8630
|
-
|
|
8631
|
-
/**
|
|
8632
|
-
* A container to keep track of different kinds of costs incurred as a part
|
|
8633
|
-
* of this invocation.
|
|
8634
|
-
*/
|
|
8635
|
-
__init45() {this._invocationCostManager = new InvocationCostManager()}
|
|
8636
|
-
/**
|
|
8637
|
-
* Constructor for InvocationContext
|
|
8638
|
-
*/
|
|
8639
|
-
constructor(options) {;_class25.prototype.__init44.call(this);_class25.prototype.__init45.call(this);
|
|
8640
|
-
this.artifactService = options.artifactService;
|
|
8641
|
-
this.sessionService = options.sessionService;
|
|
8642
|
-
this.memoryService = options.memoryService;
|
|
8643
|
-
this.invocationId = options.invocationId || newInvocationContextId();
|
|
8644
|
-
this.branch = options.branch;
|
|
8645
|
-
this.agent = options.agent;
|
|
8646
|
-
this.userContent = options.userContent;
|
|
8647
|
-
this.session = options.session;
|
|
8648
|
-
this.endInvocation = options.endInvocation || false;
|
|
8649
|
-
this.liveRequestQueue = options.liveRequestQueue;
|
|
8650
|
-
this.activeStreamingTools = options.activeStreamingTools;
|
|
8651
|
-
this.transcriptionCache = options.transcriptionCache;
|
|
8652
|
-
this.runConfig = options.runConfig;
|
|
8653
|
-
}
|
|
8654
|
-
/**
|
|
8655
|
-
* App name from the session
|
|
8656
|
-
*/
|
|
8657
|
-
get appName() {
|
|
8658
|
-
return this.session.appName;
|
|
8659
|
-
}
|
|
8660
|
-
/**
|
|
8661
|
-
* User ID from the session
|
|
8662
|
-
*/
|
|
8663
|
-
get userId() {
|
|
8664
|
-
return this.session.userId;
|
|
8665
|
-
}
|
|
8666
|
-
/**
|
|
8667
|
-
* Tracks number of llm calls made.
|
|
8668
|
-
*
|
|
8669
|
-
* @throws {LlmCallsLimitExceededError} If number of llm calls made exceed the set threshold.
|
|
8670
|
-
*/
|
|
8671
|
-
incrementLlmCallCount() {
|
|
8672
|
-
this._invocationCostManager.incrementAndEnforceLlmCallsLimit(
|
|
8673
|
-
this.runConfig
|
|
8674
|
-
);
|
|
8675
|
-
}
|
|
8676
|
-
/**
|
|
8677
|
-
* Creates a child invocation context for a sub-agent
|
|
8678
|
-
*/
|
|
8679
|
-
createChildContext(agent) {
|
|
8680
|
-
return new _InvocationContext({
|
|
8681
|
-
artifactService: this.artifactService,
|
|
8682
|
-
sessionService: this.sessionService,
|
|
8683
|
-
memoryService: this.memoryService,
|
|
8684
|
-
invocationId: this.invocationId,
|
|
8685
|
-
// Keep same invocation ID
|
|
8686
|
-
branch: this.branch ? `${this.branch}.${agent.name}` : agent.name,
|
|
8687
|
-
// Update branch
|
|
8688
|
-
agent,
|
|
8689
|
-
// Update to the new agent
|
|
8690
|
-
userContent: this.userContent,
|
|
8691
|
-
session: this.session,
|
|
8692
|
-
endInvocation: this.endInvocation,
|
|
8693
|
-
liveRequestQueue: this.liveRequestQueue,
|
|
8694
|
-
activeStreamingTools: this.activeStreamingTools,
|
|
8695
|
-
transcriptionCache: this.transcriptionCache,
|
|
8696
|
-
runConfig: this.runConfig
|
|
8697
|
-
});
|
|
8698
|
-
}
|
|
8699
|
-
}, _class25);
|
|
8700
|
-
|
|
8701
8865
|
// src/agents/parallel-agent.ts
|
|
8702
8866
|
function createBranchContextForSubAgent(agent, subAgent, invocationContext) {
|
|
8703
8867
|
const branchSuffix = `${agent.name}.${subAgent.name}`;
|
|
@@ -8813,7 +8977,7 @@ var LoopAgent = class extends BaseAgent {
|
|
|
8813
8977
|
for (const subAgent of this.subAgents) {
|
|
8814
8978
|
for await (const event of subAgent.runAsync(ctx)) {
|
|
8815
8979
|
yield event;
|
|
8816
|
-
if (_optionalChain([event, 'access',
|
|
8980
|
+
if (_optionalChain([event, 'access', _240 => _240.actions, 'optionalAccess', _241 => _241.escalate])) {
|
|
8817
8981
|
return;
|
|
8818
8982
|
}
|
|
8819
8983
|
}
|
|
@@ -8831,7 +8995,7 @@ var LoopAgent = class extends BaseAgent {
|
|
|
8831
8995
|
|
|
8832
8996
|
// src/agents/lang-graph-agent.ts
|
|
8833
8997
|
init_logger();
|
|
8834
|
-
var LangGraphAgent = (
|
|
8998
|
+
var LangGraphAgent = (_class27 = class extends BaseAgent {
|
|
8835
8999
|
/**
|
|
8836
9000
|
* Graph nodes (agents and their connections)
|
|
8837
9001
|
*/
|
|
@@ -8847,8 +9011,8 @@ var LangGraphAgent = (_class26 = class extends BaseAgent {
|
|
|
8847
9011
|
/**
|
|
8848
9012
|
* Results from node executions
|
|
8849
9013
|
*/
|
|
8850
|
-
|
|
8851
|
-
|
|
9014
|
+
__init47() {this.results = []}
|
|
9015
|
+
__init48() {this.logger = new Logger({ name: "LangGraphAgent" })}
|
|
8852
9016
|
/**
|
|
8853
9017
|
* Constructor for LangGraphAgent
|
|
8854
9018
|
*/
|
|
@@ -8856,7 +9020,7 @@ var LangGraphAgent = (_class26 = class extends BaseAgent {
|
|
|
8856
9020
|
super({
|
|
8857
9021
|
name: config.name,
|
|
8858
9022
|
description: config.description
|
|
8859
|
-
});
|
|
9023
|
+
});_class27.prototype.__init47.call(this);_class27.prototype.__init48.call(this);;
|
|
8860
9024
|
this.nodes = /* @__PURE__ */ new Map();
|
|
8861
9025
|
for (const node of config.nodes) {
|
|
8862
9026
|
if (this.nodes.has(node.name)) {
|
|
@@ -9052,7 +9216,7 @@ var LangGraphAgent = (_class26 = class extends BaseAgent {
|
|
|
9052
9216
|
}
|
|
9053
9217
|
this.maxSteps = maxSteps;
|
|
9054
9218
|
}
|
|
9055
|
-
},
|
|
9219
|
+
}, _class27);
|
|
9056
9220
|
|
|
9057
9221
|
// src/agents/agent-builder.ts
|
|
9058
9222
|
|
|
@@ -9124,17 +9288,17 @@ var RunConfig = class {
|
|
|
9124
9288
|
*/
|
|
9125
9289
|
|
|
9126
9290
|
constructor(config) {
|
|
9127
|
-
this.speechConfig = _optionalChain([config, 'optionalAccess',
|
|
9128
|
-
this.responseModalities = _optionalChain([config, 'optionalAccess',
|
|
9129
|
-
this.saveInputBlobsAsArtifacts = _optionalChain([config, 'optionalAccess',
|
|
9130
|
-
this.supportCFC = _optionalChain([config, 'optionalAccess',
|
|
9131
|
-
this.streamingMode = _optionalChain([config, 'optionalAccess',
|
|
9132
|
-
this.outputAudioTranscription = _optionalChain([config, 'optionalAccess',
|
|
9133
|
-
this.inputAudioTranscription = _optionalChain([config, 'optionalAccess',
|
|
9134
|
-
this.realtimeInputConfig = _optionalChain([config, 'optionalAccess',
|
|
9135
|
-
this.enableAffectiveDialog = _optionalChain([config, 'optionalAccess',
|
|
9136
|
-
this.proactivity = _optionalChain([config, 'optionalAccess',
|
|
9137
|
-
this.maxLlmCalls = _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
9291
|
+
this.speechConfig = _optionalChain([config, 'optionalAccess', _242 => _242.speechConfig]);
|
|
9292
|
+
this.responseModalities = _optionalChain([config, 'optionalAccess', _243 => _243.responseModalities]);
|
|
9293
|
+
this.saveInputBlobsAsArtifacts = _optionalChain([config, 'optionalAccess', _244 => _244.saveInputBlobsAsArtifacts]) || false;
|
|
9294
|
+
this.supportCFC = _optionalChain([config, 'optionalAccess', _245 => _245.supportCFC]) || false;
|
|
9295
|
+
this.streamingMode = _optionalChain([config, 'optionalAccess', _246 => _246.streamingMode]) || "NONE" /* NONE */;
|
|
9296
|
+
this.outputAudioTranscription = _optionalChain([config, 'optionalAccess', _247 => _247.outputAudioTranscription]);
|
|
9297
|
+
this.inputAudioTranscription = _optionalChain([config, 'optionalAccess', _248 => _248.inputAudioTranscription]);
|
|
9298
|
+
this.realtimeInputConfig = _optionalChain([config, 'optionalAccess', _249 => _249.realtimeInputConfig]);
|
|
9299
|
+
this.enableAffectiveDialog = _optionalChain([config, 'optionalAccess', _250 => _250.enableAffectiveDialog]);
|
|
9300
|
+
this.proactivity = _optionalChain([config, 'optionalAccess', _251 => _251.proactivity]);
|
|
9301
|
+
this.maxLlmCalls = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _252 => _252.maxLlmCalls]), () => ( 500));
|
|
9138
9302
|
this.validateMaxLlmCalls();
|
|
9139
9303
|
}
|
|
9140
9304
|
/**
|
|
@@ -9155,8 +9319,8 @@ var RunConfig = class {
|
|
|
9155
9319
|
};
|
|
9156
9320
|
|
|
9157
9321
|
// src/artifacts/in-memory-artifact-service.ts
|
|
9158
|
-
var InMemoryArtifactService = (
|
|
9159
|
-
|
|
9322
|
+
var InMemoryArtifactService = (_class28 = class {constructor() { _class28.prototype.__init49.call(this); }
|
|
9323
|
+
__init49() {this.artifacts = /* @__PURE__ */ new Map()}
|
|
9160
9324
|
fileHasUserNamespace(filename) {
|
|
9161
9325
|
return filename.startsWith("user:");
|
|
9162
9326
|
}
|
|
@@ -9229,7 +9393,7 @@ var InMemoryArtifactService = (_class27 = class {constructor() { _class27.protot
|
|
|
9229
9393
|
}
|
|
9230
9394
|
return Array.from({ length: versions.length }, (_, i) => i);
|
|
9231
9395
|
}
|
|
9232
|
-
},
|
|
9396
|
+
}, _class28);
|
|
9233
9397
|
|
|
9234
9398
|
// src/runners.ts
|
|
9235
9399
|
init_logger();
|
|
@@ -9256,15 +9420,15 @@ function _extractWordsLower(text) {
|
|
|
9256
9420
|
const words = text.match(/[A-Za-z]+/g) || [];
|
|
9257
9421
|
return new Set(words.map((word) => word.toLowerCase()));
|
|
9258
9422
|
}
|
|
9259
|
-
var InMemoryMemoryService = (
|
|
9423
|
+
var InMemoryMemoryService = (_class29 = class {
|
|
9260
9424
|
/**
|
|
9261
9425
|
* Keys are app_name/user_id, session_id. Values are session event lists.
|
|
9262
9426
|
*/
|
|
9263
|
-
|
|
9427
|
+
__init50() {this._sessionEvents = /* @__PURE__ */ new Map()}
|
|
9264
9428
|
/**
|
|
9265
9429
|
* Constructor for InMemoryMemoryService
|
|
9266
9430
|
*/
|
|
9267
|
-
constructor() {;
|
|
9431
|
+
constructor() {;_class29.prototype.__init50.call(this);
|
|
9268
9432
|
this._sessionEvents = /* @__PURE__ */ new Map();
|
|
9269
9433
|
}
|
|
9270
9434
|
/**
|
|
@@ -9278,7 +9442,7 @@ var InMemoryMemoryService = (_class28 = class {
|
|
|
9278
9442
|
}
|
|
9279
9443
|
const userSessions = this._sessionEvents.get(userKey);
|
|
9280
9444
|
const filteredEvents = session.events.filter(
|
|
9281
|
-
(event) => _optionalChain([event, 'access',
|
|
9445
|
+
(event) => _optionalChain([event, 'access', _253 => _253.content, 'optionalAccess', _254 => _254.parts])
|
|
9282
9446
|
);
|
|
9283
9447
|
userSessions.set(session.id, filteredEvents);
|
|
9284
9448
|
}
|
|
@@ -9348,7 +9512,7 @@ var InMemoryMemoryService = (_class28 = class {
|
|
|
9348
9512
|
clear() {
|
|
9349
9513
|
this._sessionEvents.clear();
|
|
9350
9514
|
}
|
|
9351
|
-
},
|
|
9515
|
+
}, _class29);
|
|
9352
9516
|
|
|
9353
9517
|
// src/sessions/in-memory-session-service.ts
|
|
9354
9518
|
var _crypto = require('crypto');
|
|
@@ -9390,19 +9554,19 @@ var BaseSessionService = class {
|
|
|
9390
9554
|
};
|
|
9391
9555
|
|
|
9392
9556
|
// src/sessions/in-memory-session-service.ts
|
|
9393
|
-
var InMemorySessionService = (
|
|
9557
|
+
var InMemorySessionService = (_class30 = class extends BaseSessionService {constructor(...args2) { super(...args2); _class30.prototype.__init51.call(this);_class30.prototype.__init52.call(this);_class30.prototype.__init53.call(this); }
|
|
9394
9558
|
/**
|
|
9395
9559
|
* A map from app name to a map from user ID to a map from session ID to session.
|
|
9396
9560
|
*/
|
|
9397
|
-
|
|
9561
|
+
__init51() {this.sessions = /* @__PURE__ */ new Map()}
|
|
9398
9562
|
/**
|
|
9399
9563
|
* A map from app name to a map from user ID to a map from key to the value.
|
|
9400
9564
|
*/
|
|
9401
|
-
|
|
9565
|
+
__init52() {this.userState = /* @__PURE__ */ new Map()}
|
|
9402
9566
|
/**
|
|
9403
9567
|
* A map from app name to a map from key to the value.
|
|
9404
9568
|
*/
|
|
9405
|
-
|
|
9569
|
+
__init53() {this.appState = /* @__PURE__ */ new Map()}
|
|
9406
9570
|
/**
|
|
9407
9571
|
* Creates a new session.
|
|
9408
9572
|
*/
|
|
@@ -9417,7 +9581,7 @@ var InMemorySessionService = (_class29 = class extends BaseSessionService {const
|
|
|
9417
9581
|
return this.createSessionImpl(appName, userId, state, sessionId);
|
|
9418
9582
|
}
|
|
9419
9583
|
createSessionImpl(appName, userId, state, sessionId) {
|
|
9420
|
-
const finalSessionId = _optionalChain([sessionId, 'optionalAccess',
|
|
9584
|
+
const finalSessionId = _optionalChain([sessionId, 'optionalAccess', _255 => _255.trim, 'call', _256 => _256()]) || _crypto.randomUUID.call(void 0, );
|
|
9421
9585
|
const session = {
|
|
9422
9586
|
appName,
|
|
9423
9587
|
userId,
|
|
@@ -9574,7 +9738,7 @@ var InMemorySessionService = (_class29 = class extends BaseSessionService {const
|
|
|
9574
9738
|
warning(`sessionId ${sessionId} not in sessions[appName][userId]`);
|
|
9575
9739
|
return event;
|
|
9576
9740
|
}
|
|
9577
|
-
if (_optionalChain([event, 'access',
|
|
9741
|
+
if (_optionalChain([event, 'access', _257 => _257.actions, 'optionalAccess', _258 => _258.stateDelta])) {
|
|
9578
9742
|
for (const key in event.actions.stateDelta) {
|
|
9579
9743
|
const value = event.actions.stateDelta[key];
|
|
9580
9744
|
if (key.startsWith(State.APP_PREFIX)) {
|
|
@@ -9599,7 +9763,7 @@ var InMemorySessionService = (_class29 = class extends BaseSessionService {const
|
|
|
9599
9763
|
storageSession.lastUpdateTime = event.timestamp;
|
|
9600
9764
|
return event;
|
|
9601
9765
|
}
|
|
9602
|
-
},
|
|
9766
|
+
}, _class30);
|
|
9603
9767
|
|
|
9604
9768
|
// src/runners.ts
|
|
9605
9769
|
function _findFunctionCallEventIfLastEventIsFunctionResponse(session) {
|
|
@@ -9608,14 +9772,14 @@ function _findFunctionCallEventIfLastEventIsFunctionResponse(session) {
|
|
|
9608
9772
|
return null;
|
|
9609
9773
|
}
|
|
9610
9774
|
const lastEvent = events[events.length - 1];
|
|
9611
|
-
if (_optionalChain([lastEvent, 'access',
|
|
9612
|
-
const functionCallId = _optionalChain([lastEvent, 'access',
|
|
9775
|
+
if (_optionalChain([lastEvent, 'access', _259 => _259.content, 'optionalAccess', _260 => _260.parts, 'optionalAccess', _261 => _261.some, 'call', _262 => _262((part) => part.functionResponse)])) {
|
|
9776
|
+
const functionCallId = _optionalChain([lastEvent, 'access', _263 => _263.content, 'access', _264 => _264.parts, 'access', _265 => _265.find, 'call', _266 => _266(
|
|
9613
9777
|
(part) => part.functionResponse
|
|
9614
|
-
), 'optionalAccess',
|
|
9778
|
+
), 'optionalAccess', _267 => _267.functionResponse, 'optionalAccess', _268 => _268.id]);
|
|
9615
9779
|
if (!functionCallId) return null;
|
|
9616
9780
|
for (let i = events.length - 2; i >= 0; i--) {
|
|
9617
9781
|
const event = events[i];
|
|
9618
|
-
const functionCalls = _optionalChain([event, 'access',
|
|
9782
|
+
const functionCalls = _optionalChain([event, 'access', _269 => _269.getFunctionCalls, 'optionalCall', _270 => _270()]) || [];
|
|
9619
9783
|
for (const functionCall of functionCalls) {
|
|
9620
9784
|
if (functionCall.id === functionCallId) {
|
|
9621
9785
|
return event;
|
|
@@ -9625,7 +9789,7 @@ function _findFunctionCallEventIfLastEventIsFunctionResponse(session) {
|
|
|
9625
9789
|
}
|
|
9626
9790
|
return null;
|
|
9627
9791
|
}
|
|
9628
|
-
var Runner = (
|
|
9792
|
+
var Runner = (_class31 = class {
|
|
9629
9793
|
/**
|
|
9630
9794
|
* The app name of the runner.
|
|
9631
9795
|
*/
|
|
@@ -9646,7 +9810,7 @@ var Runner = (_class30 = class {
|
|
|
9646
9810
|
* The memory service for the runner.
|
|
9647
9811
|
*/
|
|
9648
9812
|
|
|
9649
|
-
|
|
9813
|
+
__init54() {this.logger = new Logger({ name: "Runner" })}
|
|
9650
9814
|
/**
|
|
9651
9815
|
* Initializes the Runner.
|
|
9652
9816
|
*/
|
|
@@ -9656,7 +9820,7 @@ var Runner = (_class30 = class {
|
|
|
9656
9820
|
artifactService,
|
|
9657
9821
|
sessionService,
|
|
9658
9822
|
memoryService
|
|
9659
|
-
}) {;
|
|
9823
|
+
}) {;_class31.prototype.__init54.call(this);
|
|
9660
9824
|
this.appName = appName;
|
|
9661
9825
|
this.agent = agent;
|
|
9662
9826
|
this.artifactService = artifactService;
|
|
@@ -9745,6 +9909,9 @@ var Runner = (_class30 = class {
|
|
|
9745
9909
|
)) {
|
|
9746
9910
|
if (!event.partial) {
|
|
9747
9911
|
await this.sessionService.appendEvent(session, event);
|
|
9912
|
+
if (this.memoryService) {
|
|
9913
|
+
await this.memoryService.addSessionToMemory(session);
|
|
9914
|
+
}
|
|
9748
9915
|
}
|
|
9749
9916
|
yield event;
|
|
9750
9917
|
}
|
|
@@ -9803,15 +9970,15 @@ var Runner = (_class30 = class {
|
|
|
9803
9970
|
*/
|
|
9804
9971
|
_findAgentToRun(session, rootAgent) {
|
|
9805
9972
|
const event = _findFunctionCallEventIfLastEventIsFunctionResponse(session);
|
|
9806
|
-
if (_optionalChain([event, 'optionalAccess',
|
|
9973
|
+
if (_optionalChain([event, 'optionalAccess', _271 => _271.author])) {
|
|
9807
9974
|
return rootAgent.findAgent(event.author);
|
|
9808
9975
|
}
|
|
9809
|
-
const nonUserEvents = _optionalChain([session, 'access',
|
|
9976
|
+
const nonUserEvents = _optionalChain([session, 'access', _272 => _272.events, 'optionalAccess', _273 => _273.filter, 'call', _274 => _274((e) => e.author !== "user"), 'access', _275 => _275.reverse, 'call', _276 => _276()]) || [];
|
|
9810
9977
|
for (const event2 of nonUserEvents) {
|
|
9811
9978
|
if (event2.author === rootAgent.name) {
|
|
9812
9979
|
return rootAgent;
|
|
9813
9980
|
}
|
|
9814
|
-
const agent = _optionalChain([rootAgent, 'access',
|
|
9981
|
+
const agent = _optionalChain([rootAgent, 'access', _277 => _277.findSubAgent, 'optionalCall', _278 => _278(event2.author)]);
|
|
9815
9982
|
if (!agent) {
|
|
9816
9983
|
this.logger.debug(
|
|
9817
9984
|
`Event from an unknown agent: ${event2.author}, event id: ${event2.id}`
|
|
@@ -9860,7 +10027,7 @@ var Runner = (_class30 = class {
|
|
|
9860
10027
|
runConfig
|
|
9861
10028
|
});
|
|
9862
10029
|
}
|
|
9863
|
-
},
|
|
10030
|
+
}, _class31);
|
|
9864
10031
|
var InMemoryRunner = class extends Runner {
|
|
9865
10032
|
/**
|
|
9866
10033
|
* Deprecated. Please don't use. The in-memory session service for the runner.
|
|
@@ -9883,16 +10050,18 @@ var InMemoryRunner = class extends Runner {
|
|
|
9883
10050
|
};
|
|
9884
10051
|
|
|
9885
10052
|
// src/agents/agent-builder.ts
|
|
9886
|
-
var AgentBuilder = (
|
|
10053
|
+
var AgentBuilder = (_class32 = class _AgentBuilder {
|
|
10054
|
+
|
|
10055
|
+
|
|
9887
10056
|
|
|
9888
10057
|
|
|
9889
10058
|
|
|
10059
|
+
__init55() {this.agentType = "llm"}
|
|
9890
10060
|
|
|
9891
|
-
__init54() {this.agentType = "llm"}
|
|
9892
10061
|
/**
|
|
9893
10062
|
* Private constructor - use static create() method
|
|
9894
10063
|
*/
|
|
9895
|
-
constructor(name) {;
|
|
10064
|
+
constructor(name) {;_class32.prototype.__init55.call(this);
|
|
9896
10065
|
this.config = { name };
|
|
9897
10066
|
}
|
|
9898
10067
|
/**
|
|
@@ -9956,6 +10125,51 @@ var AgentBuilder = (_class31 = class _AgentBuilder {
|
|
|
9956
10125
|
this.config.planner = planner;
|
|
9957
10126
|
return this;
|
|
9958
10127
|
}
|
|
10128
|
+
/**
|
|
10129
|
+
* Set the code executor for the agent
|
|
10130
|
+
* @param codeExecutor The code executor to use for running code
|
|
10131
|
+
* @returns This builder instance for chaining
|
|
10132
|
+
*/
|
|
10133
|
+
withCodeExecutor(codeExecutor) {
|
|
10134
|
+
this.config.codeExecutor = codeExecutor;
|
|
10135
|
+
return this;
|
|
10136
|
+
}
|
|
10137
|
+
/**
|
|
10138
|
+
* Set the output key for the agent
|
|
10139
|
+
* @param outputKey The output key in session state to store the output of the agent
|
|
10140
|
+
* @returns This builder instance for chaining
|
|
10141
|
+
*/
|
|
10142
|
+
withOutputKey(outputKey) {
|
|
10143
|
+
this.config.outputKey = outputKey;
|
|
10144
|
+
return this;
|
|
10145
|
+
}
|
|
10146
|
+
/**
|
|
10147
|
+
* Add sub-agents to the agent
|
|
10148
|
+
* @param subAgents Sub-agents to add to the agent
|
|
10149
|
+
* @returns This builder instance for chaining
|
|
10150
|
+
*/
|
|
10151
|
+
withSubAgents(subAgents) {
|
|
10152
|
+
this.config.subAgents = subAgents;
|
|
10153
|
+
return this;
|
|
10154
|
+
}
|
|
10155
|
+
/**
|
|
10156
|
+
* Set the before agent callback
|
|
10157
|
+
* @param callback Callback to invoke before agent execution
|
|
10158
|
+
* @returns This builder instance for chaining
|
|
10159
|
+
*/
|
|
10160
|
+
withBeforeAgentCallback(callback) {
|
|
10161
|
+
this.config.beforeAgentCallback = callback;
|
|
10162
|
+
return this;
|
|
10163
|
+
}
|
|
10164
|
+
/**
|
|
10165
|
+
* Set the after agent callback
|
|
10166
|
+
* @param callback Callback to invoke after agent execution
|
|
10167
|
+
* @returns This builder instance for chaining
|
|
10168
|
+
*/
|
|
10169
|
+
withAfterAgentCallback(callback) {
|
|
10170
|
+
this.config.afterAgentCallback = callback;
|
|
10171
|
+
return this;
|
|
10172
|
+
}
|
|
9959
10173
|
/**
|
|
9960
10174
|
* Configure as a sequential agent
|
|
9961
10175
|
* @param subAgents Sub-agents to execute in sequence
|
|
@@ -10006,14 +10220,38 @@ var AgentBuilder = (_class31 = class _AgentBuilder {
|
|
|
10006
10220
|
* @param options Session configuration options (userId and appName)
|
|
10007
10221
|
* @returns This builder instance for chaining
|
|
10008
10222
|
*/
|
|
10009
|
-
|
|
10010
|
-
this.
|
|
10011
|
-
|
|
10223
|
+
withSessionService(service, options = {}) {
|
|
10224
|
+
this.sessionService = service;
|
|
10225
|
+
this.sessionOptions = {
|
|
10012
10226
|
userId: options.userId || this.generateDefaultUserId(),
|
|
10013
|
-
appName: options.appName || this.generateDefaultAppName()
|
|
10227
|
+
appName: options.appName || this.generateDefaultAppName(),
|
|
10228
|
+
state: options.state,
|
|
10229
|
+
sessionId: options.sessionId
|
|
10014
10230
|
};
|
|
10015
10231
|
return this;
|
|
10016
10232
|
}
|
|
10233
|
+
/**
|
|
10234
|
+
* Configure with an existing session instance
|
|
10235
|
+
* @param session Existing session to use
|
|
10236
|
+
* @returns This builder instance for chaining
|
|
10237
|
+
* @throws Error if no session service has been configured via withSessionService()
|
|
10238
|
+
*/
|
|
10239
|
+
withSession(session) {
|
|
10240
|
+
if (!this.sessionService) {
|
|
10241
|
+
throw new Error(
|
|
10242
|
+
"Session service must be configured before using withSession(). Call withSessionService() first, or use withQuickSession() for in-memory sessions."
|
|
10243
|
+
);
|
|
10244
|
+
}
|
|
10245
|
+
this.sessionOptions = {
|
|
10246
|
+
...this.sessionOptions,
|
|
10247
|
+
userId: session.userId,
|
|
10248
|
+
appName: session.appName,
|
|
10249
|
+
sessionId: session.id,
|
|
10250
|
+
state: session.state
|
|
10251
|
+
};
|
|
10252
|
+
this.existingSession = session;
|
|
10253
|
+
return this;
|
|
10254
|
+
}
|
|
10017
10255
|
/**
|
|
10018
10256
|
* Configure memory service for the agent
|
|
10019
10257
|
* @param memoryService Memory service to use for conversation history and context
|
|
@@ -10039,7 +10277,7 @@ var AgentBuilder = (_class31 = class _AgentBuilder {
|
|
|
10039
10277
|
* @returns This builder instance for chaining
|
|
10040
10278
|
*/
|
|
10041
10279
|
withQuickSession(options = {}) {
|
|
10042
|
-
return this.
|
|
10280
|
+
return this.withSessionService(new InMemorySessionService(), options);
|
|
10043
10281
|
}
|
|
10044
10282
|
/**
|
|
10045
10283
|
* Build the agent and optionally create runner and session
|
|
@@ -10049,18 +10287,24 @@ var AgentBuilder = (_class31 = class _AgentBuilder {
|
|
|
10049
10287
|
const agent = this.createAgent();
|
|
10050
10288
|
let runner;
|
|
10051
10289
|
let session;
|
|
10052
|
-
if (!this.
|
|
10290
|
+
if (!this.sessionService) {
|
|
10053
10291
|
this.withQuickSession();
|
|
10054
10292
|
}
|
|
10055
|
-
if (this.
|
|
10056
|
-
|
|
10057
|
-
this.
|
|
10058
|
-
|
|
10059
|
-
|
|
10293
|
+
if (this.sessionService && this.sessionOptions) {
|
|
10294
|
+
if (this.existingSession) {
|
|
10295
|
+
session = this.existingSession;
|
|
10296
|
+
} else {
|
|
10297
|
+
session = await this.sessionService.createSession(
|
|
10298
|
+
this.sessionOptions.appName,
|
|
10299
|
+
this.sessionOptions.userId,
|
|
10300
|
+
this.sessionOptions.state,
|
|
10301
|
+
this.sessionOptions.sessionId
|
|
10302
|
+
);
|
|
10303
|
+
}
|
|
10060
10304
|
const runnerConfig = {
|
|
10061
|
-
appName: this.
|
|
10305
|
+
appName: this.sessionOptions.appName,
|
|
10062
10306
|
agent,
|
|
10063
|
-
sessionService: this.
|
|
10307
|
+
sessionService: this.sessionService,
|
|
10064
10308
|
memoryService: this.memoryService,
|
|
10065
10309
|
artifactService: this.artifactService
|
|
10066
10310
|
};
|
|
@@ -10095,7 +10339,15 @@ var AgentBuilder = (_class31 = class _AgentBuilder {
|
|
|
10095
10339
|
description: this.config.description,
|
|
10096
10340
|
instruction: this.config.instruction,
|
|
10097
10341
|
tools: this.config.tools,
|
|
10098
|
-
planner: this.config.planner
|
|
10342
|
+
planner: this.config.planner,
|
|
10343
|
+
codeExecutor: this.config.codeExecutor,
|
|
10344
|
+
subAgents: this.config.subAgents,
|
|
10345
|
+
beforeAgentCallback: this.config.beforeAgentCallback,
|
|
10346
|
+
afterAgentCallback: this.config.afterAgentCallback,
|
|
10347
|
+
memoryService: this.memoryService,
|
|
10348
|
+
artifactService: this.artifactService,
|
|
10349
|
+
outputKey: this.config.outputKey,
|
|
10350
|
+
sessionService: this.sessionService
|
|
10099
10351
|
});
|
|
10100
10352
|
}
|
|
10101
10353
|
case "sequential":
|
|
@@ -10160,20 +10412,20 @@ var AgentBuilder = (_class31 = class _AgentBuilder {
|
|
|
10160
10412
|
* @returns Enhanced runner with simplified API
|
|
10161
10413
|
*/
|
|
10162
10414
|
createEnhancedRunner(baseRunner, session) {
|
|
10163
|
-
const
|
|
10415
|
+
const sessionOptions = this.sessionOptions;
|
|
10164
10416
|
return {
|
|
10165
10417
|
async ask(message) {
|
|
10166
10418
|
const newMessage = typeof message === "string" ? { parts: [{ text: message }] } : typeof message === "object" && "contents" in message ? { parts: message.contents[message.contents.length - 1].parts } : message;
|
|
10167
10419
|
let response = "";
|
|
10168
|
-
if (!
|
|
10420
|
+
if (!_optionalChain([sessionOptions, 'optionalAccess', _279 => _279.userId])) {
|
|
10169
10421
|
throw new Error("Session configuration is required");
|
|
10170
10422
|
}
|
|
10171
10423
|
for await (const event of baseRunner.runAsync({
|
|
10172
|
-
userId:
|
|
10424
|
+
userId: sessionOptions.userId,
|
|
10173
10425
|
sessionId: session.id,
|
|
10174
10426
|
newMessage
|
|
10175
10427
|
})) {
|
|
10176
|
-
if (_optionalChain([event, 'access',
|
|
10428
|
+
if (_optionalChain([event, 'access', _280 => _280.content, 'optionalAccess', _281 => _281.parts]) && Array.isArray(event.content.parts)) {
|
|
10177
10429
|
const content = event.content.parts.map(
|
|
10178
10430
|
(part) => (part && typeof part === "object" && "text" in part ? part.text : "") || ""
|
|
10179
10431
|
).join("");
|
|
@@ -10182,14 +10434,14 @@ var AgentBuilder = (_class31 = class _AgentBuilder {
|
|
|
10182
10434
|
}
|
|
10183
10435
|
}
|
|
10184
10436
|
}
|
|
10185
|
-
return response;
|
|
10437
|
+
return response.trim();
|
|
10186
10438
|
},
|
|
10187
10439
|
runAsync(params) {
|
|
10188
10440
|
return baseRunner.runAsync(params);
|
|
10189
10441
|
}
|
|
10190
10442
|
};
|
|
10191
10443
|
}
|
|
10192
|
-
},
|
|
10444
|
+
}, _class32);
|
|
10193
10445
|
|
|
10194
10446
|
// src/memory/index.ts
|
|
10195
10447
|
var memory_exports = {};
|
|
@@ -10253,7 +10505,7 @@ var VertexAiSessionService = class extends BaseSessionService {
|
|
|
10253
10505
|
path: `operations/${operationId}`,
|
|
10254
10506
|
request_dict: {}
|
|
10255
10507
|
});
|
|
10256
|
-
if (_optionalChain([lroResponse, 'optionalAccess',
|
|
10508
|
+
if (_optionalChain([lroResponse, 'optionalAccess', _282 => _282.done])) {
|
|
10257
10509
|
break;
|
|
10258
10510
|
}
|
|
10259
10511
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
@@ -10523,11 +10775,11 @@ var VertexAiSessionService = class extends BaseSessionService {
|
|
|
10523
10775
|
|
|
10524
10776
|
// src/sessions/database-session-service.ts
|
|
10525
10777
|
var _kysely = require('kysely');
|
|
10526
|
-
var DatabaseSessionService = (
|
|
10778
|
+
var DatabaseSessionService = (_class33 = class extends BaseSessionService {
|
|
10527
10779
|
|
|
10528
|
-
|
|
10780
|
+
__init56() {this.initialized = false}
|
|
10529
10781
|
constructor(config) {
|
|
10530
|
-
super();
|
|
10782
|
+
super();_class33.prototype.__init56.call(this);;
|
|
10531
10783
|
this.db = config.db;
|
|
10532
10784
|
if (!config.skipTableCreation) {
|
|
10533
10785
|
this.initializeDatabase().catch((error) => {
|
|
@@ -10602,7 +10854,7 @@ var DatabaseSessionService = (_class32 = class extends BaseSessionService {
|
|
|
10602
10854
|
if (!jsonString) return defaultValue;
|
|
10603
10855
|
try {
|
|
10604
10856
|
return JSON.parse(jsonString);
|
|
10605
|
-
} catch (
|
|
10857
|
+
} catch (e5) {
|
|
10606
10858
|
return defaultValue;
|
|
10607
10859
|
}
|
|
10608
10860
|
}
|
|
@@ -10624,12 +10876,12 @@ var DatabaseSessionService = (_class32 = class extends BaseSessionService {
|
|
|
10624
10876
|
}
|
|
10625
10877
|
async createSession(appName, userId, state, sessionId) {
|
|
10626
10878
|
await this.ensureInitialized();
|
|
10627
|
-
const id = _optionalChain([sessionId, 'optionalAccess',
|
|
10879
|
+
const id = _optionalChain([sessionId, 'optionalAccess', _283 => _283.trim, 'call', _284 => _284()]) || this.generateSessionId();
|
|
10628
10880
|
return await this.db.transaction().execute(async (trx) => {
|
|
10629
10881
|
const appState = await trx.selectFrom("app_states").selectAll().where("app_name", "=", appName).executeTakeFirst();
|
|
10630
10882
|
const userState = await trx.selectFrom("user_states").selectAll().where("app_name", "=", appName).where("user_id", "=", userId).executeTakeFirst();
|
|
10631
|
-
let currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess',
|
|
10632
|
-
let currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess',
|
|
10883
|
+
let currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess', _285 => _285.state]), {});
|
|
10884
|
+
let currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess', _286 => _286.state]), {});
|
|
10633
10885
|
if (!appState) {
|
|
10634
10886
|
await trx.insertInto("app_states").values({
|
|
10635
10887
|
app_name: appName,
|
|
@@ -10688,21 +10940,21 @@ var DatabaseSessionService = (_class32 = class extends BaseSessionService {
|
|
|
10688
10940
|
return void 0;
|
|
10689
10941
|
}
|
|
10690
10942
|
let eventQuery = trx.selectFrom("events").selectAll().where("session_id", "=", sessionId).orderBy("timestamp", "desc");
|
|
10691
|
-
if (_optionalChain([config, 'optionalAccess',
|
|
10943
|
+
if (_optionalChain([config, 'optionalAccess', _287 => _287.afterTimestamp])) {
|
|
10692
10944
|
eventQuery = eventQuery.where(
|
|
10693
10945
|
"timestamp",
|
|
10694
10946
|
">=",
|
|
10695
10947
|
new Date(config.afterTimestamp * 1e3)
|
|
10696
10948
|
);
|
|
10697
10949
|
}
|
|
10698
|
-
if (_optionalChain([config, 'optionalAccess',
|
|
10950
|
+
if (_optionalChain([config, 'optionalAccess', _288 => _288.numRecentEvents])) {
|
|
10699
10951
|
eventQuery = eventQuery.limit(config.numRecentEvents);
|
|
10700
10952
|
}
|
|
10701
10953
|
const storageEvents = await eventQuery.execute();
|
|
10702
10954
|
const appState = await trx.selectFrom("app_states").selectAll().where("app_name", "=", appName).executeTakeFirst();
|
|
10703
10955
|
const userState = await trx.selectFrom("user_states").selectAll().where("app_name", "=", appName).where("user_id", "=", userId).executeTakeFirst();
|
|
10704
|
-
const currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess',
|
|
10705
|
-
const currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess',
|
|
10956
|
+
const currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess', _289 => _289.state]), {});
|
|
10957
|
+
const currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess', _290 => _290.state]), {});
|
|
10706
10958
|
const sessionState = this.parseJsonSafely(storageSession.state, {});
|
|
10707
10959
|
const mergedState = this.mergeState(
|
|
10708
10960
|
currentAppState,
|
|
@@ -10760,13 +11012,13 @@ var DatabaseSessionService = (_class32 = class extends BaseSessionService {
|
|
|
10760
11012
|
}
|
|
10761
11013
|
const appState = await trx.selectFrom("app_states").selectAll().where("app_name", "=", session.appName).executeTakeFirst();
|
|
10762
11014
|
const userState = await trx.selectFrom("user_states").selectAll().where("app_name", "=", session.appName).where("user_id", "=", session.userId).executeTakeFirst();
|
|
10763
|
-
let currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess',
|
|
10764
|
-
let currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess',
|
|
11015
|
+
let currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess', _291 => _291.state]), {});
|
|
11016
|
+
let currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess', _292 => _292.state]), {});
|
|
10765
11017
|
let sessionState = this.parseJsonSafely(storageSession.state, {});
|
|
10766
11018
|
let appStateDelta = {};
|
|
10767
11019
|
let userStateDelta = {};
|
|
10768
11020
|
let sessionStateDelta = {};
|
|
10769
|
-
if (_optionalChain([event, 'access',
|
|
11021
|
+
if (_optionalChain([event, 'access', _293 => _293.actions, 'optionalAccess', _294 => _294.stateDelta])) {
|
|
10770
11022
|
const deltas = this.extractStateDelta(event.actions.stateDelta);
|
|
10771
11023
|
appStateDelta = deltas.appStateDelta;
|
|
10772
11024
|
userStateDelta = deltas.userStateDelta;
|
|
@@ -10912,7 +11164,7 @@ var DatabaseSessionService = (_class32 = class extends BaseSessionService {
|
|
|
10912
11164
|
* Overrides the base class method to work with plain object state.
|
|
10913
11165
|
*/
|
|
10914
11166
|
updateSessionState(session, event) {
|
|
10915
|
-
if (!_optionalChain([event, 'access',
|
|
11167
|
+
if (!_optionalChain([event, 'access', _295 => _295.actions, 'optionalAccess', _296 => _296.stateDelta])) {
|
|
10916
11168
|
return;
|
|
10917
11169
|
}
|
|
10918
11170
|
for (const [key, value] of Object.entries(event.actions.stateDelta)) {
|
|
@@ -10921,10 +11173,10 @@ var DatabaseSessionService = (_class32 = class extends BaseSessionService {
|
|
|
10921
11173
|
}
|
|
10922
11174
|
}
|
|
10923
11175
|
}
|
|
10924
|
-
},
|
|
11176
|
+
}, _class33);
|
|
10925
11177
|
|
|
10926
11178
|
// src/sessions/database-factories.ts
|
|
10927
|
-
|
|
11179
|
+
|
|
10928
11180
|
|
|
10929
11181
|
function createDependencyError(packageName, dbType) {
|
|
10930
11182
|
return new Error(
|
|
@@ -11082,7 +11334,7 @@ var GcsArtifactService = class {
|
|
|
11082
11334
|
};
|
|
11083
11335
|
return part;
|
|
11084
11336
|
} catch (error) {
|
|
11085
|
-
if (_optionalChain([error, 'optionalAccess',
|
|
11337
|
+
if (_optionalChain([error, 'optionalAccess', _297 => _297.code]) === 404) {
|
|
11086
11338
|
return null;
|
|
11087
11339
|
}
|
|
11088
11340
|
throw error;
|
|
@@ -11328,4 +11580,5 @@ var VERSION = "0.1.0";
|
|
|
11328
11580
|
|
|
11329
11581
|
|
|
11330
11582
|
|
|
11331
|
-
|
|
11583
|
+
|
|
11584
|
+
exports.AF_FUNCTION_CALL_ID_PREFIX = AF_FUNCTION_CALL_ID_PREFIX; exports.Agent = LlmAgent; exports.AgentBuilder = AgentBuilder; exports.AgentTool = AgentTool; exports.Agents = agents_exports; exports.AiSdkLlm = AiSdkLlm; exports.AnthropicLlm = AnthropicLlm; exports.ApiKeyCredential = ApiKeyCredential; exports.ApiKeyScheme = ApiKeyScheme; exports.AuthConfig = AuthConfig; exports.AuthCredential = AuthCredential; exports.AuthCredentialType = AuthCredentialType; exports.AuthHandler = AuthHandler; exports.AuthScheme = AuthScheme; exports.AuthSchemeType = AuthSchemeType; exports.AuthTool = AuthTool; exports.AutoFlow = AutoFlow; exports.BaseAgent = BaseAgent; exports.BaseCodeExecutor = BaseCodeExecutor; exports.BaseLLMConnection = BaseLLMConnection; exports.BaseLlm = BaseLlm; exports.BaseLlmFlow = BaseLlmFlow; exports.BaseLlmRequestProcessor = BaseLlmRequestProcessor; exports.BaseLlmResponseProcessor = BaseLlmResponseProcessor; exports.BasePlanner = BasePlanner; exports.BaseSessionService = BaseSessionService; exports.BaseTool = BaseTool; exports.BasicAuthCredential = BasicAuthCredential; exports.BearerTokenCredential = BearerTokenCredential; exports.BuiltInCodeExecutor = BuiltInCodeExecutor; exports.BuiltInPlanner = BuiltInPlanner; exports.CallbackContext = CallbackContext; exports.CodeExecutionUtils = CodeExecutionUtils; exports.CodeExecutorContext = CodeExecutorContext; exports.DatabaseSessionService = DatabaseSessionService; exports.EnhancedAuthConfig = EnhancedAuthConfig; exports.Event = Event; exports.EventActions = EventActions; exports.Events = events_exports; exports.ExitLoopTool = ExitLoopTool; exports.FileOperationsTool = FileOperationsTool; exports.Flows = flows_exports; exports.FunctionTool = FunctionTool; exports.GcsArtifactService = GcsArtifactService; exports.GetUserChoiceTool = GetUserChoiceTool; exports.GoogleLlm = GoogleLlm; exports.GoogleSearch = GoogleSearch; exports.HttpRequestTool = HttpRequestTool; exports.HttpScheme = HttpScheme; exports.InMemoryArtifactService = InMemoryArtifactService; exports.InMemoryMemoryService = InMemoryMemoryService; exports.InMemoryRunner = InMemoryRunner; exports.InMemorySessionService = InMemorySessionService; exports.InvocationContext = InvocationContext; exports.LLMRegistry = LLMRegistry; exports.LangGraphAgent = LangGraphAgent; exports.LlmAgent = LlmAgent; exports.LlmCallsLimitExceededError = LlmCallsLimitExceededError; exports.LlmRequest = LlmRequest; exports.LlmResponse = LlmResponse; exports.LoadArtifactsTool = LoadArtifactsTool; exports.LoadMemoryTool = LoadMemoryTool; exports.LoopAgent = LoopAgent; exports.McpAbi = McpAbi; exports.McpAtp = McpAtp; exports.McpBamm = McpBamm; exports.McpCoinGecko = McpCoinGecko; exports.McpDiscord = McpDiscord; exports.McpError = McpError; exports.McpErrorType = McpErrorType; exports.McpFilesystem = McpFilesystem; exports.McpFraxlend = McpFraxlend; exports.McpGeneric = McpGeneric; exports.McpIqWiki = McpIqWiki; exports.McpMemory = McpMemory; exports.McpNearAgent = McpNearAgent; exports.McpNearIntents = McpNearIntents; exports.McpOdos = McpOdos; exports.McpSamplingHandler = McpSamplingHandler; exports.McpTelegram = McpTelegram; exports.McpToolset = McpToolset; exports.Memory = memory_exports; exports.Models = models_exports; exports.OAuth2Credential = OAuth2Credential; exports.OAuth2Scheme = OAuth2Scheme; exports.OpenAiLlm = OpenAiLlm; exports.OpenIdConnectScheme = OpenIdConnectScheme; exports.ParallelAgent = ParallelAgent; exports.PlanReActPlanner = PlanReActPlanner; exports.REQUEST_EUC_FUNCTION_CALL_NAME = REQUEST_EUC_FUNCTION_CALL_NAME; exports.ReadonlyContext = ReadonlyContext; exports.RunConfig = RunConfig; exports.Runner = Runner; exports.SequentialAgent = SequentialAgent; exports.Sessions = sessions_exports; exports.SingleFlow = SingleFlow; exports.State = State; exports.StreamingMode = StreamingMode; exports.TelemetryService = TelemetryService; exports.ToolContext = ToolContext; exports.Tools = tools_exports; exports.TransferToAgentTool = TransferToAgentTool; exports.UserInteractionTool = UserInteractionTool; exports.VERSION = VERSION; exports.VertexAiSessionService = VertexAiSessionService; exports._findFunctionCallEventIfLastEventIsFunctionResponse = _findFunctionCallEventIfLastEventIsFunctionResponse; exports.adkToMcpToolType = adkToMcpToolType; exports.agentTransferRequestProcessor = requestProcessor8; exports.basicRequestProcessor = requestProcessor2; exports.buildFunctionDeclaration = buildFunctionDeclaration; exports.codeExecutionRequestProcessor = requestProcessor3; exports.codeExecutionResponseProcessor = responseProcessor; exports.contentRequestProcessor = requestProcessor4; exports.createAuthToolArguments = createAuthToolArguments; exports.createBranchContextForSubAgent = createBranchContextForSubAgent; exports.createDatabaseSessionService = createDatabaseSessionService; exports.createFunctionTool = createFunctionTool; exports.createMysqlSessionService = createMysqlSessionService; exports.createPostgresSessionService = createPostgresSessionService; exports.createSamplingHandler = createSamplingHandler; exports.createSqliteSessionService = createSqliteSessionService; exports.createTool = createTool; exports.generateAuthEvent = generateAuthEvent; exports.generateClientFunctionCallId = generateClientFunctionCallId; exports.getLongRunningFunctionCalls = getLongRunningFunctionCalls; exports.getMcpTools = getMcpTools; exports.handleFunctionCallsAsync = handleFunctionCallsAsync; exports.handleFunctionCallsLive = handleFunctionCallsLive; exports.identityRequestProcessor = requestProcessor5; exports.initializeTelemetry = initializeTelemetry; exports.injectSessionState = injectSessionState; exports.instructionsRequestProcessor = requestProcessor6; exports.isEnhancedAuthConfig = isEnhancedAuthConfig; exports.jsonSchemaToDeclaration = jsonSchemaToDeclaration; exports.mcpSchemaToParameters = mcpSchemaToParameters; exports.mergeAgentRun = mergeAgentRun; exports.mergeParallelFunctionResponseEvents = mergeParallelFunctionResponseEvents; exports.newInvocationContextId = newInvocationContextId; exports.nlPlanningRequestProcessor = requestProcessor7; exports.nlPlanningResponseProcessor = responseProcessor2; exports.normalizeJsonSchema = normalizeJsonSchema; exports.populateClientFunctionCallId = populateClientFunctionCallId; exports.registerProviders = registerProviders; exports.removeClientFunctionCallId = removeClientFunctionCallId; exports.requestProcessor = requestProcessor; exports.shutdownTelemetry = shutdownTelemetry; exports.telemetryService = telemetryService; exports.traceLlmCall = traceLlmCall; exports.traceToolCall = traceToolCall; exports.tracer = tracer;
|