@google/adk 2.2.1 → 2.3.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/a2a_remote_agent.js +4 -1
- package/dist/cjs/a2a/agent_card.js +102 -26
- package/dist/cjs/a2a/agent_to_a2a.js +1 -1
- package/dist/cjs/agents/functions.js +199 -25
- package/dist/cjs/agents/instructions.js +4 -1
- package/dist/cjs/agents/invocation_context.js +26 -4
- package/dist/cjs/agents/langgraph_agent.js +152 -0
- package/dist/cjs/agents/llm_agent.js +175 -101
- package/dist/cjs/agents/processors/code_execution_request_processor.js +10 -6
- package/dist/cjs/agents/remote_agent.js +187 -0
- package/dist/cjs/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/cjs/auth/auth_handler.js +37 -5
- package/dist/cjs/auth/auth_schemes.js +9 -0
- package/dist/cjs/cli/cli_eval.js +532 -0
- package/dist/cjs/cli/utils/envs.js +116 -0
- package/dist/cjs/cli/utils/evals.js +137 -0
- package/dist/cjs/cli/utils/logs.js +150 -0
- package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/cjs/code_executors/code_execution_utils.js +48 -16
- package/dist/cjs/code_executors/code_executor_context.js +6 -2
- package/dist/cjs/common.js +72 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +12 -10
- package/dist/cjs/context/token_based_context_compactor.js +2 -1
- package/dist/cjs/events/event.js +4 -2
- package/dist/cjs/examples/example_util.js +23 -2
- package/dist/cjs/flows/llm_flows/audio_transcriber.js +170 -0
- package/dist/cjs/index.js +97 -1
- package/dist/cjs/integrations/agent_registry/helpers.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +16 -8
- package/dist/cjs/models/google_llm.js +13 -16
- package/dist/cjs/models/llm_response.js +9 -1
- package/dist/cjs/models/registry.js +1 -1
- package/dist/cjs/models/routed_llm.js +9 -8
- package/dist/cjs/planners/plan_re_act_planner.js +1 -1
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +105 -33
- package/dist/cjs/sessions/db/operations.js +1 -1
- package/dist/cjs/sessions/in_memory_session_service.js +3 -1
- package/dist/cjs/sessions/state.js +8 -4
- package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
- package/dist/cjs/telemetry/tracing.js +97 -66
- package/dist/cjs/tools/agent_tool.js +44 -0
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +142 -0
- package/dist/cjs/tools/apihub_tool/clients/apihub_client.js +272 -0
- package/dist/cjs/tools/apihub_tool/clients/secret_client.js +148 -0
- package/dist/cjs/tools/apihub_tool/clients/service_account.js +48 -0
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +185 -0
- package/dist/cjs/tools/application_integration_tool/clients/cloud_request.js +133 -0
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +603 -0
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +219 -0
- package/dist/cjs/tools/crewai_tool.js +132 -0
- package/dist/cjs/tools/example_tool.js +10 -0
- package/dist/cjs/tools/function_tool.js +319 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +97 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +226 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +58 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
- package/dist/cjs/tools/google_api_tool/index.js +64 -0
- package/dist/cjs/tools/langchain_tool.js +172 -0
- package/dist/cjs/tools/mcp/index.js +12 -0
- package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +46 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
- package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
- package/dist/cjs/tools/toolbox_tool.js +108 -0
- package/dist/cjs/utils/env_aware_utils.js +6 -8
- package/dist/cjs/utils/error_utils.js +11 -11
- package/dist/cjs/utils/file_extension_utils.js +11 -0
- package/dist/cjs/utils/file_utils.js +2 -24
- package/dist/cjs/utils/gemini_schema_util.js +4 -1
- package/dist/cjs/utils/json_utils.js +49 -0
- package/dist/cjs/utils/live_connection_utils.js +4 -5
- package/dist/cjs/utils/logger_node.js +7 -1
- package/dist/cjs/utils/object_notation_utils.js +6 -3
- package/dist/cjs/utils/streaming_utils.js +12 -12
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/a2a_remote_agent.js +4 -1
- package/dist/esm/a2a/agent_card.js +103 -27
- package/dist/esm/a2a/agent_to_a2a.js +5 -2
- package/dist/esm/agents/functions.js +198 -25
- package/dist/esm/agents/instructions.js +4 -1
- package/dist/esm/agents/invocation_context.js +24 -4
- package/dist/esm/agents/langgraph_agent.js +123 -0
- package/dist/esm/agents/llm_agent.js +185 -104
- package/dist/esm/agents/processors/code_execution_request_processor.js +13 -8
- package/dist/esm/agents/remote_agent.js +164 -0
- package/dist/esm/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/esm/auth/auth_handler.js +37 -5
- package/dist/esm/auth/auth_schemes.js +8 -0
- package/dist/esm/cli/cli_eval.js +510 -0
- package/dist/esm/cli/utils/envs.js +78 -0
- package/dist/esm/cli/utils/evals.js +109 -0
- package/dist/esm/cli/utils/logs.js +111 -0
- package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/esm/code_executors/code_execution_utils.js +46 -16
- package/dist/esm/code_executors/code_executor_context.js +5 -2
- package/dist/esm/common.js +67 -3
- package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
- package/dist/esm/context/token_based_context_compactor.js +2 -1
- package/dist/esm/events/event.js +4 -2
- package/dist/esm/examples/example_util.js +21 -1
- package/dist/esm/flows/llm_flows/audio_transcriber.js +142 -0
- package/dist/esm/index.js +99 -1
- package/dist/esm/integrations/agent_registry/helpers.js +1 -1
- package/dist/esm/models/gemini_llm_connection.js +16 -8
- package/dist/esm/models/google_llm.js +14 -17
- package/dist/esm/models/llm_response.js +9 -1
- package/dist/esm/models/registry.js +1 -1
- package/dist/esm/models/routed_llm.js +9 -8
- package/dist/esm/planners/plan_re_act_planner.js +1 -1
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +105 -33
- package/dist/esm/sessions/db/operations.js +1 -1
- package/dist/esm/sessions/in_memory_session_service.js +3 -1
- package/dist/esm/sessions/state.js +8 -4
- package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
- package/dist/esm/telemetry/tracing.js +97 -66
- package/dist/esm/tools/agent_tool.js +44 -0
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +106 -0
- package/dist/esm/tools/apihub_tool/clients/apihub_client.js +244 -0
- package/dist/esm/tools/apihub_tool/clients/secret_client.js +132 -0
- package/dist/esm/tools/apihub_tool/clients/service_account.js +21 -0
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +163 -0
- package/dist/esm/tools/application_integration_tool/clients/cloud_request.js +103 -0
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +561 -0
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +215 -0
- package/dist/esm/tools/crewai_tool.js +107 -0
- package/dist/esm/tools/example_tool.js +13 -1
- package/dist/esm/tools/function_tool.js +316 -0
- package/dist/esm/tools/google_api_tool/google_api_tool.js +70 -0
- package/dist/esm/tools/google_api_tool/google_api_tool_set.js +188 -0
- package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +24 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
- package/dist/esm/tools/google_api_tool/index.js +33 -0
- package/dist/esm/tools/langchain_tool.js +148 -0
- package/dist/esm/tools/mcp/index.js +6 -0
- package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +50 -3
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
- package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
- package/dist/esm/tools/toolbox_tool.js +80 -0
- package/dist/esm/utils/env_aware_utils.js +6 -8
- package/dist/esm/utils/error_utils.js +9 -10
- package/dist/esm/utils/file_extension_utils.js +11 -0
- package/dist/esm/utils/file_utils.js +2 -23
- package/dist/esm/utils/gemini_schema_util.js +4 -1
- package/dist/esm/utils/json_utils.js +21 -0
- package/dist/esm/utils/live_connection_utils.js +4 -5
- package/dist/esm/utils/logger_node.js +7 -1
- package/dist/esm/utils/object_notation_utils.js +4 -2
- package/dist/esm/utils/streaming_utils.js +11 -11
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent.d.ts +9 -0
- package/dist/types/a2a/agent_card.d.ts +44 -1
- package/dist/types/a2a/agent_to_a2a.d.ts +9 -0
- package/dist/types/a2a/index.d.ts +1 -0
- package/dist/types/agents/functions.d.ts +33 -1
- package/dist/types/agents/invocation_context.d.ts +20 -1
- package/dist/types/agents/langgraph_agent.d.ts +153 -0
- package/dist/types/agents/remote_agent.d.ts +68 -0
- package/dist/types/auth/auth_handler.d.ts +28 -1
- package/dist/types/auth/auth_schemes.d.ts +13 -0
- package/dist/types/cli/cli_eval.d.ts +173 -0
- package/dist/types/cli/utils/envs.d.ts +23 -0
- package/dist/types/cli/utils/evals.d.ts +47 -0
- package/dist/types/cli/utils/logs.d.ts +38 -0
- package/dist/types/code_executors/code_execution_utils.d.ts +39 -0
- package/dist/types/code_executors/code_executor_context.d.ts +1 -0
- package/dist/types/common.d.ts +27 -4
- package/dist/types/events/event.d.ts +4 -0
- package/dist/types/examples/example_util.d.ts +17 -0
- package/dist/types/flows/llm_flows/audio_transcriber.d.ts +85 -0
- package/dist/types/index.d.ts +16 -1
- package/dist/types/models/gemini_llm_connection.d.ts +6 -7
- package/dist/types/models/routed_llm.d.ts +1 -1
- package/dist/types/runner/in_memory_runner.d.ts +2 -1
- package/dist/types/runner/runner.d.ts +34 -0
- package/dist/types/sessions/state.d.ts +5 -1
- package/dist/types/sessions/vertex_ai_session_service.d.ts +8 -0
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +4 -2
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +122 -0
- package/dist/types/tools/apihub_tool/clients/apihub_client.d.ts +142 -0
- package/dist/types/tools/apihub_tool/clients/secret_client.d.ts +55 -0
- package/dist/types/tools/apihub_tool/clients/service_account.d.ts +11 -0
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +86 -0
- package/dist/types/tools/application_integration_tool/clients/cloud_request.d.ts +53 -0
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +215 -0
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
- package/dist/types/tools/crewai_tool.d.ts +85 -0
- package/dist/types/tools/example_tool.d.ts +10 -0
- package/dist/types/tools/function_tool.d.ts +32 -0
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +30 -0
- package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +78 -0
- package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +33 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +164 -0
- package/dist/types/tools/google_api_tool/index.d.ts +11 -0
- package/dist/types/tools/langchain_tool.d.ts +103 -0
- package/dist/types/tools/mcp/index.d.ts +3 -0
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +34 -1
- package/dist/types/tools/mcp/mcp_toolset.d.ts +15 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +19 -0
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +18 -1
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
- package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
- package/dist/types/tools/toolbox_tool.d.ts +73 -0
- package/dist/types/utils/env_aware_utils.d.ts +18 -2
- package/dist/types/utils/error_utils.d.ts +7 -0
- package/dist/types/utils/file_utils.d.ts +6 -1
- package/dist/types/utils/gemini_schema_util.d.ts +1 -2
- package/dist/types/utils/json_utils.d.ts +11 -0
- package/dist/types/utils/object_notation_utils.d.ts +7 -0
- package/dist/types/utils/streaming_utils.d.ts +11 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +102 -103
- package/dist/web/index_web.js.map +4 -4
- package/package.json +8 -3
- package/dist/cjs/models/gemini_continuation.js +0 -232
- package/dist/esm/models/gemini_continuation.js +0 -205
- package/dist/types/models/gemini_continuation.d.ts +0 -59
|
@@ -0,0 +1,172 @@
|
|
|
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 langchain_tool_exports = {};
|
|
27
|
+
__export(langchain_tool_exports, {
|
|
28
|
+
LangchainTool: () => LangchainTool,
|
|
29
|
+
isLangchainTool: () => isLangchainTool
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(langchain_tool_exports);
|
|
32
|
+
var import_schema = require("../utils/schema.js");
|
|
33
|
+
var import_simple_zod_to_json = require("../utils/simple_zod_to_json.js");
|
|
34
|
+
var import_variant_utils = require("../utils/variant_utils.js");
|
|
35
|
+
var import_function_tool = require("./function_tool.js");
|
|
36
|
+
/**
|
|
37
|
+
* @license
|
|
38
|
+
* Copyright 2026 Google LLC
|
|
39
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
40
|
+
*/
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const LANGCHAIN_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.langchainTool");
|
|
43
|
+
function isLangchainTool(obj) {
|
|
44
|
+
return typeof obj === "object" && obj !== null && LANGCHAIN_TOOL_SIGNATURE_SYMBOL in obj && obj[LANGCHAIN_TOOL_SIGNATURE_SYMBOL] === true;
|
|
45
|
+
}
|
|
46
|
+
__name(isLangchainTool, "isLangchainTool");
|
|
47
|
+
function isLangchainToolConfig(value) {
|
|
48
|
+
return typeof value === "object" && value !== null && "tool" in value && typeof value.tool === "object" && value.tool !== null;
|
|
49
|
+
}
|
|
50
|
+
__name(isLangchainToolConfig, "isLangchainToolConfig");
|
|
51
|
+
function resolveRunnerFunction(tool) {
|
|
52
|
+
if (typeof tool._run === "function") {
|
|
53
|
+
return tool._run.bind(tool);
|
|
54
|
+
}
|
|
55
|
+
if (typeof tool._call === "function") {
|
|
56
|
+
return tool._call.bind(tool);
|
|
57
|
+
}
|
|
58
|
+
if (typeof tool.invoke === "function") {
|
|
59
|
+
return tool.invoke.bind(tool);
|
|
60
|
+
}
|
|
61
|
+
if (typeof tool.run === "function") {
|
|
62
|
+
return tool.run.bind(tool);
|
|
63
|
+
}
|
|
64
|
+
throw new TypeError(
|
|
65
|
+
"LangchainTool requires a tool object with a _run, _call, invoke, or run method."
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
__name(resolveRunnerFunction, "resolveRunnerFunction");
|
|
69
|
+
function isStructuredLangchainTool(tool) {
|
|
70
|
+
return typeof tool._run === "function" || typeof tool._call === "function" || typeof tool.invoke === "function" || tool.argsSchema !== void 0 || tool.schema !== void 0 || tool.args !== void 0;
|
|
71
|
+
}
|
|
72
|
+
__name(isStructuredLangchainTool, "isStructuredLangchainTool");
|
|
73
|
+
function extractLangchainPropertiesMap(tool) {
|
|
74
|
+
var _a2;
|
|
75
|
+
if (tool.args && typeof tool.args === "object") {
|
|
76
|
+
return structuredClone(tool.args);
|
|
77
|
+
}
|
|
78
|
+
const schemaSource = (_a2 = tool.argsSchema) != null ? _a2 : tool.schema;
|
|
79
|
+
if (!schemaSource) {
|
|
80
|
+
return {};
|
|
81
|
+
}
|
|
82
|
+
let rawSchema;
|
|
83
|
+
if (typeof schemaSource.modelJsonSchema === "function") {
|
|
84
|
+
rawSchema = schemaSource.modelJsonSchema();
|
|
85
|
+
} else if (typeof schemaSource.jsonSchema === "function") {
|
|
86
|
+
rawSchema = schemaSource.jsonSchema();
|
|
87
|
+
} else if ((0, import_simple_zod_to_json.isZodSchema)(schemaSource)) {
|
|
88
|
+
rawSchema = structuredClone((0, import_schema.toJsonSchema)(schemaSource));
|
|
89
|
+
} else {
|
|
90
|
+
rawSchema = structuredClone(schemaSource);
|
|
91
|
+
}
|
|
92
|
+
const properties = rawSchema["properties"] && typeof rawSchema["properties"] === "object" ? structuredClone(
|
|
93
|
+
rawSchema["properties"]
|
|
94
|
+
) : structuredClone(rawSchema);
|
|
95
|
+
const requiredSet = Array.isArray(rawSchema["required"]) ? new Set(rawSchema["required"]) : void 0;
|
|
96
|
+
for (const [key, prop] of Object.entries(properties)) {
|
|
97
|
+
if (!prop || typeof prop !== "object") {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(prop["type"])) {
|
|
101
|
+
const types = prop["type"];
|
|
102
|
+
delete prop["type"];
|
|
103
|
+
prop["anyOf"] = types.map((t) => ({ type: t }));
|
|
104
|
+
} else if (requiredSet !== void 0 && !requiredSet.has(key) && !("default" in prop) && !("anyOf" in prop) && typeof prop["type"] === "string") {
|
|
105
|
+
const propType = prop["type"];
|
|
106
|
+
delete prop["type"];
|
|
107
|
+
prop["anyOf"] = [{ type: propType }, { type: "null" }];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return properties;
|
|
111
|
+
}
|
|
112
|
+
__name(extractLangchainPropertiesMap, "extractLangchainPropertiesMap");
|
|
113
|
+
const _LangchainTool = class _LangchainTool extends (_b = import_function_tool.FunctionTool, _a = LANGCHAIN_TOOL_SIGNATURE_SYMBOL, _b) {
|
|
114
|
+
constructor(toolOrConfig, options) {
|
|
115
|
+
var _a2, _b2, _c, _d;
|
|
116
|
+
const config = isLangchainToolConfig(toolOrConfig) ? toolOrConfig : {
|
|
117
|
+
tool: toolOrConfig,
|
|
118
|
+
name: options == null ? void 0 : options.name,
|
|
119
|
+
description: options == null ? void 0 : options.description
|
|
120
|
+
};
|
|
121
|
+
const runnerFn = resolveRunnerFunction(config.tool);
|
|
122
|
+
const rawFn = (_c = (_b2 = (_a2 = config.tool._run) != null ? _a2 : config.tool._call) != null ? _b2 : config.tool.invoke) != null ? _c : config.tool.run;
|
|
123
|
+
const resolvedName = config.name || config.tool.name || (rawFn == null ? void 0 : rawFn.name) || "langchain_tool";
|
|
124
|
+
const resolvedDescription = config.description || config.tool.description || "";
|
|
125
|
+
const schemaCandidate = (_d = config.tool.argsSchema) != null ? _d : config.tool.schema;
|
|
126
|
+
super({
|
|
127
|
+
name: resolvedName,
|
|
128
|
+
description: resolvedDescription,
|
|
129
|
+
parameters: (0, import_simple_zod_to_json.isZodObject)(schemaCandidate) ? schemaCandidate : void 0,
|
|
130
|
+
execute: /* @__PURE__ */ __name(async (args, toolContext) => {
|
|
131
|
+
return await runnerFn(
|
|
132
|
+
args != null ? args : {},
|
|
133
|
+
toolContext
|
|
134
|
+
);
|
|
135
|
+
}, "execute")
|
|
136
|
+
});
|
|
137
|
+
/** A unique symbol to identify ADK LangchainTool class. */
|
|
138
|
+
this[_a] = true;
|
|
139
|
+
this.tool = config.tool;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Builds the `FunctionDeclaration` for the wrapped LangChain tool.
|
|
143
|
+
*/
|
|
144
|
+
_getDeclaration() {
|
|
145
|
+
var _a2, _b2, _c;
|
|
146
|
+
if (isStructuredLangchainTool(this.tool)) {
|
|
147
|
+
const propertiesMap = extractLangchainPropertiesMap(this.tool);
|
|
148
|
+
const rawFn = (_c = (_b2 = (_a2 = this.tool._run) != null ? _a2 : this.tool._call) != null ? _b2 : this.tool.invoke) != null ? _c : this.tool.run;
|
|
149
|
+
return (0, import_function_tool.buildFunctionDeclarationForLangchain)(
|
|
150
|
+
this.apiVariant === import_variant_utils.GoogleLLMVariant.VERTEX_AI,
|
|
151
|
+
this.name,
|
|
152
|
+
this.description,
|
|
153
|
+
rawFn,
|
|
154
|
+
propertiesMap
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
return (0, import_function_tool.buildFunctionDeclarationUtil)(
|
|
158
|
+
this.apiVariant === import_variant_utils.GoogleLLMVariant.VERTEX_AI,
|
|
159
|
+
this.name,
|
|
160
|
+
this.description,
|
|
161
|
+
this.tool.run,
|
|
162
|
+
{ properties: extractLangchainPropertiesMap(this.tool) }
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
__name(_LangchainTool, "LangchainTool");
|
|
167
|
+
let LangchainTool = _LangchainTool;
|
|
168
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
169
|
+
0 && (module.exports = {
|
|
170
|
+
LangchainTool,
|
|
171
|
+
isLangchainTool
|
|
172
|
+
});
|
|
@@ -9,6 +9,10 @@ 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 __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
12
16
|
var __copyProps = (to, from, except, desc) => {
|
|
13
17
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
18
|
for (let key of __getOwnPropNames(from))
|
|
@@ -20,7 +24,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
24
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
26
|
var mcp_exports = {};
|
|
27
|
+
__export(mcp_exports, {
|
|
28
|
+
genaiSchemaToJsonSchema: () => import_genai_schema_to_json.genaiSchemaToJsonSchema,
|
|
29
|
+
toGeminiSchema: () => import_gemini_schema_util.toGeminiSchema
|
|
30
|
+
});
|
|
23
31
|
module.exports = __toCommonJS(mcp_exports);
|
|
32
|
+
var import_gemini_schema_util = require("../../utils/gemini_schema_util.js");
|
|
33
|
+
var import_genai_schema_to_json = require("../../utils/genai_schema_to_json.js");
|
|
24
34
|
__reExport(mcp_exports, require("./load_mcp_resource_tool.js"), module.exports);
|
|
25
35
|
__reExport(mcp_exports, require("./mcp_session_manager.js"), module.exports);
|
|
26
36
|
__reExport(mcp_exports, require("./mcp_tool.js"), module.exports);
|
|
@@ -32,6 +42,8 @@ __reExport(mcp_exports, require("./mcp_toolset.js"), module.exports);
|
|
|
32
42
|
*/
|
|
33
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
44
|
0 && (module.exports = {
|
|
45
|
+
genaiSchemaToJsonSchema,
|
|
46
|
+
toGeminiSchema,
|
|
35
47
|
...require("./load_mcp_resource_tool.js"),
|
|
36
48
|
...require("./mcp_session_manager.js"),
|
|
37
49
|
...require("./mcp_tool.js"),
|
|
@@ -67,6 +67,18 @@ function buildTransportOptions(params) {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
__name(buildTransportOptions, "buildTransportOptions");
|
|
70
|
+
function buildSseTransportOptions(params) {
|
|
71
|
+
const { transportOptions, header, headers } = params;
|
|
72
|
+
const callerHeaders = (transportOptions == null ? void 0 : transportOptions.requestInit) === void 0 ? header != null ? header : headers : transportOptions.requestInit.headers;
|
|
73
|
+
return {
|
|
74
|
+
...transportOptions,
|
|
75
|
+
requestInit: {
|
|
76
|
+
...transportOptions == null ? void 0 : transportOptions.requestInit,
|
|
77
|
+
headers: (0, import_client_labels.mergeTrackingHeaders)(callerHeaders)
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
__name(buildSseTransportOptions, "buildSseTransportOptions");
|
|
70
82
|
const _MCPSessionManager = class _MCPSessionManager {
|
|
71
83
|
constructor(connectionParams) {
|
|
72
84
|
this.activeSessions = /* @__PURE__ */ new Set();
|
|
@@ -105,6 +117,19 @@ const _MCPSessionManager = class _MCPSessionManager {
|
|
|
105
117
|
await client.connect(transport);
|
|
106
118
|
break;
|
|
107
119
|
}
|
|
120
|
+
case "SseConnectionParams": {
|
|
121
|
+
const { SSEClientTransport } = await (0, import_optional_peer.loadOptionalPeer)(
|
|
122
|
+
MCP_SDK,
|
|
123
|
+
() => Promise.resolve().then(() => __toESM(require("@modelcontextprotocol/sdk/client/sse.js"), 1))
|
|
124
|
+
);
|
|
125
|
+
const transport = new SSEClientTransport(
|
|
126
|
+
new URL(this.connectionParams.url),
|
|
127
|
+
buildSseTransportOptions(this.connectionParams)
|
|
128
|
+
);
|
|
129
|
+
transport.onerror = logTransportError;
|
|
130
|
+
await client.connect(transport);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
108
133
|
default: {
|
|
109
134
|
const _exhaustiveCheck = this.connectionParams;
|
|
110
135
|
break;
|
|
@@ -165,12 +165,11 @@ function bearerJwtScheme() {
|
|
|
165
165
|
}
|
|
166
166
|
__name(bearerJwtScheme, "bearerJwtScheme");
|
|
167
167
|
function bearerTokenParam(authScheme, token) {
|
|
168
|
-
var _a;
|
|
169
168
|
const param = {
|
|
170
169
|
originalName: "Authorization",
|
|
171
170
|
paramLocation: "header",
|
|
172
171
|
paramSchema: { type: "string" },
|
|
173
|
-
description:
|
|
172
|
+
description: authScheme.description || "Bearer token",
|
|
174
173
|
name: `${INTERNAL_AUTH_PREFIX}Authorization`,
|
|
175
174
|
required: true
|
|
176
175
|
};
|
package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js
CHANGED
|
@@ -37,14 +37,48 @@ __export(auto_auth_credential_exchanger_exports, {
|
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(auto_auth_credential_exchanger_exports);
|
|
39
39
|
var import_auth_credential = require("../../../../auth/auth_credential.js");
|
|
40
|
+
var import_auth_schemes = require("../../../../auth/auth_schemes.js");
|
|
40
41
|
var import_oauth2_credential_exchanger = require("../../../../auth/oauth2/oauth2_credential_exchanger.js");
|
|
41
42
|
var import_experimental = require("../../../../utils/experimental.js");
|
|
43
|
+
var import_oauth2_exchanger = require("./oauth2_exchanger.js");
|
|
42
44
|
var import_service_account_exchanger = require("./service_account_exchanger.js");
|
|
43
45
|
/**
|
|
44
46
|
* @license
|
|
45
47
|
* Copyright 2026 Google LLC
|
|
46
48
|
* SPDX-License-Identifier: Apache-2.0
|
|
47
49
|
*/
|
|
50
|
+
function isPendingAuthorizationCode(authScheme, authCredential) {
|
|
51
|
+
var _a, _b, _c;
|
|
52
|
+
return !!authScheme && (0, import_oauth2_credential_exchanger.determineGrantType)(authScheme) === import_auth_schemes.OAuthGrantType.AUTHORIZATION_CODE && !((_a = authCredential.oauth2) == null ? void 0 : _a.accessToken) && !((_b = authCredential.oauth2) == null ? void 0 : _b.authCode) && !((_c = authCredential.oauth2) == null ? void 0 : _c.authResponseUri);
|
|
53
|
+
}
|
|
54
|
+
__name(isPendingAuthorizationCode, "isPendingAuthorizationCode");
|
|
55
|
+
function createDefaultOAuth2Exchanger() {
|
|
56
|
+
const tokenFetcher = new import_oauth2_credential_exchanger.OAuth2CredentialExchanger();
|
|
57
|
+
return {
|
|
58
|
+
async exchange(params) {
|
|
59
|
+
const { authScheme, authCredential } = params;
|
|
60
|
+
if (authScheme && authCredential.http) {
|
|
61
|
+
return {
|
|
62
|
+
credential: authCredential,
|
|
63
|
+
wasExchanged: false
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (isPendingAuthorizationCode(authScheme, authCredential)) {
|
|
67
|
+
return {
|
|
68
|
+
credential: authCredential,
|
|
69
|
+
wasExchanged: false
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const { credential, wasExchanged } = await tokenFetcher.exchange(params);
|
|
73
|
+
const bearer = (0, import_oauth2_exchanger.generateAuthToken)(credential);
|
|
74
|
+
return {
|
|
75
|
+
credential: bearer,
|
|
76
|
+
wasExchanged: wasExchanged || bearer !== credential
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
__name(createDefaultOAuth2Exchanger, "createDefaultOAuth2Exchanger");
|
|
48
82
|
let AutoAuthCredentialExchanger = class {
|
|
49
83
|
/**
|
|
50
84
|
* @param customExchangers - Optional exchangers that add to or override the
|
|
@@ -52,14 +86,24 @@ let AutoAuthCredentialExchanger = class {
|
|
|
52
86
|
* exchanger instance to use for that type.
|
|
53
87
|
*/
|
|
54
88
|
constructor(customExchangers) {
|
|
89
|
+
/**
|
|
90
|
+
* The exchanger used for each auth credential type.
|
|
91
|
+
*
|
|
92
|
+
* By default `OAUTH2` and `OPEN_ID_CONNECT` run
|
|
93
|
+
* {@link OAuth2CredentialExchanger} and convert any access token with
|
|
94
|
+
* {@link generateAuthToken}, and `SERVICE_ACCOUNT` maps to a
|
|
95
|
+
* {@link ServiceAccountCredentialExchanger}, with any custom exchangers from
|
|
96
|
+
* the constructor merged over them. The map is live: an entry added or
|
|
97
|
+
* replaced after construction is used by the next {@link exchange} call.
|
|
98
|
+
*/
|
|
55
99
|
this.exchangers = /* @__PURE__ */ new Map();
|
|
56
100
|
this.exchangers.set(
|
|
57
101
|
import_auth_credential.AuthCredentialTypes.OAUTH2,
|
|
58
|
-
|
|
102
|
+
createDefaultOAuth2Exchanger()
|
|
59
103
|
);
|
|
60
104
|
this.exchangers.set(
|
|
61
105
|
import_auth_credential.AuthCredentialTypes.OPEN_ID_CONNECT,
|
|
62
|
-
|
|
106
|
+
createDefaultOAuth2Exchanger()
|
|
63
107
|
);
|
|
64
108
|
this.exchangers.set(
|
|
65
109
|
import_auth_credential.AuthCredentialTypes.SERVICE_ACCOUNT,
|
|
@@ -40,6 +40,7 @@ __export(oauth2_exchanger_exports, {
|
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(oauth2_exchanger_exports);
|
|
42
42
|
var import_auth_credential = require("../../../../auth/auth_credential.js");
|
|
43
|
+
var import_auth_schemes = require("../../../../auth/auth_schemes.js");
|
|
43
44
|
var import_experimental = require("../../../../utils/experimental.js");
|
|
44
45
|
/**
|
|
45
46
|
* @license
|
|
@@ -52,7 +53,7 @@ function checkSchemeCredentialType(authScheme, authCredential) {
|
|
|
52
53
|
"auth_credential is empty. Please create AuthCredential using OAuth2Auth."
|
|
53
54
|
);
|
|
54
55
|
}
|
|
55
|
-
if (authScheme.type !==
|
|
56
|
+
if (authScheme.type !== import_auth_schemes.AuthSchemeType.OPEN_ID_CONNECT && authScheme.type !== import_auth_schemes.AuthSchemeType.OAUTH2) {
|
|
56
57
|
throw new Error(
|
|
57
58
|
`Invalid security scheme, expect AuthSchemeType.openIdConnect or AuthSchemeType.oauth2 auth scheme, but got ${authScheme.type}`
|
|
58
59
|
);
|
|
@@ -37,6 +37,7 @@ __export(service_account_exchanger_exports, {
|
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(service_account_exchanger_exports);
|
|
39
39
|
var import_google_auth_library = require("google-auth-library");
|
|
40
|
+
var import_node_crypto = require("node:crypto");
|
|
40
41
|
var import_auth_credential = require("../../../../auth/auth_credential.js");
|
|
41
42
|
var import_experimental = require("../../../../utils/experimental.js");
|
|
42
43
|
var import_base_auth_credential_exchanger = require("./base_auth_credential_exchanger.js");
|
|
@@ -47,6 +48,83 @@ var import_base_auth_credential_exchanger = require("./base_auth_credential_exch
|
|
|
47
48
|
*/
|
|
48
49
|
const DEFAULT_SCOPES = ["https://www.googleapis.com/auth/cloud-platform"];
|
|
49
50
|
const MISSING_SERVICE_ACCOUNT_CREDENTIALS = "Service account credentials are missing. Please provide them, or set `useDefaultCredential: true` to use application default credentials in a hosted service like Cloud Run.";
|
|
51
|
+
const GOOGLE_TOKEN_URI = "https://oauth2.googleapis.com/token";
|
|
52
|
+
const JWT_BEARER_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer";
|
|
53
|
+
const ASSERTION_LIFETIME_SECONDS = 3600;
|
|
54
|
+
const TOKEN_REQUEST_TIMEOUT_MS = 3e4;
|
|
55
|
+
function hasCustomTokenUri(creds) {
|
|
56
|
+
return !!creds.tokenUri && creds.tokenUri !== GOOGLE_TOKEN_URI;
|
|
57
|
+
}
|
|
58
|
+
__name(hasCustomTokenUri, "hasCustomTokenUri");
|
|
59
|
+
function base64UrlJson(value) {
|
|
60
|
+
return Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
61
|
+
}
|
|
62
|
+
__name(base64UrlJson, "base64UrlJson");
|
|
63
|
+
function signJwtBearerAssertion(creds, scopes, issuedAt) {
|
|
64
|
+
const header = {
|
|
65
|
+
alg: "RS256",
|
|
66
|
+
typ: "JWT",
|
|
67
|
+
...creds.privateKeyId ? { kid: creds.privateKeyId } : {}
|
|
68
|
+
};
|
|
69
|
+
const payload = {
|
|
70
|
+
iss: creds.clientEmail,
|
|
71
|
+
scope: scopes.join(" "),
|
|
72
|
+
aud: GOOGLE_TOKEN_URI,
|
|
73
|
+
iat: issuedAt,
|
|
74
|
+
exp: issuedAt + ASSERTION_LIFETIME_SECONDS
|
|
75
|
+
};
|
|
76
|
+
const signingInput = `${base64UrlJson(header)}.${base64UrlJson(payload)}`;
|
|
77
|
+
const signature = (0, import_node_crypto.createSign)("RSA-SHA256").update(signingInput).sign(creds.privateKey, "base64url");
|
|
78
|
+
return `${signingInput}.${signature}`;
|
|
79
|
+
}
|
|
80
|
+
__name(signJwtBearerAssertion, "signJwtBearerAssertion");
|
|
81
|
+
async function readTokenErrorDetail(response) {
|
|
82
|
+
try {
|
|
83
|
+
const body = await response.json();
|
|
84
|
+
if (typeof body !== "object" || body === null) {
|
|
85
|
+
return void 0;
|
|
86
|
+
}
|
|
87
|
+
const parts = [];
|
|
88
|
+
if ("error" in body && typeof body.error === "string" && body.error.length > 0) {
|
|
89
|
+
parts.push(body.error);
|
|
90
|
+
}
|
|
91
|
+
if ("error_description" in body && typeof body.error_description === "string" && body.error_description.length > 0) {
|
|
92
|
+
parts.push(body.error_description);
|
|
93
|
+
}
|
|
94
|
+
return parts.length > 0 ? parts.join(": ") : void 0;
|
|
95
|
+
} catch {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
__name(readTokenErrorDetail, "readTokenErrorDetail");
|
|
100
|
+
async function requestJwtBearerToken(creds, scopes) {
|
|
101
|
+
const assertion = signJwtBearerAssertion(
|
|
102
|
+
creds,
|
|
103
|
+
scopes,
|
|
104
|
+
Math.floor(Date.now() / 1e3)
|
|
105
|
+
);
|
|
106
|
+
const response = await fetch(creds.tokenUri, {
|
|
107
|
+
method: "POST",
|
|
108
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
109
|
+
body: new URLSearchParams({
|
|
110
|
+
grant_type: JWT_BEARER_GRANT_TYPE,
|
|
111
|
+
assertion
|
|
112
|
+
}),
|
|
113
|
+
signal: AbortSignal.timeout(TOKEN_REQUEST_TIMEOUT_MS)
|
|
114
|
+
});
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
const detail = await readTokenErrorDetail(response);
|
|
117
|
+
throw new Error(
|
|
118
|
+
detail ? `Token endpoint responded with HTTP ${response.status}: ${detail}` : `Token endpoint responded with HTTP ${response.status}`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
const body = await response.json();
|
|
122
|
+
if (typeof body === "object" && body !== null && "access_token" in body && typeof body.access_token === "string") {
|
|
123
|
+
return body.access_token;
|
|
124
|
+
}
|
|
125
|
+
return void 0;
|
|
126
|
+
}
|
|
127
|
+
__name(requestJwtBearerToken, "requestJwtBearerToken");
|
|
50
128
|
let ServiceAccountCredentialExchanger = class {
|
|
51
129
|
async exchange(params) {
|
|
52
130
|
const { authCredential } = params;
|
|
@@ -87,21 +165,27 @@ let ServiceAccountCredentialExchanger = class {
|
|
|
87
165
|
}
|
|
88
166
|
}
|
|
89
167
|
async exchangeForExplicitCredential(saConfig) {
|
|
168
|
+
var _a;
|
|
90
169
|
const creds = saConfig.serviceAccountCredential;
|
|
91
170
|
if (!creds) {
|
|
92
171
|
throw new import_base_auth_credential_exchanger.AuthCredentialMissingError(MISSING_SERVICE_ACCOUNT_CREDENTIALS);
|
|
93
172
|
}
|
|
94
173
|
try {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
174
|
+
let token;
|
|
175
|
+
if (hasCustomTokenUri(creds)) {
|
|
176
|
+
token = await requestJwtBearerToken(creds, (_a = saConfig.scopes) != null ? _a : []);
|
|
177
|
+
} else {
|
|
178
|
+
const client = new import_google_auth_library.JWT({
|
|
179
|
+
email: creds.clientEmail,
|
|
180
|
+
key: creds.privateKey,
|
|
181
|
+
keyId: creds.privateKeyId,
|
|
182
|
+
projectId: creds.projectId,
|
|
183
|
+
universeDomain: creds.universeDomain,
|
|
184
|
+
scopes: saConfig.scopes
|
|
185
|
+
});
|
|
186
|
+
const tokens = await client.authorize();
|
|
187
|
+
token = tokens.access_token;
|
|
188
|
+
}
|
|
105
189
|
if (!token) {
|
|
106
190
|
throw new Error("Failed to get access token from explicit credentials");
|
|
107
191
|
}
|
|
@@ -50,6 +50,16 @@ var import_base_auth_credential_exchanger = require("../auth/credential_exchange
|
|
|
50
50
|
* SPDX-License-Identifier: Apache-2.0
|
|
51
51
|
*/
|
|
52
52
|
const DEFAULT_CREDENTIAL_KEY = "default_openapi_key";
|
|
53
|
+
const INTERACTIVE_CREDENTIAL_TYPES = /* @__PURE__ */ new Set([
|
|
54
|
+
import_auth_credential.AuthCredentialTypes.OAUTH2,
|
|
55
|
+
import_auth_credential.AuthCredentialTypes.OPEN_ID_CONNECT
|
|
56
|
+
]);
|
|
57
|
+
function isMissingInteractiveToken(result) {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
const { credential, wasExchanged } = result;
|
|
60
|
+
return !wasExchanged && INTERACTIVE_CREDENTIAL_TYPES.has(credential.authType) && !credential.http && !((_a = credential.oauth2) == null ? void 0 : _a.accessToken) && !((_b = credential.oauth2) == null ? void 0 : _b.refreshToken);
|
|
61
|
+
}
|
|
62
|
+
__name(isMissingInteractiveToken, "isMissingInteractiveToken");
|
|
53
63
|
const _ToolContextCredentialStore = class _ToolContextCredentialStore {
|
|
54
64
|
constructor(context) {
|
|
55
65
|
this.context = context;
|
|
@@ -165,7 +175,8 @@ let ToolAuthHandler = class {
|
|
|
165
175
|
};
|
|
166
176
|
}
|
|
167
177
|
/**
|
|
168
|
-
* Exchanges `credential`, or returns `undefined` when the exchange failed
|
|
178
|
+
* Exchanges `credential`, or returns `undefined` when the exchange failed or
|
|
179
|
+
* produced an interactive credential that still holds no token.
|
|
169
180
|
*
|
|
170
181
|
* An exchange failure is transient far more often than it is fatal, so it
|
|
171
182
|
* becomes a `pending` result the client can resume from rather than an
|
|
@@ -175,10 +186,11 @@ let ToolAuthHandler = class {
|
|
|
175
186
|
var _a;
|
|
176
187
|
const exchanger = (_a = this.credentialExchanger) != null ? _a : new import_auto_auth_credential_exchanger.AutoAuthCredentialExchanger();
|
|
177
188
|
try {
|
|
178
|
-
|
|
189
|
+
const result = await exchanger.exchange({
|
|
179
190
|
authScheme: this.authScheme,
|
|
180
191
|
authCredential: credential
|
|
181
192
|
});
|
|
193
|
+
return isMissingInteractiveToken(result) ? void 0 : result;
|
|
182
194
|
} catch (e) {
|
|
183
195
|
import_logger.logger.error(
|
|
184
196
|
`Failed to exchange credential: ${e instanceof Error ? e.message : e}`
|
|
@@ -25,7 +25,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
25
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
26
|
var base_retrieval_tool_exports = {};
|
|
27
27
|
__export(base_retrieval_tool_exports, {
|
|
28
|
-
BaseRetrievalTool: () => BaseRetrievalTool
|
|
28
|
+
BaseRetrievalTool: () => BaseRetrievalTool,
|
|
29
|
+
isBaseRetrievalTool: () => isBaseRetrievalTool
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(base_retrieval_tool_exports);
|
|
31
32
|
var import_genai = require("@google/genai");
|
|
@@ -35,7 +36,20 @@ var import_base_tool = require("../base_tool.js");
|
|
|
35
36
|
* Copyright 2026 Google LLC
|
|
36
37
|
* SPDX-License-Identifier: Apache-2.0
|
|
37
38
|
*/
|
|
38
|
-
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const BASE_RETRIEVAL_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
41
|
+
"google.adk.baseRetrievalTool"
|
|
42
|
+
);
|
|
43
|
+
function isBaseRetrievalTool(obj) {
|
|
44
|
+
return typeof obj === "object" && obj !== null && BASE_RETRIEVAL_TOOL_SIGNATURE_SYMBOL in obj && obj[BASE_RETRIEVAL_TOOL_SIGNATURE_SYMBOL] === true;
|
|
45
|
+
}
|
|
46
|
+
__name(isBaseRetrievalTool, "isBaseRetrievalTool");
|
|
47
|
+
const _BaseRetrievalTool = class _BaseRetrievalTool extends (_b = import_base_tool.BaseTool, _a = BASE_RETRIEVAL_TOOL_SIGNATURE_SYMBOL, _b) {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
/** Unique symbol to identify `BaseRetrievalTool` class. */
|
|
51
|
+
this[_a] = true;
|
|
52
|
+
}
|
|
39
53
|
_getDeclaration() {
|
|
40
54
|
return {
|
|
41
55
|
name: this.name,
|
|
@@ -56,5 +70,6 @@ __name(_BaseRetrievalTool, "BaseRetrievalTool");
|
|
|
56
70
|
let BaseRetrievalTool = _BaseRetrievalTool;
|
|
57
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
72
|
0 && (module.exports = {
|
|
59
|
-
BaseRetrievalTool
|
|
73
|
+
BaseRetrievalTool,
|
|
74
|
+
isBaseRetrievalTool
|
|
60
75
|
});
|
|
@@ -0,0 +1,108 @@
|
|
|
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 toolbox_tool_exports = {};
|
|
27
|
+
__export(toolbox_tool_exports, {
|
|
28
|
+
ToolboxTool: () => ToolboxTool,
|
|
29
|
+
isToolboxTool: () => isToolboxTool
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(toolbox_tool_exports);
|
|
32
|
+
var import_langchain_tool = require("./langchain_tool.js");
|
|
33
|
+
/**
|
|
34
|
+
* @license
|
|
35
|
+
* Copyright 2026 Google LLC
|
|
36
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
37
|
+
*/
|
|
38
|
+
var _a;
|
|
39
|
+
const TOOLBOX_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.toolboxTool");
|
|
40
|
+
function isToolboxTool(obj) {
|
|
41
|
+
return typeof obj === "object" && obj !== null && TOOLBOX_TOOL_SIGNATURE_SYMBOL in obj && obj[TOOLBOX_TOOL_SIGNATURE_SYMBOL] === true;
|
|
42
|
+
}
|
|
43
|
+
__name(isToolboxTool, "isToolboxTool");
|
|
44
|
+
function createUnconfiguredToolboxClient(url) {
|
|
45
|
+
const endpoint = url != null ? url : "unspecified URL";
|
|
46
|
+
const throwMissingClient = /* @__PURE__ */ __name(() => {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`ToolboxTool requires a ToolboxClientLike instance (for endpoint "${endpoint}"). Pass {url, client} to the ToolboxTool constructor.`
|
|
49
|
+
);
|
|
50
|
+
}, "throwMissingClient");
|
|
51
|
+
return {
|
|
52
|
+
loadTool: throwMissingClient,
|
|
53
|
+
loadToolset: throwMissingClient
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
__name(createUnconfiguredToolboxClient, "createUnconfiguredToolboxClient");
|
|
57
|
+
_a = TOOLBOX_TOOL_SIGNATURE_SYMBOL;
|
|
58
|
+
const _ToolboxTool = class _ToolboxTool {
|
|
59
|
+
constructor(urlOrOptions) {
|
|
60
|
+
/** A unique symbol to identify ADK ToolboxTool class. */
|
|
61
|
+
this[_a] = true;
|
|
62
|
+
var _a2;
|
|
63
|
+
if (typeof urlOrOptions === "string") {
|
|
64
|
+
this.url = urlOrOptions;
|
|
65
|
+
this.toolboxClient = createUnconfiguredToolboxClient(urlOrOptions);
|
|
66
|
+
} else {
|
|
67
|
+
this.url = urlOrOptions.url;
|
|
68
|
+
this.toolboxClient = (_a2 = urlOrOptions.client) != null ? _a2 : createUnconfiguredToolboxClient(urlOrOptions.url);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Loads a single tool from the Toolbox client and wraps it in a
|
|
73
|
+
* {@link LangchainTool}.
|
|
74
|
+
*/
|
|
75
|
+
getTool(toolName) {
|
|
76
|
+
var _a2, _b, _c;
|
|
77
|
+
const loader = (_c = (_a2 = this.toolboxClient.loadTool) == null ? void 0 : _a2.bind(this.toolboxClient)) != null ? _c : (_b = this.toolboxClient.load_tool) == null ? void 0 : _b.bind(this.toolboxClient);
|
|
78
|
+
if (!loader) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
"ToolboxClient does not implement loadTool or load_tool."
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const tool = loader(toolName);
|
|
84
|
+
return new import_langchain_tool.LangchainTool(tool);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Loads a toolset from the Toolbox client and wraps each tool in a
|
|
88
|
+
* {@link LangchainTool}.
|
|
89
|
+
*/
|
|
90
|
+
getToolset(toolsetName) {
|
|
91
|
+
var _a2, _b, _c;
|
|
92
|
+
const loader = (_c = (_a2 = this.toolboxClient.loadToolset) == null ? void 0 : _a2.bind(this.toolboxClient)) != null ? _c : (_b = this.toolboxClient.load_toolset) == null ? void 0 : _b.bind(this.toolboxClient);
|
|
93
|
+
if (!loader) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
"ToolboxClient does not implement loadToolset or load_toolset."
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
const tools = loader(toolsetName);
|
|
99
|
+
return tools.map((tool) => new import_langchain_tool.LangchainTool(tool));
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
__name(_ToolboxTool, "ToolboxTool");
|
|
103
|
+
let ToolboxTool = _ToolboxTool;
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
ToolboxTool,
|
|
107
|
+
isToolboxTool
|
|
108
|
+
});
|