Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nodejs/langchain/sample-agent/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ USE_AGENTIC_AUTH=false
connections__service_connection__settings__clientId=
connections__service_connection__settings__clientSecret=
connections__service_connection__settings__tenantId=
connections__service_connection__settings__authority=

# Set service connection as default
connectionsMap__0__serviceUrl=*
connectionsMap__0__connection=service_connection

# AgenticAuthentication Options
agentic_type=agentic
agentic_altBlueprintConnectionName=service_connection
agentic_scopes=ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default # Prod Agentic scope
5 changes: 2 additions & 3 deletions nodejs/langchain/sample-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
"@langchain/langgraph": "*",
"@langchain/mcp-adapters": "*",
"@langchain/openai": "*",
"@microsoft/agents-activity": "1.1.0-alpha.58",
"@microsoft/agents-hosting": "1.1.0-alpha.58",
"@microsoft/agents-hosting-express": "1.1.0-alpha.58",
"@microsoft/agents-activity": "^1.1.0-alpha.85",
"@microsoft/agents-hosting": "^1.1.0-alpha.85",
"dotenv": "^17.2.3",
"express": "^5.1.0",
"langchain": "^1.0.1",
Expand Down
37 changes: 15 additions & 22 deletions nodejs/langchain/sample-agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,29 @@ import { configDotenv } from 'dotenv';
configDotenv();

import { AuthConfiguration, authorizeJWT, CloudAdapter, Request } from '@microsoft/agents-hosting';
import express, { Response } from 'express';
import express, { Response } from 'express'
import { agentApplication } from './agent';

const authConfig: AuthConfiguration = {};
const adapter = new CloudAdapter(authConfig);

const app = express();
app.use(express.json());
app.use(authorizeJWT(authConfig));
const server = express()
server.use(express.json())
server.use(authorizeJWT(authConfig))

app.post('/api/messages', async (req: Request, res: Response) => {
await adapter.process(req, res, async (context) => {
await agentApplication.run(context);
});
});
server.post('/api/messages', (req: Request, res: Response) => {
const adapter = agentApplication.adapter as CloudAdapter;
adapter.process(req, res, async (context) => {
await agentApplication.run(context)
})
})

const port = process.env.PORT || 3978;
const server = app.listen(port, () => {
console.log(`\nServer listening to port ${port} for appId ${authConfig.clientId} debug ${process.env.DEBUG}`);
const port = process.env.PORT || 3978
server.listen(port, async () => {
console.log(`\nServer listening to port ${port} for appId ${authConfig.clientId} debug ${process.env.DEBUG}`)
}).on('error', async (err) => {
console.error(err);
process.exit(1);
}).on('close', async () => {
console.log('Kairo is shutting down...');
});

process.on('SIGINT', () => {
console.log('Received SIGINT. Shutting down gracefully...');
server.close(() => {
console.log('Server closed.');
process.exit(0);
});
console.log('Server closed');
process.exit(0);
});