@paean-ai/adk 0.2.25 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/agents/functions.js +1 -0
- package/dist/cjs/agents/llm_agent.js +7 -0
- package/dist/cjs/events/event.js +1 -2
- package/dist/cjs/index.js +12 -12
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/models/google_llm.js +40 -5
- package/dist/cjs/models/llm_response.js +7 -0
- package/dist/cjs/utils/variant_utils.js +1 -1
- package/dist/esm/agents/functions.js +1 -0
- package/dist/esm/agents/llm_agent.js +7 -0
- package/dist/esm/events/event.js +1 -2
- package/dist/esm/index.js +12 -12
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/models/google_llm.js +40 -5
- package/dist/esm/models/llm_response.js +7 -0
- package/dist/esm/utils/variant_utils.js +1 -1
- package/dist/types/models/google_llm.d.ts +4 -0
- package/dist/web/agents/functions.js +1 -0
- package/dist/web/agents/llm_agent.js +7 -0
- package/dist/web/events/event.js +1 -2
- package/dist/web/index.js +1 -1
- package/dist/web/index.js.map +3 -3
- package/dist/web/models/google_llm.js +40 -5
- package/dist/web/models/llm_response.js +7 -0
- package/dist/web/utils/variant_utils.js +1 -1
- package/package.json +1 -1
|
@@ -65,11 +65,13 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
65
65
|
this.headers = headers;
|
|
66
66
|
this.isGemini3Preview = (0, import_model_name.isGemini3PreviewModel)(model);
|
|
67
67
|
const canReadEnv = typeof process === "object";
|
|
68
|
+
const aiStudioApiKey = canReadEnv ? process.env["AI_STUDIO_API_KEY"] : void 0;
|
|
69
|
+
const useAiStudioMode = !!aiStudioApiKey;
|
|
68
70
|
this.apiEndpoint = apiEndpoint;
|
|
69
71
|
if (!this.apiEndpoint && canReadEnv) {
|
|
70
72
|
this.apiEndpoint = process.env["GEMINI_API_ENDPOINT"];
|
|
71
73
|
}
|
|
72
|
-
if (!this.apiEndpoint && this.isGemini3Preview) {
|
|
74
|
+
if (!this.apiEndpoint && this.isGemini3Preview && !useAiStudioMode) {
|
|
73
75
|
this.apiEndpoint = GEMINI3_PREVIEW_API_ENDPOINT;
|
|
74
76
|
import_logger.logger.info(`Using Gemini 3 preview endpoint: ${this.apiEndpoint}`);
|
|
75
77
|
}
|
|
@@ -80,6 +82,15 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
80
82
|
useVertexAI = vertexAIfromEnv.toLowerCase() === "true" || vertexAIfromEnv === "1";
|
|
81
83
|
}
|
|
82
84
|
}
|
|
85
|
+
if (useAiStudioMode) {
|
|
86
|
+
if (useVertexAI) {
|
|
87
|
+
import_logger.logger.info(
|
|
88
|
+
"AI_STUDIO_API_KEY set \u2014 overriding Vertex AI mode to use AI Studio (generativelanguage.googleapis.com)"
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
useVertexAI = false;
|
|
92
|
+
this.apiKey = aiStudioApiKey;
|
|
93
|
+
}
|
|
83
94
|
if (this.isGemini3Preview && useVertexAI) {
|
|
84
95
|
const availableApiKey = apiKey || (canReadEnv ? process.env["GOOGLE_GENAI_API_KEY"] || process.env["GEMINI_API_KEY"] : void 0);
|
|
85
96
|
if (availableApiKey) {
|
|
@@ -258,10 +269,10 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
258
269
|
}
|
|
259
270
|
if (hasFunctionCalls) {
|
|
260
271
|
if (pendingFCResponse && ((_i = pendingFCResponse.content) == null ? void 0 : _i.parts)) {
|
|
261
|
-
const
|
|
262
|
-
(p) => p.functionCall
|
|
272
|
+
const newParts = (((_j = llmResponse.content) == null ? void 0 : _j.parts) || []).filter(
|
|
273
|
+
(p) => p.functionCall || p.thoughtSignature
|
|
263
274
|
);
|
|
264
|
-
pendingFCResponse.content.parts.push(...
|
|
275
|
+
pendingFCResponse.content.parts.push(...newParts);
|
|
265
276
|
pendingFCResponse.usageMetadata = llmResponse.usageMetadata;
|
|
266
277
|
} else {
|
|
267
278
|
pendingFCResponse = llmResponse;
|
|
@@ -282,7 +293,14 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
282
293
|
const partsWithSig = pendingFCResponse.content.parts.filter(
|
|
283
294
|
(p) => p.thoughtSignature
|
|
284
295
|
).length;
|
|
285
|
-
if (partsWithSig === 0) {
|
|
296
|
+
if (partsWithSig === 0 && thoughtSignature) {
|
|
297
|
+
for (const part of pendingFCResponse.content.parts) {
|
|
298
|
+
if (part.functionCall) {
|
|
299
|
+
part.thoughtSignature = thoughtSignature;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
} else if (partsWithSig === 0) {
|
|
286
304
|
import_logger.logger.warn(
|
|
287
305
|
`[Gemini3] No thoughtSignature on merged function call parts \u2014 may cause 400 on next request`
|
|
288
306
|
);
|
|
@@ -461,6 +479,7 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
461
479
|
return new import_gemini_llm_connection.GeminiLlmConnection(liveSession);
|
|
462
480
|
}
|
|
463
481
|
preprocessRequest(llmRequest) {
|
|
482
|
+
var _a;
|
|
464
483
|
if (this.apiBackend === import_variant_utils.GoogleLLMVariant.GEMINI_API) {
|
|
465
484
|
if (llmRequest.config) {
|
|
466
485
|
llmRequest.config.labels = void 0;
|
|
@@ -474,6 +493,22 @@ class Gemini extends import_base_llm.BaseLlm {
|
|
|
474
493
|
}
|
|
475
494
|
}
|
|
476
495
|
}
|
|
496
|
+
if (((_a = llmRequest.config) == null ? void 0 : _a.tools) && llmRequest.config.tools.length > 1) {
|
|
497
|
+
const hasBuiltInSearch = llmRequest.config.tools.some(
|
|
498
|
+
(t) => "googleSearch" in t || "googleSearchRetrieval" in t
|
|
499
|
+
);
|
|
500
|
+
const hasFunctionDeclarations = llmRequest.config.tools.some(
|
|
501
|
+
(t) => "functionDeclarations" in t
|
|
502
|
+
);
|
|
503
|
+
if (hasBuiltInSearch && hasFunctionDeclarations) {
|
|
504
|
+
import_logger.logger.warn(
|
|
505
|
+
"Gemini API (AI Studio) does not support combining built-in search tools with custom function declarations. Removing built-in search tool from this request."
|
|
506
|
+
);
|
|
507
|
+
llmRequest.config.tools = llmRequest.config.tools.filter(
|
|
508
|
+
(t) => !("googleSearch" in t) && !("googleSearchRetrieval" in t)
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
477
512
|
}
|
|
478
513
|
}
|
|
479
514
|
}
|
|
@@ -27,6 +27,7 @@ __export(llm_response_exports, {
|
|
|
27
27
|
createLlmResponse: () => createLlmResponse
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(llm_response_exports);
|
|
30
|
+
var import_genai = require("@google/genai");
|
|
30
31
|
/**
|
|
31
32
|
* @license
|
|
32
33
|
* Copyright 2025 Google LLC
|
|
@@ -45,6 +46,12 @@ function createLlmResponse(response) {
|
|
|
45
46
|
finishReason: candidate.finishReason
|
|
46
47
|
};
|
|
47
48
|
}
|
|
49
|
+
if (candidate.finishReason === import_genai.FinishReason.STOP) {
|
|
50
|
+
return {
|
|
51
|
+
usageMetadata,
|
|
52
|
+
finishReason: candidate.finishReason
|
|
53
|
+
};
|
|
54
|
+
}
|
|
48
55
|
return {
|
|
49
56
|
errorCode: candidate.finishReason,
|
|
50
57
|
errorMessage: candidate.finishMessage,
|
|
@@ -46,7 +46,7 @@ function getBooleanEnvVar(envVar) {
|
|
|
46
46
|
return false;
|
|
47
47
|
}
|
|
48
48
|
const envVarValue = (process.env[envVar] || "").toLowerCase();
|
|
49
|
-
return ["true", "1"].includes(
|
|
49
|
+
return ["true", "1"].includes(envVarValue);
|
|
50
50
|
}
|
|
51
51
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
52
|
0 && (module.exports = {
|
|
@@ -371,6 +371,7 @@ function mergeParallelFunctionResponseEvents(functionResponseEvents) {
|
|
|
371
371
|
const actionsList = functionResponseEvents.map((event) => event.actions || {});
|
|
372
372
|
const mergedActions = mergeEventActions(actionsList);
|
|
373
373
|
return createEvent({
|
|
374
|
+
invocationId: baseEvent.invocationId,
|
|
374
375
|
author: baseEvent.author,
|
|
375
376
|
branch: baseEvent.branch,
|
|
376
377
|
content: { role: "user", parts: mergedParts },
|
|
@@ -435,6 +435,9 @@ async function* runPreProcessor(invocationContext, llmRequest) {
|
|
|
435
435
|
}
|
|
436
436
|
const codeExecutorContext = new CodeExecutorContext(new State(invocationContext.session.state));
|
|
437
437
|
if (codeExecutorContext.getErrorCount(invocationContext.invocationId) >= codeExecutor.errorRetryAttempts) {
|
|
438
|
+
logger.warn(
|
|
439
|
+
`[CodeExecutor] Pre-processor skipped: error count exceeded max retry attempts (${codeExecutor.errorRetryAttempts}) for invocation ${invocationContext.invocationId}`
|
|
440
|
+
);
|
|
438
441
|
return;
|
|
439
442
|
}
|
|
440
443
|
const allInputFiles = extractAndReplaceInlineFiles(codeExecutorContext, llmRequest);
|
|
@@ -501,6 +504,9 @@ async function* runPostProcessor(invocationContext, llmResponse) {
|
|
|
501
504
|
}
|
|
502
505
|
const codeExecutorContext = new CodeExecutorContext(new State(invocationContext.session.state));
|
|
503
506
|
if (codeExecutorContext.getErrorCount(invocationContext.invocationId) >= codeExecutor.errorRetryAttempts) {
|
|
507
|
+
logger.warn(
|
|
508
|
+
`[CodeExecutor] Post-processor skipped: error count exceeded max retry attempts (${codeExecutor.errorRetryAttempts}) for invocation ${invocationContext.invocationId}`
|
|
509
|
+
);
|
|
504
510
|
return;
|
|
505
511
|
}
|
|
506
512
|
const responseContent = llmResponse.content;
|
|
@@ -1012,6 +1018,7 @@ const _LlmAgent = class _LlmAgent extends BaseAgent {
|
|
|
1012
1018
|
const allEmpty = llmResponse.content.parts.every(
|
|
1013
1019
|
(p) => {
|
|
1014
1020
|
if (p.functionCall || p.functionResponse || p.executableCode || p.codeExecutionResult) return false;
|
|
1021
|
+
if (p.inlineData || p.fileData) return false;
|
|
1015
1022
|
if ("text" in p && typeof p.text === "string" && p.text.length > 0) return false;
|
|
1016
1023
|
return true;
|
|
1017
1024
|
}
|
package/dist/esm/events/event.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { createEventActions } from "./event_actions.js";
|
|
7
7
|
function createEvent(params = {}) {
|
|
8
|
-
|
|
8
|
+
return {
|
|
9
9
|
...params,
|
|
10
10
|
id: params.id || createNewEventId(),
|
|
11
11
|
invocationId: params.invocationId || "",
|
|
@@ -15,7 +15,6 @@ function createEvent(params = {}) {
|
|
|
15
15
|
branch: params.branch,
|
|
16
16
|
timestamp: params.timestamp || Date.now()
|
|
17
17
|
};
|
|
18
|
-
return event;
|
|
19
18
|
}
|
|
20
19
|
function isFinalResponse(event) {
|
|
21
20
|
if (event.actions.skipSummarization || event.longRunningToolIds && event.longRunningToolIds.length > 0) {
|