@frontmcp/sdk 1.12.0 → 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
|
@@ -15,10 +15,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
15
15
|
import { AuthorityDeniedError, resolveRequiredScopes } from "@frontmcp/auth";
|
|
16
16
|
import { internalZ as z } from "@frontmcp/lazy-zod";
|
|
17
17
|
import { ReadResourceRequestSchema, ReadResourceResultSchema } from "@frontmcp/protocol";
|
|
18
|
-
import { randomBytes } from "@frontmcp/utils";
|
|
18
|
+
import { escapeControlCharacters, randomBytes } from "@frontmcp/utils";
|
|
19
19
|
import { fitResourceAnswer } from "../../answer/index.mjs";
|
|
20
20
|
import { assertAppLoaded, loadAppOfPlaceholder } from "../../app/lazy/lazy-placeholders.mjs";
|
|
21
21
|
import { loadRemoteAppCapabilities } from "../../app/remote-capabilities.utils.mjs";
|
|
22
|
+
import { AUTHORITIES_NOT_CONFIGURED } from "../../builtin/authorities/authorities-not-configured.mjs";
|
|
22
23
|
import {
|
|
23
24
|
Flow,
|
|
24
25
|
FlowBase,
|
|
@@ -168,7 +169,9 @@ var ReadResourceFlow = class extends FlowBase {
|
|
|
168
169
|
try {
|
|
169
170
|
await app.ensureCapabilitiesLoaded();
|
|
170
171
|
} catch (error) {
|
|
171
|
-
this.logger.warn(
|
|
172
|
+
this.logger.warn(
|
|
173
|
+
`Failed to load capabilities for remote app ${app.id}: ${escapeControlCharacters(error.message)}`
|
|
174
|
+
);
|
|
172
175
|
}
|
|
173
176
|
}
|
|
174
177
|
});
|
|
@@ -178,9 +181,10 @@ var ReadResourceFlow = class extends FlowBase {
|
|
|
178
181
|
async findResource() {
|
|
179
182
|
this.logger.verbose("findResource:start");
|
|
180
183
|
const { uri } = this.state.required.input;
|
|
181
|
-
|
|
184
|
+
const loggedUri = escapeControlCharacters(uri);
|
|
185
|
+
this.logger.verbose(`findResource: looking for resource with URI "${loggedUri}"`);
|
|
182
186
|
if (isUIResourceUri(uri)) {
|
|
183
|
-
this.logger.verbose(`findResource: detected UI resource URI "${
|
|
187
|
+
this.logger.verbose(`findResource: detected UI resource URI "${loggedUri}"`);
|
|
184
188
|
const { sessionId, authInfo } = this.state;
|
|
185
189
|
const platformType = authInfo?.sessionIdPayload?.platformType ?? this.tryGetContext()?.platformType ?? (sessionId ? this.scope.notifications.getPlatformType(sessionId) : void 0);
|
|
186
190
|
this.logger.verbose(`findResource: platform type for session: ${platformType ?? "unknown"}`);
|
|
@@ -193,30 +197,30 @@ var ReadResourceFlow = class extends FlowBase {
|
|
|
193
197
|
const uiResult = handleUIResourceRead(uri, this.scope.toolUI, platformType, serverUrl);
|
|
194
198
|
if (uiResult.handled) {
|
|
195
199
|
if (uiResult.error) {
|
|
196
|
-
this.logger.warn(`findResource: UI resource error - ${uiResult.error}`);
|
|
200
|
+
this.logger.warn(`findResource: UI resource error - ${escapeControlCharacters(uiResult.error)}`);
|
|
197
201
|
throw new ResourceNotFoundError(uri);
|
|
198
202
|
}
|
|
199
203
|
this.state.set("isUIResource", true);
|
|
200
204
|
this.state.set("uiResourceResult", uiResult.result);
|
|
201
|
-
this.logger.verbose(`findResource: UI resource "${
|
|
205
|
+
this.logger.verbose(`findResource: UI resource "${loggedUri}" resolved from cache`);
|
|
202
206
|
this.logger.verbose("findResource:done");
|
|
203
207
|
return;
|
|
204
208
|
}
|
|
205
209
|
}
|
|
206
210
|
const match = resolvedResources.take(this.rawInput, uri) ?? this.scope.resources.findResourceForUri(uri);
|
|
207
211
|
if (!match) {
|
|
208
|
-
this.logger.warn(`findResource: resource for URI "${
|
|
212
|
+
this.logger.warn(`findResource: resource for URI "${loggedUri}" not found`);
|
|
209
213
|
throw new ResourceNotFoundError(uri);
|
|
210
214
|
}
|
|
211
215
|
const { availableWhen } = match.instance.metadata;
|
|
212
216
|
const callSurface = callSurfaceOf(this.input.ctx);
|
|
213
217
|
const availability = availabilityForCall(availableWhen, callSurface);
|
|
214
218
|
if (availability === "not-offered") {
|
|
215
|
-
this.logger.warn(`findResource: resource for URI "${
|
|
219
|
+
this.logger.warn(`findResource: resource for URI "${loggedUri}" is not offered on surface "${callSurface}"`);
|
|
216
220
|
throw new ResourceNotFoundError(uri);
|
|
217
221
|
}
|
|
218
222
|
if (availability === "unavailable") {
|
|
219
|
-
this.logger.warn(`findResource: resource for URI "${
|
|
223
|
+
this.logger.warn(`findResource: resource for URI "${loggedUri}" is unavailable in this environment`);
|
|
220
224
|
throw entryUnavailableError(
|
|
221
225
|
match.instance.isTemplate ? "ResourceTemplate" : "Resource",
|
|
222
226
|
uri,
|
|
@@ -227,7 +231,7 @@ var ReadResourceFlow = class extends FlowBase {
|
|
|
227
231
|
if (match.instance.owner) {
|
|
228
232
|
this.state.set("resourceOwnerId", match.instance.owner.id);
|
|
229
233
|
}
|
|
230
|
-
this.logger = this.logger.child(`ReadResourceFlow(${
|
|
234
|
+
this.logger = this.logger.child(`ReadResourceFlow(${loggedUri})`);
|
|
231
235
|
this.state.set("resource", match.instance);
|
|
232
236
|
this.state.set("params", match.params);
|
|
233
237
|
this.logger.verbose(
|
|
@@ -248,9 +252,6 @@ var ReadResourceFlow = class extends FlowBase {
|
|
|
248
252
|
}
|
|
249
253
|
async checkEntryAuthorities() {
|
|
250
254
|
this.logger.verbose("checkEntryAuthorities:start");
|
|
251
|
-
const engine = this.scope.authoritiesEngine;
|
|
252
|
-
const ctxBuilder = this.scope.authoritiesContextBuilder;
|
|
253
|
-
if (!engine || !ctxBuilder) return;
|
|
254
255
|
const resource = this.state.resource;
|
|
255
256
|
if (!resource) return;
|
|
256
257
|
const metadata = resource.metadata;
|
|
@@ -259,6 +260,15 @@ var ReadResourceFlow = class extends FlowBase {
|
|
|
259
260
|
this.logger.verbose("checkEntryAuthorities:skip (no authorities)");
|
|
260
261
|
return;
|
|
261
262
|
}
|
|
263
|
+
const engine = this.scope.authoritiesEngine;
|
|
264
|
+
const ctxBuilder = this.scope.authoritiesContextBuilder;
|
|
265
|
+
if (!engine || !ctxBuilder) {
|
|
266
|
+
throw new AuthorityDeniedError({
|
|
267
|
+
entryType: "Resource",
|
|
268
|
+
entryName: resource.fullName || resource.name,
|
|
269
|
+
deniedBy: AUTHORITIES_NOT_CONFIGURED
|
|
270
|
+
});
|
|
271
|
+
}
|
|
262
272
|
const authInfo = this.state.authInfo ?? {};
|
|
263
273
|
const evalCtx = ctxBuilder.build(authInfo);
|
|
264
274
|
const result = await engine.evaluate(authorities, evalCtx);
|
|
@@ -145,7 +145,6 @@ var ResourceTemplatesListFlow = class extends FlowBase {
|
|
|
145
145
|
this.logger.verbose("filterByAuthorities:start");
|
|
146
146
|
const engine = this.scope.authoritiesEngine;
|
|
147
147
|
const ctxBuilder = this.scope.authoritiesContextBuilder;
|
|
148
|
-
if (!engine || !ctxBuilder) return;
|
|
149
148
|
const templates = this.state.required.templates;
|
|
150
149
|
const ctx = this.rawInput["ctx"];
|
|
151
150
|
const authInfo = ctx?.["authInfo"] ?? {};
|
|
@@ -154,6 +153,7 @@ var ResourceTemplatesListFlow = class extends FlowBase {
|
|
|
154
153
|
const metadata = item.template.metadata;
|
|
155
154
|
const authorities = metadata["authorities"];
|
|
156
155
|
if (!authorities) return item;
|
|
156
|
+
if (!engine || !ctxBuilder) return null;
|
|
157
157
|
const listed = await isListedByAuthorities(
|
|
158
158
|
engine,
|
|
159
159
|
ctxBuilder,
|
|
@@ -151,7 +151,6 @@ var ResourcesListFlow = class extends FlowBase {
|
|
|
151
151
|
this.logger.verbose("filterByAuthorities:start");
|
|
152
152
|
const engine = this.scope.authoritiesEngine;
|
|
153
153
|
const ctxBuilder = this.scope.authoritiesContextBuilder;
|
|
154
|
-
if (!engine || !ctxBuilder) return;
|
|
155
154
|
const resources = this.state.required.resources;
|
|
156
155
|
const ctx = this.rawInput["ctx"];
|
|
157
156
|
const authInfo = ctx?.["authInfo"] ?? {};
|
|
@@ -160,6 +159,7 @@ var ResourcesListFlow = class extends FlowBase {
|
|
|
160
159
|
const metadata = item.resource.metadata;
|
|
161
160
|
const authorities = metadata["authorities"];
|
|
162
161
|
if (!authorities) return item;
|
|
162
|
+
if (!engine || !ctxBuilder) return null;
|
|
163
163
|
const listed = await isListedByAuthorities(
|
|
164
164
|
engine,
|
|
165
165
|
ctxBuilder,
|
|
@@ -14,6 +14,7 @@ import { AuthorityDeniedError, resolveRequiredScopes } from "@frontmcp/auth";
|
|
|
14
14
|
import { internalZ as z } from "@frontmcp/lazy-zod";
|
|
15
15
|
import { EmptyResultSchema, SubscribeRequestSchema } from "@frontmcp/protocol";
|
|
16
16
|
import { loadRemoteAppCapabilities } from "../../app/remote-capabilities.utils.mjs";
|
|
17
|
+
import { AUTHORITIES_NOT_CONFIGURED } from "../../builtin/authorities/authorities-not-configured.mjs";
|
|
17
18
|
import { Flow, FlowBase, FlowHooksOf } from "../../common/index.mjs";
|
|
18
19
|
import { availabilityForCall, callSurfaceOf, entryUnavailableError } from "../../common/availability/index.mjs";
|
|
19
20
|
import { InvalidInputError, InvalidMethodError, ResourceNotFoundError } from "../../errors/index.mjs";
|
|
@@ -88,9 +89,16 @@ var SubscribeResourceFlow = class extends FlowBase {
|
|
|
88
89
|
const engine = this.scope.authoritiesEngine;
|
|
89
90
|
const ctxBuilder = this.scope.authoritiesContextBuilder;
|
|
90
91
|
const { resource } = this.state;
|
|
91
|
-
if (!
|
|
92
|
+
if (!resource) return;
|
|
92
93
|
const authorities = resource.metadata["authorities"];
|
|
93
94
|
if (!authorities) return;
|
|
95
|
+
if (!engine || !ctxBuilder) {
|
|
96
|
+
throw new AuthorityDeniedError({
|
|
97
|
+
entryType: "Resource",
|
|
98
|
+
entryName: resource.fullName || resource.name,
|
|
99
|
+
deniedBy: AUTHORITIES_NOT_CONFIGURED
|
|
100
|
+
});
|
|
101
|
+
}
|
|
94
102
|
const authInfo = this.input.ctx?.authInfo ?? {};
|
|
95
103
|
const result = await engine.evaluate(authorities, ctxBuilder.build(authInfo));
|
|
96
104
|
if (result.granted) return;
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ResourceKind,
|
|
7
7
|
ResourceTemplateKind
|
|
8
8
|
} from "../common/index.mjs";
|
|
9
|
+
import { FrontMcpContextStorage } from "../context/frontmcp-context-storage.mjs";
|
|
9
10
|
import { InvalidRegistryKindError } from "../errors/index.mjs";
|
|
10
11
|
import { InvalidHookFlowError } from "../errors/mcp.error.mjs";
|
|
11
12
|
import { describeUnreachableEntryClassHooks, unreachableHooksMessage } from "../hooks/entry-class-hooks.mjs";
|
|
@@ -109,7 +110,8 @@ var ResourceInstance = class extends ResourceEntry {
|
|
|
109
110
|
params: {},
|
|
110
111
|
providers,
|
|
111
112
|
logger,
|
|
112
|
-
|
|
113
|
+
// The caller of the completion request, from the request context the flow runs in
|
|
114
|
+
authInfo: requestAuthInfoOf(scope)
|
|
113
115
|
};
|
|
114
116
|
const instance = new cls(resourceCtorArgs);
|
|
115
117
|
if (hasConventionMethod) {
|
|
@@ -216,6 +218,13 @@ var FunctionResourceContext = class extends ResourceContext {
|
|
|
216
218
|
return this.record.provide(uri, params, this);
|
|
217
219
|
}
|
|
218
220
|
};
|
|
221
|
+
function requestAuthInfoOf(scope) {
|
|
222
|
+
try {
|
|
223
|
+
return scope.providers.get(FrontMcpContextStorage).getStore()?.authInfo ?? {};
|
|
224
|
+
} catch {
|
|
225
|
+
return {};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
219
228
|
export {
|
|
220
229
|
ResourceInstance
|
|
221
230
|
};
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
httpOutputSchema,
|
|
38
38
|
httpRespond,
|
|
39
39
|
intentSchema,
|
|
40
|
+
isStaticMode,
|
|
40
41
|
normalizeEntryPrefix,
|
|
41
42
|
normalizeScopeBase,
|
|
42
43
|
partitionsByIdentity,
|
|
@@ -145,7 +146,18 @@ var HttpRequestFlow = class extends FlowBase {
|
|
|
145
146
|
hasBody: !!request.body,
|
|
146
147
|
bodyMethod: body?.["method"]
|
|
147
148
|
});
|
|
148
|
-
this.logger.debug(`[${this.requestId}] HEADERS`, { headers:
|
|
149
|
+
this.logger.debug(`[${this.requestId}] HEADERS`, { headers: this.loggableHeaders(headers) });
|
|
150
|
+
}
|
|
151
|
+
/** The request headers as the debug log shows them; the static-auth credential header is redacted whatever its name. */
|
|
152
|
+
loggableHeaders(headers) {
|
|
153
|
+
const authOptions = this.scope.auth?.options;
|
|
154
|
+
const credentialHeader = authOptions && isStaticMode(authOptions) ? authOptions.header.toLowerCase() : void 0;
|
|
155
|
+
return Object.fromEntries(
|
|
156
|
+
Object.entries(headersForLog(headers)).map(([headerName, value]) => [
|
|
157
|
+
headerName,
|
|
158
|
+
headerName.toLowerCase() === credentialHeader ? "[REDACTED]" : value
|
|
159
|
+
])
|
|
160
|
+
);
|
|
149
161
|
}
|
|
150
162
|
async checkIpFilter() {
|
|
151
163
|
enforceIpFilter(
|
|
@@ -672,7 +684,7 @@ var HttpRequestFlow = class extends FlowBase {
|
|
|
672
684
|
this.respond(httpRespond.rpcError("No valid session ID provided"));
|
|
673
685
|
return;
|
|
674
686
|
}
|
|
675
|
-
this.logger.info(`[${this.requestId}] DELETE session: ${sessionId}
|
|
687
|
+
this.logger.info(`[${this.requestId}] DELETE session: ${sessionId.slice(0, 20)}...`);
|
|
676
688
|
this.scope.notifications.terminateSession(sessionId);
|
|
677
689
|
const authorization = request[ServerRequestTokens.auth];
|
|
678
690
|
const transportService = this.scope.transportService;
|
|
@@ -685,7 +697,7 @@ var HttpRequestFlow = class extends FlowBase {
|
|
|
685
697
|
}
|
|
686
698
|
await transportService.deleteStoredSession(sessionId);
|
|
687
699
|
}
|
|
688
|
-
this.logger.info(`[${this.requestId}] Session terminated: ${sessionId}
|
|
700
|
+
this.logger.info(`[${this.requestId}] Session terminated: ${sessionId.slice(0, 20)}...`);
|
|
689
701
|
this.respond(httpRespond.noContent());
|
|
690
702
|
} catch (error) {
|
|
691
703
|
if (!(error instanceof FlowControl)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// libs/sdk/src/scope/optional-dependency.util.ts
|
|
2
|
+
import { registerOptionalModule, requireOptionalModule } from "@frontmcp/utils";
|
|
2
3
|
function probeOptionalDependency(moduleName, loadError, resolve) {
|
|
3
4
|
let resolvedPath;
|
|
4
5
|
try {
|
|
@@ -26,19 +27,6 @@ async function importOptionalPeer(moduleName, importer, resolve, feature) {
|
|
|
26
27
|
);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
var BUNDLED_OPTIONAL_MODULES = /* @__PURE__ */ Symbol.for("frontmcp.bundledOptionalModules");
|
|
30
|
-
function bundledOptionalModules() {
|
|
31
|
-
const registryHost = globalThis;
|
|
32
|
-
registryHost[BUNDLED_OPTIONAL_MODULES] ??= /* @__PURE__ */ new Map();
|
|
33
|
-
return registryHost[BUNDLED_OPTIONAL_MODULES];
|
|
34
|
-
}
|
|
35
|
-
function registerOptionalModule(moduleName, moduleExports) {
|
|
36
|
-
bundledOptionalModules().set(moduleName, moduleExports);
|
|
37
|
-
}
|
|
38
|
-
function requireOptionalModule(moduleName, load) {
|
|
39
|
-
const registry = bundledOptionalModules();
|
|
40
|
-
return registry.has(moduleName) ? registry.get(moduleName) : load();
|
|
41
|
-
}
|
|
42
30
|
export {
|
|
43
31
|
importOptionalPeer,
|
|
44
32
|
probeOptionalDependency,
|
|
@@ -80,6 +80,33 @@ function keptUntilFailure(start, forget) {
|
|
|
80
80
|
throw error;
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
+
function entriesWithAuthorities(registries, agentPath = "") {
|
|
84
|
+
const entries = [];
|
|
85
|
+
const add = (kind, name, metadata) => {
|
|
86
|
+
const authorities = metadata?.["authorities"];
|
|
87
|
+
if (authorities !== void 0 && authorities !== null && authorities !== false) {
|
|
88
|
+
entries.push({ label: `${kind} "${agentPath}${name}"`, authorities });
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
for (const tool of registries.tools.getTools(true)) add("Tool", tool.name, tool.metadata);
|
|
92
|
+
for (const resource of registries.resources.getResources(true)) add("Resource", resource.name, resource.metadata);
|
|
93
|
+
for (const template of registries.resources.getResourceTemplates()) {
|
|
94
|
+
add("Resource template", template.name, template.metadata);
|
|
95
|
+
}
|
|
96
|
+
for (const prompt of registries.prompts.getPrompts(true)) add("Prompt", prompt.name, prompt.metadata);
|
|
97
|
+
for (const agent of registries.agents.getAgents(true)) {
|
|
98
|
+
add("Agent", agent.name, agent.metadata);
|
|
99
|
+
const agentScope = agent.getAgentScope?.();
|
|
100
|
+
if (!agentScope) {
|
|
101
|
+
for (const metadata of agentToolMetadata(agent)) add("Tool", `${agent.name}:${metadata.name}`, metadata);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const { tools, resources, prompts, agents } = agentScope;
|
|
105
|
+
entries.push(...entriesWithAuthorities({ tools, resources, prompts, agents }, `${agentPath}${agent.name}:`));
|
|
106
|
+
}
|
|
107
|
+
for (const skill of registries.skills?.getSkills(true) ?? []) add("Skill", skill.name, skill.metadata);
|
|
108
|
+
return entries;
|
|
109
|
+
}
|
|
83
110
|
var Scope = class _Scope extends ScopeEntry {
|
|
84
111
|
id;
|
|
85
112
|
globalProviders;
|
|
@@ -762,6 +789,8 @@ var Scope = class _Scope extends ScopeEntry {
|
|
|
762
789
|
this._channelEventBus = channelResult.channelEventBus;
|
|
763
790
|
this._channelTeardown = channelResult.teardown;
|
|
764
791
|
this.onDispose(() => this.teardownChannels());
|
|
792
|
+
this.validateAuthoritiesConfig();
|
|
793
|
+
this.validateEnforcedMetadata();
|
|
765
794
|
if (!isJobWorker(this.metadata)) await channelResult.connectServices();
|
|
766
795
|
}
|
|
767
796
|
const { items: appEvents, providers: eventProviders } = this.appEntryProviders("events", normalizeEvent);
|
|
@@ -1599,39 +1628,18 @@ var Scope = class _Scope extends ScopeEntry {
|
|
|
1599
1628
|
}
|
|
1600
1629
|
/**
|
|
1601
1630
|
* Every entry that declares `authorities`, labelled for startup errors: tools, resources and
|
|
1602
|
-
* resource templates, prompts, agents and the
|
|
1631
|
+
* resource templates, prompts, agents and the entries of each agent's private scope, and skills,
|
|
1632
|
+
* hidden ones included.
|
|
1603
1633
|
* @internal
|
|
1604
1634
|
*/
|
|
1605
1635
|
collectEntriesWithAuthorities() {
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
};
|
|
1613
|
-
for (const tool of this.scopeTools.getTools(true)) {
|
|
1614
|
-
add(`Tool "${tool.name}"`, tool.metadata);
|
|
1615
|
-
}
|
|
1616
|
-
for (const resource of this.scopeResources.getResources(true)) {
|
|
1617
|
-
add(`Resource "${resource.name}"`, resource.metadata);
|
|
1618
|
-
}
|
|
1619
|
-
for (const template of this.scopeResources.getResourceTemplates()) {
|
|
1620
|
-
add(`Resource template "${template.name}"`, template.metadata);
|
|
1621
|
-
}
|
|
1622
|
-
for (const prompt of this.scopePrompts.getPrompts(true)) {
|
|
1623
|
-
add(`Prompt "${prompt.name}"`, prompt.metadata);
|
|
1624
|
-
}
|
|
1625
|
-
for (const agent of this.scopeAgents.getAgents(true)) {
|
|
1626
|
-
add(`Agent "${agent.name}"`, agent.metadata);
|
|
1627
|
-
for (const metadata of agentToolMetadata(agent)) {
|
|
1628
|
-
add(`Tool "${agent.name}:${metadata.name}"`, metadata);
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
for (const skill of this.scopeSkills.getSkills(true)) {
|
|
1632
|
-
add(`Skill "${skill.name}"`, skill.metadata);
|
|
1633
|
-
}
|
|
1634
|
-
return entries;
|
|
1636
|
+
return entriesWithAuthorities({
|
|
1637
|
+
tools: this.scopeTools,
|
|
1638
|
+
resources: this.scopeResources,
|
|
1639
|
+
prompts: this.scopePrompts,
|
|
1640
|
+
agents: this.scopeAgents,
|
|
1641
|
+
skills: this.scopeSkills
|
|
1642
|
+
});
|
|
1635
1643
|
}
|
|
1636
1644
|
/**
|
|
1637
1645
|
* Fail-fast at startup, so an entry never looks protected while anyone can use it:
|
|
@@ -1649,6 +1657,7 @@ var Scope = class _Scope extends ScopeEntry {
|
|
|
1649
1657
|
}
|
|
1650
1658
|
async checkLateApp(app) {
|
|
1651
1659
|
const { tools, resources, prompts, agents, skills } = app;
|
|
1660
|
+
assertEntryAuthorities(this._authoritiesEngine, this._authoritiesContextBuilder, entriesWithAuthorities(app));
|
|
1652
1661
|
const problems = findUnenforcedMetadata({ hooks: this.scopeHooks, tools, resources, prompts, agents, skills });
|
|
1653
1662
|
if (problems.length > 0) throw new UnenforcedMetadataError(problems);
|
|
1654
1663
|
checkHookOrder(hookRunsOf(this.scopeHooks), (message) => this.logger.warn(message));
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
// libs/sdk/src/server/security/replaceable-directory.ts
|
|
2
|
-
import { dirname, stat } from "@frontmcp/utils";
|
|
2
|
+
import { dirname, lstat, stat } from "@frontmcp/utils";
|
|
3
3
|
var GROUP_OR_OTHER_WRITE = 18;
|
|
4
4
|
var STICKY_BIT = 512;
|
|
5
5
|
var ROOT_UID = 0;
|
|
6
6
|
async function findReplaceableDirectory(start) {
|
|
7
7
|
for (let directory = start; ; directory = dirname(directory)) {
|
|
8
|
+
const link = await lstat(directory);
|
|
9
|
+
if (link.isSymbolicLink() && isOtherUser(link.uid)) return { directory, mode: link.mode, ownerUid: link.uid };
|
|
8
10
|
const { mode, uid } = await stat(directory);
|
|
9
|
-
if (uid
|
|
11
|
+
if (isOtherUser(uid)) return { directory, mode, ownerUid: uid };
|
|
10
12
|
if (mode & GROUP_OR_OTHER_WRITE && !(mode & STICKY_BIT)) return { directory, mode };
|
|
11
13
|
if (dirname(directory) === directory) return void 0;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
16
|
+
function isOtherUser(uid) {
|
|
17
|
+
return uid !== ROOT_UID && uid !== process.getuid?.();
|
|
18
|
+
}
|
|
14
19
|
export {
|
|
15
20
|
findReplaceableDirectory
|
|
16
21
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// libs/sdk/src/server/security/resolve-allowed-hosts.ts
|
|
2
|
+
var IPV4_LOOPBACK = /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
2
3
|
var LOOPBACK_NAMES = ["localhost", "127.0.0.1", "[::1]"];
|
|
3
4
|
function canonicalizeAddress(address) {
|
|
4
5
|
const bare = address.trim().toLowerCase().replace(/^\[|\]$/g, "");
|
|
5
|
-
if (!bare.includes(":")) return bare;
|
|
6
6
|
try {
|
|
7
|
-
return new URL(`http://[${bare}]`).hostname.replace(/^\[|\]$/g, "");
|
|
7
|
+
return new URL(bare.includes(":") ? `http://[${bare}]` : `http://${bare}`).hostname.replace(/^\[|\]$/g, "");
|
|
8
8
|
} catch {
|
|
9
9
|
return bare;
|
|
10
10
|
}
|
|
@@ -12,7 +12,7 @@ function canonicalizeAddress(address) {
|
|
|
12
12
|
function isLoopbackAddress(address) {
|
|
13
13
|
if (!address) return false;
|
|
14
14
|
const normalized = canonicalizeAddress(address);
|
|
15
|
-
return normalized === "::1" || normalized === "localhost" ||
|
|
15
|
+
return normalized === "::1" || normalized === "localhost" || IPV4_LOOPBACK.test(normalized) || // IPv4-mapped IPv6 loopback, which `URL` renders as `::ffff:7f00:1`.
|
|
16
16
|
normalized === "::ffff:7f00:1" || normalized.startsWith("::ffff:127.");
|
|
17
17
|
}
|
|
18
18
|
function withAndWithoutPort(host, port) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// libs/sdk/src/server/server.validation.ts
|
|
2
2
|
import { base64Decode } from "@frontmcp/utils";
|
|
3
3
|
import { httpOutputSchema, serializeHttpCookie } from "../common/index.mjs";
|
|
4
|
+
import { serializeContentDisposition } from "../common/utils/content-disposition.utils.mjs";
|
|
4
5
|
import { toLocationHeader } from "../utils/http-location.utils.mjs";
|
|
5
6
|
function applyHeaders(res, headers) {
|
|
6
7
|
if (!headers) return;
|
|
@@ -15,9 +16,6 @@ function applyCookies(res, cookies) {
|
|
|
15
16
|
const cookieStrings = cookies.map(serializeHttpCookie);
|
|
16
17
|
res.setHeader("Set-Cookie", [...existingArr, ...cookieStrings]);
|
|
17
18
|
}
|
|
18
|
-
function contentDisposition(disposition, filename) {
|
|
19
|
-
return `${disposition}${filename ? `; filename="${filename}"` : ""}`;
|
|
20
|
-
}
|
|
21
19
|
function utf8ByteLength(s) {
|
|
22
20
|
const enc = new TextEncoder();
|
|
23
21
|
return enc.encode(s).byteLength;
|
|
@@ -99,7 +97,7 @@ async function writeHttpResponse(res, value) {
|
|
|
99
97
|
case "binary":
|
|
100
98
|
case "image": {
|
|
101
99
|
res.setHeader("Content-Type", out.contentType);
|
|
102
|
-
res.setHeader("Content-Disposition",
|
|
100
|
+
res.setHeader("Content-Disposition", serializeContentDisposition(out.disposition, out.filename));
|
|
103
101
|
const bytes = typeof out.body === "string" ? stringToBytes(out.body, out.encoding) : out.body;
|
|
104
102
|
res.setHeader("Content-Length", bytes.byteLength);
|
|
105
103
|
res.status(out.status).end(bytes);
|
|
@@ -107,7 +105,7 @@ async function writeHttpResponse(res, value) {
|
|
|
107
105
|
}
|
|
108
106
|
case "stream": {
|
|
109
107
|
res.setHeader("Content-Type", out.contentType);
|
|
110
|
-
res.setHeader("Content-Disposition",
|
|
108
|
+
res.setHeader("Content-Disposition", serializeContentDisposition(out.disposition, out.filename));
|
|
111
109
|
res.status(out.status);
|
|
112
110
|
if ("flushHeaders" in res && typeof res.flushHeaders === "function") res.flushHeaders();
|
|
113
111
|
const maybeIter = out.stream[Symbol.asyncIterator];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// libs/sdk/src/skill/cache/skill-http-cache.catalog.ts
|
|
2
|
+
import { sha256Hex } from "@frontmcp/utils";
|
|
3
|
+
function catalogDigest(skills) {
|
|
4
|
+
return sha256Hex(JSON.stringify(skills.map((skill) => skill.fullName || skill.name).sort()));
|
|
5
|
+
}
|
|
6
|
+
function toCachedDocument(body, skills) {
|
|
7
|
+
return `${catalogDigest(skills)}
|
|
8
|
+
${body}`;
|
|
9
|
+
}
|
|
10
|
+
function fromCachedDocument(cached, skills) {
|
|
11
|
+
const prefix = `${catalogDigest(skills)}
|
|
12
|
+
`;
|
|
13
|
+
return cached?.startsWith(prefix) ? cached.slice(prefix.length) : null;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
fromCachedDocument,
|
|
17
|
+
toCachedDocument
|
|
18
|
+
};
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
import { normalizeSkillsConfigOptions } from "../../../common/types/options/skills-http/index.mjs";
|
|
27
27
|
import { authorizeSkillHttpRequest } from "../../auth/index.mjs";
|
|
28
28
|
import { getSkillHttpCache } from "../../cache/index.mjs";
|
|
29
|
+
import { fromCachedDocument, toCachedDocument } from "../../cache/skill-http-cache.catalog.mjs";
|
|
29
30
|
import { filterSkillsByAuthorities } from "../../skill-authorities.helper.mjs";
|
|
30
31
|
import { filterServableSkills, SKILLS_HTTP_SURFACE } from "../../skill-filter.helper.mjs";
|
|
31
32
|
import { formatSkillsForLlmFull } from "../../skill-http.utils.mjs";
|
|
@@ -112,7 +113,7 @@ var LlmFullTxtFlow = class extends FlowBase {
|
|
|
112
113
|
);
|
|
113
114
|
const cache = skills.length === allSkills.length ? await getSkillHttpCache(this.scope) : void 0;
|
|
114
115
|
if (cache) {
|
|
115
|
-
const cached = await cache.getLlmFullTxt();
|
|
116
|
+
const cached = fromCachedDocument(await cache.getLlmFullTxt(), skills);
|
|
116
117
|
if (cached) {
|
|
117
118
|
this.respond({
|
|
118
119
|
kind: "text",
|
|
@@ -134,7 +135,7 @@ var LlmFullTxtFlow = class extends FlowBase {
|
|
|
134
135
|
return;
|
|
135
136
|
}
|
|
136
137
|
if (cache) {
|
|
137
|
-
await cache.setLlmFullTxt(content);
|
|
138
|
+
await cache.setLlmFullTxt(toCachedDocument(content, skills));
|
|
138
139
|
}
|
|
139
140
|
this.respond({
|
|
140
141
|
kind: "text",
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
import { normalizeSkillsConfigOptions } from "../../../common/types/options/skills-http/index.mjs";
|
|
27
27
|
import { authorizeSkillHttpRequest } from "../../auth/index.mjs";
|
|
28
28
|
import { getSkillHttpCache } from "../../cache/index.mjs";
|
|
29
|
+
import { fromCachedDocument, toCachedDocument } from "../../cache/skill-http-cache.catalog.mjs";
|
|
29
30
|
import { filterSkillsByAuthorities } from "../../skill-authorities.helper.mjs";
|
|
30
31
|
import { filterServableSkills, SKILLS_HTTP_SURFACE } from "../../skill-filter.helper.mjs";
|
|
31
32
|
import { formatSkillsForLlmCompact } from "../../skill-http.utils.mjs";
|
|
@@ -111,7 +112,7 @@ var LlmTxtFlow = class extends FlowBase {
|
|
|
111
112
|
);
|
|
112
113
|
const cache = skills.length === httpSkills.length ? await getSkillHttpCache(this.scope) : void 0;
|
|
113
114
|
if (cache) {
|
|
114
|
-
const cached = await cache.getLlmTxt();
|
|
115
|
+
const cached = fromCachedDocument(await cache.getLlmTxt(), skills);
|
|
115
116
|
if (cached) {
|
|
116
117
|
this.respond({
|
|
117
118
|
kind: "text",
|
|
@@ -133,7 +134,7 @@ var LlmTxtFlow = class extends FlowBase {
|
|
|
133
134
|
}
|
|
134
135
|
const content = formatSkillsForLlmCompact(skills);
|
|
135
136
|
if (cache) {
|
|
136
|
-
await cache.setLlmTxt(content);
|
|
137
|
+
await cache.setLlmTxt(toCachedDocument(content, skills));
|
|
137
138
|
}
|
|
138
139
|
this.respond({
|
|
139
140
|
kind: "text",
|
|
@@ -18,7 +18,7 @@ import { SkillBundleNotLoadedError } from "../errors/skill-bundle-not-loaded.err
|
|
|
18
18
|
import { assertSkillAuthorized } from "../skill-authorities.helper.mjs";
|
|
19
19
|
import { readySkillCatalog } from "../skill-catalog-source.mjs";
|
|
20
20
|
import { createSkillEntryResolver } from "../skill-entry.resolver.mjs";
|
|
21
|
-
import { isSkillServable, skillToolsForCaller } from "../skill-filter.helper.mjs";
|
|
21
|
+
import { isSkillServable, skillToolsForCaller, skillToolsListedFor } from "../skill-filter.helper.mjs";
|
|
22
22
|
import { formatSkillForLLMWithSchemas } from "../skill-http.utils.mjs";
|
|
23
23
|
import { formatSkillForLLM } from "../skill.utils.mjs";
|
|
24
24
|
var inputSchema = z.object({
|
|
@@ -68,13 +68,16 @@ var LoadSkillFlow = class extends FlowBase {
|
|
|
68
68
|
const { notLoadedReason } = await readySkillCatalog(this.scope);
|
|
69
69
|
const loadResults = [];
|
|
70
70
|
const resolveEntry = createSkillEntryResolver(skillRegistry);
|
|
71
|
-
|
|
71
|
+
const seenSkills = /* @__PURE__ */ new Set();
|
|
72
|
+
for (const skillId of new Set(skillIds)) {
|
|
72
73
|
const result = await skillRegistry.loadSkill(skillId);
|
|
73
74
|
if (!result) {
|
|
74
75
|
if (notLoadedReason !== void 0) throw new SkillBundleNotLoadedError(notLoadedReason);
|
|
75
76
|
warnings.push(`Skill "${skillId}" not found`);
|
|
76
77
|
continue;
|
|
77
78
|
}
|
|
79
|
+
if (seenSkills.has(result.skill.id)) continue;
|
|
80
|
+
seenSkills.add(result.skill.id);
|
|
78
81
|
const entry = resolveEntry(skillId, result.skill.id);
|
|
79
82
|
if (entry) {
|
|
80
83
|
if (!await isSkillServable(this.scope, entry, ctx)) {
|
|
@@ -83,7 +86,11 @@ var LoadSkillFlow = class extends FlowBase {
|
|
|
83
86
|
}
|
|
84
87
|
await assertSkillAuthorized(this.scope, entry, authInfo);
|
|
85
88
|
}
|
|
86
|
-
const loadResult =
|
|
89
|
+
const loadResult = await skillToolsListedFor(
|
|
90
|
+
this.scope,
|
|
91
|
+
skillToolsForCaller(result, this.scope.tools, ctx),
|
|
92
|
+
authInfo
|
|
93
|
+
);
|
|
87
94
|
if (loadResult.warning) warnings.push(loadResult.warning);
|
|
88
95
|
loadResults.push({ loadResult });
|
|
89
96
|
}
|
|
@@ -21,6 +21,7 @@ async function handleAuthorizationResult(authResult, sessionManager, policyMode,
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
const allowlist = sessionManager.getToolAllowlist();
|
|
24
|
+
if (authResult.reason === "no_active_skill") throw new ToolNotAllowedError(authResult, allowlist);
|
|
24
25
|
switch (policyMode) {
|
|
25
26
|
case "strict":
|
|
26
27
|
logger?.warn(`SkillToolGuard: blocking tool "${authResult.toolName}" (strict mode)`, {
|
|
@@ -57,7 +58,8 @@ function createSkillToolGuardHook(sessionManager, options = {}) {
|
|
|
57
58
|
const { logger, onApprovalRequired, trackToolCalls = true, verifiedSessionId } = options;
|
|
58
59
|
class SkillToolGuardHookImpl {
|
|
59
60
|
async checkSkillToolAuthorization(ctx) {
|
|
60
|
-
const
|
|
61
|
+
const { tool } = ctx.state;
|
|
62
|
+
const rawToolName = tool?.name || tool?.metadata?.id || tool?.metadata?.name || ctx.state.input?.name || tool?.fullName;
|
|
61
63
|
if (!rawToolName) {
|
|
62
64
|
logger?.verbose("SkillToolGuard: skipping (no tool name in context)");
|
|
63
65
|
return;
|
|
@@ -76,11 +78,9 @@ function createSkillToolGuardHook(sessionManager, options = {}) {
|
|
|
76
78
|
], SkillToolGuardHookImpl.prototype, "checkSkillToolAuthorization", 1);
|
|
77
79
|
async function authorizeInActiveSession(toolName) {
|
|
78
80
|
const session = sessionManager.getActiveSession();
|
|
79
|
-
if (!session) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
if (!session.activeSkillId) {
|
|
81
|
+
if (!session?.activeSkillId) {
|
|
82
|
+
const authResult2 = sessionManager.checkToolAuthorization(toolName);
|
|
83
|
+
if (!authResult2.allowed) throw new ToolNotAllowedError(authResult2);
|
|
84
84
|
logger?.verbose("SkillToolGuard: skipping (no active skill)");
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
@@ -95,7 +95,7 @@ function createSkillToolGuardHook(sessionManager, options = {}) {
|
|
|
95
95
|
await handleAuthorizationResult(
|
|
96
96
|
authResult,
|
|
97
97
|
sessionManager,
|
|
98
|
-
session.policyMode,
|
|
98
|
+
session.strictAllowlist ? "strict" : session.policyMode,
|
|
99
99
|
session.activeSkillId,
|
|
100
100
|
onApprovalRequired,
|
|
101
101
|
logger
|