@microsoft/teamsfx-core 3.0.10-beta.2025122503.0 → 3.0.10-beta.2026011501.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.
Files changed (170) hide show
  1. package/build/client/graphClient.d.ts +1 -0
  2. package/build/client/graphClient.d.ts.map +1 -1
  3. package/build/client/teamsDevPortalClient.d.ts +1 -0
  4. package/build/client/teamsDevPortalClient.d.ts.map +1 -1
  5. package/build/common/featureFlags.d.ts +10 -20
  6. package/build/common/featureFlags.d.ts.map +1 -1
  7. package/build/common/featureFlags.js +11 -20
  8. package/build/common/featureFlags.js.map +1 -1
  9. package/build/common/telemetry.d.ts +2 -0
  10. package/build/common/telemetry.d.ts.map +1 -1
  11. package/build/common/telemetry.js +2 -0
  12. package/build/common/telemetry.js.map +1 -1
  13. package/build/common/templates-config.json +1 -1
  14. package/build/component/coordinator/index.d.ts.map +1 -1
  15. package/build/component/coordinator/index.js +0 -11
  16. package/build/component/coordinator/index.js.map +1 -1
  17. package/build/component/deps-checker/internal/dotnetChecker.d.ts +5 -1
  18. package/build/component/deps-checker/internal/dotnetChecker.d.ts.map +1 -1
  19. package/build/component/deps-checker/internal/dotnetChecker.js +16 -8
  20. package/build/component/deps-checker/internal/dotnetChecker.js.map +1 -1
  21. package/build/component/driver/deploy/spfx/utility/spoClient.d.ts +1 -0
  22. package/build/component/driver/deploy/spfx/utility/spoClient.d.ts.map +1 -1
  23. package/build/component/driver/devTool/httpClient.d.ts +1 -0
  24. package/build/component/driver/devTool/httpClient.d.ts.map +1 -1
  25. package/build/component/driver/devTool/nodeInstaller.d.ts +1 -0
  26. package/build/component/driver/devTool/nodeInstaller.d.ts.map +1 -1
  27. package/build/component/driver/script/scriptDriver.d.ts +1 -0
  28. package/build/component/driver/script/scriptDriver.d.ts.map +1 -1
  29. package/build/component/driver/teamsApp/constants.d.ts +1 -1
  30. package/build/component/driver/teamsApp/constants.d.ts.map +1 -1
  31. package/build/component/driver/teamsApp/constants.js +2 -2
  32. package/build/component/driver/teamsApp/constants.js.map +1 -1
  33. package/build/component/driver/teamsApp/copyAppPackageToSPFx.d.ts +1 -0
  34. package/build/component/driver/teamsApp/copyAppPackageToSPFx.d.ts.map +1 -1
  35. package/build/component/driver/teamsApp/interfaces/appdefinitions/appPackage.d.ts +1 -0
  36. package/build/component/driver/teamsApp/interfaces/appdefinitions/appPackage.d.ts.map +1 -1
  37. package/build/component/driver/teamsApp/utils/ManifestUtils.d.ts +1 -0
  38. package/build/component/driver/teamsApp/utils/ManifestUtils.d.ts.map +1 -1
  39. package/build/component/generator/configFiles/configGenerator.d.ts +15 -0
  40. package/build/component/generator/configFiles/configGenerator.d.ts.map +1 -0
  41. package/build/component/generator/configFiles/configGenerator.js +167 -0
  42. package/build/component/generator/configFiles/configGenerator.js.map +1 -0
  43. package/build/component/generator/configFiles/copyPolicy.d.ts +10 -0
  44. package/build/component/generator/configFiles/copyPolicy.d.ts.map +1 -0
  45. package/build/component/generator/configFiles/copyPolicy.js +42 -0
  46. package/build/component/generator/configFiles/copyPolicy.js.map +1 -0
  47. package/build/component/generator/configFiles/jsonMerger.d.ts +11 -0
  48. package/build/component/generator/configFiles/jsonMerger.d.ts.map +1 -0
  49. package/build/component/generator/configFiles/jsonMerger.js +83 -0
  50. package/build/component/generator/configFiles/jsonMerger.js.map +1 -0
  51. package/build/component/generator/configFiles/renderTemplate.d.ts +2 -0
  52. package/build/component/generator/configFiles/renderTemplate.d.ts.map +1 -0
  53. package/build/component/generator/configFiles/renderTemplate.js +16 -0
  54. package/build/component/generator/configFiles/renderTemplate.js.map +1 -0
  55. package/build/component/generator/declarativeAgent/generator.d.ts +5 -0
  56. package/build/component/generator/declarativeAgent/generator.d.ts.map +1 -1
  57. package/build/component/generator/declarativeAgent/generator.js +76 -36
  58. package/build/component/generator/declarativeAgent/generator.js.map +1 -1
  59. package/build/component/generator/declarativeAgent/helper.d.ts.map +1 -1
  60. package/build/component/generator/declarativeAgent/helper.js +0 -1
  61. package/build/component/generator/declarativeAgent/helper.js.map +1 -1
  62. package/build/component/generator/generatorAction.d.ts +1 -0
  63. package/build/component/generator/generatorAction.d.ts.map +1 -1
  64. package/build/component/generator/openApiSpec/common.d.ts.map +1 -1
  65. package/build/component/generator/openApiSpec/common.js +11 -22
  66. package/build/component/generator/openApiSpec/common.js.map +1 -1
  67. package/build/component/generator/openApiSpec/kiota.d.ts +0 -6
  68. package/build/component/generator/openApiSpec/kiota.d.ts.map +1 -1
  69. package/build/component/generator/openApiSpec/kiota.js +2 -17
  70. package/build/component/generator/openApiSpec/kiota.js.map +1 -1
  71. package/build/component/generator/templates/templateInfo.d.ts +1 -1
  72. package/build/component/generator/templates/templateInfo.d.ts.map +1 -1
  73. package/build/component/generator/utils.d.ts +3 -2
  74. package/build/component/generator/utils.d.ts.map +1 -1
  75. package/build/component/generator/utils.js.map +1 -1
  76. package/build/component/m365/packageService.d.ts.map +1 -1
  77. package/build/component/m365/packageService.js +16 -20
  78. package/build/component/m365/packageService.js.map +1 -1
  79. package/build/component/utils/envUtil.d.ts +1 -0
  80. package/build/component/utils/envUtil.d.ts.map +1 -1
  81. package/build/component/utils/pathUtils.d.ts +2 -1
  82. package/build/component/utils/pathUtils.d.ts.map +1 -1
  83. package/build/component/utils/pathUtils.js +19 -3
  84. package/build/component/utils/pathUtils.js.map +1 -1
  85. package/build/component/utils/settingsUtil.d.ts +1 -1
  86. package/build/component/utils/settingsUtil.d.ts.map +1 -1
  87. package/build/component/utils/settingsUtil.js +20 -7
  88. package/build/component/utils/settingsUtil.js.map +1 -1
  89. package/build/core/FxCore.d.ts +6 -2
  90. package/build/core/FxCore.d.ts.map +1 -1
  91. package/build/core/FxCore.declarativeAgent.d.ts +6 -0
  92. package/build/core/FxCore.declarativeAgent.d.ts.map +1 -0
  93. package/build/core/FxCore.declarativeAgent.js +210 -0
  94. package/build/core/FxCore.declarativeAgent.js.map +1 -0
  95. package/build/core/FxCore.js +45 -248
  96. package/build/core/FxCore.js.map +1 -1
  97. package/build/core/generateConfigFiles.d.ts +4 -0
  98. package/build/core/generateConfigFiles.d.ts.map +1 -0
  99. package/build/core/generateConfigFiles.js +61 -0
  100. package/build/core/generateConfigFiles.js.map +1 -0
  101. package/build/core/middleware/projectSettingsLoader.d.ts.map +1 -1
  102. package/build/core/middleware/projectSettingsLoader.js +8 -2
  103. package/build/core/middleware/projectSettingsLoader.js.map +1 -1
  104. package/build/question/other.d.ts.map +1 -1
  105. package/build/question/other.js +0 -2
  106. package/build/question/other.js.map +1 -1
  107. package/build/question/questionNames.d.ts +0 -3
  108. package/build/question/questionNames.d.ts.map +1 -1
  109. package/build/question/questionNames.js +0 -3
  110. package/build/question/questionNames.js.map +1 -1
  111. package/build/question/scaffold/vsc/ProjectTypeOptions.d.ts +0 -1
  112. package/build/question/scaffold/vsc/ProjectTypeOptions.d.ts.map +1 -1
  113. package/build/question/scaffold/vsc/ProjectTypeOptions.js +1 -14
  114. package/build/question/scaffold/vsc/ProjectTypeOptions.js.map +1 -1
  115. package/build/question/scaffold/vsc/createRootNode.d.ts.map +1 -1
  116. package/build/question/scaffold/vsc/createRootNode.js +1 -5
  117. package/build/question/scaffold/vsc/createRootNode.js.map +1 -1
  118. package/build/question/scaffold/vsc/daProjectTypeNode.d.ts.map +1 -1
  119. package/build/question/scaffold/vsc/daProjectTypeNode.js +1 -2
  120. package/build/question/scaffold/vsc/daProjectTypeNode.js.map +1 -1
  121. package/build/question/scaffold/vsc/officeAddinProjectTypeNode.d.ts +0 -1
  122. package/build/question/scaffold/vsc/officeAddinProjectTypeNode.d.ts.map +1 -1
  123. package/build/question/scaffold/vsc/officeAddinProjectTypeNode.js +2 -51
  124. package/build/question/scaffold/vsc/officeAddinProjectTypeNode.js.map +1 -1
  125. package/build/question/scaffold/vsc/teamsProjectTypeNode.d.ts.map +1 -1
  126. package/build/question/scaffold/vsc/teamsProjectTypeNode.js +4 -15
  127. package/build/question/scaffold/vsc/teamsProjectTypeNode.js.map +1 -1
  128. package/package.json +5 -5
  129. package/resource/package.nls.cs.json +1 -0
  130. package/resource/package.nls.de.json +13 -12
  131. package/resource/package.nls.es.json +12 -11
  132. package/resource/package.nls.fr.json +1 -0
  133. package/resource/package.nls.it.json +1 -0
  134. package/resource/package.nls.ja.json +2 -1
  135. package/resource/package.nls.json +2 -3
  136. package/resource/package.nls.ko.json +12 -11
  137. package/resource/package.nls.pl.json +12 -11
  138. package/resource/package.nls.pt-BR.json +8 -7
  139. package/resource/package.nls.ru.json +3 -2
  140. package/resource/package.nls.tr.json +1 -0
  141. package/resource/package.nls.zh-Hans.json +1 -0
  142. package/resource/package.nls.zh-Hant.json +6 -5
  143. package/templates/configs/local/python/.vscode/launch.json.tpl +93 -0
  144. package/templates/configs/local/python/.vscode/tasks.json.tpl +103 -0
  145. package/templates/configs/local/python/env/.env.local +6 -0
  146. package/templates/configs/local/python/m365agents.local.yml.tpl +121 -0
  147. package/templates/configs/local/typescript/.gitignore +1 -0
  148. package/templates/configs/local/typescript/.vscode/launch.json.tpl +147 -0
  149. package/templates/configs/local/typescript/.vscode/tasks.json.tpl +129 -0
  150. package/templates/configs/local/typescript/env/.env.local +6 -0
  151. package/templates/configs/local/typescript/m365agents.local.yml.tpl +129 -0
  152. package/templates/configs/local/typescript/package.json +8 -0
  153. package/templates/configs/playground/python/.vscode/launch.json +46 -0
  154. package/templates/configs/playground/python/.vscode/tasks.json +35 -0
  155. package/templates/configs/playground/python/env/.env.playground +7 -0
  156. package/templates/configs/playground/python/m365agents.playground.yml +14 -0
  157. package/templates/configs/playground/typescript/.gitignore +4 -0
  158. package/templates/configs/playground/typescript/.localConfigs.playground +0 -0
  159. package/templates/configs/playground/typescript/.vscode/launch.json +31 -0
  160. package/templates/configs/playground/typescript/.vscode/tasks.json +104 -0
  161. package/templates/configs/playground/typescript/env/.env.playground +7 -0
  162. package/templates/configs/playground/typescript/env/.env.playground.user +0 -0
  163. package/templates/configs/playground/typescript/m365agents.playground.yml +23 -0
  164. package/templates/configs/playground/typescript/package.json +9 -0
  165. package/templates/fallback/common.zip +0 -0
  166. package/templates/fallback/csharp.zip +0 -0
  167. package/templates/fallback/js.zip +0 -0
  168. package/templates/fallback/python.zip +0 -0
  169. package/templates/fallback/ts.zip +0 -0
  170. 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,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AAc,EAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,mBAAK,CAAC,UAAU,EAAE,CAAC;QAChE,6BAAc;QACd,IAAA,uBAAU,EAAC,qBAAqB,CAAC;QACjC,qCAAkB;KACnB,CAAC;;;;qEAmOD;AAzOH,gEA+OC"}
@@ -7,7 +7,6 @@ const tslib_1 = require("tslib");
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"));
@@ -18,7 +17,6 @@ const url_1 = require("url");
18
17
  const teamsDevPortalClient_1 = require("../client/teamsDevPortalClient");
19
18
  const constants_1 = require("../common/constants");
20
19
  const daSpecParser_1 = require("../common/daSpecParser");
21
- const featureFlags_1 = require("../common/featureFlags");
22
20
  const globalVars_1 = require("../common/globalVars");
23
21
  const localizeUtils_1 = require("../common/localizeUtils");
24
22
  const projectSettingsHelper_1 = require("../common/projectSettingsHelper");
@@ -28,7 +26,6 @@ const templates_config_json_1 = tslib_1.__importDefault(require("../common/templ
28
26
  const tools_1 = require("../common/tools");
29
27
  const utils_1 = require("../common/utils");
30
28
  const versionMetadata_1 = require("../common/versionMetadata");
31
- const actionInjector_1 = require("../component/configManager/actionInjector");
32
29
  const constant_1 = require("../component/configManager/constant");
33
30
  const parser_1 = require("../component/configManager/parser");
34
31
  const constants_2 = require("../component/constants");
@@ -74,6 +71,7 @@ const callback_1 = require("./callback");
74
71
  const collaborator_1 = require("./collaborator");
75
72
  const crypto_1 = require("./crypto");
76
73
  const environmentName_1 = require("./environmentName");
74
+ const generateConfigFiles_1 = require("./generateConfigFiles");
77
75
  const concurrentLocker_1 = require("./middleware/concurrentLocker");
78
76
  const contextInjector_1 = require("./middleware/contextInjector");
79
77
  const errorHandler_1 = require("./middleware/errorHandler");
@@ -83,8 +81,10 @@ const retry_1 = require("./middleware/retry");
83
81
  const v3MigrationUtils_1 = require("./middleware/utils/v3MigrationUtils");
84
82
  const share_2 = require("./share");
85
83
  const telemetry_2 = require("./telemetry");
86
- class FxCore {
84
+ const FxCore_declarativeAgent_1 = require("./FxCore.declarativeAgent");
85
+ class FxCore extends FxCore_declarativeAgent_1.FxCoreDeclarativeAgentPart {
87
86
  constructor(tools) {
87
+ super();
88
88
  (0, globalVars_1.setTools)(tools);
89
89
  }
90
90
  /**
@@ -1056,7 +1056,7 @@ class FxCore {
1056
1056
  .toString()
1057
1057
  .split(/\r?\n/)
1058
1058
  .forEach((line) => {
1059
- const reg = /^([a-zA-Z_][a-zA-Z0-9_]*=)/g;
1059
+ const reg = /^([a-zA-Z_][a-zA-Z0-9_]*=)(.*)/g;
1060
1060
  const match = reg.exec(line);
1061
1061
  if (match) {
1062
1062
  if (match[1].startsWith("TEAMSFX_ENV=")) {
@@ -1066,7 +1066,7 @@ class FxCore {
1066
1066
  writeStream.write(`APP_NAME_SUFFIX=${targetEnvName}${os.EOL}`);
1067
1067
  }
1068
1068
  else if (match[1].startsWith("AGENT_SCOPE=")) {
1069
- writeStream.write(`AGENT_SCOPE=shared${os.EOL}`);
1069
+ writeStream.write(`AGENT_SCOPE=${match[2]}${os.EOL}`);
1070
1070
  }
1071
1071
  else {
1072
1072
  writeStream.write(`${match[1]}${os.EOL}`);
@@ -1349,24 +1349,10 @@ class FxCore {
1349
1349
  if (!inputs.projectPath) {
1350
1350
  throw new Error("projectPath is undefined"); // should never happen
1351
1351
  }
1352
- // Call Kiota to select the OpenAPI spec file
1353
- if (inputs.platform === teamsfx_api_1.Platform.VSCode &&
1354
- featureFlags_1.featureFlagManager.getBooleanValue(featureFlags_1.FeatureFlags.KiotaIntegration) &&
1355
- inputs[constants_3.QuestionNames.ActionType] === constants_3.ActionStartOptions.apiSpec().id &&
1356
- !!!inputs[constants_3.QuestionNames.ActionManifestPath]) {
1357
- return (0, teamsfx_api_1.ok)({
1358
- projectPath: inputs.projectPath,
1359
- lastCommand: constants_2.KiotaLastCommands.addPlugin,
1360
- manifestPath: inputs[constants_3.QuestionNames.ManifestPath],
1361
- });
1362
- }
1363
1352
  const context = (0, globalVars_1.createContext)();
1364
1353
  const teamsManifestPath = inputs[constants_3.QuestionNames.ManifestPath];
1365
1354
  const appPackageFolder = path.dirname(teamsManifestPath);
1366
1355
  const isGenerateFromApiSpec = inputs[constants_3.QuestionNames.ActionType] === constants_3.ActionStartOptions.apiSpec().id;
1367
- const isKiotaIntegration = inputs.platform === teamsfx_api_1.Platform.VSCode &&
1368
- featureFlags_1.featureFlagManager.getBooleanValue(featureFlags_1.FeatureFlags.KiotaIntegration) &&
1369
- !!inputs[constants_3.QuestionNames.ActionManifestPath];
1370
1356
  // validate the project is valid for adding plugin
1371
1357
  const manifestRes = await ManifestUtils_1.manifestUtils._readAppManifest(teamsManifestPath);
1372
1358
  if (manifestRes.isErr()) {
@@ -1393,15 +1379,9 @@ class FxCore {
1393
1379
  // Will be used if generating from API spec
1394
1380
  let specParser = undefined;
1395
1381
  let authNameAndSchemes = [];
1396
- if (isGenerateFromApiSpec && !isKiotaIntegration) {
1382
+ if (isGenerateFromApiSpec) {
1397
1383
  specParser = new m365_spec_parser_1.SpecParser(inputs[constants_3.QuestionNames.ApiSpecLocation].trim(), (0, helper_2.getParserOptions)(m365_spec_parser_1.ProjectType.Copilot, true));
1398
1384
  const listResult = await (0, daSpecParser_1.listAPIInfo)(inputs[constants_3.QuestionNames.ApiSpecLocation].trim());
1399
- if (inputs.platform === teamsfx_api_1.Platform.VSCode &&
1400
- featureFlags_1.featureFlagManager.getBooleanValue(featureFlags_1.FeatureFlags.KiotaIntegration) &&
1401
- inputs[constants_3.QuestionNames.ActionType] === constants_3.ActionStartOptions.apiSpec().id &&
1402
- !!inputs[constants_3.QuestionNames.ActionManifestPath]) {
1403
- inputs[constants_3.QuestionNames.ApiOperation] = listResult.APIs.filter((value) => value.isValid).map((value) => value.api);
1404
- }
1405
1385
  authNameAndSchemes = this.parseAuthNameAndScheme(listResult, inputs);
1406
1386
  if (authNameAndSchemes.length > 0) {
1407
1387
  const doesLocalYamlPathExists = await fs_extra_1.default.pathExists(path.join(inputs.projectPath, versionMetadata_1.MetadataV3.localConfigFile));
@@ -1428,64 +1408,39 @@ class FxCore {
1428
1408
  actionId = `action_${suffix}`;
1429
1409
  }
1430
1410
  let destinationPluginManifestPath;
1431
- if (isKiotaIntegration) {
1432
- // 1. Copy openapi spec file
1433
- const openapiSpecFileName = path.basename(inputs[constants_3.QuestionNames.ApiSpecLocation]);
1434
- const openapiSpecPath = path.join(appPackageFolder, openapiSpecFileName);
1435
- await fs_extra_1.default.copyFile(inputs[constants_3.QuestionNames.ApiSpecLocation].trim(), openapiSpecPath);
1436
- // 2. Copy plugin manifest file
1437
- const pluginManifestPath = path.join(inputs.projectPath, teamsfx_api_1.AppPackageFolderName, path.basename(inputs[constants_3.QuestionNames.ActionManifestPath]));
1438
- destinationPluginManifestPath = pluginManifestPath;
1439
- await fs_extra_1.default.copyFile(inputs[constants_3.QuestionNames.ActionManifestPath], pluginManifestPath);
1440
- // 2.1 Need to update the plugin manifest file
1441
- const authData = await (0, daSpecParser_1.parseAndUpdatePluginManifestForKiota)(pluginManifestPath, true);
1442
- // 3. Update teamsapp.local.yaml and teamsapp.yaml if need to add auth action
1443
- for (const authInfo of authData) {
1444
- await (0, helper_2.injectAuthAction)(inputs.projectPath, authInfo.authName, undefined, openapiSpecPath, false, authInfo.authType === "apiKey" ? "ApiKeyPluginVault" : "OAuthPluginVault", false, authInfo.registrationId);
1445
- }
1446
- // 4. Add action in plugin manifest
1411
+ // generate files
1412
+ if (isGenerateFromApiSpec && specParser) {
1413
+ destinationPluginManifestPath =
1414
+ await CopilotGptManifestUtils_1.copilotGptManifestUtils.getDefaultNextAvailablePluginManifestPath(appPackageFolder, undefined);
1415
+ const destinationApiSpecPath = await PluginManifestUtils_1.pluginManifestUtils.getDefaultNextAvailableApiSpecPath(inputs[constants_3.QuestionNames.ApiSpecLocation].trim(), path.join(appPackageFolder, teamsfx_api_1.DefaultApiSpecFolderName));
1416
+ const generateRes = await (0, helper_2.generateFromApiSpec)(specParser, teamsManifestPath, inputs, context, teamsfx_api_1.Stage.addPlugin, m365_spec_parser_1.ProjectType.Copilot, {
1417
+ destinationApiSpecFilePath: destinationApiSpecPath,
1418
+ pluginManifestFilePath: destinationPluginManifestPath,
1419
+ }, inputs[constants_3.QuestionNames.ApiSpecLocation].trim());
1420
+ if (generateRes.isErr()) {
1421
+ return (0, teamsfx_api_1.err)(generateRes.error);
1422
+ }
1423
+ const warnings = generateRes.value.warnings;
1424
+ if (warnings && warnings.length > 0) {
1425
+ const warnSummary = await (0, helper_2.generateScaffoldingSummary)(warnings, manifestRes.value, path.relative(inputs.projectPath, destinationApiSpecPath), path.relative(inputs.projectPath, destinationPluginManifestPath), inputs.projectPath);
1426
+ context.logProvider.info(warnSummary + "\n");
1427
+ }
1447
1428
  const addActionRes = await CopilotGptManifestUtils_1.copilotGptManifestUtils.addAction(declarativeCopilotManifestPath, actionId, (0, utils_3.normalizePath)(path.relative(appPackageFolder, destinationPluginManifestPath), true));
1448
1429
  if (addActionRes.isErr()) {
1449
1430
  return (0, teamsfx_api_1.err)(addActionRes.error);
1450
1431
  }
1451
- // 5. Update plugin manifest to add ac info (optional)
1452
- await (0, helper_2.generateAdaptiveCardInPluginManifestForKiota)(pluginManifestPath, openapiSpecPath, context);
1432
+ for (const authNameAndScheme of authNameAndSchemes) {
1433
+ await this.updateAuthActionInYaml(authNameAndScheme.authName, authNameAndScheme.authScheme, inputs.projectPath, destinationApiSpecPath, destinationPluginManifestPath);
1434
+ }
1453
1435
  }
1454
1436
  else {
1455
- // generate files
1456
- if (isGenerateFromApiSpec && specParser) {
1457
- destinationPluginManifestPath =
1458
- await CopilotGptManifestUtils_1.copilotGptManifestUtils.getDefaultNextAvailablePluginManifestPath(appPackageFolder, undefined);
1459
- const destinationApiSpecPath = await PluginManifestUtils_1.pluginManifestUtils.getDefaultNextAvailableApiSpecPath(inputs[constants_3.QuestionNames.ApiSpecLocation].trim(), path.join(appPackageFolder, teamsfx_api_1.DefaultApiSpecFolderName));
1460
- const generateRes = await (0, helper_2.generateFromApiSpec)(specParser, teamsManifestPath, inputs, context, teamsfx_api_1.Stage.addPlugin, m365_spec_parser_1.ProjectType.Copilot, {
1461
- destinationApiSpecFilePath: destinationApiSpecPath,
1462
- pluginManifestFilePath: destinationPluginManifestPath,
1463
- }, inputs[constants_3.QuestionNames.ApiSpecLocation].trim());
1464
- if (generateRes.isErr()) {
1465
- return (0, teamsfx_api_1.err)(generateRes.error);
1466
- }
1467
- const warnings = generateRes.value.warnings;
1468
- if (warnings && warnings.length > 0) {
1469
- const warnSummary = await (0, helper_2.generateScaffoldingSummary)(warnings, manifestRes.value, path.relative(inputs.projectPath, destinationApiSpecPath), path.relative(inputs.projectPath, destinationPluginManifestPath), inputs.projectPath);
1470
- context.logProvider.info(warnSummary + "\n");
1471
- }
1472
- const addActionRes = await CopilotGptManifestUtils_1.copilotGptManifestUtils.addAction(declarativeCopilotManifestPath, actionId, (0, utils_3.normalizePath)(path.relative(appPackageFolder, destinationPluginManifestPath), true));
1473
- if (addActionRes.isErr()) {
1474
- return (0, teamsfx_api_1.err)(addActionRes.error);
1475
- }
1476
- for (const authNameAndScheme of authNameAndSchemes) {
1477
- await this.updateAuthActionInYaml(authNameAndScheme.authName, authNameAndScheme.authScheme, inputs.projectPath, destinationApiSpecPath, destinationPluginManifestPath);
1478
- }
1479
- }
1480
- else {
1481
- const addPluginRes = await (0, helper_1.addExistingPlugin)(declarativeCopilotManifestPath, inputs[constants_3.QuestionNames.PluginManifestFilePath].trim(), inputs[constants_3.QuestionNames.PluginOpenApiSpecFilePath].trim(), actionId, context, teamsfx_api_1.Stage.addPlugin);
1482
- if (addPluginRes.isErr()) {
1483
- return (0, teamsfx_api_1.err)(addPluginRes.error);
1484
- }
1485
- destinationPluginManifestPath = addPluginRes.value.destinationPluginManifestPath;
1486
- const warningMessage = (0, common_1.outputScaffoldingWarningMessage)(addPluginRes.value.warnings);
1487
- context.logProvider.info(warningMessage);
1437
+ const addPluginRes = await (0, helper_1.addExistingPlugin)(declarativeCopilotManifestPath, inputs[constants_3.QuestionNames.PluginManifestFilePath].trim(), inputs[constants_3.QuestionNames.PluginOpenApiSpecFilePath].trim(), actionId, context, teamsfx_api_1.Stage.addPlugin);
1438
+ if (addPluginRes.isErr()) {
1439
+ return (0, teamsfx_api_1.err)(addPluginRes.error);
1488
1440
  }
1441
+ destinationPluginManifestPath = addPluginRes.value.destinationPluginManifestPath;
1442
+ const warningMessage = (0, common_1.outputScaffoldingWarningMessage)(addPluginRes.value.warnings);
1443
+ context.logProvider.info(warningMessage);
1489
1444
  }
1490
1445
  if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
1491
1446
  const successMessage = (0, localizeUtils_1.getLocalizedString)("core.addPlugin.success.vsc", actionId);
@@ -1902,165 +1857,6 @@ class FxCore {
1902
1857
  }
1903
1858
  return (0, teamsfx_api_1.ok)(undefined);
1904
1859
  }
1905
- async updateActionWithMCP(inputs) {
1906
- var _a, _b, _c, _d;
1907
- const context = (0, globalVars_1.createContext)();
1908
- const projectPath = inputs.projectPath;
1909
- if (!projectPath) {
1910
- throw new Error("projectPath is undefined"); // should never happen
1911
- }
1912
- const aiPluginFilePath = inputs[constants_3.QuestionNames.PluginManifestFilePath];
1913
- if (!(await fs_extra_1.default.pathExists(aiPluginFilePath))) {
1914
- 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));
1915
- return (0, teamsfx_api_1.err)(error);
1916
- }
1917
- const aiPluginFilePathRelative = path.basename(aiPluginFilePath);
1918
- const mcpServerUrl = inputs[constants_3.QuestionNames.MCPForDAServerUrl];
1919
- const serverName = inputs[constants_3.QuestionNames.MCPForDAServerName];
1920
- const mcpAuth = inputs[constants_3.QuestionNames.MCPForDAAuth];
1921
- const authType = inputs[constants_3.QuestionNames.MCPForDAAuthType];
1922
- let oauthAuthorizationUrl = undefined;
1923
- let oauthTokenUrl = undefined;
1924
- let oauthRefreshUrl = undefined;
1925
- let registrationId = undefined;
1926
- if (mcpAuth === "OAuthPluginVault") {
1927
- try {
1928
- registrationId = `MCP_DA_AUTH_ID_${serverName.toUpperCase()}`;
1929
- if (authType === "oauth") {
1930
- let wellKnownMetadataUrl = inputs[constants_3.QuestionNames.MCPForDAAuthWellKnownUrl];
1931
- if (!wellKnownMetadataUrl) {
1932
- const mcpAuthMetadataUrl = inputs[constants_3.QuestionNames.MCPForDAAuthMetadataUrl];
1933
- if (!mcpAuthMetadataUrl) {
1934
- throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpAuthMetadataUrlNotFound"));
1935
- }
1936
- const response = await axios_1.default.get(mcpAuthMetadataUrl);
1937
- if (response.status === 200 &&
1938
- response.data &&
1939
- response.data.authorization_servers &&
1940
- response.data.authorization_servers.length > 0) {
1941
- const mcpServerMetadataUrl = (_a = response.data.authorization_servers) === null || _a === void 0 ? void 0 : _a[0];
1942
- // Transform the URL to the proper OAuth authorization server metadata endpoint
1943
- // According to RFC 8414, the well-known endpoint should be constructed as:
1944
- // https://{domain}/.well-known/oauth-authorization-server{path}
1945
- const serverUrl = new URL(mcpServerMetadataUrl);
1946
- wellKnownMetadataUrl = `${serverUrl.protocol}//${serverUrl.host}/.well-known/oauth-authorization-server${serverUrl.pathname}`;
1947
- }
1948
- else {
1949
- throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpServerMetadataUrlNotFound"));
1950
- }
1951
- }
1952
- const metadataResponse = await axios_1.default.get(wellKnownMetadataUrl);
1953
- if (metadataResponse.status === 200) {
1954
- oauthAuthorizationUrl = metadataResponse.data.authorization_endpoint;
1955
- oauthTokenUrl = metadataResponse.data.token_endpoint;
1956
- oauthRefreshUrl = metadataResponse.data.refresh_endpoint;
1957
- }
1958
- if (!oauthAuthorizationUrl || !oauthTokenUrl) {
1959
- throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.authUrlNotFound"));
1960
- }
1961
- }
1962
- }
1963
- catch (error) {
1964
- void context.userInteraction.showMessage("error", (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpAuthMetadataMissingError", error.message), false);
1965
- }
1966
- }
1967
- // 2. Read ai-plugin.json
1968
- const aiPluginContent = await fs_extra_1.default.readJSON(aiPluginFilePath);
1969
- // For dynamic fetch tools, keep the functions empty and add runtime info
1970
- // TODO: support dynamic fetch tools in the future
1971
- const mcpToolsDetail = inputs[constants_3.QuestionNames.MCPForDAAvailableTools];
1972
- const mcpToolsSelected = inputs[constants_3.QuestionNames.MCPForDAPreFetchTools];
1973
- if (!mcpToolsDetail || !mcpToolsSelected) {
1974
- const error = new teamsfx_api_1.UserError("MCPForDAPreFetchToolsNotFound", "PreFetchToolsNotFound", (0, localizeUtils_1.getDefaultString)("core.MCPForDA.preFetchToolsNotFound"), (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.preFetchToolsNotFound"));
1975
- return (0, teamsfx_api_1.err)(error);
1976
- }
1977
- const toolsSelectedPrevious = [];
1978
- aiPluginContent.runtimes
1979
- .filter((runtime) => (runtime.type === "RemoteMCPServer" &&
1980
- runtime.spec.url === mcpServerUrl &&
1981
- !runtime.spec["enable_dynamic_discovery"]) ||
1982
- runtime.type === "LocalPlugin")
1983
- .forEach((runtime) => {
1984
- toolsSelectedPrevious.push(...runtime.run_for_functions);
1985
- });
1986
- aiPluginContent.functions = aiPluginContent.functions.filter((func) => !toolsSelectedPrevious.includes(func.name));
1987
- aiPluginContent.functions = [
1988
- ...aiPluginContent.functions,
1989
- ...mcpToolsDetail
1990
- .filter((tool) => mcpToolsSelected.includes(tool.name))
1991
- .map((tool) => {
1992
- return {
1993
- name: tool.name,
1994
- description: tool.description,
1995
- };
1996
- }),
1997
- ];
1998
- const matchedRuntime = aiPluginContent.runtimes.find((runtime) => runtime.type === "RemoteMCPServer" && runtime.spec.url === mcpServerUrl);
1999
- aiPluginContent.runtimes = aiPluginContent.runtimes.filter((runtime) => (runtime.type !== "RemoteMCPServer" && runtime.type !== "LocalPlugin") ||
2000
- runtime.spec.url !== mcpServerUrl ||
2001
- runtime.spec["enable_dynamic_discovery"] === true);
2002
- if (inputs[constants_3.QuestionNames.MCPLocalServerIdentifier] != null) {
2003
- aiPluginContent.runtimes.push({
2004
- type: "LocalPlugin",
2005
- spec: {
2006
- local_endpoint: `${constants_2.LocalMcpPrefix}${inputs[constants_3.QuestionNames.MCPLocalServerIdentifier]}`,
2007
- },
2008
- run_for_functions: mcpToolsSelected,
2009
- });
2010
- }
2011
- else {
2012
- let mcpFile = (_b = matchedRuntime === null || matchedRuntime === void 0 ? void 0 : matchedRuntime.spec.mcp_tool_description) === null || _b === void 0 ? void 0 : _b.file;
2013
- if (!mcpFile) {
2014
- mcpFile = "mcp-tools.json";
2015
- let suffix = 1;
2016
- while (await fs_extra_1.default.pathExists(path.join(path.dirname(aiPluginFilePath), mcpFile))) {
2017
- mcpFile = `mcp-tools-${suffix}.json`;
2018
- suffix += 1;
2019
- }
2020
- }
2021
- await fs_extra_1.default.writeJSON(path.join(path.dirname(aiPluginFilePath), mcpFile), {
2022
- tools: [
2023
- ...mcpToolsDetail
2024
- .filter((tool) => mcpToolsSelected.includes(tool.name))
2025
- .map((tool) => {
2026
- return Object.assign(Object.assign({}, tool), { title: tool.name
2027
- .replace(/_/g, " ")
2028
- .replace(/^./, (str) => str.toUpperCase()) });
2029
- }),
2030
- ],
2031
- }, { spaces: 4 });
2032
- aiPluginContent.runtimes.push({
2033
- type: "RemoteMCPServer",
2034
- spec: {
2035
- url: mcpServerUrl,
2036
- mcp_tool_description: {
2037
- file: mcpFile,
2038
- },
2039
- },
2040
- run_for_functions: mcpToolsSelected,
2041
- auth: mcpAuth === "OAuthPluginVault" && !!registrationId
2042
- ? {
2043
- type: "OAuthPluginVault",
2044
- reference_id: `$\{\{${registrationId}\}\}`,
2045
- }
2046
- : undefined,
2047
- });
2048
- }
2049
- if (mcpAuth === "OAuthPluginVault" && !!registrationId) {
2050
- // insert oauth info in teamsapp.yaml
2051
- await actionInjector_1.ActionInjector.injectCreateOAuthActionForMCP(pathUtils_1.pathUtils.getYmlFilePath(projectPath), authType, serverName, registrationId, mcpServerUrl, oauthAuthorizationUrl, oauthTokenUrl, oauthRefreshUrl);
2052
- }
2053
- void context.userInteraction
2054
- .showMessage("info", (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.updatePluginManifest", aiPluginFilePathRelative), false, "Provision")
2055
- .then((result) => {
2056
- if (result.isOk() && result.value === "Provision") {
2057
- void this.provisionResources(inputs);
2058
- }
2059
- });
2060
- await fs_extra_1.default.writeJSON(aiPluginFilePath, aiPluginContent, { spaces: 4 });
2061
- void ((_d = (_c = context.userInteraction).openFile) === null || _d === void 0 ? void 0 : _d.call(_c, aiPluginFilePath));
2062
- return (0, teamsfx_api_1.ok)(undefined);
2063
- }
2064
1860
  /**
2065
1861
  * dynamic template metadata download
2066
1862
  */
@@ -2116,6 +1912,12 @@ class FxCore {
2116
1912
  return (0, teamsfx_api_1.err)(systemErr);
2117
1913
  }
2118
1914
  }
1915
+ /**
1916
+ * dynamic template metadata download
1917
+ */
1918
+ async generateConfigFiles(inputs) {
1919
+ return await (0, generateConfigFiles_1.generateConfigFiles)(inputs);
1920
+ }
2119
1921
  async updateAuthActionInYaml(authName, authScheme, projectPath, apSpecPath, pluginManifestPath, forceToAddNew = true) {
2120
1922
  if (authName && authScheme) {
2121
1923
  const authInjectRes = await (0, helper_2.injectAuthAction)(projectPath, authName, authScheme, apSpecPath, forceToAddNew);
@@ -2938,17 +2740,6 @@ tslib_1.__decorate([
2938
2740
  tslib_1.__metadata("design:paramtypes", [Object]),
2939
2741
  tslib_1.__metadata("design:returntype", Promise)
2940
2742
  ], FxCore.prototype, "installAppToChannel", null);
2941
- tslib_1.__decorate([
2942
- (0, hooks_1.hooks)([
2943
- (0, globalVars_1.ErrorContextMW)({ component: "FxCore", stage: teamsfx_api_1.Stage.installApp }),
2944
- errorHandler_1.ErrorHandlerMW,
2945
- (0, questionMW_1.QuestionMW)("updateActionWithMCP"),
2946
- concurrentLocker_1.ConcurrentLockerMW,
2947
- ]),
2948
- tslib_1.__metadata("design:type", Function),
2949
- tslib_1.__metadata("design:paramtypes", [Object]),
2950
- tslib_1.__metadata("design:returntype", Promise)
2951
- ], FxCore.prototype, "updateActionWithMCP", null);
2952
2743
  tslib_1.__decorate([
2953
2744
  (0, hooks_1.hooks)([
2954
2745
  (0, globalVars_1.ErrorContextMW)({ component: "FxCore", stage: "fetchOnlineTemplateMetadata" }),
@@ -2958,5 +2749,11 @@ tslib_1.__decorate([
2958
2749
  tslib_1.__metadata("design:paramtypes", []),
2959
2750
  tslib_1.__metadata("design:returntype", Promise)
2960
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);
2961
2758
  exports.FxCore = FxCore;
2962
2759
  //# sourceMappingURL=FxCore.js.map