Skip to content

Commit

Permalink
fix: copilot spec parser
Browse files Browse the repository at this point in the history
  • Loading branch information
anchenyi committed Sep 30, 2024
1 parent 467e728 commit 1d93226
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/manifest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,9 @@ export class ManifestUtil {

return telemetryProperties;
}

static async useCopilotExtensionsInSchema(manifest: TeamsAppManifest): Promise<boolean> {
const schema = await this.fetchSchema(manifest);
return !!schema.value.definitions?.copilotExtensions;
}
}
8 changes: 5 additions & 3 deletions packages/spec-parser/src/manifestUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
PluginManifestSchema,
FunctionObject,
AuthObject,
ManifestUtil,
} from "@microsoft/teams-manifest";
import { AdaptiveCardGenerator } from "./adaptiveCardGenerator";
import { wrapResponseSemantics } from "./adaptiveCardWrapper";
Expand All @@ -41,7 +42,9 @@ export class ManifestUpdater {
const manifest: TeamsAppManifest = await fs.readJSON(manifestPath);
const apiPluginRelativePath = ManifestUpdater.getRelativePath(manifestPath, apiPluginFilePath);

if (manifest.copilotExtensions) {
const useCopilotExtensionsInSchema = await ManifestUtil.useCopilotExtensionsInSchema(manifest);
if (useCopilotExtensionsInSchema) {
manifest.copilotExtensions = manifest.copilotExtensions || {};
if (!options.isGptPlugin) {
manifest.copilotExtensions.plugins = [
{
Expand All @@ -52,8 +55,7 @@ export class ManifestUpdater {
ManifestUpdater.updateManifestDescription(manifest, spec);
}
} else {
(manifest as any).copilotAgents = (manifest as any).copilotAgents || {};

manifest.copilotAgents = manifest.copilotAgents || {};
if (!options.isGptPlugin) {
(manifest as any).copilotAgents.plugins = [
{
Expand Down

0 comments on commit 1d93226

Please sign in to comment.