feat: enhance agents-hosting to support diverse web APIs#1135
Open
matthewmeyer wants to merge 4 commits into
Open
feat: enhance agents-hosting to support diverse web APIs#1135matthewmeyer wants to merge 4 commits into
matthewmeyer wants to merge 4 commits into
Conversation
matthewmeyer
commented
Jun 4, 2026
Contributor
- Introduced WebResponse interface to decouple hosting layer from Express types.
- Added new interfaces for web response handling and middleware compatibility.
- Implemented tests to validate CloudAdapter and authorizeJWT functionality with WebResponse.
- Added agents-hosting-fastify to support Fastify hosted agents
- Created fastify-empty-agent sample to demonstrate usage with Fastify.
- Updated tsconfig and build configurations to include new Fastify agent.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR evolves the hosting layer to be web-framework-agnostic by introducing a minimal WebResponse contract and moving shared hosting helpers into @microsoft/agents-hosting, then adds a new @microsoft/agents-hosting-fastify integration plus a Fastify-based sample agent and parity/regression tests.
Changes:
- Introduces framework-agnostic
WebResponse/ middleware types and updatesCloudAdapter.process+authorizeJWTto depend on them (not Express types). - Promotes shared helpers (e.g.,
createCloudAdapter, agent-response handler creation) into@microsoft/agents-hostingand updates Express integration to re-export/align. - Adds new Fastify hosting package + tests, plus a
fastify-empty-agentsample and build reference wiring.
Reviewed changes
Copilot reviewed 46 out of 47 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.build.json | Adds project references for the new Fastify package and sample agent. |
| test-agents/fastify-empty-agent/tsconfig.json | TS build config for the new Fastify sample. |
| test-agents/fastify-empty-agent/src/agent.ts | New Fastify-hosted “empty agent” sample entrypoint. |
| test-agents/fastify-empty-agent/README.md | Documentation for running the Fastify sample. |
| test-agents/fastify-empty-agent/package.json | Sample package wiring + deps on local workspaces. |
| test-agents/fastify-empty-agent/env.TEMPLATE | Sample environment template for auth settings. |
| test-agents/empty-agent/README.md | Fixes sample title typo (“emtpy-agent” → “empty-agent”). |
| README.md | Documents the new @microsoft/agents-hosting-fastify package in the package table and minor wording fix. |
| packages/agents-hosting/test/hosting/jwt-middleware.webresponse.test.ts | Regression tests ensuring JWT middleware works with WebResponse without Express types. |
| packages/agents-hosting/test/hosting/adapter/cloudAdapter.webresponse.test.ts | Regression tests ensuring CloudAdapter.process works with WebResponse and throws structured errors on missing body. |
| packages/agents-hosting/src/interfaces/webResponse.ts | Introduces the WebResponse structural contract plus NextFunction and params carrier. |
| packages/agents-hosting/src/interfaces/index.ts | Re-exports interfaces for public consumption. |
| packages/agents-hosting/src/index.ts | Exposes new core helpers/interfaces from the package entrypoint. |
| packages/agents-hosting/src/errorHelper.ts | Adds hosting/web-layer error definitions (e.g., missing request body, JWT decode/audience errors). |
| packages/agents-hosting/src/createCloudAdapter.ts | Moves createCloudAdapter into core for reuse by non-Express integrations. |
| packages/agents-hosting/src/cloudAdapter.ts | Switches response type dependency from Express Response to framework-agnostic WebResponse; improves missing-body error. |
| packages/agents-hosting/src/auth/jwt-middleware.ts | Removes Express type imports; updates error creation and wire error message behavior. |
| packages/agents-hosting/src/agent-client/index.ts | Exports new response-handler factory. |
| packages/agents-hosting/src/agent-client/createAgentResponseHandler.ts | Adds framework-agnostic agent-response handler implementation and canonical route constant. |
| packages/agents-hosting/src/agent-client/agentResponseHandler.ts | Refactors response controller configuration to use the new framework-agnostic handler. |
| packages/agents-hosting/README.md | Documents new framework-agnostic hosting integration APIs. |
| packages/agents-hosting-fastify/tsconfig.json | TS build config for the new Fastify integration package. |
| packages/agents-hosting-fastify/test/startServer.test.ts | Tests Fastify startServer behavior (routePath, beforeListen, JWT, rate limit). |
| packages/agents-hosting-fastify/test/replyAdapter.test.ts | Tests Fastify reply adapter’s WebResponse behavior. |
| packages/agents-hosting-fastify/test/plugin.test.ts | Tests plugin defaults, custom routePath, prefix, decorator preservation. |
| packages/agents-hosting-fastify/test/parity.test.ts | Express ↔ Fastify parity suite validating key behavior matches. |
| packages/agents-hosting-fastify/test/createAgentRequestHandler.test.ts | Tests Fastify request handler wrapper behavior vs JWT middleware + adapter. |
| packages/agents-hosting-fastify/test/configureResponseController.test.ts | Smoke tests Fastify response-controller wrapper registers the canonical route. |
| packages/agents-hosting-fastify/src/startServer.ts | Implements Fastify startServer with per-route JWT auth + optional rate limit/bodyLimit. |
| packages/agents-hosting-fastify/src/replyAdapter.ts | Implements FastifyReplyAdapter to satisfy WebResponse. |
| packages/agents-hosting-fastify/src/plugin.ts | Implements encapsulated Fastify plugin for registering the messages route. |
| packages/agents-hosting-fastify/src/index.ts | Public exports for the Fastify package and re-exports of core helpers. |
| packages/agents-hosting-fastify/src/createAgentRequestHandler.ts | Creates a Fastify-native handler that invokes core JWT + CloudAdapter.process. |
| packages/agents-hosting-fastify/src/configureResponseController.ts | Fastify wrapper wiring the agent-response controller via the core handler. |
| packages/agents-hosting-fastify/README.md | Usage docs and differences vs Express integration. |
| packages/agents-hosting-fastify/package.json | New package manifest for @microsoft/agents-hosting-fastify. |
| packages/agents-hosting-express/src/startServer.ts | Adjusts legacy overload behavior for empty auth config object and keeps parity with new semantics. |
| packages/agents-hosting-express/src/createCloudAdapter.ts | Re-exports createCloudAdapter from core for backward compatibility. |
| packages/agents-hosting-express/src/createAgentRequestHandler.ts | Switches to core WebResponse and adds compile-time assignability guard. |
| packages/agents-hosting-express/README.md | Notes createCloudAdapter promotion to core. |
| packages/agents-activity/src/exceptionHelper.ts | Extends AgentError to include a .description property set by ExceptionHelper. |
| compat/baseline/agents-hosting.api.md | Updates API baseline for new core hosting surface and signature changes. |
| compat/baseline/agents-hosting-fastify.api.md | Adds API baseline for the new Fastify package. |
| compat/baseline/agents-hosting-express.api.md | Updates API baseline for expanded Express package exports. |
| CLAUDE.md | Updates repository guidance to include the new Fastify integration package. |
| .github/copilot-instructions.md | Adds repo-specific Copilot contribution/architecture guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dee5f21 to
eb183cb
Compare
…rface - Introduced WebResponse interface to decouple hosting layer from Express types. - Added new interfaces for web response handling and middleware compatibility. - Implemented tests to validate CloudAdapter and authorizeJWT functionality with WebResponse. - Added agents-hosting-fastify to support Fastify hosted agents - Created fastify-empty-agent sample to demonstrate usage with Fastify. - Updated tsconfig and build configurations to include new Fastify agent.
eb183cb to
5215f68
Compare
…tests for missing request body handling
Comment on lines
+147
to
+156
| function extractBearerToken (authorization: string | string[] | undefined): string | undefined { | ||
| const values = Array.isArray(authorization) ? authorization : [authorization] | ||
| for (const value of values) { | ||
| const token = parseBearerValue(value) | ||
| if (token) { | ||
| return token | ||
| } | ||
| } | ||
| return undefined | ||
| } |
Comment on lines
+181
to
+185
| // Emit only the human-readable description rather than the | ||
| // ExceptionHelper-formatted "[code] - description - helplink" string, | ||
| // so the wire format does not leak internal error codes or help links. | ||
| const wireMessage: string | undefined = err?.description ?? err?.message | ||
| res.status(401).send({ 'jwt-auth-error': wireMessage }) |
| * still part of the package's public type surface (and the API report). Keeping | ||
| * it structural avoids committing to a richer, named route-registrar contract. | ||
| */ | ||
| interface WebApp { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.