@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
|
@@ -1,21 +1,51 @@
|
|
|
1
|
-
import { ResourceMetadata } from '../metadata';
|
|
2
|
-
import { FuncType,
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ResourceMetadata, ResourceTemplateMetadata } from '../metadata';
|
|
2
|
+
import { FuncType, Type } from './base.interface';
|
|
3
|
+
import { ExecutionContextBase, ExecutionContextBaseArgs } from './execution-context.interface';
|
|
4
|
+
/**
|
|
5
|
+
* Base interface for resource implementations.
|
|
6
|
+
* @template Params - Type for URI template parameters (defaults to generic string record)
|
|
7
|
+
* @template Out - Type for the resource output
|
|
8
|
+
*/
|
|
9
|
+
export interface ResourceInterface<Params extends Record<string, string> = Record<string, string>, Out = unknown> {
|
|
10
|
+
execute(uri: string, params: Params): Promise<Out>;
|
|
5
11
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Type for resource class or function.
|
|
14
|
+
* @template Params - Type for URI template parameters
|
|
15
|
+
* @template Out - Type for the resource output
|
|
16
|
+
*/
|
|
17
|
+
export type ResourceType<Params extends Record<string, string> = Record<string, string>, Out = unknown> = Type<ResourceInterface<Params, Out>> | FuncType<ResourceInterface<Params, Out>>;
|
|
18
|
+
type HistoryEntry<T> = {
|
|
19
|
+
at: number;
|
|
20
|
+
stage?: string;
|
|
21
|
+
value: T | undefined;
|
|
22
|
+
note?: string;
|
|
23
|
+
};
|
|
24
|
+
export type ResourceCtorArgs<Params extends Record<string, string> = Record<string, string>> = ExecutionContextBaseArgs & {
|
|
25
|
+
metadata: ResourceMetadata | ResourceTemplateMetadata;
|
|
26
|
+
uri: string;
|
|
27
|
+
params: Params;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Abstract base class for resource execution contexts.
|
|
31
|
+
* @template Params - Type for URI template parameters (e.g., `{ userId: string }`)
|
|
32
|
+
* @template Out - Type for the resource output
|
|
33
|
+
*/
|
|
34
|
+
export declare abstract class ResourceContext<Params extends Record<string, string> = Record<string, string>, Out = unknown> extends ExecutionContextBase<Out> {
|
|
35
|
+
protected readonly resourceId: string;
|
|
36
|
+
protected readonly resourceName: string;
|
|
37
|
+
readonly metadata: ResourceMetadata | ResourceTemplateMetadata;
|
|
38
|
+
/** The actual URI being read */
|
|
39
|
+
readonly uri: string;
|
|
40
|
+
/** Extracted URI template parameters (empty for static resources) */
|
|
41
|
+
readonly params: Params;
|
|
42
|
+
private _output?;
|
|
43
|
+
private readonly _outputHistory;
|
|
44
|
+
constructor(args: ResourceCtorArgs<Params>);
|
|
45
|
+
abstract execute(uri: string, params: Params): Promise<Out>;
|
|
18
46
|
get output(): Out | undefined;
|
|
47
|
+
set output(v: Out | undefined);
|
|
48
|
+
get outputHistory(): ReadonlyArray<HistoryEntry<Out>>;
|
|
19
49
|
respond(value: Out): never;
|
|
20
|
-
fail(reason: string, error: any): never;
|
|
21
50
|
}
|
|
51
|
+
export {};
|
|
@@ -1,3 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// file: libs/sdk/src/common/interfaces/resource.interface.ts
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ResourceContext = void 0;
|
|
5
|
+
const flow_interface_1 = require("./flow.interface");
|
|
6
|
+
const execution_context_interface_1 = require("./execution-context.interface");
|
|
7
|
+
/**
|
|
8
|
+
* Abstract base class for resource execution contexts.
|
|
9
|
+
* @template Params - Type for URI template parameters (e.g., `{ userId: string }`)
|
|
10
|
+
* @template Out - Type for the resource output
|
|
11
|
+
*/
|
|
12
|
+
class ResourceContext extends execution_context_interface_1.ExecutionContextBase {
|
|
13
|
+
resourceId;
|
|
14
|
+
resourceName;
|
|
15
|
+
metadata;
|
|
16
|
+
/** The actual URI being read */
|
|
17
|
+
uri;
|
|
18
|
+
/** Extracted URI template parameters (empty for static resources) */
|
|
19
|
+
params;
|
|
20
|
+
// ---- OUTPUT storages (backing fields)
|
|
21
|
+
_output;
|
|
22
|
+
// ---- histories
|
|
23
|
+
_outputHistory = [];
|
|
24
|
+
constructor(args) {
|
|
25
|
+
const { metadata, uri, params, providers, logger } = args;
|
|
26
|
+
super({
|
|
27
|
+
providers,
|
|
28
|
+
logger: logger.child(`resource:${metadata.name}`),
|
|
29
|
+
authInfo: args.authInfo,
|
|
30
|
+
});
|
|
31
|
+
this.resourceName = metadata.name;
|
|
32
|
+
// resourceId uses the metadata name as the stable identifier for the resource type
|
|
33
|
+
// (runId is the unique instance identifier for this specific execution)
|
|
34
|
+
this.resourceId = metadata.name;
|
|
35
|
+
this.metadata = metadata;
|
|
36
|
+
this.uri = uri;
|
|
37
|
+
this.params = params;
|
|
38
|
+
}
|
|
39
|
+
get output() {
|
|
40
|
+
return this._output;
|
|
41
|
+
}
|
|
42
|
+
set output(v) {
|
|
43
|
+
this._output = v;
|
|
44
|
+
this._outputHistory.push({ at: Date.now(), stage: this.activeStage, value: v });
|
|
45
|
+
}
|
|
46
|
+
get outputHistory() {
|
|
47
|
+
return this._outputHistory;
|
|
48
|
+
}
|
|
49
|
+
respond(value) {
|
|
50
|
+
// record validated output and surface the value via control flow
|
|
51
|
+
this.output = value;
|
|
52
|
+
flow_interface_1.FlowControl.respond(value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.ResourceContext = ResourceContext;
|
|
3
56
|
//# sourceMappingURL=resource.interface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/resource.interface.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"resource.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/resource.interface.ts"],"names":[],"mappings":";AAAA,6DAA6D;;;AAM7D,qDAA+C;AAE/C,+EAA+F;AAkC/F;;;;GAIG;AACH,MAAsB,eAGpB,SAAQ,kDAAyB;IACd,UAAU,CAAS;IACnB,YAAY,CAAS;IAC/B,QAAQ,CAA8C;IAE/D,gCAAgC;IACvB,GAAG,CAAS;IACrB,qEAAqE;IAC5D,MAAM,CAAS;IAExB,wCAAwC;IAChC,OAAO,CAAO;IAEtB,iBAAiB;IACA,cAAc,GAAwB,EAAE,CAAC;IAE1D,YAAY,IAA8B;QACxC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAC1D,KAAK,CAAC;YACJ,SAAS;YACT,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,QAAQ,CAAC,IAAI,EAAE,CAAC;YACjD,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC;QAClC,mFAAmF;QACnF,wEAAwE;QACxE,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAID,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAW,MAAM,CAAC,CAAkB;QAClC,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,KAAU;QAChB,iEAAiE;QACjE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,4BAAW,CAAC,OAAO,CAAM,KAAK,CAAC,CAAC;IAClC,CAAC;CACF;AAvDD,0CAuDC","sourcesContent":["// file: libs/sdk/src/common/interfaces/resource.interface.ts\n\nimport { ResourceMetadata, ResourceTemplateMetadata } from '../metadata';\nimport { FuncType, 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 { ExecutionContextBase, ExecutionContextBaseArgs } from './execution-context.interface';\n\n/**\n * Base interface for resource implementations.\n * @template Params - Type for URI template parameters (defaults to generic string record)\n * @template Out - Type for the resource output\n */\nexport interface ResourceInterface<Params extends Record<string, string> = Record<string, string>, Out = unknown> {\n execute(uri: string, params: Params): Promise<Out>;\n}\n\n/**\n * Type for resource class or function.\n * @template Params - Type for URI template parameters\n * @template Out - Type for the resource output\n */\nexport type ResourceType<Params extends Record<string, string> = Record<string, string>, Out = unknown> =\n | Type<ResourceInterface<Params, Out>>\n | FuncType<ResourceInterface<Params, Out>>;\n\ntype HistoryEntry<T> = {\n at: number;\n stage?: string;\n value: T | undefined;\n note?: string;\n};\n\nexport type ResourceCtorArgs<Params extends Record<string, string> = Record<string, string>> =\n ExecutionContextBaseArgs & {\n metadata: ResourceMetadata | ResourceTemplateMetadata;\n uri: string;\n params: Params;\n };\n\n/**\n * Abstract base class for resource execution contexts.\n * @template Params - Type for URI template parameters (e.g., `{ userId: string }`)\n * @template Out - Type for the resource output\n */\nexport abstract class ResourceContext<\n Params extends Record<string, string> = Record<string, string>,\n Out = unknown,\n> extends ExecutionContextBase<Out> {\n protected readonly resourceId: string;\n protected readonly resourceName: string;\n readonly metadata: ResourceMetadata | ResourceTemplateMetadata;\n\n /** The actual URI being read */\n readonly uri: string;\n /** Extracted URI template parameters (empty for static resources) */\n readonly params: Params;\n\n // ---- OUTPUT storages (backing fields)\n private _output?: Out;\n\n // ---- histories\n private readonly _outputHistory: HistoryEntry<Out>[] = [];\n\n constructor(args: ResourceCtorArgs<Params>) {\n const { metadata, uri, params, providers, logger } = args;\n super({\n providers,\n logger: logger.child(`resource:${metadata.name}`),\n authInfo: args.authInfo,\n });\n this.resourceName = metadata.name;\n // resourceId uses the metadata name as the stable identifier for the resource type\n // (runId is the unique instance identifier for this specific execution)\n this.resourceId = metadata.name;\n this.metadata = metadata;\n this.uri = uri;\n this.params = params;\n }\n\n abstract execute(uri: string, params: Params): Promise<Out>;\n\n public get output(): Out | undefined {\n return this._output;\n }\n\n public set output(v: Out | 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<Out>> {\n return this._outputHistory;\n }\n\n respond(value: Out): never {\n // record validated output and surface the value via control flow\n this.output = value;\n FlowControl.respond<Out>(value);\n }\n}\n"]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { FuncType,
|
|
2
|
-
import { ProviderRegistryInterface } from './internal';
|
|
1
|
+
import { FuncType, Type } from './base.interface';
|
|
3
2
|
import { ToolInputType, ToolMetadata, ToolOutputType } from '../metadata';
|
|
4
|
-
import { FrontMcpLogger } from './logger.interface';
|
|
5
|
-
import { URL } from 'url';
|
|
6
|
-
import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
7
3
|
import { ToolInputOf, ToolOutputOf } from '../decorators';
|
|
4
|
+
import { ExecutionContextBase, ExecutionContextBaseArgs } from './execution-context.interface';
|
|
5
|
+
import type { AIPlatformType, ClientInfo } from '../../notification';
|
|
8
6
|
export type ToolType<T = any> = Type<T> | FuncType<T>;
|
|
9
7
|
type HistoryEntry<T> = {
|
|
10
8
|
at: number;
|
|
@@ -12,37 +10,26 @@ type HistoryEntry<T> = {
|
|
|
12
10
|
value: T | undefined;
|
|
13
11
|
note?: string;
|
|
14
12
|
};
|
|
15
|
-
export type ToolCtorArgs<In> = {
|
|
13
|
+
export type ToolCtorArgs<In> = ExecutionContextBaseArgs & {
|
|
16
14
|
metadata: ToolMetadata;
|
|
17
15
|
input: In;
|
|
18
|
-
providers: ProviderRegistryInterface;
|
|
19
|
-
logger: FrontMcpLogger;
|
|
20
|
-
authInfo: AuthInfo;
|
|
21
16
|
};
|
|
22
17
|
export declare abstract class ToolContext<InSchema extends ToolInputType = ToolInputType, OutSchema extends ToolOutputType = ToolOutputType, In = ToolInputOf<{
|
|
23
18
|
inputSchema: InSchema;
|
|
24
19
|
}>, Out = ToolOutputOf<{
|
|
25
20
|
outputSchema: OutSchema;
|
|
26
|
-
}>> {
|
|
27
|
-
private providers;
|
|
28
|
-
readonly authInfo: AuthInfo;
|
|
29
|
-
protected readonly runId: string;
|
|
21
|
+
}>> extends ExecutionContextBase<Out> {
|
|
30
22
|
protected readonly toolId: string;
|
|
31
23
|
protected readonly toolName: string;
|
|
32
24
|
readonly metadata: ToolMetadata;
|
|
33
|
-
protected readonly logger: FrontMcpLogger;
|
|
34
|
-
protected activeStage: string;
|
|
35
25
|
private _rawInput?;
|
|
36
26
|
private _input?;
|
|
37
27
|
private _outputDraft?;
|
|
38
28
|
private _output?;
|
|
39
|
-
private _error?;
|
|
40
29
|
private readonly _inputHistory;
|
|
41
30
|
private readonly _outputHistory;
|
|
42
31
|
constructor(args: ToolCtorArgs<In>);
|
|
43
32
|
abstract execute(input: In): Promise<Out>;
|
|
44
|
-
get<T>(token: Token<T>): T;
|
|
45
|
-
tryGet<T>(token: Token<T>): T | undefined;
|
|
46
33
|
get input(): In;
|
|
47
34
|
set input(v: In | undefined);
|
|
48
35
|
get inputHistory(): ReadonlyArray<HistoryEntry<In>>;
|
|
@@ -50,9 +37,39 @@ export declare abstract class ToolContext<InSchema extends ToolInputType = ToolI
|
|
|
50
37
|
set output(v: Out | undefined);
|
|
51
38
|
get outputHistory(): ReadonlyArray<HistoryEntry<Out>>;
|
|
52
39
|
respond(value: Out): never;
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Get the detected AI platform type for the current session.
|
|
42
|
+
* This is auto-detected from the client info during MCP initialization.
|
|
43
|
+
*
|
|
44
|
+
* Use this to customize tool responses (e.g., UI format) based on the calling platform.
|
|
45
|
+
*
|
|
46
|
+
* @returns The detected platform type, or 'unknown' if not detected
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* async execute(input: Input): Promise<Output> {
|
|
50
|
+
* const platform = this.platform;
|
|
51
|
+
* if (platform === 'openai') {
|
|
52
|
+
* // Return OpenAI-specific response format
|
|
53
|
+
* }
|
|
54
|
+
* // ...
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
get platform(): AIPlatformType;
|
|
59
|
+
/**
|
|
60
|
+
* Get the client info (name and version) for the current session.
|
|
61
|
+
* This is captured from the MCP initialize request.
|
|
62
|
+
*
|
|
63
|
+
* @returns The client info, or undefined if not available
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* async execute(input: Input): Promise<Output> {
|
|
67
|
+
* const client = this.clientInfo;
|
|
68
|
+
* console.log(`Called by: ${client?.name} v${client?.version}`);
|
|
69
|
+
* // ...
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
get clientInfo(): ClientInfo | undefined;
|
|
57
74
|
}
|
|
58
75
|
export {};
|
|
@@ -1,49 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ToolContext = void 0;
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
5
4
|
const flow_interface_1 = require("./flow.interface");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
authInfo;
|
|
9
|
-
runId;
|
|
5
|
+
const execution_context_interface_1 = require("./execution-context.interface");
|
|
6
|
+
class ToolContext extends execution_context_interface_1.ExecutionContextBase {
|
|
10
7
|
toolId;
|
|
11
8
|
toolName;
|
|
12
9
|
metadata;
|
|
13
|
-
logger;
|
|
14
|
-
activeStage;
|
|
15
10
|
// ---- INPUT storages (backing fields)
|
|
16
11
|
_rawInput;
|
|
17
12
|
_input;
|
|
18
13
|
// ---- OUTPUT storages (backing fields)
|
|
19
14
|
_outputDraft;
|
|
20
15
|
_output;
|
|
21
|
-
_error;
|
|
22
16
|
// ---- histories
|
|
23
17
|
_inputHistory = [];
|
|
24
18
|
_outputHistory = [];
|
|
25
19
|
constructor(args) {
|
|
26
|
-
const { metadata, input, providers, logger
|
|
27
|
-
|
|
20
|
+
const { metadata, input, providers, logger } = args;
|
|
21
|
+
super({
|
|
22
|
+
providers,
|
|
23
|
+
logger: logger.child(`tool:${metadata.id ?? metadata.name}`),
|
|
24
|
+
authInfo: args.authInfo,
|
|
25
|
+
});
|
|
28
26
|
this.toolName = metadata.name;
|
|
29
27
|
this.toolId = metadata.id ?? metadata.name;
|
|
30
28
|
this.metadata = metadata;
|
|
31
29
|
this._input = input;
|
|
32
|
-
this.providers = providers;
|
|
33
|
-
this.logger = logger.child(`tool:${this.toolId}`);
|
|
34
|
-
this.authInfo = authInfo;
|
|
35
|
-
}
|
|
36
|
-
get(token) {
|
|
37
|
-
return this.providers.get(token);
|
|
38
|
-
}
|
|
39
|
-
tryGet(token) {
|
|
40
|
-
try {
|
|
41
|
-
return this.providers.get(token);
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
this.logger.warn("Requesting provider that doesn't exist: ", token);
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
30
|
}
|
|
48
31
|
get input() {
|
|
49
32
|
return this._input;
|
|
@@ -74,16 +57,60 @@ class ToolContext {
|
|
|
74
57
|
this.output = value;
|
|
75
58
|
flow_interface_1.FlowControl.respond(value);
|
|
76
59
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
60
|
+
// ============================================
|
|
61
|
+
// Platform Detection API
|
|
62
|
+
// ============================================
|
|
63
|
+
/**
|
|
64
|
+
* Get the detected AI platform type for the current session.
|
|
65
|
+
* This is auto-detected from the client info during MCP initialization.
|
|
66
|
+
*
|
|
67
|
+
* Use this to customize tool responses (e.g., UI format) based on the calling platform.
|
|
68
|
+
*
|
|
69
|
+
* @returns The detected platform type, or 'unknown' if not detected
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* async execute(input: Input): Promise<Output> {
|
|
73
|
+
* const platform = this.platform;
|
|
74
|
+
* if (platform === 'openai') {
|
|
75
|
+
* // Return OpenAI-specific response format
|
|
76
|
+
* }
|
|
77
|
+
* // ...
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
get platform() {
|
|
82
|
+
// First check sessionIdPayload (detected from user-agent during session creation)
|
|
83
|
+
const payloadPlatform = this.authInfo.sessionIdPayload?.platformType;
|
|
84
|
+
if (payloadPlatform && payloadPlatform !== 'unknown') {
|
|
85
|
+
return payloadPlatform;
|
|
86
|
+
}
|
|
87
|
+
// Fall back to notification service (detected from MCP clientInfo during initialize)
|
|
88
|
+
const sessionId = this.authInfo.sessionId;
|
|
89
|
+
if (!sessionId) {
|
|
90
|
+
return 'unknown';
|
|
91
|
+
}
|
|
92
|
+
return this.scope.notifications.getPlatformType(sessionId);
|
|
84
93
|
}
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Get the client info (name and version) for the current session.
|
|
96
|
+
* This is captured from the MCP initialize request.
|
|
97
|
+
*
|
|
98
|
+
* @returns The client info, or undefined if not available
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* async execute(input: Input): Promise<Output> {
|
|
102
|
+
* const client = this.clientInfo;
|
|
103
|
+
* console.log(`Called by: ${client?.name} v${client?.version}`);
|
|
104
|
+
* // ...
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
get clientInfo() {
|
|
109
|
+
const sessionId = this.authInfo.sessionId;
|
|
110
|
+
if (!sessionId) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
return this.scope.notifications.getClientInfo(sessionId);
|
|
87
114
|
}
|
|
88
115
|
}
|
|
89
116
|
exports.ToolContext = ToolContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/tool.interface.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"tool.interface.js","sourceRoot":"","sources":["../../../../src/common/interfaces/tool.interface.ts"],"names":[],"mappings":";;;AAIA,qDAA+C;AAG/C,+EAA+F;AAiB/F,MAAsB,WAKpB,SAAQ,kDAAyB;IACd,MAAM,CAAS;IACf,QAAQ,CAAS;IAC3B,QAAQ,CAAe;IAEhC,uCAAuC;IAC/B,SAAS,CAAqB;IAC9B,MAAM,CAAM;IAEpB,wCAAwC;IAChC,YAAY,CAAsB;IAClC,OAAO,CAAO;IAEtB,iBAAiB;IACA,aAAa,GAAuB,EAAE,CAAC;IACvC,cAAc,GAAwB,EAAE,CAAC;IAE1D,YAAY,IAAsB;QAChC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACpD,KAAK,CAAC;YACJ,SAAS;YACT,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC5D,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAID,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAY,CAAC;IAC3B,CAAC;IAED,IAAW,KAAK,CAAC,CAAiB;QAChC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YACtB,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,KAAK,EAAE,IAAI,CAAC,WAAW;YACvB,KAAK,EAAE,CAAC;SACT,CAAC,CAAC;IACL,CAAC;IAED,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAW,MAAM,CAAC,CAAkB;QAClC,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,KAAU;QAChB,iEAAiE;QACjE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,4BAAW,CAAC,OAAO,CAAM,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,+CAA+C;IAC/C,yBAAyB;IACzB,+CAA+C;IAE/C;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,QAAQ;QACV,kFAAkF;QAClF,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,YAAY,CAAC;QACrE,IAAI,eAAe,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YACrD,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,qFAAqF;QACrF,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC1C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAI,UAAU;QACZ,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC1C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;CACF;AAnID,kCAmIC","sourcesContent":["import { FuncType, Type } from './base.interface';\nimport { ProviderRegistryInterface } from './internal';\nimport { ToolInputType, ToolMetadata, ToolOutputType } from '../metadata';\nimport { FrontMcpLogger } from './logger.interface';\nimport { FlowControl } from './flow.interface';\nimport { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';\nimport { ToolInputOf, ToolOutputOf } from '../decorators';\nimport { ExecutionContextBase, ExecutionContextBaseArgs } from './execution-context.interface';\nimport type { AIPlatformType, ClientInfo } from '../../notification';\n\nexport type ToolType<T = any> = Type<T> | FuncType<T>;\n\ntype HistoryEntry<T> = {\n at: number;\n stage?: string;\n value: T | undefined;\n note?: string;\n};\n\nexport type ToolCtorArgs<In> = ExecutionContextBaseArgs & {\n metadata: ToolMetadata;\n input: In;\n};\n\nexport abstract class ToolContext<\n InSchema extends ToolInputType = ToolInputType,\n OutSchema extends ToolOutputType = ToolOutputType,\n In = ToolInputOf<{ inputSchema: InSchema }>,\n Out = ToolOutputOf<{ outputSchema: OutSchema }>,\n> extends ExecutionContextBase<Out> {\n protected readonly toolId: string;\n protected readonly toolName: string;\n readonly metadata: ToolMetadata;\n\n // ---- INPUT storages (backing fields)\n private _rawInput?: Partial<In> | any;\n private _input?: In;\n\n // ---- OUTPUT storages (backing fields)\n private _outputDraft?: Partial<Out> | any;\n private _output?: Out;\n\n // ---- histories\n private readonly _inputHistory: HistoryEntry<In>[] = [];\n private readonly _outputHistory: HistoryEntry<Out>[] = [];\n\n constructor(args: ToolCtorArgs<In>) {\n const { metadata, input, providers, logger } = args;\n super({\n providers,\n logger: logger.child(`tool:${metadata.id ?? metadata.name}`),\n authInfo: args.authInfo,\n });\n this.toolName = metadata.name;\n this.toolId = metadata.id ?? metadata.name;\n this.metadata = metadata;\n this._input = input;\n }\n\n abstract execute(input: In): Promise<Out>;\n\n public get input(): In {\n return this._input as In;\n }\n\n public set input(v: In | undefined) {\n this._input = v;\n this._inputHistory.push({\n at: Date.now(),\n stage: this.activeStage,\n value: v,\n });\n }\n\n public get inputHistory(): ReadonlyArray<HistoryEntry<In>> {\n return this._inputHistory;\n }\n\n public get output(): Out | undefined {\n return this._output;\n }\n\n public set output(v: Out | 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<Out>> {\n return this._outputHistory;\n }\n\n respond(value: Out): never {\n // record validated output and surface the value via control flow\n this.output = value;\n FlowControl.respond<Out>(value);\n }\n\n // ============================================\n // Platform Detection API\n // ============================================\n\n /**\n * Get the detected AI platform type for the current session.\n * This is auto-detected from the client info during MCP initialization.\n *\n * Use this to customize tool responses (e.g., UI format) based on the calling platform.\n *\n * @returns The detected platform type, or 'unknown' if not detected\n * @example\n * ```typescript\n * async execute(input: Input): Promise<Output> {\n * const platform = this.platform;\n * if (platform === 'openai') {\n * // Return OpenAI-specific response format\n * }\n * // ...\n * }\n * ```\n */\n get platform(): AIPlatformType {\n // First check sessionIdPayload (detected from user-agent during session creation)\n const payloadPlatform = this.authInfo.sessionIdPayload?.platformType;\n if (payloadPlatform && payloadPlatform !== 'unknown') {\n return payloadPlatform;\n }\n\n // Fall back to notification service (detected from MCP clientInfo during initialize)\n const sessionId = this.authInfo.sessionId;\n if (!sessionId) {\n return 'unknown';\n }\n return this.scope.notifications.getPlatformType(sessionId);\n }\n\n /**\n * Get the client info (name and version) for the current session.\n * This is captured from the MCP initialize request.\n *\n * @returns The client info, or undefined if not available\n * @example\n * ```typescript\n * async execute(input: Input): Promise<Output> {\n * const client = this.clientInfo;\n * console.log(`Called by: ${client?.name} v${client?.version}`);\n * // ...\n * }\n * ```\n */\n get clientInfo(): ClientInfo | undefined {\n const sessionId = this.authInfo.sessionId;\n if (!sessionId) {\n return undefined;\n }\n return this.scope.notifications.getClientInfo(sessionId);\n }\n}\n"]}
|
|
@@ -11,12 +11,4 @@ export declare const frontMcpAdapterMetadataSchema: z.ZodObject<{
|
|
|
11
11
|
id: z.ZodOptional<z.ZodString>;
|
|
12
12
|
name: z.ZodString;
|
|
13
13
|
description: z.ZodOptional<z.ZodString>;
|
|
14
|
-
},
|
|
15
|
-
id: z.ZodOptional<z.ZodString>;
|
|
16
|
-
name: z.ZodString;
|
|
17
|
-
description: z.ZodOptional<z.ZodString>;
|
|
18
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
19
|
-
id: z.ZodOptional<z.ZodString>;
|
|
20
|
-
name: z.ZodString;
|
|
21
|
-
description: z.ZodOptional<z.ZodString>;
|
|
22
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
14
|
+
}, z.core.$loose>;
|