@google/adk 2.2.0 → 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/a2a/event_converter_utils.js +5 -1
- package/dist/cjs/a2a/metadata_converter_utils.js +2 -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 +90 -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/abort_events.js +135 -0
- package/dist/cjs/events/event.js +4 -2
- package/dist/cjs/events/internal_metadata.js +131 -0
- 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/plugins/debug_logging_plugin.js +653 -0
- package/dist/cjs/plugins/plugin_manager.js +1 -1
- package/dist/cjs/plugins/tool_call_integrity_plugin.js +364 -0
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +121 -35
- 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/a2a/event_converter_utils.js +5 -1
- package/dist/esm/a2a/metadata_converter_utils.js +2 -1
- 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 +87 -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/abort_events.js +110 -0
- package/dist/esm/events/event.js +4 -2
- package/dist/esm/events/internal_metadata.js +97 -0
- 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/plugins/debug_logging_plugin.js +615 -0
- package/dist/esm/plugins/plugin_manager.js +1 -1
- package/dist/esm/plugins/tool_call_integrity_plugin.js +339 -0
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +124 -35
- 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 +30 -4
- package/dist/types/events/abort_events.d.ts +43 -0
- package/dist/types/events/event.d.ts +4 -0
- package/dist/types/events/internal_metadata.d.ts +78 -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/plugins/debug_logging_plugin.d.ts +157 -0
- package/dist/types/plugins/tool_call_integrity_plugin.d.ts +116 -0
- 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 +105 -106
- package/dist/web/index_web.js.map +4 -4
- package/package.json +8 -3
|
@@ -11,6 +11,8 @@ var _a, _b;
|
|
|
11
11
|
import { Type } from "@google/genai";
|
|
12
12
|
import { isZodObject, zodObjectToSchema } from "../utils/simple_zod_to_json.js";
|
|
13
13
|
import { BaseTool } from "./base_tool.js";
|
|
14
|
+
import { toGeminiSchema } from "../utils/gemini_schema_util.js";
|
|
15
|
+
import { toJsonSchema } from "../utils/schema.js";
|
|
14
16
|
function toSchema(parameters) {
|
|
15
17
|
if (parameters === void 0) {
|
|
16
18
|
return { type: Type.OBJECT, properties: {} };
|
|
@@ -21,6 +23,27 @@ function toSchema(parameters) {
|
|
|
21
23
|
return parameters;
|
|
22
24
|
}
|
|
23
25
|
__name(toSchema, "toSchema");
|
|
26
|
+
function toResponseSchema(response) {
|
|
27
|
+
var _a2;
|
|
28
|
+
if (isZodObject(response)) {
|
|
29
|
+
return zodObjectToSchema(response);
|
|
30
|
+
}
|
|
31
|
+
if (typeof response === "object" && response !== null && "safeParse" in response && typeof response.safeParse === "function") {
|
|
32
|
+
return (_a2 = toGeminiSchema(
|
|
33
|
+
toJsonSchema(response)
|
|
34
|
+
)) != null ? _a2 : { type: Type.TYPE_UNSPECIFIED };
|
|
35
|
+
}
|
|
36
|
+
return response;
|
|
37
|
+
}
|
|
38
|
+
__name(toResponseSchema, "toResponseSchema");
|
|
39
|
+
function isPlainRecord(value) {
|
|
40
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41
|
+
}
|
|
42
|
+
__name(isPlainRecord, "isPlainRecord");
|
|
43
|
+
function isAsyncIterable(value) {
|
|
44
|
+
return typeof value === "object" && value !== null && Symbol.asyncIterator in value && typeof value[Symbol.asyncIterator] === "function";
|
|
45
|
+
}
|
|
46
|
+
__name(isAsyncIterable, "isAsyncIterable");
|
|
24
47
|
const FUNCTION_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.functionTool");
|
|
25
48
|
function isFunctionTool(obj) {
|
|
26
49
|
return typeof obj === "object" && obj !== null && FUNCTION_TOOL_SIGNATURE_SYMBOL in obj && obj[FUNCTION_TOOL_SIGNATURE_SYMBOL] === true;
|
|
@@ -48,6 +71,7 @@ const _FunctionTool = class _FunctionTool extends (_b = BaseTool, _a = FUNCTION_
|
|
|
48
71
|
this[_a] = true;
|
|
49
72
|
this.execute = options.execute;
|
|
50
73
|
this.parameters = options.parameters;
|
|
74
|
+
this.response = options.response;
|
|
51
75
|
this.requireConfirmation = (_b2 = options.requireConfirmation) != null ? _b2 : false;
|
|
52
76
|
}
|
|
53
77
|
/**
|
|
@@ -55,6 +79,14 @@ const _FunctionTool = class _FunctionTool extends (_b = BaseTool, _a = FUNCTION_
|
|
|
55
79
|
* and parameter schema.
|
|
56
80
|
*/
|
|
57
81
|
_getDeclaration() {
|
|
82
|
+
if (this.response !== void 0) {
|
|
83
|
+
return {
|
|
84
|
+
name: this.name,
|
|
85
|
+
description: this.description,
|
|
86
|
+
parameters: toSchema(this.parameters),
|
|
87
|
+
response: toResponseSchema(this.response)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
58
90
|
return {
|
|
59
91
|
name: this.name,
|
|
60
92
|
description: this.description,
|
|
@@ -87,6 +119,41 @@ const _FunctionTool = class _FunctionTool extends (_b = BaseTool, _a = FUNCTION_
|
|
|
87
119
|
throw new Error(`Error in tool '${this.name}': ${errorMessage}`);
|
|
88
120
|
}
|
|
89
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Invokes the tool in live streaming mode, injecting any active input stream
|
|
124
|
+
* from the invocation context and yielding items from the returned stream.
|
|
125
|
+
*
|
|
126
|
+
* @param req The live tool invocation request.
|
|
127
|
+
*/
|
|
128
|
+
async *_callLive(req) {
|
|
129
|
+
var _a2;
|
|
130
|
+
const validatedArgs = this.validateArgs(req.args);
|
|
131
|
+
const argsToCall = isPlainRecord(validatedArgs) ? { ...validatedArgs } : { ...req.args };
|
|
132
|
+
const activeTool = (_a2 = req.invocationContext.activeStreamingTools) == null ? void 0 : _a2[this.name];
|
|
133
|
+
if (activeTool == null ? void 0 : activeTool.stream) {
|
|
134
|
+
argsToCall["inputStream"] = activeTool.stream;
|
|
135
|
+
}
|
|
136
|
+
const rawResult = this.execute(
|
|
137
|
+
argsToCall,
|
|
138
|
+
req.toolContext
|
|
139
|
+
);
|
|
140
|
+
if (isAsyncIterable(rawResult)) {
|
|
141
|
+
for await (const item of rawResult) {
|
|
142
|
+
yield item;
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const awaited = await rawResult;
|
|
147
|
+
if (isAsyncIterable(awaited)) {
|
|
148
|
+
for await (const item of awaited) {
|
|
149
|
+
yield item;
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (awaited !== void 0) {
|
|
154
|
+
yield awaited;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
90
157
|
/**
|
|
91
158
|
* Whether this call is gated on human approval — the static flag, or the
|
|
92
159
|
* predicate evaluated against the validated arguments.
|
|
@@ -148,7 +215,256 @@ const _FunctionTool = class _FunctionTool extends (_b = BaseTool, _a = FUNCTION_
|
|
|
148
215
|
};
|
|
149
216
|
__name(_FunctionTool, "FunctionTool");
|
|
150
217
|
let FunctionTool = _FunctionTool;
|
|
218
|
+
const SCHEMA_TYPE_MAP = {
|
|
219
|
+
str: Type.STRING,
|
|
220
|
+
int: Type.INTEGER,
|
|
221
|
+
float: Type.NUMBER,
|
|
222
|
+
bool: Type.BOOLEAN,
|
|
223
|
+
string: Type.STRING,
|
|
224
|
+
integer: Type.INTEGER,
|
|
225
|
+
number: Type.NUMBER,
|
|
226
|
+
boolean: Type.BOOLEAN,
|
|
227
|
+
list: Type.ARRAY,
|
|
228
|
+
array: Type.ARRAY,
|
|
229
|
+
tuple: Type.ARRAY,
|
|
230
|
+
object: Type.OBJECT,
|
|
231
|
+
Dict: Type.OBJECT,
|
|
232
|
+
List: Type.ARRAY,
|
|
233
|
+
Tuple: Type.ARRAY,
|
|
234
|
+
Any: Type.TYPE_UNSPECIFIED,
|
|
235
|
+
STRING: Type.STRING,
|
|
236
|
+
INTEGER: Type.INTEGER,
|
|
237
|
+
NUMBER: Type.NUMBER,
|
|
238
|
+
BOOLEAN: Type.BOOLEAN,
|
|
239
|
+
ARRAY: Type.ARRAY,
|
|
240
|
+
OBJECT: Type.OBJECT,
|
|
241
|
+
NULL: Type.NULL,
|
|
242
|
+
null: Type.NULL,
|
|
243
|
+
TYPE_UNSPECIFIED: Type.TYPE_UNSPECIFIED
|
|
244
|
+
};
|
|
245
|
+
function annotateNullableFields(schema) {
|
|
246
|
+
const properties = schema["properties"];
|
|
247
|
+
if (!isPlainRecord(properties)) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
for (const propertySchema of Object.values(properties)) {
|
|
251
|
+
if (!isPlainRecord(propertySchema)) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
const anyOf = propertySchema["anyOf"];
|
|
255
|
+
if (!Array.isArray(anyOf)) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
for (let i = 0; i < anyOf.length; i++) {
|
|
259
|
+
const branch = anyOf[i];
|
|
260
|
+
if (isPlainRecord(branch) && (branch["type"] === "null" || branch["type"] === Type.NULL)) {
|
|
261
|
+
propertySchema["nullable"] = true;
|
|
262
|
+
anyOf.splice(i, 1);
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
__name(annotateNullableFields, "annotateNullableFields");
|
|
269
|
+
function annotateRequiredFields(schema) {
|
|
270
|
+
const properties = schema["properties"];
|
|
271
|
+
if (!isPlainRecord(properties)) {
|
|
272
|
+
schema["required"] = [];
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const required = [];
|
|
276
|
+
for (const [fieldName, fieldSchema] of Object.entries(properties)) {
|
|
277
|
+
if (isPlainRecord(fieldSchema) && !fieldSchema["nullable"] && !("default" in fieldSchema)) {
|
|
278
|
+
required.push(fieldName);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
schema["required"] = required;
|
|
282
|
+
}
|
|
283
|
+
__name(annotateRequiredFields, "annotateRequiredFields");
|
|
284
|
+
function removeAnyOf(schema) {
|
|
285
|
+
const properties = schema["properties"];
|
|
286
|
+
if (!isPlainRecord(properties)) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
for (const propertySchema of Object.values(properties)) {
|
|
290
|
+
if (!isPlainRecord(propertySchema)) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const unionTypes = propertySchema["anyOf"];
|
|
294
|
+
delete propertySchema["anyOf"];
|
|
295
|
+
if (Array.isArray(unionTypes)) {
|
|
296
|
+
for (const branch of unionTypes) {
|
|
297
|
+
if (isPlainRecord(branch) && branch["type"] !== "null" && branch["type"] !== Type.NULL) {
|
|
298
|
+
Object.assign(propertySchema, branch);
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
__name(removeAnyOf, "removeAnyOf");
|
|
306
|
+
function removeDefault(schema) {
|
|
307
|
+
const properties = schema["properties"];
|
|
308
|
+
if (!isPlainRecord(properties)) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
for (const propertySchema of Object.values(properties)) {
|
|
312
|
+
if (isPlainRecord(propertySchema)) {
|
|
313
|
+
delete propertySchema["default"];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
__name(removeDefault, "removeDefault");
|
|
318
|
+
function removeNullable(schema) {
|
|
319
|
+
const properties = schema["properties"];
|
|
320
|
+
if (!isPlainRecord(properties)) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
for (const propertySchema of Object.values(properties)) {
|
|
324
|
+
if (isPlainRecord(propertySchema)) {
|
|
325
|
+
delete propertySchema["nullable"];
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
__name(removeNullable, "removeNullable");
|
|
330
|
+
function removeTitle(schema) {
|
|
331
|
+
const properties = schema["properties"];
|
|
332
|
+
if (!isPlainRecord(properties)) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
for (const propertySchema of Object.values(properties)) {
|
|
336
|
+
if (isPlainRecord(propertySchema)) {
|
|
337
|
+
delete propertySchema["title"];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
__name(removeTitle, "removeTitle");
|
|
342
|
+
function processParameterSchema(vertexai, schema) {
|
|
343
|
+
annotateNullableFields(schema);
|
|
344
|
+
annotateRequiredFields(schema);
|
|
345
|
+
if (!vertexai) {
|
|
346
|
+
removeAnyOf(schema);
|
|
347
|
+
removeDefault(schema);
|
|
348
|
+
removeNullable(schema);
|
|
349
|
+
removeTitle(schema);
|
|
350
|
+
}
|
|
351
|
+
return schema;
|
|
352
|
+
}
|
|
353
|
+
__name(processParameterSchema, "processParameterSchema");
|
|
354
|
+
function mapPropertySchemaType(propertySchema) {
|
|
355
|
+
var _a2, _b2;
|
|
356
|
+
if (typeof propertySchema["type"] === "string") {
|
|
357
|
+
propertySchema["type"] = (_a2 = SCHEMA_TYPE_MAP[propertySchema["type"]]) != null ? _a2 : Type.TYPE_UNSPECIFIED;
|
|
358
|
+
if (propertySchema["type"] === Type.ARRAY && isPlainRecord(propertySchema["items"])) {
|
|
359
|
+
mapPropertySchemaType(propertySchema["items"]);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (isPlainRecord(propertySchema["properties"])) {
|
|
363
|
+
for (const nestedProp of Object.values(propertySchema["properties"])) {
|
|
364
|
+
if (isPlainRecord(nestedProp)) {
|
|
365
|
+
mapPropertySchemaType(nestedProp);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (Array.isArray(propertySchema["anyOf"])) {
|
|
370
|
+
for (const branch of propertySchema["anyOf"]) {
|
|
371
|
+
if (isPlainRecord(branch) && typeof branch["type"] === "string") {
|
|
372
|
+
branch["type"] = (_b2 = SCHEMA_TYPE_MAP[branch["type"]]) != null ? _b2 : Type.TYPE_UNSPECIFIED;
|
|
373
|
+
propertySchema["type"] = branch["type"];
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
__name(mapPropertySchemaType, "mapPropertySchemaType");
|
|
379
|
+
function mapSchemaTypes(schema) {
|
|
380
|
+
const properties = schema["properties"];
|
|
381
|
+
if (!isPlainRecord(properties)) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
for (const propertySchema of Object.values(properties)) {
|
|
385
|
+
if (isPlainRecord(propertySchema)) {
|
|
386
|
+
mapPropertySchemaType(propertySchema);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
__name(mapSchemaTypes, "mapSchemaTypes");
|
|
391
|
+
function resolveReturnSchema(func, beforeParamSchema) {
|
|
392
|
+
var _a2, _b2, _c;
|
|
393
|
+
const funcObj = typeof func === "function" || isPlainRecord(func) ? func : void 0;
|
|
394
|
+
const responseCandidate = (_a2 = funcObj == null ? void 0 : funcObj.response) != null ? _a2 : beforeParamSchema["response"];
|
|
395
|
+
if (responseCandidate !== void 0) {
|
|
396
|
+
return toResponseSchema(responseCandidate);
|
|
397
|
+
}
|
|
398
|
+
const returnTypeCandidate = (_b2 = funcObj == null ? void 0 : funcObj.returnType) != null ? _b2 : typeof beforeParamSchema["returnType"] === "string" ? beforeParamSchema["returnType"] : void 0;
|
|
399
|
+
if (typeof returnTypeCandidate === "string") {
|
|
400
|
+
return {
|
|
401
|
+
type: (_c = SCHEMA_TYPE_MAP[returnTypeCandidate]) != null ? _c : Type.TYPE_UNSPECIFIED
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
if (typeof func === "function") {
|
|
405
|
+
return { type: Type.TYPE_UNSPECIFIED };
|
|
406
|
+
}
|
|
407
|
+
return void 0;
|
|
408
|
+
}
|
|
409
|
+
__name(resolveReturnSchema, "resolveReturnSchema");
|
|
410
|
+
function buildFunctionDeclarationUtil(vertexai, name, description, func, beforeParamSchema) {
|
|
411
|
+
const schemaCopy = structuredClone(beforeParamSchema);
|
|
412
|
+
mapSchemaTypes(schemaCopy);
|
|
413
|
+
const properties = isPlainRecord(schemaCopy["properties"]) ? schemaCopy["properties"] : {};
|
|
414
|
+
const hasProperties = Object.keys(properties).length > 0;
|
|
415
|
+
const declaration = {
|
|
416
|
+
name,
|
|
417
|
+
description
|
|
418
|
+
};
|
|
419
|
+
if (hasProperties) {
|
|
420
|
+
const parameters = {
|
|
421
|
+
type: Type.OBJECT,
|
|
422
|
+
properties
|
|
423
|
+
};
|
|
424
|
+
if (Array.isArray(schemaCopy["required"]) && schemaCopy["required"].length > 0) {
|
|
425
|
+
parameters.required = schemaCopy["required"];
|
|
426
|
+
}
|
|
427
|
+
declaration.parameters = parameters;
|
|
428
|
+
}
|
|
429
|
+
if (vertexai) {
|
|
430
|
+
const responseSchema = resolveReturnSchema(func, schemaCopy);
|
|
431
|
+
if (responseSchema !== void 0) {
|
|
432
|
+
declaration.response = responseSchema;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return declaration;
|
|
436
|
+
}
|
|
437
|
+
__name(buildFunctionDeclarationUtil, "buildFunctionDeclarationUtil");
|
|
438
|
+
function buildFunctionDeclarationForLangchain(vertexai, name, description, func, paramSchema) {
|
|
439
|
+
const rawCopy = structuredClone(paramSchema);
|
|
440
|
+
const explicitRequired = Array.isArray(rawCopy["required"]) ? rawCopy["required"] : void 0;
|
|
441
|
+
delete rawCopy["required"];
|
|
442
|
+
const wrapped = processParameterSchema(vertexai, {
|
|
443
|
+
properties: rawCopy
|
|
444
|
+
});
|
|
445
|
+
const properties = isPlainRecord(wrapped["properties"]) ? { ...wrapped["properties"] } : {};
|
|
446
|
+
const computedRequired = Array.isArray(wrapped["required"]) ? wrapped["required"] : [];
|
|
447
|
+
const requiredFields = explicitRequired !== void 0 ? explicitRequired : computedRequired;
|
|
448
|
+
return buildFunctionDeclarationUtil(vertexai, name, description, func, {
|
|
449
|
+
properties,
|
|
450
|
+
required: requiredFields
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
__name(buildFunctionDeclarationForLangchain, "buildFunctionDeclarationForLangchain");
|
|
454
|
+
function buildFunctionDeclarationForParamsForCrewai(vertexai, name, description, func, paramSchema) {
|
|
455
|
+
const processed = processParameterSchema(
|
|
456
|
+
vertexai,
|
|
457
|
+
structuredClone(paramSchema)
|
|
458
|
+
);
|
|
459
|
+
return buildFunctionDeclarationUtil(vertexai, name, description, func, {
|
|
460
|
+
...processed
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
__name(buildFunctionDeclarationForParamsForCrewai, "buildFunctionDeclarationForParamsForCrewai");
|
|
151
464
|
export {
|
|
152
465
|
FunctionTool,
|
|
466
|
+
buildFunctionDeclarationForLangchain,
|
|
467
|
+
buildFunctionDeclarationForParamsForCrewai,
|
|
468
|
+
buildFunctionDeclarationUtil,
|
|
153
469
|
isFunctionTool
|
|
154
470
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
7
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
8
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
+
if (decorator = decorators[i])
|
|
10
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
11
|
+
if (kind && result) __defProp(target, key, result);
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2026 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
*/
|
|
19
|
+
var _a, _b;
|
|
20
|
+
import { AuthCredentialTypes } from "../../auth/auth_credential.js";
|
|
21
|
+
import { experimental } from "../../utils/experimental.js";
|
|
22
|
+
import { BaseTool } from "../base_tool.js";
|
|
23
|
+
const GOOGLE_API_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.googleApiTool");
|
|
24
|
+
function isGoogleApiTool(obj) {
|
|
25
|
+
return typeof obj === "object" && obj !== null && GOOGLE_API_TOOL_SIGNATURE_SYMBOL in obj && obj[GOOGLE_API_TOOL_SIGNATURE_SYMBOL] === true;
|
|
26
|
+
}
|
|
27
|
+
__name(isGoogleApiTool, "isGoogleApiTool");
|
|
28
|
+
let GoogleApiTool = class extends (_b = BaseTool, _a = GOOGLE_API_TOOL_SIGNATURE_SYMBOL, _b) {
|
|
29
|
+
constructor(restApiTool) {
|
|
30
|
+
super({
|
|
31
|
+
name: restApiTool.name,
|
|
32
|
+
description: restApiTool.description,
|
|
33
|
+
isLongRunning: restApiTool.isLongRunning
|
|
34
|
+
});
|
|
35
|
+
this[_a] = true;
|
|
36
|
+
this.restApiTool = restApiTool;
|
|
37
|
+
}
|
|
38
|
+
_getDeclaration() {
|
|
39
|
+
return this.restApiTool._getDeclaration();
|
|
40
|
+
}
|
|
41
|
+
runAsync(request) {
|
|
42
|
+
return this.restApiTool.runAsync(request);
|
|
43
|
+
}
|
|
44
|
+
configureAuth(clientId, clientSecret) {
|
|
45
|
+
this.restApiTool.configureAuthCredential({
|
|
46
|
+
authType: AuthCredentialTypes.OPEN_ID_CONNECT,
|
|
47
|
+
oauth2: {
|
|
48
|
+
clientId,
|
|
49
|
+
clientSecret
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
__name(GoogleApiTool, "GoogleApiTool");
|
|
55
|
+
__decorateClass([
|
|
56
|
+
experimental
|
|
57
|
+
], GoogleApiTool.prototype, "_getDeclaration", 1);
|
|
58
|
+
__decorateClass([
|
|
59
|
+
experimental
|
|
60
|
+
], GoogleApiTool.prototype, "runAsync", 1);
|
|
61
|
+
__decorateClass([
|
|
62
|
+
experimental
|
|
63
|
+
], GoogleApiTool.prototype, "configureAuth", 1);
|
|
64
|
+
GoogleApiTool = __decorateClass([
|
|
65
|
+
experimental
|
|
66
|
+
], GoogleApiTool);
|
|
67
|
+
export {
|
|
68
|
+
GoogleApiTool,
|
|
69
|
+
isGoogleApiTool
|
|
70
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
7
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
8
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
+
if (decorator = decorators[i])
|
|
10
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
11
|
+
if (kind && result) __defProp(target, key, result);
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2026 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
*/
|
|
19
|
+
var _a, _b;
|
|
20
|
+
import * as fs from "node:fs";
|
|
21
|
+
import * as path from "node:path";
|
|
22
|
+
import { experimental } from "../../utils/experimental.js";
|
|
23
|
+
import { BaseToolset } from "../base_toolset.js";
|
|
24
|
+
import { OpenAPIToolset } from "../openapi_tool/openapi_toolset.js";
|
|
25
|
+
import { GoogleApiTool, isGoogleApiTool } from "./google_api_tool.js";
|
|
26
|
+
import { GoogleApiToOpenApiConverter } from "./googleapi_to_openapi_converter.js";
|
|
27
|
+
const GOOGLE_API_TOOL_SET_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
28
|
+
"google.adk.googleApiToolSet"
|
|
29
|
+
);
|
|
30
|
+
const GOOGLE_OIDC_AUTH_ENDPOINT = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
31
|
+
const GOOGLE_OIDC_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token";
|
|
32
|
+
const GOOGLE_OIDC_USERINFO_ENDPOINT = "https://openidconnect.googleapis.com/v1/userinfo";
|
|
33
|
+
const GOOGLE_OIDC_REVOCATION_ENDPOINT = "https://oauth2.googleapis.com/revoke";
|
|
34
|
+
function isGoogleApiToolSet(obj) {
|
|
35
|
+
return typeof obj === "object" && obj !== null && GOOGLE_API_TOOL_SET_SIGNATURE_SYMBOL in obj && obj[GOOGLE_API_TOOL_SET_SIGNATURE_SYMBOL] === true;
|
|
36
|
+
}
|
|
37
|
+
__name(isGoogleApiToolSet, "isGoogleApiToolSet");
|
|
38
|
+
let GoogleApiToolSet = class extends (_b = BaseToolset, _a = GOOGLE_API_TOOL_SET_SIGNATURE_SYMBOL, _b) {
|
|
39
|
+
constructor(tools, options = {}) {
|
|
40
|
+
var _a2;
|
|
41
|
+
super((_a2 = options.toolFilter) != null ? _a2 : []);
|
|
42
|
+
this[_a] = true;
|
|
43
|
+
this.apiName = options.apiName;
|
|
44
|
+
this.apiVersion = options.apiVersion;
|
|
45
|
+
if (tools !== void 0) {
|
|
46
|
+
this.tools = tools.map(
|
|
47
|
+
(tool) => isGoogleApiTool(tool) ? tool : new GoogleApiTool(tool)
|
|
48
|
+
);
|
|
49
|
+
this.toolsLoaded = true;
|
|
50
|
+
} else {
|
|
51
|
+
this.tools = [];
|
|
52
|
+
this.toolsLoaded = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async ensureToolsLoaded() {
|
|
56
|
+
if (this.toolsLoaded || !this.apiName || !this.apiVersion) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!this.loadingPromise) {
|
|
60
|
+
const apiName = this.apiName;
|
|
61
|
+
const apiVersion = this.apiVersion;
|
|
62
|
+
this.loadingPromise = (async () => {
|
|
63
|
+
try {
|
|
64
|
+
const loaded = await GoogleApiToolSet.loadToolSet(
|
|
65
|
+
apiName,
|
|
66
|
+
apiVersion
|
|
67
|
+
);
|
|
68
|
+
this.tools = loaded.tools;
|
|
69
|
+
if (this.pendingAuth) {
|
|
70
|
+
for (const tool of this.tools) {
|
|
71
|
+
tool.configureAuth(
|
|
72
|
+
this.pendingAuth.clientId,
|
|
73
|
+
this.pendingAuth.clientSecret
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this.toolsLoaded = true;
|
|
78
|
+
} finally {
|
|
79
|
+
this.loadingPromise = void 0;
|
|
80
|
+
}
|
|
81
|
+
})();
|
|
82
|
+
}
|
|
83
|
+
await this.loadingPromise;
|
|
84
|
+
}
|
|
85
|
+
async getTools(context) {
|
|
86
|
+
await this.ensureToolsLoaded();
|
|
87
|
+
return this.tools.filter(
|
|
88
|
+
(tool) => this.isToolSelected(tool, context)
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
async getTool(toolName) {
|
|
92
|
+
await this.ensureToolsLoaded();
|
|
93
|
+
return this.tools.find((tool) => tool.name === toolName);
|
|
94
|
+
}
|
|
95
|
+
configureAuth(clientId, clientSecret) {
|
|
96
|
+
this.pendingAuth = { clientId, clientSecret };
|
|
97
|
+
for (const tool of this.tools) {
|
|
98
|
+
tool.configureAuth(clientId, clientSecret);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async close() {
|
|
102
|
+
return Promise.resolve();
|
|
103
|
+
}
|
|
104
|
+
static loadToolSetWithOidcAuth(options = {}) {
|
|
105
|
+
var _a2;
|
|
106
|
+
let specStr;
|
|
107
|
+
if (options.specFile) {
|
|
108
|
+
const dir = (_a2 = options.callerDir) != null ? _a2 : process.cwd();
|
|
109
|
+
const yamlPath = path.isAbsolute(options.specFile) ? options.specFile : path.join(dir, options.specFile);
|
|
110
|
+
specStr = fs.readFileSync(yamlPath, "utf-8");
|
|
111
|
+
}
|
|
112
|
+
const authScheme = {
|
|
113
|
+
type: "openIdConnect",
|
|
114
|
+
openIdConnectUrl: "",
|
|
115
|
+
authorizationEndpoint: GOOGLE_OIDC_AUTH_ENDPOINT,
|
|
116
|
+
tokenEndpoint: GOOGLE_OIDC_TOKEN_ENDPOINT,
|
|
117
|
+
userinfoEndpoint: GOOGLE_OIDC_USERINFO_ENDPOINT,
|
|
118
|
+
revocationEndpoint: GOOGLE_OIDC_REVOCATION_ENDPOINT,
|
|
119
|
+
tokenEndpointAuthMethodsSupported: [
|
|
120
|
+
"client_secret_post",
|
|
121
|
+
"client_secret_basic"
|
|
122
|
+
],
|
|
123
|
+
grantTypesSupported: ["authorization_code"],
|
|
124
|
+
scopes: options.scopes
|
|
125
|
+
};
|
|
126
|
+
return new OpenAPIToolset({
|
|
127
|
+
specDict: options.specDict,
|
|
128
|
+
specStr,
|
|
129
|
+
specType: "yaml",
|
|
130
|
+
authScheme
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
static async loadToolSet(apiName, apiVersion) {
|
|
134
|
+
var _a2, _b2, _c, _d, _e;
|
|
135
|
+
const specDict = await new GoogleApiToOpenApiConverter(
|
|
136
|
+
apiName,
|
|
137
|
+
apiVersion
|
|
138
|
+
).convert();
|
|
139
|
+
const oauth2Scheme = (_b2 = (_a2 = specDict.components) == null ? void 0 : _a2.securitySchemes) == null ? void 0 : _b2["oauth2"];
|
|
140
|
+
const scopesMap = (_e = (_d = (_c = oauth2Scheme == null ? void 0 : oauth2Scheme.flows) == null ? void 0 : _c.authorizationCode) == null ? void 0 : _d.scopes) != null ? _e : {};
|
|
141
|
+
const firstScope = Object.keys(scopesMap)[0];
|
|
142
|
+
const scopes = firstScope ? [firstScope] : void 0;
|
|
143
|
+
const openapiToolset = this.loadToolSetWithOidcAuth({
|
|
144
|
+
specDict,
|
|
145
|
+
scopes
|
|
146
|
+
});
|
|
147
|
+
const tools = await openapiToolset.getTools();
|
|
148
|
+
return new this(tools, { apiName, apiVersion });
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
__name(GoogleApiToolSet, "GoogleApiToolSet");
|
|
152
|
+
__decorateClass([
|
|
153
|
+
experimental
|
|
154
|
+
], GoogleApiToolSet.prototype, "getTools", 1);
|
|
155
|
+
__decorateClass([
|
|
156
|
+
experimental
|
|
157
|
+
], GoogleApiToolSet.prototype, "getTool", 1);
|
|
158
|
+
__decorateClass([
|
|
159
|
+
experimental
|
|
160
|
+
], GoogleApiToolSet.prototype, "configureAuth", 1);
|
|
161
|
+
__decorateClass([
|
|
162
|
+
experimental
|
|
163
|
+
], GoogleApiToolSet.prototype, "close", 1);
|
|
164
|
+
__decorateClass([
|
|
165
|
+
experimental
|
|
166
|
+
], GoogleApiToolSet, "loadToolSetWithOidcAuth", 1);
|
|
167
|
+
__decorateClass([
|
|
168
|
+
experimental
|
|
169
|
+
], GoogleApiToolSet, "loadToolSet", 1);
|
|
170
|
+
GoogleApiToolSet = __decorateClass([
|
|
171
|
+
experimental
|
|
172
|
+
], GoogleApiToolSet);
|
|
173
|
+
function createLazyGoogleApiToolSet(apiName, apiVersion) {
|
|
174
|
+
const BaseConstructor = Object.getPrototypeOf(
|
|
175
|
+
GoogleApiToolSet
|
|
176
|
+
);
|
|
177
|
+
return Reflect.construct(
|
|
178
|
+
BaseConstructor,
|
|
179
|
+
[void 0, { apiName, apiVersion }],
|
|
180
|
+
GoogleApiToolSet
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
__name(createLazyGoogleApiToolSet, "createLazyGoogleApiToolSet");
|
|
184
|
+
export {
|
|
185
|
+
GoogleApiToolSet,
|
|
186
|
+
createLazyGoogleApiToolSet,
|
|
187
|
+
isGoogleApiToolSet
|
|
188
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
/**
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2026 Google LLC
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
import { createLazyGoogleApiToolSet } from "./google_api_tool_set.js";
|
|
9
|
+
const calendarToolSet = createLazyGoogleApiToolSet("calendar", "v3");
|
|
10
|
+
const bigqueryToolSet = createLazyGoogleApiToolSet("bigquery", "v2");
|
|
11
|
+
const gmailToolSet = createLazyGoogleApiToolSet("gmail", "v1");
|
|
12
|
+
const youtubeToolSet = createLazyGoogleApiToolSet("youtube", "v3");
|
|
13
|
+
const slidesToolSet = createLazyGoogleApiToolSet("slides", "v1");
|
|
14
|
+
const sheetsToolSet = createLazyGoogleApiToolSet("sheets", "v4");
|
|
15
|
+
const docsToolSet = createLazyGoogleApiToolSet("docs", "v1");
|
|
16
|
+
export {
|
|
17
|
+
bigqueryToolSet,
|
|
18
|
+
calendarToolSet,
|
|
19
|
+
docsToolSet,
|
|
20
|
+
gmailToolSet,
|
|
21
|
+
sheetsToolSet,
|
|
22
|
+
slidesToolSet,
|
|
23
|
+
youtubeToolSet
|
|
24
|
+
};
|