@frontmcp/sdk 1.13.1 → 1.13.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/auth/auth-ui/auth-ui.render.d.ts +5 -2
- package/auth/auth-ui/auth-ui.render.d.ts.map +1 -1
- package/auth/auth-ui/index.d.ts +1 -1
- package/auth/auth-ui/index.d.ts.map +1 -1
- package/auth/flows/oauth.authorize.flow.d.ts +1 -0
- package/auth/flows/oauth.authorize.flow.d.ts.map +1 -1
- package/auth/flows/oauth.callback.flow.d.ts.map +1 -1
- package/auth/flows/oauth.register.flow.d.ts +18 -1
- package/auth/flows/oauth.register.flow.d.ts.map +1 -1
- package/auth/flows/well-known.prm.flow.d.ts +4 -0
- package/auth/flows/well-known.prm.flow.d.ts.map +1 -1
- package/auth/instances/instance.local-primary-auth.d.ts +4 -3
- package/auth/instances/instance.local-primary-auth.d.ts.map +1 -1
- package/auth/instances/instance.remote-primary-auth.d.ts.map +1 -1
- package/browser/auth/auth-ui/auth-ui.render.mjs +9 -8
- package/browser/auth/auth-ui/index.mjs +4 -2
- package/browser/auth/federated-steps.mjs +1 -1
- package/browser/auth/flows/oauth.authorize.flow.mjs +15 -8
- package/browser/auth/flows/oauth.callback.flow.mjs +10 -3
- package/browser/auth/flows/oauth.connect.flow.mjs +1 -1
- package/browser/auth/flows/oauth.provider-callback.flow.mjs +1 -1
- package/browser/auth/flows/oauth.register.flow.mjs +5 -1
- package/browser/auth/flows/well-known.prm.flow.mjs +22 -3
- package/browser/auth/instances/instance.local-primary-auth.mjs +20 -9
- package/browser/auth/instances/instance.remote-primary-auth.mjs +5 -0
- package/browser/common/decorators/http-route.decorator.mjs +9 -1
- package/browser/common/index.mjs +1 -1
- package/browser/common/metadata/index.mjs +1 -1
- package/browser/common/metadata/materialized.metadata.mjs +13 -0
- package/browser/common/metadata/resource.metadata.mjs +6 -5
- package/browser/common/tokens/resource.tokens.mjs +1 -0
- package/browser/common/types/options/http/schema.mjs +17 -1
- package/browser/common/types/options/transport/schema.mjs +11 -1
- package/browser/direct/direct-server.mjs +15 -11
- package/browser/errors/index.mjs +3 -1
- package/browser/errors/mcp.error.mjs +7 -0
- package/browser/errors/transport.errors.mjs +7 -1
- package/browser/event/event-scope.helper.mjs +4 -2
- package/browser/event/event-subscription-info.mjs +55 -0
- package/browser/event/event.registry.mjs +18 -0
- package/browser/event/flows/event-ended.flow.mjs +89 -0
- package/browser/event/flows/event-unsubscribe.flow.mjs +7 -1
- package/browser/event/poll/event-poll-leases.mjs +11 -0
- package/browser/event/stream/event-stream.mjs +4 -0
- package/browser/event/stream/event-streams.mjs +13 -0
- package/browser/event/subscription/event-subscription-termination.mjs +1 -0
- package/browser/event/subscription/event-subscriptions.mjs +18 -2
- package/browser/front-mcp/front-mcp.mjs +13 -0
- package/browser/http-route/flows/http.route.flow.mjs +71 -8
- package/browser/http-route/http-route.table.mjs +61 -15
- package/browser/http-route/people-session-store.mjs +47 -0
- package/browser/http-route/people-sign-in.routes.mjs +3 -2
- package/browser/http-route/sse-route.stream.mjs +19 -8
- package/browser/index.cjs +3011 -2017
- package/browser/index.mjs +24 -3
- package/browser/notification/notification.service.mjs +8 -1
- package/browser/resource/materialized/materialized-resource.context.mjs +3 -1
- package/browser/resource/materialized/materialized-resources.mjs +53 -27
- package/browser/resource/materialized/resource-store.mjs +269 -17
- package/browser/resource/resource.registry.mjs +31 -0
- package/browser/scope/http-scope.helper.mjs +2 -1
- package/browser/scope/scope.instance.mjs +2 -2
- package/browser/server/security/host-validation.mjs +4 -1
- package/browser/server/server.instance.mjs +22 -4
- package/browser/subsystems.mjs +21 -2
- package/browser/tool/flows/call-tool.flow.mjs +3 -3
- package/browser/tool/undeclared-arguments-message.mjs +10 -8
- package/browser/tool/undeclared-arguments.mjs +33 -0
- package/browser/transport/adapters/transport.sse.adapter.mjs +5 -2
- package/browser/transport/adapters/transport.streamable-http.adapter.mjs +3 -1
- package/browser/transport/flows/handle.mcp-20260728.flow.mjs +7 -2
- package/browser/transport/mcp-20260728/subscriptions.mjs +24 -4
- package/browser/transport/stream-keep-alive.mjs +70 -0
- package/browser/transport/transport.registry.mjs +9 -7
- package/browser/transport/web-standard-mcp.mjs +3 -1
- package/common/decorators/http-route.decorator.d.ts +2 -1
- package/common/decorators/http-route.decorator.d.ts.map +1 -1
- package/common/interfaces/http-route.interface.d.ts +9 -1
- package/common/interfaces/http-route.interface.d.ts.map +1 -1
- package/common/metadata/app.metadata.d.ts +8 -0
- package/common/metadata/app.metadata.d.ts.map +1 -1
- package/common/metadata/front-mcp.metadata.d.ts +197 -0
- package/common/metadata/front-mcp.metadata.d.ts.map +1 -1
- package/common/metadata/http-route.metadata.d.ts +11 -3
- package/common/metadata/http-route.metadata.d.ts.map +1 -1
- package/common/metadata/materialized.metadata.d.ts +21 -0
- package/common/metadata/materialized.metadata.d.ts.map +1 -1
- package/common/metadata/resource.metadata.d.ts +8 -1
- package/common/metadata/resource.metadata.d.ts.map +1 -1
- package/common/tokens/resource.tokens.d.ts +1 -0
- package/common/tokens/resource.tokens.d.ts.map +1 -1
- package/common/types/options/auth/index.d.ts +1 -1
- package/common/types/options/auth/index.d.ts.map +1 -1
- package/common/types/options/http/index.d.ts +1 -1
- package/common/types/options/http/index.d.ts.map +1 -1
- package/common/types/options/http/interfaces.d.ts +41 -1
- package/common/types/options/http/interfaces.d.ts.map +1 -1
- package/common/types/options/http/schema.d.ts +12 -0
- package/common/types/options/http/schema.d.ts.map +1 -1
- package/common/types/options/transport/index.d.ts +1 -1
- package/common/types/options/transport/index.d.ts.map +1 -1
- package/common/types/options/transport/interfaces.d.ts +24 -0
- package/common/types/options/transport/interfaces.d.ts.map +1 -1
- package/common/types/options/transport/schema.d.ts +3 -0
- package/common/types/options/transport/schema.d.ts.map +1 -1
- package/direct/direct-server.d.ts +4 -2
- package/direct/direct-server.d.ts.map +1 -1
- package/direct/direct.types.d.ts +7 -0
- package/direct/direct.types.d.ts.map +1 -1
- package/errors/index.d.ts +1 -1
- package/errors/index.d.ts.map +1 -1
- package/errors/mcp.error.d.ts +4 -0
- package/errors/mcp.error.d.ts.map +1 -1
- package/errors/transport.errors.d.ts +4 -0
- package/errors/transport.errors.d.ts.map +1 -1
- package/esm/index.mjs +42 -42
- package/event/event-scope.helper.d.ts.map +1 -1
- package/event/event-subscription-info.d.ts +72 -0
- package/event/event-subscription-info.d.ts.map +1 -0
- package/event/event.registry.d.ts +7 -0
- package/event/event.registry.d.ts.map +1 -1
- package/event/flows/event-ended.flow.d.ts +56 -0
- package/event/flows/event-ended.flow.d.ts.map +1 -0
- package/event/flows/event-unsubscribe.flow.d.ts +4 -1
- package/event/flows/event-unsubscribe.flow.d.ts.map +1 -1
- package/event/index.d.ts +3 -1
- package/event/index.d.ts.map +1 -1
- package/event/poll/event-poll-leases.d.ts +3 -0
- package/event/poll/event-poll-leases.d.ts.map +1 -1
- package/event/stream/event-stream.d.ts +2 -0
- package/event/stream/event-stream.d.ts.map +1 -1
- package/event/stream/event-streams.d.ts +3 -0
- package/event/stream/event-streams.d.ts.map +1 -1
- package/event/subscription/event-subscription-termination.d.ts +4 -1
- package/event/subscription/event-subscription-termination.d.ts.map +1 -1
- package/event/subscription/event-subscriptions.d.ts +19 -1
- package/event/subscription/event-subscriptions.d.ts.map +1 -1
- package/front-mcp/front-mcp.d.ts.map +1 -1
- package/http-route/flows/http.route.flow.d.ts +12 -4
- package/http-route/flows/http.route.flow.d.ts.map +1 -1
- package/http-route/http-route.table.d.ts +10 -3
- package/http-route/http-route.table.d.ts.map +1 -1
- package/http-route/people-session-store.d.ts +24 -0
- package/http-route/people-session-store.d.ts.map +1 -0
- package/http-route/people-sign-in.routes.d.ts +2 -2
- package/http-route/people-sign-in.routes.d.ts.map +1 -1
- package/http-route/sse-route.stream.d.ts +6 -1
- package/http-route/sse-route.stream.d.ts.map +1 -1
- package/index.d.ts +16 -8
- package/index.d.ts.map +1 -1
- package/index.js +43 -43
- package/notification/notification.service.d.ts.map +1 -1
- package/package.json +10 -10
- package/resource/materialized/index.d.ts +1 -1
- package/resource/materialized/index.d.ts.map +1 -1
- package/resource/materialized/materialized-resource.context.d.ts +1 -0
- package/resource/materialized/materialized-resource.context.d.ts.map +1 -1
- package/resource/materialized/materialized-resources.d.ts +11 -5
- package/resource/materialized/materialized-resources.d.ts.map +1 -1
- package/resource/materialized/resource-store.d.ts +31 -1
- package/resource/materialized/resource-store.d.ts.map +1 -1
- package/resource/resource.registry.d.ts +11 -0
- package/resource/resource.registry.d.ts.map +1 -1
- package/scope/http-scope.helper.d.ts +1 -1
- package/scope/http-scope.helper.d.ts.map +1 -1
- package/scope/scope.instance.d.ts.map +1 -1
- package/server/adapters/polyfills/browser-express-host.d.ts +3 -0
- package/server/adapters/polyfills/browser-express-host.d.ts.map +1 -1
- package/server/adapters/polyfills/node-express-host.d.ts +1 -0
- package/server/adapters/polyfills/node-express-host.d.ts.map +1 -1
- package/server/adapters/user-content.listener.d.ts +26 -0
- package/server/adapters/user-content.listener.d.ts.map +1 -0
- package/server/security/host-validation.d.ts.map +1 -1
- package/server/server.instance.d.ts +1 -0
- package/server/server.instance.d.ts.map +1 -1
- package/subsystems.d.ts +1 -1
- package/subsystems.d.ts.map +1 -1
- package/tool/undeclared-arguments-message.d.ts +8 -5
- package/tool/undeclared-arguments-message.d.ts.map +1 -1
- package/tool/undeclared-arguments.d.ts +2 -0
- package/tool/undeclared-arguments.d.ts.map +1 -1
- package/transport/adapters/base-sse-transport.d.ts +4 -0
- package/transport/adapters/base-sse-transport.d.ts.map +1 -1
- package/transport/adapters/polyfills/browser-sse-transport.d.ts +1 -0
- package/transport/adapters/polyfills/browser-sse-transport.d.ts.map +1 -1
- package/transport/adapters/streamable-http-transport.d.ts +2 -0
- package/transport/adapters/streamable-http-transport.d.ts.map +1 -1
- package/transport/adapters/transport.sse.adapter.d.ts.map +1 -1
- package/transport/adapters/transport.streamable-http.adapter.d.ts.map +1 -1
- package/transport/flows/handle.mcp-20260728.flow.d.ts.map +1 -1
- package/transport/mcp-20260728/subscriptions.d.ts +2 -0
- package/transport/mcp-20260728/subscriptions.d.ts.map +1 -1
- package/transport/stream-keep-alive.d.ts +13 -0
- package/transport/stream-keep-alive.d.ts.map +1 -0
- package/transport/transport.registry.d.ts +1 -1
- package/transport/transport.registry.d.ts.map +1 -1
- package/transport/web-standard-mcp.d.ts.map +1 -1
|
@@ -459,6 +459,13 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
459
459
|
providerIssuer: (providerId) => this.providerAuthorizationServer(providerId)
|
|
460
460
|
});
|
|
461
461
|
this.consentStoreImpl = new StorageConsentStore(adapter);
|
|
462
|
+
if (this.isDcrEnabled()) {
|
|
463
|
+
this.dcrClientRegistryImpl.useStore(adapter, {
|
|
464
|
+
onError: (operation, error) => this.logger.warn(
|
|
465
|
+
`Dynamic client registration: cannot ${operation} a client in the token storage, so only this process knows it: ${String(error)}`
|
|
466
|
+
)
|
|
467
|
+
});
|
|
468
|
+
}
|
|
462
469
|
const backend = isSqliteTokenStorage(this.tokenStorage) ? "sqlite" : isRedisTokenStorage(this.tokenStorage) ? "redis" : "unknown";
|
|
463
470
|
this.logger.info(`Token storage initialized with persistent backend: ${backend}`);
|
|
464
471
|
} catch (err) {
|
|
@@ -789,11 +796,12 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
789
796
|
* Exchange an authorization code for tokens
|
|
790
797
|
*/
|
|
791
798
|
async exchangeCode(code, clientId, redirectUri, codeVerifier, clientSecret, defaultAudience, issuer, clientAssertion) {
|
|
792
|
-
|
|
799
|
+
const client = await this.dcrClientRegistryImpl.load(clientId);
|
|
800
|
+
if (this.dcrClientRegistryImpl.verifyClientSecret(clientId, clientSecret, client) === "invalid") {
|
|
793
801
|
this.logger.warn("Client authentication failed at token endpoint (authorization_code)");
|
|
794
802
|
return { error: "invalid_client", error_description: "Client authentication failed" };
|
|
795
803
|
}
|
|
796
|
-
const declared = await this.checkDeclaredGrant(clientId, "authorization_code", clientAssertion);
|
|
804
|
+
const declared = await this.checkDeclaredGrant(clientId, "authorization_code", clientAssertion, client);
|
|
797
805
|
if ("error" in declared) return declared;
|
|
798
806
|
const codeRecord = await this.authorizationStore.getAuthorizationCode(code);
|
|
799
807
|
if (!codeRecord) {
|
|
@@ -872,6 +880,7 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
872
880
|
if (codeRecord.pendingAuthId && codeRecord.federatedLoginUsed) {
|
|
873
881
|
providerTokensId = await this.moveProviderTokens(`pending:${codeRecord.pendingAuthId}`, accessToken);
|
|
874
882
|
}
|
|
883
|
+
await this.dcrClientRegistryImpl.touch(clientId);
|
|
875
884
|
this.logger.info(`Tokens issued for user: ${user.sub}`);
|
|
876
885
|
const tokens = {
|
|
877
886
|
access_token: accessToken,
|
|
@@ -904,11 +913,12 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
904
913
|
/**
|
|
905
914
|
* Refuse a grant the client did not declare in its `grant_types` (RFC 7591): in its registration, its
|
|
906
915
|
* `dcr.clients` entry or its client ID metadata document. A client that declared nothing (an unregistered
|
|
907
|
-
* id under `requireRegisteredClients: false`, or one registered on another instance or before a restart
|
|
908
|
-
* is not limited, and gets `grantTypes: undefined` and `authMethod: undefined`. A CIMD client whose document
|
|
909
|
-
* declares `private_key_jwt` must also present a valid client assertion.
|
|
916
|
+
* id under `requireRegisteredClients: false`, or one registered on another instance or before a restart
|
|
917
|
+
* with a memory token storage) is not limited, and gets `grantTypes: undefined` and `authMethod: undefined`. A CIMD client whose document
|
|
918
|
+
* declares `private_key_jwt` must also present a valid client assertion. `registered` is the registration the token
|
|
919
|
+
* request read with `load`.
|
|
910
920
|
*/
|
|
911
|
-
async checkDeclaredGrant(clientId, grantType, clientAssertion) {
|
|
921
|
+
async checkDeclaredGrant(clientId, grantType, clientAssertion, registered) {
|
|
912
922
|
let grantTypes;
|
|
913
923
|
let authMethod;
|
|
914
924
|
try {
|
|
@@ -926,7 +936,6 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
926
936
|
grantTypes = metadata?.grant_types;
|
|
927
937
|
authMethod = metadata?.token_endpoint_auth_method ?? "none";
|
|
928
938
|
} else {
|
|
929
|
-
const registered = this.dcrClientRegistryImpl.get(clientId);
|
|
930
939
|
grantTypes = registered?.grant_types;
|
|
931
940
|
authMethod = registered?.token_endpoint_auth_method;
|
|
932
941
|
}
|
|
@@ -989,11 +998,12 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
989
998
|
* Refresh an access token using a refresh token
|
|
990
999
|
*/
|
|
991
1000
|
async refreshAccessToken(refreshToken, clientId, clientSecret, defaultAudience, issuer, clientAssertion) {
|
|
992
|
-
|
|
1001
|
+
const client = await this.dcrClientRegistryImpl.load(clientId);
|
|
1002
|
+
if (this.dcrClientRegistryImpl.verifyClientSecret(clientId, clientSecret, client) === "invalid") {
|
|
993
1003
|
this.logger.warn("Client authentication failed at token endpoint (refresh_token)");
|
|
994
1004
|
return { error: "invalid_client", error_description: "Client authentication failed" };
|
|
995
1005
|
}
|
|
996
|
-
const declared = await this.checkDeclaredGrant(clientId, "refresh_token", clientAssertion);
|
|
1006
|
+
const declared = await this.checkDeclaredGrant(clientId, "refresh_token", clientAssertion, client);
|
|
997
1007
|
if ("error" in declared) return declared;
|
|
998
1008
|
const tokenRecord = await this.authorizationStore.getRefreshToken(refreshToken);
|
|
999
1009
|
if (!tokenRecord) {
|
|
@@ -1071,6 +1081,7 @@ var LocalPrimaryAuth = class extends FrontMcpAuth {
|
|
|
1071
1081
|
await this.authorizationStore.storeRefreshToken({ ...newRefreshRecord, providerTokensId: movedTo });
|
|
1072
1082
|
}
|
|
1073
1083
|
}
|
|
1084
|
+
await this.dcrClientRegistryImpl.touch(clientId);
|
|
1074
1085
|
this.logger.info(`Tokens refreshed for user: ${user.sub}`);
|
|
1075
1086
|
return {
|
|
1076
1087
|
access_token: accessToken,
|
|
@@ -38,6 +38,11 @@ var RemotePrimaryAuth = class extends FrontMcpAuth {
|
|
|
38
38
|
});
|
|
39
39
|
await this.registerAuthFlows(scope);
|
|
40
40
|
this.warnWithoutConfiguredAudience(scope);
|
|
41
|
+
if (this.options.resourceMetadata?.clientId === true && !this.options.clientId) {
|
|
42
|
+
scope.logger.warn(
|
|
43
|
+
"auth.resourceMetadata.clientId is true but auth.clientId is not set, so the protected resource metadata names no client_id. Set auth.clientId, or give resourceMetadata.clientId the client id itself."
|
|
44
|
+
);
|
|
45
|
+
}
|
|
41
46
|
return Promise.resolve();
|
|
42
47
|
}
|
|
43
48
|
/** Warn once at startup when nothing configures the token audience: say what this server accepts, and what to set. */
|
|
@@ -14,7 +14,12 @@ var httpRouteMetadataSchema = z.object({
|
|
|
14
14
|
path: z.custom((value) => typeof value === "function" || isHttpRoutePath(value), {
|
|
15
15
|
message: HTTP_ROUTE_PATH_MESSAGE
|
|
16
16
|
}),
|
|
17
|
-
auth: z.enum(["people", "subject", "
|
|
17
|
+
auth: z.enum(["people", "subject", "bearer", "public"], {
|
|
18
|
+
message: "auth must be 'people', 'subject', 'bearer' or 'public'"
|
|
19
|
+
}).optional(),
|
|
20
|
+
authorities: z.custom((rule) => typeof rule === "string" || typeof rule === "object" && rule !== null, {
|
|
21
|
+
message: "authorities must be a profile name, a list of names or a policy"
|
|
22
|
+
}).optional(),
|
|
18
23
|
sse: z.object({
|
|
19
24
|
store: z.custom(
|
|
20
25
|
(value) => typeof value?.subscribe === "function",
|
|
@@ -27,6 +32,9 @@ var httpRouteMetadataSchema = z.object({
|
|
|
27
32
|
}).strict().refine((metadata) => !metadata.sse || metadata.method === "GET", {
|
|
28
33
|
message: "an sse route must use method GET",
|
|
29
34
|
path: ["sse"]
|
|
35
|
+
}).refine((metadata) => metadata.authorities === void 0 || metadata.auth === "bearer", {
|
|
36
|
+
message: "authorities need auth: 'bearer', whose token names the caller they check",
|
|
37
|
+
path: ["authorities"]
|
|
30
38
|
});
|
|
31
39
|
function HttpRoute(metadata) {
|
|
32
40
|
return (target) => {
|
package/browser/common/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// libs/sdk/src/common/index.ts
|
|
2
2
|
export { FRONTMCP_CONFIG_METADATA_KEY, FrontMcp, getDecoratorConfig, Flow, FrontMcpFlow, AroundHookOf, DidHookOf, FinallyHookOf, FlowHooksOf, StageHookOf, WillHookOf, consumePendingTC39Hooks, peekPendingTC39HooksForClass, registerPendingTC39Hook, resolvePendingTC39HooksForClass, App, FrontMcpApp, app, frontMcpApp, FrontMcpProvider, Provider, AuthProvider, FrontMcpAuthProvider, Adapter, FrontMcpAdapter, FrontMcpPlugin, Plugin, FrontMcpTool, Tool, frontMcpTool, tool, FrontMcpResource, FrontMcpResourceTemplate, Resource, ResourceTemplate, frontMcpResource, frontMcpResourceTemplate, resource, resourceTemplate, FrontMcpPrompt, Prompt, frontMcpPrompt, prompt, FrontMcpLogTransport, LogTransport, Agent, FrontMcpAgent, agent, frontMcpAgent, FrontMcpSkill, Skill, frontMcpSkill, getSkillMetadata, isSkillDecorated, skill, FrontMcpJob, Job, frontMcpJob, job, FrontMcpWorkflow, Workflow, frontMcpWorkflow, workflow, Channel, channel, isChannelClass, isChannelFunction, Event, FrontMcpEvent, event, frontMcpEvent, isEventClass, isEventFunction, Duty, Worker, HttpRoute } from "./decorators/index.mjs";
|
|
3
3
|
export { jsonWebKeySetSchema, jwkParametersSchema, jwkSchema, aiPlatformTypeSchema, authorizationSchema, sessionIdPayloadSchema, sessionIdSchema, userClaimSchema, serverInfoOptionsSchema, platformDetectionConfigSchema, platformMappingEntrySchema, sessionOptionsSchema, defaultHttpPort, httpOptionsSchema, allowsPublicAccess, appAuthOptionsSchema, authOptionsSchema, authenticateFnSchema, consentConfigSchema, federatedAuthConfigSchema, flatRemoteProviderFields, incrementalAuthConfigSchema, isLocalMode, isOrchestratedLocal, isOrchestratedMode, isOrchestratedRemote, isPublicMode, isRemoteMode, isStaticMode, isTransparentMode, localAuthSchema, localDcrClientSchema, localDcrConfigSchema, localSigningConfigSchema, loginConfigSchema, orchestratedLocalSchema, orchestratedRemoteSchema, parseAuthOptions, providerConfigSchema, publicAccessConfigSchema, publicAuthOptionsSchema, remoteAuthSchema, remoteProviderConfigSchema, secureStoreConfigSchema, secureStoreCustomBackendSchema, secureStoreEncryptionSchema, secureStoreScopeSchema, skippedAppBehaviorSchema, staticAuthOptionsSchema, tokenRefreshConfigSchema, tokenStorageConfigSchema, tokenStorageSqliteSchema, transparentAuthOptionsSchema, upstreamProviderSchema, LogLevel, LogLevelName, loggingOptionsSchema, isPubsubConfigured, isRedisProvider, isVercelKvProvider, parseRedisUrl, pubsubOptionsSchema, redisOptionsSchema, redisProviderSchema, redisUrlSchema, storageProviderSchema, vercelKvProviderSchema, PROTOCOL_PRESETS, eventStoreConfigSchema, expandProtocolConfig, isDistributedMode, persistenceConfigSchema, shouldCacheProviders, transportOptionsSchema, DEFAULT_TOOL_PAGINATION, paginationOptionsSchema, toolPaginationOptionsSchema, outboundFetchOptionsSchema, DEFAULT_ELICITATION_OPTIONS, elicitationOptionsSchema, normalizeEndpointConfig, normalizeSkillsConfigOptions, skillsConfigAuthModeSchema, skillsConfigEndpointConfigSchema, skillsConfigOptionsSchema, extAppsHostCapabilitiesSchema, extAppsOptionsSchema, resolveDefaultSqlitePath, sqliteOptionsSchema, observabilityOptionsSchema, DEFAULT_HEALTH_OPTIONS, healthOptionsSchema, healthReadyzOptionsSchema, DEFAULT_METRICS_OPTIONS, metricsOptionsSchema, metricsProcessOptionsSchema, DEFAULT_REGISTRY_PUBLIC_KEY_ENV, REGISTRY_SERVER_NAME_PATTERN, mcpRegistryOptionsSchema, mcpRegistryRepositorySchema, toRegistryAuthRecord, lifecycleOptionsSchema, clientProfilesOptionsSchema, offloadOptionsSchema, devtoolsOptionsSchema, DEFAULT_INSTRUCTIONS_BUDGET, instructionsBudgetOptionsSchema, resolveInstructionsBudget } from "./types/index.mjs";
|
|
4
|
-
export { ProviderScope, frontMcpBaseSchema, frontMcpMetadataSchema, parseFrontMcpConfigLite, BUDGET_LIST_POLICIES, DEFAULT_OUTPUT_SCHEMA_MODE, DEFAULT_SCHEMA_DESCRIPTION_FORMAT, MIN_OUTPUT_BUDGET_BYTES, OUTPUT_SCHEMA_MODES, SCHEMA_DESCRIPTION_FORMATS, UNDECLARED_KEYS_POLICIES, formatOutputSchemaForDescription, outputPolicySchema, resolveAllowNonFinite, resolveOutputBudget, resolveOutputSchemaMode, resolveSchemaDescriptionFormat, resolveUndeclaredKeysPolicy, withUndeclaredKeysAllowed, enabledOptionSchema, isEnabledSource, isResourceKey, resourceKeySchema, frontMcpFlowMetadataSchema, HookPhase, hookOptionsSchema, frontMcpLocalAppMetadataSchema, frontMcpRemoteAppMetadataSchema, lazyAppMetadataSchema, packageLoaderSchema, frontMcpProviderMetadataSchema, AuthProviderScope, frontMcpAuthProviderMetadataSchema, frontMcpAdapterMetadataSchema, frontMcpPluginMetadataSchema, AudioOutputSchema, ImageOutputSchema, ResourceLinkOutputSchema, ResourceOutputSchema, frontMcpToolMetadataSchema, normalizeToolAuthProviders, resolveToolVisibility, frontMcpResourceMetadataSchema, frontMcpResourceTemplateMetadataSchema, frontMcpPromptMetadataSchema, frontMcpLogTransportMetadataSchema, frontMcpAgentMetadataSchema, withConfig, extractToolNames, getToolNameFromClass, isFileInstructions, isInlineInstructions, isToolRefWithClass, isToolRefWithName, isUrlInstructions, normalizeToolRef, skillMetadataSchema, MAX_JOB_TIMER_MS, frontMcpJobMetadataSchema, jobRunnerSchema, timerLimitMessage, frontMcpWorkflowMetadataSchema, channelNotificationSchema, channelSourceConfigSchema, channelsConfigSchema, frontMcpChannelMetadataSchema, EVENT_NAME_MAX_LENGTH, eventsConfigSchema, frontMcpEventMetadataSchema, PRIMITIVE_FILTER_KEYS, appFilterConfigSchema, dutyMetadataSchema, defineDutyMetadata, dutyMetadataOf, workerMetadataSchema, defineWorkerMetadata, workerMetadataOf, HTTP_ROUTE_PATH_MESSAGE, defineHttpRouteMetadata, httpRouteMetadataOf, isHttpRoutePath } from "./metadata/index.mjs";
|
|
4
|
+
export { ProviderScope, frontMcpBaseSchema, frontMcpMetadataSchema, parseFrontMcpConfigLite, BUDGET_LIST_POLICIES, DEFAULT_OUTPUT_SCHEMA_MODE, DEFAULT_SCHEMA_DESCRIPTION_FORMAT, MIN_OUTPUT_BUDGET_BYTES, OUTPUT_SCHEMA_MODES, SCHEMA_DESCRIPTION_FORMATS, UNDECLARED_KEYS_POLICIES, formatOutputSchemaForDescription, outputPolicySchema, resolveAllowNonFinite, resolveOutputBudget, resolveOutputSchemaMode, resolveSchemaDescriptionFormat, resolveUndeclaredKeysPolicy, withUndeclaredKeysAllowed, enabledOptionSchema, isEnabledSource, isProducedResourceKey, isResourceKey, isResourceKeyFamily, resourceKeyFamilySchema, resourceKeySchema, frontMcpFlowMetadataSchema, HookPhase, hookOptionsSchema, frontMcpLocalAppMetadataSchema, frontMcpRemoteAppMetadataSchema, lazyAppMetadataSchema, packageLoaderSchema, frontMcpProviderMetadataSchema, AuthProviderScope, frontMcpAuthProviderMetadataSchema, frontMcpAdapterMetadataSchema, frontMcpPluginMetadataSchema, AudioOutputSchema, ImageOutputSchema, ResourceLinkOutputSchema, ResourceOutputSchema, frontMcpToolMetadataSchema, normalizeToolAuthProviders, resolveToolVisibility, frontMcpResourceMetadataSchema, frontMcpResourceTemplateMetadataSchema, frontMcpPromptMetadataSchema, frontMcpLogTransportMetadataSchema, frontMcpAgentMetadataSchema, withConfig, extractToolNames, getToolNameFromClass, isFileInstructions, isInlineInstructions, isToolRefWithClass, isToolRefWithName, isUrlInstructions, normalizeToolRef, skillMetadataSchema, MAX_JOB_TIMER_MS, frontMcpJobMetadataSchema, jobRunnerSchema, timerLimitMessage, frontMcpWorkflowMetadataSchema, channelNotificationSchema, channelSourceConfigSchema, channelsConfigSchema, frontMcpChannelMetadataSchema, EVENT_NAME_MAX_LENGTH, eventsConfigSchema, frontMcpEventMetadataSchema, PRIMITIVE_FILTER_KEYS, appFilterConfigSchema, dutyMetadataSchema, defineDutyMetadata, dutyMetadataOf, workerMetadataSchema, defineWorkerMetadata, workerMetadataOf, HTTP_ROUTE_PATH_MESSAGE, defineHttpRouteMetadata, httpRouteMetadataOf, isHttpRoutePath } from "./metadata/index.mjs";
|
|
5
5
|
export { ExecutionContextBase, FrontMcpServer, ServerRequest, ServerResponse, FlowBase, FlowControl, AsyncProvider, AsyncAuthProvider, ToolContext, ResourceContext, PromptContext, FRONTMCP_LOGGER, FrontMcpLogger, LogTransportInterface, LLM_ADAPTER, supportsStreaming, AgentContext, SkillContext, JobContext, WorkflowContext, ChannelContext, EventContext, EventPublisher, HttpRouteContext, Auth, FrontMcpAuth } from "./interfaces/index.mjs";
|
|
6
6
|
export { FrontMcpTokens, ServerRequestTokens, FrontMcpFlowTokens, FrontMcpFlowHookTokens, FrontMcpLocalAppTokens, FrontMcpRemoteAppTokens, FrontMcpProviderTokens, FrontMcpAuthProviderTokens, FrontMcpAdapterTokens, FrontMcpPluginTokens, FrontMcpToolTokens, extendedToolMetadata, FrontMcpResourceTemplateTokens, FrontMcpResourceTokens, extendedResourceMetadata, extendedResourceTemplateMetadata, FrontMcpPromptTokens, extendedPromptMetadata, FrontMcpLogTransportTokens, FrontMcpAgentTokens, extendedAgentMetadata, FrontMcpSkillTokens, extendedSkillMetadata, skillCallerDir, FrontMcpJobTokens, extendedJobMetadata, FrontMcpWorkflowTokens, extendedWorkflowMetadata, FrontMcpChannelTokens, EVENT_PUBLISHER, FrontMcpEventTokens } from "./tokens/index.mjs";
|
|
7
7
|
export { DynamicAdapter, adapterInitOptionsOf, DynamicPlugin, initOptionsOf, isDynamicPluginClass } from "./dynamic/index.mjs";
|
|
@@ -3,7 +3,7 @@ import { ProviderScope } from "@frontmcp/di";
|
|
|
3
3
|
export { frontMcpBaseSchema, frontMcpMetadataSchema, parseFrontMcpConfigLite } from "./front-mcp.metadata.mjs";
|
|
4
4
|
export { BUDGET_LIST_POLICIES, DEFAULT_OUTPUT_SCHEMA_MODE, DEFAULT_SCHEMA_DESCRIPTION_FORMAT, MIN_OUTPUT_BUDGET_BYTES, OUTPUT_SCHEMA_MODES, SCHEMA_DESCRIPTION_FORMATS, UNDECLARED_KEYS_POLICIES, formatOutputSchemaForDescription, outputPolicySchema, resolveAllowNonFinite, resolveOutputBudget, resolveOutputSchemaMode, resolveSchemaDescriptionFormat, resolveUndeclaredKeysPolicy, withUndeclaredKeysAllowed } from "./output-policy.mjs";
|
|
5
5
|
export { enabledOptionSchema, isEnabledSource } from "./enabled.metadata.mjs";
|
|
6
|
-
export { isResourceKey, resourceKeySchema } from "./materialized.metadata.mjs";
|
|
6
|
+
export { isProducedResourceKey, isResourceKey, isResourceKeyFamily, resourceKeyFamilySchema, resourceKeySchema } from "./materialized.metadata.mjs";
|
|
7
7
|
export { frontMcpFlowMetadataSchema } from "./flow.metadata.mjs";
|
|
8
8
|
export { HookPhase, hookOptionsSchema } from "./hook.metadata.mjs";
|
|
9
9
|
export { frontMcpLocalAppMetadataSchema, frontMcpRemoteAppMetadataSchema, lazyAppMetadataSchema, packageLoaderSchema } from "./app.metadata.mjs";
|
|
@@ -7,7 +7,20 @@ function isResourceKey(value) {
|
|
|
7
7
|
var resourceKeySchema = z.custom(isResourceKey, {
|
|
8
8
|
message: "`from` must be a key of a resource store, such as resourceStore().key('board')"
|
|
9
9
|
});
|
|
10
|
+
function isProducedResourceKey(key) {
|
|
11
|
+
return typeof key.markDirty === "function";
|
|
12
|
+
}
|
|
13
|
+
function isResourceKeyFamily(value) {
|
|
14
|
+
const candidate = value;
|
|
15
|
+
return typeof candidate === "object" && candidate !== null && typeof candidate.name === "string" && typeof candidate.key === "function" && typeof candidate.store?.connect === "function" && typeof candidate.store.close === "function";
|
|
16
|
+
}
|
|
17
|
+
var resourceKeyFamilySchema = z.custom(isResourceKeyFamily, {
|
|
18
|
+
message: "`from` on @ResourceTemplate must be a key family of a resource store, such as resourceStore().family('table')"
|
|
19
|
+
});
|
|
10
20
|
export {
|
|
21
|
+
isProducedResourceKey,
|
|
11
22
|
isResourceKey,
|
|
23
|
+
isResourceKeyFamily,
|
|
24
|
+
resourceKeyFamilySchema,
|
|
12
25
|
resourceKeySchema
|
|
13
26
|
};
|
|
@@ -3,7 +3,10 @@ import { internalZ as z } from "@frontmcp/lazy-zod";
|
|
|
3
3
|
import { IconSchema } from "@frontmcp/protocol";
|
|
4
4
|
import { entryAvailabilitySchema, isValidMcpUri, isValidMcpUriTemplate } from "@frontmcp/utils";
|
|
5
5
|
import { enabledOptionSchema } from "./enabled.metadata.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
resourceKeyFamilySchema,
|
|
8
|
+
resourceKeySchema
|
|
9
|
+
} from "./materialized.metadata.mjs";
|
|
7
10
|
var resourceWorkerOptionSchema = z.union([
|
|
8
11
|
z.boolean(),
|
|
9
12
|
z.object({
|
|
@@ -44,11 +47,9 @@ var frontMcpResourceTemplateMetadataSchema = z.object({
|
|
|
44
47
|
_meta: z.record(z.string(), z.unknown()).optional(),
|
|
45
48
|
availableWhen: entryAvailabilitySchema.optional(),
|
|
46
49
|
enabled: enabledOptionSchema.optional(),
|
|
50
|
+
from: resourceKeyFamilySchema.optional(),
|
|
47
51
|
worker: resourceWorkerOptionSchema.optional()
|
|
48
|
-
}).passthrough()
|
|
49
|
-
message: "`from` serves one stored value at a fixed `uri`: declare it on @Resource, not on @ResourceTemplate",
|
|
50
|
-
path: ["from"]
|
|
51
|
-
});
|
|
52
|
+
}).passthrough();
|
|
52
53
|
export {
|
|
53
54
|
frontMcpResourceMetadataSchema,
|
|
54
55
|
frontMcpResourceTemplateMetadataSchema
|
|
@@ -29,6 +29,7 @@ var FrontMcpResourceTemplateTokens = {
|
|
|
29
29
|
_meta: tokenFactory.meta("_meta"),
|
|
30
30
|
availableWhen: tokenFactory.meta("availableWhen"),
|
|
31
31
|
enabled: tokenFactory.meta("enabled"),
|
|
32
|
+
from: tokenFactory.meta("from"),
|
|
32
33
|
worker: tokenFactory.meta("worker"),
|
|
33
34
|
metadata: tokenFactory.meta("metadata")
|
|
34
35
|
// used in resourceTemplate({}) construction
|
|
@@ -58,6 +58,20 @@ var forwardHeaderGlobSchema = z.string().regex(HEADER_GLOB_PATTERN, {
|
|
|
58
58
|
message: `http.forwardHeaders: "${glob}" matches ${refused.join(", ")}. FrontMCP never forwards authorization, cookie, proxy-*, hop-by-hop, content-length or client-address (host, forwarded, x-forwarded-*, x-real-ip) headers; name the application headers to keep instead.`
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
|
+
var userContentSchema = z.object({
|
|
62
|
+
port: z.number().int().min(0).max(65535).optional(),
|
|
63
|
+
socketPath: z.string().min(1).optional(),
|
|
64
|
+
root: z.string().min(1),
|
|
65
|
+
allowedHosts: z.array(z.string().min(1)).optional(),
|
|
66
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
67
|
+
csp: z.object({
|
|
68
|
+
directives: z.record(z.string(), z.union([z.string(), z.array(z.string())])),
|
|
69
|
+
reportUri: z.string().optional(),
|
|
70
|
+
reportOnly: z.boolean().optional()
|
|
71
|
+
}).strict().optional()
|
|
72
|
+
}).strict().refine((options) => options.port !== void 0 || options.socketPath !== void 0, {
|
|
73
|
+
message: "http.userContent needs a port or a socketPath of its own"
|
|
74
|
+
});
|
|
61
75
|
var defaultHttpPort = () => Number(getEnv("PORT")) || 3e3;
|
|
62
76
|
var httpOptionsSchema = z.object({
|
|
63
77
|
// Read when the options are parsed, through `getEnv`, not when this module loads: a browser
|
|
@@ -125,7 +139,9 @@ var httpOptionsSchema = z.object({
|
|
|
125
139
|
/** Response security headers; see `SecurityHeadersOptions`. */
|
|
126
140
|
securityHeaders: securityHeadersSchema.optional(),
|
|
127
141
|
/** More request headers to keep in `customHeaders`, besides `x-frontmcp-*`; see `HttpOptionsInterface`. */
|
|
128
|
-
forwardHeaders: z.array(forwardHeaderGlobSchema).optional()
|
|
142
|
+
forwardHeaders: z.array(forwardHeaderGlobSchema).optional(),
|
|
143
|
+
/** A second listener for static user content; see `UserContentOptions`. */
|
|
144
|
+
userContent: userContentSchema.optional()
|
|
129
145
|
});
|
|
130
146
|
export {
|
|
131
147
|
defaultHttpPort,
|
|
@@ -81,6 +81,7 @@ function toLegacyProtocolFlags(protocol) {
|
|
|
81
81
|
requireSessionForStreamable: expanded.strictSession
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
+
var MAX_HEARTBEAT_MS = 2147483647;
|
|
84
85
|
var protocolConfigSchema = z.object({
|
|
85
86
|
sse: z.boolean().optional(),
|
|
86
87
|
streamable: z.boolean().optional(),
|
|
@@ -159,7 +160,16 @@ var transportOptionsSchema = z.object({
|
|
|
159
160
|
// ============================================
|
|
160
161
|
// EventStore Configuration
|
|
161
162
|
// ============================================
|
|
162
|
-
eventStore: eventStoreConfigSchema.optional()
|
|
163
|
+
eventStore: eventStoreConfigSchema.optional(),
|
|
164
|
+
sse: z.object({
|
|
165
|
+
heartbeatMs: z.union([
|
|
166
|
+
z.number().int().nonnegative("transport.sse.heartbeatMs must be 0 or more").max(
|
|
167
|
+
MAX_HEARTBEAT_MS,
|
|
168
|
+
`transport.sse.heartbeatMs must be at most ${MAX_HEARTBEAT_MS} ms (about 24.8 days)`
|
|
169
|
+
),
|
|
170
|
+
z.literal(false)
|
|
171
|
+
]).optional()
|
|
172
|
+
}).optional()
|
|
163
173
|
});
|
|
164
174
|
function isDistributedMode(distributedMode) {
|
|
165
175
|
if (distributedMode === true) return true;
|
|
@@ -32,7 +32,7 @@ function callerSessionId(authContext, defaultSessionId) {
|
|
|
32
32
|
return callerIdentity ? `${baseSessionId}:${sha256Hex(callerIdentity)}` : baseSessionId;
|
|
33
33
|
}
|
|
34
34
|
var DirectMcpServerImpl = class {
|
|
35
|
-
|
|
35
|
+
servedScope;
|
|
36
36
|
ready;
|
|
37
37
|
_isDisposed = false;
|
|
38
38
|
defaultSessionId;
|
|
@@ -45,15 +45,19 @@ var DirectMcpServerImpl = class {
|
|
|
45
45
|
* @param options - Server-wide defaults: the `workerEnv` a call or client without its own reads
|
|
46
46
|
*/
|
|
47
47
|
constructor(scope, disposeOwner, options) {
|
|
48
|
-
this.
|
|
48
|
+
this.servedScope = scope;
|
|
49
49
|
this.disposeOwner = disposeOwner;
|
|
50
50
|
this.defaultWorkerEnv = options?.workerEnv;
|
|
51
51
|
this.defaultSessionId = `direct:${randomUUID()}`;
|
|
52
52
|
this.ready = Promise.resolve();
|
|
53
53
|
}
|
|
54
|
+
/** The scope this server serves, read-only. */
|
|
55
|
+
get scope() {
|
|
56
|
+
return this.servedScope;
|
|
57
|
+
}
|
|
54
58
|
/** The publisher of this server's events; on a server without events, one that rejects. */
|
|
55
59
|
get events() {
|
|
56
|
-
return this.
|
|
60
|
+
return this.servedScope.events?.publisher ?? { publish: () => Promise.reject(new EventsNotEnabledError()) };
|
|
57
61
|
}
|
|
58
62
|
/**
|
|
59
63
|
* Build the MCP handler context that flows expect.
|
|
@@ -63,7 +67,7 @@ var DirectMcpServerImpl = class {
|
|
|
63
67
|
buildHandlerContext(options) {
|
|
64
68
|
const authInfo = buildAuthInfo(options?.authContext, this.defaultSessionId);
|
|
65
69
|
const platformEnv = options?.workerEnv ?? this.defaultWorkerEnv;
|
|
66
|
-
return withMcpSurface(this.
|
|
70
|
+
return withMcpSurface(this.servedScope, {
|
|
67
71
|
authInfo,
|
|
68
72
|
metadata: options?.metadata,
|
|
69
73
|
...platformEnv !== void 0 ? { platformEnv } : {},
|
|
@@ -80,13 +84,13 @@ var DirectMcpServerImpl = class {
|
|
|
80
84
|
}
|
|
81
85
|
const ctx = this.buildHandlerContext(options);
|
|
82
86
|
try {
|
|
83
|
-
return await runRequestExclusive(() => this.
|
|
87
|
+
return await runRequestExclusive(() => this.servedScope.runFlowForOutput(flowName, { request, ctx }));
|
|
84
88
|
} catch (e) {
|
|
85
89
|
if (e instanceof FlowControl && e.type === "respond") {
|
|
86
90
|
return e.output;
|
|
87
91
|
}
|
|
88
92
|
const failure = toDirectFailure(e);
|
|
89
|
-
this.errorHandler ??= new ErrorHandler({ logger: this.
|
|
93
|
+
this.errorHandler ??= new ErrorHandler({ logger: this.servedScope.logger.child("direct-server") });
|
|
90
94
|
this.errorHandler.logError(toMcpError(failure), { flowName });
|
|
91
95
|
throw failure;
|
|
92
96
|
}
|
|
@@ -124,7 +128,7 @@ var DirectMcpServerImpl = class {
|
|
|
124
128
|
if (this._isDisposed) {
|
|
125
129
|
throw new InternalMcpError("DirectMcpServer has been disposed");
|
|
126
130
|
}
|
|
127
|
-
return registerRuntimeTool(this.
|
|
131
|
+
return registerRuntimeTool(this.servedScope, definition);
|
|
128
132
|
}
|
|
129
133
|
// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
130
134
|
// Resource Operations
|
|
@@ -208,7 +212,7 @@ var DirectMcpServerImpl = class {
|
|
|
208
212
|
const workerEnv = given?.workerEnv ?? this.defaultWorkerEnv;
|
|
209
213
|
const options = workerEnv !== void 0 ? { ...given, workerEnv } : given;
|
|
210
214
|
const { DirectClientImpl } = await import("./direct-client.mjs");
|
|
211
|
-
return DirectClientImpl.create(this.
|
|
215
|
+
return DirectClientImpl.create(this.servedScope, options);
|
|
212
216
|
}
|
|
213
217
|
// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
214
218
|
// Lifecycle
|
|
@@ -216,10 +220,10 @@ var DirectMcpServerImpl = class {
|
|
|
216
220
|
async dispose() {
|
|
217
221
|
if (this._isDisposed) return;
|
|
218
222
|
this._isDisposed = true;
|
|
219
|
-
await this.
|
|
220
|
-
if (this.
|
|
223
|
+
await this.servedScope.emitDispose();
|
|
224
|
+
if (this.servedScope.transportService) {
|
|
221
225
|
try {
|
|
222
|
-
await this.
|
|
226
|
+
await this.servedScope.transportService.destroy();
|
|
223
227
|
} catch (err) {
|
|
224
228
|
console.debug("DirectMcpServer cleanup warning:", err);
|
|
225
229
|
}
|
package/browser/errors/index.mjs
CHANGED
|
@@ -206,7 +206,8 @@ import {
|
|
|
206
206
|
UnsafeSocketDirectoryError,
|
|
207
207
|
SocketInUseError,
|
|
208
208
|
SocketPathConflictError,
|
|
209
|
-
SocketPermissionError
|
|
209
|
+
SocketPermissionError,
|
|
210
|
+
UserContentConfigurationError
|
|
210
211
|
} from "./transport.errors.mjs";
|
|
211
212
|
import {
|
|
212
213
|
EncryptionContextNotSetError,
|
|
@@ -506,6 +507,7 @@ export {
|
|
|
506
507
|
UnsupportedContentTypeError,
|
|
507
508
|
UnsupportedHookOwnerKindError,
|
|
508
509
|
UnsupportedTransportTypeError,
|
|
510
|
+
UserContentConfigurationError,
|
|
509
511
|
VaultLoadError,
|
|
510
512
|
VaultNotFoundError,
|
|
511
513
|
VercelKvAsyncInitRequiredError,
|
|
@@ -261,6 +261,12 @@ var InvalidResourceStoreError = class extends InternalMcpError {
|
|
|
261
261
|
super(`resourceStore(): ${details}`, "INVALID_RESOURCE_STORE");
|
|
262
262
|
}
|
|
263
263
|
};
|
|
264
|
+
var ResourceStoreClosedError = class extends InternalMcpError {
|
|
265
|
+
constructor(key) {
|
|
266
|
+
const subject = key === void 0 ? "a key" : `key "${key}"`;
|
|
267
|
+
super(`resourceStore(): the store closed while ${subject} was being produced`, "RESOURCE_STORE_CLOSED");
|
|
268
|
+
}
|
|
269
|
+
};
|
|
264
270
|
function availabilityRemedy(entryType, availability, missingAxes) {
|
|
265
271
|
const requirements = missingAxes.map((axis) => {
|
|
266
272
|
const allowed = availability?.[axis];
|
|
@@ -678,6 +684,7 @@ export {
|
|
|
678
684
|
RequestContextNotAvailableError,
|
|
679
685
|
ResourceNotFoundError,
|
|
680
686
|
ResourceReadError,
|
|
687
|
+
ResourceStoreClosedError,
|
|
681
688
|
SessionMissingError,
|
|
682
689
|
StaleToolListError,
|
|
683
690
|
ToolExecutionError,
|
|
@@ -94,6 +94,11 @@ var SocketPermissionError = class extends InternalMcpError {
|
|
|
94
94
|
super(`Could not make Unix socket ${socketPath} owner-only (0600): ${detail}.`, "SOCKET_PERMISSION");
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
+
var UserContentConfigurationError = class extends InternalMcpError {
|
|
98
|
+
constructor(detail) {
|
|
99
|
+
super(`http.userContent: ${detail}`, "USER_CONTENT_CONFIGURATION");
|
|
100
|
+
}
|
|
101
|
+
};
|
|
97
102
|
export {
|
|
98
103
|
InvalidTransportSessionError,
|
|
99
104
|
MethodNotImplementedError,
|
|
@@ -108,5 +113,6 @@ export {
|
|
|
108
113
|
TransportServiceNotAvailableError,
|
|
109
114
|
UnsafeSocketDirectoryError,
|
|
110
115
|
UnsupportedContentTypeError,
|
|
111
|
-
UnsupportedTransportTypeError
|
|
116
|
+
UnsupportedTransportTypeError,
|
|
117
|
+
UserContentConfigurationError
|
|
112
118
|
};
|
|
@@ -14,6 +14,7 @@ import { ScopeEventPublisher } from "./event-publisher.mjs";
|
|
|
14
14
|
import { reauthorizeSubscriber } from "./event-reauthorization.mjs";
|
|
15
15
|
import EventRegistry from "./event.registry.mjs";
|
|
16
16
|
import EventDeliverFlow from "./flows/event-deliver.flow.mjs";
|
|
17
|
+
import EventEndedFlow from "./flows/event-ended.flow.mjs";
|
|
17
18
|
import EventPollFlow from "./flows/event-poll.flow.mjs";
|
|
18
19
|
import EventPublishFlow, { EVENT_DELIVERY_MAX_BYTES } from "./flows/event-publish.flow.mjs";
|
|
19
20
|
import EventStreamFlow from "./flows/event-stream.flow.mjs";
|
|
@@ -119,7 +120,8 @@ async function enableWebhookDelivery(scope, eventRegistry, eventsConfig, logger)
|
|
|
119
120
|
verifier,
|
|
120
121
|
settings: eventsConfig.subscriptions,
|
|
121
122
|
rotationGraceMs: webhook.rotationGraceMs,
|
|
122
|
-
logger
|
|
123
|
+
logger,
|
|
124
|
+
ended: (ending) => scope.runFlow("events:ended", ending)
|
|
123
125
|
});
|
|
124
126
|
const outbox = new EventOutbox({
|
|
125
127
|
storage,
|
|
@@ -133,7 +135,7 @@ async function enableWebhookDelivery(scope, eventRegistry, eventsConfig, logger)
|
|
|
133
135
|
eventRegistry.subscriptions = subscriptions;
|
|
134
136
|
eventRegistry.outbox = outbox;
|
|
135
137
|
eventRegistry.storage = storage;
|
|
136
|
-
await scope.registryFlows(EventDeliverFlow);
|
|
138
|
+
await scope.registryFlows(EventDeliverFlow, EventEndedFlow);
|
|
137
139
|
subscriptions.start();
|
|
138
140
|
outbox.start();
|
|
139
141
|
const replays = new EventReplays({
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// libs/sdk/src/event/event-subscription-info.ts
|
|
2
|
+
function subscriberSummaryOf(subscriber) {
|
|
3
|
+
return {
|
|
4
|
+
sub: subscriber.sub,
|
|
5
|
+
...subscriber.iss !== void 0 && { iss: subscriber.iss },
|
|
6
|
+
...subscriber.tenantId !== void 0 && { tenantId: subscriber.tenantId }
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function callbackHostOf(url) {
|
|
10
|
+
try {
|
|
11
|
+
return new URL(url).host;
|
|
12
|
+
} catch {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function webhookSubscriptionInfoOf(record) {
|
|
17
|
+
const { lastDeliveryAt, lastError, failedSince, failures, suspendedSince } = record.status;
|
|
18
|
+
return {
|
|
19
|
+
id: record.id,
|
|
20
|
+
eventName: record.eventName,
|
|
21
|
+
mode: "webhook",
|
|
22
|
+
principalKey: record.principalKey,
|
|
23
|
+
subscriber: subscriberSummaryOf(record.subscriber),
|
|
24
|
+
arguments: record.arguments,
|
|
25
|
+
dialect: record.dialect,
|
|
26
|
+
createdAt: record.createdAt,
|
|
27
|
+
updatedAt: record.updatedAt,
|
|
28
|
+
expiresAt: record.expiresAt,
|
|
29
|
+
verifiedAt: record.verifiedAt,
|
|
30
|
+
lastAuthorizedAt: record.lastAuthorizedAt,
|
|
31
|
+
active: record.active,
|
|
32
|
+
delivery: {
|
|
33
|
+
host: callbackHostOf(record.delivery.url),
|
|
34
|
+
failures: failures ?? 0,
|
|
35
|
+
...suspendedSince !== void 0 && { suspendedSince },
|
|
36
|
+
...lastDeliveryAt !== void 0 && { lastDeliveryAt },
|
|
37
|
+
...lastError !== void 0 && { lastError },
|
|
38
|
+
...failedSince !== void 0 && { failedSince }
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function heldSubscriptionInfoOf(subscription, principalKey, args) {
|
|
43
|
+
return {
|
|
44
|
+
id: subscription.id,
|
|
45
|
+
eventName: subscription.name,
|
|
46
|
+
principalKey,
|
|
47
|
+
subscriber: subscriberSummaryOf(subscription.subscriber),
|
|
48
|
+
arguments: args
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
heldSubscriptionInfoOf,
|
|
53
|
+
subscriberSummaryOf,
|
|
54
|
+
webhookSubscriptionInfoOf
|
|
55
|
+
};
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "../common/index.mjs";
|
|
10
10
|
import { EventNameConflictError } from "../errors/index.mjs";
|
|
11
11
|
import { RegistryAbstract } from "../regsitry/index.mjs";
|
|
12
|
+
import { webhookSubscriptionInfoOf } from "./event-subscription-info.mjs";
|
|
12
13
|
import { EventInstance } from "./event.instance.mjs";
|
|
13
14
|
import { normalizeEvent } from "./event.utils.mjs";
|
|
14
15
|
var EventRegistry = class extends RegistryAbstract {
|
|
@@ -134,6 +135,23 @@ var EventRegistry = class extends RegistryAbstract {
|
|
|
134
135
|
getChannelEvents() {
|
|
135
136
|
return this.getEvents().filter((event) => this.sendsToChannelSessions(event));
|
|
136
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* The subscriptions of every registered event, or of one: webhook subscriptions from the store every process
|
|
140
|
+
* shares, and the poll leases and streams this process holds. Read only: nothing is swept or changed. Each one has
|
|
141
|
+
* no webhook secret or signing key, no callback URL (only its host), and none of its owner's claims.
|
|
142
|
+
*/
|
|
143
|
+
async listSubscriptions(eventName) {
|
|
144
|
+
const listed = [];
|
|
145
|
+
const store = this.subscriptions?.store;
|
|
146
|
+
if (store) {
|
|
147
|
+
const eventNames = eventName === void 0 ? this.getEvents().map((event) => event.name) : [eventName];
|
|
148
|
+
for (const name of eventNames) {
|
|
149
|
+
for (const record of await store.listByEvent(name)) listed.push(webhookSubscriptionInfoOf(record));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
listed.push(...this.pollLeases?.list(eventName) ?? [], ...this.streams?.list(eventName) ?? []);
|
|
153
|
+
return listed;
|
|
154
|
+
}
|
|
137
155
|
/** The capability to advertise: both forms once an event is served, nothing otherwise. */
|
|
138
156
|
getCapabilities() {
|
|
139
157
|
if (!this.servesEvents()) return {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// libs/sdk/src/event/flows/event-ended.flow.ts
|
|
13
|
+
import { internalZ as z } from "@frontmcp/lazy-zod";
|
|
14
|
+
import {
|
|
15
|
+
Flow,
|
|
16
|
+
FlowBase,
|
|
17
|
+
FlowHooksOf
|
|
18
|
+
} from "../../common/index.mjs";
|
|
19
|
+
import { subscriptionRefOf } from "../subscription/event-subscriptions.mjs";
|
|
20
|
+
var reasonSchema = z.enum([
|
|
21
|
+
"unsubscribed",
|
|
22
|
+
"expired",
|
|
23
|
+
"closed",
|
|
24
|
+
"terminated"
|
|
25
|
+
]);
|
|
26
|
+
var inputSchema = z.object({
|
|
27
|
+
record: z.any(),
|
|
28
|
+
reason: reasonSchema,
|
|
29
|
+
termination: z.any().optional()
|
|
30
|
+
});
|
|
31
|
+
var outputSchema = z.object({});
|
|
32
|
+
var stateSchema = z.object({
|
|
33
|
+
/** The subscription as it was stored when it was removed. */
|
|
34
|
+
record: z.any(),
|
|
35
|
+
/** The subscription as the event's `onUnsubscribe` got it: `{ id, name, mode, subscriber }`. */
|
|
36
|
+
subscription: z.any(),
|
|
37
|
+
reason: reasonSchema,
|
|
38
|
+
/** For `'terminated'`: the error its callback is told, access revoked or a callback that kept failing. */
|
|
39
|
+
termination: z.any()
|
|
40
|
+
});
|
|
41
|
+
var plan = {
|
|
42
|
+
pre: ["parseInput"],
|
|
43
|
+
execute: ["notifyEnded"],
|
|
44
|
+
post: ["buildResult"],
|
|
45
|
+
finalize: ["finalize"]
|
|
46
|
+
};
|
|
47
|
+
var name = "events:ended";
|
|
48
|
+
var { Stage } = FlowHooksOf(name);
|
|
49
|
+
var EventEndedFlow = class extends FlowBase {
|
|
50
|
+
logger = this.scopeLogger.child("EventEndedFlow");
|
|
51
|
+
async parseInput() {
|
|
52
|
+
const { record, reason, termination } = this.input;
|
|
53
|
+
this.state.set({ record, subscription: subscriptionRefOf(record), reason, ...termination && { termination } });
|
|
54
|
+
}
|
|
55
|
+
async notifyEnded() {
|
|
56
|
+
const { record, reason } = this.state.required;
|
|
57
|
+
this.logger.verbose(`notifyEnded: subscription ${record.id} to event "${record.eventName}" ended (${reason})`);
|
|
58
|
+
}
|
|
59
|
+
async buildResult() {
|
|
60
|
+
this.respond({});
|
|
61
|
+
}
|
|
62
|
+
async finalize() {
|
|
63
|
+
this.logger.verbose("finalize");
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
__decorateClass([
|
|
67
|
+
Stage("parseInput")
|
|
68
|
+
], EventEndedFlow.prototype, "parseInput", 1);
|
|
69
|
+
__decorateClass([
|
|
70
|
+
Stage("notifyEnded")
|
|
71
|
+
], EventEndedFlow.prototype, "notifyEnded", 1);
|
|
72
|
+
__decorateClass([
|
|
73
|
+
Stage("buildResult")
|
|
74
|
+
], EventEndedFlow.prototype, "buildResult", 1);
|
|
75
|
+
__decorateClass([
|
|
76
|
+
Stage("finalize")
|
|
77
|
+
], EventEndedFlow.prototype, "finalize", 1);
|
|
78
|
+
EventEndedFlow = __decorateClass([
|
|
79
|
+
Flow({
|
|
80
|
+
name,
|
|
81
|
+
plan,
|
|
82
|
+
inputSchema,
|
|
83
|
+
outputSchema,
|
|
84
|
+
access: "public"
|
|
85
|
+
})
|
|
86
|
+
], EventEndedFlow);
|
|
87
|
+
export {
|
|
88
|
+
EventEndedFlow as default
|
|
89
|
+
};
|
|
@@ -24,7 +24,11 @@ var outputSchema = UnsubscribeEventResultSchema;
|
|
|
24
24
|
var stateSchema = z.object({
|
|
25
25
|
authInfo: z.any(),
|
|
26
26
|
dialect: z.enum(["sep-3415", "sketch"]),
|
|
27
|
-
owner: z.any()
|
|
27
|
+
owner: z.any(),
|
|
28
|
+
/** The id the request names, derived from the caller, the callback, the event and its arguments. */
|
|
29
|
+
subscriptionId: z.string(),
|
|
30
|
+
/** The subscription this request removed, as it was stored; undefined when none matched, which succeeds too. */
|
|
31
|
+
removed: z.any()
|
|
28
32
|
});
|
|
29
33
|
var plan = {
|
|
30
34
|
pre: ["parseInput", "resolveDialect", "requireSubscriber"],
|
|
@@ -68,8 +72,10 @@ var EventUnsubscribeFlow = class extends FlowBase {
|
|
|
68
72
|
const identity = this.subscriptions.identityOf(owner.principalKey, delivery.url, eventName, this.storedArguments());
|
|
69
73
|
this.subscriptions.sweepIfDue();
|
|
70
74
|
const removed = await this.subscriptions.store.delete(identity.id);
|
|
75
|
+
this.state.set({ subscriptionId: identity.id, removed });
|
|
71
76
|
if (!removed) return;
|
|
72
77
|
await this.subscriptions.notifyUnsubscribed(removed, "unsubscribed", authInfo);
|
|
78
|
+
await this.subscriptions.notifyEnded({ record: removed, reason: "unsubscribed" });
|
|
73
79
|
this.logger.verbose(`removeSubscription: subscription ${removed.id} removed from event "${eventName}"`);
|
|
74
80
|
}
|
|
75
81
|
async buildResult() {
|