@microsoft/teamsfx-core 3.0.10-alpha.bd1eea45e.0 → 3.0.10-alpha.edb63176e.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/client/graphClient.d.ts +1 -0
- package/build/client/graphClient.d.ts.map +1 -1
- package/build/client/teamsDevPortalClient.d.ts +1 -0
- package/build/client/teamsDevPortalClient.d.ts.map +1 -1
- package/build/common/featureFlags.d.ts +10 -20
- package/build/common/featureFlags.d.ts.map +1 -1
- package/build/common/featureFlags.js +12 -21
- 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/coordinator/index.d.ts.map +1 -1
- package/build/component/coordinator/index.js +0 -11
- package/build/component/coordinator/index.js.map +1 -1
- package/build/component/deps-checker/internal/dotnetChecker.d.ts +5 -1
- package/build/component/deps-checker/internal/dotnetChecker.d.ts.map +1 -1
- package/build/component/deps-checker/internal/dotnetChecker.js +16 -8
- package/build/component/deps-checker/internal/dotnetChecker.js.map +1 -1
- package/build/component/driver/deploy/spfx/utility/spoClient.d.ts +1 -0
- package/build/component/driver/deploy/spfx/utility/spoClient.d.ts.map +1 -1
- package/build/component/driver/devTool/httpClient.d.ts +1 -0
- package/build/component/driver/devTool/httpClient.d.ts.map +1 -1
- package/build/component/driver/devTool/nodeInstaller.d.ts +1 -0
- package/build/component/driver/devTool/nodeInstaller.d.ts.map +1 -1
- package/build/component/driver/script/scriptDriver.d.ts +1 -0
- package/build/component/driver/script/scriptDriver.d.ts.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/driver/share/utils.d.ts.map +1 -1
- package/build/component/driver/share/utils.js +6 -0
- package/build/component/driver/share/utils.js.map +1 -1
- package/build/component/driver/teamsApp/constants.d.ts +1 -1
- package/build/component/driver/teamsApp/constants.d.ts.map +1 -1
- package/build/component/driver/teamsApp/constants.js +2 -2
- package/build/component/driver/teamsApp/constants.js.map +1 -1
- package/build/component/driver/teamsApp/copyAppPackageToSPFx.d.ts +1 -0
- package/build/component/driver/teamsApp/copyAppPackageToSPFx.d.ts.map +1 -1
- package/build/component/driver/teamsApp/createAppPackage.d.ts.map +1 -1
- package/build/component/driver/teamsApp/createAppPackage.js +12 -1
- package/build/component/driver/teamsApp/createAppPackage.js.map +1 -1
- package/build/component/driver/teamsApp/interfaces/appdefinitions/appPackage.d.ts +1 -0
- package/build/component/driver/teamsApp/interfaces/appdefinitions/appPackage.d.ts.map +1 -1
- package/build/component/driver/teamsApp/utils/ManifestUtils.d.ts +1 -0
- package/build/component/driver/teamsApp/utils/ManifestUtils.d.ts.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 +168 -0
- package/build/component/generator/configFiles/configGenerator.js.map +1 -0
- package/build/component/generator/configFiles/copyPolicy.d.ts +12 -0
- package/build/component/generator/configFiles/copyPolicy.d.ts.map +1 -0
- package/build/component/generator/configFiles/copyPolicy.js +63 -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/generator.d.ts +5 -0
- package/build/component/generator/declarativeAgent/generator.d.ts.map +1 -1
- package/build/component/generator/declarativeAgent/generator.js +76 -36
- package/build/component/generator/declarativeAgent/generator.js.map +1 -1
- 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/generator/generatorAction.d.ts +1 -0
- package/build/component/generator/generatorAction.d.ts.map +1 -1
- package/build/component/generator/openApiSpec/common.d.ts.map +1 -1
- package/build/component/generator/openApiSpec/common.js +11 -22
- package/build/component/generator/openApiSpec/common.js.map +1 -1
- package/build/component/generator/openApiSpec/kiota.d.ts +0 -6
- package/build/component/generator/openApiSpec/kiota.d.ts.map +1 -1
- package/build/component/generator/openApiSpec/kiota.js +2 -17
- package/build/component/generator/openApiSpec/kiota.js.map +1 -1
- package/build/component/generator/templates/templateInfo.d.ts +1 -1
- package/build/component/generator/templates/templateInfo.d.ts.map +1 -1
- package/build/component/generator/utils.d.ts +3 -2
- package/build/component/generator/utils.d.ts.map +1 -1
- package/build/component/generator/utils.js.map +1 -1
- package/build/component/m365/packageService.d.ts.map +1 -1
- package/build/component/m365/packageService.js +16 -20
- package/build/component/m365/packageService.js.map +1 -1
- package/build/component/middleware/envMW.d.ts.map +1 -1
- package/build/component/middleware/envMW.js +7 -0
- package/build/component/middleware/envMW.js.map +1 -1
- package/build/component/utils/envUtil.d.ts +1 -0
- package/build/component/utils/envUtil.d.ts.map +1 -1
- package/build/component/utils/odrProvider.d.ts +13 -0
- package/build/component/utils/odrProvider.d.ts.map +1 -1
- package/build/component/utils/odrProvider.js +25 -0
- package/build/component/utils/odrProvider.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 +45 -231
- 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 +64 -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/build/question/other.d.ts.map +1 -1
- package/build/question/other.js +0 -2
- package/build/question/other.js.map +1 -1
- package/build/question/questionNames.d.ts +0 -3
- package/build/question/questionNames.d.ts.map +1 -1
- package/build/question/questionNames.js +0 -3
- package/build/question/questionNames.js.map +1 -1
- package/build/question/scaffold/vsc/ProjectTypeOptions.d.ts +0 -1
- package/build/question/scaffold/vsc/ProjectTypeOptions.d.ts.map +1 -1
- package/build/question/scaffold/vsc/ProjectTypeOptions.js +1 -14
- package/build/question/scaffold/vsc/ProjectTypeOptions.js.map +1 -1
- package/build/question/scaffold/vsc/createRootNode.d.ts.map +1 -1
- package/build/question/scaffold/vsc/createRootNode.js +1 -5
- package/build/question/scaffold/vsc/createRootNode.js.map +1 -1
- package/build/question/scaffold/vsc/daProjectTypeNode.d.ts.map +1 -1
- package/build/question/scaffold/vsc/daProjectTypeNode.js +1 -2
- package/build/question/scaffold/vsc/daProjectTypeNode.js.map +1 -1
- package/build/question/scaffold/vsc/officeAddinProjectTypeNode.d.ts +0 -1
- package/build/question/scaffold/vsc/officeAddinProjectTypeNode.d.ts.map +1 -1
- package/build/question/scaffold/vsc/officeAddinProjectTypeNode.js +2 -51
- package/build/question/scaffold/vsc/officeAddinProjectTypeNode.js.map +1 -1
- package/build/question/scaffold/vsc/teamsProjectTypeNode.d.ts.map +1 -1
- package/build/question/scaffold/vsc/teamsProjectTypeNode.js +5 -16
- package/build/question/scaffold/vsc/teamsProjectTypeNode.js.map +1 -1
- package/package.json +5 -5
- package/resource/package.nls.cs.json +4 -4
- package/resource/package.nls.de.json +16 -16
- package/resource/package.nls.es.json +15 -15
- package/resource/package.nls.fr.json +4 -4
- package/resource/package.nls.it.json +4 -4
- package/resource/package.nls.ja.json +5 -5
- package/resource/package.nls.json +4 -4
- package/resource/package.nls.ko.json +15 -15
- package/resource/package.nls.pl.json +15 -15
- package/resource/package.nls.pt-BR.json +11 -11
- package/resource/package.nls.ru.json +6 -6
- package/resource/package.nls.tr.json +4 -4
- package/resource/package.nls.zh-Hans.json +4 -4
- package/resource/package.nls.zh-Hant.json +9 -9
- 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/configs/remote/python/.vscode/launch.json.tpl +70 -0
- package/templates/configs/remote/python/.webappignore +11 -0
- package/templates/configs/remote/python/env/.env.dev +11 -0
- package/templates/configs/remote/python/infra/azure.bicep.tpl +108 -0
- package/templates/configs/remote/python/infra/azure.parameters.json.tpl +20 -0
- package/templates/configs/remote/python/infra/botRegistration/azurebot.bicep +42 -0
- package/templates/configs/remote/python/infra/botRegistration/readme.md +1 -0
- package/templates/configs/remote/python/m365agents.yml.tpl +131 -0
- package/templates/configs/remote/typescript/.vscode/launch.json.tpl +70 -0
- package/templates/configs/remote/typescript/.webappignore +27 -0
- package/templates/configs/remote/typescript/env/.env.dev +11 -0
- package/templates/configs/remote/typescript/infra/azure.bicep.tpl +105 -0
- package/templates/configs/remote/typescript/infra/azure.parameters.json.tpl +17 -0
- package/templates/configs/remote/typescript/infra/botRegistration/azurebot.bicep +42 -0
- package/templates/configs/remote/typescript/infra/botRegistration/readme.md +1 -0
- package/templates/configs/remote/typescript/m365agents.yml.tpl +142 -0
- package/templates/configs/remote/typescript/web.config +60 -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
package/build/core/FxCore.js
CHANGED
|
@@ -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,9 +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
|
-
const
|
|
87
|
-
class FxCore {
|
|
84
|
+
const FxCore_declarativeAgent_1 = require("./FxCore.declarativeAgent");
|
|
85
|
+
class FxCore extends FxCore_declarativeAgent_1.FxCoreDeclarativeAgentPart {
|
|
88
86
|
constructor(tools) {
|
|
87
|
+
super();
|
|
89
88
|
(0, globalVars_1.setTools)(tools);
|
|
90
89
|
}
|
|
91
90
|
/**
|
|
@@ -1057,7 +1056,7 @@ class FxCore {
|
|
|
1057
1056
|
.toString()
|
|
1058
1057
|
.split(/\r?\n/)
|
|
1059
1058
|
.forEach((line) => {
|
|
1060
|
-
const reg = /^([a-zA-Z_][a-zA-Z0-9_]*=)/g;
|
|
1059
|
+
const reg = /^([a-zA-Z_][a-zA-Z0-9_]*=)(.*)/g;
|
|
1061
1060
|
const match = reg.exec(line);
|
|
1062
1061
|
if (match) {
|
|
1063
1062
|
if (match[1].startsWith("TEAMSFX_ENV=")) {
|
|
@@ -1067,7 +1066,7 @@ class FxCore {
|
|
|
1067
1066
|
writeStream.write(`APP_NAME_SUFFIX=${targetEnvName}${os.EOL}`);
|
|
1068
1067
|
}
|
|
1069
1068
|
else if (match[1].startsWith("AGENT_SCOPE=")) {
|
|
1070
|
-
writeStream.write(`AGENT_SCOPE
|
|
1069
|
+
writeStream.write(`AGENT_SCOPE=${match[2]}${os.EOL}`);
|
|
1071
1070
|
}
|
|
1072
1071
|
else {
|
|
1073
1072
|
writeStream.write(`${match[1]}${os.EOL}`);
|
|
@@ -1350,24 +1349,10 @@ class FxCore {
|
|
|
1350
1349
|
if (!inputs.projectPath) {
|
|
1351
1350
|
throw new Error("projectPath is undefined"); // should never happen
|
|
1352
1351
|
}
|
|
1353
|
-
// Call Kiota to select the OpenAPI spec file
|
|
1354
|
-
if (inputs.platform === teamsfx_api_1.Platform.VSCode &&
|
|
1355
|
-
featureFlags_1.featureFlagManager.getBooleanValue(featureFlags_1.FeatureFlags.KiotaIntegration) &&
|
|
1356
|
-
inputs[constants_3.QuestionNames.ActionType] === constants_3.ActionStartOptions.apiSpec().id &&
|
|
1357
|
-
!!!inputs[constants_3.QuestionNames.ActionManifestPath]) {
|
|
1358
|
-
return (0, teamsfx_api_1.ok)({
|
|
1359
|
-
projectPath: inputs.projectPath,
|
|
1360
|
-
lastCommand: constants_2.KiotaLastCommands.addPlugin,
|
|
1361
|
-
manifestPath: inputs[constants_3.QuestionNames.ManifestPath],
|
|
1362
|
-
});
|
|
1363
|
-
}
|
|
1364
1352
|
const context = (0, globalVars_1.createContext)();
|
|
1365
1353
|
const teamsManifestPath = inputs[constants_3.QuestionNames.ManifestPath];
|
|
1366
1354
|
const appPackageFolder = path.dirname(teamsManifestPath);
|
|
1367
1355
|
const isGenerateFromApiSpec = inputs[constants_3.QuestionNames.ActionType] === constants_3.ActionStartOptions.apiSpec().id;
|
|
1368
|
-
const isKiotaIntegration = inputs.platform === teamsfx_api_1.Platform.VSCode &&
|
|
1369
|
-
featureFlags_1.featureFlagManager.getBooleanValue(featureFlags_1.FeatureFlags.KiotaIntegration) &&
|
|
1370
|
-
!!inputs[constants_3.QuestionNames.ActionManifestPath];
|
|
1371
1356
|
// validate the project is valid for adding plugin
|
|
1372
1357
|
const manifestRes = await ManifestUtils_1.manifestUtils._readAppManifest(teamsManifestPath);
|
|
1373
1358
|
if (manifestRes.isErr()) {
|
|
@@ -1394,15 +1379,9 @@ class FxCore {
|
|
|
1394
1379
|
// Will be used if generating from API spec
|
|
1395
1380
|
let specParser = undefined;
|
|
1396
1381
|
let authNameAndSchemes = [];
|
|
1397
|
-
if (isGenerateFromApiSpec
|
|
1382
|
+
if (isGenerateFromApiSpec) {
|
|
1398
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));
|
|
1399
1384
|
const listResult = await (0, daSpecParser_1.listAPIInfo)(inputs[constants_3.QuestionNames.ApiSpecLocation].trim());
|
|
1400
|
-
if (inputs.platform === teamsfx_api_1.Platform.VSCode &&
|
|
1401
|
-
featureFlags_1.featureFlagManager.getBooleanValue(featureFlags_1.FeatureFlags.KiotaIntegration) &&
|
|
1402
|
-
inputs[constants_3.QuestionNames.ActionType] === constants_3.ActionStartOptions.apiSpec().id &&
|
|
1403
|
-
!!inputs[constants_3.QuestionNames.ActionManifestPath]) {
|
|
1404
|
-
inputs[constants_3.QuestionNames.ApiOperation] = listResult.APIs.filter((value) => value.isValid).map((value) => value.api);
|
|
1405
|
-
}
|
|
1406
1385
|
authNameAndSchemes = this.parseAuthNameAndScheme(listResult, inputs);
|
|
1407
1386
|
if (authNameAndSchemes.length > 0) {
|
|
1408
1387
|
const doesLocalYamlPathExists = await fs_extra_1.default.pathExists(path.join(inputs.projectPath, versionMetadata_1.MetadataV3.localConfigFile));
|
|
@@ -1429,64 +1408,39 @@ class FxCore {
|
|
|
1429
1408
|
actionId = `action_${suffix}`;
|
|
1430
1409
|
}
|
|
1431
1410
|
let destinationPluginManifestPath;
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
await
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
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
|
+
}
|
|
1448
1428
|
const addActionRes = await CopilotGptManifestUtils_1.copilotGptManifestUtils.addAction(declarativeCopilotManifestPath, actionId, (0, utils_3.normalizePath)(path.relative(appPackageFolder, destinationPluginManifestPath), true));
|
|
1449
1429
|
if (addActionRes.isErr()) {
|
|
1450
1430
|
return (0, teamsfx_api_1.err)(addActionRes.error);
|
|
1451
1431
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1432
|
+
for (const authNameAndScheme of authNameAndSchemes) {
|
|
1433
|
+
await this.updateAuthActionInYaml(authNameAndScheme.authName, authNameAndScheme.authScheme, inputs.projectPath, destinationApiSpecPath, destinationPluginManifestPath);
|
|
1434
|
+
}
|
|
1454
1435
|
}
|
|
1455
1436
|
else {
|
|
1456
|
-
|
|
1457
|
-
if (
|
|
1458
|
-
|
|
1459
|
-
await CopilotGptManifestUtils_1.copilotGptManifestUtils.getDefaultNextAvailablePluginManifestPath(appPackageFolder, undefined);
|
|
1460
|
-
const destinationApiSpecPath = await PluginManifestUtils_1.pluginManifestUtils.getDefaultNextAvailableApiSpecPath(inputs[constants_3.QuestionNames.ApiSpecLocation].trim(), path.join(appPackageFolder, teamsfx_api_1.DefaultApiSpecFolderName));
|
|
1461
|
-
const generateRes = await (0, helper_2.generateFromApiSpec)(specParser, teamsManifestPath, inputs, context, teamsfx_api_1.Stage.addPlugin, m365_spec_parser_1.ProjectType.Copilot, {
|
|
1462
|
-
destinationApiSpecFilePath: destinationApiSpecPath,
|
|
1463
|
-
pluginManifestFilePath: destinationPluginManifestPath,
|
|
1464
|
-
}, inputs[constants_3.QuestionNames.ApiSpecLocation].trim());
|
|
1465
|
-
if (generateRes.isErr()) {
|
|
1466
|
-
return (0, teamsfx_api_1.err)(generateRes.error);
|
|
1467
|
-
}
|
|
1468
|
-
const warnings = generateRes.value.warnings;
|
|
1469
|
-
if (warnings && warnings.length > 0) {
|
|
1470
|
-
const warnSummary = await (0, helper_2.generateScaffoldingSummary)(warnings, manifestRes.value, path.relative(inputs.projectPath, destinationApiSpecPath), path.relative(inputs.projectPath, destinationPluginManifestPath), inputs.projectPath);
|
|
1471
|
-
context.logProvider.info(warnSummary + "\n");
|
|
1472
|
-
}
|
|
1473
|
-
const addActionRes = await CopilotGptManifestUtils_1.copilotGptManifestUtils.addAction(declarativeCopilotManifestPath, actionId, (0, utils_3.normalizePath)(path.relative(appPackageFolder, destinationPluginManifestPath), true));
|
|
1474
|
-
if (addActionRes.isErr()) {
|
|
1475
|
-
return (0, teamsfx_api_1.err)(addActionRes.error);
|
|
1476
|
-
}
|
|
1477
|
-
for (const authNameAndScheme of authNameAndSchemes) {
|
|
1478
|
-
await this.updateAuthActionInYaml(authNameAndScheme.authName, authNameAndScheme.authScheme, inputs.projectPath, destinationApiSpecPath, destinationPluginManifestPath);
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
else {
|
|
1482
|
-
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);
|
|
1483
|
-
if (addPluginRes.isErr()) {
|
|
1484
|
-
return (0, teamsfx_api_1.err)(addPluginRes.error);
|
|
1485
|
-
}
|
|
1486
|
-
destinationPluginManifestPath = addPluginRes.value.destinationPluginManifestPath;
|
|
1487
|
-
const warningMessage = (0, common_1.outputScaffoldingWarningMessage)(addPluginRes.value.warnings);
|
|
1488
|
-
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);
|
|
1489
1440
|
}
|
|
1441
|
+
destinationPluginManifestPath = addPluginRes.value.destinationPluginManifestPath;
|
|
1442
|
+
const warningMessage = (0, common_1.outputScaffoldingWarningMessage)(addPluginRes.value.warnings);
|
|
1443
|
+
context.logProvider.info(warningMessage);
|
|
1490
1444
|
}
|
|
1491
1445
|
if (inputs.platform === teamsfx_api_1.Platform.VSCode) {
|
|
1492
1446
|
const successMessage = (0, localizeUtils_1.getLocalizedString)("core.addPlugin.success.vsc", actionId);
|
|
@@ -1903,147 +1857,6 @@ class FxCore {
|
|
|
1903
1857
|
}
|
|
1904
1858
|
return (0, teamsfx_api_1.ok)(undefined);
|
|
1905
1859
|
}
|
|
1906
|
-
async updateActionWithMCP(inputs) {
|
|
1907
|
-
var _a, _b, _c;
|
|
1908
|
-
const context = (0, globalVars_1.createContext)();
|
|
1909
|
-
const projectPath = inputs.projectPath;
|
|
1910
|
-
if (!projectPath) {
|
|
1911
|
-
throw new Error("projectPath is undefined"); // should never happen
|
|
1912
|
-
}
|
|
1913
|
-
const aiPluginFilePath = inputs[constants_3.QuestionNames.PluginManifestFilePath];
|
|
1914
|
-
if (!(await fs_extra_1.default.pathExists(aiPluginFilePath))) {
|
|
1915
|
-
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));
|
|
1916
|
-
return (0, teamsfx_api_1.err)(error);
|
|
1917
|
-
}
|
|
1918
|
-
const aiPluginFilePathRelative = path.basename(aiPluginFilePath);
|
|
1919
|
-
const mcpServerUrl = inputs[constants_3.QuestionNames.MCPForDAServerUrl];
|
|
1920
|
-
const serverName = inputs[constants_3.QuestionNames.MCPForDAServerName];
|
|
1921
|
-
const mcpAuth = inputs[constants_3.QuestionNames.MCPForDAAuth];
|
|
1922
|
-
const authType = inputs[constants_3.QuestionNames.MCPForDAAuthType];
|
|
1923
|
-
let oauthAuthorizationUrl = undefined;
|
|
1924
|
-
let oauthTokenUrl = undefined;
|
|
1925
|
-
let oauthRefreshUrl = undefined;
|
|
1926
|
-
let registrationId = undefined;
|
|
1927
|
-
if (mcpAuth === "OAuthPluginVault") {
|
|
1928
|
-
try {
|
|
1929
|
-
registrationId = `MCP_DA_AUTH_ID_${serverName.toUpperCase()}`;
|
|
1930
|
-
if (authType === "oauth") {
|
|
1931
|
-
let wellKnownMetadataUrl = inputs[constants_3.QuestionNames.MCPForDAAuthWellKnownUrl];
|
|
1932
|
-
if (!wellKnownMetadataUrl) {
|
|
1933
|
-
const mcpAuthMetadataUrl = inputs[constants_3.QuestionNames.MCPForDAAuthMetadataUrl];
|
|
1934
|
-
if (!mcpAuthMetadataUrl) {
|
|
1935
|
-
throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpAuthMetadataUrlNotFound"));
|
|
1936
|
-
}
|
|
1937
|
-
const response = await axios_1.default.get(mcpAuthMetadataUrl);
|
|
1938
|
-
if (response.status === 200 &&
|
|
1939
|
-
response.data &&
|
|
1940
|
-
response.data.authorization_servers &&
|
|
1941
|
-
response.data.authorization_servers.length > 0) {
|
|
1942
|
-
const mcpServerMetadataUrl = (_a = response.data.authorization_servers) === null || _a === void 0 ? void 0 : _a[0];
|
|
1943
|
-
// Transform the URL to the proper OAuth authorization server metadata endpoint
|
|
1944
|
-
// According to RFC 8414, the well-known endpoint should be constructed as:
|
|
1945
|
-
// https://{domain}/.well-known/oauth-authorization-server{path}
|
|
1946
|
-
const serverUrl = new URL(mcpServerMetadataUrl);
|
|
1947
|
-
wellKnownMetadataUrl = `${serverUrl.protocol}//${serverUrl.host}/.well-known/oauth-authorization-server${serverUrl.pathname}`;
|
|
1948
|
-
}
|
|
1949
|
-
else {
|
|
1950
|
-
throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpServerMetadataUrlNotFound"));
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
const metadataResponse = await axios_1.default.get(wellKnownMetadataUrl);
|
|
1954
|
-
if (metadataResponse.status === 200) {
|
|
1955
|
-
oauthAuthorizationUrl = metadataResponse.data.authorization_endpoint;
|
|
1956
|
-
oauthTokenUrl = metadataResponse.data.token_endpoint;
|
|
1957
|
-
oauthRefreshUrl = metadataResponse.data.refresh_endpoint;
|
|
1958
|
-
}
|
|
1959
|
-
if (!oauthAuthorizationUrl || !oauthTokenUrl) {
|
|
1960
|
-
throw new Error((0, localizeUtils_1.getLocalizedString)("core.MCPForDA.authUrlNotFound"));
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
|
-
catch (error) {
|
|
1965
|
-
void context.userInteraction.showMessage("error", (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.mcpAuthMetadataMissingError", error.message), false);
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
// 2. Read ai-plugin.json
|
|
1969
|
-
const aiPluginContent = await fs_extra_1.default.readJSON(aiPluginFilePath);
|
|
1970
|
-
// For dynamic fetch tools, keep the functions empty and add runtime info
|
|
1971
|
-
// TODO: support dynamic fetch tools in the future
|
|
1972
|
-
const mcpToolsDetail = inputs[constants_3.QuestionNames.MCPForDAAvailableTools];
|
|
1973
|
-
const mcpToolsSelected = inputs[constants_3.QuestionNames.MCPForDAPreFetchTools];
|
|
1974
|
-
if (!mcpToolsDetail || !mcpToolsSelected) {
|
|
1975
|
-
const error = new teamsfx_api_1.UserError("MCPForDAPreFetchToolsNotFound", "PreFetchToolsNotFound", (0, localizeUtils_1.getDefaultString)("core.MCPForDA.preFetchToolsNotFound"), (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.preFetchToolsNotFound"));
|
|
1976
|
-
return (0, teamsfx_api_1.err)(error);
|
|
1977
|
-
}
|
|
1978
|
-
const toolsSelectedPrevious = [];
|
|
1979
|
-
aiPluginContent.runtimes
|
|
1980
|
-
.filter((runtime) => (runtime.type === "RemoteMCPServer" &&
|
|
1981
|
-
runtime.spec.url === mcpServerUrl &&
|
|
1982
|
-
runtime.spec["enable_dynamic_discovery"] === false) ||
|
|
1983
|
-
runtime.type === "LocalPlugin")
|
|
1984
|
-
.forEach((runtime) => {
|
|
1985
|
-
toolsSelectedPrevious.push(...runtime.run_for_functions);
|
|
1986
|
-
});
|
|
1987
|
-
aiPluginContent.functions = aiPluginContent.functions.filter((func) => !toolsSelectedPrevious.includes(func.name));
|
|
1988
|
-
aiPluginContent.functions = [
|
|
1989
|
-
...aiPluginContent.functions,
|
|
1990
|
-
...mcpToolsDetail
|
|
1991
|
-
.filter((tool) => mcpToolsSelected.includes(tool.name))
|
|
1992
|
-
.map((tool) => {
|
|
1993
|
-
return {
|
|
1994
|
-
name: tool.name,
|
|
1995
|
-
description: tool.description,
|
|
1996
|
-
parameters: {
|
|
1997
|
-
type: tool.inputSchema.type || "object",
|
|
1998
|
-
properties: tool.inputSchema.properties,
|
|
1999
|
-
required: tool.inputSchema.required || [],
|
|
2000
|
-
},
|
|
2001
|
-
};
|
|
2002
|
-
}),
|
|
2003
|
-
];
|
|
2004
|
-
aiPluginContent.runtimes = aiPluginContent.runtimes.filter((runtime) => (runtime.type !== "RemoteMCPServer" && runtime.type !== "LocalPlugin") ||
|
|
2005
|
-
runtime.spec.url !== mcpServerUrl ||
|
|
2006
|
-
runtime.spec["enable_dynamic_discovery"] === true);
|
|
2007
|
-
if (inputs[constants_3.QuestionNames.MCPLocalServerIdentifier] != null) {
|
|
2008
|
-
aiPluginContent.runtimes.push({
|
|
2009
|
-
type: "LocalPlugin",
|
|
2010
|
-
spec: {
|
|
2011
|
-
local_endpoint: `${constants_4.LocalMcpPrefix}${inputs[constants_3.QuestionNames.MCPLocalServerIdentifier]}`,
|
|
2012
|
-
},
|
|
2013
|
-
run_for_functions: mcpToolsSelected,
|
|
2014
|
-
});
|
|
2015
|
-
}
|
|
2016
|
-
else {
|
|
2017
|
-
aiPluginContent.runtimes.push({
|
|
2018
|
-
type: "RemoteMCPServer",
|
|
2019
|
-
spec: {
|
|
2020
|
-
url: mcpServerUrl,
|
|
2021
|
-
enable_dynamic_discovery: false,
|
|
2022
|
-
},
|
|
2023
|
-
run_for_functions: mcpToolsSelected,
|
|
2024
|
-
auth: mcpAuth === "OAuthPluginVault" && !!registrationId
|
|
2025
|
-
? {
|
|
2026
|
-
type: "OAuthPluginVault",
|
|
2027
|
-
reference_id: `$\{\{${registrationId}\}\}`,
|
|
2028
|
-
}
|
|
2029
|
-
: undefined,
|
|
2030
|
-
});
|
|
2031
|
-
}
|
|
2032
|
-
if (mcpAuth === "OAuthPluginVault" && !!registrationId) {
|
|
2033
|
-
// insert oauth info in teamsapp.yaml
|
|
2034
|
-
await actionInjector_1.ActionInjector.injectCreateOAuthActionForMCP(pathUtils_1.pathUtils.getYmlFilePath(projectPath), authType, serverName, registrationId, mcpServerUrl, oauthAuthorizationUrl, oauthTokenUrl, oauthRefreshUrl);
|
|
2035
|
-
}
|
|
2036
|
-
void context.userInteraction
|
|
2037
|
-
.showMessage("info", (0, localizeUtils_1.getLocalizedString)("core.MCPForDA.updatePluginManifest", aiPluginFilePathRelative), false, "Provision")
|
|
2038
|
-
.then((result) => {
|
|
2039
|
-
if (result.isOk() && result.value === "Provision") {
|
|
2040
|
-
void this.provisionResources(inputs);
|
|
2041
|
-
}
|
|
2042
|
-
});
|
|
2043
|
-
await fs_extra_1.default.writeJSON(aiPluginFilePath, aiPluginContent, { spaces: 4 });
|
|
2044
|
-
void ((_c = (_b = context.userInteraction).openFile) === null || _c === void 0 ? void 0 : _c.call(_b, aiPluginFilePath));
|
|
2045
|
-
return (0, teamsfx_api_1.ok)(undefined);
|
|
2046
|
-
}
|
|
2047
1860
|
/**
|
|
2048
1861
|
* dynamic template metadata download
|
|
2049
1862
|
*/
|
|
@@ -2099,6 +1912,12 @@ class FxCore {
|
|
|
2099
1912
|
return (0, teamsfx_api_1.err)(systemErr);
|
|
2100
1913
|
}
|
|
2101
1914
|
}
|
|
1915
|
+
/**
|
|
1916
|
+
* dynamic template metadata download
|
|
1917
|
+
*/
|
|
1918
|
+
async generateConfigFiles(inputs) {
|
|
1919
|
+
return await (0, generateConfigFiles_1.generateConfigFiles)(inputs);
|
|
1920
|
+
}
|
|
2102
1921
|
async updateAuthActionInYaml(authName, authScheme, projectPath, apSpecPath, pluginManifestPath, forceToAddNew = true) {
|
|
2103
1922
|
if (authName && authScheme) {
|
|
2104
1923
|
const authInjectRes = await (0, helper_2.injectAuthAction)(projectPath, authName, authScheme, apSpecPath, forceToAddNew);
|
|
@@ -2921,17 +2740,6 @@ tslib_1.__decorate([
|
|
|
2921
2740
|
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
2922
2741
|
tslib_1.__metadata("design:returntype", Promise)
|
|
2923
2742
|
], FxCore.prototype, "installAppToChannel", null);
|
|
2924
|
-
tslib_1.__decorate([
|
|
2925
|
-
(0, hooks_1.hooks)([
|
|
2926
|
-
(0, globalVars_1.ErrorContextMW)({ component: "FxCore", stage: teamsfx_api_1.Stage.installApp }),
|
|
2927
|
-
errorHandler_1.ErrorHandlerMW,
|
|
2928
|
-
(0, questionMW_1.QuestionMW)("updateActionWithMCP"),
|
|
2929
|
-
concurrentLocker_1.ConcurrentLockerMW,
|
|
2930
|
-
]),
|
|
2931
|
-
tslib_1.__metadata("design:type", Function),
|
|
2932
|
-
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
2933
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
2934
|
-
], FxCore.prototype, "updateActionWithMCP", null);
|
|
2935
2743
|
tslib_1.__decorate([
|
|
2936
2744
|
(0, hooks_1.hooks)([
|
|
2937
2745
|
(0, globalVars_1.ErrorContextMW)({ component: "FxCore", stage: "fetchOnlineTemplateMetadata" }),
|
|
@@ -2941,5 +2749,11 @@ tslib_1.__decorate([
|
|
|
2941
2749
|
tslib_1.__metadata("design:paramtypes", []),
|
|
2942
2750
|
tslib_1.__metadata("design:returntype", Promise)
|
|
2943
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);
|
|
2944
2758
|
exports.FxCore = FxCore;
|
|
2945
2759
|
//# sourceMappingURL=FxCore.js.map
|