From 90edd909b8908aad89fb972a0598ef9f3548b9c1 Mon Sep 17 00:00:00 2001 From: Rido Date: Mon, 28 Jul 2025 23:46:46 +0000 Subject: [PATCH 1/6] feat: add comprehensive template dependency analysis documentation --- docs/template-dependency-analysis.md | 240 +++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 docs/template-dependency-analysis.md diff --git a/docs/template-dependency-analysis.md b/docs/template-dependency-analysis.md new file mode 100644 index 00000000000..915c7b0a64a --- /dev/null +++ b/docs/template-dependency-analysis.md @@ -0,0 +1,240 @@ +# Microsoft 365 Agents Toolkit - Template Dependency Analysis + +**Analysis Date:** July 28, 2025 +**Repository:** microsoft-365-agents-toolkit +**Directory Analyzed:** `templates/vsc/js/` + +## Overview + +This document provides a comprehensive analysis of all JavaScript templates in the Microsoft 365 Agents Toolkit, focusing on their dependencies and architectural patterns. The analysis reveals three distinct approaches to building Microsoft 365 applications within the toolkit. + +## Template Categories + +### 1. Microsoft Agents SDK Templates +Templates using the new `@microsoft/agents-*` packages represent the latest approach to building Microsoft 365 applications. + +### 2. Teams AI Library Templates +Templates using `@microsoft/teams-ai` for AI-powered bots and copilots. + +### 3. Other Framework Templates +Templates using Azure Functions, React, or other specialized frameworks. + +--- + + + +## Detailed Analysis by Framework + +### Microsoft Agents SDK Templates (11 templates) + +The newest approach using `@microsoft/agents-*` packages: + +#### Core Microsoft Agents SDK Templates +| Template | Hosting Packages | Specialized Dependencies | +|----------|------------------|-------------------------| +| **basic-custom-engine-agent** | `@microsoft/agents-hosting` ^0.2.14 | `@azure/identity` ^4.8.0, `@azure/openai` ^2.0.0, `openai` ^4.94.0 | +| **default-bot** | `@microsoft/agents-hosting` ^0.2.14 | None (minimal bot) | +| **weather-agent** | `@microsoft/agents-hosting` ^0.2.14 | `@langchain/langgraph` ^0.2.66, `@azure/openai` ^2.0.0, `zod` 3.25.67 | + +#### Message Extension Templates (Microsoft Agents SDK) +| Template | Dependencies | +|----------|-------------| +| **link-unfurling** | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14 | +| **m365-message-extension** | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14, `adaptivecards` ^3.0.1 | +| **message-extension** | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14, `isomorphic-fetch` ^3.0.0 | +| **message-extension-action** | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14, `adaptivecards` ^3.0.1 | + +#### Notification Templates (Microsoft Agents SDK) +All notification templates use version ^0.4.3 of the hosting packages: + +| Template | Trigger Type | Dependencies | +|----------|-------------|-------------| +| **notification-express** | HTTP (Express) | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-hosting-teams` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | +| **notification-http-timer-trigger** | HTTP + Timer (Azure Functions) | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-hosting-teams` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | +| **notification-http-trigger** | HTTP (Azure Functions) | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-hosting-teams` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | +| **notification-timer-trigger** | Timer (Azure Functions) | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-hosting-teams` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | + +**Key Observations:** +- Notification templates use newer versions (^0.4.3) compared to other Agents SDK templates (^0.2.14) +- All include `@microsoft/agents-activity` for activity handling +- Express-based vs Azure Functions-based hosting options + +--- + +### Teams AI Library Templates (9 templates) + +Templates using `@microsoft/teams-ai` for AI-powered functionality: + +#### Version Distribution +| Version | Templates | Notes | +|---------|-----------|-------| +| **^1.7.0** | command-and-response, workflow | Latest version | +| **^1.6.1** | custom-copilot-assistant-assistants-api | Pinned version (~1.6.1) | +| **^1.5.3** | custom-copilot-assistant-new, custom-copilot-basic, custom-copilot-rag-azure-ai-search, custom-copilot-rag-customize, custom-copilot-rag-microsoft365 | Most common version | +| **^1.1.0** | custom-copilot-rag-custom-api | Oldest version | + +#### AI Assistant Templates +| Template | Teams AI Version | Specialization | +|----------|------------------|----------------| +| **custom-copilot-assistant-assistants-api** | ~1.6.1 | OpenAI Assistants API integration | +| **custom-copilot-assistant-new** | ^1.5.3 | General AI assistant | +| **custom-copilot-basic** | ^1.5.3 | Basic AI chat functionality | + +#### RAG (Retrieval-Augmented Generation) Templates +| Template | Teams AI Version | Data Source | Additional Dependencies | +|----------|------------------|-------------|------------------------| +| **custom-copilot-rag-azure-ai-search** | ^1.5.3 | Azure AI Search | `@azure/search-documents` ^12.0.0 | +| **custom-copilot-rag-custom-api** | ^1.1.0 | Custom API | `openapi-client-axios` ^7.4.0, `js-yaml` ^4.1.0 | +| **custom-copilot-rag-customize** | ^1.5.3 | Custom data source | `@azure/search-documents` ^12.0.0 | +| **custom-copilot-rag-microsoft365** | ^1.5.3 | Microsoft 365 data | `@microsoft/microsoft-graph-client` ^3.0.1, `@azure/search-documents` ^12.0.0 | + +#### Bot Framework Templates +| Template | Teams AI Version | Purpose | +|----------|------------------|---------| +| **command-and-response** | ^1.7.0 | Command handling bot | +| **workflow** | ^1.7.0 | Workflow automation bot | + +**Common Dependencies:** +- All Teams AI templates use `botbuilder` ^4.23.1 +- Most use `express` ^5.0.1 +- Adaptive Cards templates include `adaptivecards-templating` ^2.3.1 + +--- + +## Complete Template Inventory + +| Template Name | Primary Framework | Key Dependencies | +|---------------|-------------------|------------------| +| **basic-custom-engine-agent** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@azure/identity` ^4.8.0, `@azure/openai` ^2.0.0, `openai` ^4.94.0 | +| **command-and-response** | Teams AI Library | `@microsoft/teams-ai` ^1.7.0, `botbuilder` ^4.23.1, `adaptive-expressions` ^4.23.1 | +| **custom-copilot-assistant-assistants-api** | Teams AI Library | `@microsoft/teams-ai` ~1.6.1, `botbuilder` ^4.23.1 | +| **custom-copilot-assistant-new** | Teams AI Library | `@microsoft/teams-ai` ^1.5.3, `botbuilder` ^4.23.1 | +| **custom-copilot-basic** | Teams AI Library | `@microsoft/teams-ai` ^1.5.3, `botbuilder` ^4.23.1 | +| **custom-copilot-rag-azure-ai-search** | Teams AI Library | `@microsoft/teams-ai` ^1.5.3, `@azure/search-documents` ^12.0.0, `botbuilder` ^4.23.1 | +| **custom-copilot-rag-custom-api** | Teams AI Library | `@microsoft/teams-ai` ^1.1.0, `botbuilder` ^4.23.1, `openapi-client-axios` ^7.4.0 | +| **custom-copilot-rag-customize** | Teams AI Library | `@microsoft/teams-ai` ^1.5.3, `@azure/search-documents` ^12.0.0, `botbuilder` ^4.23.1 | +| **custom-copilot-rag-microsoft365** | Teams AI Library | `@microsoft/teams-ai` ^1.5.3, `@microsoft/microsoft-graph-client` ^3.0.1, `@azure/search-documents` ^12.0.0 | +| **dashboard-tab** | React/Vite | `@fluentui/react-components` ^9.55.1, `@microsoft/teams-js` ^2.31.1, `react` ^18.2.0 | +| **declarative-agent-with-action-from-scratch** | Azure Functions | `@azure/functions` ^4.3.0 | +| **declarative-agent-with-action-from-scratch-bearer** | Azure Functions | `@azure/functions` ^4.3.0 | +| **declarative-agent-with-action-from-scratch-oauth** | Azure Functions | `@azure/functions` ^4.3.0, `jsonwebtoken` ^9.0.2, `jwks-rsa` ^3.1.0 | +| **default-bot** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14 | +| **default-bot-message-extension** | Bot Builder | `botbuilder` ^4.23.1, `adaptivecards` ^3.0.1 | +| **link-unfurling** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14 | +| **m365-message-extension** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14 | +| **message-extension** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14 | +| **message-extension-action** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14 | +| **message-extension-with-api-from-scratch** | Azure Functions | `@azure/functions` ^4.3.0 | +| **message-extension-with-api-from-scratch-api-key** | Azure Functions | `@azure/functions` ^4.3.0 | +| **message-extension-with-api-from-scratch-sso** | Azure Functions | `@azure/functions` ^4.3.0, `jsonwebtoken` ^9.0.2, `jwks-rsa` ^3.1.0 | +| **non-sso-tab** | Express Static | `express` ^4.21.1, `send` ^0.18.0 | +| **non-sso-tab-default-bot** | Multi-component | `concurrently` ^7.6.0 (separate bot and tab packages) | +| **notification-express** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | +| **notification-http-timer-trigger** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | +| **notification-http-trigger** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | +| **notification-timer-trigger** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | +| **sso-tab-naa** | React/Vite | `@azure/msal-browser` ^4.12.0, `@microsoft/teams-js` ^2.31.1, `react` ^18.2.0 | +| **weather-agent** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@langchain/langgraph` ^0.2.66, `@azure/openai` ^2.0.0 | +| **workflow** | Teams AI Library | `@microsoft/teams-ai` ^1.7.0, `botbuilder` ^4.23.1, `adaptive-expressions` ^4.23.1 | + +--- + +### Other Framework Templates (12 templates) + +#### Legacy/Bot Builder Templates (3 templates) +| Template | Framework | Purpose | +|----------|-----------|---------| +| **default-bot-message-extension** | Bot Builder v4 | Message extension with traditional Bot Framework | +| **non-sso-tab-default-bot** | Multi-component | Combination of tab and bot in separate packages | + +**Note:** Office add-in templates (`office-json-addin`, `office-xml-addin-*`) don't have `package.json.tpl` files and likely use different templating mechanisms. + +--- + +## Architecture Patterns + +### 1. Microsoft Agents SDK Pattern +- **Hosting:** `@microsoft/agents-hosting` + `@microsoft/agents-hosting-teams` +- **Activity Management:** `@microsoft/agents-activity` (for notifications) +- **Benefits:** Streamlined development, built-in Teams integration +- **Use Cases:** Modern Microsoft 365 applications, message extensions, notifications + +### 2. Teams AI Library Pattern +- **Core:** `@microsoft/teams-ai` + `botbuilder` +- **AI Integration:** Built-in AI orchestration and prompt management +- **Benefits:** Advanced AI capabilities, RAG support, conversation management +- **Use Cases:** AI-powered bots, copilots, intelligent assistants + + +## Version Analysis + +### Microsoft Agents SDK Versions +- **Core templates:** ^0.2.14 +- **Notification templates:** ^0.4.3 (newer) +- **Trend:** Active development with version progression + +### Teams AI Library Versions +- **Latest:** ^1.7.0 (command-and-response, workflow) +- **Stable:** ^1.5.3 (most copilot templates) +- **Legacy:** ^1.1.0 (custom-copilot-rag-custom-api) +- **Trend:** Most templates are on recent stable versions + +### Common Dependencies +- **Express:** Ranges from ^4.21.1 to ^5.0.1 +- **Bot Builder:** Consistently ^4.23.1 +- **Adaptive Cards:** ^3.0.1 to ^3.0.5 +- **Node.js:** All templates support "18 || 20 || 22" + +--- + +## Development Patterns + +### Script Patterns +Common across most templates: +```json +{ + "dev:teamsfx": "env-cmd --silent -f .localConfigs npm run dev", + "dev:teamsfx:testtool": "env-cmd --silent -f .localConfigs.playground npm run dev", + "dev:teamsfx:launch-testtool": "env-cmd --silent -f env/.env.playground teamsapptester start" +} +``` + +### Development Dependencies +Standard across templates: +- `env-cmd` ^10.1.0 (environment configuration) +- `nodemon` ^3.1.7 (development server) +- `concurrently` (for multi-component templates) + +--- + +## Recommendations + +### For New Projects +1. **Choose Microsoft Agents SDK** for new Microsoft 365 applications +2. **Use Teams AI Library** for AI-powered conversational experiences +3. **Consider Azure Functions** for lightweight API backends +4. **Use React patterns** for rich interactive tabs + +### Migration Considerations +- **From Bot Builder:** Consider Teams AI Library for AI features +- **To Agents SDK:** Evaluate benefits of streamlined hosting +- **Version Updates:** Keep AI Library templates on latest versions + +### Architecture Decision Factors +- **Complexity:** Agents SDK for simple, Functions for minimal +- **AI Requirements:** Teams AI Library for advanced AI features +- **UI Needs:** React patterns for rich interfaces +- **Hosting Preferences:** Express vs Azure Functions vs Agents hosting + +--- + +## Conclusion + +The Microsoft 365 Agents Toolkit demonstrates a strategic evolution in development approaches: + +1. **Microsoft Agents SDK** represents the future direction for Microsoft 365 application development +2. **Teams AI Library** provides sophisticated AI capabilities for conversational experiences +3. **Azure Functions** offers lightweight, serverless options for API development +4. **React/Tab templates** enable rich, modern user interfaces + +The diversity of templates allows developers to choose the most appropriate technology stack based on their specific requirements, while the consistent patterns across templates ensure a cohesive development experience. From 7789cfc51f442863998eb217e3afe3cf3efc26a2 Mon Sep 17 00:00:00 2001 From: Rido Date: Wed, 30 Jul 2025 17:37:07 +0000 Subject: [PATCH 2/6] Update basic samples to Agents SDJK node --- .../infra/azure.bicep.tpl | 2 +- .../package.json.tpl | 5 +- .../basic-custom-engine-agent/src/adapter.js | 35 --------- .../src/agent.js.tpl | 4 +- .../js/basic-custom-engine-agent/src/index.js | 29 +------- templates/vsc/js/default-bot/index.js | 58 +-------------- .../vsc/js/default-bot/infra/azure.bicep | 2 +- templates/vsc/js/default-bot/package.json.tpl | 5 +- templates/vsc/js/default-bot/teamsBot.js | 22 +++--- .../js/weather-agent/infra/azure.bicep.tpl | 2 +- .../vsc/js/weather-agent/package.json.tpl | 6 +- .../vsc/js/weather-agent/src/agent.js.tpl | 4 +- templates/vsc/js/weather-agent/src/index.js | 31 +------- .../infra/azure.bicep.tpl | 2 +- .../package.json.tpl | 11 ++- .../basic-custom-engine-agent/src/adapter.ts | 35 --------- .../src/agent.ts.tpl | 4 +- .../ts/basic-custom-engine-agent/src/index.ts | 34 +-------- .../ts/default-bot/{teamsBot.ts => agent.ts} | 20 +++--- templates/vsc/ts/default-bot/index.ts | 71 +------------------ .../vsc/ts/default-bot/infra/azure.bicep | 2 +- templates/vsc/ts/default-bot/package.json.tpl | 13 ++-- .../ts/weather-agent/infra/azure.bicep.tpl | 2 +- .../vsc/ts/weather-agent/package.json.tpl | 12 ++-- .../vsc/ts/weather-agent/src/agent.ts.tpl | 4 +- templates/vsc/ts/weather-agent/src/index.ts | 36 +--------- 26 files changed, 72 insertions(+), 379 deletions(-) delete mode 100644 templates/vsc/js/basic-custom-engine-agent/src/adapter.js delete mode 100644 templates/vsc/ts/basic-custom-engine-agent/src/adapter.ts rename templates/vsc/ts/default-bot/{teamsBot.ts => agent.ts} (76%) diff --git a/templates/vsc/js/basic-custom-engine-agent/infra/azure.bicep.tpl b/templates/vsc/js/basic-custom-engine-agent/infra/azure.bicep.tpl index 6adb2e7b4a4..41aad4d240f 100644 --- a/templates/vsc/js/basic-custom-engine-agent/infra/azure.bicep.tpl +++ b/templates/vsc/js/basic-custom-engine-agent/infra/azure.bicep.tpl @@ -60,7 +60,7 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = { } { name: 'WEBSITE_NODE_DEFAULT_VERSION' - value: '~18' // Set NodeJS version to 18.x for your site + value: '~22' // Set NodeJS version to 22.x for your site } { name: 'RUNNING_ON_AZURE' diff --git a/templates/vsc/js/basic-custom-engine-agent/package.json.tpl b/templates/vsc/js/basic-custom-engine-agent/package.json.tpl index fee24ca6133..4a1f43608b4 100644 --- a/templates/vsc/js/basic-custom-engine-agent/package.json.tpl +++ b/templates/vsc/js/basic-custom-engine-agent/package.json.tpl @@ -27,13 +27,12 @@ "dependencies": { "@azure/identity": "^4.8.0", "@azure/openai": "^2.0.0", - "@microsoft/agents-hosting": "^0.2.14", - "express": "^5.0.1", + "@microsoft/agents-hosting-express": "^1.0.0", "openai": "^4.94.0" }, "devDependencies": { "env-cmd": "^10.1.0", - "nodemon": "^3.1.7", + "nodemon": "^3.1.10", "shx": "^0.3.3" } } \ No newline at end of file diff --git a/templates/vsc/js/basic-custom-engine-agent/src/adapter.js b/templates/vsc/js/basic-custom-engine-agent/src/adapter.js deleted file mode 100644 index 9780383b53d..00000000000 --- a/templates/vsc/js/basic-custom-engine-agent/src/adapter.js +++ /dev/null @@ -1,35 +0,0 @@ -const { CloudAdapter, loadAuthConfigFromEnv } = require("@microsoft/agents-hosting"); - -// Create authentication configuration -const authConfig = loadAuthConfigFromEnv(); - -// Create adapter -const adapter = new CloudAdapter(authConfig); - -// Catch-all for errors. -const onTurnErrorHandler = async (context, error) => { - // This check writes out errors to console log .vs. app insights. - // NOTE: In production environment, you should consider logging this to Azure - // application insights. - console.error(`\n [onTurnError] unhandled error: ${error}`); - - // Only send error message for user messages, not for other message types so the agent doesn't spam a channel or chat. - if (context.activity.type === "message") { - // Send a trace activity, which will be displayed in Bot Framework Emulator - await context.sendTraceActivity( - "OnTurnError Trace", - `${error}`, - "https://www.botframework.com/schemas/error", - "TurnError" - ); - - // Send a message to the user - await context.sendActivity("The agent encountered an error or bug."); - await context.sendActivity("To continue to run this agent, please fix the agent source code."); - } -}; - -// Set the onTurnError for the singleton TeamsAdapter. -adapter.onTurnError = onTurnErrorHandler; - -module.exports = adapter; diff --git a/templates/vsc/js/basic-custom-engine-agent/src/agent.js.tpl b/templates/vsc/js/basic-custom-engine-agent/src/agent.js.tpl index 9ddfb8b59a2..2896c0fcd91 100644 --- a/templates/vsc/js/basic-custom-engine-agent/src/agent.js.tpl +++ b/templates/vsc/js/basic-custom-engine-agent/src/agent.js.tpl @@ -25,12 +25,12 @@ const agentApp = new AgentApplication({ storage, }); -agentApp.conversationUpdate("membersAdded", async (context) => { +agentApp.onConversationUpdate("membersAdded", async (context) => { await context.sendActivity(`Hi there! I'm an agent to chat with you.`); }); // Listen for ANY message to be received. MUST BE AFTER ANY OTHER MESSAGE HANDLERS -agentApp.activity(ActivityTypes.Message, async (context) => { +agentApp.onActivity(ActivityTypes.Message, async (context) => { // Echo back users request const result = await client.chat.completions.create({ messages: [ diff --git a/templates/vsc/js/basic-custom-engine-agent/src/index.js b/templates/vsc/js/basic-custom-engine-agent/src/index.js index d65761ec827..c0ea65349bf 100644 --- a/templates/vsc/js/basic-custom-engine-agent/src/index.js +++ b/templates/vsc/js/basic-custom-engine-agent/src/index.js @@ -1,28 +1,3 @@ -// Import required packages -const { authorizeJWT, loadAuthConfigFromEnv } = require("@microsoft/agents-hosting"); -const express = require("express"); - -// This bot's adapter -const adapter = require("./adapter"); - -// This bot's main dialog. +const { startServer } = require("@microsoft/agents-hosting-express"); const { agentApp } = require("./agent"); - -// Create authentication configuration -const authConfig = loadAuthConfigFromEnv(); - -// Create express application. -const expressApp = express(); -expressApp.use(express.json()); -expressApp.use(authorizeJWT(authConfig)); - -const server = expressApp.listen(process.env.port || process.env.PORT || 3978, () => { - console.log(`\nAgent started, ${expressApp.name} listening to`, server.address()); -}); - -// Listen for incoming requests. -expressApp.post("/api/messages", async (req, res) => { - await adapter.process(req, res, async (context) => { - await agentApp.run(context); - }); -}); +startServer(agentApp) \ No newline at end of file diff --git a/templates/vsc/js/default-bot/index.js b/templates/vsc/js/default-bot/index.js index a19e873a856..f207d9712d4 100644 --- a/templates/vsc/js/default-bot/index.js +++ b/templates/vsc/js/default-bot/index.js @@ -1,56 +1,4 @@ -// index.js is used to setup and configure your bot -// Import required packages -const express = require("express"); - -// Import required bot services. -// See https://aka.ms/bot-services to learn more about the different parts of a bot. -const { authorizeJWT, CloudAdapter, loadAuthConfigFromEnv } = require("@microsoft/agents-hosting"); -const { teamsBot } = require("./teamsBot"); - -// Create authentication configuration -const authConfig = loadAuthConfigFromEnv(); - -// Create adapter -const adapter = new CloudAdapter(authConfig); - -adapter.onTurnError = async (context, error) => { - // This check writes out errors to console log .vs. app insights. - // NOTE: In production environment, you should consider logging this to Azure - // application insights. See https://aka.ms/bottelemetry for telemetry - // configuration instructions. - console.error(`\n [onTurnError] unhandled error: ${error}`); - - // Only send error message for user messages, not for other message types so the bot doesn't spam a channel or chat. - if (context.activity.type === "message") { - // Send a message to the user - await context.sendActivity(`The bot encountered an unhandled error:\n ${error.message}`); - await context.sendActivity("To continue to run this bot, please fix the bot source code."); - } -}; - -// Create express application. -const expressApp = express(); -expressApp.use(express.json()); -expressApp.use(authorizeJWT(authConfig)); - -const port = process.env.port || process.env.PORT || 3978; -const server = expressApp.listen(port, () => { - console.log( - `Bot Started, listening to port ${port} for appId ${authConfig.clientId} debug ${process.env.DEBUG}` - ); -}); - -// Listen for incoming requests. -expressApp.post("/api/messages", async (req, res) => { - await adapter.process(req, res, async (context) => { - await teamsBot.run(context); - }); -}); - -// Gracefully shutdown HTTP server -["exit", "uncaughtException", "SIGINT", "SIGTERM", "SIGUSR1", "SIGUSR2"].forEach((event) => { - process.on(event, () => { - server.close(); - }); -}); +const { startServer } = require("@microsoft/agents-hosting-express"); +const { agentApp } = require("./teamsBot"); +startServer(agentApp) diff --git a/templates/vsc/js/default-bot/infra/azure.bicep b/templates/vsc/js/default-bot/infra/azure.bicep index 3999e8c3a86..d883f5ce16f 100644 --- a/templates/vsc/js/default-bot/infra/azure.bicep +++ b/templates/vsc/js/default-bot/infra/azure.bicep @@ -45,7 +45,7 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = { } { name: 'WEBSITE_NODE_DEFAULT_VERSION' - value: '~18' // Set NodeJS version to 18.x for your site + value: '~22' // Set NodeJS version to 22.x for your site } { name: 'RUNNING_ON_AZURE' diff --git a/templates/vsc/js/default-bot/package.json.tpl b/templates/vsc/js/default-bot/package.json.tpl index 6355873d6b3..ee038dc898f 100644 --- a/templates/vsc/js/default-bot/package.json.tpl +++ b/templates/vsc/js/default-bot/package.json.tpl @@ -21,11 +21,10 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@microsoft/agents-hosting": "^0.2.14", - "express": "^5.0.1" + "@microsoft/agents-hosting-express": "^1.0.0" }, "devDependencies": { "env-cmd": "^10.1.0", - "nodemon": "^3.1.7" + "nodemon": "^3.1.10" } } diff --git a/templates/vsc/js/default-bot/teamsBot.js b/templates/vsc/js/default-bot/teamsBot.js index f8579d65b6f..ff513895a40 100644 --- a/templates/vsc/js/default-bot/teamsBot.js +++ b/templates/vsc/js/default-bot/teamsBot.js @@ -10,33 +10,33 @@ const downloader = new AttachmentDownloader(); // Define storage and application const storage = new MemoryStorage(); -const teamsBot = new AgentApplication({ +const agentApp = new AgentApplication({ storage, fileDownloaders: [downloader], }); // Listen for user to say '/reset' and then delete conversation state -teamsBot.message("/reset", async (context, state) => { +agentApp.onMessage("/reset", async (context, state) => { state.deleteConversationState(); await context.sendActivity("Ok I've deleted the current conversation state."); }); -teamsBot.message("/count", async (context, state) => { +agentApp.onMessage("/count", async (context, state) => { const count = state.conversation.count ?? 0; await context.sendActivity(`The count is ${count}`); }); -teamsBot.message("/diag", async (context, state) => { +agentApp.onMessage("/diag", async (context, state) => { await state.load(context, storage); await context.sendActivity(JSON.stringify(context.activity)); }); -teamsBot.message("/state", async (context, state) => { +agentApp.onMessage("/state", async (context, state) => { await state.load(context, storage); await context.sendActivity(JSON.stringify(state)); }); -teamsBot.message("/runtime", async (context, state) => { +agentApp.onMessage("/runtime", async (context, state) => { const runtime = { nodeversion: process.version, sdkversion: version, @@ -44,14 +44,14 @@ teamsBot.message("/runtime", async (context, state) => { await context.sendActivity(JSON.stringify(runtime)); }); -teamsBot.conversationUpdate("membersAdded", async (context, state) => { +agentApp.onConversationUpdate("membersAdded", async (context, state) => { await context.sendActivity( `Hi there! I'm an echo bot running on Agents SDK version ${version} that will echo what you said to me.` ); }); // Listen for ANY message to be received. MUST BE AFTER ANY OTHER MESSAGE HANDLERS -teamsBot.activity(ActivityTypes.Message, async (context, state) => { +agentApp.onActivity(ActivityTypes.Message, async (context, state) => { // Increment count state let count = state.conversation.count ?? 0; state.conversation.count = ++count; @@ -60,15 +60,15 @@ teamsBot.activity(ActivityTypes.Message, async (context, state) => { await context.sendActivity(`[${count}] you said: ${context.activity.text}`); }); -teamsBot.activity(/^message/, async (context, state) => { +agentApp.onActivity(/^message/, async (context, state) => { await context.sendActivity(`Matched with regex: ${context.activity.type}`); }); -teamsBot.activity( +agentApp.onActivity( async (context) => Promise.resolve(context.activity.type === "message"), async (context, state) => { await context.sendActivity(`Matched function: ${context.activity.type}`); } ); -module.exports.teamsBot = teamsBot; +module.exports.agentApp = agentApp; diff --git a/templates/vsc/js/weather-agent/infra/azure.bicep.tpl b/templates/vsc/js/weather-agent/infra/azure.bicep.tpl index 6adb2e7b4a4..41aad4d240f 100644 --- a/templates/vsc/js/weather-agent/infra/azure.bicep.tpl +++ b/templates/vsc/js/weather-agent/infra/azure.bicep.tpl @@ -60,7 +60,7 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = { } { name: 'WEBSITE_NODE_DEFAULT_VERSION' - value: '~18' // Set NodeJS version to 18.x for your site + value: '~22' // Set NodeJS version to 22.x for your site } { name: 'RUNNING_ON_AZURE' diff --git a/templates/vsc/js/weather-agent/package.json.tpl b/templates/vsc/js/weather-agent/package.json.tpl index f22f749bb48..ba70f059c23 100644 --- a/templates/vsc/js/weather-agent/package.json.tpl +++ b/templates/vsc/js/weather-agent/package.json.tpl @@ -28,13 +28,11 @@ "@azure/openai": "^2.0.0", "@langchain/langgraph": "^0.2.66", "@langchain/openai": "^0.5.6", - "@microsoft/agents-hosting": "^0.2.14", - "express": "^5.0.1", - "zod": "3.25.67" + "@microsoft/agents-hosting-express": "^1.0.0" }, "devDependencies": { "env-cmd": "^10.1.0", - "nodemon": "^3.1.7", + "nodemon": "^3.1.10", "shx": "^0.3.3" }, "overrides": { diff --git a/templates/vsc/js/weather-agent/src/agent.js.tpl b/templates/vsc/js/weather-agent/src/agent.js.tpl index 7d98ae322a9..83488fbb986 100644 --- a/templates/vsc/js/weather-agent/src/agent.js.tpl +++ b/templates/vsc/js/weather-agent/src/agent.js.tpl @@ -9,7 +9,7 @@ const { getWeatherTool } = require("./tools/getWeatherTool"); const weatherAgent = new AgentApplicationBuilder().build(); -weatherAgent.conversationUpdate( +weatherAgent.onConversationUpdate( "membersAdded", async (context) => { await context.sendActivity( @@ -55,7 +55,7 @@ Respond in JSON format with the following JSON schema, and do not use markdown i "content": "{The content of the response, may be plain text, or JSON based adaptive card}" }`); -weatherAgent.activity(ActivityTypes.Message, async (context, state) => { +weatherAgent.onActivity(ActivityTypes.Message, async (context, state) => { const llmResponse = await agent.invoke( { messages: [sysMessage, new HumanMessage(context.activity.text)], diff --git a/templates/vsc/js/weather-agent/src/index.js b/templates/vsc/js/weather-agent/src/index.js index 7516fc31c03..f207d9712d4 100644 --- a/templates/vsc/js/weather-agent/src/index.js +++ b/templates/vsc/js/weather-agent/src/index.js @@ -1,29 +1,4 @@ -// Import required packages -const { authorizeJWT, CloudAdapter, loadAuthConfigFromEnv } = require("@microsoft/agents-hosting"); -const express = require("express"); -// This bot's main dialog. -const { weatherAgent } = require("./agent"); - -// Create authentication configuration -const authConfig = loadAuthConfigFromEnv(); -const adapter = new CloudAdapter(authConfig); - -// Create express application. -const server = express(); -server.use(express.json()); -server.use(authorizeJWT(authConfig)); - -// Listen for incoming requests. -server.post("/api/messages", async (req, res) => { - await adapter.process(req, res, async (context) => { - await weatherAgent.run(context); - }); -}); - -const port = process.env.port || process.env.PORT || 3978; -server.listen(port, () => { - console.log( - `\nServer listening to port ${port} for appId ${authConfig.clientId} debug ${process.env.DEBUG}` - ); -}); +const { startServer } = require("@microsoft/agents-hosting-express"); +const { agentApp } = require("./teamsBot"); +startServer(agentApp) diff --git a/templates/vsc/ts/basic-custom-engine-agent/infra/azure.bicep.tpl b/templates/vsc/ts/basic-custom-engine-agent/infra/azure.bicep.tpl index 6adb2e7b4a4..41aad4d240f 100644 --- a/templates/vsc/ts/basic-custom-engine-agent/infra/azure.bicep.tpl +++ b/templates/vsc/ts/basic-custom-engine-agent/infra/azure.bicep.tpl @@ -60,7 +60,7 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = { } { name: 'WEBSITE_NODE_DEFAULT_VERSION' - value: '~18' // Set NodeJS version to 18.x for your site + value: '~22' // Set NodeJS version to 22.x for your site } { name: 'RUNNING_ON_AZURE' diff --git a/templates/vsc/ts/basic-custom-engine-agent/package.json.tpl b/templates/vsc/ts/basic-custom-engine-agent/package.json.tpl index c12fa9533c1..d669c1d0e5e 100644 --- a/templates/vsc/ts/basic-custom-engine-agent/package.json.tpl +++ b/templates/vsc/ts/basic-custom-engine-agent/package.json.tpl @@ -28,17 +28,16 @@ "dependencies": { "@azure/identity": "^4.8.0", "@azure/openai": "^2.0.0", - "@microsoft/agents-hosting": "^0.2.14", - "express": "^5.0.1", + "@microsoft/agents-hosting-express": "^1.0.0", "openai": "^4.94.0" }, "devDependencies": { "@types/express": "^5.0.0", - "@types/node": "^18.0.0", + "@types/node": "^22.0.0", "env-cmd": "^10.1.0", - "nodemon": "^3.1.7", + "nodemon": "^3.1.10", "shx": "^0.3.3", - "ts-node": "^10.4.0", - "typescript": "^5.5.4" + "ts-node": "^10.9.2", + "typescript": "^5.8.3" } } \ No newline at end of file diff --git a/templates/vsc/ts/basic-custom-engine-agent/src/adapter.ts b/templates/vsc/ts/basic-custom-engine-agent/src/adapter.ts deleted file mode 100644 index 5ac047072c8..00000000000 --- a/templates/vsc/ts/basic-custom-engine-agent/src/adapter.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { AuthConfiguration, CloudAdapter, loadAuthConfigFromEnv } from "@microsoft/agents-hosting"; - -// Create authentication configuration -const authConfig: AuthConfiguration = loadAuthConfigFromEnv(); - -// Create adapter -const adapter = new CloudAdapter(authConfig); - -// Catch-all for errors. -const onTurnErrorHandler = async (context, error) => { - // This check writes out errors to console log .vs. app insights. - // NOTE: In production environment, you should consider logging this to Azure - // application insights. - console.error(`\n [onTurnError] unhandled error: ${error}`); - - // Only send error message for user messages, not for other message types so the agent doesn't spam a channel or chat. - if (context.activity.type === "message") { - // Send a trace activity, which will be displayed in Bot Framework Emulator - await context.sendTraceActivity( - "OnTurnError Trace", - `${error}`, - "https://www.botframework.com/schemas/error", - "TurnError" - ); - - // Send a message to the user - await context.sendActivity("The agent encountered an error or bug."); - await context.sendActivity("To continue to run this agent, please fix the agent source code."); - } -}; - -// Set the onTurnError for the singleton TeamsAdapter. -adapter.onTurnError = onTurnErrorHandler; - -export default adapter; diff --git a/templates/vsc/ts/basic-custom-engine-agent/src/agent.ts.tpl b/templates/vsc/ts/basic-custom-engine-agent/src/agent.ts.tpl index ad156c02a34..8082e531702 100644 --- a/templates/vsc/ts/basic-custom-engine-agent/src/agent.ts.tpl +++ b/templates/vsc/ts/basic-custom-engine-agent/src/agent.ts.tpl @@ -24,12 +24,12 @@ export const agentApp = new AgentApplication({ storage, }); -agentApp.conversationUpdate("membersAdded", async (context: TurnContext) => { +agentApp.onConversationUpdate("membersAdded", async (context: TurnContext) => { await context.sendActivity(`Hi there! I'm an agent to chat with you.`); }); // Listen for ANY message to be received. MUST BE AFTER ANY OTHER MESSAGE HANDLERS -agentApp.activity(ActivityTypes.Message, async (context: TurnContext) => { +agentApp.onActivity(ActivityTypes.Message, async (context: TurnContext) => { // Echo back users request const result = await client.chat.completions.create({ messages: [ diff --git a/templates/vsc/ts/basic-custom-engine-agent/src/index.ts b/templates/vsc/ts/basic-custom-engine-agent/src/index.ts index b4f56d57485..7c9e7be279e 100644 --- a/templates/vsc/ts/basic-custom-engine-agent/src/index.ts +++ b/templates/vsc/ts/basic-custom-engine-agent/src/index.ts @@ -1,33 +1,3 @@ -// Import required packages -import { - AuthConfiguration, - authorizeJWT, - loadAuthConfigFromEnv, - Request, -} from "@microsoft/agents-hosting"; -import express, { Response } from "express"; - -// This bot's adapter -import adapter from "./adapter"; - -// This bot's main dialog. +import { startServer } from "@microsoft/agents-hosting-express"; import { agentApp } from "./agent"; - -// Create authentication configuration -const authConfig: AuthConfiguration = loadAuthConfigFromEnv(); - -// Create express application. -const expressApp = express(); -expressApp.use(express.json()); -expressApp.use(authorizeJWT(authConfig)); - -const server = expressApp.listen(process.env.port || process.env.PORT || 3978, () => { - console.log(`\nAgent started, ${expressApp.name} listening to`, server.address()); -}); - -// Listen for incoming requests. -expressApp.post("/api/messages", async (req: Request, res: Response) => { - await adapter.process(req, res, async (context) => { - await agentApp.run(context); - }); -}); +startServer(agentApp) \ No newline at end of file diff --git a/templates/vsc/ts/default-bot/teamsBot.ts b/templates/vsc/ts/default-bot/agent.ts similarity index 76% rename from templates/vsc/ts/default-bot/teamsBot.ts rename to templates/vsc/ts/default-bot/agent.ts index 63a14fd1bf5..0845419801d 100644 --- a/templates/vsc/ts/default-bot/teamsBot.ts +++ b/templates/vsc/ts/default-bot/agent.ts @@ -17,33 +17,33 @@ const downloader = new AttachmentDownloader(); // Define storage and application const storage = new MemoryStorage(); -export const teamsBot = new AgentApplication({ +export const agentApp = new AgentApplication({ storage, fileDownloaders: [downloader], }); // Listen for user to say '/reset' and then delete conversation state -teamsBot.message("/reset", async (context: TurnContext, state: ApplicationTurnState) => { +agentApp.onMessage("/reset", async (context: TurnContext, state: ApplicationTurnState) => { state.deleteConversationState(); await context.sendActivity("Ok I've deleted the current conversation state."); }); -teamsBot.message("/count", async (context: TurnContext, state: ApplicationTurnState) => { +agentApp.onMessage("/count", async (context: TurnContext, state: ApplicationTurnState) => { const count = state.conversation.count ?? 0; await context.sendActivity(`The count is ${count}`); }); -teamsBot.message("/diag", async (context: TurnContext, state: ApplicationTurnState) => { +agentApp.onMessage("/diag", async (context: TurnContext, state: ApplicationTurnState) => { await state.load(context, storage); await context.sendActivity(JSON.stringify(context.activity)); }); -teamsBot.message("/state", async (context: TurnContext, state: ApplicationTurnState) => { +agentApp.onMessage("/state", async (context: TurnContext, state: ApplicationTurnState) => { await state.load(context, storage); await context.sendActivity(JSON.stringify(state)); }); -teamsBot.message("/runtime", async (context: TurnContext, state: ApplicationTurnState) => { +agentApp.onMessage("/runtime", async (context: TurnContext, state: ApplicationTurnState) => { const runtime = { nodeversion: process.version, sdkversion: version, @@ -51,7 +51,7 @@ teamsBot.message("/runtime", async (context: TurnContext, state: ApplicationTurn await context.sendActivity(JSON.stringify(runtime)); }); -teamsBot.conversationUpdate( +agentApp.onConversationUpdate( "membersAdded", async (context: TurnContext, state: ApplicationTurnState) => { await context.sendActivity( @@ -61,7 +61,7 @@ teamsBot.conversationUpdate( ); // Listen for ANY message to be received. MUST BE AFTER ANY OTHER MESSAGE HANDLERS -teamsBot.activity( +agentApp.onActivity( ActivityTypes.Message, async (context: TurnContext, state: ApplicationTurnState) => { // Increment count state @@ -73,11 +73,11 @@ teamsBot.activity( } ); -teamsBot.activity(/^message/, async (context: TurnContext, state: ApplicationTurnState) => { +agentApp.onActivity(/^message/, async (context: TurnContext, state: ApplicationTurnState) => { await context.sendActivity(`Matched with regex: ${context.activity.type}`); }); -teamsBot.activity( +agentApp.onActivity( async (context: TurnContext) => Promise.resolve(context.activity.type === "message"), async (context, state) => { await context.sendActivity(`Matched function: ${context.activity.type}`); diff --git a/templates/vsc/ts/default-bot/index.ts b/templates/vsc/ts/default-bot/index.ts index c1427a9e0c7..7c9e7be279e 100644 --- a/templates/vsc/ts/default-bot/index.ts +++ b/templates/vsc/ts/default-bot/index.ts @@ -1,68 +1,3 @@ -import { - AuthConfiguration, - authorizeJWT, - CloudAdapter, - loadAuthConfigFromEnv, - Request, - TurnContext, -} from "@microsoft/agents-hosting"; -import express, { Response } from "express"; - -import { teamsBot } from "./teamsBot"; - -// Create authentication configuration -const authConfig: AuthConfiguration = loadAuthConfigFromEnv(); - -// Create adapter -const adapter = new CloudAdapter(authConfig); - -// Catch-all for errors. -const onTurnErrorHandler = async (context: TurnContext, error: Error) => { - // This check writes out errors to console log .vs. app insights. - // NOTE: In production environment, you should consider logging this to Azure - // application insights. - console.error(`\n [onTurnError] unhandled error: ${error}`); - - // Only send error message for user messages, not for other message types so the bot doesn't spam a channel or chat. - if (context.activity.type === "message") { - // Send a trace activity - await context.sendTraceActivity( - "OnTurnError Trace", - `${error}`, - "https://www.botframework.com/schemas/error", - "TurnError" - ); - - // Send a message to the user - await context.sendActivity(`The bot encountered unhandled error:\n ${error.message}`); - await context.sendActivity("To continue to run this bot, please fix the bot source code."); - } -}; - -// Set the onTurnError for the singleton CloudAdapter. -adapter.onTurnError = onTurnErrorHandler; - -// Create express application -const server = express(); -server.use(express.json()); -server.use(authorizeJWT(authConfig)); - -// Listen for incoming requests. -server.post("/api/messages", async (req: Request, res: Response) => { - await adapter.process(req, res, async (context) => { - await teamsBot.run(context); - }); -}); - -// Start the server -const port = process.env.PORT || 3978; -server - .listen(port, () => { - console.log( - `Bot Started, listening to port ${port} for appId ${authConfig.clientId} debug ${process.env.DEBUG}` - ); - }) - .on("error", (err) => { - console.error(err); - process.exit(1); - }); +import { startServer } from "@microsoft/agents-hosting-express"; +import { agentApp } from "./agent"; +startServer(agentApp) \ No newline at end of file diff --git a/templates/vsc/ts/default-bot/infra/azure.bicep b/templates/vsc/ts/default-bot/infra/azure.bicep index 3999e8c3a86..d883f5ce16f 100644 --- a/templates/vsc/ts/default-bot/infra/azure.bicep +++ b/templates/vsc/ts/default-bot/infra/azure.bicep @@ -45,7 +45,7 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = { } { name: 'WEBSITE_NODE_DEFAULT_VERSION' - value: '~18' // Set NodeJS version to 18.x for your site + value: '~22' // Set NodeJS version to 22.x for your site } { name: 'RUNNING_ON_AZURE' diff --git a/templates/vsc/ts/default-bot/package.json.tpl b/templates/vsc/ts/default-bot/package.json.tpl index 05a14501a6c..5d2af322e2d 100644 --- a/templates/vsc/ts/default-bot/package.json.tpl +++ b/templates/vsc/ts/default-bot/package.json.tpl @@ -23,16 +23,15 @@ "url": "https://github.com" }, "dependencies": { - "@microsoft/agents-hosting": "^0.2.14", - "express": "^5.0.1" + "@microsoft/agents-hosting-express": "^1.0.0" }, - "devDependencies": { + "devvDependencies": { "@types/express": "^5.0.0", - "@types/node": "^18.0.0", + "@types/node": "^22.0.0", "env-cmd": "^10.1.0", - "nodemon": "^3.1.7", + "nodemon": "^3.1.10", "shx": "^0.3.3", - "ts-node": "^10.4.0", - "typescript": "^4.4.4" + "ts-node": "^10.9.2", + "typescript": "^5.8.3" } } diff --git a/templates/vsc/ts/weather-agent/infra/azure.bicep.tpl b/templates/vsc/ts/weather-agent/infra/azure.bicep.tpl index 6adb2e7b4a4..41aad4d240f 100644 --- a/templates/vsc/ts/weather-agent/infra/azure.bicep.tpl +++ b/templates/vsc/ts/weather-agent/infra/azure.bicep.tpl @@ -60,7 +60,7 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = { } { name: 'WEBSITE_NODE_DEFAULT_VERSION' - value: '~18' // Set NodeJS version to 18.x for your site + value: '~22' // Set NodeJS version to 22.x for your site } { name: 'RUNNING_ON_AZURE' diff --git a/templates/vsc/ts/weather-agent/package.json.tpl b/templates/vsc/ts/weather-agent/package.json.tpl index d2fd9f2b9a6..9cdda2652b1 100644 --- a/templates/vsc/ts/weather-agent/package.json.tpl +++ b/templates/vsc/ts/weather-agent/package.json.tpl @@ -29,18 +29,16 @@ "@azure/openai": "^2.0.0", "@langchain/langgraph": "^0.2.66", "@langchain/openai": "^0.5.6", - "@microsoft/agents-hosting": "^0.2.14", - "express": "^5.0.1", - "zod": "3.25.67" + "@microsoft/agents-hosting-express": "^1.0.0" }, "devDependencies": { "@types/express": "^5.0.0", - "@types/node": "^18.0.0", + "@types/node": "^22.0.0", "env-cmd": "^10.1.0", - "nodemon": "^3.1.7", + "nodemon": "^3.1.10", "shx": "^0.3.3", - "ts-node": "^10.4.0", - "typescript": "^5.5.4" + "ts-node": "^10.9.2", + "typescript": "^5.8.3" }, "overrides": { "**": { diff --git a/templates/vsc/ts/weather-agent/src/agent.ts.tpl b/templates/vsc/ts/weather-agent/src/agent.ts.tpl index fe01280c35d..d6fadc8ffaf 100644 --- a/templates/vsc/ts/weather-agent/src/agent.ts.tpl +++ b/templates/vsc/ts/weather-agent/src/agent.ts.tpl @@ -13,7 +13,7 @@ import { getWeatherTool } from "./tools/getWeatherTool"; export const weatherAgent = new AgentApplicationBuilder().build(); -weatherAgent.conversationUpdate( +weatherAgent.onConversationUpdate( "membersAdded", async (context: TurnContext) => { await context.sendActivity( @@ -64,7 +64,7 @@ Respond in JSON format with the following JSON schema, and do not use markdown i "content": "{The content of the response, may be plain text, or JSON based adaptive card}" }`); -weatherAgent.activity(ActivityTypes.Message, async (context, state) => { +weatherAgent.onActivity(ActivityTypes.Message, async (context, state) => { const llmResponse = await agent.invoke( { messages: [sysMessage, new HumanMessage(context.activity.text!)], diff --git a/templates/vsc/ts/weather-agent/src/index.ts b/templates/vsc/ts/weather-agent/src/index.ts index 876aa2ece49..1b647cb1ccc 100644 --- a/templates/vsc/ts/weather-agent/src/index.ts +++ b/templates/vsc/ts/weather-agent/src/index.ts @@ -1,35 +1,3 @@ -// Import required packages -import { - AuthConfiguration, - authorizeJWT, - CloudAdapter, - loadAuthConfigFromEnv, - Request, -} from "@microsoft/agents-hosting"; -import express, { Response } from "express"; - -// This bot's main dialog. +import { startServer } from "@microsoft/agents-hosting-express"; import { weatherAgent } from "./agent"; - -// Create authentication configuration -const authConfig: AuthConfiguration = loadAuthConfigFromEnv(); -const adapter = new CloudAdapter(authConfig); - -// Create express application. -const server = express(); -server.use(express.json()); -server.use(authorizeJWT(authConfig)); - -// Listen for incoming requests. -server.post("/api/messages", async (req: Request, res: Response) => { - await adapter.process(req, res, async (context) => { - await weatherAgent.run(context); - }); -}); - -const port = process.env.port || process.env.PORT || 3978; -server.listen(port, () => { - console.log( - `\nServer listening to port ${port} for appId ${authConfig.clientId} debug ${process.env.DEBUG}` - ); -}); +startServer(weatherAgent) \ No newline at end of file From aa91d6b65be03e739142c0a83cbd6e312d274916 Mon Sep 17 00:00:00 2001 From: Rido Date: Wed, 30 Jul 2025 17:42:25 +0000 Subject: [PATCH 3/6] rm templ-deps doc --- docs/template-dependency-analysis.md | 240 --------------------------- 1 file changed, 240 deletions(-) delete mode 100644 docs/template-dependency-analysis.md diff --git a/docs/template-dependency-analysis.md b/docs/template-dependency-analysis.md deleted file mode 100644 index 915c7b0a64a..00000000000 --- a/docs/template-dependency-analysis.md +++ /dev/null @@ -1,240 +0,0 @@ -# Microsoft 365 Agents Toolkit - Template Dependency Analysis - -**Analysis Date:** July 28, 2025 -**Repository:** microsoft-365-agents-toolkit -**Directory Analyzed:** `templates/vsc/js/` - -## Overview - -This document provides a comprehensive analysis of all JavaScript templates in the Microsoft 365 Agents Toolkit, focusing on their dependencies and architectural patterns. The analysis reveals three distinct approaches to building Microsoft 365 applications within the toolkit. - -## Template Categories - -### 1. Microsoft Agents SDK Templates -Templates using the new `@microsoft/agents-*` packages represent the latest approach to building Microsoft 365 applications. - -### 2. Teams AI Library Templates -Templates using `@microsoft/teams-ai` for AI-powered bots and copilots. - -### 3. Other Framework Templates -Templates using Azure Functions, React, or other specialized frameworks. - ---- - - - -## Detailed Analysis by Framework - -### Microsoft Agents SDK Templates (11 templates) - -The newest approach using `@microsoft/agents-*` packages: - -#### Core Microsoft Agents SDK Templates -| Template | Hosting Packages | Specialized Dependencies | -|----------|------------------|-------------------------| -| **basic-custom-engine-agent** | `@microsoft/agents-hosting` ^0.2.14 | `@azure/identity` ^4.8.0, `@azure/openai` ^2.0.0, `openai` ^4.94.0 | -| **default-bot** | `@microsoft/agents-hosting` ^0.2.14 | None (minimal bot) | -| **weather-agent** | `@microsoft/agents-hosting` ^0.2.14 | `@langchain/langgraph` ^0.2.66, `@azure/openai` ^2.0.0, `zod` 3.25.67 | - -#### Message Extension Templates (Microsoft Agents SDK) -| Template | Dependencies | -|----------|-------------| -| **link-unfurling** | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14 | -| **m365-message-extension** | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14, `adaptivecards` ^3.0.1 | -| **message-extension** | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14, `isomorphic-fetch` ^3.0.0 | -| **message-extension-action** | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14, `adaptivecards` ^3.0.1 | - -#### Notification Templates (Microsoft Agents SDK) -All notification templates use version ^0.4.3 of the hosting packages: - -| Template | Trigger Type | Dependencies | -|----------|-------------|-------------| -| **notification-express** | HTTP (Express) | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-hosting-teams` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | -| **notification-http-timer-trigger** | HTTP + Timer (Azure Functions) | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-hosting-teams` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | -| **notification-http-trigger** | HTTP (Azure Functions) | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-hosting-teams` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | -| **notification-timer-trigger** | Timer (Azure Functions) | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-hosting-teams` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | - -**Key Observations:** -- Notification templates use newer versions (^0.4.3) compared to other Agents SDK templates (^0.2.14) -- All include `@microsoft/agents-activity` for activity handling -- Express-based vs Azure Functions-based hosting options - ---- - -### Teams AI Library Templates (9 templates) - -Templates using `@microsoft/teams-ai` for AI-powered functionality: - -#### Version Distribution -| Version | Templates | Notes | -|---------|-----------|-------| -| **^1.7.0** | command-and-response, workflow | Latest version | -| **^1.6.1** | custom-copilot-assistant-assistants-api | Pinned version (~1.6.1) | -| **^1.5.3** | custom-copilot-assistant-new, custom-copilot-basic, custom-copilot-rag-azure-ai-search, custom-copilot-rag-customize, custom-copilot-rag-microsoft365 | Most common version | -| **^1.1.0** | custom-copilot-rag-custom-api | Oldest version | - -#### AI Assistant Templates -| Template | Teams AI Version | Specialization | -|----------|------------------|----------------| -| **custom-copilot-assistant-assistants-api** | ~1.6.1 | OpenAI Assistants API integration | -| **custom-copilot-assistant-new** | ^1.5.3 | General AI assistant | -| **custom-copilot-basic** | ^1.5.3 | Basic AI chat functionality | - -#### RAG (Retrieval-Augmented Generation) Templates -| Template | Teams AI Version | Data Source | Additional Dependencies | -|----------|------------------|-------------|------------------------| -| **custom-copilot-rag-azure-ai-search** | ^1.5.3 | Azure AI Search | `@azure/search-documents` ^12.0.0 | -| **custom-copilot-rag-custom-api** | ^1.1.0 | Custom API | `openapi-client-axios` ^7.4.0, `js-yaml` ^4.1.0 | -| **custom-copilot-rag-customize** | ^1.5.3 | Custom data source | `@azure/search-documents` ^12.0.0 | -| **custom-copilot-rag-microsoft365** | ^1.5.3 | Microsoft 365 data | `@microsoft/microsoft-graph-client` ^3.0.1, `@azure/search-documents` ^12.0.0 | - -#### Bot Framework Templates -| Template | Teams AI Version | Purpose | -|----------|------------------|---------| -| **command-and-response** | ^1.7.0 | Command handling bot | -| **workflow** | ^1.7.0 | Workflow automation bot | - -**Common Dependencies:** -- All Teams AI templates use `botbuilder` ^4.23.1 -- Most use `express` ^5.0.1 -- Adaptive Cards templates include `adaptivecards-templating` ^2.3.1 - ---- - -## Complete Template Inventory - -| Template Name | Primary Framework | Key Dependencies | -|---------------|-------------------|------------------| -| **basic-custom-engine-agent** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@azure/identity` ^4.8.0, `@azure/openai` ^2.0.0, `openai` ^4.94.0 | -| **command-and-response** | Teams AI Library | `@microsoft/teams-ai` ^1.7.0, `botbuilder` ^4.23.1, `adaptive-expressions` ^4.23.1 | -| **custom-copilot-assistant-assistants-api** | Teams AI Library | `@microsoft/teams-ai` ~1.6.1, `botbuilder` ^4.23.1 | -| **custom-copilot-assistant-new** | Teams AI Library | `@microsoft/teams-ai` ^1.5.3, `botbuilder` ^4.23.1 | -| **custom-copilot-basic** | Teams AI Library | `@microsoft/teams-ai` ^1.5.3, `botbuilder` ^4.23.1 | -| **custom-copilot-rag-azure-ai-search** | Teams AI Library | `@microsoft/teams-ai` ^1.5.3, `@azure/search-documents` ^12.0.0, `botbuilder` ^4.23.1 | -| **custom-copilot-rag-custom-api** | Teams AI Library | `@microsoft/teams-ai` ^1.1.0, `botbuilder` ^4.23.1, `openapi-client-axios` ^7.4.0 | -| **custom-copilot-rag-customize** | Teams AI Library | `@microsoft/teams-ai` ^1.5.3, `@azure/search-documents` ^12.0.0, `botbuilder` ^4.23.1 | -| **custom-copilot-rag-microsoft365** | Teams AI Library | `@microsoft/teams-ai` ^1.5.3, `@microsoft/microsoft-graph-client` ^3.0.1, `@azure/search-documents` ^12.0.0 | -| **dashboard-tab** | React/Vite | `@fluentui/react-components` ^9.55.1, `@microsoft/teams-js` ^2.31.1, `react` ^18.2.0 | -| **declarative-agent-with-action-from-scratch** | Azure Functions | `@azure/functions` ^4.3.0 | -| **declarative-agent-with-action-from-scratch-bearer** | Azure Functions | `@azure/functions` ^4.3.0 | -| **declarative-agent-with-action-from-scratch-oauth** | Azure Functions | `@azure/functions` ^4.3.0, `jsonwebtoken` ^9.0.2, `jwks-rsa` ^3.1.0 | -| **default-bot** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14 | -| **default-bot-message-extension** | Bot Builder | `botbuilder` ^4.23.1, `adaptivecards` ^3.0.1 | -| **link-unfurling** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14 | -| **m365-message-extension** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14 | -| **message-extension** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14 | -| **message-extension-action** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@microsoft/agents-hosting-teams` ^0.2.14 | -| **message-extension-with-api-from-scratch** | Azure Functions | `@azure/functions` ^4.3.0 | -| **message-extension-with-api-from-scratch-api-key** | Azure Functions | `@azure/functions` ^4.3.0 | -| **message-extension-with-api-from-scratch-sso** | Azure Functions | `@azure/functions` ^4.3.0, `jsonwebtoken` ^9.0.2, `jwks-rsa` ^3.1.0 | -| **non-sso-tab** | Express Static | `express` ^4.21.1, `send` ^0.18.0 | -| **non-sso-tab-default-bot** | Multi-component | `concurrently` ^7.6.0 (separate bot and tab packages) | -| **notification-express** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | -| **notification-http-timer-trigger** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | -| **notification-http-trigger** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | -| **notification-timer-trigger** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.4.3, `@microsoft/agents-activity` ^0.4.3 | -| **sso-tab-naa** | React/Vite | `@azure/msal-browser` ^4.12.0, `@microsoft/teams-js` ^2.31.1, `react` ^18.2.0 | -| **weather-agent** | Microsoft Agents SDK | `@microsoft/agents-hosting` ^0.2.14, `@langchain/langgraph` ^0.2.66, `@azure/openai` ^2.0.0 | -| **workflow** | Teams AI Library | `@microsoft/teams-ai` ^1.7.0, `botbuilder` ^4.23.1, `adaptive-expressions` ^4.23.1 | - ---- - -### Other Framework Templates (12 templates) - -#### Legacy/Bot Builder Templates (3 templates) -| Template | Framework | Purpose | -|----------|-----------|---------| -| **default-bot-message-extension** | Bot Builder v4 | Message extension with traditional Bot Framework | -| **non-sso-tab-default-bot** | Multi-component | Combination of tab and bot in separate packages | - -**Note:** Office add-in templates (`office-json-addin`, `office-xml-addin-*`) don't have `package.json.tpl` files and likely use different templating mechanisms. - ---- - -## Architecture Patterns - -### 1. Microsoft Agents SDK Pattern -- **Hosting:** `@microsoft/agents-hosting` + `@microsoft/agents-hosting-teams` -- **Activity Management:** `@microsoft/agents-activity` (for notifications) -- **Benefits:** Streamlined development, built-in Teams integration -- **Use Cases:** Modern Microsoft 365 applications, message extensions, notifications - -### 2. Teams AI Library Pattern -- **Core:** `@microsoft/teams-ai` + `botbuilder` -- **AI Integration:** Built-in AI orchestration and prompt management -- **Benefits:** Advanced AI capabilities, RAG support, conversation management -- **Use Cases:** AI-powered bots, copilots, intelligent assistants - - -## Version Analysis - -### Microsoft Agents SDK Versions -- **Core templates:** ^0.2.14 -- **Notification templates:** ^0.4.3 (newer) -- **Trend:** Active development with version progression - -### Teams AI Library Versions -- **Latest:** ^1.7.0 (command-and-response, workflow) -- **Stable:** ^1.5.3 (most copilot templates) -- **Legacy:** ^1.1.0 (custom-copilot-rag-custom-api) -- **Trend:** Most templates are on recent stable versions - -### Common Dependencies -- **Express:** Ranges from ^4.21.1 to ^5.0.1 -- **Bot Builder:** Consistently ^4.23.1 -- **Adaptive Cards:** ^3.0.1 to ^3.0.5 -- **Node.js:** All templates support "18 || 20 || 22" - ---- - -## Development Patterns - -### Script Patterns -Common across most templates: -```json -{ - "dev:teamsfx": "env-cmd --silent -f .localConfigs npm run dev", - "dev:teamsfx:testtool": "env-cmd --silent -f .localConfigs.playground npm run dev", - "dev:teamsfx:launch-testtool": "env-cmd --silent -f env/.env.playground teamsapptester start" -} -``` - -### Development Dependencies -Standard across templates: -- `env-cmd` ^10.1.0 (environment configuration) -- `nodemon` ^3.1.7 (development server) -- `concurrently` (for multi-component templates) - ---- - -## Recommendations - -### For New Projects -1. **Choose Microsoft Agents SDK** for new Microsoft 365 applications -2. **Use Teams AI Library** for AI-powered conversational experiences -3. **Consider Azure Functions** for lightweight API backends -4. **Use React patterns** for rich interactive tabs - -### Migration Considerations -- **From Bot Builder:** Consider Teams AI Library for AI features -- **To Agents SDK:** Evaluate benefits of streamlined hosting -- **Version Updates:** Keep AI Library templates on latest versions - -### Architecture Decision Factors -- **Complexity:** Agents SDK for simple, Functions for minimal -- **AI Requirements:** Teams AI Library for advanced AI features -- **UI Needs:** React patterns for rich interfaces -- **Hosting Preferences:** Express vs Azure Functions vs Agents hosting - ---- - -## Conclusion - -The Microsoft 365 Agents Toolkit demonstrates a strategic evolution in development approaches: - -1. **Microsoft Agents SDK** represents the future direction for Microsoft 365 application development -2. **Teams AI Library** provides sophisticated AI capabilities for conversational experiences -3. **Azure Functions** offers lightweight, serverless options for API development -4. **React/Tab templates** enable rich, modern user interfaces - -The diversity of templates allows developers to choose the most appropriate technology stack based on their specific requirements, while the consistent patterns across templates ensure a cohesive development experience. From f0581efb9bc1c110629c914b5aa8d68437f55ff8 Mon Sep 17 00:00:00 2001 From: Rido Date: Wed, 30 Jul 2025 18:04:19 +0000 Subject: [PATCH 4/6] fix: lint issues --- templates/vsc/js/basic-custom-engine-agent/src/index.js | 2 +- templates/vsc/js/default-bot/index.js | 3 +-- templates/vsc/js/weather-agent/src/index.js | 3 +-- templates/vsc/ts/basic-custom-engine-agent/src/index.ts | 2 +- templates/vsc/ts/default-bot/index.ts | 2 +- templates/vsc/ts/weather-agent/src/index.ts | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/templates/vsc/js/basic-custom-engine-agent/src/index.js b/templates/vsc/js/basic-custom-engine-agent/src/index.js index c0ea65349bf..ae654c4d5c9 100644 --- a/templates/vsc/js/basic-custom-engine-agent/src/index.js +++ b/templates/vsc/js/basic-custom-engine-agent/src/index.js @@ -1,3 +1,3 @@ const { startServer } = require("@microsoft/agents-hosting-express"); const { agentApp } = require("./agent"); -startServer(agentApp) \ No newline at end of file +startServer(agentApp); diff --git a/templates/vsc/js/default-bot/index.js b/templates/vsc/js/default-bot/index.js index f207d9712d4..b81d80f6ce8 100644 --- a/templates/vsc/js/default-bot/index.js +++ b/templates/vsc/js/default-bot/index.js @@ -1,4 +1,3 @@ - const { startServer } = require("@microsoft/agents-hosting-express"); const { agentApp } = require("./teamsBot"); -startServer(agentApp) +startServer(agentApp); diff --git a/templates/vsc/js/weather-agent/src/index.js b/templates/vsc/js/weather-agent/src/index.js index f207d9712d4..b81d80f6ce8 100644 --- a/templates/vsc/js/weather-agent/src/index.js +++ b/templates/vsc/js/weather-agent/src/index.js @@ -1,4 +1,3 @@ - const { startServer } = require("@microsoft/agents-hosting-express"); const { agentApp } = require("./teamsBot"); -startServer(agentApp) +startServer(agentApp); diff --git a/templates/vsc/ts/basic-custom-engine-agent/src/index.ts b/templates/vsc/ts/basic-custom-engine-agent/src/index.ts index 7c9e7be279e..25f892be4c0 100644 --- a/templates/vsc/ts/basic-custom-engine-agent/src/index.ts +++ b/templates/vsc/ts/basic-custom-engine-agent/src/index.ts @@ -1,3 +1,3 @@ import { startServer } from "@microsoft/agents-hosting-express"; import { agentApp } from "./agent"; -startServer(agentApp) \ No newline at end of file +startServer(agentApp); diff --git a/templates/vsc/ts/default-bot/index.ts b/templates/vsc/ts/default-bot/index.ts index 7c9e7be279e..25f892be4c0 100644 --- a/templates/vsc/ts/default-bot/index.ts +++ b/templates/vsc/ts/default-bot/index.ts @@ -1,3 +1,3 @@ import { startServer } from "@microsoft/agents-hosting-express"; import { agentApp } from "./agent"; -startServer(agentApp) \ No newline at end of file +startServer(agentApp); diff --git a/templates/vsc/ts/weather-agent/src/index.ts b/templates/vsc/ts/weather-agent/src/index.ts index 1b647cb1ccc..8e57b88f43b 100644 --- a/templates/vsc/ts/weather-agent/src/index.ts +++ b/templates/vsc/ts/weather-agent/src/index.ts @@ -1,3 +1,3 @@ import { startServer } from "@microsoft/agents-hosting-express"; import { weatherAgent } from "./agent"; -startServer(weatherAgent) \ No newline at end of file +startServer(weatherAgent); From 0f8b531e449963fb3be8038190f0a859b31c54d2 Mon Sep 17 00:00:00 2001 From: Rido Date: Thu, 31 Jul 2025 10:10:43 +0000 Subject: [PATCH 5/6] fix: update package.json.tpl overrides for zod dependencies --- templates/vsc/ts/weather-agent/package.json.tpl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/vsc/ts/weather-agent/package.json.tpl b/templates/vsc/ts/weather-agent/package.json.tpl index 9cdda2652b1..05d14040d90 100644 --- a/templates/vsc/ts/weather-agent/package.json.tpl +++ b/templates/vsc/ts/weather-agent/package.json.tpl @@ -41,7 +41,10 @@ "typescript": "^5.8.3" }, "overrides": { - "**": { + "@microsoft/agents-activity": { + "zod": "3.25.67" + }, + "@langchain/core": { "zod": "3.25.67" } } From 68a3a9799e0514bd255dcbe3be2ef599976723da Mon Sep 17 00:00:00 2001 From: Rido Date: Thu, 31 Jul 2025 14:33:32 +0000 Subject: [PATCH 6/6] refactor: review module syntax --- .../vsc/js/basic-custom-engine-agent/package.json.tpl | 3 --- templates/vsc/js/default-bot/{teamsBot.js => agent.js} | 0 templates/vsc/js/default-bot/index.js | 2 +- templates/vsc/js/default-bot/package.json.tpl | 3 --- templates/vsc/js/weather-agent/package.json.tpl | 3 --- templates/vsc/js/weather-agent/src/index.js | 2 +- .../vsc/ts/basic-custom-engine-agent/package.json.tpl | 3 --- templates/vsc/ts/basic-custom-engine-agent/tsconfig.json | 3 ++- templates/vsc/ts/default-bot/agent.ts | 8 ++++---- templates/vsc/ts/default-bot/package.json.tpl | 3 --- templates/vsc/ts/default-bot/tsconfig.json | 4 ++-- templates/vsc/ts/weather-agent/package.json.tpl | 3 --- templates/vsc/ts/weather-agent/tsconfig.json | 3 ++- 13 files changed, 12 insertions(+), 28 deletions(-) rename templates/vsc/js/default-bot/{teamsBot.js => agent.js} (100%) diff --git a/templates/vsc/js/basic-custom-engine-agent/package.json.tpl b/templates/vsc/js/basic-custom-engine-agent/package.json.tpl index 4a1f43608b4..5d5deecf890 100644 --- a/templates/vsc/js/basic-custom-engine-agent/package.json.tpl +++ b/templates/vsc/js/basic-custom-engine-agent/package.json.tpl @@ -5,9 +5,6 @@ "teamsAppId": null }, "description": "Basic Custome Engine Agent with Microsoft 365 Agents SDK", - "engines": { - "node": "18 || 20 || 22" - }, "author": "Microsoft", "license": "MIT", "main": "./src/index.js", diff --git a/templates/vsc/js/default-bot/teamsBot.js b/templates/vsc/js/default-bot/agent.js similarity index 100% rename from templates/vsc/js/default-bot/teamsBot.js rename to templates/vsc/js/default-bot/agent.js diff --git a/templates/vsc/js/default-bot/index.js b/templates/vsc/js/default-bot/index.js index b81d80f6ce8..ae654c4d5c9 100644 --- a/templates/vsc/js/default-bot/index.js +++ b/templates/vsc/js/default-bot/index.js @@ -1,3 +1,3 @@ const { startServer } = require("@microsoft/agents-hosting-express"); -const { agentApp } = require("./teamsBot"); +const { agentApp } = require("./agent"); startServer(agentApp); diff --git a/templates/vsc/js/default-bot/package.json.tpl b/templates/vsc/js/default-bot/package.json.tpl index ee038dc898f..fa7bb843351 100644 --- a/templates/vsc/js/default-bot/package.json.tpl +++ b/templates/vsc/js/default-bot/package.json.tpl @@ -5,9 +5,6 @@ "teamsAppId": null }, "description": "Microsoft 365 Agents Toolkit echo bot sample", - "engines": { - "node": "18 || 20 || 22" - }, "author": "Microsoft", "license": "MIT", "main": "index.js", diff --git a/templates/vsc/js/weather-agent/package.json.tpl b/templates/vsc/js/weather-agent/package.json.tpl index ba70f059c23..e977f6706a4 100644 --- a/templates/vsc/js/weather-agent/package.json.tpl +++ b/templates/vsc/js/weather-agent/package.json.tpl @@ -5,9 +5,6 @@ "teamsAppId": null }, "description": "Weather Agent with Microsoft 365 Agents SDK and LangChain", - "engines": { - "node": "18 || 20 || 22" - }, "author": "Microsoft", "license": "MIT", "main": "./src/index.js", diff --git a/templates/vsc/js/weather-agent/src/index.js b/templates/vsc/js/weather-agent/src/index.js index b81d80f6ce8..ae654c4d5c9 100644 --- a/templates/vsc/js/weather-agent/src/index.js +++ b/templates/vsc/js/weather-agent/src/index.js @@ -1,3 +1,3 @@ const { startServer } = require("@microsoft/agents-hosting-express"); -const { agentApp } = require("./teamsBot"); +const { agentApp } = require("./agent"); startServer(agentApp); diff --git a/templates/vsc/ts/basic-custom-engine-agent/package.json.tpl b/templates/vsc/ts/basic-custom-engine-agent/package.json.tpl index d669c1d0e5e..27cf0f12ebd 100644 --- a/templates/vsc/ts/basic-custom-engine-agent/package.json.tpl +++ b/templates/vsc/ts/basic-custom-engine-agent/package.json.tpl @@ -5,9 +5,6 @@ "teamsAppId": null }, "description": "Basic Custome Engine Agent with Microsoft 365 Agents SDK", - "engines": { - "node": "18 || 20 || 22" - }, "author": "Microsoft", "license": "MIT", "main": "./lib/src/index.js", diff --git a/templates/vsc/ts/basic-custom-engine-agent/tsconfig.json b/templates/vsc/ts/basic-custom-engine-agent/tsconfig.json index a68afb21f72..4a2330fdc68 100644 --- a/templates/vsc/ts/basic-custom-engine-agent/tsconfig.json +++ b/templates/vsc/ts/basic-custom-engine-agent/tsconfig.json @@ -1,8 +1,9 @@ { "compilerOptions": { "declaration": true, - "target": "es2017", + "target": "es2019", "module": "commonjs", + "moduleResolution": "node", "outDir": "./lib", "rootDir": "./", "sourceMap": true, diff --git a/templates/vsc/ts/default-bot/agent.ts b/templates/vsc/ts/default-bot/agent.ts index 0845419801d..15cb160848d 100644 --- a/templates/vsc/ts/default-bot/agent.ts +++ b/templates/vsc/ts/default-bot/agent.ts @@ -6,7 +6,7 @@ import { TurnContext, TurnState, } from "@microsoft/agents-hosting"; -import { version } from "@microsoft/agents-hosting/package.json"; +import pkg from "@microsoft/agents-hosting/package.json"; interface ConversationState { count: number; @@ -43,10 +43,10 @@ agentApp.onMessage("/state", async (context: TurnContext, state: ApplicationTurn await context.sendActivity(JSON.stringify(state)); }); -agentApp.onMessage("/runtime", async (context: TurnContext, state: ApplicationTurnState) => { +agentApp.onMessage("/runtime", async (context: TurnContext) => { const runtime = { nodeversion: process.version, - sdkversion: version, + sdkversion: pkg.version, }; await context.sendActivity(JSON.stringify(runtime)); }); @@ -55,7 +55,7 @@ agentApp.onConversationUpdate( "membersAdded", async (context: TurnContext, state: ApplicationTurnState) => { await context.sendActivity( - `Hi there! I'm an echo bot running on Agents SDK version ${version} that will echo what you said to me.` + `Hi there! I'm an echo bot running on Agents SDK version ${pkg.version} that will echo what you said to me.` ); } ); diff --git a/templates/vsc/ts/default-bot/package.json.tpl b/templates/vsc/ts/default-bot/package.json.tpl index 5d2af322e2d..9d557b48479 100644 --- a/templates/vsc/ts/default-bot/package.json.tpl +++ b/templates/vsc/ts/default-bot/package.json.tpl @@ -2,9 +2,6 @@ "name": "{{SafeProjectNameLowerCase}}", "version": "1.0.0", "description": "Microsoft 365 Agents Toolkit echo bot sample", - "engines": { - "node": "18 || 20 || 22" - }, "author": "Microsoft", "license": "MIT", "main": "./lib/index.js", diff --git a/templates/vsc/ts/default-bot/tsconfig.json b/templates/vsc/ts/default-bot/tsconfig.json index 385a05ba674..852f5750086 100644 --- a/templates/vsc/ts/default-bot/tsconfig.json +++ b/templates/vsc/ts/default-bot/tsconfig.json @@ -1,11 +1,11 @@ { "compilerOptions": { "declaration": true, - "target": "es2017", + "target": "es2019", "module": "commonjs", + "moduleResolution": "node", "outDir": "./lib", "rootDir": "./", - "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/vsc/ts/weather-agent/package.json.tpl b/templates/vsc/ts/weather-agent/package.json.tpl index 05d14040d90..796f395869e 100644 --- a/templates/vsc/ts/weather-agent/package.json.tpl +++ b/templates/vsc/ts/weather-agent/package.json.tpl @@ -5,9 +5,6 @@ "teamsAppId": null }, "description": "Weather Agent with Microsoft 365 Agents SDK and LangChain", - "engines": { - "node": "18 || 20 || 22" - }, "author": "Microsoft", "license": "MIT", "main": "./lib/src/index.js", diff --git a/templates/vsc/ts/weather-agent/tsconfig.json b/templates/vsc/ts/weather-agent/tsconfig.json index a68afb21f72..4a2330fdc68 100644 --- a/templates/vsc/ts/weather-agent/tsconfig.json +++ b/templates/vsc/ts/weather-agent/tsconfig.json @@ -1,8 +1,9 @@ { "compilerOptions": { "declaration": true, - "target": "es2017", + "target": "es2019", "module": "commonjs", + "moduleResolution": "node", "outDir": "./lib", "rootDir": "./", "sourceMap": true,