@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
|
@@ -16,6 +16,20 @@ export declare function collectFunctionDeclarations(llmRequest: LlmRequest): Fun
|
|
|
16
16
|
*
|
|
17
17
|
* A single-value `enum` is used rather than `const`, because it is semantically
|
|
18
18
|
* identical and more widely supported across constraint engines.
|
|
19
|
+
*
|
|
20
|
+
* Every branch sets `additionalProperties: false`, and that is load-bearing
|
|
21
|
+
* rather than tidy. Omitted, JSON Schema permits extra keys, so a decoder may
|
|
22
|
+
* emit `,"` after the last required key instead of `}`. The object then never
|
|
23
|
+
* has to close: the model keeps writing until the output runs out, and the
|
|
24
|
+
* reply arrives as truncated JSON. Whether it closes in time is left to
|
|
25
|
+
* sampling, which is why one session can answer a question cleanly and mangle
|
|
26
|
+
* the next. Closing the branch makes `}` the only legal token once `text` is
|
|
27
|
+
* written.
|
|
28
|
+
*
|
|
29
|
+
* It is set on the envelope only, never pushed into a tool's own argument
|
|
30
|
+
* schema. Those belong to the caller; some describe objects that legitimately
|
|
31
|
+
* accept keys they do not list, and forbidding those here would make a valid
|
|
32
|
+
* call impossible to express.
|
|
19
33
|
*/
|
|
20
34
|
export declare function buildToolChoiceSchema(declarations: FunctionDeclaration[]): Record<string, unknown>;
|
|
21
35
|
/** Renders tool declarations into instructions the model can act on. */
|
|
@@ -66,3 +80,18 @@ export declare function stripAdkIdentityPreamble(systemPrompt: string): string;
|
|
|
66
80
|
export declare function isAbortError(error: unknown): boolean;
|
|
67
81
|
export declare function finalText(text: string): LlmResponse;
|
|
68
82
|
export declare function errorResponse(error: unknown): LlmResponse;
|
|
83
|
+
/** Shown when a reply is JSON, is broken, and holds no readable answer. */
|
|
84
|
+
export declare const TRUNCATED_REPLY = "The model started an answer and did not finish it. Ask again.";
|
|
85
|
+
/** True when a reply is the JSON envelope rather than plain prose. */
|
|
86
|
+
export declare function looksLikeEnvelope(raw: string): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Reads the answer out of a truncated `{"kind":"final","text":"…` envelope.
|
|
89
|
+
*
|
|
90
|
+
* A constrained reply that stops early is usually still readable: the answer
|
|
91
|
+
* sits in `text` and only the closing quote and brace are missing. Scanning it
|
|
92
|
+
* out by hand beats `JSON.parse`, which needs the whole document, and beats
|
|
93
|
+
* showing the envelope to the caller.
|
|
94
|
+
*
|
|
95
|
+
* Returns undefined when there is no `text` key to read.
|
|
96
|
+
*/
|
|
97
|
+
export declare function salvageFinalText(raw: string): string | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Part } from '@google/genai';
|
|
7
|
+
import { Context } from '../agents/context.js';
|
|
8
|
+
import { ReadonlyContext } from '../agents/readonly_context.js';
|
|
9
|
+
import { LlmRequest } from '../models/llm_request.js';
|
|
10
|
+
/**
|
|
11
|
+
* A unique symbol to identify ADK planner classes.
|
|
12
|
+
* Defined once and shared by all BasePlanner instances.
|
|
13
|
+
*/
|
|
14
|
+
declare const BASE_PLANNER_SIGNATURE_SYMBOL: unique symbol;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if an object is an instance of BasePlanner.
|
|
17
|
+
* @param obj The object to check.
|
|
18
|
+
* @returns True if the object is an instance of BasePlanner, false otherwise.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isBasePlanner(obj: unknown): obj is BasePlanner;
|
|
21
|
+
/**
|
|
22
|
+
* Abstract base class for all planners.
|
|
23
|
+
*
|
|
24
|
+
* The planner allows the agent to generate plans for the queries to guide its
|
|
25
|
+
* action.
|
|
26
|
+
*/
|
|
27
|
+
export declare abstract class BasePlanner {
|
|
28
|
+
/** A unique symbol to identify ADK base planner class. */
|
|
29
|
+
readonly [BASE_PLANNER_SIGNATURE_SYMBOL] = true;
|
|
30
|
+
/**
|
|
31
|
+
* Builds the system instruction to be appended to the LLM request for
|
|
32
|
+
* planning.
|
|
33
|
+
*
|
|
34
|
+
* @param readonlyContext The readonly context of the invocation.
|
|
35
|
+
* @param llmRequest The LLM request. Readonly.
|
|
36
|
+
* @returns The planning system instruction, or undefined if no instruction is
|
|
37
|
+
* needed.
|
|
38
|
+
*/
|
|
39
|
+
abstract buildPlanningInstruction(readonlyContext: ReadonlyContext, llmRequest: LlmRequest): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Processes the LLM response for planning.
|
|
42
|
+
*
|
|
43
|
+
* @param callbackContext The callback context of the invocation.
|
|
44
|
+
* @param responseParts The LLM response parts. Readonly.
|
|
45
|
+
* @returns The processed response parts, or undefined if no processing is
|
|
46
|
+
* needed.
|
|
47
|
+
*/
|
|
48
|
+
abstract processPlanningResponse(callbackContext: Context, responseParts: Part[]): Part[] | undefined;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Part, ThinkingConfig } from '@google/genai';
|
|
7
|
+
import { Context } from '../agents/context.js';
|
|
8
|
+
import { ReadonlyContext } from '../agents/readonly_context.js';
|
|
9
|
+
import { LlmRequest } from '../models/llm_request.js';
|
|
10
|
+
import { BasePlanner } from './base_planner.js';
|
|
11
|
+
/**
|
|
12
|
+
* A unique symbol to identify ADK built-in planner classes.
|
|
13
|
+
* Defined once and shared by all BuiltInPlanner instances.
|
|
14
|
+
*/
|
|
15
|
+
declare const BUILT_IN_PLANNER_SIGNATURE_SYMBOL: unique symbol;
|
|
16
|
+
/**
|
|
17
|
+
* Type guard to check if an object is an instance of BuiltInPlanner.
|
|
18
|
+
* @param obj The object to check.
|
|
19
|
+
* @returns True if the object is an instance of BuiltInPlanner, false
|
|
20
|
+
* otherwise.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isBuiltInPlanner(obj: unknown): obj is BuiltInPlanner;
|
|
23
|
+
/**
|
|
24
|
+
* The built-in planner that uses model's built-in thinking features.
|
|
25
|
+
*/
|
|
26
|
+
export declare class BuiltInPlanner extends BasePlanner {
|
|
27
|
+
/** A unique symbol to identify ADK built-in planner class. */
|
|
28
|
+
readonly [BUILT_IN_PLANNER_SIGNATURE_SYMBOL] = true;
|
|
29
|
+
/**
|
|
30
|
+
* Config for model built-in thinking features. An error will be returned if
|
|
31
|
+
* this field is set for models that don't support thinking.
|
|
32
|
+
*/
|
|
33
|
+
thinkingConfig: ThinkingConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Initializes the built-in planner.
|
|
36
|
+
*
|
|
37
|
+
* @param options.thinkingConfig Config for model built-in thinking features.
|
|
38
|
+
* An error will be returned if this field is set for models that don't
|
|
39
|
+
* support thinking.
|
|
40
|
+
*/
|
|
41
|
+
constructor(options: {
|
|
42
|
+
thinkingConfig: ThinkingConfig;
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Applies the thinking config to the LLM request.
|
|
46
|
+
*
|
|
47
|
+
* @param llmRequest The LLM request to apply the thinking config to.
|
|
48
|
+
*/
|
|
49
|
+
applyThinkingConfig(llmRequest: LlmRequest): void;
|
|
50
|
+
buildPlanningInstruction(_readonlyContext: ReadonlyContext, _llmRequest: LlmRequest): string | undefined;
|
|
51
|
+
processPlanningResponse(_callbackContext: Context, _responseParts: Part[]): Part[] | undefined;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Part } from '@google/genai';
|
|
7
|
+
import { Context } from '../agents/context.js';
|
|
8
|
+
import { ReadonlyContext } from '../agents/readonly_context.js';
|
|
9
|
+
import { LlmRequest } from '../models/llm_request.js';
|
|
10
|
+
import { BasePlanner } from './base_planner.js';
|
|
11
|
+
/**
|
|
12
|
+
* Plan-Re-Act planner that constrains the LLM response to generate a plan
|
|
13
|
+
* before any action/observation.
|
|
14
|
+
*
|
|
15
|
+
* Note: this planner does not require the model to support built-in thinking
|
|
16
|
+
* features or setting the thinking config.
|
|
17
|
+
*/
|
|
18
|
+
export declare class PlanReActPlanner extends BasePlanner {
|
|
19
|
+
buildPlanningInstruction(_readonlyContext: ReadonlyContext, _llmRequest: LlmRequest): string;
|
|
20
|
+
processPlanningResponse(_callbackContext: Context, responseParts: Part[]): Part[] | undefined;
|
|
21
|
+
}
|
|
@@ -121,13 +121,13 @@ export declare abstract class BasePlugin {
|
|
|
121
121
|
* This callback helps logging and modifying the user message before the
|
|
122
122
|
* runner starts the invocation.
|
|
123
123
|
*
|
|
124
|
-
* @param
|
|
125
|
-
* @param
|
|
124
|
+
* @param _params.invocationContext The context for the entire invocation.
|
|
125
|
+
* @param _params.userMessage The message content input by user.
|
|
126
126
|
* @returns An optional `Content` to be returned to the ADK. Returning a
|
|
127
127
|
* value to replace the user message. Returning `undefined` to proceed
|
|
128
128
|
* normally.
|
|
129
129
|
*/
|
|
130
|
-
onUserMessageCallback(
|
|
130
|
+
onUserMessageCallback(_params: {
|
|
131
131
|
invocationContext: InvocationContext;
|
|
132
132
|
userMessage: Content;
|
|
133
133
|
}): Promise<Content | undefined>;
|
|
@@ -137,13 +137,13 @@ export declare abstract class BasePlugin {
|
|
|
137
137
|
* This is the first callback to be called in the lifecycle, ideal for global
|
|
138
138
|
* setup or initialization tasks.
|
|
139
139
|
*
|
|
140
|
-
* @param
|
|
140
|
+
* @param _params.invocationContext The context for the entire invocation, containing
|
|
141
141
|
* session information, the root agent, etc.
|
|
142
142
|
* @returns An optional `Event` to be returned to the ADK. Returning a value
|
|
143
143
|
* to halt execution of the runner and ends the runner with that event.
|
|
144
144
|
* Return `undefined` to proceed normally.
|
|
145
145
|
*/
|
|
146
|
-
beforeRunCallback(
|
|
146
|
+
beforeRunCallback(_params: {
|
|
147
147
|
invocationContext: InvocationContext;
|
|
148
148
|
}): Promise<Content | undefined>;
|
|
149
149
|
/**
|
|
@@ -152,15 +152,15 @@ export declare abstract class BasePlugin {
|
|
|
152
152
|
* This is the ideal place to make modification to the event before the event
|
|
153
153
|
* is handled by the underlying agent app.
|
|
154
154
|
*
|
|
155
|
-
* @param
|
|
156
|
-
* @param
|
|
155
|
+
* @param _params.invocationContext The context for the entire invocation.
|
|
156
|
+
* @param _params.event The event raised by the runner.
|
|
157
157
|
* @returns An optional value. A non-`undefined` return may be used by the
|
|
158
|
-
* framework to modify or replace the response. Copy
|
|
159
|
-
* constructing a replacement to preserve fields that are not
|
|
160
|
-
* modified, such as event actions. Returning `undefined` allows the
|
|
158
|
+
* framework to modify or replace the response. Copy the incoming
|
|
159
|
+
* `event` when constructing a replacement to preserve fields that are not
|
|
160
|
+
* being modified, such as event actions. Returning `undefined` allows the
|
|
161
161
|
* original response to be used.
|
|
162
162
|
*/
|
|
163
|
-
onEventCallback(
|
|
163
|
+
onEventCallback(_params: {
|
|
164
164
|
invocationContext: InvocationContext;
|
|
165
165
|
event: Event;
|
|
166
166
|
}): Promise<Event | undefined>;
|
|
@@ -170,10 +170,10 @@ export declare abstract class BasePlugin {
|
|
|
170
170
|
* This is the final callback in the ADK lifecycle, suitable for cleanup,
|
|
171
171
|
* final logging, or reporting tasks.
|
|
172
172
|
*
|
|
173
|
-
* @param
|
|
173
|
+
* @param _params.invocationContext The context for the entire invocation.
|
|
174
174
|
* @returns undefined
|
|
175
175
|
*/
|
|
176
|
-
afterRunCallback(
|
|
176
|
+
afterRunCallback(_params: {
|
|
177
177
|
invocationContext: InvocationContext;
|
|
178
178
|
}): Promise<void>;
|
|
179
179
|
/**
|
|
@@ -182,13 +182,13 @@ export declare abstract class BasePlugin {
|
|
|
182
182
|
* This callback can be used for logging, setup, or to short-circuit the
|
|
183
183
|
* agent's execution by returning a value.
|
|
184
184
|
*
|
|
185
|
-
* @param
|
|
186
|
-
* @param
|
|
185
|
+
* @param _params.agent The agent that is about to run.
|
|
186
|
+
* @param _params.callbackContext The context for the agent invocation.
|
|
187
187
|
* @returns An optional `Content` object. If a value is returned, it will
|
|
188
188
|
* bypass the agent's callbacks and its execution, and return this value
|
|
189
189
|
* directly. Returning `undefined` allows the agent to proceed normally.
|
|
190
190
|
*/
|
|
191
|
-
beforeAgentCallback(
|
|
191
|
+
beforeAgentCallback(_params: {
|
|
192
192
|
agent: BaseAgent;
|
|
193
193
|
callbackContext: Context;
|
|
194
194
|
}): Promise<Content | undefined>;
|
|
@@ -198,13 +198,13 @@ export declare abstract class BasePlugin {
|
|
|
198
198
|
* This callback can be used to inspect, log, or modify the agent's final
|
|
199
199
|
* result before it is returned.
|
|
200
200
|
*
|
|
201
|
-
* @param
|
|
202
|
-
* @param
|
|
201
|
+
* @param _params.agent The agent that has just run.
|
|
202
|
+
* @param _params.callbackContext The context for the agent invocation.
|
|
203
203
|
* @returns An optional `Content` object. If a value is returned, it will
|
|
204
204
|
* replace the agent's original result. Returning `undefined` uses the
|
|
205
205
|
* original, unmodified result.
|
|
206
206
|
*/
|
|
207
|
-
afterAgentCallback(
|
|
207
|
+
afterAgentCallback(_params: {
|
|
208
208
|
agent: BaseAgent;
|
|
209
209
|
callbackContext: Context;
|
|
210
210
|
}): Promise<Content | undefined>;
|
|
@@ -248,13 +248,13 @@ export declare abstract class BasePlugin {
|
|
|
248
248
|
* object. It can also be used to implement caching by returning a cached
|
|
249
249
|
* `LlmResponse`, which would skip the actual model call.
|
|
250
250
|
*
|
|
251
|
-
* @param
|
|
252
|
-
* @param
|
|
251
|
+
* @param _params.callbackContext The context for the current agent call.
|
|
252
|
+
* @param _params.llmRequest The prepared request object to be sent to the model.
|
|
253
253
|
* @returns An optional value. The interpretation of a non-`undefined`
|
|
254
254
|
* trigger an early exit and returns the response immediately. Returning
|
|
255
255
|
* `undefined` allows the LLM request to proceed normally.
|
|
256
256
|
*/
|
|
257
|
-
beforeModelCallback(
|
|
257
|
+
beforeModelCallback(_params: {
|
|
258
258
|
callbackContext: Context;
|
|
259
259
|
llmRequest: LlmRequest;
|
|
260
260
|
}): Promise<LlmResponse | undefined>;
|
|
@@ -264,13 +264,13 @@ export declare abstract class BasePlugin {
|
|
|
264
264
|
* This is the ideal place to log model responses, collect metrics on token
|
|
265
265
|
* usage, or perform post-processing on the raw `LlmResponse`.
|
|
266
266
|
*
|
|
267
|
-
* @param
|
|
268
|
-
* @param
|
|
267
|
+
* @param _params.callbackContext The context for the current agent call.
|
|
268
|
+
* @param _params.llmResponse The response object received from the model.
|
|
269
269
|
* @returns An optional value. A non-`undefined` return may be used by the
|
|
270
270
|
* framework to modify or replace the response. Returning `undefined`
|
|
271
271
|
* allows the original response to be used.
|
|
272
272
|
*/
|
|
273
|
-
afterModelCallback(
|
|
273
|
+
afterModelCallback(_params: {
|
|
274
274
|
callbackContext: Context;
|
|
275
275
|
llmResponse: LlmResponse;
|
|
276
276
|
}): Promise<LlmResponse | undefined>;
|
|
@@ -280,15 +280,15 @@ export declare abstract class BasePlugin {
|
|
|
280
280
|
* This callback provides an opportunity to handle model errors gracefully,
|
|
281
281
|
* potentially providing alternative responses or recovery mechanisms.
|
|
282
282
|
*
|
|
283
|
-
* @param
|
|
284
|
-
* @param
|
|
283
|
+
* @param _params.callbackContext The context for the current agent call.
|
|
284
|
+
* @param _params.llmRequest The request that was sent to the model when the error
|
|
285
285
|
* occurred.
|
|
286
|
-
* @param
|
|
286
|
+
* @param _params.error The exception that was raised during model execution.
|
|
287
287
|
* @returns An optional LlmResponse. If an LlmResponse is returned, it will be
|
|
288
288
|
* used instead of propagating the error. Returning `undefined` allows
|
|
289
289
|
* the original error to be raised.
|
|
290
290
|
*/
|
|
291
|
-
onModelErrorCallback(
|
|
291
|
+
onModelErrorCallback(_params: {
|
|
292
292
|
callbackContext: Context;
|
|
293
293
|
llmRequest: LlmRequest;
|
|
294
294
|
error: Error;
|
|
@@ -299,13 +299,13 @@ export declare abstract class BasePlugin {
|
|
|
299
299
|
* This callback provides an opportunity to inspect, log, or modify the
|
|
300
300
|
* available tools before they are selected.
|
|
301
301
|
*
|
|
302
|
-
* @param
|
|
303
|
-
* @param
|
|
302
|
+
* @param _params.callbackContext The context for the current agent call.
|
|
303
|
+
* @param _params.tools The available tools.
|
|
304
304
|
* @returns An optional value. A non-`undefined` return may be used by the
|
|
305
305
|
* framework to modify or replace the available tools. Returning
|
|
306
306
|
* `undefined` allows the original tools to be used.
|
|
307
307
|
*/
|
|
308
|
-
beforeToolSelection(
|
|
308
|
+
beforeToolSelection(_params: {
|
|
309
309
|
callbackContext: Context;
|
|
310
310
|
tools: Readonly<Record<string, BaseTool>>;
|
|
311
311
|
}): Promise<Readonly<Record<string, BaseTool>> | undefined>;
|
|
@@ -315,10 +315,10 @@ export declare abstract class BasePlugin {
|
|
|
315
315
|
* This callback provides an opportunity to inspect or modify the context
|
|
316
316
|
* before it is compacted.
|
|
317
317
|
*
|
|
318
|
-
* @param
|
|
319
|
-
* @param
|
|
318
|
+
* @param _params.invocationContext The context for the entire invocation.
|
|
319
|
+
* @param _params.trigger The trigger for the context compaction.
|
|
320
320
|
*/
|
|
321
|
-
beforeContextCompaction(
|
|
321
|
+
beforeContextCompaction(_params: {
|
|
322
322
|
invocationContext: InvocationContext;
|
|
323
323
|
trigger: ContextCompactionTrigger;
|
|
324
324
|
}): Promise<void>;
|
|
@@ -328,10 +328,10 @@ export declare abstract class BasePlugin {
|
|
|
328
328
|
* This callback provides an opportunity to inspect the context
|
|
329
329
|
* after it has been compacted.
|
|
330
330
|
*
|
|
331
|
-
* @param
|
|
332
|
-
* @param
|
|
331
|
+
* @param _params.invocationContext The context for the entire invocation.
|
|
332
|
+
* @param _params.trigger The trigger for the context compaction.
|
|
333
333
|
*/
|
|
334
|
-
afterContextCompaction(
|
|
334
|
+
afterContextCompaction(_params: {
|
|
335
335
|
invocationContext: InvocationContext;
|
|
336
336
|
trigger: ContextCompactionTrigger;
|
|
337
337
|
}): Promise<void>;
|
|
@@ -341,15 +341,15 @@ export declare abstract class BasePlugin {
|
|
|
341
341
|
* This callback is useful for logging tool usage, input validation, or
|
|
342
342
|
* modifying the arguments before they are passed to the tool.
|
|
343
343
|
*
|
|
344
|
-
* @param
|
|
345
|
-
* @param
|
|
344
|
+
* @param _params.tool The tool instance that is about to be executed.
|
|
345
|
+
* @param _params.toolArgs The dictionary of arguments to be used for invoking the
|
|
346
346
|
* tool.
|
|
347
|
-
* @param
|
|
347
|
+
* @param _params.toolContext The context specific to the tool execution.
|
|
348
348
|
* @returns An optional dictionary. If a dictionary is returned, it will stop
|
|
349
349
|
* the tool execution and return this response immediately. Returning
|
|
350
350
|
* `undefined` uses the original, unmodified arguments.
|
|
351
351
|
*/
|
|
352
|
-
beforeToolCallback(
|
|
352
|
+
beforeToolCallback(_params: {
|
|
353
353
|
tool: BaseTool;
|
|
354
354
|
toolArgs: Record<string, unknown>;
|
|
355
355
|
toolContext: Context;
|
|
@@ -360,16 +360,16 @@ export declare abstract class BasePlugin {
|
|
|
360
360
|
* This callback allows for inspecting, logging, or modifying the result
|
|
361
361
|
* returned by a tool.
|
|
362
362
|
*
|
|
363
|
-
* @param
|
|
364
|
-
* @param
|
|
365
|
-
* @param
|
|
366
|
-
* @param
|
|
363
|
+
* @param _params.tool The tool instance that has just been executed.
|
|
364
|
+
* @param _params.toolArgs The original arguments that were passed to the tool.
|
|
365
|
+
* @param _params.toolContext The context specific to the tool execution.
|
|
366
|
+
* @param _params.result The dictionary returned by the tool invocation.
|
|
367
367
|
* @returns An optional dictionary. If a dictionary is returned, it will
|
|
368
368
|
* **replace** the original result from the tool. This allows for
|
|
369
369
|
* post-processing or altering tool outputs. Returning `undefined` uses
|
|
370
370
|
* the original, unmodified result.
|
|
371
371
|
*/
|
|
372
|
-
afterToolCallback(
|
|
372
|
+
afterToolCallback(_params: {
|
|
373
373
|
tool: BaseTool;
|
|
374
374
|
toolArgs: Record<string, unknown>;
|
|
375
375
|
toolContext: Context;
|
|
@@ -391,15 +391,15 @@ export declare abstract class BasePlugin {
|
|
|
391
391
|
* This callback provides an opportunity to handle tool errors gracefully,
|
|
392
392
|
* potentially providing alternative responses or recovery mechanisms.
|
|
393
393
|
*
|
|
394
|
-
* @param
|
|
395
|
-
* @param
|
|
396
|
-
* @param
|
|
397
|
-
* @param
|
|
394
|
+
* @param _params.tool The tool instance that encountered an error.
|
|
395
|
+
* @param _params.toolArgs The arguments that were passed to the tool.
|
|
396
|
+
* @param _params.toolContext The context specific to the tool execution.
|
|
397
|
+
* @param _params.error The exception that was raised during tool execution.
|
|
398
398
|
* @returns An optional dictionary. If a dictionary is returned, it will be
|
|
399
399
|
* used as the tool response instead of propagating the error. Returning
|
|
400
400
|
* `undefined` allows the original error to be raised.
|
|
401
401
|
*/
|
|
402
|
-
onToolErrorCallback(
|
|
402
|
+
onToolErrorCallback(_params: {
|
|
403
403
|
tool: BaseTool;
|
|
404
404
|
toolArgs: Record<string, unknown>;
|
|
405
405
|
toolContext: Context;
|
|
@@ -26,4 +26,12 @@ export interface SkillRegistry {
|
|
|
26
26
|
* Returns the description for the search_skills tool.
|
|
27
27
|
*/
|
|
28
28
|
searchToolDescription?(): string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Releases resources held by the registry, such as network clients or
|
|
31
|
+
* temporary credentials.
|
|
32
|
+
*
|
|
33
|
+
* Optional: registries that hold no resources may omit it. `SkillToolset`
|
|
34
|
+
* invokes it, when present, from its own `close()`.
|
|
35
|
+
*/
|
|
36
|
+
close?(): Promise<void>;
|
|
29
37
|
}
|
|
@@ -4,7 +4,14 @@
|
|
|
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
|
+
import { AuthCredential, ServiceAccount } from '../../../auth/auth_credential.js';
|
|
8
|
+
import { AuthScheme, OpenIdConnectWithConfig } from '../../../auth/auth_schemes.js';
|
|
9
|
+
import { ApiParameter } from '../openapi_spec_parser/operation_parser.js';
|
|
10
|
+
/**
|
|
11
|
+
* Prefix that marks a tool parameter as auth-injected rather than
|
|
12
|
+
* model-supplied.
|
|
13
|
+
*/
|
|
14
|
+
export declare const INTERNAL_AUTH_PREFIX = "_auth_prefix_vaf_";
|
|
8
15
|
/**
|
|
9
16
|
* Applies the given credential to the request headers and URL.
|
|
10
17
|
*
|
|
@@ -28,3 +35,105 @@ export declare function createApiKeyScheme(name: string, inLocation: 'header' |
|
|
|
28
35
|
* Helper to create a simple Bearer Token auth scheme.
|
|
29
36
|
*/
|
|
30
37
|
export declare function createBearerScheme(): OpenAPIV3.SecuritySchemeObject;
|
|
38
|
+
/**
|
|
39
|
+
* Creates an AuthScheme and AuthCredential for an API key or a bearer token.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // API key in a header.
|
|
43
|
+
* const [scheme, credential] = tokenToSchemeCredential(
|
|
44
|
+
* 'apikey', 'header', 'X-API-Key', 'your_api_key_value');
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // OAuth2 bearer token in the Authorization header.
|
|
48
|
+
* const [scheme, credential] = tokenToSchemeCredential(
|
|
49
|
+
* 'oauth2Token', 'header', 'Authorization', 'your_bearer_token_value');
|
|
50
|
+
*
|
|
51
|
+
* @param tokenType `'apikey'` or `'oauth2Token'`.
|
|
52
|
+
* @param location Where the API key travels. Ignored for `'oauth2Token'`,
|
|
53
|
+
* because a bearer token always travels in the Authorization header.
|
|
54
|
+
* @param name The name of the header, query parameter, or cookie.
|
|
55
|
+
* @param credentialValue The API key or token value. Omit it to build the
|
|
56
|
+
* scheme alone.
|
|
57
|
+
* @returns A `[scheme, credential]` pair. The credential is `undefined` when
|
|
58
|
+
* `credentialValue` is omitted.
|
|
59
|
+
* @throws Error For an unsupported token type or API key location.
|
|
60
|
+
*/
|
|
61
|
+
export declare function tokenToSchemeCredential(tokenType: 'apikey' | 'oauth2Token', location?: 'header' | 'query' | 'cookie', name?: string, credentialValue?: string): [AuthScheme, AuthCredential | undefined];
|
|
62
|
+
/**
|
|
63
|
+
* Creates a bearer scheme and a service-account credential from a raw Google
|
|
64
|
+
* service-account JSON object.
|
|
65
|
+
*
|
|
66
|
+
* @param config The parsed service-account key file.
|
|
67
|
+
* @param scopes The scopes to request.
|
|
68
|
+
* @returns A `[scheme, credential]` pair.
|
|
69
|
+
*/
|
|
70
|
+
export declare function serviceAccountDictToSchemeCredential(config: Record<string, unknown>, scopes: string[]): [AuthScheme, AuthCredential];
|
|
71
|
+
/**
|
|
72
|
+
* Creates a bearer scheme and a service-account credential from an already
|
|
73
|
+
* built `ServiceAccount`.
|
|
74
|
+
*
|
|
75
|
+
* @param config The service-account configuration.
|
|
76
|
+
* @returns A `[scheme, credential]` pair.
|
|
77
|
+
*/
|
|
78
|
+
export declare function serviceAccountSchemeCredential(config: ServiceAccount): [AuthScheme, AuthCredential];
|
|
79
|
+
/**
|
|
80
|
+
* Builds an OpenID Connect scheme and credential from a configuration object
|
|
81
|
+
* and a client-secret object.
|
|
82
|
+
*
|
|
83
|
+
* @param configDict An OpenID Connect configuration. Snake_case keys, as a
|
|
84
|
+
* discovery document delivers them, are accepted and normalized.
|
|
85
|
+
* @param scopes The scopes to request.
|
|
86
|
+
* @param credentialDict The Google OAuth client secret. Its keys stay
|
|
87
|
+
* snake_case, because it is an on-disk wire format. A `{web: {…}}` or
|
|
88
|
+
* `{installed: {…}}` wrapper is unwrapped.
|
|
89
|
+
* @returns A `[scheme, credential]` pair.
|
|
90
|
+
* @throws Error When the configuration or the client secret is incomplete.
|
|
91
|
+
*/
|
|
92
|
+
export declare function openidDictToSchemeCredential(configDict: Record<string, unknown>, scopes: string[], credentialDict: Record<string, unknown>): [OpenIdConnectWithConfig, AuthCredential];
|
|
93
|
+
/**
|
|
94
|
+
* Fetches an OpenID Connect discovery document and pairs it with a client
|
|
95
|
+
* secret.
|
|
96
|
+
*
|
|
97
|
+
* The URL is used as given. A caller that accepts it from an untrusted source
|
|
98
|
+
* has to validate it first, because this function performs the request.
|
|
99
|
+
*
|
|
100
|
+
* @param openidUrl The OpenID Connect discovery URL.
|
|
101
|
+
* @param scopes The scopes to request.
|
|
102
|
+
* @param credentialDict The Google OAuth client secret, keyed snake_case.
|
|
103
|
+
* @returns A `[scheme, credential]` pair.
|
|
104
|
+
* @throws Error When the request fails, the body is not a JSON object, or the
|
|
105
|
+
* configuration is incomplete.
|
|
106
|
+
*/
|
|
107
|
+
export declare function openidUrlToSchemeCredential(openidUrl: string, scopes: string[], credentialDict: Record<string, unknown>): Promise<[OpenIdConnectWithConfig, AuthCredential]>;
|
|
108
|
+
/**
|
|
109
|
+
* Converts a scheme and credential into the tool parameter that carries the
|
|
110
|
+
* credential, plus the value to send for it.
|
|
111
|
+
*
|
|
112
|
+
* Service-account, OAuth2, and OpenID Connect credentials reach this function
|
|
113
|
+
* already exchanged for a bearer token, so they take the HTTP branch.
|
|
114
|
+
*
|
|
115
|
+
* @param authScheme The auth scheme.
|
|
116
|
+
* @param authCredential The auth credential.
|
|
117
|
+
* @returns A `[parameter, values]` pair, both `undefined` when the credential
|
|
118
|
+
* carries nothing to send.
|
|
119
|
+
* @throws Error For basic authentication, which is not supported, and for a
|
|
120
|
+
* scheme and credential combination that cannot be expressed as a parameter.
|
|
121
|
+
*/
|
|
122
|
+
export declare function credentialToParam(authScheme: AuthScheme, authCredential?: AuthCredential): [ApiParameter | undefined, Record<string, string> | undefined];
|
|
123
|
+
/**
|
|
124
|
+
* Converts a security scheme object out of an OpenAPI document into an
|
|
125
|
+
* `AuthScheme`.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* const scheme = dictToAuthScheme({
|
|
129
|
+
* type: 'apiKey',
|
|
130
|
+
* in: 'header',
|
|
131
|
+
* name: 'X-API-Key',
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* @param data The security scheme object.
|
|
135
|
+
* @returns The validated auth scheme.
|
|
136
|
+
* @throws Error When `type` is missing or unrecognised, or the rest of the
|
|
137
|
+
* object does not match the shape that type requires.
|
|
138
|
+
*/
|
|
139
|
+
export declare function dictToAuthScheme(data: Record<string, unknown>): AuthScheme;
|
package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts
CHANGED
|
@@ -3,17 +3,47 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { AuthCredential } from '../../../../auth/auth_credential.js';
|
|
6
|
+
import { AuthCredential, AuthCredentialTypes } from '../../../../auth/auth_credential.js';
|
|
7
7
|
import { AuthScheme } from '../../../../auth/auth_schemes.js';
|
|
8
8
|
import { BaseCredentialExchanger, ExchangeResult } from '../../../../auth/exchanger/base_credential_exchanger.js';
|
|
9
|
+
/**
|
|
10
|
+
* A map from auth credential type to the exchanger that handles it, merged
|
|
11
|
+
* over the built-in defaults.
|
|
12
|
+
*/
|
|
13
|
+
export type CustomCredentialExchangers = Partial<Record<AuthCredentialTypes, BaseCredentialExchanger>>;
|
|
9
14
|
/**
|
|
10
15
|
* Automatically selects the appropriate credential exchanger based on the auth scheme.
|
|
16
|
+
* Ported from Python implementation.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Common case: a built-in exchanger handles the credential.
|
|
20
|
+
* const exchanger = new AutoAuthCredentialExchanger();
|
|
21
|
+
* const result = await exchanger.exchange({
|
|
22
|
+
* authScheme: serviceAccountScheme,
|
|
23
|
+
* authCredential: serviceAccountCredential,
|
|
24
|
+
* });
|
|
25
|
+
* // result.credential carries an OAuth token as a bearer token.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Use CustomAuthExchanger for OAuth2 instead of the built-in exchanger.
|
|
29
|
+
* const exchanger = new AutoAuthCredentialExchanger({
|
|
30
|
+
* [AuthCredentialTypes.OAUTH2]: new CustomAuthExchanger(),
|
|
31
|
+
* });
|
|
11
32
|
*/
|
|
12
33
|
export declare class AutoAuthCredentialExchanger implements BaseCredentialExchanger {
|
|
13
34
|
private exchangers;
|
|
14
|
-
|
|
35
|
+
/**
|
|
36
|
+
* @param customExchangers - Optional exchangers that add to or override the
|
|
37
|
+
* built-in ones. The key is the auth credential type; the value is the
|
|
38
|
+
* exchanger instance to use for that type.
|
|
39
|
+
*/
|
|
40
|
+
constructor(customExchangers?: CustomCredentialExchangers);
|
|
15
41
|
exchange(params: {
|
|
16
42
|
authScheme?: AuthScheme;
|
|
17
43
|
authCredential: AuthCredential;
|
|
18
44
|
}): Promise<ExchangeResult>;
|
|
45
|
+
exchange(params: {
|
|
46
|
+
authScheme?: AuthScheme;
|
|
47
|
+
authCredential?: AuthCredential;
|
|
48
|
+
}): Promise<ExchangeResult | null>;
|
|
19
49
|
}
|
package/dist/types/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Error raised when a required authentication credential is missing.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AuthCredentialMissingError extends Error {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Base class for authentication credential exchangers.
|
|
16
|
+
*
|
|
17
|
+
* A subclass exchanges the credential an OpenAPI tool was configured with for
|
|
18
|
+
* one that can be sent to the API. The base implementation always throws, so a
|
|
19
|
+
* subclass that forgets to override the method fails on the first call rather
|
|
20
|
+
* than silently returning nothing.
|
|
21
|
+
*/
|
|
22
|
+
export declare class BaseAuthCredentialExchanger {
|
|
23
|
+
/**
|
|
24
|
+
* Exchanges the provided authentication credential for a usable
|
|
25
|
+
* token or credential.
|
|
26
|
+
*
|
|
27
|
+
* @param _authScheme The security scheme.
|
|
28
|
+
* @param _authCredential The authentication credential.
|
|
29
|
+
* @returns An updated AuthCredential object containing the fetched
|
|
30
|
+
* credential. For simple schemes like API key, it may return the original
|
|
31
|
+
* credential if no exchange is needed.
|
|
32
|
+
* @throws {Error} If the method is not implemented by a subclass.
|
|
33
|
+
*/
|
|
34
|
+
exchangeCredential(_authScheme: AuthScheme, _authCredential?: AuthCredential): AuthCredential;
|
|
35
|
+
}
|