@frontmcp/sdk 0.4.1 → 0.5.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.
- package/README.md +30 -18
- package/package.json +20 -5
- package/src/app/app.registry.d.ts +3 -2
- package/src/app/app.registry.js +3 -1
- package/src/app/app.registry.js.map +1 -1
- package/src/app/instances/app.local.instance.js +2 -2
- package/src/app/instances/app.local.instance.js.map +1 -1
- package/src/auth/auth.registry.d.ts +34 -2
- package/src/auth/auth.registry.js +162 -24
- package/src/auth/auth.registry.js.map +1 -1
- package/src/auth/auth.utils.js +8 -9
- package/src/auth/auth.utils.js.map +1 -1
- package/src/auth/authorization/authorization.class.d.ts +125 -0
- package/src/auth/authorization/authorization.class.js +224 -0
- package/src/auth/authorization/authorization.class.js.map +1 -0
- package/src/auth/authorization/authorization.types.d.ts +300 -0
- package/src/auth/authorization/authorization.types.js +79 -0
- package/src/auth/authorization/authorization.types.js.map +1 -0
- package/src/auth/authorization/index.d.ts +5 -0
- package/src/auth/authorization/index.js +19 -0
- package/src/auth/authorization/index.js.map +1 -0
- package/src/auth/authorization/orchestrated.authorization.d.ts +242 -0
- package/src/auth/authorization/orchestrated.authorization.js +306 -0
- package/src/auth/authorization/orchestrated.authorization.js.map +1 -0
- package/src/auth/authorization/public.authorization.d.ts +91 -0
- package/src/auth/authorization/public.authorization.js +132 -0
- package/src/auth/authorization/public.authorization.js.map +1 -0
- package/src/auth/authorization/transparent.authorization.d.ts +130 -0
- package/src/auth/authorization/transparent.authorization.js +147 -0
- package/src/auth/authorization/transparent.authorization.js.map +1 -0
- package/src/auth/consent/consent.types.d.ts +111 -0
- package/src/auth/consent/consent.types.js +119 -0
- package/src/auth/consent/consent.types.js.map +1 -0
- package/src/auth/consent/index.d.ts +1 -0
- package/src/auth/consent/index.js +13 -0
- package/src/auth/consent/index.js.map +1 -0
- package/src/auth/detection/auth-provider-detection.d.ts +84 -0
- package/src/auth/detection/auth-provider-detection.js +230 -0
- package/src/auth/detection/auth-provider-detection.js.map +1 -0
- package/src/auth/detection/index.d.ts +1 -0
- package/src/auth/detection/index.js +15 -0
- package/src/auth/detection/index.js.map +1 -0
- package/src/auth/flows/auth.verify.flow.d.ts +110 -0
- package/src/auth/flows/auth.verify.flow.js +379 -0
- package/src/auth/flows/auth.verify.flow.js.map +1 -0
- package/src/auth/flows/oauth.authorize.flow.d.ts +118 -164
- package/src/auth/flows/oauth.authorize.flow.js +701 -33
- package/src/auth/flows/oauth.authorize.flow.js.map +1 -1
- package/src/auth/flows/oauth.callback.flow.d.ts +117 -0
- package/src/auth/flows/oauth.callback.flow.js +357 -0
- package/src/auth/flows/oauth.callback.flow.js.map +1 -0
- package/src/auth/flows/oauth.register.flow.d.ts +32 -125
- package/src/auth/flows/oauth.token.flow.d.ts +52 -154
- package/src/auth/flows/oauth.token.flow.js +193 -55
- package/src/auth/flows/oauth.token.flow.js.map +1 -1
- package/src/auth/flows/session.verify.flow.d.ts +66 -321
- package/src/auth/flows/session.verify.flow.js +107 -18
- package/src/auth/flows/session.verify.flow.js.map +1 -1
- package/src/auth/flows/well-known.jwks.flow.d.ts +34 -205
- package/src/auth/flows/well-known.jwks.flow.js +15 -8
- package/src/auth/flows/well-known.jwks.flow.js.map +1 -1
- package/src/auth/flows/well-known.oauth-authorization-server.flow.d.ts +48 -223
- package/src/auth/flows/well-known.oauth-authorization-server.flow.js +2 -3
- package/src/auth/flows/well-known.oauth-authorization-server.flow.js.map +1 -1
- package/src/auth/flows/well-known.prm.flow.d.ts +19 -120
- package/src/auth/flows/well-known.prm.flow.js +3 -4
- package/src/auth/flows/well-known.prm.flow.js.map +1 -1
- package/src/auth/instances/instance.local-primary-auth.d.ts +91 -4
- package/src/auth/instances/instance.local-primary-auth.js +236 -6
- package/src/auth/instances/instance.local-primary-auth.js.map +1 -1
- package/src/auth/instances/instance.remote-primary-auth.d.ts +4 -3
- package/src/auth/instances/instance.remote-primary-auth.js +2 -2
- package/src/auth/instances/instance.remote-primary-auth.js.map +1 -1
- package/src/auth/session/authorization-vault.d.ts +611 -0
- package/src/auth/session/authorization-vault.js +817 -0
- package/src/auth/session/authorization-vault.js.map +1 -0
- package/src/auth/session/authorization.store.d.ts +301 -0
- package/src/auth/session/authorization.store.js +323 -0
- package/src/auth/session/authorization.store.js.map +1 -0
- package/src/auth/session/encrypted-authorization-vault.d.ts +181 -0
- package/src/auth/session/encrypted-authorization-vault.js +493 -0
- package/src/auth/session/encrypted-authorization-vault.js.map +1 -0
- package/src/auth/session/index.d.ts +4 -4
- package/src/auth/session/index.js +11 -7
- package/src/auth/session/index.js.map +1 -1
- package/src/auth/session/session.schema.d.ts +1 -1
- package/src/auth/session/session.service.d.ts +1 -1
- package/src/auth/session/transport-session.manager.d.ts +101 -0
- package/src/auth/session/transport-session.manager.js +300 -0
- package/src/auth/session/transport-session.manager.js.map +1 -0
- package/src/auth/session/transport-session.types.d.ts +457 -0
- package/src/auth/session/transport-session.types.js +110 -0
- package/src/auth/session/transport-session.types.js.map +1 -0
- package/src/auth/session/utils/session-id.utils.d.ts +14 -2
- package/src/auth/session/utils/session-id.utils.js +68 -19
- package/src/auth/session/utils/session-id.utils.js.map +1 -1
- package/src/auth/session/vault-encryption.d.ts +189 -0
- package/src/auth/session/vault-encryption.js +263 -0
- package/src/auth/session/vault-encryption.js.map +1 -0
- package/src/auth/ui/base-layout.d.ts +188 -0
- package/src/auth/ui/base-layout.js +292 -0
- package/src/auth/ui/base-layout.js.map +1 -0
- package/src/auth/ui/htmx-templates.d.ts +135 -0
- package/src/auth/ui/htmx-templates.js +433 -0
- package/src/auth/ui/htmx-templates.js.map +1 -0
- package/src/auth/ui/index.d.ts +11 -0
- package/src/auth/ui/index.js +35 -0
- package/src/auth/ui/index.js.map +1 -0
- package/src/auth/utils/audience.validator.d.ts +129 -0
- package/src/auth/utils/audience.validator.js +196 -0
- package/src/auth/utils/audience.validator.js.map +1 -0
- package/src/auth/utils/index.d.ts +2 -0
- package/src/auth/utils/index.js +7 -0
- package/src/auth/utils/index.js.map +1 -0
- package/src/auth/utils/www-authenticate.utils.d.ts +97 -0
- package/src/auth/utils/www-authenticate.utils.js +183 -0
- package/src/auth/utils/www-authenticate.utils.js.map +1 -0
- package/src/common/common.schema.d.ts +2 -16
- package/src/common/constants.d.ts +3 -0
- package/src/common/constants.js +6 -1
- package/src/common/constants.js.map +1 -1
- package/src/common/decorators/decorator-utils.d.ts +131 -0
- package/src/common/decorators/decorator-utils.js +195 -0
- package/src/common/decorators/decorator-utils.js.map +1 -0
- package/src/common/decorators/front-mcp.decorator.js +3 -2
- package/src/common/decorators/front-mcp.decorator.js.map +1 -1
- package/src/common/decorators/hook.decorator.d.ts +58 -2
- package/src/common/decorators/hook.decorator.js +127 -17
- package/src/common/decorators/hook.decorator.js.map +1 -1
- package/src/common/decorators/plugin.decorator.d.ts +1 -1
- package/src/common/decorators/plugin.decorator.js +11 -10
- package/src/common/decorators/plugin.decorator.js.map +1 -1
- package/src/common/decorators/resource.decorator.d.ts +32 -3
- package/src/common/decorators/resource.decorator.js +46 -4
- package/src/common/decorators/resource.decorator.js.map +1 -1
- package/src/common/decorators/tool.decorator.d.ts +54 -5
- package/src/common/decorators/tool.decorator.js.map +1 -1
- package/src/common/dynamic/dynamic.plugin.d.ts +22 -11
- package/src/common/dynamic/dynamic.plugin.js +7 -1
- package/src/common/dynamic/dynamic.plugin.js.map +1 -1
- package/src/common/entries/prompt.entry.d.ts +46 -2
- package/src/common/entries/prompt.entry.js +10 -0
- package/src/common/entries/prompt.entry.js.map +1 -1
- package/src/common/entries/resource.entry.d.ts +69 -6
- package/src/common/entries/resource.entry.js +27 -3
- package/src/common/entries/resource.entry.js.map +1 -1
- package/src/common/entries/scope.entry.d.ts +5 -1
- package/src/common/entries/scope.entry.js +3 -3
- package/src/common/entries/scope.entry.js.map +1 -1
- package/src/common/flow/flow.utils.d.ts +56 -0
- package/src/common/flow/flow.utils.js +96 -0
- package/src/common/flow/flow.utils.js.map +1 -0
- package/src/common/index.d.ts +2 -2
- package/src/common/index.js +2 -2
- package/src/common/index.js.map +1 -1
- package/src/common/interfaces/execution-context.interface.d.ts +59 -0
- package/src/common/interfaces/execution-context.interface.js +81 -0
- package/src/common/interfaces/execution-context.interface.js.map +1 -0
- package/src/common/interfaces/flow.interface.d.ts +1 -1
- package/src/common/interfaces/flow.interface.js.map +1 -1
- package/src/common/interfaces/index.d.ts +1 -0
- package/src/common/interfaces/index.js +1 -0
- package/src/common/interfaces/index.js.map +1 -1
- package/src/common/interfaces/internal/primary-auth-provider.interface.d.ts +17 -2
- package/src/common/interfaces/internal/primary-auth-provider.interface.js +52 -4
- package/src/common/interfaces/internal/primary-auth-provider.interface.js.map +1 -1
- package/src/common/interfaces/internal/registry.interface.d.ts +16 -2
- package/src/common/interfaces/internal/registry.interface.js.map +1 -1
- package/src/common/interfaces/plugin.interface.js.map +1 -1
- package/src/common/interfaces/prompt.interface.d.ts +53 -4
- package/src/common/interfaces/prompt.interface.js +78 -0
- package/src/common/interfaces/prompt.interface.js.map +1 -1
- package/src/common/interfaces/resource.interface.d.ts +47 -17
- package/src/common/interfaces/resource.interface.js +53 -0
- package/src/common/interfaces/resource.interface.js.map +1 -1
- package/src/common/interfaces/tool.interface.d.ts +39 -22
- package/src/common/interfaces/tool.interface.js +61 -34
- package/src/common/interfaces/tool.interface.js.map +1 -1
- package/src/common/metadata/adapter.metadata.d.ts +1 -9
- package/src/common/metadata/app.metadata.d.ts +425 -730
- package/src/common/metadata/auth-provider.metadata.d.ts +2 -12
- package/src/common/metadata/flow.metadata.d.ts +10 -25
- package/src/common/metadata/front-mcp.metadata.d.ts +602 -1023
- package/src/common/metadata/front-mcp.metadata.js +6 -4
- package/src/common/metadata/front-mcp.metadata.js.map +1 -1
- package/src/common/metadata/hook.metadata.d.ts +1 -1
- package/src/common/metadata/hook.metadata.js.map +1 -1
- package/src/common/metadata/index.d.ts +1 -0
- package/src/common/metadata/index.js +1 -0
- package/src/common/metadata/index.js.map +1 -1
- package/src/common/metadata/logger.metadata.d.ts +1 -9
- package/src/common/metadata/plugin.metadata.d.ts +8 -30
- package/src/common/metadata/prompt.metadata.d.ts +4 -161
- package/src/common/metadata/provider.metadata.d.ts +2 -12
- package/src/common/metadata/resource.metadata.d.ts +6 -98
- package/src/common/metadata/resource.metadata.js +15 -6
- package/src/common/metadata/resource.metadata.js.map +1 -1
- package/src/common/metadata/tool-ui.metadata.d.ts +10 -0
- package/src/common/metadata/tool-ui.metadata.js +12 -0
- package/src/common/metadata/tool-ui.metadata.js.map +1 -0
- package/src/common/metadata/tool.metadata.d.ts +78 -199
- package/src/common/metadata/tool.metadata.js +11 -14
- package/src/common/metadata/tool.metadata.js.map +1 -1
- package/src/common/providers/base-config.provider.d.ts +84 -0
- package/src/common/providers/base-config.provider.js +128 -0
- package/src/common/providers/base-config.provider.js.map +1 -0
- package/src/common/records/plugin.record.d.ts +5 -6
- package/src/common/records/plugin.record.js.map +1 -1
- package/src/common/records/prompt.record.js.map +1 -1
- package/src/common/records/resource.record.d.ts +17 -1
- package/src/common/records/resource.record.js +12 -6
- package/src/common/records/resource.record.js.map +1 -1
- package/src/common/records/tool.record.js.map +1 -1
- package/src/common/schemas/annotated-class.schema.d.ts +9 -9
- package/src/common/schemas/annotated-class.schema.js +92 -27
- package/src/common/schemas/annotated-class.schema.js.map +1 -1
- package/src/common/schemas/http-input.schema.d.ts +6 -30
- package/src/common/schemas/http-output.schema.d.ts +326 -1630
- package/src/common/schemas/http-output.schema.js +39 -1
- package/src/common/schemas/http-output.schema.js.map +1 -1
- package/src/common/tokens/front-mcp.tokens.js +4 -1
- package/src/common/tokens/front-mcp.tokens.js.map +1 -1
- package/src/common/tokens/resource.tokens.d.ts +2 -0
- package/src/common/tokens/resource.tokens.js +4 -1
- package/src/common/tokens/resource.tokens.js.map +1 -1
- package/src/common/tokens/tool.tokens.d.ts +2 -0
- package/src/common/tokens/tool.tokens.js +2 -0
- package/src/common/tokens/tool.tokens.js.map +1 -1
- package/src/common/types/auth/jwt.types.d.ts +5 -31
- package/src/common/types/auth/session.types.d.ts +97 -192
- package/src/common/types/auth/session.types.js +24 -11
- package/src/common/types/auth/session.types.js.map +1 -1
- package/src/common/types/options/auth.options.d.ts +1013 -490
- package/src/common/types/options/auth.options.js +554 -36
- package/src/common/types/options/auth.options.js.map +1 -1
- package/src/common/types/options/http.options.d.ts +1 -9
- package/src/common/types/options/logging.options.d.ts +7 -13
- package/src/common/types/options/logging.options.js +4 -0
- package/src/common/types/options/logging.options.js.map +1 -1
- package/src/common/types/options/server-info.options.d.ts +3 -31
- package/src/common/types/options/session.options.d.ts +90 -10
- package/src/common/types/options/session.options.js +26 -3
- package/src/common/types/options/session.options.js.map +1 -1
- package/src/common/utils/decide-request-intent.utils.d.ts +8 -46
- package/src/common/utils/decide-request-intent.utils.js +88 -23
- package/src/common/utils/decide-request-intent.utils.js.map +1 -1
- package/src/completion/flows/complete.flow.d.ts +74 -0
- package/src/completion/flows/complete.flow.js +199 -0
- package/src/completion/flows/complete.flow.js.map +1 -0
- package/src/errors/authorization-required.error.d.ts +189 -0
- package/src/errors/authorization-required.error.js +274 -0
- package/src/errors/authorization-required.error.js.map +1 -0
- package/src/errors/index.d.ts +2 -1
- package/src/errors/index.js +17 -1
- package/src/errors/index.js.map +1 -1
- package/src/errors/mcp.error.d.ts +101 -1
- package/src/errors/mcp.error.js +147 -2
- package/src/errors/mcp.error.js.map +1 -1
- package/src/flows/flow.instance.js +4 -3
- package/src/flows/flow.instance.js.map +1 -1
- package/src/flows/flow.registry.js.map +1 -1
- package/src/flows/flow.stages.js +14 -11
- package/src/flows/flow.stages.js.map +1 -1
- package/src/front-mcp/front-mcp.providers.d.ts +464 -102
- package/src/front-mcp/front-mcp.providers.js +3 -5
- package/src/front-mcp/front-mcp.providers.js.map +1 -1
- package/src/hooks/hook.instance.d.ts +1 -1
- package/src/hooks/hook.instance.js +5 -2
- package/src/hooks/hook.instance.js.map +1 -1
- package/src/hooks/hook.registry.js +7 -5
- package/src/hooks/hook.registry.js.map +1 -1
- package/src/index.d.ts +28 -9
- package/src/index.js +5 -1
- package/src/index.js.map +1 -1
- package/src/logger/instances/instance.logger.js +3 -2
- package/src/logger/instances/instance.logger.js.map +1 -1
- package/src/logger/logger.registry.js +7 -2
- package/src/logger/logger.registry.js.map +1 -1
- package/src/logging/flows/set-level.flow.d.ts +62 -0
- package/src/logging/flows/set-level.flow.js +108 -0
- package/src/logging/flows/set-level.flow.js.map +1 -0
- package/src/mcp-apps/csp.d.ts +111 -0
- package/src/mcp-apps/csp.js +267 -0
- package/src/mcp-apps/csp.js.map +1 -0
- package/src/mcp-apps/index.d.ts +23 -0
- package/src/mcp-apps/index.js +91 -0
- package/src/mcp-apps/index.js.map +1 -0
- package/src/mcp-apps/schemas.d.ts +403 -0
- package/src/mcp-apps/schemas.js +345 -0
- package/src/mcp-apps/schemas.js.map +1 -0
- package/src/mcp-apps/template.d.ts +94 -0
- package/src/mcp-apps/template.js +419 -0
- package/src/mcp-apps/template.js.map +1 -0
- package/src/mcp-apps/types.d.ts +323 -0
- package/src/mcp-apps/types.js +59 -0
- package/src/mcp-apps/types.js.map +1 -0
- package/src/notification/index.d.ts +1 -0
- package/src/notification/index.js +13 -0
- package/src/notification/index.js.map +1 -0
- package/src/notification/notification.service.d.ts +378 -0
- package/src/notification/notification.service.js +727 -0
- package/src/notification/notification.service.js.map +1 -0
- package/src/plugin/plugin.registry.js +12 -9
- package/src/plugin/plugin.registry.js.map +1 -1
- package/src/prompt/flows/get-prompt.flow.d.ts +153 -0
- package/src/prompt/flows/get-prompt.flow.js +214 -0
- package/src/prompt/flows/get-prompt.flow.js.map +1 -0
- package/src/prompt/flows/prompts-list.flow.d.ts +67 -0
- package/src/prompt/flows/prompts-list.flow.js +176 -0
- package/src/prompt/flows/prompts-list.flow.js.map +1 -0
- package/src/prompt/index.d.ts +7 -0
- package/src/prompt/index.js +17 -0
- package/src/prompt/index.js.map +1 -0
- package/src/prompt/prompt.events.d.ts +17 -0
- package/src/prompt/prompt.events.js +25 -0
- package/src/prompt/prompt.events.js.map +1 -0
- package/src/prompt/prompt.instance.d.ts +30 -0
- package/src/prompt/prompt.instance.js +120 -0
- package/src/prompt/prompt.instance.js.map +1 -0
- package/src/prompt/prompt.registry.d.ts +79 -12
- package/src/prompt/prompt.registry.js +360 -15
- package/src/prompt/prompt.registry.js.map +1 -1
- package/src/prompt/prompt.types.d.ts +26 -0
- package/src/prompt/prompt.types.js +11 -0
- package/src/prompt/prompt.types.js.map +1 -0
- package/src/prompt/prompt.utils.d.ts +26 -0
- package/src/prompt/prompt.utils.js +136 -0
- package/src/prompt/prompt.utils.js.map +1 -0
- package/src/provider/provider.registry.d.ts +12 -5
- package/src/provider/provider.registry.js +30 -138
- package/src/provider/provider.registry.js.map +1 -1
- package/src/regsitry/registry.base.d.ts +1 -1
- package/src/regsitry/registry.base.js.map +1 -1
- package/src/resource/flows/read-resource.flow.d.ts +91 -0
- package/src/resource/flows/read-resource.flow.js +270 -0
- package/src/resource/flows/read-resource.flow.js.map +1 -0
- package/src/resource/flows/resource-templates-list.flow.d.ts +64 -0
- package/src/resource/flows/resource-templates-list.flow.js +191 -0
- package/src/resource/flows/resource-templates-list.flow.js.map +1 -0
- package/src/resource/flows/resources-list.flow.d.ts +64 -0
- package/src/resource/flows/resources-list.flow.js +196 -0
- package/src/resource/flows/resources-list.flow.js.map +1 -0
- package/src/resource/flows/subscribe-resource.flow.d.ts +45 -0
- package/src/resource/flows/subscribe-resource.flow.js +123 -0
- package/src/resource/flows/subscribe-resource.flow.js.map +1 -0
- package/src/resource/flows/unsubscribe-resource.flow.d.ts +44 -0
- package/src/resource/flows/unsubscribe-resource.flow.js +107 -0
- package/src/resource/flows/unsubscribe-resource.flow.js.map +1 -0
- package/src/resource/index.d.ts +8 -0
- package/src/resource/index.js +20 -0
- package/src/resource/index.js.map +1 -0
- package/src/resource/resource.events.d.ts +24 -0
- package/src/resource/resource.events.js +17 -0
- package/src/resource/resource.events.js.map +1 -0
- package/src/resource/resource.instance.d.ts +35 -0
- package/src/resource/resource.instance.js +163 -0
- package/src/resource/resource.instance.js.map +1 -0
- package/src/resource/resource.registry.d.ts +106 -12
- package/src/resource/resource.registry.js +449 -13
- package/src/resource/resource.registry.js.map +1 -1
- package/src/resource/resource.types.d.ts +35 -0
- package/src/resource/resource.types.js +11 -0
- package/src/resource/resource.types.js.map +1 -0
- package/src/resource/resource.utils.d.ts +30 -0
- package/src/resource/resource.utils.js +151 -0
- package/src/resource/resource.utils.js.map +1 -0
- package/src/scope/flows/http.request.flow.d.ts +48 -330
- package/src/scope/flows/http.request.flow.js +306 -78
- package/src/scope/flows/http.request.flow.js.map +1 -1
- package/src/scope/scope.instance.d.ts +12 -0
- package/src/scope/scope.instance.js +145 -15
- package/src/scope/scope.instance.js.map +1 -1
- package/src/tool/flows/call-tool.flow.d.ts +64 -1110
- package/src/tool/flows/call-tool.flow.js +303 -15
- package/src/tool/flows/call-tool.flow.js.map +1 -1
- package/src/tool/flows/tools-list.flow.d.ts +32 -473
- package/src/tool/flows/tools-list.flow.js +121 -40
- package/src/tool/flows/tools-list.flow.js.map +1 -1
- package/src/tool/tool.events.d.ts +8 -1
- package/src/tool/tool.events.js.map +1 -1
- package/src/tool/tool.instance.d.ts +3 -1
- package/src/tool/tool.instance.js +17 -3
- package/src/tool/tool.instance.js.map +1 -1
- package/src/tool/tool.registry.d.ts +7 -1
- package/src/tool/tool.registry.js +26 -10
- package/src/tool/tool.registry.js.map +1 -1
- package/src/tool/tool.types.d.ts +4 -4
- package/src/tool/tool.types.js.map +1 -1
- package/src/tool/tool.utils.d.ts +3 -12
- package/src/tool/tool.utils.js +39 -193
- package/src/tool/tool.utils.js.map +1 -1
- package/src/tool/ui/index.d.ts +22 -0
- package/src/tool/ui/index.js +63 -0
- package/src/tool/ui/index.js.map +1 -0
- package/src/tool/ui/platform-adapters.d.ts +10 -0
- package/src/tool/ui/platform-adapters.js +18 -0
- package/src/tool/ui/platform-adapters.js.map +1 -0
- package/src/tool/ui/template-helpers.d.ts +46 -0
- package/src/tool/ui/template-helpers.js +112 -0
- package/src/tool/ui/template-helpers.js.map +1 -0
- package/src/tool/ui/ui-resource-template.d.ts +34 -0
- package/src/tool/ui/ui-resource-template.js +64 -0
- package/src/tool/ui/ui-resource-template.js.map +1 -0
- package/src/tool/ui/ui-resource.handler.d.ts +74 -0
- package/src/tool/ui/ui-resource.handler.js +129 -0
- package/src/tool/ui/ui-resource.handler.js.map +1 -0
- package/src/transport/adapters/transport.local.adapter.d.ts +2 -2
- package/src/transport/adapters/transport.local.adapter.js +28 -7
- package/src/transport/adapters/transport.local.adapter.js.map +1 -1
- package/src/transport/adapters/transport.sse.adapter.d.ts +2 -2
- package/src/transport/adapters/transport.sse.adapter.js +4 -3
- package/src/transport/adapters/transport.sse.adapter.js.map +1 -1
- package/src/transport/adapters/transport.streamable-http.adapter.d.ts +10 -3
- package/src/transport/adapters/transport.streamable-http.adapter.js +54 -8
- package/src/transport/adapters/transport.streamable-http.adapter.js.map +1 -1
- package/src/transport/flows/handle.sse.flow.d.ts +29 -63
- package/src/transport/flows/handle.sse.flow.js +78 -10
- package/src/transport/flows/handle.sse.flow.js.map +1 -1
- package/src/transport/flows/handle.stateless-http.flow.d.ts +29 -0
- package/src/transport/flows/handle.stateless-http.flow.js +102 -0
- package/src/transport/flows/handle.stateless-http.flow.js.map +1 -0
- package/src/transport/flows/handle.streamable-http.flow.d.ts +32 -64
- package/src/transport/flows/handle.streamable-http.flow.js +158 -26
- package/src/transport/flows/handle.streamable-http.flow.js.map +1 -1
- package/src/transport/legacy/legacy.sse.tranporter.d.ts +9 -0
- package/src/transport/legacy/legacy.sse.tranporter.js +17 -2
- package/src/transport/legacy/legacy.sse.tranporter.js.map +1 -1
- package/src/transport/mcp-handlers/call-tool-request.handler.js +27 -1
- package/src/transport/mcp-handlers/call-tool-request.handler.js.map +1 -1
- package/src/transport/mcp-handlers/complete-request.handler.d.ts +69 -0
- package/src/transport/mcp-handlers/complete-request.handler.js +11 -0
- package/src/transport/mcp-handlers/complete-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/get-prompt-request.handler.d.ts +87 -0
- package/src/transport/mcp-handlers/get-prompt-request.handler.js +11 -0
- package/src/transport/mcp-handlers/get-prompt-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/index.d.ts +517 -208
- package/src/transport/mcp-handlers/index.js +39 -2
- package/src/transport/mcp-handlers/index.js.map +1 -1
- package/src/transport/mcp-handlers/initialize-request.handler.d.ts +1 -1
- package/src/transport/mcp-handlers/initialize-request.handler.js +73 -7
- package/src/transport/mcp-handlers/initialize-request.handler.js.map +1 -1
- package/src/transport/mcp-handlers/list-prompts-request.handler.d.ts +54 -0
- package/src/transport/mcp-handlers/list-prompts-request.handler.js +11 -0
- package/src/transport/mcp-handlers/list-prompts-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.d.ts +51 -0
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.js +12 -0
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/list-resources-request.handler.d.ts +51 -0
- package/src/transport/mcp-handlers/list-resources-request.handler.js +12 -0
- package/src/transport/mcp-handlers/list-resources-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/list-tools-request.handler.d.ts +19 -146
- package/src/transport/mcp-handlers/logging-set-level-request.handler.d.ts +46 -0
- package/src/transport/mcp-handlers/logging-set-level-request.handler.js +34 -0
- package/src/transport/mcp-handlers/logging-set-level-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/mcp-handlers.types.d.ts +3 -7
- package/src/transport/mcp-handlers/mcp-handlers.types.js.map +1 -1
- package/src/transport/mcp-handlers/read-resource-request.handler.d.ts +46 -0
- package/src/transport/mcp-handlers/read-resource-request.handler.js +12 -0
- package/src/transport/mcp-handlers/read-resource-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.d.ts +11 -0
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.js +26 -0
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.js.map +1 -0
- package/src/transport/mcp-handlers/subscribe-request.handler.d.ts +37 -0
- package/src/transport/mcp-handlers/subscribe-request.handler.js +34 -0
- package/src/transport/mcp-handlers/subscribe-request.handler.js.map +1 -0
- package/src/transport/mcp-handlers/unsubscribe-request.handler.d.ts +37 -0
- package/src/transport/mcp-handlers/unsubscribe-request.handler.js +34 -0
- package/src/transport/mcp-handlers/unsubscribe-request.handler.js.map +1 -0
- package/src/transport/transport.local.js +7 -2
- package/src/transport/transport.local.js.map +1 -1
- package/src/transport/transport.registry.d.ts +30 -0
- package/src/transport/transport.registry.js +84 -1
- package/src/transport/transport.registry.js.map +1 -1
- package/src/transport/transport.types.d.ts +3 -3
- package/src/transport/transport.types.js.map +1 -1
- package/src/utils/content.utils.d.ts +48 -0
- package/src/utils/content.utils.js +194 -0
- package/src/utils/content.utils.js.map +1 -0
- package/src/utils/index.d.ts +8 -0
- package/src/utils/index.js +55 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/lineage.utils.d.ts +40 -0
- package/src/utils/lineage.utils.js +82 -0
- package/src/utils/lineage.utils.js.map +1 -0
- package/src/utils/naming.utils.d.ts +46 -0
- package/src/utils/naming.utils.js +136 -0
- package/src/utils/naming.utils.js.map +1 -0
- package/src/utils/types.utils.d.ts +2 -2
- package/src/utils/types.utils.js.map +1 -1
- package/src/utils/uri-template.utils.d.ts +57 -0
- package/src/utils/uri-template.utils.js +113 -0
- package/src/utils/uri-template.utils.js.map +1 -0
- package/src/utils/uri-validation.utils.d.ts +40 -0
- package/src/utils/uri-validation.utils.js +76 -0
- package/src/utils/uri-validation.utils.js.map +1 -0
- package/src/__test-utils__/fixtures/hook.fixtures.d.ts +0 -46
- package/src/__test-utils__/fixtures/hook.fixtures.js +0 -114
- package/src/__test-utils__/fixtures/hook.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/index.d.ts +0 -7
- package/src/__test-utils__/fixtures/index.js +0 -11
- package/src/__test-utils__/fixtures/index.js.map +0 -1
- package/src/__test-utils__/fixtures/plugin.fixtures.d.ts +0 -46
- package/src/__test-utils__/fixtures/plugin.fixtures.js +0 -127
- package/src/__test-utils__/fixtures/plugin.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/provider.fixtures.d.ts +0 -69
- package/src/__test-utils__/fixtures/provider.fixtures.js +0 -131
- package/src/__test-utils__/fixtures/provider.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/scope.fixtures.d.ts +0 -14
- package/src/__test-utils__/fixtures/scope.fixtures.js +0 -59
- package/src/__test-utils__/fixtures/scope.fixtures.js.map +0 -1
- package/src/__test-utils__/fixtures/tool.fixtures.d.ts +0 -36
- package/src/__test-utils__/fixtures/tool.fixtures.js +0 -91
- package/src/__test-utils__/fixtures/tool.fixtures.js.map +0 -1
- package/src/__test-utils__/helpers/assertion.helpers.d.ts +0 -45
- package/src/__test-utils__/helpers/assertion.helpers.js +0 -153
- package/src/__test-utils__/helpers/assertion.helpers.js.map +0 -1
- package/src/__test-utils__/helpers/async.helpers.d.ts +0 -48
- package/src/__test-utils__/helpers/async.helpers.js +0 -112
- package/src/__test-utils__/helpers/async.helpers.js.map +0 -1
- package/src/__test-utils__/helpers/index.d.ts +0 -6
- package/src/__test-utils__/helpers/index.js +0 -10
- package/src/__test-utils__/helpers/index.js.map +0 -1
- package/src/__test-utils__/helpers/setup.helpers.d.ts +0 -54
- package/src/__test-utils__/helpers/setup.helpers.js +0 -106
- package/src/__test-utils__/helpers/setup.helpers.js.map +0 -1
- package/src/__test-utils__/index.d.ts +0 -9
- package/src/__test-utils__/index.js +0 -14
- package/src/__test-utils__/index.js.map +0 -1
- package/src/__test-utils__/mocks/flow-instance.mock.d.ts +0 -50
- package/src/__test-utils__/mocks/flow-instance.mock.js +0 -72
- package/src/__test-utils__/mocks/flow-instance.mock.js.map +0 -1
- package/src/__test-utils__/mocks/hook-registry.mock.d.ts +0 -25
- package/src/__test-utils__/mocks/hook-registry.mock.js +0 -65
- package/src/__test-utils__/mocks/hook-registry.mock.js.map +0 -1
- package/src/__test-utils__/mocks/index.d.ts +0 -8
- package/src/__test-utils__/mocks/index.js +0 -12
- package/src/__test-utils__/mocks/index.js.map +0 -1
- package/src/__test-utils__/mocks/plugin-registry.mock.d.ts +0 -43
- package/src/__test-utils__/mocks/plugin-registry.mock.js +0 -70
- package/src/__test-utils__/mocks/plugin-registry.mock.js.map +0 -1
- package/src/__test-utils__/mocks/provider-registry.mock.d.ts +0 -39
- package/src/__test-utils__/mocks/provider-registry.mock.js +0 -72
- package/src/__test-utils__/mocks/provider-registry.mock.js.map +0 -1
- package/src/__test-utils__/mocks/tool-registry.mock.d.ts +0 -43
- package/src/__test-utils__/mocks/tool-registry.mock.js +0 -79
- package/src/__test-utils__/mocks/tool-registry.mock.js.map +0 -1
- package/src/auth/path.utils.d.ts +0 -20
- package/src/auth/path.utils.js +0 -71
- package/src/auth/path.utils.js.map +0 -1
- package/src/common/decorators-old/async-with.decorator.d.ts +0 -10
- package/src/common/decorators-old/async-with.decorator.js +0 -24
- package/src/common/decorators-old/async-with.decorator.js.map +0 -1
- package/src/common/decorators-old/auth-hook.decorator.d.ts +0 -14
- package/src/common/decorators-old/auth-hook.decorator.js +0 -27
- package/src/common/decorators-old/auth-hook.decorator.js.map +0 -1
- package/src/common/decorators-old/session-hook.decorator.d.ts +0 -14
- package/src/common/decorators-old/session-hook.decorator.js +0 -27
- package/src/common/decorators-old/session-hook.decorator.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.service.js","sourceRoot":"","sources":["../../../src/notification/notification.service.ts"],"names":[],"mappings":";AAAA,0DAA0D;;;AAqE1D,kDAMC;AAQD,wEAKC;AA4FD,kEAkBC;AAUD,4CAkBC;AA/ND,iEAAyG;AAwDzG;;GAEG;AACU,QAAA,sBAAsB,GAAG,4BAAqC,CAAC;AAE5E;;;;GAIG;AACH,SAAgB,m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C,IAAI,CAAC,gCAAgC,CAAC,CAAC;IACrD,CAAC;IAEO,wBAAwB,CAC9B,MAAiB,EACjB,SAAiB,EACjB,MAA6B,EAC7B,MAAgC;QAEhC,IAAI,CAAC;YACH,gEAAgE;YAChE,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;YACtD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,MAAM,eAAe,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QAChF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,+CAA+C;YAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,+BAA+B,MAAM,eAAe,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,QACxE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAC3C,EAAE,CACH,CAAC;YACF,sCAAsC;YACtC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;;AAroBH,kDAsoBC","sourcesContent":["// file: libs/sdk/src/notification/notification.service.ts\n\nimport { Server as McpServer } from '@modelcontextprotocol/sdk/server/index.js';\nimport { ListRootsResultSchema, type LoggingLevel, type Root } from '@modelcontextprotocol/sdk/types.js';\nimport { FrontMcpLogger } from '../common';\nimport type { Scope } from '../scope';\nimport type { AIPlatformType } from '../common/types/auth/session.types';\nimport type { PlatformDetectionConfig, PlatformMappingEntry } from '../common/types/options/session.options';\n\n/**\n * Re-export Root from MCP SDK for convenience.\n * Per MCP 2025-11-25 specification.\n */\nexport type { Root };\n\n/**\n * Re-export AIPlatformType from session types for backwards compatibility.\n */\nexport type { AIPlatformType } from '../common/types/auth/session.types';\n\n/**\n * Alias for MCP SDK's LoggingLevel for backwards compatibility.\n * @deprecated Use LoggingLevel from @modelcontextprotocol/sdk/types.js directly\n */\nexport type McpLoggingLevel = LoggingLevel;\n\n/**\n * Client capabilities from the initialize request.\n * Stored per session to understand what the client supports.\n */\nexport interface ClientCapabilities {\n /** Whether the client supports roots and root change notifications */\n roots?: {\n listChanged?: boolean;\n };\n /** Other capabilities can be added here as needed */\n sampling?: Record<string, unknown>;\n /** Experimental capabilities including MCP Apps extension */\n experimental?: {\n /** MCP Apps (ext-apps) extension capability */\n 'io.modelcontextprotocol/ui'?: {\n /** Supported MIME types (e.g., ['text/html+mcp']) */\n mimeTypes?: string[];\n };\n [key: string]: unknown;\n };\n}\n\n/**\n * Client info from the MCP initialize request.\n * Contains the name and version of the calling client.\n */\nexport interface ClientInfo {\n /** Client application name (e.g., \"claude-desktop\", \"chatgpt\", \"cursor\") */\n name: string;\n /** Client version string */\n version: string;\n}\n\n/**\n * MCP Apps extension key in capabilities.experimental\n */\nexport const MCP_APPS_EXTENSION_KEY = 'io.modelcontextprotocol/ui' as const;\n\n/**\n * Check if client capabilities include MCP Apps extension.\n * @param capabilities - Client capabilities from initialize request\n * @returns true if the client supports MCP Apps\n */\nexport function hasMcpAppsExtension(capabilities?: ClientCapabilities): boolean {\n if (!capabilities?.experimental) {\n return false;\n }\n const uiExtension = capabilities.experimental[MCP_APPS_EXTENSION_KEY];\n return uiExtension !== undefined && uiExtension !== null;\n}\n\n/**\n * Detect platform from client capabilities.\n * Checks for known extension capabilities before falling back to client info.\n * @param capabilities - Client capabilities from initialize request\n * @returns Platform type if detected from capabilities, undefined otherwise\n */\nexport function detectPlatformFromCapabilities(capabilities?: ClientCapabilities): AIPlatformType | undefined {\n if (hasMcpAppsExtension(capabilities)) {\n return 'ext-apps';\n }\n return undefined;\n}\n\n/**\n * Match client name against custom mapping patterns.\n * @param clientName - The client name to match\n * @param mappings - Array of custom mapping entries\n * @returns The matched platform type, or undefined if no match\n */\nfunction matchCustomMappings(clientName: string, mappings?: PlatformMappingEntry[]): AIPlatformType | undefined {\n if (!mappings || mappings.length === 0) {\n return undefined;\n }\n\n const lowerClientName = clientName.toLowerCase();\n\n for (const mapping of mappings) {\n if (typeof mapping.pattern === 'string') {\n // Exact match (case-insensitive) - use RegExp for substring matching\n if (lowerClientName === mapping.pattern.toLowerCase()) {\n return mapping.platform;\n }\n } else {\n // RegExp match\n if (mapping.pattern.test(clientName)) {\n return mapping.platform;\n }\n }\n }\n\n return undefined;\n}\n\n/**\n * Default keyword-based platform detection.\n * Works with client names, user-agent strings, or any identifier.\n * @param identifier - The identifier to detect (clientInfo.name, user-agent, etc.)\n * @returns The detected platform type\n */\nfunction defaultPlatformDetection(identifier: string): AIPlatformType {\n const lowerIdentifier = identifier.toLowerCase();\n\n // OpenAI/ChatGPT clients (includes user-agent like 'openai-mcp/1.0.0')\n if (lowerIdentifier.includes('chatgpt') || lowerIdentifier.includes('openai') || lowerIdentifier.includes('gpt')) {\n return 'openai';\n }\n\n // Claude clients\n if (lowerIdentifier.includes('claude') || lowerIdentifier.includes('anthropic')) {\n return 'claude';\n }\n\n // Google Gemini clients (use specific patterns to prevent false positives like \"google-drive-connector\")\n if (\n lowerIdentifier.includes('gemini') ||\n lowerIdentifier.includes('bard') ||\n lowerIdentifier.includes('google-ai') ||\n lowerIdentifier.includes('google ai')\n ) {\n return 'gemini';\n }\n\n // Cursor IDE\n if (lowerIdentifier.includes('cursor')) {\n return 'cursor';\n }\n\n // Continue.dev\n if (lowerIdentifier.includes('continue')) {\n return 'continue';\n }\n\n // Sourcegraph Cody\n if (lowerIdentifier.includes('cody') || lowerIdentifier.includes('sourcegraph')) {\n return 'cody';\n }\n\n // Generic MCP client (fallback for known MCP implementations)\n if (lowerIdentifier.includes('mcp')) {\n return 'generic-mcp';\n }\n\n return 'unknown';\n}\n\n/**\n * Detect platform from user-agent header.\n * Called during session creation before MCP initialize.\n *\n * @param userAgent - The User-Agent header value\n * @param config - Optional platform detection configuration\n * @returns The detected platform type\n */\nexport function detectPlatformFromUserAgent(userAgent?: string, config?: PlatformDetectionConfig): AIPlatformType {\n if (!userAgent) {\n return 'unknown';\n }\n\n // Check custom mappings first\n const customMatch = matchCustomMappings(userAgent, config?.mappings);\n if (customMatch) {\n return customMatch;\n }\n\n // If customOnly, don't use default detection\n if (config?.customOnly) {\n return 'unknown';\n }\n\n // Use default detection on user-agent\n return defaultPlatformDetection(userAgent);\n}\n\n/**\n * Detect the AI platform type from client info.\n * Supports custom mappings that are checked before default detection.\n *\n * @param clientInfo - Client info from MCP initialize request\n * @param config - Optional platform detection configuration with custom mappings\n * @returns The detected platform type\n */\nexport function detectAIPlatform(clientInfo?: ClientInfo, config?: PlatformDetectionConfig): AIPlatformType {\n if (!clientInfo?.name) {\n return 'unknown';\n }\n\n // First, check custom mappings if provided\n const customMatch = matchCustomMappings(clientInfo.name, config?.mappings);\n if (customMatch) {\n return customMatch;\n }\n\n // If customOnly is true, don't fall back to default detection\n if (config?.customOnly) {\n return 'unknown';\n }\n\n // Fall back to default keyword-based detection\n return defaultPlatformDetection(clientInfo.name);\n}\n\n/**\n * MCP logging level priority (lower number = more verbose).\n * Uses LoggingLevel from MCP SDK for type safety.\n */\nexport const MCP_LOGGING_LEVEL_PRIORITY: Record<LoggingLevel, number> = {\n debug: 0,\n info: 1,\n notice: 2,\n warning: 3,\n error: 4,\n critical: 5,\n alert: 6,\n emergency: 7,\n};\n\n/**\n * MCP notification method types per the 2025-11-25 specification.\n */\nexport type McpNotificationMethod =\n | 'notifications/resources/list_changed'\n | 'notifications/tools/list_changed'\n | 'notifications/prompts/list_changed'\n | 'notifications/resources/updated'\n | 'notifications/message';\n\n/**\n * Information about a registered MCP server/transport connection.\n */\nexport interface RegisteredServer {\n /** Unique session identifier */\n sessionId: string;\n /** The MCP server instance */\n server: McpServer;\n /** Timestamp when the server was registered */\n registeredAt: number;\n /** Client capabilities from the initialize request */\n clientCapabilities?: ClientCapabilities;\n /** Client info (name/version) from the initialize request */\n clientInfo?: ClientInfo;\n /** Detected AI platform type based on client info */\n platformType?: AIPlatformType;\n /** Cached roots from the client (invalidated on roots/list_changed) */\n cachedRoots?: Root[];\n /** Timestamp when roots were last fetched */\n rootsFetchedAt?: number;\n}\n\n/**\n * NotificationService manages server→client notifications per MCP 2025-11-25 spec.\n *\n * It tracks all active MCP server instances and broadcasts notifications when\n * registries (resources, tools, prompts) change.\n *\n * It also manages resource subscriptions per session, allowing clients to\n * subscribe to specific resource URIs and receive notifications when they change.\n *\n * @example\n * ```typescript\n * // In LocalTransportAdapter after server.connect()\n * scope.notifications.registerServer(sessionId, this.server);\n *\n * // On session close\n * scope.notifications.unregisterServer(sessionId);\n *\n * // Resource subscriptions\n * scope.notifications.subscribeResource(sessionId, 'file://path/to/file');\n * scope.notifications.unsubscribeResource(sessionId, 'file://path/to/file');\n * ```\n */\nexport class NotificationService {\n private readonly logger: FrontMcpLogger;\n private readonly servers = new Map<string, RegisteredServer>();\n private readonly unsubscribers: Array<() => void> = [];\n /** Maps session ID to set of subscribed resource URIs */\n private readonly subscriptions = new Map<string, Set<string>>();\n /** Maps session ID to minimum log level for that session */\n private readonly logLevels = new Map<string, McpLoggingLevel>();\n /**\n * Set of terminated session IDs (for session invalidation on DELETE).\n * Uses LRU-style eviction to prevent unbounded memory growth.\n */\n private readonly terminatedSessions = new Set<string>();\n /** Maximum number of terminated sessions to track before eviction */\n private static readonly MAX_TERMINATED_SESSIONS = 10000;\n\n constructor(private readonly scope: Scope) {\n this.logger = scope.logger.child('NotificationService');\n }\n\n /**\n * Initialize the notification service and subscribe to registry changes.\n * Called after all registries are ready.\n */\n async initialize(): Promise<void> {\n this.logger.verbose('Initializing notification service');\n\n // Subscribe to resource changes\n const unsubResources = this.scope.resources.subscribe({ immediate: false }, (event) => {\n if (event.changeScope === 'global') {\n this.broadcastNotification('notifications/resources/list_changed');\n }\n });\n this.unsubscribers.push(unsubResources);\n\n // Subscribe to tool changes\n const unsubTools = this.scope.tools.subscribe({ immediate: false }, (event) => {\n if (event.changeScope === 'global') {\n this.broadcastNotification('notifications/tools/list_changed');\n }\n });\n this.unsubscribers.push(unsubTools);\n\n // Subscribe to prompt changes\n const unsubPrompts = this.scope.prompts.subscribe({ immediate: false }, (event) => {\n if (event.changeScope === 'global') {\n this.broadcastNotification('notifications/prompts/list_changed');\n }\n });\n this.unsubscribers.push(unsubPrompts);\n\n this.logger.info('Notification service initialized with registry subscriptions');\n }\n\n /**\n * Register an MCP server instance for receiving notifications.\n * Call this when a transport connection is established.\n *\n * @param sessionId - Unique session identifier\n * @param server - The MCP server instance\n */\n registerServer(sessionId: string, server: McpServer): void {\n if (this.servers.has(sessionId)) {\n this.logger.warn(`Server already registered for session: ${sessionId.slice(0, 20)}...`);\n return;\n }\n\n this.servers.set(sessionId, {\n sessionId,\n server,\n registeredAt: Date.now(),\n });\n\n this.logger.verbose(`Registered server for session: ${sessionId.slice(0, 20)}... (total: ${this.servers.size})`);\n }\n\n /**\n * Unregister an MCP server instance.\n * Call this when a transport connection is closed.\n * Also cleans up any resource subscriptions for this session.\n *\n * @param sessionId - The session identifier to unregister\n * @returns true if the server was registered and is now unregistered, false if not found\n */\n unregisterServer(sessionId: string): boolean {\n const deleted = this.servers.delete(sessionId);\n\n // Clean up resource subscriptions for this session\n const subCount = this.subscriptions.get(sessionId)?.size ?? 0;\n this.subscriptions.delete(sessionId);\n\n // Clean up log level setting for this session\n const hadLogLevel = this.logLevels.delete(sessionId);\n\n if (deleted) {\n this.logger.verbose(\n `Unregistered server for session: ${sessionId.slice(0, 20)}... (remaining: ${\n this.servers.size\n }, cleaned ${subCount} subscription(s)${hadLogLevel ? ', removed log level' : ''})`,\n );\n }\n return deleted;\n }\n\n /**\n * Terminate a session. This adds the session ID to the terminated set,\n * preventing further use of this session ID. This is called during DELETE\n * session handling per MCP 2025-11-25 spec.\n *\n * Note: For stateless sessions (encrypted JWTs), the session ID cannot be\n * truly \"invalidated\" cryptographically, but we track it in memory to reject\n * future requests with this session ID on this server instance.\n *\n * @param sessionId - The session ID to terminate\n * @returns true if the session was registered and is now terminated\n */\n terminateSession(sessionId: string): boolean {\n // First unregister the server (cleans up subscriptions, log levels, etc.)\n const wasRegistered = this.unregisterServer(sessionId);\n\n // Add to terminated sessions set (even if not registered, to handle edge cases)\n // Implement LRU-style eviction to prevent unbounded memory growth\n if (this.terminatedSessions.size >= NotificationService.MAX_TERMINATED_SESSIONS) {\n // Remove the oldest entry (first item in Set maintains insertion order)\n const oldest = this.terminatedSessions.values().next().value;\n if (oldest) {\n this.terminatedSessions.delete(oldest);\n this.logger.verbose(`Evicted oldest terminated session to make room: ${oldest.slice(0, 20)}...`);\n }\n }\n this.terminatedSessions.add(sessionId);\n this.logger.verbose(\n `Terminated session: ${sessionId.slice(0, 20)}... (total terminated: ${this.terminatedSessions.size})`,\n );\n\n return wasRegistered;\n }\n\n /**\n * Check if a session has been terminated.\n * Used during session verification to reject requests with terminated session IDs.\n *\n * @param sessionId - The session ID to check\n * @returns true if the session has been terminated\n */\n isSessionTerminated(sessionId: string): boolean {\n return this.terminatedSessions.has(sessionId);\n }\n\n /**\n * Broadcast a notification to all registered servers.\n *\n * @param method - The MCP notification method\n * @param params - Optional notification parameters\n */\n broadcastNotification(method: McpNotificationMethod, params?: Record<string, unknown>): void {\n if (this.servers.size === 0) {\n this.logger.verbose(`No servers registered for notification: ${method}`);\n return;\n }\n\n this.logger.verbose(`Broadcasting ${method} to ${this.servers.size} server(s)`);\n\n for (const [sessionId, { server }] of this.servers) {\n this.sendNotificationToServer(server, sessionId, method, params);\n }\n }\n\n /**\n * Send a notification to a specific session.\n *\n * @param sessionId - The target session\n * @param method - The MCP notification method\n * @param params - Optional notification parameters\n */\n sendNotificationToSession(sessionId: string, method: McpNotificationMethod, params?: Record<string, unknown>): void {\n const registered = this.servers.get(sessionId);\n if (!registered) {\n this.logger.warn(`Cannot send notification to unregistered session: ${sessionId.slice(0, 20)}...`);\n return;\n }\n\n this.sendNotificationToServer(registered.server, sessionId, method, params);\n }\n\n /**\n * Subscribe a session to receive notifications when a specific resource changes.\n *\n * @param sessionId - The session to subscribe\n * @param uri - The resource URI to subscribe to\n * @returns true if this is a new subscription, false if already subscribed\n */\n subscribeResource(sessionId: string, uri: string): boolean {\n if (!this.servers.has(sessionId)) {\n this.logger.warn(`Cannot subscribe unregistered session ${sessionId.slice(0, 20)}... to resource ${uri}`);\n return false;\n }\n\n let sessionSubs = this.subscriptions.get(sessionId);\n if (!sessionSubs) {\n sessionSubs = new Set();\n this.subscriptions.set(sessionId, sessionSubs);\n }\n\n const isNew = !sessionSubs.has(uri);\n sessionSubs.add(uri);\n\n if (isNew) {\n this.logger.verbose(`Session ${sessionId.slice(0, 20)}... subscribed to resource ${uri}`);\n }\n\n return isNew;\n }\n\n /**\n * Unsubscribe a session from a specific resource.\n *\n * @param sessionId - The session to unsubscribe\n * @param uri - The resource URI to unsubscribe from\n * @returns true if the subscription was removed, false if not subscribed\n */\n unsubscribeResource(sessionId: string, uri: string): boolean {\n const sessionSubs = this.subscriptions.get(sessionId);\n if (!sessionSubs) {\n return false;\n }\n\n const wasSubscribed = sessionSubs.delete(uri);\n\n // Clean up empty subscription sets\n if (sessionSubs.size === 0) {\n this.subscriptions.delete(sessionId);\n }\n\n if (wasSubscribed) {\n this.logger.verbose(`Session ${sessionId.slice(0, 20)}... unsubscribed from resource ${uri}`);\n }\n\n return wasSubscribed;\n }\n\n /**\n * Check if a session is subscribed to a specific resource.\n *\n * @param sessionId - The session to check\n * @param uri - The resource URI\n * @returns true if subscribed\n */\n isSubscribed(sessionId: string, uri: string): boolean {\n return this.subscriptions.get(sessionId)?.has(uri) ?? false;\n }\n\n /**\n * Get all sessions subscribed to a specific resource.\n *\n * @param uri - The resource URI\n * @returns Array of session IDs subscribed to this resource\n */\n getSubscribersForResource(uri: string): string[] {\n const subscribers: string[] = [];\n for (const [sessionId, uris] of this.subscriptions) {\n if (uris.has(uri)) {\n subscribers.push(sessionId);\n }\n }\n return subscribers;\n }\n\n /**\n * Send a resource update notification to subscribed sessions only.\n * Per MCP 2025-11-25 spec, only sessions that have subscribed to this\n * resource via `resources/subscribe` will receive the notification.\n *\n * @param uri - The resource URI that was updated\n */\n notifyResourceUpdated(uri: string): void {\n const subscribers = this.getSubscribersForResource(uri);\n\n if (subscribers.length === 0) {\n this.logger.verbose(`No subscribers for resource ${uri}, skipping notification`);\n return;\n }\n\n this.logger.verbose(`Notifying ${subscribers.length} subscriber(s) of resource update: ${uri}`);\n\n for (const sessionId of subscribers) {\n this.sendNotificationToSession(sessionId, 'notifications/resources/updated', { uri });\n }\n }\n\n /**\n * Get the number of registered servers.\n */\n get serverCount(): number {\n return this.servers.size;\n }\n\n /**\n * Set the minimum log level for a session.\n * Only log messages at or above this level will be sent to the session.\n * Per MCP spec, the default level when not set is determined by the server.\n *\n * @param sessionId - The session to configure\n * @param level - The minimum log level\n * @returns true if the session was found and level was set\n */\n setLogLevel(sessionId: string, level: McpLoggingLevel): boolean {\n if (!this.servers.has(sessionId)) {\n this.logger.warn(`Cannot set log level for unregistered session: ${sessionId.slice(0, 20)}...`);\n return false;\n }\n\n this.logLevels.set(sessionId, level);\n this.logger.verbose(`Set log level to '${level}' for session ${sessionId.slice(0, 20)}...`);\n return true;\n }\n\n /**\n * Get the current log level for a session.\n *\n * @param sessionId - The session to query\n * @returns The log level, or undefined if not set\n */\n getLogLevel(sessionId: string): McpLoggingLevel | undefined {\n return this.logLevels.get(sessionId);\n }\n\n /**\n * Send a log message to all sessions that have enabled the given level.\n * Per MCP 2025-11-25 spec, this sends a 'notifications/message' notification\n * to sessions whose configured minimum level allows this message through.\n *\n * @param level - The log level of this message\n * @param loggerName - Optional logger name/component identifier\n * @param data - The log message data (string or structured data)\n */\n sendLogMessage(level: McpLoggingLevel, loggerName: string | undefined, data: unknown): void {\n const messagePriority = MCP_LOGGING_LEVEL_PRIORITY[level];\n\n for (const [sessionId, { server }] of this.servers) {\n const sessionLevel = this.logLevels.get(sessionId);\n\n // If session hasn't set a level, skip (server decides default behavior)\n // Here we default to NOT sending unless explicitly subscribed\n if (!sessionLevel) {\n continue;\n }\n\n const sessionPriority = MCP_LOGGING_LEVEL_PRIORITY[sessionLevel];\n\n // Only send if message level >= session's minimum level\n if (messagePriority >= sessionPriority) {\n const params: Record<string, unknown> = {\n level,\n data,\n };\n if (loggerName) {\n params['logger'] = loggerName;\n }\n\n this.sendNotificationToServer(server, sessionId, 'notifications/message', params);\n }\n }\n }\n\n /**\n * Send a log message to a specific session, respecting its log level.\n *\n * @param sessionId - The target session\n * @param level - The log level of this message\n * @param loggerName - Optional logger name/component identifier\n * @param data - The log message data\n * @returns true if the message was sent (session exists and level allows)\n */\n sendLogMessageToSession(\n sessionId: string,\n level: McpLoggingLevel,\n loggerName: string | undefined,\n data: unknown,\n ): boolean {\n const registered = this.servers.get(sessionId);\n if (!registered) {\n return false;\n }\n\n const sessionLevel = this.logLevels.get(sessionId);\n if (!sessionLevel) {\n // Session hasn't enabled logging\n return false;\n }\n\n const messagePriority = MCP_LOGGING_LEVEL_PRIORITY[level];\n const sessionPriority = MCP_LOGGING_LEVEL_PRIORITY[sessionLevel];\n\n if (messagePriority < sessionPriority) {\n // Message level is too verbose for this session\n return false;\n }\n\n const params: Record<string, unknown> = {\n level,\n data,\n };\n if (loggerName) {\n params['logger'] = loggerName;\n }\n\n this.sendNotificationToServer(registered.server, sessionId, 'notifications/message', params);\n return true;\n }\n\n // =====================================================\n // Client Capabilities & Roots API (MCP 2025-11-25)\n // =====================================================\n\n /**\n * Set client capabilities for a session.\n * Called during initialization to store what the client supports.\n *\n * @param sessionId - The session to configure\n * @param capabilities - The client's capabilities from the initialize request\n * @returns true if the session was found and capabilities were set\n */\n setClientCapabilities(sessionId: string, capabilities: ClientCapabilities): boolean {\n const registered = this.servers.get(sessionId);\n if (!registered) {\n this.logger.warn(`Cannot set client capabilities for unregistered session: ${sessionId.slice(0, 20)}...`);\n return false;\n }\n\n registered.clientCapabilities = capabilities;\n this.logger.verbose(\n `Set client capabilities for session ${sessionId.slice(0, 20)}...: roots.listChanged=${\n capabilities.roots?.listChanged ?? false\n }`,\n );\n return true;\n }\n\n /**\n * Get client capabilities for a session.\n *\n * @param sessionId - The session to query\n * @returns The client's capabilities, or undefined if not set\n */\n getClientCapabilities(sessionId: string): ClientCapabilities | undefined {\n return this.servers.get(sessionId)?.clientCapabilities;\n }\n\n /**\n * Set client info for a session and auto-detect the AI platform type.\n * Called during initialization to store who the client is.\n * Uses the scope's platform detection configuration for custom mappings.\n *\n * @param sessionId - The session to configure\n * @param clientInfo - The client's info (name/version) from the initialize request\n * @returns The detected platform type, or undefined if the session was not found\n */\n setClientInfo(sessionId: string, clientInfo: ClientInfo): AIPlatformType | undefined {\n const registered = this.servers.get(sessionId);\n if (!registered) {\n this.logger.warn(`Cannot set client info for unregistered session: ${sessionId.slice(0, 20)}...`);\n return undefined;\n }\n\n registered.clientInfo = clientInfo;\n // Use platform detection config from scope if available\n const platformDetectionConfig = this.scope.metadata?.session?.platformDetection;\n registered.platformType = detectAIPlatform(clientInfo, platformDetectionConfig);\n this.logger.verbose(\n `Set client info for session ${sessionId.slice(0, 20)}...: name=${clientInfo.name}, version=${\n clientInfo.version\n }, platform=${registered.platformType}`,\n );\n return registered.platformType;\n }\n\n /**\n * Get client info for a session.\n *\n * @param sessionId - The session to query\n * @returns The client's info, or undefined if not set\n */\n getClientInfo(sessionId: string): ClientInfo | undefined {\n return this.servers.get(sessionId)?.clientInfo;\n }\n\n /**\n * Get the detected AI platform type for a session.\n * This is auto-detected from client info during initialization.\n *\n * @param sessionId - The session to query\n * @returns The detected platform type, or 'unknown' if not detected\n */\n getPlatformType(sessionId: string): AIPlatformType {\n const session = this.servers.get(sessionId);\n return session?.platformType ?? 'unknown';\n }\n\n /**\n * Check if a session's client supports roots listing.\n *\n * @param sessionId - The session to check\n * @returns true if the client supports roots\n */\n supportsRoots(sessionId: string): boolean {\n const capabilities = this.getClientCapabilities(sessionId);\n return capabilities?.roots !== undefined;\n }\n\n /**\n * List roots from the client for a session.\n * This sends a `roots/list` request to the client and returns the roots.\n *\n * If the client doesn't support roots, returns an empty array.\n * Results are cached and invalidated when `notifications/roots/list_changed` is received.\n *\n * @param sessionId - The session to request roots from\n * @param options - Options for the request\n * @param options.forceRefresh - If true, bypass the cache and fetch fresh roots\n * @param options.timeout - Timeout in milliseconds (default: 30000)\n * @returns Array of roots from the client\n */\n async listRoots(sessionId: string, options?: { forceRefresh?: boolean; timeout?: number }): Promise<Root[]> {\n const registered = this.servers.get(sessionId);\n if (!registered) {\n this.logger.warn(`Cannot list roots for unregistered session: ${sessionId.slice(0, 20)}...`);\n return [];\n }\n\n // Check if client supports roots\n if (!this.supportsRoots(sessionId)) {\n this.logger.verbose(`Client for session ${sessionId.slice(0, 20)}... does not support roots`);\n return [];\n }\n\n // Return cached roots if available and not forcing refresh\n if (!options?.forceRefresh && registered.cachedRoots !== undefined) {\n this.logger.verbose(\n `Returning cached roots for session ${sessionId.slice(0, 20)}... (${registered.cachedRoots.length} roots)`,\n );\n return registered.cachedRoots;\n }\n\n try {\n this.logger.verbose(`Requesting roots from client for session ${sessionId.slice(0, 20)}...`);\n\n // Send roots/list request to client\n const result = await registered.server.request({ method: 'roots/list' }, ListRootsResultSchema, {\n timeout: options?.timeout ?? 30000,\n });\n\n // Cache the result\n registered.cachedRoots = result.roots as Root[];\n registered.rootsFetchedAt = Date.now();\n\n this.logger.verbose(\n `Received ${registered.cachedRoots.length} root(s) from client for session ${sessionId.slice(0, 20)}...`,\n );\n return registered.cachedRoots;\n } catch (error) {\n this.logger.warn(\n `Failed to list roots for session ${sessionId.slice(0, 20)}...: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n );\n // Return cached roots if available, otherwise empty array\n return registered.cachedRoots ?? [];\n }\n }\n\n /**\n * Invalidate cached roots for a session.\n * Call this when receiving `notifications/roots/list_changed` from the client.\n *\n * @param sessionId - The session whose roots cache should be invalidated\n * @returns true if the session was found and cache was invalidated\n */\n invalidateRootsCache(sessionId: string): boolean {\n const registered = this.servers.get(sessionId);\n if (!registered) {\n return false;\n }\n\n const hadCache = registered.cachedRoots !== undefined;\n registered.cachedRoots = undefined;\n registered.rootsFetchedAt = undefined;\n\n if (hadCache) {\n this.logger.verbose(`Invalidated roots cache for session ${sessionId.slice(0, 20)}...`);\n }\n return hadCache;\n }\n\n /**\n * Get the cached roots for a session without fetching from the client.\n *\n * @param sessionId - The session to query\n * @returns Cached roots, or undefined if not cached\n */\n getCachedRoots(sessionId: string): Root[] | undefined {\n return this.servers.get(sessionId)?.cachedRoots;\n }\n\n /**\n * Clean up subscriptions and resources.\n */\n async destroy(): Promise<void> {\n this.logger.verbose('Destroying notification service');\n\n // Unsubscribe from all registry listeners\n for (const unsub of this.unsubscribers) {\n unsub();\n }\n this.unsubscribers.length = 0;\n\n // Clear server registrations, resource subscriptions, log levels, and terminated sessions\n this.servers.clear();\n this.subscriptions.clear();\n this.logLevels.clear();\n this.terminatedSessions.clear();\n\n this.logger.info('Notification service destroyed');\n }\n\n private sendNotificationToServer(\n server: McpServer,\n sessionId: string,\n method: McpNotificationMethod,\n params?: Record<string, unknown>,\n ): void {\n try {\n // MCP SDK's server.notification() sends a JSON-RPC notification\n server.notification({ method, params: params ?? {} });\n this.logger.verbose(`Sent ${method} to session ${sessionId.slice(0, 20)}...`);\n } catch (error) {\n // Connection may have closed; log and continue\n this.logger.warn(\n `Failed to send notification ${method} to session ${sessionId.slice(0, 20)}...: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n );\n // Optionally unregister dead sessions\n this.unregisterServer(sessionId);\n }\n }\n}\n"]}
|
|
@@ -68,8 +68,9 @@ class PluginRegistry extends regsitry_1.RegistryAbstract {
|
|
|
68
68
|
const deps = this.graph.get(token);
|
|
69
69
|
const providers = new provider_registry_1.default(rec.metadata.providers ?? [], this.providers);
|
|
70
70
|
await providers.ready;
|
|
71
|
-
//
|
|
72
|
-
|
|
71
|
+
// Create a plugin-specific owner (NOT the parent's owner)
|
|
72
|
+
// This ensures plugin tools have kind='plugin' for proper filtering in adoption
|
|
73
|
+
const pluginOwner = {
|
|
73
74
|
kind: 'plugin',
|
|
74
75
|
id: rec.metadata.name,
|
|
75
76
|
ref: token,
|
|
@@ -78,14 +79,16 @@ class PluginRegistry extends regsitry_1.RegistryAbstract {
|
|
|
78
79
|
await plugins.ready;
|
|
79
80
|
const adapters = new adapter_regsitry_1.default(providers, rec.metadata.adapters ?? []);
|
|
80
81
|
await adapters.ready;
|
|
81
|
-
const tools = new tool_registry_1.default(providers, rec.metadata.tools ?? [],
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
ref: token,
|
|
85
|
-
});
|
|
86
|
-
const resources = new resource_registry_1.default(providers, rec.metadata.resources ?? []);
|
|
87
|
-
const prompts = new prompt_registry_1.default(providers, rec.metadata.prompts ?? []);
|
|
82
|
+
const tools = new tool_registry_1.default(providers, rec.metadata.tools ?? [], pluginOwner);
|
|
83
|
+
const resources = new resource_registry_1.default(providers, rec.metadata.resources ?? [], pluginOwner);
|
|
84
|
+
const prompts = new prompt_registry_1.default(providers, rec.metadata.prompts ?? [], pluginOwner);
|
|
88
85
|
await Promise.all([tools.ready, resources.ready, prompts.ready]);
|
|
86
|
+
// Register plugin registries with parent provider registry (app's providers)
|
|
87
|
+
// This makes plugin tools discoverable during app's ToolRegistry adoption (Path 2)
|
|
88
|
+
// Note: We don't add to scope-level providers to maintain app isolation
|
|
89
|
+
this.providers.addRegistry('ToolRegistry', tools);
|
|
90
|
+
this.providers.addRegistry('ResourceRegistry', resources);
|
|
91
|
+
this.providers.addRegistry('PromptRegistry', prompts);
|
|
89
92
|
this.pProviders.set(token, providers);
|
|
90
93
|
this.pPlugins.set(token, plugins);
|
|
91
94
|
this.pAdapters.set(token, adapters);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.registry.js","sourceRoot":"","sources":["../../../src/plugin/plugin.registry.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,4BAA0B;AAC1B,sCAA8G;AAC9G,iDAAsE;AACtE,8FAA6D;AAC7D,sDAAiD;AACjD,2FAA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AAI,gBAAgB,EAAE,CAAC;gBACrB,MAAM,SAAS,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;YACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF;AAxJD,iCAwJC","sourcesContent":["// plugin-registry.ts\nimport 'reflect-metadata';\nimport { PluginEntry, PluginKind, PluginRecord, PluginRegistryInterface, PluginType, Token } from '../common';\nimport { normalizePlugin, pluginDiscoveryDeps } from './plugin.utils';\nimport ProviderRegistry from '../provider/provider.registry';\nimport { tokenName } from '../utils/token.utils';\nimport AdapterRegistry from '../adapter/adapter.regsitry';\nimport ToolRegistry from '../tool/tool.registry';\nimport ResourceRegistry from '../resource/resource.registry';\nimport PromptRegistry from '../prompt/prompt.registry';\nimport { Ctor } from '../types/token.types';\nimport { normalizeProvider } from '../provider/provider.utils';\nimport { RegistryAbstract, RegistryBuildMapResult } from '../regsitry';\nimport { Scope } from '../scope';\nimport { normalizeHooksFromCls } from '../hooks/hooks.utils';\n\nexport default class PluginRegistry\n extends RegistryAbstract<PluginEntry, PluginRecord, PluginType[]>\n implements PluginRegistryInterface\n{\n /** providers by token */\n private readonly pProviders: Map<Token, ProviderRegistry> = new Map();\n /** providers by token */\n private readonly pPlugins: Map<Token, PluginRegistry> = new Map();\n /** adapters by token */\n private readonly pAdapters: Map<Token, AdapterRegistry> = new Map();\n /** tools by token */\n private readonly pTools: Map<Token, ToolRegistry> = new Map();\n /** resources by token */\n private readonly pResources: Map<Token, ResourceRegistry> = new Map();\n /** prompts by token */\n private readonly pPrompts: Map<Token, PromptRegistry> = new Map();\n\n private readonly scope: Scope;\n private readonly owner?: { kind: 'app' | 'plugin'; id: string; ref: Token };\n\n constructor(\n providers: ProviderRegistry,\n list: PluginType[],\n owner?: { kind: 'app' | 'plugin'; id: string; ref: Token },\n ) {\n super('PluginRegistry', providers, list);\n this.scope = providers.getActiveScope();\n this.owner = owner;\n }\n\n getPlugins(): PluginEntry[] {\n return [...this.instances.values()];\n }\n\n protected override buildMap(list: PluginType[]): RegistryBuildMapResult<PluginRecord> {\n const tokens = new Set<Token>();\n const defs = new Map<Token, PluginRecord>();\n const graph = new Map<Token, Set<Token>>();\n\n for (const raw of list) {\n const rec = normalizePlugin(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 = pluginDiscoveryDeps(rec);\n\n for (const d of deps) {\n if (!this.providers.get(d)) {\n throw new Error(`Plugin ${tokenName(token)} depends on ${tokenName(d)}, which is not registered.`);\n }\n this.graph.get(token)!.add(d);\n }\n }\n }\n\n protected async initialize() {\n for (const token of this.tokens) {\n const rec = this.defs.get(token)!;\n const deps = this.graph.get(token)!;\n\n const providers = new ProviderRegistry(rec.metadata.providers ?? [], this.providers);\n await providers.ready;\n\n // Pass the owner context to nested plugins (plugins can be owned by apps or other plugins)\n const pluginOwner = this.owner || {\n kind: 'plugin' as const,\n id: rec.metadata.name,\n ref: token,\n };\n\n const plugins = new PluginRegistry(providers, rec.metadata.plugins ?? [], pluginOwner);\n await plugins.ready;\n\n const adapters = new AdapterRegistry(providers, rec.metadata.adapters ?? []);\n await adapters.ready;\n\n const tools = new ToolRegistry(providers, rec.metadata.tools ?? [], {\n kind: 'plugin',\n id: rec.metadata.name,\n ref: token,\n });\n const resources = new ResourceRegistry(providers, rec.metadata.resources ?? []);\n const prompts = new PromptRegistry(providers, rec.metadata.prompts ?? []);\n\n await Promise.all([tools.ready, resources.ready, prompts.ready]);\n\n this.pProviders.set(token, providers);\n this.pPlugins.set(token, plugins);\n this.pAdapters.set(token, adapters);\n this.pTools.set(token, tools);\n this.pResources.set(token, resources);\n this.pPrompts.set(token, prompts);\n\n /**\n * Register exported providers to the parent providers registry.\n */\n const exported = (rec.metadata.exports ?? []).map((rawToken) => {\n const token = normalizeProvider(rawToken);\n return providers.getProviderInfo(token.provide);\n });\n this.providers.mergeFromRegistry(providers, exported);\n\n const depsTokens = [...deps];\n const depsInstances = await Promise.all(depsTokens.map((t) => this.providers.resolveBootstrapDep(t)));\n\n let pluginInstance: PluginEntry;\n if (rec.kind === PluginKind.CLASS) {\n const klass = rec.useClass as any;\n pluginInstance = new klass(...depsInstances);\n } else if (rec.kind === PluginKind.CLASS_TOKEN) {\n const klass = rec.provide as any;\n pluginInstance = new (klass as Ctor<any>)(...depsInstances);\n } else if (rec.kind === PluginKind.FACTORY) {\n const deps = [...rec.inject()];\n const args: any[] = [];\n for (const d of deps) args.push(await this.providers.resolveBootstrapDep(d));\n pluginInstance = rec.useFactory(...args);\n } else if (rec.kind === PluginKind.VALUE) {\n pluginInstance = (rec as any).useValue;\n } else {\n throw Error('Invalid plugin kind');\n }\n\n const hooks = normalizeHooksFromCls(pluginInstance);\n if (hooks.length > 0) {\n // Add owner information to each hook before registering\n const hooksWithOwner = hooks.map((hook) => ({\n ...hook,\n metadata: {\n ...hook.metadata,\n owner: this.owner,\n },\n }));\n await this.scope.hooks.registerHooks(false, ...hooksWithOwner);\n }\n pluginInstance.get = providers.get.bind(providers) as any;\n const dynamicProviders = rec.providers;\n if (dynamicProviders) {\n await providers.addDynamicProviders(dynamicProviders);\n }\n this.instances.set(token, pluginInstance);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plugin.registry.js","sourceRoot":"","sources":["../../../src/plugin/plugin.registry.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,4BAA0B;AAC1B,sCAA8G;AAC9G,iDAAsE;AACtE,8FAA6D;AAC7D,sDAAiD;AACjD,2FAA0D;AAC1D,kFAAiD;AACjD,8FAA6D;AAC7D,wFAAuD;AAEvD,+DAA+D;AAC/D,0CAAuE;AAEvE,sDAA6D;AAE7D,MAAqB,cACnB,SAAQ,2BAAyD;IAGjE,yBAAyB;IACR,UAAU,GAA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AC,SAAS,CAAC;YACvC,IAAI,gBAAgB,EAAE,CAAC;gBACrB,MAAM,SAAS,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;YACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF;AA5JD,iCA4JC","sourcesContent":["// plugin-registry.ts\nimport 'reflect-metadata';\nimport { PluginEntry, PluginKind, PluginRecord, PluginRegistryInterface, PluginType, Token } from '../common';\nimport { normalizePlugin, pluginDiscoveryDeps } from './plugin.utils';\nimport ProviderRegistry from '../provider/provider.registry';\nimport { tokenName } from '../utils/token.utils';\nimport AdapterRegistry from '../adapter/adapter.regsitry';\nimport ToolRegistry from '../tool/tool.registry';\nimport ResourceRegistry from '../resource/resource.registry';\nimport PromptRegistry from '../prompt/prompt.registry';\nimport { Ctor } from '../types/token.types';\nimport { normalizeProvider } from '../provider/provider.utils';\nimport { RegistryAbstract, RegistryBuildMapResult } from '../regsitry';\nimport { Scope } from '../scope';\nimport { normalizeHooksFromCls } from '../hooks/hooks.utils';\n\nexport default class PluginRegistry\n extends RegistryAbstract<PluginEntry, PluginRecord, PluginType[]>\n implements PluginRegistryInterface\n{\n /** providers by token */\n private readonly pProviders: Map<Token, ProviderRegistry> = new Map();\n /** providers by token */\n private readonly pPlugins: Map<Token, PluginRegistry> = new Map();\n /** adapters by token */\n private readonly pAdapters: Map<Token, AdapterRegistry> = new Map();\n /** tools by token */\n private readonly pTools: Map<Token, ToolRegistry> = new Map();\n /** resources by token */\n private readonly pResources: Map<Token, ResourceRegistry> = new Map();\n /** prompts by token */\n private readonly pPrompts: Map<Token, PromptRegistry> = new Map();\n\n private readonly scope: Scope;\n private readonly owner?: { kind: 'app' | 'plugin'; id: string; ref: Token };\n\n constructor(\n providers: ProviderRegistry,\n list: PluginType[],\n owner?: { kind: 'app' | 'plugin'; id: string; ref: Token },\n ) {\n super('PluginRegistry', providers, list);\n this.scope = providers.getActiveScope();\n this.owner = owner;\n }\n\n getPlugins(): PluginEntry[] {\n return [...this.instances.values()];\n }\n\n protected override buildMap(list: PluginType[]): RegistryBuildMapResult<PluginRecord> {\n const tokens = new Set<Token>();\n const defs = new Map<Token, PluginRecord>();\n const graph = new Map<Token, Set<Token>>();\n\n for (const raw of list) {\n const rec = normalizePlugin(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 = pluginDiscoveryDeps(rec);\n\n for (const d of deps) {\n if (!this.providers.get(d)) {\n throw new Error(`Plugin ${tokenName(token)} depends on ${tokenName(d)}, which is not registered.`);\n }\n this.graph.get(token)!.add(d);\n }\n }\n }\n\n protected async initialize() {\n for (const token of this.tokens) {\n const rec = this.defs.get(token)!;\n const deps = this.graph.get(token)!;\n\n const providers = new ProviderRegistry(rec.metadata.providers ?? [], this.providers);\n await providers.ready;\n\n // Create a plugin-specific owner (NOT the parent's owner)\n // This ensures plugin tools have kind='plugin' for proper filtering in adoption\n const pluginOwner = {\n kind: 'plugin' as const,\n id: rec.metadata.name,\n ref: token,\n };\n\n const plugins = new PluginRegistry(providers, rec.metadata.plugins ?? [], pluginOwner);\n await plugins.ready;\n\n const adapters = new AdapterRegistry(providers, rec.metadata.adapters ?? []);\n await adapters.ready;\n\n const tools = new ToolRegistry(providers, rec.metadata.tools ?? [], pluginOwner);\n const resources = new ResourceRegistry(providers, rec.metadata.resources ?? [], pluginOwner);\n const prompts = new PromptRegistry(providers, rec.metadata.prompts ?? [], pluginOwner);\n\n await Promise.all([tools.ready, resources.ready, prompts.ready]);\n\n // Register plugin registries with parent provider registry (app's providers)\n // This makes plugin tools discoverable during app's ToolRegistry adoption (Path 2)\n // Note: We don't add to scope-level providers to maintain app isolation\n this.providers.addRegistry('ToolRegistry', tools);\n this.providers.addRegistry('ResourceRegistry', resources);\n this.providers.addRegistry('PromptRegistry', prompts);\n\n this.pProviders.set(token, providers);\n this.pPlugins.set(token, plugins);\n this.pAdapters.set(token, adapters);\n this.pTools.set(token, tools);\n this.pResources.set(token, resources);\n this.pPrompts.set(token, prompts);\n\n /**\n * Register exported providers to the parent providers registry.\n */\n const exported = (rec.metadata.exports ?? []).map((rawToken) => {\n const token = normalizeProvider(rawToken);\n return providers.getProviderInfo(token.provide);\n });\n this.providers.mergeFromRegistry(providers, exported);\n\n const depsTokens = [...deps];\n const depsInstances = await Promise.all(depsTokens.map((t) => this.providers.resolveBootstrapDep(t)));\n\n let pluginInstance: PluginEntry;\n if (rec.kind === PluginKind.CLASS) {\n const klass = rec.useClass as any;\n pluginInstance = new klass(...depsInstances);\n } else if (rec.kind === PluginKind.CLASS_TOKEN) {\n const klass = rec.provide as any;\n pluginInstance = new (klass as Ctor<any>)(...depsInstances);\n } else if (rec.kind === PluginKind.FACTORY) {\n const deps = [...rec.inject()];\n const args: any[] = [];\n for (const d of deps) args.push(await this.providers.resolveBootstrapDep(d));\n pluginInstance = rec.useFactory(...args);\n } else if (rec.kind === PluginKind.VALUE) {\n pluginInstance = (rec as any).useValue;\n } else {\n throw Error('Invalid plugin kind');\n }\n\n const hooks = normalizeHooksFromCls(pluginInstance);\n if (hooks.length > 0) {\n // Add owner information to each hook before registering\n const hooksWithOwner = hooks.map((hook) => ({\n ...hook,\n metadata: {\n ...hook.metadata,\n owner: this.owner,\n },\n }));\n await this.scope.hooks.registerHooks(false, ...hooksWithOwner);\n }\n pluginInstance.get = providers.get.bind(providers) as any;\n const dynamicProviders = rec.providers;\n if (dynamicProviders) {\n await providers.addDynamicProviders(dynamicProviders);\n }\n this.instances.set(token, pluginInstance);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { FlowBase, FlowRunOptions, PromptContext, PromptEntry } from '../../common';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
4
|
+
declare const inputSchema: z.ZodObject<{
|
|
5
|
+
request: z.ZodObject<{
|
|
6
|
+
method: z.ZodLiteral<"prompts/get">;
|
|
7
|
+
params: z.ZodObject<{
|
|
8
|
+
_meta: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
10
|
+
}, z.core.$loose>>;
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
13
|
+
}, z.core.$loose>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
ctx: z.ZodAny;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
declare const outputSchema: z.ZodObject<{
|
|
18
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
19
|
+
description: z.ZodOptional<z.ZodString>;
|
|
20
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
21
|
+
role: z.ZodEnum<{
|
|
22
|
+
user: "user";
|
|
23
|
+
assistant: "assistant";
|
|
24
|
+
}>;
|
|
25
|
+
content: z.ZodUnion<readonly [z.ZodObject<{
|
|
26
|
+
type: z.ZodLiteral<"text">;
|
|
27
|
+
text: z.ZodString;
|
|
28
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
type: z.ZodLiteral<"image">;
|
|
31
|
+
data: z.ZodString;
|
|
32
|
+
mimeType: z.ZodString;
|
|
33
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
34
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
35
|
+
type: z.ZodLiteral<"audio">;
|
|
36
|
+
data: z.ZodString;
|
|
37
|
+
mimeType: z.ZodString;
|
|
38
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
39
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
40
|
+
uri: z.ZodString;
|
|
41
|
+
description: z.ZodOptional<z.ZodString>;
|
|
42
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
43
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
44
|
+
icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
45
|
+
src: z.ZodString;
|
|
46
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
47
|
+
sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
|
+
}, z.core.$strip>>>;
|
|
49
|
+
name: z.ZodString;
|
|
50
|
+
title: z.ZodOptional<z.ZodString>;
|
|
51
|
+
type: z.ZodLiteral<"resource_link">;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"resource">;
|
|
54
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
55
|
+
uri: z.ZodString;
|
|
56
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
57
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
58
|
+
text: z.ZodString;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
60
|
+
uri: z.ZodString;
|
|
61
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
62
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
63
|
+
blob: z.ZodString;
|
|
64
|
+
}, z.core.$strip>]>;
|
|
65
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
66
|
+
}, z.core.$strip>]>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
}, z.core.$loose>;
|
|
69
|
+
declare const stateSchema: z.ZodObject<{
|
|
70
|
+
input: z.ZodObject<{
|
|
71
|
+
name: z.ZodString;
|
|
72
|
+
arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
promptOwnerId: z.ZodOptional<z.ZodString>;
|
|
75
|
+
authInfo: z.ZodType<AuthInfo>;
|
|
76
|
+
prompt: z.ZodType<PromptEntry>;
|
|
77
|
+
parsedArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
78
|
+
promptContext: z.ZodType<PromptContext>;
|
|
79
|
+
rawOutput: z.ZodOptional<z.ZodAny>;
|
|
80
|
+
output: z.ZodObject<{
|
|
81
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
82
|
+
description: z.ZodOptional<z.ZodString>;
|
|
83
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
84
|
+
role: z.ZodEnum<{
|
|
85
|
+
user: "user";
|
|
86
|
+
assistant: "assistant";
|
|
87
|
+
}>;
|
|
88
|
+
content: z.ZodUnion<readonly [z.ZodObject<{
|
|
89
|
+
type: z.ZodLiteral<"text">;
|
|
90
|
+
text: z.ZodString;
|
|
91
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
92
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
93
|
+
type: z.ZodLiteral<"image">;
|
|
94
|
+
data: z.ZodString;
|
|
95
|
+
mimeType: z.ZodString;
|
|
96
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
97
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
98
|
+
type: z.ZodLiteral<"audio">;
|
|
99
|
+
data: z.ZodString;
|
|
100
|
+
mimeType: z.ZodString;
|
|
101
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
102
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
103
|
+
uri: z.ZodString;
|
|
104
|
+
description: z.ZodOptional<z.ZodString>;
|
|
105
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
106
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
107
|
+
icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
108
|
+
src: z.ZodString;
|
|
109
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
110
|
+
sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
111
|
+
}, z.core.$strip>>>;
|
|
112
|
+
name: z.ZodString;
|
|
113
|
+
title: z.ZodOptional<z.ZodString>;
|
|
114
|
+
type: z.ZodLiteral<"resource_link">;
|
|
115
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
116
|
+
type: z.ZodLiteral<"resource">;
|
|
117
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
118
|
+
uri: z.ZodString;
|
|
119
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
120
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
121
|
+
text: z.ZodString;
|
|
122
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
123
|
+
uri: z.ZodString;
|
|
124
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
125
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
126
|
+
blob: z.ZodString;
|
|
127
|
+
}, z.core.$strip>]>;
|
|
128
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
129
|
+
}, z.core.$strip>]>;
|
|
130
|
+
}, z.core.$strip>>;
|
|
131
|
+
}, z.core.$loose>;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
declare const plan: {
|
|
134
|
+
readonly pre: ["parseInput", "findPrompt", "createPromptContext"];
|
|
135
|
+
readonly execute: ["execute", "validateOutput"];
|
|
136
|
+
readonly finalize: ["finalize"];
|
|
137
|
+
};
|
|
138
|
+
declare global {
|
|
139
|
+
interface ExtendFlows {
|
|
140
|
+
'prompts:get-prompt': FlowRunOptions<GetPromptFlow, typeof plan, typeof inputSchema, typeof outputSchema, typeof stateSchema>;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
declare const name: "prompts:get-prompt";
|
|
144
|
+
export default class GetPromptFlow extends FlowBase<typeof name> {
|
|
145
|
+
logger: import("../../common").FrontMcpLogger;
|
|
146
|
+
parseInput(): Promise<void>;
|
|
147
|
+
findPrompt(): Promise<void>;
|
|
148
|
+
createPromptContext(): Promise<void>;
|
|
149
|
+
execute(): Promise<void>;
|
|
150
|
+
validateOutput(): Promise<void>;
|
|
151
|
+
finalize(): Promise<void>;
|
|
152
|
+
}
|
|
153
|
+
export {};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: libs/sdk/src/prompt/flows/get-prompt.flow.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
8
|
+
const errors_1 = require("../../errors");
|
|
9
|
+
const inputSchema = zod_1.z.object({
|
|
10
|
+
request: types_js_1.GetPromptRequestSchema,
|
|
11
|
+
// z.any() used because ctx is the MCP SDK's PromptGetExtra type which varies by SDK version
|
|
12
|
+
ctx: zod_1.z.any(),
|
|
13
|
+
});
|
|
14
|
+
const outputSchema = types_js_1.GetPromptResultSchema;
|
|
15
|
+
const stateSchema = zod_1.z.object({
|
|
16
|
+
input: zod_1.z.object({
|
|
17
|
+
name: zod_1.z.string().min(1),
|
|
18
|
+
arguments: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
|
|
19
|
+
}),
|
|
20
|
+
// Prompt owner ID for hook filtering during execution
|
|
21
|
+
promptOwnerId: zod_1.z.string().optional(),
|
|
22
|
+
// z.any() used because AuthInfo is a complex external type from @modelcontextprotocol/sdk
|
|
23
|
+
authInfo: zod_1.z.any().optional(),
|
|
24
|
+
// z.any() used because PromptEntry is a complex abstract class type
|
|
25
|
+
prompt: zod_1.z.any(),
|
|
26
|
+
// Cached parsed arguments to avoid parsing twice (once in createPromptContext, once in execute)
|
|
27
|
+
parsedArgs: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
|
|
28
|
+
// z.any() used because PromptContext is a complex abstract class type
|
|
29
|
+
promptContext: zod_1.z.any(),
|
|
30
|
+
// z.any() used because prompt output type varies by prompt implementation
|
|
31
|
+
rawOutput: zod_1.z.any().optional(),
|
|
32
|
+
output: outputSchema,
|
|
33
|
+
});
|
|
34
|
+
const plan = {
|
|
35
|
+
pre: ['parseInput', 'findPrompt', 'createPromptContext'],
|
|
36
|
+
execute: ['execute', 'validateOutput'],
|
|
37
|
+
finalize: ['finalize'],
|
|
38
|
+
};
|
|
39
|
+
const name = 'prompts:get-prompt';
|
|
40
|
+
const { Stage } = (0, common_1.FlowHooksOf)(name);
|
|
41
|
+
let GetPromptFlow = class GetPromptFlow extends common_1.FlowBase {
|
|
42
|
+
logger = this.scopeLogger.child('GetPromptFlow');
|
|
43
|
+
async parseInput() {
|
|
44
|
+
this.logger.verbose('parseInput:start');
|
|
45
|
+
let method;
|
|
46
|
+
let params;
|
|
47
|
+
let ctx;
|
|
48
|
+
try {
|
|
49
|
+
const inputData = inputSchema.parse(this.rawInput);
|
|
50
|
+
method = inputData.request.method;
|
|
51
|
+
params = inputData.request.params;
|
|
52
|
+
ctx = inputData.ctx;
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
throw new errors_1.InvalidInputError('Invalid Input', e instanceof zod_1.z.ZodError ? e.issues : undefined);
|
|
56
|
+
}
|
|
57
|
+
if (method !== 'prompts/get') {
|
|
58
|
+
this.logger.warn(`parseInput: invalid method "${method}"`);
|
|
59
|
+
throw new errors_1.InvalidMethodError(method, 'prompts/get');
|
|
60
|
+
}
|
|
61
|
+
this.state.set({
|
|
62
|
+
input: {
|
|
63
|
+
name: params.name,
|
|
64
|
+
arguments: params.arguments,
|
|
65
|
+
},
|
|
66
|
+
authInfo: ctx.authInfo,
|
|
67
|
+
});
|
|
68
|
+
this.logger.verbose('parseInput:done');
|
|
69
|
+
}
|
|
70
|
+
async findPrompt() {
|
|
71
|
+
this.logger.verbose('findPrompt:start');
|
|
72
|
+
const { name } = this.state.required.input;
|
|
73
|
+
this.logger.info(`findPrompt: looking for prompt with name "${name}"`);
|
|
74
|
+
// Try to find a prompt that matches this name
|
|
75
|
+
const prompt = this.scope.prompts.findByName(name);
|
|
76
|
+
if (!prompt) {
|
|
77
|
+
this.logger.warn(`findPrompt: prompt "${name}" not found`);
|
|
78
|
+
throw new errors_1.PromptNotFoundError(name);
|
|
79
|
+
}
|
|
80
|
+
// Store prompt owner ID in state for hook filtering during execution
|
|
81
|
+
this.state.set('promptOwnerId', prompt.owner?.id);
|
|
82
|
+
this.logger = this.logger.child(`GetPromptFlow(${name})`);
|
|
83
|
+
this.state.set('prompt', prompt);
|
|
84
|
+
this.logger.info(`findPrompt: prompt "${prompt.name}" found`);
|
|
85
|
+
this.logger.verbose('findPrompt:done');
|
|
86
|
+
}
|
|
87
|
+
async createPromptContext() {
|
|
88
|
+
this.logger.verbose('createPromptContext:start');
|
|
89
|
+
const { ctx } = this.input;
|
|
90
|
+
const { prompt, input } = this.state.required;
|
|
91
|
+
try {
|
|
92
|
+
// Parse and validate arguments, cache for reuse in execute stage
|
|
93
|
+
const parsedArgs = prompt.parseArguments(input.arguments);
|
|
94
|
+
this.state.set('parsedArgs', parsedArgs);
|
|
95
|
+
const context = prompt.create(parsedArgs, ctx);
|
|
96
|
+
const promptHooks = this.scope.hooks.getClsHooks(prompt.record.provide).map((hook) => {
|
|
97
|
+
hook.run = async () => {
|
|
98
|
+
return context[hook.metadata.method]();
|
|
99
|
+
};
|
|
100
|
+
return hook;
|
|
101
|
+
});
|
|
102
|
+
this.appendContextHooks(promptHooks);
|
|
103
|
+
context.mark('createPromptContext');
|
|
104
|
+
this.state.set('promptContext', context);
|
|
105
|
+
this.logger.verbose('createPromptContext:done');
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
this.logger.error('createPromptContext: failed to create context', error);
|
|
109
|
+
throw new errors_1.PromptExecutionError(input.name, error instanceof Error ? error : undefined);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async execute() {
|
|
113
|
+
this.logger.verbose('execute:start');
|
|
114
|
+
const promptContext = this.state.promptContext;
|
|
115
|
+
const { input, parsedArgs } = this.state.required;
|
|
116
|
+
if (!promptContext) {
|
|
117
|
+
this.logger.warn('execute: promptContext not found, skipping execution');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
promptContext.mark('execute');
|
|
121
|
+
try {
|
|
122
|
+
// Use cached parsed arguments from createPromptContext stage
|
|
123
|
+
promptContext.output = await promptContext.execute(parsedArgs);
|
|
124
|
+
this.logger.verbose('execute:done');
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
this.logger.error('execute: prompt execution failed', error);
|
|
128
|
+
throw new errors_1.PromptExecutionError(input.name, error instanceof Error ? error : undefined);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async validateOutput() {
|
|
132
|
+
this.logger.verbose('validateOutput:start');
|
|
133
|
+
const { promptContext } = this.state;
|
|
134
|
+
if (!promptContext) {
|
|
135
|
+
this.logger.warn('validateOutput: promptContext not found, skipping validation');
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
promptContext.mark('validateOutput');
|
|
139
|
+
// Store the RAW output for plugins to inspect
|
|
140
|
+
this.state.set('rawOutput', promptContext.output);
|
|
141
|
+
this.logger.verbose('validateOutput:done');
|
|
142
|
+
}
|
|
143
|
+
async finalize() {
|
|
144
|
+
this.logger.verbose('finalize:start');
|
|
145
|
+
const { prompt, rawOutput, input } = this.state;
|
|
146
|
+
if (!prompt) {
|
|
147
|
+
this.logger.error('finalize: prompt not found in state');
|
|
148
|
+
throw new errors_1.PromptExecutionError('unknown', new Error('Prompt not found in state'));
|
|
149
|
+
}
|
|
150
|
+
if (rawOutput === undefined) {
|
|
151
|
+
this.logger.error('finalize: prompt output not found in state');
|
|
152
|
+
throw new errors_1.PromptExecutionError(input?.name || 'unknown', new Error('Prompt output not found'));
|
|
153
|
+
}
|
|
154
|
+
// Parse and construct the MCP-compliant output using safeParseOutput
|
|
155
|
+
const parseResult = prompt.safeParseOutput(rawOutput);
|
|
156
|
+
if (!parseResult.success) {
|
|
157
|
+
this.logger.error('finalize: output validation failed', {
|
|
158
|
+
prompt: prompt.metadata.name,
|
|
159
|
+
errors: parseResult.error,
|
|
160
|
+
});
|
|
161
|
+
throw new errors_1.InvalidOutputError();
|
|
162
|
+
}
|
|
163
|
+
// Respond with the properly formatted MCP result
|
|
164
|
+
this.respond(parseResult.data);
|
|
165
|
+
this.logger.verbose('finalize:done');
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
tslib_1.__decorate([
|
|
169
|
+
Stage('parseInput'),
|
|
170
|
+
tslib_1.__metadata("design:type", Function),
|
|
171
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
172
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
173
|
+
], GetPromptFlow.prototype, "parseInput", null);
|
|
174
|
+
tslib_1.__decorate([
|
|
175
|
+
Stage('findPrompt'),
|
|
176
|
+
tslib_1.__metadata("design:type", Function),
|
|
177
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
178
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
179
|
+
], GetPromptFlow.prototype, "findPrompt", null);
|
|
180
|
+
tslib_1.__decorate([
|
|
181
|
+
Stage('createPromptContext'),
|
|
182
|
+
tslib_1.__metadata("design:type", Function),
|
|
183
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
184
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
185
|
+
], GetPromptFlow.prototype, "createPromptContext", null);
|
|
186
|
+
tslib_1.__decorate([
|
|
187
|
+
Stage('execute'),
|
|
188
|
+
tslib_1.__metadata("design:type", Function),
|
|
189
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
190
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
191
|
+
], GetPromptFlow.prototype, "execute", null);
|
|
192
|
+
tslib_1.__decorate([
|
|
193
|
+
Stage('validateOutput'),
|
|
194
|
+
tslib_1.__metadata("design:type", Function),
|
|
195
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
196
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
197
|
+
], GetPromptFlow.prototype, "validateOutput", null);
|
|
198
|
+
tslib_1.__decorate([
|
|
199
|
+
Stage('finalize'),
|
|
200
|
+
tslib_1.__metadata("design:type", Function),
|
|
201
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
202
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
203
|
+
], GetPromptFlow.prototype, "finalize", null);
|
|
204
|
+
GetPromptFlow = tslib_1.__decorate([
|
|
205
|
+
(0, common_1.Flow)({
|
|
206
|
+
name,
|
|
207
|
+
plan,
|
|
208
|
+
inputSchema,
|
|
209
|
+
outputSchema,
|
|
210
|
+
access: 'authorized',
|
|
211
|
+
})
|
|
212
|
+
], GetPromptFlow);
|
|
213
|
+
exports.default = GetPromptFlow;
|
|
214
|
+
//# sourceMappingURL=get-prompt.flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-prompt.flow.js","sourceRoot":"","sources":["../../../../src/prompt/flows/get-prompt.flow.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAErD,yCAAiH;AACjH,6BAAwB;AACxB,iEAAmG;AAEnG,yCAMsB;AAEtB,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,OAAO,EAAE,iCAAsB;IAC/B,4FAA4F;IAC5F,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE;CACb,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,gCA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K,CAAC,UAAU,CAAC;;;;6CA8BjB;AA3JkB,aAAa;IAPjC,IAAA,aAAI,EAAC;QACJ,IAAI;QACJ,IAAI;QACJ,WAAW;QACX,YAAY;QACZ,MAAM,EAAE,YAAY;KACrB,CAAC;GACmB,aAAa,CA4JjC;kBA5JoB,aAAa","sourcesContent":["// file: libs/sdk/src/prompt/flows/get-prompt.flow.ts\n\nimport { Flow, FlowBase, FlowHooksOf, FlowPlan, FlowRunOptions, PromptContext, PromptEntry } from '../../common';\nimport { z } from 'zod';\nimport { GetPromptRequestSchema, GetPromptResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';\nimport {\n InvalidMethodError,\n PromptNotFoundError,\n InvalidInputError,\n InvalidOutputError,\n PromptExecutionError,\n} from '../../errors';\n\nconst inputSchema = z.object({\n request: GetPromptRequestSchema,\n // z.any() used because ctx is the MCP SDK's PromptGetExtra type which varies by SDK version\n ctx: z.any(),\n});\n\nconst outputSchema = GetPromptResultSchema;\n\nconst stateSchema = z.object({\n input: z.object({\n name: z.string().min(1),\n arguments: z.record(z.string(), z.string()).optional(),\n }),\n // Prompt owner ID for hook filtering during execution\n promptOwnerId: z.string().optional(),\n // z.any() used because AuthInfo is a complex external type from @modelcontextprotocol/sdk\n authInfo: z.any().optional() as z.ZodType<AuthInfo>,\n // z.any() used because PromptEntry is a complex abstract class type\n prompt: z.any() as z.ZodType<PromptEntry>,\n // Cached parsed arguments to avoid parsing twice (once in createPromptContext, once in execute)\n parsedArgs: z.record(z.string(), z.string()).optional(),\n // z.any() used because PromptContext is a complex abstract class type\n promptContext: z.any() as z.ZodType<PromptContext>,\n // z.any() used because prompt output type varies by prompt implementation\n rawOutput: z.any().optional(),\n output: outputSchema,\n});\n\nconst plan = {\n pre: ['parseInput', 'findPrompt', 'createPromptContext'],\n execute: ['execute', 'validateOutput'],\n finalize: ['finalize'],\n} as const satisfies FlowPlan<string>;\n\ndeclare global {\n interface ExtendFlows {\n 'prompts:get-prompt': FlowRunOptions<\n GetPromptFlow,\n typeof plan,\n typeof inputSchema,\n typeof outputSchema,\n typeof stateSchema\n >;\n }\n}\n\nconst name = 'prompts:get-prompt' as const;\nconst { Stage } = FlowHooksOf<'prompts:get-prompt'>(name);\n\n@Flow({\n name,\n plan,\n inputSchema,\n outputSchema,\n access: 'authorized',\n})\nexport default class GetPromptFlow extends FlowBase<typeof name> {\n logger = this.scopeLogger.child('GetPromptFlow');\n\n @Stage('parseInput')\n async parseInput() {\n this.logger.verbose('parseInput:start');\n\n let method!: string;\n let params: any;\n let ctx: any;\n try {\n const inputData = inputSchema.parse(this.rawInput);\n method = inputData.request.method;\n params = inputData.request.params;\n ctx = inputData.ctx;\n } catch (e) {\n throw new InvalidInputError('Invalid Input', e instanceof z.ZodError ? e.issues : undefined);\n }\n\n if (method !== 'prompts/get') {\n this.logger.warn(`parseInput: invalid method \"${method}\"`);\n throw new InvalidMethodError(method, 'prompts/get');\n }\n\n this.state.set({\n input: {\n name: params.name,\n arguments: params.arguments,\n },\n authInfo: ctx.authInfo,\n });\n this.logger.verbose('parseInput:done');\n }\n\n @Stage('findPrompt')\n async findPrompt() {\n this.logger.verbose('findPrompt:start');\n\n const { name } = this.state.required.input;\n this.logger.info(`findPrompt: looking for prompt with name \"${name}\"`);\n\n // Try to find a prompt that matches this name\n const prompt = this.scope.prompts.findByName(name);\n\n if (!prompt) {\n this.logger.warn(`findPrompt: prompt \"${name}\" not found`);\n throw new PromptNotFoundError(name);\n }\n\n // Store prompt owner ID in state for hook filtering during execution\n this.state.set('promptOwnerId', prompt.owner?.id);\n\n this.logger = this.logger.child(`GetPromptFlow(${name})`);\n this.state.set('prompt', prompt);\n this.logger.info(`findPrompt: prompt \"${prompt.name}\" found`);\n this.logger.verbose('findPrompt:done');\n }\n\n @Stage('createPromptContext')\n async createPromptContext() {\n this.logger.verbose('createPromptContext:start');\n const { ctx } = this.input;\n const { prompt, input } = this.state.required;\n\n try {\n // Parse and validate arguments, cache for reuse in execute stage\n const parsedArgs = prompt.parseArguments(input.arguments);\n this.state.set('parsedArgs', parsedArgs);\n\n const context = prompt.create(parsedArgs, ctx);\n const promptHooks = this.scope.hooks.getClsHooks(prompt.record.provide).map((hook) => {\n hook.run = async () => {\n return context[hook.metadata.method]();\n };\n return hook;\n });\n\n this.appendContextHooks(promptHooks);\n context.mark('createPromptContext');\n this.state.set('promptContext', context);\n this.logger.verbose('createPromptContext:done');\n } catch (error) {\n this.logger.error('createPromptContext: failed to create context', error);\n throw new PromptExecutionError(input.name, error instanceof Error ? error : undefined);\n }\n }\n\n @Stage('execute')\n async execute() {\n this.logger.verbose('execute:start');\n const promptContext = this.state.promptContext;\n const { input, parsedArgs } = this.state.required;\n\n if (!promptContext) {\n this.logger.warn('execute: promptContext not found, skipping execution');\n return;\n }\n promptContext.mark('execute');\n\n try {\n // Use cached parsed arguments from createPromptContext stage\n promptContext.output = await promptContext.execute(parsedArgs);\n this.logger.verbose('execute:done');\n } catch (error) {\n this.logger.error('execute: prompt execution failed', error);\n throw new PromptExecutionError(input.name, error instanceof Error ? error : undefined);\n }\n }\n\n @Stage('validateOutput')\n async validateOutput() {\n this.logger.verbose('validateOutput:start');\n const { promptContext } = this.state;\n if (!promptContext) {\n this.logger.warn('validateOutput: promptContext not found, skipping validation');\n return;\n }\n promptContext.mark('validateOutput');\n\n // Store the RAW output for plugins to inspect\n this.state.set('rawOutput', promptContext.output);\n\n this.logger.verbose('validateOutput:done');\n }\n\n @Stage('finalize')\n async finalize() {\n this.logger.verbose('finalize:start');\n const { prompt, rawOutput, input } = this.state;\n\n if (!prompt) {\n this.logger.error('finalize: prompt not found in state');\n throw new PromptExecutionError('unknown', new Error('Prompt not found in state'));\n }\n\n if (rawOutput === undefined) {\n this.logger.error('finalize: prompt output not found in state');\n throw new PromptExecutionError(input?.name || 'unknown', new Error('Prompt output not found'));\n }\n\n // Parse and construct the MCP-compliant output using safeParseOutput\n const parseResult = prompt.safeParseOutput(rawOutput);\n\n if (!parseResult.success) {\n this.logger.error('finalize: output validation failed', {\n prompt: prompt.metadata.name,\n errors: parseResult.error,\n });\n\n throw new InvalidOutputError();\n }\n\n // Respond with the properly formatted MCP result\n this.respond(parseResult.data);\n this.logger.verbose('finalize:done');\n }\n}\n"]}
|