@microsoft/teamsfx-core 3.0.15-rc.0 → 3.0.16-alpha.027c46bf2b.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/aadAppClient.d.ts.map +1 -1
- package/build/client/aadAppClient.js +6 -6
- package/build/client/aadAppClient.js.map +1 -1
- package/build/common/featureFlags.d.ts +0 -5
- package/build/common/featureFlags.d.ts.map +1 -1
- package/build/common/featureFlags.js +0 -5
- package/build/common/featureFlags.js.map +1 -1
- package/build/common/httpProxy.d.ts +21 -0
- package/build/common/httpProxy.d.ts.map +1 -0
- package/build/common/httpProxy.js +117 -0
- package/build/common/httpProxy.js.map +1 -0
- package/build/common/mcpToolFetcher.d.ts +90 -0
- package/build/common/mcpToolFetcher.d.ts.map +1 -0
- package/build/common/mcpToolFetcher.js +404 -0
- package/build/common/mcpToolFetcher.js.map +1 -0
- package/build/common/odrProvider.d.ts +43 -0
- package/build/common/odrProvider.d.ts.map +1 -0
- package/build/common/odrProvider.js +154 -0
- package/build/common/odrProvider.js.map +1 -0
- package/build/common/openApiParserOptions.d.ts +3 -0
- package/build/common/openApiParserOptions.d.ts.map +1 -0
- package/build/common/openApiParserOptions.js +61 -0
- package/build/common/openApiParserOptions.js.map +1 -0
- package/build/common/secretmasker/dict.d.ts.map +1 -1
- package/build/common/secretmasker/dict.js +5 -2
- package/build/common/secretmasker/dict.js.map +1 -1
- package/build/common/secretmasker/feature.js.map +1 -1
- package/build/common/templates-config.json +4 -4
- package/build/component/coordinator/index.d.ts.map +1 -1
- package/build/component/coordinator/index.js.map +1 -1
- package/build/component/deps-checker/internal/dotnetChecker.js.map +1 -1
- package/build/component/driver/deploy/azure/impl/AzureZipDeployImpl.d.ts +3 -0
- package/build/component/driver/deploy/azure/impl/AzureZipDeployImpl.d.ts.map +1 -1
- package/build/component/driver/deploy/azure/impl/AzureZipDeployImpl.js +38 -3
- package/build/component/driver/deploy/azure/impl/AzureZipDeployImpl.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/driver/teamsApp/create.d.ts.map +1 -1
- package/build/component/driver/teamsApp/create.js +3 -3
- package/build/component/driver/teamsApp/create.js.map +1 -1
- package/build/component/driver/teamsApp/createAppPackage.d.ts +1 -0
- package/build/component/driver/teamsApp/createAppPackage.d.ts.map +1 -1
- package/build/component/driver/teamsApp/createAppPackage.js +23 -0
- package/build/component/driver/teamsApp/createAppPackage.js.map +1 -1
- package/build/component/driver/teamsApp/utils/CopilotGptManifestUtils.js.map +1 -1
- package/build/component/generator/declarativeAgent/helper.d.ts.map +1 -1
- package/build/component/generator/declarativeAgent/helper.js +25 -2
- package/build/component/generator/declarativeAgent/helper.js.map +1 -1
- package/build/component/generator/generatorAction.d.ts +3 -1
- package/build/component/generator/generatorAction.d.ts.map +1 -1
- package/build/component/generator/generatorAction.js.map +1 -1
- package/build/component/generator/officeAddin/generator.d.ts +1 -0
- package/build/component/generator/officeAddin/generator.d.ts.map +1 -1
- package/build/component/generator/officeAddin/generator.js +109 -2
- package/build/component/generator/officeAddin/generator.js.map +1 -1
- package/build/component/generator/openApiSpec/helper.d.ts +2 -3
- package/build/component/generator/openApiSpec/helper.d.ts.map +1 -1
- package/build/component/generator/openApiSpec/helper.js +19 -57
- package/build/component/generator/openApiSpec/helper.js.map +1 -1
- package/build/component/generator/templateHelper.d.ts +10 -2
- package/build/component/generator/templateHelper.d.ts.map +1 -1
- package/build/component/generator/templateHelper.js +16 -3
- package/build/component/generator/templateHelper.js.map +1 -1
- package/build/component/generator/templates/metadata/index.d.ts +15 -0
- package/build/component/generator/templates/metadata/index.d.ts.map +1 -1
- package/build/component/generator/templates/metadata/index.js +39 -0
- package/build/component/generator/templates/metadata/index.js.map +1 -1
- package/build/component/generator/templates/templateNames.d.ts +2 -0
- package/build/component/generator/templates/templateNames.d.ts.map +1 -1
- package/build/component/generator/templates/templateNames.js +2 -0
- package/build/component/generator/templates/templateNames.js.map +1 -1
- package/build/component/generator/utils.d.ts.map +1 -1
- package/build/component/generator/utils.js +6 -0
- package/build/component/generator/utils.js.map +1 -1
- package/build/component/generator/v4TemplateBridge.d.ts +4 -1
- package/build/component/generator/v4TemplateBridge.d.ts.map +1 -1
- package/build/component/generator/v4TemplateBridge.js +19 -3
- package/build/component/generator/v4TemplateBridge.js.map +1 -1
- package/build/component/utils/envUtil.d.ts.map +1 -1
- package/build/component/utils/envUtil.js +2 -2
- package/build/component/utils/envUtil.js.map +1 -1
- package/build/component/utils/fileOperation.d.ts.map +1 -1
- package/build/component/utils/fileOperation.js +4 -1
- package/build/component/utils/fileOperation.js.map +1 -1
- package/build/component/utils/mcpAuthScaffolder.d.ts +28 -0
- package/build/component/utils/mcpAuthScaffolder.d.ts.map +1 -1
- package/build/component/utils/mcpAuthScaffolder.js +39 -4
- package/build/component/utils/mcpAuthScaffolder.js.map +1 -1
- package/build/component/utils/mcpToolFetcher.d.ts +1 -72
- package/build/component/utils/mcpToolFetcher.d.ts.map +1 -1
- package/build/component/utils/mcpToolFetcher.js +1 -227
- package/build/component/utils/mcpToolFetcher.js.map +1 -1
- package/build/component/utils/odrProvider.d.ts +1 -55
- package/build/component/utils/odrProvider.d.ts.map +1 -1
- package/build/component/utils/odrProvider.js +1 -101
- package/build/component/utils/odrProvider.js.map +1 -1
- package/build/core/FxCore.d.ts.map +1 -1
- package/build/core/FxCore.declarativeAgent.d.ts.map +1 -1
- package/build/core/FxCore.declarativeAgent.js +110 -3
- package/build/core/FxCore.declarativeAgent.js.map +1 -1
- package/build/core/FxCore.js +4 -6
- package/build/core/FxCore.js.map +1 -1
- package/build/core/createFrontDoorAdapters.d.ts +4 -27
- package/build/core/createFrontDoorAdapters.d.ts.map +1 -1
- package/build/core/createFrontDoorAdapters.js +17 -157
- package/build/core/createFrontDoorAdapters.js.map +1 -1
- package/build/core/createProjectFrontDoor.d.ts +10 -12
- package/build/core/createProjectFrontDoor.d.ts.map +1 -1
- package/build/core/createProjectFrontDoor.js +143 -106
- package/build/core/createProjectFrontDoor.js.map +1 -1
- package/build/core/modifyProjectFrontDoor.d.ts +0 -1
- package/build/core/modifyProjectFrontDoor.d.ts.map +1 -1
- package/build/core/modifyProjectFrontDoor.js +0 -2
- package/build/core/modifyProjectFrontDoor.js.map +1 -1
- package/build/index.d.ts +3 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +9 -1
- package/build/index.js.map +1 -1
- package/build/question/create.d.ts.map +1 -1
- package/build/question/create.js +2 -1
- package/build/question/create.js.map +1 -1
- package/build/question/inputs/AddKnowledgeInputs.d.ts.map +1 -1
- package/build/question/inputs/CreateProjectInputs.d.ts +4 -0
- package/build/question/inputs/CreateProjectInputs.d.ts.map +1 -1
- package/build/question/options/CreateProjectOptions.d.ts.map +1 -1
- package/build/question/options/CreateProjectOptions.js +14 -0
- package/build/question/options/CreateProjectOptions.js.map +1 -1
- package/build/question/other.d.ts.map +1 -1
- package/build/question/other.js +11 -1
- package/build/question/other.js.map +1 -1
- package/build/question/questionNames.d.ts +2 -0
- package/build/question/questionNames.d.ts.map +1 -1
- package/build/question/questionNames.js +2 -0
- package/build/question/questionNames.js.map +1 -1
- package/build/question/scaffold/constructNode.d.ts +3 -1
- package/build/question/scaffold/constructNode.d.ts.map +1 -1
- package/build/question/scaffold/constructNode.js +50 -0
- package/build/question/scaffold/constructNode.js.map +1 -1
- package/build/question/scaffold/vsc/CapabilityOptions.d.ts +2 -0
- package/build/question/scaffold/vsc/CapabilityOptions.d.ts.map +1 -1
- package/build/question/scaffold/vsc/CapabilityOptions.js +16 -0
- package/build/question/scaffold/vsc/CapabilityOptions.js.map +1 -1
- package/build/question/scaffold/vsc/teamsProjectTypeNode.d.ts +19 -1
- package/build/question/scaffold/vsc/teamsProjectTypeNode.d.ts.map +1 -1
- package/build/question/scaffold/vsc/teamsProjectTypeNode.js +39 -7
- package/build/question/scaffold/vsc/teamsProjectTypeNode.js.map +1 -1
- package/build/v4/buildTarget/parseSelector.d.ts +6 -2
- package/build/v4/buildTarget/parseSelector.d.ts.map +1 -1
- package/build/v4/buildTarget/parseSelector.js +58 -45
- package/build/v4/buildTarget/parseSelector.js.map +1 -1
- package/build/v4/buildTarget/resolveBuildTarget.d.ts +21 -7
- package/build/v4/buildTarget/resolveBuildTarget.d.ts.map +1 -1
- package/build/v4/buildTarget/resolveBuildTarget.js +97 -52
- package/build/v4/buildTarget/resolveBuildTarget.js.map +1 -1
- package/build/v4/collectInputs/collectInputs.d.ts +51 -10
- package/build/v4/collectInputs/collectInputs.d.ts.map +1 -1
- package/build/v4/collectInputs/collectInputs.js +287 -91
- package/build/v4/collectInputs/collectInputs.js.map +1 -1
- package/build/v4/distribution/createQuestions.d.ts.map +1 -1
- package/build/v4/distribution/createQuestions.js +2 -29
- package/build/v4/distribution/createQuestions.js.map +1 -1
- package/build/v4/distribution/declarativePackage.d.ts.map +1 -1
- package/build/v4/distribution/declarativePackage.js +2 -30
- package/build/v4/distribution/declarativePackage.js.map +1 -1
- package/build/v4/distribution/questionFragments.d.ts +11 -0
- package/build/v4/distribution/questionFragments.d.ts.map +1 -0
- package/build/v4/distribution/questionFragments.js +130 -0
- package/build/v4/distribution/questionFragments.js.map +1 -0
- package/build/v4/engineVersion.d.ts +7 -0
- package/build/v4/engineVersion.d.ts.map +1 -0
- package/build/v4/engineVersion.js +12 -0
- package/build/v4/engineVersion.js.map +1 -0
- package/build/v4/expression/evaluateExpression.d.ts +13 -0
- package/build/v4/expression/evaluateExpression.d.ts.map +1 -1
- package/build/v4/expression/evaluateExpression.js +57 -0
- package/build/v4/expression/evaluateExpression.js.map +1 -1
- package/build/v4/index.d.ts +7 -0
- package/build/v4/index.d.ts.map +1 -1
- package/build/v4/index.js +7 -0
- package/build/v4/index.js.map +1 -1
- package/build/v4/inspection/scaffoldCatalog.d.ts +28 -0
- package/build/v4/inspection/scaffoldCatalog.d.ts.map +1 -0
- package/build/v4/inspection/scaffoldCatalog.js +66 -0
- package/build/v4/inspection/scaffoldCatalog.js.map +1 -0
- package/build/v4/inspection/scaffoldMetadataSource.d.ts +6 -0
- package/build/v4/inspection/scaffoldMetadataSource.d.ts.map +1 -0
- package/build/v4/inspection/scaffoldMetadataSource.js +78 -0
- package/build/v4/inspection/scaffoldMetadataSource.js.map +1 -0
- package/build/v4/mcp/mcpAuthAction.d.ts +36 -0
- package/build/v4/mcp/mcpAuthAction.d.ts.map +1 -0
- package/build/v4/mcp/mcpAuthAction.js +177 -0
- package/build/v4/mcp/mcpAuthAction.js.map +1 -0
- package/build/v4/mcp/mcpAuthScaffold.d.ts +37 -0
- package/build/v4/mcp/mcpAuthScaffold.d.ts.map +1 -0
- package/build/v4/mcp/mcpAuthScaffold.js +162 -0
- package/build/v4/mcp/mcpAuthScaffold.js.map +1 -0
- package/build/v4/model/dataModel.d.ts +1 -1
- package/build/v4/model/dataModel.d.ts.map +1 -1
- package/build/v4/pipeline/runScaffoldPipeline.d.ts +27 -5
- package/build/v4/pipeline/runScaffoldPipeline.d.ts.map +1 -1
- package/build/v4/pipeline/runScaffoldPipeline.js +64 -10
- package/build/v4/pipeline/runScaffoldPipeline.js.map +1 -1
- package/build/v4/providers/createOptionsProviders.d.ts +11 -0
- package/build/v4/providers/createOptionsProviders.d.ts.map +1 -0
- package/build/v4/providers/createOptionsProviders.js +268 -0
- package/build/v4/providers/createOptionsProviders.js.map +1 -0
- package/build/v4/renderContext/buildRenderContext.d.ts.map +1 -1
- package/build/v4/renderContext/buildRenderContext.js +4 -6
- package/build/v4/renderContext/buildRenderContext.js.map +1 -1
- package/build/v4/runtime/generalSensitivityLabel.d.ts +5 -0
- package/build/v4/runtime/generalSensitivityLabel.d.ts.map +1 -0
- package/build/v4/runtime/generalSensitivityLabel.js +36 -0
- package/build/v4/runtime/generalSensitivityLabel.js.map +1 -0
- package/build/v4/runtime/inMemoryRuntime.d.ts +7 -1
- package/build/v4/runtime/inMemoryRuntime.d.ts.map +1 -1
- package/build/v4/runtime/inMemoryRuntime.js +25 -3
- package/build/v4/runtime/inMemoryRuntime.js.map +1 -1
- package/build/v4/runtime/packageParse.d.ts.map +1 -1
- package/build/v4/runtime/packageParse.js +64 -8
- package/build/v4/runtime/packageParse.js.map +1 -1
- package/build/v4/runtime/realRuntime.d.ts +3 -1
- package/build/v4/runtime/realRuntime.d.ts.map +1 -1
- package/build/v4/runtime/realRuntime.js +3 -2
- package/build/v4/runtime/realRuntime.js.map +1 -1
- package/build/v4/runtime/renderMustache.d.ts.map +1 -1
- package/build/v4/runtime/renderMustache.js +13 -4
- package/build/v4/runtime/renderMustache.js.map +1 -1
- package/build/v4/runtime/runtimeRegistry.d.ts +12 -3
- package/build/v4/runtime/runtimeRegistry.d.ts.map +1 -1
- package/build/v4/runtime/runtimeRegistry.js +123 -17
- package/build/v4/runtime/runtimeRegistry.js.map +1 -1
- package/build/v4/runtime/scaffold.d.ts +1 -0
- package/build/v4/runtime/scaffold.d.ts.map +1 -1
- package/build/v4/runtime/scaffold.js +1 -20
- package/build/v4/runtime/scaffold.js.map +1 -1
- package/build/v4/runtime/steps/daAction.d.ts.map +1 -1
- package/build/v4/runtime/steps/daAction.js +3 -111
- package/build/v4/runtime/steps/daAction.js.map +1 -1
- package/build/v4/runtime/steps/daSensitivity.d.ts +14 -0
- package/build/v4/runtime/steps/daSensitivity.d.ts.map +1 -0
- package/build/v4/runtime/steps/daSensitivity.js +50 -0
- package/build/v4/runtime/steps/daSensitivity.js.map +1 -0
- package/build/v4/runtime/steps/mcpAuth.d.ts +5 -2
- package/build/v4/runtime/steps/mcpAuth.d.ts.map +1 -1
- package/build/v4/runtime/steps/mcpAuth.js +37 -66
- package/build/v4/runtime/steps/mcpAuth.js.map +1 -1
- package/build/v4/runtime/steps/mcpLocal.d.ts +0 -4
- package/build/v4/runtime/steps/mcpLocal.d.ts.map +1 -1
- package/build/v4/runtime/steps/mcpLocal.js +11 -31
- package/build/v4/runtime/steps/mcpLocal.js.map +1 -1
- package/build/v4/runtime/steps/mcpStatic.d.ts +1 -1
- package/build/v4/runtime/steps/mcpStatic.d.ts.map +1 -1
- package/build/v4/runtime/steps/mcpStatic.js +14 -32
- package/build/v4/runtime/steps/mcpStatic.js.map +1 -1
- package/build/v4/runtime/steps/metaOs.d.ts.map +1 -1
- package/build/v4/runtime/steps/metaOs.js +39 -51
- package/build/v4/runtime/steps/metaOs.js.map +1 -1
- package/build/v4/runtime/steps/officeAddin.d.ts.map +1 -1
- package/build/v4/runtime/steps/officeAddin.js +7 -12
- package/build/v4/runtime/steps/officeAddin.js.map +1 -1
- package/build/v4/runtime/steps/openApi.d.ts.map +1 -1
- package/build/v4/runtime/steps/openApi.js +85 -566
- package/build/v4/runtime/steps/openApi.js.map +1 -1
- package/build/v4/runtime/steps/openApiCustomApi.d.ts +5 -0
- package/build/v4/runtime/steps/openApiCustomApi.d.ts.map +1 -0
- package/build/v4/runtime/steps/openApiCustomApi.js +385 -0
- package/build/v4/runtime/steps/openApiCustomApi.js.map +1 -0
- package/build/v4/runtime/whitelist.d.ts +27 -0
- package/build/v4/runtime/whitelist.d.ts.map +1 -1
- package/build/v4/runtime/whitelist.js +156 -1
- package/build/v4/runtime/whitelist.js.map +1 -1
- package/build/v4/runtime/withTempDirectory.d.ts +10 -0
- package/build/v4/runtime/withTempDirectory.d.ts.map +1 -0
- package/build/v4/runtime/withTempDirectory.js +41 -0
- package/build/v4/runtime/withTempDirectory.js.map +1 -0
- package/build/v4/surface/createFloorTail.d.ts +12 -0
- package/build/v4/surface/createFloorTail.d.ts.map +1 -0
- package/build/v4/surface/createFloorTail.js +138 -0
- package/build/v4/surface/createFloorTail.js.map +1 -0
- package/build/v4/surface/createInputs.d.ts +25 -3
- package/build/v4/surface/createInputs.d.ts.map +1 -1
- package/build/v4/surface/createInputs.js +54 -431
- package/build/v4/surface/createInputs.js.map +1 -1
- package/build/v4/surface/createSelectorWalk.d.ts +8 -3
- package/build/v4/surface/createSelectorWalk.d.ts.map +1 -1
- package/build/v4/surface/createSelectorWalk.js +21 -11
- package/build/v4/surface/createSelectorWalk.js.map +1 -1
- package/build/v4/surface/deriveCreateOptions.d.ts.map +1 -1
- package/build/v4/surface/deriveCreateOptions.js +5 -2
- package/build/v4/surface/deriveCreateOptions.js.map +1 -1
- package/build/v4/surface/localizePrompt.d.ts +11 -0
- package/build/v4/surface/localizePrompt.d.ts.map +1 -0
- package/build/v4/surface/localizePrompt.js +32 -0
- package/build/v4/surface/localizePrompt.js.map +1 -0
- package/build/v4/surface/modifySelectorWalk.d.ts.map +1 -1
- package/build/v4/surface/modifySelectorWalk.js +0 -3
- package/build/v4/surface/modifySelectorWalk.js.map +1 -1
- package/build/v4/surface/uiPromptUI.d.ts.map +1 -1
- package/build/v4/surface/uiPromptUI.js +45 -45
- package/build/v4/surface/uiPromptUI.js.map +1 -1
- package/build/v4/validation/capabilityCatalog.d.ts +8 -0
- package/build/v4/validation/capabilityCatalog.d.ts.map +1 -0
- package/build/v4/validation/capabilityCatalog.js +62 -0
- package/build/v4/validation/capabilityCatalog.js.map +1 -0
- package/build/v4/validation/templateArchiveValidation.d.ts +15 -0
- package/build/v4/validation/templateArchiveValidation.d.ts.map +1 -0
- package/build/v4/validation/templateArchiveValidation.js +297 -0
- package/build/v4/validation/templateArchiveValidation.js.map +1 -0
- package/build/v4/validation/validateTemplatePackage.d.ts +21 -2
- package/build/v4/validation/validateTemplatePackage.d.ts.map +1 -1
- package/build/v4/validation/validateTemplatePackage.js +155 -31
- package/build/v4/validation/validateTemplatePackage.js.map +1 -1
- package/build/v4/validators/createInputValidators.d.ts +7 -0
- package/build/v4/validators/createInputValidators.d.ts.map +1 -0
- package/build/v4/validators/createInputValidators.js +77 -0
- package/build/v4/validators/createInputValidators.js.map +1 -0
- package/build/v4/validators/mcpCredentialValidators.d.ts +5 -0
- package/build/v4/validators/mcpCredentialValidators.d.ts.map +1 -0
- package/build/v4/validators/mcpCredentialValidators.js +13 -0
- package/build/v4/validators/mcpCredentialValidators.js.map +1 -0
- package/build/v4/validators/mcpServerUrlValidator.d.ts +9 -0
- package/build/v4/validators/mcpServerUrlValidator.d.ts.map +1 -0
- package/build/v4/validators/mcpServerUrlValidator.js +15 -0
- package/build/v4/validators/mcpServerUrlValidator.js.map +1 -0
- package/package.json +29 -23
- package/resource/package.nls.cs.json +56 -54
- package/resource/package.nls.de.json +56 -54
- package/resource/package.nls.es.json +55 -53
- package/resource/package.nls.fr.json +56 -54
- package/resource/package.nls.it.json +55 -53
- package/resource/package.nls.ja.json +56 -54
- package/resource/package.nls.json +10 -3
- package/resource/package.nls.ko.json +56 -54
- package/resource/package.nls.pl.json +56 -54
- package/resource/package.nls.pt-BR.json +56 -54
- package/resource/package.nls.ru.json +56 -54
- package/resource/package.nls.tr.json +56 -54
- package/resource/package.nls.zh-Hans.json +56 -54
- package/resource/package.nls.zh-Hant.json +56 -54
- package/resource/templates/package.nls.cs.json +22 -9
- package/resource/templates/package.nls.de.json +22 -9
- package/resource/templates/package.nls.es.json +22 -9
- package/resource/templates/package.nls.fr.json +22 -9
- package/resource/templates/package.nls.it.json +22 -9
- package/resource/templates/package.nls.ja.json +22 -9
- package/resource/templates/package.nls.json +16 -3
- package/resource/templates/package.nls.ko.json +22 -9
- package/resource/templates/package.nls.pl.json +22 -9
- package/resource/templates/package.nls.pt-BR.json +22 -9
- package/resource/templates/package.nls.ru.json +22 -9
- package/resource/templates/package.nls.tr.json +22 -9
- package/resource/templates/package.nls.zh-Hans.json +22 -9
- package/resource/templates/package.nls.zh-Hant.json +22 -9
- package/resource/templates/package.nls.zh-cn.json +7 -1
- package/resource/templates/package.nls.zh-tw.json +7 -1
- 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/allTemplates.json +16 -2
- package/templates/metadata.zip +0 -0
- package/templates/ui/wizardNode.json +24 -0
- package/templates/v4/create-selector.json +30 -5
- package/templates/v4/floor.json +1 -1
- package/templates/v4/modify-selector.json +1 -6
- package/templates/v4/templates-metadata.zip +0 -0
- package/templates/v4/templates.zip +0 -0
- package/templates/configs/local/typescript/.gitignore +0 -1
- package/templates/configs/playground/typescript/.gitignore +0 -4
|
@@ -8,12 +8,17 @@ const m365_spec_parser_1 = require("@microsoft/m365-spec-parser");
|
|
|
8
8
|
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
|
|
9
9
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
10
10
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
11
|
-
const os = tslib_1.__importStar(require("os"));
|
|
12
11
|
const path = tslib_1.__importStar(require("path"));
|
|
13
12
|
const neverthrow_1 = require("neverthrow");
|
|
13
|
+
const constants_1 = require("../../../common/constants");
|
|
14
|
+
const daSpecParser_1 = require("../../../common/daSpecParser");
|
|
15
|
+
const localizeUtils_1 = require("../../../common/localizeUtils");
|
|
16
|
+
const openApiParserOptions_1 = require("../../../common/openApiParserOptions");
|
|
14
17
|
const stringUtils_1 = require("../../../common/stringUtils");
|
|
15
18
|
const utils_1 = require("../../../common/utils");
|
|
16
|
-
const
|
|
19
|
+
const constants_2 = require("../../../question/constants");
|
|
20
|
+
const withTempDirectory_1 = require("../withTempDirectory");
|
|
21
|
+
const openApiCustomApi_1 = require("./openApiCustomApi");
|
|
17
22
|
/** Generate API plugin files through spec-parser, then copy artifacts back via `ctx.write`. */
|
|
18
23
|
const SOURCE = "Scaffold";
|
|
19
24
|
exports.STEP_GENERATE_OPENAPI_PLUGIN_FILES = "openapi/generate-plugin-files";
|
|
@@ -24,19 +29,10 @@ const PLUGIN_PATH = `${teamsfx_api_1.AppPackageFolderName}/${teamsfx_api_1.Defau
|
|
|
24
29
|
const API_SPEC_PATH = `${teamsfx_api_1.AppPackageFolderName}/${teamsfx_api_1.DefaultApiSpecFolderName}/${teamsfx_api_1.DefaultApiSpecYamlFileName}`;
|
|
25
30
|
const ORIGINAL_API_SPEC_PATH = `${API_SPEC_PATH}.original`;
|
|
26
31
|
const DEFAULT_ACTION_ID = "action_1";
|
|
32
|
+
/** Mirrors `invalidApiSpecErrorName` in the legacy openApiSpec helper, which v4 must not import. */
|
|
33
|
+
const INVALID_API_SPEC_ERROR_NAME = "invalid-api-spec";
|
|
27
34
|
const M365_AGENTS_YML = "m365agents.yml";
|
|
28
35
|
const M365_AGENTS_LOCAL_YML = "m365agents.local.yml";
|
|
29
|
-
const TEAMS_AI_OPERATION_METHODS = [
|
|
30
|
-
"get",
|
|
31
|
-
"post",
|
|
32
|
-
"put",
|
|
33
|
-
"delete",
|
|
34
|
-
"patch",
|
|
35
|
-
"head",
|
|
36
|
-
"connect",
|
|
37
|
-
"options",
|
|
38
|
-
"trace",
|
|
39
|
-
];
|
|
40
36
|
function systemError(name, message) {
|
|
41
37
|
return new teamsfx_api_1.SystemError({ source: SOURCE, name, message });
|
|
42
38
|
}
|
|
@@ -51,9 +47,6 @@ function stringArrayParam(params, key) {
|
|
|
51
47
|
}
|
|
52
48
|
return value;
|
|
53
49
|
}
|
|
54
|
-
function isRecord(value) {
|
|
55
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
56
|
-
}
|
|
57
50
|
function readRequired(ctx, filePath) {
|
|
58
51
|
const current = ctx.read(filePath);
|
|
59
52
|
if (current === undefined) {
|
|
@@ -64,107 +57,6 @@ function readRequired(ctx, filePath) {
|
|
|
64
57
|
function errorMessage(error) {
|
|
65
58
|
return error instanceof Error ? error.message : String(error);
|
|
66
59
|
}
|
|
67
|
-
function parseJsonObject(json, filePath, errorName) {
|
|
68
|
-
let parsed;
|
|
69
|
-
try {
|
|
70
|
-
parsed = JSON.parse(json);
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
return (0, neverthrow_1.err)(systemError(`${errorName}Parse`, `Cannot parse '${filePath}' as JSON: ${errorMessage(error)}`));
|
|
74
|
-
}
|
|
75
|
-
if (!isRecord(parsed)) {
|
|
76
|
-
return (0, neverthrow_1.err)(systemError(`${errorName}Shape`, `'${filePath}' is not a JSON object`));
|
|
77
|
-
}
|
|
78
|
-
return (0, neverthrow_1.ok)(parsed);
|
|
79
|
-
}
|
|
80
|
-
function isConversationStarter(value) {
|
|
81
|
-
return isRecord(value) && typeof value.text === "string";
|
|
82
|
-
}
|
|
83
|
-
function conversationStartersFromUnknown(value) {
|
|
84
|
-
if (!Array.isArray(value)) {
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
return value.filter(isConversationStarter).map((starter) => ({ text: starter.text }));
|
|
88
|
-
}
|
|
89
|
-
function pluginConversationStarters(plugin) {
|
|
90
|
-
const capabilities = plugin.capabilities;
|
|
91
|
-
if (!isRecord(capabilities)) {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
return conversationStartersFromUnknown(capabilities.conversation_starters);
|
|
95
|
-
}
|
|
96
|
-
function pluginOperationIds(plugin) {
|
|
97
|
-
const operationIds = new Set();
|
|
98
|
-
if (!Array.isArray(plugin.functions)) {
|
|
99
|
-
return operationIds;
|
|
100
|
-
}
|
|
101
|
-
for (const func of plugin.functions) {
|
|
102
|
-
if (!isRecord(func) || typeof func.name !== "string") {
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
operationIds.add(func.name);
|
|
106
|
-
}
|
|
107
|
-
return operationIds;
|
|
108
|
-
}
|
|
109
|
-
async function specConversationStarters(apiSpecPath, operationIds) {
|
|
110
|
-
if (operationIds.size === 0) {
|
|
111
|
-
return [];
|
|
112
|
-
}
|
|
113
|
-
const parser = new m365_spec_parser_1.SpecParser(apiSpecPath, openApiParseOptions());
|
|
114
|
-
const listed = await parser.list();
|
|
115
|
-
const starters = [];
|
|
116
|
-
for (const operation of listed.APIs) {
|
|
117
|
-
if (!operation.isValid || !operation.operationId || !operationIds.has(operation.operationId)) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
const text = operation.summary || operation.description;
|
|
121
|
-
if (text) {
|
|
122
|
-
starters.push({ text });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return starters;
|
|
126
|
-
}
|
|
127
|
-
function appendConversationStarters(agent, starters) {
|
|
128
|
-
if (starters.length === 0) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const nextStarters = Array.isArray(agent.conversation_starters)
|
|
132
|
-
? [...agent.conversation_starters]
|
|
133
|
-
: [];
|
|
134
|
-
for (const starter of starters) {
|
|
135
|
-
if (nextStarters.length >= 6) {
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
const alreadyExists = nextStarters.some((existingStarter) => isConversationStarter(existingStarter) && existingStarter.text === starter.text);
|
|
139
|
-
if (!alreadyExists) {
|
|
140
|
-
nextStarters.push(starter);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
agent.conversation_starters = nextStarters;
|
|
144
|
-
}
|
|
145
|
-
async function addActionAndConversationStarters(agentJson, pluginJson, apiSpecPath) {
|
|
146
|
-
const agent = parseJsonObject(agentJson, AGENT_PATH, "OpenApiDeclarativeAgent");
|
|
147
|
-
if (agent.isErr()) {
|
|
148
|
-
return (0, neverthrow_1.err)(agent.error);
|
|
149
|
-
}
|
|
150
|
-
const plugin = parseJsonObject(pluginJson, PLUGIN_PATH, "OpenApiPluginManifest");
|
|
151
|
-
if (plugin.isErr()) {
|
|
152
|
-
return (0, neverthrow_1.err)(plugin.error);
|
|
153
|
-
}
|
|
154
|
-
const actions = agent.value.actions;
|
|
155
|
-
if (actions !== undefined && !Array.isArray(actions)) {
|
|
156
|
-
return (0, neverthrow_1.err)(systemError("OpenApiDeclarativeAgentActions", `'${AGENT_PATH}' actions is not an array`));
|
|
157
|
-
}
|
|
158
|
-
const nextActions = Array.isArray(actions) ? [...actions] : [];
|
|
159
|
-
nextActions.push({ id: DEFAULT_ACTION_ID, file: teamsfx_api_1.DefaultPluginManifestFileName });
|
|
160
|
-
agent.value.actions = nextActions;
|
|
161
|
-
let starters = pluginConversationStarters(plugin.value);
|
|
162
|
-
if (starters.length === 0) {
|
|
163
|
-
starters = await specConversationStarters(apiSpecPath, pluginOperationIds(plugin.value));
|
|
164
|
-
}
|
|
165
|
-
appendConversationStarters(agent.value, starters);
|
|
166
|
-
return (0, neverthrow_1.ok)(JSON.stringify(agent.value, null, 4) + "\n");
|
|
167
|
-
}
|
|
168
60
|
function registrationIdEnvName(authName) {
|
|
169
61
|
return m365_spec_parser_1.Utils.getSafeRegistrationIdEnvName(`${authName}_${m365_spec_parser_1.ConstantString.RegistrationIdPostfix}`);
|
|
170
62
|
}
|
|
@@ -181,14 +73,11 @@ function authType(operation) {
|
|
|
181
73
|
}
|
|
182
74
|
return undefined;
|
|
183
75
|
}
|
|
184
|
-
|
|
185
|
-
const parser = new m365_spec_parser_1.SpecParser(apiSpecLocation, openApiParseOptions());
|
|
186
|
-
const listed = await parser.list();
|
|
187
|
-
const selected = listed.APIs.filter((operation) => apiOperations.includes(operation.api));
|
|
76
|
+
function selectedAuthRegistrations(selectedOperations) {
|
|
188
77
|
const serverUrls = new Set();
|
|
189
78
|
const authNames = new Set();
|
|
190
79
|
const registrations = [];
|
|
191
|
-
for (const operation of
|
|
80
|
+
for (const operation of selectedOperations) {
|
|
192
81
|
const type = authType(operation);
|
|
193
82
|
const authName = operation.auth?.name;
|
|
194
83
|
if (type === undefined || !authName) {
|
|
@@ -216,6 +105,10 @@ async function selectedAuthRegistrations(apiSpecLocation, apiOperations) {
|
|
|
216
105
|
}
|
|
217
106
|
return (0, neverthrow_1.ok)(registrations);
|
|
218
107
|
}
|
|
108
|
+
function conversationStarterText(operation) {
|
|
109
|
+
const text = operation.summary?.trim() || operation.description?.trim();
|
|
110
|
+
return text || undefined;
|
|
111
|
+
}
|
|
219
112
|
function authActionBlock(registration) {
|
|
220
113
|
if (registration.authType === "apiKey") {
|
|
221
114
|
return [
|
|
@@ -272,431 +165,34 @@ function updateAuthYml(ctx, filePath, registrations) {
|
|
|
272
165
|
ctx.write(filePath, Buffer.from(updated, "utf8"));
|
|
273
166
|
}
|
|
274
167
|
function openApiParseOptions() {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
allowAPIKeyAuth: true,
|
|
278
|
-
allowBearerTokenAuth: true,
|
|
279
|
-
allowMultipleParameters: true,
|
|
280
|
-
allowOauth2: true,
|
|
281
|
-
projectType: m365_spec_parser_1.ProjectType.Copilot,
|
|
282
|
-
allowMissingId: true,
|
|
283
|
-
allowSwagger: true,
|
|
284
|
-
allowMethods: ["get", "post", "put", "delete", "patch", "head", "connect", "options", "trace"],
|
|
285
|
-
allowResponseSemantics: true,
|
|
286
|
-
allowConversationStarters: false,
|
|
287
|
-
allowConfirmation: false,
|
|
288
|
-
};
|
|
168
|
+
// Reuse the v3 Copilot parser options (single source of truth) instead of a v4 copy.
|
|
169
|
+
return (0, openApiParserOptions_1.getParserOptions)(m365_spec_parser_1.ProjectType.Copilot, true);
|
|
289
170
|
}
|
|
290
171
|
function teamsAiParseOptions() {
|
|
291
|
-
return
|
|
292
|
-
allowAPIKeyAuth: true,
|
|
293
|
-
allowBearerTokenAuth: true,
|
|
294
|
-
allowMultipleParameters: true,
|
|
295
|
-
allowOauth2: true,
|
|
296
|
-
projectType: m365_spec_parser_1.ProjectType.TeamsAi,
|
|
297
|
-
allowMethods: ["get", "post", "put", "delete", "patch", "head", "connect", "options", "trace"],
|
|
298
|
-
};
|
|
172
|
+
return (0, openApiParserOptions_1.getParserOptions)(m365_spec_parser_1.ProjectType.TeamsAi);
|
|
299
173
|
}
|
|
300
174
|
function languageParam(params) {
|
|
301
175
|
const language = stringParam(params, "language");
|
|
302
176
|
switch (language) {
|
|
303
|
-
case
|
|
304
|
-
return
|
|
305
|
-
case
|
|
306
|
-
return
|
|
307
|
-
case
|
|
308
|
-
return
|
|
177
|
+
case constants_2.ProgrammingLanguage.TS:
|
|
178
|
+
return constants_2.ProgrammingLanguage.TS;
|
|
179
|
+
case constants_2.ProgrammingLanguage.JS:
|
|
180
|
+
return constants_2.ProgrammingLanguage.JS;
|
|
181
|
+
case constants_2.ProgrammingLanguage.PY:
|
|
182
|
+
return constants_2.ProgrammingLanguage.PY;
|
|
309
183
|
default:
|
|
310
184
|
return undefined;
|
|
311
185
|
}
|
|
312
186
|
}
|
|
313
187
|
function teamsAiLanguageFiles(language) {
|
|
314
|
-
if (language ===
|
|
188
|
+
if (language === constants_2.ProgrammingLanguage.TS) {
|
|
315
189
|
return { appPath: "src/app/app.ts", handlerPath: "src/app/handlers.ts" };
|
|
316
190
|
}
|
|
317
|
-
if (language ===
|
|
191
|
+
if (language === constants_2.ProgrammingLanguage.JS) {
|
|
318
192
|
return { appPath: "src/app/app.js", handlerPath: "src/app/handlers.js" };
|
|
319
193
|
}
|
|
320
194
|
return { appPath: "src/app.py", handlerPath: "src/handlers.py" };
|
|
321
195
|
}
|
|
322
|
-
function recordProperty(record, key) {
|
|
323
|
-
const value = record[key];
|
|
324
|
-
return isRecord(value) ? value : undefined;
|
|
325
|
-
}
|
|
326
|
-
function stringProperty(record, key) {
|
|
327
|
-
const value = record[key];
|
|
328
|
-
return typeof value === "string" ? value : undefined;
|
|
329
|
-
}
|
|
330
|
-
function stringArrayProperty(record, key) {
|
|
331
|
-
const value = record[key];
|
|
332
|
-
if (!Array.isArray(value) || !value.every((item) => typeof item === "string")) {
|
|
333
|
-
return undefined;
|
|
334
|
-
}
|
|
335
|
-
return value;
|
|
336
|
-
}
|
|
337
|
-
function teamsAiOperationDescription(operation, method, pathUrl) {
|
|
338
|
-
return (stringProperty(operation, "description") ??
|
|
339
|
-
stringProperty(operation, "summary") ??
|
|
340
|
-
`${method.toUpperCase()} ${pathUrl}`);
|
|
341
|
-
}
|
|
342
|
-
function teamsAiOperationPrompt(operation, method, pathUrl) {
|
|
343
|
-
return (stringProperty(operation, "summary") ??
|
|
344
|
-
stringProperty(operation, "description") ??
|
|
345
|
-
`${method.toUpperCase()} ${pathUrl}`);
|
|
346
|
-
}
|
|
347
|
-
function filterJsonSchema(schema) {
|
|
348
|
-
if (!isRecord(schema)) {
|
|
349
|
-
return { type: "object" };
|
|
350
|
-
}
|
|
351
|
-
const filtered = {};
|
|
352
|
-
const type = stringProperty(schema, "type");
|
|
353
|
-
if (type !== undefined) {
|
|
354
|
-
filtered.type = type;
|
|
355
|
-
}
|
|
356
|
-
const description = stringProperty(schema, "description");
|
|
357
|
-
if (description !== undefined) {
|
|
358
|
-
filtered.description = description;
|
|
359
|
-
}
|
|
360
|
-
const required = stringArrayProperty(schema, "required");
|
|
361
|
-
if (required !== undefined) {
|
|
362
|
-
filtered.required = required;
|
|
363
|
-
}
|
|
364
|
-
const properties = recordProperty(schema, "properties");
|
|
365
|
-
if (properties !== undefined) {
|
|
366
|
-
const filteredProperties = {};
|
|
367
|
-
for (const [propertyName, propertySchema] of Object.entries(properties)) {
|
|
368
|
-
filteredProperties[propertyName] = filterJsonSchema(propertySchema);
|
|
369
|
-
}
|
|
370
|
-
filtered.properties = filteredProperties;
|
|
371
|
-
}
|
|
372
|
-
if (schema.items !== undefined) {
|
|
373
|
-
filtered.items = filterJsonSchema(schema.items);
|
|
374
|
-
}
|
|
375
|
-
return Object.keys(filtered).length === 0 ? { type: "object" } : filtered;
|
|
376
|
-
}
|
|
377
|
-
function ensureObjectSection(sections, sectionName) {
|
|
378
|
-
const existing = recordProperty(sections, sectionName);
|
|
379
|
-
if (existing !== undefined) {
|
|
380
|
-
return existing;
|
|
381
|
-
}
|
|
382
|
-
const section = { type: "object", properties: {}, required: [] };
|
|
383
|
-
sections[sectionName] = section;
|
|
384
|
-
return section;
|
|
385
|
-
}
|
|
386
|
-
function addRequiredValue(record, key, value) {
|
|
387
|
-
const required = stringArrayProperty(record, key) ?? [];
|
|
388
|
-
if (!required.includes(value)) {
|
|
389
|
-
required.push(value);
|
|
390
|
-
}
|
|
391
|
-
record[key] = required;
|
|
392
|
-
}
|
|
393
|
-
function teamsAiParametersSchema(operation) {
|
|
394
|
-
const parameterProperties = {};
|
|
395
|
-
const parameters = operation.parameters;
|
|
396
|
-
if (Array.isArray(parameters)) {
|
|
397
|
-
for (const parameter of parameters) {
|
|
398
|
-
if (!isRecord(parameter)) {
|
|
399
|
-
continue;
|
|
400
|
-
}
|
|
401
|
-
const name = stringProperty(parameter, "name");
|
|
402
|
-
const location = stringProperty(parameter, "in");
|
|
403
|
-
if (name === undefined || location === undefined) {
|
|
404
|
-
continue;
|
|
405
|
-
}
|
|
406
|
-
const section = ensureObjectSection(parameterProperties, location);
|
|
407
|
-
const sectionProperties = recordProperty(section, "properties") ?? {};
|
|
408
|
-
const schema = filterJsonSchema(parameter.schema);
|
|
409
|
-
const description = stringProperty(parameter, "description");
|
|
410
|
-
if (description !== undefined) {
|
|
411
|
-
schema.description = description;
|
|
412
|
-
}
|
|
413
|
-
sectionProperties[name] = schema;
|
|
414
|
-
section.properties = sectionProperties;
|
|
415
|
-
if (parameter.required === true) {
|
|
416
|
-
addRequiredValue(section, "required", name);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
const requestBody = recordProperty(operation, "requestBody");
|
|
421
|
-
const content = requestBody === undefined ? undefined : recordProperty(requestBody, "content");
|
|
422
|
-
const jsonMedia = content === undefined ? undefined : recordProperty(content, "application/json");
|
|
423
|
-
if (jsonMedia?.schema !== undefined) {
|
|
424
|
-
const bodySchema = filterJsonSchema(jsonMedia.schema);
|
|
425
|
-
const description = requestBody === undefined ? undefined : stringProperty(requestBody, "description");
|
|
426
|
-
if (description !== undefined) {
|
|
427
|
-
bodySchema.description = description;
|
|
428
|
-
}
|
|
429
|
-
parameterProperties.body = bodySchema;
|
|
430
|
-
}
|
|
431
|
-
const root = {
|
|
432
|
-
type: "object",
|
|
433
|
-
properties: parameterProperties,
|
|
434
|
-
required: [],
|
|
435
|
-
};
|
|
436
|
-
for (const [sectionName, section] of Object.entries(parameterProperties)) {
|
|
437
|
-
if (isRecord(section) && stringArrayProperty(section, "required")?.length) {
|
|
438
|
-
addRequiredValue(root, "required", sectionName);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
if (requestBody?.required === true) {
|
|
442
|
-
addRequiredValue(root, "required", "body");
|
|
443
|
-
}
|
|
444
|
-
return root;
|
|
445
|
-
}
|
|
446
|
-
function teamsAiSpecOperations(spec) {
|
|
447
|
-
if (!isRecord(spec) || !isRecord(spec.paths)) {
|
|
448
|
-
return [];
|
|
449
|
-
}
|
|
450
|
-
const operations = [];
|
|
451
|
-
for (const [pathUrl, pathItem] of Object.entries(spec.paths)) {
|
|
452
|
-
if (!isRecord(pathItem)) {
|
|
453
|
-
continue;
|
|
454
|
-
}
|
|
455
|
-
for (const method of TEAMS_AI_OPERATION_METHODS) {
|
|
456
|
-
const operation = pathItem[method];
|
|
457
|
-
if (!isRecord(operation)) {
|
|
458
|
-
continue;
|
|
459
|
-
}
|
|
460
|
-
const operationId = stringProperty(operation, "operationId");
|
|
461
|
-
if (operationId === undefined) {
|
|
462
|
-
continue;
|
|
463
|
-
}
|
|
464
|
-
operations.push({
|
|
465
|
-
pathUrl,
|
|
466
|
-
method,
|
|
467
|
-
operationId,
|
|
468
|
-
description: teamsAiOperationDescription(operation, method, pathUrl),
|
|
469
|
-
prompt: teamsAiOperationPrompt(operation, method, pathUrl),
|
|
470
|
-
parametersSchema: teamsAiParametersSchema(operation),
|
|
471
|
-
auth: Array.isArray(operation.security) && operation.security.length > 0,
|
|
472
|
-
source: operation,
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
return operations;
|
|
477
|
-
}
|
|
478
|
-
function safeFileStem(value) {
|
|
479
|
-
return value.replace(/[^a-zA-Z0-9]/g, "_");
|
|
480
|
-
}
|
|
481
|
-
function teamsAiPromptText(spec) {
|
|
482
|
-
const description = isRecord(spec) ? recordProperty(spec, "info")?.description : undefined;
|
|
483
|
-
return `The following is a conversation with an AI assistant.\nThe assistant can help to call APIs for the open api spec file${typeof description === "string" ? ". " + description : "."}\nIf the API doesn't require parameters, invoke it with default JSON object { "path": null, "body": null, "query": null }.\n\n`;
|
|
484
|
-
}
|
|
485
|
-
function teamsAiFunctionDefinitionCode(operationId) {
|
|
486
|
-
return `.function(
|
|
487
|
-
functionDefs.${operationId}.name,
|
|
488
|
-
functionDefs.${operationId}.description,
|
|
489
|
-
functionDefs.${operationId}.parameters,
|
|
490
|
-
async (parameter) => {
|
|
491
|
-
const result = await functionHandlers.${operationId}Handler(parameter);
|
|
492
|
-
if(result) {
|
|
493
|
-
await send(result);
|
|
494
|
-
return "result showed";
|
|
495
|
-
} else {
|
|
496
|
-
return "no result";
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
)`;
|
|
500
|
-
}
|
|
501
|
-
function teamsAiFunctionHandlerCode(operation, language) {
|
|
502
|
-
const exportPrefix = language === constants_1.ProgrammingLanguage.TS ? "export " : "";
|
|
503
|
-
const parameterName = language === constants_1.ProgrammingLanguage.TS ? "parameter: any" : "parameters";
|
|
504
|
-
const parameterVariable = language === constants_1.ProgrammingLanguage.TS ? "parameter" : "parameters";
|
|
505
|
-
const authConfig = operation.auth ? "addAuthConfig(client);" : "";
|
|
506
|
-
const exportSuffix = language === constants_1.ProgrammingLanguage.JS
|
|
507
|
-
? `\nmodule.exports = { ${operation.operationId}Handler };`
|
|
508
|
-
: "";
|
|
509
|
-
return `${exportPrefix}const ${operation.operationId}Handler = async (
|
|
510
|
-
${parameterName}
|
|
511
|
-
) => {
|
|
512
|
-
const client = await api.getClient();
|
|
513
|
-
${authConfig}
|
|
514
|
-
const apiPath = client.paths["${operation.pathUrl}"];
|
|
515
|
-
if (apiPath && apiPath.${operation.method}) {
|
|
516
|
-
const result = await apiPath.${operation.method}(${parameterVariable}.path, ${parameterVariable}.body, {
|
|
517
|
-
params: ${parameterVariable}.query,
|
|
518
|
-
});
|
|
519
|
-
if (!result || !result.data) {
|
|
520
|
-
throw new Error("Get empty result from api call.");
|
|
521
|
-
}
|
|
522
|
-
const cardName = "${operation.operationId}".replace(/[^a-zA-Z0-9]/g, "_");
|
|
523
|
-
const cardTemplatePath = path.join(__dirname, "../adaptiveCards", cardName + ".json");
|
|
524
|
-
if (await fs.exists(cardTemplatePath)){
|
|
525
|
-
const card = generateAdaptiveCard(cardTemplatePath, result);
|
|
526
|
-
return card;
|
|
527
|
-
} else {
|
|
528
|
-
return JSON.stringify(result.data);
|
|
529
|
-
}
|
|
530
|
-
} else {
|
|
531
|
-
return "";
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
};${exportSuffix}`;
|
|
535
|
-
}
|
|
536
|
-
function pythonTeamsAiFunctionDefinitionCode(operationId) {
|
|
537
|
-
return `.with_function(
|
|
538
|
-
Function(
|
|
539
|
-
name=function_defs["${operationId}"]["name"],
|
|
540
|
-
description=function_defs["${operationId}"]["description"],
|
|
541
|
-
parameter_schema=function_defs["${operationId}"]["parameters"],
|
|
542
|
-
handler=make_handler(${operationId}, ctx)
|
|
543
|
-
)
|
|
544
|
-
)`;
|
|
545
|
-
}
|
|
546
|
-
function pythonTeamsAiFunctionHandlerCode(operation) {
|
|
547
|
-
return `async def ${operation.operationId}(
|
|
548
|
-
parameters,
|
|
549
|
-
):
|
|
550
|
-
path = getattr(parameters, "path", {})
|
|
551
|
-
body = getattr(parameters, "body", None)
|
|
552
|
-
query = getattr(parameters, "query", {}) or {}
|
|
553
|
-
resp = client.${operation.operationId}(**path, json=body, _headers={}, _params=query, _cookies={})
|
|
554
|
-
|
|
555
|
-
if resp.status_code != 200:
|
|
556
|
-
return resp.reason
|
|
557
|
-
else:
|
|
558
|
-
card_template_path = os.path.join(current_dir, 'adaptiveCards/${operation.operationId}.json')
|
|
559
|
-
if not os.path.exists(card_template_path):
|
|
560
|
-
json_resoponse_str = resp.text
|
|
561
|
-
return json_resoponse_str
|
|
562
|
-
else:
|
|
563
|
-
with open(card_template_path) as card_template_file:
|
|
564
|
-
adaptive_card_template = card_template_file.read()
|
|
565
|
-
|
|
566
|
-
renderer = AdaptiveCardRenderer(adaptive_card_template)
|
|
567
|
-
|
|
568
|
-
json_resoponse_str = resp.text
|
|
569
|
-
rendered_card_str = renderer.render(json_resoponse_str)
|
|
570
|
-
rendered_card_json = json.loads(rendered_card_str)
|
|
571
|
-
return AdaptiveCard.model_validate(rendered_card_json)
|
|
572
|
-
`;
|
|
573
|
-
}
|
|
574
|
-
function teamsAiAdaptiveCard(operation) {
|
|
575
|
-
return {
|
|
576
|
-
type: "AdaptiveCard",
|
|
577
|
-
version: "1.5",
|
|
578
|
-
body: [
|
|
579
|
-
{ type: "TextBlock", text: operation.description, wrap: true },
|
|
580
|
-
{ type: "TextBlock", text: "${JSON.stringify($root)}", wrap: true },
|
|
581
|
-
],
|
|
582
|
-
};
|
|
583
|
-
}
|
|
584
|
-
function teamsAiAdaptiveCardWithMockData(operation) {
|
|
585
|
-
try {
|
|
586
|
-
const [card, jsonPath, jsonData] = m365_spec_parser_1.AdaptiveCardGenerator.generateAdaptiveCard(operation.source, true, 5);
|
|
587
|
-
const body = isRecord(card) ? card.body : undefined;
|
|
588
|
-
if (jsonPath !== "$" && Array.isArray(body) && isRecord(body[0])) {
|
|
589
|
-
body[0].$data = `\${${jsonPath}}`;
|
|
590
|
-
}
|
|
591
|
-
return { card, data: jsonData };
|
|
592
|
-
}
|
|
593
|
-
catch {
|
|
594
|
-
return { card: teamsAiAdaptiveCard(operation), data: {} };
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
async function updatePromptSuggestions(destinationPath, operations) {
|
|
598
|
-
const manifestPath = path.join(destinationPath, teamsfx_api_1.AppPackageFolderName, teamsfx_api_1.ManifestTemplateFileName);
|
|
599
|
-
let manifest;
|
|
600
|
-
try {
|
|
601
|
-
const parsed = parseJsonObject(await fs.readFile(manifestPath, "utf8"), MANIFEST_PATH, "TeamsAiManifest");
|
|
602
|
-
if (parsed.isErr()) {
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
manifest = parsed.value;
|
|
606
|
-
}
|
|
607
|
-
catch {
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
const bots = manifest.bots;
|
|
611
|
-
if (!Array.isArray(bots) || !isRecord(bots[0])) {
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
bots[0].commandLists = [
|
|
615
|
-
{
|
|
616
|
-
scopes: ["personal"],
|
|
617
|
-
commands: operations.slice(0, 10).map((operation) => ({
|
|
618
|
-
title: operation.prompt.slice(0, 32),
|
|
619
|
-
description: operation.prompt.slice(0, 128),
|
|
620
|
-
})),
|
|
621
|
-
},
|
|
622
|
-
];
|
|
623
|
-
await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 4) + "\n");
|
|
624
|
-
}
|
|
625
|
-
async function updateTypescriptJavascriptTeamsAiCustomApi(spec, language, destinationPath, openapiSpecFileName) {
|
|
626
|
-
const operations = teamsAiSpecOperations(spec);
|
|
627
|
-
if (operations.length === 0) {
|
|
628
|
-
return (0, neverthrow_1.err)(systemError("OpenApiTeamsAiOperationsMissing", "Failed to find generated OpenAPI operations for the Teams AI custom API template."));
|
|
629
|
-
}
|
|
630
|
-
const appFolder = path.join(destinationPath, "src", "app");
|
|
631
|
-
const adaptiveCardsFolder = path.join(destinationPath, "src", "adaptiveCards");
|
|
632
|
-
await fs.ensureDir(appFolder);
|
|
633
|
-
await fs.ensureDir(adaptiveCardsFolder);
|
|
634
|
-
await fs.writeFile(path.join(appFolder, "instructions.txt"), teamsAiPromptText(spec));
|
|
635
|
-
const actions = {};
|
|
636
|
-
for (const operation of operations) {
|
|
637
|
-
actions[operation.operationId] = {
|
|
638
|
-
name: operation.operationId,
|
|
639
|
-
description: operation.description,
|
|
640
|
-
parameters: operation.parametersSchema,
|
|
641
|
-
};
|
|
642
|
-
const cardName = safeFileStem(operation.operationId);
|
|
643
|
-
const adaptiveCard = teamsAiAdaptiveCardWithMockData(operation);
|
|
644
|
-
await fs.writeFile(path.join(adaptiveCardsFolder, `${cardName}.json`), JSON.stringify(adaptiveCard.card, null, 2));
|
|
645
|
-
await fs.writeFile(path.join(adaptiveCardsFolder, `${cardName}.data.json`), JSON.stringify(adaptiveCard.data, null, 2));
|
|
646
|
-
}
|
|
647
|
-
await fs.writeFile(path.join(appFolder, "functions.json"), JSON.stringify(actions, null, 2));
|
|
648
|
-
const appFilePath = path.join(appFolder, language === constants_1.ProgrammingLanguage.JS ? "app.js" : "app.ts");
|
|
649
|
-
const handlerFilePath = path.join(appFolder, language === constants_1.ProgrammingLanguage.JS ? "handlers.js" : "handlers.ts");
|
|
650
|
-
const appFileContent = await fs.readFile(appFilePath, "utf8");
|
|
651
|
-
await fs.writeFile(appFilePath, appFileContent.replace("// Replace with function definition code", `${operations.map((operation) => teamsAiFunctionDefinitionCode(operation.operationId)).join("\n")};`));
|
|
652
|
-
const handlerFileContent = await fs.readFile(handlerFilePath, "utf8");
|
|
653
|
-
await fs.writeFile(handlerFilePath, handlerFileContent
|
|
654
|
-
.replace("{{OPENAPI_SPEC_PATH}}", openapiSpecFileName)
|
|
655
|
-
.replace("// Replace with function handler code", operations.map((operation) => teamsAiFunctionHandlerCode(operation, language)).join("\n\n")));
|
|
656
|
-
await updatePromptSuggestions(destinationPath, operations);
|
|
657
|
-
return (0, neverthrow_1.ok)(undefined);
|
|
658
|
-
}
|
|
659
|
-
async function updatePythonTeamsAiCustomApi(spec, destinationPath, openapiSpecFileName) {
|
|
660
|
-
const operations = teamsAiSpecOperations(spec);
|
|
661
|
-
if (operations.length === 0) {
|
|
662
|
-
return (0, neverthrow_1.err)(systemError("OpenApiTeamsAiPythonOperationsMissing", "Failed to find generated OpenAPI operations for the Python custom API template."));
|
|
663
|
-
}
|
|
664
|
-
const srcFolder = path.join(destinationPath, "src");
|
|
665
|
-
const adaptiveCardsFolder = path.join(srcFolder, "adaptiveCards");
|
|
666
|
-
await fs.ensureDir(adaptiveCardsFolder);
|
|
667
|
-
await fs.writeFile(path.join(srcFolder, "instructions.txt"), teamsAiPromptText(spec));
|
|
668
|
-
const functions = {};
|
|
669
|
-
const functionDefinitions = [];
|
|
670
|
-
const functionHandlers = [];
|
|
671
|
-
const operationIds = [];
|
|
672
|
-
for (const operation of operations) {
|
|
673
|
-
functions[operation.operationId] = {
|
|
674
|
-
name: operation.operationId,
|
|
675
|
-
description: operation.description,
|
|
676
|
-
parameters: operation.parametersSchema,
|
|
677
|
-
};
|
|
678
|
-
functionDefinitions.push(pythonTeamsAiFunctionDefinitionCode(operation.operationId));
|
|
679
|
-
functionHandlers.push(pythonTeamsAiFunctionHandlerCode(operation));
|
|
680
|
-
operationIds.push(operation.operationId);
|
|
681
|
-
const cardName = safeFileStem(operation.operationId);
|
|
682
|
-
const adaptiveCard = teamsAiAdaptiveCardWithMockData(operation);
|
|
683
|
-
await fs.writeFile(path.join(adaptiveCardsFolder, `${cardName}.json`), JSON.stringify(adaptiveCard.card, null, 2));
|
|
684
|
-
await fs.writeFile(path.join(adaptiveCardsFolder, `${cardName}.data.json`), JSON.stringify(adaptiveCard.data, null, 2));
|
|
685
|
-
}
|
|
686
|
-
await fs.writeFile(path.join(srcFolder, "functions.json"), JSON.stringify(functions, null, 2));
|
|
687
|
-
const appPath = path.join(srcFolder, "app.py");
|
|
688
|
-
const appContent = await fs.readFile(appPath, "utf8");
|
|
689
|
-
await fs.writeFile(appPath, appContent
|
|
690
|
-
.replace("// Replace with function definition code", `prompt${functionDefinitions.join("")}`)
|
|
691
|
-
.replace("//Replace with functions to be imported", operationIds.join(", ")));
|
|
692
|
-
const handlerPath = path.join(srcFolder, "handlers.py");
|
|
693
|
-
const handlerContent = await fs.readFile(handlerPath, "utf8");
|
|
694
|
-
await fs.writeFile(handlerPath, handlerContent
|
|
695
|
-
.replace("{{OPENAPI_SPEC_PATH}}", openapiSpecFileName)
|
|
696
|
-
.replace("// Replace with function handler code", functionHandlers.join("\n\n")));
|
|
697
|
-
await updatePromptSuggestions(destinationPath, operations);
|
|
698
|
-
return (0, neverthrow_1.ok)(undefined);
|
|
699
|
-
}
|
|
700
196
|
async function writeTempFile(root, relativePath, data) {
|
|
701
197
|
const destination = path.join(root, relativePath);
|
|
702
198
|
await fs.ensureDir(path.dirname(destination));
|
|
@@ -768,32 +264,70 @@ exports.openApiGeneratePluginFiles = {
|
|
|
768
264
|
if (agent.isErr()) {
|
|
769
265
|
return (0, neverthrow_1.err)(agent.error);
|
|
770
266
|
}
|
|
771
|
-
|
|
772
|
-
|
|
267
|
+
// Same shared gate the legacy path runs, so an incompatible document fails before generation.
|
|
268
|
+
const validation = await (0, daSpecParser_1.validateOpenAPISpec)(apiSpecLocation);
|
|
269
|
+
if (validation.status === m365_spec_parser_1.ValidationStatus.Error) {
|
|
270
|
+
const message = (0, localizeUtils_1.getLocalizedString)("core.createProjectQuestion.apiSpec.multipleValidationErrors.message");
|
|
271
|
+
return (0, neverthrow_1.err)(new teamsfx_api_1.UserError(SOURCE, INVALID_API_SPEC_ERROR_NAME, message, message));
|
|
272
|
+
}
|
|
273
|
+
return (0, withTempDirectory_1.withTempDirectory)("m365atk-openapi-", (phase, error) => systemError("OpenApiGenerateFailed", `Failed to generate OpenAPI plugin files during temporary file ${phase}: ${errorMessage(error)}`), async (tempRoot) => {
|
|
773
274
|
const temp = await writeTempBaseFiles(tempRoot, manifest.value, agent.value);
|
|
774
275
|
const parser = new m365_spec_parser_1.SpecParser(apiSpecLocation, openApiParseOptions());
|
|
775
|
-
await parser.
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
276
|
+
const listed = await parser.list();
|
|
277
|
+
const selectedOperations = listed.APIs.filter((operation) => apiOperations.includes(operation.api));
|
|
278
|
+
// Share the v3 declarative-agent generator so the Kiota-integration flag selects the same branch.
|
|
279
|
+
let generated;
|
|
280
|
+
try {
|
|
281
|
+
generated = await (0, daSpecParser_1.generatePlugin)(apiSpecLocation, temp.manifestPath, temp.apiSpecPath, temp.pluginPath, apiOperations, m365_spec_parser_1.AdaptiveCardUpdateStrategy.CreateNew);
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
if (!(error instanceof m365_spec_parser_1.SpecParserError)) {
|
|
285
|
+
throw error;
|
|
286
|
+
}
|
|
287
|
+
return (0, neverthrow_1.err)(new teamsfx_api_1.SystemError(constants_1.SpecParserSource, error.errorType.toString(), error.message, error.message));
|
|
288
|
+
}
|
|
289
|
+
for (const warning of generated.warnings) {
|
|
290
|
+
ctx.warn?.({ type: String(warning.type), content: warning.content });
|
|
779
291
|
}
|
|
780
|
-
const
|
|
292
|
+
const agentManifestPath = path.join(tempRoot, AGENT_PATH);
|
|
293
|
+
let agentManifest;
|
|
294
|
+
try {
|
|
295
|
+
agentManifest = teamsfx_api_1.DeclarativeAgentManifestWrapper.fromJSON(await fs.readFile(agentManifestPath, "utf8"));
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
return (0, neverthrow_1.err)(systemError("JSONSyntaxError", `The declarative agent manifest is not valid JSON: ${errorMessage(error)}`));
|
|
299
|
+
}
|
|
300
|
+
agentManifest.upsertAction(DEFAULT_ACTION_ID, teamsfx_api_1.DefaultPluginManifestFileName);
|
|
301
|
+
const remainingStarterSlots = Math.max(0, 6 - agentManifest.conversationStarters.length);
|
|
302
|
+
const seenStarterTexts = new Set(agentManifest.conversationStarters.map((starter) => starter.text));
|
|
303
|
+
const starterTexts = selectedOperations
|
|
304
|
+
.map(conversationStarterText)
|
|
305
|
+
.filter((text) => text !== undefined)
|
|
306
|
+
.filter((text) => {
|
|
307
|
+
if (seenStarterTexts.has(text)) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
seenStarterTexts.add(text);
|
|
311
|
+
return true;
|
|
312
|
+
})
|
|
313
|
+
.slice(0, remainingStarterSlots);
|
|
314
|
+
for (const text of starterTexts) {
|
|
315
|
+
agentManifest.addConversationStarter(text);
|
|
316
|
+
}
|
|
317
|
+
await fs.writeFile(agentManifestPath, agentManifest.toJSON(), "utf8");
|
|
318
|
+
const registrations = selectedAuthRegistrations(selectedOperations);
|
|
781
319
|
if (registrations.isErr()) {
|
|
782
320
|
return (0, neverthrow_1.err)(registrations.error);
|
|
783
321
|
}
|
|
784
|
-
await fs.writeFile(path.join(tempRoot, AGENT_PATH), updatedAgent.value);
|
|
785
322
|
await writeTempTreeToContext(tempRoot, ctx);
|
|
786
|
-
ctx.
|
|
323
|
+
if (ctx.read(ORIGINAL_API_SPEC_PATH) === undefined) {
|
|
324
|
+
// The Kiota branch already emits the unfiltered document beside the generated spec.
|
|
325
|
+
ctx.write(ORIGINAL_API_SPEC_PATH, await readOriginalOpenApiSpec(apiSpecLocation));
|
|
326
|
+
}
|
|
787
327
|
updateAuthYml(ctx, M365_AGENTS_YML, registrations.value);
|
|
788
328
|
updateAuthYml(ctx, M365_AGENTS_LOCAL_YML, registrations.value);
|
|
789
329
|
return (0, neverthrow_1.ok)(undefined);
|
|
790
|
-
}
|
|
791
|
-
catch (error) {
|
|
792
|
-
return (0, neverthrow_1.err)(systemError("OpenApiGenerateFailed", `Failed to generate OpenAPI plugin files: ${errorMessage(error)}`));
|
|
793
|
-
}
|
|
794
|
-
finally {
|
|
795
|
-
await fs.remove(tempRoot);
|
|
796
|
-
}
|
|
330
|
+
});
|
|
797
331
|
},
|
|
798
332
|
};
|
|
799
333
|
exports.openApiGenerateTeamsAiCustomApiFiles = {
|
|
@@ -816,8 +350,7 @@ exports.openApiGenerateTeamsAiCustomApiFiles = {
|
|
|
816
350
|
if (apiSpecLocation === undefined || apiOperations === undefined || language === undefined) {
|
|
817
351
|
return (0, neverthrow_1.err)(systemError("OpenApiTeamsAiParams", "resolved parameters are not all valid"));
|
|
818
352
|
}
|
|
819
|
-
|
|
820
|
-
try {
|
|
353
|
+
return (0, withTempDirectory_1.withTempDirectory)("m365atk-openapi-teams-ai-", (phase, error) => systemError("OpenApiTeamsAiGenerateFailed", `Failed to generate Teams AI custom API files during temporary file ${phase}: ${errorMessage(error)}`), async (tempRoot) => {
|
|
821
354
|
const languageFiles = teamsAiLanguageFiles(language);
|
|
822
355
|
const baseFiles = await writeTeamsAiBaseFiles(ctx, tempRoot, languageFiles);
|
|
823
356
|
if (baseFiles.isErr()) {
|
|
@@ -844,27 +377,13 @@ exports.openApiGenerateTeamsAiCustomApiFiles = {
|
|
|
844
377
|
if (filteredSpec === undefined) {
|
|
845
378
|
return (0, neverthrow_1.err)(systemError("OpenApiTeamsAiFilteredSpecMissing", "Failed to generate the filtered OpenAPI document for the selected operations."));
|
|
846
379
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
return (0, neverthrow_1.err)(updatePythonResult.error);
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
else {
|
|
854
|
-
const updateResult = await updateTypescriptJavascriptTeamsAiCustomApi(filteredSpec, language, tempRoot, openapiSpecFileName);
|
|
855
|
-
if (updateResult.isErr()) {
|
|
856
|
-
return (0, neverthrow_1.err)(updateResult.error);
|
|
857
|
-
}
|
|
380
|
+
const warnings = await (0, openApiCustomApi_1.generateTeamsAiCustomApiFiles)(filteredSpec, language, tempRoot, openapiSpecFileName);
|
|
381
|
+
for (const warning of warnings) {
|
|
382
|
+
ctx.warn?.({ type: String(warning.type), content: warning.content });
|
|
858
383
|
}
|
|
859
384
|
await writeTempTreeToContext(tempRoot, ctx);
|
|
860
385
|
return (0, neverthrow_1.ok)(undefined);
|
|
861
|
-
}
|
|
862
|
-
catch (error) {
|
|
863
|
-
return (0, neverthrow_1.err)(systemError("OpenApiTeamsAiGenerateFailed", `Failed to generate Teams AI custom API files: ${errorMessage(error)}`));
|
|
864
|
-
}
|
|
865
|
-
finally {
|
|
866
|
-
await fs.remove(tempRoot);
|
|
867
|
-
}
|
|
386
|
+
});
|
|
868
387
|
},
|
|
869
388
|
};
|
|
870
389
|
//# sourceMappingURL=openApi.js.map
|