@google/adk 2.2.1 → 2.4.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/agent_engine_client.js +172 -0
- package/dist/cjs/agents/base_agent.js +20 -4
- package/dist/cjs/agents/functions.js +227 -25
- package/dist/cjs/agents/instructions.js +6 -2
- 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 +194 -107
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/code_execution_request_processor.js +18 -6
- package/dist/cjs/agents/processors/content_processor_utils.js +38 -10
- package/dist/cjs/agents/processors/content_request_processor.js +34 -2
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +12 -3
- 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/code_executors/container_code_executor.js +27 -16
- package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/cjs/common.js +61 -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/errors/input_validation_error.js +3 -2
- 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 +104 -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/base_plugin.js +13 -23
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +105 -33
- package/dist/cjs/sessions/base_session_service.js +14 -8
- package/dist/cjs/sessions/database_session_service.js +50 -28
- package/dist/cjs/sessions/db/operations.js +1 -1
- package/dist/cjs/sessions/in_memory_session_service.js +3 -1
- package/dist/cjs/sessions/stale_session_error.js +59 -0
- package/dist/cjs/sessions/state.js +8 -4
- package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
- package/dist/cjs/skills/loader.js +52 -18
- package/dist/cjs/telemetry/setup.js +0 -1
- package/dist/cjs/telemetry/tracing.js +147 -73
- package/dist/cjs/tools/agent_tool.js +44 -0
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +137 -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 +263 -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 +671 -0
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +223 -0
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +184 -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 +100 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +173 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
- package/dist/cjs/tools/google_api_tool/index.js +61 -0
- package/dist/cjs/tools/load_artifacts_tool.js +12 -6
- package/dist/cjs/tools/load_memory_tool.js +12 -10
- package/dist/cjs/tools/mcp/index.js +12 -0
- package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/cjs/tools/mcp/mcp_toolset.js +1 -14
- 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 +4 -3
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
- package/dist/cjs/tools/toolbox_toolset.js +174 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/cjs/utils/client_labels.js +19 -2
- package/dist/cjs/utils/env_aware_utils.js +6 -8
- package/dist/cjs/utils/error_utils.js +11 -11
- package/dist/cjs/utils/failover_utils.js +1 -1
- 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 +28 -7
- 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 +11 -1
- package/dist/cjs/utils/object_notation_utils.js +6 -3
- package/dist/cjs/utils/output_schema_utils.js +5 -2
- package/dist/cjs/utils/streaming_utils.js +12 -12
- package/dist/cjs/utils/task.js +1 -1
- 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/agent_engine_client.js +144 -0
- package/dist/esm/agents/base_agent.js +20 -4
- package/dist/esm/agents/functions.js +226 -25
- package/dist/esm/agents/instructions.js +6 -2
- 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 +204 -110
- package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/code_execution_request_processor.js +21 -8
- package/dist/esm/agents/processors/content_processor_utils.js +38 -10
- package/dist/esm/agents/processors/content_request_processor.js +34 -2
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +12 -3
- 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/code_executors/container_code_executor.js +27 -16
- package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/esm/common.js +65 -4
- package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
- package/dist/esm/context/token_based_context_compactor.js +2 -1
- package/dist/esm/errors/input_validation_error.js +3 -2
- 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 +114 -2
- 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/base_plugin.js +13 -23
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +105 -33
- package/dist/esm/sessions/base_session_service.js +12 -7
- package/dist/esm/sessions/database_session_service.js +49 -28
- package/dist/esm/sessions/db/operations.js +1 -1
- package/dist/esm/sessions/in_memory_session_service.js +3 -1
- package/dist/esm/sessions/stale_session_error.js +31 -0
- package/dist/esm/sessions/state.js +8 -4
- package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
- package/dist/esm/skills/loader.js +51 -17
- package/dist/esm/telemetry/setup.js +1 -2
- package/dist/esm/telemetry/tracing.js +151 -74
- package/dist/esm/tools/agent_tool.js +44 -0
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +101 -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 +245 -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 +629 -0
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +219 -0
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +158 -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 +73 -0
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +146 -0
- package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
- package/dist/esm/tools/google_api_tool/index.js +31 -0
- package/dist/esm/tools/load_artifacts_tool.js +10 -5
- package/dist/esm/tools/load_memory_tool.js +12 -10
- package/dist/esm/tools/mcp/index.js +6 -0
- package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +1 -14
- 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 +4 -3
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
- package/dist/esm/tools/toolbox_toolset.js +148 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/esm/utils/client_labels.js +19 -2
- package/dist/esm/utils/env_aware_utils.js +6 -8
- package/dist/esm/utils/error_utils.js +9 -10
- package/dist/esm/utils/failover_utils.js +1 -1
- 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 +27 -7
- 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 +11 -1
- package/dist/esm/utils/object_notation_utils.js +4 -2
- package/dist/esm/utils/output_schema_utils.js +5 -2
- package/dist/esm/utils/streaming_utils.js +11 -11
- package/dist/esm/utils/task.js +1 -1
- 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/agent_engine_client.d.ts +37 -0
- package/dist/types/agents/base_agent.d.ts +12 -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/llm_agent.d.ts +5 -1
- package/dist/types/agents/processors/content_processor_utils.d.ts +4 -2
- package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
- 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/code_executors/container_code_executor.d.ts +17 -5
- package/dist/types/common.d.ts +24 -5
- package/dist/types/errors/input_validation_error.d.ts +2 -1
- 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 +19 -2
- 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/base_plugin.d.ts +0 -10
- package/dist/types/runner/in_memory_runner.d.ts +2 -1
- package/dist/types/runner/runner.d.ts +34 -0
- package/dist/types/sessions/base_session_service.d.ts +5 -0
- package/dist/types/sessions/database_session_service.d.ts +17 -1
- package/dist/types/sessions/stale_session_error.d.ts +21 -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/loader.d.ts +3 -2
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +20 -4
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +115 -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 +109 -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 +229 -0
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
- package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
- package/dist/types/tools/base_toolset.d.ts +6 -5
- 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 +37 -0
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +55 -0
- package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +165 -0
- package/dist/types/tools/google_api_tool/index.d.ts +10 -0
- package/dist/types/tools/load_artifacts_tool.d.ts +14 -1
- package/dist/types/tools/load_memory_tool.d.ts +23 -1
- 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/openapi_spec_parser.d.ts +12 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +8 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
- package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
- package/dist/types/tools/toolbox_toolset.d.ts +159 -0
- package/dist/types/utils/client_labels.d.ts +2 -1
- 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 +9 -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/output_schema_utils.d.ts +3 -2
- package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
- package/dist/types/utils/streaming_utils.d.ts +11 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +117 -110
- package/dist/web/index_web.js.map +4 -4
- package/package.json +38 -26
- 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
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* constructs of the framework that are not observable by the SDK.
|
|
15
15
|
*/
|
|
16
16
|
import { Content } from '@google/genai';
|
|
17
|
-
import { Context } from '@opentelemetry/api';
|
|
17
|
+
import { Context, Span } from '@opentelemetry/api';
|
|
18
18
|
import { BaseAgent } from '../agents/base_agent.js';
|
|
19
19
|
import { InvocationContext } from '../agents/invocation_context.js';
|
|
20
20
|
import { Event } from '../events/event.js';
|
|
@@ -62,17 +62,33 @@ export declare function traceNodeExecution({ nodePath, runId, attempt, status, i
|
|
|
62
62
|
export interface TraceToolCallParams {
|
|
63
63
|
tool: BaseTool;
|
|
64
64
|
args: Record<string, unknown>;
|
|
65
|
-
functionResponseEvent
|
|
65
|
+
functionResponseEvent?: Event;
|
|
66
|
+
/** The exception raised while executing the tool, if any. */
|
|
67
|
+
error?: unknown;
|
|
68
|
+
/** An error type reported by a tool response instead of a thrown error. */
|
|
69
|
+
errorType?: string;
|
|
70
|
+
/** The tool execution span. Defaults to the active span when omitted. */
|
|
71
|
+
span?: Span;
|
|
72
|
+
invocationContext: InvocationContext;
|
|
66
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Resolves a stable error classification suitable for the OpenTelemetry
|
|
76
|
+
* `error.type` attribute without using the potentially sensitive error message.
|
|
77
|
+
*
|
|
78
|
+
* @param error The thrown value.
|
|
79
|
+
* @returns The explicit ADK error type, GenAI API status, or error class name.
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolveErrorType(error: unknown): string;
|
|
67
82
|
/**
|
|
68
83
|
* Traces tool call.
|
|
69
84
|
*
|
|
70
85
|
* @param params The parameters object containing tool, args, and function response event.
|
|
71
86
|
*/
|
|
72
|
-
export declare function traceToolCall(
|
|
87
|
+
export declare function traceToolCall(params: TraceToolCallParams): void;
|
|
73
88
|
export interface TraceMergedToolCallsParams {
|
|
74
89
|
responseEventId: string;
|
|
75
90
|
functionResponseEvent: Event;
|
|
91
|
+
invocationContext: InvocationContext;
|
|
76
92
|
}
|
|
77
93
|
/**
|
|
78
94
|
* Traces merged tool call events.
|
|
@@ -82,7 +98,7 @@ export interface TraceMergedToolCallsParams {
|
|
|
82
98
|
*
|
|
83
99
|
* @param params The parameters object containing response event ID and function response event.
|
|
84
100
|
*/
|
|
85
|
-
export declare function traceMergedToolCalls({ responseEventId, functionResponseEvent, }: TraceMergedToolCallsParams): void;
|
|
101
|
+
export declare function traceMergedToolCalls({ responseEventId, functionResponseEvent, invocationContext, }: TraceMergedToolCallsParams): void;
|
|
86
102
|
export interface TraceCallLlmParams {
|
|
87
103
|
invocationContext: InvocationContext;
|
|
88
104
|
eventId: string;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
7
|
+
import { ReadonlyContext } from '../../agents/readonly_context.js';
|
|
8
|
+
import { AuthCredential } from '../../auth/auth_credential.js';
|
|
9
|
+
import { BaseTool } from '../base_tool.js';
|
|
10
|
+
import { BaseToolset, ToolPredicate } from '../base_toolset.js';
|
|
11
|
+
import { BaseAPIHubClient } from './clients/apihub_client.js';
|
|
12
|
+
/** Options for {@link APIHubToolset}. */
|
|
13
|
+
export interface APIHubToolsetOptions {
|
|
14
|
+
/**
|
|
15
|
+
* The API Hub resource to build tools from. It must name an API, and may
|
|
16
|
+
* also name a version and a spec, for example
|
|
17
|
+
* `projects/my-project/locations/us-central1/apis/my-api`. An API Hub
|
|
18
|
+
* console URL is also accepted.
|
|
19
|
+
*
|
|
20
|
+
* When it names a spec, that spec is used. Otherwise the first spec of the
|
|
21
|
+
* named version, or of the first version of the named API, is used.
|
|
22
|
+
*/
|
|
23
|
+
apihubResourceName: string;
|
|
24
|
+
/**
|
|
25
|
+
* An OAuth access token for API Hub, for example the output of
|
|
26
|
+
* `gcloud auth print-access-token`. Ignored when `apihubClient` is set.
|
|
27
|
+
*/
|
|
28
|
+
accessToken?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The content of a service account key file, as a JSON string, used to
|
|
31
|
+
* authenticate to API Hub when `accessToken` is not set. Ignored when
|
|
32
|
+
* `apihubClient` is set.
|
|
33
|
+
*/
|
|
34
|
+
serviceAccountJson?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The toolset name. When empty, it is set from the spec's `info.title` in
|
|
37
|
+
* snake_case, or `unnamed` when the spec has no title.
|
|
38
|
+
*/
|
|
39
|
+
name?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The toolset description. When empty, it is set from the spec's
|
|
42
|
+
* `info.description`.
|
|
43
|
+
*/
|
|
44
|
+
description?: string;
|
|
45
|
+
/**
|
|
46
|
+
* When true, the spec is fetched on the first call to `getTools`
|
|
47
|
+
* instead of when the toolset is constructed.
|
|
48
|
+
*/
|
|
49
|
+
lazyLoadSpec?: boolean;
|
|
50
|
+
/** Auth scheme applied to every tool the spec produces. */
|
|
51
|
+
authScheme?: OpenAPIV3.SecuritySchemeObject;
|
|
52
|
+
/** Auth credential applied to every tool the spec produces. */
|
|
53
|
+
authCredential?: AuthCredential;
|
|
54
|
+
/**
|
|
55
|
+
* The client that fetches the spec. Defaults to an {@link APIHubClient}
|
|
56
|
+
* built from `accessToken` and `serviceAccountJson`.
|
|
57
|
+
*/
|
|
58
|
+
apihubClient?: BaseAPIHubClient;
|
|
59
|
+
/**
|
|
60
|
+
* Filter selecting which tools from the spec are exposed by `getTools`.
|
|
61
|
+
* Accepts a list of tool names or a {@link ToolPredicate} function.
|
|
62
|
+
*/
|
|
63
|
+
toolFilter?: ToolPredicate | string[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Builds one tool per operation of an API registered in API Hub.
|
|
67
|
+
*
|
|
68
|
+
* The toolset fetches an OpenAPI spec from API Hub, parses it as YAML or JSON,
|
|
69
|
+
* and hands it to an {@link OpenAPIToolset}, which produces a
|
|
70
|
+
* `RestApiTool` for each operation.
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* const toolset = new APIHubToolset({
|
|
74
|
+
* apihubResourceName:
|
|
75
|
+
* 'projects/my-project/locations/us-central1/apis/my-api',
|
|
76
|
+
* });
|
|
77
|
+
* const agent = new LlmAgent({
|
|
78
|
+
* name: 'api_agent',
|
|
79
|
+
* model: 'gemini-flash-latest',
|
|
80
|
+
* tools: [toolset],
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* By default the spec is fetched when the toolset is constructed. A
|
|
85
|
+
* constructor cannot wait for the request, so a failure is reported by the
|
|
86
|
+
* first call to `getTools`, and every later call reports the same
|
|
87
|
+
* failure.
|
|
88
|
+
*
|
|
89
|
+
* With `lazyLoadSpec`, the spec is fetched on the first call to `getTools`.
|
|
90
|
+
* A successful result is kept, including a spec that produced no
|
|
91
|
+
* tools. A failed fetch is not kept, so the next call fetches again.
|
|
92
|
+
*/
|
|
93
|
+
export declare class APIHubToolset extends BaseToolset {
|
|
94
|
+
/** The toolset name, filled in from the spec when empty. */
|
|
95
|
+
name: string;
|
|
96
|
+
/** The toolset description, filled in from the spec when empty. */
|
|
97
|
+
description: string;
|
|
98
|
+
private readonly apihubResourceName;
|
|
99
|
+
private readonly lazyLoadSpec;
|
|
100
|
+
private readonly apihubClient;
|
|
101
|
+
private readonly authScheme?;
|
|
102
|
+
private readonly authCredential?;
|
|
103
|
+
private toolsetPromise?;
|
|
104
|
+
constructor(options: APIHubToolsetOptions);
|
|
105
|
+
/**
|
|
106
|
+
* Returns one tool per operation in the spec, or an empty array when the
|
|
107
|
+
* spec is empty.
|
|
108
|
+
*
|
|
109
|
+
* @throws When the spec cannot be fetched or is not valid YAML or JSON.
|
|
110
|
+
*/
|
|
111
|
+
getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
|
|
112
|
+
close(): Promise<void>;
|
|
113
|
+
private loadToolset;
|
|
114
|
+
private prepareTools;
|
|
115
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Fetches the content of an API specification registered in API Hub.
|
|
8
|
+
*
|
|
9
|
+
* Implement this interface to give an `APIHubToolset` a different source of
|
|
10
|
+
* specs, such as a cache, a local file, or a test double.
|
|
11
|
+
*/
|
|
12
|
+
export interface BaseAPIHubClient {
|
|
13
|
+
/**
|
|
14
|
+
* Returns the content of the spec that `path` resolves to.
|
|
15
|
+
*
|
|
16
|
+
* @param path An API, API version or API spec resource name, or an API Hub
|
|
17
|
+
* console URL.
|
|
18
|
+
*/
|
|
19
|
+
getSpecContent(path: string): Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
/** Options for {@link APIHubClient}. */
|
|
22
|
+
export interface APIHubClientOptions {
|
|
23
|
+
/**
|
|
24
|
+
* An OAuth access token sent as the bearer token on every request, for
|
|
25
|
+
* example the output of `gcloud auth print-access-token`. Takes precedence
|
|
26
|
+
* over `serviceAccountJson`.
|
|
27
|
+
*/
|
|
28
|
+
accessToken?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The content of a service account key file, as a JSON string. Used to mint
|
|
31
|
+
* access tokens when `accessToken` is not set. When neither is set, the
|
|
32
|
+
* client uses application default credentials.
|
|
33
|
+
*/
|
|
34
|
+
serviceAccountJson?: string;
|
|
35
|
+
}
|
|
36
|
+
/** An API resource as API Hub returns it. */
|
|
37
|
+
export interface APIHubApi {
|
|
38
|
+
/** Resource name, `projects/{p}/locations/{l}/apis/{a}`. */
|
|
39
|
+
name: string;
|
|
40
|
+
/** Resource names of the versions of this API. */
|
|
41
|
+
versions?: string[];
|
|
42
|
+
}
|
|
43
|
+
/** An API version resource as API Hub returns it. */
|
|
44
|
+
export interface APIHubApiVersion {
|
|
45
|
+
/** Resource name, `projects/{p}/locations/{l}/apis/{a}/versions/{v}`. */
|
|
46
|
+
name: string;
|
|
47
|
+
/** Resource names of the specs attached to this version. */
|
|
48
|
+
specs?: string[];
|
|
49
|
+
}
|
|
50
|
+
/** The resource names parsed out of an API Hub path or URL. */
|
|
51
|
+
export interface APIHubResourceNames {
|
|
52
|
+
/** `projects/{p}/locations/{l}/apis/{a}`. */
|
|
53
|
+
apiResourceName: string;
|
|
54
|
+
/** `.../apis/{a}/versions/{v}`, when the input names a version. */
|
|
55
|
+
apiVersionResourceName?: string;
|
|
56
|
+
/** `.../versions/{v}/specs/{s}`, when the input names a version and a spec. */
|
|
57
|
+
apiSpecResourceName?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Client for the API Hub REST API.
|
|
61
|
+
*
|
|
62
|
+
* Each request sends a bearer token. The token is `accessToken` when it is
|
|
63
|
+
* set; otherwise the client mints one from `serviceAccountJson`, or from
|
|
64
|
+
* application default credentials when that is not set either. Minted tokens
|
|
65
|
+
* are cached and refreshed by `google-auth-library`.
|
|
66
|
+
*/
|
|
67
|
+
export declare class APIHubClient implements BaseAPIHubClient {
|
|
68
|
+
private readonly accessToken?;
|
|
69
|
+
private readonly serviceAccountJson?;
|
|
70
|
+
private auth?;
|
|
71
|
+
constructor(options?: APIHubClientOptions);
|
|
72
|
+
/**
|
|
73
|
+
* Returns the content of the first spec that `path` resolves to.
|
|
74
|
+
*
|
|
75
|
+
* - A path naming an API resolves to the first spec of its first version.
|
|
76
|
+
* - A path naming an API version resolves to the first spec of that version.
|
|
77
|
+
* - A path naming an API spec resolves to that spec.
|
|
78
|
+
*
|
|
79
|
+
* `path` may be a resource name such as
|
|
80
|
+
* `projects/my-project/locations/us-central1/apis/my-api`, or a console URL
|
|
81
|
+
* such as
|
|
82
|
+
* `https://console.cloud.google.com/apigee/api-hub/locations/us-central1/apis/my-api?project=my-project`.
|
|
83
|
+
*
|
|
84
|
+
* @param path The API, API version or API spec to read.
|
|
85
|
+
* @return The decoded spec content, or `''` when the spec is empty.
|
|
86
|
+
* @throws When the path cannot be parsed, when the API has no versions, when
|
|
87
|
+
* the version has no specs, or when a request fails.
|
|
88
|
+
*/
|
|
89
|
+
getSpecContent(path: string): Promise<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Lists the APIs registered in a project and location.
|
|
92
|
+
*
|
|
93
|
+
* @param project The Google Cloud project ID.
|
|
94
|
+
* @param location The API Hub location, for example `us-central1`.
|
|
95
|
+
* @return The APIs, or an empty array when there are none.
|
|
96
|
+
*/
|
|
97
|
+
listApis(project: string, location: string): Promise<APIHubApi[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Gets an API by resource name.
|
|
100
|
+
*
|
|
101
|
+
* @param apiResourceName `projects/{p}/locations/{l}/apis/{a}`.
|
|
102
|
+
*/
|
|
103
|
+
getApi(apiResourceName: string): Promise<APIHubApi>;
|
|
104
|
+
/**
|
|
105
|
+
* Gets an API version by resource name.
|
|
106
|
+
*
|
|
107
|
+
* @param apiVersionName `projects/{p}/locations/{l}/apis/{a}/versions/{v}`.
|
|
108
|
+
*/
|
|
109
|
+
getApiVersion(apiVersionName: string): Promise<APIHubApiVersion>;
|
|
110
|
+
/** Reads the base64-encoded contents of a spec and decodes them as UTF-8. */
|
|
111
|
+
private fetchSpec;
|
|
112
|
+
/** Sends an authenticated GET request and parses the JSON response. */
|
|
113
|
+
private get;
|
|
114
|
+
/**
|
|
115
|
+
* Returns the bearer token for the next request.
|
|
116
|
+
*
|
|
117
|
+
* `GoogleAuth` is created once and reused, so that it can cache the token
|
|
118
|
+
* and refresh it when it expires.
|
|
119
|
+
*/
|
|
120
|
+
private getAccessToken;
|
|
121
|
+
/**
|
|
122
|
+
* Builds the error for a token that could not be obtained.
|
|
123
|
+
*
|
|
124
|
+
* Without a service account, the likely fix is to supply a credential. With
|
|
125
|
+
* one, the key itself was rejected, so the error says so and gives the
|
|
126
|
+
* reason.
|
|
127
|
+
*/
|
|
128
|
+
private tokenError;
|
|
129
|
+
private createAuth;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Extracts the API, API version and API spec resource names from an API Hub
|
|
133
|
+
* resource path or console URL.
|
|
134
|
+
*
|
|
135
|
+
* The project comes from a `projects/{p}` segment, or from a `project` query
|
|
136
|
+
* parameter when the path has none. The location and the API are required.
|
|
137
|
+
* The spec name is returned only when both a version and a spec are present.
|
|
138
|
+
*
|
|
139
|
+
* @param urlOrPath A resource name, or a console URL under `api-hub/`.
|
|
140
|
+
* @throws When the project, the location or the API cannot be found.
|
|
141
|
+
*/
|
|
142
|
+
export declare function extractResourceName(urlOrPath: string): APIHubResourceNames;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** Options for {@link SecretManagerClient}. */
|
|
7
|
+
export interface SecretManagerClientOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The content of a service account key file, as a JSON string, not a path.
|
|
10
|
+
* Takes precedence over `authToken`.
|
|
11
|
+
*/
|
|
12
|
+
serviceAccountJson?: string;
|
|
13
|
+
/** An existing OAuth access token. */
|
|
14
|
+
authToken?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reads secrets from Google Cloud Secret Manager.
|
|
18
|
+
*
|
|
19
|
+
* The client authenticates with `serviceAccountJson` when it is set, then with
|
|
20
|
+
* `authToken`, and otherwise with application default credentials.
|
|
21
|
+
*
|
|
22
|
+
* `@google-cloud/secret-manager` is an optional peer dependency. It is loaded
|
|
23
|
+
* on the first call to {@link SecretManagerClient.getSecret}, so constructing
|
|
24
|
+
* the client does not require it.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SecretManagerClient {
|
|
27
|
+
private readonly credentials?;
|
|
28
|
+
private readonly authToken?;
|
|
29
|
+
private clientPromise?;
|
|
30
|
+
/**
|
|
31
|
+
* @throws `Invalid service account JSON: ...` when `serviceAccountJson`
|
|
32
|
+
* does not parse.
|
|
33
|
+
*/
|
|
34
|
+
constructor(options?: SecretManagerClientOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Returns the payload of a secret version as a UTF-8 string.
|
|
37
|
+
*
|
|
38
|
+
* @param resourceName The secret version, in the form
|
|
39
|
+
* `projects/{project}/secrets/{secret}/versions/{version}`. Use
|
|
40
|
+
* `latest` as the version to read the newest one.
|
|
41
|
+
* @throws When default credentials are needed and cannot be resolved, or
|
|
42
|
+
* when Secret Manager returns an error, such as a missing secret or a
|
|
43
|
+
* denied permission.
|
|
44
|
+
*/
|
|
45
|
+
getSecret(resourceName: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolves the Secret Manager client, loading the optional peer and the
|
|
48
|
+
* credentials on first use.
|
|
49
|
+
*
|
|
50
|
+
* A created client is kept. A failure is not kept, so the next call tries
|
|
51
|
+
* again, for example once default credentials become available.
|
|
52
|
+
*/
|
|
53
|
+
private getClient;
|
|
54
|
+
private createClient;
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Parses a service account key from its JSON text.
|
|
8
|
+
*
|
|
9
|
+
* @throws `Invalid service account JSON: ...` when `json` does not parse.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseServiceAccountJson(json: string): Record<string, string>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ReadonlyContext } from '../../agents/readonly_context.js';
|
|
7
|
+
import { AuthCredential } from '../../auth/auth_credential.js';
|
|
8
|
+
import { AuthScheme } from '../../auth/auth_schemes.js';
|
|
9
|
+
import { BaseTool } from '../base_tool.js';
|
|
10
|
+
import { BaseToolset, ToolPredicate } from '../base_toolset.js';
|
|
11
|
+
import { IntegrationConnectorTool, type IntegrationConnectorToolOptions } from './integration_connector_tool.js';
|
|
12
|
+
export { IntegrationConnectorTool, type IntegrationConnectorToolOptions };
|
|
13
|
+
/** Options of {@link ApplicationIntegrationToolset}. */
|
|
14
|
+
export interface ApplicationIntegrationToolsetOptions {
|
|
15
|
+
/** The Google Cloud project ID. */
|
|
16
|
+
project: string;
|
|
17
|
+
/** The Google Cloud location, such as `us-central1`. */
|
|
18
|
+
location: string;
|
|
19
|
+
/** The integration name. Set it together with `triggers` or alone for all triggers. */
|
|
20
|
+
integration?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The API trigger IDs of the integration, such as
|
|
23
|
+
* `['api_trigger/my_trigger']`.
|
|
24
|
+
*/
|
|
25
|
+
triggers?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* The Integration Connectors connection name. Set it together with
|
|
28
|
+
* `entityOperations`, `actions`, or both.
|
|
29
|
+
*/
|
|
30
|
+
connection?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Operations to expose, keyed by entity name, such as
|
|
33
|
+
* `{Issues: ['LIST', 'GET']}`. An empty list exposes every operation the
|
|
34
|
+
* entity supports.
|
|
35
|
+
*/
|
|
36
|
+
entityOperations?: Record<string, string[]>;
|
|
37
|
+
/** Connection actions to expose, such as `['ExecuteCustomQuery']`. */
|
|
38
|
+
actions?: string[];
|
|
39
|
+
/** Prefix of every generated tool name. Defaults to `''`. */
|
|
40
|
+
toolNamePrefix?: string;
|
|
41
|
+
/** Text appended to every generated tool description. Defaults to `''`. */
|
|
42
|
+
toolInstructions?: string;
|
|
43
|
+
/**
|
|
44
|
+
* A service-account key, as a JSON string. It authenticates both the spec
|
|
45
|
+
* requests and the generated tools. When omitted, both use Application
|
|
46
|
+
* Default Credentials.
|
|
47
|
+
*/
|
|
48
|
+
serviceAccountJson?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Authentication scheme for dynamic end-user credentials on connection tools,
|
|
51
|
+
* when `authOverrideEnabled` is enabled on the connection.
|
|
52
|
+
*/
|
|
53
|
+
authScheme?: AuthScheme;
|
|
54
|
+
/**
|
|
55
|
+
* Authentication credential for dynamic end-user credentials on connection
|
|
56
|
+
* tools, when `authOverrideEnabled` is enabled on the connection.
|
|
57
|
+
*/
|
|
58
|
+
authCredential?: AuthCredential;
|
|
59
|
+
/**
|
|
60
|
+
* Filter used to select which generated tools are exposed by `getTools`.
|
|
61
|
+
*/
|
|
62
|
+
toolFilter?: ToolPredicate | string[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A toolset generated from a Google Cloud Application Integration API trigger,
|
|
66
|
+
* or from the entity operations and actions of an Integration Connectors
|
|
67
|
+
* connection.
|
|
68
|
+
*
|
|
69
|
+
* The constructor only validates the options. The first `getTools` call
|
|
70
|
+
* fetches the spec and builds the tools, and later calls reuse them.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Every operation of an integration API trigger.
|
|
74
|
+
* const integrationToolset = new ApplicationIntegrationToolset({
|
|
75
|
+
* project: 'my-project',
|
|
76
|
+
* location: 'us-central1',
|
|
77
|
+
* integration: 'my-integration',
|
|
78
|
+
* triggers: ['api_trigger/my_trigger'],
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* // Entity operations and actions of a connection.
|
|
83
|
+
* const connectionToolset = new ApplicationIntegrationToolset({
|
|
84
|
+
* project: 'my-project',
|
|
85
|
+
* location: 'us-central1',
|
|
86
|
+
* connection: 'my-connection',
|
|
87
|
+
* entityOperations: {Issues: ['LIST', 'GET'], Projects: []},
|
|
88
|
+
* actions: ['ExecuteCustomQuery'],
|
|
89
|
+
* });
|
|
90
|
+
*/
|
|
91
|
+
export declare class ApplicationIntegrationToolset extends BaseToolset {
|
|
92
|
+
private readonly options;
|
|
93
|
+
private toolsPromise?;
|
|
94
|
+
private openApiToolsets;
|
|
95
|
+
/**
|
|
96
|
+
* @throws Error Unless the options name either an integration, or a
|
|
97
|
+
* connection with at least one entity operation or action.
|
|
98
|
+
*/
|
|
99
|
+
constructor(options: ApplicationIntegrationToolsetOptions);
|
|
100
|
+
/**
|
|
101
|
+
* Returns the generated tools.
|
|
102
|
+
*
|
|
103
|
+
* The first call fetches the spec and builds the tools. Concurrent calls
|
|
104
|
+
* share that load. When it fails, the next call tries again.
|
|
105
|
+
*/
|
|
106
|
+
getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
|
|
107
|
+
close(): Promise<void>;
|
|
108
|
+
private loadTools;
|
|
109
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** OAuth scope every Integration Connectors and Application Integration call needs. */
|
|
7
|
+
export declare const CLOUD_PLATFORM_SCOPE = "https://www.googleapis.com/auth/cloud-platform";
|
|
8
|
+
/** Wraps a failure as `An unexpected error occurred: …`. */
|
|
9
|
+
export declare function unexpectedError(e: unknown): Error;
|
|
10
|
+
/**
|
|
11
|
+
* Supplies cloud-platform access tokens from a service-account key, or from
|
|
12
|
+
* Application Default Credentials when no key is given.
|
|
13
|
+
*
|
|
14
|
+
* One instance holds one `GoogleAuth`, which caches the token and refreshes it
|
|
15
|
+
* before it expires.
|
|
16
|
+
*/
|
|
17
|
+
export declare class CloudPlatformTokenSource {
|
|
18
|
+
private readonly serviceAccountJson?;
|
|
19
|
+
private auth?;
|
|
20
|
+
constructor(serviceAccountJson?: string | undefined);
|
|
21
|
+
/**
|
|
22
|
+
* Returns an access token.
|
|
23
|
+
*
|
|
24
|
+
* @throws Error When no key is given and Application Default Credentials are
|
|
25
|
+
* unavailable, or when no token is issued.
|
|
26
|
+
*/
|
|
27
|
+
getAccessToken(): Promise<string>;
|
|
28
|
+
private getAuth;
|
|
29
|
+
}
|
|
30
|
+
/** Options for {@link sendCloudRequest}. */
|
|
31
|
+
export interface SendCloudRequestOptions {
|
|
32
|
+
/** The request URL. */
|
|
33
|
+
url: string;
|
|
34
|
+
/** The HTTP method. */
|
|
35
|
+
method: 'GET' | 'POST';
|
|
36
|
+
/** The JSON request body for a POST request. */
|
|
37
|
+
body?: unknown;
|
|
38
|
+
/** Supplies the bearer token. */
|
|
39
|
+
tokenSource: CloudPlatformTokenSource;
|
|
40
|
+
/** The message for an HTTP 400 or 404 response. */
|
|
41
|
+
invalidRequestMessage: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Sends an authenticated JSON request to a Google Cloud API and returns the
|
|
45
|
+
* parsed response body.
|
|
46
|
+
*
|
|
47
|
+
* @param options The request URL, method, body, token source, and 400/404 message.
|
|
48
|
+
* @throws Error `invalidRequestMessage` for HTTP 400 and 404,
|
|
49
|
+
* `Request error: …` for any other non-2xx status or a failed fetch, and
|
|
50
|
+
* `An unexpected error occurred: …` for anything else, such as a missing
|
|
51
|
+
* credential or a body that is not JSON.
|
|
52
|
+
*/
|
|
53
|
+
export declare function sendCloudRequest(options: SendCloudRequestOptions): Promise<unknown>;
|