@frontmcp/sdk 0.5.0 → 0.6.0

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.
Files changed (226) hide show
  1. package/README.md +3 -3
  2. package/package.json +8 -19
  3. package/src/adapter/adapter.instance.js +5 -0
  4. package/src/adapter/adapter.instance.js.map +1 -1
  5. package/src/auth/authorization/authorization.class.d.ts +1 -4
  6. package/src/auth/authorization/authorization.class.js +6 -13
  7. package/src/auth/authorization/authorization.class.js.map +1 -1
  8. package/src/auth/flows/session.verify.flow.d.ts +1 -0
  9. package/src/auth/flows/session.verify.flow.js +11 -1
  10. package/src/auth/flows/session.verify.flow.js.map +1 -1
  11. package/src/auth/flows/well-known.jwks.flow.js +2 -2
  12. package/src/auth/flows/well-known.jwks.flow.js.map +1 -1
  13. package/src/auth/jwks/dev-key-persistence.d.ts +63 -0
  14. package/src/auth/jwks/dev-key-persistence.js +219 -0
  15. package/src/auth/jwks/dev-key-persistence.js.map +1 -0
  16. package/src/auth/jwks/index.d.ts +1 -0
  17. package/src/auth/jwks/index.js +1 -0
  18. package/src/auth/jwks/index.js.map +1 -1
  19. package/src/auth/jwks/jwks.service.d.ts +7 -4
  20. package/src/auth/jwks/jwks.service.js +81 -12
  21. package/src/auth/jwks/jwks.service.js.map +1 -1
  22. package/src/auth/jwks/jwks.types.d.ts +7 -0
  23. package/src/auth/jwks/jwks.types.js.map +1 -1
  24. package/src/auth/machine-id.d.ts +5 -0
  25. package/src/auth/machine-id.js +32 -0
  26. package/src/auth/machine-id.js.map +1 -0
  27. package/src/auth/session/index.d.ts +1 -0
  28. package/src/auth/session/index.js +3 -1
  29. package/src/auth/session/index.js.map +1 -1
  30. package/src/auth/session/record/session.base.js +5 -3
  31. package/src/auth/session/record/session.base.js.map +1 -1
  32. package/src/auth/session/record/session.stateless.d.ts +2 -2
  33. package/src/auth/session/record/session.stateless.js +5 -3
  34. package/src/auth/session/record/session.stateless.js.map +1 -1
  35. package/src/auth/session/redis-session.store.d.ts +64 -0
  36. package/src/auth/session/redis-session.store.js +204 -0
  37. package/src/auth/session/redis-session.store.js.map +1 -0
  38. package/src/auth/session/session.service.d.ts +0 -2
  39. package/src/auth/session/session.service.js +1 -7
  40. package/src/auth/session/session.service.js.map +1 -1
  41. package/src/auth/session/transport-session.manager.js +3 -5
  42. package/src/auth/session/transport-session.manager.js.map +1 -1
  43. package/src/auth/session/transport-session.types.d.ts +4 -0
  44. package/src/auth/session/transport-session.types.js +4 -3
  45. package/src/auth/session/transport-session.types.js.map +1 -1
  46. package/src/auth/session/utils/session-id.utils.d.ts +12 -1
  47. package/src/auth/session/utils/session-id.utils.js +48 -9
  48. package/src/auth/session/utils/session-id.utils.js.map +1 -1
  49. package/src/auth/ui/base-layout.d.ts +0 -8
  50. package/src/auth/ui/base-layout.js +1 -14
  51. package/src/auth/ui/base-layout.js.map +1 -1
  52. package/src/auth/ui/index.d.ts +3 -4
  53. package/src/auth/ui/index.js +10 -11
  54. package/src/auth/ui/index.js.map +1 -1
  55. package/src/auth/ui/{htmx-templates.d.ts → templates.d.ts} +5 -6
  56. package/src/auth/ui/{htmx-templates.js → templates.js} +8 -15
  57. package/src/auth/ui/templates.js.map +1 -0
  58. package/src/common/decorators/decorator-utils.js.map +1 -1
  59. package/src/common/decorators/front-mcp.decorator.js +28 -2
  60. package/src/common/decorators/front-mcp.decorator.js.map +1 -1
  61. package/src/common/index.d.ts +0 -1
  62. package/src/common/index.js +0 -1
  63. package/src/common/index.js.map +1 -1
  64. package/src/common/interfaces/adapter.interface.d.ts +6 -0
  65. package/src/common/interfaces/adapter.interface.js.map +1 -1
  66. package/src/common/interfaces/execution-context.interface.d.ts +52 -3
  67. package/src/common/interfaces/execution-context.interface.js +88 -3
  68. package/src/common/interfaces/execution-context.interface.js.map +1 -1
  69. package/src/common/interfaces/flow.interface.d.ts +13 -0
  70. package/src/common/interfaces/flow.interface.js +24 -0
  71. package/src/common/interfaces/flow.interface.js.map +1 -1
  72. package/src/common/interfaces/server.interface.d.ts +9 -0
  73. package/src/common/interfaces/server.interface.js.map +1 -1
  74. package/src/common/metadata/app.metadata.d.ts +108 -0
  75. package/src/common/metadata/front-mcp.metadata.d.ts +659 -2
  76. package/src/common/metadata/front-mcp.metadata.js +3 -1
  77. package/src/common/metadata/front-mcp.metadata.js.map +1 -1
  78. package/src/common/metadata/provider.metadata.d.ts +14 -0
  79. package/src/common/metadata/provider.metadata.js +18 -2
  80. package/src/common/metadata/provider.metadata.js.map +1 -1
  81. package/src/common/metadata/tool.metadata.d.ts +33 -1
  82. package/src/common/metadata/tool.metadata.js.map +1 -1
  83. package/src/common/migrate/auth-transport.migrate.d.ts +62 -0
  84. package/src/common/migrate/auth-transport.migrate.js +140 -0
  85. package/src/common/migrate/auth-transport.migrate.js.map +1 -0
  86. package/src/common/migrate/index.d.ts +1 -0
  87. package/src/common/migrate/index.js +6 -0
  88. package/src/common/migrate/index.js.map +1 -0
  89. package/src/common/schemas/http-output.schema.d.ts +10 -2
  90. package/src/common/schemas/index.d.ts +1 -0
  91. package/src/common/schemas/index.js +1 -0
  92. package/src/common/schemas/index.js.map +1 -1
  93. package/src/common/schemas/session-header.schema.d.ts +16 -0
  94. package/src/common/schemas/session-header.schema.js +42 -0
  95. package/src/common/schemas/session-header.schema.js.map +1 -0
  96. package/src/common/tokens/front-mcp.tokens.js +3 -1
  97. package/src/common/tokens/front-mcp.tokens.js.map +1 -1
  98. package/src/common/types/options/auth.options.d.ts +233 -3
  99. package/src/common/types/options/auth.options.js +29 -40
  100. package/src/common/types/options/auth.options.js.map +1 -1
  101. package/src/common/types/options/index.d.ts +2 -0
  102. package/src/common/types/options/index.js +2 -0
  103. package/src/common/types/options/index.js.map +1 -1
  104. package/src/common/types/options/redis.options.d.ts +22 -0
  105. package/src/common/types/options/redis.options.js +45 -0
  106. package/src/common/types/options/redis.options.js.map +1 -0
  107. package/src/common/types/options/transport.options.d.ts +84 -0
  108. package/src/common/types/options/transport.options.js +121 -0
  109. package/src/common/types/options/transport.options.js.map +1 -0
  110. package/src/completion/flows/complete.flow.d.ts +17 -2
  111. package/src/context/frontmcp-context-storage.d.ts +94 -0
  112. package/src/context/frontmcp-context-storage.js +183 -0
  113. package/src/context/frontmcp-context-storage.js.map +1 -0
  114. package/src/context/frontmcp-context.d.ts +269 -0
  115. package/src/context/frontmcp-context.js +360 -0
  116. package/src/context/frontmcp-context.js.map +1 -0
  117. package/src/context/frontmcp-context.provider.d.ts +43 -0
  118. package/src/context/frontmcp-context.provider.js +61 -0
  119. package/src/context/frontmcp-context.provider.js.map +1 -0
  120. package/src/context/index.d.ts +34 -0
  121. package/src/context/index.js +64 -0
  122. package/src/context/index.js.map +1 -0
  123. package/src/context/request-context-storage.d.ts +89 -0
  124. package/src/context/request-context-storage.js +183 -0
  125. package/src/context/request-context-storage.js.map +1 -0
  126. package/src/context/request-context.d.ts +184 -0
  127. package/src/context/request-context.js +209 -0
  128. package/src/context/request-context.js.map +1 -0
  129. package/src/context/request-context.provider.d.ts +37 -0
  130. package/src/context/request-context.provider.js +51 -0
  131. package/src/context/request-context.provider.js.map +1 -0
  132. package/src/context/session-key.provider.d.ts +45 -0
  133. package/src/context/session-key.provider.js +65 -0
  134. package/src/context/session-key.provider.js.map +1 -0
  135. package/src/context/trace-context.d.ts +43 -0
  136. package/src/context/trace-context.js +142 -0
  137. package/src/context/trace-context.js.map +1 -0
  138. package/src/errors/index.d.ts +1 -1
  139. package/src/errors/index.js +3 -1
  140. package/src/errors/index.js.map +1 -1
  141. package/src/errors/mcp.error.d.ts +7 -0
  142. package/src/errors/mcp.error.js +11 -1
  143. package/src/errors/mcp.error.js.map +1 -1
  144. package/src/flows/flow.instance.d.ts +16 -0
  145. package/src/flows/flow.instance.js +166 -80
  146. package/src/flows/flow.instance.js.map +1 -1
  147. package/src/flows/flow.registry.d.ts +5 -0
  148. package/src/flows/flow.registry.js +45 -3
  149. package/src/flows/flow.registry.js.map +1 -1
  150. package/src/front-mcp/front-mcp.d.ts +12 -0
  151. package/src/front-mcp/front-mcp.js +22 -3
  152. package/src/front-mcp/front-mcp.js.map +1 -1
  153. package/src/front-mcp/front-mcp.providers.d.ts +266 -1
  154. package/src/front-mcp/front-mcp.providers.js +2 -1
  155. package/src/front-mcp/front-mcp.providers.js.map +1 -1
  156. package/src/front-mcp/serverless-handler.d.ts +28 -0
  157. package/src/front-mcp/serverless-handler.js +61 -0
  158. package/src/front-mcp/serverless-handler.js.map +1 -0
  159. package/src/hooks/hooks.utils.d.ts +1 -1
  160. package/src/hooks/hooks.utils.js +10 -3
  161. package/src/hooks/hooks.utils.js.map +1 -1
  162. package/src/index.d.ts +8 -4
  163. package/src/index.js +20 -1
  164. package/src/index.js.map +1 -1
  165. package/src/logger/instances/instance.logger.js +0 -1
  166. package/src/logger/instances/instance.logger.js.map +1 -1
  167. package/src/logging/flows/set-level.flow.d.ts +17 -2
  168. package/src/notification/notification.service.js +5 -1
  169. package/src/notification/notification.service.js.map +1 -1
  170. package/src/prompt/flows/get-prompt.flow.d.ts +97 -2
  171. package/src/prompt/flows/prompts-list.flow.d.ts +12 -1
  172. package/src/provider/provider.registry.d.ts +97 -5
  173. package/src/provider/provider.registry.js +306 -9
  174. package/src/provider/provider.registry.js.map +1 -1
  175. package/src/provider/provider.types.d.ts +21 -3
  176. package/src/provider/provider.types.js.map +1 -1
  177. package/src/resource/flows/read-resource.flow.d.ts +22 -3
  178. package/src/resource/flows/resource-templates-list.flow.d.ts +20 -1
  179. package/src/resource/flows/resources-list.flow.d.ts +20 -1
  180. package/src/resource/flows/subscribe-resource.flow.d.ts +17 -2
  181. package/src/resource/flows/unsubscribe-resource.flow.d.ts +17 -2
  182. package/src/scope/flows/http.request.flow.js +43 -7
  183. package/src/scope/flows/http.request.flow.js.map +1 -1
  184. package/src/scope/scope.instance.js +12 -5
  185. package/src/scope/scope.instance.js.map +1 -1
  186. package/src/server/adapters/base.host.adapter.d.ts +9 -0
  187. package/src/server/adapters/base.host.adapter.js.map +1 -1
  188. package/src/server/adapters/express.host.adapter.d.ts +12 -0
  189. package/src/server/adapters/express.host.adapter.js +21 -1
  190. package/src/server/adapters/express.host.adapter.js.map +1 -1
  191. package/src/server/server.instance.d.ts +3 -0
  192. package/src/server/server.instance.js +14 -7
  193. package/src/server/server.instance.js.map +1 -1
  194. package/src/tool/flows/call-tool.flow.d.ts +118 -13
  195. package/src/tool/flows/call-tool.flow.js +240 -194
  196. package/src/tool/flows/call-tool.flow.js.map +1 -1
  197. package/src/tool/flows/tools-list.flow.d.ts +25 -11
  198. package/src/tool/flows/tools-list.flow.js +82 -31
  199. package/src/tool/flows/tools-list.flow.js.map +1 -1
  200. package/src/tool/tool.instance.d.ts +1 -4
  201. package/src/transport/adapters/transport.streamable-http.adapter.js +1 -0
  202. package/src/transport/adapters/transport.streamable-http.adapter.js.map +1 -1
  203. package/src/transport/flows/handle.sse.flow.js +9 -2
  204. package/src/transport/flows/handle.sse.flow.js.map +1 -1
  205. package/src/transport/flows/handle.streamable-http.flow.js +63 -6
  206. package/src/transport/flows/handle.streamable-http.flow.js.map +1 -1
  207. package/src/transport/mcp-handlers/complete-request.handler.d.ts +27 -1
  208. package/src/transport/mcp-handlers/get-prompt-request.handler.d.ts +52 -1
  209. package/src/transport/mcp-handlers/index.d.ts +413 -7
  210. package/src/transport/mcp-handlers/initialize-request.handler.js +12 -2
  211. package/src/transport/mcp-handlers/initialize-request.handler.js.map +1 -1
  212. package/src/transport/mcp-handlers/list-prompts-request.handler.d.ts +27 -1
  213. package/src/transport/mcp-handlers/list-resource-templates-request.handler.d.ts +32 -1
  214. package/src/transport/mcp-handlers/list-resources-request.handler.d.ts +32 -1
  215. package/src/transport/mcp-handlers/list-tools-request.handler.d.ts +30 -1
  216. package/src/transport/mcp-handlers/logging-set-level-request.handler.d.ts +20 -0
  217. package/src/transport/mcp-handlers/read-resource-request.handler.d.ts +27 -1
  218. package/src/transport/mcp-handlers/subscribe-request.handler.d.ts +20 -0
  219. package/src/transport/mcp-handlers/unsubscribe-request.handler.d.ts +20 -0
  220. package/src/transport/transport.registry.d.ts +68 -4
  221. package/src/transport/transport.registry.js +313 -11
  222. package/src/transport/transport.registry.js.map +1 -1
  223. package/src/auth/ui/htmx-templates.js.map +0 -1
  224. package/src/common/providers/session.provider.d.ts +0 -13
  225. package/src/common/providers/session.provider.js +0 -27
  226. package/src/common/providers/session.provider.js.map +0 -1
@@ -12,7 +12,9 @@ exports.frontMcpBaseSchema = zod_1.z.object({
12
12
  apps: zod_1.z.array(schemas_1.annotatedFrontMcpAppSchema),
13
13
  serve: zod_1.z.boolean().optional().default(true),
14
14
  http: types_1.httpOptionsSchema.optional(),
15
- session: types_1.sessionOptionsSchema.optional(),
15
+ redis: types_1.redisOptionsSchema.optional(),
16
+ transport: types_1.transportOptionsSchema.optional().transform((val) => val ?? types_1.transportOptionsSchema.parse({})),
17
+ session: types_1.sessionOptionsSchema.optional(), // @deprecated - kept for backward compatibility
16
18
  logging: types_1.loggingOptionsSchema.optional(),
17
19
  });
18
20
  const frontMcpMultiAppSchema = exports.frontMcpBaseSchema.extend({
@@ -1 +1 @@
1
- {"version":3,"file":"front-mcp.metadata.js","sourceRoot":"","sources":["../../../../src/common/metadata/front-mcp.metadata.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,oCAakB;AAClB,wCAKoB;AA8BP,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,+BAAuB;IAC7B,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,0CAAgC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3E,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,sCAA4B,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACnE,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,0CAAgC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3E,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,oCAA0B,CAAC;IACzC,KAAK,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3C,IAAI,EAAE,yBAAiB,CAAC,QAAQ,EAAE;IAClC,OAAO,EAAE,4BAAoB,CAAC,QAAQ,EAAE;IACxC,OAAO,EAAE,4BAAoB,CAAC,QAAQ,EAAE;CACG,CAAC,CAAC;AAO/C,MAAM,sBAAsB,GAAG,0BAAkB,CAAC,MAAM,CAAC;IACvD,UAAU,EAAE,OAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,kDAAkD,CAAC;IACxG,IAAI,EAAE,yBAAiB,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;CAClC,CAAC,CAAC;AAOzE,MAAM,wBAAwB,GAAG,0BAAkB,CAAC,MAAM,CAAC;IACzD,UAAU,EAAE,OAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,6DAA6D,CAAC;IACnG,IAAI,EAAE,OAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;CAC6C,CAAC,CAAC;AAI9D,QAAA,sBAAsB,GAAG,sBAAsB,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport {\n AuthOptions,\n authOptionsSchema,\n SessionOptions,\n sessionOptionsSchema,\n ServerInfoOptions,\n serverInfoOptionsSchema,\n HttpOptions,\n httpOptionsSchema,\n LoggingOptions,\n loggingOptionsSchema,\n RawZodShape,\n AuthOptionsInput,\n} from '../types';\nimport {\n annotatedFrontMcpAppSchema,\n annotatedFrontMcpProvidersSchema,\n annotatedFrontMcpResourcesSchema,\n annotatedFrontMcpToolsSchema,\n} from '../schemas';\nimport { AppType, ProviderType, ResourceType, ToolType } from '../interfaces';\n\nexport interface FrontMcpBaseMetadata {\n info: ServerInfoOptions;\n apps: AppType[];\n http?: HttpOptions;\n session?: SessionOptions;\n logging?: LoggingOptions;\n\n serve?: boolean; // default to true\n\n /**\n * Additional providers that are available to all apps.\n */\n providers?: ProviderType[];\n\n /**\n * Shared tools that are available to all apps.\n * These are merged (additively) with app-specific tools.\n */\n tools?: ToolType[];\n\n /**\n * Shared resources that are available to all apps.\n * These are merged (additively) with app-specific resources.\n */\n resources?: ResourceType[];\n}\n\nexport const frontMcpBaseSchema = z.object({\n info: serverInfoOptionsSchema,\n providers: z.array(annotatedFrontMcpProvidersSchema).optional().default([]),\n tools: z.array(annotatedFrontMcpToolsSchema).optional().default([]),\n resources: z.array(annotatedFrontMcpResourcesSchema).optional().default([]),\n apps: z.array(annotatedFrontMcpAppSchema),\n serve: z.boolean().optional().default(true),\n http: httpOptionsSchema.optional(),\n session: sessionOptionsSchema.optional(),\n logging: loggingOptionsSchema.optional(),\n} satisfies RawZodShape<FrontMcpBaseMetadata>);\n\nexport interface FrontMcpMultiAppMetadata extends FrontMcpBaseMetadata {\n splitByApp?: false;\n auth?: AuthOptionsInput;\n}\n\nconst frontMcpMultiAppSchema = frontMcpBaseSchema.extend({\n splitByApp: z.literal(false).default(false).describe('If true, each app gets its own scope & basePath.'),\n auth: authOptionsSchema.optional().describe(\"Configures the server's default authentication provider.\"),\n} satisfies RawZodShape<FrontMcpMultiAppMetadata, FrontMcpBaseMetadata>);\n\nexport interface FrontMcpSplitByAppMetadata extends FrontMcpBaseMetadata {\n splitByApp: true;\n auth?: never;\n}\n\nconst frontMcpSplitByAppSchema = frontMcpBaseSchema.extend({\n splitByApp: z.literal(true).describe('If false, apps are grouped under the same scope & basePath.'),\n auth: z.never().optional(),\n} satisfies RawZodShape<FrontMcpSplitByAppMetadata, FrontMcpBaseMetadata>);\n\nexport type FrontMcpMetadata = FrontMcpMultiAppMetadata | FrontMcpSplitByAppMetadata;\n\nexport const frontMcpMetadataSchema = frontMcpMultiAppSchema.or(frontMcpSplitByAppSchema);\n\nexport type FrontMcpMultiAppConfig = z.infer<typeof frontMcpMultiAppSchema>;\nexport type FrontMcpSplitByAppConfig = z.infer<typeof frontMcpSplitByAppSchema>;\n\nexport type FrontMcpConfigType = z.infer<typeof frontMcpMetadataSchema>;\n\nexport interface AppScopeMetadata extends Omit<FrontMcpSplitByAppMetadata, 'auth' | 'splitByApp'> {\n id: string;\n apps: [AppType];\n auth?: AuthOptions;\n}\n\nexport interface MultiAppScopeMetadata extends FrontMcpMultiAppMetadata {\n id: string;\n apps: AppType[];\n}\n\nexport type ScopeMetadata = AppScopeMetadata | MultiAppScopeMetadata;\n"]}
1
+ {"version":3,"file":"front-mcp.metadata.js","sourceRoot":"","sources":["../../../../src/common/metadata/front-mcp.metadata.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,oCAiBkB;AAClB,wCAKoB;AA+CP,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,+BAAuB;IAC7B,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,0CAAgC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3E,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,sCAA4B,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACnE,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,0CAAgC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3E,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,oCAA0B,CAAC;IACzC,KAAK,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3C,IAAI,EAAE,yBAAiB,CAAC,QAAQ,EAAE;IAClC,KAAK,EAAE,0BAAkB,CAAC,QAAQ,EAAE;IACpC,SAAS,EAAE,8BAAsB,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,8BAAsB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACxG,OAAO,EAAE,4BAAoB,CAAC,QAAQ,EAAE,EAAE,gDAAgD;IAC1F,OAAO,EAAE,4BAAoB,CAAC,QAAQ,EAAE;CACG,CAAC,CAAC;AAO/C,MAAM,sBAAsB,GAAG,0BAAkB,CAAC,MAAM,CAAC;IACvD,UAAU,EAAE,OAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,kDAAkD,CAAC;IACxG,IAAI,EAAE,yBAAiB,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;CAClC,CAAC,CAAC;AAOzE,MAAM,wBAAwB,GAAG,0BAAkB,CAAC,MAAM,CAAC;IACzD,UAAU,EAAE,OAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,6DAA6D,CAAC;IACnG,IAAI,EAAE,OAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;CAC6C,CAAC,CAAC;AAI9D,QAAA,sBAAsB,GAAG,sBAAsB,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport {\n AuthOptions,\n authOptionsSchema,\n SessionOptions,\n sessionOptionsSchema,\n ServerInfoOptions,\n serverInfoOptionsSchema,\n HttpOptions,\n httpOptionsSchema,\n LoggingOptions,\n loggingOptionsSchema,\n RawZodShape,\n AuthOptionsInput,\n RedisOptionsInput,\n redisOptionsSchema,\n TransportOptionsInput,\n transportOptionsSchema,\n} from '../types';\nimport {\n annotatedFrontMcpAppSchema,\n annotatedFrontMcpProvidersSchema,\n annotatedFrontMcpResourcesSchema,\n annotatedFrontMcpToolsSchema,\n} from '../schemas';\nimport { AppType, ProviderType, ResourceType, ToolType } from '../interfaces';\n\nexport interface FrontMcpBaseMetadata {\n info: ServerInfoOptions;\n apps: AppType[];\n http?: HttpOptions;\n logging?: LoggingOptions;\n\n serve?: boolean; // default to true\n\n /**\n * Shared Redis configuration\n * Used by transport persistence and auth token storage\n */\n redis?: RedisOptionsInput;\n\n /**\n * Transport and session lifecycle configuration\n * Controls transport protocols, session management, and persistence\n * @default {} (all transport options use their schema defaults)\n */\n transport?: TransportOptionsInput; // Optional in input, but always defined in output\n\n /**\n * @deprecated Use `transport` instead. Session config has been merged into transport.\n */\n session?: SessionOptions;\n\n /**\n * Additional providers that are available to all apps.\n */\n providers?: ProviderType[];\n\n /**\n * Shared tools that are available to all apps.\n * These are merged (additively) with app-specific tools.\n */\n tools?: ToolType[];\n\n /**\n * Shared resources that are available to all apps.\n * These are merged (additively) with app-specific resources.\n */\n resources?: ResourceType[];\n}\n\nexport const frontMcpBaseSchema = z.object({\n info: serverInfoOptionsSchema,\n providers: z.array(annotatedFrontMcpProvidersSchema).optional().default([]),\n tools: z.array(annotatedFrontMcpToolsSchema).optional().default([]),\n resources: z.array(annotatedFrontMcpResourcesSchema).optional().default([]),\n apps: z.array(annotatedFrontMcpAppSchema),\n serve: z.boolean().optional().default(true),\n http: httpOptionsSchema.optional(),\n redis: redisOptionsSchema.optional(),\n transport: transportOptionsSchema.optional().transform((val) => val ?? transportOptionsSchema.parse({})),\n session: sessionOptionsSchema.optional(), // @deprecated - kept for backward compatibility\n logging: loggingOptionsSchema.optional(),\n} satisfies RawZodShape<FrontMcpBaseMetadata>);\n\nexport interface FrontMcpMultiAppMetadata extends FrontMcpBaseMetadata {\n splitByApp?: false;\n auth?: AuthOptionsInput;\n}\n\nconst frontMcpMultiAppSchema = frontMcpBaseSchema.extend({\n splitByApp: z.literal(false).default(false).describe('If true, each app gets its own scope & basePath.'),\n auth: authOptionsSchema.optional().describe(\"Configures the server's default authentication provider.\"),\n} satisfies RawZodShape<FrontMcpMultiAppMetadata, FrontMcpBaseMetadata>);\n\nexport interface FrontMcpSplitByAppMetadata extends FrontMcpBaseMetadata {\n splitByApp: true;\n auth?: never;\n}\n\nconst frontMcpSplitByAppSchema = frontMcpBaseSchema.extend({\n splitByApp: z.literal(true).describe('If false, apps are grouped under the same scope & basePath.'),\n auth: z.never().optional(),\n} satisfies RawZodShape<FrontMcpSplitByAppMetadata, FrontMcpBaseMetadata>);\n\nexport type FrontMcpMetadata = FrontMcpMultiAppMetadata | FrontMcpSplitByAppMetadata;\n\nexport const frontMcpMetadataSchema = frontMcpMultiAppSchema.or(frontMcpSplitByAppSchema);\n\nexport type FrontMcpMultiAppConfig = z.infer<typeof frontMcpMultiAppSchema>;\nexport type FrontMcpSplitByAppConfig = z.infer<typeof frontMcpSplitByAppSchema>;\n\nexport type FrontMcpConfigType = z.infer<typeof frontMcpMetadataSchema>;\n\nexport interface AppScopeMetadata extends Omit<FrontMcpSplitByAppMetadata, 'auth' | 'splitByApp'> {\n id: string;\n apps: [AppType];\n auth?: AuthOptions;\n}\n\nexport interface MultiAppScopeMetadata extends FrontMcpMultiAppMetadata {\n id: string;\n apps: AppType[];\n}\n\nexport type ScopeMetadata = AppScopeMetadata | MultiAppScopeMetadata;\n"]}
@@ -10,10 +10,24 @@ export interface ProviderMetadata {
10
10
  }
11
11
  /**
12
12
  * Provider lifetime scope semantics.
13
+ *
14
+ * - GLOBAL: Singleton, shared across all requests
15
+ * - CONTEXT: Per-context instance (combines session + request data)
16
+ * - SESSION: deprecated Use CONTEXT instead
17
+ * - REQUEST: deprecated Use CONTEXT instead
13
18
  */
14
19
  export declare enum ProviderScope {
20
+ /** Singleton, shared across all requests */
15
21
  GLOBAL = "global",
22
+ /** Per-context instance (unified session + request scope) */
23
+ CONTEXT = "context",
24
+ /**
25
+ * @deprecated Use CONTEXT instead. Maps to CONTEXT internally.
26
+ */
16
27
  SESSION = "session",
28
+ /**
29
+ * @deprecated Use CONTEXT instead. Maps to CONTEXT internally.
30
+ */
17
31
  REQUEST = "request"
18
32
  }
19
33
  export declare const frontMcpProviderMetadataSchema: z.ZodObject<{
@@ -4,17 +4,33 @@ exports.frontMcpProviderMetadataSchema = exports.ProviderScope = void 0;
4
4
  const zod_1 = require("zod");
5
5
  /**
6
6
  * Provider lifetime scope semantics.
7
+ *
8
+ * - GLOBAL: Singleton, shared across all requests
9
+ * - CONTEXT: Per-context instance (combines session + request data)
10
+ * - SESSION: deprecated Use CONTEXT instead
11
+ * - REQUEST: deprecated Use CONTEXT instead
7
12
  */
8
13
  var ProviderScope;
9
14
  (function (ProviderScope) {
15
+ /** Singleton, shared across all requests */
10
16
  ProviderScope["GLOBAL"] = "global";
17
+ /** Per-context instance (unified session + request scope) */
18
+ ProviderScope["CONTEXT"] = "context";
19
+ /**
20
+ * @deprecated Use CONTEXT instead. Maps to CONTEXT internally.
21
+ */
11
22
  ProviderScope["SESSION"] = "session";
23
+ /**
24
+ * @deprecated Use CONTEXT instead. Maps to CONTEXT internally.
25
+ */
12
26
  ProviderScope["REQUEST"] = "request";
13
27
  })(ProviderScope || (exports.ProviderScope = ProviderScope = {}));
14
- exports.frontMcpProviderMetadataSchema = zod_1.z.object({
28
+ exports.frontMcpProviderMetadataSchema = zod_1.z
29
+ .object({
15
30
  id: zod_1.z.string().optional(),
16
31
  name: zod_1.z.string().min(1),
17
32
  description: zod_1.z.string().optional(),
18
33
  scope: zod_1.z.nativeEnum(ProviderScope).optional().default(ProviderScope.GLOBAL),
19
- }).passthrough();
34
+ })
35
+ .passthrough();
20
36
  //# sourceMappingURL=provider.metadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.metadata.js","sourceRoot":"","sources":["../../../../src/common/metadata/provider.metadata.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAcxB;;GAEG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;AACrB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAEY,QAAA,8BAA8B,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,KAAK,EAAE,OAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC;CACpC,CAAC,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import { z } from 'zod';\nimport { RawZodShape } from '../types';\n\n\n/**\n * Declarative metadata describing what a FrontMcpProvider contributes at app scope.\n */\nexport interface ProviderMetadata {\n id?: string;\n name: string;\n description?: string;\n scope?: ProviderScope;\n}\n\n/**\n * Provider lifetime scope semantics.\n */\nexport enum ProviderScope {\n GLOBAL = 'global',\n SESSION = 'session',\n REQUEST = 'request',\n}\n\nexport const frontMcpProviderMetadataSchema = z.object({\n id: z.string().optional(),\n name: z.string().min(1),\n description: z.string().optional(),\n scope: z.nativeEnum(ProviderScope).optional().default(ProviderScope.GLOBAL),\n} satisfies RawZodShape<ProviderMetadata>).passthrough();\n\n"]}
1
+ {"version":3,"file":"provider.metadata.js","sourceRoot":"","sources":["../../../../src/common/metadata/provider.metadata.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAaxB;;;;;;;GAOG;AACH,IAAY,aAaX;AAbD,WAAY,aAAa;IACvB,4CAA4C;IAC5C,kCAAiB,CAAA;IACjB,6DAA6D;IAC7D,oCAAmB,CAAA;IACnB;;OAEG;IACH,oCAAmB,CAAA;IACnB;;OAEG;IACH,oCAAmB,CAAA;AACrB,CAAC,EAbW,aAAa,6BAAb,aAAa,QAaxB;AAEY,QAAA,8BAA8B,GAAG,OAAC;KAC5C,MAAM,CAAC;IACN,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,KAAK,EAAE,OAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC;CACpC,CAAC;KACzC,WAAW,EAAE,CAAC","sourcesContent":["import { z } from 'zod';\nimport { RawZodShape } from '../types';\n\n/**\n * Declarative metadata describing what a FrontMcpProvider contributes at app scope.\n */\nexport interface ProviderMetadata {\n id?: string;\n name: string;\n description?: string;\n scope?: ProviderScope;\n}\n\n/**\n * Provider lifetime scope semantics.\n *\n * - GLOBAL: Singleton, shared across all requests\n * - CONTEXT: Per-context instance (combines session + request data)\n * - SESSION: deprecated Use CONTEXT instead\n * - REQUEST: deprecated Use CONTEXT instead\n */\nexport enum ProviderScope {\n /** Singleton, shared across all requests */\n GLOBAL = 'global',\n /** Per-context instance (unified session + request scope) */\n CONTEXT = 'context',\n /**\n * @deprecated Use CONTEXT instead. Maps to CONTEXT internally.\n */\n SESSION = 'session',\n /**\n * @deprecated Use CONTEXT instead. Maps to CONTEXT internally.\n */\n REQUEST = 'request',\n}\n\nexport const frontMcpProviderMetadataSchema = z\n .object({\n id: z.string().optional(),\n name: z.string().min(1),\n description: z.string().optional(),\n scope: z.nativeEnum(ProviderScope).optional().default(ProviderScope.GLOBAL),\n } satisfies RawZodShape<ProviderMetadata>)\n .passthrough();\n"]}
@@ -80,6 +80,14 @@ export declare const ImageOutputSchema: z.ZodObject<{
80
80
  type: z.ZodLiteral<"image">;
81
81
  data: z.ZodString;
82
82
  mimeType: z.ZodString;
83
+ annotations: z.ZodOptional<z.ZodObject<{
84
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
85
+ user: "user";
86
+ assistant: "assistant";
87
+ }>>>;
88
+ priority: z.ZodOptional<z.ZodNumber>;
89
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
90
+ }, z.core.$strip>>;
83
91
  _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
84
92
  }, z.core.$strip>;
85
93
  export type ImageOutput = z.output<typeof ImageOutputSchema>;
@@ -91,6 +99,14 @@ export declare const AudioOutputSchema: z.ZodObject<{
91
99
  type: z.ZodLiteral<"audio">;
92
100
  data: z.ZodString;
93
101
  mimeType: z.ZodString;
102
+ annotations: z.ZodOptional<z.ZodObject<{
103
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
104
+ user: "user";
105
+ assistant: "assistant";
106
+ }>>>;
107
+ priority: z.ZodOptional<z.ZodNumber>;
108
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
109
+ }, z.core.$strip>>;
94
110
  _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
95
111
  }, z.core.$strip>;
96
112
  export type AudioOutput = z.output<typeof AudioOutputSchema>;
@@ -111,6 +127,14 @@ export declare const ResourceOutputSchema: z.ZodObject<{
111
127
  _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
112
128
  blob: z.ZodString;
113
129
  }, z.core.$strip>]>;
130
+ annotations: z.ZodOptional<z.ZodObject<{
131
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
132
+ user: "user";
133
+ assistant: "assistant";
134
+ }>>>;
135
+ priority: z.ZodOptional<z.ZodNumber>;
136
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
137
+ }, z.core.$strip>>;
114
138
  _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
115
139
  }, z.core.$strip>;
116
140
  export type ResourceOutput = z.output<typeof ResourceOutputSchema>;
@@ -122,6 +146,14 @@ export declare const ResourceLinkOutputSchema: z.ZodObject<{
122
146
  uri: z.ZodString;
123
147
  description: z.ZodOptional<z.ZodString>;
124
148
  mimeType: z.ZodOptional<z.ZodString>;
149
+ annotations: z.ZodOptional<z.ZodObject<{
150
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
151
+ user: "user";
152
+ assistant: "assistant";
153
+ }>>>;
154
+ priority: z.ZodOptional<z.ZodNumber>;
155
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
156
+ }, z.core.$strip>>;
125
157
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
126
158
  icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
127
159
  src: z.ZodString;
@@ -142,7 +174,7 @@ export type ToolSingleOutputType = PrimitiveOutputType | ImageOutputType | Audio
142
174
  * Default default tool schema is {}
143
175
  */
144
176
  export type ToolOutputType = ToolSingleOutputType | ToolSingleOutputType[] | undefined;
145
- export type ToolInputType = z.ZodRawShape;
177
+ export type ToolInputType = z.ZodRawShape | z.ZodObject<any>;
146
178
  /**
147
179
  * Declarative metadata describing what an McpTool contributes.
148
180
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tool.metadata.js","sourceRoot":"","sources":["../../../../src/common/metadata/tool.metadata.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAMxB,iEAK4C;AAyE5C,MAAM,wBAAwB,GAAG,OAAC;KAC/B,MAAM,CAAC;IACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,YAAY,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACpC,eAAe,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACvC,cAAc,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACtC,aAAa,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACC,CAAC;KACxC,WAAW,EAAE,CAAC;AAmBJ,QAAA,iBAAiB,GAAG,6BAAkB,CAAC;AAOvC,QAAA,iBAAiB,GAAG,6BAAkB,CAAC;AAOvC,QAAA,oBAAoB,GAAG,iCAAsB,CAAC;AAO9C,QAAA,wBAAwB,GAAG,6BAAkB,CAAC;AAyF3D;;;;;GAKG;AAEH,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AAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,WAAW,EAAE,OAAC,CAAC,UAAU,CAAC,MAAM,CAAC;IACjC,cAAc,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAClC,YAAY,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACzC,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3C,WAAW,EAAE,wBAAwB,CAAC,QAAQ,EAAE;IAChD,iBAAiB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACxD,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE;IAC/C,EAAE,EAAE,OAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC+B,CAAC;KACjE,WAAW,EAAE,CAAC","sourcesContent":["import { z } from 'zod';\nimport { RawZodShape } from '../types';\nimport type { JSONSchema } from 'zod/v4/core';\n\n/** JSON Schema type from Zod v4 */\ntype JsonSchema = JSONSchema.JSONSchema;\nimport {\n ImageContentSchema,\n AudioContentSchema,\n ResourceLinkSchema,\n EmbeddedResourceSchema,\n} from '@modelcontextprotocol/sdk/types.js';\nimport { ToolUIConfig } from './tool-ui.metadata';\nimport { ToolInputOf, ToolOutputOf } from '../decorators';\n\ndeclare global {\n /**\n * Declarative metadata extends to the an McpTool decorator.\n */\n interface ExtendFrontMcpToolMetadata {}\n}\n\n/**\n * Example input/output pair for a tool, used in documentation and describe output.\n */\nexport interface ToolExample {\n /**\n * Description of what this example demonstrates.\n */\n description: string;\n\n /**\n * Example input values for the tool.\n */\n input: Record<string, unknown>;\n\n /**\n * Optional expected output for the example.\n */\n output?: unknown;\n}\n\nexport interface ToolAnnotations {\n [x: string]: unknown;\n\n /**\n * A human-readable title for the tool.\n */\n title?: string;\n /**\n * If true, the tool does not modify its environment.\n *\n * Default: false\n */\n readOnlyHint?: boolean;\n /**\n * If true, the tool may perform destructive updates to its environment.\n * If false, the tool performs only additive updates.\n *\n * (This property is meaningful only when `readOnlyHint == false`)\n *\n * Default: true\n */\n destructiveHint?: boolean;\n /**\n * If true, calling the tool repeatedly with the same arguments\n * will have no additional effect on the its environment.\n *\n * (This property is meaningful only when `readOnlyHint == false`)\n *\n * Default: false\n */\n idempotentHint?: boolean;\n /**\n * If true, this tool may interact with an \"open world\" of external\n * entities. If false, the tool's domain of interaction is closed.\n * For example, the world of a web search tool is open, whereas that\n * of a memory tool is not.\n *\n * Default: true\n */\n openWorldHint?: boolean;\n}\n\nconst mcpToolAnnotationsSchema = z\n .object({\n title: z.string().optional(),\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n } satisfies RawZodShape<ToolAnnotations>)\n .passthrough();\n\n/**\n * Tool response type text: include if outputSchema is zod primitive types\n */\ntype PrimitiveOutputType =\n | 'string'\n | 'number'\n | 'date'\n | 'boolean'\n | z.ZodString\n | z.ZodNumber\n | z.ZodBoolean\n | z.ZodBigInt\n | z.ZodDate;\n/**\n * Tool response type image, will use the ImageContentSchema from MCP types\n */\ntype ImageOutputType = 'image';\nexport const ImageOutputSchema = ImageContentSchema;\nexport type ImageOutput = z.output<typeof ImageOutputSchema>;\n\n/**\n * Tool response type audio, will use the AudioContentSchema from MCP types\n */\ntype AudioOutputType = 'audio';\nexport const AudioOutputSchema = AudioContentSchema;\nexport type AudioOutput = z.output<typeof AudioOutputSchema>;\n\n/**\n * Tool response type resource, will use the EmbeddedResourceSchema from MCP types\n */\ntype ResourceOutputType = 'resource';\nexport const ResourceOutputSchema = EmbeddedResourceSchema;\nexport type ResourceOutput = z.output<typeof ResourceOutputSchema>;\n\n/**\n * Tool response type resource_link, will use the ResourceLinkSchema from MCP types\n */\ntype ResourceLinkOutputType = 'resource_link';\nexport const ResourceLinkOutputSchema = ResourceLinkSchema;\nexport type ResourceLinkOutput = z.output<typeof ResourceLinkOutputSchema>;\n\n/**\n * Tool response type json, ZodRawShape for fast usage\n */\ntype StructuredOutputType =\n | z.ZodRawShape\n | z.ZodObject<any>\n | z.ZodArray<z.ZodType>\n | z.ZodUnion<[z.ZodObject<any>, ...z.ZodObject<any>[]]>\n | z.ZodDiscriminatedUnion<z.ZodObject<any>[]>;\n\nexport type ToolSingleOutputType =\n | PrimitiveOutputType\n | ImageOutputType\n | AudioOutputType\n | ResourceOutputType\n | ResourceLinkOutputType\n | StructuredOutputType;\n\n/**\n * Default default tool schema is {}\n */\nexport type ToolOutputType = ToolSingleOutputType | ToolSingleOutputType[] | undefined;\nexport type ToolInputType = z.ZodRawShape;\n\n/**\n * Declarative metadata describing what an McpTool contributes.\n */\nexport interface ToolMetadata<InSchema = ToolInputType, OutSchema extends ToolOutputType = ToolOutputType>\n extends ExtendFrontMcpToolMetadata {\n /**\n * Optional unique identifier for the tool.\n * If omitted, a consumer may derive an ID from the class or file name.\n */\n id?: string;\n\n /**\n * Human‑readable name of the tool, used in UIs, logs, and discovery.\n */\n name: string;\n\n /**\n * Short summary describing what the tool does and when to use it.\n */\n description?: string;\n\n /**\n * Zod schema describing the expected input payload for the tool.\n * Used for validation and for generating automatic docs/UX.\n */\n inputSchema: InSchema;\n /**\n * Zod schema describing the expected input payload for the tool.\n * Used for validation and for generating automatic docs/UX.\n */\n rawInputSchema?: JsonSchema;\n\n /**\n * Zod schema describing the structure of the tool's successful output.\n */\n outputSchema?: OutSchema;\n\n /**\n * Optional list of tags/labels that categorize the tool for discovery and filtering.\n */\n tags?: string[];\n\n annotations?: ToolAnnotations;\n\n /**\n * If true, the tool will not be shown in the tool/list action results.\n * this method can still be called directly with tool/call even if hidden.\n * use case: tools that are intended to be private or internal. (usually for testing / private apis)\n * Default: false\n */\n hideFromDiscovery?: boolean;\n\n /**\n * Optional usage examples for the tool.\n * These are used by codecall:describe to provide accurate usage examples.\n * If provided, these take precedence over auto-generated examples.\n */\n examples?: ToolExample[];\n\n ui?: ToolUIConfig<ToolInputOf<InSchema>, ToolOutputOf<OutSchema>>;\n}\n\n/**\n * Runtime schema for ToolSingleOutputType:\n * - literals ('string', 'image', ...)\n * - any Zod schema (ZodObject, ZodArray, etc.)\n * - raw shapes (Record<string, ZodTypeAny>)\n */\n\nconst primitiveOutputLiteralSchema = z.enum(['string', 'number', 'date', 'boolean']);\nconst specialOutputLiteralSchema = z.enum(['image', 'audio', 'resource', 'resource_link']);\n\nconst outputLiteralSchema = z.union([primitiveOutputLiteralSchema, specialOutputLiteralSchema]);\n\n// Any Zod schema instance (object, array, union, etc.)\nconst zodSchemaInstanceSchema = z.instanceof(z.ZodType);\n\n// Raw shape: { field: z.string(), ... }\nconst zodRawShapeSchema = z.record(z.string(), zodSchemaInstanceSchema);\n\nconst toolSingleOutputSchema = z.union([outputLiteralSchema, zodSchemaInstanceSchema, zodRawShapeSchema]);\n\n// ToolOutputType = ToolSingleOutputType | ToolSingleOutputType[]\nconst toolOutputSchema = z.union([toolSingleOutputSchema, z.array(toolSingleOutputSchema)]);\nconst toolExampleSchema = z.object({\n description: z.string(),\n input: z.record(z.string(), z.unknown()),\n output: z.unknown().optional(),\n});\n\nexport const frontMcpToolMetadataSchema = z\n .object({\n id: z.string().optional(),\n name: z.string().min(1),\n description: z.string().optional(),\n inputSchema: z.instanceof(Object),\n rawInputSchema: z.any().optional(),\n outputSchema: toolOutputSchema.optional(),\n tags: z.array(z.string().min(1)).optional(),\n annotations: mcpToolAnnotationsSchema.optional(),\n hideFromDiscovery: z.boolean().optional().default(false),\n examples: z.array(toolExampleSchema).optional(),\n ui: z.looseObject({}).optional(),\n } satisfies RawZodShape<ToolMetadata, ExtendFrontMcpToolMetadata>)\n .passthrough();\n"]}
1
+ {"version":3,"file":"tool.metad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AC,iBAAiB,CAAC,CAAC,QAAQ,EAAE;IAC/C,EAAE,EAAE,OAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC+B,CAAC;KACjE,WAAW,EAAE,CAAC","sourcesContent":["import { z } from 'zod';\nimport { RawZodShape } from '../types';\nimport type { JSONSchema } from 'zod/v4/core';\n\n/** JSON Schema type from Zod v4 */\ntype JsonSchema = JSONSchema.JSONSchema;\nimport {\n ImageContentSchema,\n AudioContentSchema,\n ResourceLinkSchema,\n EmbeddedResourceSchema,\n} from '@modelcontextprotocol/sdk/types.js';\nimport { ToolUIConfig } from './tool-ui.metadata';\nimport { ToolInputOf, ToolOutputOf } from '../decorators';\n\ndeclare global {\n /**\n * Declarative metadata extends to the an McpTool decorator.\n */\n interface ExtendFrontMcpToolMetadata {}\n}\n\n/**\n * Example input/output pair for a tool, used in documentation and describe output.\n */\nexport interface ToolExample {\n /**\n * Description of what this example demonstrates.\n */\n description: string;\n\n /**\n * Example input values for the tool.\n */\n input: Record<string, unknown>;\n\n /**\n * Optional expected output for the example.\n */\n output?: unknown;\n}\n\nexport interface ToolAnnotations {\n [x: string]: unknown;\n\n /**\n * A human-readable title for the tool.\n */\n title?: string;\n /**\n * If true, the tool does not modify its environment.\n *\n * Default: false\n */\n readOnlyHint?: boolean;\n /**\n * If true, the tool may perform destructive updates to its environment.\n * If false, the tool performs only additive updates.\n *\n * (This property is meaningful only when `readOnlyHint == false`)\n *\n * Default: true\n */\n destructiveHint?: boolean;\n /**\n * If true, calling the tool repeatedly with the same arguments\n * will have no additional effect on the its environment.\n *\n * (This property is meaningful only when `readOnlyHint == false`)\n *\n * Default: false\n */\n idempotentHint?: boolean;\n /**\n * If true, this tool may interact with an \"open world\" of external\n * entities. If false, the tool's domain of interaction is closed.\n * For example, the world of a web search tool is open, whereas that\n * of a memory tool is not.\n *\n * Default: true\n */\n openWorldHint?: boolean;\n}\n\nconst mcpToolAnnotationsSchema = z\n .object({\n title: z.string().optional(),\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n } satisfies RawZodShape<ToolAnnotations>)\n .passthrough();\n\n/**\n * Tool response type text: include if outputSchema is zod primitive types\n */\ntype PrimitiveOutputType =\n | 'string'\n | 'number'\n | 'date'\n | 'boolean'\n | z.ZodString\n | z.ZodNumber\n | z.ZodBoolean\n | z.ZodBigInt\n | z.ZodDate;\n/**\n * Tool response type image, will use the ImageContentSchema from MCP types\n */\ntype ImageOutputType = 'image';\nexport const ImageOutputSchema = ImageContentSchema;\nexport type ImageOutput = z.output<typeof ImageOutputSchema>;\n\n/**\n * Tool response type audio, will use the AudioContentSchema from MCP types\n */\ntype AudioOutputType = 'audio';\nexport const AudioOutputSchema = AudioContentSchema;\nexport type AudioOutput = z.output<typeof AudioOutputSchema>;\n\n/**\n * Tool response type resource, will use the EmbeddedResourceSchema from MCP types\n */\ntype ResourceOutputType = 'resource';\nexport const ResourceOutputSchema = EmbeddedResourceSchema;\nexport type ResourceOutput = z.output<typeof ResourceOutputSchema>;\n\n/**\n * Tool response type resource_link, will use the ResourceLinkSchema from MCP types\n */\ntype ResourceLinkOutputType = 'resource_link';\nexport const ResourceLinkOutputSchema = ResourceLinkSchema;\nexport type ResourceLinkOutput = z.output<typeof ResourceLinkOutputSchema>;\n\n/**\n * Tool response type json, ZodRawShape for fast usage\n */\ntype StructuredOutputType =\n | z.ZodRawShape\n | z.ZodObject<any>\n | z.ZodArray<z.ZodType>\n | z.ZodUnion<[z.ZodObject<any>, ...z.ZodObject<any>[]]>\n | z.ZodDiscriminatedUnion<z.ZodObject<any>[]>;\n\nexport type ToolSingleOutputType =\n | PrimitiveOutputType\n | ImageOutputType\n | AudioOutputType\n | ResourceOutputType\n | ResourceLinkOutputType\n | StructuredOutputType;\n\n/**\n * Default default tool schema is {}\n */\nexport type ToolOutputType = ToolSingleOutputType | ToolSingleOutputType[] | undefined;\nexport type ToolInputType = z.ZodRawShape | z.ZodObject<any>;\n\n/**\n * Declarative metadata describing what an McpTool contributes.\n */\nexport interface ToolMetadata<InSchema = ToolInputType, OutSchema extends ToolOutputType = ToolOutputType>\n extends ExtendFrontMcpToolMetadata {\n /**\n * Optional unique identifier for the tool.\n * If omitted, a consumer may derive an ID from the class or file name.\n */\n id?: string;\n\n /**\n * Human‑readable name of the tool, used in UIs, logs, and discovery.\n */\n name: string;\n\n /**\n * Short summary describing what the tool does and when to use it.\n */\n description?: string;\n\n /**\n * Zod schema describing the expected input payload for the tool.\n * Used for validation and for generating automatic docs/UX.\n */\n inputSchema: InSchema;\n /**\n * Zod schema describing the expected input payload for the tool.\n * Used for validation and for generating automatic docs/UX.\n */\n rawInputSchema?: JsonSchema;\n\n /**\n * Zod schema describing the structure of the tool's successful output.\n */\n outputSchema?: OutSchema;\n\n /**\n * Optional list of tags/labels that categorize the tool for discovery and filtering.\n */\n tags?: string[];\n\n annotations?: ToolAnnotations;\n\n /**\n * If true, the tool will not be shown in the tool/list action results.\n * this method can still be called directly with tool/call even if hidden.\n * use case: tools that are intended to be private or internal. (usually for testing / private apis)\n * Default: false\n */\n hideFromDiscovery?: boolean;\n\n /**\n * Optional usage examples for the tool.\n * These are used by codecall:describe to provide accurate usage examples.\n * If provided, these take precedence over auto-generated examples.\n */\n examples?: ToolExample[];\n\n ui?: ToolUIConfig<ToolInputOf<InSchema>, ToolOutputOf<OutSchema>>;\n}\n\n/**\n * Runtime schema for ToolSingleOutputType:\n * - literals ('string', 'image', ...)\n * - any Zod schema (ZodObject, ZodArray, etc.)\n * - raw shapes (Record<string, ZodTypeAny>)\n */\n\nconst primitiveOutputLiteralSchema = z.enum(['string', 'number', 'date', 'boolean']);\nconst specialOutputLiteralSchema = z.enum(['image', 'audio', 'resource', 'resource_link']);\n\nconst outputLiteralSchema = z.union([primitiveOutputLiteralSchema, specialOutputLiteralSchema]);\n\n// Any Zod schema instance (object, array, union, etc.)\nconst zodSchemaInstanceSchema = z.instanceof(z.ZodType);\n\n// Raw shape: { field: z.string(), ... }\nconst zodRawShapeSchema = z.record(z.string(), zodSchemaInstanceSchema);\n\nconst toolSingleOutputSchema = z.union([outputLiteralSchema, zodSchemaInstanceSchema, zodRawShapeSchema]);\n\n// ToolOutputType = ToolSingleOutputType | ToolSingleOutputType[]\nconst toolOutputSchema = z.union([toolSingleOutputSchema, z.array(toolSingleOutputSchema)]);\nconst toolExampleSchema = z.object({\n description: z.string(),\n input: z.record(z.string(), z.unknown()),\n output: z.unknown().optional(),\n});\n\nexport const frontMcpToolMetadataSchema = z\n .object({\n id: z.string().optional(),\n name: z.string().min(1),\n description: z.string().optional(),\n inputSchema: z.instanceof(Object),\n rawInputSchema: z.any().optional(),\n outputSchema: toolOutputSchema.optional(),\n tags: z.array(z.string().min(1)).optional(),\n annotations: mcpToolAnnotationsSchema.optional(),\n hideFromDiscovery: z.boolean().optional().default(false),\n examples: z.array(toolExampleSchema).optional(),\n ui: z.looseObject({}).optional(),\n } satisfies RawZodShape<ToolMetadata, ExtendFrontMcpToolMetadata>)\n .passthrough();\n"]}
@@ -0,0 +1,62 @@
1
+ import type { TransportOptionsInput } from '../types/options/transport.options';
2
+ import type { RedisOptionsInput } from '../types/options/redis.options';
3
+ import type { SessionOptions } from '../types/options/session.options';
4
+ /**
5
+ * Old transport config structure (nested under auth)
6
+ */
7
+ interface OldTransportConfig {
8
+ enableLegacySSE?: boolean;
9
+ enableSseListener?: boolean;
10
+ enableStreamableHttp?: boolean;
11
+ enableStatelessHttp?: boolean;
12
+ enableStatefulHttp?: boolean;
13
+ requireSessionForStreamable?: boolean;
14
+ recreation?: {
15
+ enabled?: boolean;
16
+ redis?: RedisOptionsInput;
17
+ defaultTtlMs?: number;
18
+ };
19
+ }
20
+ /**
21
+ * Old auth config structure (with nested transport)
22
+ */
23
+ interface OldAuthConfig {
24
+ mode: string;
25
+ transport?: OldTransportConfig;
26
+ [key: string]: unknown;
27
+ }
28
+ /**
29
+ * Metadata structure for migration
30
+ */
31
+ interface MigratableMetadata {
32
+ auth?: OldAuthConfig;
33
+ session?: SessionOptions;
34
+ transport?: TransportOptionsInput;
35
+ redis?: RedisOptionsInput;
36
+ }
37
+ /**
38
+ * Reset deprecation warning flag (for testing)
39
+ */
40
+ export declare function resetDeprecationWarning(): void;
41
+ /**
42
+ * Check if config needs migration
43
+ */
44
+ export declare function needsMigration(metadata: MigratableMetadata): boolean;
45
+ /**
46
+ * Migrate old config structure to new structure
47
+ *
48
+ * Returns the migrated values that should be applied to the metadata
49
+ */
50
+ export declare function migrateAuthTransportConfig(metadata: MigratableMetadata): {
51
+ transport?: TransportOptionsInput;
52
+ redis?: RedisOptionsInput;
53
+ auth?: OldAuthConfig;
54
+ };
55
+ /**
56
+ * Apply migration to metadata (mutates in place for decorator use)
57
+ *
58
+ * This function takes a metadata object with the old config structure
59
+ * and transforms it to the new structure in place.
60
+ */
61
+ export declare function applyMigration<T extends MigratableMetadata>(metadata: T): T;
62
+ export {};
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ // common/migrate/auth-transport.migrate.ts
3
+ //
4
+ // Migration helper for auth.transport -> transport config
5
+ //
6
+ // This file handles backward compatibility for the old config structure.
7
+ // DELETE THIS FILE when removing deprecated support (target: v1.0.0)
8
+ //
9
+ // Migration performed:
10
+ // 1. auth.transport -> transport (top-level)
11
+ // 2. session -> transport (merged)
12
+ // 3. auth.transport.recreation.redis -> redis (top-level, if not already set)
13
+ // 4. auth.tokenStorage.config -> references top-level redis
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.resetDeprecationWarning = resetDeprecationWarning;
16
+ exports.needsMigration = needsMigration;
17
+ exports.migrateAuthTransportConfig = migrateAuthTransportConfig;
18
+ exports.applyMigration = applyMigration;
19
+ let deprecationWarningShown = false;
20
+ /**
21
+ * Show deprecation warning once per process
22
+ */
23
+ function showDeprecationWarning(hasOldTransport, hasOldSession) {
24
+ if (deprecationWarningShown) {
25
+ return;
26
+ }
27
+ deprecationWarningShown = true;
28
+ const warnings = [];
29
+ if (hasOldTransport) {
30
+ warnings.push(' - auth.transport is deprecated, use top-level "transport" instead');
31
+ }
32
+ if (hasOldSession) {
33
+ warnings.push(' - session is deprecated, merge into top-level "transport" instead');
34
+ }
35
+ console.warn('\n[DEPRECATION WARNING] FrontMCP config structure has changed:\n' +
36
+ warnings.join('\n') +
37
+ '\n - For Redis config, use top-level "redis" instead\n' +
38
+ '\nSee documentation: https://docs.agentfront.dev/docs/servers/server\n');
39
+ }
40
+ /**
41
+ * Reset deprecation warning flag (for testing)
42
+ */
43
+ function resetDeprecationWarning() {
44
+ deprecationWarningShown = false;
45
+ }
46
+ /**
47
+ * Check if config needs migration
48
+ */
49
+ function needsMigration(metadata) {
50
+ const hasOldTransport = !!(metadata.auth && 'transport' in metadata.auth && metadata.auth.transport);
51
+ const hasOldSession = !!metadata.session;
52
+ return hasOldTransport || hasOldSession;
53
+ }
54
+ /**
55
+ * Migrate old config structure to new structure
56
+ *
57
+ * Returns the migrated values that should be applied to the metadata
58
+ */
59
+ function migrateAuthTransportConfig(metadata) {
60
+ const result = {};
61
+ const hasOldTransport = !!(metadata.auth && 'transport' in metadata.auth && metadata.auth.transport);
62
+ const hasOldSession = !!metadata.session;
63
+ if (!hasOldTransport && !hasOldSession) {
64
+ return result;
65
+ }
66
+ // Show deprecation warning
67
+ showDeprecationWarning(hasOldTransport, hasOldSession);
68
+ // Start with existing transport config if present
69
+ result.transport = { ...metadata.transport };
70
+ // Migrate session config
71
+ if (hasOldSession) {
72
+ const session = metadata.session;
73
+ result.transport = {
74
+ ...result.transport,
75
+ sessionMode: session.sessionMode,
76
+ transportIdMode: session.transportIdMode,
77
+ platformDetection: session.platformDetection,
78
+ };
79
+ }
80
+ // Migrate auth.transport config
81
+ if (hasOldTransport) {
82
+ const oldTransport = metadata.auth.transport;
83
+ // Merge transport protocol settings
84
+ result.transport = {
85
+ ...result.transport,
86
+ enableLegacySSE: oldTransport.enableLegacySSE ?? result.transport.enableLegacySSE,
87
+ enableSseListener: oldTransport.enableSseListener ?? result.transport.enableSseListener,
88
+ enableStreamableHttp: oldTransport.enableStreamableHttp ?? result.transport.enableStreamableHttp,
89
+ enableStatelessHttp: oldTransport.enableStatelessHttp ?? result.transport.enableStatelessHttp,
90
+ enableStatefulHttp: oldTransport.enableStatefulHttp ?? result.transport.enableStatefulHttp,
91
+ requireSessionForStreamable: oldTransport.requireSessionForStreamable ?? result.transport.requireSessionForStreamable,
92
+ };
93
+ // Migrate recreation -> persistence
94
+ if (oldTransport.recreation) {
95
+ result.transport.persistence = {
96
+ enabled: oldTransport.recreation.enabled ?? false,
97
+ redis: oldTransport.recreation.redis,
98
+ defaultTtlMs: oldTransport.recreation.defaultTtlMs,
99
+ };
100
+ // Extract Redis config to top-level if not already present
101
+ if (oldTransport.recreation.redis && !metadata.redis) {
102
+ result.redis = oldTransport.recreation.redis;
103
+ }
104
+ }
105
+ // Create clean auth without transport
106
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
107
+ const { transport: _, ...cleanAuth } = metadata.auth;
108
+ result.auth = cleanAuth;
109
+ }
110
+ return result;
111
+ }
112
+ /**
113
+ * Apply migration to metadata (mutates in place for decorator use)
114
+ *
115
+ * This function takes a metadata object with the old config structure
116
+ * and transforms it to the new structure in place.
117
+ */
118
+ function applyMigration(metadata) {
119
+ if (!needsMigration(metadata)) {
120
+ return metadata;
121
+ }
122
+ const migrated = migrateAuthTransportConfig(metadata);
123
+ // Apply migrated transport config
124
+ if (migrated.transport) {
125
+ metadata['transport'] = {
126
+ ...metadata.transport,
127
+ ...migrated.transport,
128
+ };
129
+ }
130
+ // Apply migrated redis config
131
+ if (migrated.redis) {
132
+ metadata['redis'] = migrated.redis;
133
+ }
134
+ // Apply cleaned auth config (without transport)
135
+ if (migrated.auth) {
136
+ metadata.auth = migrated.auth;
137
+ }
138
+ return metadata;
139
+ }
140
+ //# sourceMappingURL=auth-transport.migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-transport.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nD,GAAG,QAAQ,CAAC,SAAS;YACrB,GAAG,QAAQ,CAAC,SAAS;SACtB,CAAC;IACJ,CAAC;IAED,8BAA8B;IAC9B,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QAClB,QAAoC,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAClE,CAAC;IAED,gDAAgD;IAChD,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;QAClB,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["// common/migrate/auth-transport.migrate.ts\n//\n// Migration helper for auth.transport -> transport config\n//\n// This file handles backward compatibility for the old config structure.\n// DELETE THIS FILE when removing deprecated support (target: v1.0.0)\n//\n// Migration performed:\n// 1. auth.transport -> transport (top-level)\n// 2. session -> transport (merged)\n// 3. auth.transport.recreation.redis -> redis (top-level, if not already set)\n// 4. auth.tokenStorage.config -> references top-level redis\n\nimport type { TransportOptionsInput } from '../types/options/transport.options';\nimport type { RedisOptionsInput } from '../types/options/redis.options';\nimport type { SessionOptions } from '../types/options/session.options';\n\n/**\n * Old transport config structure (nested under auth)\n */\ninterface OldTransportConfig {\n enableLegacySSE?: boolean;\n enableSseListener?: boolean;\n enableStreamableHttp?: boolean;\n enableStatelessHttp?: boolean;\n enableStatefulHttp?: boolean;\n requireSessionForStreamable?: boolean;\n recreation?: {\n enabled?: boolean;\n redis?: RedisOptionsInput;\n defaultTtlMs?: number;\n };\n}\n\n/**\n * Old auth config structure (with nested transport)\n */\ninterface OldAuthConfig {\n mode: string;\n transport?: OldTransportConfig;\n [key: string]: unknown;\n}\n\n/**\n * Metadata structure for migration\n */\ninterface MigratableMetadata {\n auth?: OldAuthConfig;\n session?: SessionOptions;\n transport?: TransportOptionsInput;\n redis?: RedisOptionsInput;\n}\n\nlet deprecationWarningShown = false;\n\n/**\n * Show deprecation warning once per process\n */\nfunction showDeprecationWarning(hasOldTransport: boolean, hasOldSession: boolean): void {\n if (deprecationWarningShown) {\n return;\n }\n deprecationWarningShown = true;\n\n const warnings: string[] = [];\n if (hasOldTransport) {\n warnings.push(' - auth.transport is deprecated, use top-level \"transport\" instead');\n }\n if (hasOldSession) {\n warnings.push(' - session is deprecated, merge into top-level \"transport\" instead');\n }\n\n console.warn(\n '\\n[DEPRECATION WARNING] FrontMCP config structure has changed:\\n' +\n warnings.join('\\n') +\n '\\n - For Redis config, use top-level \"redis\" instead\\n' +\n '\\nSee documentation: https://docs.agentfront.dev/docs/servers/server\\n',\n );\n}\n\n/**\n * Reset deprecation warning flag (for testing)\n */\nexport function resetDeprecationWarning(): void {\n deprecationWarningShown = false;\n}\n\n/**\n * Check if config needs migration\n */\nexport function needsMigration(metadata: MigratableMetadata): boolean {\n const hasOldTransport = !!(metadata.auth && 'transport' in metadata.auth && metadata.auth.transport);\n const hasOldSession = !!metadata.session;\n return hasOldTransport || hasOldSession;\n}\n\n/**\n * Migrate old config structure to new structure\n *\n * Returns the migrated values that should be applied to the metadata\n */\nexport function migrateAuthTransportConfig(metadata: MigratableMetadata): {\n transport?: TransportOptionsInput;\n redis?: RedisOptionsInput;\n auth?: OldAuthConfig;\n} {\n const result: {\n transport?: TransportOptionsInput;\n redis?: RedisOptionsInput;\n auth?: OldAuthConfig;\n } = {};\n\n const hasOldTransport = !!(metadata.auth && 'transport' in metadata.auth && metadata.auth.transport);\n const hasOldSession = !!metadata.session;\n\n if (!hasOldTransport && !hasOldSession) {\n return result;\n }\n\n // Show deprecation warning\n showDeprecationWarning(hasOldTransport, hasOldSession);\n\n // Start with existing transport config if present\n result.transport = { ...metadata.transport };\n\n // Migrate session config\n if (hasOldSession) {\n const session = metadata.session!;\n result.transport = {\n ...result.transport,\n sessionMode: session.sessionMode,\n transportIdMode: session.transportIdMode,\n platformDetection: session.platformDetection,\n };\n }\n\n // Migrate auth.transport config\n if (hasOldTransport) {\n const oldTransport = metadata.auth!.transport!;\n\n // Merge transport protocol settings\n result.transport = {\n ...result.transport,\n enableLegacySSE: oldTransport.enableLegacySSE ?? result.transport.enableLegacySSE,\n enableSseListener: oldTransport.enableSseListener ?? result.transport.enableSseListener,\n enableStreamableHttp: oldTransport.enableStreamableHttp ?? result.transport.enableStreamableHttp,\n enableStatelessHttp: oldTransport.enableStatelessHttp ?? result.transport.enableStatelessHttp,\n enableStatefulHttp: oldTransport.enableStatefulHttp ?? result.transport.enableStatefulHttp,\n requireSessionForStreamable:\n oldTransport.requireSessionForStreamable ?? result.transport.requireSessionForStreamable,\n };\n\n // Migrate recreation -> persistence\n if (oldTransport.recreation) {\n result.transport.persistence = {\n enabled: oldTransport.recreation.enabled ?? false,\n redis: oldTransport.recreation.redis,\n defaultTtlMs: oldTransport.recreation.defaultTtlMs,\n };\n\n // Extract Redis config to top-level if not already present\n if (oldTransport.recreation.redis && !metadata.redis) {\n result.redis = oldTransport.recreation.redis;\n }\n }\n\n // Create clean auth without transport\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { transport: _, ...cleanAuth } = metadata.auth!;\n result.auth = cleanAuth as OldAuthConfig;\n }\n\n return result;\n}\n\n/**\n * Apply migration to metadata (mutates in place for decorator use)\n *\n * This function takes a metadata object with the old config structure\n * and transforms it to the new structure in place.\n */\nexport function applyMigration<T extends MigratableMetadata>(metadata: T): T {\n if (!needsMigration(metadata)) {\n return metadata;\n }\n\n const migrated = migrateAuthTransportConfig(metadata);\n\n // Apply migrated transport config\n if (migrated.transport) {\n (metadata as Record<string, unknown>)['transport'] = {\n ...metadata.transport,\n ...migrated.transport,\n };\n }\n\n // Apply migrated redis config\n if (migrated.redis) {\n (metadata as Record<string, unknown>)['redis'] = migrated.redis;\n }\n\n // Apply cleaned auth config (without transport)\n if (migrated.auth) {\n metadata.auth = migrated.auth;\n }\n\n return metadata;\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from './auth-transport.migrate';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // common/migrate/index.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("./auth-transport.migrate"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/migrate/index.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;AAE1B,mEAAyC","sourcesContent":["// common/migrate/index.ts\n\nexport * from './auth-transport.migrate';\n"]}
@@ -302,7 +302,11 @@ export declare const HttpJsonRpcSchema: z.ZodObject<{
302
302
  jsonrpc: z.ZodLiteral<"2.0">;
303
303
  id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
304
304
  result: z.ZodObject<{
305
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
305
+ _meta: z.ZodOptional<z.ZodObject<{
306
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
307
+ taskId: z.ZodString;
308
+ }, z.core.$loose>>;
309
+ }, z.core.$loose>>;
306
310
  }, z.core.$loose>;
307
311
  }, z.core.$strict>, z.ZodObject<{
308
312
  jsonrpc: z.ZodLiteral<"2.0">;
@@ -596,7 +600,11 @@ export declare const httpOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
596
600
  jsonrpc: z.ZodLiteral<"2.0">;
597
601
  id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
598
602
  result: z.ZodObject<{
599
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
603
+ _meta: z.ZodOptional<z.ZodObject<{
604
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
605
+ taskId: z.ZodString;
606
+ }, z.core.$loose>>;
607
+ }, z.core.$loose>>;
600
608
  }, z.core.$loose>;
601
609
  }, z.core.$strict>, z.ZodObject<{
602
610
  jsonrpc: z.ZodLiteral<"2.0">;
@@ -1,3 +1,4 @@
1
1
  export * from './annotated-class.schema';
2
2
  export * from './http-output.schema';
3
3
  export * from './http-input.schema';
4
+ export * from './session-header.schema';
@@ -4,4 +4,5 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./annotated-class.schema"), exports);
5
5
  tslib_1.__exportStar(require("./http-output.schema"), exports);
6
6
  tslib_1.__exportStar(require("./http-input.schema"), exports);
7
+ tslib_1.__exportStar(require("./session-header.schema"), exports);
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/schemas/index.ts"],"names":[],"mappings":";;;AAAA,mEAAyC;AACzC,+DAAqC;AACrC,8DAAoC","sourcesContent":["export * from './annotated-class.schema';\nexport * from './http-output.schema';\nexport * from './http-input.schema';"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/schemas/index.ts"],"names":[],"mappings":";;;AAAA,mEAAyC;AACzC,+DAAqC;AACrC,8DAAoC;AACpC,kEAAwC","sourcesContent":["export * from './annotated-class.schema';\nexport * from './http-output.schema';\nexport * from './http-input.schema';\nexport * from './session-header.schema';\n"]}
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Zod schema for validating mcp-session-id header format.
4
+ * Uses Zod's built-in validators to prevent ReDoS attacks and ensure safe validation.
5
+ *
6
+ * - Max length: 2048 characters (encrypted session IDs can be 460-700+ characters
7
+ * due to AES-256-GCM encryption producing base64url format: iv.tag.ciphertext)
8
+ * - Only allows printable ASCII characters (0x20-0x7E)
9
+ * - Rejects control characters and null bytes
10
+ */
11
+ export declare const mcpSessionHeaderSchema: z.ZodString;
12
+ /**
13
+ * Validate mcp-session-id header using Zod schema.
14
+ * Returns undefined for invalid or missing values.
15
+ */
16
+ export declare function validateMcpSessionHeader(value: string | undefined): string | undefined;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mcpSessionHeaderSchema = void 0;
4
+ exports.validateMcpSessionHeader = validateMcpSessionHeader;
5
+ const zod_1 = require("zod");
6
+ /**
7
+ * Zod schema for validating mcp-session-id header format.
8
+ * Uses Zod's built-in validators to prevent ReDoS attacks and ensure safe validation.
9
+ *
10
+ * - Max length: 2048 characters (encrypted session IDs can be 460-700+ characters
11
+ * due to AES-256-GCM encryption producing base64url format: iv.tag.ciphertext)
12
+ * - Only allows printable ASCII characters (0x20-0x7E)
13
+ * - Rejects control characters and null bytes
14
+ */
15
+ exports.mcpSessionHeaderSchema = zod_1.z
16
+ .string()
17
+ .min(1)
18
+ .max(2048)
19
+ .refine((value) => {
20
+ // Check each character is printable ASCII (0x20-0x7E)
21
+ for (let i = 0; i < value.length; i++) {
22
+ const code = value.charCodeAt(i);
23
+ if (code < 0x20 || code > 0x7e) {
24
+ return false;
25
+ }
26
+ }
27
+ return true;
28
+ }, { message: 'Session ID must contain only printable ASCII characters' })
29
+ .refine((v) => v === v.trim(), {
30
+ message: 'Session ID must not have leading/trailing whitespace',
31
+ });
32
+ /**
33
+ * Validate mcp-session-id header using Zod schema.
34
+ * Returns undefined for invalid or missing values.
35
+ */
36
+ function validateMcpSessionHeader(value) {
37
+ if (!value)
38
+ return undefined;
39
+ const result = exports.mcpSessionHeaderSchema.safeParse(value);
40
+ return result.success ? result.data : undefined;
41
+ }
42
+ //# sourceMappingURL=session-header.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-header.schema.js","sourceRoot":"","sources":["../../../../src/common/schemas/session-header.schema.ts"],"names":[],"mappings":";;;AAoCA,4DAIC;AAxCD,6BAAwB;AAExB;;;;;;;;GAQG;AACU,QAAA,sBAAsB,GAAG,OAAC;KACpC,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,IAAI,CAAC;KACT,MAAM,CACL,CAAC,KAAK,EAAE,EAAE;IACR,sDAAsD;IACtD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,EACD,EAAE,OAAO,EAAE,yDAAyD,EAAE,CACvE;KACA,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;IAC7B,OAAO,EAAE,sDAAsD;CAChE,CAAC,CAAC;AAEL;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,KAAyB;IAChE,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,MAAM,GAAG,8BAAsB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC","sourcesContent":["import { z } from 'zod';\n\n/**\n * Zod schema for validating mcp-session-id header format.\n * Uses Zod's built-in validators to prevent ReDoS attacks and ensure safe validation.\n *\n * - Max length: 2048 characters (encrypted session IDs can be 460-700+ characters\n * due to AES-256-GCM encryption producing base64url format: iv.tag.ciphertext)\n * - Only allows printable ASCII characters (0x20-0x7E)\n * - Rejects control characters and null bytes\n */\nexport const mcpSessionHeaderSchema = z\n .string()\n .min(1)\n .max(2048)\n .refine(\n (value) => {\n // Check each character is printable ASCII (0x20-0x7E)\n for (let i = 0; i < value.length; i++) {\n const code = value.charCodeAt(i);\n if (code < 0x20 || code > 0x7e) {\n return false;\n }\n }\n return true;\n },\n { message: 'Session ID must contain only printable ASCII characters' },\n )\n .refine((v) => v === v.trim(), {\n message: 'Session ID must not have leading/trailing whitespace',\n });\n\n/**\n * Validate mcp-session-id header using Zod schema.\n * Returns undefined for invalid or missing values.\n */\nexport function validateMcpSessionHeader(value: string | undefined): string | undefined {\n if (!value) return undefined;\n const result = mcpSessionHeaderSchema.safeParse(value);\n return result.success ? result.data : undefined;\n}\n"]}
@@ -7,7 +7,9 @@ exports.FrontMcpTokens = {
7
7
  info: base_tokens_1.tokenFactory.meta('info'),
8
8
  apps: base_tokens_1.tokenFactory.meta('apps'),
9
9
  http: base_tokens_1.tokenFactory.meta('http'),
10
- session: base_tokens_1.tokenFactory.meta('session'),
10
+ redis: base_tokens_1.tokenFactory.meta('redis'),
11
+ transport: base_tokens_1.tokenFactory.meta('transport'),
12
+ session: base_tokens_1.tokenFactory.meta('session'), // @deprecated - kept for backward compatibility
11
13
  serve: base_tokens_1.tokenFactory.meta('serve'),
12
14
  splitByApp: base_tokens_1.tokenFactory.meta('splitByApp'),
13
15
  auth: base_tokens_1.tokenFactory.meta('auth'),
@@ -1 +1 @@
1
- {"version":3,"file":"front-mcp.tokens.js","sourceRoot":"","sources":["../../../../src/common/tokens/front-mcp.tokens.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAIhC,QAAA,cAAc,GAAuC;IAChE,IAAI,EAAE,0BAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,0BAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,0BAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,0BAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE,0BAAY,CAAC,IAAI,CAAC,SAAS,CAAC;IACrC,KAAK,EAAE,0BAAY,CAAC,IAAI,CAAC,OAAO,CAAC;IACjC,UAAU,EAAE,0BAAY,CAAC,IAAI,CAAC,YAAY,CAAC;IAC3C,IAAI,EAAE,0BAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE,0BAAY,CAAC,IAAI,CAAC,SAAS,CAAC;IAErC,0BAA0B;IAC1B,SAAS,EAAE,0BAAY,CAAC,IAAI,CAAC,WAAW,CAAC;IACzC,2CAA2C;IAC3C,KAAK,EAAE,0BAAY,CAAC,IAAI,CAAC,OAAO,CAAC;IACjC,+CAA+C;IAC/C,SAAS,EAAE,0BAAY,CAAC,IAAI,CAAC,WAAW,CAAC;CAC1C,CAAC","sourcesContent":["import { tokenFactory } from './base.tokens';\nimport { RawMetadataShape } from '../types';\nimport { FrontMcpMetadata } from '../metadata';\n\nexport const FrontMcpTokens: RawMetadataShape<FrontMcpMetadata> = {\n type: tokenFactory.type('root'),\n info: tokenFactory.meta('info'),\n apps: tokenFactory.meta('apps'),\n http: tokenFactory.meta('http'),\n session: tokenFactory.meta('session'),\n serve: tokenFactory.meta('serve'),\n splitByApp: tokenFactory.meta('splitByApp'),\n auth: tokenFactory.meta('auth'),\n logging: tokenFactory.meta('logging'),\n\n // global scoped providers\n providers: tokenFactory.meta('providers'),\n // global scoped tools (shared across apps)\n tools: tokenFactory.meta('tools'),\n // global scoped resources (shared across apps)\n resources: tokenFactory.meta('resources'),\n};\n"]}
1
+ {"version":3,"file":"front-mcp.tokens.js","sourceRoot":"","sources":["../../../../src/common/tokens/front-mcp.tokens.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAIhC,QAAA,cAAc,GAAuC;IAChE,IAAI,EAAE,0BAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,0BAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,0BAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,0BAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAC/B,KAAK,EAAE,0BAAY,CAAC,IAAI,CAAC,OAAO,CAAC;IACjC,SAAS,EAAE,0BAAY,CAAC,IAAI,CAAC,WAAW,CAAC;IACzC,OAAO,EAAE,0BAAY,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,gDAAgD;IACvF,KAAK,EAAE,0BAAY,CAAC,IAAI,CAAC,OAAO,CAAC;IACjC,UAAU,EAAE,0BAAY,CAAC,IAAI,CAAC,YAAY,CAAC;IAC3C,IAAI,EAAE,0BAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE,0BAAY,CAAC,IAAI,CAAC,SAAS,CAAC;IAErC,0BAA0B;IAC1B,SAAS,EAAE,0BAAY,CAAC,IAAI,CAAC,WAAW,CAAC;IACzC,2CAA2C;IAC3C,KAAK,EAAE,0BAAY,CAAC,IAAI,CAAC,OAAO,CAAC;IACjC,+CAA+C;IAC/C,SAAS,EAAE,0BAAY,CAAC,IAAI,CAAC,WAAW,CAAC;CAC1C,CAAC","sourcesContent":["import { tokenFactory } from './base.tokens';\nimport { RawMetadataShape } from '../types';\nimport { FrontMcpMetadata } from '../metadata';\n\nexport const FrontMcpTokens: RawMetadataShape<FrontMcpMetadata> = {\n type: tokenFactory.type('root'),\n info: tokenFactory.meta('info'),\n apps: tokenFactory.meta('apps'),\n http: tokenFactory.meta('http'),\n redis: tokenFactory.meta('redis'),\n transport: tokenFactory.meta('transport'),\n session: tokenFactory.meta('session'), // @deprecated - kept for backward compatibility\n serve: tokenFactory.meta('serve'),\n splitByApp: tokenFactory.meta('splitByApp'),\n auth: tokenFactory.meta('auth'),\n logging: tokenFactory.meta('logging'),\n\n // global scoped providers\n providers: tokenFactory.meta('providers'),\n // global scoped tools (shared across apps)\n tools: tokenFactory.meta('tools'),\n // global scoped resources (shared across apps)\n resources: tokenFactory.meta('resources'),\n};\n"]}