@microsoft/agents-hosting-express 1.6.1 → 1.7.0-beta.5.g67b2005119

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/README.md CHANGED
@@ -69,6 +69,8 @@ app.listen(3978);
69
69
 
70
70
  For full control, use `createCloudAdapter` to obtain the `CloudAdapter` directly. This is useful when you need to customize request processing and can provide the request/response shape expected by `CloudAdapter.process`.
71
71
 
72
+ > `createCloudAdapter` is now exported from `@microsoft/agents-hosting`; the re-export below is preserved for backward compatibility. New code may import it directly from `@microsoft/agents-hosting` to avoid taking a dependency on Express.
73
+
72
74
  `CloudAdapter.process` expects:
73
75
 
74
76
  - a parsed activity body on `req.body` (for example, via `express.json()` in Express)
package/dist/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": "1.6.1",
4
+ "version": "1.7.0-beta.5.g67b2005119",
5
5
  "homepage": "https://github.com/microsoft/Agents-for-js",
6
6
  "repository": {
7
7
  "type": "git",
@@ -19,8 +19,8 @@
19
19
  "main": "dist/src/index.js",
20
20
  "types": "dist/src/index.d.ts",
21
21
  "dependencies": {
22
- "@microsoft/agents-hosting": "1.6.1",
23
- "@microsoft/agents-telemetry": "1.6.1",
22
+ "@microsoft/agents-hosting": "1.7.0-beta.5.g67b2005119",
23
+ "@microsoft/agents-telemetry": "1.7.0-beta.5.g67b2005119",
24
24
  "express": "5.2.1",
25
25
  "express-rate-limit": "8.5.2"
26
26
  },
@@ -2,19 +2,12 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ActivityHandler, AgentApplication, AuthConfiguration, Request, TurnState } from '@microsoft/agents-hosting';
5
+ import { ActivityHandler, AgentApplication, AuthConfiguration, WebResponse, Request, TurnState } from '@microsoft/agents-hosting';
6
6
  /**
7
- * Minimal response interface describing the methods used by the Agent request handler.
8
- * Any framework whose response object satisfies this shape is compatible.
7
+ * Re-export of `WebResponse` from `@microsoft/agents-hosting` for backward compatibility.
8
+ * New code should import `WebResponse` directly from `@microsoft/agents-hosting`.
9
9
  */
10
- export interface WebResponse {
11
- status(code: number): this;
12
- setHeader(name: string, value: string): this;
13
- send(body?: unknown): this;
14
- end(): this;
15
- headersSent: boolean;
16
- writableEnded: boolean;
17
- }
10
+ export type { WebResponse };
18
11
  /**
19
12
  * A request handler function signature that does not import Express types in its public API.
20
13
  *
@@ -1 +1 @@
1
- {"version":3,"file":"createAgentRequestHandler.js","sourceRoot":"","sources":["../../src/createAgentRequestHandler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,8DAA6J;AAC7J,6DAAyD;AAwBzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACI,MAAM,yBAAyB,GAAG,CACvC,KAA8D,EAC9D,iBAAqC,EAChB,EAAE;IACvB,MAAM,UAAU,GAAG,IAAA,0CAAyB,EAAC,iBAAiB,CAAC,CAAA;IAC/D,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,IAAA,uCAAkB,EAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IAC5E,MAAM,aAAa,GAAG,IAAA,6BAAY,EAAC,UAAU,CAAC,CAAA;IAE9C,OAAO,KAAK,EAAE,GAAY,EAAE,GAAgB,EAAiB,EAAE;QAC7D,IAAI,eAAoB,CAAA;QACxB,IAAI,UAAU,GAAG,KAAK,CAAA;QAEtB,MAAM,aAAa,CAAC,GAAG,EAAE,GAAe,EAAE,CAAC,GAAS,EAAE,EAAE;YACtD,UAAU,GAAG,IAAI,CAAA;YACjB,eAAe,GAAG,GAAG,CAAA;QACvB,CAAC,CAAC,CAAA;QAEF,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,eAAe,CAAA;QACvB,CAAC;QAED,uGAAuG;QACvG,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC,WAAW,EAAE,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,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAA;IACrF,CAAC,CAAA;AACH,CAAC,CAAA;AA5BY,QAAA,yBAAyB,6BA4BrC"}
@@ -1,36 +1,9 @@
1
1
  /**
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License.
4
- */
5
- import { ActivityHandler, AgentApplication, AuthConfiguration, CloudAdapter, HeaderPropagationDefinition, TurnState } from '@microsoft/agents-hosting';
6
- /**
7
- * Result of creating a CloudAdapter from an agent.
8
- */
9
- export interface CloudAdapterResult {
10
- adapter: CloudAdapter;
11
- headerPropagation: HeaderPropagationDefinition | undefined;
12
- }
13
- /**
14
- * Creates a CloudAdapter for the given agent.
15
- *
16
- * If the agent is an AgentApplication with a pre-configured adapter, that adapter is reused.
17
- * Otherwise, a new CloudAdapter is created.
18
- *
19
- * @param agent - The AgentApplication or ActivityHandler instance.
20
- * @param authConfig - Optional auth configuration used when creating a new CloudAdapter.
21
- * If the agent already has an adapter, that adapter is reused and this value is ignored.
22
- * @returns An object containing the CloudAdapter and optional header propagation configuration.
23
- *
24
- * @example
25
- * ```typescript
26
- * import { AgentApplication, TurnState } from '@microsoft/agents-hosting';
27
- * import { createCloudAdapter } from '@microsoft/agents-hosting-express';
28
- *
29
- * const app = new AgentApplication<TurnState>();
30
- * const { adapter, headerPropagation } = createCloudAdapter(app, { clientId: process.env.CLIENT_ID });
31
4
  *
32
- * // Use the adapter directly with request/response objects compatible with CloudAdapter.process
33
- * adapter.process(req, res, (context) => app.run(context), headerPropagation);
34
- * ```
5
+ * Re-export from `@microsoft/agents-hosting` for backward compatibility.
6
+ * `createCloudAdapter` was moved into core so it can be reused by Fastify and
7
+ * other hosting integrations without dragging the Express runtime along.
35
8
  */
36
- export declare const createCloudAdapter: (agent: AgentApplication<TurnState<any, any>> | ActivityHandler, authConfig?: AuthConfiguration) => CloudAdapterResult;
9
+ export { createCloudAdapter, type CloudAdapterResult } from '@microsoft/agents-hosting';
@@ -2,44 +2,13 @@
2
2
  /**
3
3
  * Copyright (c) Microsoft Corporation. All rights reserved.
4
4
  * Licensed under the MIT License.
5
+ *
6
+ * Re-export from `@microsoft/agents-hosting` for backward compatibility.
7
+ * `createCloudAdapter` was moved into core so it can be reused by Fastify and
8
+ * other hosting integrations without dragging the Express runtime along.
5
9
  */
6
10
  Object.defineProperty(exports, "__esModule", { value: true });
7
11
  exports.createCloudAdapter = void 0;
8
- const agents_hosting_1 = require("@microsoft/agents-hosting");
9
- /**
10
- * Creates a CloudAdapter for the given agent.
11
- *
12
- * If the agent is an AgentApplication with a pre-configured adapter, that adapter is reused.
13
- * Otherwise, a new CloudAdapter is created.
14
- *
15
- * @param agent - The AgentApplication or ActivityHandler instance.
16
- * @param authConfig - Optional auth configuration used when creating a new CloudAdapter.
17
- * If the agent already has an adapter, that adapter is reused and this value is ignored.
18
- * @returns An object containing the CloudAdapter and optional header propagation configuration.
19
- *
20
- * @example
21
- * ```typescript
22
- * import { AgentApplication, TurnState } from '@microsoft/agents-hosting';
23
- * import { createCloudAdapter } from '@microsoft/agents-hosting-express';
24
- *
25
- * const app = new AgentApplication<TurnState>();
26
- * const { adapter, headerPropagation } = createCloudAdapter(app, { clientId: process.env.CLIENT_ID });
27
- *
28
- * // Use the adapter directly with request/response objects compatible with CloudAdapter.process
29
- * adapter.process(req, res, (context) => app.run(context), headerPropagation);
30
- * ```
31
- */
32
- const createCloudAdapter = (agent, authConfig) => {
33
- let adapter;
34
- let headerPropagation;
35
- if (agent instanceof agents_hosting_1.ActivityHandler || !agent.adapter) {
36
- adapter = new agents_hosting_1.CloudAdapter(authConfig);
37
- }
38
- else {
39
- adapter = agent.adapter;
40
- headerPropagation = agent === null || agent === void 0 ? void 0 : agent.options.headerPropagation;
41
- }
42
- return { adapter, headerPropagation };
43
- };
44
- exports.createCloudAdapter = createCloudAdapter;
12
+ var agents_hosting_1 = require("@microsoft/agents-hosting");
13
+ Object.defineProperty(exports, "createCloudAdapter", { enumerable: true, get: function () { return agents_hosting_1.createCloudAdapter; } });
45
14
  //# sourceMappingURL=createCloudAdapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createCloudAdapter.js","sourceRoot":"","sources":["../../src/createCloudAdapter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,8DAAsJ;AAUtJ;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACI,MAAM,kBAAkB,GAAG,CAChC,KAA8D,EAC9D,UAA8B,EACV,EAAE;IACtB,IAAI,OAAqB,CAAA;IACzB,IAAI,iBAA0D,CAAA;IAC9D,IAAI,KAAK,YAAY,gCAAe,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACvD,OAAO,GAAG,IAAI,6BAAY,CAAC,UAAU,CAAC,CAAA;IACxC,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,KAAK,CAAC,OAAuB,CAAA;QACvC,iBAAiB,GAAI,KAA+C,aAA/C,KAAK,uBAAL,KAAK,CAA4C,OAAO,CAAC,iBAAiB,CAAA;IACjG,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAA;AACvC,CAAC,CAAA;AAbY,QAAA,kBAAkB,sBAa9B"}
1
+ {"version":3,"file":"createCloudAdapter.js","sourceRoot":"","sources":["../../src/createCloudAdapter.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,4DAAuF;AAA9E,oHAAA,kBAAkB,OAAA"}
@@ -19,7 +19,12 @@ function startServer(agent, optionsOrAuth) {
19
19
  var _a, _b, _c;
20
20
  const isOptions = typeof optionsOrAuth === 'object' && optionsOrAuth !== null &&
21
21
  ('authConfig' in optionsOrAuth || 'port' in optionsOrAuth || 'routePath' in optionsOrAuth || 'rateLimitOptions' in optionsOrAuth || 'beforeListen' in optionsOrAuth);
22
- const opts = isOptions ? optionsOrAuth : { authConfig: optionsOrAuth };
22
+ // Legacy overload: the second argument is a raw AuthConfiguration. An empty object carries no auth
23
+ // settings, so treat it like no argument and load defaults from the environment (matching startServer(agent)).
24
+ const hasAuthSettings = !isOptions && optionsOrAuth != null && Object.keys(optionsOrAuth).length > 0;
25
+ const opts = isOptions
26
+ ? optionsOrAuth
27
+ : { authConfig: hasAuthSettings ? optionsOrAuth : undefined };
23
28
  const authConfig = (0, agents_hosting_1.getAuthConfigWithDefaults)(opts.authConfig);
24
29
  const routePath = (_a = opts.routePath) !== null && _a !== void 0 ? _a : '/api/messages';
25
30
  const { adapter, headerPropagation } = (0, createCloudAdapter_1.createCloudAdapter)(agent, authConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"startServer.js","sourceRoot":"","sources":["../../src/startServer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AA4GH,kCAoDC;AA9JD,sDAA2C;AAC3C,4EAA0C;AAC1C,8DAA6J;AAC7J,yEAAgE;AAChE,kEAAmD;AACnD,6DAAyD;AAEzD,MAAM,MAAM,GAAG,IAAA,wBAAK,EAAC,wBAAwB,CAAC,CAAA;AAmG9C,SAAgB,WAAW,CAAE,KAA8D,EAAE,aAAsD;;IACjJ,MAAM,SAAS,GAAG,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,KAAK,IAAI;QAC3E,CAAC,YAAY,IAAI,aAAa,IAAI,MAAM,IAAI,aAAa,IAAI,WAAW,IAAI,aAAa,IAAI,kBAAkB,IAAI,aAAa,IAAI,cAAc,IAAI,aAAa,CAAC,CAAA;IAEtK,MAAM,IAAI,GAAuB,SAAS,CAAC,CAAC,CAAC,aAAmC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,aAA8C,EAAE,CAAA;IACjJ,MAAM,UAAU,GAAsB,IAAA,0CAAyB,EAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAChF,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,SAAS,mCAAI,eAAe,CAAA;IACnD,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,IAAA,uCAAkB,E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AC,OAAO,CAAC;YAC7B,MAAM,EAAE,KAAK,YAAY,gCAAe,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe;SACzF;QACD,iBAAiB,EAAE,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;KAC5E,CAAC,CAAA;IACF,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;IAC7B,OAAO,MAAM,CAAA;AACf,CAAC"}
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": "1.6.1",
4
+ "version": "1.7.0-beta.5.g67b2005119",
5
5
  "homepage": "https://github.com/microsoft/Agents-for-js",
6
6
  "repository": {
7
7
  "type": "git",
@@ -19,8 +19,8 @@
19
19
  "main": "dist/src/index.js",
20
20
  "types": "dist/src/index.d.ts",
21
21
  "dependencies": {
22
- "@microsoft/agents-hosting": "1.6.1",
23
- "@microsoft/agents-telemetry": "1.6.1",
22
+ "@microsoft/agents-hosting": "1.7.0-beta.5.g67b2005119",
23
+ "@microsoft/agents-telemetry": "1.7.0-beta.5.g67b2005119",
24
24
  "express": "5.2.1",
25
25
  "express-rate-limit": "8.5.2"
26
26
  },
@@ -3,22 +3,28 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { type Response } from 'express'
7
- import { ActivityHandler, AgentApplication, AuthConfiguration, authorizeJWT, getAuthConfigWithDefaults, Request, TurnState } from '@microsoft/agents-hosting'
6
+ import { type Response as ExpressResponse } from 'express'
7
+ import { ActivityHandler, AgentApplication, AuthConfiguration, authorizeJWT, getAuthConfigWithDefaults, WebResponse, Request, TurnState } from '@microsoft/agents-hosting'
8
8
  import { createCloudAdapter } from './createCloudAdapter'
9
9
 
10
10
  /**
11
- * Minimal response interface describing the methods used by the Agent request handler.
12
- * Any framework whose response object satisfies this shape is compatible.
11
+ * Compile-time contract guard no runtime effect; type-checked by `npm run build`.
12
+ *
13
+ * Locks in the structural relationship the Express integration relies on: Express's
14
+ * `Response` must remain assignable to `WebResponse` (the response parameter of
15
+ * `CloudAdapter.process` and `authorizeJWT`). If `WebResponse` ever drifts — e.g. it
16
+ * gains a member that Express's `Response` does not provide — this line fails to
17
+ * compile, surfacing the break here at build time rather than in consumer code.
13
18
  */
14
- export interface WebResponse {
15
- status (code: number): this
16
- setHeader (name: string, value: string): this
17
- send (body?: unknown): this
18
- end (): this
19
- headersSent: boolean
20
- writableEnded: boolean
21
- }
19
+ type AssertAssignable<Target, Source extends Target> = Source
20
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
+ type _ExpressResponseSatisfiesWebResponse = AssertAssignable<WebResponse, ExpressResponse>
22
+
23
+ /**
24
+ * Re-export of `WebResponse` from `@microsoft/agents-hosting` for backward compatibility.
25
+ * New code should import `WebResponse` directly from `@microsoft/agents-hosting`.
26
+ */
27
+ export type { WebResponse }
22
28
 
23
29
  /**
24
30
  * A request handler function signature that does not import Express types in its public API.
@@ -72,7 +78,7 @@ export const createAgentRequestHandler = (
72
78
  let middlewareError: any
73
79
  let nextCalled = false
74
80
 
75
- await jwtMiddleware(req, res as Response, (err?: any) => {
81
+ await jwtMiddleware(req, res, (err?: any) => {
76
82
  nextCalled = true
77
83
  middlewareError = err
78
84
  })
@@ -86,6 +92,6 @@ export const createAgentRequestHandler = (
86
92
  return
87
93
  }
88
94
 
89
- await adapter.process(req, res as Response, (context) => agent.run(context), headerPropagation)
95
+ await adapter.process(req, res, (context) => agent.run(context), headerPropagation)
90
96
  }
91
97
  }
@@ -1,52 +1,10 @@
1
1
  /**
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License.
4
- */
5
-
6
- import { ActivityHandler, AgentApplication, AuthConfiguration, CloudAdapter, HeaderPropagationDefinition, TurnState } from '@microsoft/agents-hosting'
7
-
8
- /**
9
- * Result of creating a CloudAdapter from an agent.
10
- */
11
- export interface CloudAdapterResult {
12
- adapter: CloudAdapter
13
- headerPropagation: HeaderPropagationDefinition | undefined
14
- }
15
-
16
- /**
17
- * Creates a CloudAdapter for the given agent.
18
- *
19
- * If the agent is an AgentApplication with a pre-configured adapter, that adapter is reused.
20
- * Otherwise, a new CloudAdapter is created.
21
- *
22
- * @param agent - The AgentApplication or ActivityHandler instance.
23
- * @param authConfig - Optional auth configuration used when creating a new CloudAdapter.
24
- * If the agent already has an adapter, that adapter is reused and this value is ignored.
25
- * @returns An object containing the CloudAdapter and optional header propagation configuration.
26
4
  *
27
- * @example
28
- * ```typescript
29
- * import { AgentApplication, TurnState } from '@microsoft/agents-hosting';
30
- * import { createCloudAdapter } from '@microsoft/agents-hosting-express';
31
- *
32
- * const app = new AgentApplication<TurnState>();
33
- * const { adapter, headerPropagation } = createCloudAdapter(app, { clientId: process.env.CLIENT_ID });
34
- *
35
- * // Use the adapter directly with request/response objects compatible with CloudAdapter.process
36
- * adapter.process(req, res, (context) => app.run(context), headerPropagation);
37
- * ```
5
+ * Re-export from `@microsoft/agents-hosting` for backward compatibility.
6
+ * `createCloudAdapter` was moved into core so it can be reused by Fastify and
7
+ * other hosting integrations without dragging the Express runtime along.
38
8
  */
39
- export const createCloudAdapter = (
40
- agent: AgentApplication<TurnState<any, any>> | ActivityHandler,
41
- authConfig?: AuthConfiguration
42
- ): CloudAdapterResult => {
43
- let adapter: CloudAdapter
44
- let headerPropagation: HeaderPropagationDefinition | undefined
45
- if (agent instanceof ActivityHandler || !agent.adapter) {
46
- adapter = new CloudAdapter(authConfig)
47
- } else {
48
- adapter = agent.adapter as CloudAdapter
49
- headerPropagation = (agent as AgentApplication<TurnState<any, any>>)?.options.headerPropagation
50
- }
51
- return { adapter, headerPropagation }
52
- }
9
+
10
+ export { createCloudAdapter, type CloudAdapterResult } from '@microsoft/agents-hosting'
@@ -113,7 +113,12 @@ export function startServer (agent: AgentApplication<TurnState<any, any>> | Acti
113
113
  const isOptions = typeof optionsOrAuth === 'object' && optionsOrAuth !== null &&
114
114
  ('authConfig' in optionsOrAuth || 'port' in optionsOrAuth || 'routePath' in optionsOrAuth || 'rateLimitOptions' in optionsOrAuth || 'beforeListen' in optionsOrAuth)
115
115
 
116
- const opts: StartServerOptions = isOptions ? optionsOrAuth as StartServerOptions : { authConfig: optionsOrAuth as AuthConfiguration | undefined }
116
+ // Legacy overload: the second argument is a raw AuthConfiguration. An empty object carries no auth
117
+ // settings, so treat it like no argument and load defaults from the environment (matching startServer(agent)).
118
+ const hasAuthSettings = !isOptions && optionsOrAuth != null && Object.keys(optionsOrAuth).length > 0
119
+ const opts: StartServerOptions = isOptions
120
+ ? optionsOrAuth as StartServerOptions
121
+ : { authConfig: hasAuthSettings ? optionsOrAuth as AuthConfiguration : undefined }
117
122
  const authConfig: AuthConfiguration = getAuthConfigWithDefaults(opts.authConfig)
118
123
  const routePath = opts.routePath ?? '/api/messages'
119
124
  const { adapter, headerPropagation } = createCloudAdapter(agent, authConfig)