Skip to content

Commit

Permalink
Add VSCode build/debug seetings and ESLint (#71)
Browse files Browse the repository at this point in the history
* Add ESLint configuration and scripts for code quality checks

* Refactor launch configurations and tasks for copilotstudio-client; add environment template

* Update CI workflow to set working directory for linting and dependency installation in samples

* Replace ESLint configuration with neostandard; update lint script and clean up code formatting

* Add README.md for M365 Agents SDK Samples with debugging instructions

* Add samples list to README.md for better navigation and clarity

* Update sample links in README.md for improved navigation

* Update samples table in README.md for consistency in column headers

* Fix endpoint URL format in manifest.template.json by removing the protocol prefix

* Add post-create command and recommended extensions for development container

* Install OpenSSH server in post-create command for improved development environment setup

* Fix typo in postCreateCommand.sh for xdg-utils installation

* Update devcontainer image version and add new VS Code extensions

* Update devcontainer image and add TypeScript and Deno features

* Add ESLint extension to development container configuration

* Refactor VS Code configurations and update package import syntax for improved project structure

* Migrate Node.js project to TypeScript and restructure build process

* Add cards bot sample (#68)

* add cards bot sample

* remove action card

---------

Co-authored-by: Rido <[email protected]>

* Add prebuild and prestart scripts, and configure VS Code launch and tasks for Node.js samples

* Add build steps for Cards bot and Skill bot in CI workflow

* Remove VS Code configuration from .gitignore and add node-samples workspace file

---------

Co-authored-by: Jhonatan Sandoval Velasco <[email protected]>
  • Loading branch information
rido-min and JhontSouth authored Feb 27, 2025
1 parent 8bf0927 commit 4227c0a
Show file tree
Hide file tree
Showing 35 changed files with 4,332 additions and 124 deletions.
13 changes: 9 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
"features": {
"ghcr.io/devcontainers/features/azure-cli:1": {},
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/stuartleeks/dev-container-features/dev-tunnels:0": {}
"ghcr.io/stuartleeks/dev-container-features/dev-tunnels:0": {},
"ghcr.io/devcontainers-community/npm-features/typescript:1": {},
"ghcr.io/devcontainers-extra/features/deno:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"GitHub.copilot-chat",
"TeamsDevApp.vscode-adaptive-cards"
"TeamsDevApp.vscode-adaptive-cards",
"ms-dotnettools.csdevkit",
"github.vscode-github-actions",
"dbaeumer.vscode-eslint"
]
}
}
},
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh"
}
11 changes: 11 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sudo apt update

sudo DEBIAN_FRONTEND=noninteractive \
UCF_FORCE_CONFFOLD=1 \
UCF_FORCE_CONFDEF=1 \
apt -o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
install openssh-server -y

sudo apt upgrade -y
sudo apt install xdg-utils -y
22 changes: 21 additions & 1 deletion .github/workflows/ci-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,34 @@ jobs:
with:
node-version: 22

- name: Build echo bot
- name: Install dependencies
run: npm install
working-directory: ./samples

- name: Run lint
run: npm run lint
working-directory: ./samples

- name: Build Echo bot
working-directory: ./samples/basic/echo-bot/nodejs/
run: |
npm install
npm run build
- name: Build Cards bot
working-directory: ./samples/basic/cards/nodejs/
run: |
npm install
npm run build
- name: Build Copilot Studio client sample
working-directory: ./samples/basic/copilotstudio-client/nodejs/
run: |
npm install
npm run build
- name: Build Skill bot
working-directory: ./samples/complex/copilotstudio-skill/nodejs/
run: |
npm install
npm run build
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,6 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd

# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

Expand Down
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"github.copilot-chat",
"github.codespaces",
"ms-dotnettools.csdevkit",
"teamsdevapp.vscode-adaptive-cards"
]
}
20 changes: 0 additions & 20 deletions .vscode/launch.json

This file was deleted.

20 changes: 20 additions & 0 deletions node-samples.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"folders": [
{
"path": "samples/basic/echo-bot/nodejs",
"name" : "echo bot"
},
{
"path": "samples/basic/cards/nodejs",
"name": "cards"
},
{
"path": "samples/basic/copilotstudio-client/nodejs",
"name": "copilotstudio-client"
},
{
"path" : "samples/complex/copilotstudio-skill/nodejs",
"name": "copilotstudio-skill"
}
]
}
8 changes: 8 additions & 0 deletions samples/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
]
}
4 changes: 4 additions & 0 deletions samples/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": "2.0.0",
"tasks": []
}
16 changes: 16 additions & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# M365 Agents SDK Samples

To enable debugging, open this folder using Visual Studio Code (VSCode). Follow these steps:

1. Launch VSCode.
2. Select `File` > `Open Folder...`.
3. Navigate to the `/workspaces/Agents/samples` directory and open it.
4. Once the folder is open, you can start debugging by setting breakpoints and running the samples.

## Samples list

|Category | Name | Description | node | dotnet | python |
|---------|-------------|-------------|--------|--------|--------|
| Basic | Echo Bot | Simplest bot | [basic/echo-bot/nodejs](./basic/echo-bot/nodejs) | TBD | TBD |
| Basic | Copilot Studio Client | Consume CopilotStudio Agent | [basic/copilotstudio-client/nodejs](./basic/copilotstudio-client/nodejs) | TBD | TBD |
| Complex | Copilot Studio Skill | Call the echo bot from a Copilot Studio skill | [complex/copilotstudio-skill/nodejs](./complex/copilotstudio-skill/nodejs) | TBD | TBD |
17 changes: 17 additions & 0 deletions samples/basic/cards/nodejs/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "node-card-bot",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/dist/index.js",
"outFiles": [ "${workspaceFolder}/**/dist/**/*.js" ],
"envFile": "${workspaceFolder}/.env",
"preLaunchTask": "npm: build card-bot"
}
]
}
15 changes: 15 additions & 0 deletions samples/basic/cards/nodejs/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"label": "npm: build card-bot"
}
]
}
1 change: 1 addition & 0 deletions samples/basic/cards/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"license": "MIT",
"main": "./lib/index.js",
"scripts": {
"prebuild": "npm install",
"build": "tsc --build",
"prestart": "npm run build",
"start": "node --env-file .env ./dist/index.js",
Expand Down
17 changes: 17 additions & 0 deletions samples/basic/copilotstudio-client/nodejs/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "node-copilotstudio-client",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/dist/index.js",
"outFiles": [ "${workspaceFolder}/**/dist/**/*.js" ],
"envFile": "${workspaceFolder}/.env",
"preLaunchTask": "npm: build copilotstudio-client"
}
]
}
15 changes: 15 additions & 0 deletions samples/basic/copilotstudio-client/nodejs/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"label": "npm: build copilotstudio-client"
}
]
}
9 changes: 9 additions & 0 deletions samples/basic/copilotstudio-client/nodejs/env.TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
environmentId=127b164e-50eb-e1f3-9e9e-a3b54a865c16
botIdentifier=cr0d1_myTestAgent
tenantId=18743834-d9d8-4376-aba7-5dba2dbe8c2a
appClientId=3be1aa5f-e633-437a-bf2b-9a8b6627195c

# cloud= # PowerPlatformCloud enum key.
# customPowerPlatformCloud= # Power Platform API endpoint to use if Cloud is configured as "Other"
# copilotBotType="" # BotType enum key.
DEBUG="copilot-studio-client"
1 change: 1 addition & 0 deletions samples/basic/copilotstudio-client/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"main": "./dist/index.js",
"type": "module",
"scripts": {
"prebuild": "npm install",
"build": "tsc --build",
"prestart": "npm run build",
"start": "node --env-file .env ./dist/index.js"
Expand Down
8 changes: 5 additions & 3 deletions samples/basic/copilotstudio-client/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import path from 'path'

import { MsalCachePlugin } from './msalCachePlugin.js'

async function acquireToken(settings: ConnectionSettings): Promise<string> {
async function acquireToken (settings: ConnectionSettings): Promise<string> {
const msalConfig = {
auth: {
clientId: settings.appClientId,
Expand All @@ -25,8 +25,10 @@ async function acquireToken(settings: ConnectionSettings): Promise<string> {
},
system: {
loggerOptions: {
loggerCallback(loglevel: msal.LogLevel, message: string, containsPii: boolean) {
console.log(message)
loggerCallback (loglevel: msal.LogLevel, message: string, containsPii: boolean) {
if (!containsPii) {
console.log(loglevel, message)
}
},
piiLoggingEnabled: false,
logLevel: msal.LogLevel.Verbose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { ICachePlugin, TokenCacheContext } from '@azure/msal-node'

export class MsalCachePlugin implements ICachePlugin {
private cacheLocation: string = ''
constructor(cacheLocation: string) {
constructor (cacheLocation: string) {
this.cacheLocation = cacheLocation
}

async beforeCacheAccess(tokenCacheContext: TokenCacheContext): Promise<void> {
async beforeCacheAccess (tokenCacheContext: TokenCacheContext): Promise<void> {
return new Promise((resolve, reject) => {
if (fs.existsSync(this.cacheLocation)) {
fs.readFile(this.cacheLocation, 'utf-8', (error, data) => {
Expand All @@ -32,7 +32,7 @@ export class MsalCachePlugin implements ICachePlugin {
})
}

async afterCacheAccess(tokenCacheContext: TokenCacheContext): Promise<void> {
async afterCacheAccess (tokenCacheContext: TokenCacheContext): Promise<void> {
return new Promise((resolve, reject) => {
if (tokenCacheContext.cacheHasChanged) {
fs.writeFile(this.cacheLocation, tokenCacheContext.tokenCache.serialize(), (error) => {
Expand Down
17 changes: 17 additions & 0 deletions samples/basic/echo-bot/nodejs/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "node-echo-bot",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/dist/index.js",
"outFiles": [ "${workspaceFolder}/**/dist/**/*.js" ],
"envFile": "${workspaceFolder}/.env",
"preLaunchTask": "npm: build echo-bot"
}
]
}
15 changes: 15 additions & 0 deletions samples/basic/echo-bot/nodejs/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"label": "npm: build echo-bot"
}
]
}
1 change: 1 addition & 0 deletions samples/basic/echo-bot/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"license": "MIT",
"main": "./dist/index.js",
"scripts": {
"prebuild": "npm install",
"build": "tsc --build",
"prestart": "npm run build",
"start": "node --env-file .env ./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion samples/basic/echo-bot/nodejs/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ActivityHandler, MessageFactory } from '@microsoft/agents-bot-hosting'
import { version } from '@microsoft/agents-bot-hosting/package.json'

export class EchoBot extends ActivityHandler {
constructor() {
constructor () {
super()
this.onMessage(async (context, next) => {
const replyText = `Echo: ${context.activity.text}`
Expand Down
Loading

0 comments on commit 4227c0a

Please sign in to comment.