@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
|
@@ -0,0 +1,215 @@
|
|
|
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
|
+
import { experimental } from "../../../utils/experimental.js";
|
|
20
|
+
import { isJsonObject } from "../../../utils/json_utils.js";
|
|
21
|
+
import {
|
|
22
|
+
CloudPlatformTokenSource,
|
|
23
|
+
sendCloudRequest,
|
|
24
|
+
unexpectedError
|
|
25
|
+
} from "./cloud_request.js";
|
|
26
|
+
import {
|
|
27
|
+
actionRequest,
|
|
28
|
+
actionResponse,
|
|
29
|
+
ConnectionsClient,
|
|
30
|
+
CONNECTOR_BASE_SPEC,
|
|
31
|
+
connectorPayload,
|
|
32
|
+
createOperation,
|
|
33
|
+
createOperationRequest,
|
|
34
|
+
deleteOperation,
|
|
35
|
+
deleteOperationRequest,
|
|
36
|
+
executeCustomQueryRequest,
|
|
37
|
+
getActionOperation,
|
|
38
|
+
getOperation,
|
|
39
|
+
getOperationRequest,
|
|
40
|
+
listOperation,
|
|
41
|
+
listOperationRequest,
|
|
42
|
+
updateOperation,
|
|
43
|
+
updateOperationRequest
|
|
44
|
+
} from "./connections_client.js";
|
|
45
|
+
const EXECUTE_CONNECTION_INTEGRATION = "ExecuteConnection";
|
|
46
|
+
const EXECUTE_CUSTOM_QUERY_ACTION = "ExecuteCustomQuery";
|
|
47
|
+
let IntegrationClient = class {
|
|
48
|
+
constructor(options) {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
this.project = options.project;
|
|
51
|
+
this.location = options.location;
|
|
52
|
+
this.integration = options.integration;
|
|
53
|
+
this.trigger = options.trigger;
|
|
54
|
+
this.connection = options.connection;
|
|
55
|
+
this.entityOperations = (_a = options.entityOperations) != null ? _a : {};
|
|
56
|
+
this.actions = (_b = options.actions) != null ? _b : [];
|
|
57
|
+
this.serviceAccountJson = options.serviceAccountJson;
|
|
58
|
+
this.tokenSource = new CloudPlatformTokenSource(options.serviceAccountJson);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fetches the OpenAPI spec Application Integration generates for the API
|
|
62
|
+
* trigger of the integration.
|
|
63
|
+
*
|
|
64
|
+
* @throws Error For a rejected request, a missing credential, or a response
|
|
65
|
+
* that carries no parseable spec.
|
|
66
|
+
*/
|
|
67
|
+
async getOpenApiSpecForIntegration() {
|
|
68
|
+
const url = `https://${this.location}-integrations.googleapis.com/v1/projects/${this.project}/locations/${this.location}:generateOpenApiSpec`;
|
|
69
|
+
const body = await sendCloudRequest({
|
|
70
|
+
url,
|
|
71
|
+
method: "POST",
|
|
72
|
+
body: {
|
|
73
|
+
apiTriggerResources: [
|
|
74
|
+
{
|
|
75
|
+
integrationResource: this.integration,
|
|
76
|
+
triggerId: [this.trigger]
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
fileFormat: "JSON"
|
|
80
|
+
},
|
|
81
|
+
tokenSource: this.tokenSource,
|
|
82
|
+
invalidRequestMessage: `Invalid request. Please check the provided values of project(${this.project}), location(${this.location}), integration(${this.integration}) and trigger(${this.trigger}).`
|
|
83
|
+
});
|
|
84
|
+
try {
|
|
85
|
+
const spec = isJsonObject(body) ? body["openApiSpec"] : void 0;
|
|
86
|
+
if (typeof spec !== "string") {
|
|
87
|
+
throw new Error("The response carries no openApiSpec string.");
|
|
88
|
+
}
|
|
89
|
+
const parsed = JSON.parse(spec);
|
|
90
|
+
if (!isJsonObject(parsed)) {
|
|
91
|
+
throw new Error("The openApiSpec is not a JSON object.");
|
|
92
|
+
}
|
|
93
|
+
return parsed;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
throw unexpectedError(e);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Builds an OpenAPI spec for the entity operations and actions of the
|
|
100
|
+
* connection.
|
|
101
|
+
*
|
|
102
|
+
* Every operation becomes a POST to the `ExecuteConnection` integration,
|
|
103
|
+
* with a path fragment that keeps the paths distinct.
|
|
104
|
+
*
|
|
105
|
+
* @param toolName Prefix of every generated `operationId`.
|
|
106
|
+
* @param toolInstructions Text appended to every operation description.
|
|
107
|
+
* @throws Error When neither entity operations nor actions are configured,
|
|
108
|
+
* or an operation is not one of create, update, delete, list or get.
|
|
109
|
+
*/
|
|
110
|
+
async getOpenApiSpecForConnection(toolName = "", toolInstructions = "") {
|
|
111
|
+
var _a;
|
|
112
|
+
if (Object.keys(this.entityOperations).length === 0 && this.actions.length === 0) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
"No entity operations or actions provided. Please provide at least one of them."
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
const connectionsClient = new ConnectionsClient({
|
|
118
|
+
project: this.project,
|
|
119
|
+
location: this.location,
|
|
120
|
+
connection: (_a = this.connection) != null ? _a : "",
|
|
121
|
+
serviceAccountJson: this.serviceAccountJson
|
|
122
|
+
});
|
|
123
|
+
const connectorSpec = structuredClone(CONNECTOR_BASE_SPEC);
|
|
124
|
+
const schemas = connectorSpec.components.schemas;
|
|
125
|
+
const pathPrefix = `/v2/projects/${this.project}/locations/${this.location}/integrations/${EXECUTE_CONNECTION_INTEGRATION}:execute?triggerId=api_trigger/${EXECUTE_CONNECTION_INTEGRATION}`;
|
|
126
|
+
for (const [entity, requestedOperations] of Object.entries(
|
|
127
|
+
this.entityOperations
|
|
128
|
+
)) {
|
|
129
|
+
const { schema, operations: supportedOperations } = await connectionsClient.getEntitySchemaAndOperations(entity);
|
|
130
|
+
const operations = requestedOperations.length > 0 ? requestedOperations : supportedOperations;
|
|
131
|
+
const schemaAsString = JSON.stringify(schema);
|
|
132
|
+
schemas[`connectorInputPayload_${entity}`] = connectorPayload(schema);
|
|
133
|
+
for (const operation of operations) {
|
|
134
|
+
const operationLower = operation.toLowerCase();
|
|
135
|
+
const path = `${pathPrefix}#${operationLower}_${entity}`;
|
|
136
|
+
switch (operationLower) {
|
|
137
|
+
case "create":
|
|
138
|
+
connectorSpec.paths[path] = createOperation({
|
|
139
|
+
entity,
|
|
140
|
+
toolName,
|
|
141
|
+
toolInstructions
|
|
142
|
+
});
|
|
143
|
+
schemas[`create_${entity}_Request`] = createOperationRequest(entity);
|
|
144
|
+
break;
|
|
145
|
+
case "update":
|
|
146
|
+
connectorSpec.paths[path] = updateOperation({
|
|
147
|
+
entity,
|
|
148
|
+
toolName,
|
|
149
|
+
toolInstructions
|
|
150
|
+
});
|
|
151
|
+
schemas[`update_${entity}_Request`] = updateOperationRequest(entity);
|
|
152
|
+
break;
|
|
153
|
+
case "delete":
|
|
154
|
+
connectorSpec.paths[path] = deleteOperation({
|
|
155
|
+
entity,
|
|
156
|
+
toolName,
|
|
157
|
+
toolInstructions
|
|
158
|
+
});
|
|
159
|
+
schemas[`delete_${entity}_Request`] = deleteOperationRequest();
|
|
160
|
+
break;
|
|
161
|
+
case "list":
|
|
162
|
+
connectorSpec.paths[path] = listOperation({
|
|
163
|
+
entity,
|
|
164
|
+
schemaAsString,
|
|
165
|
+
toolName,
|
|
166
|
+
toolInstructions
|
|
167
|
+
});
|
|
168
|
+
schemas[`list_${entity}_Request`] = listOperationRequest();
|
|
169
|
+
break;
|
|
170
|
+
case "get":
|
|
171
|
+
connectorSpec.paths[path] = getOperation({
|
|
172
|
+
entity,
|
|
173
|
+
schemaAsString,
|
|
174
|
+
toolName,
|
|
175
|
+
toolInstructions
|
|
176
|
+
});
|
|
177
|
+
schemas[`get_${entity}_Request`] = getOperationRequest();
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
throw new Error(
|
|
181
|
+
`Invalid operation: ${operation} for entity: ${entity}`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for (const action of this.actions) {
|
|
187
|
+
const { inputSchema, outputSchema, displayName } = await connectionsClient.getActionSchema(action);
|
|
188
|
+
let operation = "EXECUTE_ACTION";
|
|
189
|
+
if (action === EXECUTE_CUSTOM_QUERY_ACTION) {
|
|
190
|
+
schemas[`${action}_Request`] = executeCustomQueryRequest();
|
|
191
|
+
operation = "EXECUTE_QUERY";
|
|
192
|
+
} else {
|
|
193
|
+
schemas[`${displayName}_Request`] = actionRequest(displayName);
|
|
194
|
+
schemas[`connectorInputPayload_${displayName}`] = connectorPayload(inputSchema);
|
|
195
|
+
}
|
|
196
|
+
schemas[`connectorOutputPayload_${displayName}`] = connectorPayload(outputSchema);
|
|
197
|
+
schemas[`${displayName}_Response`] = actionResponse(displayName);
|
|
198
|
+
connectorSpec.paths[`${pathPrefix}#${action}`] = getActionOperation({
|
|
199
|
+
action,
|
|
200
|
+
operation,
|
|
201
|
+
actionDisplayName: displayName,
|
|
202
|
+
toolName,
|
|
203
|
+
toolInstructions
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return connectorSpec;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
__name(IntegrationClient, "IntegrationClient");
|
|
210
|
+
IntegrationClient = __decorateClass([
|
|
211
|
+
experimental
|
|
212
|
+
], IntegrationClient);
|
|
213
|
+
export {
|
|
214
|
+
IntegrationClient
|
|
215
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
var _a, _b;
|
|
11
|
+
import { toJsonSchema } from "../utils/schema.js";
|
|
12
|
+
import { isZodObject, isZodSchema } from "../utils/simple_zod_to_json.js";
|
|
13
|
+
import { GoogleLLMVariant } from "../utils/variant_utils.js";
|
|
14
|
+
import {
|
|
15
|
+
buildFunctionDeclarationForParamsForCrewai,
|
|
16
|
+
FunctionTool
|
|
17
|
+
} from "./function_tool.js";
|
|
18
|
+
const CREWAI_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.crewaiTool");
|
|
19
|
+
function isCrewaiTool(obj) {
|
|
20
|
+
return typeof obj === "object" && obj !== null && CREWAI_TOOL_SIGNATURE_SYMBOL in obj && obj[CREWAI_TOOL_SIGNATURE_SYMBOL] === true;
|
|
21
|
+
}
|
|
22
|
+
__name(isCrewaiTool, "isCrewaiTool");
|
|
23
|
+
function isCrewaiToolConfig(value) {
|
|
24
|
+
return typeof value === "object" && value !== null && "tool" in value && typeof value.tool === "object" && value.tool !== null && typeof value.tool.run === "function";
|
|
25
|
+
}
|
|
26
|
+
__name(isCrewaiToolConfig, "isCrewaiToolConfig");
|
|
27
|
+
function normalizeCrewaiSchemaJson(argsSchema) {
|
|
28
|
+
if (!argsSchema) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
if (typeof argsSchema.modelJsonSchema === "function") {
|
|
32
|
+
return argsSchema.modelJsonSchema();
|
|
33
|
+
}
|
|
34
|
+
if (typeof argsSchema.jsonSchema === "function") {
|
|
35
|
+
return argsSchema.jsonSchema();
|
|
36
|
+
}
|
|
37
|
+
if (isZodSchema(argsSchema)) {
|
|
38
|
+
const raw = structuredClone(toJsonSchema(argsSchema));
|
|
39
|
+
const requiredSet = new Set(
|
|
40
|
+
Array.isArray(raw["required"]) ? raw["required"] : []
|
|
41
|
+
);
|
|
42
|
+
const properties = raw["properties"];
|
|
43
|
+
if (properties && typeof properties === "object") {
|
|
44
|
+
for (const [key, prop] of Object.entries(properties)) {
|
|
45
|
+
if (!prop || typeof prop !== "object") {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(prop["type"])) {
|
|
49
|
+
const types = prop["type"];
|
|
50
|
+
delete prop["type"];
|
|
51
|
+
prop["anyOf"] = types.map((t) => ({ type: t }));
|
|
52
|
+
} else if (!requiredSet.has(key) && !("default" in prop) && !("anyOf" in prop) && typeof prop["type"] === "string") {
|
|
53
|
+
const propType = prop["type"];
|
|
54
|
+
delete prop["type"];
|
|
55
|
+
prop["anyOf"] = [{ type: propType }, { type: "null" }];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return raw;
|
|
60
|
+
}
|
|
61
|
+
return structuredClone(argsSchema);
|
|
62
|
+
}
|
|
63
|
+
__name(normalizeCrewaiSchemaJson, "normalizeCrewaiSchemaJson");
|
|
64
|
+
const _CrewaiTool = class _CrewaiTool extends (_b = FunctionTool, _a = CREWAI_TOOL_SIGNATURE_SYMBOL, _b) {
|
|
65
|
+
constructor(toolOrConfig, options) {
|
|
66
|
+
const config = isCrewaiToolConfig(toolOrConfig) ? toolOrConfig : {
|
|
67
|
+
tool: toolOrConfig,
|
|
68
|
+
name: options == null ? void 0 : options.name,
|
|
69
|
+
description: options == null ? void 0 : options.description
|
|
70
|
+
};
|
|
71
|
+
const resolvedName = config.name || (config.tool.name ? config.tool.name.replace(/ /g, "_").toLowerCase() : config.tool.run.name || "crewai_tool");
|
|
72
|
+
const resolvedDescription = config.description || config.tool.description || "";
|
|
73
|
+
super({
|
|
74
|
+
name: resolvedName,
|
|
75
|
+
description: resolvedDescription,
|
|
76
|
+
parameters: isZodObject(config.tool.argsSchema) ? config.tool.argsSchema : void 0,
|
|
77
|
+
execute: /* @__PURE__ */ __name(async (args, toolContext) => {
|
|
78
|
+
return await config.tool.run(
|
|
79
|
+
args != null ? args : {},
|
|
80
|
+
toolContext
|
|
81
|
+
);
|
|
82
|
+
}, "execute")
|
|
83
|
+
});
|
|
84
|
+
/** A unique symbol to identify ADK CrewaiTool class. */
|
|
85
|
+
this[_a] = true;
|
|
86
|
+
this.tool = config.tool;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Builds the `FunctionDeclaration` for the wrapped CrewAI tool.
|
|
90
|
+
*/
|
|
91
|
+
_getDeclaration() {
|
|
92
|
+
const schemaJson = normalizeCrewaiSchemaJson(this.tool.argsSchema);
|
|
93
|
+
return buildFunctionDeclarationForParamsForCrewai(
|
|
94
|
+
this.apiVariant === GoogleLLMVariant.VERTEX_AI,
|
|
95
|
+
this.name,
|
|
96
|
+
this.description,
|
|
97
|
+
this.tool.run,
|
|
98
|
+
schemaJson
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
__name(_CrewaiTool, "CrewaiTool");
|
|
103
|
+
let CrewaiTool = _CrewaiTool;
|
|
104
|
+
export {
|
|
105
|
+
CrewaiTool,
|
|
106
|
+
isCrewaiTool
|
|
107
|
+
};
|
|
@@ -7,12 +7,21 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
7
7
|
* Copyright 2026 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
isBaseExampleProvider
|
|
12
|
+
} from "../examples/base_example_provider.js";
|
|
13
|
+
import { buildExampleSi, validateExamples } from "../examples/example_util.js";
|
|
11
14
|
import { appendInstructions } from "../models/llm_request.js";
|
|
12
15
|
import {
|
|
13
16
|
BaseTool
|
|
14
17
|
} from "./base_tool.js";
|
|
15
18
|
const _ExampleTool = class _ExampleTool extends BaseTool {
|
|
19
|
+
/**
|
|
20
|
+
* @param examples - A list of {@link Example}s, or a
|
|
21
|
+
* {@link BaseExampleProvider} that returns them for a query.
|
|
22
|
+
* @throws {InputValidationError} When `examples` is neither a
|
|
23
|
+
* {@link BaseExampleProvider} nor a list of well-formed examples.
|
|
24
|
+
*/
|
|
16
25
|
constructor(examples) {
|
|
17
26
|
super({
|
|
18
27
|
// Name and description are not used because this tool only changes
|
|
@@ -20,6 +29,9 @@ const _ExampleTool = class _ExampleTool extends BaseTool {
|
|
|
20
29
|
name: "example_tool",
|
|
21
30
|
description: "example tool"
|
|
22
31
|
});
|
|
32
|
+
if (!isBaseExampleProvider(examples)) {
|
|
33
|
+
validateExamples(examples);
|
|
34
|
+
}
|
|
23
35
|
this.examples = examples;
|
|
24
36
|
}
|
|
25
37
|
async runAsync(_request) {
|