@microsoft/agents-hosting-express 0.6.21-g3c2261b2fc → 1.0.0-ge4831811bf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +43 -0
- package/dist/src/startServer.d.ts +7 -6
- package/dist/src/startServer.js +9 -7
- package/dist/src/startServer.js.map +1 -1
- package/package.json +2 -2
- package/src/startServer.ts +11 -7
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"name": "@microsoft/agents-hosting-express",
|
|
4
|
+
"version": "1.0.0-ge4831811bf",
|
|
5
|
+
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/microsoft/Agents-for-js.git"
|
|
9
|
+
},
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Microsoft",
|
|
12
|
+
"email": "agentssdk@microsoft.com",
|
|
13
|
+
"url": "https://aka.ms/Agents"
|
|
14
|
+
},
|
|
15
|
+
"description": "Microsoft 365 Agents SDK for JavaScript",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"Agents"
|
|
18
|
+
],
|
|
19
|
+
"main": "dist/src/index.js",
|
|
20
|
+
"types": "dist/src/index.d.ts",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@microsoft/agents-hosting": "1.0.0-ge4831811bf",
|
|
23
|
+
"express": "^5.1.0"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"files": [
|
|
27
|
+
"README.md",
|
|
28
|
+
"dist/src",
|
|
29
|
+
"src",
|
|
30
|
+
"package.json"
|
|
31
|
+
],
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/src/index.d.ts",
|
|
35
|
+
"import": "./dist/src/index.js",
|
|
36
|
+
"require": "./dist/src/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20.0.0"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ActivityHandler, AgentApplication, AuthConfiguration, TurnState } from '@microsoft/agents-hosting';
|
|
6
6
|
/**
|
|
7
|
-
* Starts an Express server for handling Agent requests.
|
|
8
|
-
*
|
|
9
|
-
* @param agent - The AgentApplication or ActivityHandler instance to process incoming activities.
|
|
10
|
-
* @param authConfiguration - Optional custom authentication configuration. If not provided,
|
|
11
|
-
* configuration will be loaded from environment variables using loadAuthConfigFromEnv().
|
|
12
|
-
* @returns void - This function does not return a value as it starts a long-running server process.
|
|
7
|
+
* @summary Starts an Express server for handling Agent requests.
|
|
13
8
|
*
|
|
14
9
|
* @remarks
|
|
15
10
|
* This function sets up an Express server with the necessary middleware and routes for handling
|
|
@@ -29,5 +24,11 @@ import { ActivityHandler, AgentApplication, AuthConfiguration, TurnState } from
|
|
|
29
24
|
*
|
|
30
25
|
* startServer(app);
|
|
31
26
|
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param agent - The AgentApplication or ActivityHandler instance to process incoming activities.
|
|
29
|
+
* @param authConfiguration - Optional custom authentication configuration. If not provided,
|
|
30
|
+
* configuration will be loaded from environment variables using loadAuthConfigFromEnv().
|
|
31
|
+
* @returns void - This function does not return a value as it starts a long-running server process.
|
|
32
|
+
*
|
|
32
33
|
*/
|
|
33
34
|
export declare const startServer: (agent: AgentApplication<TurnState<any, any>> | ActivityHandler, authConfiguration?: AuthConfiguration) => void;
|
package/dist/src/startServer.js
CHANGED
|
@@ -12,12 +12,7 @@ const express_1 = __importDefault(require("express"));
|
|
|
12
12
|
const agents_hosting_1 = require("@microsoft/agents-hosting");
|
|
13
13
|
const package_json_1 = require("@microsoft/agents-hosting/package.json");
|
|
14
14
|
/**
|
|
15
|
-
* Starts an Express server for handling Agent requests.
|
|
16
|
-
*
|
|
17
|
-
* @param agent - The AgentApplication or ActivityHandler instance to process incoming activities.
|
|
18
|
-
* @param authConfiguration - Optional custom authentication configuration. If not provided,
|
|
19
|
-
* configuration will be loaded from environment variables using loadAuthConfigFromEnv().
|
|
20
|
-
* @returns void - This function does not return a value as it starts a long-running server process.
|
|
15
|
+
* @summary Starts an Express server for handling Agent requests.
|
|
21
16
|
*
|
|
22
17
|
* @remarks
|
|
23
18
|
* This function sets up an Express server with the necessary middleware and routes for handling
|
|
@@ -37,6 +32,12 @@ const package_json_1 = require("@microsoft/agents-hosting/package.json");
|
|
|
37
32
|
*
|
|
38
33
|
* startServer(app);
|
|
39
34
|
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param agent - The AgentApplication or ActivityHandler instance to process incoming activities.
|
|
37
|
+
* @param authConfiguration - Optional custom authentication configuration. If not provided,
|
|
38
|
+
* configuration will be loaded from environment variables using loadAuthConfigFromEnv().
|
|
39
|
+
* @returns void - This function does not return a value as it starts a long-running server process.
|
|
40
|
+
*
|
|
40
41
|
*/
|
|
41
42
|
const startServer = (agent, authConfiguration) => {
|
|
42
43
|
const authConfig = authConfiguration !== null && authConfiguration !== void 0 ? authConfiguration : (0, agents_hosting_1.loadAuthConfigFromEnv)();
|
|
@@ -47,10 +48,11 @@ const startServer = (agent, authConfiguration) => {
|
|
|
47
48
|
else {
|
|
48
49
|
adapter = agent.adapter;
|
|
49
50
|
}
|
|
51
|
+
const headerPropagation = agent === null || agent === void 0 ? void 0 : agent.options.headerPropagation;
|
|
50
52
|
const server = (0, express_1.default)();
|
|
51
53
|
server.use(express_1.default.json());
|
|
52
54
|
server.use((0, agents_hosting_1.authorizeJWT)(authConfig));
|
|
53
|
-
server.post('/api/messages', (req, res) => adapter.process(req, res, (context) => agent.run(context)));
|
|
55
|
+
server.post('/api/messages', (req, res) => adapter.process(req, res, (context) => agent.run(context), headerPropagation));
|
|
54
56
|
const port = process.env.PORT || 3978;
|
|
55
57
|
server.listen(port, async () => {
|
|
56
58
|
console.log(`\nServer listening to port ${port} on sdk ${package_json_1.version} for appId ${authConfig.clientId} debug ${process.env.DEBUG}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startServer.js","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,sDAA2C;AAC3C,8DAAuK;AACvK,yEAAgE;AAChE
|
|
1
|
+
{"version":3,"file":"startServer.js","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,sDAA2C;AAC3C,8DAAuK;AACvK,yEAAgE;AAChE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,MAAM,WAAW,GAAG,CAAC,KAA8D,EAAE,iBAAqC,EAAE,EAAE;IACnI,MAAM,UAAU,GAAsB,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,IAAA,sCAAqB,GAAE,CAAA;IAClF,IAAI,OAAqB,CAAA;IACzB,IAAI,KAAK,YAAY,gCAAe,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACvD,OAAO,GAAG,IAAI,6BAAY,EAAE,CAAA;IAC9B,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,KAAK,CAAC,OAAuB,CAAA;IACzC,CAAC;IAED,MAAM,iBAAiB,GAAI,KAA+C,aAA/C,KAAK,uBAAL,KAAK,CAA4C,OAAO,CAAC,iBAAiB,CAAA;IAErG,MAAM,MAAM,GAAG,IAAA,iBAAO,GAAE,CAAA;IACxB,MAAM,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,EAAE,CAAC,CAAA;IAC1B,MAAM,CAAC,GAAG,CAAC,IAAA,6BAAY,EAAC,UAAU,CAAC,CAAC,CAAA;IAEpC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE,CAC3D,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CACpC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAClB,iBAAiB,CAAC,CACrB,CAAA;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAA;IACrC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;QAC7B,OAAO,CAAC,GAAG,CAAC,8BAA8B,IAAI,WAAW,sBAAO,cAAc,UAAU,CAAC,QAAQ,UAAU,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAA;IACjI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC,CAAA;AAzBY,QAAA,WAAW,eAyBvB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@microsoft/agents-hosting-express",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0-ge4831811bf",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"main": "dist/src/index.js",
|
|
20
20
|
"types": "dist/src/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@microsoft/agents-hosting": "0.
|
|
22
|
+
"@microsoft/agents-hosting": "1.0.0-ge4831811bf",
|
|
23
23
|
"express": "^5.1.0"
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
package/src/startServer.ts
CHANGED
|
@@ -7,12 +7,7 @@ import express, { Response } from 'express'
|
|
|
7
7
|
import { ActivityHandler, AgentApplication, AuthConfiguration, authorizeJWT, CloudAdapter, loadAuthConfigFromEnv, Request, TurnState } from '@microsoft/agents-hosting'
|
|
8
8
|
import { version } from '@microsoft/agents-hosting/package.json'
|
|
9
9
|
/**
|
|
10
|
-
* Starts an Express server for handling Agent requests.
|
|
11
|
-
*
|
|
12
|
-
* @param agent - The AgentApplication or ActivityHandler instance to process incoming activities.
|
|
13
|
-
* @param authConfiguration - Optional custom authentication configuration. If not provided,
|
|
14
|
-
* configuration will be loaded from environment variables using loadAuthConfigFromEnv().
|
|
15
|
-
* @returns void - This function does not return a value as it starts a long-running server process.
|
|
10
|
+
* @summary Starts an Express server for handling Agent requests.
|
|
16
11
|
*
|
|
17
12
|
* @remarks
|
|
18
13
|
* This function sets up an Express server with the necessary middleware and routes for handling
|
|
@@ -32,6 +27,12 @@ import { version } from '@microsoft/agents-hosting/package.json'
|
|
|
32
27
|
*
|
|
33
28
|
* startServer(app);
|
|
34
29
|
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param agent - The AgentApplication or ActivityHandler instance to process incoming activities.
|
|
32
|
+
* @param authConfiguration - Optional custom authentication configuration. If not provided,
|
|
33
|
+
* configuration will be loaded from environment variables using loadAuthConfigFromEnv().
|
|
34
|
+
* @returns void - This function does not return a value as it starts a long-running server process.
|
|
35
|
+
*
|
|
35
36
|
*/
|
|
36
37
|
export const startServer = (agent: AgentApplication<TurnState<any, any>> | ActivityHandler, authConfiguration?: AuthConfiguration) => {
|
|
37
38
|
const authConfig: AuthConfiguration = authConfiguration ?? loadAuthConfigFromEnv()
|
|
@@ -41,6 +42,9 @@ export const startServer = (agent: AgentApplication<TurnState<any, any>> | Activ
|
|
|
41
42
|
} else {
|
|
42
43
|
adapter = agent.adapter as CloudAdapter
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
const headerPropagation = (agent as AgentApplication<TurnState<any, any>>)?.options.headerPropagation
|
|
47
|
+
|
|
44
48
|
const server = express()
|
|
45
49
|
server.use(express.json())
|
|
46
50
|
server.use(authorizeJWT(authConfig))
|
|
@@ -48,7 +52,7 @@ export const startServer = (agent: AgentApplication<TurnState<any, any>> | Activ
|
|
|
48
52
|
server.post('/api/messages', (req: Request, res: Response) =>
|
|
49
53
|
adapter.process(req, res, (context) =>
|
|
50
54
|
agent.run(context)
|
|
51
|
-
)
|
|
55
|
+
, headerPropagation)
|
|
52
56
|
)
|
|
53
57
|
|
|
54
58
|
const port = process.env.PORT || 3978
|