@iqai/adk 0.4.1 → 0.5.2
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 +26 -0
- package/dist/index.d.mts +202 -11
- package/dist/index.d.ts +202 -11
- package/dist/index.js +505 -125
- package/dist/index.mjs +403 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3389,6 +3389,11 @@ var EventActions = (_class10 = class {
|
|
|
3389
3389
|
* Requested authentication configurations.
|
|
3390
3390
|
*/
|
|
3391
3391
|
|
|
3392
|
+
/**
|
|
3393
|
+
* Event compaction information. When set, this event represents
|
|
3394
|
+
* a compaction of events within the specified timestamp range.
|
|
3395
|
+
*/
|
|
3396
|
+
|
|
3392
3397
|
/**
|
|
3393
3398
|
* Constructor for EventActions
|
|
3394
3399
|
*/
|
|
@@ -3399,6 +3404,7 @@ var EventActions = (_class10 = class {
|
|
|
3399
3404
|
this.transferToAgent = options.transferToAgent;
|
|
3400
3405
|
this.escalate = options.escalate;
|
|
3401
3406
|
this.requestedAuthConfigs = options.requestedAuthConfigs;
|
|
3407
|
+
this.compaction = options.compaction;
|
|
3402
3408
|
}
|
|
3403
3409
|
}, _class10);
|
|
3404
3410
|
|
|
@@ -3521,6 +3527,24 @@ var ReadonlyContext = class {
|
|
|
3521
3527
|
get agentName() {
|
|
3522
3528
|
return this._invocationContext.agent.name;
|
|
3523
3529
|
}
|
|
3530
|
+
/**
|
|
3531
|
+
* The application name for this invocation. READONLY field.
|
|
3532
|
+
*/
|
|
3533
|
+
get appName() {
|
|
3534
|
+
return this._invocationContext.appName;
|
|
3535
|
+
}
|
|
3536
|
+
/**
|
|
3537
|
+
* The user ID for this invocation. READONLY field.
|
|
3538
|
+
*/
|
|
3539
|
+
get userId() {
|
|
3540
|
+
return this._invocationContext.userId;
|
|
3541
|
+
}
|
|
3542
|
+
/**
|
|
3543
|
+
* The session ID for this invocation. READONLY field.
|
|
3544
|
+
*/
|
|
3545
|
+
get sessionId() {
|
|
3546
|
+
return this._invocationContext.session.id;
|
|
3547
|
+
}
|
|
3524
3548
|
/**
|
|
3525
3549
|
* The state of the current session. READONLY field.
|
|
3526
3550
|
*/
|
|
@@ -3923,9 +3947,196 @@ init_logger();
|
|
|
3923
3947
|
var events_exports = {};
|
|
3924
3948
|
__export(events_exports, {
|
|
3925
3949
|
Event: () => Event,
|
|
3926
|
-
EventActions: () => EventActions
|
|
3950
|
+
EventActions: () => EventActions,
|
|
3951
|
+
LlmEventSummarizer: () => LlmEventSummarizer,
|
|
3952
|
+
runCompactionForSlidingWindow: () => runCompactionForSlidingWindow
|
|
3927
3953
|
});
|
|
3928
3954
|
|
|
3955
|
+
// src/events/llm-event-summarizer.ts
|
|
3956
|
+
var DEFAULT_SUMMARIZATION_PROMPT = `You are a helpful assistant tasked with summarizing a conversation history.
|
|
3957
|
+
Please provide a concise summary of the following events, capturing the key information and context.
|
|
3958
|
+
Focus on the main topics discussed, important decisions made, and any action items or results.
|
|
3959
|
+
|
|
3960
|
+
Events to summarize:
|
|
3961
|
+
{events}
|
|
3962
|
+
|
|
3963
|
+
Provide your summary in a clear, concise format.`;
|
|
3964
|
+
var LlmEventSummarizer = class {
|
|
3965
|
+
|
|
3966
|
+
|
|
3967
|
+
/**
|
|
3968
|
+
* Creates a new LLM event summarizer.
|
|
3969
|
+
* @param model - The LLM model to use for summarization
|
|
3970
|
+
* @param prompt - Optional custom prompt template. Use {events} as placeholder for event content.
|
|
3971
|
+
*/
|
|
3972
|
+
constructor(model, prompt) {
|
|
3973
|
+
this.model = model;
|
|
3974
|
+
this.prompt = prompt || DEFAULT_SUMMARIZATION_PROMPT;
|
|
3975
|
+
}
|
|
3976
|
+
/**
|
|
3977
|
+
* Summarizes events using the configured LLM.
|
|
3978
|
+
*/
|
|
3979
|
+
async maybeSummarizeEvents(events) {
|
|
3980
|
+
if (!events || events.length === 0) {
|
|
3981
|
+
return void 0;
|
|
3982
|
+
}
|
|
3983
|
+
const eventsText = this.formatEventsForSummarization(events);
|
|
3984
|
+
const promptWithEvents = this.prompt.replace("{events}", eventsText);
|
|
3985
|
+
const llmRequest = new LlmRequest({
|
|
3986
|
+
contents: [
|
|
3987
|
+
{
|
|
3988
|
+
role: "user",
|
|
3989
|
+
parts: [{ text: promptWithEvents }]
|
|
3990
|
+
}
|
|
3991
|
+
]
|
|
3992
|
+
});
|
|
3993
|
+
let summaryText = "";
|
|
3994
|
+
for await (const response of this.model.generateContentAsync(llmRequest)) {
|
|
3995
|
+
summaryText += _optionalChain([response, 'access', _143 => _143.content, 'optionalAccess', _144 => _144.parts, 'optionalAccess', _145 => _145.map, 'call', _146 => _146((part) => part.text || ""), 'access', _147 => _147.join, 'call', _148 => _148("")]);
|
|
3996
|
+
}
|
|
3997
|
+
summaryText = summaryText.trim();
|
|
3998
|
+
if (!summaryText) {
|
|
3999
|
+
return void 0;
|
|
4000
|
+
}
|
|
4001
|
+
const summaryContent = {
|
|
4002
|
+
role: "model",
|
|
4003
|
+
parts: [{ text: summaryText }]
|
|
4004
|
+
};
|
|
4005
|
+
const compactionEvent = new Event({
|
|
4006
|
+
invocationId: Event.newId(),
|
|
4007
|
+
author: "user",
|
|
4008
|
+
actions: new EventActions({
|
|
4009
|
+
compaction: {
|
|
4010
|
+
startTimestamp: events[0].timestamp,
|
|
4011
|
+
endTimestamp: events[events.length - 1].timestamp,
|
|
4012
|
+
compactedContent: summaryContent
|
|
4013
|
+
}
|
|
4014
|
+
})
|
|
4015
|
+
});
|
|
4016
|
+
return compactionEvent;
|
|
4017
|
+
}
|
|
4018
|
+
/**
|
|
4019
|
+
* Formats events into a readable text format for summarization.
|
|
4020
|
+
*/
|
|
4021
|
+
formatEventsForSummarization(events) {
|
|
4022
|
+
const lines = [];
|
|
4023
|
+
for (const event of events) {
|
|
4024
|
+
const timestamp = new Date(event.timestamp * 1e3).toISOString();
|
|
4025
|
+
const author = event.author;
|
|
4026
|
+
if (_optionalChain([event, 'access', _149 => _149.content, 'optionalAccess', _150 => _150.parts])) {
|
|
4027
|
+
for (const part of event.content.parts) {
|
|
4028
|
+
if (part.text) {
|
|
4029
|
+
lines.push(`[${timestamp}] ${author}: ${part.text}`);
|
|
4030
|
+
} else if (part.functionCall) {
|
|
4031
|
+
lines.push(
|
|
4032
|
+
`[${timestamp}] ${author}: Called tool '${part.functionCall.name}' with args ${JSON.stringify(part.functionCall.args)}`
|
|
4033
|
+
);
|
|
4034
|
+
} else if (part.functionResponse) {
|
|
4035
|
+
lines.push(
|
|
4036
|
+
`[${timestamp}] ${author}: Tool '${part.functionResponse.name}' returned: ${JSON.stringify(part.functionResponse.response)}`
|
|
4037
|
+
);
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
}
|
|
4042
|
+
return lines.join("\n");
|
|
4043
|
+
}
|
|
4044
|
+
};
|
|
4045
|
+
|
|
4046
|
+
// src/events/compaction.ts
|
|
4047
|
+
init_logger();
|
|
4048
|
+
var logger = new Logger({ name: "EventCompaction" });
|
|
4049
|
+
async function runCompactionForSlidingWindow(config, session, sessionService, summarizer) {
|
|
4050
|
+
if (!session.events || session.events.length === 0) {
|
|
4051
|
+
return;
|
|
4052
|
+
}
|
|
4053
|
+
const lastCompactedEndTimestamp = findLastCompactedEndTimestamp(
|
|
4054
|
+
session.events
|
|
4055
|
+
);
|
|
4056
|
+
const latestTimestampByInvocation = buildLatestTimestampByInvocation(
|
|
4057
|
+
session.events
|
|
4058
|
+
);
|
|
4059
|
+
const uniqueInvocationIds = Array.from(latestTimestampByInvocation.keys());
|
|
4060
|
+
const newInvocationIds = uniqueInvocationIds.filter(
|
|
4061
|
+
(invId) => (latestTimestampByInvocation.get(invId) || 0) > lastCompactedEndTimestamp
|
|
4062
|
+
);
|
|
4063
|
+
if (newInvocationIds.length < config.compactionInterval) {
|
|
4064
|
+
logger.debug(
|
|
4065
|
+
`Not enough new invocations for compaction. Need ${config.compactionInterval}, have ${newInvocationIds.length}`
|
|
4066
|
+
);
|
|
4067
|
+
return;
|
|
4068
|
+
}
|
|
4069
|
+
const endInvId = newInvocationIds[newInvocationIds.length - 1];
|
|
4070
|
+
const firstNewInvId = newInvocationIds[0];
|
|
4071
|
+
const firstNewInvIdx = uniqueInvocationIds.indexOf(firstNewInvId);
|
|
4072
|
+
const startIdx = Math.max(0, firstNewInvIdx - config.overlapSize);
|
|
4073
|
+
const startInvId = uniqueInvocationIds[startIdx];
|
|
4074
|
+
logger.debug(
|
|
4075
|
+
`Compacting invocations from ${startInvId} to ${endInvId} (${newInvocationIds.length} new invocations, overlap: ${config.overlapSize})`
|
|
4076
|
+
);
|
|
4077
|
+
const eventsToCompact = sliceEventsByInvocationRange(
|
|
4078
|
+
session.events,
|
|
4079
|
+
startInvId,
|
|
4080
|
+
endInvId
|
|
4081
|
+
);
|
|
4082
|
+
if (eventsToCompact.length === 0) {
|
|
4083
|
+
logger.debug("No events to compact after filtering");
|
|
4084
|
+
return;
|
|
4085
|
+
}
|
|
4086
|
+
logger.debug(`Summarizing ${eventsToCompact.length} events`);
|
|
4087
|
+
const compactionEvent = await summarizer.maybeSummarizeEvents(eventsToCompact);
|
|
4088
|
+
if (compactionEvent) {
|
|
4089
|
+
logger.debug(
|
|
4090
|
+
`Compaction created covering timestamps ${_optionalChain([compactionEvent, 'access', _151 => _151.actions, 'access', _152 => _152.compaction, 'optionalAccess', _153 => _153.startTimestamp])} to ${_optionalChain([compactionEvent, 'access', _154 => _154.actions, 'access', _155 => _155.compaction, 'optionalAccess', _156 => _156.endTimestamp])}`
|
|
4091
|
+
);
|
|
4092
|
+
await sessionService.appendEvent(session, compactionEvent);
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
function findLastCompactedEndTimestamp(events) {
|
|
4096
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
4097
|
+
const event = events[i];
|
|
4098
|
+
if (_optionalChain([event, 'access', _157 => _157.actions, 'optionalAccess', _158 => _158.compaction])) {
|
|
4099
|
+
return event.actions.compaction.endTimestamp;
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
return 0;
|
|
4103
|
+
}
|
|
4104
|
+
function buildLatestTimestampByInvocation(events) {
|
|
4105
|
+
const latestByInvocation = /* @__PURE__ */ new Map();
|
|
4106
|
+
for (const event of events) {
|
|
4107
|
+
if (_optionalChain([event, 'access', _159 => _159.actions, 'optionalAccess', _160 => _160.compaction])) {
|
|
4108
|
+
continue;
|
|
4109
|
+
}
|
|
4110
|
+
const invId = event.invocationId;
|
|
4111
|
+
if (!invId) {
|
|
4112
|
+
continue;
|
|
4113
|
+
}
|
|
4114
|
+
const current = latestByInvocation.get(invId) || 0;
|
|
4115
|
+
if (event.timestamp > current) {
|
|
4116
|
+
latestByInvocation.set(invId, event.timestamp);
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
return latestByInvocation;
|
|
4120
|
+
}
|
|
4121
|
+
function sliceEventsByInvocationRange(events, startInvId, endInvId) {
|
|
4122
|
+
let firstIndex = -1;
|
|
4123
|
+
let lastIndex = -1;
|
|
4124
|
+
for (let i = 0; i < events.length; i++) {
|
|
4125
|
+
const event = events[i];
|
|
4126
|
+
if (event.invocationId === startInvId && firstIndex === -1) {
|
|
4127
|
+
firstIndex = i;
|
|
4128
|
+
}
|
|
4129
|
+
if (event.invocationId === endInvId) {
|
|
4130
|
+
lastIndex = i;
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4133
|
+
if (firstIndex === -1 || lastIndex === -1 || firstIndex > lastIndex) {
|
|
4134
|
+
return [];
|
|
4135
|
+
}
|
|
4136
|
+
const slicedEvents = events.slice(firstIndex, lastIndex + 1);
|
|
4137
|
+
return slicedEvents.filter((event) => !_optionalChain([event, 'access', _161 => _161.actions, 'optionalAccess', _162 => _162.compaction]));
|
|
4138
|
+
}
|
|
4139
|
+
|
|
3929
4140
|
// src/flows/llm-flows/base-llm-flow.ts
|
|
3930
4141
|
init_logger();
|
|
3931
4142
|
|
|
@@ -4079,6 +4290,7 @@ __export(tools_exports, {
|
|
|
4079
4290
|
McpAtp: () => McpAtp,
|
|
4080
4291
|
McpBamm: () => McpBamm,
|
|
4081
4292
|
McpCoinGecko: () => McpCoinGecko,
|
|
4293
|
+
McpCoinGeckoPro: () => McpCoinGeckoPro,
|
|
4082
4294
|
McpDiscord: () => McpDiscord,
|
|
4083
4295
|
McpError: () => McpError,
|
|
4084
4296
|
McpErrorType: () => McpErrorType,
|
|
@@ -4435,7 +4647,7 @@ var AgentTool = (_class15 = class extends BaseTool {
|
|
|
4435
4647
|
} catch (e3) {
|
|
4436
4648
|
toolResult = mergedText;
|
|
4437
4649
|
}
|
|
4438
|
-
if (this.outputKey && _optionalChain([context4, 'optionalAccess',
|
|
4650
|
+
if (this.outputKey && _optionalChain([context4, 'optionalAccess', _163 => _163.state])) {
|
|
4439
4651
|
context4.state[this.outputKey] = toolResult;
|
|
4440
4652
|
}
|
|
4441
4653
|
return toolResult;
|
|
@@ -4702,7 +4914,7 @@ var FileOperationsTool = class extends BaseTool {
|
|
|
4702
4914
|
name: "file_operations",
|
|
4703
4915
|
description: "Perform file system operations like reading, writing, and managing files"
|
|
4704
4916
|
});
|
|
4705
|
-
this.basePath = _optionalChain([options, 'optionalAccess',
|
|
4917
|
+
this.basePath = _optionalChain([options, 'optionalAccess', _164 => _164.basePath]) || process.cwd();
|
|
4706
4918
|
}
|
|
4707
4919
|
/**
|
|
4708
4920
|
* Get the function declaration for the tool
|
|
@@ -5185,7 +5397,7 @@ var LoadMemoryTool = (_class20 = class extends BaseTool {
|
|
|
5185
5397
|
const searchResult = await context4.searchMemory(args.query);
|
|
5186
5398
|
return {
|
|
5187
5399
|
memories: searchResult.memories || [],
|
|
5188
|
-
count: _optionalChain([searchResult, 'access',
|
|
5400
|
+
count: _optionalChain([searchResult, 'access', _165 => _165.memories, 'optionalAccess', _166 => _166.length]) || 0
|
|
5189
5401
|
};
|
|
5190
5402
|
} catch (error) {
|
|
5191
5403
|
console.error("Error searching memory:", error);
|
|
@@ -5742,7 +5954,7 @@ var McpClientService = (_class22 = class {
|
|
|
5742
5954
|
},
|
|
5743
5955
|
this,
|
|
5744
5956
|
async (instance) => await instance.reinitialize(),
|
|
5745
|
-
_optionalChain([this, 'access',
|
|
5957
|
+
_optionalChain([this, 'access', _167 => _167.config, 'access', _168 => _168.retryOptions, 'optionalAccess', _169 => _169.maxRetries]) || 2
|
|
5746
5958
|
);
|
|
5747
5959
|
return await wrappedCall();
|
|
5748
5960
|
} catch (error) {
|
|
@@ -5826,7 +6038,7 @@ var McpClientService = (_class22 = class {
|
|
|
5826
6038
|
this.mcpSamplingHandler = null;
|
|
5827
6039
|
if (this.client) {
|
|
5828
6040
|
try {
|
|
5829
|
-
_optionalChain([this, 'access',
|
|
6041
|
+
_optionalChain([this, 'access', _170 => _170.client, 'access', _171 => _171.removeRequestHandler, 'optionalCall', _172 => _172("sampling/createMessage")]);
|
|
5830
6042
|
} catch (error) {
|
|
5831
6043
|
this.logger.error("Failed to remove sampling handler:", error);
|
|
5832
6044
|
}
|
|
@@ -6123,7 +6335,7 @@ var McpToolAdapter = (_class23 = class extends BaseTool {
|
|
|
6123
6335
|
}, _class23);
|
|
6124
6336
|
|
|
6125
6337
|
// src/tools/mcp/servers.ts
|
|
6126
|
-
function createMcpConfig(name,
|
|
6338
|
+
function createMcpConfig(name, packageNameOrUrl, config = {}) {
|
|
6127
6339
|
const {
|
|
6128
6340
|
debug,
|
|
6129
6341
|
description,
|
|
@@ -6140,17 +6352,25 @@ function createMcpConfig(name, packageName, config = {}) {
|
|
|
6140
6352
|
if (!env.PATH) {
|
|
6141
6353
|
env.PATH = process.env.PATH || "";
|
|
6142
6354
|
}
|
|
6355
|
+
let isUrl;
|
|
6356
|
+
try {
|
|
6357
|
+
const url = new URL(packageNameOrUrl);
|
|
6358
|
+
isUrl = url.protocol === "http:" || url.protocol === "https:";
|
|
6359
|
+
} catch (e5) {
|
|
6360
|
+
isUrl = false;
|
|
6361
|
+
}
|
|
6362
|
+
const transport = {
|
|
6363
|
+
mode: "stdio",
|
|
6364
|
+
command: "npx",
|
|
6365
|
+
args: isUrl ? ["-y", "mcp-remote@latest", packageNameOrUrl] : ["-y", packageNameOrUrl],
|
|
6366
|
+
env
|
|
6367
|
+
};
|
|
6143
6368
|
return {
|
|
6144
6369
|
name,
|
|
6145
6370
|
description: description || `Client for ${name}`,
|
|
6146
6371
|
debug: debug || false,
|
|
6147
6372
|
retryOptions: retryOptions || { maxRetries: 2, initialDelay: 200 },
|
|
6148
|
-
transport
|
|
6149
|
-
mode: "stdio",
|
|
6150
|
-
command: "npx",
|
|
6151
|
-
args: ["-y", packageName],
|
|
6152
|
-
env
|
|
6153
|
-
},
|
|
6373
|
+
transport,
|
|
6154
6374
|
samplingHandler
|
|
6155
6375
|
};
|
|
6156
6376
|
}
|
|
@@ -6229,7 +6449,15 @@ function McpDiscord(config = {}) {
|
|
|
6229
6449
|
function McpCoinGecko(config = {}) {
|
|
6230
6450
|
const mcpConfig = createMcpConfig(
|
|
6231
6451
|
"CoinGecko MCP Client",
|
|
6232
|
-
"
|
|
6452
|
+
"https://mcp.api.coingecko.com/mcp",
|
|
6453
|
+
config
|
|
6454
|
+
);
|
|
6455
|
+
return new McpToolset(mcpConfig);
|
|
6456
|
+
}
|
|
6457
|
+
function McpCoinGeckoPro(config = {}) {
|
|
6458
|
+
const mcpConfig = createMcpConfig(
|
|
6459
|
+
"CoinGecko Pro MCP Client",
|
|
6460
|
+
"https://mcp.pro-api.coingecko.com/mcp",
|
|
6233
6461
|
config
|
|
6234
6462
|
);
|
|
6235
6463
|
return new McpToolset(mcpConfig);
|
|
@@ -6346,7 +6574,7 @@ var McpToolset = (_class24 = class {
|
|
|
6346
6574
|
"resource_closed_error" /* RESOURCE_CLOSED_ERROR */
|
|
6347
6575
|
);
|
|
6348
6576
|
}
|
|
6349
|
-
if (this.tools.length > 0 && !_optionalChain([this, 'access',
|
|
6577
|
+
if (this.tools.length > 0 && !_optionalChain([this, 'access', _173 => _173.config, 'access', _174 => _174.cacheConfig, 'optionalAccess', _175 => _175.enabled]) === false) {
|
|
6350
6578
|
return this.tools;
|
|
6351
6579
|
}
|
|
6352
6580
|
if (!this.clientService) {
|
|
@@ -6375,7 +6603,7 @@ var McpToolset = (_class24 = class {
|
|
|
6375
6603
|
}
|
|
6376
6604
|
}
|
|
6377
6605
|
}
|
|
6378
|
-
if (_optionalChain([this, 'access',
|
|
6606
|
+
if (_optionalChain([this, 'access', _176 => _176.config, 'access', _177 => _177.cacheConfig, 'optionalAccess', _178 => _178.enabled]) !== false) {
|
|
6379
6607
|
this.tools = tools;
|
|
6380
6608
|
}
|
|
6381
6609
|
return tools;
|
|
@@ -6464,12 +6692,12 @@ function populateClientFunctionCallId(modelResponseEvent) {
|
|
|
6464
6692
|
}
|
|
6465
6693
|
}
|
|
6466
6694
|
function removeClientFunctionCallId(content) {
|
|
6467
|
-
if (_optionalChain([content, 'optionalAccess',
|
|
6695
|
+
if (_optionalChain([content, 'optionalAccess', _179 => _179.parts])) {
|
|
6468
6696
|
for (const part of content.parts) {
|
|
6469
|
-
if (_optionalChain([part, 'access',
|
|
6697
|
+
if (_optionalChain([part, 'access', _180 => _180.functionCall, 'optionalAccess', _181 => _181.id, 'optionalAccess', _182 => _182.startsWith, 'call', _183 => _183(AF_FUNCTION_CALL_ID_PREFIX)])) {
|
|
6470
6698
|
part.functionCall.id = void 0;
|
|
6471
6699
|
}
|
|
6472
|
-
if (_optionalChain([part, 'access',
|
|
6700
|
+
if (_optionalChain([part, 'access', _184 => _184.functionResponse, 'optionalAccess', _185 => _185.id, 'optionalAccess', _186 => _186.startsWith, 'call', _187 => _187(AF_FUNCTION_CALL_ID_PREFIX)])) {
|
|
6473
6701
|
part.functionResponse.id = void 0;
|
|
6474
6702
|
}
|
|
6475
6703
|
}
|
|
@@ -6664,7 +6892,7 @@ function mergeParallelFunctionResponseEvents(functionResponseEvents) {
|
|
|
6664
6892
|
}
|
|
6665
6893
|
const mergedParts = [];
|
|
6666
6894
|
for (const event of functionResponseEvents) {
|
|
6667
|
-
if (_optionalChain([event, 'access',
|
|
6895
|
+
if (_optionalChain([event, 'access', _188 => _188.content, 'optionalAccess', _189 => _189.parts])) {
|
|
6668
6896
|
for (const part of event.content.parts) {
|
|
6669
6897
|
mergedParts.push(part);
|
|
6670
6898
|
}
|
|
@@ -6785,7 +7013,7 @@ var BaseLlmFlow = (_class25 = class {constructor() { _class25.prototype.__init43
|
|
|
6785
7013
|
const seen = /* @__PURE__ */ new Set();
|
|
6786
7014
|
const filtered = [];
|
|
6787
7015
|
for (const t of tools) {
|
|
6788
|
-
const name = _optionalChain([t, 'optionalAccess',
|
|
7016
|
+
const name = _optionalChain([t, 'optionalAccess', _190 => _190.name]);
|
|
6789
7017
|
if (!name) continue;
|
|
6790
7018
|
if (seen.has(name)) {
|
|
6791
7019
|
continue;
|
|
@@ -6802,7 +7030,7 @@ var BaseLlmFlow = (_class25 = class {constructor() { _class25.prototype.__init43
|
|
|
6802
7030
|
if (tools.length > 0) {
|
|
6803
7031
|
const toolsData = tools.map((tool) => ({
|
|
6804
7032
|
Name: tool.name,
|
|
6805
|
-
Description: _optionalChain([tool, 'access',
|
|
7033
|
+
Description: _optionalChain([tool, 'access', _191 => _191.description, 'optionalAccess', _192 => _192.substring, 'call', _193 => _193(0, 50)]) + (_optionalChain([tool, 'access', _194 => _194.description, 'optionalAccess', _195 => _195.length]) > 50 ? "..." : ""),
|
|
6806
7034
|
"Long Running": tool.isLongRunning ? "Yes" : "No"
|
|
6807
7035
|
}));
|
|
6808
7036
|
this.logger.debugArray("\u{1F6E0}\uFE0F Available Tools", toolsData);
|
|
@@ -6865,14 +7093,14 @@ var BaseLlmFlow = (_class25 = class {constructor() { _class25.prototype.__init43
|
|
|
6865
7093
|
);
|
|
6866
7094
|
if (functionResponseEvent) {
|
|
6867
7095
|
yield functionResponseEvent;
|
|
6868
|
-
const transferToAgent = _optionalChain([functionResponseEvent, 'access',
|
|
7096
|
+
const transferToAgent = _optionalChain([functionResponseEvent, 'access', _196 => _196.actions, 'optionalAccess', _197 => _197.transferToAgent]);
|
|
6869
7097
|
if (transferToAgent) {
|
|
6870
7098
|
this.logger.debug(`\u{1F504} Live transfer to agent '${transferToAgent}'`);
|
|
6871
7099
|
const agentToRun = this._getAgentToRun(
|
|
6872
7100
|
invocationContext,
|
|
6873
7101
|
transferToAgent
|
|
6874
7102
|
);
|
|
6875
|
-
for await (const event of _optionalChain([agentToRun, 'access',
|
|
7103
|
+
for await (const event of _optionalChain([agentToRun, 'access', _198 => _198.runLive, 'optionalCall', _199 => _199(invocationContext)]) || agentToRun.runAsync(invocationContext)) {
|
|
6876
7104
|
yield event;
|
|
6877
7105
|
}
|
|
6878
7106
|
}
|
|
@@ -6904,7 +7132,7 @@ var BaseLlmFlow = (_class25 = class {constructor() { _class25.prototype.__init43
|
|
|
6904
7132
|
yield authEvent;
|
|
6905
7133
|
}
|
|
6906
7134
|
yield functionResponseEvent;
|
|
6907
|
-
const transferToAgent = _optionalChain([functionResponseEvent, 'access',
|
|
7135
|
+
const transferToAgent = _optionalChain([functionResponseEvent, 'access', _200 => _200.actions, 'optionalAccess', _201 => _201.transferToAgent]);
|
|
6908
7136
|
if (transferToAgent) {
|
|
6909
7137
|
this.logger.debug(`\u{1F504} Transferring to agent '${transferToAgent}'`);
|
|
6910
7138
|
const agentToRun = this._getAgentToRun(
|
|
@@ -6950,7 +7178,7 @@ var BaseLlmFlow = (_class25 = class {constructor() { _class25.prototype.__init43
|
|
|
6950
7178
|
}
|
|
6951
7179
|
invocationContext.incrementLlmCallCount();
|
|
6952
7180
|
const isStreaming = invocationContext.runConfig.streamingMode === "sse" /* SSE */;
|
|
6953
|
-
let tools = _optionalChain([llmRequest, 'access',
|
|
7181
|
+
let tools = _optionalChain([llmRequest, 'access', _202 => _202.config, 'optionalAccess', _203 => _203.tools]) || [];
|
|
6954
7182
|
if (tools.length) {
|
|
6955
7183
|
const deduped = [];
|
|
6956
7184
|
const seenFn = /* @__PURE__ */ new Set();
|
|
@@ -6959,7 +7187,7 @@ var BaseLlmFlow = (_class25 = class {constructor() { _class25.prototype.__init43
|
|
|
6959
7187
|
if (tool && Array.isArray(tool.functionDeclarations)) {
|
|
6960
7188
|
const newFds = tool.functionDeclarations.filter(
|
|
6961
7189
|
(fd) => {
|
|
6962
|
-
if (_optionalChain([fd, 'optionalAccess',
|
|
7190
|
+
if (_optionalChain([fd, 'optionalAccess', _204 => _204.name])) {
|
|
6963
7191
|
if (seenFn.has(fd.name)) {
|
|
6964
7192
|
return false;
|
|
6965
7193
|
}
|
|
@@ -6971,7 +7199,7 @@ var BaseLlmFlow = (_class25 = class {constructor() { _class25.prototype.__init43
|
|
|
6971
7199
|
if (newFds.length) {
|
|
6972
7200
|
deduped.push({ ...tool, functionDeclarations: newFds });
|
|
6973
7201
|
}
|
|
6974
|
-
} else if (_optionalChain([tool, 'optionalAccess',
|
|
7202
|
+
} else if (_optionalChain([tool, 'optionalAccess', _205 => _205.name])) {
|
|
6975
7203
|
if (seenFn.has(tool.name)) continue;
|
|
6976
7204
|
seenFn.add(tool.name);
|
|
6977
7205
|
deduped.push(tool);
|
|
@@ -6991,21 +7219,21 @@ var BaseLlmFlow = (_class25 = class {constructor() { _class25.prototype.__init43
|
|
|
6991
7219
|
return tool.functionDeclarations.map((fn) => fn.name).join(", ");
|
|
6992
7220
|
}
|
|
6993
7221
|
if (tool.name) return tool.name;
|
|
6994
|
-
if (_optionalChain([tool, 'access',
|
|
6995
|
-
if (_optionalChain([tool, 'access',
|
|
7222
|
+
if (_optionalChain([tool, 'access', _206 => _206.function, 'optionalAccess', _207 => _207.name])) return tool.function.name;
|
|
7223
|
+
if (_optionalChain([tool, 'access', _208 => _208.function, 'optionalAccess', _209 => _209.function, 'optionalAccess', _210 => _210.name])) return tool.function.function.name;
|
|
6996
7224
|
return "unknown";
|
|
6997
7225
|
}).join(", ");
|
|
6998
7226
|
const systemInstruction = llmRequest.getSystemInstructionText() || "";
|
|
6999
7227
|
const truncatedSystemInstruction = systemInstruction.length > 100 ? `${systemInstruction.substring(0, 100)}...` : systemInstruction;
|
|
7000
|
-
const contentPreview = _optionalChain([llmRequest, 'access',
|
|
7228
|
+
const contentPreview = _optionalChain([llmRequest, 'access', _211 => _211.contents, 'optionalAccess', _212 => _212.length]) > 0 ? LogFormatter.formatContentPreview(llmRequest.contents[0]) : "none";
|
|
7001
7229
|
this.logger.debugStructured("\u{1F4E4} LLM Request", {
|
|
7002
7230
|
Model: llm.model,
|
|
7003
7231
|
Agent: invocationContext.agent.name,
|
|
7004
|
-
"Content Items": _optionalChain([llmRequest, 'access',
|
|
7232
|
+
"Content Items": _optionalChain([llmRequest, 'access', _213 => _213.contents, 'optionalAccess', _214 => _214.length]) || 0,
|
|
7005
7233
|
"Content Preview": contentPreview,
|
|
7006
7234
|
"System Instruction": truncatedSystemInstruction || "none",
|
|
7007
7235
|
"Available Tools": toolNames || "none",
|
|
7008
|
-
"Tool Count": _optionalChain([llmRequest, 'access',
|
|
7236
|
+
"Tool Count": _optionalChain([llmRequest, 'access', _215 => _215.config, 'optionalAccess', _216 => _216.tools, 'optionalAccess', _217 => _217.length]) || 0,
|
|
7009
7237
|
Streaming: isStreaming ? "Yes" : "No"
|
|
7010
7238
|
});
|
|
7011
7239
|
let responseCount = 0;
|
|
@@ -7020,8 +7248,8 @@ var BaseLlmFlow = (_class25 = class {constructor() { _class25.prototype.__init43
|
|
|
7020
7248
|
llmRequest,
|
|
7021
7249
|
llmResponse
|
|
7022
7250
|
);
|
|
7023
|
-
const tokenCount = _optionalChain([llmResponse, 'access',
|
|
7024
|
-
const functionCalls = _optionalChain([llmResponse, 'access',
|
|
7251
|
+
const tokenCount = _optionalChain([llmResponse, 'access', _218 => _218.usageMetadata, 'optionalAccess', _219 => _219.totalTokenCount]) || "unknown";
|
|
7252
|
+
const functionCalls = _optionalChain([llmResponse, 'access', _220 => _220.content, 'optionalAccess', _221 => _221.parts, 'optionalAccess', _222 => _222.filter, 'call', _223 => _223((part) => part.functionCall)]) || [];
|
|
7025
7253
|
const functionCallsDisplay = LogFormatter.formatFunctionCalls(functionCalls);
|
|
7026
7254
|
const responsePreview = LogFormatter.formatResponsePreview(llmResponse);
|
|
7027
7255
|
this.logger.debugStructured("\u{1F4E5} LLM Response", {
|
|
@@ -7165,7 +7393,7 @@ var EnhancedAuthConfig = class {
|
|
|
7165
7393
|
*/
|
|
7166
7394
|
generateCredentialKey() {
|
|
7167
7395
|
const schemeKey = this.authScheme.type || "unknown";
|
|
7168
|
-
const credentialKey = _optionalChain([this, 'access',
|
|
7396
|
+
const credentialKey = _optionalChain([this, 'access', _224 => _224.rawAuthCredential, 'optionalAccess', _225 => _225.type]) || "none";
|
|
7169
7397
|
const timestamp = Date.now();
|
|
7170
7398
|
return `adk_${schemeKey}_${credentialKey}_${timestamp}`;
|
|
7171
7399
|
}
|
|
@@ -7322,7 +7550,7 @@ var AuthLlmRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
|
7322
7550
|
*/
|
|
7323
7551
|
parseAndStoreAuthResponse(authHandler, invocationContext) {
|
|
7324
7552
|
try {
|
|
7325
|
-
const credentialKey = _optionalChain([authHandler, 'access',
|
|
7553
|
+
const credentialKey = _optionalChain([authHandler, 'access', _226 => _226.authConfig, 'access', _227 => _227.context, 'optionalAccess', _228 => _228.credentialKey]) || `temp:${Date.now()}`;
|
|
7326
7554
|
const fullCredentialKey = credentialKey.startsWith("temp:") ? credentialKey : `temp:${credentialKey}`;
|
|
7327
7555
|
invocationContext.session.state[fullCredentialKey] = authHandler.credential;
|
|
7328
7556
|
if (authHandler.authConfig.authScheme.type === "oauth2" || authHandler.authConfig.authScheme.type === "openIdConnect") {
|
|
@@ -7351,15 +7579,15 @@ var BasicLlmRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
|
7351
7579
|
llmRequest.config = {};
|
|
7352
7580
|
}
|
|
7353
7581
|
if (agent.outputSchema) {
|
|
7354
|
-
const hasTools = await _asyncOptionalChain([(await _optionalChain([agent, 'access',
|
|
7582
|
+
const hasTools = await _asyncOptionalChain([(await _optionalChain([agent, 'access', _229 => _229.canonicalTools, 'optionalCall', _230 => _230(invocationContext)])), 'optionalAccess', async _231 => _231.length]) > 0;
|
|
7355
7583
|
const hasTransfers = !!("subAgents" in agent && agent.subAgents && agent.subAgents.length > 0 && !(agent.disallowTransferToParent && agent.disallowTransferToPeers));
|
|
7356
7584
|
if (!hasTools && !hasTransfers) {
|
|
7357
7585
|
llmRequest.setOutputSchema(agent.outputSchema);
|
|
7358
7586
|
} else {
|
|
7359
7587
|
(() => {
|
|
7360
7588
|
try {
|
|
7361
|
-
const
|
|
7362
|
-
|
|
7589
|
+
const logger2 = new Logger({ name: "BasicLlmRequestProcessor" });
|
|
7590
|
+
logger2.debug(
|
|
7363
7591
|
`Skipping request-level output schema for agent ${agent.name} because tools/transfers are present. Schema will be validated during response processing.`
|
|
7364
7592
|
);
|
|
7365
7593
|
} catch (e) {
|
|
@@ -7443,7 +7671,7 @@ var BuiltInCodeExecutor = class extends BaseCodeExecutor {
|
|
|
7443
7671
|
* Pre-process the LLM request for Gemini 2.0+ models to use the code execution tool
|
|
7444
7672
|
*/
|
|
7445
7673
|
processLlmRequest(llmRequest) {
|
|
7446
|
-
if (!_optionalChain([llmRequest, 'access',
|
|
7674
|
+
if (!_optionalChain([llmRequest, 'access', _232 => _232.model, 'optionalAccess', _233 => _233.startsWith, 'call', _234 => _234("gemini-2")])) {
|
|
7447
7675
|
throw new Error(
|
|
7448
7676
|
`Gemini code execution tool is not supported for model ${llmRequest.model}`
|
|
7449
7677
|
);
|
|
@@ -7480,7 +7708,7 @@ var CodeExecutionUtils = class _CodeExecutionUtils {
|
|
|
7480
7708
|
static isBase64Encoded(str) {
|
|
7481
7709
|
try {
|
|
7482
7710
|
return btoa(atob(str)) === str;
|
|
7483
|
-
} catch (
|
|
7711
|
+
} catch (e6) {
|
|
7484
7712
|
return false;
|
|
7485
7713
|
}
|
|
7486
7714
|
}
|
|
@@ -7488,7 +7716,7 @@ var CodeExecutionUtils = class _CodeExecutionUtils {
|
|
|
7488
7716
|
* Extracts the first code block from the content and truncates everything after it
|
|
7489
7717
|
*/
|
|
7490
7718
|
static extractCodeAndTruncateContent(content, codeBlockDelimiters) {
|
|
7491
|
-
if (!_optionalChain([content, 'optionalAccess',
|
|
7719
|
+
if (!_optionalChain([content, 'optionalAccess', _235 => _235.parts, 'optionalAccess', _236 => _236.length])) {
|
|
7492
7720
|
return null;
|
|
7493
7721
|
}
|
|
7494
7722
|
for (let idx = 0; idx < content.parts.length; idx++) {
|
|
@@ -7574,7 +7802,7 @@ ${fileNames}`);
|
|
|
7574
7802
|
* Converts the code execution parts to text parts in a Content
|
|
7575
7803
|
*/
|
|
7576
7804
|
static convertCodeExecutionParts(content, codeBlockDelimiter, executionResultDelimiters) {
|
|
7577
|
-
if (!_optionalChain([content, 'access',
|
|
7805
|
+
if (!_optionalChain([content, 'access', _237 => _237.parts, 'optionalAccess', _238 => _238.length])) {
|
|
7578
7806
|
return;
|
|
7579
7807
|
}
|
|
7580
7808
|
const lastPart = content.parts[content.parts.length - 1];
|
|
@@ -7967,7 +8195,7 @@ async function* runPostProcessor(invocationContext, llmResponse) {
|
|
|
7967
8195
|
function extractAndReplaceInlineFiles(codeExecutorContext, llmRequest) {
|
|
7968
8196
|
const allInputFiles = codeExecutorContext.getInputFiles();
|
|
7969
8197
|
const savedFileNames = new Set(allInputFiles.map((f) => f.name));
|
|
7970
|
-
for (let i = 0; i < (_optionalChain([llmRequest, 'access',
|
|
8198
|
+
for (let i = 0; i < (_optionalChain([llmRequest, 'access', _239 => _239.contents, 'optionalAccess', _240 => _240.length]) || 0); i++) {
|
|
7971
8199
|
const content = llmRequest.contents[i];
|
|
7972
8200
|
if (content.role !== "user" || !content.parts) {
|
|
7973
8201
|
continue;
|
|
@@ -7999,7 +8227,7 @@ Available file: \`${fileName}\`
|
|
|
7999
8227
|
}
|
|
8000
8228
|
function getOrSetExecutionId(invocationContext, codeExecutorContext) {
|
|
8001
8229
|
const agent = invocationContext.agent;
|
|
8002
|
-
if (!hasCodeExecutor(agent) || !_optionalChain([agent, 'access',
|
|
8230
|
+
if (!hasCodeExecutor(agent) || !_optionalChain([agent, 'access', _241 => _241.codeExecutor, 'optionalAccess', _242 => _242.stateful])) {
|
|
8003
8231
|
return void 0;
|
|
8004
8232
|
}
|
|
8005
8233
|
let executionId = codeExecutorContext.getExecutionId();
|
|
@@ -8230,7 +8458,7 @@ function rearrangeEventsForLatestFunctionResponse(events) {
|
|
|
8230
8458
|
continue;
|
|
8231
8459
|
}
|
|
8232
8460
|
const functionResponses2 = event.getFunctionResponses();
|
|
8233
|
-
if (_optionalChain([functionResponses2, 'optionalAccess',
|
|
8461
|
+
if (_optionalChain([functionResponses2, 'optionalAccess', _243 => _243.some, 'call', _244 => _244((fr) => fr.id && functionResponsesIds.has(fr.id))])) {
|
|
8234
8462
|
functionResponseEvents.push(event);
|
|
8235
8463
|
}
|
|
8236
8464
|
}
|
|
@@ -8261,7 +8489,8 @@ function getContents(currentBranch, events, agentName = "") {
|
|
|
8261
8489
|
isOtherAgentReply(agentName, event) ? convertForeignEvent(event) : event
|
|
8262
8490
|
);
|
|
8263
8491
|
}
|
|
8264
|
-
|
|
8492
|
+
const processedEvents = processCompactionEvents(filteredEvents);
|
|
8493
|
+
let resultEvents = rearrangeEventsForLatestFunctionResponse(processedEvents);
|
|
8265
8494
|
resultEvents = rearrangeEventsForAsyncFunctionResponsesInHistory(resultEvents);
|
|
8266
8495
|
const contents = [];
|
|
8267
8496
|
for (const event of resultEvents) {
|
|
@@ -8329,7 +8558,7 @@ function mergeFunctionResponseEvents(functionResponseEvents) {
|
|
|
8329
8558
|
const partIndicesInMergedEvent = {};
|
|
8330
8559
|
for (let idx = 0; idx < partsInMergedEvent.length; idx++) {
|
|
8331
8560
|
const part = partsInMergedEvent[idx];
|
|
8332
|
-
if (_optionalChain([part, 'access',
|
|
8561
|
+
if (_optionalChain([part, 'access', _245 => _245.functionResponse, 'optionalAccess', _246 => _246.id])) {
|
|
8333
8562
|
partIndicesInMergedEvent[part.functionResponse.id] = idx;
|
|
8334
8563
|
}
|
|
8335
8564
|
}
|
|
@@ -8338,7 +8567,7 @@ function mergeFunctionResponseEvents(functionResponseEvents) {
|
|
|
8338
8567
|
throw new Error("There should be at least one function_response part.");
|
|
8339
8568
|
}
|
|
8340
8569
|
for (const part of event.content.parts) {
|
|
8341
|
-
if (_optionalChain([part, 'access',
|
|
8570
|
+
if (_optionalChain([part, 'access', _247 => _247.functionResponse, 'optionalAccess', _248 => _248.id])) {
|
|
8342
8571
|
const functionCallId = part.functionResponse.id;
|
|
8343
8572
|
if (functionCallId in partIndicesInMergedEvent) {
|
|
8344
8573
|
partsInMergedEvent[partIndicesInMergedEvent[functionCallId]] = part;
|
|
@@ -8373,6 +8602,31 @@ function isAuthEvent(event) {
|
|
|
8373
8602
|
}
|
|
8374
8603
|
return false;
|
|
8375
8604
|
}
|
|
8605
|
+
function processCompactionEvents(events) {
|
|
8606
|
+
const result = [];
|
|
8607
|
+
let lastCompactionStartTime = Number.POSITIVE_INFINITY;
|
|
8608
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
8609
|
+
const event = events[i];
|
|
8610
|
+
if (_optionalChain([event, 'access', _249 => _249.actions, 'optionalAccess', _250 => _250.compaction])) {
|
|
8611
|
+
const compaction = event.actions.compaction;
|
|
8612
|
+
const synthesizedEvent = new Event({
|
|
8613
|
+
timestamp: compaction.endTimestamp,
|
|
8614
|
+
author: "model",
|
|
8615
|
+
content: compaction.compactedContent,
|
|
8616
|
+
branch: event.branch,
|
|
8617
|
+
invocationId: event.invocationId
|
|
8618
|
+
});
|
|
8619
|
+
result.unshift(synthesizedEvent);
|
|
8620
|
+
lastCompactionStartTime = Math.min(
|
|
8621
|
+
lastCompactionStartTime,
|
|
8622
|
+
compaction.startTimestamp
|
|
8623
|
+
);
|
|
8624
|
+
} else if (event.timestamp < lastCompactionStartTime) {
|
|
8625
|
+
result.unshift(event);
|
|
8626
|
+
}
|
|
8627
|
+
}
|
|
8628
|
+
return result;
|
|
8629
|
+
}
|
|
8376
8630
|
|
|
8377
8631
|
// src/flows/llm-flows/identity.ts
|
|
8378
8632
|
var IdentityLlmRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
@@ -8520,7 +8774,7 @@ var InstructionsLlmRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
|
8520
8774
|
llmRequest.appendInstructions([
|
|
8521
8775
|
'IMPORTANT: After any tool calls, function calls, or agent transfers have completed, produce ONE final assistant message whose entire content is ONLY the JSON object that conforms to the schema provided above. Do NOT include any explanatory text, markdown, or additional messages. Do NOT wrap the JSON in code fences (for example, do NOT use ```json or ```). If you cannot produce valid JSON that matches the schema, return a JSON object with an "error" field describing the problem.'
|
|
8522
8776
|
]);
|
|
8523
|
-
} catch (
|
|
8777
|
+
} catch (e7) {
|
|
8524
8778
|
}
|
|
8525
8779
|
}
|
|
8526
8780
|
for await (const _ of []) {
|
|
@@ -8605,7 +8859,7 @@ var PlanReActPlanner = class extends BasePlanner {
|
|
|
8605
8859
|
let firstFcPartIndex = -1;
|
|
8606
8860
|
for (let i = 0; i < responseParts.length; i++) {
|
|
8607
8861
|
if (responseParts[i].functionCall) {
|
|
8608
|
-
if (!_optionalChain([responseParts, 'access',
|
|
8862
|
+
if (!_optionalChain([responseParts, 'access', _251 => _251[i], 'access', _252 => _252.functionCall, 'optionalAccess', _253 => _253.name])) {
|
|
8609
8863
|
continue;
|
|
8610
8864
|
}
|
|
8611
8865
|
preservedParts.push(responseParts[i]);
|
|
@@ -8644,7 +8898,7 @@ var PlanReActPlanner = class extends BasePlanner {
|
|
|
8644
8898
|
* Handles non-function-call parts of the response
|
|
8645
8899
|
*/
|
|
8646
8900
|
_handleNonFunctionCallParts(responsePart, preservedParts) {
|
|
8647
|
-
if (_optionalChain([responsePart, 'access',
|
|
8901
|
+
if (_optionalChain([responsePart, 'access', _254 => _254.text, 'optionalAccess', _255 => _255.includes, 'call', _256 => _256(FINAL_ANSWER_TAG)])) {
|
|
8648
8902
|
const [reasoningText, finalAnswerText] = this._splitByLastPattern(
|
|
8649
8903
|
responsePart.text,
|
|
8650
8904
|
FINAL_ANSWER_TAG
|
|
@@ -8742,14 +8996,7 @@ var NlPlanningRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
|
8742
8996
|
llmRequest
|
|
8743
8997
|
);
|
|
8744
8998
|
if (planningInstruction) {
|
|
8745
|
-
|
|
8746
|
-
llmRequest.appendInstructions([planningInstruction]);
|
|
8747
|
-
} else {
|
|
8748
|
-
const existingInstructions = llmRequest.instructions || "";
|
|
8749
|
-
llmRequest.instructions = `${existingInstructions}
|
|
8750
|
-
|
|
8751
|
-
${planningInstruction}`;
|
|
8752
|
-
}
|
|
8999
|
+
llmRequest.appendInstructions([planningInstruction]);
|
|
8753
9000
|
}
|
|
8754
9001
|
removeThoughtFromRequest(llmRequest);
|
|
8755
9002
|
for await (const _ of []) {
|
|
@@ -8890,7 +9137,7 @@ var OutputSchemaResponseProcessor = (_class26 = class extends BaseLlmResponsePro
|
|
|
8890
9137
|
stripCodeFences(raw) {
|
|
8891
9138
|
const fencePattern = /```(?:json)?\s*([\s\S]*?)```/i;
|
|
8892
9139
|
const fenceMatch = raw.match(fencePattern);
|
|
8893
|
-
if (_optionalChain([fenceMatch, 'optionalAccess',
|
|
9140
|
+
if (_optionalChain([fenceMatch, 'optionalAccess', _257 => _257[1]])) {
|
|
8894
9141
|
return fenceMatch[1].trim();
|
|
8895
9142
|
}
|
|
8896
9143
|
const lines = raw.split(/\r?\n/).map((l) => l.trim());
|
|
@@ -8927,7 +9174,7 @@ var SharedMemoryRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
|
8927
9174
|
const memoryService = invocationContext.memoryService;
|
|
8928
9175
|
if (!memoryService) return;
|
|
8929
9176
|
const lastUserEvent = invocationContext.session.events.findLast(
|
|
8930
|
-
(e) => e.author === "user" && _optionalChain([e, 'access',
|
|
9177
|
+
(e) => e.author === "user" && _optionalChain([e, 'access', _258 => _258.content, 'optionalAccess', _259 => _259.parts, 'optionalAccess', _260 => _260.length])
|
|
8931
9178
|
);
|
|
8932
9179
|
if (!lastUserEvent) return;
|
|
8933
9180
|
const query = (_nullishCoalesce(lastUserEvent.content.parts, () => ( []))).map((p) => p.text || "").join(" ");
|
|
@@ -8938,7 +9185,7 @@ var SharedMemoryRequestProcessor = class extends BaseLlmRequestProcessor {
|
|
|
8938
9185
|
});
|
|
8939
9186
|
const sessionTexts = new Set(
|
|
8940
9187
|
(llmRequest.contents || []).flatMap(
|
|
8941
|
-
(c) => _optionalChain([c, 'access',
|
|
9188
|
+
(c) => _optionalChain([c, 'access', _261 => _261.parts, 'optionalAccess', _262 => _262.map, 'call', _263 => _263((p) => p.text)]) || []
|
|
8942
9189
|
)
|
|
8943
9190
|
);
|
|
8944
9191
|
for (const memory of results.memories) {
|
|
@@ -9359,7 +9606,7 @@ var LlmAgent = (_class27 = class _LlmAgent extends BaseAgent {
|
|
|
9359
9606
|
* This matches the Python implementation's _llm_flow property
|
|
9360
9607
|
*/
|
|
9361
9608
|
get llmFlow() {
|
|
9362
|
-
if (this.disallowTransferToParent && this.disallowTransferToPeers && !_optionalChain([this, 'access',
|
|
9609
|
+
if (this.disallowTransferToParent && this.disallowTransferToPeers && !_optionalChain([this, 'access', _264 => _264.subAgents, 'optionalAccess', _265 => _265.length])) {
|
|
9363
9610
|
return new SingleFlow();
|
|
9364
9611
|
}
|
|
9365
9612
|
return new AutoFlow();
|
|
@@ -9375,7 +9622,7 @@ var LlmAgent = (_class27 = class _LlmAgent extends BaseAgent {
|
|
|
9375
9622
|
);
|
|
9376
9623
|
return;
|
|
9377
9624
|
}
|
|
9378
|
-
if (this.outputKey && event.isFinalResponse() && _optionalChain([event, 'access',
|
|
9625
|
+
if (this.outputKey && event.isFinalResponse() && _optionalChain([event, 'access', _266 => _266.content, 'optionalAccess', _267 => _267.parts])) {
|
|
9379
9626
|
let result = event.content.parts.map((part) => part.text || "").join("");
|
|
9380
9627
|
if (this.outputSchema) {
|
|
9381
9628
|
if (!result.trim()) {
|
|
@@ -9595,7 +9842,7 @@ var LoopAgent = class extends BaseAgent {
|
|
|
9595
9842
|
for (const subAgent of this.subAgents) {
|
|
9596
9843
|
for await (const event of subAgent.runAsync(ctx)) {
|
|
9597
9844
|
yield event;
|
|
9598
|
-
if (_optionalChain([event, 'access',
|
|
9845
|
+
if (_optionalChain([event, 'access', _268 => _268.actions, 'optionalAccess', _269 => _269.escalate])) {
|
|
9599
9846
|
return;
|
|
9600
9847
|
}
|
|
9601
9848
|
}
|
|
@@ -9907,17 +10154,17 @@ var RunConfig = class {
|
|
|
9907
10154
|
*/
|
|
9908
10155
|
|
|
9909
10156
|
constructor(config) {
|
|
9910
|
-
this.speechConfig = _optionalChain([config, 'optionalAccess',
|
|
9911
|
-
this.responseModalities = _optionalChain([config, 'optionalAccess',
|
|
9912
|
-
this.saveInputBlobsAsArtifacts = _optionalChain([config, 'optionalAccess',
|
|
9913
|
-
this.supportCFC = _optionalChain([config, 'optionalAccess',
|
|
9914
|
-
this.streamingMode = _optionalChain([config, 'optionalAccess',
|
|
9915
|
-
this.outputAudioTranscription = _optionalChain([config, 'optionalAccess',
|
|
9916
|
-
this.inputAudioTranscription = _optionalChain([config, 'optionalAccess',
|
|
9917
|
-
this.realtimeInputConfig = _optionalChain([config, 'optionalAccess',
|
|
9918
|
-
this.enableAffectiveDialog = _optionalChain([config, 'optionalAccess',
|
|
9919
|
-
this.proactivity = _optionalChain([config, 'optionalAccess',
|
|
9920
|
-
this.maxLlmCalls = _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
10157
|
+
this.speechConfig = _optionalChain([config, 'optionalAccess', _270 => _270.speechConfig]);
|
|
10158
|
+
this.responseModalities = _optionalChain([config, 'optionalAccess', _271 => _271.responseModalities]);
|
|
10159
|
+
this.saveInputBlobsAsArtifacts = _optionalChain([config, 'optionalAccess', _272 => _272.saveInputBlobsAsArtifacts]) || false;
|
|
10160
|
+
this.supportCFC = _optionalChain([config, 'optionalAccess', _273 => _273.supportCFC]) || false;
|
|
10161
|
+
this.streamingMode = _optionalChain([config, 'optionalAccess', _274 => _274.streamingMode]) || "NONE" /* NONE */;
|
|
10162
|
+
this.outputAudioTranscription = _optionalChain([config, 'optionalAccess', _275 => _275.outputAudioTranscription]);
|
|
10163
|
+
this.inputAudioTranscription = _optionalChain([config, 'optionalAccess', _276 => _276.inputAudioTranscription]);
|
|
10164
|
+
this.realtimeInputConfig = _optionalChain([config, 'optionalAccess', _277 => _277.realtimeInputConfig]);
|
|
10165
|
+
this.enableAffectiveDialog = _optionalChain([config, 'optionalAccess', _278 => _278.enableAffectiveDialog]);
|
|
10166
|
+
this.proactivity = _optionalChain([config, 'optionalAccess', _279 => _279.proactivity]);
|
|
10167
|
+
this.maxLlmCalls = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _280 => _280.maxLlmCalls]), () => ( 500));
|
|
9921
10168
|
this.validateMaxLlmCalls();
|
|
9922
10169
|
}
|
|
9923
10170
|
/**
|
|
@@ -10061,7 +10308,7 @@ var InMemoryMemoryService = (_class30 = class {
|
|
|
10061
10308
|
}
|
|
10062
10309
|
const userSessions = this._sessionEvents.get(userKey);
|
|
10063
10310
|
const filteredEvents = session.events.filter(
|
|
10064
|
-
(event) => _optionalChain([event, 'access',
|
|
10311
|
+
(event) => _optionalChain([event, 'access', _281 => _281.content, 'optionalAccess', _282 => _282.parts])
|
|
10065
10312
|
);
|
|
10066
10313
|
userSessions.set(session.id, filteredEvents);
|
|
10067
10314
|
}
|
|
@@ -10200,7 +10447,7 @@ var InMemorySessionService = (_class31 = class extends BaseSessionService {const
|
|
|
10200
10447
|
return this.createSessionImpl(appName, userId, state, sessionId);
|
|
10201
10448
|
}
|
|
10202
10449
|
createSessionImpl(appName, userId, state, sessionId) {
|
|
10203
|
-
const finalSessionId = _optionalChain([sessionId, 'optionalAccess',
|
|
10450
|
+
const finalSessionId = _optionalChain([sessionId, 'optionalAccess', _283 => _283.trim, 'call', _284 => _284()]) || _crypto.randomUUID.call(void 0, );
|
|
10204
10451
|
const session = {
|
|
10205
10452
|
appName,
|
|
10206
10453
|
userId,
|
|
@@ -10357,7 +10604,7 @@ var InMemorySessionService = (_class31 = class extends BaseSessionService {const
|
|
|
10357
10604
|
warning(`sessionId ${sessionId} not in sessions[appName][userId]`);
|
|
10358
10605
|
return event;
|
|
10359
10606
|
}
|
|
10360
|
-
if (_optionalChain([event, 'access',
|
|
10607
|
+
if (_optionalChain([event, 'access', _285 => _285.actions, 'optionalAccess', _286 => _286.stateDelta])) {
|
|
10361
10608
|
for (const key in event.actions.stateDelta) {
|
|
10362
10609
|
const value = event.actions.stateDelta[key];
|
|
10363
10610
|
if (key.startsWith(State.APP_PREFIX)) {
|
|
@@ -10391,14 +10638,14 @@ function _findFunctionCallEventIfLastEventIsFunctionResponse(session) {
|
|
|
10391
10638
|
return null;
|
|
10392
10639
|
}
|
|
10393
10640
|
const lastEvent = events[events.length - 1];
|
|
10394
|
-
if (_optionalChain([lastEvent, 'access',
|
|
10395
|
-
const functionCallId = _optionalChain([lastEvent, 'access',
|
|
10641
|
+
if (_optionalChain([lastEvent, 'access', _287 => _287.content, 'optionalAccess', _288 => _288.parts, 'optionalAccess', _289 => _289.some, 'call', _290 => _290((part) => part.functionResponse)])) {
|
|
10642
|
+
const functionCallId = _optionalChain([lastEvent, 'access', _291 => _291.content, 'access', _292 => _292.parts, 'access', _293 => _293.find, 'call', _294 => _294(
|
|
10396
10643
|
(part) => part.functionResponse
|
|
10397
|
-
), 'optionalAccess',
|
|
10644
|
+
), 'optionalAccess', _295 => _295.functionResponse, 'optionalAccess', _296 => _296.id]);
|
|
10398
10645
|
if (!functionCallId) return null;
|
|
10399
10646
|
for (let i = events.length - 2; i >= 0; i--) {
|
|
10400
10647
|
const event = events[i];
|
|
10401
|
-
const functionCalls = _optionalChain([event, 'access',
|
|
10648
|
+
const functionCalls = _optionalChain([event, 'access', _297 => _297.getFunctionCalls, 'optionalCall', _298 => _298()]) || [];
|
|
10402
10649
|
for (const functionCall of functionCalls) {
|
|
10403
10650
|
if (functionCall.id === functionCallId) {
|
|
10404
10651
|
return event;
|
|
@@ -10429,6 +10676,10 @@ var Runner = (_class32 = class {
|
|
|
10429
10676
|
* The memory service for the runner.
|
|
10430
10677
|
*/
|
|
10431
10678
|
|
|
10679
|
+
/**
|
|
10680
|
+
* Configuration for event compaction.
|
|
10681
|
+
*/
|
|
10682
|
+
|
|
10432
10683
|
__init55() {this.logger = new Logger({ name: "Runner" })}
|
|
10433
10684
|
/**
|
|
10434
10685
|
* Initializes the Runner.
|
|
@@ -10438,13 +10689,15 @@ var Runner = (_class32 = class {
|
|
|
10438
10689
|
agent,
|
|
10439
10690
|
artifactService,
|
|
10440
10691
|
sessionService,
|
|
10441
|
-
memoryService
|
|
10692
|
+
memoryService,
|
|
10693
|
+
eventsCompactionConfig
|
|
10442
10694
|
}) {;_class32.prototype.__init55.call(this);
|
|
10443
10695
|
this.appName = appName;
|
|
10444
10696
|
this.agent = agent;
|
|
10445
10697
|
this.artifactService = artifactService;
|
|
10446
10698
|
this.sessionService = sessionService;
|
|
10447
10699
|
this.memoryService = memoryService;
|
|
10700
|
+
this.eventsCompactionConfig = eventsCompactionConfig;
|
|
10448
10701
|
}
|
|
10449
10702
|
/**
|
|
10450
10703
|
* Runs the agent synchronously.
|
|
@@ -10546,6 +10799,10 @@ var Runner = (_class32 = class {
|
|
|
10546
10799
|
}
|
|
10547
10800
|
yield event;
|
|
10548
10801
|
}
|
|
10802
|
+
await _api.context.with(
|
|
10803
|
+
spanContext,
|
|
10804
|
+
() => this._runCompaction(session, invocationContext)
|
|
10805
|
+
);
|
|
10549
10806
|
} catch (error) {
|
|
10550
10807
|
this.logger.debug("Error running agent:", error);
|
|
10551
10808
|
span.recordException(error);
|
|
@@ -10601,15 +10858,15 @@ var Runner = (_class32 = class {
|
|
|
10601
10858
|
*/
|
|
10602
10859
|
_findAgentToRun(session, rootAgent) {
|
|
10603
10860
|
const event = _findFunctionCallEventIfLastEventIsFunctionResponse(session);
|
|
10604
|
-
if (_optionalChain([event, 'optionalAccess',
|
|
10861
|
+
if (_optionalChain([event, 'optionalAccess', _299 => _299.author])) {
|
|
10605
10862
|
return rootAgent.findAgent(event.author);
|
|
10606
10863
|
}
|
|
10607
|
-
const nonUserEvents = _optionalChain([session, 'access',
|
|
10864
|
+
const nonUserEvents = _optionalChain([session, 'access', _300 => _300.events, 'optionalAccess', _301 => _301.filter, 'call', _302 => _302((e) => e.author !== "user"), 'access', _303 => _303.reverse, 'call', _304 => _304()]) || [];
|
|
10608
10865
|
for (const event2 of nonUserEvents) {
|
|
10609
10866
|
if (event2.author === rootAgent.name) {
|
|
10610
10867
|
return rootAgent;
|
|
10611
10868
|
}
|
|
10612
|
-
const agent = _optionalChain([rootAgent, 'access',
|
|
10869
|
+
const agent = _optionalChain([rootAgent, 'access', _305 => _305.findSubAgent, 'optionalCall', _306 => _306(event2.author)]);
|
|
10613
10870
|
if (!agent) {
|
|
10614
10871
|
this.logger.debug(
|
|
10615
10872
|
`Event from an unknown agent: ${event2.author}, event id: ${event2.id}`
|
|
@@ -10658,6 +10915,52 @@ var Runner = (_class32 = class {
|
|
|
10658
10915
|
runConfig
|
|
10659
10916
|
});
|
|
10660
10917
|
}
|
|
10918
|
+
/**
|
|
10919
|
+
* Runs compaction if configured.
|
|
10920
|
+
*/
|
|
10921
|
+
async _runCompaction(session, _invocationContext) {
|
|
10922
|
+
if (!this.eventsCompactionConfig) {
|
|
10923
|
+
return;
|
|
10924
|
+
}
|
|
10925
|
+
const summarizer = this._getOrCreateSummarizer();
|
|
10926
|
+
if (!summarizer) {
|
|
10927
|
+
this.logger.warn(
|
|
10928
|
+
"Event compaction configured but no summarizer available"
|
|
10929
|
+
);
|
|
10930
|
+
return;
|
|
10931
|
+
}
|
|
10932
|
+
try {
|
|
10933
|
+
await runCompactionForSlidingWindow(
|
|
10934
|
+
this.eventsCompactionConfig,
|
|
10935
|
+
session,
|
|
10936
|
+
this.sessionService,
|
|
10937
|
+
summarizer
|
|
10938
|
+
);
|
|
10939
|
+
} catch (error) {
|
|
10940
|
+
this.logger.error("Error running compaction:", error);
|
|
10941
|
+
}
|
|
10942
|
+
}
|
|
10943
|
+
/**
|
|
10944
|
+
* Gets the configured summarizer or creates a default LLM-based one.
|
|
10945
|
+
*/
|
|
10946
|
+
_getOrCreateSummarizer() {
|
|
10947
|
+
if (_optionalChain([this, 'access', _307 => _307.eventsCompactionConfig, 'optionalAccess', _308 => _308.summarizer])) {
|
|
10948
|
+
return this.eventsCompactionConfig.summarizer;
|
|
10949
|
+
}
|
|
10950
|
+
if (this.agent instanceof LlmAgent) {
|
|
10951
|
+
try {
|
|
10952
|
+
const model = this.agent.canonicalModel;
|
|
10953
|
+
return new LlmEventSummarizer(model);
|
|
10954
|
+
} catch (error) {
|
|
10955
|
+
this.logger.warn(
|
|
10956
|
+
"Could not get canonical model for default summarizer:",
|
|
10957
|
+
error
|
|
10958
|
+
);
|
|
10959
|
+
return void 0;
|
|
10960
|
+
}
|
|
10961
|
+
}
|
|
10962
|
+
return void 0;
|
|
10963
|
+
}
|
|
10661
10964
|
}, _class32);
|
|
10662
10965
|
var InMemoryRunner = class extends Runner {
|
|
10663
10966
|
/**
|
|
@@ -10687,6 +10990,7 @@ var AgentBuilder = (_class33 = class _AgentBuilder {
|
|
|
10687
10990
|
|
|
10688
10991
|
|
|
10689
10992
|
|
|
10993
|
+
|
|
10690
10994
|
__init56() {this.agentType = "llm"}
|
|
10691
10995
|
|
|
10692
10996
|
|
|
@@ -10860,6 +11164,54 @@ var AgentBuilder = (_class33 = class _AgentBuilder {
|
|
|
10860
11164
|
this.config.afterAgentCallback = callback;
|
|
10861
11165
|
return this;
|
|
10862
11166
|
}
|
|
11167
|
+
/**
|
|
11168
|
+
* Set the before model callback for LLM interaction
|
|
11169
|
+
* @param callback Callback to invoke before calling the LLM
|
|
11170
|
+
* @returns This builder instance for chaining
|
|
11171
|
+
*/
|
|
11172
|
+
withBeforeModelCallback(callback) {
|
|
11173
|
+
this.warnIfLocked("withBeforeModelCallback");
|
|
11174
|
+
this.config.beforeModelCallback = callback;
|
|
11175
|
+
return this;
|
|
11176
|
+
}
|
|
11177
|
+
/**
|
|
11178
|
+
* Set the after model callback for LLM interaction
|
|
11179
|
+
* @param callback Callback to invoke after receiving LLM response
|
|
11180
|
+
* @returns This builder instance for chaining
|
|
11181
|
+
*/
|
|
11182
|
+
withAfterModelCallback(callback) {
|
|
11183
|
+
this.warnIfLocked("withAfterModelCallback");
|
|
11184
|
+
this.config.afterModelCallback = callback;
|
|
11185
|
+
return this;
|
|
11186
|
+
}
|
|
11187
|
+
/**
|
|
11188
|
+
* Set the before tool callback for tool execution
|
|
11189
|
+
* @param callback Callback to invoke before running a tool
|
|
11190
|
+
* @returns This builder instance for chaining
|
|
11191
|
+
*/
|
|
11192
|
+
withBeforeToolCallback(callback) {
|
|
11193
|
+
this.warnIfLocked("withBeforeToolCallback");
|
|
11194
|
+
this.config.beforeToolCallback = callback;
|
|
11195
|
+
return this;
|
|
11196
|
+
}
|
|
11197
|
+
/**
|
|
11198
|
+
* Set the after tool callback for tool execution
|
|
11199
|
+
* @param callback Callback to invoke after running a tool
|
|
11200
|
+
* @returns This builder instance for chaining
|
|
11201
|
+
*/
|
|
11202
|
+
withAfterToolCallback(callback) {
|
|
11203
|
+
this.warnIfLocked("withAfterToolCallback");
|
|
11204
|
+
this.config.afterToolCallback = callback;
|
|
11205
|
+
return this;
|
|
11206
|
+
}
|
|
11207
|
+
/**
|
|
11208
|
+
* Convenience method to start building with an existing agent
|
|
11209
|
+
* @param agent The agent instance to wrap
|
|
11210
|
+
* @returns New AgentBuilder instance with agent set
|
|
11211
|
+
*/
|
|
11212
|
+
static withAgent(agent) {
|
|
11213
|
+
return new _AgentBuilder(agent.name || "default_agent").withAgent(agent);
|
|
11214
|
+
}
|
|
10863
11215
|
/**
|
|
10864
11216
|
* Provide an already constructed agent instance. Further definition-mutating calls
|
|
10865
11217
|
* (model/tools/instruction/etc.) will be ignored with a dev warning.
|
|
@@ -11041,6 +11393,26 @@ var AgentBuilder = (_class33 = class _AgentBuilder {
|
|
|
11041
11393
|
this.runConfig = config instanceof RunConfig ? config : new RunConfig({ ...this.runConfig || {}, ...config });
|
|
11042
11394
|
return this;
|
|
11043
11395
|
}
|
|
11396
|
+
/**
|
|
11397
|
+
* Configure event compaction for automatic history management
|
|
11398
|
+
* @param config Event compaction configuration
|
|
11399
|
+
* @returns This builder instance for chaining
|
|
11400
|
+
* @example
|
|
11401
|
+
* ```typescript
|
|
11402
|
+
* const { runner } = await AgentBuilder
|
|
11403
|
+
* .create("assistant")
|
|
11404
|
+
* .withModel("gemini-2.5-flash")
|
|
11405
|
+
* .withEventsCompaction({
|
|
11406
|
+
* compactionInterval: 10, // Compact every 10 invocations
|
|
11407
|
+
* overlapSize: 2, // Include 2 prior invocations
|
|
11408
|
+
* })
|
|
11409
|
+
* .build();
|
|
11410
|
+
* ```
|
|
11411
|
+
*/
|
|
11412
|
+
withEventsCompaction(config) {
|
|
11413
|
+
this.eventsCompactionConfig = config;
|
|
11414
|
+
return this;
|
|
11415
|
+
}
|
|
11044
11416
|
/**
|
|
11045
11417
|
* Configure with an in-memory session with custom IDs
|
|
11046
11418
|
* Note: In-memory sessions are created automatically by default, use this only if you need custom appName/userId
|
|
@@ -11077,7 +11449,8 @@ var AgentBuilder = (_class33 = class _AgentBuilder {
|
|
|
11077
11449
|
agent,
|
|
11078
11450
|
sessionService: this.sessionService,
|
|
11079
11451
|
memoryService: this.memoryService,
|
|
11080
|
-
artifactService: this.artifactService
|
|
11452
|
+
artifactService: this.artifactService,
|
|
11453
|
+
eventsCompactionConfig: this.eventsCompactionConfig
|
|
11081
11454
|
};
|
|
11082
11455
|
const baseRunner = new Runner(runnerConfig);
|
|
11083
11456
|
runner = this.createEnhancedRunner(baseRunner, session);
|
|
@@ -11133,6 +11506,10 @@ var AgentBuilder = (_class33 = class _AgentBuilder {
|
|
|
11133
11506
|
subAgents: this.config.subAgents,
|
|
11134
11507
|
beforeAgentCallback: this.config.beforeAgentCallback,
|
|
11135
11508
|
afterAgentCallback: this.config.afterAgentCallback,
|
|
11509
|
+
beforeModelCallback: this.config.beforeModelCallback,
|
|
11510
|
+
afterModelCallback: this.config.afterModelCallback,
|
|
11511
|
+
beforeToolCallback: this.config.beforeToolCallback,
|
|
11512
|
+
afterToolCallback: this.config.afterToolCallback,
|
|
11136
11513
|
memoryService: this.memoryService,
|
|
11137
11514
|
artifactService: this.artifactService,
|
|
11138
11515
|
outputKey: this.config.outputKey,
|
|
@@ -11223,7 +11600,7 @@ var AgentBuilder = (_class33 = class _AgentBuilder {
|
|
|
11223
11600
|
const outputSchema = this.config.outputSchema;
|
|
11224
11601
|
const agentType = this.agentType;
|
|
11225
11602
|
const isMulti = agentType === "parallel" || agentType === "sequential";
|
|
11226
|
-
const subAgentNames = _optionalChain([this, 'access',
|
|
11603
|
+
const subAgentNames = _optionalChain([this, 'access', _309 => _309.config, 'access', _310 => _310.subAgents, 'optionalAccess', _311 => _311.map, 'call', _312 => _312((a) => a.name)]) || [];
|
|
11227
11604
|
const runConfig = this.runConfig;
|
|
11228
11605
|
return {
|
|
11229
11606
|
__outputSchema: outputSchema,
|
|
@@ -11232,7 +11609,7 @@ var AgentBuilder = (_class33 = class _AgentBuilder {
|
|
|
11232
11609
|
let combinedResponse = "";
|
|
11233
11610
|
const perAgentBuffers = {};
|
|
11234
11611
|
const authors = /* @__PURE__ */ new Set();
|
|
11235
|
-
if (!_optionalChain([sessionOptions, 'optionalAccess',
|
|
11612
|
+
if (!_optionalChain([sessionOptions, 'optionalAccess', _313 => _313.userId])) {
|
|
11236
11613
|
throw new Error("Session configuration is required");
|
|
11237
11614
|
}
|
|
11238
11615
|
for await (const event of baseRunner.runAsync({
|
|
@@ -11241,7 +11618,7 @@ var AgentBuilder = (_class33 = class _AgentBuilder {
|
|
|
11241
11618
|
newMessage,
|
|
11242
11619
|
runConfig
|
|
11243
11620
|
})) {
|
|
11244
|
-
if (_optionalChain([event, 'access',
|
|
11621
|
+
if (_optionalChain([event, 'access', _314 => _314.content, 'optionalAccess', _315 => _315.parts]) && Array.isArray(event.content.parts)) {
|
|
11245
11622
|
const content = event.content.parts.map(
|
|
11246
11623
|
(part) => (part && typeof part === "object" && "text" in part ? part.text : "") || ""
|
|
11247
11624
|
).join("");
|
|
@@ -11445,7 +11822,7 @@ var VertexAiRagMemoryService = class {
|
|
|
11445
11822
|
content
|
|
11446
11823
|
};
|
|
11447
11824
|
events.push(event);
|
|
11448
|
-
} catch (
|
|
11825
|
+
} catch (e8) {
|
|
11449
11826
|
}
|
|
11450
11827
|
}
|
|
11451
11828
|
}
|
|
@@ -11528,7 +11905,7 @@ var VertexAiSessionService = class extends BaseSessionService {
|
|
|
11528
11905
|
path: `operations/${operationId}`,
|
|
11529
11906
|
request_dict: {}
|
|
11530
11907
|
});
|
|
11531
|
-
if (_optionalChain([lroResponse, 'optionalAccess',
|
|
11908
|
+
if (_optionalChain([lroResponse, 'optionalAccess', _316 => _316.done])) {
|
|
11532
11909
|
break;
|
|
11533
11910
|
}
|
|
11534
11911
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
@@ -11877,7 +12254,7 @@ var DatabaseSessionService = (_class34 = class extends BaseSessionService {
|
|
|
11877
12254
|
if (!jsonString) return defaultValue;
|
|
11878
12255
|
try {
|
|
11879
12256
|
return JSON.parse(jsonString);
|
|
11880
|
-
} catch (
|
|
12257
|
+
} catch (e9) {
|
|
11881
12258
|
return defaultValue;
|
|
11882
12259
|
}
|
|
11883
12260
|
}
|
|
@@ -11899,12 +12276,12 @@ var DatabaseSessionService = (_class34 = class extends BaseSessionService {
|
|
|
11899
12276
|
}
|
|
11900
12277
|
async createSession(appName, userId, state, sessionId) {
|
|
11901
12278
|
await this.ensureInitialized();
|
|
11902
|
-
const id = _optionalChain([sessionId, 'optionalAccess',
|
|
12279
|
+
const id = _optionalChain([sessionId, 'optionalAccess', _317 => _317.trim, 'call', _318 => _318()]) || this.generateSessionId();
|
|
11903
12280
|
return await this.db.transaction().execute(async (trx) => {
|
|
11904
12281
|
const appState = await trx.selectFrom("app_states").selectAll().where("app_name", "=", appName).executeTakeFirst();
|
|
11905
12282
|
const userState = await trx.selectFrom("user_states").selectAll().where("app_name", "=", appName).where("user_id", "=", userId).executeTakeFirst();
|
|
11906
|
-
let currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess',
|
|
11907
|
-
let currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess',
|
|
12283
|
+
let currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess', _319 => _319.state]), {});
|
|
12284
|
+
let currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess', _320 => _320.state]), {});
|
|
11908
12285
|
if (!appState) {
|
|
11909
12286
|
await trx.insertInto("app_states").values({
|
|
11910
12287
|
app_name: appName,
|
|
@@ -11963,21 +12340,21 @@ var DatabaseSessionService = (_class34 = class extends BaseSessionService {
|
|
|
11963
12340
|
return void 0;
|
|
11964
12341
|
}
|
|
11965
12342
|
let eventQuery = trx.selectFrom("events").selectAll().where("session_id", "=", sessionId).orderBy("timestamp", "desc");
|
|
11966
|
-
if (_optionalChain([config, 'optionalAccess',
|
|
12343
|
+
if (_optionalChain([config, 'optionalAccess', _321 => _321.afterTimestamp])) {
|
|
11967
12344
|
eventQuery = eventQuery.where(
|
|
11968
12345
|
"timestamp",
|
|
11969
12346
|
">=",
|
|
11970
12347
|
new Date(config.afterTimestamp * 1e3)
|
|
11971
12348
|
);
|
|
11972
12349
|
}
|
|
11973
|
-
if (_optionalChain([config, 'optionalAccess',
|
|
12350
|
+
if (_optionalChain([config, 'optionalAccess', _322 => _322.numRecentEvents])) {
|
|
11974
12351
|
eventQuery = eventQuery.limit(config.numRecentEvents);
|
|
11975
12352
|
}
|
|
11976
12353
|
const storageEvents = await eventQuery.execute();
|
|
11977
12354
|
const appState = await trx.selectFrom("app_states").selectAll().where("app_name", "=", appName).executeTakeFirst();
|
|
11978
12355
|
const userState = await trx.selectFrom("user_states").selectAll().where("app_name", "=", appName).where("user_id", "=", userId).executeTakeFirst();
|
|
11979
|
-
const currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess',
|
|
11980
|
-
const currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess',
|
|
12356
|
+
const currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess', _323 => _323.state]), {});
|
|
12357
|
+
const currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess', _324 => _324.state]), {});
|
|
11981
12358
|
const sessionState = this.parseJsonSafely(storageSession.state, {});
|
|
11982
12359
|
const mergedState = this.mergeState(
|
|
11983
12360
|
currentAppState,
|
|
@@ -12035,13 +12412,13 @@ var DatabaseSessionService = (_class34 = class extends BaseSessionService {
|
|
|
12035
12412
|
}
|
|
12036
12413
|
const appState = await trx.selectFrom("app_states").selectAll().where("app_name", "=", session.appName).executeTakeFirst();
|
|
12037
12414
|
const userState = await trx.selectFrom("user_states").selectAll().where("app_name", "=", session.appName).where("user_id", "=", session.userId).executeTakeFirst();
|
|
12038
|
-
let currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess',
|
|
12039
|
-
let currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess',
|
|
12415
|
+
let currentAppState = this.parseJsonSafely(_optionalChain([appState, 'optionalAccess', _325 => _325.state]), {});
|
|
12416
|
+
let currentUserState = this.parseJsonSafely(_optionalChain([userState, 'optionalAccess', _326 => _326.state]), {});
|
|
12040
12417
|
let sessionState = this.parseJsonSafely(storageSession.state, {});
|
|
12041
12418
|
let appStateDelta = {};
|
|
12042
12419
|
let userStateDelta = {};
|
|
12043
12420
|
let sessionStateDelta = {};
|
|
12044
|
-
if (_optionalChain([event, 'access',
|
|
12421
|
+
if (_optionalChain([event, 'access', _327 => _327.actions, 'optionalAccess', _328 => _328.stateDelta])) {
|
|
12045
12422
|
const deltas = this.extractStateDelta(event.actions.stateDelta);
|
|
12046
12423
|
appStateDelta = deltas.appStateDelta;
|
|
12047
12424
|
userStateDelta = deltas.userStateDelta;
|
|
@@ -12187,7 +12564,7 @@ var DatabaseSessionService = (_class34 = class extends BaseSessionService {
|
|
|
12187
12564
|
* Overrides the base class method to work with plain object state.
|
|
12188
12565
|
*/
|
|
12189
12566
|
updateSessionState(session, event) {
|
|
12190
|
-
if (!_optionalChain([event, 'access',
|
|
12567
|
+
if (!_optionalChain([event, 'access', _329 => _329.actions, 'optionalAccess', _330 => _330.stateDelta])) {
|
|
12191
12568
|
return;
|
|
12192
12569
|
}
|
|
12193
12570
|
for (const [key, value] of Object.entries(event.actions.stateDelta)) {
|
|
@@ -12357,7 +12734,7 @@ var GcsArtifactService = class {
|
|
|
12357
12734
|
};
|
|
12358
12735
|
return part;
|
|
12359
12736
|
} catch (error) {
|
|
12360
|
-
if (_optionalChain([error, 'optionalAccess',
|
|
12737
|
+
if (_optionalChain([error, 'optionalAccess', _331 => _331.code]) === 404) {
|
|
12361
12738
|
return null;
|
|
12362
12739
|
}
|
|
12363
12740
|
throw error;
|
|
@@ -12608,13 +12985,13 @@ var VertexAiEvalFacade = class _VertexAiEvalFacade {
|
|
|
12608
12985
|
};
|
|
12609
12986
|
}
|
|
12610
12987
|
_getText(content) {
|
|
12611
|
-
if (_optionalChain([content, 'optionalAccess',
|
|
12988
|
+
if (_optionalChain([content, 'optionalAccess', _332 => _332.parts])) {
|
|
12612
12989
|
return content.parts.map((p) => p.text || "").filter((text) => text.length > 0).join("\n");
|
|
12613
12990
|
}
|
|
12614
12991
|
return "";
|
|
12615
12992
|
}
|
|
12616
12993
|
_getScore(evalResult) {
|
|
12617
|
-
if (_optionalChain([evalResult, 'optionalAccess',
|
|
12994
|
+
if (_optionalChain([evalResult, 'optionalAccess', _333 => _333.summaryMetrics, 'optionalAccess', _334 => _334[0], 'optionalAccess', _335 => _335.meanScore]) !== void 0 && typeof evalResult.summaryMetrics[0].meanScore === "number" && !Number.isNaN(evalResult.summaryMetrics[0].meanScore)) {
|
|
12618
12995
|
return evalResult.summaryMetrics[0].meanScore;
|
|
12619
12996
|
}
|
|
12620
12997
|
return void 0;
|
|
@@ -12764,7 +13141,7 @@ var ResponseEvaluator = class extends Evaluator {
|
|
|
12764
13141
|
return fmeasure;
|
|
12765
13142
|
}
|
|
12766
13143
|
extractText(content) {
|
|
12767
|
-
if (_optionalChain([content, 'optionalAccess',
|
|
13144
|
+
if (_optionalChain([content, 'optionalAccess', _336 => _336.parts])) {
|
|
12768
13145
|
return content.parts.map((p) => p.text || "").filter((text) => text.length > 0).join(" ");
|
|
12769
13146
|
}
|
|
12770
13147
|
return "";
|
|
@@ -12797,7 +13174,7 @@ var TrajectoryEvaluator = class extends Evaluator {
|
|
|
12797
13174
|
for (let i = 0; i < actualInvocations.length; i++) {
|
|
12798
13175
|
const actual = actualInvocations[i];
|
|
12799
13176
|
const expected = expectedInvocations[i];
|
|
12800
|
-
if (!_optionalChain([actual, 'access',
|
|
13177
|
+
if (!_optionalChain([actual, 'access', _337 => _337.intermediateData, 'optionalAccess', _338 => _338.toolUses]) || !_optionalChain([expected, 'access', _339 => _339.intermediateData, 'optionalAccess', _340 => _340.toolUses])) {
|
|
12801
13178
|
perInvocationResults.push({
|
|
12802
13179
|
actualInvocation: actual,
|
|
12803
13180
|
expectedInvocation: expected,
|
|
@@ -12885,7 +13262,7 @@ var SafetyEvaluatorV1 = class extends Evaluator {
|
|
|
12885
13262
|
|
|
12886
13263
|
// src/evaluation/llm-as-judge-utils.ts
|
|
12887
13264
|
function getTextFromContent(content) {
|
|
12888
|
-
if (_optionalChain([content, 'optionalAccess',
|
|
13265
|
+
if (_optionalChain([content, 'optionalAccess', _341 => _341.parts])) {
|
|
12889
13266
|
return content.parts.map((part) => part.text).filter(Boolean).join("\n");
|
|
12890
13267
|
}
|
|
12891
13268
|
return "";
|
|
@@ -12897,9 +13274,9 @@ function getEvalStatus(score, threshold) {
|
|
|
12897
13274
|
// src/evaluation/llm-as-judge.ts
|
|
12898
13275
|
var LlmAsJudge = class {
|
|
12899
13276
|
async sampleJudge(prompt, numSamples, critiqueParser, judgeModelOptions) {
|
|
12900
|
-
const modelName = _optionalChain([judgeModelOptions, 'optionalAccess',
|
|
13277
|
+
const modelName = _optionalChain([judgeModelOptions, 'optionalAccess', _342 => _342.judgeModel]) || "gemini-2.5-flash";
|
|
12901
13278
|
const model = LLMRegistry.getModelOrCreate(modelName);
|
|
12902
|
-
const config = _optionalChain([judgeModelOptions, 'optionalAccess',
|
|
13279
|
+
const config = _optionalChain([judgeModelOptions, 'optionalAccess', _343 => _343.judgeModelConfig]) || {};
|
|
12903
13280
|
const samples = [];
|
|
12904
13281
|
for (let i = 0; i < numSamples; i++) {
|
|
12905
13282
|
try {
|
|
@@ -12965,7 +13342,7 @@ function parseCritique(response) {
|
|
|
12965
13342
|
const labelMatchIsResponseValid = response.match(
|
|
12966
13343
|
/"is_the_agent_response_valid":\s*\[*[\n\s]*"*([^"^\]^\s]*)"*[\n\s]*\]*\s*[,\n\}]/
|
|
12967
13344
|
);
|
|
12968
|
-
if (_optionalChain([labelMatchIsResponseValid, 'optionalAccess',
|
|
13345
|
+
if (_optionalChain([labelMatchIsResponseValid, 'optionalAccess', _344 => _344[1]])) {
|
|
12969
13346
|
const label = labelMatchIsResponseValid[1].toLowerCase();
|
|
12970
13347
|
return label === "valid" ? "valid" /* VALID */ : "invalid" /* INVALID */;
|
|
12971
13348
|
}
|
|
@@ -13010,7 +13387,7 @@ var FinalResponseMatchV2Evaluator = class extends Evaluator {
|
|
|
13010
13387
|
"{prompt}",
|
|
13011
13388
|
prompt
|
|
13012
13389
|
).replace("{response}", response).replace("{golden_response}", goldenResponse);
|
|
13013
|
-
const numSamples = _nullishCoalesce(_optionalChain([this, 'access',
|
|
13390
|
+
const numSamples = _nullishCoalesce(_optionalChain([this, 'access', _345 => _345.metric, 'access', _346 => _346.judgeModelOptions, 'optionalAccess', _347 => _347.numSamples]), () => ( DEFAULT_NUM_SAMPLES));
|
|
13014
13391
|
const labels = await this.llmAsJudge.sampleJudge(
|
|
13015
13392
|
formattedPrompt,
|
|
13016
13393
|
numSamples,
|
|
@@ -13050,7 +13427,7 @@ var MetricEvaluatorRegistry = (_class35 = class {constructor() { _class35.protot
|
|
|
13050
13427
|
const metricName = metricInfo.metricName;
|
|
13051
13428
|
if (this.registry.has(metricName)) {
|
|
13052
13429
|
console.info(
|
|
13053
|
-
`Updating Evaluator class for ${metricName} from ${_optionalChain([this, 'access',
|
|
13430
|
+
`Updating Evaluator class for ${metricName} from ${_optionalChain([this, 'access', _348 => _348.registry, 'access', _349 => _349.get, 'call', _350 => _350(metricName), 'optionalAccess', _351 => _351.evaluator, 'access', _352 => _352.name])} to ${evaluator.name}`
|
|
13054
13431
|
);
|
|
13055
13432
|
}
|
|
13056
13433
|
this.registry.set(metricName, {
|
|
@@ -13164,10 +13541,10 @@ var LocalEvalService = class extends BaseEvalService {
|
|
|
13164
13541
|
for (const evalMetric of evaluateConfig.evalMetrics) {
|
|
13165
13542
|
const evaluator = DEFAULT_METRIC_EVALUATOR_REGISTRY.getEvaluator(evalMetric);
|
|
13166
13543
|
const actual = results.filter(
|
|
13167
|
-
(r) => !_optionalChain([r, 'access',
|
|
13544
|
+
(r) => !_optionalChain([r, 'access', _353 => _353.invocationId, 'optionalAccess', _354 => _354.includes, 'call', _355 => _355("expected")])
|
|
13168
13545
|
);
|
|
13169
13546
|
const expected = results.filter(
|
|
13170
|
-
(r) => _optionalChain([r, 'access',
|
|
13547
|
+
(r) => _optionalChain([r, 'access', _356 => _356.invocationId, 'optionalAccess', _357 => _357.includes, 'call', _358 => _358("expected")])
|
|
13171
13548
|
);
|
|
13172
13549
|
const result = await evaluator.evaluateInvocations(actual, expected);
|
|
13173
13550
|
evalResult.evalCaseResults.push({
|
|
@@ -13559,13 +13936,13 @@ ${failures.join(
|
|
|
13559
13936
|
console.log("\n\n");
|
|
13560
13937
|
}
|
|
13561
13938
|
static _convertContentToText(content) {
|
|
13562
|
-
if (_optionalChain([content, 'optionalAccess',
|
|
13939
|
+
if (_optionalChain([content, 'optionalAccess', _359 => _359.parts])) {
|
|
13563
13940
|
return content.parts.map((p) => p.text || "").filter((text) => text.length > 0).join("\n");
|
|
13564
13941
|
}
|
|
13565
13942
|
return "";
|
|
13566
13943
|
}
|
|
13567
13944
|
static _convertToolCallsToText(intermediateData) {
|
|
13568
|
-
if (_optionalChain([intermediateData, 'optionalAccess',
|
|
13945
|
+
if (_optionalChain([intermediateData, 'optionalAccess', _360 => _360.toolUses])) {
|
|
13569
13946
|
return intermediateData.toolUses.map((t) => JSON.stringify(t)).join("\n");
|
|
13570
13947
|
}
|
|
13571
13948
|
return "";
|
|
@@ -13620,7 +13997,7 @@ ${failures.join(
|
|
|
13620
13997
|
for (const [metricName, evalMetricResultsWithInvocations] of Object.entries(
|
|
13621
13998
|
evalMetricResults
|
|
13622
13999
|
)) {
|
|
13623
|
-
const threshold = _optionalChain([evalMetricResultsWithInvocations, 'access',
|
|
14000
|
+
const threshold = _optionalChain([evalMetricResultsWithInvocations, 'access', _361 => _361[0], 'optionalAccess', _362 => _362.evalMetricResult, 'access', _363 => _363.threshold]) || 0;
|
|
13624
14001
|
const scores = evalMetricResultsWithInvocations.map((m) => m.evalMetricResult.score).filter((s) => s !== void 0);
|
|
13625
14002
|
let overallScore;
|
|
13626
14003
|
let overallEvalStatus;
|
|
@@ -13709,7 +14086,7 @@ var RougeEvaluator = class extends Evaluator {
|
|
|
13709
14086
|
}
|
|
13710
14087
|
};
|
|
13711
14088
|
function getTextFromContent2(content) {
|
|
13712
|
-
if (_optionalChain([content, 'optionalAccess',
|
|
14089
|
+
if (_optionalChain([content, 'optionalAccess', _364 => _364.parts])) {
|
|
13713
14090
|
return content.parts.map((part) => part.text).filter(Boolean).join("\n");
|
|
13714
14091
|
}
|
|
13715
14092
|
return "";
|
|
@@ -13904,4 +14281,7 @@ var VERSION = "0.1.0";
|
|
|
13904
14281
|
|
|
13905
14282
|
|
|
13906
14283
|
|
|
13907
|
-
|
|
14284
|
+
|
|
14285
|
+
|
|
14286
|
+
|
|
14287
|
+
exports.AF_FUNCTION_CALL_ID_PREFIX = AF_FUNCTION_CALL_ID_PREFIX; exports.Agent = LlmAgent; exports.AgentBuilder = AgentBuilder; exports.AgentEvaluator = AgentEvaluator; 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.EvalResult = EvalResult; exports.EvalStatus = EvalStatus; exports.Evaluation = evaluation_exports; exports.Evaluator = Evaluator; exports.Event = Event; exports.EventActions = EventActions; exports.Events = events_exports; exports.ExitLoopTool = ExitLoopTool; exports.FileOperationsTool = FileOperationsTool; exports.FinalResponseMatchV2Evaluator = FinalResponseMatchV2Evaluator; 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.LlmEventSummarizer = LlmEventSummarizer; exports.LlmRequest = LlmRequest; exports.LlmResponse = LlmResponse; exports.LoadArtifactsTool = LoadArtifactsTool; exports.LoadMemoryTool = LoadMemoryTool; exports.LocalEvalService = LocalEvalService; exports.LoopAgent = LoopAgent; exports.McpAbi = McpAbi; exports.McpAtp = McpAtp; exports.McpBamm = McpBamm; exports.McpCoinGecko = McpCoinGecko; exports.McpCoinGeckoPro = McpCoinGeckoPro; 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.McpUpbit = McpUpbit; 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.PrebuiltMetrics = PrebuiltMetrics; exports.REQUEST_EUC_FUNCTION_CALL_NAME = REQUEST_EUC_FUNCTION_CALL_NAME; exports.ReadonlyContext = ReadonlyContext; exports.RougeEvaluator = RougeEvaluator; exports.RunConfig = RunConfig; exports.Runner = Runner; exports.SafetyEvaluatorV1 = SafetyEvaluatorV1; 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.TrajectoryEvaluator = TrajectoryEvaluator; exports.TransferToAgentTool = TransferToAgentTool; exports.UserInteractionTool = UserInteractionTool; exports.VERSION = VERSION; exports.VertexAiRagMemoryService = VertexAiRagMemoryService; 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.convertMcpToolToBaseTool = convertMcpToolToBaseTool; 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.runCompactionForSlidingWindow = runCompactionForSlidingWindow; exports.shutdownTelemetry = shutdownTelemetry; exports.telemetryService = telemetryService; exports.traceLlmCall = traceLlmCall; exports.traceToolCall = traceToolCall; exports.tracer = tracer;
|