@frontmcp/sdk 0.4.0 → 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 +111 -10
- 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,59 @@
|
|
|
1
|
+
import { Token } from './base.interface';
|
|
2
|
+
import { ProviderRegistryInterface } from './internal';
|
|
3
|
+
import { FrontMcpLogger } from './logger.interface';
|
|
4
|
+
import { URL } from 'url';
|
|
5
|
+
import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
6
|
+
import { ScopeEntry } from '../entries';
|
|
7
|
+
/**
|
|
8
|
+
* Base constructor arguments for all execution contexts.
|
|
9
|
+
*/
|
|
10
|
+
export type ExecutionContextBaseArgs = {
|
|
11
|
+
providers: ProviderRegistryInterface;
|
|
12
|
+
logger: FrontMcpLogger;
|
|
13
|
+
authInfo: AuthInfo;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Abstract base class for execution contexts (tools, resources, prompts, etc.).
|
|
17
|
+
* Provides common functionality for dependency injection, logging, and flow control.
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class ExecutionContextBase<Out = unknown> {
|
|
20
|
+
private providers;
|
|
21
|
+
readonly authInfo: AuthInfo;
|
|
22
|
+
/** Unique identifier for this execution run */
|
|
23
|
+
protected readonly runId: string;
|
|
24
|
+
protected readonly logger: FrontMcpLogger;
|
|
25
|
+
/** Current stage name for tracking/debugging */
|
|
26
|
+
protected activeStage: string;
|
|
27
|
+
/** Error if execution failed */
|
|
28
|
+
private _error?;
|
|
29
|
+
constructor(args: ExecutionContextBaseArgs);
|
|
30
|
+
/**
|
|
31
|
+
* Get a dependency from the provider registry.
|
|
32
|
+
* @throws Error if the dependency is not found
|
|
33
|
+
*/
|
|
34
|
+
get<T>(token: Token<T>): T;
|
|
35
|
+
/**
|
|
36
|
+
* Get the current scope.
|
|
37
|
+
*/
|
|
38
|
+
get scope(): ScopeEntry;
|
|
39
|
+
/**
|
|
40
|
+
* Try to get a dependency, returning undefined if not found.
|
|
41
|
+
*/
|
|
42
|
+
tryGet<T>(token: Token<T>): T | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Fail the execution and trigger error handling.
|
|
45
|
+
*/
|
|
46
|
+
protected fail(err: Error): never;
|
|
47
|
+
/**
|
|
48
|
+
* Mark the current execution stage (for debugging/tracking).
|
|
49
|
+
*/
|
|
50
|
+
mark(stage: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Fetch a URL using the standard fetch API.
|
|
53
|
+
*/
|
|
54
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
55
|
+
/**
|
|
56
|
+
* Get the current error, if any.
|
|
57
|
+
*/
|
|
58
|
+
protected get error(): Error | undefined;
|
|
59
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// file: libs/sdk/src/common/interfaces/execution-context.interface.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ExecutionContextBase = void 0;
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const flow_interface_1 = require("./flow.interface");
|
|
7
|
+
/**
|
|
8
|
+
* Abstract base class for execution contexts (tools, resources, prompts, etc.).
|
|
9
|
+
* Provides common functionality for dependency injection, logging, and flow control.
|
|
10
|
+
*/
|
|
11
|
+
class ExecutionContextBase {
|
|
12
|
+
providers;
|
|
13
|
+
authInfo;
|
|
14
|
+
/** Unique identifier for this execution run */
|
|
15
|
+
runId;
|
|
16
|
+
logger;
|
|
17
|
+
/** Current stage name for tracking/debugging */
|
|
18
|
+
activeStage = 'init';
|
|
19
|
+
/** Error if execution failed */
|
|
20
|
+
_error;
|
|
21
|
+
constructor(args) {
|
|
22
|
+
const { providers, logger, authInfo } = args;
|
|
23
|
+
this.runId = (0, crypto_1.randomUUID)();
|
|
24
|
+
this.providers = providers;
|
|
25
|
+
this.logger = logger;
|
|
26
|
+
this.authInfo = authInfo;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get a dependency from the provider registry.
|
|
30
|
+
* @throws Error if the dependency is not found
|
|
31
|
+
*/
|
|
32
|
+
get(token) {
|
|
33
|
+
return this.providers.get(token);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the current scope.
|
|
37
|
+
*/
|
|
38
|
+
get scope() {
|
|
39
|
+
return this.providers.getScope();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Try to get a dependency, returning undefined if not found.
|
|
43
|
+
*/
|
|
44
|
+
tryGet(token) {
|
|
45
|
+
try {
|
|
46
|
+
return this.providers.get(token);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
50
|
+
this.logger.warn(`Failed to get provider ${String(token)}: ${msg}`);
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Fail the execution and trigger error handling.
|
|
56
|
+
*/
|
|
57
|
+
fail(err) {
|
|
58
|
+
this._error = err;
|
|
59
|
+
flow_interface_1.FlowControl.fail(err);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Mark the current execution stage (for debugging/tracking).
|
|
63
|
+
*/
|
|
64
|
+
mark(stage) {
|
|
65
|
+
this.activeStage = stage;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Fetch a URL using the standard fetch API.
|
|
69
|
+
*/
|
|
70
|
+
fetch(input, init) {
|
|
71
|
+
return fetch(input, init);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the current error, if any.
|
|
75
|
+
*/
|
|
76
|
+
get error() {
|
|
77
|
+
return this._error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.ExecutionContextBase = ExecutionContextBase;
|
|
81
|
+
//# sourceMappingURL=execution-context.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-context.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/execution-context.interface.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;AAEtE,mCAAoC;AAIpC,qDAA+C;AAc/C;;;GAGG;AACH,MAAsB,oBAAoB;IAChC,SAAS,CAA4B;IACpC,QAAQ,CAAW;IAE5B,+CAA+C;IAC5B,KAAK,CAAS;IACd,MAAM,CAAiB;IAE1C,gDAAgD;IACtC,WAAW,GAAG,MAAM,CAAC;IAE/B,gCAAgC;IACxB,MAAM,CAAS;IAEvB,YAAY,IAA8B;QACxC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAA,mBAAU,GAAE,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,GAAG,CAAI,KAAe;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,MAAM,CAAI,KAAe;QACvB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACvD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;YACpE,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;OAEG;IACO,IAAI,CAAC,GAAU;QACvB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QAClB,4BAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,KAAa;QAChB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAwB,EAAE,IAAkB;QAChD,OAAO,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAc,KAAK;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AA9ED,oDA8EC","sourcesContent":["// file: libs/sdk/src/common/interfaces/execution-context.interface.ts\n\nimport { randomUUID } from 'crypto';\nimport { Token } from './base.interface';\nimport { ProviderRegistryInterface } from './internal';\nimport { FrontMcpLogger } from './logger.interface';\nimport { FlowControl } from './flow.interface';\nimport { URL } from 'url';\nimport { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';\nimport { ScopeEntry } from '../entries';\n\n/**\n * Base constructor arguments for all execution contexts.\n */\nexport type ExecutionContextBaseArgs = {\n providers: ProviderRegistryInterface;\n logger: FrontMcpLogger;\n authInfo: AuthInfo;\n};\n\n/**\n * Abstract base class for execution contexts (tools, resources, prompts, etc.).\n * Provides common functionality for dependency injection, logging, and flow control.\n */\nexport abstract class ExecutionContextBase<Out = unknown> {\n private providers: ProviderRegistryInterface;\n readonly authInfo: AuthInfo;\n\n /** Unique identifier for this execution run */\n protected readonly runId: string;\n protected readonly logger: FrontMcpLogger;\n\n /** Current stage name for tracking/debugging */\n protected activeStage = 'init';\n\n /** Error if execution failed */\n private _error?: Error;\n\n constructor(args: ExecutionContextBaseArgs) {\n const { providers, logger, authInfo } = args;\n this.runId = randomUUID();\n this.providers = providers;\n this.logger = logger;\n this.authInfo = authInfo;\n }\n\n /**\n * Get a dependency from the provider registry.\n * @throws Error if the dependency is not found\n */\n get<T>(token: Token<T>): T {\n return this.providers.get(token);\n }\n\n /**\n * Get the current scope.\n */\n get scope(): ScopeEntry {\n return this.providers.getScope();\n }\n\n /**\n * Try to get a dependency, returning undefined if not found.\n */\n tryGet<T>(token: Token<T>): T | undefined {\n try {\n return this.providers.get(token);\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n this.logger.warn(`Failed to get provider ${String(token)}: ${msg}`);\n return undefined;\n }\n }\n\n /**\n * Fail the execution and trigger error handling.\n */\n protected fail(err: Error): never {\n this._error = err;\n FlowControl.fail(err);\n }\n\n /**\n * Mark the current execution stage (for debugging/tracking).\n */\n mark(stage: string): void {\n this.activeStage = stage;\n }\n\n /**\n * Fetch a URL using the standard fetch API.\n */\n fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {\n return fetch(input, init);\n }\n\n /**\n * Get the current error, if any.\n */\n protected get error(): Error | undefined {\n return this._error;\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { FlowMetadata, FlowName } from '../metadata';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { HookEntry, ScopeEntry } from '../entries';
|
|
5
5
|
import { FlowStateOf } from './internal/flow.utils';
|
|
6
|
-
import { FrontMcpLogger } from
|
|
6
|
+
import { FrontMcpLogger } from './logger.interface';
|
|
7
7
|
export type FlowInputOf<N extends FlowName> = z.infer<ExtendFlows[N]['input']>;
|
|
8
8
|
export type FlowOutputOf<N extends FlowName> = z.infer<ExtendFlows[N]['output']>;
|
|
9
9
|
export type FlowPlanOf<N extends FlowName> = ExtendFlows[N]['plan'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/flow.interface.ts"],"names":[],"mappings":";;;AAIA,
|
|
1
|
+
{"version":3,"file":"flow.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/flow.interface.ts"],"names":[],"mappings":";;;AAIA,sDAA+D;AAY/D,MAAa,WAAY,SAAQ,KAAK;IACR;IAAuC;IAAnE,YAA4B,IAAqB,EAAkB,MAAW;QAC5E,KAAK,EAAE,CAAC;QADkB,SAAI,GAAJ,IAAI,CAAiB;QAAkB,WAAM,GAAN,MAAM,CAAK;IAE9E,CAAC;IAED,MAAM,CAAC,OAAO,CAAI,MAAS;QACzB,MAAM,IAAI,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,IAAI;QACT,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,MAAM,IAAI,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,KAAY;QACtB,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAc;QACzB,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;CACF;AAxBD,kCAwBC;AAED,uCAAuC;AACvC,MAAsB,QAAQ;IAMP;IACV;IACU;IACA;IACA;IATX,KAAK,CAAiB;IAChC,KAAK,GAAmB,sBAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7C,WAAW,CAAiB;IAE5B,YACqB,QAAyB,EACnC,QAAuC,EAC7B,KAAiB,EACjB,kBAAgD,EAChD,OAAoC,IAAI,GAAG,EAAE;QAJ7C,aAAQ,GAAR,QAAQ,CAAiB;QACnC,aAAQ,GAAR,QAAQ,CAA+B;QAC7B,UAAK,GAAL,KAAK,CAAY;QACjB,uBAAkB,GAAlB,kBAAkB,CAA8B;QAChD,SAAI,GAAJ,IAAI,CAAyC;QAEhE,IAAI,CAAC,KAAK,GAAI,QAAQ,CAAC,WAAmB,EAAE,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,GAAG,CAAI,KAAe;QACpB,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAM,CAAC;QAC3D,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,MAAuB;QAC7B,MAAM,WAAW,CAAC,OAAO,CAAE,IAAI,CAAC,QAAQ,CAAC,YAAiC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5F,CAAC;IAED,IAAI,CAAC,KAAY;QACf,MAAM,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAES,KAAK,CAAC,OAAe;QAC7B,MAAM,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAES,IAAI;QACZ,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAES,OAAO;QACf,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CACF;AAxCD,4BAwCC","sourcesContent":["import { Token, Type } from './base.interface';\nimport { FlowMetadata, FlowName } from '../metadata';\nimport { z } from 'zod';\nimport { HookEntry, ScopeEntry } from '../entries';\nimport { FlowState, FlowStateOf } from './internal/flow.utils';\nimport { FrontMcpLogger } from './logger.interface';\n\nexport type FlowInputOf<N extends FlowName> = z.infer<ExtendFlows[N]['input']>;\nexport type FlowOutputOf<N extends FlowName> = z.infer<ExtendFlows[N]['output']>;\nexport type FlowPlanOf<N extends FlowName> = ExtendFlows[N]['plan'];\nexport type FlowCtxOf<N extends FlowName> = ExtendFlows[N]['ctx'];\nexport type FlowStagesOf<N extends FlowName> = ExtendFlows[N]['stage'];\nexport type FlowExecuteStagesOf<N extends FlowName> = ExtendFlows[N]['executeStage'];\n\nexport type FlowControlType = 'respond' | 'fail' | 'abort' | 'next' | 'handled';\n\nexport class FlowControl extends Error {\n constructor(public readonly type: FlowControlType, public readonly output: any) {\n super();\n }\n\n static respond<T>(output: T): never {\n throw new FlowControl('respond', output);\n }\n\n static next(): never {\n throw new FlowControl('next', null);\n }\n\n static handled(): never {\n throw new FlowControl('handled', null);\n }\n\n static fail(error: Error): never {\n throw new FlowControl('fail', { error: error.message });\n }\n\n static abort(reason: string): never {\n throw new FlowControl('abort', reason);\n }\n}\n\n// 1) The actual abstract class (value)\nexport abstract class FlowBase<N extends FlowName = FlowName> {\n protected input: FlowInputOf<N>;\n state: FlowStateOf<N> = FlowState.create({});\n scopeLogger: FrontMcpLogger;\n\n constructor(\n protected readonly metadata: FlowMetadata<N>,\n readonly rawInput: Partial<FlowInputOf<N>> | any,\n protected readonly scope: ScopeEntry,\n protected readonly appendContextHooks: (hooks: HookEntry[]) => void,\n protected readonly deps: ReadonlyMap<Token, unknown> = new Map(),\n ) {\n this.input = (metadata.inputSchema as any)?.parse?.(rawInput);\n this.scopeLogger = scope.logger;\n }\n\n get<T>(token: Token<T>): T {\n if (this.deps.has(token)) return this.deps.get(token) as T;\n return this.scope.providers.get(token);\n }\n\n respond(output: FlowOutputOf<N>) {\n throw FlowControl.respond((this.metadata.outputSchema as z.ZodObject<any>).parse(output));\n }\n\n fail(error: Error) {\n throw FlowControl.fail(error);\n }\n\n protected abort(message: string) {\n throw FlowControl.abort(message);\n }\n\n protected next() {\n throw FlowControl.next();\n }\n\n protected handled() {\n throw FlowControl.handled();\n }\n}\n\nexport type FlowType<Provide = FlowBase<any>> = Type<Provide>;\n"]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./base.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./execution-context.interface"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./front-mcp.interface"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./server.interface"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./scope.interface"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,gEAAsC;AACtC,6DAAmC;AACnC,4DAAkC;AAClC,2DAAiC;AACjC,2DAAiC;AACjC,0DAAgC;AAChC,+DAAqC;AACrC,oEAA0C;AAC1C,8DAAoC;AACpC,6DAAmC;AACnC,2DAAiC;AACjC,+DAAqC;AACrC,6DAAmC;AACnC,6DAAmC;AAEnC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,wEAA8C;AAC9C,gEAAsC;AACtC,6DAAmC;AACnC,4DAAkC;AAClC,2DAAiC;AACjC,2DAAiC;AACjC,0DAAgC;AAChC,+DAAqC;AACrC,oEAA0C;AAC1C,8DAAoC;AACpC,6DAAmC;AACnC,2DAAiC;AACjC,+DAAqC;AACrC,6DAAmC;AACnC,6DAAmC;AAEnC,qDAA2B","sourcesContent":["export * from './base.interface';\nexport * from './execution-context.interface';\nexport * from './front-mcp.interface';\nexport * from './server.interface';\nexport * from './scope.interface';\nexport * from './flow.interface';\nexport * from './hook.interface';\nexport * from './app.interface';\nexport * from './provider.interface';\nexport * from './auth-provider.interface';\nexport * from './adapter.interface';\nexport * from './plugin.interface';\nexport * from './tool.interface';\nexport * from './resource.interface';\nexport * from './prompt.interface';\nexport * from './logger.interface';\n\nexport * from './internal';\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServerRequest } from '../server.interface';
|
|
2
|
-
import { AuthOptions } from '../../types';
|
|
2
|
+
import { AuthOptions, TransportConfig } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Base class for primary auth provider.
|
|
5
5
|
* Used for easy access current auth context by dependency injection.
|
|
@@ -17,8 +17,23 @@ export declare abstract class FrontMcpAuth<Options extends AuthOptions = AuthOpt
|
|
|
17
17
|
readonly options: Options;
|
|
18
18
|
readonly id: string;
|
|
19
19
|
constructor(options: Options);
|
|
20
|
+
/**
|
|
21
|
+
* Derive the provider ID from options.
|
|
22
|
+
* This logic MUST match deriveProviderId in auth-provider-detection.ts
|
|
23
|
+
* to ensure consistent provider IDs across the system.
|
|
24
|
+
*/
|
|
25
|
+
private deriveId;
|
|
20
26
|
abstract fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
21
27
|
abstract validate(request: ServerRequest): Promise<void>;
|
|
22
28
|
abstract get issuer(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Default transport configuration when not specified
|
|
31
|
+
*/
|
|
32
|
+
private static readonly DEFAULT_TRANSPORT;
|
|
33
|
+
/**
|
|
34
|
+
* Get transport configuration with all defaults applied.
|
|
35
|
+
* Returns default values when transport is not configured.
|
|
36
|
+
*/
|
|
37
|
+
get transport(): TransportConfig;
|
|
23
38
|
}
|
|
24
|
-
export { FrontMcpAuth as Auth
|
|
39
|
+
export { FrontMcpAuth as Auth };
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Auth = exports.FrontMcpAuth = void 0;
|
|
4
|
+
const types_1 = require("../../types");
|
|
4
5
|
const utils_1 = require("../../utils");
|
|
6
|
+
/**
|
|
7
|
+
* Convert URL to a safe provider ID (hostname with dots replaced)
|
|
8
|
+
* Matches the logic in auth-provider-detection.ts for consistency
|
|
9
|
+
*/
|
|
10
|
+
function urlToProviderId(url) {
|
|
11
|
+
try {
|
|
12
|
+
const parsed = new URL(url);
|
|
13
|
+
return parsed.hostname.replace(/\./g, '_');
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return url.replace(/[^a-zA-Z0-9]/g, '_');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
5
19
|
/**
|
|
6
20
|
* Base class for primary auth provider.
|
|
7
21
|
* Used for easy access current auth context by dependency injection.
|
|
@@ -20,12 +34,46 @@ class FrontMcpAuth {
|
|
|
20
34
|
id;
|
|
21
35
|
constructor(options) {
|
|
22
36
|
this.options = options;
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
this.id = this.deriveId(options);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Derive the provider ID from options.
|
|
41
|
+
* This logic MUST match deriveProviderId in auth-provider-detection.ts
|
|
42
|
+
* to ensure consistent provider IDs across the system.
|
|
43
|
+
*/
|
|
44
|
+
deriveId(options) {
|
|
45
|
+
if ((0, types_1.isPublicMode)(options)) {
|
|
46
|
+
return options.issuer ?? 'public';
|
|
25
47
|
}
|
|
26
|
-
|
|
27
|
-
|
|
48
|
+
if ((0, types_1.isTransparentMode)(options)) {
|
|
49
|
+
return options.remote.id ?? (0, utils_1.urlToSafeId)(options.remote.provider);
|
|
28
50
|
}
|
|
51
|
+
if ((0, types_1.isOrchestratedMode)(options)) {
|
|
52
|
+
if ((0, types_1.isOrchestratedRemote)(options)) {
|
|
53
|
+
return options.remote.id ?? (0, utils_1.urlToSafeId)(options.remote.provider);
|
|
54
|
+
}
|
|
55
|
+
// Local orchestrated – match detection defaults
|
|
56
|
+
return options.local?.issuer ?? 'local';
|
|
57
|
+
}
|
|
58
|
+
return 'unknown';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Default transport configuration when not specified
|
|
62
|
+
*/
|
|
63
|
+
static DEFAULT_TRANSPORT = {
|
|
64
|
+
enableLegacySSE: false,
|
|
65
|
+
enableSseListener: true,
|
|
66
|
+
enableStreamableHttp: true,
|
|
67
|
+
enableStatelessHttp: false,
|
|
68
|
+
enableStatefulHttp: false,
|
|
69
|
+
requireSessionForStreamable: true,
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Get transport configuration with all defaults applied.
|
|
73
|
+
* Returns default values when transport is not configured.
|
|
74
|
+
*/
|
|
75
|
+
get transport() {
|
|
76
|
+
return this.options.transport ?? FrontMcpAuth.DEFAULT_TRANSPORT;
|
|
29
77
|
}
|
|
30
78
|
}
|
|
31
79
|
exports.FrontMcpAuth = FrontMcpAuth;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primary-auth-provider.interface.js","sourceRoot":"","sources":["../../../../../src/common/interfaces/internal/primary-auth-provider.interface.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"primary-auth-provider.interface.js","sourceRoot":"","sources":["../../../../../src/common/interfaces/internal/primary-auth-provider.interface.ts"],"names":[],"mappings":";;;AACA,uCAOqB;AACrB,uCAA0C;AAE1C;;;GAGG;AACH,SAAS,eAAe,CAAC,GAAW;IAClC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAsB,YAAY;IAChC,KAAK,CAAgB;IACZ,OAAO,CAAU;IACjB,EAAE,CAAS;IAEpB,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACK,QAAQ,CAAC,OAAoB;QACnC,IAAI,IAAA,oBAAY,EAAC,OAAO,CAAC,EAAE,CAAC;YAC1B,OAAO,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC;QACpC,CAAC;QAED,IAAI,IAAA,yBAAiB,EAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,IAAA,mBAAW,EAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,IAAA,0BAAkB,EAAC,OAAO,CAAC,EAAE,CAAC;YAChC,IAAI,IAAA,4BAAoB,EAAC,OAAO,CAAC,EAAE,CAAC;gBAClC,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,IAAA,mBAAW,EAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACnE,CAAC;YACD,gDAAgD;YAChD,OAAO,OAAO,CAAC,KAAK,EAAE,MAAM,IAAI,OAAO,CAAC;QAC1C,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAQD;;OAEG;IACK,MAAM,CAAU,iBAAiB,GAAoB;QAC3D,eAAe,EAAE,KAAK;QACtB,iBAAiB,EAAE,IAAI;QACvB,oBAAoB,EAAE,IAAI;QAC1B,mBAAmB,EAAE,KAAK;QAC1B,kBAAkB,EAAE,KAAK;QACzB,2BAA2B,EAAE,IAAI;KAClC,CAAC;IAEF;;;OAGG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,YAAY,CAAC,iBAAiB,CAAC;IAClE,CAAC;;AA3DH,oCA4DC;AAEwB,4BAAI","sourcesContent":["import { ServerRequest } from '../server.interface';\nimport {\n AuthOptions,\n TransportConfig,\n isPublicMode,\n isTransparentMode,\n isOrchestratedMode,\n isOrchestratedRemote,\n} from '../../types';\nimport { urlToSafeId } from '../../utils';\n\n/**\n * Convert URL to a safe provider ID (hostname with dots replaced)\n * Matches the logic in auth-provider-detection.ts for consistency\n */\nfunction urlToProviderId(url: string): string {\n try {\n const parsed = new URL(url);\n return parsed.hostname.replace(/\\./g, '_');\n } catch {\n return url.replace(/[^a-zA-Z0-9]/g, '_');\n }\n}\n\n/**\n * Base class for primary auth provider.\n * Used for easy access current auth context by dependency injection.\n *\n * In tool context, you can access current auth context by calling:\n * this.get(FrontMcpAuth) | this.get(Auth)\n *\n * Or in session scoped Providers in constructor arguments:\n * constructor(private readonly auth: FrontMcpAuth) {\n * // auth.fetch('MY endpoint ')\n * }\n */\nexport abstract class FrontMcpAuth<Options extends AuthOptions = AuthOptions> {\n ready: Promise<void>;\n readonly options: Options;\n readonly id: string;\n\n constructor(options: Options) {\n this.options = options;\n this.id = this.deriveId(options);\n }\n\n /**\n * Derive the provider ID from options.\n * This logic MUST match deriveProviderId in auth-provider-detection.ts\n * to ensure consistent provider IDs across the system.\n */\n private deriveId(options: AuthOptions): string {\n if (isPublicMode(options)) {\n return options.issuer ?? 'public';\n }\n\n if (isTransparentMode(options)) {\n return options.remote.id ?? urlToSafeId(options.remote.provider);\n }\n\n if (isOrchestratedMode(options)) {\n if (isOrchestratedRemote(options)) {\n return options.remote.id ?? urlToSafeId(options.remote.provider);\n }\n // Local orchestrated – match detection defaults\n return options.local?.issuer ?? 'local';\n }\n\n return 'unknown';\n }\n\n abstract fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;\n\n abstract validate(request: ServerRequest): Promise<void>;\n\n abstract get issuer(): string;\n\n /**\n * Default transport configuration when not specified\n */\n private static readonly DEFAULT_TRANSPORT: TransportConfig = {\n enableLegacySSE: false,\n enableSseListener: true,\n enableStreamableHttp: true,\n enableStatelessHttp: false,\n enableStatefulHttp: false,\n requireSessionForStreamable: true,\n };\n\n /**\n * Get transport configuration with all defaults applied.\n * Returns default values when transport is not configured.\n */\n get transport(): TransportConfig {\n return this.options.transport ?? FrontMcpAuth.DEFAULT_TRANSPORT;\n }\n}\n\nexport { FrontMcpAuth as Auth };\n"]}
|
|
@@ -4,6 +4,7 @@ import { FrontMcpAuth } from './primary-auth-provider.interface';
|
|
|
4
4
|
import { FlowName } from '../../metadata';
|
|
5
5
|
import { FlowCtxOf, FlowInputOf, FlowStagesOf } from '../flow.interface';
|
|
6
6
|
import { HookRecord } from '../../records';
|
|
7
|
+
import { ToolChangeEvent } from '../../../tool/tool.events';
|
|
7
8
|
export interface ScopeRegistryInterface {
|
|
8
9
|
getScopes(): ScopeEntry[];
|
|
9
10
|
}
|
|
@@ -50,6 +51,7 @@ export interface ProviderViews {
|
|
|
50
51
|
}
|
|
51
52
|
export interface ProviderRegistryInterface {
|
|
52
53
|
get<T>(token: Token<T>): T;
|
|
54
|
+
getScope(): ScopeEntry;
|
|
53
55
|
getProviders(): ProviderEntry[];
|
|
54
56
|
getRegistries<T extends RegistryKind>(type: T): RegistryType[T][];
|
|
55
57
|
buildViews(session: any): Promise<ProviderViews>;
|
|
@@ -71,14 +73,26 @@ export interface ToolRegistryInterface {
|
|
|
71
73
|
owner: EntryOwnerRef;
|
|
72
74
|
getTools(includeHidden?: boolean): ToolEntry[];
|
|
73
75
|
getInlineTools(): ToolEntry<any, any>[];
|
|
76
|
+
subscribe(opts: {
|
|
77
|
+
immediate?: boolean;
|
|
78
|
+
filter?: (i: ToolEntry) => boolean;
|
|
79
|
+
}, cb: (evt: ToolChangeEvent) => void): () => void;
|
|
74
80
|
}
|
|
75
81
|
export interface ResourceRegistryInterface {
|
|
76
|
-
|
|
82
|
+
owner: EntryOwnerRef;
|
|
83
|
+
getResources(includeHidden?: boolean): ResourceEntry<any, any>[];
|
|
84
|
+
getResourceTemplates(): ResourceEntry<any, any>[];
|
|
77
85
|
getInlineResources(): ResourceEntry<any, any>[];
|
|
86
|
+
findResourceForUri(uri: string): {
|
|
87
|
+
instance: ResourceEntry<any, any>;
|
|
88
|
+
params: Record<string, string>;
|
|
89
|
+
} | undefined;
|
|
78
90
|
}
|
|
79
91
|
export interface PromptRegistryInterface {
|
|
80
|
-
|
|
92
|
+
owner: EntryOwnerRef;
|
|
93
|
+
getPrompts(includeHidden?: boolean): PromptEntry[];
|
|
81
94
|
getInlinePrompts(): PromptEntry[];
|
|
95
|
+
findByName(name: string): PromptEntry | undefined;
|
|
82
96
|
}
|
|
83
97
|
export interface LoggerRegistryInterface {
|
|
84
98
|
getLoggers(): LoggerEntry[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.interface.js","sourceRoot":"","sources":["../../../../../src/common/interfaces/internal/registry.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ScopeEntry,\n FlowEntry,\n AuthProviderEntry,\n AppEntry,\n ProviderEntry,\n PluginEntry,\n AdapterEntry,\n PromptEntry,\n ResourceEntry,\n ToolEntry,\n LoggerEntry,\n EntryOwnerRef,\n HookEntry,\n} from '../../entries';\nimport { Token } from '../base.interface';\nimport { FrontMcpAuth } from './primary-auth-provider.interface';\nimport { FlowName } from '../../metadata';\nimport { FlowCtxOf, FlowInputOf, FlowStagesOf } from '../flow.interface';\nimport { HookRecord } from '../../records';\n\nexport interface ScopeRegistryInterface {\n getScopes(): ScopeEntry[];\n}\n\nexport interface FlowRegistryInterface {\n getFlows(): FlowEntry<FlowName>[];\n}\n\nexport interface HookRegistryInterface {\n /**\n * used to pull hooks registered by a class and related to that class only,\n * like registering hooks on specific tool execution\n * @param token\n */\n getClsHooks(token: Token): HookEntry[];\n\n /**\n * Used to pull all hooks registered to specific flow by name,\n * this is used to construct the flow graph and execute hooks in order\n * @param flow\n */\n getFlowHooks<Name extends FlowName>(\n flow: Name,\n ): HookEntry<FlowInputOf<Name>, Name, FlowStagesOf<Name>, FlowCtxOf<Name>>[];\n\n /**\n * Used to pull all hooks registered to specific flow and stage by name,\n * this is used to construct the flow graph and execute hooks in order\n * @param flow\n * @param stage\n */\n getFlowStageHooks<Name extends FlowName>(\n flow: Name,\n stage: FlowStagesOf<Name> | string,\n ): HookEntry<FlowInputOf<Name>, Name, FlowStagesOf<Name>, FlowCtxOf<Name>>[];\n\n /**\n * Used to pull hooks for a specific flow, optionally filtered by owner ID.\n * Returns all hooks if no ownerId is provided, or only hooks belonging to\n * the specified owner or global hooks (no owner) if ownerId is provided.\n * @param flow\n * @param ownerId\n */\n getFlowHooksForOwner<Name extends FlowName>(\n flow: Name,\n ownerId?: string,\n ): HookEntry<FlowInputOf<Name>, Name, FlowStagesOf<Name>, FlowCtxOf<Name>>[];\n\n registerHooks(embedded: boolean, ...records: HookRecord[]): Promise<void[]>;\n}\n\nexport interface ProviderViews {\n /** App-wide singletons, created at boot. Immutable from invokes POV. */\n global: ReadonlyMap<Token, unknown>;\n /** Session-scoped cache for this sessionId. Mutable. */\n session: Map<Token, unknown>;\n /** Request-scoped providers for this single invocation. Mutable. */\n request: Map<Token, unknown>;\n}\n\nexport interface ProviderRegistryInterface {\n get<T>(token: Token<T>): T;\n\n getProviders(): ProviderEntry[];\n\n getRegistries<T extends RegistryKind>(type: T): RegistryType[T][];\n\n // TODO: fix session type\n buildViews(session: any): Promise<ProviderViews>;\n}\n\nexport interface AuthRegistryInterface {\n getPrimary(): FrontMcpAuth;\n\n getAuthProviders(): AuthProviderEntry[];\n}\n\nexport interface AppRegistryInterface {\n getApps(): AppEntry[];\n}\n\nexport interface PluginRegistryInterface {\n getPlugins(): PluginEntry[];\n}\n\nexport interface AdapterRegistryInterface {\n getAdapters(): AdapterEntry[];\n}\n\nexport interface ToolRegistryInterface {\n owner: EntryOwnerRef;\n\n // inline tools plus discovered by nested tool registries\n getTools(includeHidden?: boolean): ToolEntry[];\n\n // inline tools only\n getInlineTools(): ToolEntry<any, any>[];\n}\n\nexport interface ResourceRegistryInterface {\n // inline resources plus discovered by nested
|
|
1
|
+
{"version":3,"file":"registry.interface.js","sourceRoot":"","sources":["../../../../../src/common/interfaces/internal/registry.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ScopeEntry,\n FlowEntry,\n AuthProviderEntry,\n AppEntry,\n ProviderEntry,\n PluginEntry,\n AdapterEntry,\n PromptEntry,\n ResourceEntry,\n ToolEntry,\n LoggerEntry,\n EntryOwnerRef,\n HookEntry,\n} from '../../entries';\nimport { Token } from '../base.interface';\nimport { FrontMcpAuth } from './primary-auth-provider.interface';\nimport { FlowName } from '../../metadata';\nimport { FlowCtxOf, FlowInputOf, FlowStagesOf } from '../flow.interface';\nimport { HookRecord } from '../../records';\nimport { ToolChangeEvent } from '../../../tool/tool.events';\n\nexport interface ScopeRegistryInterface {\n getScopes(): ScopeEntry[];\n}\n\nexport interface FlowRegistryInterface {\n getFlows(): FlowEntry<FlowName>[];\n}\n\nexport interface HookRegistryInterface {\n /**\n * used to pull hooks registered by a class and related to that class only,\n * like registering hooks on specific tool execution\n * @param token\n */\n getClsHooks(token: Token): HookEntry[];\n\n /**\n * Used to pull all hooks registered to specific flow by name,\n * this is used to construct the flow graph and execute hooks in order\n * @param flow\n */\n getFlowHooks<Name extends FlowName>(\n flow: Name,\n ): HookEntry<FlowInputOf<Name>, Name, FlowStagesOf<Name>, FlowCtxOf<Name>>[];\n\n /**\n * Used to pull all hooks registered to specific flow and stage by name,\n * this is used to construct the flow graph and execute hooks in order\n * @param flow\n * @param stage\n */\n getFlowStageHooks<Name extends FlowName>(\n flow: Name,\n stage: FlowStagesOf<Name> | string,\n ): HookEntry<FlowInputOf<Name>, Name, FlowStagesOf<Name>, FlowCtxOf<Name>>[];\n\n /**\n * Used to pull hooks for a specific flow, optionally filtered by owner ID.\n * Returns all hooks if no ownerId is provided, or only hooks belonging to\n * the specified owner or global hooks (no owner) if ownerId is provided.\n * @param flow\n * @param ownerId\n */\n getFlowHooksForOwner<Name extends FlowName>(\n flow: Name,\n ownerId?: string,\n ): HookEntry<FlowInputOf<Name>, Name, FlowStagesOf<Name>, FlowCtxOf<Name>>[];\n\n registerHooks(embedded: boolean, ...records: HookRecord[]): Promise<void[]>;\n}\n\nexport interface ProviderViews {\n /** App-wide singletons, created at boot. Immutable from invokes POV. */\n global: ReadonlyMap<Token, unknown>;\n /** Session-scoped cache for this sessionId. Mutable. */\n session: Map<Token, unknown>;\n /** Request-scoped providers for this single invocation. Mutable. */\n request: Map<Token, unknown>;\n}\n\nexport interface ProviderRegistryInterface {\n get<T>(token: Token<T>): T;\n\n getScope(): ScopeEntry;\n\n getProviders(): ProviderEntry[];\n\n getRegistries<T extends RegistryKind>(type: T): RegistryType[T][];\n\n // TODO: fix session type\n buildViews(session: any): Promise<ProviderViews>;\n}\n\nexport interface AuthRegistryInterface {\n getPrimary(): FrontMcpAuth;\n\n getAuthProviders(): AuthProviderEntry[];\n}\n\nexport interface AppRegistryInterface {\n getApps(): AppEntry[];\n}\n\nexport interface PluginRegistryInterface {\n getPlugins(): PluginEntry[];\n}\n\nexport interface AdapterRegistryInterface {\n getAdapters(): AdapterEntry[];\n}\n\nexport interface ToolRegistryInterface {\n owner: EntryOwnerRef;\n\n // inline tools plus discovered by nested tool registries\n getTools(includeHidden?: boolean): ToolEntry[];\n\n // inline tools only\n getInlineTools(): ToolEntry<any, any>[];\n\n // subscribe to tool change events\n subscribe(\n opts: { immediate?: boolean; filter?: (i: ToolEntry) => boolean },\n cb: (evt: ToolChangeEvent) => void,\n ): () => void;\n}\n\nexport interface ResourceRegistryInterface {\n // owner of this registry\n owner: EntryOwnerRef;\n\n // inline resources plus discovered by nested resource registries\n getResources(includeHidden?: boolean): ResourceEntry<any, any>[];\n\n // resource templates\n getResourceTemplates(): ResourceEntry<any, any>[];\n\n // inline resources only\n getInlineResources(): ResourceEntry<any, any>[];\n\n // find a resource by URI (exact match first, then template matching)\n findResourceForUri(uri: string): { instance: ResourceEntry<any, any>; params: Record<string, string> } | undefined;\n}\n\nexport interface PromptRegistryInterface {\n // owner reference for the registry\n owner: EntryOwnerRef;\n\n // inline prompts plus discovered by nested prompt registries\n getPrompts(includeHidden?: boolean): PromptEntry[];\n\n // inline prompts only\n getInlinePrompts(): PromptEntry[];\n\n // find a prompt by name\n findByName(name: string): PromptEntry | undefined;\n}\n\nexport interface LoggerRegistryInterface {\n getLoggers(): LoggerEntry[];\n}\n\nexport type GlobalRegistryKind = 'LoggerRegistry' | 'ScopeRegistry';\n\nexport type ScopedRegistryKind = 'AppRegistry' | 'AuthRegistry' | 'FlowRegistry' | 'HookRegistry';\n\nexport type AppRegistryKind =\n | 'ProviderRegistry'\n | 'PluginRegistry'\n | 'AdapterRegistry'\n | 'ToolRegistry'\n | 'PromptRegistry'\n | 'ResourceRegistry';\n\nexport type RegistryKind = GlobalRegistryKind | ScopedRegistryKind | AppRegistryKind;\n\nexport type RegistryType = {\n LoggerRegistry: LoggerRegistryInterface;\n ScopeRegistry: ScopeRegistryInterface;\n FlowRegistry: FlowRegistryInterface;\n HookRegistry: HookRegistryInterface;\n AppRegistry: AppRegistryInterface;\n AuthRegistry: AuthRegistryInterface;\n ProviderRegistry: ProviderRegistryInterface;\n PluginRegistry: PluginRegistryInterface;\n AdapterRegistry: AdapterRegistryInterface;\n ToolRegistry: ToolRegistryInterface;\n ResourceRegistry: ResourceRegistryInterface;\n PromptRegistry: PromptRegistryInterface;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/plugin.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { Type, Token, ValueType, ClassType, FactoryType } from './base.interface';\nimport { PluginMetadata } from '../metadata';\n\nexport interface PluginInterface {
|
|
1
|
+
{"version":3,"file":"plugin.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/plugin.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { Type, Token, ValueType, ClassType, FactoryType } from './base.interface';\nimport { PluginMetadata } from '../metadata';\n\nexport interface PluginInterface {}\n\nexport type PluginClassType<Provide> = ClassType<Provide> & PluginMetadata;\nexport type PluginValueType<Provide> = ValueType<Provide> & PluginMetadata;\nexport type PluginFactoryType<Provide, Tokens extends readonly Token[]> = FactoryType<Provide, Tokens> & PluginMetadata;\n\nexport type PluginType<Provide extends PluginInterface = PluginInterface> =\n | Type<Provide>\n | PluginClassType<Provide>\n | PluginValueType<Provide>\n | PluginFactoryType<Provide, readonly any[]>;\n"]}
|
|
@@ -1,5 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { PromptMetadata } from '../metadata';
|
|
2
|
+
import { FuncType, Token, Type } from './base.interface';
|
|
3
|
+
import { ProviderRegistryInterface } from './internal';
|
|
4
|
+
import { FrontMcpLogger } from './logger.interface';
|
|
5
|
+
import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
6
|
+
import { ScopeEntry } from '../entries';
|
|
7
|
+
import { GetPromptResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
export interface PromptInterface {
|
|
9
|
+
execute(args: Record<string, string>): Promise<GetPromptResult>;
|
|
3
10
|
}
|
|
4
|
-
type PromptType = Type<PromptInterface> | FuncType<PromptInterface>;
|
|
5
|
-
|
|
11
|
+
export type PromptType = Type<PromptInterface> | FuncType<PromptInterface>;
|
|
12
|
+
type HistoryEntry<T> = {
|
|
13
|
+
at: number;
|
|
14
|
+
stage?: string;
|
|
15
|
+
value: T | undefined;
|
|
16
|
+
note?: string;
|
|
17
|
+
};
|
|
18
|
+
export type PromptCtorArgs = {
|
|
19
|
+
metadata: PromptMetadata;
|
|
20
|
+
args: Record<string, string>;
|
|
21
|
+
providers: ProviderRegistryInterface;
|
|
22
|
+
logger: FrontMcpLogger;
|
|
23
|
+
authInfo: AuthInfo;
|
|
24
|
+
};
|
|
25
|
+
export declare abstract class PromptContext {
|
|
26
|
+
private providers;
|
|
27
|
+
readonly authInfo: AuthInfo;
|
|
28
|
+
protected readonly runId: string;
|
|
29
|
+
protected readonly promptId: string;
|
|
30
|
+
protected readonly promptName: string;
|
|
31
|
+
readonly metadata: PromptMetadata;
|
|
32
|
+
protected readonly logger: FrontMcpLogger;
|
|
33
|
+
/** The arguments passed to the prompt */
|
|
34
|
+
readonly args: Record<string, string>;
|
|
35
|
+
protected activeStage: string;
|
|
36
|
+
private _output?;
|
|
37
|
+
private _error?;
|
|
38
|
+
private readonly _outputHistory;
|
|
39
|
+
constructor(ctorArgs: PromptCtorArgs);
|
|
40
|
+
abstract execute(args: Record<string, string>): Promise<GetPromptResult>;
|
|
41
|
+
get<T>(token: Token<T>): T;
|
|
42
|
+
get scope(): ScopeEntry;
|
|
43
|
+
tryGet<T>(token: Token<T>): T | undefined;
|
|
44
|
+
get output(): GetPromptResult | undefined;
|
|
45
|
+
set output(v: GetPromptResult | undefined);
|
|
46
|
+
get outputHistory(): ReadonlyArray<HistoryEntry<GetPromptResult>>;
|
|
47
|
+
respond(value: GetPromptResult): never;
|
|
48
|
+
/** Get the error that caused the prompt to fail, if any. */
|
|
49
|
+
get error(): Error | undefined;
|
|
50
|
+
/** Fail the run (invoker will run error/finalize). */
|
|
51
|
+
protected fail(err: Error): never;
|
|
52
|
+
mark(stage: string): void;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -1,3 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// file: libs/sdk/src/common/interfaces/prompt.interface.ts
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.PromptContext = void 0;
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const flow_interface_1 = require("./flow.interface");
|
|
7
|
+
class PromptContext {
|
|
8
|
+
providers;
|
|
9
|
+
authInfo;
|
|
10
|
+
runId;
|
|
11
|
+
promptId;
|
|
12
|
+
promptName;
|
|
13
|
+
metadata;
|
|
14
|
+
logger;
|
|
15
|
+
/** The arguments passed to the prompt */
|
|
16
|
+
args;
|
|
17
|
+
activeStage = 'init';
|
|
18
|
+
// ---- OUTPUT storages (backing fields)
|
|
19
|
+
_output;
|
|
20
|
+
_error;
|
|
21
|
+
// ---- histories
|
|
22
|
+
_outputHistory = [];
|
|
23
|
+
constructor(ctorArgs) {
|
|
24
|
+
const { metadata, args, providers, logger, authInfo } = ctorArgs;
|
|
25
|
+
this.runId = (0, crypto_1.randomUUID)();
|
|
26
|
+
this.promptName = metadata.name;
|
|
27
|
+
// promptId uses the metadata name as the stable identifier for the prompt type
|
|
28
|
+
// (runId is the unique instance identifier for this specific execution)
|
|
29
|
+
this.promptId = metadata.name;
|
|
30
|
+
this.metadata = metadata;
|
|
31
|
+
this.args = args;
|
|
32
|
+
this.providers = providers;
|
|
33
|
+
this.logger = logger.child(`prompt:${this.promptId}`);
|
|
34
|
+
this.authInfo = authInfo;
|
|
35
|
+
}
|
|
36
|
+
get(token) {
|
|
37
|
+
return this.providers.get(token);
|
|
38
|
+
}
|
|
39
|
+
get scope() {
|
|
40
|
+
return this.providers.getScope();
|
|
41
|
+
}
|
|
42
|
+
tryGet(token) {
|
|
43
|
+
try {
|
|
44
|
+
return this.providers.get(token);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
48
|
+
this.logger.warn(`Failed to get provider ${String(token)}: ${msg}`);
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
get output() {
|
|
53
|
+
return this._output;
|
|
54
|
+
}
|
|
55
|
+
set output(v) {
|
|
56
|
+
this._output = v;
|
|
57
|
+
this._outputHistory.push({ at: Date.now(), stage: this.activeStage, value: v });
|
|
58
|
+
}
|
|
59
|
+
get outputHistory() {
|
|
60
|
+
return this._outputHistory;
|
|
61
|
+
}
|
|
62
|
+
respond(value) {
|
|
63
|
+
// record validated output and surface the value via control flow
|
|
64
|
+
this.output = value;
|
|
65
|
+
flow_interface_1.FlowControl.respond(value);
|
|
66
|
+
}
|
|
67
|
+
/** Get the error that caused the prompt to fail, if any. */
|
|
68
|
+
get error() {
|
|
69
|
+
return this._error;
|
|
70
|
+
}
|
|
71
|
+
/** Fail the run (invoker will run error/finalize). */
|
|
72
|
+
fail(err) {
|
|
73
|
+
this._error = err;
|
|
74
|
+
flow_interface_1.FlowControl.fail(err);
|
|
75
|
+
}
|
|
76
|
+
mark(stage) {
|
|
77
|
+
this.activeStage = stage;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.PromptContext = PromptContext;
|
|
3
81
|
//# sourceMappingURL=prompt.interface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/prompt.interface.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"prompt.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/prompt.interface.ts"],"names":[],"mappings":";AAAA,2DAA2D;;;AAE3D,mCAAoC;AAKpC,qDAA+C;AA0B/C,MAAsB,aAAa;IACzB,SAAS,CAA4B;IACpC,QAAQ,CAAW;IAET,KAAK,CAAS;IACd,QAAQ,CAAS;IACjB,UAAU,CAAS;IAC7B,QAAQ,CAAiB;IACf,MAAM,CAAiB;IAE1C,yCAAyC;IAChC,IAAI,CAAyB;IAE5B,WAAW,GAAG,MAAM,CAAC;IAE/B,wCAAwC;IAChC,OAAO,CAAmB;IAE1B,MAAM,CAAS;IAEvB,iBAAiB;IACA,cAAc,GAAoC,EAAE,CAAC;IAEtE,YAAY,QAAwB;QAClC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;QACjE,IAAI,CAAC,KAAK,GAAG,IAAA,mBAAU,GAAE,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC;QAChC,+EAA+E;QAC/E,wEAAwE;QACxE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAID,GAAG,CAAI,KAAe;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,CAAI,KAAe;QACvB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACvD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;YACpE,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAW,MAAM,CAAC,CAA8B;QAC9C,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,KAAsB;QAC5B,iEAAiE;QACjE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,4BAAW,CAAC,OAAO,CAAkB,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,4DAA4D;IAC5D,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,sDAAsD;IAC5C,IAAI,CAAC,GAAU;QACvB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QAClB,4BAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,KAAa;QAChB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;CACF;AA1FD,sCA0FC","sourcesContent":["// file: libs/sdk/src/common/interfaces/prompt.interface.ts\n\nimport { randomUUID } from 'crypto';\nimport { PromptMetadata } from '../metadata';\nimport { FuncType, Token, Type } from './base.interface';\nimport { ProviderRegistryInterface } from './internal';\nimport { FrontMcpLogger } from './logger.interface';\nimport { FlowControl } from './flow.interface';\nimport { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';\nimport { ScopeEntry } from '../entries';\nimport { GetPromptResult } from '@modelcontextprotocol/sdk/types.js';\n\nexport interface PromptInterface {\n execute(args: Record<string, string>): Promise<GetPromptResult>;\n}\n\nexport type PromptType = Type<PromptInterface> | FuncType<PromptInterface>;\n\ntype HistoryEntry<T> = {\n at: number;\n stage?: string;\n value: T | undefined;\n note?: string;\n};\n\nexport type PromptCtorArgs = {\n metadata: PromptMetadata;\n args: Record<string, string>;\n providers: ProviderRegistryInterface;\n logger: FrontMcpLogger;\n authInfo: AuthInfo;\n};\n\nexport abstract class PromptContext {\n private providers: ProviderRegistryInterface;\n readonly authInfo: AuthInfo;\n\n protected readonly runId: string;\n protected readonly promptId: string;\n protected readonly promptName: string;\n readonly metadata: PromptMetadata;\n protected readonly logger: FrontMcpLogger;\n\n /** The arguments passed to the prompt */\n readonly args: Record<string, string>;\n\n protected activeStage = 'init';\n\n // ---- OUTPUT storages (backing fields)\n private _output?: GetPromptResult;\n\n private _error?: Error;\n\n // ---- histories\n private readonly _outputHistory: HistoryEntry<GetPromptResult>[] = [];\n\n constructor(ctorArgs: PromptCtorArgs) {\n const { metadata, args, providers, logger, authInfo } = ctorArgs;\n this.runId = randomUUID();\n this.promptName = metadata.name;\n // promptId uses the metadata name as the stable identifier for the prompt type\n // (runId is the unique instance identifier for this specific execution)\n this.promptId = metadata.name;\n this.metadata = metadata;\n this.args = args;\n this.providers = providers;\n this.logger = logger.child(`prompt:${this.promptId}`);\n this.authInfo = authInfo;\n }\n\n abstract execute(args: Record<string, string>): Promise<GetPromptResult>;\n\n get<T>(token: Token<T>): T {\n return this.providers.get(token);\n }\n\n get scope(): ScopeEntry {\n return this.providers.getScope();\n }\n\n tryGet<T>(token: Token<T>): T | undefined {\n try {\n return this.providers.get(token);\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n this.logger.warn(`Failed to get provider ${String(token)}: ${msg}`);\n return undefined;\n }\n }\n\n public get output(): GetPromptResult | undefined {\n return this._output;\n }\n\n public set output(v: GetPromptResult | undefined) {\n this._output = v;\n this._outputHistory.push({ at: Date.now(), stage: this.activeStage, value: v });\n }\n\n public get outputHistory(): ReadonlyArray<HistoryEntry<GetPromptResult>> {\n return this._outputHistory;\n }\n\n respond(value: GetPromptResult): never {\n // record validated output and surface the value via control flow\n this.output = value;\n FlowControl.respond<GetPromptResult>(value);\n }\n\n /** Get the error that caused the prompt to fail, if any. */\n public get error(): Error | undefined {\n return this._error;\n }\n\n /** Fail the run (invoker will run error/finalize). */\n protected fail(err: Error): never {\n this._error = err;\n FlowControl.fail(err);\n }\n\n mark(stage: string): void {\n this.activeStage = stage;\n }\n}\n"]}
|