@google/adk 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/agents/base_agent.js +19 -1
- package/dist/cjs/agents/instructions.js +81 -33
- package/dist/cjs/agents/invocation_context.js +0 -1
- package/dist/cjs/agents/llm_agent.js +52 -5
- package/dist/cjs/agents/processors/agent_transfer_llm_request_processor.js +7 -0
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +8 -1
- package/dist/cjs/agents/processors/content_processor_utils.js +37 -24
- package/dist/cjs/agents/processors/content_request_processor.js +7 -0
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +12 -0
- package/dist/cjs/agents/processors/identity_llm_request_processor.js +7 -0
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +5 -0
- package/dist/cjs/agents/processors/request_confirmation_llm_request_processor.js +9 -1
- package/dist/cjs/agents/processors/tool_filter_request_processor.js +7 -1
- package/dist/cjs/auth/auth_preprocessor.js +12 -10
- package/dist/cjs/auth/oauth2/oauth2_discovery.js +1 -1
- package/dist/cjs/code_executors/code_executor_context.js +7 -7
- package/dist/cjs/common.js +39 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +11 -0
- package/dist/cjs/context/token_based_context_compactor.js +1 -1
- package/dist/cjs/events/event.js +1 -1
- package/dist/cjs/integrations/agent_registry/agent_registry_mcp_toolset.js +21 -2
- package/dist/cjs/models/gemini_llm_connection.js +62 -19
- package/dist/cjs/models/google_llm.js +26 -8
- package/dist/cjs/plugins/security_plugin.js +16 -0
- package/dist/cjs/sessions/base_session_service.js +13 -2
- package/dist/cjs/sessions/database_session_service.js +2 -2
- package/dist/cjs/sessions/db/schema.js +45 -10
- package/dist/cjs/sessions/in_memory_session_service.js +2 -1
- package/dist/cjs/sessions/vertex_ai_session_service.js +2 -1
- package/dist/cjs/skills/gcp_skill_registry.js +104 -0
- package/dist/cjs/skills/loader.js +65 -0
- package/dist/cjs/skills/skill_registry.js +27 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +232 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +224 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +127 -0
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +133 -0
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +256 -0
- package/dist/cjs/tools/skill/load_skill_resource_tool.js +25 -3
- package/dist/cjs/tools/skill/load_skill_tool.js +12 -1
- package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -1
- package/dist/cjs/tools/skill/search_skills_tool.js +108 -0
- package/dist/cjs/tools/skill/skill_toolset.js +40 -5
- package/dist/cjs/utils/async_queue.js +88 -0
- package/dist/cjs/utils/case_utils.js +53 -0
- package/dist/cjs/utils/env_aware_utils.js +4 -0
- package/dist/cjs/utils/live_connection_utils.js +284 -0
- package/dist/cjs/utils/model_name.js +9 -0
- package/dist/cjs/utils/streaming_utils.js +9 -8
- package/dist/cjs/version.js +1 -1
- package/dist/esm/agents/base_agent.js +19 -1
- package/dist/esm/agents/instructions.js +81 -33
- package/dist/esm/agents/invocation_context.js +0 -1
- package/dist/esm/agents/llm_agent.js +53 -5
- package/dist/esm/agents/processors/agent_transfer_llm_request_processor.js +7 -0
- package/dist/esm/agents/processors/basic_llm_request_processor.js +8 -1
- package/dist/esm/agents/processors/content_processor_utils.js +35 -23
- package/dist/esm/agents/processors/content_request_processor.js +7 -0
- package/dist/esm/agents/processors/context_compactor_request_processor.js +12 -0
- package/dist/esm/agents/processors/identity_llm_request_processor.js +7 -0
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +5 -0
- package/dist/esm/agents/processors/request_confirmation_llm_request_processor.js +9 -1
- package/dist/esm/agents/processors/tool_filter_request_processor.js +7 -1
- package/dist/esm/auth/auth_preprocessor.js +12 -10
- package/dist/esm/auth/oauth2/oauth2_discovery.js +1 -1
- package/dist/esm/code_executors/code_executor_context.js +7 -7
- package/dist/esm/common.js +33 -1
- package/dist/esm/context/summarizers/llm_summarizer.js +11 -0
- package/dist/esm/context/token_based_context_compactor.js +1 -1
- package/dist/esm/events/event.js +1 -1
- package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +21 -2
- package/dist/esm/models/gemini_llm_connection.js +62 -19
- package/dist/esm/models/google_llm.js +26 -8
- package/dist/esm/plugins/security_plugin.js +16 -0
- package/dist/esm/sessions/base_session_service.js +11 -1
- package/dist/esm/sessions/database_session_service.js +2 -2
- package/dist/esm/sessions/db/schema.js +44 -10
- package/dist/esm/sessions/in_memory_session_service.js +4 -2
- package/dist/esm/sessions/vertex_ai_session_service.js +4 -2
- package/dist/esm/skills/gcp_skill_registry.js +78 -0
- package/dist/esm/skills/loader.js +64 -0
- package/dist/esm/skills/skill_registry.js +7 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +206 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +198 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +101 -0
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +97 -0
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +229 -0
- package/dist/esm/tools/skill/load_skill_resource_tool.js +25 -3
- package/dist/esm/tools/skill/load_skill_tool.js +12 -1
- package/dist/esm/tools/skill/run_skill_script_tool.js +12 -1
- package/dist/esm/tools/skill/search_skills_tool.js +82 -0
- package/dist/esm/tools/skill/skill_toolset.js +40 -5
- package/dist/esm/utils/async_queue.js +60 -0
- package/dist/esm/utils/case_utils.js +25 -0
- package/dist/esm/utils/env_aware_utils.js +4 -0
- package/dist/esm/utils/live_connection_utils.js +256 -0
- package/dist/esm/utils/model_name.js +8 -0
- package/dist/esm/utils/streaming_utils.js +9 -8
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +29 -4
- package/dist/types/a2a/event_converter_utils.d.ts +14 -1
- package/dist/types/a2a/metadata_converter_utils.d.ts +18 -0
- package/dist/types/a2a/part_converter_utils.d.ts +51 -6
- package/dist/types/agents/invocation_context.d.ts +0 -9
- package/dist/types/agents/llm_agent.d.ts +14 -0
- package/dist/types/agents/processors/agent_transfer_llm_request_processor.d.ts +14 -0
- package/dist/types/agents/processors/basic_llm_request_processor.d.ts +7 -0
- package/dist/types/agents/processors/content_processor_utils.d.ts +26 -0
- package/dist/types/agents/processors/content_request_processor.d.ts +16 -0
- package/dist/types/agents/processors/context_compactor_request_processor.d.ts +12 -0
- package/dist/types/agents/processors/identity_llm_request_processor.d.ts +7 -0
- package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +9 -1
- package/dist/types/agents/processors/tool_filter_request_processor.d.ts +12 -1
- package/dist/types/common.d.ts +15 -1
- package/dist/types/context/summarizers/llm_summarizer.d.ts +17 -0
- package/dist/types/events/event_actions.d.ts +1 -2
- package/dist/types/integrations/agent_registry/agent_registry_mcp_toolset.d.ts +21 -2
- package/dist/types/models/base_llm_connection.d.ts +10 -0
- package/dist/types/models/gemini_llm_connection.d.ts +15 -4
- package/dist/types/models/llm_response.d.ts +10 -1
- package/dist/types/plugins/security_plugin.d.ts +30 -0
- package/dist/types/sessions/base_session_service.d.ts +4 -0
- package/dist/types/sessions/db/schema.d.ts +1 -0
- package/dist/types/skills/gcp_skill_registry.d.ts +24 -0
- package/dist/types/skills/loader.d.ts +7 -0
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/skills/skill_registry.d.ts +29 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +34 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +59 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +23 -0
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +27 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +50 -0
- package/dist/types/tools/skill/load_skill_resource_tool.d.ts +1 -1
- package/dist/types/tools/skill/search_skills_tool.d.ts +14 -0
- package/dist/types/tools/skill/skill_toolset.d.ts +5 -0
- package/dist/types/utils/async_queue.d.ts +18 -0
- package/dist/types/utils/case_utils.d.ts +12 -0
- package/dist/types/utils/live_connection_utils.d.ts +30 -0
- package/dist/types/utils/model_name.d.ts +7 -0
- package/dist/types/utils/streaming_utils.d.ts +0 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/web/agents/base_agent.js +31 -1
- package/dist/web/agents/instructions.js +81 -33
- package/dist/web/agents/invocation_context.js +0 -1
- package/dist/web/agents/llm_agent.js +53 -5
- package/dist/web/agents/processors/agent_transfer_llm_request_processor.js +7 -0
- package/dist/web/agents/processors/basic_llm_request_processor.js +8 -1
- package/dist/web/agents/processors/content_processor_utils.js +53 -23
- package/dist/web/agents/processors/content_request_processor.js +7 -0
- package/dist/web/agents/processors/context_compactor_request_processor.js +12 -0
- package/dist/web/agents/processors/identity_llm_request_processor.js +7 -0
- package/dist/web/agents/processors/instructions_llm_request_processor.js +5 -0
- package/dist/web/agents/processors/request_confirmation_llm_request_processor.js +9 -1
- package/dist/web/agents/processors/tool_filter_request_processor.js +7 -1
- package/dist/web/auth/auth_preprocessor.js +12 -10
- package/dist/web/auth/oauth2/oauth2_discovery.js +1 -1
- package/dist/web/code_executors/code_executor_context.js +7 -7
- package/dist/web/common.js +33 -1
- package/dist/web/context/summarizers/llm_summarizer.js +11 -0
- package/dist/web/context/token_based_context_compactor.js +1 -1
- package/dist/web/events/event.js +1 -1
- package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +21 -2
- package/dist/web/models/gemini_llm_connection.js +75 -19
- package/dist/web/models/google_llm.js +26 -8
- package/dist/web/plugins/security_plugin.js +16 -0
- package/dist/web/sessions/base_session_service.js +11 -1
- package/dist/web/sessions/database_session_service.js +2 -2
- package/dist/web/sessions/db/schema.js +44 -10
- package/dist/web/sessions/in_memory_session_service.js +4 -2
- package/dist/web/sessions/vertex_ai_session_service.js +4 -2
- package/dist/web/skills/gcp_skill_registry.js +78 -0
- package/dist/web/skills/loader.js +64 -0
- package/dist/web/skills/skill_registry.js +7 -0
- package/dist/web/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +221 -0
- package/dist/web/tools/openapi_tool/openapi_spec_parser/operation_parser.js +198 -0
- package/dist/web/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +101 -0
- package/dist/web/tools/openapi_tool/openapi_toolset.js +97 -0
- package/dist/web/tools/openapi_tool/rest_api_tool.js +229 -0
- package/dist/web/tools/skill/load_skill_resource_tool.js +25 -3
- package/dist/web/tools/skill/load_skill_tool.js +12 -1
- package/dist/web/tools/skill/run_skill_script_tool.js +12 -1
- package/dist/web/tools/skill/search_skills_tool.js +82 -0
- package/dist/web/tools/skill/skill_toolset.js +40 -5
- package/dist/web/utils/async_queue.js +60 -0
- package/dist/web/utils/case_utils.js +25 -0
- package/dist/web/utils/env_aware_utils.js +4 -0
- package/dist/web/utils/live_connection_utils.js +254 -0
- package/dist/web/utils/model_name.js +8 -0
- package/dist/web/utils/streaming_utils.js +9 -8
- package/dist/web/version.js +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
26
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
27
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
28
|
+
if (decorator = decorators[i])
|
|
29
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
30
|
+
if (kind && result) __defProp(target, key, result);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
var operation_parser_exports = {};
|
|
34
|
+
__export(operation_parser_exports, {
|
|
35
|
+
OperationParser: () => OperationParser
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(operation_parser_exports);
|
|
38
|
+
var import_experimental = require("../../../utils/experimental.js");
|
|
39
|
+
/**
|
|
40
|
+
* @license
|
|
41
|
+
* Copyright 2026 Google LLC
|
|
42
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
43
|
+
*/
|
|
44
|
+
let OperationParser = class {
|
|
45
|
+
constructor(operation, options = {}) {
|
|
46
|
+
this.operation = operation;
|
|
47
|
+
this.params = [];
|
|
48
|
+
var _a;
|
|
49
|
+
this.preservePropertyNames = (_a = options.preservePropertyNames) != null ? _a : false;
|
|
50
|
+
this.processOperationParameters();
|
|
51
|
+
this.processRequestBody();
|
|
52
|
+
this.processReturnValue();
|
|
53
|
+
this.dedupeParamNames();
|
|
54
|
+
}
|
|
55
|
+
getParamName(originalName) {
|
|
56
|
+
if (this.preservePropertyNames) {
|
|
57
|
+
return originalName;
|
|
58
|
+
}
|
|
59
|
+
return originalName.replace(/[A-Z]/g, (g) => "_" + g.toLowerCase()).replace(/^_/, "");
|
|
60
|
+
}
|
|
61
|
+
processOperationParameters() {
|
|
62
|
+
const parameters = this.operation.parameters || [];
|
|
63
|
+
for (const param of parameters) {
|
|
64
|
+
if ("name" in param) {
|
|
65
|
+
const originalName = param.name;
|
|
66
|
+
const description = param.description || "";
|
|
67
|
+
const location = param.in || "";
|
|
68
|
+
const schema = param.schema || {};
|
|
69
|
+
this.params.push({
|
|
70
|
+
originalName,
|
|
71
|
+
paramLocation: location,
|
|
72
|
+
paramSchema: schema,
|
|
73
|
+
description,
|
|
74
|
+
required: param.required || false,
|
|
75
|
+
name: this.getParamName(originalName)
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
processRequestBody() {
|
|
81
|
+
const requestBody = this.operation.requestBody;
|
|
82
|
+
if (!requestBody || "$ref" in requestBody) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const content = requestBody.content || {};
|
|
86
|
+
const firstMimeType = Object.keys(content)[0];
|
|
87
|
+
if (!firstMimeType) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const mediaTypeObject = content[firstMimeType];
|
|
91
|
+
const schema = mediaTypeObject.schema;
|
|
92
|
+
const description = requestBody.description || "";
|
|
93
|
+
if (schema && !("$ref" in schema)) {
|
|
94
|
+
if (schema.type === "object") {
|
|
95
|
+
const properties = schema.properties || {};
|
|
96
|
+
if (Object.keys(properties).length > 0) {
|
|
97
|
+
for (const [propName, propDetails] of Object.entries(properties)) {
|
|
98
|
+
if (!("$ref" in propDetails)) {
|
|
99
|
+
this.params.push({
|
|
100
|
+
originalName: propName,
|
|
101
|
+
paramLocation: "body",
|
|
102
|
+
paramSchema: propDetails,
|
|
103
|
+
description: propDetails.description,
|
|
104
|
+
required: (schema.required || []).includes(propName),
|
|
105
|
+
name: this.getParamName(propName)
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
this.params.push({
|
|
111
|
+
originalName: "",
|
|
112
|
+
paramLocation: "body",
|
|
113
|
+
paramSchema: schema,
|
|
114
|
+
description,
|
|
115
|
+
required: true,
|
|
116
|
+
name: "body"
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
} else if (schema.type === "array") {
|
|
120
|
+
this.params.push({
|
|
121
|
+
originalName: "array",
|
|
122
|
+
paramLocation: "body",
|
|
123
|
+
paramSchema: schema,
|
|
124
|
+
description,
|
|
125
|
+
required: true,
|
|
126
|
+
name: "body"
|
|
127
|
+
});
|
|
128
|
+
} else {
|
|
129
|
+
this.params.push({
|
|
130
|
+
originalName: "body",
|
|
131
|
+
paramLocation: "body",
|
|
132
|
+
paramSchema: schema,
|
|
133
|
+
description,
|
|
134
|
+
required: true,
|
|
135
|
+
name: "body"
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
processReturnValue() {
|
|
141
|
+
const responses = this.operation.responses || {};
|
|
142
|
+
const validCodes = Object.keys(responses).filter((k) => k.startsWith("2"));
|
|
143
|
+
const min20x = validCodes.sort()[0];
|
|
144
|
+
let returnSchema = {};
|
|
145
|
+
if (min20x) {
|
|
146
|
+
const response = responses[min20x];
|
|
147
|
+
if (!("$ref" in response) && response.content) {
|
|
148
|
+
const firstMimeType = Object.keys(response.content)[0];
|
|
149
|
+
if (firstMimeType) {
|
|
150
|
+
const schema = response.content[firstMimeType].schema;
|
|
151
|
+
if (schema && !("$ref" in schema)) {
|
|
152
|
+
returnSchema = schema;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
this.returnValue = {
|
|
158
|
+
originalName: "",
|
|
159
|
+
paramLocation: "",
|
|
160
|
+
paramSchema: returnSchema,
|
|
161
|
+
required: true,
|
|
162
|
+
name: "return"
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
dedupeParamNames() {
|
|
166
|
+
const nameCounts = /* @__PURE__ */ new Map();
|
|
167
|
+
for (const param of this.params) {
|
|
168
|
+
const name = param.name;
|
|
169
|
+
const count = nameCounts.get(name) || 0;
|
|
170
|
+
if (count > 0) {
|
|
171
|
+
param.name = `${name}_${count}`;
|
|
172
|
+
}
|
|
173
|
+
nameCounts.set(name, count + 1);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
getParameters() {
|
|
177
|
+
return this.params;
|
|
178
|
+
}
|
|
179
|
+
getJsonSchema() {
|
|
180
|
+
const properties = {};
|
|
181
|
+
const required = [];
|
|
182
|
+
for (const param of this.params) {
|
|
183
|
+
properties[param.name] = param.paramSchema;
|
|
184
|
+
if (param.required) {
|
|
185
|
+
required.push(param.name);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
type: "object",
|
|
190
|
+
properties,
|
|
191
|
+
required: required.length > 0 ? required : void 0,
|
|
192
|
+
title: `${this.operation.operationId || "unnamed"}_Arguments`
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
getFunctionName() {
|
|
196
|
+
const operationId = this.operation.operationId;
|
|
197
|
+
if (!operationId) {
|
|
198
|
+
throw new Error("Operation ID is missing");
|
|
199
|
+
}
|
|
200
|
+
return this.getParamName(operationId).substring(0, 60);
|
|
201
|
+
}
|
|
202
|
+
getDescription() {
|
|
203
|
+
return this.operation.description || this.operation.summary || "";
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
__decorateClass([
|
|
207
|
+
import_experimental.experimental
|
|
208
|
+
], OperationParser.prototype, "getParameters", 1);
|
|
209
|
+
__decorateClass([
|
|
210
|
+
import_experimental.experimental
|
|
211
|
+
], OperationParser.prototype, "getJsonSchema", 1);
|
|
212
|
+
__decorateClass([
|
|
213
|
+
import_experimental.experimental
|
|
214
|
+
], OperationParser.prototype, "getFunctionName", 1);
|
|
215
|
+
__decorateClass([
|
|
216
|
+
import_experimental.experimental
|
|
217
|
+
], OperationParser.prototype, "getDescription", 1);
|
|
218
|
+
OperationParser = __decorateClass([
|
|
219
|
+
import_experimental.experimental
|
|
220
|
+
], OperationParser);
|
|
221
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
222
|
+
0 && (module.exports = {
|
|
223
|
+
OperationParser
|
|
224
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
26
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
27
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
28
|
+
if (decorator = decorators[i])
|
|
29
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
30
|
+
if (kind && result) __defProp(target, key, result);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
var tool_auth_handler_exports = {};
|
|
34
|
+
__export(tool_auth_handler_exports, {
|
|
35
|
+
ToolAuthHandler: () => ToolAuthHandler
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(tool_auth_handler_exports);
|
|
38
|
+
var import_experimental = require("../../../utils/experimental.js");
|
|
39
|
+
var import_auto_auth_credential_exchanger = require("../auth/credential_exchangers/auto_auth_credential_exchanger.js");
|
|
40
|
+
/**
|
|
41
|
+
* @license
|
|
42
|
+
* Copyright 2026 Google LLC
|
|
43
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
44
|
+
*/
|
|
45
|
+
class ToolContextCredentialStore {
|
|
46
|
+
constructor(context) {
|
|
47
|
+
this.context = context;
|
|
48
|
+
}
|
|
49
|
+
getCredentialKey(authScheme) {
|
|
50
|
+
const schemeName = (authScheme == null ? void 0 : authScheme.type) || "default";
|
|
51
|
+
return `${schemeName}_existing_exchanged_credential`;
|
|
52
|
+
}
|
|
53
|
+
getCredential(authScheme) {
|
|
54
|
+
const key = this.getCredentialKey(authScheme);
|
|
55
|
+
const state = this.context.state;
|
|
56
|
+
if (state) {
|
|
57
|
+
const serialized = state[key];
|
|
58
|
+
if (serialized) {
|
|
59
|
+
return serialized;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
storeCredential(key, credential) {
|
|
65
|
+
const state = this.context.state;
|
|
66
|
+
if (state) {
|
|
67
|
+
state[key] = credential;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
let ToolAuthHandler = class {
|
|
72
|
+
constructor(context, authScheme, authCredential, credentialKey) {
|
|
73
|
+
this.context = context;
|
|
74
|
+
this.authScheme = authScheme;
|
|
75
|
+
this.authCredential = authCredential;
|
|
76
|
+
this.credentialKey = credentialKey;
|
|
77
|
+
}
|
|
78
|
+
static fromToolContext(context, authScheme, authCredential, options = {}) {
|
|
79
|
+
return new ToolAuthHandler(
|
|
80
|
+
context,
|
|
81
|
+
authScheme,
|
|
82
|
+
authCredential,
|
|
83
|
+
options.credentialKey
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
async prepareAuthCredentials() {
|
|
87
|
+
if (!this.authScheme) {
|
|
88
|
+
return { state: "done" };
|
|
89
|
+
}
|
|
90
|
+
const store = new ToolContextCredentialStore(this.context);
|
|
91
|
+
const existingCredential = store.getCredential(this.authScheme);
|
|
92
|
+
if (existingCredential) {
|
|
93
|
+
return { state: "done", authCredential: existingCredential };
|
|
94
|
+
}
|
|
95
|
+
const authConfig = {
|
|
96
|
+
authScheme: this.authScheme,
|
|
97
|
+
rawAuthCredential: this.authCredential,
|
|
98
|
+
credentialKey: this.credentialKey || "default_openapi_key"
|
|
99
|
+
};
|
|
100
|
+
const credential = this.context.getAuthResponse(authConfig);
|
|
101
|
+
if (credential) {
|
|
102
|
+
const exchanger = new import_auto_auth_credential_exchanger.AutoAuthCredentialExchanger();
|
|
103
|
+
const result = await exchanger.exchange({
|
|
104
|
+
authScheme: this.authScheme,
|
|
105
|
+
authCredential: credential
|
|
106
|
+
});
|
|
107
|
+
const key = store.getCredentialKey(this.authScheme);
|
|
108
|
+
store.storeCredential(key, result.credential);
|
|
109
|
+
return { state: "done", authCredential: result.credential };
|
|
110
|
+
}
|
|
111
|
+
this.context.requestCredential(authConfig);
|
|
112
|
+
return { state: "pending" };
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
__decorateClass([
|
|
116
|
+
import_experimental.experimental
|
|
117
|
+
], ToolAuthHandler.prototype, "prepareAuthCredentials", 1);
|
|
118
|
+
__decorateClass([
|
|
119
|
+
import_experimental.experimental
|
|
120
|
+
], ToolAuthHandler, "fromToolContext", 1);
|
|
121
|
+
ToolAuthHandler = __decorateClass([
|
|
122
|
+
import_experimental.experimental
|
|
123
|
+
], ToolAuthHandler);
|
|
124
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
+
0 && (module.exports = {
|
|
126
|
+
ToolAuthHandler
|
|
127
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
36
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
37
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
38
|
+
if (decorator = decorators[i])
|
|
39
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
40
|
+
if (kind && result) __defProp(target, key, result);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
var openapi_toolset_exports = {};
|
|
44
|
+
__export(openapi_toolset_exports, {
|
|
45
|
+
OpenAPIToolset: () => OpenAPIToolset
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(openapi_toolset_exports);
|
|
48
|
+
var import_js_yaml = __toESM(require("js-yaml"), 1);
|
|
49
|
+
var import_experimental = require("../../utils/experimental.js");
|
|
50
|
+
var import_base_toolset = require("../base_toolset.js");
|
|
51
|
+
var import_openapi_spec_parser = require("./openapi_spec_parser/openapi_spec_parser.js");
|
|
52
|
+
var import_rest_api_tool = require("./rest_api_tool.js");
|
|
53
|
+
/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2026 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
57
|
+
*/
|
|
58
|
+
let OpenAPIToolset = class extends import_base_toolset.BaseToolset {
|
|
59
|
+
constructor(options = {}) {
|
|
60
|
+
super(options.toolFilter || [], options.prefix);
|
|
61
|
+
this.tools = [];
|
|
62
|
+
let spec = options.specDict;
|
|
63
|
+
if (!spec && options.specStr) {
|
|
64
|
+
if (options.specType === "yaml" || !options.specType && options.specStr.trim().startsWith("---")) {
|
|
65
|
+
spec = import_js_yaml.default.load(options.specStr);
|
|
66
|
+
} else {
|
|
67
|
+
spec = JSON.parse(options.specStr);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!spec) {
|
|
71
|
+
throw new Error("Either specDict or specStr must be provided.");
|
|
72
|
+
}
|
|
73
|
+
const parser = new import_openapi_spec_parser.OpenApiSpecParser({
|
|
74
|
+
preservePropertyNames: options.preservePropertyNames
|
|
75
|
+
});
|
|
76
|
+
const parsedOperations = parser.parse(spec);
|
|
77
|
+
for (const op of parsedOperations) {
|
|
78
|
+
let toolName = op.name;
|
|
79
|
+
if (this.prefix) {
|
|
80
|
+
toolName = `${this.prefix}_${toolName}`;
|
|
81
|
+
}
|
|
82
|
+
const tool = (0, import_rest_api_tool.createRestApiTool)(
|
|
83
|
+
{
|
|
84
|
+
name: toolName,
|
|
85
|
+
description: op.description,
|
|
86
|
+
endpoint: op.endpoint,
|
|
87
|
+
operation: op.operation,
|
|
88
|
+
authScheme: op.authScheme
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
preservePropertyNames: options.preservePropertyNames,
|
|
92
|
+
headerProvider: options.headerProvider,
|
|
93
|
+
credentialKey: options.credentialKey
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
this.tools.push(tool);
|
|
97
|
+
}
|
|
98
|
+
if (options.authScheme || options.authCredential) {
|
|
99
|
+
for (const tool of this.tools) {
|
|
100
|
+
if (options.authScheme) tool.configureAuthScheme(options.authScheme);
|
|
101
|
+
if (options.authCredential)
|
|
102
|
+
tool.configureAuthCredential(options.authCredential);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async getTools(context) {
|
|
107
|
+
return this.tools.filter((tool) => {
|
|
108
|
+
if (Array.isArray(this.toolFilter) && this.toolFilter.length > 0) {
|
|
109
|
+
return this.toolFilter.includes(tool.name);
|
|
110
|
+
}
|
|
111
|
+
if (context) {
|
|
112
|
+
return this.isToolSelected(tool, context);
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async close() {
|
|
118
|
+
return Promise.resolve();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
__decorateClass([
|
|
122
|
+
import_experimental.experimental
|
|
123
|
+
], OpenAPIToolset.prototype, "getTools", 1);
|
|
124
|
+
__decorateClass([
|
|
125
|
+
import_experimental.experimental
|
|
126
|
+
], OpenAPIToolset.prototype, "close", 1);
|
|
127
|
+
OpenAPIToolset = __decorateClass([
|
|
128
|
+
import_experimental.experimental
|
|
129
|
+
], OpenAPIToolset);
|
|
130
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
131
|
+
0 && (module.exports = {
|
|
132
|
+
OpenAPIToolset
|
|
133
|
+
});
|