@frontmcp/sdk 0.6.0 → 0.6.2
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/{src/auth → auth}/instances/instance.local-primary-auth.d.ts +1 -1
- package/{src/auth → auth}/instances/instance.remote-primary-auth.d.ts +1 -1
- package/{src/auth → auth}/session/index.d.ts +1 -0
- package/auth/session/vercel-kv-session.store.d.ts +96 -0
- package/{src/common → common}/interfaces/internal/primary-auth-provider.interface.d.ts +1 -4
- package/{src/common → common}/metadata/front-mcp.metadata.d.ts +1779 -67
- package/{src/common → common}/metadata/prompt.metadata.d.ts +4 -0
- package/{src/common → common}/metadata/resource.metadata.d.ts +8 -0
- package/{src/common → common}/metadata/tool-ui.metadata.d.ts +2 -2
- package/{src/common → common}/metadata/tool.metadata.d.ts +4 -0
- package/{src/common → common}/schemas/http-output.schema.d.ts +24 -6
- package/common/types/options/auth/app-auth.schema.d.ts +275 -0
- package/common/types/options/auth/auth.interfaces.d.ts +461 -0
- package/common/types/options/auth/auth.schema.d.ts +284 -0
- package/common/types/options/auth/auth.utils.d.ts +32 -0
- package/common/types/options/auth/index.d.ts +16 -0
- package/common/types/options/auth/orchestrated.schema.d.ts +381 -0
- package/common/types/options/auth/public.schema.d.ts +42 -0
- package/common/types/options/auth/shared.schemas.d.ts +120 -0
- package/common/types/options/auth/transparent.schema.d.ts +56 -0
- package/common/types/options/auth/transport.deprecated.d.ts +63 -0
- package/{src/common → common}/types/options/index.d.ts +1 -1
- package/common/types/options/redis.options.d.ts +190 -0
- package/{src/common → common}/types/options/server-info.options.d.ts +4 -0
- package/{src/common → common}/types/options/transport.options.d.ts +74 -5
- package/{src/common → common}/utils/decide-request-intent.utils.d.ts +6 -7
- package/common/utils/global-config.utils.d.ts +36 -0
- package/{src/common → common}/utils/index.d.ts +1 -0
- package/{src/completion → completion}/flows/complete.flow.d.ts +6 -8
- package/{src/errors → errors}/index.d.ts +1 -1
- package/{src/errors → errors}/mcp.error.d.ts +9 -0
- package/esm/index.mjs +22664 -0
- package/esm/mcp-apps/index.mjs +723 -0
- package/esm/package.json +81 -0
- package/{src/front-mcp → front-mcp}/front-mcp.providers.d.ts +246 -38
- package/front-mcp/index.d.ts +2 -0
- package/{src/index.d.ts → index.d.ts} +1 -1
- package/index.js +22957 -0
- package/logger/logger.tokens.d.ts +1 -0
- package/{src/logging → logging}/flows/set-level.flow.d.ts +6 -8
- package/mcp-apps/index.js +799 -0
- package/package.json +37 -17
- package/{src/prompt → prompt}/flows/get-prompt.flow.d.ts +14 -8
- package/{src/prompt → prompt}/flows/prompts-list.flow.d.ts +8 -7
- package/{src/resource → resource}/flows/read-resource.flow.d.ts +8 -9
- package/{src/resource → resource}/flows/resource-templates-list.flow.d.ts +8 -7
- package/{src/resource → resource}/flows/resources-list.flow.d.ts +8 -7
- package/{src/resource → resource}/flows/subscribe-resource.flow.d.ts +6 -8
- package/{src/resource → resource}/flows/unsubscribe-resource.flow.d.ts +6 -8
- package/store/adapters/store.vercel-kv.adapter.d.ts +86 -0
- package/{src/store → store}/index.d.ts +2 -0
- package/store/store.factory.d.ts +86 -0
- package/{src/tool → tool}/flows/call-tool.flow.d.ts +18 -9
- package/{src/tool → tool}/flows/tools-list.flow.d.ts +9 -8
- package/{src/tool → tool}/ui/index.d.ts +4 -4
- package/{src/tool → tool}/ui/platform-adapters.d.ts +2 -2
- package/{src/tool → tool}/ui/template-helpers.d.ts +5 -7
- package/{src/tool → tool}/ui/ui-resource.handler.d.ts +1 -1
- package/{src/transport → transport}/mcp-handlers/complete-request.handler.d.ts +4 -15
- package/{src/transport → transport}/mcp-handlers/get-prompt-request.handler.d.ts +5 -15
- package/{src/transport → transport}/mcp-handlers/index.d.ts +67 -195
- package/{src/transport → transport}/mcp-handlers/list-prompts-request.handler.d.ts +5 -15
- package/{src/transport → transport}/mcp-handlers/list-resource-templates-request.handler.d.ts +5 -15
- package/{src/transport → transport}/mcp-handlers/list-resources-request.handler.d.ts +5 -15
- package/{src/transport → transport}/mcp-handlers/list-tools-request.handler.d.ts +5 -15
- package/{src/transport → transport}/mcp-handlers/logging-set-level-request.handler.d.ts +3 -14
- package/{src/transport → transport}/mcp-handlers/read-resource-request.handler.d.ts +4 -15
- package/{src/transport → transport}/mcp-handlers/subscribe-request.handler.d.ts +3 -14
- package/{src/transport → transport}/mcp-handlers/unsubscribe-request.handler.d.ts +3 -14
- package/{src/transport → transport}/transport.registry.d.ts +5 -1
- package/README.md +0 -460
- package/src/adapter/adapter.instance.js +0 -70
- package/src/adapter/adapter.instance.js.map +0 -1
- package/src/adapter/adapter.regsitry.js +0 -54
- package/src/adapter/adapter.regsitry.js.map +0 -1
- package/src/adapter/adapter.utils.js +0 -83
- package/src/adapter/adapter.utils.js.map +0 -1
- package/src/app/app.registry.js +0 -66
- package/src/app/app.registry.js.map +0 -1
- package/src/app/app.utils.js +0 -58
- package/src/app/app.utils.js.map +0 -1
- package/src/app/instances/app.local.instance.js +0 -67
- package/src/app/instances/app.local.instance.js.map +0 -1
- package/src/app/instances/app.remote.instance.js +0 -36
- package/src/app/instances/app.remote.instance.js.map +0 -1
- package/src/app/instances/index.js +0 -6
- package/src/app/instances/index.js.map +0 -1
- package/src/auth/auth.registry.js +0 -219
- package/src/auth/auth.registry.js.map +0 -1
- package/src/auth/auth.utils.js +0 -84
- package/src/auth/auth.utils.js.map +0 -1
- package/src/auth/authorization/authorization.class.js +0 -217
- package/src/auth/authorization/authorization.class.js.map +0 -1
- package/src/auth/authorization/authorization.types.js +0 -79
- package/src/auth/authorization/authorization.types.js.map +0 -1
- package/src/auth/authorization/index.js +0 -19
- package/src/auth/authorization/index.js.map +0 -1
- package/src/auth/authorization/orchestrated.authorization.js +0 -306
- package/src/auth/authorization/orchestrated.authorization.js.map +0 -1
- package/src/auth/authorization/public.authorization.js +0 -132
- package/src/auth/authorization/public.authorization.js.map +0 -1
- package/src/auth/authorization/transparent.authorization.js +0 -147
- package/src/auth/authorization/transparent.authorization.js.map +0 -1
- package/src/auth/consent/consent.types.js +0 -119
- package/src/auth/consent/consent.types.js.map +0 -1
- package/src/auth/consent/index.js +0 -13
- package/src/auth/consent/index.js.map +0 -1
- package/src/auth/detection/auth-provider-detection.js +0 -230
- package/src/auth/detection/auth-provider-detection.js.map +0 -1
- package/src/auth/detection/index.js +0 -15
- package/src/auth/detection/index.js.map +0 -1
- package/src/auth/flows/auth.verify.flow.js +0 -379
- package/src/auth/flows/auth.verify.flow.js.map +0 -1
- package/src/auth/flows/oauth.authorize.flow.js +0 -822
- package/src/auth/flows/oauth.authorize.flow.js.map +0 -1
- package/src/auth/flows/oauth.callback.flow.js +0 -357
- package/src/auth/flows/oauth.callback.flow.js.map +0 -1
- package/src/auth/flows/oauth.register.flow.js +0 -201
- package/src/auth/flows/oauth.register.flow.js.map +0 -1
- package/src/auth/flows/oauth.token.flow.js +0 -319
- package/src/auth/flows/oauth.token.flow.js.map +0 -1
- package/src/auth/flows/session.verify.flow.js +0 -304
- package/src/auth/flows/session.verify.flow.js.map +0 -1
- package/src/auth/flows/well-known.jwks.flow.js +0 -89
- package/src/auth/flows/well-known.jwks.flow.js.map +0 -1
- package/src/auth/flows/well-known.oauth-authorization-server.flow.js +0 -122
- package/src/auth/flows/well-known.oauth-authorization-server.flow.js.map +0 -1
- package/src/auth/flows/well-known.prm.flow.js +0 -106
- package/src/auth/flows/well-known.prm.flow.js.map +0 -1
- package/src/auth/instances/instance.local-primary-auth.js +0 -308
- package/src/auth/instances/instance.local-primary-auth.js.map +0 -1
- package/src/auth/instances/instance.remote-primary-auth.js +0 -49
- package/src/auth/instances/instance.remote-primary-auth.js.map +0 -1
- package/src/auth/jwks/dev-key-persistence.js +0 -219
- package/src/auth/jwks/dev-key-persistence.js.map +0 -1
- package/src/auth/jwks/index.js +0 -7
- package/src/auth/jwks/index.js.map +0 -1
- package/src/auth/jwks/jwks.service.js +0 -303
- package/src/auth/jwks/jwks.service.js.map +0 -1
- package/src/auth/jwks/jwks.types.js +0 -3
- package/src/auth/jwks/jwks.types.js.map +0 -1
- package/src/auth/jwks/jwks.utils.js +0 -32
- package/src/auth/jwks/jwks.utils.js.map +0 -1
- package/src/auth/machine-id.js +0 -32
- package/src/auth/machine-id.js.map +0 -1
- package/src/auth/oauth/flows/oauth.authorize.flow.js +0 -33
- package/src/auth/oauth/flows/oauth.authorize.flow.js.map +0 -1
- package/src/auth/oauth/flows/oauth.device-authorization.flow.js +0 -48
- package/src/auth/oauth/flows/oauth.device-authorization.flow.js.map +0 -1
- package/src/auth/oauth/flows/oauth.introspect.flow.js +0 -28
- package/src/auth/oauth/flows/oauth.introspect.flow.js.map +0 -1
- package/src/auth/oauth/flows/oauth.par.flow.js +0 -29
- package/src/auth/oauth/flows/oauth.par.flow.js.map +0 -1
- package/src/auth/oauth/flows/oauth.revoke.flow.js +0 -27
- package/src/auth/oauth/flows/oauth.revoke.flow.js.map +0 -1
- package/src/auth/oauth/flows/oauth.token.flow.js +0 -59
- package/src/auth/oauth/flows/oauth.token.flow.js.map +0 -1
- package/src/auth/oauth/flows/oauth.userinfo.flow.js +0 -24
- package/src/auth/oauth/flows/oauth.userinfo.flow.js.map +0 -1
- package/src/auth/oauth/flows/oidc.logout.flow.js +0 -20
- package/src/auth/oauth/flows/oidc.logout.flow.js.map +0 -1
- package/src/auth/session/authorization-vault.js +0 -817
- package/src/auth/session/authorization-vault.js.map +0 -1
- package/src/auth/session/authorization.store.js +0 -323
- package/src/auth/session/authorization.store.js.map +0 -1
- package/src/auth/session/encrypted-authorization-vault.js +0 -493
- package/src/auth/session/encrypted-authorization-vault.js.map +0 -1
- package/src/auth/session/index.js +0 -16
- package/src/auth/session/index.js.map +0 -1
- package/src/auth/session/record/session.base.js +0 -125
- package/src/auth/session/record/session.base.js.map +0 -1
- package/src/auth/session/record/session.stateful.js +0 -55
- package/src/auth/session/record/session.stateful.js.map +0 -1
- package/src/auth/session/record/session.stateless.js +0 -32
- package/src/auth/session/record/session.stateless.js.map +0 -1
- package/src/auth/session/record/session.transparent.js +0 -22
- package/src/auth/session/record/session.transparent.js.map +0 -1
- package/src/auth/session/redis-session.store.js +0 -204
- package/src/auth/session/redis-session.store.js.map +0 -1
- package/src/auth/session/session.crypto.js +0 -47
- package/src/auth/session/session.crypto.js.map +0 -1
- package/src/auth/session/session.schema.js +0 -13
- package/src/auth/session/session.schema.js.map +0 -1
- package/src/auth/session/session.service.js +0 -105
- package/src/auth/session/session.service.js.map +0 -1
- package/src/auth/session/session.transport.js +0 -20
- package/src/auth/session/session.transport.js.map +0 -1
- package/src/auth/session/session.types.js +0 -4
- package/src/auth/session/session.types.js.map +0 -1
- package/src/auth/session/token.refresh.js +0 -63
- package/src/auth/session/token.refresh.js.map +0 -1
- package/src/auth/session/token.store.js +0 -53
- package/src/auth/session/token.store.js.map +0 -1
- package/src/auth/session/token.vault.js +0 -54
- package/src/auth/session/token.vault.js.map +0 -1
- package/src/auth/session/transport-session.manager.js +0 -298
- package/src/auth/session/transport-session.manager.js.map +0 -1
- package/src/auth/session/transport-session.types.js +0 -111
- package/src/auth/session/transport-session.types.js.map +0 -1
- package/src/auth/session/utils/auth-token.utils.js +0 -57
- package/src/auth/session/utils/auth-token.utils.js.map +0 -1
- package/src/auth/session/utils/session-id.utils.js +0 -217
- package/src/auth/session/utils/session-id.utils.js.map +0 -1
- package/src/auth/session/utils/tiny-ttl-cache.js +0 -26
- package/src/auth/session/utils/tiny-ttl-cache.js.map +0 -1
- package/src/auth/session/vault-encryption.js +0 -263
- package/src/auth/session/vault-encryption.js.map +0 -1
- package/src/auth/ui/base-layout.js +0 -279
- package/src/auth/ui/base-layout.js.map +0 -1
- package/src/auth/ui/index.js +0 -34
- package/src/auth/ui/index.js.map +0 -1
- package/src/auth/ui/templates.js +0 -426
- package/src/auth/ui/templates.js.map +0 -1
- package/src/auth/utils/audience.validator.js +0 -196
- package/src/auth/utils/audience.validator.js.map +0 -1
- package/src/auth/utils/index.js +0 -7
- package/src/auth/utils/index.js.map +0 -1
- package/src/auth/utils/www-authenticate.utils.js +0 -183
- package/src/auth/utils/www-authenticate.utils.js.map +0 -1
- package/src/common/common.schema.js +0 -35
- package/src/common/common.schema.js.map +0 -1
- package/src/common/constants.js +0 -13
- package/src/common/constants.js.map +0 -1
- package/src/common/decorators/adapter.decorator.js +0 -20
- package/src/common/decorators/adapter.decorator.js.map +0 -1
- package/src/common/decorators/app.decorator.js +0 -44
- package/src/common/decorators/app.decorator.js.map +0 -1
- package/src/common/decorators/auth-provider.decorator.js +0 -20
- package/src/common/decorators/auth-provider.decorator.js.map +0 -1
- package/src/common/decorators/decorator-utils.js +0 -195
- package/src/common/decorators/decorator-utils.js.map +0 -1
- package/src/common/decorators/flow.decorator.js +0 -19
- package/src/common/decorators/flow.decorator.js.map +0 -1
- package/src/common/decorators/front-mcp.decorator.js +0 -67
- package/src/common/decorators/front-mcp.decorator.js.map +0 -1
- package/src/common/decorators/hook.decorator.js +0 -178
- package/src/common/decorators/hook.decorator.js.map +0 -1
- package/src/common/decorators/index.js +0 -16
- package/src/common/decorators/index.js.map +0 -1
- package/src/common/decorators/logger.decorator.js +0 -20
- package/src/common/decorators/logger.decorator.js.map +0 -1
- package/src/common/decorators/plugin.decorator.js +0 -39
- package/src/common/decorators/plugin.decorator.js.map +0 -1
- package/src/common/decorators/prompt.decorator.js +0 -38
- package/src/common/decorators/prompt.decorator.js.map +0 -1
- package/src/common/decorators/provider.decorator.js +0 -20
- package/src/common/decorators/provider.decorator.js.map +0 -1
- package/src/common/decorators/resource.decorator.js +0 -94
- package/src/common/decorators/resource.decorator.js.map +0 -1
- package/src/common/decorators/tool.decorator.js +0 -45
- package/src/common/decorators/tool.decorator.js.map +0 -1
- package/src/common/dynamic/dynamic.adapter.js +0 -28
- package/src/common/dynamic/dynamic.adapter.js.map +0 -1
- package/src/common/dynamic/dynamic.plugin.js +0 -42
- package/src/common/dynamic/dynamic.plugin.js.map +0 -1
- package/src/common/dynamic/dynamic.utils.js +0 -27
- package/src/common/dynamic/dynamic.utils.js.map +0 -1
- package/src/common/dynamic/index.js +0 -6
- package/src/common/dynamic/index.js.map +0 -1
- package/src/common/entries/adapter.entry.js +0 -8
- package/src/common/entries/adapter.entry.js.map +0 -1
- package/src/common/entries/app.entry.js +0 -9
- package/src/common/entries/app.entry.js.map +0 -1
- package/src/common/entries/auth-provider.entry.js +0 -8
- package/src/common/entries/auth-provider.entry.js.map +0 -1
- package/src/common/entries/base.entry.js +0 -17
- package/src/common/entries/base.entry.js.map +0 -1
- package/src/common/entries/flow.entry.js +0 -21
- package/src/common/entries/flow.entry.js.map +0 -1
- package/src/common/entries/hook.entry.js +0 -20
- package/src/common/entries/hook.entry.js.map +0 -1
- package/src/common/entries/index.js +0 -17
- package/src/common/entries/index.js.map +0 -1
- package/src/common/entries/logger.entry.js +0 -8
- package/src/common/entries/logger.entry.js.map +0 -1
- package/src/common/entries/plugin.entry.js +0 -8
- package/src/common/entries/plugin.entry.js.map +0 -1
- package/src/common/entries/prompt.entry.js +0 -18
- package/src/common/entries/prompt.entry.js.map +0 -1
- package/src/common/entries/provider.entry.js +0 -8
- package/src/common/entries/provider.entry.js.map +0 -1
- package/src/common/entries/resource.entry.js +0 -35
- package/src/common/entries/resource.entry.js.map +0 -1
- package/src/common/entries/scope.entry.js +0 -14
- package/src/common/entries/scope.entry.js.map +0 -1
- package/src/common/entries/tool.entry.js +0 -31
- package/src/common/entries/tool.entry.js.map +0 -1
- package/src/common/flow/flow.utils.js +0 -96
- package/src/common/flow/flow.utils.js.map +0 -1
- package/src/common/index.js +0 -20
- package/src/common/index.js.map +0 -1
- package/src/common/interfaces/adapter.interface.js +0 -3
- package/src/common/interfaces/adapter.interface.js.map +0 -1
- package/src/common/interfaces/app.interface.js +0 -3
- package/src/common/interfaces/app.interface.js.map +0 -1
- package/src/common/interfaces/auth-hook.interface.js +0 -135
- package/src/common/interfaces/auth-hook.interface.js.map +0 -1
- package/src/common/interfaces/auth-provider.interface.js +0 -18
- package/src/common/interfaces/auth-provider.interface.js.map +0 -1
- package/src/common/interfaces/base.interface.js +0 -3
- package/src/common/interfaces/base.interface.js.map +0 -1
- package/src/common/interfaces/execution-context.interface.js +0 -166
- package/src/common/interfaces/execution-context.interface.js.map +0 -1
- package/src/common/interfaces/flow.interface.js +0 -95
- package/src/common/interfaces/flow.interface.js.map +0 -1
- package/src/common/interfaces/front-mcp.interface.js +0 -3
- package/src/common/interfaces/front-mcp.interface.js.map +0 -1
- package/src/common/interfaces/hook.interface.js +0 -3
- package/src/common/interfaces/hook.interface.js.map +0 -1
- package/src/common/interfaces/index.js +0 -21
- package/src/common/interfaces/index.js.map +0 -1
- package/src/common/interfaces/internal/flow.utils.js +0 -83
- package/src/common/interfaces/internal/flow.utils.js.map +0 -1
- package/src/common/interfaces/internal/index.js +0 -7
- package/src/common/interfaces/internal/index.js.map +0 -1
- package/src/common/interfaces/internal/primary-auth-provider.interface.js +0 -81
- package/src/common/interfaces/internal/primary-auth-provider.interface.js.map +0 -1
- package/src/common/interfaces/internal/registry.interface.js +0 -3
- package/src/common/interfaces/internal/registry.interface.js.map +0 -1
- package/src/common/interfaces/logger.interface.js +0 -10
- package/src/common/interfaces/logger.interface.js.map +0 -1
- package/src/common/interfaces/plugin.interface.js +0 -3
- package/src/common/interfaces/plugin.interface.js.map +0 -1
- package/src/common/interfaces/prompt.interface.js +0 -81
- package/src/common/interfaces/prompt.interface.js.map +0 -1
- package/src/common/interfaces/provider.interface.js +0 -18
- package/src/common/interfaces/provider.interface.js.map +0 -1
- package/src/common/interfaces/resource.interface.js +0 -56
- package/src/common/interfaces/resource.interface.js.map +0 -1
- package/src/common/interfaces/scope.interface.js +0 -3
- package/src/common/interfaces/scope.interface.js.map +0 -1
- package/src/common/interfaces/server.interface.js +0 -18
- package/src/common/interfaces/server.interface.js.map +0 -1
- package/src/common/interfaces/session-hook.interface.js +0 -140
- package/src/common/interfaces/session-hook.interface.js.map +0 -1
- package/src/common/interfaces/tool-hook.interface.js +0 -92
- package/src/common/interfaces/tool-hook.interface.js.map +0 -1
- package/src/common/interfaces/tool.interface.js +0 -117
- package/src/common/interfaces/tool.interface.js.map +0 -1
- package/src/common/metadata/adapter.metadata.js +0 -10
- package/src/common/metadata/adapter.metadata.js.map +0 -1
- package/src/common/metadata/app.metadata.js +0 -30
- package/src/common/metadata/app.metadata.js.map +0 -1
- package/src/common/metadata/auth-provider.metadata.js +0 -19
- package/src/common/metadata/auth-provider.metadata.js.map +0 -1
- package/src/common/metadata/flow.metadata.js +0 -15
- package/src/common/metadata/flow.metadata.js.map +0 -1
- package/src/common/metadata/front-mcp.metadata.js +0 -29
- package/src/common/metadata/front-mcp.metadata.js.map +0 -1
- package/src/common/metadata/hook.metadata.js +0 -3
- package/src/common/metadata/hook.metadata.js.map +0 -1
- package/src/common/metadata/index.js +0 -17
- package/src/common/metadata/index.js.map +0 -1
- package/src/common/metadata/logger.metadata.js +0 -10
- package/src/common/metadata/logger.metadata.js.map +0 -1
- package/src/common/metadata/plugin.metadata.js +0 -18
- package/src/common/metadata/plugin.metadata.js.map +0 -1
- package/src/common/metadata/prompt.metadata.js +0 -27
- package/src/common/metadata/prompt.metadata.js.map +0 -1
- package/src/common/metadata/provider.metadata.js +0 -36
- package/src/common/metadata/provider.metadata.js.map +0 -1
- package/src/common/metadata/resource.metadata.js +0 -31
- package/src/common/metadata/resource.metadata.js.map +0 -1
- package/src/common/metadata/tool-ui.metadata.js +0 -12
- package/src/common/metadata/tool-ui.metadata.js.map +0 -1
- package/src/common/metadata/tool.metadata.js +0 -55
- package/src/common/metadata/tool.metadata.js.map +0 -1
- package/src/common/migrate/auth-transport.migrate.js +0 -140
- package/src/common/migrate/auth-transport.migrate.js.map +0 -1
- package/src/common/migrate/index.js +0 -6
- package/src/common/migrate/index.js.map +0 -1
- package/src/common/providers/base-config.provider.js +0 -128
- package/src/common/providers/base-config.provider.js.map +0 -1
- package/src/common/records/adapter.record.js +0 -11
- package/src/common/records/adapter.record.js.map +0 -1
- package/src/common/records/app.record.js +0 -9
- package/src/common/records/app.record.js.map +0 -1
- package/src/common/records/auth-provider.record.js +0 -12
- package/src/common/records/auth-provider.record.js.map +0 -1
- package/src/common/records/flow.record.js +0 -8
- package/src/common/records/flow.record.js.map +0 -1
- package/src/common/records/hook.record.js +0 -8
- package/src/common/records/hook.record.js.map +0 -1
- package/src/common/records/index.js +0 -16
- package/src/common/records/index.js.map +0 -1
- package/src/common/records/logger.record.js +0 -8
- package/src/common/records/logger.record.js.map +0 -1
- package/src/common/records/plugin.record.js +0 -11
- package/src/common/records/plugin.record.js.map +0 -1
- package/src/common/records/prompt.record.js +0 -9
- package/src/common/records/prompt.record.js.map +0 -1
- package/src/common/records/provider.record.js +0 -14
- package/src/common/records/provider.record.js.map +0 -1
- package/src/common/records/resource.record.js +0 -20
- package/src/common/records/resource.record.js.map +0 -1
- package/src/common/records/scope.record.js +0 -9
- package/src/common/records/scope.record.js.map +0 -1
- package/src/common/records/tool.record.js +0 -9
- package/src/common/records/tool.record.js.map +0 -1
- package/src/common/schemas/annotated-class.schema.js +0 -109
- package/src/common/schemas/annotated-class.schema.js.map +0 -1
- package/src/common/schemas/http-input.schema.js +0 -13
- package/src/common/schemas/http-input.schema.js.map +0 -1
- package/src/common/schemas/http-output.schema.js +0 -321
- package/src/common/schemas/http-output.schema.js.map +0 -1
- package/src/common/schemas/index.js +0 -8
- package/src/common/schemas/index.js.map +0 -1
- package/src/common/schemas/session-header.schema.js +0 -42
- package/src/common/schemas/session-header.schema.js.map +0 -1
- package/src/common/tokens/adapter.tokens.js +0 -11
- package/src/common/tokens/adapter.tokens.js.map +0 -1
- package/src/common/tokens/app.tokens.js +0 -30
- package/src/common/tokens/app.tokens.js.map +0 -1
- package/src/common/tokens/auth-provider.tokens.js +0 -12
- package/src/common/tokens/auth-provider.tokens.js.map +0 -1
- package/src/common/tokens/base.tokens.js +0 -9
- package/src/common/tokens/base.tokens.js.map +0 -1
- package/src/common/tokens/flow-hook.tokens.js +0 -9
- package/src/common/tokens/flow-hook.tokens.js.map +0 -1
- package/src/common/tokens/flow.tokens.js +0 -16
- package/src/common/tokens/flow.tokens.js.map +0 -1
- package/src/common/tokens/front-mcp.tokens.js +0 -24
- package/src/common/tokens/front-mcp.tokens.js.map +0 -1
- package/src/common/tokens/index.js +0 -17
- package/src/common/tokens/index.js.map +0 -1
- package/src/common/tokens/logger.tokens.js +0 -11
- package/src/common/tokens/logger.tokens.js.map +0 -1
- package/src/common/tokens/plugin.tokens.js +0 -18
- package/src/common/tokens/plugin.tokens.js.map +0 -1
- package/src/common/tokens/prompt.tokens.js +0 -14
- package/src/common/tokens/prompt.tokens.js.map +0 -1
- package/src/common/tokens/provider.tokens.js +0 -12
- package/src/common/tokens/provider.tokens.js.map +0 -1
- package/src/common/tokens/resource.tokens.js +0 -28
- package/src/common/tokens/resource.tokens.js.map +0 -1
- package/src/common/tokens/server.tokens.js +0 -11
- package/src/common/tokens/server.tokens.js.map +0 -1
- package/src/common/tokens/tool.tokens.js +0 -21
- package/src/common/tokens/tool.tokens.js.map +0 -1
- package/src/common/types/auth/index.js +0 -6
- package/src/common/types/auth/index.js.map +0 -1
- package/src/common/types/auth/jwt.types.js +0 -36
- package/src/common/types/auth/jwt.types.js.map +0 -1
- package/src/common/types/auth/session.types.js +0 -53
- package/src/common/types/auth/session.types.js.map +0 -1
- package/src/common/types/common.types.js +0 -3
- package/src/common/types/common.types.js.map +0 -1
- package/src/common/types/index.js +0 -7
- package/src/common/types/index.js.map +0 -1
- package/src/common/types/options/auth.options.d.ts +0 -1266
- package/src/common/types/options/auth.options.js +0 -560
- package/src/common/types/options/auth.options.js.map +0 -1
- package/src/common/types/options/http.options.js +0 -10
- package/src/common/types/options/http.options.js.map +0 -1
- package/src/common/types/options/index.js +0 -11
- package/src/common/types/options/index.js.map +0 -1
- package/src/common/types/options/logging.options.js +0 -33
- package/src/common/types/options/logging.options.js.map +0 -1
- package/src/common/types/options/redis.options.d.ts +0 -22
- package/src/common/types/options/redis.options.js +0 -45
- package/src/common/types/options/redis.options.js.map +0 -1
- package/src/common/types/options/server-info.options.js +0 -13
- package/src/common/types/options/server-info.options.js.map +0 -1
- package/src/common/types/options/session.options.js +0 -32
- package/src/common/types/options/session.options.js.map +0 -1
- package/src/common/types/options/transport.options.js +0 -121
- package/src/common/types/options/transport.options.js.map +0 -1
- package/src/common/utils/decide-request-intent.utils.js +0 -391
- package/src/common/utils/decide-request-intent.utils.js.map +0 -1
- package/src/common/utils/index.js +0 -6
- package/src/common/utils/index.js.map +0 -1
- package/src/common/utils/path.utils.js +0 -66
- package/src/common/utils/path.utils.js.map +0 -1
- package/src/completion/flows/complete.flow.js +0 -199
- package/src/completion/flows/complete.flow.js.map +0 -1
- package/src/context/frontmcp-context-storage.js +0 -183
- package/src/context/frontmcp-context-storage.js.map +0 -1
- package/src/context/frontmcp-context.js +0 -360
- package/src/context/frontmcp-context.js.map +0 -1
- package/src/context/frontmcp-context.provider.js +0 -61
- package/src/context/frontmcp-context.provider.js.map +0 -1
- package/src/context/index.js +0 -64
- package/src/context/index.js.map +0 -1
- package/src/context/request-context-storage.js +0 -183
- package/src/context/request-context-storage.js.map +0 -1
- package/src/context/request-context.js +0 -209
- package/src/context/request-context.js.map +0 -1
- package/src/context/request-context.provider.js +0 -51
- package/src/context/request-context.provider.js.map +0 -1
- package/src/context/session-key.provider.js +0 -65
- package/src/context/session-key.provider.js.map +0 -1
- package/src/context/trace-context.js +0 -142
- package/src/context/trace-context.js.map +0 -1
- package/src/errors/authorization-required.error.js +0 -274
- package/src/errors/authorization-required.error.js.map +0 -1
- package/src/errors/error-handler.js +0 -107
- package/src/errors/error-handler.js.map +0 -1
- package/src/errors/index.js +0 -44
- package/src/errors/index.js.map +0 -1
- package/src/errors/mcp.error.js +0 -398
- package/src/errors/mcp.error.js.map +0 -1
- package/src/exceptions/mcp-exceptions/session-missing.exception.js +0 -11
- package/src/exceptions/mcp-exceptions/session-missing.exception.js.map +0 -1
- package/src/exceptions/mcp-exceptions/unsupported-client-version.exception.js +0 -15
- package/src/exceptions/mcp-exceptions/unsupported-client-version.exception.js.map +0 -1
- package/src/flows/flow.instance.js +0 -420
- package/src/flows/flow.instance.js.map +0 -1
- package/src/flows/flow.registry.js +0 -121
- package/src/flows/flow.registry.js.map +0 -1
- package/src/flows/flow.stages.js +0 -113
- package/src/flows/flow.stages.js.map +0 -1
- package/src/flows/flow.utils.js +0 -36
- package/src/flows/flow.utils.js.map +0 -1
- package/src/front-mcp/front-mcp.js +0 -63
- package/src/front-mcp/front-mcp.js.map +0 -1
- package/src/front-mcp/front-mcp.providers.js +0 -29
- package/src/front-mcp/front-mcp.providers.js.map +0 -1
- package/src/front-mcp/front-mcp.tokens.js +0 -5
- package/src/front-mcp/front-mcp.tokens.js.map +0 -1
- package/src/front-mcp/index.d.ts +0 -1
- package/src/front-mcp/index.js +0 -5
- package/src/front-mcp/index.js.map +0 -1
- package/src/front-mcp/serverless-handler.js +0 -61
- package/src/front-mcp/serverless-handler.js.map +0 -1
- package/src/hooks/hook.instance.js +0 -26
- package/src/hooks/hook.instance.js.map +0 -1
- package/src/hooks/hook.registry.js +0 -152
- package/src/hooks/hook.registry.js.map +0 -1
- package/src/hooks/hooks.utils.js +0 -34
- package/src/hooks/hooks.utils.js.map +0 -1
- package/src/index.js +0 -36
- package/src/index.js.map +0 -1
- package/src/logger/instances/instance.console-logger.js +0 -75
- package/src/logger/instances/instance.console-logger.js.map +0 -1
- package/src/logger/instances/instance.logger.js +0 -77
- package/src/logger/instances/instance.logger.js.map +0 -1
- package/src/logger/logger.registry.js +0 -96
- package/src/logger/logger.registry.js.map +0 -1
- package/src/logger/logger.tokens.js +0 -3
- package/src/logger/logger.tokens.js.map +0 -1
- package/src/logger/logger.types.js +0 -8
- package/src/logger/logger.types.js.map +0 -1
- package/src/logger/logger.utils.js +0 -42
- package/src/logger/logger.utils.js.map +0 -1
- package/src/logging/flows/set-level.flow.js +0 -108
- package/src/logging/flows/set-level.flow.js.map +0 -1
- package/src/mcp-apps/csp.js +0 -267
- package/src/mcp-apps/csp.js.map +0 -1
- package/src/mcp-apps/index.js +0 -91
- package/src/mcp-apps/index.js.map +0 -1
- package/src/mcp-apps/schemas.js +0 -345
- package/src/mcp-apps/schemas.js.map +0 -1
- package/src/mcp-apps/template.js +0 -419
- package/src/mcp-apps/template.js.map +0 -1
- package/src/mcp-apps/types.js +0 -59
- package/src/mcp-apps/types.js.map +0 -1
- package/src/notification/index.js +0 -13
- package/src/notification/index.js.map +0 -1
- package/src/notification/notification.service.js +0 -731
- package/src/notification/notification.service.js.map +0 -1
- package/src/plugin/plugin.registry.js +0 -152
- package/src/plugin/plugin.registry.js.map +0 -1
- package/src/plugin/plugin.utils.js +0 -88
- package/src/plugin/plugin.utils.js.map +0 -1
- package/src/prompt/flows/get-prompt.flow.js +0 -214
- package/src/prompt/flows/get-prompt.flow.js.map +0 -1
- package/src/prompt/flows/prompts-list.flow.js +0 -176
- package/src/prompt/flows/prompts-list.flow.js.map +0 -1
- package/src/prompt/index.js +0 -17
- package/src/prompt/index.js.map +0 -1
- package/src/prompt/prompt.events.js +0 -25
- package/src/prompt/prompt.events.js.map +0 -1
- package/src/prompt/prompt.instance.js +0 -120
- package/src/prompt/prompt.instance.js.map +0 -1
- package/src/prompt/prompt.registry.js +0 -380
- package/src/prompt/prompt.registry.js.map +0 -1
- package/src/prompt/prompt.types.js +0 -11
- package/src/prompt/prompt.types.js.map +0 -1
- package/src/prompt/prompt.utils.js +0 -136
- package/src/prompt/prompt.utils.js.map +0 -1
- package/src/provider/provider.registry.js +0 -868
- package/src/provider/provider.registry.js.map +0 -1
- package/src/provider/provider.types.js +0 -3
- package/src/provider/provider.types.js.map +0 -1
- package/src/provider/provider.utils.js +0 -103
- package/src/provider/provider.utils.js.map +0 -1
- package/src/regsitry/index.js +0 -5
- package/src/regsitry/index.js.map +0 -1
- package/src/regsitry/registry.base.js +0 -32
- package/src/regsitry/registry.base.js.map +0 -1
- package/src/resource/flows/read-resource.flow.js +0 -270
- package/src/resource/flows/read-resource.flow.js.map +0 -1
- package/src/resource/flows/resource-templates-list.flow.js +0 -191
- package/src/resource/flows/resource-templates-list.flow.js.map +0 -1
- package/src/resource/flows/resources-list.flow.js +0 -196
- package/src/resource/flows/resources-list.flow.js.map +0 -1
- package/src/resource/flows/subscribe-resource.flow.js +0 -123
- package/src/resource/flows/subscribe-resource.flow.js.map +0 -1
- package/src/resource/flows/unsubscribe-resource.flow.js +0 -107
- package/src/resource/flows/unsubscribe-resource.flow.js.map +0 -1
- package/src/resource/index.js +0 -20
- package/src/resource/index.js.map +0 -1
- package/src/resource/resource.events.js +0 -17
- package/src/resource/resource.events.js.map +0 -1
- package/src/resource/resource.instance.js +0 -163
- package/src/resource/resource.instance.js.map +0 -1
- package/src/resource/resource.registry.js +0 -468
- package/src/resource/resource.registry.js.map +0 -1
- package/src/resource/resource.types.js +0 -11
- package/src/resource/resource.types.js.map +0 -1
- package/src/resource/resource.utils.js +0 -151
- package/src/resource/resource.utils.js.map +0 -1
- package/src/scope/flows/http.request.flow.js +0 -474
- package/src/scope/flows/http.request.flow.js.map +0 -1
- package/src/scope/index.js +0 -6
- package/src/scope/index.js.map +0 -1
- package/src/scope/scope.instance.js +0 -263
- package/src/scope/scope.instance.js.map +0 -1
- package/src/scope/scope.registry.js +0 -94
- package/src/scope/scope.registry.js.map +0 -1
- package/src/scope/scope.utils.js +0 -61
- package/src/scope/scope.utils.js.map +0 -1
- package/src/server/adapters/base.host.adapter.js +0 -8
- package/src/server/adapters/base.host.adapter.js.map +0 -1
- package/src/server/adapters/express.host.adapter.js +0 -70
- package/src/server/adapters/express.host.adapter.js.map +0 -1
- package/src/server/server.instance.js +0 -54
- package/src/server/server.instance.js.map +0 -1
- package/src/server/server.types.js +0 -3
- package/src/server/server.types.js.map +0 -1
- package/src/server/server.validation.js +0 -192
- package/src/server/server.validation.js.map +0 -1
- package/src/store/adapters/store.base.adapter.js +0 -16
- package/src/store/adapters/store.base.adapter.js.map +0 -1
- package/src/store/adapters/store.memory.adapter.js +0 -89
- package/src/store/adapters/store.memory.adapter.js.map +0 -1
- package/src/store/adapters/store.redis.adapter.js +0 -104
- package/src/store/adapters/store.redis.adapter.js.map +0 -1
- package/src/store/index.js +0 -12
- package/src/store/index.js.map +0 -1
- package/src/store/store.helpers.js +0 -67
- package/src/store/store.helpers.js.map +0 -1
- package/src/store/store.registry.js +0 -37
- package/src/store/store.registry.js.map +0 -1
- package/src/store/store.tokens.js +0 -7
- package/src/store/store.tokens.js.map +0 -1
- package/src/store/store.types.js +0 -11
- package/src/store/store.types.js.map +0 -1
- package/src/store/store.utils.js +0 -18
- package/src/store/store.utils.js.map +0 -1
- package/src/tool/flows/call-tool.flow.js +0 -616
- package/src/tool/flows/call-tool.flow.js.map +0 -1
- package/src/tool/flows/tools-list.flow.js +0 -328
- package/src/tool/flows/tools-list.flow.js.map +0 -1
- package/src/tool/tool.events.js +0 -16
- package/src/tool/tool.events.js.map +0 -1
- package/src/tool/tool.instance.js +0 -117
- package/src/tool/tool.instance.js.map +0 -1
- package/src/tool/tool.registry.js +0 -353
- package/src/tool/tool.registry.js.map +0 -1
- package/src/tool/tool.types.js +0 -10
- package/src/tool/tool.types.js.map +0 -1
- package/src/tool/tool.utils.js +0 -366
- package/src/tool/tool.utils.js.map +0 -1
- package/src/tool/ui/index.js +0 -63
- package/src/tool/ui/index.js.map +0 -1
- package/src/tool/ui/platform-adapters.js +0 -18
- package/src/tool/ui/platform-adapters.js.map +0 -1
- package/src/tool/ui/template-helpers.js +0 -112
- package/src/tool/ui/template-helpers.js.map +0 -1
- package/src/tool/ui/ui-resource-template.js +0 -64
- package/src/tool/ui/ui-resource-template.js.map +0 -1
- package/src/tool/ui/ui-resource.handler.js +0 -129
- package/src/tool/ui/ui-resource.handler.js.map +0 -1
- package/src/transport/adapters/transport.local.adapter.js +0 -148
- package/src/transport/adapters/transport.local.adapter.js.map +0 -1
- package/src/transport/adapters/transport.sse.adapter.js +0 -65
- package/src/transport/adapters/transport.sse.adapter.js.map +0 -1
- package/src/transport/adapters/transport.streamable-http.adapter.js +0 -112
- package/src/transport/adapters/transport.streamable-http.adapter.js.map +0 -1
- package/src/transport/flows/handle.sse.flow.js +0 -197
- package/src/transport/flows/handle.sse.flow.js.map +0 -1
- package/src/transport/flows/handle.stateless-http.flow.js +0 -102
- package/src/transport/flows/handle.stateless-http.flow.js.map +0 -1
- package/src/transport/flows/handle.streamable-http.flow.js +0 -315
- package/src/transport/flows/handle.streamable-http.flow.js.map +0 -1
- package/src/transport/legacy/legacy.sse.tranporter.js +0 -185
- package/src/transport/legacy/legacy.sse.tranporter.js.map +0 -1
- package/src/transport/mcp-handlers/Initialized-notification.hanlder.js +0 -14
- package/src/transport/mcp-handlers/Initialized-notification.hanlder.js.map +0 -1
- package/src/transport/mcp-handlers/call-tool-request.handler.js +0 -46
- package/src/transport/mcp-handlers/call-tool-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/complete-request.handler.js +0 -11
- package/src/transport/mcp-handlers/complete-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/get-prompt-request.handler.js +0 -11
- package/src/transport/mcp-handlers/get-prompt-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/index.js +0 -57
- package/src/transport/mcp-handlers/index.js.map +0 -1
- package/src/transport/mcp-handlers/initialize-request.handler.js +0 -109
- package/src/transport/mcp-handlers/initialize-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/list-prompts-request.handler.js +0 -11
- package/src/transport/mcp-handlers/list-prompts-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.js +0 -12
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/list-resources-request.handler.js +0 -12
- package/src/transport/mcp-handlers/list-resources-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/list-tools-request.handler.js +0 -11
- package/src/transport/mcp-handlers/list-tools-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/logging-set-level-request.handler.js +0 -34
- package/src/transport/mcp-handlers/logging-set-level-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/mcp-handlers.types.js +0 -3
- package/src/transport/mcp-handlers/mcp-handlers.types.js.map +0 -1
- package/src/transport/mcp-handlers/read-resource-request.handler.js +0 -12
- package/src/transport/mcp-handlers/read-resource-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.js +0 -26
- package/src/transport/mcp-handlers/roots-list-changed-notification.handler.js.map +0 -1
- package/src/transport/mcp-handlers/subscribe-request.handler.js +0 -34
- package/src/transport/mcp-handlers/subscribe-request.handler.js.map +0 -1
- package/src/transport/mcp-handlers/unsubscribe-request.handler.js +0 -34
- package/src/transport/mcp-handlers/unsubscribe-request.handler.js.map +0 -1
- package/src/transport/transport.error.js +0 -25
- package/src/transport/transport.error.js.map +0 -1
- package/src/transport/transport.event-store.js +0 -36
- package/src/transport/transport.event-store.js.map +0 -1
- package/src/transport/transport.local.js +0 -71
- package/src/transport/transport.local.js.map +0 -1
- package/src/transport/transport.registry.js +0 -523
- package/src/transport/transport.registry.js.map +0 -1
- package/src/transport/transport.remote.js +0 -31
- package/src/transport/transport.remote.js.map +0 -1
- package/src/transport/transport.types.js +0 -3
- package/src/transport/transport.types.js.map +0 -1
- package/src/types/drinen-hooks.types.js +0 -3
- package/src/types/drinen-hooks.types.js.map +0 -1
- package/src/types/invoke.type.js +0 -34
- package/src/types/invoke.type.js.map +0 -1
- package/src/types/token.types.js +0 -3
- package/src/types/token.types.js.map +0 -1
- package/src/utils/content.utils.js +0 -194
- package/src/utils/content.utils.js.map +0 -1
- package/src/utils/index.js +0 -55
- package/src/utils/index.js.map +0 -1
- package/src/utils/lineage.utils.js +0 -82
- package/src/utils/lineage.utils.js.map +0 -1
- package/src/utils/metadata.utils.js +0 -26
- package/src/utils/metadata.utils.js.map +0 -1
- package/src/utils/naming.utils.js +0 -136
- package/src/utils/naming.utils.js.map +0 -1
- package/src/utils/server.utils.js +0 -59
- package/src/utils/server.utils.js.map +0 -1
- package/src/utils/string.utils.js +0 -10
- package/src/utils/string.utils.js.map +0 -1
- package/src/utils/token.utils.js +0 -65
- package/src/utils/token.utils.js.map +0 -1
- package/src/utils/types.utils.js +0 -3
- package/src/utils/types.utils.js.map +0 -1
- package/src/utils/uri-template.utils.js +0 -113
- package/src/utils/uri-template.utils.js.map +0 -1
- package/src/utils/uri-validation.utils.js +0 -76
- package/src/utils/uri-validation.utils.js.map +0 -1
- package/{src/adapter → adapter}/adapter.instance.d.ts +0 -0
- package/{src/adapter → adapter}/adapter.regsitry.d.ts +0 -0
- package/{src/adapter → adapter}/adapter.utils.d.ts +0 -0
- package/{src/app → app}/app.registry.d.ts +0 -0
- package/{src/app → app}/app.utils.d.ts +0 -0
- package/{src/app → app}/instances/app.local.instance.d.ts +0 -0
- package/{src/app → app}/instances/app.remote.instance.d.ts +0 -0
- package/{src/app → app}/instances/index.d.ts +0 -0
- package/{src/auth → auth}/auth.registry.d.ts +0 -0
- package/{src/auth → auth}/auth.utils.d.ts +0 -0
- package/{src/auth → auth}/authorization/authorization.class.d.ts +0 -0
- package/{src/auth → auth}/authorization/authorization.types.d.ts +0 -0
- package/{src/auth → auth}/authorization/index.d.ts +0 -0
- package/{src/auth → auth}/authorization/orchestrated.authorization.d.ts +0 -0
- package/{src/auth → auth}/authorization/public.authorization.d.ts +0 -0
- package/{src/auth → auth}/authorization/transparent.authorization.d.ts +0 -0
- package/{src/auth → auth}/consent/consent.types.d.ts +0 -0
- package/{src/auth → auth}/consent/index.d.ts +0 -0
- package/{src/auth → auth}/detection/auth-provider-detection.d.ts +0 -0
- package/{src/auth → auth}/detection/index.d.ts +0 -0
- package/{src/auth → auth}/flows/auth.verify.flow.d.ts +0 -0
- package/{src/auth → auth}/flows/oauth.authorize.flow.d.ts +0 -0
- package/{src/auth → auth}/flows/oauth.callback.flow.d.ts +0 -0
- package/{src/auth → auth}/flows/oauth.register.flow.d.ts +0 -0
- package/{src/auth → auth}/flows/oauth.token.flow.d.ts +0 -0
- package/{src/auth → auth}/flows/session.verify.flow.d.ts +0 -0
- package/{src/auth → auth}/flows/well-known.jwks.flow.d.ts +0 -0
- package/{src/auth → auth}/flows/well-known.oauth-authorization-server.flow.d.ts +0 -0
- package/{src/auth → auth}/flows/well-known.prm.flow.d.ts +0 -0
- package/{src/auth → auth}/jwks/dev-key-persistence.d.ts +0 -0
- package/{src/auth → auth}/jwks/index.d.ts +0 -0
- package/{src/auth → auth}/jwks/jwks.service.d.ts +0 -0
- package/{src/auth → auth}/jwks/jwks.types.d.ts +0 -0
- package/{src/auth → auth}/jwks/jwks.utils.d.ts +0 -0
- package/{src/auth → auth}/machine-id.d.ts +0 -0
- package/{src/auth → auth}/oauth/flows/oauth.authorize.flow.d.ts +0 -0
- package/{src/auth → auth}/oauth/flows/oauth.device-authorization.flow.d.ts +0 -0
- package/{src/auth → auth}/oauth/flows/oauth.introspect.flow.d.ts +0 -0
- package/{src/auth → auth}/oauth/flows/oauth.par.flow.d.ts +0 -0
- package/{src/auth → auth}/oauth/flows/oauth.revoke.flow.d.ts +0 -0
- package/{src/auth → auth}/oauth/flows/oauth.token.flow.d.ts +0 -0
- package/{src/auth → auth}/oauth/flows/oauth.userinfo.flow.d.ts +0 -0
- package/{src/auth → auth}/oauth/flows/oidc.logout.flow.d.ts +0 -0
- package/{src/auth → auth}/session/authorization-vault.d.ts +0 -0
- package/{src/auth → auth}/session/authorization.store.d.ts +0 -0
- package/{src/auth → auth}/session/encrypted-authorization-vault.d.ts +0 -0
- package/{src/auth → auth}/session/record/session.base.d.ts +0 -0
- package/{src/auth → auth}/session/record/session.stateful.d.ts +0 -0
- package/{src/auth → auth}/session/record/session.stateless.d.ts +0 -0
- package/{src/auth → auth}/session/record/session.transparent.d.ts +0 -0
- package/{src/auth → auth}/session/redis-session.store.d.ts +0 -0
- package/{src/auth → auth}/session/session.crypto.d.ts +0 -0
- package/{src/auth → auth}/session/session.schema.d.ts +0 -0
- package/{src/auth → auth}/session/session.service.d.ts +0 -0
- package/{src/auth → auth}/session/session.transport.d.ts +0 -0
- package/{src/auth → auth}/session/session.types.d.ts +0 -0
- package/{src/auth → auth}/session/token.refresh.d.ts +0 -0
- package/{src/auth → auth}/session/token.store.d.ts +0 -0
- package/{src/auth → auth}/session/token.vault.d.ts +0 -0
- package/{src/auth → auth}/session/transport-session.manager.d.ts +0 -0
- package/{src/auth → auth}/session/transport-session.types.d.ts +0 -0
- package/{src/auth → auth}/session/utils/auth-token.utils.d.ts +0 -0
- package/{src/auth → auth}/session/utils/session-id.utils.d.ts +0 -0
- package/{src/auth → auth}/session/utils/tiny-ttl-cache.d.ts +0 -0
- package/{src/auth → auth}/session/vault-encryption.d.ts +0 -0
- package/{src/auth → auth}/ui/base-layout.d.ts +0 -0
- package/{src/auth → auth}/ui/index.d.ts +0 -0
- package/{src/auth → auth}/ui/templates.d.ts +0 -0
- package/{src/auth → auth}/utils/audience.validator.d.ts +0 -0
- package/{src/auth → auth}/utils/index.d.ts +0 -0
- package/{src/auth → auth}/utils/www-authenticate.utils.d.ts +0 -0
- package/{src/common → common}/common.schema.d.ts +0 -0
- package/{src/common → common}/constants.d.ts +0 -0
- package/{src/common → common}/decorators/adapter.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/app.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/auth-provider.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/decorator-utils.d.ts +0 -0
- package/{src/common → common}/decorators/flow.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/front-mcp.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/hook.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/index.d.ts +0 -0
- package/{src/common → common}/decorators/logger.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/plugin.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/prompt.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/provider.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/resource.decorator.d.ts +0 -0
- package/{src/common → common}/decorators/tool.decorator.d.ts +0 -0
- package/{src/common → common}/dynamic/dynamic.adapter.d.ts +0 -0
- package/{src/common → common}/dynamic/dynamic.plugin.d.ts +0 -0
- package/{src/common → common}/dynamic/dynamic.utils.d.ts +0 -0
- package/{src/common → common}/dynamic/index.d.ts +0 -0
- package/{src/common → common}/entries/adapter.entry.d.ts +0 -0
- package/{src/common → common}/entries/app.entry.d.ts +0 -0
- package/{src/common → common}/entries/auth-provider.entry.d.ts +0 -0
- package/{src/common → common}/entries/base.entry.d.ts +0 -0
- package/{src/common → common}/entries/flow.entry.d.ts +0 -0
- package/{src/common → common}/entries/hook.entry.d.ts +0 -0
- package/{src/common → common}/entries/index.d.ts +0 -0
- package/{src/common → common}/entries/logger.entry.d.ts +0 -0
- package/{src/common → common}/entries/plugin.entry.d.ts +0 -0
- package/{src/common → common}/entries/prompt.entry.d.ts +0 -0
- package/{src/common → common}/entries/provider.entry.d.ts +0 -0
- package/{src/common → common}/entries/resource.entry.d.ts +0 -0
- package/{src/common → common}/entries/scope.entry.d.ts +0 -0
- package/{src/common → common}/entries/tool.entry.d.ts +0 -0
- package/{src/common → common}/flow/flow.utils.d.ts +0 -0
- package/{src/common → common}/index.d.ts +0 -0
- package/{src/common → common}/interfaces/adapter.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/app.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/auth-hook.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/auth-provider.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/base.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/execution-context.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/flow.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/front-mcp.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/hook.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/index.d.ts +0 -0
- package/{src/common → common}/interfaces/internal/flow.utils.d.ts +0 -0
- package/{src/common → common}/interfaces/internal/index.d.ts +0 -0
- package/{src/common → common}/interfaces/internal/registry.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/logger.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/plugin.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/prompt.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/provider.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/resource.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/scope.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/server.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/session-hook.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/tool-hook.interface.d.ts +0 -0
- package/{src/common → common}/interfaces/tool.interface.d.ts +0 -0
- package/{src/common → common}/metadata/adapter.metadata.d.ts +0 -0
- package/{src/common → common}/metadata/app.metadata.d.ts +42 -42
- /package/{src/common → common}/metadata/auth-provider.metadata.d.ts +0 -0
- /package/{src/common → common}/metadata/flow.metadata.d.ts +0 -0
- /package/{src/common → common}/metadata/hook.metadata.d.ts +0 -0
- /package/{src/common → common}/metadata/index.d.ts +0 -0
- /package/{src/common → common}/metadata/logger.metadata.d.ts +0 -0
- /package/{src/common → common}/metadata/plugin.metadata.d.ts +0 -0
- /package/{src/common → common}/metadata/provider.metadata.d.ts +0 -0
- /package/{src/common → common}/migrate/auth-transport.migrate.d.ts +0 -0
- /package/{src/common → common}/migrate/index.d.ts +0 -0
- /package/{src/common → common}/providers/base-config.provider.d.ts +0 -0
- /package/{src/common → common}/records/adapter.record.d.ts +0 -0
- /package/{src/common → common}/records/app.record.d.ts +0 -0
- /package/{src/common → common}/records/auth-provider.record.d.ts +0 -0
- /package/{src/common → common}/records/flow.record.d.ts +0 -0
- /package/{src/common → common}/records/hook.record.d.ts +0 -0
- /package/{src/common → common}/records/index.d.ts +0 -0
- /package/{src/common → common}/records/logger.record.d.ts +0 -0
- /package/{src/common → common}/records/plugin.record.d.ts +0 -0
- /package/{src/common → common}/records/prompt.record.d.ts +0 -0
- /package/{src/common → common}/records/provider.record.d.ts +0 -0
- /package/{src/common → common}/records/resource.record.d.ts +0 -0
- /package/{src/common → common}/records/scope.record.d.ts +0 -0
- /package/{src/common → common}/records/tool.record.d.ts +0 -0
- /package/{src/common → common}/schemas/annotated-class.schema.d.ts +0 -0
- /package/{src/common → common}/schemas/http-input.schema.d.ts +0 -0
- /package/{src/common → common}/schemas/index.d.ts +0 -0
- /package/{src/common → common}/schemas/session-header.schema.d.ts +0 -0
- /package/{src/common → common}/tokens/adapter.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/app.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/auth-provider.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/base.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/flow-hook.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/flow.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/front-mcp.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/index.d.ts +0 -0
- /package/{src/common → common}/tokens/logger.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/plugin.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/prompt.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/provider.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/resource.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/server.tokens.d.ts +0 -0
- /package/{src/common → common}/tokens/tool.tokens.d.ts +0 -0
- /package/{src/common → common}/types/auth/index.d.ts +0 -0
- /package/{src/common → common}/types/auth/jwt.types.d.ts +0 -0
- /package/{src/common → common}/types/auth/session.types.d.ts +0 -0
- /package/{src/common → common}/types/common.types.d.ts +0 -0
- /package/{src/common → common}/types/index.d.ts +0 -0
- /package/{src/logger/logger.tokens.d.ts → common/types/options/auth/auth.typecheck.d.ts} +0 -0
- /package/{src/common → common}/types/options/http.options.d.ts +0 -0
- /package/{src/common → common}/types/options/logging.options.d.ts +0 -0
- /package/{src/common → common}/types/options/session.options.d.ts +0 -0
- /package/{src/common → common}/utils/path.utils.d.ts +0 -0
- /package/{src/context → context}/frontmcp-context-storage.d.ts +0 -0
- /package/{src/context → context}/frontmcp-context.d.ts +0 -0
- /package/{src/context → context}/frontmcp-context.provider.d.ts +0 -0
- /package/{src/context → context}/index.d.ts +0 -0
- /package/{src/context → context}/request-context-storage.d.ts +0 -0
- /package/{src/context → context}/request-context.d.ts +0 -0
- /package/{src/context → context}/request-context.provider.d.ts +0 -0
- /package/{src/context → context}/session-key.provider.d.ts +0 -0
- /package/{src/context → context}/trace-context.d.ts +0 -0
- /package/{src/errors → errors}/authorization-required.error.d.ts +0 -0
- /package/{src/errors → errors}/error-handler.d.ts +0 -0
- /package/{src/exceptions → exceptions}/mcp-exceptions/session-missing.exception.d.ts +0 -0
- /package/{src/exceptions → exceptions}/mcp-exceptions/unsupported-client-version.exception.d.ts +0 -0
- /package/{src/flows → flows}/flow.instance.d.ts +0 -0
- /package/{src/flows → flows}/flow.registry.d.ts +0 -0
- /package/{src/flows → flows}/flow.stages.d.ts +0 -0
- /package/{src/flows → flows}/flow.utils.d.ts +0 -0
- /package/{src/front-mcp → front-mcp}/front-mcp.d.ts +0 -0
- /package/{src/front-mcp → front-mcp}/front-mcp.tokens.d.ts +0 -0
- /package/{src/front-mcp → front-mcp}/serverless-handler.d.ts +0 -0
- /package/{src/hooks → hooks}/hook.instance.d.ts +0 -0
- /package/{src/hooks → hooks}/hook.registry.d.ts +0 -0
- /package/{src/hooks → hooks}/hooks.utils.d.ts +0 -0
- /package/{src/logger → logger}/instances/instance.console-logger.d.ts +0 -0
- /package/{src/logger → logger}/instances/instance.logger.d.ts +0 -0
- /package/{src/logger → logger}/logger.registry.d.ts +0 -0
- /package/{src/logger → logger}/logger.types.d.ts +0 -0
- /package/{src/logger → logger}/logger.utils.d.ts +0 -0
- /package/{src/mcp-apps → mcp-apps}/csp.d.ts +0 -0
- /package/{src/mcp-apps → mcp-apps}/index.d.ts +0 -0
- /package/{src/mcp-apps → mcp-apps}/schemas.d.ts +0 -0
- /package/{src/mcp-apps → mcp-apps}/template.d.ts +0 -0
- /package/{src/mcp-apps → mcp-apps}/types.d.ts +0 -0
- /package/{src/notification → notification}/index.d.ts +0 -0
- /package/{src/notification → notification}/notification.service.d.ts +0 -0
- /package/{src/plugin → plugin}/plugin.registry.d.ts +0 -0
- /package/{src/plugin → plugin}/plugin.utils.d.ts +0 -0
- /package/{src/prompt → prompt}/index.d.ts +0 -0
- /package/{src/prompt → prompt}/prompt.events.d.ts +0 -0
- /package/{src/prompt → prompt}/prompt.instance.d.ts +0 -0
- /package/{src/prompt → prompt}/prompt.registry.d.ts +0 -0
- /package/{src/prompt → prompt}/prompt.types.d.ts +0 -0
- /package/{src/prompt → prompt}/prompt.utils.d.ts +0 -0
- /package/{src/provider → provider}/provider.registry.d.ts +0 -0
- /package/{src/provider → provider}/provider.types.d.ts +0 -0
- /package/{src/provider → provider}/provider.utils.d.ts +0 -0
- /package/{src/regsitry → regsitry}/index.d.ts +0 -0
- /package/{src/regsitry → regsitry}/registry.base.d.ts +0 -0
- /package/{src/resource → resource}/index.d.ts +0 -0
- /package/{src/resource → resource}/resource.events.d.ts +0 -0
- /package/{src/resource → resource}/resource.instance.d.ts +0 -0
- /package/{src/resource → resource}/resource.registry.d.ts +0 -0
- /package/{src/resource → resource}/resource.types.d.ts +0 -0
- /package/{src/resource → resource}/resource.utils.d.ts +0 -0
- /package/{src/scope → scope}/flows/http.request.flow.d.ts +0 -0
- /package/{src/scope → scope}/index.d.ts +0 -0
- /package/{src/scope → scope}/scope.instance.d.ts +0 -0
- /package/{src/scope → scope}/scope.registry.d.ts +0 -0
- /package/{src/scope → scope}/scope.utils.d.ts +0 -0
- /package/{src/server → server}/adapters/base.host.adapter.d.ts +0 -0
- /package/{src/server → server}/adapters/express.host.adapter.d.ts +0 -0
- /package/{src/server → server}/server.instance.d.ts +0 -0
- /package/{src/server → server}/server.types.d.ts +0 -0
- /package/{src/server → server}/server.validation.d.ts +0 -0
- /package/{src/store → store}/adapters/store.base.adapter.d.ts +0 -0
- /package/{src/store → store}/adapters/store.memory.adapter.d.ts +0 -0
- /package/{src/store → store}/adapters/store.redis.adapter.d.ts +0 -0
- /package/{src/store → store}/store.helpers.d.ts +0 -0
- /package/{src/store → store}/store.registry.d.ts +0 -0
- /package/{src/store → store}/store.tokens.d.ts +0 -0
- /package/{src/store → store}/store.types.d.ts +0 -0
- /package/{src/store → store}/store.utils.d.ts +0 -0
- /package/{src/tool → tool}/tool.events.d.ts +0 -0
- /package/{src/tool → tool}/tool.instance.d.ts +0 -0
- /package/{src/tool → tool}/tool.registry.d.ts +0 -0
- /package/{src/tool → tool}/tool.types.d.ts +0 -0
- /package/{src/tool → tool}/tool.utils.d.ts +0 -0
- /package/{src/tool → tool}/ui/ui-resource-template.d.ts +0 -0
- /package/{src/transport → transport}/adapters/transport.local.adapter.d.ts +0 -0
- /package/{src/transport → transport}/adapters/transport.sse.adapter.d.ts +0 -0
- /package/{src/transport → transport}/adapters/transport.streamable-http.adapter.d.ts +0 -0
- /package/{src/transport → transport}/flows/handle.sse.flow.d.ts +0 -0
- /package/{src/transport → transport}/flows/handle.stateless-http.flow.d.ts +0 -0
- /package/{src/transport → transport}/flows/handle.streamable-http.flow.d.ts +0 -0
- /package/{src/transport → transport}/legacy/legacy.sse.tranporter.d.ts +0 -0
- /package/{src/transport → transport}/mcp-handlers/Initialized-notification.hanlder.d.ts +0 -0
- /package/{src/transport → transport}/mcp-handlers/call-tool-request.handler.d.ts +0 -0
- /package/{src/transport → transport}/mcp-handlers/initialize-request.handler.d.ts +0 -0
- /package/{src/transport → transport}/mcp-handlers/mcp-handlers.types.d.ts +0 -0
- /package/{src/transport → transport}/mcp-handlers/roots-list-changed-notification.handler.d.ts +0 -0
- /package/{src/transport → transport}/transport.error.d.ts +0 -0
- /package/{src/transport → transport}/transport.event-store.d.ts +0 -0
- /package/{src/transport → transport}/transport.local.d.ts +0 -0
- /package/{src/transport → transport}/transport.remote.d.ts +0 -0
- /package/{src/transport → transport}/transport.types.d.ts +0 -0
- /package/{src/types → types}/drinen-hooks.types.d.ts +0 -0
- /package/{src/types → types}/invoke.type.d.ts +0 -0
- /package/{src/types → types}/token.types.d.ts +0 -0
- /package/{src/utils → utils}/content.utils.d.ts +0 -0
- /package/{src/utils → utils}/index.d.ts +0 -0
- /package/{src/utils → utils}/lineage.utils.d.ts +0 -0
- /package/{src/utils → utils}/metadata.utils.d.ts +0 -0
- /package/{src/utils → utils}/naming.utils.d.ts +0 -0
- /package/{src/utils → utils}/server.utils.d.ts +0 -0
- /package/{src/utils → utils}/string.utils.d.ts +0 -0
- /package/{src/utils → utils}/token.utils.d.ts +0 -0
- /package/{src/utils → utils}/types.utils.d.ts +0 -0
- /package/{src/utils → utils}/uri-template.utils.d.ts +0 -0
- /package/{src/utils → utils}/uri-validation.utils.d.ts +0 -0
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// noinspection ExceptionCaughtLocallyJS
|
|
3
|
-
// flows/flow.instance.ts
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.FlowInstance = void 0;
|
|
6
|
-
require("reflect-metadata");
|
|
7
|
-
const common_1 = require("../common");
|
|
8
|
-
const flow_stages_1 = require("./flow.stages");
|
|
9
|
-
const server_validation_1 = require("../server/server.validation");
|
|
10
|
-
const context_1 = require("../context");
|
|
11
|
-
const mcp_error_1 = require("../errors/mcp.error");
|
|
12
|
-
const crypto_1 = require("crypto");
|
|
13
|
-
const CAP = (s) => (s ? s[0].toUpperCase() + s.slice(1) : s);
|
|
14
|
-
const WILL = (s) => `will${CAP(s)}`;
|
|
15
|
-
const DID = (s) => `did${CAP(s)}`;
|
|
16
|
-
const AROUND = (s) => `around${CAP(s)}`;
|
|
17
|
-
function parseTypedKey(k) {
|
|
18
|
-
const lc = k.toLowerCase();
|
|
19
|
-
if (lc.startsWith('will') && k.length > 4)
|
|
20
|
-
return { base: k.slice(4, 5).toLowerCase() + k.slice(5), type: 'will' };
|
|
21
|
-
if (lc.startsWith('did') && k.length > 3)
|
|
22
|
-
return { base: k.slice(3, 4).toLowerCase() + k.slice(4), type: 'did' };
|
|
23
|
-
if (lc.startsWith('around') && k.length > 6)
|
|
24
|
-
return { base: k.slice(6, 7).toLowerCase() + k.slice(7), type: 'around' };
|
|
25
|
-
return { base: k };
|
|
26
|
-
}
|
|
27
|
-
class FlowInstance extends common_1.FlowEntry {
|
|
28
|
-
deps;
|
|
29
|
-
globalProviders;
|
|
30
|
-
plan;
|
|
31
|
-
FlowClass;
|
|
32
|
-
stages;
|
|
33
|
-
hooks;
|
|
34
|
-
constructor(scope, record, deps, globalProviders) {
|
|
35
|
-
super(scope, record);
|
|
36
|
-
this.deps = [...deps];
|
|
37
|
-
this.globalProviders = globalProviders;
|
|
38
|
-
this.FlowClass = this.record.provide;
|
|
39
|
-
this.ready = this.initialize();
|
|
40
|
-
this.plan = this.record.metadata.plan;
|
|
41
|
-
this.hooks = scope.providers.getHooksRegistry();
|
|
42
|
-
}
|
|
43
|
-
async initialize() {
|
|
44
|
-
const server = this.globalProviders.getActiveServer();
|
|
45
|
-
this.stages = (0, flow_stages_1.collectFlowHookMap)(this.FlowClass);
|
|
46
|
-
const { middleware } = this.metadata;
|
|
47
|
-
if (middleware) {
|
|
48
|
-
const path = typeof middleware.path === 'string' ? middleware.path : '';
|
|
49
|
-
server.registerMiddleware(path, async (request, response, next) => {
|
|
50
|
-
const canActivate = await this.canActivate(request);
|
|
51
|
-
if (!canActivate)
|
|
52
|
-
return next();
|
|
53
|
-
// Get context storage to wrap entire flow in FrontMcpContext
|
|
54
|
-
const contextStorage = this.getContextStorage();
|
|
55
|
-
try {
|
|
56
|
-
// Use runWithContext to wrap entire flow execution in AsyncLocalStorage context
|
|
57
|
-
// This ensures all stages have access to FrontMcpContext
|
|
58
|
-
const result = await this.runWithContext(contextStorage, request, { request, response, next }, new Map());
|
|
59
|
-
if (result)
|
|
60
|
-
return (0, server_validation_1.writeHttpResponse)(response, result);
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
if (e instanceof common_1.FlowControl) {
|
|
64
|
-
switch (e.type) {
|
|
65
|
-
case 'abort':
|
|
66
|
-
return (0, server_validation_1.writeHttpResponse)(response, { kind: 'text', status: 500, body: 'Aborted' });
|
|
67
|
-
case 'fail':
|
|
68
|
-
return (0, server_validation_1.writeHttpResponse)(response, { kind: 'text', status: 500, body: 'Internal Server Error' });
|
|
69
|
-
case 'handled':
|
|
70
|
-
return;
|
|
71
|
-
case 'next':
|
|
72
|
-
return next();
|
|
73
|
-
case 'respond':
|
|
74
|
-
return (0, server_validation_1.writeHttpResponse)(response, e.output);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// Log unhandled errors for visibility (non-FlowControl errors indicate bugs)
|
|
78
|
-
// Note: Using structured logging to avoid Node.js util.inspect issues with Zod errors
|
|
79
|
-
console.error('[FlowInstance] Unhandled error:', {
|
|
80
|
-
name: e instanceof Error ? e.name : 'UnknownError',
|
|
81
|
-
message: e instanceof Error ? e.message : String(e),
|
|
82
|
-
});
|
|
83
|
-
return (0, server_validation_1.writeHttpResponse)(response, {
|
|
84
|
-
kind: 'text',
|
|
85
|
-
status: 500,
|
|
86
|
-
body: 'Internal Server Error',
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return next();
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return Promise.resolve();
|
|
93
|
-
}
|
|
94
|
-
async canActivate(request) {
|
|
95
|
-
if (this.method && request.method !== this.method)
|
|
96
|
-
return false;
|
|
97
|
-
const canActivate = this.metadata.middleware?.canActivate ?? [];
|
|
98
|
-
if (this.FlowClass['canActivate']) {
|
|
99
|
-
canActivate.push(this.FlowClass['canActivate']);
|
|
100
|
-
}
|
|
101
|
-
if (canActivate.length === 0)
|
|
102
|
-
return true;
|
|
103
|
-
const results = await Promise.all(canActivate.map((m) => m(request, this.scope)));
|
|
104
|
-
return results.every((r) => r);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Get FrontMcpContextStorage from providers (with fallback).
|
|
108
|
-
* Returns undefined if not available (backward compatibility).
|
|
109
|
-
*/
|
|
110
|
-
getContextStorage() {
|
|
111
|
-
try {
|
|
112
|
-
return this.globalProviders.get(context_1.FrontMcpContextStorage);
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
return undefined;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Run flow wrapped in FrontMcpContext.
|
|
120
|
-
* This ensures ALL stages have access to the context via AsyncLocalStorage.
|
|
121
|
-
*
|
|
122
|
-
* @param storage - FrontMcpContextStorage instance
|
|
123
|
-
* @param request - The HTTP request
|
|
124
|
-
* @param input - Flow input
|
|
125
|
-
* @param deps - Flow dependencies
|
|
126
|
-
* @returns Flow output or undefined
|
|
127
|
-
*/
|
|
128
|
-
async runWithContext(storage, request, input, deps) {
|
|
129
|
-
// If no storage available, run without context (backward compatibility)
|
|
130
|
-
if (!storage) {
|
|
131
|
-
return this.run(input, deps);
|
|
132
|
-
}
|
|
133
|
-
// Extract context parameters from request
|
|
134
|
-
const headers = (request.headers ?? {});
|
|
135
|
-
// Generate unique ID for anonymous sessions to prevent session collision
|
|
136
|
-
// All unauthenticated requests previously shared 'anonymous', causing data leakage
|
|
137
|
-
// Handle empty strings explicitly: '' ?? 'fallback' returns '', not 'fallback'
|
|
138
|
-
const headerSessionId = typeof headers['mcp-session-id'] === 'string' ? headers['mcp-session-id'].trim() : '';
|
|
139
|
-
const sessionId = headerSessionId.length > 0 ? headerSessionId : `anon:${(0, crypto_1.randomUUID)()}`;
|
|
140
|
-
const scope = this.globalProviders.getActiveScope();
|
|
141
|
-
// Wrap ENTIRE flow execution in AsyncLocalStorage context
|
|
142
|
-
return storage.runFromHeaders(headers, {
|
|
143
|
-
sessionId,
|
|
144
|
-
scopeId: scope.id,
|
|
145
|
-
}, async () => {
|
|
146
|
-
return this.run(input, deps);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
async run(input, deps) {
|
|
150
|
-
const scope = this.globalProviders.getActiveScope();
|
|
151
|
-
const { FlowClass, plan, name } = this;
|
|
152
|
-
// Build provider views for scoped DI
|
|
153
|
-
// This enables CONTEXT scoped providers to be resolved
|
|
154
|
-
const contextStorage = this.getContextStorage();
|
|
155
|
-
const currentContext = contextStorage?.getStore();
|
|
156
|
-
// Get session ID from context - should always be available since runWithContext wraps the entire flow
|
|
157
|
-
// If unavailable, it indicates a bug in context propagation (not a normal case)
|
|
158
|
-
const sessionKey = currentContext?.sessionId;
|
|
159
|
-
if (!sessionKey) {
|
|
160
|
-
// This should never happen since runWithContext wraps the entire flow execution
|
|
161
|
-
// If we reach here, there's a bug in context propagation
|
|
162
|
-
throw new mcp_error_1.RequestContextNotAvailableError('FrontMcpContext unavailable - session ID required for provider resolution. Ensure flow is wrapped with runWithContext.');
|
|
163
|
-
}
|
|
164
|
-
// Build views with current context if available
|
|
165
|
-
const views = await this.globalProviders.buildViews(sessionKey, currentContext ? new Map([[context_1.FRONTMCP_CONTEXT, currentContext]]) : undefined);
|
|
166
|
-
// Merge context-scoped providers into deps for resolution by FlowClass
|
|
167
|
-
const mergedDeps = new Map(deps);
|
|
168
|
-
for (const [token, instance] of views.context) {
|
|
169
|
-
mergedDeps.set(token, instance);
|
|
170
|
-
}
|
|
171
|
-
// Clone stages so we can merge injections safely per run.
|
|
172
|
-
const baseStages = this.stages;
|
|
173
|
-
const stages = (0, flow_stages_1.cloneStageMap)(baseStages);
|
|
174
|
-
// Compute next order base after any class-defined entries.
|
|
175
|
-
let orderBase = Math.max(0, ...Object.values(stages).flatMap((list) => list.map((e) => e._order ?? 0))) + 1;
|
|
176
|
-
// Get tool owner ID if this is a tool call flow
|
|
177
|
-
// The tool owner ID is set by the CallToolFlow.findTool stage
|
|
178
|
-
const toolOwnerId = input?._toolOwnerId;
|
|
179
|
-
const initialInjectedHooks = this.hooks.getFlowHooksForOwner(name, toolOwnerId) ?? [];
|
|
180
|
-
// FlowClass generic type is erased at runtime, so we use FlowBase<any>
|
|
181
|
-
// to avoid complex type gymnastics while maintaining basic type safety
|
|
182
|
-
let context;
|
|
183
|
-
let contextReady = false;
|
|
184
|
-
const materializeAndMerge = async (newHooks, opts) => {
|
|
185
|
-
if (!newHooks?.length || !contextReady)
|
|
186
|
-
return;
|
|
187
|
-
const metas = [];
|
|
188
|
-
for (const h of newHooks) {
|
|
189
|
-
try {
|
|
190
|
-
metas.push(h.metadata);
|
|
191
|
-
}
|
|
192
|
-
catch (e) {
|
|
193
|
-
// Use safe logging to avoid Node.js 24 util.inspect bug with Zod errors
|
|
194
|
-
console.warn('[flow] Ignoring injected hook that failed to materialize:', e instanceof Error ? e.message : 'Unknown error');
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
if (metas.length) {
|
|
198
|
-
const start = opts?.orderStart ?? orderBase;
|
|
199
|
-
(0, flow_stages_1.mergeHookMetasIntoStageMap)(FlowClass, stages, metas, start);
|
|
200
|
-
if (opts?.orderStart === undefined)
|
|
201
|
-
orderBase += metas.length;
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
const appendContextHooks = async (hooks) => {
|
|
205
|
-
await materializeAndMerge(hooks);
|
|
206
|
-
};
|
|
207
|
-
// Construct flow instance with merged dependencies (includes scoped providers)
|
|
208
|
-
// eslint-disable-next-line prefer-const -- declaration must precede helper functions that close over context
|
|
209
|
-
context = new FlowClass(this.metadata, input, scope, appendContextHooks, mergedDeps);
|
|
210
|
-
// Now injections can materialize
|
|
211
|
-
contextReady = true;
|
|
212
|
-
// Initial registry hooks should not pre-empt stages; they just get registered
|
|
213
|
-
await materializeAndMerge(initialInjectedHooks, { orderStart: -1_000_000 });
|
|
214
|
-
// Refresh order base to be after everything currently present
|
|
215
|
-
orderBase = Math.max(0, ...Object.values(stages).flatMap((list) => list.map((e) => e._order ?? 0))) + 1;
|
|
216
|
-
let responded;
|
|
217
|
-
// Robust list runner (doesn't skip mid-run insertions)
|
|
218
|
-
const runList = async (key, opts) => {
|
|
219
|
-
const getList = () => (stages[key] ?? []);
|
|
220
|
-
const seen = new Set();
|
|
221
|
-
while (true) {
|
|
222
|
-
const list = getList();
|
|
223
|
-
const item = list.find((e) => !seen.has(e));
|
|
224
|
-
if (!item)
|
|
225
|
-
break;
|
|
226
|
-
seen.add(item);
|
|
227
|
-
try {
|
|
228
|
-
await item.method(context);
|
|
229
|
-
}
|
|
230
|
-
catch (e) {
|
|
231
|
-
if (e instanceof common_1.FlowControl) {
|
|
232
|
-
if (e.type === 'respond') {
|
|
233
|
-
if (!opts?.ignoreRespond) {
|
|
234
|
-
responded = e.output;
|
|
235
|
-
return { outcome: 'respond', control: e };
|
|
236
|
-
}
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
return { outcome: e.type, control: e };
|
|
240
|
-
}
|
|
241
|
-
return { outcome: 'unknown_error', control: e };
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return { outcome: 'ok' };
|
|
245
|
-
};
|
|
246
|
-
// Run exactly one stage in order: will → around → stage → did (did runs once)
|
|
247
|
-
const runOneStage = async (stageName, stopOnRespond) => {
|
|
248
|
-
// 1) willStage
|
|
249
|
-
{
|
|
250
|
-
const res = await runList(WILL(stageName));
|
|
251
|
-
if (res.outcome === 'respond' && stopOnRespond)
|
|
252
|
-
return res;
|
|
253
|
-
if (res.outcome !== 'ok' && res.outcome !== 'respond')
|
|
254
|
-
return res;
|
|
255
|
-
}
|
|
256
|
-
// 2) aroundStage (acts as pre-handlers unless you later add true wrapping)
|
|
257
|
-
{
|
|
258
|
-
const res = await runList(AROUND(stageName));
|
|
259
|
-
if (res.outcome === 'respond' && stopOnRespond)
|
|
260
|
-
return res;
|
|
261
|
-
if (res.outcome !== 'ok' && res.outcome !== 'respond')
|
|
262
|
-
return res;
|
|
263
|
-
}
|
|
264
|
-
// 3) stage
|
|
265
|
-
let bodyOutcome = { outcome: 'ok' };
|
|
266
|
-
{
|
|
267
|
-
const res = await runList(stageName, { ignoreRespond: false });
|
|
268
|
-
bodyOutcome = res;
|
|
269
|
-
if (res.outcome !== 'ok' && res.outcome !== 'respond') {
|
|
270
|
-
// fail/abort/next/handled/unknown → do NOT run did
|
|
271
|
-
return res;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
// 4) didStage (run once regardless of body respond)
|
|
275
|
-
{
|
|
276
|
-
const res = await runList(DID(stageName), { ignoreRespond: true });
|
|
277
|
-
if (res.outcome !== 'ok' && res.outcome !== 'respond')
|
|
278
|
-
return res;
|
|
279
|
-
}
|
|
280
|
-
if (bodyOutcome.outcome === 'respond')
|
|
281
|
-
return bodyOutcome;
|
|
282
|
-
return { outcome: 'ok' };
|
|
283
|
-
};
|
|
284
|
-
// IMPORTANT: ignore typed stage names in plan arrays.
|
|
285
|
-
// Only base stage names in the plan drive execution; typed hooks run *with* their base.
|
|
286
|
-
const runStageGroup = async (group, stopOnRespond, opts) => {
|
|
287
|
-
if (!group || group.length === 0)
|
|
288
|
-
return { outcome: 'ok' };
|
|
289
|
-
const seenBase = new Set();
|
|
290
|
-
for (const rawKey of group) {
|
|
291
|
-
const { base, type } = parseTypedKey(rawKey);
|
|
292
|
-
if (type) {
|
|
293
|
-
// Soft warning once per typed key occurrence (optional)
|
|
294
|
-
// console.warn(`[flow] Ignoring typed stage "${rawKey}" in plan; hooks will run with base "${base}".`);
|
|
295
|
-
continue; // Do not run typed keys as standalone stages
|
|
296
|
-
}
|
|
297
|
-
if (seenBase.has(base))
|
|
298
|
-
continue;
|
|
299
|
-
seenBase.add(base);
|
|
300
|
-
const res = await runOneStage(base, stopOnRespond);
|
|
301
|
-
if (res.outcome === 'respond') {
|
|
302
|
-
if (stopOnRespond)
|
|
303
|
-
return res;
|
|
304
|
-
// else keep going
|
|
305
|
-
}
|
|
306
|
-
else if (res.outcome !== 'ok') {
|
|
307
|
-
return res;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
return { outcome: 'ok' };
|
|
311
|
-
};
|
|
312
|
-
const runErrorStage = async () => {
|
|
313
|
-
await runStageGroup(plan.error, false, { ignoreRespond: true });
|
|
314
|
-
};
|
|
315
|
-
const runFinalizeStage = async (options) => {
|
|
316
|
-
const res = await runStageGroup(plan.finalize, false);
|
|
317
|
-
// Handle finalize stage errors
|
|
318
|
-
if (res.outcome === 'unknown_error' || res.outcome === 'fail') {
|
|
319
|
-
const finalizeError = res.control ?? new mcp_error_1.InternalMcpError('Finalize stage failed');
|
|
320
|
-
if (options?.suppressErrors) {
|
|
321
|
-
// Log finalizes errors but doesn't throw when called from finally blocks
|
|
322
|
-
// This prevents masking the original error
|
|
323
|
-
this.scope.logger.error('[FrontMCP] Finalize stage error (suppressed to preserve original error):', finalizeError);
|
|
324
|
-
return res;
|
|
325
|
-
}
|
|
326
|
-
throw finalizeError;
|
|
327
|
-
}
|
|
328
|
-
return res;
|
|
329
|
-
};
|
|
330
|
-
// ---------- PRE ----------
|
|
331
|
-
{
|
|
332
|
-
const pre = await runStageGroup(plan.pre, true);
|
|
333
|
-
if (pre.outcome === 'respond') {
|
|
334
|
-
const post = await runStageGroup(plan.post, false);
|
|
335
|
-
if (post.outcome === 'unknown_error' || post.outcome === 'fail') {
|
|
336
|
-
try {
|
|
337
|
-
await runErrorStage();
|
|
338
|
-
}
|
|
339
|
-
finally {
|
|
340
|
-
await runFinalizeStage({ suppressErrors: true });
|
|
341
|
-
}
|
|
342
|
-
throw post.control ?? new mcp_error_1.InternalMcpError('Missing control for fail/error outcome');
|
|
343
|
-
}
|
|
344
|
-
if (post.outcome === 'abort' || post.outcome === 'next' || post.outcome === 'handled') {
|
|
345
|
-
await runFinalizeStage({ suppressErrors: true });
|
|
346
|
-
if (!(post.control instanceof common_1.FlowControl)) {
|
|
347
|
-
throw new mcp_error_1.InternalMcpError('Expected FlowControl but received different error type');
|
|
348
|
-
}
|
|
349
|
-
throw post.control;
|
|
350
|
-
}
|
|
351
|
-
await runFinalizeStage();
|
|
352
|
-
return responded;
|
|
353
|
-
}
|
|
354
|
-
if (pre.outcome === 'unknown_error' || pre.outcome === 'fail') {
|
|
355
|
-
try {
|
|
356
|
-
await runErrorStage();
|
|
357
|
-
}
|
|
358
|
-
finally {
|
|
359
|
-
await runFinalizeStage({ suppressErrors: true });
|
|
360
|
-
}
|
|
361
|
-
throw pre.control ?? new mcp_error_1.InternalMcpError('Missing control for fail/error outcome');
|
|
362
|
-
}
|
|
363
|
-
if (pre.outcome === 'abort' || pre.outcome === 'next' || pre.outcome === 'handled') {
|
|
364
|
-
await runFinalizeStage({ suppressErrors: true });
|
|
365
|
-
if (!(pre.control instanceof common_1.FlowControl)) {
|
|
366
|
-
throw new mcp_error_1.InternalMcpError('Expected FlowControl but received different error type');
|
|
367
|
-
}
|
|
368
|
-
throw pre.control;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
// ---------- EXECUTE ----------
|
|
372
|
-
if (!responded) {
|
|
373
|
-
const exec = await runStageGroup(plan.execute, true);
|
|
374
|
-
if (exec.outcome === 'respond') {
|
|
375
|
-
// continue to post + finalize
|
|
376
|
-
}
|
|
377
|
-
else if (exec.outcome === 'unknown_error' || exec.outcome === 'fail') {
|
|
378
|
-
try {
|
|
379
|
-
await runErrorStage();
|
|
380
|
-
}
|
|
381
|
-
finally {
|
|
382
|
-
await runFinalizeStage({ suppressErrors: true });
|
|
383
|
-
}
|
|
384
|
-
throw exec.control ?? new mcp_error_1.InternalMcpError('Missing control for fail/error outcome');
|
|
385
|
-
}
|
|
386
|
-
else if (exec.outcome === 'abort' || exec.outcome === 'next' || exec.outcome === 'handled') {
|
|
387
|
-
await runFinalizeStage({ suppressErrors: true });
|
|
388
|
-
if (!(exec.control instanceof common_1.FlowControl)) {
|
|
389
|
-
throw new mcp_error_1.InternalMcpError('Expected FlowControl but received different error type');
|
|
390
|
-
}
|
|
391
|
-
throw exec.control;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
// ---------- POST ----------
|
|
395
|
-
{
|
|
396
|
-
const post = await runStageGroup(plan.post, false);
|
|
397
|
-
if (post.outcome === 'unknown_error' || post.outcome === 'fail') {
|
|
398
|
-
try {
|
|
399
|
-
await runErrorStage();
|
|
400
|
-
}
|
|
401
|
-
finally {
|
|
402
|
-
await runFinalizeStage({ suppressErrors: true });
|
|
403
|
-
}
|
|
404
|
-
throw post.control ?? new mcp_error_1.InternalMcpError('Missing control for fail/error outcome');
|
|
405
|
-
}
|
|
406
|
-
if (post.outcome === 'abort' || post.outcome === 'next' || post.outcome === 'handled') {
|
|
407
|
-
await runFinalizeStage({ suppressErrors: true });
|
|
408
|
-
if (!(post.control instanceof common_1.FlowControl)) {
|
|
409
|
-
throw new mcp_error_1.InternalMcpError('Expected FlowControl but received different error type');
|
|
410
|
-
}
|
|
411
|
-
throw post.control;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
// ---------- FINALIZE ----------
|
|
415
|
-
await runFinalizeStage();
|
|
416
|
-
return responded;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
exports.FlowInstance = FlowInstance;
|
|
420
|
-
//# sourceMappingURL=flow.instance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flow.instance.js","sourceRoot":"","sources":["../../../src/flows/flow.instance.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,yBAAyB;;;AAEzB,4BAA0B;AAC1B,sCAkBmB;AAEnB,+CAAwG;AACxG,mEAAgE;AAIhE,wCAAsE;AACtE,mDAAwF;AACxF,mCAAoC;AASpC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrE,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5C,MAAM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LocallyJS\n// flows/flow.instance.ts\n\nimport 'reflect-metadata';\nimport {\n FlowBase,\n FlowControl,\n FlowCtxOf,\n FlowEntry,\n FlowInputOf,\n FlowName,\n FlowOutputOf,\n FlowPlan,\n FlowRecord,\n FlowStagesOf,\n FlowType,\n HookEntry,\n HookMetadata,\n Reference,\n ServerRequest,\n Token,\n Type,\n} from '../common';\nimport ProviderRegistry from '../provider/provider.registry';\nimport { collectFlowHookMap, StageMap, cloneStageMap, mergeHookMetasIntoStageMap } from './flow.stages';\nimport { writeHttpResponse } from '../server/server.validation';\nimport { Scope } from '../scope';\nimport HookRegistry from '../hooks/hook.registry';\nimport { rpcError } from '../transport/transport.error';\nimport { FrontMcpContextStorage, FRONTMCP_CONTEXT } from '../context';\nimport { RequestContextNotAvailableError, InternalMcpError } from '../errors/mcp.error';\nimport { randomUUID } from 'crypto';\n\ntype StageOutcome = 'ok' | 'respond' | 'next' | 'handled' | 'fail' | 'abort' | 'unknown_error';\n\ninterface StageResult {\n outcome: StageOutcome;\n control?: FlowControl | Error;\n}\n\nconst CAP = (s: string) => (s ? s[0].toUpperCase() + s.slice(1) : s);\nconst WILL = (s: string) => `will${CAP(s)}`;\nconst DID = (s: string) => `did${CAP(s)}`;\nconst AROUND = (s: string) => `around${CAP(s)}`;\n\nfunction parseTypedKey(k: string): { base: string; type?: 'will' | 'did' | 'around' } {\n const lc = k.toLowerCase();\n if (lc.startsWith('will') && k.length > 4) return { base: k.slice(4, 5).toLowerCase() + k.slice(5), type: 'will' };\n if (lc.startsWith('did') && k.length > 3) return { base: k.slice(3, 4).toLowerCase() + k.slice(4), type: 'did' };\n if (lc.startsWith('around') && k.length > 6)\n return { base: k.slice(6, 7).toLowerCase() + k.slice(7), type: 'around' };\n return { base: k };\n}\n\nexport class FlowInstance<Name extends FlowName> extends FlowEntry<Name> {\n readonly deps: Reference[];\n readonly globalProviders: ProviderRegistry;\n private plan: FlowPlan<never>;\n private FlowClass: FlowType;\n private stages: StageMap<FlowType>;\n private hooks: HookRegistry;\n\n constructor(scope: Scope, record: FlowRecord, deps: Set<Reference>, globalProviders: ProviderRegistry) {\n super(scope, record);\n this.deps = [...deps];\n this.globalProviders = globalProviders;\n this.FlowClass = this.record.provide;\n this.ready = this.initialize();\n this.plan = this.record.metadata.plan;\n this.hooks = scope.providers.getHooksRegistry();\n }\n\n protected async initialize() {\n const server = this.globalProviders.getActiveServer();\n\n this.stages = collectFlowHookMap(this.FlowClass);\n\n const { middleware } = this.metadata;\n if (middleware) {\n const path = typeof middleware.path === 'string' ? middleware.path : '';\n server.registerMiddleware(path, async (request, response, next) => {\n const canActivate = await this.canActivate(request);\n if (!canActivate) return next();\n\n // Get context storage to wrap entire flow in FrontMcpContext\n const contextStorage = this.getContextStorage();\n\n try {\n // Use runWithContext to wrap entire flow execution in AsyncLocalStorage context\n // This ensures all stages have access to FrontMcpContext\n const result = await this.runWithContext(\n contextStorage,\n request,\n { request, response, next } as any,\n new Map(),\n );\n if (result) return writeHttpResponse(response, result);\n } catch (e) {\n if (e instanceof FlowControl) {\n switch (e.type) {\n case 'abort':\n return writeHttpResponse(response, { kind: 'text', status: 500, body: 'Aborted' });\n case 'fail':\n return writeHttpResponse(response, { kind: 'text', status: 500, body: 'Internal Server Error' });\n case 'handled':\n return;\n case 'next':\n return next();\n case 'respond':\n return writeHttpResponse(response, e.output as any);\n }\n }\n // Log unhandled errors for visibility (non-FlowControl errors indicate bugs)\n // Note: Using structured logging to avoid Node.js util.inspect issues with Zod errors\n console.error('[FlowInstance] Unhandled error:', {\n name: e instanceof Error ? e.name : 'UnknownError',\n message: e instanceof Error ? e.message : String(e),\n });\n return writeHttpResponse(response, {\n kind: 'text',\n status: 500,\n body: 'Internal Server Error',\n });\n }\n\n return next();\n });\n }\n\n return Promise.resolve();\n }\n\n async canActivate(request: ServerRequest): Promise<boolean> {\n if (this.method && request.method !== this.method) return false;\n\n const canActivate = this.metadata.middleware?.canActivate ?? [];\n if ((this.FlowClass as any)['canActivate']) {\n canActivate.push((this.FlowClass as any)['canActivate']);\n }\n if (canActivate.length === 0) return true;\n\n const results = await Promise.all(canActivate.map((m) => m(request, this.scope)));\n return results.every((r) => r);\n }\n\n /**\n * Get FrontMcpContextStorage from providers (with fallback).\n * Returns undefined if not available (backward compatibility).\n */\n private getContextStorage(): FrontMcpContextStorage | undefined {\n try {\n return this.globalProviders.get(FrontMcpContextStorage);\n } catch {\n return undefined;\n }\n }\n\n /**\n * Run flow wrapped in FrontMcpContext.\n * This ensures ALL stages have access to the context via AsyncLocalStorage.\n *\n * @param storage - FrontMcpContextStorage instance\n * @param request - The HTTP request\n * @param input - Flow input\n * @param deps - Flow dependencies\n * @returns Flow output or undefined\n */\n private async runWithContext(\n storage: FrontMcpContextStorage | undefined,\n request: ServerRequest,\n input: FlowInputOf<Name>,\n deps: Map<Token, Type>,\n ): Promise<FlowOutputOf<Name> | undefined> {\n // If no storage available, run without context (backward compatibility)\n if (!storage) {\n return this.run(input, deps);\n }\n\n // Extract context parameters from request\n const headers = (request.headers ?? {}) as Record<string, unknown>;\n // Generate unique ID for anonymous sessions to prevent session collision\n // All unauthenticated requests previously shared 'anonymous', causing data leakage\n // Handle empty strings explicitly: '' ?? 'fallback' returns '', not 'fallback'\n const headerSessionId = typeof headers['mcp-session-id'] === 'string' ? headers['mcp-session-id'].trim() : '';\n const sessionId = headerSessionId.length > 0 ? headerSessionId : `anon:${randomUUID()}`;\n const scope = this.globalProviders.getActiveScope();\n\n // Wrap ENTIRE flow execution in AsyncLocalStorage context\n return storage.runFromHeaders(\n headers,\n {\n sessionId,\n scopeId: scope.id,\n },\n async () => {\n return this.run(input, deps);\n },\n );\n }\n\n async run(input: FlowInputOf<Name>, deps: Map<Token, Type>): Promise<FlowOutputOf<Name> | undefined> {\n const scope = this.globalProviders.getActiveScope();\n const { FlowClass, plan, name } = this;\n\n // Build provider views for scoped DI\n // This enables CONTEXT scoped providers to be resolved\n const contextStorage = this.getContextStorage();\n const currentContext = contextStorage?.getStore();\n // Get session ID from context - should always be available since runWithContext wraps the entire flow\n // If unavailable, it indicates a bug in context propagation (not a normal case)\n const sessionKey = currentContext?.sessionId;\n if (!sessionKey) {\n // This should never happen since runWithContext wraps the entire flow execution\n // If we reach here, there's a bug in context propagation\n throw new RequestContextNotAvailableError(\n 'FrontMcpContext unavailable - session ID required for provider resolution. Ensure flow is wrapped with runWithContext.',\n );\n }\n\n // Build views with current context if available\n const views = await this.globalProviders.buildViews(\n sessionKey,\n currentContext ? new Map([[FRONTMCP_CONTEXT, currentContext]]) : undefined,\n );\n\n // Merge context-scoped providers into deps for resolution by FlowClass\n const mergedDeps = new Map(deps);\n for (const [token, instance] of views.context) {\n mergedDeps.set(token, instance as Type);\n }\n\n // Clone stages so we can merge injections safely per run.\n const baseStages = this.stages;\n const stages: StageMap<any> = cloneStageMap(baseStages);\n\n // Compute next order base after any class-defined entries.\n let orderBase = Math.max(0, ...Object.values(stages).flatMap((list) => list.map((e: any) => e._order ?? 0))) + 1;\n\n // Get tool owner ID if this is a tool call flow\n // The tool owner ID is set by the CallToolFlow.findTool stage\n const toolOwnerId = (input as any)?._toolOwnerId;\n\n const initialInjectedHooks =\n (this.hooks.getFlowHooksForOwner(name, toolOwnerId) as HookEntry<\n FlowInputOf<Name>,\n Name,\n FlowStagesOf<Name>,\n FlowCtxOf<Name>\n >[]) ?? [];\n\n // FlowClass generic type is erased at runtime, so we use FlowBase<any>\n // to avoid complex type gymnastics while maintaining basic type safety\n let context: FlowBase<any>;\n let contextReady = false;\n\n const materializeAndMerge = async (\n newHooks: HookEntry<FlowInputOf<Name>, Name, FlowStagesOf<Name>, FlowCtxOf<Name>>[],\n opts?: { orderStart?: number },\n ) => {\n if (!newHooks?.length || !contextReady) return;\n\n const metas: HookMetadata[] = [];\n for (const h of newHooks) {\n try {\n metas.push(h.metadata);\n } catch (e) {\n // Use safe logging to avoid Node.js 24 util.inspect bug with Zod errors\n\n console.warn(\n '[flow] Ignoring injected hook that failed to materialize:',\n e instanceof Error ? e.message : 'Unknown error',\n );\n }\n }\n\n if (metas.length) {\n const start = opts?.orderStart ?? orderBase;\n mergeHookMetasIntoStageMap(FlowClass, stages, metas, start);\n if (opts?.orderStart === undefined) orderBase += metas.length;\n }\n };\n\n const appendContextHooks = async (\n hooks: HookEntry<FlowInputOf<Name>, Name, FlowStagesOf<Name>, FlowCtxOf<Name>>[],\n ) => {\n await materializeAndMerge(hooks);\n };\n\n // Construct flow instance with merged dependencies (includes scoped providers)\n // eslint-disable-next-line prefer-const -- declaration must precede helper functions that close over context\n context = new FlowClass(this.metadata, input, scope, appendContextHooks, mergedDeps);\n\n // Now injections can materialize\n contextReady = true;\n\n // Initial registry hooks should not pre-empt stages; they just get registered\n await materializeAndMerge(initialInjectedHooks, { orderStart: -1_000_000 });\n\n // Refresh order base to be after everything currently present\n orderBase = Math.max(0, ...Object.values(stages).flatMap((list) => list.map((e: any) => e._order ?? 0))) + 1;\n\n let responded: FlowOutputOf<Name> | undefined;\n\n // Robust list runner (doesn't skip mid-run insertions)\n const runList = async (key: string, opts?: { ignoreRespond?: boolean }): Promise<StageResult> => {\n const getList = () => ((stages as any)[key] ?? []) as Array<{ method: (ctx: any) => Promise<void> }>;\n const seen = new Set<any>();\n\n while (true) {\n const list = getList();\n const item = list.find((e) => !seen.has(e));\n if (!item) break;\n seen.add(item);\n\n try {\n await item.method(context);\n } catch (e: any) {\n if (e instanceof FlowControl) {\n if (e.type === 'respond') {\n if (!opts?.ignoreRespond) {\n responded = e.output as FlowOutputOf<Name>;\n return { outcome: 'respond', control: e };\n }\n continue;\n }\n return { outcome: e.type, control: e };\n }\n return { outcome: 'unknown_error', control: e as Error };\n }\n }\n return { outcome: 'ok' };\n };\n\n // Run exactly one stage in order: will → around → stage → did (did runs once)\n const runOneStage = async (stageName: string, stopOnRespond: boolean): Promise<StageResult> => {\n // 1) willStage\n {\n const res = await runList(WILL(stageName));\n if (res.outcome === 'respond' && stopOnRespond) return res;\n if (res.outcome !== 'ok' && res.outcome !== 'respond') return res;\n }\n\n // 2) aroundStage (acts as pre-handlers unless you later add true wrapping)\n {\n const res = await runList(AROUND(stageName));\n if (res.outcome === 'respond' && stopOnRespond) return res;\n if (res.outcome !== 'ok' && res.outcome !== 'respond') return res;\n }\n\n // 3) stage\n let bodyOutcome: StageResult = { outcome: 'ok' };\n {\n const res = await runList(stageName, { ignoreRespond: false });\n bodyOutcome = res;\n if (res.outcome !== 'ok' && res.outcome !== 'respond') {\n // fail/abort/next/handled/unknown → do NOT run did\n return res;\n }\n }\n\n // 4) didStage (run once regardless of body respond)\n {\n const res = await runList(DID(stageName), { ignoreRespond: true });\n if (res.outcome !== 'ok' && res.outcome !== 'respond') return res;\n }\n\n if (bodyOutcome.outcome === 'respond') return bodyOutcome;\n return { outcome: 'ok' };\n };\n\n // IMPORTANT: ignore typed stage names in plan arrays.\n // Only base stage names in the plan drive execution; typed hooks run *with* their base.\n const runStageGroup = async (\n group: Array<string> | undefined,\n stopOnRespond: boolean,\n opts?: { ignoreRespond?: boolean },\n ): Promise<StageResult> => {\n if (!group || group.length === 0) return { outcome: 'ok' };\n\n const seenBase = new Set<string>();\n for (const rawKey of group) {\n const { base, type } = parseTypedKey(rawKey);\n if (type) {\n // Soft warning once per typed key occurrence (optional)\n // console.warn(`[flow] Ignoring typed stage \"${rawKey}\" in plan; hooks will run with base \"${base}\".`);\n continue; // Do not run typed keys as standalone stages\n }\n if (seenBase.has(base)) continue;\n seenBase.add(base);\n\n const res = await runOneStage(base, stopOnRespond);\n if (res.outcome === 'respond') {\n if (stopOnRespond) return res;\n // else keep going\n } else if (res.outcome !== 'ok') {\n return res;\n }\n }\n return { outcome: 'ok' };\n };\n\n const runErrorStage = async () => {\n await runStageGroup((plan as any).error, false, { ignoreRespond: true });\n };\n\n const runFinalizeStage = async (options?: { suppressErrors?: boolean }) => {\n const res = await runStageGroup((plan as any).finalize, false);\n // Handle finalize stage errors\n if (res.outcome === 'unknown_error' || res.outcome === 'fail') {\n const finalizeError = res.control ?? new InternalMcpError('Finalize stage failed');\n if (options?.suppressErrors) {\n // Log finalizes errors but doesn't throw when called from finally blocks\n // This prevents masking the original error\n this.scope.logger.error(\n '[FrontMCP] Finalize stage error (suppressed to preserve original error):',\n finalizeError,\n );\n return res;\n }\n throw finalizeError;\n }\n return res;\n };\n\n // ---------- PRE ----------\n {\n const pre = await runStageGroup((plan as any).pre, true);\n if (pre.outcome === 'respond') {\n const post = await runStageGroup((plan as any).post, false);\n if (post.outcome === 'unknown_error' || post.outcome === 'fail') {\n try {\n await runErrorStage();\n } finally {\n await runFinalizeStage({ suppressErrors: true });\n }\n throw post.control ?? new InternalMcpError('Missing control for fail/error outcome');\n }\n if (post.outcome === 'abort' || post.outcome === 'next' || post.outcome === 'handled') {\n await runFinalizeStage({ suppressErrors: true });\n if (!(post.control instanceof FlowControl)) {\n throw new InternalMcpError('Expected FlowControl but received different error type');\n }\n throw post.control;\n }\n await runFinalizeStage();\n return responded;\n }\n if (pre.outcome === 'unknown_error' || pre.outcome === 'fail') {\n try {\n await runErrorStage();\n } finally {\n await runFinalizeStage({ suppressErrors: true });\n }\n throw pre.control ?? new InternalMcpError('Missing control for fail/error outcome');\n }\n if (pre.outcome === 'abort' || pre.outcome === 'next' || pre.outcome === 'handled') {\n await runFinalizeStage({ suppressErrors: true });\n if (!(pre.control instanceof FlowControl)) {\n throw new InternalMcpError('Expected FlowControl but received different error type');\n }\n throw pre.control;\n }\n }\n\n // ---------- EXECUTE ----------\n if (!responded) {\n const exec = await runStageGroup((plan as any).execute, true);\n if (exec.outcome === 'respond') {\n // continue to post + finalize\n } else if (exec.outcome === 'unknown_error' || exec.outcome === 'fail') {\n try {\n await runErrorStage();\n } finally {\n await runFinalizeStage({ suppressErrors: true });\n }\n throw exec.control ?? new InternalMcpError('Missing control for fail/error outcome');\n } else if (exec.outcome === 'abort' || exec.outcome === 'next' || exec.outcome === 'handled') {\n await runFinalizeStage({ suppressErrors: true });\n if (!(exec.control instanceof FlowControl)) {\n throw new InternalMcpError('Expected FlowControl but received different error type');\n }\n throw exec.control;\n }\n }\n\n // ---------- POST ----------\n {\n const post = await runStageGroup((plan as any).post, false);\n if (post.outcome === 'unknown_error' || post.outcome === 'fail') {\n try {\n await runErrorStage();\n } finally {\n await runFinalizeStage({ suppressErrors: true });\n }\n throw post.control ?? new InternalMcpError('Missing control for fail/error outcome');\n }\n if (post.outcome === 'abort' || post.outcome === 'next' || post.outcome === 'handled') {\n await runFinalizeStage({ suppressErrors: true });\n if (!(post.control instanceof FlowControl)) {\n throw new InternalMcpError('Expected FlowControl but received different error type');\n }\n throw post.control;\n }\n }\n\n // ---------- FINALIZE ----------\n await runFinalizeStage();\n\n return responded;\n }\n}\n"]}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const regsitry_1 = require("../regsitry");
|
|
4
|
-
const common_1 = require("../common");
|
|
5
|
-
const flow_utils_1 = require("./flow.utils");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const flow_instance_1 = require("./flow.instance");
|
|
8
|
-
const context_1 = require("../context");
|
|
9
|
-
const crypto_1 = require("crypto");
|
|
10
|
-
class FlowRegistry extends regsitry_1.RegistryAbstract {
|
|
11
|
-
constructor(providers, list) {
|
|
12
|
-
super('FlowRegistry', providers, list);
|
|
13
|
-
}
|
|
14
|
-
buildMap(list) {
|
|
15
|
-
const tokens = new Set();
|
|
16
|
-
const defs = new Map();
|
|
17
|
-
const graph = new Map();
|
|
18
|
-
for (const raw of list) {
|
|
19
|
-
const rec = (0, flow_utils_1.normalizeFlow)(raw);
|
|
20
|
-
const provide = rec.provide;
|
|
21
|
-
tokens.add(provide);
|
|
22
|
-
defs.set(provide, rec);
|
|
23
|
-
graph.set(provide, new Set());
|
|
24
|
-
}
|
|
25
|
-
return { tokens, defs, graph };
|
|
26
|
-
}
|
|
27
|
-
buildGraph() {
|
|
28
|
-
for (const token of this.tokens) {
|
|
29
|
-
const rec = this.defs.get(token);
|
|
30
|
-
const deps = rec.metadata.dependsOn ?? [];
|
|
31
|
-
for (const d of deps) {
|
|
32
|
-
if (d == common_1.ScopeEntry) {
|
|
33
|
-
this.graph.get(token).add(common_1.ScopeEntry);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
if (!this.providers.get(d)) {
|
|
37
|
-
throw new Error(`Flow ${(0, utils_1.tokenName)(token)} depends on ${(0, utils_1.tokenName)(d)}, which is not registered.`);
|
|
38
|
-
}
|
|
39
|
-
this.graph.get(token).add(d);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/** Instantiate adapters, run fetch/transform, and populate registries. */
|
|
45
|
-
async initialize() {
|
|
46
|
-
const readyArr = [];
|
|
47
|
-
for (const token of this.tokens) {
|
|
48
|
-
const instance = this.initializeOne(token);
|
|
49
|
-
readyArr.push(instance.ready);
|
|
50
|
-
}
|
|
51
|
-
await Promise.all(readyArr);
|
|
52
|
-
}
|
|
53
|
-
initializeOne(token) {
|
|
54
|
-
const rec = this.defs.get(token);
|
|
55
|
-
const deps = this.graph.get(token);
|
|
56
|
-
const instance = new flow_instance_1.FlowInstance(this.providers.getActiveScope(), rec, deps, this.providers);
|
|
57
|
-
this.instances.set(rec.metadata.name, instance);
|
|
58
|
-
return instance;
|
|
59
|
-
}
|
|
60
|
-
async registryFlows(rawFlows) {
|
|
61
|
-
const readyArr = [];
|
|
62
|
-
for (const raw of rawFlows) {
|
|
63
|
-
const rec = (0, flow_utils_1.normalizeFlow)(raw);
|
|
64
|
-
const provide = rec.provide;
|
|
65
|
-
this.tokens.add(provide);
|
|
66
|
-
this.defs.set(provide, rec);
|
|
67
|
-
this.graph.set(provide, new Set());
|
|
68
|
-
readyArr.push(this.initializeOne(provide).ready);
|
|
69
|
-
}
|
|
70
|
-
await Promise.all(readyArr);
|
|
71
|
-
}
|
|
72
|
-
runFlow(name, input, deps) {
|
|
73
|
-
const flow = this.instances.get(name);
|
|
74
|
-
if (!flow) {
|
|
75
|
-
throw new Error(`Flow ${name} is not registered`);
|
|
76
|
-
}
|
|
77
|
-
// Get context storage for MCP flows (if not already in a context)
|
|
78
|
-
const contextStorage = this.getContextStorage();
|
|
79
|
-
if (!contextStorage) {
|
|
80
|
-
// No context storage available, run without context (backward compatibility)
|
|
81
|
-
return flow.run(input, deps ?? new Map());
|
|
82
|
-
}
|
|
83
|
-
// Check if we're already in a context (e.g., HTTP middleware flow)
|
|
84
|
-
const existingContext = contextStorage.getStore();
|
|
85
|
-
if (existingContext) {
|
|
86
|
-
// Already in context, run directly
|
|
87
|
-
return flow.run(input, deps ?? new Map());
|
|
88
|
-
}
|
|
89
|
-
// Extract session info from MCP handler context (input.ctx.authInfo)
|
|
90
|
-
// MCP handlers pass { request, ctx } where ctx has authInfo
|
|
91
|
-
const mcpCtx = input?.ctx;
|
|
92
|
-
const authInfo = mcpCtx?.authInfo;
|
|
93
|
-
// Get session ID from authInfo (set by ensureAuthInfo in transport adapter)
|
|
94
|
-
// Fall back to anonymous session if not available
|
|
95
|
-
const rawSessionId = authInfo?.sessionId;
|
|
96
|
-
const sessionId = typeof rawSessionId === 'string' && rawSessionId.trim().length > 0 ? rawSessionId.trim() : `anon:${(0, crypto_1.randomUUID)()}`;
|
|
97
|
-
const scope = this.providers.getActiveScope();
|
|
98
|
-
// Wrap flow execution in FrontMcpContext
|
|
99
|
-
return Promise.resolve(contextStorage.run({
|
|
100
|
-
sessionId,
|
|
101
|
-
scopeId: scope.id,
|
|
102
|
-
authInfo,
|
|
103
|
-
}, async () => {
|
|
104
|
-
return flow.run(input, deps ?? new Map());
|
|
105
|
-
}));
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Get FrontMcpContextStorage from providers (with fallback).
|
|
109
|
-
* Returns undefined if not available (backward compatibility).
|
|
110
|
-
*/
|
|
111
|
-
getContextStorage() {
|
|
112
|
-
try {
|
|
113
|
-
return this.providers.get(context_1.FrontMcpContextStorage);
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
return undefined;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.default = FlowRegistry;
|
|
121
|
-
//# sourceMappingURL=flow.registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flow.registry.js","sourceRoot":"","sources":["../../../src/flows/flow.registry.ts"],"names":[],"mappings":";;AACA,0CAAuE;AACvE,sCAA+G;AAC/G,6CAA6C;AAC7C,oCAAqC;AACrC,mDAA+C;AAC/C,wCAAoD;AACpD,mCAAoC;AAEpC,MAAqB,YAAa,SAAQ,2BAAgE;IACxG,YAAY,SAA2B,EAAE,IAAgB;QACvD,KAAK,CAAC,cAAc,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAEkB,QAAQ,CAAC,IAAgB;QAC1C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAS,CAAC;QAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAqB,CAAC;QAC1C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;QAE3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,GAAG,GAAG,IAAA,0BAAa,EAAC,GAAG,CAAC,CAAC;YAC/B,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;YAC5B,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACpB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACvB,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC;IAES,UAAU;QAClB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAA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ACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAtID,+BAsIC","sourcesContent":["import ProviderRegistry from '../provider/provider.registry';\nimport { RegistryAbstract, RegistryBuildMapResult } from '../regsitry';\nimport { FlowInputOf, FlowName, FlowOutputOf, FlowRecord, FlowType, ScopeEntry, Token, Type } from '../common';\nimport { normalizeFlow } from './flow.utils';\nimport { tokenName } from '../utils';\nimport { FlowInstance } from './flow.instance';\nimport { FrontMcpContextStorage } from '../context';\nimport { randomUUID } from 'crypto';\n\nexport default class FlowRegistry extends RegistryAbstract<FlowInstance<FlowName>, FlowRecord, FlowType[]> {\n constructor(providers: ProviderRegistry, list: FlowType[]) {\n super('FlowRegistry', providers, list);\n }\n\n protected override buildMap(list: FlowType[]): RegistryBuildMapResult<FlowRecord> {\n const tokens = new Set<Token>();\n const defs = new Map<Token, FlowRecord>();\n const graph = new Map<Token, Set<Token>>();\n\n for (const raw of list) {\n const rec = normalizeFlow(raw);\n const provide = rec.provide;\n tokens.add(provide);\n defs.set(provide, rec);\n graph.set(provide, new Set());\n }\n\n return { tokens, defs, graph };\n }\n\n protected buildGraph() {\n for (const token of this.tokens) {\n const rec = this.defs.get(token)!;\n const deps = rec.metadata.dependsOn ?? [];\n\n for (const d of deps) {\n if (d == ScopeEntry) {\n this.graph.get(token)!.add(ScopeEntry);\n } else {\n if (!this.providers.get(d)) {\n throw new Error(`Flow ${tokenName(token)} depends on ${tokenName(d)}, which is not registered.`);\n }\n this.graph.get(token)!.add(d);\n }\n }\n }\n }\n\n /** Instantiate adapters, run fetch/transform, and populate registries. */\n protected async initialize(): Promise<void> {\n const readyArr: Promise<void>[] = [];\n for (const token of this.tokens) {\n const instance = this.initializeOne(token);\n readyArr.push(instance.ready);\n }\n await Promise.all(readyArr);\n }\n\n private initializeOne(token: Token) {\n const rec = this.defs.get(token)!;\n const deps = this.graph.get(token)!;\n\n const instance = new FlowInstance(this.providers.getActiveScope(), rec, deps, this.providers);\n this.instances.set(rec.metadata.name, instance);\n return instance;\n }\n\n async registryFlows(rawFlows: FlowType[]): Promise<void> {\n const readyArr: Promise<void>[] = [];\n for (const raw of rawFlows) {\n const rec = normalizeFlow(raw);\n const provide = rec.provide;\n this.tokens.add(provide);\n this.defs.set(provide, rec);\n this.graph.set(provide, new Set());\n readyArr.push(this.initializeOne(provide).ready);\n }\n await Promise.all(readyArr);\n }\n\n runFlow<Name extends FlowName>(\n name: Name,\n input: FlowInputOf<Name>,\n deps?: Map<Token, Type>,\n ): Promise<FlowOutputOf<Name> | undefined> {\n const flow = this.instances.get(name);\n if (!flow) {\n throw new Error(`Flow ${name} is not registered`);\n }\n\n // Get context storage for MCP flows (if not already in a context)\n const contextStorage = this.getContextStorage();\n if (!contextStorage) {\n // No context storage available, run without context (backward compatibility)\n return flow.run(input, deps ?? new Map()) as Promise<FlowOutputOf<Name> | undefined>;\n }\n\n // Check if we're already in a context (e.g., HTTP middleware flow)\n const existingContext = contextStorage.getStore();\n if (existingContext) {\n // Already in context, run directly\n return flow.run(input, deps ?? new Map()) as Promise<FlowOutputOf<Name> | undefined>;\n }\n\n // Extract session info from MCP handler context (input.ctx.authInfo)\n // MCP handlers pass { request, ctx } where ctx has authInfo\n const mcpCtx = (input as any)?.ctx;\n const authInfo = mcpCtx?.authInfo;\n\n // Get session ID from authInfo (set by ensureAuthInfo in transport adapter)\n // Fall back to anonymous session if not available\n const rawSessionId = authInfo?.sessionId;\n const sessionId =\n typeof rawSessionId === 'string' && rawSessionId.trim().length > 0 ? rawSessionId.trim() : `anon:${randomUUID()}`;\n\n const scope = this.providers.getActiveScope();\n\n // Wrap flow execution in FrontMcpContext\n return Promise.resolve(\n contextStorage.run(\n {\n sessionId,\n scopeId: scope.id,\n authInfo,\n },\n async () => {\n return flow.run(input, deps ?? new Map()) as Promise<FlowOutputOf<Name> | undefined>;\n },\n ),\n );\n }\n\n /**\n * Get FrontMcpContextStorage from providers (with fallback).\n * Returns undefined if not available (backward compatibility).\n */\n private getContextStorage(): FrontMcpContextStorage | undefined {\n try {\n return this.providers.get(FrontMcpContextStorage);\n } catch {\n return undefined;\n }\n }\n}\n"]}
|