@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.
Files changed (38) hide show
  1. package/dist/cjs/common.js +8 -0
  2. package/dist/cjs/index.js +83 -125
  3. package/dist/cjs/tools/agent_tool.js +1 -1
  4. package/dist/cjs/tools/mcp/mcp_tool.js +3 -2
  5. package/dist/cjs/tools/mcp/mcp_toolset.js +1 -1
  6. package/dist/cjs/tools/url_context_tool.js +73 -0
  7. package/dist/cjs/tools/vertex_ai_search_tool.js +127 -0
  8. package/dist/cjs/utils/model_name.js +8 -2
  9. package/dist/cjs/version.js +1 -1
  10. package/dist/esm/common.js +5 -0
  11. package/dist/esm/index.js +43 -130
  12. package/dist/esm/tools/agent_tool.js +1 -1
  13. package/dist/esm/tools/mcp/mcp_tool.js +3 -2
  14. package/dist/esm/tools/mcp/mcp_toolset.js +1 -1
  15. package/dist/esm/tools/url_context_tool.js +44 -0
  16. package/dist/esm/tools/vertex_ai_search_tool.js +103 -0
  17. package/dist/esm/utils/model_name.js +6 -1
  18. package/dist/esm/version.js +1 -1
  19. package/dist/types/common.d.ts +3 -0
  20. package/dist/types/tools/mcp/mcp_tool.d.ts +7 -1
  21. package/dist/types/tools/mcp/mcp_toolset.d.ts +5 -0
  22. package/dist/types/tools/url_context_tool.d.ts +17 -0
  23. package/dist/types/tools/vertex_ai_search_tool.d.ts +55 -0
  24. package/dist/types/utils/model_name.d.ts +4 -0
  25. package/dist/types/version.d.ts +1 -1
  26. package/dist/web/common.js +5 -0
  27. package/dist/web/index.js +43 -12
  28. package/dist/web/tools/agent_tool.js +1 -1
  29. package/dist/web/tools/mcp/mcp_tool.js +3 -2
  30. package/dist/web/tools/mcp/mcp_toolset.js +1 -1
  31. package/dist/web/tools/url_context_tool.js +44 -0
  32. package/dist/web/tools/vertex_ai_search_tool.js +103 -0
  33. package/dist/web/utils/model_name.js +6 -1
  34. package/dist/web/version.js +1 -1
  35. package/package.json +2 -2
  36. package/dist/cjs/index.js.map +0 -7
  37. package/dist/esm/index.js.map +0 -7
  38. package/dist/web/index.js.map +0 -7
@@ -0,0 +1,103 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ /**
4
+ * @license
5
+ * Copyright 2026 Google LLC
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ import { getLogger } from "../utils/logger.js";
9
+ import {
10
+ isGemini1Model,
11
+ isGeminiModel,
12
+ isGeminiModelIdCheckDisabled
13
+ } from "../utils/model_name.js";
14
+ import { BaseTool } from "./base_tool.js";
15
+ const logger = getLogger();
16
+ class VertexAiSearchTool extends BaseTool {
17
+ constructor(params) {
18
+ super({ name: "vertex_ai_search", description: "vertex_ai_search" });
19
+ const {
20
+ dataStoreId,
21
+ dataStoreSpecs,
22
+ searchEngineId,
23
+ filter,
24
+ maxResults,
25
+ bypassMultiToolsLimit = false
26
+ } = params;
27
+ if (dataStoreId === void 0 && searchEngineId === void 0 || dataStoreId !== void 0 && searchEngineId !== void 0) {
28
+ throw new Error(
29
+ "Either dataStoreId or searchEngineId must be specified."
30
+ );
31
+ }
32
+ if (dataStoreSpecs !== void 0 && searchEngineId === void 0) {
33
+ throw new Error(
34
+ "searchEngineId must be specified if dataStoreSpecs is specified."
35
+ );
36
+ }
37
+ this.dataStoreId = dataStoreId;
38
+ this.dataStoreSpecs = dataStoreSpecs;
39
+ this.searchEngineId = searchEngineId;
40
+ this.filter = filter;
41
+ this.maxResults = maxResults;
42
+ this.bypassMultiToolsLimit = bypassMultiToolsLimit;
43
+ }
44
+ runAsync() {
45
+ return Promise.resolve();
46
+ }
47
+ /**
48
+ * Builds the VertexAISearch configuration.
49
+ *
50
+ * Override this method in a subclass to dynamically customize the search
51
+ * configuration based on the context (e.g., set filter based on session
52
+ * state).
53
+ */
54
+ buildVertexAiSearchConfig(_readonlyContext) {
55
+ return {
56
+ datastore: this.dataStoreId,
57
+ dataStoreSpecs: this.dataStoreSpecs,
58
+ engine: this.searchEngineId,
59
+ filter: this.filter,
60
+ maxResults: this.maxResults
61
+ };
62
+ }
63
+ async processLlmRequest({
64
+ toolContext,
65
+ llmRequest
66
+ }) {
67
+ if (!llmRequest.model) {
68
+ return;
69
+ }
70
+ const modelCheckDisabled = isGeminiModelIdCheckDisabled();
71
+ llmRequest.config = llmRequest.config || {};
72
+ llmRequest.config.tools = llmRequest.config.tools || [];
73
+ if (!isGeminiModel(llmRequest.model) && !modelCheckDisabled) {
74
+ throw new Error(
75
+ "Vertex AI search tool is not supported for model ".concat(llmRequest.model)
76
+ );
77
+ }
78
+ if (isGemini1Model(llmRequest.model) && llmRequest.config.tools.length > 0 && !this.bypassMultiToolsLimit) {
79
+ throw new Error(
80
+ "Vertex AI search tool cannot be used with other tools in Gemini 1.x."
81
+ );
82
+ }
83
+ const vertexAiSearchConfig = this.buildVertexAiSearchConfig(toolContext);
84
+ let specsInfo;
85
+ if (vertexAiSearchConfig.dataStoreSpecs) {
86
+ const specIds = vertexAiSearchConfig.dataStoreSpecs.map(
87
+ (spec) => spec.dataStore ? spec.dataStore.split("/").pop() : "unnamed"
88
+ );
89
+ specsInfo = "".concat(vertexAiSearchConfig.dataStoreSpecs.length, " spec(s): [").concat(specIds.join(", "), "]");
90
+ }
91
+ logger.debug(
92
+ "Adding Vertex AI Search tool config to LLM request: " + "datastore=".concat(vertexAiSearchConfig.datastore, ", ") + "engine=".concat(vertexAiSearchConfig.engine, ", ") + "filter=".concat(vertexAiSearchConfig.filter, ", ") + "maxResults=".concat(vertexAiSearchConfig.maxResults, ", ") + "dataStoreSpecs=".concat(specsInfo)
93
+ );
94
+ llmRequest.config.tools.push({
95
+ retrieval: {
96
+ vertexAiSearch: vertexAiSearchConfig
97
+ }
98
+ });
99
+ }
100
+ }
101
+ export {
102
+ VertexAiSearchTool
103
+ };
@@ -5,6 +5,7 @@ const require = topLevelCreateRequire(import.meta.url);
5
5
  * Copyright 2025 Google LLC
6
6
  * SPDX-License-Identifier: Apache-2.0
7
7
  */
8
+ import { getBooleanEnvVar } from "./env_aware_utils.js";
8
9
  const MODEL_NAME_PATTERN = "^projects/[^/]+/locations/[^/]+/publishers/[^/]+/models/(.+)$";
9
10
  function extractModelName(modelString) {
10
11
  const match = modelString.match(MODEL_NAME_PATTERN);
@@ -45,9 +46,13 @@ function isGemini2OrAbove(modelString) {
45
46
  const parsedVersion = parseVersion(versionString);
46
47
  return parsedVersion.valid && parsedVersion.major >= 2;
47
48
  }
49
+ function isGeminiModelIdCheckDisabled() {
50
+ return getBooleanEnvVar("ADK_DISABLE_GEMINI_MODEL_ID_CHECK");
51
+ }
48
52
  export {
49
53
  extractModelName,
50
54
  isGemini1Model,
51
55
  isGemini2OrAbove,
52
- isGeminiModel
56
+ isGeminiModel,
57
+ isGeminiModelIdCheckDisabled
53
58
  };
@@ -5,7 +5,7 @@ const require = topLevelCreateRequire(import.meta.url);
5
5
  * Copyright 2025 Google LLC
6
6
  * SPDX-License-Identifier: Apache-2.0
7
7
  */
8
- const version = "1.0.0";
8
+ const version = "1.1.0";
9
9
  export {
10
10
  version
11
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/adk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Google ADK JS",
5
5
  "author": "Google",
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,7 @@
37
37
  "test": "vitest",
38
38
  "lint": "eslint 'src/**/*.ts'",
39
39
  "format": "prettier --write 'src/**/*.ts'",
40
- "prepublishOnly": "npm run build:bundle"
40
+ "prepublishOnly": "npm run build"
41
41
  },
42
42
  "dependencies": {
43
43
  "@a2a-js/sdk": "^0.3.10",