@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
@@ -1 +1 @@
1
- {"version":3,"file":"provider.registry.js","sourceRoot":"","sources":["../../../src/provider/provider.registry.ts"],"names":[],"mappings":";;AAAA,4BAA0B;AAC1B,sCAemB;AACnB,qDAAsG;AACtG,sDAAkF;AAClF,4DAAuD;AACvD,0CAAuE;AAEvE,oCAAiC;AAGjC,MAAqB,gBACnB,SAAQ,2BAA6F;IAalD;IAVnD,wDAAwD;IACvC,UAAU,CAA+B;IAC1D,8BAA8B;IACtB,KAAK,GAAe,IAAI,GAAG,EAAE,CAAC;IAEtC,uCAAuC;IACvC,uDAAuD;IAE/C,UAAU,GAAyC,IAAI,GAAG,EAAE,CAAC;IAErE,YAAY,IAAoB,EAAmB,eAAkC;QACnF,KAAK,CAAC,kBAAkB,EAAE,eAAe,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QADP,oBAAe,GAAf,eAAe,CAAmB;QAGnF,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAE5B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,QAAQ,EAAE,CAAC;QAEhB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IACjC,CAAC;IAED,YAAY;QACV,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAU,CAAC;IAC/C,CAAC;IAED,iEAAiE;IAEjE,4DAA4D;IACpD,oBAAoB,CAAC,KAAY;QACvC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAY,CAAC;YAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAA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AAC;YAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC,aAAK,CAAC,CAAC;IACpC,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,cAAc,CAAC,uBAAc,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,OAAO;YACL,MAAM,EAAE,IAAI,GAAG,EAAc;YAC7B,OAAO,EAAE,IAAI,GAAG,EAAc;YAC9B,OAAO,EAAE,IAAI,GAAG,EAAc;SAC/B,CAAC;IACJ,CAAC;CACF;AA/mBD,mCA+mBC","sourcesContent":["import 'reflect-metadata';\nimport {\n Ctor,\n ProviderInterface,\n ProviderType,\n ProviderScope,\n Token,\n ProviderRegistryInterface,\n ProviderRecord,\n ProviderKind,\n ProviderInjectedRecord,\n ScopeEntry,\n RegistryKind,\n RegistryType,\n ProviderEntry,\n FrontMcpServer,\n} from '../common';\nimport { normalizeProvider, providerDiscoveryDeps, providerInvocationTokens } from './provider.utils';\nimport { depsOfClass, isClass, isPromise, tokenName } from '../utils/token.utils';\nimport { hasAsyncWith } from '../utils/metadata.utils';\nimport { RegistryAbstract, RegistryBuildMapResult } from '../regsitry';\nimport { ProviderViews } from './provider.types';\nimport { Scope } from '../scope';\nimport HookRegistry from '../hooks/hook.registry';\n\nexport default class ProviderRegistry\n extends RegistryAbstract<ProviderEntry, ProviderRecord, ProviderType[], ProviderRegistry | undefined>\n implements ProviderRegistryInterface\n{\n /** used to track which registry provided which token */\n private readonly providedBy: Map<Token, ProviderRegistry>;\n /** topo order (deps first) */\n private order: Set<Token> = new Set();\n\n // /** scoped instance stores by key */\n // private scoped = new Map<string, Map<Token, any>>();\n\n private registries: Map<RegistryKind, Set<RegistryType>> = new Map();\n\n constructor(list: ProviderType[], private readonly parentProviders?: ProviderRegistry) {\n super('ProviderRegistry', parentProviders, list, false);\n\n this.providedBy = new Map();\n\n this.buildGraph();\n this.topoSort();\n\n this.ready = this.initialize();\n }\n\n getProviders(): ProviderEntry[] {\n return [...this.instances.values()] as const;\n }\n\n /* -------------------- Hierarchy helpers -------------------- */\n\n /** Walk up the registry chain to find a def for a token. */\n private lookupDefInHierarchy(token: Token): { registry: ProviderRegistry; rec: ProviderRecord } | undefined {\n if (this.defs.has(token as any)) return { registry: this, rec: this.defs.get(token as any)! };\n return this.providers?.lookupDefInHierarchy(token);\n }\n\n /** Resolve a DEFAULT-scoped dependency from the hierarchy, enforcing scope & instantiation. */\n private resolveDefaultFromHierarchy(token: Token): any {\n const found = this.lookupDefInHierarchy(token);\n if (!found) throw new Error(`Cannot resolve token ${tokenName(token)}: not registered in hierarchy.`);\n const { registry, rec } = found;\n const sc = registry.getProviderScope(rec);\n if (sc !== ProviderScope.GLOBAL) {\n const scName = ProviderScope[sc];\n throw new Error(\n `Dependency ${tokenName(token)} is scoped (${scName}) in ${registry.constructor.name}; cannot use as DEFAULT.`,\n );\n }\n const inst = registry.instances.get(token);\n if (inst === undefined) {\n throw new Error(`Dependency ${tokenName(token)} (DEFAULT) is not instantiated in ${registry.constructor.name}`);\n }\n return inst;\n }\n\n /* -------------------- Build phase -------------------- */\n\n protected override buildMap(list: ProviderType[]): RegistryBuildMapResult<ProviderRecord> {\n const tokens = new Set<Token>();\n const defs = new Map<Token, ProviderRecord>();\n const graph = new Map<Token, Set<Token>>();\n\n for (const raw of list) {\n const rec = normalizeProvider(raw);\n const provide = rec.provide;\n tokens.add(provide);\n defs.set(provide, rec);\n graph.set(provide, new Set());\n }\n\n return { tokens, defs, graph };\n }\n\n protected buildGraph() {\n for (const token of this.tokens) {\n const rec = this.defs.get(token)!;\n const deps = this.discoveryDeps(rec);\n\n for (const d of deps) {\n const isLocal = this.tokens.has(d);\n const up = isLocal ? undefined : this.lookupDefInHierarchy(d);\n\n if (!isLocal && !up) {\n throw new Error(\n `Provider ${tokenName(token)} depends on ${tokenName(d)}, which is not registered (local or parent).`,\n );\n }\n\n const depRec = isLocal ? this.defs.get(d)! : up!.rec;\n const depScope = isLocal ? this.getProviderScope(depRec) : up!.registry.getProviderScope(depRec);\n\n if (this.getProviderScope(rec) === ProviderScope.GLOBAL && depScope !== ProviderScope.GLOBAL) {\n throw new Error(\n `Invalid dependency: DEFAULT-scoped provider ${tokenName(\n token,\n )} cannot depend on scoped provider ${tokenName(d)}.`,\n );\n }\n\n // Only wire local -> local edges in our local graph; parent deps are external to this DAG.\n if (isLocal) this.graph.get(token)!.add(d);\n }\n }\n }\n\n protected topoSort() {\n const WHITE = 0,\n GRAY = 1,\n BLACK = 2;\n const color = new Map<Token, number>();\n const order: Set<Token> = new Set();\n const path: Token[] = [];\n\n const dfs = (n: Token) => {\n color.set(n, GRAY);\n path.push(n);\n for (const dep of this.graph.get(n) ?? []) {\n const c = color.get(dep) ?? WHITE;\n if (c === GRAY) {\n const idx = path.findIndex((p) => p === dep);\n const cycle = [...path.slice(idx), dep].map((t) => tokenName(t)).join(' -> ');\n throw new Error(`Dependency cycle detected: ${cycle}`);\n }\n if (c === WHITE) dfs(dep);\n }\n color.set(n, BLACK);\n order.add(n);\n path.pop();\n };\n\n for (const n of this.graph.keys()) if ((color.get(n) ?? WHITE) === WHITE) dfs(n);\n this.order = order;\n }\n\n /** Incremental instantiation for DEFAULT providers.\n * - Skips already-built singletons unless force:true.\n * - Can limit to a subset via onlyTokens.\n */\n protected async initialize(opts?: { force?: boolean; onlyTokens?: Iterable<Token> }) {\n const force = !!opts?.force;\n const only = opts?.onlyTokens ? new Set(opts.onlyTokens) : null;\n\n for (const token of this.order) {\n const rec = this.defs.get(token)!;\n if (this.getProviderScope(rec) !== ProviderScope.GLOBAL) continue;\n\n if (only && !only.has(token)) continue;\n if (!force && this.instances.has(token)) continue;\n\n if (force && this.instances.has(token)) {\n this.instances.delete(token);\n }\n\n try {\n await this.initiateOne(token, rec);\n } catch (e: any) {\n const msg = e?.message ?? e;\n // Use safe logging to avoid Node.js 24 util.inspect bug with Zod errors\n console.error(`Failed instantiating:`, msg);\n throw new Error(`Failed constructing ${tokenName(token)}: ${msg}`);\n }\n }\n }\n\n /* -------------------- Views & session stores -------------------- */\n\n /** Return the live singleton map as a read-only view. No copying. */\n getAllSingletons(): ReadonlyMap<Token, unknown> {\n return this.instances; // exposed as ReadonlyMap in the type\n }\n discoveryDeps(rec: ProviderRecord): Token[] {\n return providerDiscoveryDeps(rec, this.tokens, (k, phase) => depsOfClass(k, phase));\n }\n\n invocationTokens(_token: Token, rec: ProviderRecord): Token[] {\n return providerInvocationTokens(rec, (k, phase) => depsOfClass(k, phase));\n }\n\n getProviderScope(rec: ProviderRecord): ProviderScope {\n return rec.metadata?.scope ?? ProviderScope.GLOBAL;\n }\n\n getScope(): ScopeEntry {\n return this.getActiveScope();\n }\n\n /* -------------------- Instantiation -------------------- */\n\n private async withTimeout<T>(p: Promise<T>, ms: number, label: string): Promise<T> {\n if (ms <= 0 || !Number.isFinite(ms)) return p;\n let timer: any;\n try {\n const tm = new Promise<never>(\n (_, rej) => (timer = setTimeout(() => rej(new Error(`Timeout after ${ms}ms: ${label}`)), ms)),\n );\n return await Promise.race([p, tm]);\n } finally {\n clearTimeout(timer);\n }\n }\n\n private async resolveFactoryArg(t: Token, store: Map<Token, any>, scopeKey?: string): Promise<any> {\n if (store.has(t)) return store.get(t);\n if (this.instances.has(t)) return this.instances.get(t);\n\n // Local def?\n const rec = this.defs.get(t as any);\n if (rec) {\n const sc = this.getProviderScope(rec);\n if (sc === ProviderScope.GLOBAL) {\n if (!this.instances.has(t)) {\n throw new Error(`Dependency ${tokenName(t)} (DEFAULT scope) is not instantiated`);\n }\n return this.instances.get(t);\n } else {\n await this.buildIntoStore(t, rec, store, scopeKey);\n return store.get(t);\n }\n }\n\n // Parent def?\n const up = this.lookupDefInHierarchy(t);\n if (up) {\n const sc = up.registry.getProviderScope(up.rec);\n if (sc === ProviderScope.GLOBAL) {\n const inst = up.registry.instances.get(t);\n if (inst === undefined) {\n throw new Error(`Dependency ${tokenName(t)} (DEFAULT scope) is not instantiated in parent`);\n }\n return inst;\n } else {\n await up.registry.buildIntoStore(t, up.rec, store, scopeKey);\n return store.get(t);\n }\n }\n\n // Constructable fallback (non-DI)\n if (isClass(t)) {\n if (hasAsyncWith(t)) {\n const out = (t as any).with();\n return isPromise(out) ? await this.withTimeout(out, this.asyncTimeoutMs, `${t.name}.with(...)`) : out;\n }\n const instance = new (t as Ctor<any>)();\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${t.name}.init()`);\n }\n return instance;\n }\n\n throw new Error(`Cannot resolve token ${tokenName(t)}: not registered in hierarchy and not constructable.`);\n }\n\n /** Build a single DEFAULT-scoped singleton (used by incremental instantiating). */\n private async initiateOne(token: Token, rec: ProviderRecord): Promise<void> {\n switch (rec.kind) {\n case ProviderKind.VALUE: {\n this.instances.set(token, (rec as any).useValue);\n return;\n }\n case ProviderKind.FACTORY: {\n const deps = this.invocationTokens(token, rec);\n const args: any[] = [];\n for (const d of deps) args.push(await this.resolveFactoryArg(d, this.instances));\n const out = (rec as any).useFactory(...args);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${tokenName(token)}.useFactory(...)`)\n : out;\n this.instances.set(token, val);\n return;\n }\n case ProviderKind.CLASS: {\n const depTokens = this.invocationTokens(token, rec);\n const deps = depTokens.map((t) => this.resolveDefaultFromHierarchy(t));\n const klass = (rec as any).useClass;\n if (hasAsyncWith(klass)) {\n const out = (klass as any).with(...deps);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${klass.name}.with(...)`)\n : out;\n this.instances.set(token, val);\n } else {\n const instance = new (klass as Ctor<any>)(...deps);\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${klass.name}.init()`);\n }\n this.instances.set(token, instance);\n }\n return;\n }\n case ProviderKind.CLASS_TOKEN: {\n const depTokens = this.invocationTokens(token, rec);\n const deps = depTokens.map((t) => this.resolveDefaultFromHierarchy(t));\n const klass = (rec as any).provide;\n if (hasAsyncWith(klass)) {\n const out = (klass as any).with(...deps);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${klass.name}.with(...)`)\n : out;\n this.instances.set(token, val);\n } else {\n const instance = new (klass as Ctor<any>)(...deps);\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${klass.name}.init()`);\n }\n this.instances.set(token, instance);\n }\n return;\n }\n }\n }\n\n // Build a registered provider into the given scoped store (recursive for scoped deps).\n private async buildIntoStore(\n token: Token,\n rec: ProviderRecord,\n store: Map<Token, any>,\n scopeKey?: string,\n injectedDeps?: any[],\n ): Promise<void> {\n if (store.has(token)) return;\n\n try {\n switch (rec.kind) {\n case ProviderKind.VALUE: {\n store.set(token, (rec as any).useValue);\n return;\n }\n case ProviderKind.FACTORY: {\n const deps = this.invocationTokens(token, rec);\n const args: any[] = [];\n for (const d of deps) args.push(await this.resolveFactoryArg(d, store, scopeKey));\n const out = (rec as any).useFactory(...args);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${tokenName(token)}.useFactory(...)`)\n : out;\n store.set(token, val);\n return;\n }\n case ProviderKind.CLASS: {\n const depsTokens = this.invocationTokens(token, rec);\n const deps: any[] = [];\n for (const d of depsTokens) deps.push(await this.resolveManagedForClass(d, store, scopeKey));\n const klass = (rec as any).useClass as Ctor<any>;\n if (hasAsyncWith(klass)) {\n const out = (klass as any).with(...deps);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${klass.name}.with(...)`)\n : out;\n store.set(token, val);\n } else {\n const instance = new (klass as Ctor<any>)(...deps);\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${klass.name}.init()`);\n }\n store.set(token, instance);\n }\n return;\n }\n case ProviderKind.CLASS_TOKEN: {\n const depsTokens = this.invocationTokens(token, rec);\n const deps: any[] = injectedDeps ?? [];\n for (const d of depsTokens) deps.push(await this.resolveManagedForClass(d, store, scopeKey));\n const klass = (rec as any).provide as Ctor<any>;\n if (hasAsyncWith(klass)) {\n const out = (klass as any).with(...deps);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${klass.name}.with(...)`)\n : out;\n store.set(token, val);\n } else {\n const instance = new (klass as Ctor<any>)(...deps);\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${klass.name}.init()`);\n }\n store.set(token, instance);\n }\n return;\n }\n }\n } catch (e: any) {\n const msg = e?.message ?? e;\n // Use safe logging to avoid Node.js 24 util.inspect bug with Zod errors\n console.error(`Failed constructing:`, msg);\n throw new Error(`Failed constructing (scoped) ${tokenName(token)}: ${msg}`);\n }\n }\n\n // Ensure managed dependency value for CLASS/CLASS_TOKEN providers:\n // prefer scoped store, then singleton; recursively build scoped deps.\n // If not local, climb the hierarchy and either read DEFAULT instance or build scoped into this store.\n private async resolveManagedForClass(d: Token, store: Map<Token, any>, scopeKey?: string): Promise<any> {\n if (store.has(d)) return store.get(d);\n if (this.instances.has(d)) return this.instances.get(d);\n\n // Local DI?\n const depRec = this.defs.get(d as any);\n if (depRec) {\n const sc = this.getProviderScope(depRec);\n if (sc === ProviderScope.GLOBAL) {\n const v = this.instances.get(d);\n if (v === undefined) throw new Error(`${tokenName(d)} (DEFAULT scope) is not instantiated`);\n return v;\n } else {\n await this.buildIntoStore(d, depRec, store, scopeKey);\n return store.get(d);\n }\n }\n\n // Parent DI?\n const up = this.lookupDefInHierarchy(d);\n if (up) {\n const sc = up.registry.getProviderScope(up.rec);\n if (sc === ProviderScope.GLOBAL) {\n const v = up.registry.instances.get(d);\n if (v === undefined) throw new Error(`${tokenName(d)} (DEFAULT scope) is not instantiated in parent`);\n return v;\n } else {\n await up.registry.buildIntoStore(d, up.rec, store, scopeKey);\n return store.get(d);\n }\n }\n\n throw new Error(`${tokenName(d)} is not instantiated`);\n }\n\n get<T>(token: Token<T>): T {\n if (this.instances.has(token)) return this.instances.get(token) as T;\n\n const rec = this.defs.get(token as any);\n if (rec && this.getProviderScope(rec) !== ProviderScope.GLOBAL) {\n const scName = ProviderScope[this.getProviderScope(rec)];\n throw new Error(`Provider ${tokenName(token)} is scoped (${scName}). Use getScoped(token, key).`);\n }\n\n // bubble to parent\n if (this.providers) return this.providers.get<T>(token);\n\n throw new Error(`Provider ${tokenName(token)} is not available in local or parent registries`);\n }\n\n // noinspection JSUnusedGlobalSymbols\n addRegistry<T extends RegistryKind>(type: T, value: RegistryType[T]) {\n let registry = this.registries.get(type);\n if (!registry) {\n this.registries.set(type, new Set());\n registry = this.registries.get(type);\n }\n registry!.add(value as any);\n }\n\n getRegistries<T extends RegistryKind>(type: T): RegistryType[T][] {\n return [...(this.registries.get(type) ?? [])] as any;\n }\n\n getHooksRegistry() {\n return this.getRegistries('HookRegistry')[0] as HookRegistry;\n }\n\n // noinspection JSUnusedGlobalSymbols\n getScopeRegistry() {\n return this.getRegistries('ScopeRegistry')[0]!;\n }\n\n /** bootstrap helper: resolve a dependency usable during app bootstrap (must be GLOBAL). */\n async resolveBootstrapDep(t: Token): Promise<any> {\n if (this.instances.has(t)) return this.instances.get(t);\n if (this.registries.has(t as RegistryKind)) return this.registries.get(t as RegistryKind);\n\n const found = this.lookupDefInHierarchy(t);\n if (found) {\n const { registry, rec } = found;\n const sc = registry.getProviderScope(rec);\n if (sc !== ProviderScope.GLOBAL)\n throw new Error(`Plugin dependency ${tokenName(t)} must be DEFAULT-scoped at bootstrap`);\n const v = registry.instances.get(t);\n if (v === undefined) throw new Error(`Plugin dependency ${tokenName(t)} (DEFAULT scope) is not instantiated`);\n return v;\n }\n throw new Error(`Cannot resolve plugin dependency ${tokenName(t)} (local or parent)`);\n }\n\n /** Lightweight, synchronous resolver for app-scoped DI.\n * - If `cls` is a registered DEFAULT provider token, returns the singleton (must be instantiated).\n * - If `cls` is SCOPED in DI, throws (use getScoped/buildViews instead).\n * - Otherwise, if `cls` is a constructable class not registered in DI, returns `new cls()`.\n * If it defines a synchronous init(), it will be invoked (async init() is NOT awaited).\n */\n resolve<T>(cls: any): T {\n // 1) If it's a registered token (local or parent), handle via DI rules\n const found = this.lookupDefInHierarchy(cls as any);\n if (found) {\n const { registry, rec } = found;\n const sc = registry.getProviderScope(rec);\n if (sc !== ProviderScope.GLOBAL) {\n const scName = ProviderScope[sc];\n throw new Error(\n `Provider ${tokenName(cls)} is scoped (${scName}). Use getScoped(token, key) or buildViews(...).`,\n );\n }\n if (!registry.instances.has(cls)) {\n throw new Error(\n `Provider ${tokenName(cls)} (DEFAULT scope) is not instantiated. Call providers.instantiate() first.`,\n );\n }\n return registry.instances.get(cls) as T;\n }\n\n // 2) Not a registered token — best-effort construct (for tools/hooks/wrappers)\n if (isClass(cls)) {\n const instance = new (cls as Ctor<any>)();\n\n // Call sync init() if present (do NOT await)\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n // If someone accidentally made init async here, we intentionally do NOT await to keep it sync.\n init.call(instance);\n }\n\n return instance as T;\n }\n\n // 3) Unsupported token type\n throw new Error(\n `Cannot resolve ${tokenName(cls)}: not a registered DEFAULT provider and not a constructable class.`,\n );\n }\n\n mergeFromRegistry(\n providedBy: ProviderRegistry,\n exported: {\n token: Token<ProviderInterface>;\n def: ProviderRecord;\n instance: ProviderEntry;\n }[],\n ) {\n for (const { token, def, instance } of exported) {\n if (def.metadata.scope === ProviderScope.GLOBAL) {\n this.instances.set(token, instance);\n }\n this.defs.set(token, def);\n this.providedBy.set(token, providedBy);\n }\n }\n\n /**\n * Used by plugins to get the exported provider definitions.\n */\n getProviderInfo(token: Token<ProviderInterface>) {\n const def = this.defs.get(token);\n const instance = this.instances.get(token);\n if (!def || !instance)\n throw new Error(\n `Cannot get provider info for ${tokenName(\n token,\n )}: not a registered DEFAULT provider and not a constructable class.`,\n );\n return {\n token,\n def,\n instance,\n };\n }\n\n injectProvider(injected: Omit<ProviderInjectedRecord, 'kind'>) {\n const rec: ProviderInjectedRecord = {\n ...injected,\n kind: ProviderKind.INJECTED,\n };\n this.tokens.add(rec.provide);\n this.defs.set(rec.provide, rec);\n this.graph.set(rec.provide, new Set());\n this.instances.set(rec.provide, rec.value);\n }\n\n async addDynamicProviders(dynamicProviders: ProviderType[]) {\n // Normalize ProviderType[] to ProviderRecord[] before instantiation\n const normalized = dynamicProviders.map((p) => normalizeProvider(p));\n return Promise.all(normalized.map((rec) => this.initiateOne(rec.provide, rec)));\n }\n\n private getWithParents<T>(token: Token<T>): T {\n if (this.instances.has(token)) {\n return this.get(token);\n }\n const parent = this.parentProviders;\n if (!parent) {\n return this.get(token);\n }\n return parent.getWithParents(token);\n }\n\n getActiveScope(): Scope {\n return this.getWithParents(Scope);\n }\n\n getActiveServer(): FrontMcpServer {\n return this.getWithParents(FrontMcpServer);\n }\n\n /**\n * Build provider instance views for different scopes\n * NOTE: This is currently a stub implementation returning empty maps.\n * Actual view building logic is planned as part of the session management refactoring.\n * See the ProviderRegistryInterface TODO for fixing the session type.\n */\n async buildViews(session: string): Promise<ProviderViews> {\n return {\n global: new Map<Token, any>(),\n session: new Map<Token, any>(),\n request: new Map<Token, any>(),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"provider.registry.js","sourceRoot":"","sources":["../../../src/prov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AAgB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;YAChD,IAAI,EAAE,KAAK,sBAAa,CAAC,MAAM,EAAE,CAAC;gBAChC,MAAM,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC3C,IAAI,CAAC,KAAK,SAAS;oBAAE,OAAO,CAAC,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAA,uBAAS,EAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;YACzF,CAAC;QACH,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAA,uBAAS,EAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC9E,CAAC;IAED;;;;;;;OAOG;IACH,SAAS,CAAI,KAAe,EAAE,KAAoB;QAChD,sDAAsD;QACtD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAM,CAAC;QACnE,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAM,CAAC;QAEjE,mDAAmD;QACnD,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAM,CAAC;QAErE,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,uBAAS,EAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAC5G,CAAC;;AAt7BH,mCAu7BC","sourcesContent":["import 'reflect-metadata';\nimport {\n Ctor,\n ProviderInterface,\n ProviderType,\n ProviderScope,\n Token,\n ProviderRegistryInterface,\n ProviderRecord,\n ProviderKind,\n ProviderInjectedRecord,\n ScopeEntry,\n RegistryKind,\n RegistryType,\n ProviderEntry,\n FrontMcpServer,\n} from '../common';\nimport { normalizeProvider, providerDiscoveryDeps, providerInvocationTokens } from './provider.utils';\nimport { depsOfClass, isClass, isPromise, tokenName } from '../utils/token.utils';\nimport { hasAsyncWith } from '../utils/metadata.utils';\nimport { RegistryAbstract, RegistryBuildMapResult } from '../regsitry';\nimport { ProviderViews } from './provider.types';\nimport { Scope } from '../scope';\nimport HookRegistry from '../hooks/hook.registry';\nimport { SessionKey } from '../context/session-key.provider';\n\nexport default class ProviderRegistry\n extends RegistryAbstract<ProviderEntry, ProviderRecord, ProviderType[], ProviderRegistry | undefined>\n implements ProviderRegistryInterface\n{\n /** used to track which registry provided which token */\n private readonly providedBy: Map<Token, ProviderRegistry>;\n /** topo order (deps first) */\n private order: Set<Token> = new Set();\n\n // /** scoped instance stores by key */\n // private scoped = new Map<string, Map<Token, any>>();\n\n private registries: Map<RegistryKind, Set<RegistryType>> = new Map();\n\n /** Session-scoped provider instance cache by sessionKey */\n private sessionStores: Map<string, { providers: Map<Token, unknown>; lastAccess: number }> = new Map();\n\n /** Locks to prevent concurrent session builds (race condition prevention) */\n private sessionBuildLocks: Map<string, { promise: Promise<void>; resolve: () => void }> = new Map();\n\n /** Maximum number of sessions to cache (LRU eviction) */\n private static readonly MAX_SESSION_CACHE_SIZE = 10000;\n\n /** Session cache TTL in milliseconds (1 hour) */\n private static readonly SESSION_CACHE_TTL_MS = 3600000;\n\n /** Cleanup interval in milliseconds (1 minute) */\n private static readonly SESSION_CLEANUP_INTERVAL_MS = 60000;\n\n /** Handle for the session cleanup interval */\n private sessionCleanupInterval: ReturnType<typeof setInterval> | null = null;\n\n constructor(list: ProviderType[], private readonly parentProviders?: ProviderRegistry) {\n super('ProviderRegistry', parentProviders, list, false);\n\n this.providedBy = new Map();\n\n this.buildGraph();\n this.topoSort();\n\n this.ready = this.initialize();\n }\n\n getProviders(): ProviderEntry[] {\n return [...this.instances.values()] as const;\n }\n\n /* -------------------- Hierarchy helpers -------------------- */\n\n /** Walk up the registry chain to find a def for a token. */\n private lookupDefInHierarchy(token: Token): { registry: ProviderRegistry; rec: ProviderRecord } | undefined {\n if (this.defs.has(token as any)) return { registry: this, rec: this.defs.get(token as any)! };\n return this.providers?.lookupDefInHierarchy(token);\n }\n\n /** Resolve a DEFAULT-scoped dependency from the hierarchy, enforcing scope & instantiation. */\n private resolveDefaultFromHierarchy(token: Token): any {\n const found = this.lookupDefInHierarchy(token);\n if (!found) throw new Error(`Cannot resolve token ${tokenName(token)}: not registered in hierarchy.`);\n const { registry, rec } = found;\n const sc = registry.getProviderScope(rec);\n if (sc !== ProviderScope.GLOBAL) {\n const scName = ProviderScope[sc];\n throw new Error(\n `Dependency ${tokenName(token)} is scoped (${scName}) in ${registry.constructor.name}; cannot use as DEFAULT.`,\n );\n }\n const inst = registry.instances.get(token);\n if (inst === undefined) {\n throw new Error(`Dependency ${tokenName(token)} (DEFAULT) is not instantiated in ${registry.constructor.name}`);\n }\n return inst;\n }\n\n /* -------------------- Build phase -------------------- */\n\n protected override buildMap(list: ProviderType[]): RegistryBuildMapResult<ProviderRecord> {\n const tokens = new Set<Token>();\n const defs = new Map<Token, ProviderRecord>();\n const graph = new Map<Token, Set<Token>>();\n\n for (const raw of list) {\n const rec = normalizeProvider(raw);\n const provide = rec.provide;\n tokens.add(provide);\n defs.set(provide, rec);\n graph.set(provide, new Set());\n }\n\n return { tokens, defs, graph };\n }\n\n protected buildGraph() {\n for (const token of this.tokens) {\n const rec = this.defs.get(token)!;\n const deps = this.discoveryDeps(rec);\n\n for (const d of deps) {\n const isLocal = this.tokens.has(d);\n const up = isLocal ? undefined : this.lookupDefInHierarchy(d);\n\n if (!isLocal && !up) {\n throw new Error(\n `Provider ${tokenName(token)} depends on ${tokenName(d)}, which is not registered (local or parent).`,\n );\n }\n\n const depRec = isLocal ? this.defs.get(d)! : up!.rec;\n const depScope = isLocal ? this.getProviderScope(depRec) : up!.registry.getProviderScope(depRec);\n\n if (this.getProviderScope(rec) === ProviderScope.GLOBAL && depScope !== ProviderScope.GLOBAL) {\n throw new Error(\n `Invalid dependency: DEFAULT-scoped provider ${tokenName(\n token,\n )} cannot depend on scoped provider ${tokenName(d)}.`,\n );\n }\n\n // Only wire local -> local edges in our local graph; parent deps are external to this DAG.\n if (isLocal) this.graph.get(token)!.add(d);\n }\n }\n }\n\n protected topoSort() {\n const WHITE = 0,\n GRAY = 1,\n BLACK = 2;\n const color = new Map<Token, number>();\n const order: Set<Token> = new Set();\n const path: Token[] = [];\n\n const dfs = (n: Token) => {\n color.set(n, GRAY);\n path.push(n);\n for (const dep of this.graph.get(n) ?? []) {\n const c = color.get(dep) ?? WHITE;\n if (c === GRAY) {\n const idx = path.findIndex((p) => p === dep);\n const cycle = [...path.slice(idx), dep].map((t) => tokenName(t)).join(' -> ');\n throw new Error(`Dependency cycle detected: ${cycle}`);\n }\n if (c === WHITE) dfs(dep);\n }\n color.set(n, BLACK);\n order.add(n);\n path.pop();\n };\n\n for (const n of this.graph.keys()) if ((color.get(n) ?? WHITE) === WHITE) dfs(n);\n this.order = order;\n }\n\n /** Incremental instantiation for DEFAULT providers.\n * - Skips already-built singletons unless force:true.\n * - Can limit to a subset via onlyTokens.\n */\n protected async initialize(opts?: { force?: boolean; onlyTokens?: Iterable<Token> }) {\n const force = !!opts?.force;\n const only = opts?.onlyTokens ? new Set(opts.onlyTokens) : null;\n\n for (const token of this.order) {\n const rec = this.defs.get(token)!;\n if (this.getProviderScope(rec) !== ProviderScope.GLOBAL) continue;\n\n if (only && !only.has(token)) continue;\n if (!force && this.instances.has(token)) continue;\n\n if (force && this.instances.has(token)) {\n this.instances.delete(token);\n }\n\n try {\n await this.initiateOne(token, rec);\n } catch (e: any) {\n const msg = e?.message ?? e;\n // Use safe logging to avoid Node.js 24 util.inspect bug with Zod errors\n console.error(`Failed instantiating:`, msg);\n throw new Error(`Failed constructing ${tokenName(token)}: ${msg}`);\n }\n }\n\n // Start background session cleanup after initialization\n // This ensures expired sessions are periodically cleaned up (TTL enforcement)\n // Only start for scope-level registries (those with parentProviders) since\n // SESSION providers are stored in scope registries, not the global registry\n if (this.parentProviders) {\n this.startSessionCleanup();\n }\n }\n\n /* -------------------- Views & session stores -------------------- */\n\n /** Return the live singleton map as a read-only view. No copying. */\n getAllSingletons(): ReadonlyMap<Token, unknown> {\n return this.instances; // exposed as ReadonlyMap in the type\n }\n discoveryDeps(rec: ProviderRecord): Token[] {\n return providerDiscoveryDeps(rec, this.tokens, (k, phase) => depsOfClass(k, phase));\n }\n\n invocationTokens(_token: Token, rec: ProviderRecord): Token[] {\n return providerInvocationTokens(rec, (k, phase) => depsOfClass(k, phase));\n }\n\n /**\n * Normalize deprecated scopes to their modern equivalents.\n *\n * - SESSION → CONTEXT (deprecated)\n * - REQUEST → CONTEXT (deprecated)\n *\n * This enables backwards compatibility while unifying the scope model.\n */\n private normalizeScope(scope: ProviderScope): ProviderScope {\n switch (scope) {\n case ProviderScope.SESSION:\n case ProviderScope.REQUEST:\n return ProviderScope.CONTEXT;\n default:\n return scope;\n }\n }\n\n getProviderScope(rec: ProviderRecord): ProviderScope {\n const rawScope = rec.metadata?.scope ?? ProviderScope.GLOBAL;\n return this.normalizeScope(rawScope);\n }\n\n getScope(): ScopeEntry {\n return this.getActiveScope();\n }\n\n /* -------------------- Instantiation -------------------- */\n\n private async withTimeout<T>(p: Promise<T>, ms: number, label: string): Promise<T> {\n if (ms <= 0 || !Number.isFinite(ms)) return p;\n let timer: any;\n try {\n const tm = new Promise<never>(\n (_, rej) => (timer = setTimeout(() => rej(new Error(`Timeout after ${ms}ms: ${label}`)), ms)),\n );\n return await Promise.race([p, tm]);\n } finally {\n clearTimeout(timer);\n }\n }\n\n private async resolveFactoryArg(t: Token, store: Map<Token, any>, scopeKey?: string): Promise<any> {\n if (store.has(t)) return store.get(t);\n if (this.instances.has(t)) return this.instances.get(t);\n\n // Local def?\n const rec = this.defs.get(t as any);\n if (rec) {\n const sc = this.getProviderScope(rec);\n if (sc === ProviderScope.GLOBAL) {\n if (!this.instances.has(t)) {\n throw new Error(`Dependency ${tokenName(t)} (DEFAULT scope) is not instantiated`);\n }\n return this.instances.get(t);\n } else {\n await this.buildIntoStore(t, rec, store, scopeKey);\n return store.get(t);\n }\n }\n\n // Parent def?\n const up = this.lookupDefInHierarchy(t);\n if (up) {\n const sc = up.registry.getProviderScope(up.rec);\n if (sc === ProviderScope.GLOBAL) {\n const inst = up.registry.instances.get(t);\n if (inst === undefined) {\n throw new Error(`Dependency ${tokenName(t)} (DEFAULT scope) is not instantiated in parent`);\n }\n return inst;\n } else {\n await up.registry.buildIntoStore(t, up.rec, store, scopeKey);\n return store.get(t);\n }\n }\n\n // Constructable fallback (non-DI)\n if (isClass(t)) {\n if (hasAsyncWith(t)) {\n const out = (t as any).with();\n return isPromise(out) ? await this.withTimeout(out, this.asyncTimeoutMs, `${t.name}.with(...)`) : out;\n }\n const instance = new (t as Ctor<any>)();\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${t.name}.init()`);\n }\n return instance;\n }\n\n throw new Error(`Cannot resolve token ${tokenName(t)}: not registered in hierarchy and not constructable.`);\n }\n\n /** Build a single DEFAULT-scoped singleton (used by incremental instantiating). */\n private async initiateOne(token: Token, rec: ProviderRecord): Promise<void> {\n switch (rec.kind) {\n case ProviderKind.VALUE: {\n this.instances.set(token, (rec as any).useValue);\n return;\n }\n case ProviderKind.FACTORY: {\n const deps = this.invocationTokens(token, rec);\n const args: any[] = [];\n for (const d of deps) args.push(await this.resolveFactoryArg(d, this.instances));\n const out = (rec as any).useFactory(...args);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${tokenName(token)}.useFactory(...)`)\n : out;\n this.instances.set(token, val);\n return;\n }\n case ProviderKind.CLASS: {\n const depTokens = this.invocationTokens(token, rec);\n const deps = depTokens.map((t) => this.resolveDefaultFromHierarchy(t));\n const klass = (rec as any).useClass;\n if (hasAsyncWith(klass)) {\n const out = (klass as any).with(...deps);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${klass.name}.with(...)`)\n : out;\n this.instances.set(token, val);\n } else {\n const instance = new (klass as Ctor<any>)(...deps);\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${klass.name}.init()`);\n }\n this.instances.set(token, instance);\n }\n return;\n }\n case ProviderKind.CLASS_TOKEN: {\n const depTokens = this.invocationTokens(token, rec);\n const deps = depTokens.map((t) => this.resolveDefaultFromHierarchy(t));\n const klass = (rec as any).provide;\n if (hasAsyncWith(klass)) {\n const out = (klass as any).with(...deps);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${klass.name}.with(...)`)\n : out;\n this.instances.set(token, val);\n } else {\n const instance = new (klass as Ctor<any>)(...deps);\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${klass.name}.init()`);\n }\n this.instances.set(token, instance);\n }\n return;\n }\n }\n }\n\n // Build a registered provider into the given scoped store (recursive for scoped deps).\n private async buildIntoStore(\n token: Token,\n rec: ProviderRecord,\n store: Map<Token, any>,\n scopeKey?: string,\n injectedDeps?: any[],\n ): Promise<void> {\n if (store.has(token)) return;\n\n try {\n switch (rec.kind) {\n case ProviderKind.VALUE: {\n store.set(token, (rec as any).useValue);\n return;\n }\n case ProviderKind.FACTORY: {\n const deps = this.invocationTokens(token, rec);\n const args: any[] = [];\n for (const d of deps) args.push(await this.resolveFactoryArg(d, store, scopeKey));\n const out = (rec as any).useFactory(...args);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${tokenName(token)}.useFactory(...)`)\n : out;\n store.set(token, val);\n return;\n }\n case ProviderKind.CLASS: {\n const depsTokens = this.invocationTokens(token, rec);\n const deps: any[] = [];\n for (const d of depsTokens) deps.push(await this.resolveManagedForClass(d, store, scopeKey));\n const klass = (rec as any).useClass as Ctor<any>;\n if (hasAsyncWith(klass)) {\n const out = (klass as any).with(...deps);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${klass.name}.with(...)`)\n : out;\n store.set(token, val);\n } else {\n const instance = new (klass as Ctor<any>)(...deps);\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${klass.name}.init()`);\n }\n store.set(token, instance);\n }\n return;\n }\n case ProviderKind.CLASS_TOKEN: {\n const depsTokens = this.invocationTokens(token, rec);\n const deps: any[] = injectedDeps ?? [];\n for (const d of depsTokens) deps.push(await this.resolveManagedForClass(d, store, scopeKey));\n const klass = (rec as any).provide as Ctor<any>;\n if (hasAsyncWith(klass)) {\n const out = (klass as any).with(...deps);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${klass.name}.with(...)`)\n : out;\n store.set(token, val);\n } else {\n const instance = new (klass as Ctor<any>)(...deps);\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${klass.name}.init()`);\n }\n store.set(token, instance);\n }\n return;\n }\n }\n } catch (e: any) {\n const msg = e?.message ?? e;\n // Use safe logging to avoid Node.js 24 util.inspect bug with Zod errors\n console.error(`Failed constructing:`, msg);\n throw new Error(`Failed constructing (scoped) ${tokenName(token)}: ${msg}`);\n }\n }\n\n // Ensure managed dependency value for CLASS/CLASS_TOKEN providers:\n // prefer scoped store, then singleton; recursively build scoped deps.\n // If not local, climb the hierarchy and either read DEFAULT instance or build scoped into this store.\n private async resolveManagedForClass(d: Token, store: Map<Token, any>, scopeKey?: string): Promise<any> {\n if (store.has(d)) return store.get(d);\n if (this.instances.has(d)) return this.instances.get(d);\n\n // Local DI?\n const depRec = this.defs.get(d as any);\n if (depRec) {\n const sc = this.getProviderScope(depRec);\n if (sc === ProviderScope.GLOBAL) {\n const v = this.instances.get(d);\n if (v === undefined) throw new Error(`${tokenName(d)} (DEFAULT scope) is not instantiated`);\n return v;\n } else {\n await this.buildIntoStore(d, depRec, store, scopeKey);\n return store.get(d);\n }\n }\n\n // Parent DI?\n const up = this.lookupDefInHierarchy(d);\n if (up) {\n const sc = up.registry.getProviderScope(up.rec);\n if (sc === ProviderScope.GLOBAL) {\n const v = up.registry.instances.get(d);\n if (v === undefined) throw new Error(`${tokenName(d)} (DEFAULT scope) is not instantiated in parent`);\n return v;\n } else {\n await up.registry.buildIntoStore(d, up.rec, store, scopeKey);\n return store.get(d);\n }\n }\n\n throw new Error(`${tokenName(d)} is not instantiated`);\n }\n\n get<T>(token: Token<T>): T {\n if (this.instances.has(token)) return this.instances.get(token) as T;\n\n const rec = this.defs.get(token as any);\n if (rec && this.getProviderScope(rec) !== ProviderScope.GLOBAL) {\n const scName = ProviderScope[this.getProviderScope(rec)];\n throw new Error(`Provider ${tokenName(token)} is scoped (${scName}). Use getScoped(token, key).`);\n }\n\n // bubble to parent\n if (this.providers) return this.providers.get<T>(token);\n\n throw new Error(`Provider ${tokenName(token)} is not available in local or parent registries`);\n }\n\n // noinspection JSUnusedGlobalSymbols\n addRegistry<T extends RegistryKind>(type: T, value: RegistryType[T]) {\n let registry = this.registries.get(type);\n if (!registry) {\n this.registries.set(type, new Set());\n registry = this.registries.get(type);\n }\n registry!.add(value as any);\n }\n\n getRegistries<T extends RegistryKind>(type: T): RegistryType[T][] {\n return [...(this.registries.get(type) ?? [])] as any;\n }\n\n getHooksRegistry() {\n return this.getRegistries('HookRegistry')[0] as HookRegistry;\n }\n\n // noinspection JSUnusedGlobalSymbols\n getScopeRegistry() {\n return this.getRegistries('ScopeRegistry')[0]!;\n }\n\n /** bootstrap helper: resolve a dependency usable during app bootstrap (must be GLOBAL). */\n async resolveBootstrapDep(t: Token): Promise<any> {\n if (this.instances.has(t)) return this.instances.get(t);\n if (this.registries.has(t as RegistryKind)) return this.registries.get(t as RegistryKind);\n\n const found = this.lookupDefInHierarchy(t);\n if (found) {\n const { registry, rec } = found;\n const sc = registry.getProviderScope(rec);\n if (sc !== ProviderScope.GLOBAL)\n throw new Error(`Plugin dependency ${tokenName(t)} must be DEFAULT-scoped at bootstrap`);\n const v = registry.instances.get(t);\n if (v === undefined) throw new Error(`Plugin dependency ${tokenName(t)} (DEFAULT scope) is not instantiated`);\n return v;\n }\n throw new Error(`Cannot resolve plugin dependency ${tokenName(t)} (local or parent)`);\n }\n\n /** Lightweight, synchronous resolver for app-scoped DI.\n * - If `cls` is a registered DEFAULT provider token, returns the singleton (must be instantiated).\n * - If `cls` is SCOPED in DI, throws (use getScoped/buildViews instead).\n * - Otherwise, if `cls` is a constructable class not registered in DI, returns `new cls()`.\n * If it defines a synchronous init(), it will be invoked (async init() is NOT awaited).\n */\n resolve<T>(cls: any): T {\n // 1) If it's a registered token (local or parent), handle via DI rules\n const found = this.lookupDefInHierarchy(cls as any);\n if (found) {\n const { registry, rec } = found;\n const sc = registry.getProviderScope(rec);\n if (sc !== ProviderScope.GLOBAL) {\n const scName = ProviderScope[sc];\n throw new Error(\n `Provider ${tokenName(cls)} is scoped (${scName}). Use getScoped(token, key) or buildViews(...).`,\n );\n }\n if (!registry.instances.has(cls)) {\n throw new Error(\n `Provider ${tokenName(cls)} (DEFAULT scope) is not instantiated. Call providers.instantiate() first.`,\n );\n }\n return registry.instances.get(cls) as T;\n }\n\n // 2) Not a registered token — best-effort construct (for tools/hooks/wrappers)\n if (isClass(cls)) {\n const instance = new (cls as Ctor<any>)();\n\n // Call sync init() if present (do NOT await)\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n // If someone accidentally made init async here, we intentionally do NOT await to keep it sync.\n init.call(instance);\n }\n\n return instance as T;\n }\n\n // 3) Unsupported token type\n throw new Error(\n `Cannot resolve ${tokenName(cls)}: not a registered DEFAULT provider and not a constructable class.`,\n );\n }\n\n mergeFromRegistry(\n providedBy: ProviderRegistry,\n exported: {\n token: Token<ProviderInterface>;\n def: ProviderRecord;\n instance: ProviderEntry;\n }[],\n ) {\n for (const { token, def, instance } of exported) {\n if (def.metadata.scope === ProviderScope.GLOBAL) {\n this.instances.set(token, instance);\n }\n this.defs.set(token, def);\n this.providedBy.set(token, providedBy);\n }\n }\n\n /**\n * Used by plugins to get the exported provider definitions.\n */\n getProviderInfo(token: Token<ProviderInterface>) {\n const def = this.defs.get(token);\n const instance = this.instances.get(token);\n if (!def || !instance)\n throw new Error(\n `Cannot get provider info for ${tokenName(\n token,\n )}: not a registered DEFAULT provider and not a constructable class.`,\n );\n return {\n token,\n def,\n instance,\n };\n }\n\n injectProvider(injected: Omit<ProviderInjectedRecord, 'kind'>) {\n const rec: ProviderInjectedRecord = {\n ...injected,\n kind: ProviderKind.INJECTED,\n };\n this.tokens.add(rec.provide);\n this.defs.set(rec.provide, rec);\n this.graph.set(rec.provide, new Set());\n this.instances.set(rec.provide, rec.value);\n }\n\n async addDynamicProviders(dynamicProviders: ProviderType[]) {\n // Normalize ProviderType[] to ProviderRecord[] before instantiation\n const normalized = dynamicProviders.map((p) => normalizeProvider(p));\n return Promise.all(normalized.map((rec) => this.initiateOne(rec.provide, rec)));\n }\n\n private getWithParents<T>(token: Token<T>): T {\n if (this.instances.has(token)) {\n return this.get(token);\n }\n const parent = this.parentProviders;\n if (!parent) {\n return this.get(token);\n }\n return parent.getWithParents(token);\n }\n\n getActiveScope(): Scope {\n return this.getWithParents(Scope);\n }\n\n getActiveServer(): FrontMcpServer {\n return this.getWithParents(FrontMcpServer);\n }\n\n /* -------------------- Session Cache Management -------------------- */\n\n /**\n * Clean up a specific session's provider cache.\n * Call this when a session is terminated or expired.\n *\n * @param sessionKey - The session identifier to clean up\n */\n cleanupSession(sessionKey: string): void {\n this.sessionStores.delete(sessionKey);\n // Resolve any waiters before deleting the lock to prevent hung promises\n const lock = this.sessionBuildLocks.get(sessionKey);\n if (lock) {\n lock.resolve();\n this.sessionBuildLocks.delete(sessionKey);\n }\n }\n\n /**\n * Clean up expired sessions from the cache.\n * Sessions older than SESSION_CACHE_TTL_MS are removed.\n *\n * @returns Number of sessions cleaned up\n */\n cleanupExpiredSessions(): number {\n const now = Date.now();\n const cutoff = now - ProviderRegistry.SESSION_CACHE_TTL_MS;\n let cleaned = 0;\n\n for (const [key, entry] of this.sessionStores) {\n if (entry.lastAccess < cutoff) {\n this.sessionStores.delete(key);\n // Resolve any waiters before deleting the lock to prevent hung promises\n const lock = this.sessionBuildLocks.get(key);\n if (lock) {\n lock.resolve();\n this.sessionBuildLocks.delete(key);\n }\n cleaned++;\n }\n }\n\n return cleaned;\n }\n\n /**\n * Start the background session cleanup timer.\n * This periodically removes expired sessions from the cache.\n */\n startSessionCleanup(): void {\n // Only start if not already running\n if (this.sessionCleanupInterval) {\n return;\n }\n\n this.sessionCleanupInterval = setInterval(() => {\n const cleaned = this.cleanupExpiredSessions();\n if (cleaned > 0) {\n console.debug(`[ProviderRegistry] Cleaned up ${cleaned} expired sessions`);\n }\n }, ProviderRegistry.SESSION_CLEANUP_INTERVAL_MS);\n\n // Allow the process to exit even if the interval is running\n // This is important for graceful shutdown in serverless environments\n if (this.sessionCleanupInterval.unref) {\n this.sessionCleanupInterval.unref();\n }\n }\n\n /**\n * Stop the background session cleanup timer.\n * Call this when shutting down the server gracefully.\n */\n stopSessionCleanup(): void {\n if (this.sessionCleanupInterval) {\n clearInterval(this.sessionCleanupInterval);\n this.sessionCleanupInterval = null;\n }\n }\n\n /**\n * Dispose of the registry, cleaning up all resources.\n * Call this when the registry/scope is being destroyed to prevent:\n * - Memory leaks from retained interval handles\n * - Orphaned session cleanup timers\n *\n * @example\n * ```typescript\n * // In scope teardown\n * scope.providers.dispose();\n * ```\n */\n dispose(): void {\n this.stopSessionCleanup();\n // Clear all session stores to help garbage collection\n this.sessionStores.clear();\n // Resolve any pending locks to prevent hung promises\n for (const lock of this.sessionBuildLocks.values()) {\n lock.resolve();\n }\n this.sessionBuildLocks.clear();\n }\n\n /**\n * Get session cache statistics for monitoring.\n */\n getSessionCacheStats(): { size: number; maxSize: number; ttlMs: number } {\n return {\n size: this.sessionStores.size,\n maxSize: ProviderRegistry.MAX_SESSION_CACHE_SIZE,\n ttlMs: ProviderRegistry.SESSION_CACHE_TTL_MS,\n };\n }\n\n /* -------------------- Scoped Provider Views -------------------- */\n\n /**\n * Build provider instance views for different scopes.\n *\n * This method creates a complete view of providers across all scopes:\n * - GLOBAL: Returns existing singleton instances (read-only)\n * - CONTEXT: Builds per-context providers (unified session + request)\n *\n * Note: For backwards compatibility, SESSION and REQUEST scopes are normalized\n * to CONTEXT. The returned views include `session` and `request` aliases that\n * both point to the `context` store.\n *\n * @param sessionKey - Unique context/session identifier for CONTEXT-scoped providers\n * @param contextProviders - Optional pre-built CONTEXT-scoped providers (e.g., FrontMcpContext)\n * @returns ProviderViews with global and context provider maps (session/request as aliases)\n */\n async buildViews(sessionKey: string, contextProviders?: Map<Token, unknown>): Promise<ProviderViews> {\n // Early validation BEFORE any cache operations or lock acquisition\n // This prevents cache pollution with invalid session keys\n SessionKey.validate(sessionKey);\n\n // 1. Global providers - return existing singletons\n const global = this.getAllSingletons();\n\n // 2. Context providers - build per-context (unified session+request)\n // Note: We don't cache context providers because they're per-request.\n // The unified context model means all non-global providers are fresh per-request.\n const contextStore = new Map<Token, unknown>(contextProviders);\n\n // Inject SessionKey for backwards compatibility with providers that depend on it\n // @deprecated - Providers should migrate to using FRONTMCP_CONTEXT instead\n if (!contextStore.has(SessionKey)) {\n contextStore.set(SessionKey, new SessionKey(sessionKey));\n }\n\n // Build all CONTEXT-scoped providers (including normalized SESSION/REQUEST)\n for (const token of this.order) {\n const rec = this.defs.get(token);\n if (!rec) continue;\n // getProviderScope() already normalizes SESSION/REQUEST → CONTEXT\n if (this.getProviderScope(rec) !== ProviderScope.CONTEXT) continue;\n if (contextStore.has(token)) continue;\n\n await this.buildIntoStoreWithViews(token, rec, contextStore, sessionKey, contextStore, global);\n }\n\n // Return views with backwards-compatible aliases\n // All three (context, session, request) point to the same map\n return {\n global,\n context: contextStore,\n // Backwards compatibility aliases\n session: contextStore,\n request: contextStore,\n };\n }\n\n /**\n * Build a provider into a store, with access to context and global views for dependencies.\n */\n private async buildIntoStoreWithViews(\n token: Token,\n rec: ProviderRecord,\n store: Map<Token, unknown>,\n scopeKey: string,\n contextStore: Map<Token, unknown>,\n globalStore: ReadonlyMap<Token, unknown>,\n ): Promise<void> {\n if (store.has(token)) return;\n\n try {\n switch (rec.kind) {\n case ProviderKind.VALUE: {\n store.set(token, (rec as any).useValue);\n return;\n }\n case ProviderKind.FACTORY: {\n const deps = this.invocationTokens(token, rec);\n const args: any[] = [];\n for (const d of deps) {\n args.push(await this.resolveFromViews(d, contextStore, globalStore, scopeKey));\n }\n const out = (rec as any).useFactory(...args);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${tokenName(token)}.useFactory(...)`)\n : out;\n store.set(token, val);\n return;\n }\n case ProviderKind.CLASS:\n case ProviderKind.CLASS_TOKEN: {\n const depsTokens = this.invocationTokens(token, rec);\n const deps: any[] = [];\n for (const d of depsTokens) {\n deps.push(await this.resolveFromViews(d, contextStore, globalStore, scopeKey));\n }\n const klass = rec.kind === ProviderKind.CLASS ? (rec as any).useClass : (rec as any).provide;\n if (hasAsyncWith(klass)) {\n const out = (klass as any).with(...deps);\n const val = isPromise(out)\n ? await this.withTimeout(out, this.asyncTimeoutMs, `${klass.name}.with(...)`)\n : out;\n store.set(token, val);\n } else {\n const instance = new (klass as Ctor<any>)(...deps);\n const init = (instance as any)?.init;\n if (typeof init === 'function') {\n const ret = init.call(instance);\n if (isPromise(ret)) await this.withTimeout(ret, this.asyncTimeoutMs, `${klass.name}.init()`);\n }\n store.set(token, instance);\n }\n return;\n }\n }\n } catch (e: any) {\n const msg = e?.message ?? e;\n console.error(`Failed constructing (context-scoped):`, msg);\n throw new Error(`Failed constructing (context-scoped) ${tokenName(token)}: ${msg}`);\n }\n }\n\n /**\n * Resolve a dependency from the available views (context → global).\n */\n private async resolveFromViews(\n token: Token,\n contextStore: Map<Token, unknown>,\n globalStore: ReadonlyMap<Token, unknown>,\n scopeKey: string,\n ): Promise<unknown> {\n // Check stores in order: context -> global -> instances\n if (contextStore.has(token)) return contextStore.get(token);\n if (globalStore.has(token)) return globalStore.get(token);\n if (this.instances.has(token)) return this.instances.get(token);\n\n // Try to build if it's a registered provider\n const rec = this.defs.get(token as any);\n if (rec) {\n const scope = this.getProviderScope(rec);\n if (scope === ProviderScope.GLOBAL) {\n throw new Error(`GLOBAL dependency ${tokenName(token)} is not instantiated`);\n } else {\n // CONTEXT scope - build into context store\n await this.buildIntoStoreWithViews(token, rec, contextStore, scopeKey, contextStore, globalStore);\n return contextStore.get(token);\n }\n }\n\n // Check parent hierarchy\n const up = this.lookupDefInHierarchy(token);\n if (up) {\n const sc = up.registry.getProviderScope(up.rec);\n if (sc === ProviderScope.GLOBAL) {\n const v = up.registry.instances.get(token);\n if (v !== undefined) return v;\n throw new Error(`GLOBAL dependency ${tokenName(token)} is not instantiated in parent`);\n }\n }\n\n throw new Error(`Cannot resolve dependency ${tokenName(token)} from views`);\n }\n\n /**\n * Get a provider from the given views, checking context → global.\n *\n * @param token - The provider token to look up\n * @param views - The provider views to search\n * @returns The provider instance\n * @throws Error if provider not found in any view\n */\n getScoped<T>(token: Token<T>, views: ProviderViews): T {\n // Check context first (unified session+request store)\n if (views.context.has(token)) return views.context.get(token) as T;\n if (views.global.has(token)) return views.global.get(token) as T;\n\n // Check instances as fallback for global providers\n if (this.instances.has(token)) return this.instances.get(token) as T;\n\n throw new Error(`Provider ${tokenName(token)} not found in views. Ensure it was built via buildViews().`);\n }\n}\n"]}
@@ -1,9 +1,27 @@
1
1
  import { Token } from '../common';
2
+ /**
3
+ * Provider instance views for different scopes.
4
+ *
5
+ * The unified context model uses:
6
+ * - global: GLOBAL-scoped singleton providers
7
+ * - context: CONTEXT-scoped providers (per-request/session)
8
+ *
9
+ * For backwards compatibility, `session` and `request` are provided as aliases
10
+ * to `context`. Both point to the same map.
11
+ */
2
12
  export interface ProviderViews {
3
- /** App-wide singletons, created at boot. Immutable from invokes POV. */
13
+ /** App-wide singletons, created at boot. Immutable from invoke's POV. */
4
14
  global: ReadonlyMap<Token, unknown>;
5
- /** Session-scoped cache for this sessionId. Mutable. */
15
+ /** Context-scoped providers for this invocation. Unified session+request data. */
16
+ context: Map<Token, unknown>;
17
+ /**
18
+ * @deprecated Use `context` instead. Alias for backwards compatibility.
19
+ * Points to the same map as `context`.
20
+ */
6
21
  session: Map<Token, unknown>;
7
- /** Request-scoped providers for this single invocation. Mutable. */
22
+ /**
23
+ * @deprecated Use `context` instead. Alias for backwards compatibility.
24
+ * Points to the same map as `context`.
25
+ */
8
26
  request: Map<Token, unknown>;
9
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"provider.types.js","sourceRoot":"","sources":["../../../src/provider/provider.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Token } from '../common';\n\nexport interface ProviderViews {\n /** App-wide singletons, created at boot. Immutable from invokes POV. */\n global: ReadonlyMap<Token, unknown>;\n /** Session-scoped cache for this sessionId. Mutable. */\n session: Map<Token, unknown>;\n /** Request-scoped providers for this single invocation. Mutable. */\n request: Map<Token, unknown>;\n}\n"]}
1
+ {"version":3,"file":"provider.types.js","sourceRoot":"","sources":["../../../src/provider/provider.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Token } from '../common';\n\n/**\n * Provider instance views for different scopes.\n *\n * The unified context model uses:\n * - global: GLOBAL-scoped singleton providers\n * - context: CONTEXT-scoped providers (per-request/session)\n *\n * For backwards compatibility, `session` and `request` are provided as aliases\n * to `context`. Both point to the same map.\n */\nexport interface ProviderViews {\n /** App-wide singletons, created at boot. Immutable from invoke's POV. */\n global: ReadonlyMap<Token, unknown>;\n\n /** Context-scoped providers for this invocation. Unified session+request data. */\n context: Map<Token, unknown>;\n\n /**\n * @deprecated Use `context` instead. Alias for backwards compatibility.\n * Points to the same map as `context`.\n */\n session: Map<Token, unknown>;\n\n /**\n * @deprecated Use `context` instead. Alias for backwards compatibility.\n * Points to the same map as `context`.\n */\n request: Map<Token, unknown>;\n}\n"]}
@@ -5,8 +5,15 @@ declare const inputSchema: z.ZodObject<{
5
5
  request: z.ZodObject<{
6
6
  method: z.ZodLiteral<"resources/read">;
7
7
  params: z.ZodObject<{
8
+ task: z.ZodOptional<z.ZodObject<{
9
+ ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
10
+ pollInterval: z.ZodOptional<z.ZodNumber>;
11
+ }, z.core.$loose>>;
8
12
  _meta: z.ZodOptional<z.ZodObject<{
9
13
  progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
14
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
15
+ taskId: z.ZodString;
16
+ }, z.core.$loose>>;
10
17
  }, z.core.$loose>>;
11
18
  uri: z.ZodString;
12
19
  }, z.core.$loose>;
@@ -14,7 +21,11 @@ declare const inputSchema: z.ZodObject<{
14
21
  ctx: z.ZodAny;
15
22
  }, z.core.$strip>;
16
23
  declare const outputSchema: z.ZodObject<{
17
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
24
+ _meta: z.ZodOptional<z.ZodObject<{
25
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
26
+ taskId: z.ZodString;
27
+ }, z.core.$loose>>;
28
+ }, z.core.$loose>>;
18
29
  contents: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
19
30
  uri: z.ZodString;
20
31
  mimeType: z.ZodOptional<z.ZodString>;
@@ -37,7 +48,11 @@ declare const stateSchema: z.ZodObject<{
37
48
  resourceContext: z.ZodType<ResourceContext>;
38
49
  rawOutput: z.ZodOptional<z.ZodAny>;
39
50
  output: z.ZodObject<{
40
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
51
+ _meta: z.ZodOptional<z.ZodObject<{
52
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
53
+ taskId: z.ZodString;
54
+ }, z.core.$loose>>;
55
+ }, z.core.$loose>>;
41
56
  contents: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
42
57
  uri: z.ZodString;
43
58
  mimeType: z.ZodOptional<z.ZodString>;
@@ -54,7 +69,11 @@ declare const stateSchema: z.ZodObject<{
54
69
  sessionId: z.ZodOptional<z.ZodString>;
55
70
  isUIResource: z.ZodDefault<z.ZodBoolean>;
56
71
  uiResourceResult: z.ZodOptional<z.ZodObject<{
57
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
72
+ _meta: z.ZodOptional<z.ZodObject<{
73
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
74
+ taskId: z.ZodString;
75
+ }, z.core.$loose>>;
76
+ }, z.core.$loose>>;
58
77
  contents: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
59
78
  uri: z.ZodString;
60
79
  mimeType: z.ZodOptional<z.ZodString>;
@@ -4,8 +4,15 @@ import { z } from 'zod';
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  request: z.ZodObject<{
6
6
  params: z.ZodOptional<z.ZodObject<{
7
+ task: z.ZodOptional<z.ZodObject<{
8
+ ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
9
+ pollInterval: z.ZodOptional<z.ZodNumber>;
10
+ }, z.core.$loose>>;
7
11
  _meta: z.ZodOptional<z.ZodObject<{
8
12
  progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
13
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
14
+ taskId: z.ZodString;
15
+ }, z.core.$loose>>;
9
16
  }, z.core.$loose>>;
10
17
  cursor: z.ZodOptional<z.ZodString>;
11
18
  }, z.core.$loose>>;
@@ -14,12 +21,24 @@ declare const inputSchema: z.ZodObject<{
14
21
  ctx: z.ZodUnknown;
15
22
  }, z.core.$strip>;
16
23
  declare const outputSchema: z.ZodObject<{
17
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
24
+ _meta: z.ZodOptional<z.ZodObject<{
25
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
26
+ taskId: z.ZodString;
27
+ }, z.core.$loose>>;
28
+ }, z.core.$loose>>;
18
29
  nextCursor: z.ZodOptional<z.ZodString>;
19
30
  resourceTemplates: z.ZodArray<z.ZodObject<{
20
31
  uriTemplate: z.ZodString;
21
32
  description: z.ZodOptional<z.ZodString>;
22
33
  mimeType: z.ZodOptional<z.ZodString>;
34
+ annotations: z.ZodOptional<z.ZodObject<{
35
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
36
+ user: "user";
37
+ assistant: "assistant";
38
+ }>>>;
39
+ priority: z.ZodOptional<z.ZodNumber>;
40
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
41
+ }, z.core.$strip>>;
23
42
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
24
43
  icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
25
44
  src: z.ZodString;
@@ -4,8 +4,15 @@ import { z } from 'zod';
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  request: z.ZodObject<{
6
6
  params: z.ZodOptional<z.ZodObject<{
7
+ task: z.ZodOptional<z.ZodObject<{
8
+ ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
9
+ pollInterval: z.ZodOptional<z.ZodNumber>;
10
+ }, z.core.$loose>>;
7
11
  _meta: z.ZodOptional<z.ZodObject<{
8
12
  progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
13
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
14
+ taskId: z.ZodString;
15
+ }, z.core.$loose>>;
9
16
  }, z.core.$loose>>;
10
17
  cursor: z.ZodOptional<z.ZodString>;
11
18
  }, z.core.$loose>>;
@@ -14,12 +21,24 @@ declare const inputSchema: z.ZodObject<{
14
21
  ctx: z.ZodUnknown;
15
22
  }, z.core.$strip>;
16
23
  declare const outputSchema: z.ZodObject<{
17
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
24
+ _meta: z.ZodOptional<z.ZodObject<{
25
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
26
+ taskId: z.ZodString;
27
+ }, z.core.$loose>>;
28
+ }, z.core.$loose>>;
18
29
  nextCursor: z.ZodOptional<z.ZodString>;
19
30
  resources: z.ZodArray<z.ZodObject<{
20
31
  uri: z.ZodString;
21
32
  description: z.ZodOptional<z.ZodString>;
22
33
  mimeType: z.ZodOptional<z.ZodString>;
34
+ annotations: z.ZodOptional<z.ZodObject<{
35
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
36
+ user: "user";
37
+ assistant: "assistant";
38
+ }>>>;
39
+ priority: z.ZodOptional<z.ZodNumber>;
40
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
41
+ }, z.core.$strip>>;
23
42
  _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
24
43
  icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
25
44
  src: z.ZodString;
@@ -4,8 +4,15 @@ declare const inputSchema: z.ZodObject<{
4
4
  request: z.ZodObject<{
5
5
  method: z.ZodLiteral<"resources/subscribe">;
6
6
  params: z.ZodObject<{
7
+ task: z.ZodOptional<z.ZodObject<{
8
+ ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
9
+ pollInterval: z.ZodOptional<z.ZodNumber>;
10
+ }, z.core.$loose>>;
7
11
  _meta: z.ZodOptional<z.ZodObject<{
8
12
  progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
13
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
14
+ taskId: z.ZodString;
15
+ }, z.core.$loose>>;
9
16
  }, z.core.$loose>>;
10
17
  uri: z.ZodString;
11
18
  }, z.core.$loose>;
@@ -13,7 +20,11 @@ declare const inputSchema: z.ZodObject<{
13
20
  ctx: z.ZodUnknown;
14
21
  }, z.core.$strip>;
15
22
  declare const outputSchema: z.ZodObject<{
16
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
23
+ _meta: z.ZodOptional<z.ZodObject<{
24
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
25
+ taskId: z.ZodString;
26
+ }, z.core.$loose>>;
27
+ }, z.core.$loose>>;
17
28
  }, z.core.$strict>;
18
29
  declare const stateSchema: z.ZodObject<{
19
30
  input: z.ZodObject<{
@@ -21,7 +32,11 @@ declare const stateSchema: z.ZodObject<{
21
32
  }, z.core.$strip>;
22
33
  sessionId: z.ZodString;
23
34
  output: z.ZodObject<{
24
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
35
+ _meta: z.ZodOptional<z.ZodObject<{
36
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
37
+ taskId: z.ZodString;
38
+ }, z.core.$loose>>;
39
+ }, z.core.$loose>>;
25
40
  }, z.core.$strict>;
26
41
  }, z.core.$strip>;
27
42
  declare const plan: {
@@ -4,8 +4,15 @@ declare const inputSchema: z.ZodObject<{
4
4
  request: z.ZodObject<{
5
5
  method: z.ZodLiteral<"resources/unsubscribe">;
6
6
  params: z.ZodObject<{
7
+ task: z.ZodOptional<z.ZodObject<{
8
+ ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
9
+ pollInterval: z.ZodOptional<z.ZodNumber>;
10
+ }, z.core.$loose>>;
7
11
  _meta: z.ZodOptional<z.ZodObject<{
8
12
  progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
13
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
14
+ taskId: z.ZodString;
15
+ }, z.core.$loose>>;
9
16
  }, z.core.$loose>>;
10
17
  uri: z.ZodString;
11
18
  }, z.core.$loose>;
@@ -13,7 +20,11 @@ declare const inputSchema: z.ZodObject<{
13
20
  ctx: z.ZodUnknown;
14
21
  }, z.core.$strip>;
15
22
  declare const outputSchema: z.ZodObject<{
16
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
23
+ _meta: z.ZodOptional<z.ZodObject<{
24
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
25
+ taskId: z.ZodString;
26
+ }, z.core.$loose>>;
27
+ }, z.core.$loose>>;
17
28
  }, z.core.$strict>;
18
29
  declare const stateSchema: z.ZodObject<{
19
30
  input: z.ZodObject<{
@@ -21,7 +32,11 @@ declare const stateSchema: z.ZodObject<{
21
32
  }, z.core.$strip>;
22
33
  sessionId: z.ZodString;
23
34
  output: z.ZodObject<{
24
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
35
+ _meta: z.ZodOptional<z.ZodObject<{
36
+ "io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
37
+ taskId: z.ZodString;
38
+ }, z.core.$loose>>;
39
+ }, z.core.$loose>>;
25
40
  }, z.core.$strict>;
26
41
  }, z.core.$strip>;
27
42
  declare const plan: {
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const common_1 = require("../../common");
6
6
  const zod_1 = require("zod");
7
7
  const session_verify_flow_1 = require("../../auth/flows/session.verify.flow");
8
+ const node_crypto_1 = require("node:crypto");
8
9
  const plan = {
9
10
  pre: [
10
11
  // request tracing
@@ -59,15 +60,22 @@ let HttpRequestFlow = class HttpRequestFlow extends common_1.FlowBase {
59
60
  async traceRequest() {
60
61
  const { request } = this.rawInput;
61
62
  this.requestStartTime = Date.now();
62
- this.requestId = `req-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
63
- // Extract useful tracing info
64
- const userAgent = request.headers?.['user-agent'];
65
- const sessionId = request.headers?.['mcp-session-id'];
66
- const contentType = request.headers?.['content-type'];
67
- const accept = request.headers?.['accept'];
63
+ // Get FrontMcpContext from AsyncLocalStorage (already initialized by FlowInstance.runWithContext)
64
+ const ctx = this.tryGetContext();
65
+ // Use randomUUID() for fallback instead of Math.random() to avoid collisions under load
66
+ this.requestId = ctx?.requestId ?? `req-${(0, node_crypto_1.randomUUID)()}`;
67
+ // Extract request details for logging
68
+ const headers = request.headers ?? {};
68
69
  const body = request.body;
70
+ const userAgent = headers['user-agent'];
71
+ const contentType = headers['content-type'];
72
+ const accept = headers['accept'];
73
+ // Use sessionId from context (which generates unique anon IDs) or header
74
+ // 'no-session' is a logging fallback only, not used for SESSION providers
75
+ const sessionId = ctx?.sessionId ?? headers['mcp-session-id'] ?? 'no-session';
69
76
  this.logger.info(`[${this.requestId}] ▶ ${request.method} ${request.path}`, {
70
77
  requestId: this.requestId,
78
+ traceId: ctx?.traceContext.traceId?.slice(0, 16),
71
79
  method: request.method,
72
80
  path: request.path,
73
81
  userAgent: userAgent?.slice(0, 50),
@@ -78,7 +86,6 @@ let HttpRequestFlow = class HttpRequestFlow extends common_1.FlowBase {
78
86
  bodyMethod: body?.['method'],
79
87
  });
80
88
  // Log sanitized headers for debugging connection issues
81
- const headers = request.headers ?? {};
82
89
  const sanitizedHeaders = Object.fromEntries(Object.entries(headers).map(([key, value]) => {
83
90
  // Redact clearly sensitive headers
84
91
  if (/^(authorization|proxy-authorization|cookie|set-cookie|x-api-key)$/i.test(key)) {
@@ -104,6 +111,28 @@ let HttpRequestFlow = class HttpRequestFlow extends common_1.FlowBase {
104
111
  this.state.set({
105
112
  verifyResult: result,
106
113
  });
114
+ // Update FrontMcpContext with verified auth info if available
115
+ // This allows all subsequent stages to access the auth info via context
116
+ if (result.kind === 'authorized' && result.authorization) {
117
+ const ctx = this.tryGetContext();
118
+ if (ctx) {
119
+ // Build AuthInfo from the authorization object
120
+ // AuthInfo is the MCP SDK's auth type with token, clientId, scopes, etc.
121
+ const { token, user, session } = result.authorization;
122
+ ctx.updateAuthInfo({
123
+ token,
124
+ clientId: user.sub,
125
+ scopes: [],
126
+ // JWT exp is in seconds, SDK uses milliseconds throughout (e.g., Date.now())
127
+ expiresAt: user.exp ? user.exp * 1000 : undefined,
128
+ extra: {
129
+ user,
130
+ sessionId: session?.id,
131
+ sessionPayload: session?.payload,
132
+ },
133
+ });
134
+ }
135
+ }
107
136
  }
108
137
  catch (error) {
109
138
  // FlowControl is expected control flow, not an error
@@ -138,6 +167,13 @@ let HttpRequestFlow = class HttpRequestFlow extends common_1.FlowBase {
138
167
  if (verifyResult.kind === 'authorized') {
139
168
  const { authorization } = verifyResult;
140
169
  request[common_1.ServerRequestTokens.auth] = authorization;
170
+ // Update FrontMcpContext session metadata (auth info already set in checkAuthorization)
171
+ if (authorization.session?.payload) {
172
+ const ctx = this.tryGetContext();
173
+ if (ctx) {
174
+ ctx.updateSessionMetadata(authorization.session.payload);
175
+ }
176
+ }
141
177
  if (authorization.session) {
142
178
  const sessionId = authorization.session.id;
143
179
  request[common_1.ServerRequestTokens.sessionId] = sessionId;