@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,185 @@
|
|
|
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 __decorateClass = (decorators, target, key, kind) => {
|
|
27
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
28
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
29
|
+
if (decorator = decorators[i])
|
|
30
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
31
|
+
if (kind && result) __defProp(target, key, result);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
var application_integration_toolset_exports = {};
|
|
35
|
+
__export(application_integration_toolset_exports, {
|
|
36
|
+
ApplicationIntegrationToolset: () => ApplicationIntegrationToolset
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(application_integration_toolset_exports);
|
|
39
|
+
var import_auth_credential = require("../../auth/auth_credential.js");
|
|
40
|
+
var import_experimental = require("../../utils/experimental.js");
|
|
41
|
+
var import_json_utils = require("../../utils/json_utils.js");
|
|
42
|
+
var import_base_toolset = require("../base_toolset.js");
|
|
43
|
+
var import_auth_helpers = require("../openapi_tool/auth/auth_helpers.js");
|
|
44
|
+
var import_openapi_toolset = require("../openapi_tool/openapi_toolset.js");
|
|
45
|
+
var import_cloud_request = require("./clients/cloud_request.js");
|
|
46
|
+
var import_connections_client = require("./clients/connections_client.js");
|
|
47
|
+
var import_integration_client = require("./clients/integration_client.js");
|
|
48
|
+
/**
|
|
49
|
+
* @license
|
|
50
|
+
* Copyright 2026 Google LLC
|
|
51
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
52
|
+
*/
|
|
53
|
+
const AUTH_SCHEME = {
|
|
54
|
+
type: "http",
|
|
55
|
+
scheme: "bearer",
|
|
56
|
+
bearerFormat: "JWT"
|
|
57
|
+
};
|
|
58
|
+
let ApplicationIntegrationToolset = class extends import_base_toolset.BaseToolset {
|
|
59
|
+
/**
|
|
60
|
+
* @throws Error Unless the options name either an integration and a trigger,
|
|
61
|
+
* or a connection with at least one entity operation or action.
|
|
62
|
+
*/
|
|
63
|
+
constructor(options) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
super([]);
|
|
66
|
+
const hasIntegration = Boolean(options.integration && options.trigger);
|
|
67
|
+
const hasConnection = Boolean(
|
|
68
|
+
options.connection && (Object.keys((_a = options.entityOperations) != null ? _a : {}).length > 0 || ((_b = options.actions) != null ? _b : []).length > 0)
|
|
69
|
+
);
|
|
70
|
+
if (!hasIntegration && !hasConnection) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
"Either (integration and trigger) or (connection and (entityOperations or actions)) should be provided."
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
this.options = options;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the generated tools.
|
|
79
|
+
*
|
|
80
|
+
* The first call fetches the spec and builds the tools. Concurrent calls
|
|
81
|
+
* share that load. When it fails, the next call tries again.
|
|
82
|
+
*/
|
|
83
|
+
async getTools() {
|
|
84
|
+
if (!this.toolsPromise) {
|
|
85
|
+
this.toolsPromise = this.loadTools();
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
return await this.toolsPromise;
|
|
89
|
+
} catch (e) {
|
|
90
|
+
this.toolsPromise = void 0;
|
|
91
|
+
throw e;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async close() {
|
|
95
|
+
}
|
|
96
|
+
async loadTools() {
|
|
97
|
+
var _a;
|
|
98
|
+
const {
|
|
99
|
+
project,
|
|
100
|
+
location,
|
|
101
|
+
integration,
|
|
102
|
+
trigger,
|
|
103
|
+
connection,
|
|
104
|
+
entityOperations,
|
|
105
|
+
actions,
|
|
106
|
+
toolName = "",
|
|
107
|
+
toolInstructions = "",
|
|
108
|
+
serviceAccountJson
|
|
109
|
+
} = this.options;
|
|
110
|
+
const integrationClient = new import_integration_client.IntegrationClient({
|
|
111
|
+
project,
|
|
112
|
+
location,
|
|
113
|
+
integration,
|
|
114
|
+
trigger,
|
|
115
|
+
connection,
|
|
116
|
+
entityOperations,
|
|
117
|
+
actions,
|
|
118
|
+
serviceAccountJson
|
|
119
|
+
});
|
|
120
|
+
let specDict;
|
|
121
|
+
if (integration && trigger) {
|
|
122
|
+
specDict = await integrationClient.getOpenApiSpecForIntegration();
|
|
123
|
+
} else {
|
|
124
|
+
const connectionName = connection != null ? connection : "";
|
|
125
|
+
const { serviceName, host } = await new import_connections_client.ConnectionsClient({
|
|
126
|
+
project,
|
|
127
|
+
location,
|
|
128
|
+
connection: connectionName,
|
|
129
|
+
serviceAccountJson
|
|
130
|
+
}).getConnectionDetails();
|
|
131
|
+
const instructions = `${toolInstructions}ALWAYS use serviceName = ${serviceName}, host = ${host} and the connection name = projects/${project}/locations/${location}/connections/${connectionName} when using this tool. DO NOT ask the user for these values as you already have those.`;
|
|
132
|
+
specDict = await integrationClient.getOpenApiSpecForConnection(
|
|
133
|
+
toolName,
|
|
134
|
+
instructions
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
const spec = specDict;
|
|
138
|
+
const authCredential = buildAuthCredential(serviceAccountJson);
|
|
139
|
+
const toolsByName = /* @__PURE__ */ new Map();
|
|
140
|
+
for (const [path, pathItem] of Object.entries((_a = spec.paths) != null ? _a : {})) {
|
|
141
|
+
const tools = await new import_openapi_toolset.OpenAPIToolset({
|
|
142
|
+
specDict: { ...spec, paths: { [removeFragment(path)]: pathItem } },
|
|
143
|
+
authCredential,
|
|
144
|
+
authScheme: AUTH_SCHEME
|
|
145
|
+
}).getTools();
|
|
146
|
+
for (const tool of tools) {
|
|
147
|
+
toolsByName.set(tool.name, tool);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return [...toolsByName.values()];
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
__name(ApplicationIntegrationToolset, "ApplicationIntegrationToolset");
|
|
154
|
+
ApplicationIntegrationToolset = __decorateClass([
|
|
155
|
+
import_experimental.experimental
|
|
156
|
+
], ApplicationIntegrationToolset);
|
|
157
|
+
function buildAuthCredential(serviceAccountJson) {
|
|
158
|
+
if (!serviceAccountJson) {
|
|
159
|
+
return {
|
|
160
|
+
authType: import_auth_credential.AuthCredentialTypes.SERVICE_ACCOUNT,
|
|
161
|
+
serviceAccount: {
|
|
162
|
+
useDefaultCredential: true,
|
|
163
|
+
scopes: [import_cloud_request.CLOUD_PLATFORM_SCOPE]
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const key = JSON.parse(serviceAccountJson);
|
|
168
|
+
if (!(0, import_json_utils.isJsonObject)(key)) {
|
|
169
|
+
throw new Error("serviceAccountJson must hold a JSON object.");
|
|
170
|
+
}
|
|
171
|
+
const [, authCredential] = (0, import_auth_helpers.serviceAccountDictToSchemeCredential)(key, [
|
|
172
|
+
import_cloud_request.CLOUD_PLATFORM_SCOPE
|
|
173
|
+
]);
|
|
174
|
+
return authCredential;
|
|
175
|
+
}
|
|
176
|
+
__name(buildAuthCredential, "buildAuthCredential");
|
|
177
|
+
function removeFragment(path) {
|
|
178
|
+
const fragmentStart = path.indexOf("#");
|
|
179
|
+
return fragmentStart === -1 ? path : path.slice(0, fragmentStart);
|
|
180
|
+
}
|
|
181
|
+
__name(removeFragment, "removeFragment");
|
|
182
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
183
|
+
0 && (module.exports = {
|
|
184
|
+
ApplicationIntegrationToolset
|
|
185
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
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 cloud_request_exports = {};
|
|
27
|
+
__export(cloud_request_exports, {
|
|
28
|
+
CLOUD_PLATFORM_SCOPE: () => CLOUD_PLATFORM_SCOPE,
|
|
29
|
+
CloudPlatformTokenSource: () => CloudPlatformTokenSource,
|
|
30
|
+
sendCloudRequest: () => sendCloudRequest,
|
|
31
|
+
unexpectedError: () => unexpectedError
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(cloud_request_exports);
|
|
34
|
+
var import_google_auth_library = require("google-auth-library");
|
|
35
|
+
var import_error_utils = require("../../../utils/error_utils.js");
|
|
36
|
+
/**
|
|
37
|
+
* @license
|
|
38
|
+
* Copyright 2026 Google LLC
|
|
39
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
40
|
+
*/
|
|
41
|
+
const CLOUD_PLATFORM_SCOPE = "https://www.googleapis.com/auth/cloud-platform";
|
|
42
|
+
const MISSING_CREDENTIALS_MESSAGE = "Please provide a service account that has the required permissions to access the connection.";
|
|
43
|
+
function unexpectedError(e) {
|
|
44
|
+
return new Error(`An unexpected error occurred: ${(0, import_error_utils.getErrorMessage)(e)}`, {
|
|
45
|
+
cause: e
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
__name(unexpectedError, "unexpectedError");
|
|
49
|
+
const _CloudPlatformTokenSource = class _CloudPlatformTokenSource {
|
|
50
|
+
constructor(serviceAccountJson) {
|
|
51
|
+
this.serviceAccountJson = serviceAccountJson;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns an access token.
|
|
55
|
+
*
|
|
56
|
+
* @throws Error When no key is given and Application Default Credentials are
|
|
57
|
+
* unavailable, or when no token is issued.
|
|
58
|
+
*/
|
|
59
|
+
async getAccessToken() {
|
|
60
|
+
let token;
|
|
61
|
+
try {
|
|
62
|
+
token = await this.getAuth().getAccessToken();
|
|
63
|
+
} catch (e) {
|
|
64
|
+
if (this.serviceAccountJson) {
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
67
|
+
throw new Error(MISSING_CREDENTIALS_MESSAGE, { cause: e });
|
|
68
|
+
}
|
|
69
|
+
if (!token) {
|
|
70
|
+
throw new Error(MISSING_CREDENTIALS_MESSAGE);
|
|
71
|
+
}
|
|
72
|
+
return token;
|
|
73
|
+
}
|
|
74
|
+
getAuth() {
|
|
75
|
+
if (!this.auth) {
|
|
76
|
+
if (this.serviceAccountJson) {
|
|
77
|
+
const credentials = JSON.parse(this.serviceAccountJson);
|
|
78
|
+
this.auth = new import_google_auth_library.GoogleAuth({
|
|
79
|
+
scopes: [CLOUD_PLATFORM_SCOPE],
|
|
80
|
+
credentials
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
this.auth = new import_google_auth_library.GoogleAuth({ scopes: [CLOUD_PLATFORM_SCOPE] });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return this.auth;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
__name(_CloudPlatformTokenSource, "CloudPlatformTokenSource");
|
|
90
|
+
let CloudPlatformTokenSource = _CloudPlatformTokenSource;
|
|
91
|
+
async function sendCloudRequest(options) {
|
|
92
|
+
const { url, method, body, tokenSource, invalidRequestMessage } = options;
|
|
93
|
+
let token;
|
|
94
|
+
try {
|
|
95
|
+
token = await tokenSource.getAccessToken();
|
|
96
|
+
} catch (e) {
|
|
97
|
+
throw unexpectedError(e);
|
|
98
|
+
}
|
|
99
|
+
let response;
|
|
100
|
+
try {
|
|
101
|
+
response = await fetch(url, {
|
|
102
|
+
method,
|
|
103
|
+
headers: {
|
|
104
|
+
"Content-Type": "application/json",
|
|
105
|
+
"Authorization": `Bearer ${token}`
|
|
106
|
+
},
|
|
107
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
108
|
+
});
|
|
109
|
+
} catch (e) {
|
|
110
|
+
throw new Error(`Request error: ${(0, import_error_utils.getErrorMessage)(e)}`, { cause: e });
|
|
111
|
+
}
|
|
112
|
+
if (response.status === 400 || response.status === 404) {
|
|
113
|
+
throw new Error(invalidRequestMessage);
|
|
114
|
+
}
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
`Request error: HTTP ${response.status} ${response.statusText} for url: ${url}`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
return await response.json();
|
|
122
|
+
} catch (e) {
|
|
123
|
+
throw unexpectedError(e);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
__name(sendCloudRequest, "sendCloudRequest");
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
CLOUD_PLATFORM_SCOPE,
|
|
130
|
+
CloudPlatformTokenSource,
|
|
131
|
+
sendCloudRequest,
|
|
132
|
+
unexpectedError
|
|
133
|
+
});
|