Skip to content

Commit 13bad94

Browse files
authored
🤖 Merge PR DefinitelyTyped#73044 Add ICopilot type and executeEvent and executePrompt by @mikepenaMS
1 parent bcf35f7 commit 13bad94

File tree

3 files changed

+95
-4
lines changed

3 files changed

+95
-4
lines changed

‎types/powerapps-component-framework/componentframework.d.ts‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,4 +2834,64 @@ declare namespace ComponentFramework {
28342834
}
28352835
}
28362836
}
2837+
2838+
/**
2839+
* Interface for Copilot functionality
2840+
*/
2841+
interface Copilot {
2842+
/**
2843+
* Executes a Microsoft Copilot Studio Agent's topic based on the registered event name. Returns an array of type MCSResponse.
2844+
* @param eventName Name of the event to execute
2845+
* @param parameters Parameters for the event, such as an ID
2846+
* @returns Promise that resolves with the event result
2847+
*/
2848+
executeEvent(eventName: string, parameters: Record<string, unknown>): Promise<MCSResponse[]>;
2849+
2850+
/**
2851+
* Executes a Microsoft Copilot Studio Agent's topic based on registered triggered phrases. Returns an array of MCSResponse.
2852+
* @param promptText The text that is registered as a trigger query in the MCS topic.
2853+
*/
2854+
executePrompt(promptText: string): Promise<MCSResponse[]>;
2855+
}
2856+
2857+
/**
2858+
* Interface for Copilot attachment layout types
2859+
*/
2860+
type AttachmentLayout = "list" | "carousel";
2861+
2862+
/**
2863+
* Interface for Copilot attachments
2864+
*/
2865+
interface Attachment {
2866+
content?: unknown;
2867+
contentType?: string;
2868+
}
2869+
2870+
/**
2871+
* Interface for Copilot text formats
2872+
*/
2873+
type TextFormat = "plain" | "markdown" | "xml";
2874+
2875+
/*
2876+
* Interface for Copilot response
2877+
*/
2878+
interface MCSResponse {
2879+
type: string;
2880+
id?: string;
2881+
locale?: string;
2882+
replyToId?: string;
2883+
timestamp?: string;
2884+
speak?: string;
2885+
text?: string;
2886+
textFormat?: TextFormat;
2887+
suggestedActions?: {
2888+
actions: unknown[];
2889+
to?: string[];
2890+
};
2891+
value?: unknown;
2892+
valueType?: string;
2893+
name?: string;
2894+
attachmentLayout?: AttachmentLayout;
2895+
attachments?: Attachment[];
2896+
}
28372897
}

‎types/powerapps-component-framework/package.json‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@
4141
{
4242
"name": "Alex Tran",
4343
"githubUsername": "Alex-MSFT"
44-
},
45-
{
46-
"name": "Michael Pena",
47-
"githubUsername": "mikepenaMS"
4844
}
4945
]
5046
}

‎types/powerapps-component-framework/powerapps-component-framework-tests.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,3 +687,38 @@ const entityFormOptionsTest: ComponentFramework.NavigationApi.EntityFormOptions
687687
entityType: "",
688688
},
689689
};
690+
691+
const mcsResponseTest: ComponentFramework.MCSResponse = {
692+
type: "message",
693+
id: "19e7c095-4b6d-47b5-bc15-1c0ba3d5718d",
694+
timestamp: "2025-04-21T20:52:17.9125027+00:00",
695+
replyToId: "d0289e39-6192-4197-9fe2-9be66cb5127b",
696+
textFormat: "markdown",
697+
value: `Hello, here's **today's weather**`,
698+
attachmentLayout: "list",
699+
attachments: [
700+
{
701+
contentType: "application/vnd.microsoft.card.adaptive",
702+
content: {
703+
type: "AdaptiveCard",
704+
$schema: "https://adaptivecards.io/schemas/adaptive-card.json",
705+
version: "1.6",
706+
body: [
707+
{
708+
type: "TextBlock",
709+
text: "Redmond, WA",
710+
size: "Large",
711+
isSubtle: true,
712+
wrap: true,
713+
style: "heading",
714+
},
715+
],
716+
},
717+
},
718+
],
719+
};
720+
721+
const copilotTest: ComponentFramework.Copilot = {
722+
executeEvent: (eventName: string, eventData?: any) => Promise.resolve([mcsResponseTest]),
723+
executePrompt: (promptText: string) => Promise.resolve([mcsResponseTest]),
724+
};

0 commit comments

Comments
 (0)