-
Notifications
You must be signed in to change notification settings - Fork 5
Add chat history API for MCP platform real-time threat protection #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
7
commits into
main
Choose a base branch
from
copilot/implement-api-send-chat-history
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e0dc6b2
Initial plan
Copilot c354f4f
Implement chat history API for MCP platform
Copilot c9a6b5f
Refactor: Move model files to models directory, one file per type
Copilot cd16cde
Add comprehensive tests for sendChatHistory method
Copilot 9c9ff3a
Fix CI test failures: Add --experimental-vm-modules flag for Node.js 18+
Copilot bc2ed13
Update packages/agents-a365-runtime/src/operation-result.ts
pontemonti 9e98c1a
Merge branch 'main' into copilot/implement-api-send-chat-history
pontemonti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| export * from './power-platform-api-discovery'; | ||
| export * from './agentic-authorization-service'; | ||
| export * from './environment-utils'; | ||
| export * from './utility'; | ||
| export * from './utility'; | ||
| export * from './operation-error'; | ||
| export * from './operation-result'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| /** | ||
| * Encapsulates an error from an operation. | ||
| */ | ||
| export class OperationError { | ||
| /** | ||
| * Gets the exception associated with the error. | ||
| */ | ||
| public readonly exception: Error; | ||
|
|
||
| /** | ||
| * Gets the message associated with the error. | ||
| */ | ||
| public get message(): string { | ||
| return this.exception.message; | ||
| } | ||
|
|
||
| /** | ||
| * Initializes a new instance of the OperationError class. | ||
| * @param exception The exception associated with the error. | ||
| */ | ||
| constructor(exception: Error) { | ||
| if (!exception) { | ||
| throw new Error('exception is required'); | ||
| } | ||
| this.exception = exception; | ||
| } | ||
|
|
||
| /** | ||
| * Returns a string representation of the error. | ||
| * @returns A string representation of the error. | ||
| */ | ||
| public toString(): string { | ||
| return this.exception.toString(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { OperationError } from './operation-error'; | ||
|
|
||
| /** | ||
| * Represents the result of an operation. | ||
| */ | ||
| export class OperationResult { | ||
| private static readonly _success = new OperationResult(true); | ||
| private readonly _errors: OperationError[]; | ||
|
|
||
| /** | ||
| * Gets a flag indicating whether the operation succeeded. | ||
| */ | ||
| public readonly succeeded: boolean; | ||
|
|
||
| /** | ||
| * Gets an array of OperationError instances indicating errors that occurred during the operation. | ||
| */ | ||
| public get errors(): OperationError[] { | ||
| return this._errors || []; | ||
| } | ||
|
|
||
| /** | ||
| * Private constructor for OperationResult. | ||
| * @param succeeded Whether the operation succeeded. | ||
| * @param errors Optional array of errors. | ||
| */ | ||
| private constructor(succeeded: boolean, errors?: OperationError[]) { | ||
| this.succeeded = succeeded; | ||
| this._errors = errors || []; | ||
| } | ||
|
|
||
| /** | ||
| * Returns an OperationResult indicating a successful operation. | ||
| */ | ||
| public static get success(): OperationResult { | ||
| return OperationResult._success; | ||
| } | ||
|
|
||
| /** | ||
| * Creates an OperationResult indicating a failed operation, with a list of errors if applicable. | ||
| * @param errors An optional array of OperationError which caused the operation to fail. | ||
| * @returns An OperationResult indicating a failed operation, with a list of errors if applicable. | ||
| */ | ||
| public static failed(...errors: OperationError[]): OperationResult { | ||
| return new OperationResult(false, errors.length > 0 ? errors : []); | ||
| } | ||
|
|
||
| /** | ||
| * Converts the value of the current OperationResult object to its equivalent string representation. | ||
| * @returns A string representation of the current OperationResult object. | ||
| * @remarks | ||
| * If the operation was successful the toString() will return "Succeeded" otherwise it will return | ||
| * "Failed : " followed by a comma delimited list of error messages from its errors collection, if any. | ||
| */ | ||
| public toString(): string { | ||
| if (this.succeeded) { | ||
| return 'Succeeded'; | ||
| } | ||
|
|
||
| const errorMessages = this.errors.map(e => e.message).join(', '); | ||
| return `Failed : ${errorMessages}`; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export * from './Utility'; | ||
| export * from './McpToolServerConfigurationService'; | ||
| export * from './contracts'; | ||
| export * from './contracts'; | ||
| export * from './models'; |
27 changes: 27 additions & 0 deletions
27
packages/agents-a365-tooling/src/models/ChatHistoryMessage.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| /** | ||
| * Represents a single message in the chat history. | ||
| */ | ||
| export interface ChatHistoryMessage { | ||
| /** | ||
| * The unique identifier for the chat message. | ||
| */ | ||
| id: string; | ||
|
|
||
| /** | ||
| * The role of the message sender (e.g., "user", "assistant", "system"). | ||
| */ | ||
| role: string; | ||
|
|
||
| /** | ||
| * The content of the chat message. | ||
| */ | ||
| content: string; | ||
|
|
||
| /** | ||
| * The timestamp of when the message was sent. | ||
| */ | ||
| timestamp: Date; | ||
| } |
29 changes: 29 additions & 0 deletions
29
packages/agents-a365-tooling/src/models/ChatMessageRequest.ts
pontemonti marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { ChatHistoryMessage } from './ChatHistoryMessage'; | ||
|
|
||
| /** | ||
| * Represents the request payload for a real-time threat protection check on a chat message. | ||
| */ | ||
| export interface ChatMessageRequest { | ||
| /** | ||
| * The unique identifier for the conversation. | ||
| */ | ||
| conversationId: string; | ||
|
|
||
| /** | ||
| * The unique identifier for the message within the conversation. | ||
| */ | ||
| messageId: string; | ||
|
|
||
| /** | ||
| * The content of the user's message. | ||
| */ | ||
| userMessage: string; | ||
|
|
||
| /** | ||
| * The chat history messages. | ||
| */ | ||
| chatHistory: ChatHistoryMessage[]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| export * from './ChatHistoryMessage'; | ||
| export * from './ChatMessageRequest'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.