@google/adk 2.1.0 → 2.2.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/agent_card.js +8 -0
- package/dist/cjs/a2a/agent_executor.js +8 -3
- package/dist/cjs/agents/llm_agent.js +15 -1
- package/dist/cjs/agents/processors/content_processor_utils.js +10 -2
- package/dist/cjs/agents/processors/nl_planning_processor.js +114 -0
- package/dist/cjs/artifacts/gcs_artifact_service.js +13 -7
- package/dist/cjs/auth/auth_credential.js +12 -2
- package/dist/cjs/code_executors/code_execution_utils.js +3 -3
- package/dist/cjs/common.js +45 -0
- package/dist/cjs/examples/example.js +92 -0
- package/dist/cjs/examples/example_util.js +28 -4
- package/dist/cjs/examples/index.js +39 -0
- package/dist/cjs/examples/vertex_ai_example_store.js +39 -0
- package/dist/cjs/index.js +46 -0
- package/dist/cjs/memory/vertex_ai_memory_bank_service.js +17 -5
- package/dist/cjs/models/base_llm.js +1 -6
- package/dist/cjs/models/chrome_prompt_llm.js +16 -2
- package/dist/cjs/models/chrome_prompt_utils.js +54 -2
- package/dist/cjs/models/gemini_llm_connection.js +5 -4
- package/dist/cjs/planners/base_planner.js +56 -0
- package/dist/cjs/planners/built_in_planner.js +85 -0
- package/dist/cjs/planners/plan_re_act_planner.js +172 -0
- package/dist/cjs/plugins/base_plugin.js +46 -61
- package/dist/cjs/tools/example_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_session_manager.js +14 -8
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +281 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +15 -1
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js +70 -0
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +120 -0
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +10 -10
- package/dist/cjs/tools/openapi_tool/common/common.js +139 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +11 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +73 -13
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +146 -34
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +14 -2
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +90 -28
- package/dist/cjs/tools/skill/skill_toolset.js +2 -0
- package/dist/cjs/tools/tool_context.js +41 -0
- package/dist/cjs/tools/webmcp/index.js +37 -0
- package/dist/cjs/tools/webmcp/webmcp_tool.js +156 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +116 -0
- package/dist/cjs/tools/webmcp/webmcp_types.js +50 -0
- package/dist/cjs/utils/case_utils.js +52 -2
- package/dist/cjs/utils/client_labels.js +67 -0
- package/dist/cjs/utils/gemini_schema_util.js +103 -3
- package/dist/cjs/utils/hash_utils.js +73 -0
- package/dist/cjs/utils/live_connection_utils.js +10 -9
- package/dist/cjs/utils/model_name.js +17 -2
- package/dist/cjs/utils/simple_zod_to_json.js +5 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/agent_card.js +8 -0
- package/dist/esm/a2a/agent_executor.js +8 -3
- package/dist/esm/agents/llm_agent.js +18 -1
- package/dist/esm/agents/processors/content_processor_utils.js +10 -2
- package/dist/esm/agents/processors/nl_planning_processor.js +87 -0
- package/dist/esm/artifacts/gcs_artifact_service.js +13 -7
- package/dist/esm/auth/auth_credential.js +11 -1
- package/dist/esm/code_executors/code_execution_utils.js +3 -3
- package/dist/esm/common.js +38 -2
- package/dist/esm/examples/example.js +85 -0
- package/dist/esm/examples/example_util.js +25 -3
- package/dist/esm/examples/index.js +11 -0
- package/dist/esm/examples/vertex_ai_example_store.js +11 -0
- package/dist/esm/index.js +51 -1
- package/dist/esm/memory/vertex_ai_memory_bank_service.js +17 -5
- package/dist/esm/models/base_llm.js +2 -7
- package/dist/esm/models/chrome_prompt_llm.js +20 -3
- package/dist/esm/models/chrome_prompt_utils.js +51 -2
- package/dist/esm/models/gemini_llm_connection.js +6 -5
- package/dist/esm/planners/base_planner.js +28 -0
- package/dist/esm/planners/built_in_planner.js +57 -0
- package/dist/esm/planners/plan_re_act_planner.js +145 -0
- package/dist/esm/plugins/base_plugin.js +46 -61
- package/dist/esm/tools/example_tool.js +1 -1
- package/dist/esm/tools/mcp/mcp_session_manager.js +14 -8
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +272 -1
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +15 -1
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js +43 -0
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +93 -0
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +10 -12
- package/dist/esm/tools/openapi_tool/common/common.js +112 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +11 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +80 -13
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +146 -33
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +14 -2
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +89 -28
- package/dist/esm/tools/skill/skill_toolset.js +2 -0
- package/dist/esm/tools/tool_context.js +15 -0
- package/dist/esm/tools/webmcp/index.js +10 -0
- package/dist/esm/tools/webmcp/webmcp_tool.js +131 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +89 -0
- package/dist/esm/tools/webmcp/webmcp_types.js +22 -0
- package/dist/esm/utils/case_utils.js +49 -1
- package/dist/esm/utils/client_labels.js +65 -0
- package/dist/esm/utils/gemini_schema_util.js +102 -3
- package/dist/esm/utils/hash_utils.js +45 -0
- package/dist/esm/utils/live_connection_utils.js +11 -10
- package/dist/esm/utils/model_name.js +15 -2
- package/dist/esm/utils/simple_zod_to_json.js +5 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/agents/llm_agent.d.ts +12 -1
- package/dist/types/agents/processors/nl_planning_processor.d.ts +30 -0
- package/dist/types/auth/auth_credential.d.ts +9 -0
- package/dist/types/common.d.ts +16 -4
- package/dist/types/examples/base_example_provider.d.ts +2 -2
- package/dist/types/examples/example.d.ts +75 -0
- package/dist/types/examples/example_util.d.ts +13 -2
- package/dist/types/examples/index.d.ts +18 -0
- package/dist/types/examples/vertex_ai_example_store.d.ts +7 -0
- package/dist/types/index.d.ts +12 -3
- package/dist/types/memory/memory_entry.d.ts +15 -0
- package/dist/types/memory/vertex_ai_memory_bank_service.d.ts +9 -0
- package/dist/types/models/chrome_prompt_utils.d.ts +29 -0
- package/dist/types/planners/base_planner.d.ts +50 -0
- package/dist/types/planners/built_in_planner.d.ts +53 -0
- package/dist/types/planners/plan_re_act_planner.d.ts +21 -0
- package/dist/types/plugins/base_plugin.d.ts +52 -52
- package/dist/types/skills/skill_registry.d.ts +8 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +110 -1
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +32 -2
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.d.ts +35 -0
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.d.ts +54 -0
- package/dist/types/tools/openapi_tool/common/common.d.ts +60 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +7 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +56 -2
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +73 -5
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +11 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +42 -8
- package/dist/types/tools/tool_context.d.ts +19 -0
- package/dist/types/tools/webmcp/index.d.ts +12 -0
- package/dist/types/tools/webmcp/webmcp_tool.d.ts +47 -0
- package/dist/types/tools/webmcp/webmcp_toolset.d.ts +67 -0
- package/dist/types/tools/webmcp/webmcp_types.d.ts +69 -0
- package/dist/types/utils/case_utils.d.ts +36 -0
- package/dist/types/utils/client_labels.d.ts +33 -0
- package/dist/types/utils/gemini_schema_util.d.ts +13 -0
- package/dist/types/utils/hash_utils.d.ts +25 -0
- package/dist/types/utils/logger.d.ts +10 -2
- package/dist/types/utils/model_name.d.ts +30 -2
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +112 -79
- package/dist/web/index_web.js.map +4 -4
- package/package.json +8 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { AuthCredential } from '../../../../auth/auth_credential.js';
|
|
7
|
+
import { AuthScheme } from '../../../../auth/auth_schemes.js';
|
|
8
|
+
import { BaseCredentialExchanger, ExchangeResult } from '../../../../auth/exchanger/base_credential_exchanger.js';
|
|
9
|
+
/**
|
|
10
|
+
* Validates that the scheme and the credential can produce a bearer token.
|
|
11
|
+
*
|
|
12
|
+
* @param authScheme - The OpenID Connect or OAuth2 auth scheme.
|
|
13
|
+
* @param authCredential - The auth credential to validate.
|
|
14
|
+
* @throws Error - If the credential is absent, the scheme is
|
|
15
|
+
* not OpenID Connect or OAuth2, or the credential carries neither `oauth2`
|
|
16
|
+
* nor `http`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkSchemeCredentialType(authScheme: AuthScheme, authCredential?: AuthCredential): asserts authCredential is AuthCredential;
|
|
19
|
+
/**
|
|
20
|
+
* Converts an OAuth2 access token into an HTTP bearer credential.
|
|
21
|
+
*
|
|
22
|
+
* @param authCredential - The auth credential holding the access token.
|
|
23
|
+
* @returns A new credential holding the access token as an HTTP bearer token,
|
|
24
|
+
* or the original credential when there is no access token to convert. The
|
|
25
|
+
* input credential is never modified.
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateAuthToken(authCredential: AuthCredential): AuthCredential;
|
|
28
|
+
/**
|
|
29
|
+
* Exchanges an OAuth2 or OpenID Connect credential for an HTTP bearer one.
|
|
30
|
+
*
|
|
31
|
+
* @param authScheme - The auth scheme.
|
|
32
|
+
* @param authCredential - The auth credential.
|
|
33
|
+
* @returns The credential unchanged when it already carries `http`, a new HTTP
|
|
34
|
+
* bearer credential when it carries an access token, or `null` when there
|
|
35
|
+
* is no token to convert.
|
|
36
|
+
* @throws Error - If the scheme or the credential is invalid.
|
|
37
|
+
*/
|
|
38
|
+
export declare function exchangeCredential(authScheme: AuthScheme, authCredential?: AuthCredential): AuthCredential | null;
|
|
39
|
+
/**
|
|
40
|
+
* Converts OAuth2 and OpenID Connect credentials into HTTP bearer credentials.
|
|
41
|
+
*
|
|
42
|
+
* Ports `OAuth2CredentialExchanger` from adk-python
|
|
43
|
+
* `src/google/adk/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.py`
|
|
44
|
+
* at tag `v0.1.0`. The adk-js class carries a different name because
|
|
45
|
+
* `OAuth2CredentialExchanger` in `core/src/auth/oauth2/` already owns that one,
|
|
46
|
+
* and it solves a different problem: it fetches tokens from the token endpoint,
|
|
47
|
+
* where this class converts a token it is given.
|
|
48
|
+
*/
|
|
49
|
+
export declare class OAuth2BearerExchanger implements BaseCredentialExchanger {
|
|
50
|
+
exchange(params: {
|
|
51
|
+
authScheme?: AuthScheme;
|
|
52
|
+
authCredential: AuthCredential;
|
|
53
|
+
}): Promise<ExchangeResult>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
7
|
+
import { ApiParameter } from '../openapi_spec_parser/operation_parser.js';
|
|
8
|
+
/**
|
|
9
|
+
* The type hints these helpers emit are Python tokens, in a TypeScript SDK,
|
|
10
|
+
* on purpose. They are assembled into a tool description that reaches the
|
|
11
|
+
* model, so the same OpenAPI operation has to describe itself identically in
|
|
12
|
+
* adk-js and in adk-python. The reference is adk-python
|
|
13
|
+
* `src/google/adk/tools/openapi_tool/common/common.py`.
|
|
14
|
+
*/
|
|
15
|
+
/** Input to {@link createApiParameter}; `name` is derived when omitted. */
|
|
16
|
+
export interface ApiParameterInit {
|
|
17
|
+
originalName: string;
|
|
18
|
+
paramLocation: string;
|
|
19
|
+
paramSchema: OpenAPIV3.SchemaObject;
|
|
20
|
+
description?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns the Python type hint for an OpenAPI schema.
|
|
26
|
+
*
|
|
27
|
+
* @param schema The schema to describe, if any.
|
|
28
|
+
* @returns A Python type name such as `str`, `List[int]` or `Dict[str, Any]`.
|
|
29
|
+
* A missing or unrecognised type gives `Any`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getTypeHint(schema: OpenAPIV3.SchemaObject | undefined): string;
|
|
32
|
+
/**
|
|
33
|
+
* Generates the docstring line documenting one parameter.
|
|
34
|
+
*
|
|
35
|
+
* @param param The parameter to document.
|
|
36
|
+
* @returns A line of the form `name (type): description`, followed by an
|
|
37
|
+
* indented property list when the schema is an object with properties.
|
|
38
|
+
*/
|
|
39
|
+
export declare function generateParamDoc(param: ApiParameter): string;
|
|
40
|
+
/**
|
|
41
|
+
* Generates the docstring block documenting the return value.
|
|
42
|
+
*
|
|
43
|
+
* Uses the 2xx response with the smallest status code that has content.
|
|
44
|
+
*
|
|
45
|
+
* @param responses The responses of an OpenAPI operation.
|
|
46
|
+
* @returns A line of the form `Returns (type): description`, or `''` when no
|
|
47
|
+
* 2xx response has content.
|
|
48
|
+
*/
|
|
49
|
+
export declare function generateReturnDoc(responses: OpenAPIV3.ResponsesObject): string;
|
|
50
|
+
/**
|
|
51
|
+
* Builds an {@link ApiParameter}, deriving the fields adk-python derives in
|
|
52
|
+
* `ApiParameter.model_post_init`.
|
|
53
|
+
*
|
|
54
|
+
* `name` falls back to the reserved-word-safe snake_case form of
|
|
55
|
+
* `originalName`, and `description` falls back to the schema description.
|
|
56
|
+
*
|
|
57
|
+
* @param init The parameter fields.
|
|
58
|
+
* @returns The parameter with its derived fields filled in.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createApiParameter(init: ApiParameterInit): ApiParameter;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { OpenAPIV3 } from 'openapi-types';
|
|
7
|
+
import { AuthCredential } from '../../../auth/auth_credential.js';
|
|
7
8
|
import { ApiParameter } from './operation_parser.js';
|
|
8
9
|
export interface OperationEndpoint {
|
|
9
10
|
baseUrl: string;
|
|
@@ -18,6 +19,12 @@ export interface ParsedOperation {
|
|
|
18
19
|
parameters: ApiParameter[];
|
|
19
20
|
returnValue?: ApiParameter;
|
|
20
21
|
authScheme?: OpenAPIV3.SecuritySchemeObject;
|
|
22
|
+
/**
|
|
23
|
+
* Credential for the operation. The parser leaves this undefined; a caller
|
|
24
|
+
* that builds a `ParsedOperation` by hand can set it, and `OpenAPIToolset`
|
|
25
|
+
* passes it to the tool it creates.
|
|
26
|
+
*/
|
|
27
|
+
authCredential?: AuthCredential;
|
|
21
28
|
}
|
|
22
29
|
export declare class OpenApiSpecParser {
|
|
23
30
|
private preservePropertyNames;
|
|
@@ -19,13 +19,32 @@ export interface ApiParameter {
|
|
|
19
19
|
* that are compatible with Gemini's tool function declarations.
|
|
20
20
|
*/
|
|
21
21
|
export declare class OperationParser {
|
|
22
|
-
private readonly operation;
|
|
23
22
|
private params;
|
|
24
23
|
private returnValue?;
|
|
25
24
|
private preservePropertyNames;
|
|
26
|
-
|
|
25
|
+
private readonly operation;
|
|
26
|
+
/**
|
|
27
|
+
* @param operation The operation to parse. A string is parsed as JSON, and a
|
|
28
|
+
* plain object is used as given.
|
|
29
|
+
* @param options.preservePropertyNames Keeps the original parameter and
|
|
30
|
+
* function names instead of converting them to snake_case.
|
|
31
|
+
* @param options.shouldParse Whether to parse the operation during
|
|
32
|
+
* construction. Defaults to `true`.
|
|
33
|
+
*/
|
|
34
|
+
constructor(operation: OpenAPIV3.OperationObject | Record<string, unknown> | string, options?: {
|
|
27
35
|
preservePropertyNames?: boolean;
|
|
36
|
+
shouldParse?: boolean;
|
|
28
37
|
});
|
|
38
|
+
/**
|
|
39
|
+
* Builds a parser from parameters that were already parsed, without walking
|
|
40
|
+
* the operation again.
|
|
41
|
+
*
|
|
42
|
+
* @param operation The operation the parameters came from.
|
|
43
|
+
* @param params The parsed parameters.
|
|
44
|
+
* @param returnValue The parsed return value, if any.
|
|
45
|
+
* @returns A parser holding the given parameters.
|
|
46
|
+
*/
|
|
47
|
+
static load(operation: OpenAPIV3.OperationObject | Record<string, unknown> | string, params: ApiParameter[], returnValue?: ApiParameter): OperationParser;
|
|
29
48
|
private getParamName;
|
|
30
49
|
private processOperationParameters;
|
|
31
50
|
private processRequestBody;
|
|
@@ -56,4 +75,39 @@ export declare class OperationParser {
|
|
|
56
75
|
* @returns A string representing the description.
|
|
57
76
|
*/
|
|
58
77
|
getDescription(): string;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the name of the security scheme this operation declares.
|
|
80
|
+
*
|
|
81
|
+
* Only operation-level security is considered. Document-level security is
|
|
82
|
+
* not visible from here, so a caller that needs the fallback uses
|
|
83
|
+
* `OpenApiSpecParser` instead.
|
|
84
|
+
*
|
|
85
|
+
* @returns The first declared scheme name, or `''` when the operation
|
|
86
|
+
* declares none.
|
|
87
|
+
*/
|
|
88
|
+
getAuthSchemeName(): string;
|
|
89
|
+
/**
|
|
90
|
+
* Gets the parsed return value of the operation.
|
|
91
|
+
*
|
|
92
|
+
* @returns The return value, or `undefined` when the parser was constructed
|
|
93
|
+
* with `shouldParse: false` and nothing was loaded.
|
|
94
|
+
*/
|
|
95
|
+
getReturnValue(): ApiParameter | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Gets the Python-style type hint of the return value.
|
|
98
|
+
*
|
|
99
|
+
* @returns A type name such as `str`, or `Any` when the operation declares
|
|
100
|
+
* no typed 2xx response.
|
|
101
|
+
*/
|
|
102
|
+
getReturnTypeHint(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Generates a Python-style docstring describing the operation, every
|
|
105
|
+
* parameter and the return value.
|
|
106
|
+
*
|
|
107
|
+
* The type names inside it are Python's, because the artifact is a docstring
|
|
108
|
+
* in adk-python's format and the same text reaches the model in both SDKs.
|
|
109
|
+
*
|
|
110
|
+
* @returns The generated docstring.
|
|
111
|
+
*/
|
|
112
|
+
getPydocString(): string;
|
|
59
113
|
}
|
|
@@ -3,21 +3,89 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { OpenAPIV3 } from 'openapi-types';
|
|
7
6
|
import { Context } from '../../../agents/context.js';
|
|
8
7
|
import { AuthCredential } from '../../../auth/auth_credential.js';
|
|
8
|
+
import { AuthScheme } from '../../../auth/auth_schemes.js';
|
|
9
|
+
import { BaseCredentialExchanger } from '../../../auth/exchanger/base_credential_exchanger.js';
|
|
10
|
+
/** The outcome of preparing a tool's credential. */
|
|
9
11
|
export interface AuthPreparationResult {
|
|
10
12
|
state: 'pending' | 'done';
|
|
13
|
+
authScheme?: AuthScheme;
|
|
11
14
|
authCredential?: AuthCredential;
|
|
12
15
|
}
|
|
16
|
+
/** Collaborators a caller may substitute when building a {@link ToolAuthHandler}. */
|
|
17
|
+
export interface ToolAuthHandlerOptions {
|
|
18
|
+
/** Key under which a credential service loads and saves this credential. */
|
|
19
|
+
credentialKey?: string;
|
|
20
|
+
/** Exchanger to use instead of the default `AutoAuthCredentialExchanger`. */
|
|
21
|
+
credentialExchanger?: BaseCredentialExchanger;
|
|
22
|
+
/** Store to use instead of one built over the tool's own context. */
|
|
23
|
+
credentialStore?: ToolContextCredentialStore;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Stores and retrieves exchanged credentials in the session state carried by a
|
|
27
|
+
* {@link Context}.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ToolContextCredentialStore {
|
|
30
|
+
private readonly context;
|
|
31
|
+
constructor(context: Context);
|
|
32
|
+
/**
|
|
33
|
+
* Returns the state key that holds the credential exchanged for this scheme
|
|
34
|
+
* and credential pair.
|
|
35
|
+
*
|
|
36
|
+
* Both operands are hashed into the key, so two tools configured with
|
|
37
|
+
* different schemes, or with different credentials under one scheme, never
|
|
38
|
+
* share a slot.
|
|
39
|
+
*
|
|
40
|
+
* The key deliberately carries no `temp:` prefix. Session state is a copy and
|
|
41
|
+
* only the delta is persisted, and `temp:` is cleared at the end of a run,
|
|
42
|
+
* while an exchanged token has to stay readable across runs.
|
|
43
|
+
*/
|
|
44
|
+
getCredentialKey(authScheme?: AuthScheme, authCredential?: AuthCredential): string;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the credential stored for this scheme and credential pair, or
|
|
47
|
+
* `undefined` when there is none.
|
|
48
|
+
*
|
|
49
|
+
* @throws Error if the state entry under the key is not an
|
|
50
|
+
* {@link AuthCredential}, which means something else wrote to the key.
|
|
51
|
+
*/
|
|
52
|
+
getCredential(authScheme?: AuthScheme, authCredential?: AuthCredential): AuthCredential | undefined;
|
|
53
|
+
storeCredential(key: string, credential: AuthCredential): void;
|
|
54
|
+
/**
|
|
55
|
+
* Makes the credential under `key` unreadable again.
|
|
56
|
+
*
|
|
57
|
+
* adk-python deletes the state entry. `State` has no delete, so this writes
|
|
58
|
+
* `undefined`, which `State.get` returns for a missing key as well, and
|
|
59
|
+
* {@link getCredential} therefore misses exactly as a delete would make it.
|
|
60
|
+
*/
|
|
61
|
+
removeCredential(key: string): void;
|
|
62
|
+
}
|
|
13
63
|
export declare class ToolAuthHandler {
|
|
14
64
|
private readonly context;
|
|
15
65
|
private readonly authScheme?;
|
|
16
66
|
private readonly authCredential?;
|
|
17
67
|
private readonly credentialKey?;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
68
|
+
private readonly credentialExchanger?;
|
|
69
|
+
private readonly credentialStore;
|
|
70
|
+
constructor(context: Context, authScheme?: AuthScheme, authCredential?: AuthCredential, options?: ToolAuthHandlerOptions);
|
|
71
|
+
static fromToolContext(context: Context, authScheme?: AuthScheme, authCredential?: AuthCredential, options?: ToolAuthHandlerOptions): ToolAuthHandler;
|
|
22
72
|
prepareAuthCredentials(): Promise<AuthPreparationResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Exchanges `credential`, or returns `undefined` when the exchange failed.
|
|
75
|
+
*
|
|
76
|
+
* An exchange failure is transient far more often than it is fatal, so it
|
|
77
|
+
* becomes a `pending` result the client can resume from rather than an
|
|
78
|
+
* exception that fails the whole tool call.
|
|
79
|
+
*/
|
|
80
|
+
private tryExchange;
|
|
81
|
+
/**
|
|
82
|
+
* Asks the client for a credential, after checking that an interactive
|
|
83
|
+
* scheme has the OAuth2 client configuration it cannot proceed without.
|
|
84
|
+
*
|
|
85
|
+
* @throws Error if an `oauth2` or `openIdConnect` scheme has no OAuth2
|
|
86
|
+
* credential.
|
|
87
|
+
* @throws AuthCredentialMissingError if that credential omits `clientId` or
|
|
88
|
+
* `clientSecret`.
|
|
89
|
+
*/
|
|
90
|
+
private requestCredential;
|
|
23
91
|
}
|
|
@@ -8,6 +8,7 @@ import { ReadonlyContext } from '../../agents/readonly_context.js';
|
|
|
8
8
|
import { AuthCredential } from '../../auth/auth_credential.js';
|
|
9
9
|
import { BaseTool } from '../base_tool.js';
|
|
10
10
|
import { BaseToolset, ToolPredicate } from '../base_toolset.js';
|
|
11
|
+
import { RestApiTool } from './rest_api_tool.js';
|
|
11
12
|
export declare class OpenAPIToolset extends BaseToolset {
|
|
12
13
|
private tools;
|
|
13
14
|
constructor(options?: {
|
|
@@ -23,5 +24,15 @@ export declare class OpenAPIToolset extends BaseToolset {
|
|
|
23
24
|
headerProvider?: (context: ReadonlyContext) => Record<string, string>;
|
|
24
25
|
});
|
|
25
26
|
getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the parsed tool with the given name, or `undefined` when the spec
|
|
29
|
+
* produced no such tool.
|
|
30
|
+
*
|
|
31
|
+
* The lookup is over every tool parsed from the spec and does not apply
|
|
32
|
+
* `toolFilter`, which selects what an agent exposes to the model rather than
|
|
33
|
+
* what the toolset holds. When the toolset was constructed with `prefix`,
|
|
34
|
+
* pass the prefixed name.
|
|
35
|
+
*/
|
|
36
|
+
getTool(toolName: string): RestApiTool | undefined;
|
|
26
37
|
close(): Promise<void>;
|
|
27
38
|
}
|
|
@@ -8,8 +8,26 @@ import { OpenAPIV3 } from 'openapi-types';
|
|
|
8
8
|
import { ReadonlyContext } from '../../agents/readonly_context.js';
|
|
9
9
|
import { AuthCredential } from '../../auth/auth_credential.js';
|
|
10
10
|
import { BaseTool, RunAsyncToolRequest } from '../base_tool.js';
|
|
11
|
-
import { ApiParameter } from './openapi_spec_parser/operation_parser.js';
|
|
11
|
+
import { ApiParameter, OperationParser } from './openapi_spec_parser/operation_parser.js';
|
|
12
12
|
import { OperationEndpoint } from './openapi_spec_parser/openapi_spec_parser.js';
|
|
13
|
+
/**
|
|
14
|
+
* The parsed operation `createRestApiTool` accepts.
|
|
15
|
+
*
|
|
16
|
+
* `name` and `description` are optional and are derived from the operation
|
|
17
|
+
* when they are absent. `parameters` and `returnValue` carry an operation the
|
|
18
|
+
* caller has already parsed, so its names, locations and schemas stay
|
|
19
|
+
* authoritative.
|
|
20
|
+
*/
|
|
21
|
+
export interface ParsedOperationInput {
|
|
22
|
+
name?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
endpoint: OperationEndpoint;
|
|
25
|
+
operation: OpenAPIV3.OperationObject;
|
|
26
|
+
authScheme?: OpenAPIV3.SecuritySchemeObject;
|
|
27
|
+
authCredential?: AuthCredential;
|
|
28
|
+
parameters?: ApiParameter[];
|
|
29
|
+
returnValue?: ApiParameter;
|
|
30
|
+
}
|
|
13
31
|
export declare class RestApiTool extends BaseTool {
|
|
14
32
|
private readonly endpoint;
|
|
15
33
|
private readonly operation;
|
|
@@ -22,6 +40,7 @@ export declare class RestApiTool extends BaseTool {
|
|
|
22
40
|
preservePropertyNames?: boolean;
|
|
23
41
|
headerProvider?: (context: ReadonlyContext) => Record<string, string>;
|
|
24
42
|
credentialKey?: string;
|
|
43
|
+
operationParser?: OperationParser;
|
|
25
44
|
});
|
|
26
45
|
configureAuthScheme(authScheme: OpenAPIV3.SecuritySchemeObject): void;
|
|
27
46
|
configureAuthCredential(authCredential: AuthCredential): void;
|
|
@@ -34,17 +53,32 @@ export interface PreparedParams {
|
|
|
34
53
|
headers: Record<string, string>;
|
|
35
54
|
body: unknown;
|
|
36
55
|
bodyData: Record<string, unknown>;
|
|
56
|
+
cookies: Record<string, string>;
|
|
37
57
|
}
|
|
38
58
|
export declare function prepareRequestParams(endpoint: OperationEndpoint, parameters: ApiParameter[], args: Record<string, unknown>): PreparedParams;
|
|
39
59
|
export declare function prepareRequestBody(requestBody: OpenAPIV3.RequestBodyObject | OpenAPIV3.ReferenceObject | undefined, body: unknown, bodyData: Record<string, unknown>, headers: Record<string, string>): unknown;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Builds a `RestApiTool` from a parsed operation.
|
|
62
|
+
*
|
|
63
|
+
* @param parsed The operation, with the parameters already parsed when the
|
|
64
|
+
* caller has them.
|
|
65
|
+
* @param options Options forwarded to the tool and to its operation parser.
|
|
66
|
+
* @returns The tool for that operation.
|
|
67
|
+
*/
|
|
68
|
+
export declare function createRestApiTool(parsed: ParsedOperationInput, options?: {
|
|
47
69
|
preservePropertyNames?: boolean;
|
|
48
70
|
headerProvider?: (context: ReadonlyContext) => Record<string, string>;
|
|
49
71
|
credentialKey?: string;
|
|
50
72
|
}): RestApiTool;
|
|
73
|
+
/**
|
|
74
|
+
* Builds a `RestApiTool` from the JSON string form of a parsed operation.
|
|
75
|
+
*
|
|
76
|
+
* This is the only entry point that accepts undecoded input, so it is where
|
|
77
|
+
* the auth scheme is checked. A scheme reaching `createRestApiTool` as an
|
|
78
|
+
* object is already constrained by its type.
|
|
79
|
+
*
|
|
80
|
+
* @param parsedOperationJson A serialized {@link ParsedOperationInput}.
|
|
81
|
+
* @returns The tool for that operation.
|
|
82
|
+
* @throws {Error} If the auth scheme does not declare a known `type`.
|
|
83
|
+
*/
|
|
84
|
+
export declare function createRestApiToolFromJson(parsedOperationJson: string): RestApiTool;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The tool-facing names for the unified agent context.
|
|
8
|
+
*
|
|
9
|
+
* `ToolContext` and `CallbackContext` are aliases of {@link Context}, not
|
|
10
|
+
* subclasses, so a context the framework builds satisfies either name. This
|
|
11
|
+
* mirrors `adk-python`'s `google.adk.tools.tool_context`, which binds
|
|
12
|
+
* `ToolContext = Context`.
|
|
13
|
+
*
|
|
14
|
+
* Python also re-exports `AuthHandler`, `AuthConfig` and `AuthCredential` from
|
|
15
|
+
* this module. adk-js does not: the package `exports` map has no entry for this
|
|
16
|
+
* path, so no consumer can import them from here, and all three already ship
|
|
17
|
+
* from the package root.
|
|
18
|
+
*/
|
|
19
|
+
export { Context as CallbackContext, Context as ToolContext, } from '../agents/context.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* `@google/adk/tools/webmcp` subpath: the WebMCP tools only, without the full
|
|
8
|
+
* ADK barrel. Also re-exported from `@google/adk`.
|
|
9
|
+
*/
|
|
10
|
+
export * from './webmcp_tool.js';
|
|
11
|
+
export * from './webmcp_toolset.js';
|
|
12
|
+
export * from './webmcp_types.js';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { FunctionDeclaration } from '@google/genai';
|
|
7
|
+
import { BaseTool, RunAsyncToolRequest } from '../base_tool.js';
|
|
8
|
+
import { WebMCPDocument, WebMCPRegisteredTool } from './webmcp_types.js';
|
|
9
|
+
/** Parameters for {@link WebMCPTool}. */
|
|
10
|
+
export interface WebMCPToolParams {
|
|
11
|
+
/** The tool as reported by `document.modelContext.getTools()`. */
|
|
12
|
+
tool: WebMCPRegisteredTool;
|
|
13
|
+
/**
|
|
14
|
+
* Overrides the name exposed to the model, which the toolset uses to apply
|
|
15
|
+
* its prefix. Defaults to the tool's own name.
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
/** Document to read `modelContext` from. Defaults to the global document. */
|
|
19
|
+
document?: WebMCPDocument;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A tool registered by the page on `document.modelContext`.
|
|
23
|
+
*
|
|
24
|
+
* Converts the tool's JSON Schema into a Gemini `FunctionDeclaration` and
|
|
25
|
+
* executes it through `document.modelContext.executeTool()`, so the page runs
|
|
26
|
+
* its own handler and updates its own UI.
|
|
27
|
+
*
|
|
28
|
+
* A tool annotated `consequentialHint` reports itself as requiring
|
|
29
|
+
* confirmation, so significant page actions flow through ADK's existing tool
|
|
30
|
+
* confirmation rather than firing unprompted.
|
|
31
|
+
*/
|
|
32
|
+
export declare class WebMCPTool extends BaseTool {
|
|
33
|
+
readonly webmcpTool: WebMCPRegisteredTool;
|
|
34
|
+
private readonly doc?;
|
|
35
|
+
constructor(params: WebMCPToolParams);
|
|
36
|
+
/**
|
|
37
|
+
* The tool's JSON Schema as an object.
|
|
38
|
+
*
|
|
39
|
+
* `inputSchema` is specified as an object, but a browser handing back a JSON
|
|
40
|
+
* string would otherwise convert to a parameterless declaration, leaving the
|
|
41
|
+
* model no argument names to fill in — it then calls the tool with `{}`.
|
|
42
|
+
*/
|
|
43
|
+
private resolveInputSchema;
|
|
44
|
+
_getDeclaration(): FunctionDeclaration;
|
|
45
|
+
checkRequireConfirmation(): Promise<boolean>;
|
|
46
|
+
runAsync(request: RunAsyncToolRequest): Promise<unknown>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 { BaseTool } from '../base_tool.js';
|
|
8
|
+
import { BaseToolset, ToolPredicate } from '../base_toolset.js';
|
|
9
|
+
import { WebMCPDocument } from './webmcp_types.js';
|
|
10
|
+
/** Options for {@link WebMCPToolset}. */
|
|
11
|
+
export interface WebMCPToolsetOptions {
|
|
12
|
+
/** Restricts which tools reach the model, by name or predicate. */
|
|
13
|
+
toolFilter?: ToolPredicate | string[];
|
|
14
|
+
/** Prefixes every discovered tool name with `${prefix}_`. */
|
|
15
|
+
prefix?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Secure origins to also collect tools from, for cross-origin iframes. A
|
|
18
|
+
* cross-origin tool is only returned if its page also exposed it to this
|
|
19
|
+
* origin via `exposedTo`.
|
|
20
|
+
*/
|
|
21
|
+
fromOrigins?: string[];
|
|
22
|
+
/** Document to read `modelContext` from. Defaults to the global document. */
|
|
23
|
+
document?: WebMCPDocument;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A toolset backed by the tools a web page registers with WebMCP.
|
|
27
|
+
*
|
|
28
|
+
* WebMCP lets a page declare typed, callable tools on `document.modelContext`.
|
|
29
|
+
* This toolset surfaces them to an in-browser agent, so the agent drives the
|
|
30
|
+
* page through the handlers it published instead of scraping the DOM. Each
|
|
31
|
+
* tool's own `execute` runs in the page, so its UI updates as a side effect.
|
|
32
|
+
*
|
|
33
|
+
* Unlike {@link MCPToolset}, nothing is transported anywhere: discovery and
|
|
34
|
+
* execution are same-document browser calls.
|
|
35
|
+
*
|
|
36
|
+
* Outside a browser, or in a browser without WebMCP, `getTools()` returns an
|
|
37
|
+
* empty array rather than throwing, so this is safe to construct anywhere.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import {LlmAgent} from '@google/adk';
|
|
42
|
+
* import {WebMCPToolset} from '@google/adk/tools/webmcp';
|
|
43
|
+
*
|
|
44
|
+
* const agent = new LlmAgent({
|
|
45
|
+
* name: 'page_agent',
|
|
46
|
+
* model: 'gemini-3.8-live',
|
|
47
|
+
* tools: [new WebMCPToolset()],
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @see https://developer.chrome.com/docs/ai/webmcp
|
|
52
|
+
*/
|
|
53
|
+
export declare class WebMCPToolset extends BaseToolset {
|
|
54
|
+
private readonly doc?;
|
|
55
|
+
private readonly fromOrigins?;
|
|
56
|
+
private readonly changeListeners;
|
|
57
|
+
constructor(options?: WebMCPToolsetOptions);
|
|
58
|
+
/** Whether this document exposes WebMCP. */
|
|
59
|
+
isSupported(): boolean;
|
|
60
|
+
getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Subscribes to the WebMCP `toolchange` event, which fires when the page
|
|
63
|
+
* registers or removes tools. Returns an unsubscribe function.
|
|
64
|
+
*/
|
|
65
|
+
onToolChange(listener: () => void): () => void;
|
|
66
|
+
close(): Promise<void>;
|
|
67
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Minimal structural types for the WebMCP browser API.
|
|
8
|
+
*
|
|
9
|
+
* Declared here rather than taken from the `webmcp-types` package so the core
|
|
10
|
+
* package gains no dependency for a browser-only, still-experimental API. They
|
|
11
|
+
* describe only the surface this toolset uses.
|
|
12
|
+
*
|
|
13
|
+
* @see https://developer.chrome.com/docs/ai/webmcp
|
|
14
|
+
*/
|
|
15
|
+
/** Metadata a page may attach to a registered tool. */
|
|
16
|
+
export interface WebMCPToolAnnotations {
|
|
17
|
+
/** The tool only reads state. */
|
|
18
|
+
readOnlyHint?: boolean;
|
|
19
|
+
/** The tool's output may contain untrusted content. */
|
|
20
|
+
untrustedContentHint?: boolean;
|
|
21
|
+
/** The tool performs a significant or non-reversible real-world action. */
|
|
22
|
+
consequentialHint?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** A tool as reported by `document.modelContext.getTools()`. */
|
|
25
|
+
export interface WebMCPRegisteredTool {
|
|
26
|
+
name: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
/**
|
|
30
|
+
* JSON Schema for the tool's arguments.
|
|
31
|
+
*
|
|
32
|
+
* Typed loosely on purpose: the specification says object, but browsers have
|
|
33
|
+
* been observed handing back a JSON string, and a schema that is silently
|
|
34
|
+
* misread leaves the model unable to pass any arguments at all.
|
|
35
|
+
*/
|
|
36
|
+
inputSchema?: object | string;
|
|
37
|
+
annotations?: WebMCPToolAnnotations;
|
|
38
|
+
origin?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Options accepted by `getTools()`. */
|
|
41
|
+
export interface WebMCPGetToolsOptions {
|
|
42
|
+
/** Secure origins to include tools from, for cross-origin iframes. */
|
|
43
|
+
fromOrigins?: string[];
|
|
44
|
+
}
|
|
45
|
+
/** Options accepted by `executeTool()`. */
|
|
46
|
+
export interface WebMCPExecuteToolOptions {
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
}
|
|
49
|
+
/** The `document.modelContext` object. */
|
|
50
|
+
export interface WebMCPModelContext extends EventTarget {
|
|
51
|
+
getTools(options?: WebMCPGetToolsOptions): Promise<WebMCPRegisteredTool[]>;
|
|
52
|
+
executeTool(tool: WebMCPRegisteredTool, args?: unknown, options?: WebMCPExecuteToolOptions): Promise<unknown>;
|
|
53
|
+
}
|
|
54
|
+
/** A Document that may expose WebMCP. */
|
|
55
|
+
export interface WebMCPDocument {
|
|
56
|
+
modelContext?: WebMCPModelContext;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns the WebMCP entry point for a document, or undefined when the browser
|
|
60
|
+
* does not expose one.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getModelContext(doc?: WebMCPDocument): WebMCPModelContext | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Whether WebMCP is available.
|
|
65
|
+
*
|
|
66
|
+
* False outside a browser and in browsers without the API, so importing this
|
|
67
|
+
* module from Node is harmless.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isWebMCPSupported(doc?: WebMCPDocument): boolean;
|
|
@@ -10,3 +10,39 @@
|
|
|
10
10
|
* @returns The converted value.
|
|
11
11
|
*/
|
|
12
12
|
export declare function camelCaseKeys(val: unknown): unknown;
|
|
13
|
+
/**
|
|
14
|
+
* Converts one string into snake_case.
|
|
15
|
+
*
|
|
16
|
+
* Handles lowerCamelCase, UpperCamelCase and space-separated text, as well as
|
|
17
|
+
* acronyms such as `REST API` and runs of consecutive uppercase letters.
|
|
18
|
+
*
|
|
19
|
+
* The `Name` suffix separates this from `toSnakeCase` in
|
|
20
|
+
* `object_notation_utils.ts`, which converts the keys of an object and takes a
|
|
21
|
+
* different argument.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* toSnakeCaseName('camelCase'); // 'camel_case'
|
|
26
|
+
* toSnakeCaseName('UpperCamelCase'); // 'upper_camel_case'
|
|
27
|
+
* toSnakeCaseName('REST API'); // 'rest_api'
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param text The input string.
|
|
31
|
+
* @returns The snake_case form of `text`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function toSnakeCaseName(text: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Prefixes a Python keyword, the way adk-python's `rename_python_keywords`
|
|
36
|
+
* does. Mirrors the reference exactly: the set is Python's, not TypeScript's.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* renameReservedKeywords('in'); // 'param_in'
|
|
41
|
+
* renameReservedKeywords('total'); // 'total'
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param s The candidate identifier.
|
|
45
|
+
* @param prefix The prefix to add when `s` is reserved.
|
|
46
|
+
* @returns `prefix + s` when `s` is reserved, otherwise `s` unchanged.
|
|
47
|
+
*/
|
|
48
|
+
export declare function renameReservedKeywords(s: string, prefix?: string): string;
|