@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.
Files changed (326) hide show
  1. package/agent/agent.instance.d.ts +3 -0
  2. package/agent/agent.instance.d.ts.map +1 -1
  3. package/agent/agent.registry.d.ts.map +1 -1
  4. package/agent/flows/call-agent.flow.d.ts +1 -1
  5. package/agent/flows/call-agent.flow.d.ts.map +1 -1
  6. package/answer/answer-budget.d.ts.map +1 -1
  7. package/answer/client-profile.d.ts.map +1 -1
  8. package/auth/auth-ui/auth-ui.registry.d.ts.map +1 -1
  9. package/auth/auth.registry.d.ts.map +1 -1
  10. package/auth/authorized-apps.utils.d.ts +8 -0
  11. package/auth/authorized-apps.utils.d.ts.map +1 -1
  12. package/auth/flows/form-body.utils.d.ts.map +1 -1
  13. package/auth/flows/oauth.authorize.flow.d.ts +3 -1
  14. package/auth/flows/oauth.authorize.flow.d.ts.map +1 -1
  15. package/auth/flows/oauth.callback.flow.d.ts.map +1 -1
  16. package/auth/flows/oauth.register.flow.d.ts +5 -0
  17. package/auth/flows/oauth.register.flow.d.ts.map +1 -1
  18. package/auth/flows/oauth.token.flow.d.ts +3 -2
  19. package/auth/flows/oauth.token.flow.d.ts.map +1 -1
  20. package/auth/session/session-store.factory.d.ts.map +1 -1
  21. package/browser/agent/agent.instance.mjs +4 -0
  22. package/browser/agent/agent.registry.mjs +2 -2
  23. package/browser/agent/flows/call-agent.flow.mjs +10 -6
  24. package/browser/answer/answer-budget.mjs +35 -7
  25. package/browser/answer/client-profile.mjs +3 -3
  26. package/browser/auth/auth-ui/auth-ui.registry.mjs +8 -0
  27. package/browser/auth/auth.registry.mjs +4 -0
  28. package/browser/auth/authorized-apps.utils.mjs +5 -0
  29. package/browser/auth/flows/form-body.utils.mjs +4 -2
  30. package/browser/auth/flows/oauth.authorize.flow.mjs +38 -6
  31. package/browser/auth/flows/oauth.callback.flow.mjs +30 -16
  32. package/browser/auth/flows/oauth.register.flow.mjs +17 -5
  33. package/browser/auth/flows/oauth.token.flow.mjs +17 -8
  34. package/browser/auth/session/session-store.factory.mjs +5 -1
  35. package/browser/builtin/authorities/authorities-not-configured.mjs +5 -0
  36. package/browser/channel/channel-notification.service.mjs +16 -12
  37. package/browser/channel/channel.instance.mjs +9 -12
  38. package/browser/channel/channel.utils.mjs +18 -3
  39. package/browser/channel/flows/send-channel-notification.flow.mjs +4 -2
  40. package/browser/common/metadata/app.metadata.mjs +2 -1
  41. package/browser/common/metadata/event.metadata.mjs +10 -10
  42. package/browser/common/schemas/http-output.schema.mjs +6 -1
  43. package/browser/common/types/options/metrics/schema.mjs +2 -1
  44. package/browser/common/utils/content-disposition.utils.mjs +7 -0
  45. package/browser/common/utils/forward-headers.utils.mjs +5 -5
  46. package/browser/common/utils/issuer-subject.utils.mjs +17 -0
  47. package/browser/completion/flows/complete.flow.mjs +9 -1
  48. package/browser/context/frontmcp-context.mjs +5 -1
  49. package/browser/direct/connect.mjs +14 -4
  50. package/browser/direct/direct-server.mjs +3 -1
  51. package/browser/duty/duty.lifecycle.mjs +5 -3
  52. package/browser/duty/lease-store.mjs +6 -2
  53. package/browser/elicitation/flows/elicitation-request.flow.mjs +3 -2
  54. package/browser/elicitation/flows/elicitation-result.flow.mjs +5 -4
  55. package/browser/elicitation/questions/question-scope.helper.mjs +4 -2
  56. package/browser/elicitation/store/elicitation-store.factory.mjs +17 -9
  57. package/browser/elicitation/store/encrypted-elicitation.store.mjs +1 -1
  58. package/browser/elicitation/store/storage-elicitation.store.mjs +83 -63
  59. package/browser/errors/error-handler.mjs +4 -4
  60. package/browser/errors/event.errors.mjs +3 -1
  61. package/browser/errors/misconfiguration.mjs +7 -1
  62. package/browser/errors/transport.errors.mjs +1 -1
  63. package/browser/esm-loader/esm-cache.mjs +5 -1
  64. package/browser/esm-loader/esm-module-loader.mjs +6 -6
  65. package/browser/esm-loader/version-resolver.mjs +1 -1
  66. package/browser/event/event-scope.helper.mjs +13 -5
  67. package/browser/event/flows/event-poll.flow.mjs +1 -1
  68. package/browser/event/flows/event-publish-http.flow.mjs +5 -2
  69. package/browser/event/flows/event-stream.flow.mjs +1 -1
  70. package/browser/ext-apps/ext-apps.handler.mjs +26 -14
  71. package/browser/flows/flow.registry.mjs +2 -1
  72. package/browser/front-mcp/authorities-rules.check.mjs +16 -0
  73. package/browser/front-mcp/front-mcp.mjs +8 -2
  74. package/browser/index.cjs +2035 -1340
  75. package/browser/job/execution/job-execution.manager.mjs +5 -5
  76. package/browser/job/job-permission.guard.mjs +7 -0
  77. package/browser/job/job-run-access.mjs +12 -2
  78. package/browser/job/tools/list-jobs.tool.mjs +2 -7
  79. package/browser/job/tools/remove-job.tool.mjs +6 -0
  80. package/browser/job/tools/update-job.tool.mjs +3 -0
  81. package/browser/logger/instances/instance.console-logger.mjs +14 -4
  82. package/browser/logger/instances/instance.file-logger.mjs +3 -2
  83. package/browser/logger/session-id-hash.mjs +8 -0
  84. package/browser/metrics/metrics.service.mjs +2 -1
  85. package/browser/offload/offload-worker.globals.mjs +3 -3
  86. package/browser/offload/worker-jobs.mjs +9 -2
  87. package/browser/offload/worker-resources.mjs +7 -1
  88. package/browser/plugin/enforced-metadata.check.mjs +24 -7
  89. package/browser/prompt/flows/get-prompt.flow.mjs +10 -3
  90. package/browser/prompt/flows/prompts-list.flow.mjs +1 -1
  91. package/browser/provider/provider.registry.mjs +21 -10
  92. package/browser/remote-mcp/mcp-client.service.mjs +4 -3
  93. package/browser/remote-mcp/remote-entries.mjs +15 -1
  94. package/browser/remote-mcp/remote-oauth.mjs +29 -2
  95. package/browser/resource/flows/read-resource.flow.mjs +23 -13
  96. package/browser/resource/flows/resource-templates-list.flow.mjs +1 -1
  97. package/browser/resource/flows/resources-list.flow.mjs +1 -1
  98. package/browser/resource/flows/subscribe-resource.flow.mjs +9 -1
  99. package/browser/resource/resource.instance.mjs +10 -1
  100. package/browser/scope/flows/http.request.flow.mjs +15 -3
  101. package/browser/scope/optional-dependency.util.mjs +1 -13
  102. package/browser/scope/scope.instance.mjs +39 -30
  103. package/browser/server/security/replaceable-directory.mjs +7 -2
  104. package/browser/server/security/resolve-allowed-hosts.mjs +3 -3
  105. package/browser/server/server.validation.mjs +3 -5
  106. package/browser/skill/cache/skill-http-cache.catalog.mjs +18 -0
  107. package/browser/skill/flows/http/llm-full-txt.flow.mjs +3 -2
  108. package/browser/skill/flows/http/llm-txt.flow.mjs +3 -2
  109. package/browser/skill/flows/load-skill.flow.mjs +10 -3
  110. package/browser/skill/hooks/skill-tool.hook.mjs +7 -7
  111. package/browser/skill/sep-2640/sep-2640.resource-helpers.mjs +29 -10
  112. package/browser/skill/session/skill-session.manager.mjs +32 -35
  113. package/browser/skill/session/skill-session.types.mjs +2 -0
  114. package/browser/skill/skill-authorities.helper.mjs +11 -4
  115. package/browser/skill/skill-directory-loader.mjs +15 -1
  116. package/browser/skill/skill-filter.helper.mjs +35 -7
  117. package/browser/skill/skill-md-parser.mjs +17 -2
  118. package/browser/skill/skill.instance.mjs +7 -0
  119. package/browser/storage/sqlite-on-edge.mjs +28 -0
  120. package/browser/task/store/task-store.factory.mjs +8 -3
  121. package/browser/tool/flows/call-tool.flow.mjs +29 -14
  122. package/browser/tool/flows/tools-list.flow.mjs +1 -4
  123. package/browser/transport/adapters/transport.local.adapter.mjs +3 -2
  124. package/browser/transport/event-stores/event-store.factory.mjs +5 -1
  125. package/browser/transport/event-stores/redis.event-store.mjs +13 -9
  126. package/browser/transport/flows/handle.streamable-http.flow.mjs +13 -6
  127. package/browser/transport/in-memory-server.mjs +5 -3
  128. package/browser/transport/mcp-20260728/client/mcp-stateless.client.mjs +25 -6
  129. package/browser/transport/mcp-20260728/dispatcher.mjs +4 -9
  130. package/browser/transport/mcp-handlers/index.mjs +19 -1
  131. package/browser/transport/mcp-handlers/skills-list-request.handler.mjs +2 -1
  132. package/browser/transport/mcp-handlers/skills-mcp.types.mjs +3 -1
  133. package/browser/transport/web-fetch-handler.mjs +3 -3
  134. package/browser/transport/web-response.renderer.mjs +5 -4
  135. package/browser/transport/web-standard-mcp.mjs +2 -2
  136. package/browser/worker/worker.lifecycle.mjs +7 -4
  137. package/browser/workflow/tools/list-workflows.tool.mjs +6 -7
  138. package/browser/workflow/tools/register-workflow.tool.mjs +3 -2
  139. package/browser/workflow/tools/remove-workflow.tool.mjs +6 -0
  140. package/browser/workflow/tools/runtime-workflow.limits.mjs +5 -0
  141. package/browser/workflow/tools/update-workflow.tool.mjs +6 -2
  142. package/browser/workflow/trigger/workflow-webhook.routes.mjs +15 -6
  143. package/browser/workflow/trigger/workflow-webhook.signature.mjs +5 -8
  144. package/builtin/authorities/authorities-not-configured.d.ts +3 -0
  145. package/builtin/authorities/authorities-not-configured.d.ts.map +1 -0
  146. package/channel/channel-notification.service.d.ts +8 -3
  147. package/channel/channel-notification.service.d.ts.map +1 -1
  148. package/channel/channel.instance.d.ts +10 -8
  149. package/channel/channel.instance.d.ts.map +1 -1
  150. package/channel/channel.utils.d.ts +6 -1
  151. package/channel/channel.utils.d.ts.map +1 -1
  152. package/channel/flows/send-channel-notification.flow.d.ts +1 -1
  153. package/channel/flows/send-channel-notification.flow.d.ts.map +1 -1
  154. package/common/entries/channel.entry.d.ts +1 -1
  155. package/common/entries/channel.entry.d.ts.map +1 -1
  156. package/common/metadata/app.metadata.d.ts +11 -3
  157. package/common/metadata/app.metadata.d.ts.map +1 -1
  158. package/common/metadata/channel.metadata.d.ts +7 -4
  159. package/common/metadata/channel.metadata.d.ts.map +1 -1
  160. package/common/metadata/duty.metadata.d.ts +1 -1
  161. package/common/metadata/duty.metadata.d.ts.map +1 -1
  162. package/common/metadata/event.metadata.d.ts +15 -12
  163. package/common/metadata/event.metadata.d.ts.map +1 -1
  164. package/common/metadata/front-mcp.metadata.d.ts +59 -59
  165. package/common/metadata/worker.metadata.d.ts +1 -1
  166. package/common/metadata/worker.metadata.d.ts.map +1 -1
  167. package/common/schemas/http-output.schema.d.ts +1 -1
  168. package/common/schemas/http-output.schema.d.ts.map +1 -1
  169. package/common/types/options/http/interfaces.d.ts +3 -2
  170. package/common/types/options/http/interfaces.d.ts.map +1 -1
  171. package/common/types/options/metrics/interfaces.d.ts +3 -2
  172. package/common/types/options/metrics/interfaces.d.ts.map +1 -1
  173. package/common/types/options/metrics/schema.d.ts +1 -1
  174. package/common/types/options/metrics/schema.d.ts.map +1 -1
  175. package/common/utils/content-disposition.utils.d.ts +6 -0
  176. package/common/utils/content-disposition.utils.d.ts.map +1 -0
  177. package/common/utils/issuer-subject.utils.d.ts +8 -0
  178. package/common/utils/issuer-subject.utils.d.ts.map +1 -0
  179. package/completion/flows/complete.flow.d.ts.map +1 -1
  180. package/context/frontmcp-context.d.ts +5 -1
  181. package/context/frontmcp-context.d.ts.map +1 -1
  182. package/direct/connect.d.ts.map +1 -1
  183. package/direct/direct-server.d.ts.map +1 -1
  184. package/duty/duty.lifecycle.d.ts +1 -1
  185. package/duty/duty.lifecycle.d.ts.map +1 -1
  186. package/duty/lease-store.d.ts +4 -2
  187. package/duty/lease-store.d.ts.map +1 -1
  188. package/elicitation/flows/elicitation-request.flow.d.ts.map +1 -1
  189. package/elicitation/flows/elicitation-result.flow.d.ts.map +1 -1
  190. package/elicitation/questions/question-scope.helper.d.ts +4 -1
  191. package/elicitation/questions/question-scope.helper.d.ts.map +1 -1
  192. package/elicitation/store/elicitation-store.factory.d.ts.map +1 -1
  193. package/elicitation/store/elicitation.store.d.ts +8 -8
  194. package/elicitation/store/storage-elicitation.store.d.ts +11 -11
  195. package/elicitation/store/storage-elicitation.store.d.ts.map +1 -1
  196. package/errors/duty.errors.d.ts +1 -1
  197. package/errors/duty.errors.d.ts.map +1 -1
  198. package/errors/error-handler.d.ts.map +1 -1
  199. package/errors/event.errors.d.ts +9 -2
  200. package/errors/event.errors.d.ts.map +1 -1
  201. package/errors/misconfiguration.d.ts +10 -0
  202. package/errors/misconfiguration.d.ts.map +1 -1
  203. package/errors/worker.errors.d.ts +1 -1
  204. package/esm/index.mjs +62 -58
  205. package/esm-loader/esm-cache.d.ts.map +1 -1
  206. package/esm-loader/esm-module-loader.d.ts.map +1 -1
  207. package/event/event-scope.helper.d.ts.map +1 -1
  208. package/event/flows/event-publish-http.flow.d.ts +3 -2
  209. package/event/flows/event-publish-http.flow.d.ts.map +1 -1
  210. package/ext-apps/ext-apps.handler.d.ts +3 -0
  211. package/ext-apps/ext-apps.handler.d.ts.map +1 -1
  212. package/flows/flow.registry.d.ts.map +1 -1
  213. package/front-mcp/authorities-rules.check.d.ts +2 -1
  214. package/front-mcp/authorities-rules.check.d.ts.map +1 -1
  215. package/front-mcp/front-mcp.d.ts +3 -0
  216. package/front-mcp/front-mcp.d.ts.map +1 -1
  217. package/index.js +68 -64
  218. package/job/execution/job-execution.manager.d.ts.map +1 -1
  219. package/job/job-permission.guard.d.ts +2 -0
  220. package/job/job-permission.guard.d.ts.map +1 -1
  221. package/job/job-run-access.d.ts +7 -3
  222. package/job/job-run-access.d.ts.map +1 -1
  223. package/job/store/job-state.interface.d.ts +2 -0
  224. package/job/store/job-state.interface.d.ts.map +1 -1
  225. package/job/tools/list-jobs.tool.d.ts.map +1 -1
  226. package/job/tools/remove-job.tool.d.ts.map +1 -1
  227. package/job/tools/update-job.tool.d.ts.map +1 -1
  228. package/logger/instances/instance.console-logger.d.ts +1 -1
  229. package/logger/instances/instance.console-logger.d.ts.map +1 -1
  230. package/logger/instances/instance.file-logger.d.ts +2 -1
  231. package/logger/instances/instance.file-logger.d.ts.map +1 -1
  232. package/logger/session-id-hash.d.ts +3 -0
  233. package/logger/session-id-hash.d.ts.map +1 -0
  234. package/metrics/metrics.service.d.ts.map +1 -1
  235. package/offload/offload-worker.globals.d.ts +2 -2
  236. package/offload/offload-worker.globals.d.ts.map +1 -1
  237. package/offload/worker-jobs.d.ts.map +1 -1
  238. package/package.json +10 -10
  239. package/plugin/enforced-metadata.check.d.ts +3 -3
  240. package/plugin/enforced-metadata.check.d.ts.map +1 -1
  241. package/prompt/flows/get-prompt.flow.d.ts +1 -0
  242. package/prompt/flows/get-prompt.flow.d.ts.map +1 -1
  243. package/prompt/flows/prompts-list.flow.d.ts +2 -1
  244. package/prompt/flows/prompts-list.flow.d.ts.map +1 -1
  245. package/provider/provider.registry.d.ts +2 -0
  246. package/provider/provider.registry.d.ts.map +1 -1
  247. package/provider/provider.utils.d.ts +2 -2
  248. package/provider/provider.utils.d.ts.map +1 -1
  249. package/remote-mcp/mcp-client.service.d.ts.map +1 -1
  250. package/remote-mcp/mcp-client.types.d.ts +2 -0
  251. package/remote-mcp/mcp-client.types.d.ts.map +1 -1
  252. package/remote-mcp/remote-entries.d.ts.map +1 -1
  253. package/remote-mcp/remote-oauth.d.ts +4 -2
  254. package/remote-mcp/remote-oauth.d.ts.map +1 -1
  255. package/resource/flows/read-resource.flow.d.ts +1 -0
  256. package/resource/flows/read-resource.flow.d.ts.map +1 -1
  257. package/resource/flows/resource-templates-list.flow.d.ts.map +1 -1
  258. package/resource/flows/resources-list.flow.d.ts +2 -1
  259. package/resource/flows/resources-list.flow.d.ts.map +1 -1
  260. package/resource/flows/subscribe-resource.flow.d.ts.map +1 -1
  261. package/resource/resource.instance.d.ts.map +1 -1
  262. package/scope/flows/http.request.flow.d.ts +2 -0
  263. package/scope/flows/http.request.flow.d.ts.map +1 -1
  264. package/scope/optional-dependency.util.d.ts +1 -12
  265. package/scope/optional-dependency.util.d.ts.map +1 -1
  266. package/scope/scope.instance.d.ts.map +1 -1
  267. package/server/security/replaceable-directory.d.ts +4 -1
  268. package/server/security/replaceable-directory.d.ts.map +1 -1
  269. package/server/security/resolve-allowed-hosts.d.ts.map +1 -1
  270. package/server/server.validation.d.ts.map +1 -1
  271. package/shared/shared-endpoint.d.ts.map +1 -1
  272. package/skill/cache/skill-http-cache.catalog.d.ts +6 -0
  273. package/skill/cache/skill-http-cache.catalog.d.ts.map +1 -0
  274. package/skill/flows/http/llm-full-txt.flow.d.ts.map +1 -1
  275. package/skill/flows/http/llm-txt.flow.d.ts.map +1 -1
  276. package/skill/flows/load-skill.flow.d.ts.map +1 -1
  277. package/skill/hooks/skill-tool.hook.d.ts +2 -0
  278. package/skill/hooks/skill-tool.hook.d.ts.map +1 -1
  279. package/skill/sep-2640/sep-2640.resource-helpers.d.ts +5 -4
  280. package/skill/sep-2640/sep-2640.resource-helpers.d.ts.map +1 -1
  281. package/skill/session/skill-session.manager.d.ts +2 -0
  282. package/skill/session/skill-session.manager.d.ts.map +1 -1
  283. package/skill/session/skill-session.types.d.ts +6 -0
  284. package/skill/session/skill-session.types.d.ts.map +1 -1
  285. package/skill/skill-authorities.helper.d.ts +4 -5
  286. package/skill/skill-authorities.helper.d.ts.map +1 -1
  287. package/skill/skill-directory-loader.d.ts.map +1 -1
  288. package/skill/skill-filter.helper.d.ts +15 -15
  289. package/skill/skill-filter.helper.d.ts.map +1 -1
  290. package/skill/skill-md-parser.d.ts.map +1 -1
  291. package/skill/skill.instance.d.ts +5 -0
  292. package/skill/skill.instance.d.ts.map +1 -1
  293. package/storage/sqlite-on-edge.d.ts +5 -0
  294. package/storage/sqlite-on-edge.d.ts.map +1 -0
  295. package/task/store/task-store.factory.d.ts.map +1 -1
  296. package/tool/flows/call-tool.flow.d.ts +5 -2
  297. package/tool/flows/call-tool.flow.d.ts.map +1 -1
  298. package/tool/flows/tools-list.flow.d.ts +2 -1
  299. package/tool/flows/tools-list.flow.d.ts.map +1 -1
  300. package/transport/adapters/transport.local.adapter.d.ts.map +1 -1
  301. package/transport/event-stores/event-store.factory.d.ts.map +1 -1
  302. package/transport/event-stores/redis.event-store.d.ts.map +1 -1
  303. package/transport/flows/handle.streamable-http.flow.d.ts.map +1 -1
  304. package/transport/in-memory-server.d.ts.map +1 -1
  305. package/transport/mcp-20260728/client/mcp-stateless.client.d.ts +8 -2
  306. package/transport/mcp-20260728/client/mcp-stateless.client.d.ts.map +1 -1
  307. package/transport/mcp-20260728/dispatcher.d.ts +3 -1
  308. package/transport/mcp-20260728/dispatcher.d.ts.map +1 -1
  309. package/transport/mcp-handlers/index.d.ts +32 -24
  310. package/transport/mcp-handlers/index.d.ts.map +1 -1
  311. package/transport/mcp-handlers/skills-list-request.handler.d.ts.map +1 -1
  312. package/transport/mcp-handlers/skills-mcp.types.d.ts +2 -0
  313. package/transport/mcp-handlers/skills-mcp.types.d.ts.map +1 -1
  314. package/transport/web-fetch-handler.d.ts +10 -8
  315. package/transport/web-fetch-handler.d.ts.map +1 -1
  316. package/transport/web-response.renderer.d.ts.map +1 -1
  317. package/worker/worker.lifecycle.d.ts +2 -2
  318. package/worker/worker.lifecycle.d.ts.map +1 -1
  319. package/workflow/tools/list-workflows.tool.d.ts.map +1 -1
  320. package/workflow/tools/register-workflow.tool.d.ts.map +1 -1
  321. package/workflow/tools/remove-workflow.tool.d.ts.map +1 -1
  322. package/workflow/tools/runtime-workflow.limits.d.ts +3 -0
  323. package/workflow/tools/runtime-workflow.limits.d.ts.map +1 -0
  324. package/workflow/tools/update-workflow.tool.d.ts.map +1 -1
  325. package/workflow/trigger/workflow-webhook.signature.d.ts +8 -5
  326. 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(`Failed to load capabilities for remote app ${app.id}: ${error.message}`);
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
- this.logger.verbose(`findResource: looking for resource with URI "${uri}"`);
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 "${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 "${uri}" resolved from cache`);
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 "${uri}" not found`);
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 "${uri}" is not offered on surface "${callSurface}"`);
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 "${uri}" is unavailable in this environment`);
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(${uri})`);
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 (!engine || !ctxBuilder || !resource) return;
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
- authInfo: {}
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: headersForLog(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 tools of each agent, and skills, hidden ones included.
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
- const entries = [];
1607
- const add = (label, metadata) => {
1608
- const authorities = metadata?.["authorities"];
1609
- if (authorities !== void 0 && authorities !== null && authorities !== false) {
1610
- entries.push({ label, authorities });
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 !== ROOT_UID && uid !== process.getuid?.()) return { directory, mode, ownerUid: 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" || normalized.startsWith("127.") || // IPv4-mapped IPv6 loopback, which `URL` renders as `::ffff:7f00:1`.
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", contentDisposition(out.disposition, out.filename));
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", contentDisposition(out.disposition, out.filename));
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
- for (const skillId of skillIds) {
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 = skillToolsForCaller(result, this.scope.tools, ctx);
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 rawToolName = ctx.state.tool?.metadata?.name || ctx.state.input?.name || ctx.state.tool?.fullName;
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
- logger?.verbose("SkillToolGuard: skipping (no active session)");
81
- return;
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