@frontmcp/sdk 1.12.0 → 1.12.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/agent/agent.instance.d.ts +3 -0
- package/agent/agent.instance.d.ts.map +1 -1
- package/agent/agent.registry.d.ts.map +1 -1
- package/agent/flows/call-agent.flow.d.ts +1 -1
- package/agent/flows/call-agent.flow.d.ts.map +1 -1
- package/answer/answer-budget.d.ts.map +1 -1
- package/answer/client-profile.d.ts.map +1 -1
- package/auth/auth-ui/auth-ui.registry.d.ts.map +1 -1
- package/auth/auth.registry.d.ts.map +1 -1
- package/auth/authorized-apps.utils.d.ts +8 -0
- package/auth/authorized-apps.utils.d.ts.map +1 -1
- package/auth/flows/form-body.utils.d.ts.map +1 -1
- package/auth/flows/oauth.authorize.flow.d.ts +3 -1
- 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 +5 -0
- package/auth/flows/oauth.register.flow.d.ts.map +1 -1
- package/auth/flows/oauth.token.flow.d.ts +3 -2
- package/auth/flows/oauth.token.flow.d.ts.map +1 -1
- package/auth/instances/instance.local-primary-auth.d.ts.map +1 -1
- package/auth/session/session-store.factory.d.ts.map +1 -1
- package/browser/agent/agent.instance.mjs +4 -0
- package/browser/agent/agent.registry.mjs +2 -2
- package/browser/agent/flows/call-agent.flow.mjs +10 -6
- package/browser/answer/answer-budget.mjs +35 -7
- package/browser/answer/client-profile.mjs +3 -3
- package/browser/auth/auth-ui/auth-ui.registry.mjs +8 -0
- package/browser/auth/auth.registry.mjs +4 -0
- package/browser/auth/authorized-apps.utils.mjs +5 -0
- package/browser/auth/flows/form-body.utils.mjs +4 -2
- package/browser/auth/flows/oauth.authorize.flow.mjs +38 -6
- package/browser/auth/flows/oauth.callback.flow.mjs +30 -16
- package/browser/auth/flows/oauth.register.flow.mjs +17 -5
- package/browser/auth/flows/oauth.token.flow.mjs +17 -8
- package/browser/auth/instances/instance.local-primary-auth.mjs +11 -2
- package/browser/auth/session/session-store.factory.mjs +5 -1
- package/browser/builtin/authorities/authorities-not-configured.mjs +5 -0
- package/browser/channel/channel-notification.service.mjs +16 -12
- package/browser/channel/channel.instance.mjs +9 -12
- package/browser/channel/channel.utils.mjs +18 -3
- package/browser/channel/flows/send-channel-notification.flow.mjs +4 -2
- package/browser/common/metadata/app.metadata.mjs +2 -1
- package/browser/common/metadata/event.metadata.mjs +10 -10
- package/browser/common/schemas/http-output.schema.mjs +6 -1
- package/browser/common/types/options/metrics/schema.mjs +2 -1
- package/browser/common/utils/content-disposition.utils.mjs +7 -0
- package/browser/common/utils/forward-headers.utils.mjs +5 -5
- package/browser/common/utils/issuer-subject.utils.mjs +17 -0
- package/browser/completion/flows/complete.flow.mjs +9 -1
- package/browser/context/frontmcp-context.mjs +5 -1
- package/browser/direct/connect.mjs +14 -4
- package/browser/direct/direct-server.mjs +3 -1
- package/browser/duty/duty.lifecycle.mjs +5 -3
- package/browser/duty/lease-store.mjs +6 -2
- package/browser/elicitation/flows/elicitation-request.flow.mjs +3 -2
- package/browser/elicitation/flows/elicitation-result.flow.mjs +5 -4
- package/browser/elicitation/questions/question-scope.helper.mjs +4 -2
- package/browser/elicitation/store/elicitation-store.factory.mjs +17 -9
- package/browser/elicitation/store/encrypted-elicitation.store.mjs +1 -1
- package/browser/elicitation/store/storage-elicitation.store.mjs +83 -63
- package/browser/errors/error-handler.mjs +4 -4
- package/browser/errors/event.errors.mjs +3 -1
- package/browser/errors/misconfiguration.mjs +7 -1
- package/browser/errors/transport.errors.mjs +1 -1
- package/browser/esm-loader/esm-cache.mjs +5 -1
- package/browser/esm-loader/esm-module-loader.mjs +6 -6
- package/browser/esm-loader/version-resolver.mjs +1 -1
- package/browser/event/event-scope.helper.mjs +13 -5
- package/browser/event/flows/event-poll.flow.mjs +1 -1
- package/browser/event/flows/event-publish-http.flow.mjs +24 -4
- package/browser/event/flows/event-stream.flow.mjs +1 -1
- package/browser/ext-apps/ext-apps.handler.mjs +26 -14
- package/browser/flows/flow.registry.mjs +2 -1
- package/browser/front-mcp/authorities-rules.check.mjs +16 -0
- package/browser/front-mcp/front-mcp.mjs +8 -2
- package/browser/index.cjs +2064 -1344
- package/browser/job/execution/job-execution.manager.mjs +5 -5
- package/browser/job/job-permission.guard.mjs +7 -0
- package/browser/job/job-run-access.mjs +12 -2
- package/browser/job/tools/list-jobs.tool.mjs +2 -7
- package/browser/job/tools/remove-job.tool.mjs +6 -0
- package/browser/job/tools/update-job.tool.mjs +3 -0
- package/browser/logger/instances/instance.console-logger.mjs +14 -4
- package/browser/logger/instances/instance.file-logger.mjs +3 -2
- package/browser/logger/session-id-hash.mjs +8 -0
- package/browser/metrics/metrics.service.mjs +2 -1
- package/browser/offload/offload-worker.globals.mjs +3 -3
- package/browser/offload/worker-jobs.mjs +9 -2
- package/browser/offload/worker-resources.mjs +7 -1
- package/browser/plugin/enforced-metadata.check.mjs +24 -7
- package/browser/prompt/flows/get-prompt.flow.mjs +10 -3
- package/browser/prompt/flows/prompts-list.flow.mjs +1 -1
- package/browser/provider/provider.registry.mjs +21 -10
- package/browser/remote-mcp/mcp-client.service.mjs +4 -3
- package/browser/remote-mcp/remote-entries.mjs +15 -1
- package/browser/remote-mcp/remote-oauth.mjs +29 -2
- package/browser/resource/flows/read-resource.flow.mjs +23 -13
- package/browser/resource/flows/resource-templates-list.flow.mjs +1 -1
- package/browser/resource/flows/resources-list.flow.mjs +1 -1
- package/browser/resource/flows/subscribe-resource.flow.mjs +9 -1
- package/browser/resource/resource.instance.mjs +10 -1
- package/browser/scope/flows/http.request.flow.mjs +15 -3
- package/browser/scope/optional-dependency.util.mjs +1 -13
- package/browser/scope/scope.instance.mjs +39 -30
- package/browser/server/security/replaceable-directory.mjs +7 -2
- package/browser/server/security/resolve-allowed-hosts.mjs +3 -3
- package/browser/server/server.validation.mjs +3 -5
- package/browser/skill/cache/skill-http-cache.catalog.mjs +18 -0
- package/browser/skill/flows/http/llm-full-txt.flow.mjs +3 -2
- package/browser/skill/flows/http/llm-txt.flow.mjs +3 -2
- package/browser/skill/flows/load-skill.flow.mjs +10 -3
- package/browser/skill/hooks/skill-tool.hook.mjs +7 -7
- package/browser/skill/sep-2640/sep-2640.resource-helpers.mjs +29 -10
- package/browser/skill/session/skill-session.manager.mjs +32 -35
- package/browser/skill/session/skill-session.types.mjs +2 -0
- package/browser/skill/skill-authorities.helper.mjs +11 -4
- package/browser/skill/skill-directory-loader.mjs +15 -1
- package/browser/skill/skill-filter.helper.mjs +35 -7
- package/browser/skill/skill-md-parser.mjs +17 -2
- package/browser/skill/skill.instance.mjs +7 -0
- package/browser/storage/sqlite-on-edge.mjs +28 -0
- package/browser/task/store/task-store.factory.mjs +8 -3
- package/browser/tool/flows/call-tool.flow.mjs +29 -14
- package/browser/tool/flows/tools-list.flow.mjs +1 -4
- package/browser/transport/adapters/transport.local.adapter.mjs +3 -2
- package/browser/transport/event-stores/event-store.factory.mjs +5 -1
- package/browser/transport/event-stores/redis.event-store.mjs +13 -9
- package/browser/transport/flows/handle.streamable-http.flow.mjs +13 -6
- package/browser/transport/in-memory-server.mjs +5 -3
- package/browser/transport/mcp-20260728/client/mcp-stateless.client.mjs +25 -6
- package/browser/transport/mcp-20260728/dispatcher.mjs +4 -9
- package/browser/transport/mcp-handlers/index.mjs +19 -1
- package/browser/transport/mcp-handlers/skills-list-request.handler.mjs +2 -1
- package/browser/transport/mcp-handlers/skills-mcp.types.mjs +3 -1
- package/browser/transport/web-fetch-handler.mjs +3 -3
- package/browser/transport/web-response.renderer.mjs +5 -4
- package/browser/transport/web-standard-mcp.mjs +2 -2
- package/browser/worker/worker.lifecycle.mjs +7 -4
- package/browser/workflow/tools/list-workflows.tool.mjs +6 -7
- package/browser/workflow/tools/register-workflow.tool.mjs +3 -2
- package/browser/workflow/tools/remove-workflow.tool.mjs +6 -0
- package/browser/workflow/tools/runtime-workflow.limits.mjs +5 -0
- package/browser/workflow/tools/update-workflow.tool.mjs +6 -2
- package/browser/workflow/trigger/workflow-webhook.routes.mjs +15 -6
- package/browser/workflow/trigger/workflow-webhook.signature.mjs +5 -8
- package/builtin/authorities/authorities-not-configured.d.ts +3 -0
- package/builtin/authorities/authorities-not-configured.d.ts.map +1 -0
- package/channel/channel-notification.service.d.ts +8 -3
- package/channel/channel-notification.service.d.ts.map +1 -1
- package/channel/channel.instance.d.ts +10 -8
- package/channel/channel.instance.d.ts.map +1 -1
- package/channel/channel.utils.d.ts +6 -1
- package/channel/channel.utils.d.ts.map +1 -1
- package/channel/flows/send-channel-notification.flow.d.ts +1 -1
- package/channel/flows/send-channel-notification.flow.d.ts.map +1 -1
- package/common/entries/channel.entry.d.ts +1 -1
- package/common/entries/channel.entry.d.ts.map +1 -1
- package/common/metadata/app.metadata.d.ts +11 -3
- package/common/metadata/app.metadata.d.ts.map +1 -1
- package/common/metadata/channel.metadata.d.ts +7 -4
- package/common/metadata/channel.metadata.d.ts.map +1 -1
- package/common/metadata/duty.metadata.d.ts +1 -1
- package/common/metadata/duty.metadata.d.ts.map +1 -1
- package/common/metadata/event.metadata.d.ts +15 -12
- package/common/metadata/event.metadata.d.ts.map +1 -1
- package/common/metadata/front-mcp.metadata.d.ts +59 -59
- package/common/metadata/worker.metadata.d.ts +1 -1
- package/common/metadata/worker.metadata.d.ts.map +1 -1
- package/common/schemas/http-output.schema.d.ts +1 -1
- package/common/schemas/http-output.schema.d.ts.map +1 -1
- package/common/types/options/http/interfaces.d.ts +3 -2
- package/common/types/options/http/interfaces.d.ts.map +1 -1
- package/common/types/options/metrics/interfaces.d.ts +3 -2
- package/common/types/options/metrics/interfaces.d.ts.map +1 -1
- package/common/types/options/metrics/schema.d.ts +1 -1
- package/common/types/options/metrics/schema.d.ts.map +1 -1
- package/common/utils/content-disposition.utils.d.ts +6 -0
- package/common/utils/content-disposition.utils.d.ts.map +1 -0
- package/common/utils/issuer-subject.utils.d.ts +8 -0
- package/common/utils/issuer-subject.utils.d.ts.map +1 -0
- package/completion/flows/complete.flow.d.ts.map +1 -1
- package/context/frontmcp-context.d.ts +5 -1
- package/context/frontmcp-context.d.ts.map +1 -1
- package/direct/connect.d.ts.map +1 -1
- package/direct/direct-server.d.ts.map +1 -1
- package/duty/duty.lifecycle.d.ts +1 -1
- package/duty/duty.lifecycle.d.ts.map +1 -1
- package/duty/lease-store.d.ts +4 -2
- package/duty/lease-store.d.ts.map +1 -1
- package/elicitation/flows/elicitation-request.flow.d.ts.map +1 -1
- package/elicitation/flows/elicitation-result.flow.d.ts.map +1 -1
- package/elicitation/questions/question-scope.helper.d.ts +4 -1
- package/elicitation/questions/question-scope.helper.d.ts.map +1 -1
- package/elicitation/store/elicitation-store.factory.d.ts.map +1 -1
- package/elicitation/store/elicitation.store.d.ts +8 -8
- package/elicitation/store/storage-elicitation.store.d.ts +11 -11
- package/elicitation/store/storage-elicitation.store.d.ts.map +1 -1
- package/errors/duty.errors.d.ts +1 -1
- package/errors/duty.errors.d.ts.map +1 -1
- package/errors/error-handler.d.ts.map +1 -1
- package/errors/event.errors.d.ts +9 -2
- package/errors/event.errors.d.ts.map +1 -1
- package/errors/misconfiguration.d.ts +10 -0
- package/errors/misconfiguration.d.ts.map +1 -1
- package/errors/worker.errors.d.ts +1 -1
- package/esm/index.mjs +63 -59
- package/esm-loader/esm-cache.d.ts.map +1 -1
- package/esm-loader/esm-module-loader.d.ts.map +1 -1
- package/event/event-scope.helper.d.ts.map +1 -1
- package/event/flows/event-publish-http.flow.d.ts +5 -2
- package/event/flows/event-publish-http.flow.d.ts.map +1 -1
- package/ext-apps/ext-apps.handler.d.ts +3 -0
- package/ext-apps/ext-apps.handler.d.ts.map +1 -1
- package/flows/flow.registry.d.ts.map +1 -1
- package/front-mcp/authorities-rules.check.d.ts +2 -1
- package/front-mcp/authorities-rules.check.d.ts.map +1 -1
- package/front-mcp/front-mcp.d.ts +3 -0
- package/front-mcp/front-mcp.d.ts.map +1 -1
- package/index.js +68 -64
- package/job/execution/job-execution.manager.d.ts.map +1 -1
- package/job/job-permission.guard.d.ts +2 -0
- package/job/job-permission.guard.d.ts.map +1 -1
- package/job/job-run-access.d.ts +7 -3
- package/job/job-run-access.d.ts.map +1 -1
- package/job/store/job-state.interface.d.ts +2 -0
- package/job/store/job-state.interface.d.ts.map +1 -1
- package/job/tools/list-jobs.tool.d.ts.map +1 -1
- package/job/tools/remove-job.tool.d.ts.map +1 -1
- package/job/tools/update-job.tool.d.ts.map +1 -1
- package/logger/instances/instance.console-logger.d.ts +1 -1
- package/logger/instances/instance.console-logger.d.ts.map +1 -1
- package/logger/instances/instance.file-logger.d.ts +2 -1
- package/logger/instances/instance.file-logger.d.ts.map +1 -1
- package/logger/session-id-hash.d.ts +3 -0
- package/logger/session-id-hash.d.ts.map +1 -0
- package/metrics/metrics.service.d.ts.map +1 -1
- package/offload/offload-worker.globals.d.ts +2 -2
- package/offload/offload-worker.globals.d.ts.map +1 -1
- package/offload/worker-jobs.d.ts.map +1 -1
- package/package.json +10 -10
- package/plugin/enforced-metadata.check.d.ts +3 -3
- package/plugin/enforced-metadata.check.d.ts.map +1 -1
- package/prompt/flows/get-prompt.flow.d.ts +1 -0
- package/prompt/flows/get-prompt.flow.d.ts.map +1 -1
- package/prompt/flows/prompts-list.flow.d.ts +2 -1
- package/prompt/flows/prompts-list.flow.d.ts.map +1 -1
- package/provider/provider.registry.d.ts +2 -0
- package/provider/provider.registry.d.ts.map +1 -1
- package/provider/provider.utils.d.ts +2 -2
- package/provider/provider.utils.d.ts.map +1 -1
- package/remote-mcp/mcp-client.service.d.ts.map +1 -1
- package/remote-mcp/mcp-client.types.d.ts +2 -0
- package/remote-mcp/mcp-client.types.d.ts.map +1 -1
- package/remote-mcp/remote-entries.d.ts.map +1 -1
- package/remote-mcp/remote-oauth.d.ts +4 -2
- package/remote-mcp/remote-oauth.d.ts.map +1 -1
- package/resource/flows/read-resource.flow.d.ts +1 -0
- package/resource/flows/read-resource.flow.d.ts.map +1 -1
- package/resource/flows/resource-templates-list.flow.d.ts.map +1 -1
- package/resource/flows/resources-list.flow.d.ts +2 -1
- package/resource/flows/resources-list.flow.d.ts.map +1 -1
- package/resource/flows/subscribe-resource.flow.d.ts.map +1 -1
- package/resource/resource.instance.d.ts.map +1 -1
- package/scope/flows/http.request.flow.d.ts +2 -0
- package/scope/flows/http.request.flow.d.ts.map +1 -1
- package/scope/optional-dependency.util.d.ts +1 -12
- package/scope/optional-dependency.util.d.ts.map +1 -1
- package/scope/scope.instance.d.ts.map +1 -1
- package/server/security/replaceable-directory.d.ts +4 -1
- package/server/security/replaceable-directory.d.ts.map +1 -1
- package/server/security/resolve-allowed-hosts.d.ts.map +1 -1
- package/server/server.validation.d.ts.map +1 -1
- package/shared/shared-endpoint.d.ts.map +1 -1
- package/skill/cache/skill-http-cache.catalog.d.ts +6 -0
- package/skill/cache/skill-http-cache.catalog.d.ts.map +1 -0
- package/skill/flows/http/llm-full-txt.flow.d.ts.map +1 -1
- package/skill/flows/http/llm-txt.flow.d.ts.map +1 -1
- package/skill/flows/load-skill.flow.d.ts.map +1 -1
- package/skill/hooks/skill-tool.hook.d.ts +2 -0
- package/skill/hooks/skill-tool.hook.d.ts.map +1 -1
- package/skill/sep-2640/sep-2640.resource-helpers.d.ts +5 -4
- package/skill/sep-2640/sep-2640.resource-helpers.d.ts.map +1 -1
- package/skill/session/skill-session.manager.d.ts +2 -0
- package/skill/session/skill-session.manager.d.ts.map +1 -1
- package/skill/session/skill-session.types.d.ts +6 -0
- package/skill/session/skill-session.types.d.ts.map +1 -1
- package/skill/skill-authorities.helper.d.ts +4 -5
- package/skill/skill-authorities.helper.d.ts.map +1 -1
- package/skill/skill-directory-loader.d.ts.map +1 -1
- package/skill/skill-filter.helper.d.ts +15 -15
- package/skill/skill-filter.helper.d.ts.map +1 -1
- package/skill/skill-md-parser.d.ts.map +1 -1
- package/skill/skill.instance.d.ts +5 -0
- package/skill/skill.instance.d.ts.map +1 -1
- package/storage/sqlite-on-edge.d.ts +5 -0
- package/storage/sqlite-on-edge.d.ts.map +1 -0
- package/task/store/task-store.factory.d.ts.map +1 -1
- package/tool/flows/call-tool.flow.d.ts +5 -2
- package/tool/flows/call-tool.flow.d.ts.map +1 -1
- package/tool/flows/tools-list.flow.d.ts +2 -1
- package/tool/flows/tools-list.flow.d.ts.map +1 -1
- package/transport/adapters/transport.local.adapter.d.ts.map +1 -1
- package/transport/event-stores/event-store.factory.d.ts.map +1 -1
- package/transport/event-stores/redis.event-store.d.ts.map +1 -1
- package/transport/flows/handle.streamable-http.flow.d.ts.map +1 -1
- package/transport/in-memory-server.d.ts.map +1 -1
- package/transport/mcp-20260728/client/mcp-stateless.client.d.ts +8 -2
- package/transport/mcp-20260728/client/mcp-stateless.client.d.ts.map +1 -1
- package/transport/mcp-20260728/dispatcher.d.ts +3 -1
- package/transport/mcp-20260728/dispatcher.d.ts.map +1 -1
- package/transport/mcp-handlers/index.d.ts +32 -24
- package/transport/mcp-handlers/index.d.ts.map +1 -1
- package/transport/mcp-handlers/skills-list-request.handler.d.ts.map +1 -1
- package/transport/mcp-handlers/skills-mcp.types.d.ts +2 -0
- package/transport/mcp-handlers/skills-mcp.types.d.ts.map +1 -1
- package/transport/web-fetch-handler.d.ts +10 -8
- package/transport/web-fetch-handler.d.ts.map +1 -1
- package/transport/web-response.renderer.d.ts.map +1 -1
- package/worker/worker.lifecycle.d.ts +2 -2
- package/worker/worker.lifecycle.d.ts.map +1 -1
- package/workflow/tools/list-workflows.tool.d.ts.map +1 -1
- package/workflow/tools/register-workflow.tool.d.ts.map +1 -1
- package/workflow/tools/remove-workflow.tool.d.ts.map +1 -1
- package/workflow/tools/runtime-workflow.limits.d.ts +3 -0
- package/workflow/tools/runtime-workflow.limits.d.ts.map +1 -0
- package/workflow/tools/update-workflow.tool.d.ts.map +1 -1
- package/workflow/trigger/workflow-webhook.signature.d.ts +8 -5
- package/workflow/trigger/workflow-webhook.signature.d.ts.map +1 -1
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
// libs/sdk/src/elicitation/store/storage-elicitation.store.ts
|
|
2
2
|
import { expiresAtToTTL, TypedStorage } from "@frontmcp/utils";
|
|
3
|
+
import { ElicitationSubscriptionError } from "../../errors/index.mjs";
|
|
4
|
+
import { sessionIdHash } from "../../logger/session-id-hash.mjs";
|
|
3
5
|
var RESOLVED_RESULT_TTL_SECONDS = 300;
|
|
4
6
|
var RESULT_CHANNEL_PREFIX = "result:";
|
|
5
7
|
var FALLBACK_RESULT_CHANNEL_PREFIX = "fallback-result:";
|
|
8
|
+
function elicitationResultRoute(sessionId, elicitId) {
|
|
9
|
+
return `${sessionId.replace(/%/g, "%25").replace(/:/g, "%3A")}:${elicitId}`;
|
|
10
|
+
}
|
|
11
|
+
function requireSubscriberSession(elicitId, sessionId) {
|
|
12
|
+
if (!sessionId) {
|
|
13
|
+
throw new ElicitationSubscriptionError(
|
|
14
|
+
elicitId,
|
|
15
|
+
new Error("a result subscription needs the session ID the elicitation belongs to; pass it as the third argument")
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return sessionId;
|
|
19
|
+
}
|
|
6
20
|
var StorageElicitationStore = class {
|
|
7
21
|
storage;
|
|
8
22
|
pending;
|
|
9
23
|
fallback;
|
|
10
24
|
resolved;
|
|
11
25
|
logger;
|
|
12
|
-
/** Local callback registry for pub/sub (maps
|
|
26
|
+
/** Local callback registry for pub/sub (maps route -> callbacks) */
|
|
13
27
|
localCallbacks = /* @__PURE__ */ new Map();
|
|
14
|
-
/** Active subscriptions (maps
|
|
28
|
+
/** Active subscriptions (maps route -> unsubscribe function) */
|
|
15
29
|
activeSubscriptions = /* @__PURE__ */ new Map();
|
|
16
30
|
/** Pending subscriptions guard to prevent duplicate concurrent subscribe calls */
|
|
17
31
|
pendingSubscriptions = /* @__PURE__ */ new Map();
|
|
18
|
-
/** Local callback registry for fallback results (maps
|
|
32
|
+
/** Local callback registry for fallback results (maps route -> callbacks) */
|
|
19
33
|
fallbackResultCallbacks = /* @__PURE__ */ new Map();
|
|
20
|
-
/** Active fallback subscriptions (maps
|
|
34
|
+
/** Active fallback subscriptions (maps route -> unsubscribe function) */
|
|
21
35
|
activeFallbackSubscriptions = /* @__PURE__ */ new Map();
|
|
22
36
|
/** Pending fallback subscriptions guard */
|
|
23
37
|
pendingFallbackSubscriptions = /* @__PURE__ */ new Map();
|
|
@@ -39,14 +53,14 @@ var StorageElicitationStore = class {
|
|
|
39
53
|
const ttlSeconds = expiresAtToTTL(expiresAt);
|
|
40
54
|
if (ttlSeconds <= 0) {
|
|
41
55
|
this.logger?.warn("[StorageElicitationStore] Record already expired, not storing", {
|
|
42
|
-
sessionId,
|
|
56
|
+
sessionIdHash: sessionIdHash(sessionId),
|
|
43
57
|
elicitId: record.elicitId
|
|
44
58
|
});
|
|
45
59
|
return;
|
|
46
60
|
}
|
|
47
61
|
await this.pending.set(sessionId, record, { ttlSeconds });
|
|
48
62
|
this.logger?.debug("[StorageElicitationStore] Stored pending elicitation", {
|
|
49
|
-
sessionId,
|
|
63
|
+
sessionIdHash: sessionIdHash(sessionId),
|
|
50
64
|
elicitId: record.elicitId,
|
|
51
65
|
ttlSeconds
|
|
52
66
|
});
|
|
@@ -70,28 +84,31 @@ var StorageElicitationStore = class {
|
|
|
70
84
|
*/
|
|
71
85
|
async deletePending(sessionId) {
|
|
72
86
|
await this.pending.delete(sessionId);
|
|
73
|
-
this.logger?.debug("[StorageElicitationStore] Deleted pending elicitation", {
|
|
87
|
+
this.logger?.debug("[StorageElicitationStore] Deleted pending elicitation", {
|
|
88
|
+
sessionIdHash: sessionIdHash(sessionId)
|
|
89
|
+
});
|
|
74
90
|
}
|
|
75
91
|
// ============================================
|
|
76
92
|
// Pub/Sub Methods
|
|
77
93
|
// ============================================
|
|
78
94
|
/**
|
|
79
|
-
* Subscribe to elicitation results for a specific elicit ID.
|
|
95
|
+
* Subscribe to elicitation results for a specific elicit ID within the session that asked.
|
|
80
96
|
* Uses in-flight subscription guard to prevent duplicate concurrent subscriptions.
|
|
81
97
|
*/
|
|
82
|
-
async subscribeResult(elicitId, callback,
|
|
83
|
-
|
|
98
|
+
async subscribeResult(elicitId, callback, sessionId) {
|
|
99
|
+
const route = elicitationResultRoute(requireSubscriberSession(elicitId, sessionId), elicitId);
|
|
100
|
+
let callbacks = this.localCallbacks.get(route);
|
|
84
101
|
if (!callbacks) {
|
|
85
102
|
callbacks = /* @__PURE__ */ new Set();
|
|
86
|
-
this.localCallbacks.set(
|
|
103
|
+
this.localCallbacks.set(route, callbacks);
|
|
87
104
|
}
|
|
88
105
|
callbacks.add(callback);
|
|
89
|
-
if (!this.activeSubscriptions.has(
|
|
90
|
-
const channel = RESULT_CHANNEL_PREFIX +
|
|
106
|
+
if (!this.activeSubscriptions.has(route) && !this.pendingSubscriptions.has(route) && this.storage.supportsPubSub()) {
|
|
107
|
+
const channel = RESULT_CHANNEL_PREFIX + route;
|
|
91
108
|
const subscribePromise = this.storage.subscribe(channel, (message) => {
|
|
92
109
|
try {
|
|
93
110
|
const result = JSON.parse(message);
|
|
94
|
-
const cbs = this.localCallbacks.get(
|
|
111
|
+
const cbs = this.localCallbacks.get(route);
|
|
95
112
|
if (cbs) {
|
|
96
113
|
for (const cb of cbs) {
|
|
97
114
|
try {
|
|
@@ -111,34 +128,34 @@ var StorageElicitationStore = class {
|
|
|
111
128
|
});
|
|
112
129
|
}
|
|
113
130
|
}).then((unsubscribe) => {
|
|
114
|
-
this.pendingSubscriptions.delete(
|
|
115
|
-
this.activeSubscriptions.set(
|
|
131
|
+
this.pendingSubscriptions.delete(route);
|
|
132
|
+
this.activeSubscriptions.set(route, unsubscribe);
|
|
116
133
|
return unsubscribe;
|
|
117
134
|
}).catch((err) => {
|
|
118
|
-
this.pendingSubscriptions.delete(
|
|
135
|
+
this.pendingSubscriptions.delete(route);
|
|
119
136
|
this.logger?.error("[StorageElicitationStore] Failed to subscribe", {
|
|
120
137
|
elicitId,
|
|
121
138
|
error: err instanceof Error ? err.message : String(err)
|
|
122
139
|
});
|
|
123
140
|
throw err;
|
|
124
141
|
});
|
|
125
|
-
this.pendingSubscriptions.set(
|
|
142
|
+
this.pendingSubscriptions.set(route, subscribePromise);
|
|
126
143
|
try {
|
|
127
144
|
await subscribePromise;
|
|
128
145
|
} catch (error) {
|
|
129
146
|
callbacks.delete(callback);
|
|
130
147
|
if (callbacks.size === 0) {
|
|
131
|
-
this.localCallbacks.delete(
|
|
148
|
+
this.localCallbacks.delete(route);
|
|
132
149
|
}
|
|
133
150
|
throw error;
|
|
134
151
|
}
|
|
135
|
-
} else if (this.pendingSubscriptions.has(
|
|
152
|
+
} else if (this.pendingSubscriptions.has(route)) {
|
|
136
153
|
try {
|
|
137
|
-
await this.pendingSubscriptions.get(
|
|
154
|
+
await this.pendingSubscriptions.get(route);
|
|
138
155
|
} catch (error) {
|
|
139
156
|
callbacks.delete(callback);
|
|
140
157
|
if (callbacks.size === 0) {
|
|
141
|
-
this.localCallbacks.delete(
|
|
158
|
+
this.localCallbacks.delete(route);
|
|
142
159
|
}
|
|
143
160
|
throw error;
|
|
144
161
|
}
|
|
@@ -146,16 +163,16 @@ var StorageElicitationStore = class {
|
|
|
146
163
|
return async () => {
|
|
147
164
|
callbacks.delete(callback);
|
|
148
165
|
if (callbacks.size === 0) {
|
|
149
|
-
this.localCallbacks.delete(
|
|
150
|
-
if (this.pendingSubscriptions.has(
|
|
166
|
+
this.localCallbacks.delete(route);
|
|
167
|
+
if (this.pendingSubscriptions.has(route)) {
|
|
151
168
|
try {
|
|
152
|
-
await this.pendingSubscriptions.get(
|
|
169
|
+
await this.pendingSubscriptions.get(route);
|
|
153
170
|
} catch {
|
|
154
171
|
}
|
|
155
172
|
}
|
|
156
|
-
const unsubscribe = this.activeSubscriptions.get(
|
|
173
|
+
const unsubscribe = this.activeSubscriptions.get(route);
|
|
157
174
|
if (unsubscribe) {
|
|
158
|
-
this.activeSubscriptions.delete(
|
|
175
|
+
this.activeSubscriptions.delete(route);
|
|
159
176
|
try {
|
|
160
177
|
await unsubscribe();
|
|
161
178
|
} catch (err) {
|
|
@@ -169,7 +186,7 @@ var StorageElicitationStore = class {
|
|
|
169
186
|
};
|
|
170
187
|
}
|
|
171
188
|
/**
|
|
172
|
-
* Publish an elicitation result.
|
|
189
|
+
* Publish an elicitation result to the subscribers in the session that asked.
|
|
173
190
|
*
|
|
174
191
|
* When pub/sub is supported, we rely entirely on the pub/sub mechanism
|
|
175
192
|
* to deliver messages (even locally). This avoids double-invocation for
|
|
@@ -178,8 +195,9 @@ var StorageElicitationStore = class {
|
|
|
178
195
|
* When pub/sub is not supported, we invoke local callbacks directly.
|
|
179
196
|
*/
|
|
180
197
|
async publishResult(elicitId, sessionId, result) {
|
|
198
|
+
const route = elicitationResultRoute(sessionId, elicitId);
|
|
181
199
|
if (this.storage.supportsPubSub()) {
|
|
182
|
-
const channel = RESULT_CHANNEL_PREFIX +
|
|
200
|
+
const channel = RESULT_CHANNEL_PREFIX + route;
|
|
183
201
|
try {
|
|
184
202
|
await this.storage.publish(channel, JSON.stringify(result));
|
|
185
203
|
} catch (err) {
|
|
@@ -189,7 +207,7 @@ var StorageElicitationStore = class {
|
|
|
189
207
|
});
|
|
190
208
|
}
|
|
191
209
|
} else {
|
|
192
|
-
const callbacks = this.localCallbacks.get(
|
|
210
|
+
const callbacks = this.localCallbacks.get(route);
|
|
193
211
|
if (callbacks) {
|
|
194
212
|
for (const cb of callbacks) {
|
|
195
213
|
try {
|
|
@@ -204,7 +222,11 @@ var StorageElicitationStore = class {
|
|
|
204
222
|
}
|
|
205
223
|
}
|
|
206
224
|
await this.deletePending(sessionId);
|
|
207
|
-
this.logger?.debug("[StorageElicitationStore] Published result", {
|
|
225
|
+
this.logger?.debug("[StorageElicitationStore] Published result", {
|
|
226
|
+
elicitId,
|
|
227
|
+
sessionIdHash: sessionIdHash(sessionId),
|
|
228
|
+
status: result.status
|
|
229
|
+
});
|
|
208
230
|
}
|
|
209
231
|
// ============================================
|
|
210
232
|
// Fallback Elicitation Methods
|
|
@@ -275,22 +297,23 @@ var StorageElicitationStore = class {
|
|
|
275
297
|
// Waiting Fallback Pub/Sub Methods
|
|
276
298
|
// ============================================
|
|
277
299
|
/**
|
|
278
|
-
* Subscribe to fallback execution results for a specific elicit ID.
|
|
300
|
+
* Subscribe to fallback execution results for a specific elicit ID within the session that asked.
|
|
279
301
|
* Uses in-flight subscription guard to prevent duplicate concurrent subscriptions.
|
|
280
302
|
*/
|
|
281
|
-
async subscribeFallbackResult(elicitId, callback,
|
|
282
|
-
|
|
303
|
+
async subscribeFallbackResult(elicitId, callback, sessionId) {
|
|
304
|
+
const route = elicitationResultRoute(requireSubscriberSession(elicitId, sessionId), elicitId);
|
|
305
|
+
let callbacks = this.fallbackResultCallbacks.get(route);
|
|
283
306
|
if (!callbacks) {
|
|
284
307
|
callbacks = /* @__PURE__ */ new Set();
|
|
285
|
-
this.fallbackResultCallbacks.set(
|
|
308
|
+
this.fallbackResultCallbacks.set(route, callbacks);
|
|
286
309
|
}
|
|
287
310
|
callbacks.add(callback);
|
|
288
|
-
if (!this.activeFallbackSubscriptions.has(
|
|
289
|
-
const channel = FALLBACK_RESULT_CHANNEL_PREFIX +
|
|
311
|
+
if (!this.activeFallbackSubscriptions.has(route) && !this.pendingFallbackSubscriptions.has(route) && this.storage.supportsPubSub()) {
|
|
312
|
+
const channel = FALLBACK_RESULT_CHANNEL_PREFIX + route;
|
|
290
313
|
const subscribePromise = this.storage.subscribe(channel, (message) => {
|
|
291
314
|
try {
|
|
292
315
|
const result = JSON.parse(message);
|
|
293
|
-
const cbs = this.fallbackResultCallbacks.get(
|
|
316
|
+
const cbs = this.fallbackResultCallbacks.get(route);
|
|
294
317
|
if (cbs) {
|
|
295
318
|
for (const cb of cbs) {
|
|
296
319
|
try {
|
|
@@ -310,34 +333,34 @@ var StorageElicitationStore = class {
|
|
|
310
333
|
});
|
|
311
334
|
}
|
|
312
335
|
}).then((unsubscribe) => {
|
|
313
|
-
this.pendingFallbackSubscriptions.delete(
|
|
314
|
-
this.activeFallbackSubscriptions.set(
|
|
336
|
+
this.pendingFallbackSubscriptions.delete(route);
|
|
337
|
+
this.activeFallbackSubscriptions.set(route, unsubscribe);
|
|
315
338
|
return unsubscribe;
|
|
316
339
|
}).catch((err) => {
|
|
317
|
-
this.pendingFallbackSubscriptions.delete(
|
|
340
|
+
this.pendingFallbackSubscriptions.delete(route);
|
|
318
341
|
this.logger?.error("[StorageElicitationStore] Failed to subscribe to fallback result", {
|
|
319
342
|
elicitId,
|
|
320
343
|
error: err instanceof Error ? err.message : String(err)
|
|
321
344
|
});
|
|
322
345
|
throw err;
|
|
323
346
|
});
|
|
324
|
-
this.pendingFallbackSubscriptions.set(
|
|
347
|
+
this.pendingFallbackSubscriptions.set(route, subscribePromise);
|
|
325
348
|
try {
|
|
326
349
|
await subscribePromise;
|
|
327
350
|
} catch (error) {
|
|
328
351
|
callbacks.delete(callback);
|
|
329
352
|
if (callbacks.size === 0) {
|
|
330
|
-
this.fallbackResultCallbacks.delete(
|
|
353
|
+
this.fallbackResultCallbacks.delete(route);
|
|
331
354
|
}
|
|
332
355
|
throw error;
|
|
333
356
|
}
|
|
334
|
-
} else if (this.pendingFallbackSubscriptions.has(
|
|
357
|
+
} else if (this.pendingFallbackSubscriptions.has(route)) {
|
|
335
358
|
try {
|
|
336
|
-
await this.pendingFallbackSubscriptions.get(
|
|
359
|
+
await this.pendingFallbackSubscriptions.get(route);
|
|
337
360
|
} catch (error) {
|
|
338
361
|
callbacks.delete(callback);
|
|
339
362
|
if (callbacks.size === 0) {
|
|
340
|
-
this.fallbackResultCallbacks.delete(
|
|
363
|
+
this.fallbackResultCallbacks.delete(route);
|
|
341
364
|
}
|
|
342
365
|
throw error;
|
|
343
366
|
}
|
|
@@ -345,16 +368,16 @@ var StorageElicitationStore = class {
|
|
|
345
368
|
return async () => {
|
|
346
369
|
callbacks.delete(callback);
|
|
347
370
|
if (callbacks.size === 0) {
|
|
348
|
-
this.fallbackResultCallbacks.delete(
|
|
349
|
-
if (this.pendingFallbackSubscriptions.has(
|
|
371
|
+
this.fallbackResultCallbacks.delete(route);
|
|
372
|
+
if (this.pendingFallbackSubscriptions.has(route)) {
|
|
350
373
|
try {
|
|
351
|
-
await this.pendingFallbackSubscriptions.get(
|
|
374
|
+
await this.pendingFallbackSubscriptions.get(route);
|
|
352
375
|
} catch {
|
|
353
376
|
}
|
|
354
377
|
}
|
|
355
|
-
const unsubscribe = this.activeFallbackSubscriptions.get(
|
|
378
|
+
const unsubscribe = this.activeFallbackSubscriptions.get(route);
|
|
356
379
|
if (unsubscribe) {
|
|
357
|
-
this.activeFallbackSubscriptions.delete(
|
|
380
|
+
this.activeFallbackSubscriptions.delete(route);
|
|
358
381
|
try {
|
|
359
382
|
await unsubscribe();
|
|
360
383
|
} catch (err) {
|
|
@@ -368,7 +391,7 @@ var StorageElicitationStore = class {
|
|
|
368
391
|
};
|
|
369
392
|
}
|
|
370
393
|
/**
|
|
371
|
-
* Publish a fallback execution result.
|
|
394
|
+
* Publish a fallback execution result to the subscribers in the session that asked.
|
|
372
395
|
*
|
|
373
396
|
* When pub/sub is supported, we rely entirely on the pub/sub mechanism
|
|
374
397
|
* to deliver messages (even locally). This avoids double-invocation for
|
|
@@ -377,8 +400,9 @@ var StorageElicitationStore = class {
|
|
|
377
400
|
* When pub/sub is not supported, we invoke local callbacks directly.
|
|
378
401
|
*/
|
|
379
402
|
async publishFallbackResult(elicitId, sessionId, result) {
|
|
403
|
+
const route = elicitationResultRoute(sessionId, elicitId);
|
|
380
404
|
if (this.storage.supportsPubSub()) {
|
|
381
|
-
const channel = FALLBACK_RESULT_CHANNEL_PREFIX +
|
|
405
|
+
const channel = FALLBACK_RESULT_CHANNEL_PREFIX + route;
|
|
382
406
|
try {
|
|
383
407
|
await this.storage.publish(channel, JSON.stringify(result));
|
|
384
408
|
} catch (err) {
|
|
@@ -388,7 +412,7 @@ var StorageElicitationStore = class {
|
|
|
388
412
|
});
|
|
389
413
|
}
|
|
390
414
|
} else {
|
|
391
|
-
const callbacks = this.fallbackResultCallbacks.get(
|
|
415
|
+
const callbacks = this.fallbackResultCallbacks.get(route);
|
|
392
416
|
if (callbacks) {
|
|
393
417
|
for (const cb of callbacks) {
|
|
394
418
|
try {
|
|
@@ -404,7 +428,7 @@ var StorageElicitationStore = class {
|
|
|
404
428
|
}
|
|
405
429
|
this.logger?.debug("[StorageElicitationStore] Published fallback result", {
|
|
406
430
|
elicitId,
|
|
407
|
-
sessionId,
|
|
431
|
+
sessionIdHash: sessionIdHash(sessionId),
|
|
408
432
|
success: result.success
|
|
409
433
|
});
|
|
410
434
|
}
|
|
@@ -415,42 +439,38 @@ var StorageElicitationStore = class {
|
|
|
415
439
|
* Clean up store resources.
|
|
416
440
|
*/
|
|
417
441
|
async destroy() {
|
|
418
|
-
for (const
|
|
442
|
+
for (const pendingPromise of this.pendingSubscriptions.values()) {
|
|
419
443
|
try {
|
|
420
444
|
await pendingPromise;
|
|
421
445
|
} catch (err) {
|
|
422
446
|
this.logger?.debug("[StorageElicitationStore] Pending subscription failed during destroy", {
|
|
423
|
-
elicitId,
|
|
424
447
|
error: err instanceof Error ? err.message : String(err)
|
|
425
448
|
});
|
|
426
449
|
}
|
|
427
450
|
}
|
|
428
|
-
for (const
|
|
451
|
+
for (const unsubscribe of this.activeSubscriptions.values()) {
|
|
429
452
|
try {
|
|
430
453
|
await unsubscribe();
|
|
431
454
|
} catch (err) {
|
|
432
455
|
this.logger?.error("[StorageElicitationStore] Failed to unsubscribe during destroy", {
|
|
433
|
-
elicitId,
|
|
434
456
|
error: err instanceof Error ? err.message : String(err)
|
|
435
457
|
});
|
|
436
458
|
}
|
|
437
459
|
}
|
|
438
|
-
for (const
|
|
460
|
+
for (const pendingPromise of this.pendingFallbackSubscriptions.values()) {
|
|
439
461
|
try {
|
|
440
462
|
await pendingPromise;
|
|
441
463
|
} catch (err) {
|
|
442
464
|
this.logger?.debug("[StorageElicitationStore] Pending fallback subscription failed during destroy", {
|
|
443
|
-
elicitId,
|
|
444
465
|
error: err instanceof Error ? err.message : String(err)
|
|
445
466
|
});
|
|
446
467
|
}
|
|
447
468
|
}
|
|
448
|
-
for (const
|
|
469
|
+
for (const unsubscribe of this.activeFallbackSubscriptions.values()) {
|
|
449
470
|
try {
|
|
450
471
|
await unsubscribe();
|
|
451
472
|
} catch (err) {
|
|
452
473
|
this.logger?.error("[StorageElicitationStore] Failed to unsubscribe fallback during destroy", {
|
|
453
|
-
elicitId,
|
|
454
474
|
error: err instanceof Error ? err.message : String(err)
|
|
455
475
|
});
|
|
456
476
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// libs/sdk/src/errors/error-handler.ts
|
|
2
|
-
import { isProduction } from "@frontmcp/utils";
|
|
2
|
+
import { escapeControlCharacters, isProduction } from "@frontmcp/utils";
|
|
3
3
|
import { FlowControl } from "../common/interfaces/flow.interface.mjs";
|
|
4
4
|
import { McpError, toMcpError } from "./mcp.error.mjs";
|
|
5
5
|
var ErrorHandler = class {
|
|
@@ -33,12 +33,12 @@ var ErrorHandler = class {
|
|
|
33
33
|
};
|
|
34
34
|
if (error instanceof McpError) {
|
|
35
35
|
if (error.isPublic) {
|
|
36
|
-
this.logger.warn(`Public error: ${error.getInternalMessage()}`, meta);
|
|
36
|
+
this.logger.warn(`Public error: ${escapeControlCharacters(error.getInternalMessage())}`, meta);
|
|
37
37
|
} else {
|
|
38
|
-
this.logger.error(`Internal error: ${error.getInternalMessage()}`, meta);
|
|
38
|
+
this.logger.error(`Internal error: ${escapeControlCharacters(error.getInternalMessage())}`, meta);
|
|
39
39
|
}
|
|
40
40
|
} else {
|
|
41
|
-
this.logger.error(`Unexpected error: ${error.message || String(error)}`, meta);
|
|
41
|
+
this.logger.error(`Unexpected error: ${escapeControlCharacters(error.message || String(error))}`, meta);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
@@ -40,7 +40,9 @@ var EventForbiddenError = class extends EventProtocolError {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
var RESOURCE_LIMIT_MESSAGES = {
|
|
43
|
-
subscriptions: (max) => `The limit of ${max} subscriptions per caller is reached. Remove one with events/unsubscribe, then retry.`,
|
|
43
|
+
subscriptions: (max) => `The limit of ${max} webhook subscriptions per caller is reached. Remove one with events/unsubscribe, then retry.`,
|
|
44
|
+
pollLeases: (max) => `The limit of ${max} poll leases per caller is reached. A lease ends when its subscription is not polled for its lease time: stop polling one, then retry.`,
|
|
45
|
+
streams: (max) => `The limit of ${max} open event streams per caller is reached. Close one, then retry.`,
|
|
44
46
|
verifications: (max) => `The callback host was sent ${max} verification requests in the last minute. Retry in a minute.`
|
|
45
47
|
};
|
|
46
48
|
var EventResourceExhaustedError = class extends EventProtocolError {
|
|
@@ -20,11 +20,16 @@ function findMisconfiguration(error) {
|
|
|
20
20
|
if (typeof code === "string" && Object.prototype.hasOwnProperty.call(MISCONFIGURATION_REMEDIES, code)) {
|
|
21
21
|
return { code, remedy: MISCONFIGURATION_REMEDIES[code] };
|
|
22
22
|
}
|
|
23
|
-
if (current.name === "ZodError") return { code: "CONFIG_INVALID", remedy: CONFIG_INVALID_REMEDY };
|
|
24
23
|
current = current.cause;
|
|
25
24
|
}
|
|
26
25
|
return void 0;
|
|
27
26
|
}
|
|
27
|
+
function findStartupMisconfiguration(error) {
|
|
28
|
+
const coded = findMisconfiguration(error);
|
|
29
|
+
if (coded) return coded;
|
|
30
|
+
if (describeConfigIssues(error) === void 0) return void 0;
|
|
31
|
+
return { code: "CONFIG_INVALID", remedy: CONFIG_INVALID_REMEDY };
|
|
32
|
+
}
|
|
28
33
|
function flattenConfigIssue(issue, parentPath) {
|
|
29
34
|
const path = [...parentPath, ...issue.path ?? []];
|
|
30
35
|
const branches = issue.errors?.filter((branch) => branch.length > 0) ?? [];
|
|
@@ -55,5 +60,6 @@ export {
|
|
|
55
60
|
MISCONFIGURATION_REMEDIES,
|
|
56
61
|
describeConfigIssues,
|
|
57
62
|
findMisconfiguration,
|
|
63
|
+
findStartupMisconfiguration,
|
|
58
64
|
misconfigurationBody
|
|
59
65
|
};
|
|
@@ -45,7 +45,7 @@ var TransportServiceNotAvailableError = class extends InternalMcpError {
|
|
|
45
45
|
};
|
|
46
46
|
var SessionClaimConflictError = class extends InternalMcpError {
|
|
47
47
|
constructor(sessionId) {
|
|
48
|
-
super(`Session ${sessionId} claimed by another pod`, "SESSION_CLAIM_CONFLICT");
|
|
48
|
+
super(`Session ${sessionId.slice(0, 20)} claimed by another pod`, "SESSION_CLAIM_CONFLICT");
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
var SessionOwnerUnreachableError = class extends PublicMcpError {
|
|
@@ -58,7 +58,7 @@ function getDefaultCacheDir() {
|
|
|
58
58
|
return path.join(os.homedir(), ".frontmcp", "esm-cache");
|
|
59
59
|
} catch {
|
|
60
60
|
}
|
|
61
|
-
return
|
|
61
|
+
return "";
|
|
62
62
|
} catch {
|
|
63
63
|
return "";
|
|
64
64
|
}
|
|
@@ -112,6 +112,10 @@ var EsmCacheManager = class {
|
|
|
112
112
|
if (Date.now() - meta.cachedAt >= this.maxAgeMs) {
|
|
113
113
|
return void 0;
|
|
114
114
|
}
|
|
115
|
+
const ownBundles = [path.join(entryDir, "bundle.mjs"), path.join(entryDir, "bundle.cjs")];
|
|
116
|
+
if (!ownBundles.includes(meta.bundlePath)) {
|
|
117
|
+
return void 0;
|
|
118
|
+
}
|
|
115
119
|
if (!await fileExists(meta.bundlePath)) {
|
|
116
120
|
return void 0;
|
|
117
121
|
}
|
|
@@ -9,7 +9,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
// libs/sdk/src/esm-loader/esm-module-loader.ts
|
|
12
|
-
import { sha256Hex } from "@frontmcp/utils";
|
|
12
|
+
import { isNode, sha256Hex } from "@frontmcp/utils";
|
|
13
13
|
import { importComputed } from "./import-computed.mjs";
|
|
14
14
|
import { EsmCacheError, EsmManifestInvalidError, EsmPackageLoadError } from "../errors/esm.errors.mjs";
|
|
15
15
|
import { resolveRegistryToken } from "./esm-auth.types.mjs";
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
importMapPackages
|
|
22
22
|
} from "./package-specifier.mjs";
|
|
23
23
|
import { VersionResolver } from "./version-resolver.mjs";
|
|
24
|
+
var moduleDirectory;
|
|
24
25
|
var EsmModuleLoader = class {
|
|
25
26
|
cache;
|
|
26
27
|
versionResolver;
|
|
@@ -209,7 +210,7 @@ var EsmModuleLoader = class {
|
|
|
209
210
|
* Import ESM content via Blob URL (browser) or temp file (Node.js).
|
|
210
211
|
*/
|
|
211
212
|
async importEsmBundle(bundleContent) {
|
|
212
|
-
if (typeof Blob !== "undefined" && typeof URL?.createObjectURL === "function") {
|
|
213
|
+
if (!isNode() && typeof Blob !== "undefined" && typeof URL?.createObjectURL === "function") {
|
|
213
214
|
const blob = new Blob([bundleContent], { type: "text/javascript" });
|
|
214
215
|
const url = URL.createObjectURL(blob);
|
|
215
216
|
try {
|
|
@@ -218,13 +219,12 @@ var EsmModuleLoader = class {
|
|
|
218
219
|
URL.revokeObjectURL(url);
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
|
-
const {
|
|
222
|
+
const { fileExists, mkdtemp, sha256Hex: sha256Hex2, writeFile } = await import("@frontmcp/utils");
|
|
222
223
|
const nodePath = __require("node:path");
|
|
223
224
|
const nodeOs = __require("node:os");
|
|
224
225
|
const { pathToFileURL } = __require("node:url");
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const tempPath = nodePath.join(dir, `${sha256Hex2(bundleContent)}.mjs`);
|
|
226
|
+
moduleDirectory ??= await mkdtemp(nodePath.join(nodeOs.tmpdir(), "frontmcp-esm-modules-"));
|
|
227
|
+
const tempPath = nodePath.join(moduleDirectory, `${sha256Hex2(bundleContent)}.mjs`);
|
|
228
228
|
if (!await fileExists(tempPath)) {
|
|
229
229
|
await writeFile(tempPath, bundleContent);
|
|
230
230
|
}
|
|
@@ -85,7 +85,7 @@ var VersionResolver = class {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
if (data["dist-tags"]?.[specifier.range]) {
|
|
88
|
+
if (isDistTag(specifier.range) && data["dist-tags"]?.[specifier.range]) {
|
|
89
89
|
const tagVersion = data["dist-tags"][specifier.range];
|
|
90
90
|
if (isValidVersion(tagVersion)) {
|
|
91
91
|
return {
|
|
@@ -188,6 +188,18 @@ async function enablePollDelivery(scope, eventRegistry, eventsConfig, logger) {
|
|
|
188
188
|
function canHoldStreams() {
|
|
189
189
|
return getRuntimeContext().deployment !== "serverless";
|
|
190
190
|
}
|
|
191
|
+
function describeUnrelayedStreams(scope, eventsConfig) {
|
|
192
|
+
const carried = "Event streams carry what this process publishes.";
|
|
193
|
+
if (!eventsConfig.store?.redis) {
|
|
194
|
+
return `${carried} With several processes, set events.store.redis so an event published on one reaches the streams the others hold.`;
|
|
195
|
+
}
|
|
196
|
+
const reasons = [];
|
|
197
|
+
if (!eventsConfig.webhook.enabled) reasons.push("events.webhook.enabled is false, so remove that setting");
|
|
198
|
+
if (!canIdentifyCallers(scope)) {
|
|
199
|
+
reasons.push("the server runs in public auth mode, so configure an auth mode that signs callers in");
|
|
200
|
+
}
|
|
201
|
+
return `${carried} events.store.redis is set, but it relays events between processes only with webhook delivery, which is off: ${reasons.join("; ")}. Then an event published on one process reaches the streams the others hold.`;
|
|
202
|
+
}
|
|
191
203
|
async function enableStreamDelivery(scope, eventRegistry, buffer, eventsConfig, storage, logger) {
|
|
192
204
|
const streams = new EventStreams({
|
|
193
205
|
buffer,
|
|
@@ -199,11 +211,7 @@ async function enableStreamDelivery(scope, eventRegistry, buffer, eventsConfig,
|
|
|
199
211
|
eventRegistry.streams = streams;
|
|
200
212
|
await streams.start();
|
|
201
213
|
scope.onDispose(() => streams.stop());
|
|
202
|
-
if (!streams.isRelayed)
|
|
203
|
-
logger.info(
|
|
204
|
-
"Event streams carry what this process publishes. With several processes, set events.store.redis so an event published on one reaches the streams the others hold."
|
|
205
|
-
);
|
|
206
|
-
}
|
|
214
|
+
if (!streams.isRelayed) logger.info(describeUnrelayedStreams(scope, eventsConfig));
|
|
207
215
|
eventRegistry.enableDeliveryMode("push");
|
|
208
216
|
await scope.registryFlows(EventStreamFlow);
|
|
209
217
|
}
|
|
@@ -146,7 +146,7 @@ var EventPollFlow = class extends FlowBase {
|
|
|
146
146
|
if (!context.onSubscribe && !context.onUnsubscribe) return;
|
|
147
147
|
if (!leases.has(subscription.id) && leases.isFull(reader.principalKey)) {
|
|
148
148
|
const { maxPerPrincipal } = this.events.config.subscriptions;
|
|
149
|
-
throw new EventResourceExhaustedError(this.codes, "
|
|
149
|
+
throw new EventResourceExhaustedError(this.codes, "pollLeases", maxPerPrincipal);
|
|
150
150
|
}
|
|
151
151
|
await leases.renew({
|
|
152
152
|
subscription,
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
HttpJsonSchema,
|
|
26
26
|
httpRespond
|
|
27
27
|
} from "../../common/index.mjs";
|
|
28
|
+
import { PublicMcpError } from "../../errors/index.mjs";
|
|
28
29
|
import { matchRoutePath } from "../../flows/flow.http-path.mjs";
|
|
29
30
|
import { verifyWorkflowWebhook } from "../../workflow/trigger/workflow-webhook.signature.mjs";
|
|
30
31
|
import { eventSubscriberOf } from "../event-subscriber.mjs";
|
|
@@ -55,7 +56,8 @@ var stateSchema = z.object({
|
|
|
55
56
|
event: z.instanceof(EventEntry),
|
|
56
57
|
claimedEventId: z.string().optional(),
|
|
57
58
|
claimToken: z.string().optional(),
|
|
58
|
-
result: z.object({ eventId: z.string(), matched: z.number() })
|
|
59
|
+
result: z.object({ eventId: z.string(), matched: z.number() }),
|
|
60
|
+
flowError: z.instanceof(Error).optional()
|
|
59
61
|
});
|
|
60
62
|
var plan = {
|
|
61
63
|
pre: [
|
|
@@ -110,15 +112,33 @@ var EventPublishHttpFlow = class extends FlowBase {
|
|
|
110
112
|
get httpRequest() {
|
|
111
113
|
return this.rawInput.request;
|
|
112
114
|
}
|
|
113
|
-
/** Answer the request with an error and end the flow. */
|
|
115
|
+
/** Answer the request with an error and end the flow; the refusal is the run's failure, for its span and hooks. */
|
|
114
116
|
refuse(status, error, details = {}, headers) {
|
|
117
|
+
this.state.set("flowError", new PublicMcpError(`HTTP ${status}: ${error}`, "EVENT_PUBLISH_REFUSED", status));
|
|
115
118
|
return FlowControl.respond(httpRespond.json({ error, ...details }, { status, headers }));
|
|
116
119
|
}
|
|
120
|
+
/** Run a guard that answers its own refusals, and keep such a refusal as the run's failure, as `refuse()` does. */
|
|
121
|
+
async recordingRefusal(guard) {
|
|
122
|
+
try {
|
|
123
|
+
await guard();
|
|
124
|
+
} catch (signal) {
|
|
125
|
+
const refusal = signal instanceof FlowControl && signal.type === "respond" ? signal.output : void 0;
|
|
126
|
+
if (refusal?.kind === "json") {
|
|
127
|
+
const reason = Array.isArray(refusal.body) ? void 0 : refusal.body["error"];
|
|
128
|
+
const error = typeof reason === "string" ? reason : "Refused";
|
|
129
|
+
this.state.set(
|
|
130
|
+
"flowError",
|
|
131
|
+
new PublicMcpError(`HTTP ${refusal.status}: ${error}`, "EVENT_PUBLISH_REFUSED", refusal.status)
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
throw signal;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
117
137
|
async checkIpFilter() {
|
|
118
|
-
enforceIpFilter(this.scope, this.tryGetContext()?.metadata.clientIp);
|
|
138
|
+
await this.recordingRefusal(() => enforceIpFilter(this.scope, this.tryGetContext()?.metadata.clientIp));
|
|
119
139
|
}
|
|
120
140
|
async acquireQuota() {
|
|
121
|
-
await enforceGlobalRateLimit(this.scope, this.tryGetContext());
|
|
141
|
+
await this.recordingRefusal(() => enforceGlobalRateLimit(this.scope, this.tryGetContext()));
|
|
122
142
|
}
|
|
123
143
|
async readBody() {
|
|
124
144
|
const request = this.httpRequest;
|
|
@@ -145,7 +145,7 @@ var EventStreamFlow = class extends FlowBase {
|
|
|
145
145
|
});
|
|
146
146
|
if (!streams.reserve(stream)) {
|
|
147
147
|
stream.close();
|
|
148
|
-
throw new EventResourceExhaustedError(this.codes, "
|
|
148
|
+
throw new EventResourceExhaustedError(this.codes, "streams", config.subscriptions.maxPerPrincipal);
|
|
149
149
|
}
|
|
150
150
|
try {
|
|
151
151
|
await context.onSubscribe?.(subscriptionArguments, subscription);
|