@google/adk 2.1.0 → 2.2.1
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/a2a/event_converter_utils.js +5 -1
- package/dist/cjs/a2a/metadata_converter_utils.js +2 -1
- 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 +63 -0
- package/dist/cjs/events/abort_events.js +135 -0
- package/dist/cjs/events/internal_metadata.js +131 -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_continuation.js +232 -0
- 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/plugins/debug_logging_plugin.js +653 -0
- package/dist/cjs/plugins/plugin_manager.js +1 -1
- package/dist/cjs/plugins/tool_call_integrity_plugin.js +364 -0
- package/dist/cjs/runner/runner.js +17 -3
- 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/a2a/event_converter_utils.js +5 -1
- package/dist/esm/a2a/metadata_converter_utils.js +2 -1
- 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 +58 -2
- package/dist/esm/events/abort_events.js +110 -0
- package/dist/esm/events/internal_metadata.js +97 -0
- 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_continuation.js +205 -0
- 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/plugins/debug_logging_plugin.js +615 -0
- package/dist/esm/plugins/plugin_manager.js +1 -1
- package/dist/esm/plugins/tool_call_integrity_plugin.js +339 -0
- package/dist/esm/runner/runner.js +20 -3
- 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 +19 -4
- package/dist/types/events/abort_events.d.ts +43 -0
- package/dist/types/events/internal_metadata.d.ts +78 -0
- 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/models/gemini_continuation.d.ts +59 -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/plugins/debug_logging_plugin.d.ts +157 -0
- package/dist/types/plugins/tool_call_integrity_plugin.d.ts +116 -0
- 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 +113 -80
- package/dist/web/index_web.js.map +4 -4
- package/package.json +8 -2
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Content } from '@google/genai';
|
|
7
|
+
import { BaseAgent } from '../agents/base_agent.js';
|
|
8
|
+
import { Context } from '../agents/context.js';
|
|
9
|
+
import { InvocationContext } from '../agents/invocation_context.js';
|
|
10
|
+
import { Event } from '../events/event.js';
|
|
11
|
+
import { LlmRequest } from '../models/llm_request.js';
|
|
12
|
+
import { LlmResponse } from '../models/llm_response.js';
|
|
13
|
+
import { BaseTool } from '../tools/base_tool.js';
|
|
14
|
+
import { BasePlugin } from './base_plugin.js';
|
|
15
|
+
declare const DEBUG_LOGGING_PLUGIN_SYMBOL: unique symbol;
|
|
16
|
+
/**
|
|
17
|
+
* Options for configuring {@link DebugLoggingPlugin}.
|
|
18
|
+
*/
|
|
19
|
+
export interface DebugLoggingPluginOptions {
|
|
20
|
+
/**
|
|
21
|
+
* The name of the plugin instance.
|
|
22
|
+
* @defaultValue 'debug_logging_plugin'
|
|
23
|
+
*/
|
|
24
|
+
name?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Path to the output YAML debug file.
|
|
27
|
+
* @defaultValue 'adk_debug.yaml'
|
|
28
|
+
*/
|
|
29
|
+
outputPath?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to include a session state snapshot at the end of each invocation.
|
|
32
|
+
* @defaultValue true
|
|
33
|
+
*/
|
|
34
|
+
includeSessionState?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to include full system instructions in LLM request logs.
|
|
37
|
+
* @defaultValue true
|
|
38
|
+
*/
|
|
39
|
+
includeSystemInstruction?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A single debug log entry recorded during an invocation.
|
|
43
|
+
*/
|
|
44
|
+
export interface DebugEntry {
|
|
45
|
+
timestamp: string;
|
|
46
|
+
entry_type: string;
|
|
47
|
+
invocation_id?: string;
|
|
48
|
+
agent_name?: string;
|
|
49
|
+
data: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Per-invocation debug state written as a YAML document.
|
|
53
|
+
*/
|
|
54
|
+
export interface InvocationDebugState {
|
|
55
|
+
invocation_id: string;
|
|
56
|
+
session_id: string;
|
|
57
|
+
app_name: string;
|
|
58
|
+
user_id?: string;
|
|
59
|
+
start_time: string;
|
|
60
|
+
entries: DebugEntry[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Type guard to check if an object is an instance of {@link DebugLoggingPlugin}.
|
|
64
|
+
*/
|
|
65
|
+
export declare function isDebugLoggingPlugin(obj: unknown): obj is DebugLoggingPlugin;
|
|
66
|
+
/**
|
|
67
|
+
* A plugin that captures complete debug information to a YAML file.
|
|
68
|
+
*
|
|
69
|
+
* This plugin records detailed interaction data including:
|
|
70
|
+
* - LLM requests (model, system instruction, contents, tools)
|
|
71
|
+
* - LLM responses (content, usage metadata, errors)
|
|
72
|
+
* - Function calls with arguments
|
|
73
|
+
* - Function responses with results
|
|
74
|
+
* - Events yielded from the runner
|
|
75
|
+
* - Session state at the end of each invocation
|
|
76
|
+
*
|
|
77
|
+
* Each invocation is appended to the output file as a separate YAML document
|
|
78
|
+
* (separated by `---`). Credentials, sensitive keys, `temp:`-scoped state keys,
|
|
79
|
+
* and armored private key blocks are automatically redacted to `[REDACTED]`.
|
|
80
|
+
*/
|
|
81
|
+
export declare class DebugLoggingPlugin extends BasePlugin {
|
|
82
|
+
readonly [DEBUG_LOGGING_PLUGIN_SYMBOL] = true;
|
|
83
|
+
readonly outputPath: string;
|
|
84
|
+
readonly includeSessionState: boolean;
|
|
85
|
+
readonly includeSystemInstruction: boolean;
|
|
86
|
+
private readonly invocationStates;
|
|
87
|
+
private warnedAboutOutputMode;
|
|
88
|
+
constructor(options?: DebugLoggingPluginOptions);
|
|
89
|
+
/**
|
|
90
|
+
* Exposes active invocation states for testing and inspection.
|
|
91
|
+
*/
|
|
92
|
+
getInvocationState(invocationId: string): InvocationDebugState | undefined;
|
|
93
|
+
private getTimestamp;
|
|
94
|
+
/**
|
|
95
|
+
* Serializes a Gemini `Content` object to a dictionary for YAML output.
|
|
96
|
+
*/
|
|
97
|
+
serializeContent(content: Content | null | undefined): Record<string, unknown> | null;
|
|
98
|
+
/**
|
|
99
|
+
* Safely serializes an arbitrary value to a YAML/JSON-compatible format with
|
|
100
|
+
* credential, sensitive key, and private key redaction.
|
|
101
|
+
*/
|
|
102
|
+
safeSerialize(obj: unknown, depth?: number): unknown;
|
|
103
|
+
private addEntry;
|
|
104
|
+
onUserMessageCallback({ invocationContext, userMessage, }: {
|
|
105
|
+
invocationContext: InvocationContext;
|
|
106
|
+
userMessage: Content;
|
|
107
|
+
}): Promise<Content | undefined>;
|
|
108
|
+
beforeRunCallback({ invocationContext, }: {
|
|
109
|
+
invocationContext: InvocationContext;
|
|
110
|
+
}): Promise<Content | undefined>;
|
|
111
|
+
onEventCallback({ invocationContext, event, }: {
|
|
112
|
+
invocationContext: InvocationContext;
|
|
113
|
+
event: Event;
|
|
114
|
+
}): Promise<Event | undefined>;
|
|
115
|
+
afterRunCallback({ invocationContext, }: {
|
|
116
|
+
invocationContext: InvocationContext;
|
|
117
|
+
}): Promise<void>;
|
|
118
|
+
beforeAgentCallback({ callbackContext, }: {
|
|
119
|
+
agent: BaseAgent;
|
|
120
|
+
callbackContext: Context;
|
|
121
|
+
}): Promise<Content | undefined>;
|
|
122
|
+
afterAgentCallback({ callbackContext, }: {
|
|
123
|
+
agent: BaseAgent;
|
|
124
|
+
callbackContext: Context;
|
|
125
|
+
}): Promise<Content | undefined>;
|
|
126
|
+
beforeModelCallback({ callbackContext, llmRequest, }: {
|
|
127
|
+
callbackContext: Context;
|
|
128
|
+
llmRequest: LlmRequest;
|
|
129
|
+
}): Promise<LlmResponse | undefined>;
|
|
130
|
+
afterModelCallback({ callbackContext, llmResponse, }: {
|
|
131
|
+
callbackContext: Context;
|
|
132
|
+
llmResponse: LlmResponse;
|
|
133
|
+
}): Promise<LlmResponse | undefined>;
|
|
134
|
+
onModelErrorCallback({ callbackContext, llmRequest, error, }: {
|
|
135
|
+
callbackContext: Context;
|
|
136
|
+
llmRequest: LlmRequest;
|
|
137
|
+
error: Error;
|
|
138
|
+
}): Promise<LlmResponse | undefined>;
|
|
139
|
+
beforeToolCallback({ tool, toolArgs, toolContext, }: {
|
|
140
|
+
tool: BaseTool;
|
|
141
|
+
toolArgs: Record<string, unknown>;
|
|
142
|
+
toolContext: Context;
|
|
143
|
+
}): Promise<Record<string, unknown> | undefined>;
|
|
144
|
+
afterToolCallback({ tool, toolContext, result, }: {
|
|
145
|
+
tool: BaseTool;
|
|
146
|
+
toolArgs: Record<string, unknown>;
|
|
147
|
+
toolContext: Context;
|
|
148
|
+
result: Record<string, unknown>;
|
|
149
|
+
}): Promise<Record<string, unknown> | undefined>;
|
|
150
|
+
onToolErrorCallback({ tool, toolArgs, toolContext, error, }: {
|
|
151
|
+
tool: BaseTool;
|
|
152
|
+
toolArgs: Record<string, unknown>;
|
|
153
|
+
toolContext: Context;
|
|
154
|
+
error: Error;
|
|
155
|
+
}): Promise<Record<string, unknown> | undefined>;
|
|
156
|
+
}
|
|
157
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Optional HMAC integrity check for function calls stored in the session.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors adk-python's `google.adk.plugins._tool_call_integrity_plugin`.
|
|
10
|
+
*/
|
|
11
|
+
import { Content } from '@google/genai';
|
|
12
|
+
import { Context } from '../agents/context.js';
|
|
13
|
+
import { InvocationContext } from '../agents/invocation_context.js';
|
|
14
|
+
import { Event } from '../events/event.js';
|
|
15
|
+
import { BaseTool } from '../tools/base_tool.js';
|
|
16
|
+
import { BasePlugin } from './base_plugin.js';
|
|
17
|
+
/** `customMetadata` key holding `{functionCallId: stamp}`. */
|
|
18
|
+
export declare const TOOL_CALL_HMAC_METADATA_KEY = "__adk_internal_fc_hmac";
|
|
19
|
+
/** A function call in the session failed its integrity check. */
|
|
20
|
+
export declare class ToolCallIntegrityError extends Error {
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
/** Options for {@link ToolCallIntegrityPlugin}. */
|
|
24
|
+
export interface ToolCallIntegrityPluginOptions {
|
|
25
|
+
/**
|
|
26
|
+
* The HMAC key, or a list of keys during rotation. The first key stamps new
|
|
27
|
+
* calls; every key is accepted when verifying.
|
|
28
|
+
*/
|
|
29
|
+
secretKey: Uint8Array | readonly Uint8Array[];
|
|
30
|
+
/**
|
|
31
|
+
* Log a warning instead of throwing for function calls that have no stamp,
|
|
32
|
+
* such as calls stored before the plugin was installed. Such calls also run,
|
|
33
|
+
* so this reports tampering that removes a stamp but does not prevent it. A
|
|
34
|
+
* stamp that is present but wrong is always rejected. Defaults to `false`.
|
|
35
|
+
*/
|
|
36
|
+
allowUnstampedCalls?: boolean;
|
|
37
|
+
/** The plugin name. Defaults to `'tool_call_integrity'`. */
|
|
38
|
+
name?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Stamps function calls and verifies them before runs and tool calls.
|
|
42
|
+
*
|
|
43
|
+
* `onEventCallback` adds `"v1:" + HMAC-SHA256(key, payload)` for each function
|
|
44
|
+
* call to `event.customMetadata["__adk_internal_fc_hmac"]`, and throws
|
|
45
|
+
* {@link ToolCallIntegrityError} for a response that repeats a call ID before
|
|
46
|
+
* it is stored. `beforeRunCallback` recomputes the HMAC for every function call
|
|
47
|
+
* with an ID in the session history, answered or not, and throws when a stamp
|
|
48
|
+
* is wrong, malformed, repeated or left over from a call that no longer
|
|
49
|
+
* matches. `beforeToolCallback` lets a tool run only when every stored copy of
|
|
50
|
+
* its call verifies and the tool's name and arguments match one of them; it
|
|
51
|
+
* always refuses a call with no ID. Unstamped calls are rejected unless
|
|
52
|
+
* `allowUnstampedCalls` is set, in which case they are logged.
|
|
53
|
+
*
|
|
54
|
+
* Events without function calls are ignored. Events marked as restored are not
|
|
55
|
+
* verified, and their function calls are never executed. ADK marks events
|
|
56
|
+
* restored by `adk run --replay`, and {@link prepareRestoredEvent} marks events
|
|
57
|
+
* that your code copies. Anyone who can write to the session store can also
|
|
58
|
+
* set the marker, but `beforeToolCallback` still refuses those events' calls.
|
|
59
|
+
*
|
|
60
|
+
* `PluginManager` re-throws plugin errors as a generic `Error`; the
|
|
61
|
+
* {@link ToolCallIntegrityError} is its `cause`.
|
|
62
|
+
*
|
|
63
|
+
* Register this plugin before other plugins. `PluginManager` stops at the first
|
|
64
|
+
* `onEventCallback` that returns an event, and a later plugin must not change
|
|
65
|
+
* function calls or replace `customMetadata`.
|
|
66
|
+
*
|
|
67
|
+
* Requires the Web Crypto API (`globalThis.crypto.subtle`), available in
|
|
68
|
+
* browsers and in Node.js 19 and later.
|
|
69
|
+
*
|
|
70
|
+
* Example:
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const plugin = new ToolCallIntegrityPlugin({secretKey: keyBytes});
|
|
73
|
+
* const app = {name: 'my_app', rootAgent: agent, plugins: [plugin]};
|
|
74
|
+
*
|
|
75
|
+
* // Key rotation: stamp with the new key, accept both.
|
|
76
|
+
* new ToolCallIntegrityPlugin({secretKey: [newKeyBytes, oldKeyBytes]});
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare class ToolCallIntegrityPlugin extends BasePlugin {
|
|
80
|
+
private readonly keys;
|
|
81
|
+
private readonly allowUnstampedCalls;
|
|
82
|
+
private cryptoKeys?;
|
|
83
|
+
/**
|
|
84
|
+
* @throws {Error} If `secretKey` is empty or contains a key that is not
|
|
85
|
+
* non-empty bytes.
|
|
86
|
+
*/
|
|
87
|
+
constructor(options: ToolCallIntegrityPluginOptions);
|
|
88
|
+
/**
|
|
89
|
+
* Returns a copy with internal metadata removed and marked as restored.
|
|
90
|
+
*
|
|
91
|
+
* Use it on events that your code copies into another session, so that the
|
|
92
|
+
* history passes the integrity check. The copy only keeps the history: its
|
|
93
|
+
* function calls are never executed.
|
|
94
|
+
*
|
|
95
|
+
* @param event The event to copy. It is not modified.
|
|
96
|
+
* @returns The marked copy, ready to append to the new session.
|
|
97
|
+
*/
|
|
98
|
+
static prepareRestoredEvent(event: Event): Event;
|
|
99
|
+
private getCryptoKeys;
|
|
100
|
+
private sign;
|
|
101
|
+
/** `subtle.verify` compares in constant time. */
|
|
102
|
+
private verify;
|
|
103
|
+
private unstamped;
|
|
104
|
+
onEventCallback({ invocationContext, event, }: {
|
|
105
|
+
invocationContext: InvocationContext;
|
|
106
|
+
event: Event;
|
|
107
|
+
}): Promise<Event | undefined>;
|
|
108
|
+
beforeRunCallback({ invocationContext, }: {
|
|
109
|
+
invocationContext: InvocationContext;
|
|
110
|
+
}): Promise<Content | undefined>;
|
|
111
|
+
beforeToolCallback({ tool, toolArgs, toolContext, }: {
|
|
112
|
+
tool: BaseTool;
|
|
113
|
+
toolArgs: Record<string, unknown>;
|
|
114
|
+
toolContext: Context;
|
|
115
|
+
}): Promise<Record<string, unknown> | undefined>;
|
|
116
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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;
|