Add chat history API for MCP platform real-time threat protection#139
Add chat history API for MCP platform real-time threat protection#139pontemonti merged 8 commits intomainfrom
Conversation
- Add OperationResult and OperationError classes to runtime package - Add ChatHistoryMessage and ChatMessageRequest models to tooling package - Add GetChatHistoryEndpoint utility method - Add sendChatHistory methods to McpToolServerConfigurationService - Add comprehensive tests for all new functionality - All builds and tests pass successfully Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
- Create models directory under src - Split ChatHistoryMessage and ChatMessageRequest into separate files - Add models/index.ts to export all models - Update imports in McpToolServerConfigurationService and tests - Delete old models.ts file - All 264 tests passing, no regressions Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
- Add 20 new tests for sendChatHistory method - Test successful scenarios (with and without options, empty history) - Test validation errors (null/undefined parameters, missing required fields) - Test error handling (HTTP errors, timeouts, connection aborted) - Test OperationResult behavior - Test endpoint configuration (production and custom endpoints) - All 284 tests passing, no regressions Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
|
@copilot - follow these instructions to address errors in PR workflow: Root causes and recommended solutions:
Summary of changes:
These fixes will address the test failures and unblock your workflow. References: |
- Update test scripts in tests/package.json to use --experimental-vm-modules flag - Update test:coverage and test:integration scripts in root package.json - Use $(npm root)/../node_modules/.bin/jest to locate jest from monorepo root - Fixes ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG error in Node.js 18+ - All 284 tests passing with Node.js 20 Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Fixed CI test failures by adding
The axios errors in tests are intentional - they test error handling paths. The mock ensures no real network calls are made. Commit: 9c9ff3a |
There was a problem hiding this comment.
Pull request overview
This pull request successfully implements a chat history API for the MCP platform's real-time threat protection feature, following the patterns established in the .NET SDK (PR #148). The implementation adds new operation result handling classes to the runtime package, new data models for chat messages, and a service method to send chat history to the MCP platform.
Key Changes:
- Added
OperationResultandOperationErrorclasses to the runtime package for standardized operation result handling - Created
ChatHistoryMessageandChatMessageRequestmodels in the tooling package with proper TypeScript interfaces - Implemented
sendChatHistorymethod inMcpToolServerConfigurationServicewith comprehensive error handling and logging - Added
GetChatHistoryEndpointutility method to construct the appropriate endpoint URL - Fixed Node.js 18+ compatibility by adding
--experimental-vm-modulesflag to test scripts
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/agents-a365-runtime/src/operation-error.ts | New class that encapsulates operation errors with exception wrapping and message extraction |
| packages/agents-a365-runtime/src/operation-result.ts | New class providing standardized success/failure result handling with error collection |
| packages/agents-a365-runtime/src/index.ts | Exports new OperationError and OperationResult classes |
| packages/agents-a365-tooling/src/models/ChatHistoryMessage.ts | Interface defining the structure of a chat message in history |
| packages/agents-a365-tooling/src/models/ChatMessageRequest.ts | Interface for the request payload sent to the MCP platform |
| packages/agents-a365-tooling/src/models/index.ts | Exports for the new model interfaces |
| packages/agents-a365-tooling/src/Utility.ts | Added GetChatHistoryEndpoint method to construct the threat protection endpoint URL |
| packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts | Implemented sendChatHistory method with two overloads for sending chat history to MCP platform |
| packages/agents-a365-tooling/src/index.ts | Added export for new models directory |
| tests/runtime/operation-error.test.ts | Comprehensive tests for OperationError class (5 tests) |
| tests/runtime/operation-result.test.ts | Tests for OperationResult success and failure scenarios (9 tests) |
| tests/tooling/models.test.ts | Tests for ChatHistoryMessage and ChatMessageRequest models (6 tests) |
| tests/tooling/utility.test.ts | Tests for GetChatHistoryEndpoint with various configurations (5 tests) |
| tests/tooling/mcp-tool-server-configuration-service.test.ts | Comprehensive tests for sendChatHistory method including validation, error handling, and endpoint configuration (20 tests) |
| package.json | Updated test scripts to include --experimental-vm-modules flag for Node.js 18+ compatibility |
| tests/package.json | Updated test scripts with --experimental-vm-modules flag for Jest compatibility |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Implementation Plan for Chat History API ✅ COMPLETE
Based on the .NET PR #148, I need to implement the following in the Node.js/TypeScript SDK:
Phase 1: Runtime Package Updates
OperationResultclass in runtime packageOperationErrorclass in runtime packagePhase 2: Tooling Package - Models
ChatHistoryMessageinterface/class in tooling packageChatMessageRequestinterface/class in tooling packagemodels/directory with one file per typePhase 3: Tooling Package - Service Methods
GetChatHistoryEndpointutility method to Utility classSendChatHistorymethod overload (without ToolOptions) to McpToolServerConfigurationServiceSendChatHistorymethod overload (with ToolOptions) to McpToolServerConfigurationServicePhase 4: Testing
Phase 5: Build and Validation
Phase 6: Code Review Feedback
Summary
Successfully implemented the chat history API for the MCP platform following the .NET SDK pattern:
Files Added (11):
packages/agents-a365-runtime/src/operation-error.tspackages/agents-a365-runtime/src/operation-result.tspackages/agents-a365-tooling/src/models/ChatHistoryMessage.tspackages/agents-a365-tooling/src/models/ChatMessageRequest.tspackages/agents-a365-tooling/src/models/index.tstests/runtime/operation-error.test.tstests/runtime/operation-result.test.tstests/tooling/models.test.tstests/tooling/utility.test.tstests/tooling/mcp-tool-server-configuration-service.test.tsFiles Modified (6):
packages/agents-a365-runtime/src/index.tspackages/agents-a365-tooling/src/McpToolServerConfigurationService.tspackages/agents-a365-tooling/src/Utility.tspackages/agents-a365-tooling/src/index.tspackage.json(updated test scripts for Node.js 18+ compatibility)tests/package.json(updated test scripts for Node.js 18+ compatibility)Quality Metrics:
✅ 284/284 tests passing (46 new tests added)
✅ 100% build success
✅ 0 linting errors
✅ 0 code review issues
✅ 0 security vulnerabilities
✅ All copyright headers present
✅ Models organized in separate files per feedback
✅ Comprehensive test coverage for sendChatHistory method
✅ CI test failures fixed with --experimental-vm-modules flag
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.