@frontmcp/sdk 1.12.0-rc.1 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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/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 +5 -2
- 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 +2035 -1340
- 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 +62 -58
- 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 +3 -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
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
LeaseClaims,
|
|
13
13
|
leaseKey,
|
|
14
14
|
leaseStorageConfig,
|
|
15
|
+
nameKey,
|
|
15
16
|
registerReadinessProbe,
|
|
16
17
|
startsBackgroundWork
|
|
17
18
|
} from "./lease-store.mjs";
|
|
@@ -139,7 +140,7 @@ var DutyLifecycle = class {
|
|
|
139
140
|
const config = this.providers.get(FrontMcpConfig);
|
|
140
141
|
const serverName = config.info?.name ?? "frontmcp";
|
|
141
142
|
const key = leaseKey(name, scope, serverName);
|
|
142
|
-
this.claim(
|
|
143
|
+
this.claim(serverName);
|
|
143
144
|
const storage = new LazyLeaseStore(dutyStorageConfig(config.redis, scope));
|
|
144
145
|
const run = (context) => this.duty.run(context);
|
|
145
146
|
const common = { name, key, leaseMs, storage, logger, run };
|
|
@@ -153,8 +154,9 @@ var DutyLifecycle = class {
|
|
|
153
154
|
await runner.start();
|
|
154
155
|
return { runner, storage, removeHealthProbe };
|
|
155
156
|
}
|
|
156
|
-
/** Take
|
|
157
|
-
claim(
|
|
157
|
+
/** Take the duty's name in its server for its class: another class with it fails to start, whatever its scope. */
|
|
158
|
+
claim(serverName) {
|
|
159
|
+
const key = nameKey(this.metadata.name, serverName);
|
|
158
160
|
const type = this.duty.constructor;
|
|
159
161
|
const otherClass = claims.claim(key, type);
|
|
160
162
|
if (otherClass !== void 0) {
|
|
@@ -71,8 +71,11 @@ function leaseStorageConfig(redis, kind, scope) {
|
|
|
71
71
|
fallback: "error"
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
+
function nameKey(name, serverName) {
|
|
75
|
+
return [serverName, name].map(encodeURIComponent).join(":");
|
|
76
|
+
}
|
|
74
77
|
function leaseKey(name, scope, serverName) {
|
|
75
|
-
const key =
|
|
78
|
+
const key = nameKey(name, serverName);
|
|
76
79
|
if (scope !== "workspace") return key;
|
|
77
80
|
const cwd = process.cwd();
|
|
78
81
|
return `${key}:${sha256Hex(findProjectRoot(cwd) ?? cwd)}`;
|
|
@@ -96,7 +99,7 @@ async function prepareLeaseFile(file) {
|
|
|
96
99
|
var LeaseClaims = class {
|
|
97
100
|
claims = /* @__PURE__ */ new Map();
|
|
98
101
|
/**
|
|
99
|
-
* Take `key` for `type`: another class with the same key would
|
|
102
|
+
* Take `key` for `type`: another class with the same key would be a second duty or worker of that name.
|
|
100
103
|
*
|
|
101
104
|
* @returns The name of the other class that holds `key`, in which case nothing was taken
|
|
102
105
|
*/
|
|
@@ -119,6 +122,7 @@ export {
|
|
|
119
122
|
isLongLivedProcess,
|
|
120
123
|
leaseKey,
|
|
121
124
|
leaseStorageConfig,
|
|
125
|
+
nameKey,
|
|
122
126
|
openLeaseStore,
|
|
123
127
|
registerReadinessProbe,
|
|
124
128
|
startsBackgroundWork
|
|
@@ -14,6 +14,7 @@ import { internalZ as z } from "@frontmcp/lazy-zod";
|
|
|
14
14
|
import { randomUUID } from "@frontmcp/utils";
|
|
15
15
|
import { Flow, FlowBase, FlowHooksOf } from "../../common/index.mjs";
|
|
16
16
|
import { ElicitationStoreNotInitializedError, InvalidInputError } from "../../errors/index.mjs";
|
|
17
|
+
import { sessionIdHash } from "../../logger/session-id-hash.mjs";
|
|
17
18
|
import { DEFAULT_ELICIT_TTL } from "../elicitation.types.mjs";
|
|
18
19
|
var inputSchema = z.object({
|
|
19
20
|
/** Related request ID from the transport */
|
|
@@ -84,7 +85,7 @@ var ElicitationRequestFlow = class extends FlowBase {
|
|
|
84
85
|
elicitationId,
|
|
85
86
|
url
|
|
86
87
|
});
|
|
87
|
-
this.logger.verbose("parseInput:done", {
|
|
88
|
+
this.logger.verbose("parseInput:done", { sessionIdHash: sessionIdHash(input.sessionId), mode });
|
|
88
89
|
}
|
|
89
90
|
async validateRequest() {
|
|
90
91
|
this.logger.verbose("validateRequest:start");
|
|
@@ -120,7 +121,7 @@ var ElicitationRequestFlow = class extends FlowBase {
|
|
|
120
121
|
};
|
|
121
122
|
await store.setPending(pendingRecord);
|
|
122
123
|
this.state.set("pendingRecord", pendingRecord);
|
|
123
|
-
this.logger.verbose("storePendingRecord:done", { elicitId, sessionId });
|
|
124
|
+
this.logger.verbose("storePendingRecord:done", { elicitId, sessionIdHash: sessionIdHash(sessionId) });
|
|
124
125
|
}
|
|
125
126
|
async buildRequestParams() {
|
|
126
127
|
this.logger.verbose("buildRequestParams:start");
|
|
@@ -13,6 +13,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
13
13
|
import { internalZ as z } from "@frontmcp/lazy-zod";
|
|
14
14
|
import { Flow, FlowBase, FlowHooksOf } from "../../common/index.mjs";
|
|
15
15
|
import { ElicitationStoreNotInitializedError, InvalidInputError } from "../../errors/index.mjs";
|
|
16
|
+
import { sessionIdHash } from "../../logger/session-id-hash.mjs";
|
|
16
17
|
import { validateElicitationContent } from "../helpers/index.mjs";
|
|
17
18
|
var inputSchema = z.object({
|
|
18
19
|
/** Session ID for the elicitation */
|
|
@@ -58,7 +59,7 @@ var ElicitationResultFlow = class extends FlowBase {
|
|
|
58
59
|
content: input.result.content
|
|
59
60
|
});
|
|
60
61
|
this.logger.verbose("parseInput:done", {
|
|
61
|
-
|
|
62
|
+
sessionIdHash: sessionIdHash(input.sessionId),
|
|
62
63
|
action: input.result.action
|
|
63
64
|
});
|
|
64
65
|
}
|
|
@@ -72,10 +73,10 @@ var ElicitationResultFlow = class extends FlowBase {
|
|
|
72
73
|
const pendingRecord = await store.getPending(sessionId);
|
|
73
74
|
this.state.set("pendingRecord", pendingRecord ?? void 0);
|
|
74
75
|
if (!pendingRecord) {
|
|
75
|
-
this.logger.verbose("lookupPending:notFound", { sessionId });
|
|
76
|
+
this.logger.verbose("lookupPending:notFound", { sessionIdHash: sessionIdHash(sessionId) });
|
|
76
77
|
} else {
|
|
77
78
|
this.logger.verbose("lookupPending:found", {
|
|
78
|
-
sessionId,
|
|
79
|
+
sessionIdHash: sessionIdHash(sessionId),
|
|
79
80
|
elicitId: pendingRecord.elicitId
|
|
80
81
|
});
|
|
81
82
|
}
|
|
@@ -102,7 +103,7 @@ var ElicitationResultFlow = class extends FlowBase {
|
|
|
102
103
|
const validationResult = validateElicitationContent(content, pendingRecord.requestedSchema);
|
|
103
104
|
if (!validationResult.success) {
|
|
104
105
|
this.logger.warn("validateContent:failed", {
|
|
105
|
-
|
|
106
|
+
sessionIdHash: sessionIdHash(pendingRecord.sessionId),
|
|
106
107
|
elicitId: pendingRecord.elicitId,
|
|
107
108
|
errors: validationResult.errors
|
|
108
109
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// libs/sdk/src/elicitation/questions/question-scope.helper.ts
|
|
2
2
|
import { internalZ as z } from "@frontmcp/lazy-zod";
|
|
3
3
|
import { sha256Hex } from "@frontmcp/utils";
|
|
4
|
+
import { hasSqliteDriver, SQLITE_ON_EDGE_REMEDY } from "../../storage/sqlite-on-edge.mjs";
|
|
4
5
|
import { createQuestionStore, resolveQuestionStorage } from "./question-store.factory.mjs";
|
|
5
6
|
import { InvalidQuestionStoreError } from "./question.errors.mjs";
|
|
6
7
|
var DEFAULT_QUESTION_TTL_MS = 864e5;
|
|
@@ -25,10 +26,11 @@ function parsePersistentQuestionsOptions(persistent) {
|
|
|
25
26
|
}
|
|
26
27
|
return { ...parsed.data, storage: parsed.data.storage };
|
|
27
28
|
}
|
|
28
|
-
var NOT_ON_EDGE_RUNTIME =
|
|
29
|
+
var NOT_ON_EDGE_RUNTIME = `it is not available on an edge runtime: a question must outlive the isolate that asked it, and none of its stores runs there ('redis' needs a TCP connection, 'sqlite' a local file, and 'memory' ends with the isolate). Run the server on Node.js to keep questions, turn elicitation.persistent off, or name a 'sqlite' store in elicitation.persistent.storage and give it a SQLite driver: ${SQLITE_ON_EDGE_REMEDY}`;
|
|
29
30
|
function persistentQuestionsSettings(persistent, onEdgeRuntime) {
|
|
30
31
|
const settings = parsePersistentQuestionsOptions(persistent);
|
|
31
|
-
|
|
32
|
+
const opensOnEdge = settings.storage?.type === "sqlite" && hasSqliteDriver();
|
|
33
|
+
if (onEdgeRuntime && !opensOnEdge) throw new InvalidQuestionStoreError(NOT_ON_EDGE_RUNTIME);
|
|
32
34
|
return settings;
|
|
33
35
|
}
|
|
34
36
|
function questionsServerStore(storage, server) {
|
|
@@ -13,6 +13,8 @@ import { createMemoryStorage, createStorage, getEnv } from "@frontmcp/utils";
|
|
|
13
13
|
import { isVercelKvProvider } from "../../common/index.mjs";
|
|
14
14
|
import { normalizeRedisOptions } from "../../common/types/options/redis/schema.mjs";
|
|
15
15
|
import { ElicitationNotSupportedError } from "../../errors/elicitation.error.mjs";
|
|
16
|
+
import { requireOptionalModule } from "../../scope/optional-dependency.util.mjs";
|
|
17
|
+
import { hasSqliteDriver, SQLITE_ON_EDGE_REMEDY } from "../../storage/sqlite-on-edge.mjs";
|
|
16
18
|
import { isElicitationEncryptionAvailable } from "./elicitation-encryption.mjs";
|
|
17
19
|
import { EncryptedElicitationStore } from "./encrypted-elicitation.store.mjs";
|
|
18
20
|
import { StorageElicitationStore } from "./storage-elicitation.store.mjs";
|
|
@@ -44,9 +46,9 @@ async function createElicitationStore(options = {}) {
|
|
|
44
46
|
encryption
|
|
45
47
|
} = options;
|
|
46
48
|
if (sqlite) {
|
|
47
|
-
if (isEdgeRuntime) {
|
|
49
|
+
if (isEdgeRuntime && !hasSqliteDriver()) {
|
|
48
50
|
throw new ElicitationNotSupportedError(
|
|
49
|
-
|
|
51
|
+
`SQLite elicitation store is not supported on Edge runtime without a SQLite driver (better-sqlite3 is a native module). ${SQLITE_ON_EDGE_REMEDY} Otherwise use Redis or Upstash instead.`
|
|
50
52
|
);
|
|
51
53
|
}
|
|
52
54
|
let sqliteStore = createSqliteElicitationStore(sqlite, { keyPrefix, logger });
|
|
@@ -56,9 +58,7 @@ async function createElicitationStore(options = {}) {
|
|
|
56
58
|
const hasSecret2 = encryptionSecret2 || isElicitationEncryptionAvailable();
|
|
57
59
|
if (encryptionEnabled2 === true) {
|
|
58
60
|
if (!hasSecret2) {
|
|
59
|
-
throw
|
|
60
|
-
"Elicitation encryption is enabled but no secret is available. Set MCP_ELICITATION_SECRET, MCP_SESSION_SECRET, or MCP_SERVER_SECRET environment variable, or provide a secret in the encryption configuration."
|
|
61
|
-
);
|
|
61
|
+
throw missingEncryptionSecretError();
|
|
62
62
|
}
|
|
63
63
|
sqliteStore = new EncryptedElicitationStore(sqliteStore, { secret: encryptionSecret2, logger });
|
|
64
64
|
encrypted2 = true;
|
|
@@ -118,9 +118,7 @@ async function createElicitationStore(options = {}) {
|
|
|
118
118
|
let encrypted = false;
|
|
119
119
|
if (encryptionEnabled === true) {
|
|
120
120
|
if (!hasSecret) {
|
|
121
|
-
throw
|
|
122
|
-
"Elicitation encryption is enabled but no secret is available. Set MCP_ELICITATION_SECRET, MCP_SESSION_SECRET, or MCP_SERVER_SECRET environment variable, or provide a secret in the encryption configuration."
|
|
123
|
-
);
|
|
121
|
+
throw missingEncryptionSecretError();
|
|
124
122
|
}
|
|
125
123
|
store = new EncryptedElicitationStore(store, { secret: encryptionSecret, logger });
|
|
126
124
|
encrypted = true;
|
|
@@ -144,6 +142,7 @@ function createMemoryElicitationStore(options = {}) {
|
|
|
144
142
|
const encryptionSecret = encryption?.secret;
|
|
145
143
|
const hasSecret = encryptionSecret || isElicitationEncryptionAvailable();
|
|
146
144
|
let encrypted = false;
|
|
145
|
+
if (encryptionEnabled === true && !hasSecret) throw missingEncryptionSecretError();
|
|
147
146
|
if (encryptionEnabled === true && hasSecret) {
|
|
148
147
|
store = new EncryptedElicitationStore(store, { secret: encryptionSecret, logger });
|
|
149
148
|
encrypted = true;
|
|
@@ -154,6 +153,11 @@ function createMemoryElicitationStore(options = {}) {
|
|
|
154
153
|
logger?.debug("[ElicitationStoreFactory] Created explicit in-memory elicitation store", { encrypted });
|
|
155
154
|
return { store, type: "memory", storage, encrypted };
|
|
156
155
|
}
|
|
156
|
+
function missingEncryptionSecretError() {
|
|
157
|
+
return new ElicitationNotSupportedError(
|
|
158
|
+
"Elicitation encryption is enabled but no secret is available. Set MCP_ELICITATION_SECRET, MCP_SESSION_SECRET, or MCP_SERVER_SECRET environment variable, or provide a secret in the encryption configuration."
|
|
159
|
+
);
|
|
160
|
+
}
|
|
157
161
|
function createElicitationStoreFromStorage(storage, options = {}) {
|
|
158
162
|
const { keyPrefix = "mcp:elicit:", logger, requiresPubSub = true, encryption } = options;
|
|
159
163
|
if (requiresPubSub && !storage.supportsPubSub()) {
|
|
@@ -168,6 +172,7 @@ function createElicitationStoreFromStorage(storage, options = {}) {
|
|
|
168
172
|
const encryptionSecret = encryption?.secret;
|
|
169
173
|
const hasSecret = encryptionSecret || isElicitationEncryptionAvailable();
|
|
170
174
|
let encrypted = false;
|
|
175
|
+
if (encryptionEnabled === true && !hasSecret) throw missingEncryptionSecretError();
|
|
171
176
|
if (encryptionEnabled === true && hasSecret) {
|
|
172
177
|
store = new EncryptedElicitationStore(store, { secret: encryptionSecret, logger });
|
|
173
178
|
encrypted = true;
|
|
@@ -184,7 +189,10 @@ function createElicitationStoreFromStorage(storage, options = {}) {
|
|
|
184
189
|
}
|
|
185
190
|
function createSqliteElicitationStore(sqliteConfig, storeOptions = {}) {
|
|
186
191
|
const { keyPrefix = "mcp:elicit:", logger } = storeOptions;
|
|
187
|
-
const { SqliteElicitationStore } =
|
|
192
|
+
const { SqliteElicitationStore } = requireOptionalModule(
|
|
193
|
+
"@frontmcp/storage-sqlite",
|
|
194
|
+
() => __require("@frontmcp/storage-sqlite")
|
|
195
|
+
);
|
|
188
196
|
logger?.info("[ElicitationStoreFactory] Creating SQLite elicitation store", {
|
|
189
197
|
path: sqliteConfig.path,
|
|
190
198
|
keyPrefix
|
|
@@ -92,7 +92,7 @@ var EncryptedElicitationStore = class {
|
|
|
92
92
|
}
|
|
93
93
|
callback(rawResult);
|
|
94
94
|
};
|
|
95
|
-
return this.store.subscribeResult(elicitId, decryptingCallback);
|
|
95
|
+
return this.store.subscribeResult(elicitId, decryptingCallback, sessionId);
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* Publish an elicitation result with encryption.
|
|
@@ -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 {
|