@microsoft/teamsfx-core 3.0.10-alpha.5aa2874bb.0 → 3.0.10-alpha.6bfb69e98.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/build/common/featureFlags.d.ts +5 -0
- package/build/common/featureFlags.d.ts.map +1 -1
- package/build/common/featureFlags.js +6 -0
- package/build/common/featureFlags.js.map +1 -1
- package/build/common/telemetry.d.ts +2 -0
- package/build/common/telemetry.d.ts.map +1 -1
- package/build/common/telemetry.js +2 -0
- package/build/common/telemetry.js.map +1 -1
- package/build/common/templates-config.json +1 -1
- package/build/component/deps-checker/internal/dotnetChecker.d.ts.map +1 -1
- package/build/component/deps-checker/internal/dotnetChecker.js +3 -7
- package/build/component/deps-checker/internal/dotnetChecker.js.map +1 -1
- package/build/component/driver/script/scriptDriver.js +1 -1
- package/build/component/driver/script/scriptDriver.js.map +1 -1
- package/build/component/generator/configFiles/configGenerator.d.ts +15 -0
- package/build/component/generator/configFiles/configGenerator.d.ts.map +1 -0
- package/build/component/generator/configFiles/configGenerator.js +167 -0
- package/build/component/generator/configFiles/configGenerator.js.map +1 -0
- package/build/component/generator/configFiles/copyPolicy.d.ts +10 -0
- package/build/component/generator/configFiles/copyPolicy.d.ts.map +1 -0
- package/build/component/generator/configFiles/copyPolicy.js +40 -0
- package/build/component/generator/configFiles/copyPolicy.js.map +1 -0
- package/build/component/generator/configFiles/jsonMerger.d.ts +11 -0
- package/build/component/generator/configFiles/jsonMerger.d.ts.map +1 -0
- package/build/component/generator/configFiles/jsonMerger.js +83 -0
- package/build/component/generator/configFiles/jsonMerger.js.map +1 -0
- package/build/component/generator/configFiles/renderTemplate.d.ts +2 -0
- package/build/component/generator/configFiles/renderTemplate.d.ts.map +1 -0
- package/build/component/generator/configFiles/renderTemplate.js +16 -0
- package/build/component/generator/configFiles/renderTemplate.js.map +1 -0
- package/build/component/generator/declarativeAgent/helper.d.ts.map +1 -1
- package/build/component/generator/declarativeAgent/helper.js +0 -1
- package/build/component/generator/declarativeAgent/helper.js.map +1 -1
- package/build/component/utils/pathUtils.d.ts +2 -1
- package/build/component/utils/pathUtils.d.ts.map +1 -1
- package/build/component/utils/pathUtils.js +19 -3
- package/build/component/utils/pathUtils.js.map +1 -1
- package/build/component/utils/settingsUtil.d.ts +1 -1
- package/build/component/utils/settingsUtil.d.ts.map +1 -1
- package/build/component/utils/settingsUtil.js +20 -7
- package/build/component/utils/settingsUtil.js.map +1 -1
- package/build/core/FxCore.d.ts +6 -2
- package/build/core/FxCore.d.ts.map +1 -1
- package/build/core/FxCore.declarativeAgent.d.ts +6 -0
- package/build/core/FxCore.declarativeAgent.d.ts.map +1 -0
- package/build/core/FxCore.declarativeAgent.js +210 -0
- package/build/core/FxCore.declarativeAgent.js.map +1 -0
- package/build/core/FxCore.js +16 -173
- package/build/core/FxCore.js.map +1 -1
- package/build/core/generateConfigFiles.d.ts +4 -0
- package/build/core/generateConfigFiles.d.ts.map +1 -0
- package/build/core/generateConfigFiles.js +61 -0
- package/build/core/generateConfigFiles.js.map +1 -0
- package/build/core/middleware/projectSettingsLoader.d.ts.map +1 -1
- package/build/core/middleware/projectSettingsLoader.js +8 -2
- package/build/core/middleware/projectSettingsLoader.js.map +1 -1
- package/package.json +4 -4
- package/resource/package.nls.cs.json +4 -5
- package/resource/package.nls.de.json +3 -4
- package/resource/package.nls.es.json +4 -5
- package/resource/package.nls.fr.json +3 -4
- package/resource/package.nls.it.json +4 -5
- package/resource/package.nls.ja.json +4 -5
- package/resource/package.nls.json +1 -0
- package/resource/package.nls.ko.json +3 -4
- package/resource/package.nls.pl.json +4 -5
- package/resource/package.nls.pt-BR.json +4 -5
- package/resource/package.nls.ru.json +3 -4
- package/resource/package.nls.tr.json +3 -4
- package/resource/package.nls.zh-Hans.json +4 -5
- package/resource/package.nls.zh-Hant.json +4 -5
- package/templates/configs/local/python/.vscode/launch.json.tpl +93 -0
- package/templates/configs/local/python/.vscode/tasks.json.tpl +103 -0
- package/templates/configs/local/python/env/.env.local +6 -0
- package/templates/configs/local/python/m365agents.local.yml.tpl +121 -0
- package/templates/configs/local/typescript/.gitignore +1 -0
- package/templates/configs/local/typescript/.vscode/launch.json.tpl +147 -0
- package/templates/configs/local/typescript/.vscode/tasks.json.tpl +129 -0
- package/templates/configs/local/typescript/env/.env.local +6 -0
- package/templates/configs/local/typescript/m365agents.local.yml.tpl +129 -0
- package/templates/configs/local/typescript/package.json +8 -0
- package/templates/configs/playground/python/.vscode/launch.json +46 -0
- package/templates/configs/playground/python/.vscode/tasks.json +35 -0
- package/templates/configs/playground/python/env/.env.playground +7 -0
- package/templates/configs/playground/python/env/.env.playground.user +0 -0
- package/templates/configs/playground/python/m365agents.playground.yml +14 -0
- package/templates/configs/playground/typescript/.gitignore +4 -0
- package/templates/configs/playground/typescript/.vscode/launch.json +31 -0
- package/templates/configs/playground/typescript/.vscode/tasks.json +104 -0
- package/templates/configs/playground/typescript/env/.env.playground +7 -0
- package/templates/configs/playground/typescript/env/.env.playground.user +0 -0
- package/templates/configs/playground/typescript/m365agents.playground.yml +23 -0
- package/templates/configs/playground/typescript/package.json +9 -0
- package/templates/fallback/common.zip +0 -0
- package/templates/fallback/csharp.zip +0 -0
- package/templates/fallback/js.zip +0 -0
- package/templates/fallback/python.zip +0 -0
- package/templates/fallback/ts.zip +0 -0
- package/templates/metadata.zip +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.FxCoreDeclarativeAgentPart = void 0;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const hooks_1 = require("@feathersjs/hooks");
|
|
8
|
+
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
|
|
9
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
10
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
|
+
const path = tslib_1.__importStar(require("path"));
|
|
12
|
+
const globalVars_1 = require("../common/globalVars");
|
|
13
|
+
const localizeUtils_1 = require("../common/localizeUtils");
|
|
14
|
+
const actionInjector_1 = require("../component/configManager/actionInjector");
|
|
15
|
+
const constants_1 = require("../component/constants");
|
|
16
|
+
const questionMW_1 = require("../component/middleware/questionMW");
|
|
17
|
+
const pathUtils_1 = require("../component/utils/pathUtils");
|
|
18
|
+
const constants_2 = require("../question/constants");
|
|
19
|
+
const concurrentLocker_1 = require("./middleware/concurrentLocker");
|
|
20
|
+
const errorHandler_1 = require("./middleware/errorHandler");
|
|
21
|
+
class FxCoreDeclarativeAgentPart {
|
|
22
|
+
async updateActionWithMCP(inputs) {
|
|
23
|
+
var _a, _b, _c, _d;
|
|
24
|
+
const context = (0, globalVars_1.createContext)();
|
|
25
|
+
const projectPath = inputs.projectPath;
|
|
26
|
+
if (!projectPath) {
|
|
27
|
+
throw new Error("projectPath is undefined"); // should never happen
|
|
28
|
+
}
|
|
29
|
+
const aiPluginFilePath = inputs[constants_2.QuestionNames.PluginManifestFilePath];
|
|
30
|
+
if (!(await fs_extra_1.default.pathExists(aiPluginFilePath))) {
|
|
31
|
+
const error = new teamsfx_api_1.SystemError("MCPForDAPluginManifestNotFound", "PluginManifestNotFound", (0, localizeUtils_1.getDefaultString)("core.MCPForDA.pluginManifestNotFound", aiPluginFilePath), (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.pluginManifestNotFound", aiPluginFilePath));
|
|
32
|
+
return (0, teamsfx_api_1.err)(error);
|
|
33
|
+
}
|
|
34
|
+
const aiPluginFilePathRelative = path.basename(aiPluginFilePath);
|
|
35
|
+
const mcpServerUrl = inputs[constants_2.QuestionNames.MCPForDAServerUrl];
|
|
36
|
+
const serverName = inputs[constants_2.QuestionNames.MCPForDAServerName];
|
|
37
|
+
const mcpAuth = inputs[constants_2.QuestionNames.MCPForDAAuth];
|
|
38
|
+
const authType = inputs[constants_2.QuestionNames.MCPForDAAuthType];
|
|
39
|
+
let oauthAuthorizationUrl = undefined;
|
|
40
|
+
let oauthTokenUrl = undefined;
|
|
41
|
+
let oauthRefreshUrl = undefined;
|
|
42
|
+
let registrationId = undefined;
|
|
43
|
+
if (mcpAuth === "OAuthPluginVault") {
|
|
44
|
+
try {
|
|
45
|
+
registrationId = `MCP_DA_AUTH_ID_${serverName.toUpperCase()}`;
|
|
46
|
+
if (authType === "oauth") {
|
|
47
|
+
let wellKnownMetadataUrl = inputs[constants_2.QuestionNames.MCPForDAAuthWellKnownUrl];
|
|
48
|
+
if (!wellKnownMetadataUrl) {
|
|
49
|
+
const mcpAuthMetadataUrl = inputs[constants_2.QuestionNames.MCPForDAAuthMetadataUrl];
|
|
50
|
+
if (!mcpAuthMetadataUrl) {
|
|
51
|
+
throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpAuthMetadataUrlNotFound"));
|
|
52
|
+
}
|
|
53
|
+
const response = await axios_1.default.get(mcpAuthMetadataUrl);
|
|
54
|
+
if (response.status === 200 &&
|
|
55
|
+
response.data &&
|
|
56
|
+
response.data.authorization_servers &&
|
|
57
|
+
response.data.authorization_servers.length > 0) {
|
|
58
|
+
const mcpServerMetadataUrl = (_a = response.data.authorization_servers) === null || _a === void 0 ? void 0 : _a[0];
|
|
59
|
+
// Transform the URL to the proper OAuth authorization server metadata endpoint
|
|
60
|
+
// According to RFC 8414, the well-known endpoint should be constructed as:
|
|
61
|
+
// https://{domain}/.well-known/oauth-authorization-server{path}
|
|
62
|
+
const serverUrl = new URL(mcpServerMetadataUrl);
|
|
63
|
+
wellKnownMetadataUrl = `${serverUrl.protocol}//${serverUrl.host}/.well-known/oauth-authorization-server${serverUrl.pathname}`;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpServerMetadataUrlNotFound"));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const metadataResponse = await axios_1.default.get(wellKnownMetadataUrl);
|
|
70
|
+
if (metadataResponse.status === 200) {
|
|
71
|
+
oauthAuthorizationUrl = metadataResponse.data.authorization_endpoint;
|
|
72
|
+
oauthTokenUrl = metadataResponse.data.token_endpoint;
|
|
73
|
+
oauthRefreshUrl = metadataResponse.data.refresh_endpoint;
|
|
74
|
+
}
|
|
75
|
+
if (!oauthAuthorizationUrl || !oauthTokenUrl) {
|
|
76
|
+
throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.authUrlNotFound"));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
void context.userInteraction.showMessage("error", (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpAuthMetadataMissingError", error.message), false);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// 2. Read ai-plugin.json
|
|
85
|
+
const aiPluginContent = await fs_extra_1.default.readJSON(aiPluginFilePath);
|
|
86
|
+
// For dynamic fetch tools, keep the functions empty and add runtime info
|
|
87
|
+
// TODO: support dynamic fetch tools in the future
|
|
88
|
+
const mcpToolsDetail = inputs[constants_2.QuestionNames.MCPForDAAvailableTools];
|
|
89
|
+
const mcpToolsSelected = inputs[constants_2.QuestionNames.MCPForDAPreFetchTools];
|
|
90
|
+
if (!mcpToolsDetail || !mcpToolsSelected) {
|
|
91
|
+
const error = new teamsfx_api_1.UserError("MCPForDAPreFetchToolsNotFound", "PreFetchToolsNotFound", (0, localizeUtils_1.getDefaultString)("core.MCPForDA.preFetchToolsNotFound"), (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.preFetchToolsNotFound"));
|
|
92
|
+
return (0, teamsfx_api_1.err)(error);
|
|
93
|
+
}
|
|
94
|
+
const toolsSelectedPrevious = [];
|
|
95
|
+
aiPluginContent.runtimes
|
|
96
|
+
.filter((runtime) => (runtime.type === "RemoteMCPServer" && runtime.spec.url === mcpServerUrl) ||
|
|
97
|
+
runtime.type === "LocalPlugin")
|
|
98
|
+
.forEach((runtime) => {
|
|
99
|
+
toolsSelectedPrevious.push(...runtime.run_for_functions);
|
|
100
|
+
});
|
|
101
|
+
aiPluginContent.functions = aiPluginContent.functions.filter((func) => !toolsSelectedPrevious.includes(func.name));
|
|
102
|
+
aiPluginContent.functions = [
|
|
103
|
+
...aiPluginContent.functions,
|
|
104
|
+
...mcpToolsDetail
|
|
105
|
+
.filter((tool) => mcpToolsSelected.includes(tool.name))
|
|
106
|
+
.map((tool) => {
|
|
107
|
+
if (inputs[constants_2.QuestionNames.MCPLocalServerIdentifier] != null) {
|
|
108
|
+
return {
|
|
109
|
+
name: tool.name,
|
|
110
|
+
description: tool.description,
|
|
111
|
+
parameters: {
|
|
112
|
+
type: tool.inputSchema.type || "object",
|
|
113
|
+
properties: tool.inputSchema.properties,
|
|
114
|
+
required: tool.inputSchema.required || [],
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
return {
|
|
120
|
+
name: tool.name,
|
|
121
|
+
description: tool.description,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
];
|
|
126
|
+
const matchedRuntime = aiPluginContent.runtimes.find((runtime) => runtime.type === "RemoteMCPServer" && runtime.spec.url === mcpServerUrl);
|
|
127
|
+
aiPluginContent.runtimes = aiPluginContent.runtimes.filter((runtime) => (runtime.type !== "RemoteMCPServer" && runtime.type !== "LocalPlugin") ||
|
|
128
|
+
runtime.spec.url !== mcpServerUrl);
|
|
129
|
+
if (inputs[constants_2.QuestionNames.MCPLocalServerIdentifier] != null) {
|
|
130
|
+
aiPluginContent.runtimes.push({
|
|
131
|
+
type: "LocalPlugin",
|
|
132
|
+
spec: {
|
|
133
|
+
local_endpoint: `${constants_1.LocalMcpPrefix}${inputs[constants_2.QuestionNames.MCPLocalServerIdentifier]}`,
|
|
134
|
+
},
|
|
135
|
+
run_for_functions: mcpToolsSelected,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
let mcpFile = (_b = matchedRuntime === null || matchedRuntime === void 0 ? void 0 : matchedRuntime.spec.mcp_tool_description) === null || _b === void 0 ? void 0 : _b.file;
|
|
140
|
+
if (!mcpFile) {
|
|
141
|
+
mcpFile = "mcp-tools.json";
|
|
142
|
+
let suffix = 1;
|
|
143
|
+
while (await fs_extra_1.default.pathExists(path.join(path.dirname(aiPluginFilePath), mcpFile))) {
|
|
144
|
+
mcpFile = `mcp-tools-${suffix}.json`;
|
|
145
|
+
suffix += 1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
await fs_extra_1.default.writeJSON(path.join(path.dirname(aiPluginFilePath), mcpFile), {
|
|
149
|
+
tools: [
|
|
150
|
+
...mcpToolsDetail
|
|
151
|
+
.filter((tool) => mcpToolsSelected.includes(tool.name))
|
|
152
|
+
.map((tool) => {
|
|
153
|
+
return Object.assign(Object.assign({}, tool), { title: tool.name
|
|
154
|
+
.replace(/_/g, " ")
|
|
155
|
+
.replace(/^./, (str) => str.toUpperCase()) });
|
|
156
|
+
}),
|
|
157
|
+
],
|
|
158
|
+
}, { spaces: 4 });
|
|
159
|
+
aiPluginContent.runtimes.push({
|
|
160
|
+
type: "RemoteMCPServer",
|
|
161
|
+
spec: {
|
|
162
|
+
url: mcpServerUrl,
|
|
163
|
+
mcp_tool_description: {
|
|
164
|
+
file: mcpFile,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
run_for_functions: mcpToolsSelected,
|
|
168
|
+
auth: mcpAuth === "OAuthPluginVault" && !!registrationId
|
|
169
|
+
? {
|
|
170
|
+
type: "OAuthPluginVault",
|
|
171
|
+
reference_id: `$\{\{${registrationId}\}\}`,
|
|
172
|
+
}
|
|
173
|
+
: {
|
|
174
|
+
type: "None",
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (mcpAuth === "OAuthPluginVault" && !!registrationId) {
|
|
179
|
+
// insert oauth info in teamsapp.yaml
|
|
180
|
+
await actionInjector_1.ActionInjector.injectCreateOAuthActionForMCP(pathUtils_1.pathUtils.getYmlFilePath(projectPath), authType, serverName, registrationId, mcpServerUrl, oauthAuthorizationUrl, oauthTokenUrl, oauthRefreshUrl);
|
|
181
|
+
}
|
|
182
|
+
void context.userInteraction
|
|
183
|
+
.showMessage("info", (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.updatePluginManifest", aiPluginFilePathRelative), false, "Provision")
|
|
184
|
+
.then((result) => {
|
|
185
|
+
if (result.isOk() && result.value === "Provision") {
|
|
186
|
+
void this.provisionResources(inputs);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
await fs_extra_1.default.writeJSON(aiPluginFilePath, aiPluginContent, { spaces: 4 });
|
|
190
|
+
void ((_d = (_c = context.userInteraction).openFile) === null || _d === void 0 ? void 0 : _d.call(_c, aiPluginFilePath));
|
|
191
|
+
return (0, teamsfx_api_1.ok)(undefined);
|
|
192
|
+
}
|
|
193
|
+
// This method will be implemented by FxCore
|
|
194
|
+
provisionResources(_inputs) {
|
|
195
|
+
throw new Error("Method not implemented.");
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
tslib_1.__decorate([
|
|
199
|
+
(0, hooks_1.hooks)([
|
|
200
|
+
(0, globalVars_1.ErrorContextMW)({ component: "FxCore", stage: teamsfx_api_1.Stage.installApp }),
|
|
201
|
+
errorHandler_1.ErrorHandlerMW,
|
|
202
|
+
(0, questionMW_1.QuestionMW)("updateActionWithMCP"),
|
|
203
|
+
concurrentLocker_1.ConcurrentLockerMW,
|
|
204
|
+
]),
|
|
205
|
+
tslib_1.__metadata("design:type", Function),
|
|
206
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
207
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
208
|
+
], FxCoreDeclarativeAgentPart.prototype, "updateActionWithMCP", null);
|
|
209
|
+
exports.FxCoreDeclarativeAgentPart = FxCoreDeclarativeAgentPart;
|
|
210
|
+
//# sourceMappingURL=FxCore.declarativeAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FxCore.declarativeAgent.js","sourceRoot":"","sources":["../../src/core/FxCore.declarativeAgent.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,6CAA0C;AAC1C,wDASgC;AAChC,0DAA0B;AAC1B,gEAA0B;AAC1B,mDAA6B;AAC7B,qDAAqE;AACrE,2DAA+E;AAC/E,8EAA2E;AAC3E,sDAAwD;AACxD,mEAAgE;AAChE,4DAAyD;AACzD,qDAAsD;AACtD,oEAAmE;AACnE,4DAA2D;AAE3D,MAAa,0BAA0B;IAOrC,KAAK,CAAC,mBAAmB,CAAC,MAAc;;QACtC,MAAM,OAAO,GAAG,IAAA,0BAAa,GAAE,CAAC;QAChC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC,sBAAsB;SACpE;QACD,MAAM,gBAAgB,GAAG,MAAM,CAAC,yBAAa,CAAC,sBAAsB,CAAW,CAAC;QAChF,IAAI,CAAC,CAAC,MAAM,kBAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE;YAC5C,MAAM,KAAK,GAAG,IAAI,yBAAW,CAC3B,gCAAgC,EAChC,wBAAwB,EACxB,IAAA,gCAAgB,EAAC,sCAAsC,EAAE,gBAAgB,CAAC,EAC1E,IAAA,kCAAkB,EAAC,sCAAsC,EAAE,gBAAgB,CAAC,CAC7E,CAAC;YACF,OAAO,IAAA,iBAAG,EAAC,KAAK,CAAC,CAAC;SACnB;QACD,MAAM,wBAAwB,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAEjE,MAAM,YAAY,GAAG,MAAM,CAAC,yBAAa,CAAC,iBAAiB,CAAC,CAAC;QAC7D,MAAM,UAA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|
|
7
7
|
const hooks_1 = require("@feathersjs/hooks");
|
|
8
8
|
const m365_spec_parser_1 = require("@microsoft/m365-spec-parser");
|
|
9
9
|
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
|
|
10
|
-
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
11
10
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
11
|
const jsonschema = tslib_1.__importStar(require("jsonschema"));
|
|
13
12
|
const os = tslib_1.__importStar(require("os"));
|
|
@@ -27,7 +26,6 @@ const templates_config_json_1 = tslib_1.__importDefault(require("../common/templ
|
|
|
27
26
|
const tools_1 = require("../common/tools");
|
|
28
27
|
const utils_1 = require("../common/utils");
|
|
29
28
|
const versionMetadata_1 = require("../common/versionMetadata");
|
|
30
|
-
const actionInjector_1 = require("../component/configManager/actionInjector");
|
|
31
29
|
const constant_1 = require("../component/configManager/constant");
|
|
32
30
|
const parser_1 = require("../component/configManager/parser");
|
|
33
31
|
const constants_2 = require("../component/constants");
|
|
@@ -73,6 +71,7 @@ const callback_1 = require("./callback");
|
|
|
73
71
|
const collaborator_1 = require("./collaborator");
|
|
74
72
|
const crypto_1 = require("./crypto");
|
|
75
73
|
const environmentName_1 = require("./environmentName");
|
|
74
|
+
const generateConfigFiles_1 = require("./generateConfigFiles");
|
|
76
75
|
const concurrentLocker_1 = require("./middleware/concurrentLocker");
|
|
77
76
|
const contextInjector_1 = require("./middleware/contextInjector");
|
|
78
77
|
const errorHandler_1 = require("./middleware/errorHandler");
|
|
@@ -82,8 +81,10 @@ const retry_1 = require("./middleware/retry");
|
|
|
82
81
|
const v3MigrationUtils_1 = require("./middleware/utils/v3MigrationUtils");
|
|
83
82
|
const share_2 = require("./share");
|
|
84
83
|
const telemetry_2 = require("./telemetry");
|
|
85
|
-
|
|
84
|
+
const FxCore_declarativeAgent_1 = require("./FxCore.declarativeAgent");
|
|
85
|
+
class FxCore extends FxCore_declarativeAgent_1.FxCoreDeclarativeAgentPart {
|
|
86
86
|
constructor(tools) {
|
|
87
|
+
super();
|
|
87
88
|
(0, globalVars_1.setTools)(tools);
|
|
88
89
|
}
|
|
89
90
|
/**
|
|
@@ -1856,165 +1857,6 @@ class FxCore {
|
|
|
1856
1857
|
}
|
|
1857
1858
|
return (0, teamsfx_api_1.ok)(undefined);
|
|
1858
1859
|
}
|
|
1859
|
-
async updateActionWithMCP(inputs) {
|
|
1860
|
-
var _a, _b, _c, _d;
|
|
1861
|
-
const context = (0, globalVars_1.createContext)();
|
|
1862
|
-
const projectPath = inputs.projectPath;
|
|
1863
|
-
if (!projectPath) {
|
|
1864
|
-
throw new Error("projectPath is undefined"); // should never happen
|
|
1865
|
-
}
|
|
1866
|
-
const aiPluginFilePath = inputs[constants_3.QuestionNames.PluginManifestFilePath];
|
|
1867
|
-
if (!(await fs_extra_1.default.pathExists(aiPluginFilePath))) {
|
|
1868
|
-
const error = new teamsfx_api_1.SystemError("MCPForDAPluginManifestNotFound", "PluginManifestNotFound", (0, localizeUtils_1.getDefaultString)("core.MCPForDA.pluginManifestNotFound", aiPluginFilePath), (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.pluginManifestNotFound", aiPluginFilePath));
|
|
1869
|
-
return (0, teamsfx_api_1.err)(error);
|
|
1870
|
-
}
|
|
1871
|
-
const aiPluginFilePathRelative = path.basename(aiPluginFilePath);
|
|
1872
|
-
const mcpServerUrl = inputs[constants_3.QuestionNames.MCPForDAServerUrl];
|
|
1873
|
-
const serverName = inputs[constants_3.QuestionNames.MCPForDAServerName];
|
|
1874
|
-
const mcpAuth = inputs[constants_3.QuestionNames.MCPForDAAuth];
|
|
1875
|
-
const authType = inputs[constants_3.QuestionNames.MCPForDAAuthType];
|
|
1876
|
-
let oauthAuthorizationUrl = undefined;
|
|
1877
|
-
let oauthTokenUrl = undefined;
|
|
1878
|
-
let oauthRefreshUrl = undefined;
|
|
1879
|
-
let registrationId = undefined;
|
|
1880
|
-
if (mcpAuth === "OAuthPluginVault") {
|
|
1881
|
-
try {
|
|
1882
|
-
registrationId = `MCP_DA_AUTH_ID_${serverName.toUpperCase()}`;
|
|
1883
|
-
if (authType === "oauth") {
|
|
1884
|
-
let wellKnownMetadataUrl = inputs[constants_3.QuestionNames.MCPForDAAuthWellKnownUrl];
|
|
1885
|
-
if (!wellKnownMetadataUrl) {
|
|
1886
|
-
const mcpAuthMetadataUrl = inputs[constants_3.QuestionNames.MCPForDAAuthMetadataUrl];
|
|
1887
|
-
if (!mcpAuthMetadataUrl) {
|
|
1888
|
-
throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpAuthMetadataUrlNotFound"));
|
|
1889
|
-
}
|
|
1890
|
-
const response = await axios_1.default.get(mcpAuthMetadataUrl);
|
|
1891
|
-
if (response.status === 200 &&
|
|
1892
|
-
response.data &&
|
|
1893
|
-
response.data.authorization_servers &&
|
|
1894
|
-
response.data.authorization_servers.length > 0) {
|
|
1895
|
-
const mcpServerMetadataUrl = (_a = response.data.authorization_servers) === null || _a === void 0 ? void 0 : _a[0];
|
|
1896
|
-
// Transform the URL to the proper OAuth authorization server metadata endpoint
|
|
1897
|
-
// According to RFC 8414, the well-known endpoint should be constructed as:
|
|
1898
|
-
// https://{domain}/.well-known/oauth-authorization-server{path}
|
|
1899
|
-
const serverUrl = new URL(mcpServerMetadataUrl);
|
|
1900
|
-
wellKnownMetadataUrl = `${serverUrl.protocol}//${serverUrl.host}/.well-known/oauth-authorization-server${serverUrl.pathname}`;
|
|
1901
|
-
}
|
|
1902
|
-
else {
|
|
1903
|
-
throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpServerMetadataUrlNotFound"));
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
const metadataResponse = await axios_1.default.get(wellKnownMetadataUrl);
|
|
1907
|
-
if (metadataResponse.status === 200) {
|
|
1908
|
-
oauthAuthorizationUrl = metadataResponse.data.authorization_endpoint;
|
|
1909
|
-
oauthTokenUrl = metadataResponse.data.token_endpoint;
|
|
1910
|
-
oauthRefreshUrl = metadataResponse.data.refresh_endpoint;
|
|
1911
|
-
}
|
|
1912
|
-
if (!oauthAuthorizationUrl || !oauthTokenUrl) {
|
|
1913
|
-
throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.authUrlNotFound"));
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
catch (error) {
|
|
1918
|
-
void context.userInteraction.showMessage("error", (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpAuthMetadataMissingError", error.message), false);
|
|
1919
|
-
}
|
|
1920
|
-
}
|
|
1921
|
-
// 2. Read ai-plugin.json
|
|
1922
|
-
const aiPluginContent = await fs_extra_1.default.readJSON(aiPluginFilePath);
|
|
1923
|
-
// For dynamic fetch tools, keep the functions empty and add runtime info
|
|
1924
|
-
// TODO: support dynamic fetch tools in the future
|
|
1925
|
-
const mcpToolsDetail = inputs[constants_3.QuestionNames.MCPForDAAvailableTools];
|
|
1926
|
-
const mcpToolsSelected = inputs[constants_3.QuestionNames.MCPForDAPreFetchTools];
|
|
1927
|
-
if (!mcpToolsDetail || !mcpToolsSelected) {
|
|
1928
|
-
const error = new teamsfx_api_1.UserError("MCPForDAPreFetchToolsNotFound", "PreFetchToolsNotFound", (0, localizeUtils_1.getDefaultString)("core.MCPForDA.preFetchToolsNotFound"), (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.preFetchToolsNotFound"));
|
|
1929
|
-
return (0, teamsfx_api_1.err)(error);
|
|
1930
|
-
}
|
|
1931
|
-
const toolsSelectedPrevious = [];
|
|
1932
|
-
aiPluginContent.runtimes
|
|
1933
|
-
.filter((runtime) => (runtime.type === "RemoteMCPServer" &&
|
|
1934
|
-
runtime.spec.url === mcpServerUrl &&
|
|
1935
|
-
!runtime.spec["enable_dynamic_discovery"]) ||
|
|
1936
|
-
runtime.type === "LocalPlugin")
|
|
1937
|
-
.forEach((runtime) => {
|
|
1938
|
-
toolsSelectedPrevious.push(...runtime.run_for_functions);
|
|
1939
|
-
});
|
|
1940
|
-
aiPluginContent.functions = aiPluginContent.functions.filter((func) => !toolsSelectedPrevious.includes(func.name));
|
|
1941
|
-
aiPluginContent.functions = [
|
|
1942
|
-
...aiPluginContent.functions,
|
|
1943
|
-
...mcpToolsDetail
|
|
1944
|
-
.filter((tool) => mcpToolsSelected.includes(tool.name))
|
|
1945
|
-
.map((tool) => {
|
|
1946
|
-
return {
|
|
1947
|
-
name: tool.name,
|
|
1948
|
-
description: tool.description,
|
|
1949
|
-
};
|
|
1950
|
-
}),
|
|
1951
|
-
];
|
|
1952
|
-
const matchedRuntime = aiPluginContent.runtimes.find((runtime) => runtime.type === "RemoteMCPServer" && runtime.spec.url === mcpServerUrl);
|
|
1953
|
-
aiPluginContent.runtimes = aiPluginContent.runtimes.filter((runtime) => (runtime.type !== "RemoteMCPServer" && runtime.type !== "LocalPlugin") ||
|
|
1954
|
-
runtime.spec.url !== mcpServerUrl ||
|
|
1955
|
-
runtime.spec["enable_dynamic_discovery"] === true);
|
|
1956
|
-
if (inputs[constants_3.QuestionNames.MCPLocalServerIdentifier] != null) {
|
|
1957
|
-
aiPluginContent.runtimes.push({
|
|
1958
|
-
type: "LocalPlugin",
|
|
1959
|
-
spec: {
|
|
1960
|
-
local_endpoint: `${constants_2.LocalMcpPrefix}${inputs[constants_3.QuestionNames.MCPLocalServerIdentifier]}`,
|
|
1961
|
-
},
|
|
1962
|
-
run_for_functions: mcpToolsSelected,
|
|
1963
|
-
});
|
|
1964
|
-
}
|
|
1965
|
-
else {
|
|
1966
|
-
let mcpFile = (_b = matchedRuntime === null || matchedRuntime === void 0 ? void 0 : matchedRuntime.spec.mcp_tool_description) === null || _b === void 0 ? void 0 : _b.file;
|
|
1967
|
-
if (!mcpFile) {
|
|
1968
|
-
mcpFile = "mcp-tools.json";
|
|
1969
|
-
let suffix = 1;
|
|
1970
|
-
while (await fs_extra_1.default.pathExists(path.join(path.dirname(aiPluginFilePath), mcpFile))) {
|
|
1971
|
-
mcpFile = `mcp-tools-${suffix}.json`;
|
|
1972
|
-
suffix += 1;
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
await fs_extra_1.default.writeJSON(path.join(path.dirname(aiPluginFilePath), mcpFile), {
|
|
1976
|
-
tools: [
|
|
1977
|
-
...mcpToolsDetail
|
|
1978
|
-
.filter((tool) => mcpToolsSelected.includes(tool.name))
|
|
1979
|
-
.map((tool) => {
|
|
1980
|
-
return Object.assign(Object.assign({}, tool), { title: tool.name
|
|
1981
|
-
.replace(/_/g, " ")
|
|
1982
|
-
.replace(/^./, (str) => str.toUpperCase()) });
|
|
1983
|
-
}),
|
|
1984
|
-
],
|
|
1985
|
-
}, { spaces: 4 });
|
|
1986
|
-
aiPluginContent.runtimes.push({
|
|
1987
|
-
type: "RemoteMCPServer",
|
|
1988
|
-
spec: {
|
|
1989
|
-
url: mcpServerUrl,
|
|
1990
|
-
mcp_tool_description: {
|
|
1991
|
-
file: mcpFile,
|
|
1992
|
-
},
|
|
1993
|
-
},
|
|
1994
|
-
run_for_functions: mcpToolsSelected,
|
|
1995
|
-
auth: mcpAuth === "OAuthPluginVault" && !!registrationId
|
|
1996
|
-
? {
|
|
1997
|
-
type: "OAuthPluginVault",
|
|
1998
|
-
reference_id: `$\{\{${registrationId}\}\}`,
|
|
1999
|
-
}
|
|
2000
|
-
: undefined,
|
|
2001
|
-
});
|
|
2002
|
-
}
|
|
2003
|
-
if (mcpAuth === "OAuthPluginVault" && !!registrationId) {
|
|
2004
|
-
// insert oauth info in teamsapp.yaml
|
|
2005
|
-
await actionInjector_1.ActionInjector.injectCreateOAuthActionForMCP(pathUtils_1.pathUtils.getYmlFilePath(projectPath), authType, serverName, registrationId, mcpServerUrl, oauthAuthorizationUrl, oauthTokenUrl, oauthRefreshUrl);
|
|
2006
|
-
}
|
|
2007
|
-
void context.userInteraction
|
|
2008
|
-
.showMessage("info", (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.updatePluginManifest", aiPluginFilePathRelative), false, "Provision")
|
|
2009
|
-
.then((result) => {
|
|
2010
|
-
if (result.isOk() && result.value === "Provision") {
|
|
2011
|
-
void this.provisionResources(inputs);
|
|
2012
|
-
}
|
|
2013
|
-
});
|
|
2014
|
-
await fs_extra_1.default.writeJSON(aiPluginFilePath, aiPluginContent, { spaces: 4 });
|
|
2015
|
-
void ((_d = (_c = context.userInteraction).openFile) === null || _d === void 0 ? void 0 : _d.call(_c, aiPluginFilePath));
|
|
2016
|
-
return (0, teamsfx_api_1.ok)(undefined);
|
|
2017
|
-
}
|
|
2018
1860
|
/**
|
|
2019
1861
|
* dynamic template metadata download
|
|
2020
1862
|
*/
|
|
@@ -2070,6 +1912,12 @@ class FxCore {
|
|
|
2070
1912
|
return (0, teamsfx_api_1.err)(systemErr);
|
|
2071
1913
|
}
|
|
2072
1914
|
}
|
|
1915
|
+
/**
|
|
1916
|
+
* dynamic template metadata download
|
|
1917
|
+
*/
|
|
1918
|
+
async generateConfigFiles(inputs) {
|
|
1919
|
+
return await (0, generateConfigFiles_1.generateConfigFiles)(inputs);
|
|
1920
|
+
}
|
|
2073
1921
|
async updateAuthActionInYaml(authName, authScheme, projectPath, apSpecPath, pluginManifestPath, forceToAddNew = true) {
|
|
2074
1922
|
if (authName && authScheme) {
|
|
2075
1923
|
const authInjectRes = await (0, helper_2.injectAuthAction)(projectPath, authName, authScheme, apSpecPath, forceToAddNew);
|
|
@@ -2892,17 +2740,6 @@ tslib_1.__decorate([
|
|
|
2892
2740
|
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
2893
2741
|
tslib_1.__metadata("design:returntype", Promise)
|
|
2894
2742
|
], FxCore.prototype, "installAppToChannel", null);
|
|
2895
|
-
tslib_1.__decorate([
|
|
2896
|
-
(0, hooks_1.hooks)([
|
|
2897
|
-
(0, globalVars_1.ErrorContextMW)({ component: "FxCore", stage: teamsfx_api_1.Stage.installApp }),
|
|
2898
|
-
errorHandler_1.ErrorHandlerMW,
|
|
2899
|
-
(0, questionMW_1.QuestionMW)("updateActionWithMCP"),
|
|
2900
|
-
concurrentLocker_1.ConcurrentLockerMW,
|
|
2901
|
-
]),
|
|
2902
|
-
tslib_1.__metadata("design:type", Function),
|
|
2903
|
-
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
2904
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
2905
|
-
], FxCore.prototype, "updateActionWithMCP", null);
|
|
2906
2743
|
tslib_1.__decorate([
|
|
2907
2744
|
(0, hooks_1.hooks)([
|
|
2908
2745
|
(0, globalVars_1.ErrorContextMW)({ component: "FxCore", stage: "fetchOnlineTemplateMetadata" }),
|
|
@@ -2912,5 +2749,11 @@ tslib_1.__decorate([
|
|
|
2912
2749
|
tslib_1.__metadata("design:paramtypes", []),
|
|
2913
2750
|
tslib_1.__metadata("design:returntype", Promise)
|
|
2914
2751
|
], FxCore.prototype, "fetchOnlineTemplateMetadata", null);
|
|
2752
|
+
tslib_1.__decorate([
|
|
2753
|
+
(0, hooks_1.hooks)([(0, globalVars_1.ErrorContextMW)({ component: "FxCore", stage: "generateConfigFiles" }), errorHandler_1.ErrorHandlerMW]),
|
|
2754
|
+
tslib_1.__metadata("design:type", Function),
|
|
2755
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
2756
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
2757
|
+
], FxCore.prototype, "generateConfigFiles", null);
|
|
2915
2758
|
exports.FxCore = FxCore;
|
|
2916
2759
|
//# sourceMappingURL=FxCore.js.map
|