@frontmcp/sdk 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +12 -16
- package/src/adapter/adapter.instance.js +5 -0
- package/src/adapter/adapter.instance.js.map +1 -1
- package/src/auth/authorization/authorization.class.d.ts +1 -4
- package/src/auth/authorization/authorization.class.js +6 -13
- package/src/auth/authorization/authorization.class.js.map +1 -1
- package/src/auth/flows/session.verify.flow.d.ts +1 -0
- package/src/auth/flows/session.verify.flow.js +11 -1
- package/src/auth/flows/session.verify.flow.js.map +1 -1
- package/src/auth/flows/well-known.jwks.flow.js +2 -2
- package/src/auth/flows/well-known.jwks.flow.js.map +1 -1
- package/src/auth/jwks/dev-key-persistence.d.ts +63 -0
- package/src/auth/jwks/dev-key-persistence.js +219 -0
- package/src/auth/jwks/dev-key-persistence.js.map +1 -0
- package/src/auth/jwks/index.d.ts +1 -0
- package/src/auth/jwks/index.js +1 -0
- package/src/auth/jwks/index.js.map +1 -1
- package/src/auth/jwks/jwks.service.d.ts +7 -4
- package/src/auth/jwks/jwks.service.js +81 -12
- package/src/auth/jwks/jwks.service.js.map +1 -1
- package/src/auth/jwks/jwks.types.d.ts +7 -0
- package/src/auth/jwks/jwks.types.js.map +1 -1
- package/src/auth/machine-id.d.ts +5 -0
- package/src/auth/machine-id.js +32 -0
- package/src/auth/machine-id.js.map +1 -0
- package/src/auth/session/index.d.ts +2 -0
- package/src/auth/session/index.js +5 -1
- package/src/auth/session/index.js.map +1 -1
- package/src/auth/session/record/session.base.js +5 -3
- package/src/auth/session/record/session.base.js.map +1 -1
- package/src/auth/session/record/session.stateless.d.ts +2 -2
- package/src/auth/session/record/session.stateless.js +5 -3
- package/src/auth/session/record/session.stateless.js.map +1 -1
- package/src/auth/session/redis-session.store.d.ts +64 -0
- package/src/auth/session/redis-session.store.js +204 -0
- package/src/auth/session/redis-session.store.js.map +1 -0
- package/src/auth/session/session.service.d.ts +0 -2
- package/src/auth/session/session.service.js +1 -7
- package/src/auth/session/session.service.js.map +1 -1
- package/src/auth/session/transport-session.manager.js +3 -5
- package/src/auth/session/transport-session.manager.js.map +1 -1
- package/src/auth/session/transport-session.types.d.ts +4 -0
- package/src/auth/session/transport-session.types.js +4 -3
- package/src/auth/session/transport-session.types.js.map +1 -1
- package/src/auth/session/utils/session-id.utils.d.ts +12 -1
- package/src/auth/session/utils/session-id.utils.js +48 -9
- package/src/auth/session/utils/session-id.utils.js.map +1 -1
- package/src/auth/session/vercel-kv-session.store.d.ts +96 -0
- package/src/auth/session/vercel-kv-session.store.js +216 -0
- package/src/auth/session/vercel-kv-session.store.js.map +1 -0
- package/src/auth/ui/base-layout.d.ts +0 -8
- package/src/auth/ui/base-layout.js +1 -14
- package/src/auth/ui/base-layout.js.map +1 -1
- package/src/auth/ui/index.d.ts +3 -4
- package/src/auth/ui/index.js +10 -11
- package/src/auth/ui/index.js.map +1 -1
- package/src/auth/ui/{htmx-templates.d.ts → templates.d.ts} +5 -6
- package/src/auth/ui/{htmx-templates.js → templates.js} +8 -15
- package/src/auth/ui/templates.js.map +1 -0
- package/src/common/decorators/decorator-utils.js.map +1 -1
- package/src/common/decorators/front-mcp.decorator.js +26 -3
- package/src/common/decorators/front-mcp.decorator.js.map +1 -1
- package/src/common/index.d.ts +0 -1
- package/src/common/index.js +0 -1
- package/src/common/index.js.map +1 -1
- package/src/common/interfaces/adapter.interface.d.ts +6 -0
- package/src/common/interfaces/adapter.interface.js.map +1 -1
- package/src/common/interfaces/execution-context.interface.d.ts +52 -3
- package/src/common/interfaces/execution-context.interface.js +88 -3
- package/src/common/interfaces/execution-context.interface.js.map +1 -1
- package/src/common/interfaces/flow.interface.d.ts +13 -0
- package/src/common/interfaces/flow.interface.js +24 -0
- package/src/common/interfaces/flow.interface.js.map +1 -1
- package/src/common/interfaces/server.interface.d.ts +9 -0
- package/src/common/interfaces/server.interface.js.map +1 -1
- package/src/common/metadata/app.metadata.d.ts +108 -0
- package/src/common/metadata/front-mcp.metadata.d.ts +1341 -2
- package/src/common/metadata/front-mcp.metadata.js +4 -1
- package/src/common/metadata/front-mcp.metadata.js.map +1 -1
- package/src/common/metadata/prompt.metadata.d.ts +4 -0
- package/src/common/metadata/provider.metadata.d.ts +14 -0
- package/src/common/metadata/provider.metadata.js +18 -2
- package/src/common/metadata/provider.metadata.js.map +1 -1
- package/src/common/metadata/resource.metadata.d.ts +8 -0
- package/src/common/metadata/tool-ui.metadata.d.ts +2 -2
- package/src/common/metadata/tool-ui.metadata.js +1 -1
- package/src/common/metadata/tool-ui.metadata.js.map +1 -1
- package/src/common/metadata/tool.metadata.d.ts +5 -1
- package/src/common/metadata/tool.metadata.js.map +1 -1
- package/src/common/migrate/auth-transport.migrate.d.ts +62 -0
- package/src/common/migrate/auth-transport.migrate.js +140 -0
- package/src/common/migrate/auth-transport.migrate.js.map +1 -0
- package/src/common/migrate/index.d.ts +1 -0
- package/src/common/migrate/index.js +6 -0
- package/src/common/migrate/index.js.map +1 -0
- package/src/common/schemas/http-output.schema.d.ts +24 -6
- package/src/common/schemas/index.d.ts +1 -0
- package/src/common/schemas/index.js +1 -0
- package/src/common/schemas/index.js.map +1 -1
- package/src/common/schemas/session-header.schema.d.ts +16 -0
- package/src/common/schemas/session-header.schema.js +42 -0
- package/src/common/schemas/session-header.schema.js.map +1 -0
- package/src/common/tokens/front-mcp.tokens.js +4 -1
- package/src/common/tokens/front-mcp.tokens.js.map +1 -1
- package/src/common/types/options/auth.options.d.ts +233 -3
- package/src/common/types/options/auth.options.js +29 -40
- package/src/common/types/options/auth.options.js.map +1 -1
- package/src/common/types/options/index.d.ts +2 -0
- package/src/common/types/options/index.js +2 -0
- package/src/common/types/options/index.js.map +1 -1
- package/src/common/types/options/redis.options.d.ts +190 -0
- package/src/common/types/options/redis.options.js +191 -0
- package/src/common/types/options/redis.options.js.map +1 -0
- package/src/common/types/options/server-info.options.d.ts +4 -0
- package/src/common/types/options/transport.options.d.ts +148 -0
- package/src/common/types/options/transport.options.js +121 -0
- package/src/common/types/options/transport.options.js.map +1 -0
- package/src/common/utils/global-config.utils.d.ts +36 -0
- package/src/common/utils/global-config.utils.js +44 -0
- package/src/common/utils/global-config.utils.js.map +1 -0
- package/src/common/utils/index.d.ts +1 -0
- package/src/common/utils/index.js +1 -0
- package/src/common/utils/index.js.map +1 -1
- package/src/completion/flows/complete.flow.d.ts +6 -8
- package/src/context/frontmcp-context-storage.d.ts +94 -0
- package/src/context/frontmcp-context-storage.js +183 -0
- package/src/context/frontmcp-context-storage.js.map +1 -0
- package/src/context/frontmcp-context.d.ts +269 -0
- package/src/context/frontmcp-context.js +360 -0
- package/src/context/frontmcp-context.js.map +1 -0
- package/src/context/frontmcp-context.provider.d.ts +43 -0
- package/src/context/frontmcp-context.provider.js +61 -0
- package/src/context/frontmcp-context.provider.js.map +1 -0
- package/src/context/index.d.ts +34 -0
- package/src/context/index.js +64 -0
- package/src/context/index.js.map +1 -0
- package/src/context/request-context-storage.d.ts +89 -0
- package/src/context/request-context-storage.js +183 -0
- package/src/context/request-context-storage.js.map +1 -0
- package/src/context/request-context.d.ts +184 -0
- package/src/context/request-context.js +209 -0
- package/src/context/request-context.js.map +1 -0
- package/src/context/request-context.provider.d.ts +37 -0
- package/src/context/request-context.provider.js +51 -0
- package/src/context/request-context.provider.js.map +1 -0
- package/src/context/session-key.provider.d.ts +45 -0
- package/src/context/session-key.provider.js +65 -0
- package/src/context/session-key.provider.js.map +1 -0
- package/src/context/trace-context.d.ts +43 -0
- package/src/context/trace-context.js +142 -0
- package/src/context/trace-context.js.map +1 -0
- package/src/errors/index.d.ts +1 -1
- package/src/errors/index.js +4 -1
- package/src/errors/index.js.map +1 -1
- package/src/errors/mcp.error.d.ts +16 -0
- package/src/errors/mcp.error.js +29 -1
- package/src/errors/mcp.error.js.map +1 -1
- package/src/flows/flow.instance.d.ts +16 -0
- package/src/flows/flow.instance.js +166 -80
- package/src/flows/flow.instance.js.map +1 -1
- package/src/flows/flow.registry.d.ts +5 -0
- package/src/flows/flow.registry.js +45 -3
- package/src/flows/flow.registry.js.map +1 -1
- package/src/front-mcp/front-mcp.d.ts +12 -0
- package/src/front-mcp/front-mcp.js +22 -3
- package/src/front-mcp/front-mcp.js.map +1 -1
- package/src/front-mcp/front-mcp.providers.d.ts +474 -1
- package/src/front-mcp/front-mcp.providers.js +2 -1
- package/src/front-mcp/front-mcp.providers.js.map +1 -1
- package/src/front-mcp/index.d.ts +1 -0
- package/src/front-mcp/index.js +3 -0
- package/src/front-mcp/index.js.map +1 -1
- package/src/front-mcp/serverless-handler.d.ts +28 -0
- package/src/front-mcp/serverless-handler.js +61 -0
- package/src/front-mcp/serverless-handler.js.map +1 -0
- package/src/hooks/hooks.utils.d.ts +1 -1
- package/src/hooks/hooks.utils.js +10 -3
- package/src/hooks/hooks.utils.js.map +1 -1
- package/src/index.d.ts +9 -5
- package/src/index.js +21 -1
- package/src/index.js.map +1 -1
- package/src/logger/instances/instance.logger.js +0 -1
- package/src/logger/instances/instance.logger.js.map +1 -1
- package/src/logging/flows/set-level.flow.d.ts +6 -8
- package/src/notification/notification.service.js +5 -1
- package/src/notification/notification.service.js.map +1 -1
- package/src/prompt/flows/get-prompt.flow.d.ts +14 -8
- package/src/prompt/flows/prompts-list.flow.d.ts +8 -7
- package/src/provider/provider.registry.d.ts +97 -5
- package/src/provider/provider.registry.js +306 -9
- package/src/provider/provider.registry.js.map +1 -1
- package/src/provider/provider.types.d.ts +21 -3
- package/src/provider/provider.types.js.map +1 -1
- package/src/resource/flows/read-resource.flow.d.ts +8 -9
- package/src/resource/flows/resource-templates-list.flow.d.ts +8 -7
- package/src/resource/flows/resources-list.flow.d.ts +8 -7
- package/src/resource/flows/subscribe-resource.flow.d.ts +6 -8
- package/src/resource/flows/unsubscribe-resource.flow.d.ts +6 -8
- package/src/scope/flows/http.request.flow.js +43 -7
- package/src/scope/flows/http.request.flow.js.map +1 -1
- package/src/scope/scope.instance.js +12 -5
- package/src/scope/scope.instance.js.map +1 -1
- package/src/server/adapters/base.host.adapter.d.ts +9 -0
- package/src/server/adapters/base.host.adapter.js.map +1 -1
- package/src/server/adapters/express.host.adapter.d.ts +12 -0
- package/src/server/adapters/express.host.adapter.js +21 -1
- package/src/server/adapters/express.host.adapter.js.map +1 -1
- package/src/server/server.instance.d.ts +3 -0
- package/src/server/server.instance.js +14 -7
- package/src/server/server.instance.js.map +1 -1
- package/src/store/adapters/store.vercel-kv.adapter.d.ts +86 -0
- package/src/store/adapters/store.vercel-kv.adapter.js +155 -0
- package/src/store/adapters/store.vercel-kv.adapter.js.map +1 -0
- package/src/store/index.d.ts +2 -0
- package/src/store/index.js +2 -0
- package/src/store/index.js.map +1 -1
- package/src/store/store.factory.d.ts +86 -0
- package/src/store/store.factory.js +194 -0
- package/src/store/store.factory.js.map +1 -0
- package/src/tool/flows/call-tool.flow.d.ts +38 -19
- package/src/tool/flows/call-tool.flow.js +240 -194
- package/src/tool/flows/call-tool.flow.js.map +1 -1
- package/src/tool/flows/tools-list.flow.d.ts +14 -17
- package/src/tool/flows/tools-list.flow.js +84 -33
- package/src/tool/flows/tools-list.flow.js.map +1 -1
- package/src/tool/tool.instance.d.ts +1 -4
- package/src/tool/ui/index.d.ts +4 -4
- package/src/tool/ui/index.js +4 -4
- package/src/tool/ui/index.js.map +1 -1
- package/src/tool/ui/platform-adapters.d.ts +2 -2
- package/src/tool/ui/platform-adapters.js +3 -3
- package/src/tool/ui/platform-adapters.js.map +1 -1
- package/src/tool/ui/template-helpers.d.ts +5 -7
- package/src/tool/ui/template-helpers.js +9 -26
- package/src/tool/ui/template-helpers.js.map +1 -1
- package/src/tool/ui/ui-resource.handler.d.ts +1 -1
- package/src/tool/ui/ui-resource.handler.js +5 -5
- package/src/tool/ui/ui-resource.handler.js.map +1 -1
- package/src/transport/adapters/transport.streamable-http.adapter.js +1 -0
- package/src/transport/adapters/transport.streamable-http.adapter.js.map +1 -1
- package/src/transport/flows/handle.sse.flow.js +9 -2
- package/src/transport/flows/handle.sse.flow.js.map +1 -1
- package/src/transport/flows/handle.streamable-http.flow.js +63 -6
- package/src/transport/flows/handle.streamable-http.flow.js.map +1 -1
- package/src/transport/mcp-handlers/complete-request.handler.d.ts +4 -15
- package/src/transport/mcp-handlers/get-prompt-request.handler.d.ts +5 -15
- package/src/transport/mcp-handlers/index.d.ts +67 -195
- package/src/transport/mcp-handlers/initialize-request.handler.js +12 -2
- package/src/transport/mcp-handlers/initialize-request.handler.js.map +1 -1
- package/src/transport/mcp-handlers/list-prompts-request.handler.d.ts +5 -15
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.d.ts +5 -15
- package/src/transport/mcp-handlers/list-resources-request.handler.d.ts +5 -15
- package/src/transport/mcp-handlers/list-tools-request.handler.d.ts +5 -15
- package/src/transport/mcp-handlers/logging-set-level-request.handler.d.ts +3 -14
- package/src/transport/mcp-handlers/read-resource-request.handler.d.ts +4 -15
- package/src/transport/mcp-handlers/subscribe-request.handler.d.ts +3 -14
- package/src/transport/mcp-handlers/unsubscribe-request.handler.d.ts +3 -14
- package/src/transport/transport.registry.d.ts +72 -4
- package/src/transport/transport.registry.js +342 -11
- package/src/transport/transport.registry.js.map +1 -1
- package/src/auth/ui/htmx-templates.js.map +0 -1
- package/src/common/providers/session.provider.d.ts +0 -13
- package/src/common/providers/session.provider.js +0 -27
- package/src/common/providers/session.provider.js.map +0 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SessionMode, TransportIdMode, PlatformMappingEntry, PlatformDetectionConfig, platformDetectionConfigSchema } from './session.options';
|
|
3
|
+
export type { SessionMode, TransportIdMode, PlatformMappingEntry, PlatformDetectionConfig };
|
|
4
|
+
/**
|
|
5
|
+
* Transport persistence configuration
|
|
6
|
+
* Enables session persistence to Redis and automatic transport recreation after server restart
|
|
7
|
+
*/
|
|
8
|
+
export declare const transportPersistenceConfigSchema: z.ZodObject<{
|
|
9
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
+
redis: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
11
|
+
provider: z.ZodLiteral<"redis">;
|
|
12
|
+
host: z.ZodString;
|
|
13
|
+
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
14
|
+
password: z.ZodOptional<z.ZodString>;
|
|
15
|
+
db: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
16
|
+
tls: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
17
|
+
keyPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
18
|
+
defaultTtlMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
provider: z.ZodLiteral<"vercel-kv">;
|
|
21
|
+
url: z.ZodOptional<z.ZodString>;
|
|
22
|
+
token: z.ZodOptional<z.ZodString>;
|
|
23
|
+
keyPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
24
|
+
defaultTtlMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
25
|
+
}, z.core.$strip>, z.ZodPipe<z.ZodObject<{
|
|
26
|
+
host: z.ZodString;
|
|
27
|
+
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
28
|
+
password: z.ZodOptional<z.ZodString>;
|
|
29
|
+
db: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
30
|
+
tls: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
31
|
+
keyPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
32
|
+
defaultTtlMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
33
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
34
|
+
provider: "redis";
|
|
35
|
+
host: string;
|
|
36
|
+
port: number;
|
|
37
|
+
db: number;
|
|
38
|
+
tls: boolean;
|
|
39
|
+
keyPrefix: string;
|
|
40
|
+
defaultTtlMs: number;
|
|
41
|
+
password?: string | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
host: string;
|
|
44
|
+
port: number;
|
|
45
|
+
db: number;
|
|
46
|
+
tls: boolean;
|
|
47
|
+
keyPrefix: string;
|
|
48
|
+
defaultTtlMs: number;
|
|
49
|
+
password?: string | undefined;
|
|
50
|
+
}>>]>>;
|
|
51
|
+
defaultTtlMs: z.ZodDefault<z.ZodNumber>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
/**
|
|
54
|
+
* Transport options schema
|
|
55
|
+
* Consolidates transport protocol config + session lifecycle config
|
|
56
|
+
*/
|
|
57
|
+
export declare const transportOptionsSchema: z.ZodObject<{
|
|
58
|
+
sessionMode: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"stateful">, z.ZodLiteral<"stateless">, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>>;
|
|
59
|
+
transportIdMode: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"uuid">, z.ZodLiteral<"jwt">, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>>;
|
|
60
|
+
platformDetection: z.ZodOptional<z.ZodObject<{
|
|
61
|
+
mappings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
62
|
+
pattern: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<RegExp, RegExp>]>;
|
|
63
|
+
platform: z.ZodEnum<{
|
|
64
|
+
unknown: "unknown";
|
|
65
|
+
continue: "continue";
|
|
66
|
+
openai: "openai";
|
|
67
|
+
claude: "claude";
|
|
68
|
+
gemini: "gemini";
|
|
69
|
+
cursor: "cursor";
|
|
70
|
+
cody: "cody";
|
|
71
|
+
"generic-mcp": "generic-mcp";
|
|
72
|
+
"ext-apps": "ext-apps";
|
|
73
|
+
}>;
|
|
74
|
+
}, z.core.$strip>>>;
|
|
75
|
+
customOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
76
|
+
}, z.core.$strip>>;
|
|
77
|
+
enableLegacySSE: z.ZodDefault<z.ZodBoolean>;
|
|
78
|
+
enableSseListener: z.ZodDefault<z.ZodBoolean>;
|
|
79
|
+
enableStreamableHttp: z.ZodDefault<z.ZodBoolean>;
|
|
80
|
+
enableStatelessHttp: z.ZodDefault<z.ZodBoolean>;
|
|
81
|
+
enableStatefulHttp: z.ZodDefault<z.ZodBoolean>;
|
|
82
|
+
requireSessionForStreamable: z.ZodDefault<z.ZodBoolean>;
|
|
83
|
+
persistence: z.ZodOptional<z.ZodObject<{
|
|
84
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
85
|
+
redis: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
86
|
+
provider: z.ZodLiteral<"redis">;
|
|
87
|
+
host: z.ZodString;
|
|
88
|
+
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
89
|
+
password: z.ZodOptional<z.ZodString>;
|
|
90
|
+
db: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
91
|
+
tls: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
92
|
+
keyPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
93
|
+
defaultTtlMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
94
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
95
|
+
provider: z.ZodLiteral<"vercel-kv">;
|
|
96
|
+
url: z.ZodOptional<z.ZodString>;
|
|
97
|
+
token: z.ZodOptional<z.ZodString>;
|
|
98
|
+
keyPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
99
|
+
defaultTtlMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
100
|
+
}, z.core.$strip>, z.ZodPipe<z.ZodObject<{
|
|
101
|
+
host: z.ZodString;
|
|
102
|
+
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
103
|
+
password: z.ZodOptional<z.ZodString>;
|
|
104
|
+
db: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
105
|
+
tls: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
106
|
+
keyPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
107
|
+
defaultTtlMs: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
108
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
109
|
+
provider: "redis";
|
|
110
|
+
host: string;
|
|
111
|
+
port: number;
|
|
112
|
+
db: number;
|
|
113
|
+
tls: boolean;
|
|
114
|
+
keyPrefix: string;
|
|
115
|
+
defaultTtlMs: number;
|
|
116
|
+
password?: string | undefined;
|
|
117
|
+
}, {
|
|
118
|
+
host: string;
|
|
119
|
+
port: number;
|
|
120
|
+
db: number;
|
|
121
|
+
tls: boolean;
|
|
122
|
+
keyPrefix: string;
|
|
123
|
+
defaultTtlMs: number;
|
|
124
|
+
password?: string | undefined;
|
|
125
|
+
}>>]>>;
|
|
126
|
+
defaultTtlMs: z.ZodDefault<z.ZodNumber>;
|
|
127
|
+
}, z.core.$strip>>;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
/**
|
|
130
|
+
* Transport options type (with defaults applied)
|
|
131
|
+
*/
|
|
132
|
+
export type TransportOptions = z.infer<typeof transportOptionsSchema>;
|
|
133
|
+
/**
|
|
134
|
+
* Transport options input type (for user configuration)
|
|
135
|
+
*/
|
|
136
|
+
export type TransportOptionsInput = z.input<typeof transportOptionsSchema>;
|
|
137
|
+
/**
|
|
138
|
+
* Transport persistence configuration type
|
|
139
|
+
*/
|
|
140
|
+
export type TransportPersistenceConfig = z.infer<typeof transportPersistenceConfigSchema>;
|
|
141
|
+
/**
|
|
142
|
+
* Transport persistence configuration input type
|
|
143
|
+
*/
|
|
144
|
+
export type TransportPersistenceConfigInput = z.input<typeof transportPersistenceConfigSchema>;
|
|
145
|
+
/**
|
|
146
|
+
* Platform detection configuration type
|
|
147
|
+
*/
|
|
148
|
+
export type PlatformDetectionConfigType = z.infer<typeof platformDetectionConfigSchema>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// common/types/options/transport.options.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.transportOptionsSchema = exports.transportPersistenceConfigSchema = void 0;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const redis_options_1 = require("./redis.options");
|
|
7
|
+
const session_options_1 = require("./session.options");
|
|
8
|
+
// ============================================
|
|
9
|
+
// TRANSPORT PERSISTENCE (from auth.transport.recreation)
|
|
10
|
+
// ============================================
|
|
11
|
+
/**
|
|
12
|
+
* Transport persistence configuration
|
|
13
|
+
* Enables session persistence to Redis and automatic transport recreation after server restart
|
|
14
|
+
*/
|
|
15
|
+
exports.transportPersistenceConfigSchema = zod_1.z.object({
|
|
16
|
+
/**
|
|
17
|
+
* Enable transport persistence to Redis
|
|
18
|
+
* When enabled, sessions are persisted to Redis and transports can be recreated after restart
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
enabled: zod_1.z.boolean().default(false),
|
|
22
|
+
/**
|
|
23
|
+
* Redis configuration for session storage
|
|
24
|
+
* If omitted when enabled=true, uses top-level redis config
|
|
25
|
+
* Note: Validation for redis presence happens at runtime when persistence is used
|
|
26
|
+
*/
|
|
27
|
+
redis: redis_options_1.redisOptionsSchema.optional(),
|
|
28
|
+
/**
|
|
29
|
+
* Default TTL for stored session metadata (milliseconds)
|
|
30
|
+
* @default 3600000 (1 hour)
|
|
31
|
+
*/
|
|
32
|
+
defaultTtlMs: zod_1.z.number().int().positive().default(3600000),
|
|
33
|
+
});
|
|
34
|
+
// ============================================
|
|
35
|
+
// TRANSPORT OPTIONS (unified config)
|
|
36
|
+
// ============================================
|
|
37
|
+
/**
|
|
38
|
+
* Transport options schema
|
|
39
|
+
* Consolidates transport protocol config + session lifecycle config
|
|
40
|
+
*/
|
|
41
|
+
exports.transportOptionsSchema = zod_1.z.object({
|
|
42
|
+
// ============================================
|
|
43
|
+
// Session Lifecycle (from session.options.ts)
|
|
44
|
+
// ============================================
|
|
45
|
+
/**
|
|
46
|
+
* Defines how the session lifecycle and nested tokens are managed.
|
|
47
|
+
*
|
|
48
|
+
* Modes:
|
|
49
|
+
* - `'stateful'`: Session and nested tokens are stored in a server-side store (e.g., Redis).
|
|
50
|
+
* - `'stateless'`: All session data (including nested tokens) is embedded within a signed/encrypted JWT.
|
|
51
|
+
*
|
|
52
|
+
* @default 'stateful'
|
|
53
|
+
*/
|
|
54
|
+
sessionMode: zod_1.z
|
|
55
|
+
.union([zod_1.z.literal('stateful'), zod_1.z.literal('stateless'), zod_1.z.function()])
|
|
56
|
+
.optional()
|
|
57
|
+
.default('stateful'),
|
|
58
|
+
/**
|
|
59
|
+
* Defines how the Transport ID is generated, verified, and used across sessions.
|
|
60
|
+
*
|
|
61
|
+
* Modes:
|
|
62
|
+
* - `'uuid'`: Generates a random UUID per session.
|
|
63
|
+
* - `'jwt'`: Uses a signed JWT for stateless sessions, signed with a generated session key.
|
|
64
|
+
*
|
|
65
|
+
* @default 'uuid'
|
|
66
|
+
*/
|
|
67
|
+
transportIdMode: zod_1.z
|
|
68
|
+
.union([zod_1.z.literal('uuid'), zod_1.z.literal('jwt'), zod_1.z.function()])
|
|
69
|
+
.optional()
|
|
70
|
+
.default('uuid'),
|
|
71
|
+
/**
|
|
72
|
+
* Configuration for detecting the AI platform from MCP client info.
|
|
73
|
+
* Allows custom mappings to override or supplement the default keyword-based detection.
|
|
74
|
+
*/
|
|
75
|
+
platformDetection: session_options_1.platformDetectionConfigSchema.optional(),
|
|
76
|
+
// ============================================
|
|
77
|
+
// Transport Protocols (from auth.transport)
|
|
78
|
+
// ============================================
|
|
79
|
+
/**
|
|
80
|
+
* Enable legacy SSE transport (old HTTP+SSE protocol)
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
enableLegacySSE: zod_1.z.boolean().default(false),
|
|
84
|
+
/**
|
|
85
|
+
* Enable SSE listener for server-initiated messages (GET /mcp with Accept: text/event-stream)
|
|
86
|
+
* @default true
|
|
87
|
+
*/
|
|
88
|
+
enableSseListener: zod_1.z.boolean().default(true),
|
|
89
|
+
/**
|
|
90
|
+
* Enable streamable HTTP transport (POST with SSE response)
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
enableStreamableHttp: zod_1.z.boolean().default(true),
|
|
94
|
+
/**
|
|
95
|
+
* Enable stateless HTTP mode (requests without session ID)
|
|
96
|
+
* When enabled, allows requests without prior initialize
|
|
97
|
+
* Uses shared singleton transport for anonymous, per-token singleton for authenticated
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
enableStatelessHttp: zod_1.z.boolean().default(false),
|
|
101
|
+
/**
|
|
102
|
+
* Enable stateful HTTP transport (JSON-only responses)
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
enableStatefulHttp: zod_1.z.boolean().default(false),
|
|
106
|
+
/**
|
|
107
|
+
* Require session ID for streamable HTTP (non-stateless mode)
|
|
108
|
+
* When false, streamable HTTP requests don't require prior initialize
|
|
109
|
+
* @default true
|
|
110
|
+
*/
|
|
111
|
+
requireSessionForStreamable: zod_1.z.boolean().default(true),
|
|
112
|
+
// ============================================
|
|
113
|
+
// Transport Persistence
|
|
114
|
+
// ============================================
|
|
115
|
+
/**
|
|
116
|
+
* Transport persistence configuration
|
|
117
|
+
* When enabled, sessions are persisted to Redis and transports can be recreated after server restart
|
|
118
|
+
*/
|
|
119
|
+
persistence: exports.transportPersistenceConfigSchema.optional(),
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=transport.options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.options.js","sourceRoot":"","sources":["../../../../../src/common/types/options/transport.options.ts"],"names":[],"mappings":";AAAA,4CAA4C;;;AAE5C,6BAAwB;AACxB,mDAAqD;AACrD,uDAO2B;AAK3B,+CAA+C;AAC/C,yDAAyD;AACzD,+CAA+C;AAE/C;;;GAGG;AACU,QAAA,gCAAgC,GAAG,OAAC,CAAC,MAAM,CAAC;IACvD;;;;OAIG;IACH,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAEnC;;;;OAIG;IACH,KAAK,EAAE,kCAAkB,CAAC,QAAQ,EAAE;IAEpC;;;OAGG;IACH,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;CAC3D,CAAC,CAAC;AAEH,+CAA+C;AAC/C,qCAAqC;AACrC,+CAA+C;AAE/C;;;GAGG;AACU,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,+CAA+C;IAC/C,8CAA8C;IAC9C,+CAA+C;IAE/C;;;;;;;;OAQG;IACH,WAAW,EAAE,OAAC;SACX,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,OAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;SACpE,QAAQ,EAAE;SACV,OAAO,CAAC,UAAU,CAAC;IAEtB;;;;;;;;OAQG;IACH,eAAe,EAAE,OAAC;SACf,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC1D,QAAQ,EAAE;SACV,OAAO,CAAC,MAAM,CAAC;IAElB;;;OAGG;IACH,iBAAiB,EAAE,+CAA6B,CAAC,QAAQ,EAAE;IAE3D,+CAA+C;IAC/C,4CAA4C;IAC5C,+CAA+C;IAE/C;;;OAGG;IACH,eAAe,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAE3C;;;OAGG;IACH,iBAAiB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAE5C;;;OAGG;IACH,oBAAoB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAE/C;;;;;OAKG;IACH,mBAAmB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAE/C;;;OAGG;IACH,kBAAkB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAE9C;;;;OAIG;IACH,2BAA2B,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAEtD,+CAA+C;IAC/C,wBAAwB;IACxB,+CAA+C;IAE/C;;;OAGG;IACH,WAAW,EAAE,wCAAgC,CAAC,QAAQ,EAAE;CACzD,CAAC,CAAC","sourcesContent":["// common/types/options/transport.options.ts\n\nimport { z } from 'zod';\nimport { redisOptionsSchema } from './redis.options';\nimport {\n SessionMode,\n TransportIdMode,\n PlatformMappingEntry,\n PlatformDetectionConfig,\n platformMappingEntrySchema,\n platformDetectionConfigSchema,\n} from './session.options';\n\n// Re-export session types for convenience (these are the canonical definitions)\nexport type { SessionMode, TransportIdMode, PlatformMappingEntry, PlatformDetectionConfig };\n\n// ============================================\n// TRANSPORT PERSISTENCE (from auth.transport.recreation)\n// ============================================\n\n/**\n * Transport persistence configuration\n * Enables session persistence to Redis and automatic transport recreation after server restart\n */\nexport const transportPersistenceConfigSchema = z.object({\n /**\n * Enable transport persistence to Redis\n * When enabled, sessions are persisted to Redis and transports can be recreated after restart\n * @default false\n */\n enabled: z.boolean().default(false),\n\n /**\n * Redis configuration for session storage\n * If omitted when enabled=true, uses top-level redis config\n * Note: Validation for redis presence happens at runtime when persistence is used\n */\n redis: redisOptionsSchema.optional(),\n\n /**\n * Default TTL for stored session metadata (milliseconds)\n * @default 3600000 (1 hour)\n */\n defaultTtlMs: z.number().int().positive().default(3600000),\n});\n\n// ============================================\n// TRANSPORT OPTIONS (unified config)\n// ============================================\n\n/**\n * Transport options schema\n * Consolidates transport protocol config + session lifecycle config\n */\nexport const transportOptionsSchema = z.object({\n // ============================================\n // Session Lifecycle (from session.options.ts)\n // ============================================\n\n /**\n * Defines how the session lifecycle and nested tokens are managed.\n *\n * Modes:\n * - `'stateful'`: Session and nested tokens are stored in a server-side store (e.g., Redis).\n * - `'stateless'`: All session data (including nested tokens) is embedded within a signed/encrypted JWT.\n *\n * @default 'stateful'\n */\n sessionMode: z\n .union([z.literal('stateful'), z.literal('stateless'), z.function()])\n .optional()\n .default('stateful'),\n\n /**\n * Defines how the Transport ID is generated, verified, and used across sessions.\n *\n * Modes:\n * - `'uuid'`: Generates a random UUID per session.\n * - `'jwt'`: Uses a signed JWT for stateless sessions, signed with a generated session key.\n *\n * @default 'uuid'\n */\n transportIdMode: z\n .union([z.literal('uuid'), z.literal('jwt'), z.function()])\n .optional()\n .default('uuid'),\n\n /**\n * Configuration for detecting the AI platform from MCP client info.\n * Allows custom mappings to override or supplement the default keyword-based detection.\n */\n platformDetection: platformDetectionConfigSchema.optional(),\n\n // ============================================\n // Transport Protocols (from auth.transport)\n // ============================================\n\n /**\n * Enable legacy SSE transport (old HTTP+SSE protocol)\n * @default false\n */\n enableLegacySSE: z.boolean().default(false),\n\n /**\n * Enable SSE listener for server-initiated messages (GET /mcp with Accept: text/event-stream)\n * @default true\n */\n enableSseListener: z.boolean().default(true),\n\n /**\n * Enable streamable HTTP transport (POST with SSE response)\n * @default true\n */\n enableStreamableHttp: z.boolean().default(true),\n\n /**\n * Enable stateless HTTP mode (requests without session ID)\n * When enabled, allows requests without prior initialize\n * Uses shared singleton transport for anonymous, per-token singleton for authenticated\n * @default false\n */\n enableStatelessHttp: z.boolean().default(false),\n\n /**\n * Enable stateful HTTP transport (JSON-only responses)\n * @default false\n */\n enableStatefulHttp: z.boolean().default(false),\n\n /**\n * Require session ID for streamable HTTP (non-stateless mode)\n * When false, streamable HTTP requests don't require prior initialize\n * @default true\n */\n requireSessionForStreamable: z.boolean().default(true),\n\n // ============================================\n // Transport Persistence\n // ============================================\n\n /**\n * Transport persistence configuration\n * When enabled, sessions are persisted to Redis and transports can be recreated after server restart\n */\n persistence: transportPersistenceConfigSchema.optional(),\n});\n\n// ============================================\n// TYPE EXPORTS\n// ============================================\n\n/**\n * Transport options type (with defaults applied)\n */\nexport type TransportOptions = z.infer<typeof transportOptionsSchema>;\n\n/**\n * Transport options input type (for user configuration)\n */\nexport type TransportOptionsInput = z.input<typeof transportOptionsSchema>;\n\n/**\n * Transport persistence configuration type\n */\nexport type TransportPersistenceConfig = z.infer<typeof transportPersistenceConfigSchema>;\n\n/**\n * Transport persistence configuration input type\n */\nexport type TransportPersistenceConfigInput = z.input<typeof transportPersistenceConfigSchema>;\n\n/**\n * Platform detection configuration type\n */\nexport type PlatformDetectionConfigType = z.infer<typeof platformDetectionConfigSchema>;\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global Configuration Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for plugins to access global configuration from @FrontMcp decorator.
|
|
5
|
+
*/
|
|
6
|
+
import type { FrontMcpConfigType } from '../metadata';
|
|
7
|
+
import type { RedisOptions } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Extract store configuration from global FrontMcp configuration.
|
|
10
|
+
*
|
|
11
|
+
* This helper is used by plugins that want to use the global redis/store
|
|
12
|
+
* configuration instead of requiring explicit configuration.
|
|
13
|
+
*
|
|
14
|
+
* @param pluginName - Name of the plugin requesting the config (for error messages)
|
|
15
|
+
* @param config - The FrontMcp configuration object
|
|
16
|
+
* @returns The redis/store configuration
|
|
17
|
+
* @throws GlobalConfigNotFoundError if redis is not configured
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // In plugin dynamicProviders:
|
|
22
|
+
* static dynamicProviders = (options: MyPluginOptions) => {
|
|
23
|
+
* if (options.type === 'global-store') {
|
|
24
|
+
* return [{
|
|
25
|
+
* provide: MyStoreToken,
|
|
26
|
+
* inject: () => [FrontMcpConfig],
|
|
27
|
+
* useFactory: (config: FrontMcpConfigType) => {
|
|
28
|
+
* const storeConfig = getGlobalStoreConfig('MyPlugin', config);
|
|
29
|
+
* return new MyStoreProvider(storeConfig);
|
|
30
|
+
* },
|
|
31
|
+
* }];
|
|
32
|
+
* }
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function getGlobalStoreConfig(pluginName: string, config: FrontMcpConfigType): RedisOptions;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Global Configuration Utilities
|
|
4
|
+
*
|
|
5
|
+
* Helper functions for plugins to access global configuration from @FrontMcp decorator.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getGlobalStoreConfig = getGlobalStoreConfig;
|
|
9
|
+
const errors_1 = require("../../errors");
|
|
10
|
+
/**
|
|
11
|
+
* Extract store configuration from global FrontMcp configuration.
|
|
12
|
+
*
|
|
13
|
+
* This helper is used by plugins that want to use the global redis/store
|
|
14
|
+
* configuration instead of requiring explicit configuration.
|
|
15
|
+
*
|
|
16
|
+
* @param pluginName - Name of the plugin requesting the config (for error messages)
|
|
17
|
+
* @param config - The FrontMcp configuration object
|
|
18
|
+
* @returns The redis/store configuration
|
|
19
|
+
* @throws GlobalConfigNotFoundError if redis is not configured
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // In plugin dynamicProviders:
|
|
24
|
+
* static dynamicProviders = (options: MyPluginOptions) => {
|
|
25
|
+
* if (options.type === 'global-store') {
|
|
26
|
+
* return [{
|
|
27
|
+
* provide: MyStoreToken,
|
|
28
|
+
* inject: () => [FrontMcpConfig],
|
|
29
|
+
* useFactory: (config: FrontMcpConfigType) => {
|
|
30
|
+
* const storeConfig = getGlobalStoreConfig('MyPlugin', config);
|
|
31
|
+
* return new MyStoreProvider(storeConfig);
|
|
32
|
+
* },
|
|
33
|
+
* }];
|
|
34
|
+
* }
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function getGlobalStoreConfig(pluginName, config) {
|
|
39
|
+
if (!config.redis) {
|
|
40
|
+
throw new errors_1.GlobalConfigNotFoundError(pluginName, 'redis');
|
|
41
|
+
}
|
|
42
|
+
return config.redis;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=global-config.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-config.utils.js","sourceRoot":"","sources":["../../../../src/common/utils/global-config.utils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAkCH,oDAKC;AAnCD,yCAAyD;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,oBAAoB,CAAC,UAAkB,EAAE,MAA0B;IACjF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kCAAyB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC","sourcesContent":["/**\n * Global Configuration Utilities\n *\n * Helper functions for plugins to access global configuration from @FrontMcp decorator.\n */\n\nimport type { FrontMcpConfigType } from '../metadata';\nimport type { RedisOptions } from '../types';\nimport { GlobalConfigNotFoundError } from '../../errors';\n\n/**\n * Extract store configuration from global FrontMcp configuration.\n *\n * This helper is used by plugins that want to use the global redis/store\n * configuration instead of requiring explicit configuration.\n *\n * @param pluginName - Name of the plugin requesting the config (for error messages)\n * @param config - The FrontMcp configuration object\n * @returns The redis/store configuration\n * @throws GlobalConfigNotFoundError if redis is not configured\n *\n * @example\n * ```typescript\n * // In plugin dynamicProviders:\n * static dynamicProviders = (options: MyPluginOptions) => {\n * if (options.type === 'global-store') {\n * return [{\n * provide: MyStoreToken,\n * inject: () => [FrontMcpConfig],\n * useFactory: (config: FrontMcpConfigType) => {\n * const storeConfig = getGlobalStoreConfig('MyPlugin', config);\n * return new MyStoreProvider(storeConfig);\n * },\n * }];\n * }\n * };\n * ```\n */\nexport function getGlobalStoreConfig(pluginName: string, config: FrontMcpConfigType): RedisOptions {\n if (!config.redis) {\n throw new GlobalConfigNotFoundError(pluginName, 'redis');\n }\n return config.redis;\n}\n"]}
|
|
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./decide-request-intent.utils"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./path.utils"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./global-config.utils"), exports);
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/utils/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/utils/index.ts"],"names":[],"mappings":";;;AAAA,wEAA8C;AAC9C,uDAA6B;AAC7B,gEAAsC","sourcesContent":["export * from './decide-request-intent.utils';\nexport * from './path.utils';\nexport * from './global-config.utils';\n"]}
|
|
@@ -4,15 +4,11 @@ declare const inputSchema: z.ZodObject<{
|
|
|
4
4
|
request: z.ZodObject<{
|
|
5
5
|
method: z.ZodLiteral<"completion/complete">;
|
|
6
6
|
params: z.ZodObject<{
|
|
7
|
-
task: z.ZodOptional<z.ZodObject<{
|
|
8
|
-
ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
|
|
9
|
-
pollInterval: z.ZodOptional<z.ZodNumber>;
|
|
10
|
-
}, z.core.$loose>>;
|
|
11
7
|
_meta: z.ZodOptional<z.ZodObject<{
|
|
12
8
|
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
13
9
|
"io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
|
|
14
10
|
taskId: z.ZodString;
|
|
15
|
-
}, z.core.$
|
|
11
|
+
}, z.core.$strip>>;
|
|
16
12
|
}, z.core.$loose>>;
|
|
17
13
|
ref: z.ZodUnion<readonly [z.ZodObject<{
|
|
18
14
|
type: z.ZodLiteral<"ref/prompt">;
|
|
@@ -28,15 +24,16 @@ declare const inputSchema: z.ZodObject<{
|
|
|
28
24
|
context: z.ZodOptional<z.ZodObject<{
|
|
29
25
|
arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
30
26
|
}, z.core.$strip>>;
|
|
31
|
-
}, z.core.$
|
|
27
|
+
}, z.core.$strip>;
|
|
32
28
|
}, z.core.$strip>;
|
|
33
29
|
ctx: z.ZodUnknown;
|
|
34
30
|
}, z.core.$strip>;
|
|
35
31
|
declare const outputSchema: z.ZodObject<{
|
|
36
32
|
_meta: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
37
34
|
"io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
|
|
38
35
|
taskId: z.ZodString;
|
|
39
|
-
}, z.core.$
|
|
36
|
+
}, z.core.$strip>>;
|
|
40
37
|
}, z.core.$loose>>;
|
|
41
38
|
completion: z.ZodObject<{
|
|
42
39
|
values: z.ZodArray<z.ZodString>;
|
|
@@ -58,9 +55,10 @@ declare const stateSchema: z.ZodObject<{
|
|
|
58
55
|
}, z.core.$strip>;
|
|
59
56
|
output: z.ZodObject<{
|
|
60
57
|
_meta: z.ZodOptional<z.ZodObject<{
|
|
58
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
61
59
|
"io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
|
|
62
60
|
taskId: z.ZodString;
|
|
63
|
-
}, z.core.$
|
|
61
|
+
}, z.core.$strip>>;
|
|
64
62
|
}, z.core.$loose>>;
|
|
65
63
|
completion: z.ZodObject<{
|
|
66
64
|
values: z.ZodArray<z.ZodString>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FrontMcpContextStorage - AsyncLocalStorage wrapper for unified context
|
|
3
|
+
*
|
|
4
|
+
* Provides concurrent-safe context propagation using Node.js AsyncLocalStorage.
|
|
5
|
+
* Access through DI only - never use static imports to access the storage directly.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // In a flow or middleware
|
|
10
|
+
* const storage = this.get(FrontMcpContextStorage);
|
|
11
|
+
* await storage.runFromHeaders(request.headers, {
|
|
12
|
+
* sessionId: sessionId,
|
|
13
|
+
* scopeId: scope.id,
|
|
14
|
+
* }, async () => {
|
|
15
|
+
* // All code here can access the context via DI
|
|
16
|
+
* const ctx = this.get(FRONTMCP_CONTEXT);
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import { FrontMcpContext, FrontMcpContextArgs } from './frontmcp-context';
|
|
21
|
+
import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
22
|
+
/**
|
|
23
|
+
* FrontMcpContextStorage provides unified context via AsyncLocalStorage.
|
|
24
|
+
*
|
|
25
|
+
* This is a GLOBAL-scoped provider because it manages the storage itself,
|
|
26
|
+
* not the per-context data. The actual FrontMcpContext is accessed via
|
|
27
|
+
* the FRONTMCP_CONTEXT token which is CONTEXT-scoped.
|
|
28
|
+
*/
|
|
29
|
+
export declare class FrontMcpContextStorage {
|
|
30
|
+
/**
|
|
31
|
+
* Run a callback with a new FrontMcpContext.
|
|
32
|
+
*
|
|
33
|
+
* @param args - Arguments to create the context
|
|
34
|
+
* @param fn - Async function to run with the context
|
|
35
|
+
* @returns Result of the callback
|
|
36
|
+
*/
|
|
37
|
+
run<T>(args: FrontMcpContextArgs, fn: () => T | Promise<T>): T | Promise<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Run with context extracted from HTTP headers.
|
|
40
|
+
*
|
|
41
|
+
* Automatically parses trace context from headers using W3C Trace Context
|
|
42
|
+
* specification with fallback to x-frontmcp-trace-id.
|
|
43
|
+
*
|
|
44
|
+
* @param headers - HTTP headers
|
|
45
|
+
* @param args - Additional context args (sessionId, scopeId)
|
|
46
|
+
* @param fn - Async function to run
|
|
47
|
+
* @returns Result of the callback
|
|
48
|
+
*/
|
|
49
|
+
runFromHeaders<T>(headers: Record<string, unknown>, args: Omit<FrontMcpContextArgs, 'traceContext' | 'metadata'>, fn: () => T | Promise<T>): T | Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Run with an existing FrontMcpContext.
|
|
52
|
+
*
|
|
53
|
+
* Useful when you need to propagate an existing context to a new async scope.
|
|
54
|
+
*
|
|
55
|
+
* @param context - Existing FrontMcpContext
|
|
56
|
+
* @param fn - Async function to run
|
|
57
|
+
* @returns Result of the callback
|
|
58
|
+
*/
|
|
59
|
+
runWithContext<T>(context: FrontMcpContext, fn: () => T | Promise<T>): T | Promise<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Get the current FrontMcpContext.
|
|
62
|
+
*
|
|
63
|
+
* @returns Current context or undefined if not in a context scope
|
|
64
|
+
*/
|
|
65
|
+
getStore(): FrontMcpContext | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Get the current FrontMcpContext, throwing if not available.
|
|
68
|
+
*
|
|
69
|
+
* @throws Error if not in a context scope
|
|
70
|
+
*/
|
|
71
|
+
getStoreOrThrow(): FrontMcpContext;
|
|
72
|
+
/**
|
|
73
|
+
* Check if currently running within a context.
|
|
74
|
+
*
|
|
75
|
+
* @returns True if a FrontMcpContext is available
|
|
76
|
+
*/
|
|
77
|
+
hasContext(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Update the authInfo in the current context.
|
|
80
|
+
*
|
|
81
|
+
* This mutates the existing context in place to preserve internal state
|
|
82
|
+
* (marks, store, sessionMetadata) while updating auth info.
|
|
83
|
+
*
|
|
84
|
+
* @param authInfo - Auth info fields to set/update (merged with existing)
|
|
85
|
+
* @param fn - Function to run after update
|
|
86
|
+
* @returns Result of the callback
|
|
87
|
+
*/
|
|
88
|
+
updateAuthInfo<T>(authInfo: Partial<AuthInfo>, fn: () => T | Promise<T>): T | Promise<T>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Alias for backward compatibility.
|
|
92
|
+
* @deprecated Use FrontMcpContextStorage instead
|
|
93
|
+
*/
|
|
94
|
+
export { FrontMcpContextStorage as ContextStorage };
|