@google/adk 2.1.0 → 2.2.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/a2a/agent_card.js +8 -0
- package/dist/cjs/a2a/agent_executor.js +8 -3
- package/dist/cjs/agents/llm_agent.js +15 -1
- package/dist/cjs/agents/processors/content_processor_utils.js +10 -2
- package/dist/cjs/agents/processors/nl_planning_processor.js +114 -0
- package/dist/cjs/artifacts/gcs_artifact_service.js +13 -7
- package/dist/cjs/auth/auth_credential.js +12 -2
- package/dist/cjs/code_executors/code_execution_utils.js +3 -3
- package/dist/cjs/common.js +45 -0
- package/dist/cjs/examples/example.js +92 -0
- package/dist/cjs/examples/example_util.js +28 -4
- package/dist/cjs/examples/index.js +39 -0
- package/dist/cjs/examples/vertex_ai_example_store.js +39 -0
- package/dist/cjs/index.js +46 -0
- package/dist/cjs/memory/vertex_ai_memory_bank_service.js +17 -5
- package/dist/cjs/models/base_llm.js +1 -6
- package/dist/cjs/models/chrome_prompt_llm.js +16 -2
- package/dist/cjs/models/chrome_prompt_utils.js +54 -2
- package/dist/cjs/models/gemini_llm_connection.js +5 -4
- package/dist/cjs/planners/base_planner.js +56 -0
- package/dist/cjs/planners/built_in_planner.js +85 -0
- package/dist/cjs/planners/plan_re_act_planner.js +172 -0
- package/dist/cjs/plugins/base_plugin.js +46 -61
- package/dist/cjs/tools/example_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_session_manager.js +14 -8
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +281 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +15 -1
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js +70 -0
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +120 -0
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +10 -10
- package/dist/cjs/tools/openapi_tool/common/common.js +139 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +11 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +73 -13
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +146 -34
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +14 -2
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +90 -28
- package/dist/cjs/tools/skill/skill_toolset.js +2 -0
- package/dist/cjs/tools/tool_context.js +41 -0
- package/dist/cjs/tools/webmcp/index.js +37 -0
- package/dist/cjs/tools/webmcp/webmcp_tool.js +156 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +116 -0
- package/dist/cjs/tools/webmcp/webmcp_types.js +50 -0
- package/dist/cjs/utils/case_utils.js +52 -2
- package/dist/cjs/utils/client_labels.js +67 -0
- package/dist/cjs/utils/gemini_schema_util.js +103 -3
- package/dist/cjs/utils/hash_utils.js +73 -0
- package/dist/cjs/utils/live_connection_utils.js +10 -9
- package/dist/cjs/utils/model_name.js +17 -2
- package/dist/cjs/utils/simple_zod_to_json.js +5 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/agent_card.js +8 -0
- package/dist/esm/a2a/agent_executor.js +8 -3
- package/dist/esm/agents/llm_agent.js +18 -1
- package/dist/esm/agents/processors/content_processor_utils.js +10 -2
- package/dist/esm/agents/processors/nl_planning_processor.js +87 -0
- package/dist/esm/artifacts/gcs_artifact_service.js +13 -7
- package/dist/esm/auth/auth_credential.js +11 -1
- package/dist/esm/code_executors/code_execution_utils.js +3 -3
- package/dist/esm/common.js +38 -2
- package/dist/esm/examples/example.js +85 -0
- package/dist/esm/examples/example_util.js +25 -3
- package/dist/esm/examples/index.js +11 -0
- package/dist/esm/examples/vertex_ai_example_store.js +11 -0
- package/dist/esm/index.js +51 -1
- package/dist/esm/memory/vertex_ai_memory_bank_service.js +17 -5
- package/dist/esm/models/base_llm.js +2 -7
- package/dist/esm/models/chrome_prompt_llm.js +20 -3
- package/dist/esm/models/chrome_prompt_utils.js +51 -2
- package/dist/esm/models/gemini_llm_connection.js +6 -5
- package/dist/esm/planners/base_planner.js +28 -0
- package/dist/esm/planners/built_in_planner.js +57 -0
- package/dist/esm/planners/plan_re_act_planner.js +145 -0
- package/dist/esm/plugins/base_plugin.js +46 -61
- package/dist/esm/tools/example_tool.js +1 -1
- package/dist/esm/tools/mcp/mcp_session_manager.js +14 -8
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +272 -1
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +15 -1
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js +43 -0
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +93 -0
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +10 -12
- package/dist/esm/tools/openapi_tool/common/common.js +112 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +11 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +80 -13
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +146 -33
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +14 -2
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +89 -28
- package/dist/esm/tools/skill/skill_toolset.js +2 -0
- package/dist/esm/tools/tool_context.js +15 -0
- package/dist/esm/tools/webmcp/index.js +10 -0
- package/dist/esm/tools/webmcp/webmcp_tool.js +131 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +89 -0
- package/dist/esm/tools/webmcp/webmcp_types.js +22 -0
- package/dist/esm/utils/case_utils.js +49 -1
- package/dist/esm/utils/client_labels.js +65 -0
- package/dist/esm/utils/gemini_schema_util.js +102 -3
- package/dist/esm/utils/hash_utils.js +45 -0
- package/dist/esm/utils/live_connection_utils.js +11 -10
- package/dist/esm/utils/model_name.js +15 -2
- package/dist/esm/utils/simple_zod_to_json.js +5 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/agents/llm_agent.d.ts +12 -1
- package/dist/types/agents/processors/nl_planning_processor.d.ts +30 -0
- package/dist/types/auth/auth_credential.d.ts +9 -0
- package/dist/types/common.d.ts +16 -4
- package/dist/types/examples/base_example_provider.d.ts +2 -2
- package/dist/types/examples/example.d.ts +75 -0
- package/dist/types/examples/example_util.d.ts +13 -2
- package/dist/types/examples/index.d.ts +18 -0
- package/dist/types/examples/vertex_ai_example_store.d.ts +7 -0
- package/dist/types/index.d.ts +12 -3
- package/dist/types/memory/memory_entry.d.ts +15 -0
- package/dist/types/memory/vertex_ai_memory_bank_service.d.ts +9 -0
- package/dist/types/models/chrome_prompt_utils.d.ts +29 -0
- package/dist/types/planners/base_planner.d.ts +50 -0
- package/dist/types/planners/built_in_planner.d.ts +53 -0
- package/dist/types/planners/plan_re_act_planner.d.ts +21 -0
- package/dist/types/plugins/base_plugin.d.ts +52 -52
- package/dist/types/skills/skill_registry.d.ts +8 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +110 -1
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +32 -2
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.d.ts +35 -0
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.d.ts +54 -0
- package/dist/types/tools/openapi_tool/common/common.d.ts +60 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +7 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +56 -2
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +73 -5
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +11 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +42 -8
- package/dist/types/tools/tool_context.d.ts +19 -0
- package/dist/types/tools/webmcp/index.d.ts +12 -0
- package/dist/types/tools/webmcp/webmcp_tool.d.ts +47 -0
- package/dist/types/tools/webmcp/webmcp_toolset.d.ts +67 -0
- package/dist/types/tools/webmcp/webmcp_types.d.ts +69 -0
- package/dist/types/utils/case_utils.d.ts +36 -0
- package/dist/types/utils/client_labels.d.ts +33 -0
- package/dist/types/utils/gemini_schema_util.d.ts +13 -0
- package/dist/types/utils/hash_utils.d.ts +25 -0
- package/dist/types/utils/logger.d.ts +10 -2
- package/dist/types/utils/model_name.d.ts +30 -2
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +112 -79
- package/dist/web/index_web.js.map +4 -4
- package/package.json +8 -2
|
@@ -213,6 +213,14 @@ async function buildLLMAgentSkills(agent) {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
+
if (agent.codeExecutor) {
|
|
217
|
+
skills.push({
|
|
218
|
+
id: `${agent.name}-code-executor`,
|
|
219
|
+
name: "code-execution",
|
|
220
|
+
description: "Can execute code",
|
|
221
|
+
tags: ["llm", "code_execution"]
|
|
222
|
+
});
|
|
223
|
+
}
|
|
216
224
|
return skills;
|
|
217
225
|
}
|
|
218
226
|
__name(buildLLMAgentSkills, "buildLLMAgentSkills");
|
|
@@ -85,7 +85,10 @@ const _A2AAgentExecutor = class _A2AAgentExecutor {
|
|
|
85
85
|
await this.publishFinalTaskStatus({
|
|
86
86
|
executorContext,
|
|
87
87
|
eventBus,
|
|
88
|
-
event:
|
|
88
|
+
event: {
|
|
89
|
+
...unansweredRequestEvent,
|
|
90
|
+
metadata: (0, import_metadata_converter_utils.getA2ASessionMetadata)(executorContext)
|
|
91
|
+
}
|
|
89
92
|
});
|
|
90
93
|
return;
|
|
91
94
|
}
|
|
@@ -94,14 +97,16 @@ const _A2AAgentExecutor = class _A2AAgentExecutor {
|
|
|
94
97
|
(0, import_a2a_event.createTask)({
|
|
95
98
|
taskId: ctx.taskId,
|
|
96
99
|
contextId: ctx.contextId,
|
|
97
|
-
message: a2aUserMessage
|
|
100
|
+
message: a2aUserMessage,
|
|
101
|
+
metadata: (0, import_metadata_converter_utils.getA2ASessionMetadata)(executorContext)
|
|
98
102
|
})
|
|
99
103
|
);
|
|
100
104
|
}
|
|
101
105
|
eventBus.publish(
|
|
102
106
|
(0, import_a2a_event.createTaskWorkingEvent)({
|
|
103
107
|
taskId: ctx.taskId,
|
|
104
|
-
contextId: ctx.contextId
|
|
108
|
+
contextId: ctx.contextId,
|
|
109
|
+
metadata: (0, import_metadata_converter_utils.getA2ASessionMetadata)(executorContext)
|
|
105
110
|
})
|
|
106
111
|
);
|
|
107
112
|
const adkEvents = [];
|
|
@@ -40,6 +40,7 @@ var import_event = require("../events/event.js");
|
|
|
40
40
|
var import_event_actions = require("../events/event_actions.js");
|
|
41
41
|
var import_base_llm = require("../models/base_llm.js");
|
|
42
42
|
var import_registry = require("../models/registry.js");
|
|
43
|
+
var import_built_in_planner = require("../planners/built_in_planner.js");
|
|
43
44
|
var import_base_tool = require("../tools/base_tool.js");
|
|
44
45
|
var import_logger = require("../utils/logger.js");
|
|
45
46
|
var import_output_schema_utils = require("../utils/output_schema_utils.js");
|
|
@@ -59,6 +60,7 @@ var import_context_compactor_request_processor = require("./processors/context_c
|
|
|
59
60
|
var import_identity_llm_request_processor = require("./processors/identity_llm_request_processor.js");
|
|
60
61
|
var import_instructions_llm_request_processor = require("./processors/instructions_llm_request_processor.js");
|
|
61
62
|
var import_interactions_request_processor = require("./processors/interactions_request_processor.js");
|
|
63
|
+
var import_nl_planning_processor = require("./processors/nl_planning_processor.js");
|
|
62
64
|
var import_request_confirmation_llm_request_processor = require("./processors/request_confirmation_llm_request_processor.js");
|
|
63
65
|
var import_request_input_llm_request_processor = require("./processors/request_input_llm_request_processor.js");
|
|
64
66
|
var import_tool_filter_request_processor = require("./processors/tool_filter_request_processor.js");
|
|
@@ -166,6 +168,7 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
166
168
|
this.beforeToolCallback = config.beforeToolCallback;
|
|
167
169
|
this.afterToolCallback = config.afterToolCallback;
|
|
168
170
|
this.codeExecutor = config.codeExecutor;
|
|
171
|
+
this.planner = config.planner;
|
|
169
172
|
this.requestProcessors = (_i = config.requestProcessors) != null ? _i : [
|
|
170
173
|
import_basic_llm_request_processor.BASIC_LLM_REQUEST_PROCESSOR,
|
|
171
174
|
import_auth_preprocessor.AUTH_PREPROCESSOR,
|
|
@@ -174,6 +177,10 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
174
177
|
import_request_confirmation_llm_request_processor.REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR,
|
|
175
178
|
import_request_input_llm_request_processor.REQUEST_INPUT_LLM_REQUEST_PROCESSOR,
|
|
176
179
|
import_content_request_processor.CONTENT_REQUEST_PROCESSOR,
|
|
180
|
+
// Planning clears the thought flags that the planning response
|
|
181
|
+
// processor sets, so it must run after the contents are built and
|
|
182
|
+
// before code execution rewrites them.
|
|
183
|
+
import_nl_planning_processor.NL_PLANNING_REQUEST_PROCESSOR,
|
|
177
184
|
import_interactions_request_processor.INTERACTIONS_REQUEST_PROCESSOR,
|
|
178
185
|
import_code_execution_request_processor.CODE_EXECUTION_REQUEST_PROCESSOR,
|
|
179
186
|
import_tool_filter_request_processor.TOOL_FILTER_REQUEST_PROCESSOR
|
|
@@ -194,7 +201,9 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
194
201
|
);
|
|
195
202
|
}
|
|
196
203
|
}
|
|
197
|
-
this.responseProcessors = (_j = config.responseProcessors) != null ? _j : [
|
|
204
|
+
this.responseProcessors = (_j = config.responseProcessors) != null ? _j : [
|
|
205
|
+
import_nl_planning_processor.NL_PLANNING_RESPONSE_PROCESSOR
|
|
206
|
+
];
|
|
198
207
|
const agentTransferDisabled = this.disallowTransferToParent && this.disallowTransferToPeers && !((_k = this.subAgents) == null ? void 0 : _k.length);
|
|
199
208
|
if (!agentTransferDisabled) {
|
|
200
209
|
this.requestProcessors.push(import_agent_transfer_llm_request_processor.AGENT_TRANSFER_LLM_REQUEST_PROCESSOR);
|
|
@@ -213,6 +222,11 @@ const _LlmAgent = class _LlmAgent extends (_b = import_base_agent.BaseAgent, _a
|
|
|
213
222
|
"Response schema must be set via LlmAgent.output_schema."
|
|
214
223
|
);
|
|
215
224
|
}
|
|
225
|
+
if (config.generateContentConfig.thinkingConfig && (0, import_built_in_planner.isBuiltInPlanner)(this.planner) && this.planner.thinkingConfig) {
|
|
226
|
+
import_logger.logger.warn(
|
|
227
|
+
`Agent ${this.name}: both generateContentConfig.thinkingConfig and planner.thinkingConfig are set. The planner's thinkingConfig takes precedence.`
|
|
228
|
+
);
|
|
229
|
+
}
|
|
216
230
|
} else {
|
|
217
231
|
this.generateContentConfig = {};
|
|
218
232
|
}
|
|
@@ -43,6 +43,7 @@ var import_functions = require("../functions.js");
|
|
|
43
43
|
* Copyright 2025 Google LLC
|
|
44
44
|
* SPDX-License-Identifier: Apache-2.0
|
|
45
45
|
*/
|
|
46
|
+
const UNSTRINGIFIABLE_VALUE = "<unstringifiable value>";
|
|
46
47
|
function removeClientFunctionCallId(content) {
|
|
47
48
|
var _a, _b, _c, _d, _e;
|
|
48
49
|
for (const part of (_a = content == null ? void 0 : content.parts) != null ? _a : []) {
|
|
@@ -406,9 +407,16 @@ function safeStringify(obj) {
|
|
|
406
407
|
return obj;
|
|
407
408
|
}
|
|
408
409
|
try {
|
|
409
|
-
|
|
410
|
-
|
|
410
|
+
const json = JSON.stringify(obj);
|
|
411
|
+
if (typeof json === "string") {
|
|
412
|
+
return json;
|
|
413
|
+
}
|
|
414
|
+
} catch {
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
411
417
|
return String(obj);
|
|
418
|
+
} catch {
|
|
419
|
+
return UNSTRINGIFIABLE_VALUE;
|
|
412
420
|
}
|
|
413
421
|
}
|
|
414
422
|
__name(safeStringify, "safeStringify");
|
|
@@ -0,0 +1,114 @@
|
|
|
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var nl_planning_processor_exports = {};
|
|
27
|
+
__export(nl_planning_processor_exports, {
|
|
28
|
+
NL_PLANNING_REQUEST_PROCESSOR: () => NL_PLANNING_REQUEST_PROCESSOR,
|
|
29
|
+
NL_PLANNING_RESPONSE_PROCESSOR: () => NL_PLANNING_RESPONSE_PROCESSOR,
|
|
30
|
+
NlPlanningRequestProcessor: () => NlPlanningRequestProcessor,
|
|
31
|
+
NlPlanningResponseProcessor: () => NlPlanningResponseProcessor
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(nl_planning_processor_exports);
|
|
34
|
+
var import_llm_request = require("../../models/llm_request.js");
|
|
35
|
+
var import_base_planner = require("../../planners/base_planner.js");
|
|
36
|
+
var import_built_in_planner = require("../../planners/built_in_planner.js");
|
|
37
|
+
var import_context = require("../context.js");
|
|
38
|
+
var import_llm_agent = require("../llm_agent.js");
|
|
39
|
+
var import_readonly_context = require("../readonly_context.js");
|
|
40
|
+
var import_base_llm_processor = require("./base_llm_processor.js");
|
|
41
|
+
/**
|
|
42
|
+
* @license
|
|
43
|
+
* Copyright 2026 Google LLC
|
|
44
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
45
|
+
*/
|
|
46
|
+
function getPlanner(invocationContext) {
|
|
47
|
+
const agent = invocationContext.agent;
|
|
48
|
+
if (!(0, import_llm_agent.isLlmAgent)(agent) || !(0, import_base_planner.isBasePlanner)(agent.planner)) {
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
return agent.planner;
|
|
52
|
+
}
|
|
53
|
+
__name(getPlanner, "getPlanner");
|
|
54
|
+
function removeThought(part) {
|
|
55
|
+
const { thought: _thought, ...rest } = part;
|
|
56
|
+
return rest;
|
|
57
|
+
}
|
|
58
|
+
__name(removeThought, "removeThought");
|
|
59
|
+
function removeThoughtFromContents(contents) {
|
|
60
|
+
return contents.map(
|
|
61
|
+
(content) => content.parts ? { ...content, parts: content.parts.map(removeThought) } : content
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
__name(removeThoughtFromContents, "removeThoughtFromContents");
|
|
65
|
+
const _NlPlanningRequestProcessor = class _NlPlanningRequestProcessor extends import_base_llm_processor.BaseLlmRequestProcessor {
|
|
66
|
+
// eslint-disable-next-line require-yield -- this processor only mutates the request and has no event to emit
|
|
67
|
+
async *runAsync(invocationContext, llmRequest) {
|
|
68
|
+
const planner = getPlanner(invocationContext);
|
|
69
|
+
if (!planner) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if ((0, import_built_in_planner.isBuiltInPlanner)(planner)) {
|
|
73
|
+
planner.applyThinkingConfig(llmRequest);
|
|
74
|
+
}
|
|
75
|
+
const planningInstruction = planner.buildPlanningInstruction(
|
|
76
|
+
new import_readonly_context.ReadonlyContext(invocationContext),
|
|
77
|
+
llmRequest
|
|
78
|
+
);
|
|
79
|
+
if (planningInstruction) {
|
|
80
|
+
(0, import_llm_request.appendInstructions)(llmRequest, [planningInstruction]);
|
|
81
|
+
}
|
|
82
|
+
llmRequest.contents = removeThoughtFromContents(llmRequest.contents);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
__name(_NlPlanningRequestProcessor, "NlPlanningRequestProcessor");
|
|
86
|
+
let NlPlanningRequestProcessor = _NlPlanningRequestProcessor;
|
|
87
|
+
const _NlPlanningResponseProcessor = class _NlPlanningResponseProcessor extends import_base_llm_processor.BaseLlmResponseProcessor {
|
|
88
|
+
// eslint-disable-next-line require-yield -- this processor only rewrites the response and has no event to emit
|
|
89
|
+
async *runAsync(invocationContext, llmResponse) {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
const planner = getPlanner(invocationContext);
|
|
92
|
+
if (!planner || !((_b = (_a = llmResponse.content) == null ? void 0 : _a.parts) == null ? void 0 : _b.length)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const processedParts = planner.processPlanningResponse(
|
|
96
|
+
new import_context.Context({ invocationContext }),
|
|
97
|
+
llmResponse.content.parts
|
|
98
|
+
);
|
|
99
|
+
if (processedParts !== void 0) {
|
|
100
|
+
llmResponse.content = { ...llmResponse.content, parts: processedParts };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
__name(_NlPlanningResponseProcessor, "NlPlanningResponseProcessor");
|
|
105
|
+
let NlPlanningResponseProcessor = _NlPlanningResponseProcessor;
|
|
106
|
+
const NL_PLANNING_REQUEST_PROCESSOR = new NlPlanningRequestProcessor();
|
|
107
|
+
const NL_PLANNING_RESPONSE_PROCESSOR = new NlPlanningResponseProcessor();
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
NL_PLANNING_REQUEST_PROCESSOR,
|
|
111
|
+
NL_PLANNING_RESPONSE_PROCESSOR,
|
|
112
|
+
NlPlanningRequestProcessor,
|
|
113
|
+
NlPlanningResponseProcessor
|
|
114
|
+
});
|
|
@@ -82,9 +82,7 @@ const _GcsArtifactService = class _GcsArtifactService {
|
|
|
82
82
|
version
|
|
83
83
|
})
|
|
84
84
|
);
|
|
85
|
-
const customMetadata =
|
|
86
|
-
...request.customMetadata
|
|
87
|
-
};
|
|
85
|
+
const customMetadata = stringifyMetadataValues(request.customMetadata);
|
|
88
86
|
if (request.artifact.inlineData) {
|
|
89
87
|
if (request.artifact.inlineData.displayName) {
|
|
90
88
|
customMetadata[GCS_DISPLAY_NAME_METADATA_KEY] = request.artifact.inlineData.displayName;
|
|
@@ -208,10 +206,9 @@ const _GcsArtifactService = class _GcsArtifactService {
|
|
|
208
206
|
const [files] = await bucket.getFiles({ prefix: searchPrefix });
|
|
209
207
|
const versions = [];
|
|
210
208
|
for (const file of files) {
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
versions.push(v);
|
|
209
|
+
const suffix = file.name.slice(searchPrefix.length);
|
|
210
|
+
if (/^\d+$/.test(suffix)) {
|
|
211
|
+
versions.push(Number(suffix));
|
|
215
212
|
}
|
|
216
213
|
}
|
|
217
214
|
return versions.sort((a, b) => a - b);
|
|
@@ -277,6 +274,15 @@ function getFileName({
|
|
|
277
274
|
return version !== void 0 ? `${prefix}/${version}` : prefix;
|
|
278
275
|
}
|
|
279
276
|
__name(getFileName, "getFileName");
|
|
277
|
+
function stringifyMetadataValues(customMetadata) {
|
|
278
|
+
return Object.fromEntries(
|
|
279
|
+
Object.entries(customMetadata != null ? customMetadata : {}).map(([key, value]) => [
|
|
280
|
+
key,
|
|
281
|
+
String(value)
|
|
282
|
+
])
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
__name(stringifyMetadataValues, "stringifyMetadataValues");
|
|
280
286
|
function extractArtifactKeys(files, fileNamePrefix, keyPrefix = "") {
|
|
281
287
|
const keys = /* @__PURE__ */ new Set();
|
|
282
288
|
for (const file of files) {
|
|
@@ -9,6 +9,7 @@ var __defProp = Object.defineProperty;
|
|
|
9
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
12
13
|
var __export = (target, all) => {
|
|
13
14
|
for (var name in all)
|
|
14
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -24,7 +25,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
26
|
var auth_credential_exports = {};
|
|
26
27
|
__export(auth_credential_exports, {
|
|
27
|
-
AuthCredentialTypes: () => AuthCredentialTypes
|
|
28
|
+
AuthCredentialTypes: () => AuthCredentialTypes,
|
|
29
|
+
isAuthCredential: () => isAuthCredential
|
|
28
30
|
});
|
|
29
31
|
module.exports = __toCommonJS(auth_credential_exports);
|
|
30
32
|
/**
|
|
@@ -40,7 +42,15 @@ var AuthCredentialTypes = /* @__PURE__ */ ((AuthCredentialTypes2) => {
|
|
|
40
42
|
AuthCredentialTypes2["SERVICE_ACCOUNT"] = "serviceAccount";
|
|
41
43
|
return AuthCredentialTypes2;
|
|
42
44
|
})(AuthCredentialTypes || {});
|
|
45
|
+
const AUTH_CREDENTIAL_TYPES = new Set(
|
|
46
|
+
Object.values(AuthCredentialTypes)
|
|
47
|
+
);
|
|
48
|
+
function isAuthCredential(value) {
|
|
49
|
+
return typeof value === "object" && value !== null && "authType" in value && AUTH_CREDENTIAL_TYPES.has(value.authType);
|
|
50
|
+
}
|
|
51
|
+
__name(isAuthCredential, "isAuthCredential");
|
|
43
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
53
|
0 && (module.exports = {
|
|
45
|
-
AuthCredentialTypes
|
|
54
|
+
AuthCredentialTypes,
|
|
55
|
+
isAuthCredential
|
|
46
56
|
});
|
|
@@ -148,9 +148,9 @@ function convertCodeExecutionParts(content, codeBlockDelimiter, executionResultD
|
|
|
148
148
|
text: codeBlockDelimiter[0] + (lastPart.executableCode.code || "") + codeBlockDelimiter[1]
|
|
149
149
|
};
|
|
150
150
|
} else if (content.parts.length == 1 && lastPart.codeExecutionResult) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
};
|
|
151
|
+
const output = lastPart.codeExecutionResult.output;
|
|
152
|
+
const text = output == null ? "" : executionResultDelimiters[0] + output + executionResultDelimiters[1];
|
|
153
|
+
content.parts[content.parts.length - 1] = { text };
|
|
154
154
|
content.role = "user";
|
|
155
155
|
}
|
|
156
156
|
}
|
package/dist/cjs/common.js
CHANGED
|
@@ -49,6 +49,7 @@ __export(common_exports, {
|
|
|
49
49
|
BaseLlmRequestProcessor: () => import_base_llm_processor.BaseLlmRequestProcessor,
|
|
50
50
|
BaseLlmResponseProcessor: () => import_base_llm_processor.BaseLlmResponseProcessor,
|
|
51
51
|
BaseNode: () => import_workflow.BaseNode,
|
|
52
|
+
BasePlanner: () => import_base_planner.BasePlanner,
|
|
52
53
|
BasePlugin: () => import_base_plugin.BasePlugin,
|
|
53
54
|
BaseRetrievalTool: () => import_base_retrieval_tool.BaseRetrievalTool,
|
|
54
55
|
BaseSessionService: () => import_base_session_service.BaseSessionService,
|
|
@@ -56,8 +57,10 @@ __export(common_exports, {
|
|
|
56
57
|
BaseToolset: () => import_base_toolset.BaseToolset,
|
|
57
58
|
BranchPath: () => import_workflow.BranchPath,
|
|
58
59
|
BuiltInCodeExecutor: () => import_built_in_code_executor.BuiltInCodeExecutor,
|
|
60
|
+
BuiltInPlanner: () => import_built_in_planner.BuiltInPlanner,
|
|
59
61
|
BuiltInTool: () => import_built_in_tool.BuiltInTool,
|
|
60
62
|
CONTENT_REQUEST_PROCESSOR: () => import_content_request_processor.CONTENT_REQUEST_PROCESSOR,
|
|
63
|
+
CallbackContext: () => import_tool_context.CallbackContext,
|
|
61
64
|
ChromeBuiltInLlm: () => import_chrome_prompt_llm.ChromeBuiltInLlm,
|
|
62
65
|
ChromeModelUnavailableError: () => import_chrome_prompt_llm.ChromeModelUnavailableError,
|
|
63
66
|
CodeExecutionLanguage: () => import_code_execution_utils.CodeExecutionLanguage,
|
|
@@ -132,6 +135,7 @@ __export(common_exports, {
|
|
|
132
135
|
PRELOAD_MEMORY: () => import_preload_memory_tool.PRELOAD_MEMORY,
|
|
133
136
|
ParallelAgent: () => import_parallel_agent.ParallelAgent,
|
|
134
137
|
ParallelWorker: () => import_workflow.ParallelWorker,
|
|
138
|
+
PlanReActPlanner: () => import_plan_re_act_planner.PlanReActPlanner,
|
|
135
139
|
PluginManager: () => import_plugin_manager.PluginManager,
|
|
136
140
|
PolicyOutcome: () => import_security_plugin.PolicyOutcome,
|
|
137
141
|
PreloadMemoryTool: () => import_preload_memory_tool.PreloadMemoryTool,
|
|
@@ -161,6 +165,7 @@ __export(common_exports, {
|
|
|
161
165
|
Task: () => import_task.Task,
|
|
162
166
|
TokenBasedContextCompactor: () => import_token_based_context_compactor.TokenBasedContextCompactor,
|
|
163
167
|
ToolConfirmation: () => import_tool_confirmation.ToolConfirmation,
|
|
168
|
+
ToolContext: () => import_tool_context.ToolContext,
|
|
164
169
|
ToolErrorType: () => import_tool_execution_error.ToolErrorType,
|
|
165
170
|
ToolExecutionError: () => import_tool_execution_error.ToolExecutionError,
|
|
166
171
|
ToolNode: () => import_workflow.ToolNode,
|
|
@@ -169,8 +174,11 @@ __export(common_exports, {
|
|
|
169
174
|
TruncatingContextCompactor: () => import_truncating_context_compactor.TruncatingContextCompactor,
|
|
170
175
|
URL_CONTEXT: () => import_url_context_tool.URL_CONTEXT,
|
|
171
176
|
UrlContextTool: () => import_url_context_tool.UrlContextTool,
|
|
177
|
+
VertexAiExampleStore: () => import_example.VertexAiExampleStore,
|
|
172
178
|
VertexAiSearchTool: () => import_vertex_ai_search_tool.VertexAiSearchTool,
|
|
173
179
|
VertexRagRetrievalTool: () => import_vertex_rag_retrieval_tool.VertexRagRetrievalTool,
|
|
180
|
+
WebMCPTool: () => import_webmcp_tool.WebMCPTool,
|
|
181
|
+
WebMCPToolset: () => import_webmcp_toolset.WebMCPToolset,
|
|
174
182
|
Workflow: () => import_workflow.Workflow,
|
|
175
183
|
WorkflowNode: () => import_workflow.WorkflowNode,
|
|
176
184
|
asRunnableRoot: () => import_workflow.asRunnableRoot,
|
|
@@ -194,6 +202,7 @@ __export(common_exports, {
|
|
|
194
202
|
getFunctionCalls: () => import_event.getFunctionCalls,
|
|
195
203
|
getFunctionResponses: () => import_event.getFunctionResponses,
|
|
196
204
|
getLogger: () => import_logger.getLogger,
|
|
205
|
+
getModelContext: () => import_webmcp_types.getModelContext,
|
|
197
206
|
getPendingUserInputRequests: () => import_user_input_request.getPendingUserInputRequests,
|
|
198
207
|
getUserChoiceTool: () => import_get_user_choice_tool.getUserChoiceTool,
|
|
199
208
|
getUserInputRequests: () => import_user_input_request.getUserInputRequests,
|
|
@@ -201,16 +210,21 @@ __export(common_exports, {
|
|
|
201
210
|
hasTrailingCodeExecutionResult: () => import_event.hasTrailingCodeExecutionResult,
|
|
202
211
|
isAgentTool: () => import_agent_tool.isAgentTool,
|
|
203
212
|
isApp: () => import_app.isApp,
|
|
213
|
+
isAuthCredential: () => import_auth_credential.isAuthCredential,
|
|
204
214
|
isBaseAgent: () => import_base_agent.isBaseAgent,
|
|
205
215
|
isBaseExampleProvider: () => import_base_example_provider.isBaseExampleProvider,
|
|
206
216
|
isBaseLlm: () => import_base_llm.isBaseLlm,
|
|
217
|
+
isBasePlanner: () => import_base_planner.isBasePlanner,
|
|
207
218
|
isBaseTool: () => import_base_tool.isBaseTool,
|
|
208
219
|
isBaseToolset: () => import_base_toolset.isBaseToolset,
|
|
220
|
+
isBuiltInPlanner: () => import_built_in_planner.isBuiltInPlanner,
|
|
209
221
|
isCompactedEvent: () => import_compacted_event.isCompactedEvent,
|
|
210
222
|
isFinalResponse: () => import_event.isFinalResponse,
|
|
211
223
|
isFunctionTool: () => import_function_tool.isFunctionTool,
|
|
212
224
|
isGemini2OrAbove: () => import_model_name.isGemini2OrAbove,
|
|
225
|
+
isGemini35LiveTranslate: () => import_model_name.isGemini35LiveTranslate,
|
|
213
226
|
isGemini3xFlashLive: () => import_model_name.isGemini3xFlashLive,
|
|
227
|
+
isGemini3xLive: () => import_model_name.isGemini3xLive,
|
|
214
228
|
isIntentMismatchError: () => import_tool_confirmation.isIntentMismatchError,
|
|
215
229
|
isLlmAgent: () => import_llm_agent.isLlmAgent,
|
|
216
230
|
isLoopAgent: () => import_loop_agent.isLoopAgent,
|
|
@@ -230,12 +244,15 @@ __export(common_exports, {
|
|
|
230
244
|
isSessionArtifactService: () => import_session_artifact_service.isSessionArtifactService,
|
|
231
245
|
isStateSchemaError: () => import_state.isStateSchemaError,
|
|
232
246
|
isToolNotFound: () => import_functions.isToolNotFound,
|
|
247
|
+
isWebMCPSupported: () => import_webmcp_types.isWebMCPSupported,
|
|
233
248
|
isWorkflow: () => import_workflow.isWorkflow,
|
|
249
|
+
logger: () => import_logger.logger,
|
|
234
250
|
node: () => import_workflow.node,
|
|
235
251
|
normalizeRetryExceptions: () => import_workflow.normalizeRetryExceptions,
|
|
236
252
|
populateClientFunctionCallId: () => import_event.populateClientFunctionCallId,
|
|
237
253
|
prepareRetryConfig: () => import_workflow.prepareRetryConfig,
|
|
238
254
|
pruneThoughts: () => import_event.pruneThoughts,
|
|
255
|
+
renameReservedKeywords: () => import_case_utils.renameReservedKeywords,
|
|
239
256
|
requestInputTool: () => import_request_input_tool.requestInputTool,
|
|
240
257
|
requireAgent: () => import_invocation_context.requireAgent,
|
|
241
258
|
requiresUserInput: () => import_user_input_request.requiresUserInput,
|
|
@@ -246,6 +263,7 @@ __export(common_exports, {
|
|
|
246
263
|
setLogger: () => import_logger.setLogger,
|
|
247
264
|
stringifyContent: () => import_event.stringifyContent,
|
|
248
265
|
stripAdkIdentityPreamble: () => import_chrome_prompt_llm.stripAdkIdentityPreamble,
|
|
266
|
+
toSnakeCaseName: () => import_case_utils.toSnakeCaseName,
|
|
249
267
|
toStructuredEvents: () => import_structured_events.toStructuredEvents,
|
|
250
268
|
validateAppName: () => import_app.validateAppName,
|
|
251
269
|
version: () => import_version.version,
|
|
@@ -306,6 +324,7 @@ var import_event = require("./events/event.js");
|
|
|
306
324
|
var import_event_actions = require("./events/event_actions.js");
|
|
307
325
|
var import_structured_events = require("./events/structured_events.js");
|
|
308
326
|
var import_base_example_provider = require("./examples/base_example_provider.js");
|
|
327
|
+
var import_example = require("./examples/example.js");
|
|
309
328
|
var import_in_memory_memory_service = require("./memory/in_memory_memory_service.js");
|
|
310
329
|
var import_apigee_llm = require("./models/apigee_llm.js");
|
|
311
330
|
var import_base_llm = require("./models/base_llm.js");
|
|
@@ -313,6 +332,9 @@ var import_chrome_prompt_llm = require("./models/chrome_prompt_llm.js");
|
|
|
313
332
|
var import_google_llm = require("./models/google_llm.js");
|
|
314
333
|
var import_registry = require("./models/registry.js");
|
|
315
334
|
var import_routed_llm = require("./models/routed_llm.js");
|
|
335
|
+
var import_base_planner = require("./planners/base_planner.js");
|
|
336
|
+
var import_built_in_planner = require("./planners/built_in_planner.js");
|
|
337
|
+
var import_plan_re_act_planner = require("./planners/plan_re_act_planner.js");
|
|
316
338
|
var import_reflect_retry_utils = require("./plugins/_reflect_retry_utils.js");
|
|
317
339
|
var import_base_plugin = require("./plugins/base_plugin.js");
|
|
318
340
|
var import_global_instruction_plugin = require("./plugins/global_instruction_plugin.js");
|
|
@@ -349,10 +371,15 @@ var import_request_input_tool = require("./tools/request_input_tool.js");
|
|
|
349
371
|
var import_base_retrieval_tool = require("./tools/retrieval/base_retrieval_tool.js");
|
|
350
372
|
var import_llama_index_retrieval = require("./tools/retrieval/llama_index_retrieval.js");
|
|
351
373
|
var import_tool_confirmation = require("./tools/tool_confirmation.js");
|
|
374
|
+
var import_tool_context = require("./tools/tool_context.js");
|
|
352
375
|
var import_url_context_tool = require("./tools/url_context_tool.js");
|
|
353
376
|
var import_vertex_ai_search_tool = require("./tools/vertex_ai_search_tool.js");
|
|
354
377
|
var import_vertex_rag_retrieval_tool = require("./tools/vertex_rag_retrieval_tool.js");
|
|
378
|
+
var import_webmcp_tool = require("./tools/webmcp/webmcp_tool.js");
|
|
379
|
+
var import_webmcp_toolset = require("./tools/webmcp/webmcp_toolset.js");
|
|
380
|
+
var import_webmcp_types = require("./tools/webmcp/webmcp_types.js");
|
|
355
381
|
var import_async_queue = require("./utils/async_queue.js");
|
|
382
|
+
var import_case_utils = require("./utils/case_utils.js");
|
|
356
383
|
var import_client_labels = require("./utils/client_labels.js");
|
|
357
384
|
var import_logger = require("./utils/logger.js");
|
|
358
385
|
var import_model_name = require("./utils/model_name.js");
|
|
@@ -406,6 +433,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
406
433
|
BaseLlmRequestProcessor,
|
|
407
434
|
BaseLlmResponseProcessor,
|
|
408
435
|
BaseNode,
|
|
436
|
+
BasePlanner,
|
|
409
437
|
BasePlugin,
|
|
410
438
|
BaseRetrievalTool,
|
|
411
439
|
BaseSessionService,
|
|
@@ -413,8 +441,10 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
413
441
|
BaseToolset,
|
|
414
442
|
BranchPath,
|
|
415
443
|
BuiltInCodeExecutor,
|
|
444
|
+
BuiltInPlanner,
|
|
416
445
|
BuiltInTool,
|
|
417
446
|
CONTENT_REQUEST_PROCESSOR,
|
|
447
|
+
CallbackContext,
|
|
418
448
|
ChromeBuiltInLlm,
|
|
419
449
|
ChromeModelUnavailableError,
|
|
420
450
|
CodeExecutionLanguage,
|
|
@@ -489,6 +519,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
489
519
|
PRELOAD_MEMORY,
|
|
490
520
|
ParallelAgent,
|
|
491
521
|
ParallelWorker,
|
|
522
|
+
PlanReActPlanner,
|
|
492
523
|
PluginManager,
|
|
493
524
|
PolicyOutcome,
|
|
494
525
|
PreloadMemoryTool,
|
|
@@ -518,6 +549,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
518
549
|
Task,
|
|
519
550
|
TokenBasedContextCompactor,
|
|
520
551
|
ToolConfirmation,
|
|
552
|
+
ToolContext,
|
|
521
553
|
ToolErrorType,
|
|
522
554
|
ToolExecutionError,
|
|
523
555
|
ToolNode,
|
|
@@ -526,8 +558,11 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
526
558
|
TruncatingContextCompactor,
|
|
527
559
|
URL_CONTEXT,
|
|
528
560
|
UrlContextTool,
|
|
561
|
+
VertexAiExampleStore,
|
|
529
562
|
VertexAiSearchTool,
|
|
530
563
|
VertexRagRetrievalTool,
|
|
564
|
+
WebMCPTool,
|
|
565
|
+
WebMCPToolset,
|
|
531
566
|
Workflow,
|
|
532
567
|
WorkflowNode,
|
|
533
568
|
asRunnableRoot,
|
|
@@ -551,6 +586,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
551
586
|
getFunctionCalls,
|
|
552
587
|
getFunctionResponses,
|
|
553
588
|
getLogger,
|
|
589
|
+
getModelContext,
|
|
554
590
|
getPendingUserInputRequests,
|
|
555
591
|
getUserChoiceTool,
|
|
556
592
|
getUserInputRequests,
|
|
@@ -558,16 +594,21 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
558
594
|
hasTrailingCodeExecutionResult,
|
|
559
595
|
isAgentTool,
|
|
560
596
|
isApp,
|
|
597
|
+
isAuthCredential,
|
|
561
598
|
isBaseAgent,
|
|
562
599
|
isBaseExampleProvider,
|
|
563
600
|
isBaseLlm,
|
|
601
|
+
isBasePlanner,
|
|
564
602
|
isBaseTool,
|
|
565
603
|
isBaseToolset,
|
|
604
|
+
isBuiltInPlanner,
|
|
566
605
|
isCompactedEvent,
|
|
567
606
|
isFinalResponse,
|
|
568
607
|
isFunctionTool,
|
|
569
608
|
isGemini2OrAbove,
|
|
609
|
+
isGemini35LiveTranslate,
|
|
570
610
|
isGemini3xFlashLive,
|
|
611
|
+
isGemini3xLive,
|
|
571
612
|
isIntentMismatchError,
|
|
572
613
|
isLlmAgent,
|
|
573
614
|
isLoopAgent,
|
|
@@ -587,12 +628,15 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
587
628
|
isSessionArtifactService,
|
|
588
629
|
isStateSchemaError,
|
|
589
630
|
isToolNotFound,
|
|
631
|
+
isWebMCPSupported,
|
|
590
632
|
isWorkflow,
|
|
633
|
+
logger,
|
|
591
634
|
node,
|
|
592
635
|
normalizeRetryExceptions,
|
|
593
636
|
populateClientFunctionCallId,
|
|
594
637
|
prepareRetryConfig,
|
|
595
638
|
pruneThoughts,
|
|
639
|
+
renameReservedKeywords,
|
|
596
640
|
requestInputTool,
|
|
597
641
|
requireAgent,
|
|
598
642
|
requiresUserInput,
|
|
@@ -603,6 +647,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
603
647
|
setLogger,
|
|
604
648
|
stringifyContent,
|
|
605
649
|
stripAdkIdentityPreamble,
|
|
650
|
+
toSnakeCaseName,
|
|
606
651
|
toStructuredEvents,
|
|
607
652
|
validateAppName,
|
|
608
653
|
version,
|
|
@@ -9,6 +9,11 @@ var __defProp = Object.defineProperty;
|
|
|
9
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
12
17
|
var __copyProps = (to, from, except, desc) => {
|
|
13
18
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
19
|
for (let key of __getOwnPropNames(from))
|
|
@@ -19,9 +24,96 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
24
|
};
|
|
20
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
26
|
var example_exports = {};
|
|
27
|
+
__export(example_exports, {
|
|
28
|
+
VertexAiExampleStore: () => VertexAiExampleStore
|
|
29
|
+
});
|
|
22
30
|
module.exports = __toCommonJS(example_exports);
|
|
31
|
+
var import_base_example_provider = require("./base_example_provider.js");
|
|
23
32
|
/**
|
|
24
33
|
* @license
|
|
25
34
|
* Copyright 2025 Google LLC
|
|
26
35
|
* SPDX-License-Identifier: Apache-2.0
|
|
27
36
|
*/
|
|
37
|
+
const SIMILARITY_SCORE_THRESHOLD = 0.5;
|
|
38
|
+
const DEFAULT_TOP_K = 10;
|
|
39
|
+
const _VertexAiExampleStore = class _VertexAiExampleStore extends import_base_example_provider.BaseExampleProvider {
|
|
40
|
+
/**
|
|
41
|
+
* Initializes the VertexAiExampleStore.
|
|
42
|
+
*
|
|
43
|
+
* @param examplesStoreName The resource name of the vertex example store, in
|
|
44
|
+
* the format of
|
|
45
|
+
* `projects/{project}/locations/{location}/exampleStores/{example_store}`.
|
|
46
|
+
* @param apiClient A client that reaches the Vertex AI Example Store API.
|
|
47
|
+
* adk-js does not bundle the `vertexai` dependency the Python SDK relies
|
|
48
|
+
* on, so the caller supplies this client.
|
|
49
|
+
*/
|
|
50
|
+
constructor(examplesStoreName, apiClient) {
|
|
51
|
+
super();
|
|
52
|
+
this.examplesStoreName = examplesStoreName;
|
|
53
|
+
this.apiClient = apiClient;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves relevant examples from the Vertex AI Example Store for the given
|
|
57
|
+
* query.
|
|
58
|
+
*/
|
|
59
|
+
async getExamples(query) {
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
61
|
+
const request = {
|
|
62
|
+
storedContentsExampleParameters: {
|
|
63
|
+
contentSearchKey: {
|
|
64
|
+
contents: [{ role: "user", parts: [{ text: query }] }],
|
|
65
|
+
searchKeyGenerationMethod: { lastEntry: {} }
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
topK: DEFAULT_TOP_K,
|
|
69
|
+
exampleStore: this.examplesStoreName
|
|
70
|
+
};
|
|
71
|
+
const response = await this.apiClient.searchExamples(request);
|
|
72
|
+
const returnedExamples = [];
|
|
73
|
+
for (const result of (_a = response.results) != null ? _a : []) {
|
|
74
|
+
if (((_b = result.similarityScore) != null ? _b : 0) < SIMILARITY_SCORE_THRESHOLD) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const storedExample = (_c = result.example) == null ? void 0 : _c.storedContentsExample;
|
|
78
|
+
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);
|
|
79
|
+
const expectedOutput = [];
|
|
80
|
+
for (const content of expectedContents) {
|
|
81
|
+
const expectedParts = [];
|
|
82
|
+
for (const part of (_f = content.parts) != null ? _f : []) {
|
|
83
|
+
if (part.text) {
|
|
84
|
+
expectedParts.push({ text: part.text });
|
|
85
|
+
} else if (part.functionCall) {
|
|
86
|
+
expectedParts.push({
|
|
87
|
+
functionCall: {
|
|
88
|
+
name: part.functionCall.name,
|
|
89
|
+
args: { ...(_g = part.functionCall.args) != null ? _g : {} }
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
} else if (part.functionResponse) {
|
|
93
|
+
expectedParts.push({
|
|
94
|
+
functionResponse: {
|
|
95
|
+
name: part.functionResponse.name,
|
|
96
|
+
response: { ...(_h = part.functionResponse.response) != null ? _h : {} }
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
expectedOutput.push({ role: content.role, parts: expectedParts });
|
|
102
|
+
}
|
|
103
|
+
returnedExamples.push({
|
|
104
|
+
input: {
|
|
105
|
+
role: "user",
|
|
106
|
+
parts: [{ text: (_i = storedExample == null ? void 0 : storedExample.searchKey) != null ? _i : "" }]
|
|
107
|
+
},
|
|
108
|
+
output: expectedOutput
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return returnedExamples;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
__name(_VertexAiExampleStore, "VertexAiExampleStore");
|
|
115
|
+
let VertexAiExampleStore = _VertexAiExampleStore;
|
|
116
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
+
0 && (module.exports = {
|
|
118
|
+
VertexAiExampleStore
|
|
119
|
+
});
|