@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// libs/sdk/src/skill/sep-2640/sep-2640.resource-helpers.ts
|
|
2
|
-
import { isAbsolute, joinPath, pathResolve, readFileBuffer } from "@frontmcp/utils";
|
|
2
|
+
import { isAbsolute, joinPath, pathResolve, readFileBuffer, realpath } from "@frontmcp/utils";
|
|
3
3
|
import { PublicMcpError, ResourceNotFoundError } from "../../errors/index.mjs";
|
|
4
4
|
import { SkillBundleNotLoadedError } from "../errors/skill-bundle-not-loaded.error.mjs";
|
|
5
5
|
import { findSkillCatalogSource, readySkillCatalog } from "../skill-catalog-source.mjs";
|
|
@@ -53,6 +53,9 @@ async function findAndLoadSkillByPath(scope, skillPath) {
|
|
|
53
53
|
if (!loadResult) {
|
|
54
54
|
throw new PublicMcpError(`Failed to load skill at "${skillPath}".`, "INTERNAL_ERROR", 500);
|
|
55
55
|
}
|
|
56
|
+
if (findSkillByPath(scope, skillPath) !== entry) {
|
|
57
|
+
throw new ResourceNotFoundError(`skill://${skillPath}/SKILL.md`);
|
|
58
|
+
}
|
|
56
59
|
return { loadResult, instance: entry };
|
|
57
60
|
}
|
|
58
61
|
async function renderSkillMd(scope, skill, authInfo) {
|
|
@@ -106,6 +109,7 @@ async function readSkillFileByPath(instance, filePath) {
|
|
|
106
109
|
if (!baseDir) {
|
|
107
110
|
throw new ResourceNotFoundError(`skill://${instance.getSkillPath()}/${filePath}`);
|
|
108
111
|
}
|
|
112
|
+
const publishedDir = instance.getPublishedDir();
|
|
109
113
|
const resources = instance.getResources();
|
|
110
114
|
const candidateDirs = [
|
|
111
115
|
["references", resources?.references],
|
|
@@ -114,31 +118,41 @@ async function readSkillFileByPath(instance, filePath) {
|
|
|
114
118
|
["assets", resources?.assets]
|
|
115
119
|
];
|
|
116
120
|
let candidatePath;
|
|
121
|
+
let candidateDir;
|
|
117
122
|
for (const [subdir, configured] of candidateDirs) {
|
|
118
123
|
if (segments[0] !== subdir) continue;
|
|
119
|
-
const dir = configured ? isAbsolute(configured) ? configured : pathResolve(baseDir, configured) : joinPath(
|
|
124
|
+
const dir = configured ? isAbsolute(configured) ? configured : pathResolve(baseDir, configured) : publishedDir ? joinPath(publishedDir, subdir) : void 0;
|
|
125
|
+
if (!dir) break;
|
|
120
126
|
candidatePath = pathResolve(dir, ...segments.slice(1));
|
|
127
|
+
candidateDir = dir;
|
|
121
128
|
if (!isInside(candidatePath, dir)) {
|
|
122
129
|
throw new PublicMcpError(`Invalid file path "${filePath}".`, "INVALID_PARAMS", 400);
|
|
123
130
|
}
|
|
124
131
|
break;
|
|
125
132
|
}
|
|
126
133
|
if (!candidatePath) {
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
if (!publishedDir) {
|
|
135
|
+
throw new ResourceNotFoundError(`skill://${instance.getSkillPath()}/${filePath}`);
|
|
136
|
+
}
|
|
137
|
+
candidatePath = pathResolve(publishedDir, ...segments);
|
|
138
|
+
if (!isInside(candidatePath, publishedDir)) {
|
|
129
139
|
throw new PublicMcpError(`Invalid file path "${filePath}".`, "INVALID_PARAMS", 400);
|
|
130
140
|
}
|
|
131
141
|
}
|
|
132
142
|
const mimeType = guessMimeType(filePath);
|
|
143
|
+
const containingDir = publishedDir ?? candidateDir;
|
|
133
144
|
let buffer;
|
|
134
145
|
try {
|
|
135
|
-
buffer = await
|
|
146
|
+
buffer = containingDir ? await readFileInside(candidatePath, containingDir) : void 0;
|
|
136
147
|
} catch (err) {
|
|
137
148
|
if (isFileMissingError(err)) {
|
|
138
149
|
throw new ResourceNotFoundError(`skill://${instance.getSkillPath()}/${filePath}`);
|
|
139
150
|
}
|
|
140
151
|
throw err;
|
|
141
152
|
}
|
|
153
|
+
if (buffer === void 0) {
|
|
154
|
+
throw new ResourceNotFoundError(`skill://${instance.getSkillPath()}/${filePath}`);
|
|
155
|
+
}
|
|
142
156
|
if (!isTextMimeType(mimeType)) {
|
|
143
157
|
const buf2 = Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer);
|
|
144
158
|
return { kind: "blob", blob: buf2.toString("base64"), mimeType };
|
|
@@ -172,10 +186,11 @@ async function tryResolvedSubFile(instance, kind, tail) {
|
|
|
172
186
|
return parseSkillMdFrontmatter(inline).body;
|
|
173
187
|
}
|
|
174
188
|
const absolutePath = entry.path;
|
|
175
|
-
const
|
|
176
|
-
if (!
|
|
189
|
+
const entryFile = resolveEntryPath(instance, kind, absolutePath, filename);
|
|
190
|
+
if (!entryFile) continue;
|
|
177
191
|
try {
|
|
178
|
-
const buf = await readFileBuffer(
|
|
192
|
+
const buf = entryFile.root ? await readFileInside(entryFile.filePath, entryFile.root) : await readFileBuffer(entryFile.filePath);
|
|
193
|
+
if (buf === void 0) continue;
|
|
179
194
|
const text = (Buffer.isBuffer(buf) ? buf : Buffer.from(buf)).toString("utf-8");
|
|
180
195
|
return parseSkillMdFrontmatter(text).body;
|
|
181
196
|
} catch (err) {
|
|
@@ -188,7 +203,7 @@ async function tryResolvedSubFile(instance, kind, tail) {
|
|
|
188
203
|
return void 0;
|
|
189
204
|
}
|
|
190
205
|
function resolveEntryPath(instance, kind, absolutePath, filename) {
|
|
191
|
-
if (absolutePath && isAbsolute(absolutePath)) return absolutePath;
|
|
206
|
+
if (absolutePath && isAbsolute(absolutePath)) return { filePath: absolutePath };
|
|
192
207
|
if (!filename) return void 0;
|
|
193
208
|
const baseDir = instance.getBaseDir();
|
|
194
209
|
const configured = instance.getResources()?.[kind];
|
|
@@ -201,7 +216,11 @@ function resolveEntryPath(instance, kind, absolutePath, filename) {
|
|
|
201
216
|
if (!dir) return void 0;
|
|
202
217
|
const resolved = pathResolve(dir, filename);
|
|
203
218
|
if (!isInside(resolved, dir)) return void 0;
|
|
204
|
-
return resolved;
|
|
219
|
+
return { filePath: resolved, root: instance.getPublishedDir() ?? dir };
|
|
220
|
+
}
|
|
221
|
+
async function readFileInside(filePath, root) {
|
|
222
|
+
const [realFile, realRoot] = await Promise.all([realpath(filePath), realpath(root)]);
|
|
223
|
+
return isInside(realFile, realRoot) ? readFileBuffer(realFile) : void 0;
|
|
205
224
|
}
|
|
206
225
|
function isFileMissingError(err) {
|
|
207
226
|
if (typeof err !== "object" || err === null) return false;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// libs/sdk/src/skill/session/skill-session.manager.ts
|
|
2
2
|
import { AsyncLocalStorage, EventEmitter } from "@frontmcp/utils";
|
|
3
3
|
import { SkillSessionError } from "../../errors/index.mjs";
|
|
4
|
+
import { sessionIdHash } from "../../logger/session-id-hash.mjs";
|
|
4
5
|
import {
|
|
5
6
|
createEmptySessionState
|
|
6
7
|
} from "./skill-session.types.mjs";
|
|
@@ -119,6 +120,7 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
119
120
|
} else if (session.activeSkills.size === 1) {
|
|
120
121
|
session.policyMode = this.options.defaultPolicyMode;
|
|
121
122
|
}
|
|
123
|
+
if (policy?.strictAllowlist) session.strictAllowlist = true;
|
|
122
124
|
if (session.startedAt === 0) {
|
|
123
125
|
session.startedAt = now;
|
|
124
126
|
}
|
|
@@ -136,7 +138,7 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
136
138
|
}
|
|
137
139
|
});
|
|
138
140
|
this.logger?.debug(`Skill session activated: ${skillId}`, {
|
|
139
|
-
|
|
141
|
+
sessionIdHash: sessionIdHash(session.sessionId),
|
|
140
142
|
skillToolsAdded: toolNames,
|
|
141
143
|
totalAllowedTools: session.allowedTools.size,
|
|
142
144
|
activeSkillCount: session.activeSkills.size,
|
|
@@ -194,7 +196,7 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
194
196
|
}
|
|
195
197
|
});
|
|
196
198
|
this.logger?.debug(`Skill deactivated: ${skillId}`, {
|
|
197
|
-
|
|
199
|
+
sessionIdHash: sessionIdHash(session.sessionId),
|
|
198
200
|
remainingSkills: session.activeSkills.size
|
|
199
201
|
});
|
|
200
202
|
this.rebuildCombinedToolSets(session);
|
|
@@ -228,7 +230,7 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
228
230
|
});
|
|
229
231
|
}
|
|
230
232
|
this.logger?.debug(`All skills deactivated`, {
|
|
231
|
-
|
|
233
|
+
sessionIdHash: sessionIdHash(session.sessionId),
|
|
232
234
|
deactivatedSkills: skillIds,
|
|
233
235
|
duration,
|
|
234
236
|
toolCallCount: session.toolCallCount
|
|
@@ -250,6 +252,7 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
250
252
|
session.approvedTools.clear();
|
|
251
253
|
session.deniedTools.clear();
|
|
252
254
|
session.toolCallCount = 0;
|
|
255
|
+
delete session.strictAllowlist;
|
|
253
256
|
}
|
|
254
257
|
/**
|
|
255
258
|
* Check if a tool is authorized in the current session.
|
|
@@ -260,27 +263,8 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
260
263
|
*/
|
|
261
264
|
checkToolAuthorization(toolName) {
|
|
262
265
|
const session = this.getActiveSession();
|
|
263
|
-
if (!session) {
|
|
264
|
-
|
|
265
|
-
return {
|
|
266
|
-
allowed: false,
|
|
267
|
-
reason: "no_active_skill",
|
|
268
|
-
toolName,
|
|
269
|
-
context: { message: "Skill must be explicitly activated" }
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
return {
|
|
273
|
-
allowed: true,
|
|
274
|
-
reason: "no_active_skill",
|
|
275
|
-
toolName
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
if (session.activeSkills.size === 0) {
|
|
279
|
-
return {
|
|
280
|
-
allowed: true,
|
|
281
|
-
reason: "no_active_skill",
|
|
282
|
-
toolName
|
|
283
|
-
};
|
|
266
|
+
if (!session || session.activeSkills.size === 0) {
|
|
267
|
+
return this.withoutActiveSkill(toolName);
|
|
284
268
|
}
|
|
285
269
|
const activeSkillIds = Array.from(session.activeSkills.keys());
|
|
286
270
|
const activeSkillNames = Array.from(session.activeSkills.values()).map((s) => s.name);
|
|
@@ -306,12 +290,7 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
306
290
|
const elapsed = Date.now() - session.startedAt;
|
|
307
291
|
if (elapsed > this.options.maxSessionDuration) {
|
|
308
292
|
this.deactivateSkill();
|
|
309
|
-
return
|
|
310
|
-
allowed: true,
|
|
311
|
-
reason: "no_active_skill",
|
|
312
|
-
toolName,
|
|
313
|
-
context: { message: "Session expired" }
|
|
314
|
-
};
|
|
293
|
+
return this.withoutActiveSkill(toolName, "Session expired");
|
|
315
294
|
}
|
|
316
295
|
}
|
|
317
296
|
if (session.deniedTools.has(toolName)) {
|
|
@@ -328,6 +307,9 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
328
307
|
...baseResult
|
|
329
308
|
};
|
|
330
309
|
}
|
|
310
|
+
if (session.strictAllowlist) {
|
|
311
|
+
return { allowed: false, reason: "not_in_allowlist", ...baseResult };
|
|
312
|
+
}
|
|
331
313
|
if (session.approvedTools.has(toolName)) {
|
|
332
314
|
return {
|
|
333
315
|
allowed: true,
|
|
@@ -352,7 +334,7 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
352
334
|
case "permissive":
|
|
353
335
|
default:
|
|
354
336
|
this.logger?.warn(`Tool '${toolName}' not in skill allowlist but allowed (permissive mode)`, {
|
|
355
|
-
|
|
337
|
+
sessionIdHash: sessionIdHash(session.sessionId),
|
|
356
338
|
activeSkillIds
|
|
357
339
|
});
|
|
358
340
|
return {
|
|
@@ -363,6 +345,18 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
363
345
|
};
|
|
364
346
|
}
|
|
365
347
|
}
|
|
348
|
+
/** The answer for a tool call made while no skill is active: refused when `requireExplicitActivation` is set. */
|
|
349
|
+
withoutActiveSkill(toolName, message) {
|
|
350
|
+
if (this.options.requireExplicitActivation) {
|
|
351
|
+
return {
|
|
352
|
+
allowed: false,
|
|
353
|
+
reason: "no_active_skill",
|
|
354
|
+
toolName,
|
|
355
|
+
context: { message: "Skill must be explicitly activated" }
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
return { allowed: true, reason: "no_active_skill", toolName, ...message && { context: { message } } };
|
|
359
|
+
}
|
|
366
360
|
/**
|
|
367
361
|
* Check if a tool is allowed without checking policy mode.
|
|
368
362
|
* Simpler check for quick validation.
|
|
@@ -397,7 +391,7 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
397
391
|
timestamp: Date.now()
|
|
398
392
|
});
|
|
399
393
|
this.logger?.info(`Tool dynamically approved: ${toolName}`, {
|
|
400
|
-
|
|
394
|
+
sessionIdHash: sessionIdHash(session.sessionId),
|
|
401
395
|
skillId: session.activeSkillId
|
|
402
396
|
});
|
|
403
397
|
this.persistSession(session);
|
|
@@ -420,7 +414,7 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
420
414
|
timestamp: Date.now()
|
|
421
415
|
});
|
|
422
416
|
this.logger?.info(`Tool denied: ${toolName}`, {
|
|
423
|
-
|
|
417
|
+
sessionIdHash: sessionIdHash(session.sessionId),
|
|
424
418
|
skillId: session.activeSkillId
|
|
425
419
|
});
|
|
426
420
|
this.persistSession(session);
|
|
@@ -464,7 +458,7 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
464
458
|
session.policyMode = mode;
|
|
465
459
|
this.persistSession(session);
|
|
466
460
|
this.logger?.debug(`Skill session policy mode changed to: ${mode}`, {
|
|
467
|
-
|
|
461
|
+
sessionIdHash: sessionIdHash(session.sessionId),
|
|
468
462
|
skillId: session.activeSkillId
|
|
469
463
|
});
|
|
470
464
|
}
|
|
@@ -483,7 +477,10 @@ var SkillSessionManager = class extends EventEmitter {
|
|
|
483
477
|
try {
|
|
484
478
|
await this.store.save(session);
|
|
485
479
|
} catch (error) {
|
|
486
|
-
this.logger?.error("Failed to persist skill session", {
|
|
480
|
+
this.logger?.error("Failed to persist skill session", {
|
|
481
|
+
error,
|
|
482
|
+
sessionIdHash: sessionIdHash(session.sessionId)
|
|
483
|
+
});
|
|
487
484
|
}
|
|
488
485
|
}
|
|
489
486
|
}
|
|
@@ -22,6 +22,7 @@ function serializeSessionState(state) {
|
|
|
22
22
|
approvedTools: Array.from(state.approvedTools),
|
|
23
23
|
deniedTools: Array.from(state.deniedTools),
|
|
24
24
|
toolCallCount: state.toolCallCount,
|
|
25
|
+
strictAllowlist: state.strictAllowlist,
|
|
25
26
|
metadata: state.metadata
|
|
26
27
|
};
|
|
27
28
|
}
|
|
@@ -48,6 +49,7 @@ function deserializeSessionState(data) {
|
|
|
48
49
|
approvedTools: new Set(data.approvedTools),
|
|
49
50
|
deniedTools: new Set(data.deniedTools),
|
|
50
51
|
toolCallCount: data.toolCallCount,
|
|
52
|
+
strictAllowlist: data.strictAllowlist,
|
|
51
53
|
metadata: data.metadata
|
|
52
54
|
};
|
|
53
55
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// libs/sdk/src/skill/skill-authorities.helper.ts
|
|
2
2
|
import { AuthorityDeniedError, resolveRequiredScopes } from "@frontmcp/auth";
|
|
3
|
+
import { AUTHORITIES_NOT_CONFIGURED } from "../builtin/authorities/authorities-not-configured.mjs";
|
|
3
4
|
import { isListedByAuthorities } from "../surface/entry-authorized.mjs";
|
|
4
5
|
function normalizeAuthInfoForAuthorities(authInfo) {
|
|
5
6
|
if (authInfo["user"]) return authInfo;
|
|
@@ -14,11 +15,17 @@ function getSkillAuthorities(skill) {
|
|
|
14
15
|
return authorities;
|
|
15
16
|
}
|
|
16
17
|
async function assertSkillAuthorized(scope, skill, authInfo, input = {}) {
|
|
17
|
-
const engine = scope.authoritiesEngine;
|
|
18
|
-
const ctxBuilder = scope.authoritiesContextBuilder;
|
|
19
|
-
if (!engine || !ctxBuilder) return;
|
|
20
18
|
const authorities = getSkillAuthorities(skill);
|
|
21
19
|
if (!authorities) return;
|
|
20
|
+
const engine = scope.authoritiesEngine;
|
|
21
|
+
const ctxBuilder = scope.authoritiesContextBuilder;
|
|
22
|
+
if (!engine || !ctxBuilder) {
|
|
23
|
+
throw new AuthorityDeniedError({
|
|
24
|
+
entryType: "Skill",
|
|
25
|
+
entryName: skill.fullName || skill.name,
|
|
26
|
+
deniedBy: AUTHORITIES_NOT_CONFIGURED
|
|
27
|
+
});
|
|
28
|
+
}
|
|
22
29
|
const evalCtx = ctxBuilder.build(normalizeAuthInfoForAuthorities(authInfo), input);
|
|
23
30
|
const result = await engine.evaluate(authorities, evalCtx);
|
|
24
31
|
if (result.granted) return;
|
|
@@ -38,7 +45,7 @@ async function assertSkillAuthorized(scope, skill, authInfo, input = {}) {
|
|
|
38
45
|
async function filterSkillsByAuthorities(scope, skills, authInfo) {
|
|
39
46
|
const engine = scope.authoritiesEngine;
|
|
40
47
|
const ctxBuilder = scope.authoritiesContextBuilder;
|
|
41
|
-
if (!engine || !ctxBuilder) return
|
|
48
|
+
if (!engine || !ctxBuilder) return skills.filter((skill) => !getSkillAuthorities(skill));
|
|
42
49
|
const normalized = normalizeAuthInfoForAuthorities(authInfo);
|
|
43
50
|
const grants = await Promise.all(
|
|
44
51
|
skills.map(async (skill) => {
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
// libs/sdk/src/skill/skill-directory-loader.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
basename,
|
|
4
|
+
fileExists,
|
|
5
|
+
isAbsolute,
|
|
6
|
+
pathJoin,
|
|
7
|
+
pathResolve,
|
|
8
|
+
readdir,
|
|
9
|
+
readFile,
|
|
10
|
+
realpath,
|
|
11
|
+
stat
|
|
12
|
+
} from "@frontmcp/utils";
|
|
3
13
|
import { skillMetadataSchema } from "../common/metadata/skill.metadata.mjs";
|
|
4
14
|
import { SkillKind } from "../common/records/skill.record.mjs";
|
|
5
15
|
import { captureCallerDir } from "../common/utils/caller-dir.utils.mjs";
|
|
@@ -38,10 +48,14 @@ async function checkDirectory(path) {
|
|
|
38
48
|
}
|
|
39
49
|
async function findNestedSkillMd(dirPath, maxDepth = Number.POSITIVE_INFINITY) {
|
|
40
50
|
const found = [];
|
|
51
|
+
const visited = /* @__PURE__ */ new Set();
|
|
41
52
|
async function walk(current, depth, relPath) {
|
|
42
53
|
if (depth > maxDepth) return;
|
|
43
54
|
let entries;
|
|
44
55
|
try {
|
|
56
|
+
const realDir = await realpath(current);
|
|
57
|
+
if (visited.has(realDir)) return;
|
|
58
|
+
visited.add(realDir);
|
|
45
59
|
entries = await readdir(current);
|
|
46
60
|
} catch (err) {
|
|
47
61
|
if (err.code === "ENOENT") return;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// libs/sdk/src/skill/skill-filter.helper.ts
|
|
2
|
+
import { isPubliclyListed, publicAccessFor } from "../auth/public-access.utils.mjs";
|
|
2
3
|
import { availabilityForCall, callSurfaceOf, isOfferedOnSurface } from "../common/availability/index.mjs";
|
|
3
4
|
import { getCallSurface } from "../context/call-surface.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { isListedByAuthorities } from "../surface/entry-authorized.mjs";
|
|
6
|
+
import { filterSkillsByAuthorities, normalizeAuthInfoForAuthorities } from "./skill-authorities.helper.mjs";
|
|
5
7
|
import { createSkillEntryResolver, skillResultId } from "./skill-entry.resolver.mjs";
|
|
6
8
|
var SKILLS_HTTP_SURFACE = "mcp";
|
|
7
9
|
function callerSurface(ctx, surface) {
|
|
@@ -34,14 +36,39 @@ function skillToolsForCaller(loaded, tools, ctx, surface) {
|
|
|
34
36
|
const caller = callerSurface(ctx, surface);
|
|
35
37
|
if (!tools || caller === void 0 || loaded.availableTools.length === 0) return loaded;
|
|
36
38
|
const availability = new Map(tools.getTools(true).map((tool) => [tool.name, tool.metadata?.availableWhen]));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
return withToolsMissing(
|
|
40
|
+
loaded,
|
|
41
|
+
loaded.availableTools.filter((name) => !isOfferedOnSurface(availability.get(name), caller))
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
async function skillToolsListedFor(scope, loaded, authInfo) {
|
|
45
|
+
const { tools, authoritiesEngine: engine, authoritiesContextBuilder: contextBuilder } = scope;
|
|
46
|
+
const publicAccess = publicAccessFor(scope.auth?.options, authInfo);
|
|
47
|
+
if (!tools || loaded.availableTools.length === 0 || !publicAccess && (!engine || !contextBuilder)) return loaded;
|
|
48
|
+
const toolsByName = new Map(tools.getTools(true).map((tool) => [tool.name, tool]));
|
|
49
|
+
const caller = normalizeAuthInfoForAuthorities(authInfo);
|
|
50
|
+
const listed = await Promise.all(
|
|
51
|
+
loaded.availableTools.map(async (name) => {
|
|
52
|
+
const tool = toolsByName.get(name);
|
|
53
|
+
if (publicAccess && !isPubliclyListed(publicAccess, "tools", [tool?.fullName ?? name, name])) return false;
|
|
54
|
+
const authorities = tool?.metadata?.authorities;
|
|
55
|
+
if (!authorities || !engine || !contextBuilder) return true;
|
|
56
|
+
return isListedByAuthorities(engine, contextBuilder, authorities, caller, name, scope.logger);
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
return withToolsMissing(
|
|
60
|
+
loaded,
|
|
61
|
+
loaded.availableTools.filter((_, index) => !listed[index])
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
function withToolsMissing(loaded, names) {
|
|
65
|
+
if (names.length === 0) return loaded;
|
|
39
66
|
return {
|
|
40
67
|
...loaded,
|
|
41
|
-
availableTools: loaded.availableTools.filter((name) => !
|
|
42
|
-
missingTools: [...loaded.missingTools, ...
|
|
68
|
+
availableTools: loaded.availableTools.filter((name) => !names.includes(name)),
|
|
69
|
+
missingTools: [...loaded.missingTools, ...names],
|
|
43
70
|
isComplete: false,
|
|
44
|
-
warning: warningWithMissingTools(loaded.warning, loaded.skill?.name,
|
|
71
|
+
warning: warningWithMissingTools(loaded.warning, loaded.skill?.name, names)
|
|
45
72
|
};
|
|
46
73
|
}
|
|
47
74
|
var WARNING_PREFIX = /^Skill "(.*)" references /;
|
|
@@ -64,5 +91,6 @@ export {
|
|
|
64
91
|
filterDiscoverableSkillResults,
|
|
65
92
|
filterServableSkills,
|
|
66
93
|
isSkillServable,
|
|
67
|
-
skillToolsForCaller
|
|
94
|
+
skillToolsForCaller,
|
|
95
|
+
skillToolsListedFor
|
|
68
96
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// libs/sdk/src/skill/skill-md-parser.ts
|
|
2
2
|
import { readFile } from "@frontmcp/utils";
|
|
3
3
|
import * as yaml from "../third-party/js-yaml.mjs";
|
|
4
|
+
import { InvalidSkillError } from "../errors/sdk.errors.mjs";
|
|
4
5
|
function parseSkillMdFrontmatter(content) {
|
|
5
6
|
const trimmed = content.trimStart();
|
|
6
7
|
if (!trimmed.startsWith("---")) {
|
|
@@ -59,7 +60,7 @@ function skillMdFrontmatterToMetadata(frontmatter, body) {
|
|
|
59
60
|
const specMeta = {};
|
|
60
61
|
for (const [key, val] of Object.entries(meta)) {
|
|
61
62
|
if (typeof val === "string") specMeta[key] = val;
|
|
62
|
-
else specMeta[key] =
|
|
63
|
+
else specMeta[key] = metadataJson(result.name, key, val);
|
|
63
64
|
}
|
|
64
65
|
result.specMetadata = specMeta;
|
|
65
66
|
}
|
|
@@ -147,7 +148,7 @@ function skillMdFrontmatterToMetadata(frontmatter, body) {
|
|
|
147
148
|
for (const [key, val] of Object.entries(frontmatter)) {
|
|
148
149
|
if (!knownKeys.has(key) && val !== void 0) {
|
|
149
150
|
if (!result.specMetadata) result.specMetadata = {};
|
|
150
|
-
result.specMetadata[key] = typeof val === "string" ? val :
|
|
151
|
+
result.specMetadata[key] = typeof val === "string" ? val : metadataJson(result.name, key, val);
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
if (body.length > 0) {
|
|
@@ -155,6 +156,20 @@ function skillMdFrontmatterToMetadata(frontmatter, body) {
|
|
|
155
156
|
}
|
|
156
157
|
return result;
|
|
157
158
|
}
|
|
159
|
+
var MAX_METADATA_JSON_LENGTH = 1e6;
|
|
160
|
+
function metadataJson(skillName, key, value) {
|
|
161
|
+
let length = 0;
|
|
162
|
+
return JSON.stringify(value, (name, item) => {
|
|
163
|
+
length += name.length + (typeof item === "string" ? item.length : 8);
|
|
164
|
+
if (length > MAX_METADATA_JSON_LENGTH) {
|
|
165
|
+
throw new InvalidSkillError(
|
|
166
|
+
skillName ?? "SKILL.md",
|
|
167
|
+
`frontmatter field "${key}" is over ${MAX_METADATA_JSON_LENGTH} characters as JSON (YAML aliases count each repeat); make it smaller`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
return item;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
158
173
|
async function loadSkillMdFile(filePath, resources) {
|
|
159
174
|
const content = await readFile(filePath, "utf-8");
|
|
160
175
|
const { frontmatter, body } = parseSkillMdFrontmatter(content);
|
|
@@ -130,6 +130,13 @@ var SkillInstance = class extends SkillEntry {
|
|
|
130
130
|
}
|
|
131
131
|
return void 0;
|
|
132
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* The directory whose files `skill://` serves as a whole: a skill directory's own. A skill declared in code has
|
|
135
|
+
* none, since its base directory is only where its relative paths resolve; it serves the resource directories it declares.
|
|
136
|
+
*/
|
|
137
|
+
getPublishedDir() {
|
|
138
|
+
return this.record.kind === SkillKind.FILE ? dirname(this.record.filePath) || void 0 : void 0;
|
|
139
|
+
}
|
|
133
140
|
async load() {
|
|
134
141
|
if (this.cachedContent !== void 0) {
|
|
135
142
|
return this.cachedContent;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __frontmcpModule = typeof process !== "undefined" && typeof process.getBuiltinModule === "function" ? process.getBuiltinModule("module") : undefined;
|
|
2
|
+
const require = __frontmcpModule ? __frontmcpModule.createRequire(import.meta.url || 'file:///') : undefined;
|
|
3
|
+
// __frontmcpCreateRequire
|
|
4
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
+
}) : x)(function(x) {
|
|
7
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// libs/sdk/src/storage/sqlite-on-edge.ts
|
|
12
|
+
import { requireOptionalModule } from "../scope/optional-dependency.util.mjs";
|
|
13
|
+
var SQLITE_ON_EDGE_REMEDY = "In a Cloudflare Durable Object class that has one instance (the driver is set for the whole isolate), register @frontmcp/storage-sqlite with registerOptionalModule() and call useSqliteDriver(durableObjectSqlite(ctx.storage)) in its constructor.";
|
|
14
|
+
function hasSqliteDriver() {
|
|
15
|
+
try {
|
|
16
|
+
const sqliteStorage = requireOptionalModule(
|
|
17
|
+
"@frontmcp/storage-sqlite",
|
|
18
|
+
() => __require("@frontmcp/storage-sqlite")
|
|
19
|
+
);
|
|
20
|
+
return sqliteStorage.currentSqliteDriver() !== void 0;
|
|
21
|
+
} catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
SQLITE_ON_EDGE_REMEDY,
|
|
27
|
+
hasSqliteDriver
|
|
28
|
+
};
|
|
@@ -12,6 +12,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
12
12
|
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
|
+
import { requireOptionalModule } from "../../scope/optional-dependency.util.mjs";
|
|
16
|
+
import { hasSqliteDriver, SQLITE_ON_EDGE_REMEDY } from "../../storage/sqlite-on-edge.mjs";
|
|
15
17
|
import { StorageTaskStore } from "./storage-task.store.mjs";
|
|
16
18
|
import { isExplicitStorage } from "./task-backend.utils.mjs";
|
|
17
19
|
import { resolvesToVercelKvTaskBackend } from "./task-backend.utils.mjs";
|
|
@@ -35,13 +37,16 @@ function detectStorageType(storage, configuredType) {
|
|
|
35
37
|
}
|
|
36
38
|
async function createTaskStore(options = {}) {
|
|
37
39
|
const { storage: storageConfig, redis, keyPrefix = "mcp:task:", logger, isEdgeRuntime = false, sqlite } = options;
|
|
38
|
-
if (isEdgeRuntime && sqlite) {
|
|
40
|
+
if (isEdgeRuntime && sqlite && !hasSqliteDriver()) {
|
|
39
41
|
throw new TaskStoreNotSupportedError(
|
|
40
|
-
|
|
42
|
+
`SQLite task 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.`
|
|
41
43
|
);
|
|
42
44
|
}
|
|
43
45
|
if (sqlite) {
|
|
44
|
-
const { SqliteTaskStore } =
|
|
46
|
+
const { SqliteTaskStore } = requireOptionalModule(
|
|
47
|
+
"@frontmcp/storage-sqlite",
|
|
48
|
+
() => __require("@frontmcp/storage-sqlite")
|
|
49
|
+
);
|
|
45
50
|
const store2 = new SqliteTaskStore({
|
|
46
51
|
path: sqlite.path,
|
|
47
52
|
encryption: sqlite.encryption,
|