@google/adk 2.1.0 → 2.2.1

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 (166) hide show
  1. package/dist/cjs/a2a/agent_card.js +8 -0
  2. package/dist/cjs/a2a/agent_executor.js +8 -3
  3. package/dist/cjs/a2a/event_converter_utils.js +5 -1
  4. package/dist/cjs/a2a/metadata_converter_utils.js +2 -1
  5. package/dist/cjs/agents/llm_agent.js +15 -1
  6. package/dist/cjs/agents/processors/content_processor_utils.js +10 -2
  7. package/dist/cjs/agents/processors/nl_planning_processor.js +114 -0
  8. package/dist/cjs/artifacts/gcs_artifact_service.js +13 -7
  9. package/dist/cjs/auth/auth_credential.js +12 -2
  10. package/dist/cjs/code_executors/code_execution_utils.js +3 -3
  11. package/dist/cjs/common.js +63 -0
  12. package/dist/cjs/events/abort_events.js +135 -0
  13. package/dist/cjs/events/internal_metadata.js +131 -0
  14. package/dist/cjs/examples/example.js +92 -0
  15. package/dist/cjs/examples/example_util.js +28 -4
  16. package/dist/cjs/examples/index.js +39 -0
  17. package/dist/cjs/examples/vertex_ai_example_store.js +39 -0
  18. package/dist/cjs/index.js +46 -0
  19. package/dist/cjs/memory/vertex_ai_memory_bank_service.js +17 -5
  20. package/dist/cjs/models/base_llm.js +1 -6
  21. package/dist/cjs/models/chrome_prompt_llm.js +16 -2
  22. package/dist/cjs/models/chrome_prompt_utils.js +54 -2
  23. package/dist/cjs/models/gemini_continuation.js +232 -0
  24. package/dist/cjs/models/gemini_llm_connection.js +5 -4
  25. package/dist/cjs/planners/base_planner.js +56 -0
  26. package/dist/cjs/planners/built_in_planner.js +85 -0
  27. package/dist/cjs/planners/plan_re_act_planner.js +172 -0
  28. package/dist/cjs/plugins/base_plugin.js +46 -61
  29. package/dist/cjs/plugins/debug_logging_plugin.js +653 -0
  30. package/dist/cjs/plugins/plugin_manager.js +1 -1
  31. package/dist/cjs/plugins/tool_call_integrity_plugin.js +364 -0
  32. package/dist/cjs/runner/runner.js +17 -3
  33. package/dist/cjs/tools/example_tool.js +1 -1
  34. package/dist/cjs/tools/mcp/mcp_session_manager.js +14 -8
  35. package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +281 -2
  36. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +15 -1
  37. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js +70 -0
  38. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +120 -0
  39. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +10 -10
  40. package/dist/cjs/tools/openapi_tool/common/common.js +139 -0
  41. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +11 -6
  42. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +73 -13
  43. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +146 -34
  44. package/dist/cjs/tools/openapi_tool/openapi_toolset.js +14 -2
  45. package/dist/cjs/tools/openapi_tool/rest_api_tool.js +90 -28
  46. package/dist/cjs/tools/skill/skill_toolset.js +2 -0
  47. package/dist/cjs/tools/tool_context.js +41 -0
  48. package/dist/cjs/tools/webmcp/index.js +37 -0
  49. package/dist/cjs/tools/webmcp/webmcp_tool.js +156 -0
  50. package/dist/cjs/tools/webmcp/webmcp_toolset.js +116 -0
  51. package/dist/cjs/tools/webmcp/webmcp_types.js +50 -0
  52. package/dist/cjs/utils/case_utils.js +52 -2
  53. package/dist/cjs/utils/client_labels.js +67 -0
  54. package/dist/cjs/utils/gemini_schema_util.js +103 -3
  55. package/dist/cjs/utils/hash_utils.js +73 -0
  56. package/dist/cjs/utils/live_connection_utils.js +10 -9
  57. package/dist/cjs/utils/model_name.js +17 -2
  58. package/dist/cjs/utils/simple_zod_to_json.js +5 -0
  59. package/dist/cjs/version.js +1 -1
  60. package/dist/esm/a2a/agent_card.js +8 -0
  61. package/dist/esm/a2a/agent_executor.js +8 -3
  62. package/dist/esm/a2a/event_converter_utils.js +5 -1
  63. package/dist/esm/a2a/metadata_converter_utils.js +2 -1
  64. package/dist/esm/agents/llm_agent.js +18 -1
  65. package/dist/esm/agents/processors/content_processor_utils.js +10 -2
  66. package/dist/esm/agents/processors/nl_planning_processor.js +87 -0
  67. package/dist/esm/artifacts/gcs_artifact_service.js +13 -7
  68. package/dist/esm/auth/auth_credential.js +11 -1
  69. package/dist/esm/code_executors/code_execution_utils.js +3 -3
  70. package/dist/esm/common.js +58 -2
  71. package/dist/esm/events/abort_events.js +110 -0
  72. package/dist/esm/events/internal_metadata.js +97 -0
  73. package/dist/esm/examples/example.js +85 -0
  74. package/dist/esm/examples/example_util.js +25 -3
  75. package/dist/esm/examples/index.js +11 -0
  76. package/dist/esm/examples/vertex_ai_example_store.js +11 -0
  77. package/dist/esm/index.js +51 -1
  78. package/dist/esm/memory/vertex_ai_memory_bank_service.js +17 -5
  79. package/dist/esm/models/base_llm.js +2 -7
  80. package/dist/esm/models/chrome_prompt_llm.js +20 -3
  81. package/dist/esm/models/chrome_prompt_utils.js +51 -2
  82. package/dist/esm/models/gemini_continuation.js +205 -0
  83. package/dist/esm/models/gemini_llm_connection.js +6 -5
  84. package/dist/esm/planners/base_planner.js +28 -0
  85. package/dist/esm/planners/built_in_planner.js +57 -0
  86. package/dist/esm/planners/plan_re_act_planner.js +145 -0
  87. package/dist/esm/plugins/base_plugin.js +46 -61
  88. package/dist/esm/plugins/debug_logging_plugin.js +615 -0
  89. package/dist/esm/plugins/plugin_manager.js +1 -1
  90. package/dist/esm/plugins/tool_call_integrity_plugin.js +339 -0
  91. package/dist/esm/runner/runner.js +20 -3
  92. package/dist/esm/tools/example_tool.js +1 -1
  93. package/dist/esm/tools/mcp/mcp_session_manager.js +14 -8
  94. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +272 -1
  95. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +15 -1
  96. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js +43 -0
  97. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +93 -0
  98. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +10 -12
  99. package/dist/esm/tools/openapi_tool/common/common.js +112 -0
  100. package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +11 -6
  101. package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +80 -13
  102. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +146 -33
  103. package/dist/esm/tools/openapi_tool/openapi_toolset.js +14 -2
  104. package/dist/esm/tools/openapi_tool/rest_api_tool.js +89 -28
  105. package/dist/esm/tools/skill/skill_toolset.js +2 -0
  106. package/dist/esm/tools/tool_context.js +15 -0
  107. package/dist/esm/tools/webmcp/index.js +10 -0
  108. package/dist/esm/tools/webmcp/webmcp_tool.js +131 -0
  109. package/dist/esm/tools/webmcp/webmcp_toolset.js +89 -0
  110. package/dist/esm/tools/webmcp/webmcp_types.js +22 -0
  111. package/dist/esm/utils/case_utils.js +49 -1
  112. package/dist/esm/utils/client_labels.js +65 -0
  113. package/dist/esm/utils/gemini_schema_util.js +102 -3
  114. package/dist/esm/utils/hash_utils.js +45 -0
  115. package/dist/esm/utils/live_connection_utils.js +11 -10
  116. package/dist/esm/utils/model_name.js +15 -2
  117. package/dist/esm/utils/simple_zod_to_json.js +5 -0
  118. package/dist/esm/version.js +1 -1
  119. package/dist/types/agents/llm_agent.d.ts +12 -1
  120. package/dist/types/agents/processors/nl_planning_processor.d.ts +30 -0
  121. package/dist/types/auth/auth_credential.d.ts +9 -0
  122. package/dist/types/common.d.ts +19 -4
  123. package/dist/types/events/abort_events.d.ts +43 -0
  124. package/dist/types/events/internal_metadata.d.ts +78 -0
  125. package/dist/types/examples/base_example_provider.d.ts +2 -2
  126. package/dist/types/examples/example.d.ts +75 -0
  127. package/dist/types/examples/example_util.d.ts +13 -2
  128. package/dist/types/examples/index.d.ts +18 -0
  129. package/dist/types/examples/vertex_ai_example_store.d.ts +7 -0
  130. package/dist/types/index.d.ts +12 -3
  131. package/dist/types/memory/memory_entry.d.ts +15 -0
  132. package/dist/types/memory/vertex_ai_memory_bank_service.d.ts +9 -0
  133. package/dist/types/models/chrome_prompt_utils.d.ts +29 -0
  134. package/dist/types/models/gemini_continuation.d.ts +59 -0
  135. package/dist/types/planners/base_planner.d.ts +50 -0
  136. package/dist/types/planners/built_in_planner.d.ts +53 -0
  137. package/dist/types/planners/plan_re_act_planner.d.ts +21 -0
  138. package/dist/types/plugins/base_plugin.d.ts +52 -52
  139. package/dist/types/plugins/debug_logging_plugin.d.ts +157 -0
  140. package/dist/types/plugins/tool_call_integrity_plugin.d.ts +116 -0
  141. package/dist/types/skills/skill_registry.d.ts +8 -0
  142. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +110 -1
  143. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +32 -2
  144. package/dist/types/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.d.ts +35 -0
  145. package/dist/types/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.d.ts +54 -0
  146. package/dist/types/tools/openapi_tool/common/common.d.ts +60 -0
  147. package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +7 -0
  148. package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +56 -2
  149. package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +73 -5
  150. package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +11 -0
  151. package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +42 -8
  152. package/dist/types/tools/tool_context.d.ts +19 -0
  153. package/dist/types/tools/webmcp/index.d.ts +12 -0
  154. package/dist/types/tools/webmcp/webmcp_tool.d.ts +47 -0
  155. package/dist/types/tools/webmcp/webmcp_toolset.d.ts +67 -0
  156. package/dist/types/tools/webmcp/webmcp_types.d.ts +69 -0
  157. package/dist/types/utils/case_utils.d.ts +36 -0
  158. package/dist/types/utils/client_labels.d.ts +33 -0
  159. package/dist/types/utils/gemini_schema_util.d.ts +13 -0
  160. package/dist/types/utils/hash_utils.d.ts +25 -0
  161. package/dist/types/utils/logger.d.ts +10 -2
  162. package/dist/types/utils/model_name.d.ts +30 -2
  163. package/dist/types/version.d.ts +1 -1
  164. package/dist/web/index_web.js +113 -80
  165. package/dist/web/index_web.js.map +4 -4
  166. package/package.json +8 -2
@@ -0,0 +1,87 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ /**
6
+ * @license
7
+ * Copyright 2026 Google LLC
8
+ * SPDX-License-Identifier: Apache-2.0
9
+ */
10
+ import { appendInstructions } from "../../models/llm_request.js";
11
+ import { isBasePlanner } from "../../planners/base_planner.js";
12
+ import { isBuiltInPlanner } from "../../planners/built_in_planner.js";
13
+ import { Context } from "../context.js";
14
+ import { isLlmAgent } from "../llm_agent.js";
15
+ import { ReadonlyContext } from "../readonly_context.js";
16
+ import {
17
+ BaseLlmRequestProcessor,
18
+ BaseLlmResponseProcessor
19
+ } from "./base_llm_processor.js";
20
+ function getPlanner(invocationContext) {
21
+ const agent = invocationContext.agent;
22
+ if (!isLlmAgent(agent) || !isBasePlanner(agent.planner)) {
23
+ return void 0;
24
+ }
25
+ return agent.planner;
26
+ }
27
+ __name(getPlanner, "getPlanner");
28
+ function removeThought(part) {
29
+ const { thought: _thought, ...rest } = part;
30
+ return rest;
31
+ }
32
+ __name(removeThought, "removeThought");
33
+ function removeThoughtFromContents(contents) {
34
+ return contents.map(
35
+ (content) => content.parts ? { ...content, parts: content.parts.map(removeThought) } : content
36
+ );
37
+ }
38
+ __name(removeThoughtFromContents, "removeThoughtFromContents");
39
+ const _NlPlanningRequestProcessor = class _NlPlanningRequestProcessor extends BaseLlmRequestProcessor {
40
+ // eslint-disable-next-line require-yield -- this processor only mutates the request and has no event to emit
41
+ async *runAsync(invocationContext, llmRequest) {
42
+ const planner = getPlanner(invocationContext);
43
+ if (!planner) {
44
+ return;
45
+ }
46
+ if (isBuiltInPlanner(planner)) {
47
+ planner.applyThinkingConfig(llmRequest);
48
+ }
49
+ const planningInstruction = planner.buildPlanningInstruction(
50
+ new ReadonlyContext(invocationContext),
51
+ llmRequest
52
+ );
53
+ if (planningInstruction) {
54
+ appendInstructions(llmRequest, [planningInstruction]);
55
+ }
56
+ llmRequest.contents = removeThoughtFromContents(llmRequest.contents);
57
+ }
58
+ };
59
+ __name(_NlPlanningRequestProcessor, "NlPlanningRequestProcessor");
60
+ let NlPlanningRequestProcessor = _NlPlanningRequestProcessor;
61
+ const _NlPlanningResponseProcessor = class _NlPlanningResponseProcessor extends BaseLlmResponseProcessor {
62
+ // eslint-disable-next-line require-yield -- this processor only rewrites the response and has no event to emit
63
+ async *runAsync(invocationContext, llmResponse) {
64
+ var _a, _b;
65
+ const planner = getPlanner(invocationContext);
66
+ if (!planner || !((_b = (_a = llmResponse.content) == null ? void 0 : _a.parts) == null ? void 0 : _b.length)) {
67
+ return;
68
+ }
69
+ const processedParts = planner.processPlanningResponse(
70
+ new Context({ invocationContext }),
71
+ llmResponse.content.parts
72
+ );
73
+ if (processedParts !== void 0) {
74
+ llmResponse.content = { ...llmResponse.content, parts: processedParts };
75
+ }
76
+ }
77
+ };
78
+ __name(_NlPlanningResponseProcessor, "NlPlanningResponseProcessor");
79
+ let NlPlanningResponseProcessor = _NlPlanningResponseProcessor;
80
+ const NL_PLANNING_REQUEST_PROCESSOR = new NlPlanningRequestProcessor();
81
+ const NL_PLANNING_RESPONSE_PROCESSOR = new NlPlanningResponseProcessor();
82
+ export {
83
+ NL_PLANNING_REQUEST_PROCESSOR,
84
+ NL_PLANNING_RESPONSE_PROCESSOR,
85
+ NlPlanningRequestProcessor,
86
+ NlPlanningResponseProcessor
87
+ };
@@ -67,9 +67,7 @@ const _GcsArtifactService = class _GcsArtifactService {
67
67
  version
68
68
  })
69
69
  );
70
- const customMetadata = {
71
- ...request.customMetadata
72
- };
70
+ const customMetadata = stringifyMetadataValues(request.customMetadata);
73
71
  if (request.artifact.inlineData) {
74
72
  if (request.artifact.inlineData.displayName) {
75
73
  customMetadata[GCS_DISPLAY_NAME_METADATA_KEY] = request.artifact.inlineData.displayName;
@@ -193,10 +191,9 @@ const _GcsArtifactService = class _GcsArtifactService {
193
191
  const [files] = await bucket.getFiles({ prefix: searchPrefix });
194
192
  const versions = [];
195
193
  for (const file of files) {
196
- const version = file.name.split("/").pop();
197
- const v = parseInt(version, 10);
198
- if (!isNaN(v)) {
199
- versions.push(v);
194
+ const suffix = file.name.slice(searchPrefix.length);
195
+ if (/^\d+$/.test(suffix)) {
196
+ versions.push(Number(suffix));
200
197
  }
201
198
  }
202
199
  return versions.sort((a, b) => a - b);
@@ -262,6 +259,15 @@ function getFileName({
262
259
  return version !== void 0 ? `${prefix}/${version}` : prefix;
263
260
  }
264
261
  __name(getFileName, "getFileName");
262
+ function stringifyMetadataValues(customMetadata) {
263
+ return Object.fromEntries(
264
+ Object.entries(customMetadata != null ? customMetadata : {}).map(([key, value]) => [
265
+ key,
266
+ String(value)
267
+ ])
268
+ );
269
+ }
270
+ __name(stringifyMetadataValues, "stringifyMetadataValues");
265
271
  function extractArtifactKeys(files, fileNamePrefix, keyPrefix = "") {
266
272
  const keys = /* @__PURE__ */ new Set();
267
273
  for (const file of files) {
@@ -1,5 +1,7 @@
1
1
  import {createRequire as topLevelCreateRequire} from 'module';
2
2
  const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
5
  /**
4
6
  * @license
5
7
  * Copyright 2025 Google LLC
@@ -13,6 +15,14 @@ var AuthCredentialTypes = /* @__PURE__ */ ((AuthCredentialTypes2) => {
13
15
  AuthCredentialTypes2["SERVICE_ACCOUNT"] = "serviceAccount";
14
16
  return AuthCredentialTypes2;
15
17
  })(AuthCredentialTypes || {});
18
+ const AUTH_CREDENTIAL_TYPES = new Set(
19
+ Object.values(AuthCredentialTypes)
20
+ );
21
+ function isAuthCredential(value) {
22
+ return typeof value === "object" && value !== null && "authType" in value && AUTH_CREDENTIAL_TYPES.has(value.authType);
23
+ }
24
+ __name(isAuthCredential, "isAuthCredential");
16
25
  export {
17
- AuthCredentialTypes
26
+ AuthCredentialTypes,
27
+ isAuthCredential
18
28
  };
@@ -116,9 +116,9 @@ function convertCodeExecutionParts(content, codeBlockDelimiter, executionResultD
116
116
  text: codeBlockDelimiter[0] + (lastPart.executableCode.code || "") + codeBlockDelimiter[1]
117
117
  };
118
118
  } else if (content.parts.length == 1 && lastPart.codeExecutionResult) {
119
- content.parts[content.parts.length - 1] = {
120
- text: executionResultDelimiters[0] + lastPart.codeExecutionResult.output + executionResultDelimiters[1]
121
- };
119
+ const output = lastPart.codeExecutionResult.output;
120
+ const text = output == null ? "" : executionResultDelimiters[0] + output + executionResultDelimiters[1];
121
+ content.parts[content.parts.length - 1] = { text };
122
122
  content.role = "user";
123
123
  }
124
124
  }
@@ -49,7 +49,7 @@ import { createResumabilityConfig } from "./apps/resumability_config.js";
49
49
  import { InMemoryArtifactService } from "./artifacts/in_memory_artifact_service.js";
50
50
  import { ScopedArtifactService } from "./artifacts/scoped_artifact_service.js";
51
51
  import { isSessionArtifactService } from "./artifacts/session_artifact_service.js";
52
- import { AuthCredentialTypes } from "./auth/auth_credential.js";
52
+ import { AuthCredentialTypes, isAuthCredential } from "./auth/auth_credential.js";
53
53
  import { AuthHandler } from "./auth/auth_handler.js";
54
54
  import { AUTH_PREPROCESSOR, AuthPreprocessor } from "./auth/auth_preprocessor.js";
55
55
  import { AuthProviderRegistry } from "./auth/auth_provider_registry.js";
@@ -95,11 +95,20 @@ import {
95
95
  stringifyContent
96
96
  } from "./events/event.js";
97
97
  import { createEventActions } from "./events/event_actions.js";
98
+ import {
99
+ INTERNAL_METADATA_PREFIX,
100
+ RESTORED_EVENT_KEY,
101
+ markRestored,
102
+ publicEvent,
103
+ publicMetadata,
104
+ publicSession
105
+ } from "./events/internal_metadata.js";
98
106
  import { EventType, toStructuredEvents } from "./events/structured_events.js";
99
107
  import {
100
108
  BaseExampleProvider,
101
109
  isBaseExampleProvider
102
110
  } from "./examples/base_example_provider.js";
111
+ import { VertexAiExampleStore } from "./examples/example.js";
103
112
  import { InMemoryMemoryService } from "./memory/in_memory_memory_service.js";
104
113
  import { ApigeeLlm } from "./models/apigee_llm.js";
105
114
  import { BaseLlm, isBaseLlm } from "./models/base_llm.js";
@@ -111,6 +120,9 @@ import {
111
120
  import { Gemini, geminiInitParams } from "./models/google_llm.js";
112
121
  import { LLMRegistry } from "./models/registry.js";
113
122
  import { RoutedLlm } from "./models/routed_llm.js";
123
+ import { BasePlanner, isBasePlanner } from "./planners/base_planner.js";
124
+ import { BuiltInPlanner, isBuiltInPlanner } from "./planners/built_in_planner.js";
125
+ import { PlanReActPlanner } from "./planners/plan_re_act_planner.js";
114
126
  import {
115
127
  GLOBAL_SCOPE_KEY,
116
128
  REFLECT_AND_RETRY_RESPONSE_TYPE,
@@ -136,6 +148,10 @@ import {
136
148
  SecurityPlugin,
137
149
  getAskUserConfirmationFunctionCalls
138
150
  } from "./plugins/security_plugin.js";
151
+ import {
152
+ ToolCallIntegrityError,
153
+ ToolCallIntegrityPlugin
154
+ } from "./plugins/tool_call_integrity_plugin.js";
139
155
  import { InMemoryRunner } from "./runner/in_memory_runner.js";
140
156
  import {
141
157
  Runner,
@@ -190,19 +206,33 @@ import {
190
206
  ToolConfirmation,
191
207
  isIntentMismatchError
192
208
  } from "./tools/tool_confirmation.js";
209
+ import { CallbackContext, ToolContext } from "./tools/tool_context.js";
193
210
  import { URL_CONTEXT, UrlContextTool } from "./tools/url_context_tool.js";
194
211
  import { VertexAiSearchTool } from "./tools/vertex_ai_search_tool.js";
195
212
  import { VertexRagRetrievalTool } from "./tools/vertex_rag_retrieval_tool.js";
213
+ import { WebMCPTool } from "./tools/webmcp/webmcp_tool.js";
214
+ import { WebMCPToolset } from "./tools/webmcp/webmcp_toolset.js";
215
+ import {
216
+ getModelContext,
217
+ isWebMCPSupported
218
+ } from "./tools/webmcp/webmcp_types.js";
196
219
  import { AsyncQueue } from "./utils/async_queue.js";
220
+ import { renameReservedKeywords, toSnakeCaseName } from "./utils/case_utils.js";
197
221
  import { getClientLabels, runWithClientLabel } from "./utils/client_labels.js";
198
222
  import {
199
223
  LogLevel,
200
224
  getLogger,
225
+ logger,
201
226
  resetLogger,
202
227
  setLogLevel,
203
228
  setLogger
204
229
  } from "./utils/logger.js";
205
- import { isGemini2OrAbove, isGemini3xFlashLive } from "./utils/model_name.js";
230
+ import {
231
+ isGemini2OrAbove,
232
+ isGemini35LiveTranslate,
233
+ isGemini3xFlashLive,
234
+ isGemini3xLive
235
+ } from "./utils/model_name.js";
206
236
  import { zodObjectToSchema } from "./utils/simple_zod_to_json.js";
207
237
  import { Task } from "./utils/task.js";
208
238
  import { GoogleLLMVariant } from "./utils/variant_utils.js";
@@ -283,6 +313,7 @@ export {
283
313
  BaseLlmRequestProcessor,
284
314
  BaseLlmResponseProcessor,
285
315
  BaseNode,
316
+ BasePlanner,
286
317
  BasePlugin,
287
318
  BaseRetrievalTool,
288
319
  BaseSessionService,
@@ -290,8 +321,10 @@ export {
290
321
  BaseToolset,
291
322
  BranchPath,
292
323
  BuiltInCodeExecutor,
324
+ BuiltInPlanner,
293
325
  BuiltInTool,
294
326
  CONTENT_REQUEST_PROCESSOR,
327
+ CallbackContext,
295
328
  ChromeBuiltInLlm,
296
329
  ChromeModelUnavailableError,
297
330
  CodeExecutionLanguage,
@@ -327,6 +360,7 @@ export {
327
360
  GoogleSearchTool,
328
361
  Graph,
329
362
  INTERACTIONS_REQUEST_PROCESSOR,
363
+ INTERNAL_METADATA_PREFIX,
330
364
  InMemoryArtifactService,
331
365
  InMemoryCredentialService,
332
366
  InMemoryMemoryService,
@@ -366,6 +400,7 @@ export {
366
400
  PRELOAD_MEMORY,
367
401
  ParallelAgent,
368
402
  ParallelWorker,
403
+ PlanReActPlanner,
369
404
  PluginManager,
370
405
  PolicyOutcome,
371
406
  PreloadMemoryTool,
@@ -374,6 +409,7 @@ export {
374
409
  REQUEST_CREDENTIAL_FUNCTION_CALL_NAME,
375
410
  REQUEST_INPUT_FUNCTION_CALL_NAME,
376
411
  RESERVED_TOOL_CALL_ERROR_TYPE,
412
+ RESTORED_EVENT_KEY,
377
413
  ReadonlyContext,
378
414
  ReflectAndRetryModelPlugin,
379
415
  ReflectAndRetryToolPlugin,
@@ -394,7 +430,10 @@ export {
394
430
  StreamingMode,
395
431
  Task,
396
432
  TokenBasedContextCompactor,
433
+ ToolCallIntegrityError,
434
+ ToolCallIntegrityPlugin,
397
435
  ToolConfirmation,
436
+ ToolContext,
398
437
  ToolErrorType,
399
438
  ToolExecutionError,
400
439
  ToolNode,
@@ -403,8 +442,11 @@ export {
403
442
  TruncatingContextCompactor,
404
443
  URL_CONTEXT,
405
444
  UrlContextTool,
445
+ VertexAiExampleStore,
406
446
  VertexAiSearchTool,
407
447
  VertexRagRetrievalTool,
448
+ WebMCPTool,
449
+ WebMCPToolset,
408
450
  Workflow,
409
451
  WorkflowNode,
410
452
  asRunnableRoot,
@@ -428,6 +470,7 @@ export {
428
470
  getFunctionCalls,
429
471
  getFunctionResponses,
430
472
  getLogger,
473
+ getModelContext,
431
474
  getPendingUserInputRequests,
432
475
  getUserChoiceTool,
433
476
  getUserInputRequests,
@@ -435,16 +478,21 @@ export {
435
478
  hasTrailingCodeExecutionResult,
436
479
  isAgentTool,
437
480
  isApp,
481
+ isAuthCredential,
438
482
  isBaseAgent,
439
483
  isBaseExampleProvider,
440
484
  isBaseLlm,
485
+ isBasePlanner,
441
486
  isBaseTool,
442
487
  isBaseToolset,
488
+ isBuiltInPlanner,
443
489
  isCompactedEvent,
444
490
  isFinalResponse,
445
491
  isFunctionTool,
446
492
  isGemini2OrAbove,
493
+ isGemini35LiveTranslate,
447
494
  isGemini3xFlashLive,
495
+ isGemini3xLive,
448
496
  isIntentMismatchError,
449
497
  isLlmAgent,
450
498
  isLoopAgent,
@@ -464,12 +512,19 @@ export {
464
512
  isSessionArtifactService,
465
513
  isStateSchemaError,
466
514
  isToolNotFound,
515
+ isWebMCPSupported,
467
516
  isWorkflow,
517
+ logger,
518
+ markRestored,
468
519
  node,
469
520
  normalizeRetryExceptions,
470
521
  populateClientFunctionCallId,
471
522
  prepareRetryConfig,
472
523
  pruneThoughts,
524
+ publicEvent,
525
+ publicMetadata,
526
+ publicSession,
527
+ renameReservedKeywords,
473
528
  requestInputTool,
474
529
  requireAgent,
475
530
  requiresUserInput,
@@ -480,6 +535,7 @@ export {
480
535
  setLogger,
481
536
  stringifyContent,
482
537
  stripAdkIdentityPreamble,
538
+ toSnakeCaseName,
483
539
  toStructuredEvents,
484
540
  validateAppName,
485
541
  version,
@@ -0,0 +1,110 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ /**
6
+ * @license
7
+ * Copyright 2026 Google LLC
8
+ * SPDX-License-Identifier: Apache-2.0
9
+ */
10
+ import {
11
+ createEvent,
12
+ getFunctionCalls,
13
+ getFunctionResponses,
14
+ isFinalResponse
15
+ } from "./event.js";
16
+ const INVOCATION_ABORTED = "INVOCATION_ABORTED";
17
+ const ABORT_MESSAGE = "Invocation was aborted by client.";
18
+ function isAbortEvent(event) {
19
+ return event.errorCode === INVOCATION_ABORTED;
20
+ }
21
+ __name(isAbortEvent, "isAbortEvent");
22
+ function isPausedTaskReply(event) {
23
+ return Boolean(event.isolationScope) && event.author !== "user" && isFinalResponse(event);
24
+ }
25
+ __name(isPausedTaskReply, "isPausedTaskReply");
26
+ function buildAbortEvents({
27
+ events,
28
+ invocationId,
29
+ rootAgentName,
30
+ branch
31
+ }) {
32
+ var _a, _b;
33
+ const invocationEvents = events.filter(
34
+ (e) => e.invocationId === invocationId
35
+ );
36
+ if (invocationEvents.length > 0 && isPausedTaskReply(invocationEvents[invocationEvents.length - 1])) {
37
+ return [];
38
+ }
39
+ const answeredCallIds = /* @__PURE__ */ new Set();
40
+ for (const event of invocationEvents) {
41
+ for (const fr of getFunctionResponses(event)) {
42
+ if (fr.id) {
43
+ answeredCallIds.add(fr.id);
44
+ }
45
+ }
46
+ }
47
+ const groupedCalls = /* @__PURE__ */ new Map();
48
+ for (const event of invocationEvents) {
49
+ for (const fc of getFunctionCalls(event)) {
50
+ if (!fc.id || answeredCallIds.has(fc.id)) {
51
+ continue;
52
+ }
53
+ const callBranch = event.branch || branch;
54
+ const key = JSON.stringify([
55
+ (_a = event.author) != null ? _a : null,
56
+ callBranch != null ? callBranch : null,
57
+ (_b = event.isolationScope) != null ? _b : null
58
+ ]);
59
+ let group = groupedCalls.get(key);
60
+ if (!group) {
61
+ group = {
62
+ author: event.author,
63
+ branch: callBranch,
64
+ isolationScope: event.isolationScope,
65
+ calls: []
66
+ };
67
+ groupedCalls.set(key, group);
68
+ }
69
+ group.calls.push(fc);
70
+ }
71
+ }
72
+ if (groupedCalls.size === 0) {
73
+ return [
74
+ createEvent({
75
+ invocationId,
76
+ author: rootAgentName,
77
+ branch,
78
+ errorCode: INVOCATION_ABORTED,
79
+ errorMessage: ABORT_MESSAGE
80
+ })
81
+ ];
82
+ }
83
+ return [...groupedCalls.values()].map(
84
+ (group) => createEvent({
85
+ invocationId,
86
+ author: group.author,
87
+ branch: group.branch,
88
+ isolationScope: group.isolationScope,
89
+ content: {
90
+ role: "user",
91
+ parts: group.calls.map((fc) => ({
92
+ functionResponse: {
93
+ id: fc.id,
94
+ name: fc.name,
95
+ response: { error: ABORT_MESSAGE }
96
+ }
97
+ }))
98
+ },
99
+ errorCode: INVOCATION_ABORTED,
100
+ errorMessage: ABORT_MESSAGE
101
+ })
102
+ );
103
+ }
104
+ __name(buildAbortEvents, "buildAbortEvents");
105
+ export {
106
+ ABORT_MESSAGE,
107
+ INVOCATION_ABORTED,
108
+ buildAbortEvents,
109
+ isAbortEvent
110
+ };
@@ -0,0 +1,97 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ /**
6
+ * @license
7
+ * Copyright 2026 Google LLC
8
+ * SPDX-License-Identifier: Apache-2.0
9
+ */
10
+ import { logger } from "../utils/logger.js";
11
+ const INTERNAL_METADATA_PREFIX = "__adk_internal_";
12
+ const RESTORED_EVENT_KEY = `${INTERNAL_METADATA_PREFIX}restored_event`;
13
+ function isMetadataObject(value) {
14
+ return typeof value === "object" && value !== null && !Array.isArray(value);
15
+ }
16
+ __name(isMetadataObject, "isMetadataObject");
17
+ function isInternalKey(key) {
18
+ return key.startsWith(INTERNAL_METADATA_PREFIX);
19
+ }
20
+ __name(isInternalKey, "isInternalKey");
21
+ function dropInternalKeys(metadata) {
22
+ return Object.fromEntries(
23
+ Object.entries(metadata).filter(([key]) => !isInternalKey(key))
24
+ );
25
+ }
26
+ __name(dropInternalKeys, "dropInternalKeys");
27
+ function hasInternalKeys(metadata) {
28
+ return isMetadataObject(metadata) && Object.keys(metadata).some(isInternalKey);
29
+ }
30
+ __name(hasInternalKeys, "hasInternalKeys");
31
+ function withoutInternalMetadata(metadata) {
32
+ if (!isMetadataObject(metadata)) {
33
+ return metadata;
34
+ }
35
+ const kept = dropInternalKeys(metadata);
36
+ const dropped = Object.keys(metadata).filter(isInternalKey);
37
+ if (dropped.length > 0) {
38
+ logger.debug(
39
+ `Dropping ADK-internal customMetadata keys: ${JSON.stringify(dropped.sort())}`
40
+ );
41
+ }
42
+ return kept;
43
+ }
44
+ __name(withoutInternalMetadata, "withoutInternalMetadata");
45
+ function publicMetadata(metadata) {
46
+ if (!isMetadataObject(metadata)) {
47
+ return metadata;
48
+ }
49
+ const kept = dropInternalKeys(metadata);
50
+ return Object.keys(kept).length > 0 ? kept : void 0;
51
+ }
52
+ __name(publicMetadata, "publicMetadata");
53
+ function internalMetadata(metadata) {
54
+ if (!isMetadataObject(metadata)) {
55
+ return {};
56
+ }
57
+ return Object.fromEntries(
58
+ Object.entries(metadata).filter(([key]) => isInternalKey(key))
59
+ );
60
+ }
61
+ __name(internalMetadata, "internalMetadata");
62
+ function markRestored(event) {
63
+ var _a;
64
+ event.customMetadata = {
65
+ ...(_a = withoutInternalMetadata(event.customMetadata)) != null ? _a : {},
66
+ [RESTORED_EVENT_KEY]: true
67
+ };
68
+ return event;
69
+ }
70
+ __name(markRestored, "markRestored");
71
+ function publicEvent(event) {
72
+ if (!hasInternalKeys(event.customMetadata)) {
73
+ return event;
74
+ }
75
+ return { ...event, customMetadata: publicMetadata(event.customMetadata) };
76
+ }
77
+ __name(publicEvent, "publicEvent");
78
+ function publicSession(session) {
79
+ var _a;
80
+ const events = (_a = session.events) != null ? _a : [];
81
+ const publicEvents = events.map((event) => publicEvent(event));
82
+ if (publicEvents.every((event, i) => event === events[i])) {
83
+ return session;
84
+ }
85
+ return { ...session, events: publicEvents };
86
+ }
87
+ __name(publicSession, "publicSession");
88
+ export {
89
+ INTERNAL_METADATA_PREFIX,
90
+ RESTORED_EVENT_KEY,
91
+ internalMetadata,
92
+ markRestored,
93
+ publicEvent,
94
+ publicMetadata,
95
+ publicSession,
96
+ withoutInternalMetadata
97
+ };
@@ -1,7 +1,92 @@
1
1
  import {createRequire as topLevelCreateRequire} from 'module';
2
2
  const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
5
  /**
4
6
  * @license
5
7
  * Copyright 2025 Google LLC
6
8
  * SPDX-License-Identifier: Apache-2.0
7
9
  */
10
+ import { BaseExampleProvider } from "./base_example_provider.js";
11
+ const SIMILARITY_SCORE_THRESHOLD = 0.5;
12
+ const DEFAULT_TOP_K = 10;
13
+ const _VertexAiExampleStore = class _VertexAiExampleStore extends BaseExampleProvider {
14
+ /**
15
+ * Initializes the VertexAiExampleStore.
16
+ *
17
+ * @param examplesStoreName The resource name of the vertex example store, in
18
+ * the format of
19
+ * `projects/{project}/locations/{location}/exampleStores/{example_store}`.
20
+ * @param apiClient A client that reaches the Vertex AI Example Store API.
21
+ * adk-js does not bundle the `vertexai` dependency the Python SDK relies
22
+ * on, so the caller supplies this client.
23
+ */
24
+ constructor(examplesStoreName, apiClient) {
25
+ super();
26
+ this.examplesStoreName = examplesStoreName;
27
+ this.apiClient = apiClient;
28
+ }
29
+ /**
30
+ * Retrieves relevant examples from the Vertex AI Example Store for the given
31
+ * query.
32
+ */
33
+ async getExamples(query) {
34
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
35
+ const request = {
36
+ storedContentsExampleParameters: {
37
+ contentSearchKey: {
38
+ contents: [{ role: "user", parts: [{ text: query }] }],
39
+ searchKeyGenerationMethod: { lastEntry: {} }
40
+ }
41
+ },
42
+ topK: DEFAULT_TOP_K,
43
+ exampleStore: this.examplesStoreName
44
+ };
45
+ const response = await this.apiClient.searchExamples(request);
46
+ const returnedExamples = [];
47
+ for (const result of (_a = response.results) != null ? _a : []) {
48
+ if (((_b = result.similarityScore) != null ? _b : 0) < SIMILARITY_SCORE_THRESHOLD) {
49
+ continue;
50
+ }
51
+ const storedExample = (_c = result.example) == null ? void 0 : _c.storedContentsExample;
52
+ const expectedContents = ((_e = (_d = storedExample == null ? void 0 : storedExample.contentsExample) == null ? void 0 : _d.expectedContents) != null ? _e : []).map((entry) => entry.content).filter((content) => content !== void 0);
53
+ const expectedOutput = [];
54
+ for (const content of expectedContents) {
55
+ const expectedParts = [];
56
+ for (const part of (_f = content.parts) != null ? _f : []) {
57
+ if (part.text) {
58
+ expectedParts.push({ text: part.text });
59
+ } else if (part.functionCall) {
60
+ expectedParts.push({
61
+ functionCall: {
62
+ name: part.functionCall.name,
63
+ args: { ...(_g = part.functionCall.args) != null ? _g : {} }
64
+ }
65
+ });
66
+ } else if (part.functionResponse) {
67
+ expectedParts.push({
68
+ functionResponse: {
69
+ name: part.functionResponse.name,
70
+ response: { ...(_h = part.functionResponse.response) != null ? _h : {} }
71
+ }
72
+ });
73
+ }
74
+ }
75
+ expectedOutput.push({ role: content.role, parts: expectedParts });
76
+ }
77
+ returnedExamples.push({
78
+ input: {
79
+ role: "user",
80
+ parts: [{ text: (_i = storedExample == null ? void 0 : storedExample.searchKey) != null ? _i : "" }]
81
+ },
82
+ output: expectedOutput
83
+ });
84
+ }
85
+ return returnedExamples;
86
+ }
87
+ };
88
+ __name(_VertexAiExampleStore, "VertexAiExampleStore");
89
+ let VertexAiExampleStore = _VertexAiExampleStore;
90
+ export {
91
+ VertexAiExampleStore
92
+ };