@google/adk 1.0.0 → 1.1.0
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/common.js +8 -0
- package/dist/cjs/index.js +83 -125
- package/dist/cjs/tools/agent_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_tool.js +3 -2
- package/dist/cjs/tools/mcp/mcp_toolset.js +1 -1
- package/dist/cjs/tools/url_context_tool.js +73 -0
- package/dist/cjs/tools/vertex_ai_search_tool.js +127 -0
- package/dist/cjs/utils/model_name.js +8 -2
- package/dist/cjs/version.js +1 -1
- package/dist/esm/common.js +5 -0
- package/dist/esm/index.js +43 -130
- package/dist/esm/tools/agent_tool.js +1 -1
- package/dist/esm/tools/mcp/mcp_tool.js +3 -2
- package/dist/esm/tools/mcp/mcp_toolset.js +1 -1
- package/dist/esm/tools/url_context_tool.js +44 -0
- package/dist/esm/tools/vertex_ai_search_tool.js +103 -0
- package/dist/esm/utils/model_name.js +6 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/common.d.ts +3 -0
- package/dist/types/tools/mcp/mcp_tool.d.ts +7 -1
- package/dist/types/tools/mcp/mcp_toolset.d.ts +5 -0
- package/dist/types/tools/url_context_tool.d.ts +17 -0
- package/dist/types/tools/vertex_ai_search_tool.d.ts +55 -0
- package/dist/types/utils/model_name.d.ts +4 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/web/common.js +5 -0
- package/dist/web/index.js +43 -12
- package/dist/web/tools/agent_tool.js +1 -1
- package/dist/web/tools/mcp/mcp_tool.js +3 -2
- package/dist/web/tools/mcp/mcp_toolset.js +1 -1
- package/dist/web/tools/url_context_tool.js +44 -0
- package/dist/web/tools/vertex_ai_search_tool.js +103 -0
- package/dist/web/utils/model_name.js +6 -1
- package/dist/web/version.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/index.js.map +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/web/index.js.map +0 -7
|
@@ -116,7 +116,7 @@ class AgentTool extends (_b = import_base_tool.BaseTool, _a = AGENT_TOOL_SIGNATU
|
|
|
116
116
|
memoryService: (_b2 = toolContext.invocationContext.memoryService) != null ? _b2 : new import_in_memory_memory_service.InMemoryMemoryService(),
|
|
117
117
|
credentialService: toolContext.invocationContext.credentialService
|
|
118
118
|
});
|
|
119
|
-
const session = await runner.sessionService.
|
|
119
|
+
const session = await runner.sessionService.getOrCreateSession({
|
|
120
120
|
appName: this.agent.name,
|
|
121
121
|
userId: toolContext.invocationContext.userId,
|
|
122
122
|
sessionId: toolContext.invocationContext.session.id,
|
|
@@ -35,10 +35,11 @@ var import_base_tool = require("../base_tool.js");
|
|
|
35
35
|
* SPDX-License-Identifier: Apache-2.0
|
|
36
36
|
*/
|
|
37
37
|
class MCPTool extends import_base_tool.BaseTool {
|
|
38
|
-
constructor(mcpTool, mcpSessionManager) {
|
|
38
|
+
constructor(mcpTool, mcpSessionManager, originalName) {
|
|
39
39
|
super({ name: mcpTool.name, description: mcpTool.description || "" });
|
|
40
40
|
this.mcpTool = mcpTool;
|
|
41
41
|
this.mcpSessionManager = mcpSessionManager;
|
|
42
|
+
this.originalName = originalName || mcpTool.name;
|
|
42
43
|
}
|
|
43
44
|
_getDeclaration() {
|
|
44
45
|
return {
|
|
@@ -53,7 +54,7 @@ class MCPTool extends import_base_tool.BaseTool {
|
|
|
53
54
|
async runAsync(request) {
|
|
54
55
|
const session = await this.mcpSessionManager.createSession();
|
|
55
56
|
const callRequest = {};
|
|
56
|
-
callRequest.params = { name: this.
|
|
57
|
+
callRequest.params = { name: this.originalName, arguments: request.args };
|
|
57
58
|
const result = await session.callTool(callRequest.params, void 0, {
|
|
58
59
|
signal: request.toolContext.abortSignal
|
|
59
60
|
});
|
|
@@ -53,7 +53,7 @@ class MCPToolset extends import_base_toolset.BaseToolset {
|
|
|
53
53
|
...tool,
|
|
54
54
|
name: this.prefix ? `${this.prefix}_${tool.name}` : tool.name
|
|
55
55
|
};
|
|
56
|
-
return new import_mcp_tool.MCPTool(toolWithPrefix, this.mcpSessionManager);
|
|
56
|
+
return new import_mcp_tool.MCPTool(toolWithPrefix, this.mcpSessionManager, tool.name);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
async close() {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var url_context_tool_exports = {};
|
|
26
|
+
__export(url_context_tool_exports, {
|
|
27
|
+
URL_CONTEXT: () => URL_CONTEXT,
|
|
28
|
+
UrlContextTool: () => UrlContextTool
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(url_context_tool_exports);
|
|
31
|
+
var import_model_name = require("../utils/model_name.js");
|
|
32
|
+
var import_base_tool = require("./base_tool.js");
|
|
33
|
+
/**
|
|
34
|
+
* @license
|
|
35
|
+
* Copyright 2026 Google LLC
|
|
36
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
37
|
+
*/
|
|
38
|
+
class UrlContextTool extends import_base_tool.BaseTool {
|
|
39
|
+
constructor() {
|
|
40
|
+
super({ name: "url_context", description: "URL Context Tool" });
|
|
41
|
+
}
|
|
42
|
+
runAsync() {
|
|
43
|
+
return Promise.resolve();
|
|
44
|
+
}
|
|
45
|
+
async processLlmRequest({
|
|
46
|
+
llmRequest
|
|
47
|
+
}) {
|
|
48
|
+
if (!llmRequest.model) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!(0, import_model_name.isGeminiModel)(llmRequest.model)) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`URL context tool is not supported for model ${llmRequest.model}`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (!(0, import_model_name.isGemini2OrAbove)(llmRequest.model)) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`URL context tool requires Gemini 2 or above, but got ${llmRequest.model}`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
llmRequest.config = llmRequest.config || {};
|
|
62
|
+
llmRequest.config.tools = llmRequest.config.tools || [];
|
|
63
|
+
llmRequest.config.tools.push({
|
|
64
|
+
urlContext: {}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const URL_CONTEXT = new UrlContextTool();
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
URL_CONTEXT,
|
|
72
|
+
UrlContextTool
|
|
73
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var vertex_ai_search_tool_exports = {};
|
|
26
|
+
__export(vertex_ai_search_tool_exports, {
|
|
27
|
+
VertexAiSearchTool: () => VertexAiSearchTool
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(vertex_ai_search_tool_exports);
|
|
30
|
+
var import_logger = require("../utils/logger.js");
|
|
31
|
+
var import_model_name = require("../utils/model_name.js");
|
|
32
|
+
var import_base_tool = require("./base_tool.js");
|
|
33
|
+
/**
|
|
34
|
+
* @license
|
|
35
|
+
* Copyright 2026 Google LLC
|
|
36
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
37
|
+
*/
|
|
38
|
+
const logger = (0, import_logger.getLogger)();
|
|
39
|
+
class VertexAiSearchTool extends import_base_tool.BaseTool {
|
|
40
|
+
constructor(params) {
|
|
41
|
+
super({ name: "vertex_ai_search", description: "vertex_ai_search" });
|
|
42
|
+
const {
|
|
43
|
+
dataStoreId,
|
|
44
|
+
dataStoreSpecs,
|
|
45
|
+
searchEngineId,
|
|
46
|
+
filter,
|
|
47
|
+
maxResults,
|
|
48
|
+
bypassMultiToolsLimit = false
|
|
49
|
+
} = params;
|
|
50
|
+
if (dataStoreId === void 0 && searchEngineId === void 0 || dataStoreId !== void 0 && searchEngineId !== void 0) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
"Either dataStoreId or searchEngineId must be specified."
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (dataStoreSpecs !== void 0 && searchEngineId === void 0) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"searchEngineId must be specified if dataStoreSpecs is specified."
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
this.dataStoreId = dataStoreId;
|
|
61
|
+
this.dataStoreSpecs = dataStoreSpecs;
|
|
62
|
+
this.searchEngineId = searchEngineId;
|
|
63
|
+
this.filter = filter;
|
|
64
|
+
this.maxResults = maxResults;
|
|
65
|
+
this.bypassMultiToolsLimit = bypassMultiToolsLimit;
|
|
66
|
+
}
|
|
67
|
+
runAsync() {
|
|
68
|
+
return Promise.resolve();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Builds the VertexAISearch configuration.
|
|
72
|
+
*
|
|
73
|
+
* Override this method in a subclass to dynamically customize the search
|
|
74
|
+
* configuration based on the context (e.g., set filter based on session
|
|
75
|
+
* state).
|
|
76
|
+
*/
|
|
77
|
+
buildVertexAiSearchConfig(_readonlyContext) {
|
|
78
|
+
return {
|
|
79
|
+
datastore: this.dataStoreId,
|
|
80
|
+
dataStoreSpecs: this.dataStoreSpecs,
|
|
81
|
+
engine: this.searchEngineId,
|
|
82
|
+
filter: this.filter,
|
|
83
|
+
maxResults: this.maxResults
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
async processLlmRequest({
|
|
87
|
+
toolContext,
|
|
88
|
+
llmRequest
|
|
89
|
+
}) {
|
|
90
|
+
if (!llmRequest.model) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const modelCheckDisabled = (0, import_model_name.isGeminiModelIdCheckDisabled)();
|
|
94
|
+
llmRequest.config = llmRequest.config || {};
|
|
95
|
+
llmRequest.config.tools = llmRequest.config.tools || [];
|
|
96
|
+
if (!(0, import_model_name.isGeminiModel)(llmRequest.model) && !modelCheckDisabled) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`Vertex AI search tool is not supported for model ${llmRequest.model}`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
if ((0, import_model_name.isGemini1Model)(llmRequest.model) && llmRequest.config.tools.length > 0 && !this.bypassMultiToolsLimit) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
"Vertex AI search tool cannot be used with other tools in Gemini 1.x."
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
const vertexAiSearchConfig = this.buildVertexAiSearchConfig(toolContext);
|
|
107
|
+
let specsInfo;
|
|
108
|
+
if (vertexAiSearchConfig.dataStoreSpecs) {
|
|
109
|
+
const specIds = vertexAiSearchConfig.dataStoreSpecs.map(
|
|
110
|
+
(spec) => spec.dataStore ? spec.dataStore.split("/").pop() : "unnamed"
|
|
111
|
+
);
|
|
112
|
+
specsInfo = `${vertexAiSearchConfig.dataStoreSpecs.length} spec(s): [${specIds.join(", ")}]`;
|
|
113
|
+
}
|
|
114
|
+
logger.debug(
|
|
115
|
+
`Adding Vertex AI Search tool config to LLM request: datastore=${vertexAiSearchConfig.datastore}, engine=${vertexAiSearchConfig.engine}, filter=${vertexAiSearchConfig.filter}, maxResults=${vertexAiSearchConfig.maxResults}, dataStoreSpecs=${specsInfo}`
|
|
116
|
+
);
|
|
117
|
+
llmRequest.config.tools.push({
|
|
118
|
+
retrieval: {
|
|
119
|
+
vertexAiSearch: vertexAiSearchConfig
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
+
0 && (module.exports = {
|
|
126
|
+
VertexAiSearchTool
|
|
127
|
+
});
|
|
@@ -27,9 +27,11 @@ __export(model_name_exports, {
|
|
|
27
27
|
extractModelName: () => extractModelName,
|
|
28
28
|
isGemini1Model: () => isGemini1Model,
|
|
29
29
|
isGemini2OrAbove: () => isGemini2OrAbove,
|
|
30
|
-
isGeminiModel: () => isGeminiModel
|
|
30
|
+
isGeminiModel: () => isGeminiModel,
|
|
31
|
+
isGeminiModelIdCheckDisabled: () => isGeminiModelIdCheckDisabled
|
|
31
32
|
});
|
|
32
33
|
module.exports = __toCommonJS(model_name_exports);
|
|
34
|
+
var import_env_aware_utils = require("./env_aware_utils.js");
|
|
33
35
|
/**
|
|
34
36
|
* @license
|
|
35
37
|
* Copyright 2025 Google LLC
|
|
@@ -75,10 +77,14 @@ function isGemini2OrAbove(modelString) {
|
|
|
75
77
|
const parsedVersion = parseVersion(versionString);
|
|
76
78
|
return parsedVersion.valid && parsedVersion.major >= 2;
|
|
77
79
|
}
|
|
80
|
+
function isGeminiModelIdCheckDisabled() {
|
|
81
|
+
return (0, import_env_aware_utils.getBooleanEnvVar)("ADK_DISABLE_GEMINI_MODEL_ID_CHECK");
|
|
82
|
+
}
|
|
78
83
|
// Annotate the CommonJS export names for ESM import in node:
|
|
79
84
|
0 && (module.exports = {
|
|
80
85
|
extractModelName,
|
|
81
86
|
isGemini1Model,
|
|
82
87
|
isGemini2OrAbove,
|
|
83
|
-
isGeminiModel
|
|
88
|
+
isGeminiModel,
|
|
89
|
+
isGeminiModelIdCheckDisabled
|
|
84
90
|
});
|
package/dist/cjs/version.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = __toCommonJS(version_exports);
|
|
|
32
32
|
* Copyright 2025 Google LLC
|
|
33
33
|
* SPDX-License-Identifier: Apache-2.0
|
|
34
34
|
*/
|
|
35
|
-
const version = "1.
|
|
35
|
+
const version = "1.1.0";
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
|
38
38
|
version
|
package/dist/esm/common.js
CHANGED
|
@@ -102,6 +102,8 @@ import {
|
|
|
102
102
|
PreloadMemoryTool
|
|
103
103
|
} from "./tools/preload_memory_tool.js";
|
|
104
104
|
import { ToolConfirmation } from "./tools/tool_confirmation.js";
|
|
105
|
+
import { URL_CONTEXT, UrlContextTool } from "./tools/url_context_tool.js";
|
|
106
|
+
import { VertexAiSearchTool } from "./tools/vertex_ai_search_tool.js";
|
|
105
107
|
import { LogLevel, getLogger, setLogLevel, setLogger } from "./utils/logger.js";
|
|
106
108
|
import { isGemini2OrAbove } from "./utils/model_name.js";
|
|
107
109
|
import { zodObjectToSchema } from "./utils/simple_zod_to_json.js";
|
|
@@ -197,6 +199,9 @@ export {
|
|
|
197
199
|
TokenBasedContextCompactor,
|
|
198
200
|
ToolConfirmation,
|
|
199
201
|
TruncatingContextCompactor,
|
|
202
|
+
URL_CONTEXT,
|
|
203
|
+
UrlContextTool,
|
|
204
|
+
VertexAiSearchTool,
|
|
200
205
|
createEvent,
|
|
201
206
|
createEventActions,
|
|
202
207
|
createSession,
|