@redocly/framework 1.0.0-next.1 → 1.0.0-next.11

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 (484) hide show
  1. package/dist/bundler/build/output-metadata.js +1 -1
  2. package/dist/bundler/build/run.js +1 -1
  3. package/dist/bundler/build/theme-global-style-compiler.js +1 -0
  4. package/dist/bundler/build/theme-global-stylesheets.js +1 -0
  5. package/dist/bundler/build/vite-config.js +2 -2
  6. package/dist/bundler/dev/dev-content-build.js +1 -0
  7. package/dist/bundler/dev/dev-problems.js +1 -1
  8. package/dist/bundler/dev/dev-reporter.js +1 -1
  9. package/dist/bundler/dev/routes/dev-content-build-route.js +1 -0
  10. package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
  11. package/dist/bundler/dev/run.js +1 -1
  12. package/dist/bundler/dev/runtime-app.js +1 -1
  13. package/dist/bundler/dev/vite-config.js +1 -1
  14. package/dist/bundler/node-bundle.js +1 -0
  15. package/dist/bundler/runtime-files.js +1 -1
  16. package/dist/bundler/user-markdoc-schema.js +1 -1
  17. package/dist/bundler/vite-config.base.js +12 -12
  18. package/dist/cli/api-docs-build-event.js +1 -0
  19. package/dist/cli/commands/build.js +1 -1
  20. package/dist/cli/commands/ingest.js +1 -1
  21. package/dist/cli/commands/translate.js +1 -1
  22. package/dist/cli/dev-console/{sweep.js → content-build.js} +1 -1
  23. package/dist/cli/dev-console/index.js +1 -1
  24. package/dist/cli/dev-console/lines.js +2 -2
  25. package/dist/cli/dev-console/plain.js +1 -1
  26. package/dist/cli/dev-console/tui.js +2 -2
  27. package/dist/cli/output.js +12 -12
  28. package/dist/cli/validate-react-pages.js +1 -1
  29. package/dist/client/ApiAccess.js +3 -0
  30. package/dist/client/NavigationProgress.js +1 -1
  31. package/dist/client/ProductsProvider.js +1 -1
  32. package/dist/client/RouteErrorBoundary.js +1 -1
  33. package/dist/client/RuntimeLink.js +1 -0
  34. package/dist/client/ThemeGlobalStyle.js +1 -0
  35. package/dist/client/UnversionedVersionButton.js +1 -1
  36. package/dist/client/app.js +2 -7
  37. package/dist/client/client-entry.js +1 -1
  38. package/dist/client/dev-problems/ProblemsBar.js +75 -15
  39. package/dist/client/dev-problems/ProblemsModal.js +15 -15
  40. package/dist/client/dev-problems/build-segment.js +1 -0
  41. package/dist/client/dev-problems/index.js +1 -1
  42. package/dist/client/dev-problems/use-dev-problems.js +1 -1
  43. package/dist/client/experiments/runtime.js +1 -1
  44. package/dist/client/history-mount.js +1 -0
  45. package/dist/client/l10n/use-l10n-config.js +1 -1
  46. package/dist/client/l10n/use-l10n-href.js +1 -1
  47. package/dist/client/l10n/use-translate.js +1 -1
  48. package/dist/client/products.js +1 -1
  49. package/dist/client/review/ReviewBar.js +163 -69
  50. package/dist/client/review/login-url.js +1 -0
  51. package/dist/client/revisions-history.js +1 -1
  52. package/dist/client/sidebar/PoweredByRedocly.js +2 -2
  53. package/dist/client/ssr.js +1 -1
  54. package/dist/client/telemetry/report-preload-failure.js +1 -0
  55. package/dist/client/templates/dev-login.js +4 -4
  56. package/dist/client/templates/unauthorized.js +5 -5
  57. package/dist/client/theme-global-css.js +1 -0
  58. package/dist/client/use-banner.js +1 -1
  59. package/dist/client/use-bar-position.js +1 -0
  60. package/dist/client/use-page-versions.js +1 -1
  61. package/dist/client/use-router-for-local-links.js +1 -1
  62. package/dist/client/use-search.js +1 -1
  63. package/dist/client/utils/routes/is-router-path.js +1 -0
  64. package/dist/client/webmcp/tools/shared.js +1 -1
  65. package/dist/content-layer/allowed-packages.js +1 -1
  66. package/dist/content-layer/api-outputs.js +1 -1
  67. package/dist/content-layer/config-schema.d.ts +12 -3
  68. package/dist/content-layer/config-schema.js +1 -1
  69. package/dist/content-layer/config.d.ts +30 -12
  70. package/dist/content-layer/config.js +1 -1
  71. package/dist/content-layer/context.d.ts +2 -0
  72. package/dist/content-layer/context.js +1 -1
  73. package/dist/content-layer/database/adapters/node-sqlite-client.js +1 -1
  74. package/dist/content-layer/database/assets.js +1 -1
  75. package/dist/content-layer/database/blobs.js +1 -1
  76. package/dist/content-layer/database/connection.js +1 -1
  77. package/dist/content-layer/database/entity-store.d.ts +24 -3
  78. package/dist/content-layer/database/entity-store.js +1 -1
  79. package/dist/content-layer/database/files.js +1 -1
  80. package/dist/content-layer/database/finalize.js +1 -1
  81. package/dist/content-layer/database/invalidation.d.ts +6 -0
  82. package/dist/content-layer/database/invalidation.js +26 -26
  83. package/dist/content-layer/database/link-refs.js +1 -1
  84. package/dist/content-layer/database/origins.d.ts +2 -4
  85. package/dist/content-layer/database/origins.js +1 -1
  86. package/dist/content-layer/database/problems.d.ts +2 -0
  87. package/dist/content-layer/database/problems.js +1 -1
  88. package/dist/content-layer/database/reset.js +1 -1
  89. package/dist/content-layer/database/route-query-deps.js +1 -1
  90. package/dist/content-layer/database/schema.d.ts +50 -0
  91. package/dist/content-layer/database/schema.js +1 -1
  92. package/dist/content-layer/database/search-vocab.js +2 -2
  93. package/dist/content-layer/database/site-config.d.ts +23 -0
  94. package/dist/content-layer/database/site-config.js +1 -1
  95. package/dist/content-layer/database/static-files.js +1 -1
  96. package/dist/content-layer/ingest/extract-all-phase.js +1 -1
  97. package/dist/content-layer/ingest/finalize-phase.js +1 -1
  98. package/dist/content-layer/ingest/git-last-modified.js +3 -3
  99. package/dist/content-layer/ingest/hash.js +1 -1
  100. package/dist/content-layer/ingest/hook-inputs.js +1 -1
  101. package/dist/content-layer/ingest/l10n-warnings.js +1 -1
  102. package/dist/content-layer/ingest/markdoc-schema-problem.js +1 -0
  103. package/dist/content-layer/ingest/rbac-teams.js +1 -1
  104. package/dist/content-layer/ingest/run.js +1 -1
  105. package/dist/content-layer/ingest/scan.d.ts +1 -1
  106. package/dist/content-layer/ingest/scan.js +1 -1
  107. package/dist/content-layer/ingest/search-sync.js +1 -1
  108. package/dist/content-layer/ingest/slugger/resolve-final-slugs.js +1 -1
  109. package/dist/content-layer/ingest/sync.js +1 -1
  110. package/dist/content-layer/link-checker/delta.js +1 -1
  111. package/dist/content-layer/link-checker/fingerprint.js +1 -1
  112. package/dist/content-layer/link-checker/load-view.js +1 -1
  113. package/dist/content-layer/link-checker/run-build.js +1 -1
  114. package/dist/content-layer/link-checker/validate.js +1 -1
  115. package/dist/content-layer/link-checker/view.js +1 -1
  116. package/dist/content-layer/loaders/context.js +1 -1
  117. package/dist/content-layer/loaders/define.d.ts +3 -0
  118. package/dist/content-layer/markdown/client/JsonSchemaTag.js +1 -1
  119. package/dist/content-layer/markdown/client/OpenapiTagComponents.js +2 -2
  120. package/dist/content-layer/markdown/client/code-highlight-notation.js +3 -3
  121. package/dist/content-layer/markdown/client/dynamic-components.js +1 -1
  122. package/dist/content-layer/markdown/client/markdoc-components.js +2 -2
  123. package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
  124. package/dist/content-layer/markdown/constants/markdown-text-tag-set.js +1 -1
  125. package/dist/content-layer/markdown/constants/tag-sets.d.ts +20 -5
  126. package/dist/content-layer/markdown/constants/tag-sets.js +1 -1
  127. package/dist/content-layer/markdown/nodes/fence.js +1 -1
  128. package/dist/content-layer/markdown/nodes/heading.js +1 -1
  129. package/dist/content-layer/markdown/nodes/table.js +1 -1
  130. package/dist/content-layer/markdown/resolve/ast.js +1 -1
  131. package/dist/content-layer/markdown/resolve/attribute-resolver-key.d.ts +8 -1
  132. package/dist/content-layer/markdown/resolve/attribute-resolver-key.js +1 -1
  133. package/dist/content-layer/markdown/resolve/audience-tag.d.ts +2 -6
  134. package/dist/content-layer/markdown/resolve/audience-tag.js +1 -1
  135. package/dist/content-layer/markdown/resolve/markdoc-resolvers/code-snippet.js +5 -4
  136. package/dist/content-layer/markdown/resolve/markdoc-resolvers/code-walkthrough/filesets.js +1 -1
  137. package/dist/content-layer/markdown/resolve/markdoc-resolvers/diagram-file.js +1 -1
  138. package/dist/content-layer/markdown/resolve/markdoc-resolvers/file-reference.js +1 -1
  139. package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.d.ts +2 -1
  140. package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.js +1 -1
  141. package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.d.ts +1 -1
  142. package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
  143. package/dist/content-layer/markdown/resolve/markdoc-resolvers/partial.js +1 -1
  144. package/dist/content-layer/markdown/resolve/markdoc-resolvers/svg-content.js +1 -1
  145. package/dist/content-layer/markdown/resolve/markdoc.d.ts +2 -1
  146. package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
  147. package/dist/content-layer/markdown/resolve/raw-partials.d.ts +2 -1
  148. package/dist/content-layer/markdown/resolve/raw-partials.js +1 -1
  149. package/dist/content-layer/markdown/resolve/references.d.ts +3 -1
  150. package/dist/content-layer/markdown/resolve/references.js +1 -1
  151. package/dist/content-layer/markdown/resolve/render-diagrams.d.ts +8 -1
  152. package/dist/content-layer/markdown/resolve/render-diagrams.js +1 -1
  153. package/dist/content-layer/markdown/search/to-markdown.js +2 -2
  154. package/dist/content-layer/markdown/search/to-sections.d.ts +8 -3
  155. package/dist/content-layer/markdown/search/to-sections.js +1 -1
  156. package/dist/content-layer/markdown/search/to-text.d.ts +4 -1
  157. package/dist/content-layer/markdown/search/to-text.js +5 -5
  158. package/dist/content-layer/markdown/server/render.d.ts +4 -2
  159. package/dist/content-layer/markdown/server/render.js +1 -1
  160. package/dist/content-layer/markdown/service.js +1 -1
  161. package/dist/content-layer/markdown/tags/html.d.ts +5 -2
  162. package/dist/content-layer/markdown/tags/html.js +1 -1
  163. package/dist/content-layer/markdown/tags/markdoc-error.d.ts +8 -0
  164. package/dist/content-layer/markdown/tags/markdoc-error.js +1 -1
  165. package/dist/content-layer/markdown/tags/openapi.d.ts +1 -1
  166. package/dist/content-layer/markdown/tags/openapi.js +1 -1
  167. package/dist/content-layer/markdown/tags/partial.d.ts +9 -3
  168. package/dist/content-layer/markdown/tags/partial.js +1 -1
  169. package/dist/content-layer/markdown/tags/variant.d.ts +6 -0
  170. package/dist/content-layer/markdown/tags/variant.js +1 -0
  171. package/dist/content-layer/markdown/types/service.d.ts +6 -0
  172. package/dist/content-layer/markdown/utils/collect-anchors.js +1 -1
  173. package/dist/content-layer/markdown/utils/collect-headings.d.ts +3 -1
  174. package/dist/content-layer/markdown/utils/collect-headings.js +1 -1
  175. package/dist/content-layer/markdown/utils/first-heading.js +1 -1
  176. package/dist/content-layer/markdown/utils/heading-slugger.d.ts +8 -0
  177. package/dist/content-layer/markdown/utils/heading-slugger.js +1 -1
  178. package/dist/content-layer/markdown/utils/node-source-range.d.ts +3 -3
  179. package/dist/content-layer/markdown/utils/node-source-range.js +1 -1
  180. package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
  181. package/dist/content-layer/markdown/utils/reparse-example-fences.d.ts +4 -1
  182. package/dist/content-layer/markdown/utils/reparse-example-fences.js +1 -1
  183. package/dist/content-layer/markdown/utils/substitute-variables.js +1 -1
  184. package/dist/content-layer/markdown/utils/walk-markdoc-ast.d.ts +2 -2
  185. package/dist/content-layer/markdown/utils/walk-markdoc-ast.js +1 -1
  186. package/dist/content-layer/materialization/asset-reconcile.js +1 -1
  187. package/dist/content-layer/materialization/entity.js +1 -1
  188. package/dist/content-layer/materialization/materializer.js +1 -0
  189. package/dist/content-layer/materialization/static-files.js +1 -1
  190. package/dist/content-layer/plan-gates.d.ts +3 -2
  191. package/dist/content-layer/plan-gates.js +1 -1
  192. package/dist/content-layer/plugins/execute.js +1 -1
  193. package/dist/content-layer/plugins/index.js +1 -1
  194. package/dist/content-layer/plugins/internal/api-docs/client/event-handlers.js +1 -1
  195. package/dist/content-layer/plugins/internal/api-docs/client/rebase-item-links.js +1 -1
  196. package/dist/content-layer/plugins/internal/api-docs/client/template.js +12 -4
  197. package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
  198. package/dist/content-layer/plugins/internal/api-docs/server/build-definition.d.ts +28 -13
  199. package/dist/content-layer/plugins/internal/api-docs/server/build-definition.js +1 -1
  200. package/dist/content-layer/plugins/internal/api-docs/server/build-sidebar.js +1 -1
  201. package/dist/content-layer/plugins/internal/api-docs/server/declares-proto-service.d.ts +2 -0
  202. package/dist/content-layer/plugins/internal/api-docs/server/declares-proto-service.js +3 -0
  203. package/dist/content-layer/plugins/internal/api-docs/server/markdown-copy.d.ts +14 -0
  204. package/dist/content-layer/plugins/internal/api-docs/server/markdown-copy.js +23 -0
  205. package/dist/content-layer/plugins/internal/api-docs/server/markdown-decorator.d.ts +1 -4
  206. package/dist/content-layer/plugins/internal/api-docs/server/markdown-decorator.js +1 -1
  207. package/dist/content-layer/plugins/internal/api-docs/server/options.d.ts +4 -2
  208. package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
  209. package/dist/content-layer/plugins/internal/api-docs/server/search-documents.d.ts +1 -1
  210. package/dist/content-layer/plugins/internal/api-docs/server/search-documents.js +1 -1
  211. package/dist/content-layer/plugins/internal/api-docs/server/spec-download.js +1 -1
  212. package/dist/content-layer/plugins/internal/api-functions/index.js +1 -1
  213. package/dist/content-layer/plugins/internal/api-functions/server/access.js +1 -1
  214. package/dist/content-layer/plugins/internal/api-functions/server/api-function-telemetry.js +1 -0
  215. package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
  216. package/dist/content-layer/plugins/internal/app-data/banner.js +1 -1
  217. package/dist/content-layer/plugins/internal/app-data/index.d.ts +1 -1
  218. package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
  219. package/dist/content-layer/plugins/internal/app-data/products.d.ts +2 -0
  220. package/dist/content-layer/plugins/internal/app-data/products.js +1 -1
  221. package/dist/content-layer/plugins/internal/catalog-classic/client/catalog-filtering.js +1 -1
  222. package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
  223. package/dist/content-layer/plugins/internal/catalog-classic/resolve-items.d.ts +1 -1
  224. package/dist/content-layer/plugins/internal/catalog-classic/resolve-items.js +1 -1
  225. package/dist/content-layer/plugins/internal/catalog-classic/sidebars.d.ts +1 -1
  226. package/dist/content-layer/plugins/internal/index.js +1 -1
  227. package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
  228. package/dist/content-layer/plugins/internal/l10n/translations-loader.js +1 -1
  229. package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
  230. package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
  231. package/dist/content-layer/plugins/internal/markdoc/server/shared.d.ts +1 -1
  232. package/dist/content-layer/plugins/internal/mcp/constants.d.ts +20 -0
  233. package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
  234. package/dist/content-layer/plugins/internal/mcp/content-tools.d.ts +4 -1
  235. package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
  236. package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
  237. package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
  238. package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
  239. package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
  240. package/dist/content-layer/plugins/internal/mcp/server/code-credentials.js +2 -2
  241. package/dist/content-layer/plugins/internal/mcp/server/codemode/capabilities.js +6 -6
  242. package/dist/content-layer/plugins/internal/mcp/server/codemode/constants.js +1 -1
  243. package/dist/content-layer/plugins/internal/mcp/server/codemode/discover.js +1 -1
  244. package/dist/content-layer/plugins/internal/mcp/server/codemode/execute-schema.js +1 -1
  245. package/dist/content-layer/plugins/internal/mcp/server/codemode/index.js +1 -1
  246. package/dist/content-layer/plugins/internal/mcp/server/codemode/prompts.js +8 -8
  247. package/dist/content-layer/plugins/internal/mcp/server/config-gate.js +1 -1
  248. package/dist/content-layer/plugins/internal/mcp/server/custom-tools.js +1 -1
  249. package/dist/content-layer/plugins/internal/mcp/server/gateway/allowed-http-methods.js +1 -1
  250. package/dist/content-layer/plugins/internal/mcp/server/gateway/api-call-operations.js +1 -1
  251. package/dist/content-layer/plugins/internal/mcp/server/gateway/call-api.js +2 -0
  252. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +10 -10
  253. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/outcome-pages.js +1 -1
  254. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
  255. package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +7 -6
  256. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/allowed-hosts.js +1 -1
  257. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-bridge.js +1 -1
  258. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-errors.js +1 -1
  259. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/ssrf-guard.js +1 -1
  260. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/upstream-detail.js +1 -1
  261. package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
  262. package/dist/content-layer/plugins/internal/mcp/server/gateway/secret-store.js +1 -1
  263. package/dist/content-layer/plugins/internal/mcp/server/gateway/tool-list.js +1 -0
  264. package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +4 -4
  265. package/dist/content-layer/plugins/internal/mcp/server/gateway/upstream-auth-scheme.js +2 -2
  266. package/dist/content-layer/plugins/internal/mcp/server/handler.js +1 -1
  267. package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
  268. package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.js +1 -1
  269. package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
  270. package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
  271. package/dist/content-layer/plugins/internal/mcp/server/rate-limit.js +1 -1
  272. package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
  273. package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
  274. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-catalog.js +1 -1
  275. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-catalog.js +1 -1
  276. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-document.js +1 -1
  277. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-refs.js +1 -1
  278. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi.js +1 -1
  279. package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
  280. package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +2 -2
  281. package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -1
  282. package/dist/content-layer/plugins/internal/mcp/server/workflows/catalog.js +1 -0
  283. package/dist/content-layer/plugins/internal/mcp/server/workflows/document-resolver.js +1 -0
  284. package/dist/content-layer/plugins/internal/mcp/server/workflows/operations-subset.js +1 -0
  285. package/dist/content-layer/plugins/internal/mcp/server/workflows/resolve-workflows.js +1 -0
  286. package/dist/content-layer/plugins/internal/mcp/server/workflows/run-workflow.js +1 -0
  287. package/dist/content-layer/plugins/internal/mcp/server/workflows/schemas.js +1 -0
  288. package/dist/content-layer/plugins/internal/mcp/server/workflows/tools.js +1 -0
  289. package/dist/content-layer/plugins/internal/mcp/server/workflows/types.js +1 -0
  290. package/dist/content-layer/plugins/internal/mcp/server/workflows/workflow-references.js +1 -0
  291. package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
  292. package/dist/content-layer/plugins/internal/react-page/index.d.ts +3 -2
  293. package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
  294. package/dist/content-layer/plugins/internal/scorecard-classic/client/Grid.js +11 -11
  295. package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardViews.js +1 -1
  296. package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardWidgets.js +7 -7
  297. package/dist/content-layer/plugins/internal/scorecard-classic/client/template.js +2 -2
  298. package/dist/content-layer/plugins/internal/sidebar/bundle.d.ts +18 -17
  299. package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
  300. package/dist/content-layer/plugins/internal/sidebar/index.d.ts +5 -3
  301. package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
  302. package/dist/content-layer/plugins/internal/sidebar/subtree.js +1 -1
  303. package/dist/content-layer/plugins/internal/skills/index.js +1 -1
  304. package/dist/content-layer/plugins/internal/skills/server/routes.js +1 -1
  305. package/dist/content-layer/plugins/internal/versions/index.js +1 -1
  306. package/dist/content-layer/plugins/project/load.js +2 -2
  307. package/dist/content-layer/plugins/registry.js +1 -1
  308. package/dist/content-layer/plugins/request-context.d.ts +5 -0
  309. package/dist/content-layer/plugins/types/api-entity.d.ts +2 -6
  310. package/dist/content-layer/plugins/types/api-entity.js +1 -1
  311. package/dist/content-layer/plugins/types/markdoc.d.ts +2 -0
  312. package/dist/content-layer/plugins/types/plugin.d.ts +13 -0
  313. package/dist/content-layer/plugins/types/search.d.ts +14 -3
  314. package/dist/content-layer/plugins/utils/link-access.d.ts +2 -0
  315. package/dist/content-layer/plugins/utils/link-access.js +1 -1
  316. package/dist/content-layer/plugins/utils/route-index.d.ts +1 -1
  317. package/dist/content-layer/plugins/utils/route-index.js +1 -1
  318. package/dist/content-layer/plugins/utils/sidebar-label.d.ts +4 -1
  319. package/dist/content-layer/plugins/utils/sidebar-label.js +1 -1
  320. package/dist/content-layer/plugins/utils/version-path.js +1 -1
  321. package/dist/content-layer/plugins/work-time.js +1 -0
  322. package/dist/content-layer/problems/codes.d.ts +10 -0
  323. package/dist/content-layer/problems/codes.js +1 -1
  324. package/dist/content-layer/revisions/config.js +1 -1
  325. package/dist/content-layer/revisions/delete.js +1 -1
  326. package/dist/content-layer/search/engine/core/content-parser.js +1 -1
  327. package/dist/content-layer/search/engine/core/search-engine.js +1 -1
  328. package/dist/content-layer/search/facet-rows.js +1 -1
  329. package/dist/content-layer/search/keywords.d.ts +18 -0
  330. package/dist/content-layer/search/keywords.js +1 -0
  331. package/dist/content-layer/search/postings/fragment-field.d.ts +2 -0
  332. package/dist/content-layer/search/postings/fragment-field.js +1 -1
  333. package/dist/content-layer/search/postings/postings-store.d.ts +14 -0
  334. package/dist/content-layer/search/postings/postings-store.js +1 -1
  335. package/dist/content-layer/search/store.d.ts +14 -1
  336. package/dist/content-layer/server/context.js +1 -1
  337. package/dist/content-layer/server/database.js +1 -1
  338. package/dist/content-layer/server/materialize.js +1 -1
  339. package/dist/content-layer/static/audience.js +1 -1
  340. package/dist/content-layer/static/registry.js +1 -1
  341. package/dist/content-layer/templates/template-set.js +1 -1
  342. package/dist/content-layer/versions/group-info.d.ts +21 -0
  343. package/dist/content-layer/versions/group-info.js +1 -0
  344. package/dist/content-layer/versions/redirect.d.ts +24 -17
  345. package/dist/content-layer/versions/redirect.js +1 -1
  346. package/dist/content-layer/versions/resolve.d.ts +1 -21
  347. package/dist/content-layer/versions/resolve.js +1 -1
  348. package/dist/content-layer/versions/version-groups.d.ts +5 -1
  349. package/dist/content-layer/versions/version-groups.js +1 -1
  350. package/dist/plugin-api.d.ts +3 -0
  351. package/dist/plugin-api.js +1 -1
  352. package/dist/server/analytics-tags.js +1 -1
  353. package/dist/server/app.js +3 -3
  354. package/dist/server/ask-ai/feature-gate.js +1 -1
  355. package/dist/server/ask-ai/route.js +1 -1
  356. package/dist/server/auth/access-config.js +1 -1
  357. package/dist/server/auth/gate.js +1 -1
  358. package/dist/server/auth/middleware.js +1 -1
  359. package/dist/server/auth/oidc.js +1 -1
  360. package/dist/server/auth/request.js +1 -1
  361. package/dist/server/auth/routes.js +1 -1
  362. package/dist/server/auth/runtime.js +1 -1
  363. package/dist/server/content-assets/access.js +1 -1
  364. package/dist/server/content.js +14 -13
  365. package/dist/server/feedback/route.js +1 -1
  366. package/dist/server/html-tags.js +2 -1
  367. package/dist/server/lambda-entry.js +1 -1
  368. package/dist/server/llms-txt.js +1 -1
  369. package/dist/server/manifest-assets.js +2 -2
  370. package/dist/server/metrics/request-metrics.js +1 -1
  371. package/dist/server/node-entry.js +1 -1
  372. package/dist/server/page-handlers.js +1 -1
  373. package/dist/server/plugin-context.js +1 -1
  374. package/dist/server/plugin-routes.js +1 -1
  375. package/dist/server/public-url.js +1 -0
  376. package/dist/server/rbac/content-asset-access.js +1 -1
  377. package/dist/server/redirects.js +1 -1
  378. package/dist/server/replay-oauth2/route.js +1 -1
  379. package/dist/server/review/route.js +1 -1
  380. package/dist/server/runtime-config.js +1 -1
  381. package/dist/server/search/cache.js +1 -0
  382. package/dist/server/search/route.js +1 -1
  383. package/dist/server/search/search-telemetry.js +1 -0
  384. package/dist/server/seo-tags.js +2 -2
  385. package/dist/server/ssrf/ssrf-blocklist.js +1 -1
  386. package/dist/server/static-files/serve.js +1 -1
  387. package/dist/server/subprocess/runner.js +1 -1
  388. package/dist/server/telemetry/mock-server-events.js +1 -0
  389. package/dist/server/telemetry/redirect-event.js +1 -0
  390. package/dist/server/telemetry/route.js +1 -1
  391. package/dist/server/telemetry/sender.js +1 -1
  392. package/dist/server/telemetry/server-events.js +1 -1
  393. package/dist/server/template-ids.js +1 -1
  394. package/dist/shared/constants/api-spec-kinds.d.ts +7 -0
  395. package/dist/shared/constants/api-spec-kinds.js +1 -0
  396. package/dist/shared/constants/content-update.js +1 -1
  397. package/dist/shared/constants/dependency-pack.js +1 -1
  398. package/dist/shared/constants/dev-content-build.js +1 -0
  399. package/dist/shared/constants/dev-problems.js +1 -1
  400. package/dist/shared/constants/dev-source-sync.js +1 -1
  401. package/dist/shared/constants/l10n/langs/ar.js +1 -1
  402. package/dist/shared/constants/l10n/langs/de.js +1 -1
  403. package/dist/shared/constants/l10n/langs/en.js +1 -1
  404. package/dist/shared/constants/l10n/langs/es.js +1 -1
  405. package/dist/shared/constants/l10n/langs/fr.js +1 -1
  406. package/dist/shared/constants/l10n/langs/hi.js +1 -1
  407. package/dist/shared/constants/l10n/langs/it.js +1 -1
  408. package/dist/shared/constants/l10n/langs/ja.js +1 -1
  409. package/dist/shared/constants/l10n/langs/ko.js +1 -1
  410. package/dist/shared/constants/l10n/langs/pl.js +1 -1
  411. package/dist/shared/constants/l10n/langs/pt-br.js +1 -1
  412. package/dist/shared/constants/l10n/langs/pt.js +1 -1
  413. package/dist/shared/constants/l10n/langs/ru.js +1 -1
  414. package/dist/shared/constants/l10n/langs/uk.js +1 -1
  415. package/dist/shared/constants/l10n/langs/zh.js +1 -1
  416. package/dist/shared/constants/manifest-version.d.ts +3 -1
  417. package/dist/shared/constants/openapi-operation-methods.d.ts +2 -0
  418. package/dist/shared/constants/openapi-operation-methods.js +1 -0
  419. package/dist/shared/constants/review.d.ts +5 -0
  420. package/dist/shared/constants/review.js +1 -1
  421. package/dist/{server → shared}/constants/system-routes.d.ts +1 -1
  422. package/dist/shared/constants/system-routes.js +1 -0
  423. package/dist/shared/constants/versions.d.ts +2 -0
  424. package/dist/shared/constants/versions.js +1 -1
  425. package/dist/shared/experiments.js +1 -1
  426. package/dist/shared/load-dot-env.js +1 -1
  427. package/dist/shared/plan-gates.d.ts +9 -3
  428. package/dist/shared/plan-gates.js +1 -1
  429. package/dist/shared/products.js +1 -1
  430. package/dist/shared/project-env.d.ts +12 -0
  431. package/dist/shared/project-env.js +1 -0
  432. package/dist/shared/public-env.d.ts +9 -0
  433. package/dist/shared/public-env.js +1 -1
  434. package/dist/{server → shared}/rbac/api-docs.d.ts +3 -2
  435. package/dist/shared/rbac/api-docs.js +1 -0
  436. package/dist/{server → shared}/rbac/engine.d.ts +13 -10
  437. package/dist/shared/rbac/engine.js +0 -0
  438. package/dist/{server → shared}/rbac/filter.d.ts +2 -0
  439. package/dist/shared/rbac/filter.js +1 -0
  440. package/dist/{server → shared}/rbac/l10n-rules.d.ts +1 -1
  441. package/dist/shared/rbac/l10n-rules.js +1 -0
  442. package/dist/{server → shared}/rbac/route-scope.d.ts +1 -1
  443. package/dist/shared/rbac/route-scope.js +1 -0
  444. package/dist/{server → shared}/rbac/team-templates.d.ts +6 -2
  445. package/dist/shared/rbac/team-templates.js +1 -0
  446. package/dist/{server → shared}/rbac/teams.d.ts +1 -1
  447. package/dist/shared/rbac/types.js +1 -0
  448. package/dist/shared/search/facets.d.ts +5 -0
  449. package/dist/shared/search/facets.js +1 -1
  450. package/dist/shared/types/auth.d.ts +1 -0
  451. package/dist/shared/types/config.d.ts +5 -0
  452. package/dist/shared/types/search.d.ts +8 -2
  453. package/dist/shared/types/sidebar.d.ts +1 -0
  454. package/dist/shared/utils/l10n.js +1 -1
  455. package/dist/shared/utils/redirect-match.js +1 -0
  456. package/dist/shared/utils/routes/markdown-copy-url.js +1 -0
  457. package/drizzle/20261103061150_site_config_effective_hash/migration.sql +1 -0
  458. package/drizzle/20261105151816_search_http_path_tokens/migration.sql +1 -0
  459. package/drizzle/20261111152552_page_markdown_rbac_scope/migration.sql +1 -0
  460. package/package.json +37 -13
  461. package/dist/bundler/dev/__tests__/reset-content-update-state.js +0 -1
  462. package/dist/bundler/dev/materialization-sweeper.js +0 -1
  463. package/dist/client/dev-problems/sweep-segment.js +0 -1
  464. package/dist/client/review/use-bar-position.js +0 -1
  465. package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.d.ts +0 -5
  466. package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.js +0 -26
  467. package/dist/content-layer/plugins/internal/mcp/server/gateway/__tests__/fake-kv.js +0 -1
  468. package/dist/content-layer/server/config.js +0 -1
  469. package/dist/server/__tests__/rbac-fixture.js +0 -1
  470. package/dist/server/__tests__/test-session.js +0 -1
  471. package/dist/server/constants/system-routes.js +0 -1
  472. package/dist/server/rbac/api-docs.js +0 -1
  473. package/dist/server/rbac/engine.js +0 -0
  474. package/dist/server/rbac/filter.js +0 -1
  475. package/dist/server/rbac/l10n-rules.js +0 -1
  476. package/dist/server/rbac/route-scope.js +0 -1
  477. package/dist/server/rbac/team-templates.js +0 -1
  478. package/dist/server/rbac/types.js +0 -1
  479. package/dist/shared/utils/routes/markdown-path.js +0 -1
  480. /package/dist/{server → shared}/rbac/entity-scope.js +0 -0
  481. /package/dist/{server → shared}/rbac/teams.js +0 -0
  482. /package/dist/{server → shared}/rbac/types.d.ts +0 -0
  483. /package/dist/{content-layer/markdown → shared}/utils/packed-ast.d.ts +0 -0
  484. /package/dist/{content-layer/markdown → shared}/utils/packed-ast.js +0 -0
@@ -1,4 +1,4 @@
1
- import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as e,MANAGE_API_CREDENTIALS_TOOL_NAME as t,REMOVE_API_CREDENTIALS_TOOL_NAME as n}from"../../constants.js";import{publicOrigin as r}from"../../../../utils/request-origin.js";import{isToolDisabledByCaller as i}from"../disabled-tools.js";import{createSessionHandle as a,resolveSecretSubject as o}from"./subject.js";import{toolNameForMode as s}from"../codemode/tool-declarations.js";import{READ_ONLY_ANNOTATIONS as c}from"../tools/schemas.js";import{apiTitleKey as l,countApiTitles as u}from"../tools/api-titles.js";import{callableApis as d}from"./eligibility.js";import{secretStore as f}from"./secret-store.js";import{resolveUpstreamApiAuth as p}from"./upstream-auth-scheme.js";import{acceptedCredentialsLink as m,buildCredentialsAcceptedHint as h,buildUpstreamCredentialFallback as g,buildUpstreamCredentialInputRequired as _,credentialElicitationAnswer as v,dedupeElicitation as y,isStatelessRequest as b,schemeLabelOf as x,supportsUrlElicitation as S}from"./elicitation.js";import{upstreamAuthKey as C}from"./upstream-auth.js";async function w(e){return(await d(e)).length>0}const T={schema:{name:e,title:`Create anonymous session`,description:`Create an anonymous session handle for storing upstream API credentials. Pass the returned sessionHandle to execute when an API needs credentials and the caller is not signed in. Treat it as a secret and reuse it across calls.`,schema:{type:`object`,required:[],additionalProperties:!1,properties:{}},annotations:c,outputSchema:{type:`object`,required:[`sessionHandle`],properties:{sessionHandle:{type:`string`}}}},isAvailable:async e=>!e.request.viewer?.isAuthenticated&&!i(`createAnonymousSession`,e.metadata)&&await w(e),execute:async()=>{let e={sessionHandle:a()};return{content:[{type:`text`,text:JSON.stringify(e)}],structuredContent:e}}};function E(e,t,n){let r=e.map(e=>e.relativePath),i=[...r,...k(e)],a={type:`string`,description:`${n}: its \`filePath\` or the \`name\` from \`${s(`list-apis`,t)}\`.${r.length>0?` The file paths are: ${r.join(`, `)}.`:``}`,minLength:1};return i.length>0&&(a.enum=i),a}const D={type:`string`,description:`Handle returned by createAnonymousSession. Required while the caller is anonymous, so the credentials are stored against the same subject the API calls use.`,minLength:1};function O(e,r,i){return{name:t,title:`Manage API credentials`,description:[i?`Get a secure link where the user sets or replaces the credentials this server sends to a documented API.`:`Get a secure link where the user sets, replaces, or removes the credentials this server sends to a documented API.`,i?`Call it when the user wants to change an API key, or when a tool result tells you the stored credentials were rejected. To remove stored credentials, call \`${n}\` instead.`:`Call it when the user wants to change or clear an API key, or when a tool result tells you the stored credentials were rejected.`,`The link covers every credential the API accepts, so scheme is optional - pass it only when a tool result names the scheme that was rejected.`,`It returns a link for the user to open - never ask for the secret in the conversation and never pass it as an argument.`].join(`
2
- `),annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},schema:{type:`object`,required:[`api`],additionalProperties:!1,properties:{api:E(e,r,`The API to manage credentials for`),scheme:{type:`string`,description:`Name of the security scheme to manage the credential for, as named in the API description (a tool result that reports a rejected credential names it). Omit it to let the link cover every scheme the API accepts.`,minLength:1},sessionHandle:D}}}}function k(e){let t=u(e);return e.map(e=>e.name).filter(e=>t.get(l(e))===1)}function A(e,t){let n=e.find(e=>e.relativePath===t||e.name===t);if(n)return{api:n};let r=e.map(e=>e.relativePath).join(`, `);return{error:N(`Unknown API "${typeof t==`string`?t:``}". Credentials can only be managed for the APIs this server can call: ${r||`none`}.`)}}function j(e,t,n){return N(`Unknown scheme "${e}" for api "${t.relativePath}". The security schemes this server can store credentials for are: ${n.join(`, `)}.`)}async function M(e,t,n){let i=o(t,e.sessionHandle);if(i.kind!==`resolved`)return N(i.message);let{subject:a}=i,s=A(await d(t),e.api);if(`error`in s)return s.error;let{api:c}=s,l=r(t.request),u=v(n?.mcpReq.inputResponses);if(u===`accepted`){let e=await m(n?.mcpReq.requestState(),{kv:t.kv,subject:a,baseUrl:l,apis:[c.relativePath]});return{content:[{type:`text`,text:h(c.name,{url:e?.url,canManageCredentials:!0})}],isError:!1}}if(u===`declined`)return{content:[{type:`text`,text:`The user declined the credentials prompt for the "${c.name}" API, so this call minted no link.`}],isError:!1};let w=p(c),T=typeof e.scheme==`string`?e.scheme:void 0,E=Object.keys(w.schemes);if(T&&!w.schemes[T])return j(T,c,E);let D=T??w.defaultScheme,O={subject:a,baseUrl:l,target:{api:c.relativePath,name:c.name,scheme:D,schemeLabel:T?x(w.schemes,T):void 0},auth:w.schemes[D],apiAuth:w,kv:t.kv,hasExistingSecret:await f.hasSecret(t.kv,a,c.relativePath,D),reason:{kind:`requested`}};if(n&&b(n.mcpReq)&&S(n.mcpReq))return _(O);let k=C({api:c.relativePath,scheme:D});return{content:[{type:`text`,text:await y(`${a}:${k}`,()=>g(O))}],isError:!1}}function N(e){return{content:[{type:`text`,text:e}],isError:!0}}const P={schema:O([],`tools`,!0),schemaFor:async e=>O(await d(e),e.mcpMode,!i(n,e.metadata)),isAvailable:async e=>!i(`manageApiCredentials`,e.metadata)&&await w(e),execute:(e,t,n)=>M(e,t,n)};function F(e,r,i){return{name:n,title:`Remove API credentials`,description:[`Delete the credentials this server stores for the caller and sends to documented APIs. The user opens no link.`,`Call it only when the user asks to remove, clear, or forget their credentials.${i?` To replace a credential, call \`${t}\` instead.`:``}`,`Pass api to remove the credentials of one API, and add scheme to remove only one of them. To remove the credentials of every API, pass all: true instead of api.`].join(`
3
- `),annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},schema:{type:`object`,required:[],additionalProperties:!1,properties:{api:E(e,r,`The API to remove credentials for`),scheme:{type:`string`,description:`Name of the security scheme to remove the credential for, as named in the API description. Needs api. Omit it to remove every credential of the API.`,minLength:1},all:{type:`boolean`,description:`Set to true, without api, to remove the credentials of every API. Use it only when the user asks to remove all their credentials.`},sessionHandle:D}}}}async function I(e,t){let n=o(t,e.sessionHandle);if(n.kind!==`resolved`)return N(n.message);let{subject:r}=n,i=await d(t),a=typeof e.scheme==`string`?e.scheme:void 0;if(e.api===void 0)return a===void 0?e.all===!0?L(await f.deleteSecrets(t.kv,r),i,`No credentials are stored for this caller, so nothing was removed.`):N(`Name the api to remove credentials for. To remove the credentials of every API, pass all: true instead.`):N(`Pass api together with scheme "${a}": a scheme belongs to one API.`);if(e.all===!0)return N(`Pass either api or all: true, not both.`);let s=A(i,e.api);if(`error`in s)return s.error;let{api:c}=s;if(a===void 0)return L(await f.deleteSecrets(t.kv,r,c.relativePath),i,`No credentials are stored for the "${c.name}" API, so nothing was removed.`);let l=Object.keys(p(c).schemes);if(!l.includes(a))return j(a,c,l);let u=`No credential is stored for the "${a}" scheme of the "${c.name}" API, so nothing was removed.`;return await f.hasSecret(t.kv,r,c.relativePath,a)?(await f.deleteSecret(t.kv,r,c.relativePath,a),L([{api:c.relativePath,scheme:a}],i,u)):L([],i,u)}function L(e,t,n){if(e.length===0)return{content:[{type:`text`,text:n}],isError:!1};let r=/* @__PURE__ */ new Map;for(let{api:t,scheme:n}of e)r.set(t,[...r.get(t)??[],n]);return{content:[{type:`text`,text:[`Removed the stored credentials:`,...[...r].map(([e,n])=>`- "${t.find(t=>t.relativePath===e)?.name??e}" (${e}): ${n.sort().join(`, `)}`),``,`This server no longer sends them. The next call that an API rejects with HTTP 401 asks the user for new credentials.`].join(`
4
- `)}],isError:!1}}const R={schema:F([],`tools`,!0),schemaFor:async e=>F(await d(e),e.mcpMode,!i(t,e.metadata)),isAvailable:async e=>!i(`removeApiCredentials`,e.metadata)&&await w(e),execute:(e,t)=>I(e,t)};export{T as createAnonymousSessionTool,P as manageApiCredentialsTool,R as removeApiCredentialsTool};
1
+ import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as e,MANAGE_API_CREDENTIALS_TOOL_NAME as t,READ_ONLY_ANNOTATIONS as n,REMOVE_API_CREDENTIALS_TOOL_NAME as r}from"../../constants.js";import{publicOrigin as i}from"../../../../utils/request-origin.js";import{isToolDisabledByCaller as a}from"../disabled-tools.js";import{createSessionHandle as o,resolveSecretSubject as s}from"./subject.js";import{toolNameForMode as c}from"../codemode/tool-declarations.js";import{apiTitleKey as l,countApiTitles as u}from"../tools/api-titles.js";import{callableApis as d}from"./eligibility.js";import{SecretStore as f}from"./secret-store.js";import{resolveUpstreamApiAuth as p}from"./upstream-auth-scheme.js";import{acceptedCredentialsLink as m,buildCredentialsAcceptedHint as h,buildUpstreamCredentialFallback as g,buildUpstreamCredentialInputRequired as _,credentialElicitationAnswer as v,dedupeElicitation as y,isStatelessRequest as b,schemeLabelOf as x,supportsUrlElicitation as S}from"./elicitation.js";import{upstreamAuthKey as C}from"./upstream-auth.js";async function w(e){return(await d(e)).length>0}const T={schema:{name:e,title:`Create anonymous session`,description:`Create an anonymous session handle for storing upstream API credentials. Pass the returned sessionHandle to execute when an API needs credentials and the caller is not signed in. Treat it as a secret and reuse it across calls.`,schema:{type:`object`,required:[],additionalProperties:!1,properties:{}},annotations:n,outputSchema:{type:`object`,required:[`sessionHandle`],properties:{sessionHandle:{type:`string`}}}},isAvailable:async e=>!e.request.viewer?.isAuthenticated&&!a(`createAnonymousSession`,e.metadata)&&await w(e),execute:async()=>{let e={sessionHandle:o()};return{content:[{type:`text`,text:JSON.stringify(e)}],structuredContent:e}}};function E(e,t,n){let r=e.map(e=>e.relativePath),i=[...r,...k(e)],a={type:`string`,description:`${n}: its \`filePath\` or the \`name\` from \`${c(`list-apis`,t)}\`.${r.length>0?` The file paths are: ${r.join(`, `)}.`:``}`,minLength:1};return i.length>0&&(a.enum=i),a}const D={type:`string`,description:`Handle returned by createAnonymousSession. Required while the caller is anonymous, so the credentials are stored against the same subject the API calls use.`,minLength:1};function O(e,n,i){return{name:t,title:`Manage API credentials`,description:[i?`Get a secure link where the user sets or replaces the credentials this server sends to a documented API.`:`Get a secure link where the user sets, replaces, or removes the credentials this server sends to a documented API.`,i?`Call it when the user wants to change an API key, or when a tool result tells you the stored credentials were rejected. To remove stored credentials, call \`${r}\` instead.`:`Call it when the user wants to change or clear an API key, or when a tool result tells you the stored credentials were rejected.`,`The link covers every credential the API accepts, so scheme is optional - pass it only when a tool result names the scheme that was rejected.`,`It returns a link for the user to open - never ask for the secret in the conversation and never pass it as an argument.`].join(`
2
+ `),annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},schema:{type:`object`,required:[`api`],additionalProperties:!1,properties:{api:E(e,n,`The API to manage credentials for`),scheme:{type:`string`,description:`Name of the security scheme to manage the credential for, as named in the API description (a tool result that reports a rejected credential names it). Omit it to let the link cover every scheme the API accepts.`,minLength:1},sessionHandle:D}}}}function k(e){let t=u(e);return e.map(e=>e.name).filter(e=>t.get(l(e))===1)}function A(e,t){let n=e.find(e=>e.relativePath===t||e.name===t);if(n)return{api:n};let r=e.map(e=>e.relativePath).join(`, `);return{error:N(`Unknown API "${typeof t==`string`?t:``}". Credentials can only be managed for the APIs this server can call: ${r||`none`}.`)}}function j(e,t,n){return N(`Unknown scheme "${e}" for api "${t.relativePath}". The security schemes this server can store credentials for are: ${n.join(`, `)}.`)}async function M(e,t,n){let r=new f(t.gatewaySecretSeed),a=s(t,e.sessionHandle);if(a.kind!==`resolved`)return N(a.message);let{subject:o}=a,c=A(await d(t),e.api);if(`error`in c)return c.error;let{api:l}=c,u=i(t.request),w=v(n?.mcpReq.inputResponses);if(w===`accepted`){let e=await m(n?.mcpReq.requestState(),{secretStore:r,kv:t.kv,subject:o,baseUrl:u,apis:[l.relativePath]});return{content:[{type:`text`,text:h(l.name,{url:e?.url,canManageCredentials:!0})}],isError:!1}}if(w===`declined`)return{content:[{type:`text`,text:`The user declined the credentials prompt for the "${l.name}" API, so this call minted no link.`}],isError:!1};let T=p(l),E=typeof e.scheme==`string`?e.scheme:void 0,D=Object.keys(T.schemes);if(E&&!T.schemes[E])return j(E,l,D);let O=E??T.defaultScheme,k={subject:o,baseUrl:u,target:{api:l.relativePath,name:l.name,scheme:O,schemeLabel:E?x(T.schemes,E):void 0},auth:T.schemes[O],apiAuth:T,secretStore:r,kv:t.kv,hasExistingSecret:await r.hasSecret(t.kv,o,l.relativePath,O),reason:{kind:`requested`}};if(n&&b(n.mcpReq)&&S(n.mcpReq))return _(k);let M=C({api:l.relativePath,scheme:O});return{content:[{type:`text`,text:await y(`${o}:${M}`,()=>g(k))}],isError:!1}}function N(e){return{content:[{type:`text`,text:e}],isError:!0}}const P={schema:O([],`tools`,!0),schemaFor:async e=>O(await d(e),e.mcpMode,!a(r,e.metadata)),isAvailable:async e=>!a(`manageApiCredentials`,e.metadata)&&await w(e),execute:(e,t,n)=>M(e,t,n?.serverContext)};function F(e,n,i){return{name:r,title:`Remove API credentials`,description:[`Delete the credentials this server stores for the caller and sends to documented APIs. The user opens no link.`,`Call it only when the user asks to remove, clear, or forget their credentials.${i?` To replace a credential, call \`${t}\` instead.`:``}`,`Pass api to remove the credentials of one API, and add scheme to remove only one of them. To remove the credentials of every API, pass all: true instead of api.`].join(`
3
+ `),annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},schema:{type:`object`,required:[],additionalProperties:!1,properties:{api:E(e,n,`The API to remove credentials for`),scheme:{type:`string`,description:`Name of the security scheme to remove the credential for, as named in the API description. Needs api. Omit it to remove every credential of the API.`,minLength:1},all:{type:`boolean`,description:`Set to true, without api, to remove the credentials of every API. Use it only when the user asks to remove all their credentials.`},sessionHandle:D}}}}async function I(e,t){let n=new f(t.gatewaySecretSeed),r=s(t,e.sessionHandle);if(r.kind!==`resolved`)return N(r.message);let{subject:i}=r,a=await d(t),o=typeof e.scheme==`string`?e.scheme:void 0;if(e.api===void 0)return o===void 0?e.all===!0?L(await n.deleteSecrets(t.kv,i),a,`No credentials are stored for this caller, so nothing was removed.`):N(`Name the api to remove credentials for. To remove the credentials of every API, pass all: true instead.`):N(`Pass api together with scheme "${o}": a scheme belongs to one API.`);if(e.all===!0)return N(`Pass either api or all: true, not both.`);let c=A(a,e.api);if(`error`in c)return c.error;let{api:l}=c;if(o===void 0)return L(await n.deleteSecrets(t.kv,i,l.relativePath),a,`No credentials are stored for the "${l.name}" API, so nothing was removed.`);let u=Object.keys(p(l).schemes);if(!u.includes(o))return j(o,l,u);let m=`No credential is stored for the "${o}" scheme of the "${l.name}" API, so nothing was removed.`;return await n.hasSecret(t.kv,i,l.relativePath,o)?(await n.deleteSecret(t.kv,i,l.relativePath,o),L([{api:l.relativePath,scheme:o}],a,m)):L([],a,m)}function L(e,t,n){if(e.length===0)return{content:[{type:`text`,text:n}],isError:!1};let r=/* @__PURE__ */ new Map;for(let{api:t,scheme:n}of e)r.set(t,[...r.get(t)??[],n]);return{content:[{type:`text`,text:[`Removed the stored credentials:`,...[...r].map(([e,n])=>`- "${t.find(t=>t.relativePath===e)?.name??e}" (${e}): ${n.sort().join(`, `)}`),``,`This server no longer sends them. The next call that an API rejects with HTTP 401 asks the user for new credentials.`].join(`
4
+ `)}],isError:!1}}const R={schema:F([],`tools`,!0),schemaFor:async e=>F(await d(e),e.mcpMode,!a(t,e.metadata)),isAvailable:async e=>!a(`removeApiCredentials`,e.metadata)&&await w(e),execute:(e,t)=>I(e,t)};export{D as SESSION_HANDLE_PROPERTY,T as createAnonymousSessionTool,P as manageApiCredentialsTool,R as removeApiCredentialsTool};
@@ -1,2 +1,2 @@
1
- import{OPERATION_METHODS as e}from"../tools/openapi-document.js";import{basePathPrefix as t,operationHttpMethod as n,pathPattern as r}from"./route-pattern.js";const i=`default`,a={kind:`raw`},o=[`oauth2ClientCredentials`,`bearer`,`apiKey`,`cookie`,`raw`],s=new Set(e);function c(){return{schemes:{[i]:a},defaultScheme:i,routes:[],credentialQueryParams:[]}}function l(e){let{definition:t,servers:n}=e,r=g(t),i=Object.keys(r),a=u(t);if(i.length===0)return{...c(),credentialQueryParams:a};let o={schemes:r,defaultScheme:y(t.security,r)[0]??v(i,r)[0],routes:b(t,r,n),credentialQueryParams:a},s=h(t,i);return Object.keys(s).length>0&&(o.descriptions=s),o}function u(e){let t=/* @__PURE__ */ new Set;for(let n of Object.values(e.components?.securitySchemes??{}))x(n)&&n.type===`apiKey`&&n.in===`query`&&n.name&&t.add(n.name);return[...t]}function d(e){return[...new Set(Object.values(e).map(m))]}function f(e){return v(Object.keys(e),e)}function p(e,t){let n=/* @__PURE__ */ new Set;for(let r of e.routes)r.schemes.includes(t)&&n.add(`${r.method} ${r.path}`);return[...n]}function m(e){return e.kind===`apiKey`?e.header:e.kind===`cookie`?`Cookie`:`Authorization`}function h(e,t){let n={};for(let r of t){let t=e.components?.securitySchemes?.[r],i=x(t)?t.description:void 0;if(typeof i!=`string`)continue;let a=i.split(`
2
- `)[0].trim();a&&(n[r]=a.slice(0,120))}return n}function g(e){let t={};for(let[n,r]of Object.entries(e.components?.securitySchemes??{})){if(!x(r))continue;let e=_(r);e&&(t[n]=e)}return t}function _(e){if(e.type===`oauth2`){let t=e.flows?.clientCredentials;return t?{kind:`oauth2ClientCredentials`,tokenUrl:t.tokenUrl,scopes:Object.keys(t.scopes??{})}:{kind:`bearer`}}if(e.type===`openIdConnect`||e.type===`http`&&e.scheme?.toLowerCase()===`bearer`)return{kind:`bearer`};if(e.type===`apiKey`&&e.in===`header`)return{kind:`apiKey`,header:e.name||`X-Api-Key`};if(e.type===`apiKey`&&e.in===`cookie`&&e.name)return{kind:`cookie`,name:e.name}}function v(e,t){return[...e].sort((n,r)=>o.indexOf(t[n].kind)-o.indexOf(t[r].kind)||e.indexOf(n)-e.indexOf(r))}function y(e,t){let n=[];for(let r of e??[])for(let e of Object.keys(r))t[e]&&!n.includes(e)&&n.push(e);return n}function b(e,i,a){let o=t(a),c=[];for(let[t,a]of Object.entries(e.paths??{})){if(!a||typeof a!=`object`)continue;let l=r(o,t);if(l)for(let[r,o]of Object.entries(a)){if(!s.has(r.toLowerCase()))continue;let a=o?.security??e.security;if(a===void 0)continue;let u=y(a,i);u.length===0&&a.length>0||c.push({pattern:l,path:t,method:n(r),schemes:v(u,i)})}}return c}function x(e){return typeof e==`object`&&!!e&&`type`in e}export{i as DEFAULT_SCHEME_NAME,d as credentialHeadersOf,p as operationsForScheme,f as orderedSchemesOf,l as resolveUpstreamApiAuth};
1
+ import{OPERATION_METHODS as e}from"../../../../../../shared/constants/openapi-operation-methods.js";import{basePathPrefix as t,operationHttpMethod as n,pathPattern as r,pathVariableCount as i}from"./route-pattern.js";const a=`default`,o={kind:`raw`},s=[`oauth2ClientCredentials`,`bearer`,`apiKey`,`cookie`,`raw`],c=new Set(e);function l(){return{schemes:{[a]:o},defaultScheme:a,routes:[],credentialQueryParams:[]}}function u(e){let{definition:t,servers:n}=e,r=_(t),i=Object.keys(r),a=d(t);if(i.length===0)return{...l(),credentialQueryParams:a};let o={schemes:r,defaultScheme:b(t.security,r)[0]??y(i,r)[0],routes:x(t,r,n),credentialQueryParams:a},s=g(t,i);return Object.keys(s).length>0&&(o.descriptions=s),o}function d(e){let t=/* @__PURE__ */ new Set;for(let n of Object.values(e.components?.securitySchemes??{}))S(n)&&n.type===`apiKey`&&n.in===`query`&&n.name&&t.add(n.name);return[...t]}function f(e){return[...new Set(Object.values(e).map(h))]}function p(e){return y(Object.keys(e),e)}function m(e,t){let n=/* @__PURE__ */ new Set;for(let r of e.routes)r.schemes?.includes(t)&&n.add(`${r.method} ${r.path}`);return[...n]}function h(e){return e.kind===`apiKey`?e.header:e.kind===`cookie`?`Cookie`:`Authorization`}function g(e,t){let n={};for(let r of t){let t=e.components?.securitySchemes?.[r],i=S(t)?t.description:void 0;if(typeof i!=`string`)continue;let a=i.split(`
2
+ `)[0].trim();a&&(n[r]=a.slice(0,120))}return n}function _(e){let t={};for(let[n,r]of Object.entries(e.components?.securitySchemes??{})){if(!S(r))continue;let e=v(r);e&&(t[n]=e)}return t}function v(e){if(e.type===`oauth2`){let t=e.flows?.clientCredentials;return t?{kind:`oauth2ClientCredentials`,tokenUrl:t.tokenUrl,scopes:Object.keys(t.scopes??{})}:{kind:`bearer`}}if(e.type===`openIdConnect`||e.type===`http`&&e.scheme?.toLowerCase()===`bearer`)return{kind:`bearer`};if(e.type===`apiKey`&&e.in===`header`)return{kind:`apiKey`,header:e.name||`X-Api-Key`};if(e.type===`apiKey`&&e.in===`cookie`&&e.name)return{kind:`cookie`,name:e.name}}function y(e,t){return[...e].sort((n,r)=>s.indexOf(t[n].kind)-s.indexOf(t[r].kind)||e.indexOf(n)-e.indexOf(r))}function b(e,t){let n=[];for(let r of e??[])for(let e of Object.keys(r))t[e]&&!n.includes(e)&&n.push(e);return n}function x(e,a,o){let s=t(o),l=[];for(let[t,i]of Object.entries(e.paths??{})){if(!i||typeof i!=`object`)continue;let o=r(s,t);if(o)for(let[r,s]of Object.entries(i)){if(!c.has(r.toLowerCase()))continue;let i=s?.security??e.security,u={pattern:o,path:t,method:n(r)};if(l.push(u),i===void 0)continue;let d=b(i,a);u.schemes=y(d,a);let f=i.map(e=>Object.keys(e)),p=d.length===0&&f.every(e=>e.length>0)?[...new Set(f.flat())]:[];p.length>0&&(u.unsupportedSchemes=p)}}return l.sort((e,t)=>i(e.path)-i(t.path))}function S(e){return typeof e==`object`&&!!e&&`type`in e}export{a as DEFAULT_SCHEME_NAME,f as credentialHeadersOf,m as operationsForScheme,p as orderedSchemesOf,u as resolveUpstreamApiAuth};
@@ -1 +1 @@
1
- import{AI_METADATA_HEADER as e}from"../constants.js";import{isMcpHidden as t,isPublicEndpointServed as n,resolveMcpAccess as r}from"./config-gate.js";import{notFoundResponse as i}from"../../../../../server/plugin-context.js";import{publicOrigin as a}from"../../../utils/request-origin.js";import{formatError as o,jsonRpcErrorResponse as s}from"./tool-errors.js";import{buildMcpFileTools as c,createCustomTool as l,invokeCustomTool as u}from"./custom-tools.js";import{authorizeMcpRequest as d}from"./auth.js";import{EXECUTE_DEADLINE_MS as f}from"./codemode/constants.js";import{resolveMcpMode as p,resolveRequestInstructionsStyle as m,resolveRequestMcpMode as h}from"./mode.js";import{narrowMcpConfigForCaller as g}from"./gateway/caller-api-calls.js";import{isGatewayEnabled as _}from"./gateway/env.js";import{userSubject as v}from"./gateway/subject.js";import{parseUserAgent as y}from"./mcp-client.js";import{createMcpTelemetry as b}from"./mcp-telemetry.js";import{applyMcpRateLimit as x}from"./rate-limit.js";import{createToolRegistry as S}from"./tool-registry.js";import{mcpToolRegistry as C}from"./registry-instance.js";const w=`POST`;function T(e){return(e??``).split(`,`).some(e=>{let[t,...n]=e.split(`;`).map(e=>e.trim().toLowerCase());if(t!==`text/html`)return!1;let r=n.find(e=>e.startsWith(`q=`));return r===void 0||Number(r.slice(2))>0})}function E(){return s(405,`Method not allowed`,{Allow:w})}function D(e){let t={error:`Method Not Allowed`,message:`In order to use this MCP server, you need to register it in your MCP client (VS Code, Cursor, Claude Code, etc.) using this URL: ${e}`};return new Response(JSON.stringify(t),{status:405,headers:{"Content-Type":`application/json`,"Cache-Control":`no-store`,Allow:w}})}function O(){return s(501,`MCP transport is not available in this environment`)}function k(e){if(!e)return{};try{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}}function A(t,n,r,i){let a=k(t.headers.get(e)),{userAgent:o}=n.request,{client:s,clientVersion:c}=y(o),l=h(t.url,p()),u=crypto.randomUUID(),d=v(n.request.viewer),f=n.request.ip??void 0;return{config:{...n.config,mcp:g(n.config.mcp,a)},entities:n.entities,hasRoute:e=>n.hasRoute(e),isSlugVisible:(e,t)=>n.isSlugVisible(e,t),kv:n.kv,logger:n.logger,pageMarkdown:n.pageMarkdown,search:n.search,request:n.request,metadata:a,mcpMode:l,instructionsStyle:m(t.url),requestId:u,executeDeadline:i,messageId:typeof a.messageId==`string`?a.messageId:void 0,callerSubject:d,client:s,clientVersion:c,accessToken:r.accessToken,isProtected:r.isProtected??!1,isAvailableMemo:/* @__PURE__ */ new Map,subprocess:n.subprocess,claims:r.claims,telemetry:b({userAgent:o,request:t,metadata:a,mode:l,requestId:u,callerSubject:d,clientIp:f,logger:n.logger})}}async function j(e){let t=_(e.config)?(await import(`./gateway/index.js`)).gatewayTools():[],n=e.subprocess?e.mcpToolEntries??[]:[],r=C.list(),i=/* @__PURE__ */ new Set([...r.map(e=>e.schema.name),...t.map(e=>e.schema.name),...n.map(e=>e.declaration.name)]),a=e.subprocess?await c({entities:e.entities,loadContentModule:e.loadContentModule,reservedNames:i,logger:e.logger}):[];if(t.length===0&&n.length===0&&a.length===0)return C;let o=S();for(let e of r)o.register(e);for(let e of t)o.register(e);for(let e of n)o.register(l(e));for(let e of a)o.register(e);return o}async function M(e,t,n,r={}){let i=await j(e),a;try{a=await import(`./mcp-server.js`)}catch(t){return e.logger?.error(`MCP transport failed to load: ${o(t)}`),async()=>O()}let s;return a.createMcpRequestHandler({registry:i,logger:e.logger,buildToolContext:r=>s??=A(r,e,t,n),onError:r.onError})}function N(e={}){return async(o,s,c)=>{let l=Date.now()+f;if(t(c.config)||e.publicEndpoint&&!n(c.config,r(c.config)))return i();if(o.req.method===`GET`&&T(o.req.header(`accept`)))return s();let u=await x({kv:c.kv,ip:c.request.ip,bucket:`mcp`,logger:c.logger});if(u)return u;let p=await d({c:o,ctx:c,forceAnonymous:e.forceAnonymous});return p.kind===`deny`?p.response:o.req.method===`GET`?D(`${a(c.request)}${new URL(c.request.url).pathname}`):o.req.method===`POST`?(await M(p.ctx,{isProtected:p.isProtected,accessToken:p.accessToken,claims:p.claims},l))(o.req.raw):E()}}const P=N(),F=N({forceAnonymous:!0,publicEndpoint:!0});export{A as buildToolContext,N as createMcpHandler,M as createServedMcpRequestHandler,u as invokeCustomTool,P as mcp,F as mcpPublic};
1
+ import{AI_METADATA_HEADER as e}from"../constants.js";import{isMcpHidden as t,isPublicEndpointServed as n,resolveMcpAccess as r}from"./config-gate.js";import{notFoundResponse as i}from"../../../../../server/plugin-context.js";import{publicOrigin as a}from"../../../utils/request-origin.js";import{formatError as o,jsonRpcErrorResponse as s}from"./tool-errors.js";import{buildMcpFileTools as c,createCustomTool as l,invokeCustomTool as u}from"./custom-tools.js";import{authorizeMcpRequest as d}from"./auth.js";import{EXECUTE_DEADLINE_MS as f}from"./codemode/constants.js";import{resolveMcpMode as p,resolveRequestInstructionsStyle as m,resolveRequestMcpMode as h}from"./mode.js";import{narrowMcpConfigForCaller as g}from"./gateway/caller-api-calls.js";import{isGatewayEnabled as _}from"./gateway/env.js";import{userSubject as v}from"./gateway/subject.js";import{parseUserAgent as y}from"./mcp-client.js";import{createMcpTelemetry as b}from"./mcp-telemetry.js";import{applyMcpRateLimit as x}from"./rate-limit.js";import{createToolRegistry as S}from"./tool-registry.js";import{mcpToolRegistry as C}from"./registry-instance.js";const w=`POST`;function T(e){return(e??``).split(`,`).some(e=>{let[t,...n]=e.split(`;`).map(e=>e.trim().toLowerCase());if(t!==`text/html`)return!1;let r=n.find(e=>e.startsWith(`q=`));return r===void 0||Number(r.slice(2))>0})}function E(){return s(405,`Method not allowed`,{Allow:w})}function D(e){let t={error:`Method Not Allowed`,message:`In order to use this MCP server, you need to register it in your MCP client (VS Code, Cursor, Claude Code, etc.) using this URL: ${e}`};return new Response(JSON.stringify(t),{status:405,headers:{"Content-Type":`application/json`,"Cache-Control":`no-store`,Allow:w}})}function O(){return s(501,`MCP transport is not available in this environment`)}function k(e){if(!e)return{};try{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}}function A(t,n,r,i){let a=k(t.headers.get(e)),{userAgent:o}=n.request,{client:s,clientVersion:c}=y(o),l=h(t.url,p()),u=crypto.randomUUID(),d=v(n.request.viewer),f=n.request.ip??void 0;return{config:{...n.config,mcp:g(n.config.mcp,a)},entities:n.entities,hasRoute:e=>n.hasRoute(e),isSlugVisible:(e,t)=>n.isSlugVisible(e,t),kv:n.kv,gatewaySecretSeed:n.gatewaySecretSeed,logger:n.logger,pageMarkdown:n.pageMarkdown,search:n.search,request:n.request,metadata:a,mcpMode:l,instructionsStyle:m(t.url),requestId:u,executeDeadline:i,messageId:typeof a.messageId==`string`?a.messageId:void 0,callerSubject:d,client:s,clientVersion:c,accessToken:r.accessToken,isProtected:r.isProtected??!1,isAvailableMemo:/* @__PURE__ */ new Map,subprocess:n.subprocess,claims:r.claims,telemetry:b({userAgent:o,request:t,metadata:a,mode:l,requestId:u,callerSubject:d,clientIp:f,logger:n.logger})}}async function j(e){let t=_(e.config)?(await import(`./gateway/tool-list.js`)).gatewayTools():[],n=e.subprocess?e.mcpToolEntries??[]:[],r=C.list(),i=/* @__PURE__ */ new Set([...r.map(e=>e.schema.name),...t.map(e=>e.schema.name),...n.map(e=>e.declaration.name)]),a=e.subprocess?await c({entities:e.entities,loadContentModule:e.loadContentModule,reservedNames:i,logger:e.logger}):[];if(t.length===0&&n.length===0&&a.length===0)return C;let o=S();for(let e of r)o.register(e);for(let e of t)o.register(e);for(let e of n)o.register(l(e));for(let e of a)o.register(e);return o}async function M(e,t,n,r={}){let i=await j(e),a;try{a=await import(`./mcp-server.js`)}catch(t){return e.logger?.error(`MCP transport failed to load: ${o(t)}`),async()=>O()}let s;return a.createMcpRequestHandler({registry:i,logger:e.logger,buildToolContext:r=>s??=A(r,e,t,n),onError:r.onError})}function N(e={}){return async(o,s,c)=>{let l=Date.now()+f;if(t(c.config)||e.publicEndpoint&&!n(c.config,r(c.config)))return i();if(o.req.method===`GET`&&T(o.req.header(`accept`)))return s();let u=await x({kv:c.kv,ip:c.request.ip,bucket:`mcp`,logger:c.logger});if(u)return u;let p=await d({c:o,ctx:c,forceAnonymous:e.forceAnonymous});return p.kind===`deny`?p.response:o.req.method===`GET`?D(`${a(c.request)}${new URL(c.request.url).pathname}`):o.req.method===`POST`?(await M(p.ctx,{isProtected:p.isProtected,accessToken:p.accessToken,claims:p.claims},l))(o.req.raw):E()}}const P=N(),F=N({forceAnonymous:!0,publicEndpoint:!0});export{A as buildToolContext,N as createMcpHandler,M as createServedMcpRequestHandler,u as invokeCustomTool,P as mcp,F as mcpPublic};
@@ -1 +1 @@
1
- import{isObject as e}from"../../../../../shared/utils/is-object.js";import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as t,DISCOVER_TOOL_NAME as n,EXECUTE_TOOL_NAME as r}from"../constants.js";import{formatError as i}from"./tool-errors.js";import{auditToolCall as a,callAttribution as o}from"./audit.js";import{CODE_MODE_TOOL_NAMES as s,FETCH_TOOL_NAME as c}from"./codemode/constants.js";import{resolveMcpMode as l,resolveRequestMcpMode as u}from"./mode.js";import{sendMcpRequestError as d}from"./mcp-telemetry.js";import{availableTools as f,isToolAvailable as p,normalizeToolDisplayName as m}from"./tool-registry.js";import{mcpJsonSchemaValidator as h}from"./json-schema-validator.js";import{toToolListEntries as g}from"./codemode/tool-list.js";import{buildCodeModeInstructions as _,buildExecuteDescription as v,buildToolsModeInstructions as y}from"./codemode/prompts.js";import{composeExecuteAnnotations as b,getActiveCapabilities as x}from"./codemode/capabilities.js";import{discover as S,discoverSchema as C}from"./codemode/discover.js";import{EXECUTE_TOOL_SCHEMA as w,executeToolTitle as T}from"./codemode/execute-schema.js";import{runCodeMode as E}from"./codemode/index.js";import{docsServerInfo as D}from"./server-info.js";import{loadSkillResources as O}from"./skills-resources.js";import{randomUUID as k}from"node:crypto";import{McpServer as A,createMcpHandler as j,fromJsonSchema as M,isCallToolResult as N,isInputRequiredResult as P}from"@modelcontextprotocol/server";const F=`text/markdown`,I={listChanged:!1};function L(e){let{title:t,description:n,schema:r,outputSchema:i,annotations:a}=m(e);return{title:t,description:n,inputSchema:M(r,h),outputSchema:i?M(i,h):void 0,annotations:a}}function R(e,t){if(e)return t;let n=t.schema,{sessionHandle:r,...i}=n.properties;return{...t,schema:{...n,properties:i}}}function z(t,n){if(N(t)||P(t))return t;let r=[{type:`text`,text:typeof t==`string`?t:JSON.stringify(t)}];return n===`code`&&e(t)?{content:r,structuredContent:t}:{content:r}}function B(e,t){return(n,r)=>a(e,t.schema.name,n,async()=>z(await t.execute(n,e,r),e.mcpMode))}function V(e,t){return new A(e,{capabilities:{logging:{},tools:I},maxToolInputElements:1e4,instructions:t})}async function H(e,i,o){let[l,u]=await Promise.all([f(o,i),x(i)]),d=u.some(e=>e.id===c),m=l.filter(e=>!s.has(e.schema.name)).map(e=>e.schema),h=l.filter(({schema:e})=>s.has(e.name)&&e.name!==`execute`&&e.name!==`discover`),y=i.instructionsStyle!==`brief`,D=y?g(m,u):[],O=h.some(e=>e.schema.name===t),k=V(e,_(d,D,e.websiteUrl)),A=b(m,u,i.config.mcp);k.registerTool(r,L({...R(O,w),title:T(A),description:v(d,D,e.websiteUrl),annotations:A}),async(e,t)=>{let n=typeof e.sessionHandle==`string`?e.sessionHandle:void 0,s=t=>a(i,r,e,()=>E({code:e.code,description:e.description,sessionHandle:n,fetchBudget:50,registry:o,ctx:i,hostFetch:t}));if(!d)return s();let{runExecuteWithGateway:c}=await import(`./gateway/index.js`);return c({ctx:i,sessionHandle:n,serverContext:t,run:s})});let j=S(m,async e=>{let t=o.get(e);return t!==void 0&&await p(t,i)},u,i);k.registerTool(n,L(C(m,u,y)),e=>a(i,n,e,()=>j(e)));for(let e of h)k.registerTool(e.schema.name,L(R(O,e.schema)),B(i,e));return k}async function U(e,t,n){let r=new Map((await f(n,t)).map(e=>[e.schema.name,e])),i=V(e,y(e.websiteUrl));for(let e of n.list()){let n=r.get(e.schema.name)??e,a=i.registerTool(n.schema.name,L({...n.schema,outputSchema:void 0}),B(t,n));r.has(n.schema.name)||a.disable()}return i}async function W(e,t,n){let r=D(e.config,e.request),i=e.mcpMode===`code`?await H(r,e,t):await U(r,e,t);n.length>0&&i.server.registerCapabilities({resources:I});for(let e of n)i.registerResource(e.slug,e.uri,{title:e.title,description:e.description,mimeType:F},async()=>({contents:[{uri:e.uri,mimeType:F,text:await e.read()}]}));return i}function G(e){if(e.status!==200)return e;let t=new Headers(e.headers);return t.set(`Cache-Control`,`no-store`),new Response(e.body,{status:e.status,statusText:e.statusText,headers:t})}function K(){return new Response(JSON.stringify({jsonrpc:`2.0`,error:{code:-32603,message:`Internal server error`,data:`internal error`},id:null}),{status:500,headers:{"Content-Type":`application/json`,"Cache-Control":`no-store`}})}function q(e){return async t=>{let n;try{n=await e.buildToolContext(t);let r=await O(n),i=await W(n,e.registry,r),a=j(()=>i,{keepAliveMs:15e3,maxRequestBodySize:1048576,onerror:t=>e.logger?.warn(`MCP handler: ${t.message}`)}),o=await a.fetch(t);return t.headers.get(`mcp-method`)===`subscriptions/listen`&&await a.close(),G(o)}catch(r){if(e.onError)await e.onError(r);else{let a=n?o(n):{requestId:k()};e.logger?.error(`MCP request failed: ${i(r)}`,{request_id:a.requestId}),await d(r,u(t.url,l()),{logger:e.logger,caller:a})}return K()}}}export{q as createMcpRequestHandler,L as toRegisterToolConfig};
1
+ import{CALL_API_WRITE_TOOL_NAME as e,CREATE_ANONYMOUS_SESSION_TOOL_NAME as t,DISCOVER_TOOL_NAME as n,EXECUTE_TOOL_NAME as r,LIST_WORKFLOWS_TOOL_NAME as i}from"../constants.js";import{isObject as a}from"../../../../../shared/utils/is-object.js";import{formatError as o}from"./tool-errors.js";import{auditToolCall as s,callAttribution as c}from"./audit.js";import{CODE_MODE_TOOL_NAMES as l,FETCH_TOOL_NAME as u}from"./codemode/constants.js";import{resolveMcpMode as d,resolveRequestMcpMode as f}from"./mode.js";import{sendMcpRequestError as p}from"./mcp-telemetry.js";import{availableTools as m,isToolAvailable as h,normalizeToolDisplayName as g}from"./tool-registry.js";import{mcpJsonSchemaValidator as _}from"./json-schema-validator.js";import{toToolListEntries as v}from"./codemode/tool-list.js";import{buildCodeModeInstructions as y,buildExecuteDescription as b,buildToolsModeInstructions as x}from"./codemode/prompts.js";import{composeExecuteAnnotations as S,getActiveCapabilities as C}from"./codemode/capabilities.js";import{discover as w,discoverSchema as T}from"./codemode/discover.js";import{EXECUTE_TOOL_SCHEMA as E,executeOutputSchema as D,executeToolTitle as O}from"./codemode/execute-schema.js";import{runCodeMode as k}from"./codemode/index.js";import{docsServerInfo as A}from"./server-info.js";import{loadSkillResources as j}from"./skills-resources.js";import{randomUUID as M}from"node:crypto";import{McpServer as N,createMcpHandler as P,fromJsonSchema as F,isCallToolResult as I,isInputRequiredResult as L}from"@modelcontextprotocol/server";const R=`text/markdown`,z={listChanged:!1};function B(e){let{title:t,description:n,schema:r,outputSchema:i,annotations:a,_meta:o}=g(e);return{title:t,description:n,inputSchema:F(r,_),outputSchema:i?F(i,_):void 0,annotations:a,_meta:o}}function V(e,t){if(e)return t;let n=t.schema,{sessionHandle:r,...i}=n.properties;return{...t,schema:{...n,properties:i}}}function H(e,t){if(I(e)||L(e))return e;let n=[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e)}];return t===`code`&&a(e)?{content:n,structuredContent:e}:{content:n}}function U(e,t){return(n,r)=>s(e,t.schema.name,n,async()=>H(await t.execute(n,e,{serverContext:r}),e.mcpMode))}function W(e,t){return new N(e,{capabilities:{logging:{},tools:z},maxToolInputElements:1e4,instructions:t})}async function G(a,o,c){let[d,f]=await Promise.all([m(c,o),C(o)]),p=f.some(e=>e.id===u),g=d.some(({schema:t})=>t.name===e),_=d.some(({schema:e})=>e.name===i),x=d.filter(e=>!l.has(e.schema.name)).map(e=>e.schema),A=d.filter(({schema:e})=>l.has(e.name)&&e.name!==`execute`&&e.name!==`discover`),j=o.instructionsStyle!==`brief`,M=j?v(x,f):[],N=A.some(e=>e.schema.name===t),P=W(a,y({hasFetch:p,toolList:M,docsUrl:a.websiteUrl,hasCallApiWrite:g,hasWorkflows:_})),F=S(x,f);P.registerTool(r,B({...V(N,E),title:O(F),description:b(p,M,a.websiteUrl),outputSchema:D(p),annotations:F}),async(e,t)=>{let n=typeof e.sessionHandle==`string`?e.sessionHandle:void 0,i=t=>s(o,r,e,()=>k({code:e.code,description:e.description,sessionHandle:n,fetchBudget:50,registry:c,ctx:o,hostFetch:t}));if(!p)return i();let{runExecuteWithGateway:a}=await import(`./gateway/index.js`);return a({ctx:o,sessionHandle:n,serverContext:t,run:i})});let I=w(x,async e=>{let t=c.get(e);return t!==void 0&&await h(t,o)},f,o);P.registerTool(n,B(T(x,f,j)),e=>s(o,n,e,()=>I(e)));for(let e of A)P.registerTool(e.schema.name,B(V(N,e.schema)),U(o,e));return P}async function K(e,t,n){let r=new Map((await m(n,t)).map(e=>[e.schema.name,e])),i=W(e,x(e.websiteUrl));for(let e of n.list()){let n=r.get(e.schema.name)??e,a=i.registerTool(n.schema.name,B({...n.schema,outputSchema:void 0}),U(t,n));r.has(n.schema.name)||a.disable()}return i}async function q(e,t,n){let r=A(e.config,e.request),i=e.mcpMode===`code`?await G(r,e,t):await K(r,e,t);n.length>0&&i.server.registerCapabilities({resources:z});for(let e of n)i.registerResource(e.slug,e.uri,{title:e.title,description:e.description,mimeType:R},async()=>({contents:[{uri:e.uri,mimeType:R,text:await e.read()}]}));return i}function J(e){if(e.status!==200)return e;let t=new Headers(e.headers);return t.set(`Cache-Control`,`no-store`),new Response(e.body,{status:e.status,statusText:e.statusText,headers:t})}function Y(){return new Response(JSON.stringify({jsonrpc:`2.0`,error:{code:-32603,message:`Internal server error`,data:`internal error`},id:null}),{status:500,headers:{"Content-Type":`application/json`,"Cache-Control":`no-store`}})}function X(e){return async t=>{let n;try{n=await e.buildToolContext(t);let r=await j(n),i=await q(n,e.registry,r),a=P(()=>i,{keepAliveMs:15e3,maxRequestBodySize:1048576,onerror:t=>e.logger?.warn(`MCP handler: ${t.message}`)}),o=await a.fetch(t);return t.headers.get(`mcp-method`)===`subscriptions/listen`&&await a.close(),J(o)}catch(r){if(e.onError)await e.onError(r);else{let i=n?c(n):{requestId:M()};e.logger?.error(`MCP request failed: ${o(r)}`,{request_id:i.requestId}),await p(r,f(t.url,d()),{logger:e.logger,caller:i})}return Y()}}}export{X as createMcpRequestHandler,B as toRegisterToolConfig};
@@ -1 +1 @@
1
- import"../constants.js";import{errorMessage as e}from"../../../../../shared/utils/error-message.js";import{innerToolErrorClass as t,thrownErrorClass as n}from"./tool-errors.js";import{isServerTelemetryEnabled as r}from"../../../../../server/telemetry/collector.js";import{sendServerEvent as i,sendServerEvents as a}from"../../../../../server/telemetry/sender.js";import{auditCode as o,auditInput as s,auditSha256 as c,auditStack as l,isCallToolResult as u,toolOutputText as d,toolResultText as f}from"./audit.js";import{SANDBOX_FAILURE as p}from"./codemode/constants.js";import{parseUserAgent as m,readListingSource as h}from"./mcp-client.js";import{randomUUID as g}from"node:crypto";import{ulid as _}from"ulid";const v={id:`docs`,object:`mcpServer`,uri:`urn:redocly:realm:mcp:server:docs`};function y(e){if(e===void 0)return;let t=c(e);return{id:t,object:`user`,uri:`urn:redocly:realm:mcp:subject:${t}`}}function b(i){let{mode:c,requestId:g,callerSubject:_,clientIp:b,logger:x}=i,S=i.env??process.env,C=r(S),w=y(_),{client:T,clientVersion:E}=m(i.userAgent),D=i.metadata.messageId,O={client:T,client_version:E,message_id:typeof D==`string`?D:void 0,listing_source:h(i.request)},j=[],M=/* @__PURE__ */ new Set,N=/* @__PURE__ */ new WeakSet,P=(e,t)=>{j.push({type:e,data:[t],requestId:g,time:/* @__PURE__ */ new Date,actor:w,clientIp:b})},F=t=>{try{t()}catch(t){x?.warn(`MCP telemetry failed: ${e(t)}`)}},I=(e,t,n)=>P(`com.redocly.mcpServer.toolCalled`,{...v,tool:e,mode:c,output_length:n,duration_ms:t,...O}),L=(e,t,n)=>{n.stack&&x?.error(`MCP tool ${e} failed (${n.error_class})`,{request_id:g,stack:n.stack}),P(`com.redocly.mcpServer.error`,{...v,tool:e,mode:c,duration_ms:t,message:s(n.message),stack:l(n.stack),error_class:n.error_class,...O})},R=async(n,r,i)=>{let a=Date.now(),o;try{o=await r()}catch(r){let o=t(r),s=o===`server_error`;throw i.set(e(r),{tool:n,reason:s?`server_error`:`inner_tool_error`}),F(()=>L(n,Date.now()-a,{message:e(r),stack:s&&r instanceof Error?r.stack??``:``,error_class:o})),r}return F(()=>I(n,Date.now()-a,d(o).length)),o};return{toolReturned(e,t,n){F(()=>{if(!u(n)||n.isError!==!0){I(e,t,d(n).length);return}N.has(n)||L(e,t,{message:f(n,` `),stack:``,error_class:e===`execute`?`sandbox_error`:`tool_error`})})},toolThrew(t,r,i){F(()=>{let a=n(i);L(t,r,{message:e(i),stack:a===`server_error`&&i instanceof Error?i.stack??``:``,error_class:a})})},trackCodeExecution(t,n){let r=Date.now(),i=o(t),a=/* @__PURE__ */ new Map,s=0;return{hostFetch:n&&(t=>(s+=1,n(t).catch(t=>{throw a.set(e(t),{reason:`runtime_error`}),t}))),innerToolCall(e,t){let n=R(e,t,a),r=n.then(()=>void 0,()=>void 0);return M.add(r),r.then(()=>M.delete(r)),n},finish(e,t,n){let o=e.failure===p.HostError&&e.error!==void 0?a.get(e.error):void 0;o?.tool&&N.add(t);let c=e.error===void 0?`ok`:`error`,l=Date.now()-r,u=k(e.failure,o,n),d=o?.tool;F(()=>P(`com.redocly.mcpServer.codeExecuted`,{...v,code_sha256:i.sha256,code_length:i.length,fetch_count:s,outcome:c,flags:i.flags,duration_ms:l,failure_reason:u,failed_tool:d,...O})),x?.info(`Gateway MCP code executed [${i.sha256.slice(0,12)}] outcome=${c} codeLength=${i.length} fetchCount=${s}`+(i.flags?` flags=${i.flags}`:``)+` durationMs=${l}`+(u?` failureReason=${u}`:``)+(d?` failedTool=${d}`:``))}}},gatewayFetchPerformed({host:e,method:t,outcome:n,durationMs:r,path:i,api:a,status:o,bytes:s,injectedScheme:c}){F(()=>P(`com.redocly.mcpServer.gatewayFetchPerformed`,{...v,host:e,method:t,outcome:n,path:i,api:a,status:o,injected_scheme:c,bytes:s,duration_ms:r})),x?.info(`Gateway MCP fetch [${t} ${e}] outcome=${n}`+(i===void 0?``:` path=${i}`)+(a===void 0?``:` api=${a}`)+(o===void 0?``:` status=${o}`)+(c===void 0?``:` injectedScheme=${c}`)+(s===void 0?``:` bytes=${s}`)+` durationMs=${r}`)},gatewayFetchRateLimited({scope:e,limit:t,retryAfterSeconds:n}){F(()=>P(`com.redocly.mcpServer.gatewayFetchRateLimited`,{...v,scope:e,retry_after_seconds:n,limit:t}))},async flush(){if(!C){j=[];return}await A(M,300);let e=j;j=[],await a(e,{env:S,fetcher:i.fetcher,logger:x})}}}function x(e,t){let{requestId:n=g(),callerSubject:r,clientIp:a}=t.caller??{};return i({...e,requestId:n,actor:y(r),clientIp:a},t)}function S(e,t,n={}){return x({type:`com.redocly.mcpServer.error`,data:[{...v,message:s(e instanceof Error?e.message:``),stack:l(e instanceof Error?e.stack??``:``),error_class:`server_error`,mode:t}]},n)}function C({scope:e,retryAfterSeconds:t,limit:n},r={}){return x({type:`com.redocly.mcpServer.rateLimited`,data:[{...v,scope:e,retry_after_seconds:t,limit:n}]},r)}function w(e){let t=e||_(),n=t.startsWith(`mcp_`)?t:`mcp_${t}`;return{id:n,object:`mcpSession`,uri:`urn:redocly:realm:mcp:session:${n}`}}function T(e,t,n={}){return x({type:`com.redocly.mcpServerAuthorization.started`,data:[{...w(e),redirect_uri:t}]},n)}function E(e,t,n={}){return x({type:`com.redocly.mcpServerAuthorization.completed`,data:[{...w(e),redirect_uri:t}]},n)}function D(e,t,n,r,i={}){return x({type:`com.redocly.mcpServerAuthorization.failed`,data:[{...w(e),error:n,error_details:r,error_class:t}]},i)}function O(e={}){return x({type:`com.redocly.mcpServerCard.served`,data:{id:`mcpServerCardId`,object:`mcpServerCard`,uri:`urn:redocly:realm:api:mcpServerCard:mcpServerCardId`},signal:`trace`},e)}function k(e,t,n){return e===p.HostError?t?.reason??p.RuntimeError:e===p.RuntimeError&&n!==void 0?`unknown_tool`:e}async function A(e,t){if(e.size===0)return;let n;await Promise.race([Promise.allSettled(e),new Promise(e=>{n=setTimeout(e,t)})]),clearTimeout(n)}export{b as createMcpTelemetry,E as sendMcpAuthorizationCompleted,D as sendMcpAuthorizationFailed,T as sendMcpAuthorizationStarted,C as sendMcpRateLimited,S as sendMcpRequestError,O as sendMcpServerCardServed};
1
+ import"../constants.js";import{errorMessage as e}from"../../../../../shared/utils/error-message.js";import{isServerTelemetryEnabled as t}from"../../../../../server/telemetry/collector.js";import{sendServerEvent as n,sendServerEvents as r}from"../../../../../server/telemetry/sender.js";import{innerToolErrorClass as i,thrownErrorClass as a}from"./tool-errors.js";import{auditCode as o,auditInput as s,auditSha256 as c,auditStack as l,isCallToolResult as u,toolOutputText as d,toolResultText as f}from"./audit.js";import{SANDBOX_FAILURE as p}from"./codemode/constants.js";import{parseUserAgent as m,readListingSource as h}from"./mcp-client.js";import{randomUUID as g}from"node:crypto";import{ulid as _}from"ulid";const v={id:`docs`,object:`mcpServer`,uri:`urn:redocly:realm:mcp:server:docs`};function y(e){if(e===void 0)return;let t=c(e);return{id:t,object:`user`,uri:`urn:redocly:realm:mcp:subject:${t}`}}function b(n){let{mode:c,requestId:g,callerSubject:_,clientIp:b,logger:x}=n,S=n.env??process.env,C=t(S),w=y(_),{client:T,clientVersion:E}=m(n.userAgent),D=n.metadata.messageId,O={client:T,client_version:E,message_id:typeof D==`string`?D:void 0,listing_source:h(n.request)},j=[],M=/* @__PURE__ */ new Set,N=/* @__PURE__ */ new WeakSet,P=(e,t)=>{j.push({type:e,data:[t],requestId:g,time:/* @__PURE__ */ new Date,actor:w,clientIp:b})},F=t=>{try{t()}catch(t){x?.warn(`MCP telemetry failed: ${e(t)}`)}},I=(e,t,n)=>P(`com.redocly.mcpServer.toolCalled`,{...v,tool:e,mode:c,output_length:n,duration_ms:t,...O}),L=(e,t,n)=>{n.stack&&x?.error(`MCP tool ${e} failed (${n.error_class})`,{request_id:g,stack:n.stack}),P(`com.redocly.mcpServer.error`,{...v,tool:e,mode:c,duration_ms:t,message:s(n.message),stack:l(n.stack),error_class:n.error_class,...O})},R=async(t,n,r)=>{let a=Date.now(),o;try{o=await n()}catch(n){let o=i(n),s=o===`server_error`;throw r.set(e(n),{tool:t,reason:s?`server_error`:`inner_tool_error`}),F(()=>L(t,Date.now()-a,{message:e(n),stack:s&&n instanceof Error?n.stack??``:``,error_class:o})),n}return F(()=>I(t,Date.now()-a,d(o).length)),o};return{toolReturned(e,t,n){F(()=>{if(!u(n)||n.isError!==!0){I(e,t,d(n).length);return}N.has(n)||L(e,t,{message:f(n,` `),stack:``,error_class:e===`execute`?`sandbox_error`:`tool_error`})})},toolThrew(t,n,r){F(()=>{let i=a(r);L(t,n,{message:e(r),stack:i===`server_error`&&r instanceof Error?r.stack??``:``,error_class:i})})},trackCodeExecution(t,n){let r=Date.now(),i=o(t),a=/* @__PURE__ */ new Map,s=0;return{hostFetch:n&&(t=>(s+=1,n(t).catch(t=>{throw a.set(e(t),{reason:`runtime_error`}),t}))),innerToolCall(e,t){let n=R(e,t,a),r=n.then(()=>void 0,()=>void 0);return M.add(r),r.then(()=>M.delete(r)),n},finish(e,t,n){let o=e.failure===p.HostError&&e.error!==void 0?a.get(e.error):void 0;o?.tool&&N.add(t);let c=e.error===void 0?`ok`:`error`,l=Date.now()-r,u=k(e.failure,o,n),d=o?.tool;F(()=>P(`com.redocly.mcpServer.codeExecuted`,{...v,code_sha256:i.sha256,code_length:i.length,fetch_count:s,outcome:c,flags:i.flags,duration_ms:l,failure_reason:u,failed_tool:d,...O})),x?.info(`Gateway MCP code executed [${i.sha256.slice(0,12)}] outcome=${c} codeLength=${i.length} fetchCount=${s}`+(i.flags?` flags=${i.flags}`:``)+` durationMs=${l}`+(u?` failureReason=${u}`:``)+(d?` failedTool=${d}`:``))}}},gatewayFetchPerformed({host:e,method:t,outcome:n,durationMs:r,path:i,api:a,status:o,bytes:s,injectedScheme:c}){F(()=>P(`com.redocly.mcpServer.gatewayFetchPerformed`,{...v,host:e,method:t,outcome:n,path:i,api:a,status:o,injected_scheme:c,bytes:s,duration_ms:r})),x?.info(`Gateway MCP fetch [${t} ${e}] outcome=${n}`+(i===void 0?``:` path=${i}`)+(a===void 0?``:` api=${a}`)+(o===void 0?``:` status=${o}`)+(c===void 0?``:` injectedScheme=${c}`)+(s===void 0?``:` bytes=${s}`)+` durationMs=${r}`)},gatewayFetchRateLimited({scope:e,limit:t,retryAfterSeconds:n}){F(()=>P(`com.redocly.mcpServer.gatewayFetchRateLimited`,{...v,scope:e,retry_after_seconds:n,limit:t}))},async flush(){if(!C){j=[];return}await A(M,300);let e=j;j=[],await r(e,{env:S,fetcher:n.fetcher,logger:x})}}}function x(e,t){let{requestId:r=g(),callerSubject:i,clientIp:a}=t.caller??{};return n({...e,requestId:r,actor:y(i),clientIp:a},t)}function S(e,t,n={}){return x({type:`com.redocly.mcpServer.error`,data:[{...v,message:s(e instanceof Error?e.message:``),stack:l(e instanceof Error?e.stack??``:``),error_class:`server_error`,mode:t}]},n)}function C({scope:e,retryAfterSeconds:t,limit:n},r={}){return x({type:`com.redocly.mcpServer.rateLimited`,data:[{...v,scope:e,retry_after_seconds:t,limit:n}]},r)}function w(e){let t=e||_(),n=t.startsWith(`mcp_`)?t:`mcp_${t}`;return{id:n,object:`mcpSession`,uri:`urn:redocly:realm:mcp:session:${n}`}}function T(e,t,n={}){return x({type:`com.redocly.mcpServerAuthorization.started`,data:[{...w(e),redirect_uri:t}]},n)}function E(e,t,n={}){return x({type:`com.redocly.mcpServerAuthorization.completed`,data:[{...w(e),redirect_uri:t}]},n)}function D(e,t,n,r,i={}){return x({type:`com.redocly.mcpServerAuthorization.failed`,data:[{...w(e),error:n,error_details:r,error_class:t}]},i)}function O(e,t={}){return x({type:`com.redocly.mcpServerCard.served`,data:{id:`mcpServerCardId`,object:`mcpServerCard`,uri:`urn:redocly:realm:api:mcpServerCard:mcpServerCardId`,...e},signal:`trace`},t)}function k(e,t,n){return e===p.HostError?t?.reason??p.RuntimeError:e===p.RuntimeError&&n!==void 0?`unknown_tool`:e}async function A(e,t){if(e.size===0)return;let n;await Promise.race([Promise.allSettled(e),new Promise(e=>{n=setTimeout(e,t)})]),clearTimeout(n)}export{b as createMcpTelemetry,E as sendMcpAuthorizationCompleted,D as sendMcpAuthorizationFailed,T as sendMcpAuthorizationStarted,C as sendMcpRateLimited,S as sendMcpRequestError,O as sendMcpServerCardServed};
@@ -1 +1 @@
1
- import{SystemRoute as e}from"../../../../../../server/constants/system-routes.js";import{withPathPrefix as t}from"../../../../../../shared/path-prefix.js";import{MCP_CALLBACK_ROUTE as n}from"../../constants.js";import{isMcpContentProtected as r,isMcpHidden as i,resolveMcpAccess as a}from"../config-gate.js";import{getSessionIssuer as o}from"../../../../../../server/auth/middleware.js";import{notFoundResponse as s}from"../../../../../../server/plugin-context.js";import{SUPPORTED_CODE_CHALLENGE_METHODS as c}from"./constants.js";import"../auth.js";import{sendMcpAuthorizationStarted as l}from"../mcp-telemetry.js";import{applyMcpRateLimit as u}from"../rate-limit.js";import{parseRedirectUri as d}from"./redirect-uri.js";import{fetchClientMetadataDocument as f,isClientMetadataDocumentUrl as p,isRedirectUriRegistered as m}from"./client-metadata.js";import{readMcpClient as h}from"./client-registry.js";import{reportMcpAuthorizationFailure as g,withMcpFailureReporting as _}from"./error-reporting.js";import{isSupportedCodeChallengeMethod as v,signMcpArtifact as y}from"./tokens.js";import{ulid as b}from"ulid";function x(e,t){return e.json({error:`invalid_request`,error_description:t},400)}async function S(e,t,n){if(p(t)){let r;try{r=await f(t)}catch(t){let n=`Unable to resolve client metadata document: ${t instanceof Error?t.message:String(t)}`;return await g(e,n),{ok:!1,error:n}}return{ok:!0,allowed:m(n,r.redirect_uris),clientName:r.client_name??null}}let r=(await h(e.kv,t))?.redirect_uris??[];return{ok:!0,allowed:r.length===0||m(n,r),clientName:null}}const C=_(w,e=>e.json({error:`server_error`,error_description:`The server could not complete the request`},500));async function w(f,p){if(i(p.config)||!r(a(p.config)))return s();let m=o(f);if(!m)return s();let h=await u({kv:p.kv,ip:p.request.ip,bucket:`oauth`,logger:p.logger});if(h)return h;let g=new URL(f.req.url).searchParams,_=g.get(`redirect_uri`),C=g.get(`client_id`),w=g.get(`code_challenge`),T=g.get(`code_challenge_method`);if(!_||!d(_))return x(f,`redirect_uri must be an https URL, a loopback http URL, or a private-use scheme`);if(!C)return x(f,`client_id is required`);if(!w)return x(f,`code_challenge is required`);if(!T||!v(T))return x(f,`Unsupported code_challenge_method. Supported: ${c.join(`, `)}`);let E=await S(p,C,_);if(!E.ok)return f.json({error:`invalid_client`,error_description:E.error},400);if(!E.allowed)return x(f,`redirect_uri is not registered for this client`);let D=b(),O=await y({type:`mcp_context`,sessionId:D,redirectUri:_,clientId:C,clientName:E.clientName,state:g.get(`state`),codeChallenge:w,codeChallengeMethod:T},m.artifactSecret,Math.floor(Date.now()/1e3)+600);await l(D,_,{logger:p.logger});let k=new URLSearchParams({redirectTo:`${n}/${O}`});return f.redirect(`${t(e.AuthIdpLogin)}?${k.toString()}`,302)}export{C as mcpAuthorize};
1
+ import{MCP_CALLBACK_ROUTE as e}from"../../constants.js";import{SystemRoute as t}from"../../../../../../shared/constants/system-routes.js";import{withPathPrefix as n}from"../../../../../../shared/path-prefix.js";import{isMcpContentProtected as r,isMcpHidden as i,resolveMcpAccess as a}from"../config-gate.js";import{getSessionIssuer as o}from"../../../../../../server/auth/middleware.js";import{notFoundResponse as s}from"../../../../../../server/plugin-context.js";import{SUPPORTED_CODE_CHALLENGE_METHODS as c}from"./constants.js";import"../auth.js";import{sendMcpAuthorizationStarted as l}from"../mcp-telemetry.js";import{applyMcpRateLimit as u}from"../rate-limit.js";import{parseRedirectUri as d}from"./redirect-uri.js";import{fetchClientMetadataDocument as f,isClientMetadataDocumentUrl as p,isRedirectUriRegistered as m}from"./client-metadata.js";import{readMcpClient as h}from"./client-registry.js";import{reportMcpAuthorizationFailure as g,withMcpFailureReporting as _}from"./error-reporting.js";import{isSupportedCodeChallengeMethod as v,signMcpArtifact as y}from"./tokens.js";import{ulid as b}from"ulid";function x(e,t){return e.json({error:`invalid_request`,error_description:t},400)}async function S(e,t,n){if(p(t)){let r;try{r=await f(t)}catch(t){let n=`Unable to resolve client metadata document: ${t instanceof Error?t.message:String(t)}`;return await g(e,n),{ok:!1,error:n}}return{ok:!0,allowed:m(n,r.redirect_uris),clientName:r.client_name??null}}let r=(await h(e.kv,t))?.redirect_uris??[];return{ok:!0,allowed:r.length===0||m(n,r),clientName:null}}const C=_(w,e=>e.json({error:`server_error`,error_description:`The server could not complete the request`},500));async function w(f,p){if(i(p.config)||!r(a(p.config)))return s();let m=o(f);if(!m)return s();let h=await u({kv:p.kv,ip:p.request.ip,bucket:`oauth`,logger:p.logger});if(h)return h;let g=new URL(f.req.url).searchParams,_=g.get(`redirect_uri`),C=g.get(`client_id`),w=g.get(`code_challenge`),T=g.get(`code_challenge_method`);if(!_||!d(_))return x(f,`redirect_uri must be an https URL, a loopback http URL, or a private-use scheme`);if(!C)return x(f,`client_id is required`);if(!w)return x(f,`code_challenge is required`);if(!T||!v(T))return x(f,`Unsupported code_challenge_method. Supported: ${c.join(`, `)}`);let E=await S(p,C,_);if(!E.ok)return f.json({error:`invalid_client`,error_description:E.error},400);if(!E.allowed)return x(f,`redirect_uri is not registered for this client`);let D=b(),O=await y({type:`mcp_context`,sessionId:D,redirectUri:_,clientId:C,clientName:E.clientName,state:g.get(`state`),codeChallenge:w,codeChallengeMethod:T},m.artifactSecret,Math.floor(Date.now()/1e3)+600);await l(D,_,{logger:p.logger});let k=new URLSearchParams({redirectTo:`${e}/${O}`});return f.redirect(`${n(t.AuthIdpLogin)}?${k.toString()}`,302)}export{C as mcpAuthorize};
@@ -1 +1 @@
1
- import{withPathPrefix as e}from"../../../../../../shared/path-prefix.js";import{MCP_AUTHORIZATION_SERVER_ROUTE as t,MCP_AUTHORIZE_ROUTE as n,MCP_REGISTER_ROUTE as r,MCP_ROUTE as i,MCP_TOKEN_ROUTE as a}from"../../constants.js";import{isMcpContentProtected as o,isMcpHidden as s,resolveMcpAccess as c}from"../config-gate.js";import{notFoundResponse as l}from"../../../../../../server/plugin-context.js";import{publicOrigin as u}from"../../../../utils/request-origin.js";import{CORS_ANY_ORIGIN as d,SUPPORTED_MCP_GRANT_TYPES as f,SUPPORTED_MCP_SCOPES as p}from"./constants.js";import"../auth.js";function m(e){return!s(e.config)&&o(c(e.config))}function h(n,r){if(!m(r))return l();let a=u(r.request);return n.json({resource:`${a}${e(i)}`,authorization_servers:[a],bearer_methods_supported:[`header`],resource_documentation:`${a}${e(t)}`,scopes_supported:[...p],bearer_token_types_supported:[`Bearer`]},200,{...d})}function g(t,i){if(!m(i))return l();let o=u(i.request);return t.json({issuer:o,authorization_endpoint:`${o}${e(n)}`,token_endpoint:`${o}${e(a)}`,scopes_supported:[...p],registration_endpoint:`${o}${e(r)}`,response_types_supported:[`code`],grant_types_supported:[...f],subject_types_supported:[`public`],id_token_signing_alg_values_supported:[`RS256`],code_challenge_methods_supported:[`S256`],token_endpoint_auth_methods_supported:[`none`],client_id_metadata_document_supported:!0},200,{...d})}export{g as oauthAuthorizationServer,h as oauthProtectedResource};
1
+ import{MCP_AUTHORIZATION_SERVER_ROUTE as e,MCP_AUTHORIZE_ROUTE as t,MCP_REGISTER_ROUTE as n,MCP_ROUTE as r,MCP_TOKEN_ROUTE as i}from"../../constants.js";import{withPathPrefix as a}from"../../../../../../shared/path-prefix.js";import{isMcpContentProtected as o,isMcpHidden as s,resolveMcpAccess as c}from"../config-gate.js";import{notFoundResponse as l}from"../../../../../../server/plugin-context.js";import{publicOrigin as u}from"../../../../utils/request-origin.js";import{CORS_ANY_ORIGIN as d,SUPPORTED_MCP_GRANT_TYPES as f,SUPPORTED_MCP_SCOPES as p}from"./constants.js";import"../auth.js";function m(e){return!s(e.config)&&o(c(e.config))}function h(t,n){if(!m(n))return l();let i=u(n.request);return t.json({resource:`${i}${a(r)}`,authorization_servers:[i],bearer_methods_supported:[`header`],resource_documentation:`${i}${a(e)}`,scopes_supported:[...p],bearer_token_types_supported:[`Bearer`]},200,{...d})}function g(e,r){if(!m(r))return l();let o=u(r.request);return e.json({issuer:o,authorization_endpoint:`${o}${a(t)}`,token_endpoint:`${o}${a(i)}`,scopes_supported:[...p],registration_endpoint:`${o}${a(n)}`,response_types_supported:[`code`],grant_types_supported:[...f],subject_types_supported:[`public`],id_token_signing_alg_values_supported:[`RS256`],code_challenge_methods_supported:[`S256`],token_endpoint_auth_methods_supported:[`none`],client_id_metadata_document_supported:!0},200,{...d})}export{g as oauthAuthorizationServer,h as oauthProtectedResource};
@@ -1 +1 @@
1
- import{extractMappedIpv4 as e}from"../../../../../server/ssrf/ssrf-blocklist.js";import{sendMcpRateLimited as t}from"./mcp-telemetry.js";import{isIP as n}from"node:net";const r={ratePerMin:600,quotaPerDay:2e4},i={ratePerMin:60,quotaPerDay:2e3},a={ratePerMin:60,quotaPerDay:2e3};function o(e,t){return e!==void 0&&/^[1-9]\d*$/.test(e)?Number(e):t}function s(e){return e===`oauth`?i:e===`card`?a:{ratePerMin:o(process.env.MCP_RATE_LIMIT_PER_MINUTE,r.ratePerMin),quotaPerDay:o(process.env.MCP_RATE_LIMIT_PER_DAY,r.quotaPerDay)}}const c={rate:`minute`,quota:`day`};function l(t){if(n(t)!==6)return t;let r=e(t);if(r)return r;let[i,a=``]=t.split(`%`)[0].split(`::`),o=i?i.split(`:`):[],s=a?a.split(`:`):[],c=8-o.length-s.length;return`${[...o,...Array(Math.max(0,c)).fill(`0`),...s].slice(0,4).map(e=>parseInt(e||`0`,16).toString(16)).join(`:`)}::/64`}function u(e,t,n,r){return[...e===`mcp`?[`mcp`,`request-rl`]:[`mcp`,`request-rl`,e],t,String(n),String(r)]}async function d(e){let{kv:t,bucket:n,ip:r,windowSeconds:i,limit:a,now:o}=e,s=Math.floor(o/1e3),c=Math.floor(s/i),l=u(n,r,i,c),d=(await t.get(l))?.count??0;return d>=a?{allowed:!1,retryAfterSeconds:Math.max(1,(c+1)*i-s)}:(await t.set(l,{count:d+1},{ttlInSeconds:i}),{allowed:!0})}async function f(e){let t=e.now??Date.now(),{bucket:n}=e,r=e.limits??s(n),i=l(e.ip),a=await d({kv:e.kv,bucket:n,ip:i,windowSeconds:60,limit:r.ratePerMin,now:t});if(!a.allowed)return{limited:!0,scope:`rate`,retryAfterSeconds:a.retryAfterSeconds};let o=await d({kv:e.kv,bucket:n,ip:i,windowSeconds:86400,limit:r.quotaPerDay,now:t});return o.allowed?{limited:!1}:{limited:!0,scope:`quota`,retryAfterSeconds:o.retryAfterSeconds}}function p(e,t){let n={jsonrpc:`2.0`,error:{code:-32029,message:`Rate limit exceeded (${e.scope}); retry after ${e.retryAfterSeconds}s`},id:null};return new Response(JSON.stringify(n),{status:429,headers:{...t,"Content-Type":`application/json`,"Cache-Control":`no-store`,"Retry-After":String(e.retryAfterSeconds)}})}async function m(e){if(!e.ip)return;let{bucket:n,logger:r}=e,i=s(n),a;try{a=await f({kv:e.kv,ip:e.ip,bucket:n,now:e.now,limits:i})}catch(e){r?.warn(`MCP rate-limit store error, failing open: ${String(e)}`);return}if(a.limited)return r?.warn(`MCP rate limit exceeded (${n}, ${c[a.scope]})`),await t({scope:a.scope,retryAfterSeconds:a.retryAfterSeconds,limit:a.scope===`rate`?i.ratePerMin:i.quotaPerDay},{logger:r,caller:{clientIp:e.ip}}),p(a,e.headers??{})}export{m as applyMcpRateLimit,f as checkMcpRateLimit,l as ipRateLimitKey};
1
+ import{extractMappedIpv4 as e}from"../../../../../server/ssrf/ssrf-blocklist.js";import{sendMcpRateLimited as t}from"./mcp-telemetry.js";import{isIP as n}from"node:net";const r=86400,i={ratePerMin:600,quotaPerDay:2e4},a={ratePerMin:60,quotaPerDay:2e3},o={ratePerMin:60,quotaPerDay:2e3};function s(e,t){return e!==void 0&&/^[1-9]\d*$/.test(e)?Number(e):t}function c(e){return e===`oauth`?a:e===`card`?o:{ratePerMin:s(process.env.MCP_RATE_LIMIT_PER_MINUTE,i.ratePerMin),quotaPerDay:s(process.env.MCP_RATE_LIMIT_PER_DAY,i.quotaPerDay)}}const l={rate:`minute`,quota:`day`};function u(t){if(n(t)!==6)return t;let r=e(t);if(r)return r;let[i,a=``]=t.split(`%`)[0].split(`::`),o=i?i.split(`:`):[],s=a?a.split(`:`):[],c=8-o.length-s.length;return`${[...o,...Array(Math.max(0,c)).fill(`0`),...s].slice(0,4).map(e=>parseInt(e||`0`,16).toString(16)).join(`:`)}::/64`}const d=[{scope:`rate`,seconds:60},{scope:`quota`,seconds:r}];function f(e,t){return e===`mcp`?[`mcp`,`request-rl`,t]:[`mcp`,`request-rl`,e,t]}async function p(e){let{kv:t,bucket:n}=e,i=e.limits??c(n),a=Math.floor((e.now??Date.now())/1e3),o=f(n,u(e.ip)),s=await t.get(o),l={};for(let{scope:e,seconds:t}of d){let n=Math.floor(a/t),r=s?.[e],o=r?.id===n?r.count:0;if(o>=(e===`rate`?i.ratePerMin:i.quotaPerDay))return{limited:!0,scope:e,retryAfterSeconds:Math.max(1,(n+1)*t-a)};l[e]={id:n,count:o+1}}return await t.set(o,l,{ttlInSeconds:r}),{limited:!1}}function m(e,t){let n={jsonrpc:`2.0`,error:{code:-32029,message:`Rate limit exceeded (${e.scope}); retry after ${e.retryAfterSeconds}s`},id:null};return new Response(JSON.stringify(n),{status:429,headers:{...t,"Content-Type":`application/json`,"Cache-Control":`no-store`,"Retry-After":String(e.retryAfterSeconds)}})}async function h(e){if(!e.ip)return;let{bucket:n,logger:r}=e,i=c(n),a;try{a=await p({kv:e.kv,ip:e.ip,bucket:n,now:e.now,limits:i})}catch(e){r?.warn(`MCP rate-limit store error, failing open: ${String(e)}`);return}if(a.limited)return r?.warn(`MCP rate limit exceeded (${n}, ${l[a.scope]})`),await t({scope:a.scope,retryAfterSeconds:a.retryAfterSeconds,limit:a.scope===`rate`?i.ratePerMin:i.quotaPerDay},{logger:r,caller:{clientIp:e.ip}}),m(a,e.headers??{})}export{h as applyMcpRateLimit,p as checkMcpRateLimit,u as ipRateLimitKey};
@@ -1 +1 @@
1
- import{withPathPrefix as e}from"../../../../../shared/path-prefix.js";import{MCP_ROUTE as t}from"../constants.js";import{ANONYMOUS_VIEWER as n}from"../../../../../shared/types/auth.js";import{isMcpContentProtected as r,isMcpHidden as i,resolveMcpAccess as a}from"./config-gate.js";import{notFoundResponse as o}from"../../../../../server/plugin-context.js";import{publicBaseUrl as s,publicOrigin as c}from"../../../utils/request-origin.js";import{formatError as l}from"./tool-errors.js";import{CORS_ANY_ORIGIN as u,MCP_AUTH_SCHEMES as d}from"./oauth/constants.js";import"./auth.js";import{EXECUTE_DEADLINE_MS as f}from"./codemode/constants.js";import{sendMcpServerCardServed as p}from"./mcp-telemetry.js";import{applyMcpRateLimit as m}from"./rate-limit.js";import{createServedMcpRequestHandler as h}from"./handler.js";import{docsServerInfo as g}from"./server-info.js";import{CLIENT_CAPABILITIES_META_KEY as _,CLIENT_INFO_META_KEY as v,LATEST_PROTOCOL_VERSION as y,PROTOCOL_VERSION_META_KEY as b}from"@modelcontextprotocol/server";const x=`2026-07-28`,S=[`dynamic`],C={capabilities:{},tools:S};async function w(e,t,n){let r=await e(new Request(t,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json, text/event-stream`,"mcp-protocol-version":x,"mcp-method":n},body:JSON.stringify({jsonrpc:`2.0`,id:1,method:n,params:{_meta:{[b]:x,[v]:{name:`server-card`,version:`1.0`},[_]:{}}}})}));if(r.ok)return(await r.json()).result}function T(e,t){e.logger?.warn(`MCP server card lists dynamic tools: ${l(t)}`)}async function E(r,i){let a=await r.withViewer(n),o=await h(a,{isProtected:i},Date.now()+f,{onError:e=>T(r,e)}),s=new URL(e(t),c(r.request)).href,[l,u]=await Promise.all([w(o,s,`server/discover`),i?void 0:w(o,s,`tools/list`)]);if(!l)return;if(i)return{capabilities:l.capabilities,tools:S};if(!u)return;let d=u.tools.map(({name:e,title:t,description:n,inputSchema:r,annotations:i})=>({name:e,title:t,description:n,inputSchema:r,annotations:i}));return{capabilities:l.capabilities,instructions:l.instructions,tools:d.length>0?d:S}}async function D(n,c){if(i(c.config))return o();n.set(`realmCacheControlOwned`,!0);let l=await m({kv:c.kv,ip:c.request.ip,bucket:`card`,headers:u,logger:c.logger});if(l)return l;let f=g(c.config,c.request),h=r(a(c.config)),_=await E(c,h).catch(e=>{T(c,e)}),{capabilities:v,instructions:b,tools:x}=_??C;return await p({logger:c.logger}),n.json({$schema:`https://static.modelcontextprotocol.io/schemas/mcp-server-card/v1.json`,version:`1.0`,protocolVersion:y,serverInfo:{...f,title:f.name},description:f.description,documentationUrl:s(c.config,c.request),transport:{type:`streamable-http`,endpoint:e(t)},capabilities:v,authentication:h?{required:!0,schemes:[...d]}:void 0,instructions:b,tools:x},200,{...u,"Cache-Control":_?`public, max-age=3600`:`no-store`})}export{D as mcpServerCard};
1
+ import{MCP_ROUTE as e}from"../constants.js";import{withPathPrefix as t}from"../../../../../shared/path-prefix.js";import{ANONYMOUS_VIEWER as n}from"../../../../../shared/types/auth.js";import{isMcpContentProtected as r,isMcpHidden as i,resolveMcpAccess as a}from"./config-gate.js";import{notFoundResponse as o}from"../../../../../server/plugin-context.js";import{publicBaseUrl as s,publicOrigin as c}from"../../../utils/request-origin.js";import{formatError as l}from"./tool-errors.js";import{CORS_ANY_ORIGIN as u,MCP_AUTH_SCHEMES as d}from"./oauth/constants.js";import"./auth.js";import{EXECUTE_DEADLINE_MS as f}from"./codemode/constants.js";import{resolveMcpMode as p}from"./mode.js";import{sendMcpServerCardServed as m}from"./mcp-telemetry.js";import{applyMcpRateLimit as h}from"./rate-limit.js";import{createServedMcpRequestHandler as g}from"./handler.js";import{docsServerInfo as _}from"./server-info.js";import{CLIENT_CAPABILITIES_META_KEY as v,CLIENT_INFO_META_KEY as y,LATEST_PROTOCOL_VERSION as b,PROTOCOL_VERSION_META_KEY as x}from"@modelcontextprotocol/server";const S=`2026-07-28`,C=[`dynamic`],w={capabilities:{},tools:C};async function T(e,t,n){let r=await e(new Request(t,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json, text/event-stream`,"mcp-protocol-version":S,"mcp-method":n},body:JSON.stringify({jsonrpc:`2.0`,id:1,method:n,params:{_meta:{[x]:S,[y]:{name:`server-card`,version:`1.0`},[v]:{}}}})}));if(r.ok)return(await r.json()).result}function E(e,t){e.logger?.warn(`MCP server card lists dynamic tools: ${l(t)}`)}async function D(r,i){let a=await r.withViewer(n),o=await g(a,{isProtected:i},Date.now()+f,{onError:e=>E(r,e)}),s=new URL(t(e),c(r.request)).href,[l,u]=await Promise.all([T(o,s,`server/discover`),i?void 0:T(o,s,`tools/list`)]);if(!l)return;if(i)return{capabilities:l.capabilities,tools:C};if(!u)return;let d=u.tools.map(({name:e,title:t,description:n,inputSchema:r,annotations:i,_meta:a})=>({name:e,title:t,description:n,inputSchema:r,annotations:i,_meta:a}));return{capabilities:l.capabilities,instructions:l.instructions,tools:d.length>0?d:C}}async function O(n,c){if(i(c.config))return o();n.set(`realmCacheControlOwned`,!0);let l=await h({kv:c.kv,ip:c.request.ip,bucket:`card`,headers:u,logger:c.logger});if(l)return l;let f=_(c.config,c.request),g=r(a(c.config)),v=await D(c,g).catch(e=>{E(c,e)}),{capabilities:y,instructions:x,tools:S}=v??w;return await m({mode:p(),toolsCount:S===C?0:S.length,authRequired:g},{logger:c.logger}),n.json({$schema:`https://static.modelcontextprotocol.io/schemas/mcp-server-card/v1.json`,version:`1.0`,protocolVersion:b,serverInfo:{...f,title:f.name},description:f.description,documentationUrl:s(c.config,c.request),transport:{type:`streamable-http`,endpoint:t(e)},capabilities:y,authentication:g?{required:!0,schemes:[...d]}:void 0,instructions:x,tools:S},200,{...u,"Cache-Control":v?`public, max-age=3600`:`no-store`})}export{O as mcpServerCard};
@@ -1 +1 @@
1
- import{withPathPrefix as e}from"../../../../../shared/path-prefix.js";import{skillMarkdownPath as t}from"../../../utils/skill-paths.js";import{SKILL_ENTITY_TYPE as n}from"../../../types/skill-entity.js";import{isEntityScopeVisible as r}from"../../../../../server/rbac/entity-scope.js";import{publicOrigin as i}from"../../../utils/request-origin.js";async function a(a){if(a.config.skills?.hide===!0)return[];let o=await a.entities.list({type:n}),s=i(a.request),c=e=>r(e,a.request.teams,e=>a.logger?.warn(e));return o.flatMap(n=>{let{slug:r,title:i,description:o}=n.metadata??{};return typeof r!=`string`||!c(n)?[]:[{slug:r,title:i??r,description:o??``,uri:`${s}${e(t(r))}`,read:async()=>(await a.entities.load(n.key)).content}]})}export{a as loadSkillResources};
1
+ import{withPathPrefix as e}from"../../../../../shared/path-prefix.js";import{skillMarkdownPath as t}from"../../../utils/skill-paths.js";import{SKILL_ENTITY_TYPE as n}from"../../../types/skill-entity.js";import{isEntityScopeVisible as r}from"../../../../../shared/rbac/entity-scope.js";import{publicOrigin as i}from"../../../utils/request-origin.js";async function a(a){if(a.config.skills?.hide===!0)return[];let o=await a.entities.list({type:n}),s=i(a.request),c=e=>r(e,a.request.teams,e=>a.logger?.warn(e));return o.flatMap(n=>{let{slug:r,title:i,description:o}=n.metadata??{};return typeof r!=`string`||!c(n)?[]:[{slug:r,title:i??r,description:o??``,uri:`${s}${e(t(r))}`,read:async()=>(await a.entities.load(n.key)).content}]})}export{a as loadSkillResources};
@@ -1 +1 @@
1
- import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{compileContentGlob as t}from"../../../../utils/glob.js";import"../../../../types/api-entity.js";import{canonicalSlugPath as n}from"../../ignored-routes.js";import{formatError as r}from"../tool-errors.js";import{posix as i}from"node:path";const a=/* @__PURE__ */ new WeakMap,o=/* @__PURE__ */ new WeakMap;function s(e){let t=a.get(e);if(t)return t;let n=l(e);return a.set(e,n),n}async function c(e){return(await s(e)).length>0}async function l(r){let i=r.config.mcp?.ignore??[],a=i.length>0?t(i):()=>!1;return(await r.entities.list({type:`api`})).flatMap(({key:t,metadata:r})=>{let{specType:i,sourcePath:o,routeSlug:s,options:c}=r??{};if(i!==`graphql`||typeof o!=`string`||a(o)||typeof s==`string`&&a(n(s,o)))return[];let l=e(c)&&e(c.info)?c.info:{};return[{entityKey:t,relativePath:o,name:typeof l.title==`string`&&l.title?l.title:u(o),description:typeof l.description==`string`?l.description:void 0}]})}function u(e){return i.basename(e,i.extname(e))}function d(e){return e.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean)}function f(e,t){let n=t.toLowerCase(),r=e.find(e=>e.name.toLowerCase().includes(n));if(r)return r;let i=new Set(d(n)),a,o=0;for(let t of e){let e=d(t.name);e.length>o&&e.every(e=>i.has(e))&&(a=t,o=e.length)}return a}async function p(e,t){let n=f(await s(t),e);if(n)return n;throw Error(`No GraphQL schema found matching "${e}".`)}async function m(e,t){let n=await p(e,t),r=o.get(t);r||(r=/* @__PURE__ */ new Map,o.set(t,r));let i=r.get(n.entityKey);return i||(i=h(t,n),r.set(n.entityKey,i)),{name:n.name,schema:await i}}async function h(e,t){try{let n=await e.entities.load(t.entityKey),{buildSchema:r}=await import(`graphql`);return r(n)}catch(n){throw e.logger?.warn(`MCP: cannot read graphql entity "${t.entityKey}": ${r(n)}`),Error(`The GraphQL schema "${t.name}" could not be read.`)}}export{c as hasGraphqlSchemas,s as listGraphqlSchemas,m as loadGraphqlSchema,p as resolveGraphqlSchema};
1
+ import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{compileContentGlob as t}from"../../../../utils/glob.js";import"../../../../../../shared/constants/api-spec-kinds.js";import{canonicalSlugPath as n}from"../../ignored-routes.js";import{formatError as r}from"../tool-errors.js";import{posix as i}from"node:path";const a=/* @__PURE__ */ new WeakMap,o=/* @__PURE__ */ new WeakMap;function s(e){let t=a.get(e);if(t)return t;let n=l(e);return a.set(e,n),n}async function c(e){return(await s(e)).length>0}async function l(r){let i=r.config.mcp?.ignore??[],a=i.length>0?t(i):()=>!1;return(await r.entities.list({type:`api`})).flatMap(({key:t,metadata:r})=>{let{specType:i,sourcePath:o,routeSlug:s,options:c}=r??{};if(i!==`graphql`||typeof o!=`string`||a(o)||typeof s==`string`&&a(n(s,o)))return[];let l=e(c)&&e(c.info)?c.info:{};return[{entityKey:t,relativePath:o,name:typeof l.title==`string`&&l.title?l.title:u(o),description:typeof l.description==`string`?l.description:void 0}]})}function u(e){return i.basename(e,i.extname(e))}function d(e){return e.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean)}function f(e,t){let n=t.toLowerCase(),r=e.find(e=>e.name.toLowerCase().includes(n));if(r)return r;let i=new Set(d(n)),a,o=0;for(let t of e){let e=d(t.name);e.length>o&&e.every(e=>i.has(e))&&(a=t,o=e.length)}return a}async function p(e,t){let n=f(await s(t),e);if(n)return n;throw Error(`No GraphQL schema found matching "${e}".`)}async function m(e,t){let n=await p(e,t),r=o.get(t);r||(r=/* @__PURE__ */ new Map,o.set(t,r));let i=r.get(n.entityKey);return i||(i=h(t,n),r.set(n.entityKey,i)),{name:n.name,schema:await i}}async function h(e,t){try{let n=await e.entities.load(t.entityKey),{buildSchema:r}=await import(`graphql`);return r(n)}catch(n){throw e.logger?.warn(`MCP: cannot read graphql entity "${t.entityKey}": ${r(n)}`),Error(`The GraphQL schema "${t.name}" could not be read.`)}}export{c as hasGraphqlSchemas,s as listGraphqlSchemas,m as loadGraphqlSchema,p as resolveGraphqlSchema};
@@ -1 +1 @@
1
- import{compileContentGlob as e}from"../../../../utils/glob.js";import{SPEC_KIND_OPENAPI as t}from"../../../../types/api-entity.js";import{filterApiDocsByRbac as n}from"../../../../../../server/rbac/api-docs.js";import{canonicalSlugPath as r}from"../../ignored-routes.js";import{formatError as i}from"../tool-errors.js";import{OPERATION_METHODS as a,absolutePath as o,findDocumentedPath as s,formatCandidates as c,isDefinitionHidden as l,recoveryToolNames as u,visibleMethodsAt as d}from"./openapi-document.js";import{apiTitleKey as f,compareApiDescriptions as p}from"./api-titles.js";const m=/* @__PURE__ */ new WeakMap;function h(e,r){let a=m.get(e);a||(a=/* @__PURE__ */ new Map,m.set(e,a));let o=a.get(r);if(o)return o;let s=t=>e.logger?.warn(t),c=e.entities.load(r).then(r=>({full:r,visible:n(r,t,e.request.teams,{warn:s})})).catch(e=>(s(`MCP: skipping api entity "${r}": ${i(e)}`),null));return a.set(r,c),c}const g=new Set(a);function _(e){return Object.values(e.paths??{}).some(e=>typeof e==`object`&&!!e&&Object.keys(e).some(e=>g.has(e.toLowerCase())))}function v(e,t,n){let{title:r=``,version:i=``,description:a}=t.info??{};return{entityKey:e.entityKey,definition:t,fullDefinition:n,relativePath:e.relativePath,name:r,description:typeof a==`string`?a:``,version:String(i),servers:t.servers??[]}}async function y(t){let n=t.config.mcp?.ignore??[],i=n.length>0?e(n):()=>!1;return(await t.entities.list({type:`api`})).flatMap(({key:e,metadata:t})=>{let{specType:n,sourcePath:a,routeSlug:o}=t??{};return n!==`openapi`||typeof a!=`string`||i(a)||typeof o==`string`&&i(r(o,a))?[]:[{entityKey:e,relativePath:a}]})}async function b(e,t){let n=await h(e,t.entityKey);return!n?.visible||!_(n.visible)||l(n.visible.info)?null:v(t,n.visible,n.full)}async function x(e){let t=await y(e);return(await Promise.all(t.map(t=>b(e,t)))).filter(e=>e!==null)}const S=/* @__PURE__ */ new Set([`api`,`apis`,`rest`,`restful`,`openapi`,`graphql`,`spec`,`specification`,`service`,`services`]);function C(e){return e.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean)}function w(e){return new Set(C(e).filter(e=>!S.has(e)))}function T(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function E(e,t,n){let r=w(t);return e.map(e=>{let t=e[n];return{api:e,text:t,score:[...w(t)].filter(e=>r.has(e)).length}}).sort((e,t)=>t.score-e.score||e.text.localeCompare(t.text)).map(({api:e})=>e)}function D(e,t){return c(E(e,t,`name`).map(e=>`"${e.name}" (${e.relativePath})`))}function O(e,t){return c(E(e,t,`relativePath`).map(e=>`"${e.relativePath}"`))}function k(e,t){let n=f(t);if(!n)return{matches:[],isExactTitle:!1};let r=e.map(e=>({api:e,title:f(e.name)})),i=e=>e.map(({api:e})=>e),a=r.filter(({title:e})=>e===n);if(a.length>0)return{matches:i(a),isExactTitle:!0};let o=r.filter(({title:e})=>e.includes(n));if(o.length>0)return{matches:i(o),isExactTitle:!1};let s=w(n);return s.size===0?{matches:[],isExactTitle:!1}:{matches:i(r.filter(({title:e})=>{let t=w(e);return t.size>0&&T(t,s)})),isExactTitle:!1}}function A(e,t,n){let{matches:r,isExactTitle:i}=k(e,t);if(r.length===0)return;if(!i){let e=[...new Set(r.map(({name:e})=>e))];if(e.length>1)throw Error(`"${t}" matches ${e.length} APIs: ${c(e.map(e=>`"${e}"`))}. Pass one of those names exactly, or the "filePath" parameter from list-apis.`)}let a=n?r.filter(e=>e.version===n):r;if(a.length===0){let e=[...new Set(r.map(({version:e})=>e||`(no version)`))];throw Error(`"${r[0].name||t}" has no version "${n}". Available versions: ${c(e)}.`)}let[o,...s]=[...a].sort(p);return{api:o,otherMatches:s.length>0?s:void 0}}function j(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.filter(({name:e})=>e.toLowerCase().includes(n));return r.length>0?r:e.filter(({description:e})=>e.toLowerCase().includes(n))}function M({version:e,relativePath:t}){return{version:e||void 0,filePath:t}}function N(e,t=[]){return{api:e,otherMatches:t.length>0?t.map(M):void 0}}function P(e){return`Pass \`name\` (the API title, or a unique part of it) or \`filePath\` from ${u(e).listApis}.`}async function F(e,t){let{name:n,version:r,filePath:i}=e;if(!i&&!n)return I(e,t);let a=await y(t),o=i??n,s=a.find(e=>e.relativePath===o),c=s&&await b(t,s);if(c)return N(c);let l=await x(t);if(i){let e=O(l,i);throw Error(`No API found with filePath "${i}". `+(e?`Available file paths: ${e}. `:``)+`File paths come from ${u(t.mcpMode).listApis}.`)}let d=A(l,n??``,r);if(d)return N(d.api,d.otherMatches);let f=D(l,n??``);throw Error(f?`No API found matching "${n}". Available APIs: ${f}. Pass one of those names, or its \`filePath\`.`:`No API found matching "${n}".`)}async function I({path:e,method:t,version:n},r){let i=await x(r);if(i.length===0)throw Error(`This project documents no OpenAPI description.`);if(i.length===1){let[e]=i;if(n&&e.version!==n)throw Error(`"${e.name}" has no version "${n}". Available versions: ${e.version||`(no version)`}.`);return N(e)}if(!e||!t||i.length>10)throw Error(`${P(r.mcpMode)} Available APIs: ${D(i,``)}.`);let a=[],l=/* @__PURE__ */ new Set,u=[],f=t.toUpperCase();for(let t of i){let n=s(t.definition,e);if(!n)continue;let r=d(t.definition,n.path);r.includes(f)?(a.push(t),n.isTemplateMatch&&l.add(t)):r.length>0&&u.push({api:t,methods:r})}if(a.sort(p),a.length===0)throw R(i,u,e,t,r.mcpMode);let m=n?a.filter(e=>e.version===n):a;if(m.length===0){let t=[...new Set(a.map(({version:e})=>e||`(no version)`))];throw Error(`No API documenting "${o(e)}" has version "${n}". Available versions: ${c(t)}.`)}let h=m.filter(e=>!l.has(e));return L(h.length>0?h:m,e,t,r.mcpMode)}function L(e,t,n,r){let i=new Set(e.map(({name:e})=>f(e)));if(i.size>1){let a=[...i].map(t=>{let[n]=e.filter(e=>f(e.name)===t);return`"${n.name}" (${n.relativePath})`});throw Error(`${n.toUpperCase()} ${o(t)} is documented by ${i.size} APIs: ${c(a)}. Pass \`name\` or \`filePath\` from ${u(r).listApis} to pick one.`)}let[a,...s]=e;return N(a,s)}function R(e,t,n,r,i){if(t.length>0){let e=t.map(({api:e,methods:t})=>`"${e.name}" (${e.relativePath}) documents ${c(t)}.`).join(` `);return/* @__PURE__ */ Error(`No API documents ${r.toUpperCase()} ${o(n)}. ${e}`)}let{endpoints:a,search:s}=u(i);return/* @__PURE__ */ Error(`No API in this project documents ${o(n)}. Available APIs: ${D(e,``)}. Call ${a} with one of them, or ${s} with a keyword from the request.`)}export{D as describeAvailableApis,j as filterApisByName,A as findApiByNameAndVersion,x as loadApiCatalog,F as resolveApi};
1
+ import{compileContentGlob as e}from"../../../../utils/glob.js";import{SPEC_KIND_OPENAPI as t}from"../../../../../../shared/constants/api-spec-kinds.js";import{OPERATION_METHODS as n}from"../../../../../../shared/constants/openapi-operation-methods.js";import{filterApiDocsByRbac as r}from"../../../../../../shared/rbac/api-docs.js";import{canonicalSlugPath as i}from"../../ignored-routes.js";import{formatError as a}from"../tool-errors.js";import{apiTitleKey as o,compareApiDescriptions as s}from"./api-titles.js";import{absolutePath as c,findDocumentedPath as l,formatCandidates as u,isDefinitionHidden as d,recoveryToolNames as f,visibleMethodsAt as p}from"./openapi-document.js";const m=/* @__PURE__ */ new WeakMap;function h(e,n){let i=m.get(e);i||(i=/* @__PURE__ */ new Map,m.set(e,i));let o=i.get(n);if(o)return o;let s=t=>e.logger?.warn(t),c=e.entities.load(n).then(n=>({full:n,visible:r(n,t,e.request.teams,{warn:s})})).catch(e=>(s(`MCP: skipping api entity "${n}": ${a(e)}`),null));return i.set(n,c),c}const g=new Set(n);function _(e){return Object.values(e.paths??{}).some(e=>typeof e==`object`&&!!e&&Object.keys(e).some(e=>g.has(e.toLowerCase())))}function v(e,t,n){let{title:r=``,version:i=``,description:a}=t.info??{};return{entityKey:e.entityKey,definition:t,fullDefinition:n,relativePath:e.relativePath,name:r,description:typeof a==`string`?a:``,version:String(i),servers:t.servers??[]}}async function y(t){let n=t.config.mcp?.ignore??[],r=n.length>0?e(n):()=>!1;return(await t.entities.list({type:`api`})).flatMap(({key:e,metadata:t})=>{let{specType:n,sourcePath:a,routeSlug:o}=t??{};return n!==`openapi`||typeof a!=`string`||r(a)||typeof o==`string`&&r(i(o,a))?[]:[{entityKey:e,relativePath:a}]})}async function b(e,t){let n=await h(e,t.entityKey);return!n?.visible||!_(n.visible)||d(n.visible.info)?null:v(t,n.visible,n.full)}async function x(e){let t=await y(e);return(await Promise.all(t.map(t=>b(e,t)))).filter(e=>e!==null)}const S=/* @__PURE__ */ new Set([`api`,`apis`,`rest`,`restful`,`openapi`,`graphql`,`spec`,`specification`,`service`,`services`]);function C(e){return e.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean)}function w(e){return new Set(C(e).filter(e=>!S.has(e)))}function T(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function E(e,t,n){let r=w(t);return e.map(e=>{let t=e[n];return{api:e,text:t,score:[...w(t)].filter(e=>r.has(e)).length}}).sort((e,t)=>t.score-e.score||e.text.localeCompare(t.text)).map(({api:e})=>e)}function D(e,t){return u(E(e,t,`name`).map(e=>`"${e.name}" (${e.relativePath})`))}function O(e,t){return u(E(e,t,`relativePath`).map(e=>`"${e.relativePath}"`))}function k(e,t){let n=o(t);if(!n)return{matches:[],isExactTitle:!1};let r=e.map(e=>({api:e,title:o(e.name)})),i=e=>e.map(({api:e})=>e),a=r.filter(({title:e})=>e===n);if(a.length>0)return{matches:i(a),isExactTitle:!0};let s=r.filter(({title:e})=>e.includes(n));if(s.length>0)return{matches:i(s),isExactTitle:!1};let c=w(n);return c.size===0?{matches:[],isExactTitle:!1}:{matches:i(r.filter(({title:e})=>{let t=w(e);return t.size>0&&T(t,c)})),isExactTitle:!1}}function A(e,t,n){let{matches:r,isExactTitle:i}=k(e,t);if(r.length===0)return;if(!i){let e=[...new Set(r.map(({name:e})=>e))];if(e.length>1)throw Error(`"${t}" matches ${e.length} APIs: ${u(e.map(e=>`"${e}"`))}. Pass one of those names exactly, or the "filePath" parameter from list-apis.`)}let a=n?r.filter(e=>e.version===n):r;if(a.length===0){let e=[...new Set(r.map(({version:e})=>e||`(no version)`))];throw Error(`"${r[0].name||t}" has no version "${n}". Available versions: ${u(e)}.`)}let[o,...c]=[...a].sort(s);return{api:o,otherMatches:c.length>0?c:void 0}}function j(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.filter(({name:e})=>e.toLowerCase().includes(n));return r.length>0?r:e.filter(({description:e})=>e.toLowerCase().includes(n))}function M({version:e,relativePath:t}){return{version:e||void 0,filePath:t}}function N(e,t=[]){return{api:e,otherMatches:t.length>0?t.map(M):void 0}}function P(e){return`Pass \`name\` (the API title, or a unique part of it) or \`filePath\` from ${f(e).listApis}.`}async function F(e,t){let{name:n,version:r,filePath:i}=e;if(!i&&!n)return I(e,t);let a=await y(t),o=i??n,s=a.find(e=>e.relativePath===o),c=s&&await b(t,s);if(c)return N(c);let l=await x(t);if(i){let e=O(l,i);throw Error(`No API found with filePath "${i}". `+(e?`Available file paths: ${e}. `:``)+`File paths come from ${f(t.mcpMode).listApis}.`)}let u=A(l,n??``,r);if(u)return N(u.api,u.otherMatches);let d=D(l,n??``);throw Error(d?`No API found matching "${n}". Available APIs: ${d}. Pass one of those names, or its \`filePath\`.`:`No API found matching "${n}".`)}async function I({path:e,method:t,version:n},r){let i=await x(r);if(i.length===0)throw Error(`This project documents no OpenAPI description.`);if(i.length===1){let[e]=i;if(n&&e.version!==n)throw Error(`"${e.name}" has no version "${n}". Available versions: ${e.version||`(no version)`}.`);return N(e)}if(!e||!t||i.length>10)throw Error(`${P(r.mcpMode)} Available APIs: ${D(i,``)}.`);let a=[],o=/* @__PURE__ */ new Set,d=[],f=t.toUpperCase();for(let t of i){let n=l(t.definition,e);if(!n)continue;let r=p(t.definition,n.path);r.includes(f)?(a.push(t),n.isTemplateMatch&&o.add(t)):r.length>0&&d.push({api:t,methods:r})}if(a.sort(s),a.length===0)throw R(i,d,e,t,r.mcpMode);let m=n?a.filter(e=>e.version===n):a;if(m.length===0){let t=[...new Set(a.map(({version:e})=>e||`(no version)`))];throw Error(`No API documenting "${c(e)}" has version "${n}". Available versions: ${u(t)}.`)}let h=m.filter(e=>!o.has(e));return L(h.length>0?h:m,e,t,r.mcpMode)}function L(e,t,n,r){let i=new Set(e.map(({name:e})=>o(e)));if(i.size>1){let a=[...i].map(t=>{let[n]=e.filter(e=>o(e.name)===t);return`"${n.name}" (${n.relativePath})`});throw Error(`${n.toUpperCase()} ${c(t)} is documented by ${i.size} APIs: ${u(a)}. Pass \`name\` or \`filePath\` from ${f(r).listApis} to pick one.`)}let[a,...s]=e;return N(a,s)}function R(e,t,n,r,i){if(t.length>0){let e=t.map(({api:e,methods:t})=>`"${e.name}" (${e.relativePath}) documents ${u(t)}.`).join(` `);return/* @__PURE__ */ Error(`No API documents ${r.toUpperCase()} ${c(n)}. ${e}`)}let{endpoints:a,search:o}=f(i);return/* @__PURE__ */ Error(`No API in this project documents ${c(n)}. Available APIs: ${D(e,``)}. Call ${a} with one of them, or ${o} with a keyword from the request.`)}export{D as describeAvailableApis,j as filterApisByName,A as findApiByNameAndVersion,x as loadApiCatalog,F as resolveApi};
@@ -1 +1 @@
1
- import{toolNameForMode as e}from"../codemode/tool-declarations.js";import{replaceServerVariables as t}from"@redocly/api-docs/lib/services/code-samples/server-variables.js";const n=[`get`,`put`,`post`,`delete`,`options`,`head`,`patch`,`trace`,`query`,`x-query`],r=new Set(n);function i(e,t=`docs`){return!!e?.[`x-mcp`]?.[t]?.hide}function a(e,t=`docs`){return!!e?.[`x-mcp`]?.[t]?.hide}function o(e){if(!(`x-mcp`in e))return e;let{"x-mcp":t,...n}=e;return n}function s(e){return!e||i(e)?[]:Object.entries(e).filter(e=>{let[t,n]=e;return r.has(t.toLowerCase())&&typeof n==`object`&&!!n&&!i(n)})}function c(e){let t=[];for(let[n,r]of Object.entries(e.paths??{}))for(let[e,i]of s(r))t.push({path:n,method:e.toUpperCase(),summary:i.summary,description:i.description,security:i.security});return t}function l(e,t){return s(e.paths?.[t]).map(([e])=>e.toUpperCase()).sort()}function u(e){return Object.keys(e.paths??{}).filter(t=>l(e,t).length>0).sort()}function d(e){let t={};for(let[n,a]of Object.entries(e.paths??{})){if(typeof a!=`object`||!a||i(a))continue;let e=0,s=Object.entries(o(a)).flatMap(([t,n])=>r.has(t.toLowerCase())?i(n)?[]:(e+=1,[[t,typeof n==`object`&&n?o(n):n]]):[[t,n]]);e!==0&&(t[n]=Object.fromEntries(s))}return{...e,info:o(e.info),paths:t}}function f(e){return e.startsWith(`/`)?e:`/${e}`}function p(e){let[t]=e.replace(/^[a-z][a-z\d+.-]*:\/\/[^/?#]*/i,``).split(/[?#]/,1);return f(t)}function m(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)--t;return e.slice(0,t)}function h(e,n){let r=p(n),i=m(r),a=i.toLowerCase(),o=/* @__PURE__ */ new Set([r,i]);for(let n of e.servers??[]){let e=m(p(t(n)));e!==`/`&&a.startsWith(`${e.toLowerCase()}/`)&&o.add(i.slice(e.length))}return[...o]}function g(e){return e.split(`/`).slice(1)}const _=/^\{[^}]+\}$/;function v(e){return e.startsWith(`:`)?e.length>1:_.test(e)}function y(e){let t=[],n=0;for(let r=e.indexOf(`{`);r!==-1;r=e.indexOf(`{`,n)){let i=e.indexOf(`}`,r);if(i===-1)break;t.push(e.slice(n,r)),n=i+1}return t.push(e.slice(n)),t}function b(e,t){let n=y(e);if(n.length===1)return t===n[0];let r=n[0],i=n[n.length-1];if(!t.startsWith(r))return!1;let a=r.length;for(let e of n.slice(1,-1)){let n=t.indexOf(e,a+1);if(n===-1)return!1;a=n+e.length}return t.length-i.length>a&&t.endsWith(i)}function x(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return v(r)?_.test(e):b(e,r)})}function S(e){return e.map(e=>g(e.toLowerCase()))}function C(e,t){let n=g(e.toLowerCase());return t.some(e=>x(n,e))}function w(e,t){let n=f(t);if(e.paths?.[n])return{path:n,isTemplateMatch:!1};let r=h(e,t),i=u(e),a=r.find(e=>i.includes(e));if(a)return{path:a,isTemplateMatch:!1};for(let e of r.map(e=>e.toLowerCase())){let t=i.find(t=>t.toLowerCase()===e);if(t)return{path:t,isTemplateMatch:!1}}for(let e of S(r)){let t=i.filter(t=>C(t,[e]));if(t.length===1)return{path:t[0],isTemplateMatch:!0};if(t.length>1)return}}function T(e,t){return w(e,t)?.path??p(t)}function E(e,t){let n=S(h(e,t)),r=new Set(n.flat());return u(e).map(e=>({path:e,isMatch:C(e,n),sharedSegments:g(e.toLowerCase()).filter(e=>r.has(e)).length})).sort((e,t)=>Number(t.isMatch)-Number(e.isMatch)||t.sharedSegments-e.sharedSegments).map(({path:e})=>e)}const D=15;function O(e){let t=e.slice(0,15),n=e.length-t.length;return n>0?`${t.join(`, `)} (+${n} more)`:t.join(`, `)}function k(t){let n=n=>t===`code`?`site.${e(n,t)}`:n;return{endpoints:n(`get-endpoints`),search:n(`search`),listApis:n(`list-apis`),listPages:n(`list-pages`)}}function A(e,t,n,r){let i=E(e,n);if(i.length===0)return`Endpoint not found`;let{endpoints:a,search:o}=k(r);return`No path "${n}" in "${t}". Documented paths: ${O(i)}. Call ${a} for the full list, or ${o} with a keyword from the request.`}function j(e,t,n,r){let i=l(e,n);return i.length===0?`Endpoint not found`:`"${n}" in "${t}" documents no ${r.toUpperCase()}. Available methods: ${O(i)}.`}export{D as MAX_LISTED_CANDIDATES,n as OPERATION_METHODS,f as absolutePath,j as describeMethodMiss,A as describePathMiss,w as findDocumentedPath,O as formatCandidates,a as isDefinitionHidden,i as isEndpointHidden,T as matchDocumentedPath,k as recoveryToolNames,c as visibleEndpoints,l as visibleMethodsAt,s as visibleOperations,u as visiblePaths,d as withVisibleOperationsOnly,o as withoutXMcp};
1
+ import{OPERATION_METHODS as e}from"../../../../../../shared/constants/openapi-operation-methods.js";import{toolNameForMode as t}from"../codemode/tool-declarations.js";import{replaceServerVariables as n}from"@redocly/api-docs/server";const r=new Set(e);function i(e,t=`docs`){return!!e?.[`x-mcp`]?.[t]?.hide}function a(e,t=`docs`){return!!e?.[`x-mcp`]?.[t]?.hide}function o(e){if(!(`x-mcp`in e))return e;let{"x-mcp":t,...n}=e;return n}function s(e){return!e||i(e)?[]:Object.entries(e).filter(e=>{let[t,n]=e;return r.has(t.toLowerCase())&&typeof n==`object`&&!!n&&!i(n)})}function c(e){let t=[];for(let[n,r]of Object.entries(e.paths??{}))for(let[e,i]of s(r))t.push({path:n,method:e.toUpperCase(),summary:i.summary,description:i.description,security:i.security});return t}function l(e,t){return s(e.paths?.[t]).map(([e])=>e.toUpperCase()).sort()}function u(e){return Object.keys(e.paths??{}).filter(t=>l(e,t).length>0).sort()}function d(e){let t={};for(let[n,a]of Object.entries(e.paths??{})){if(typeof a!=`object`||!a||i(a))continue;let e=0,s=Object.entries(o(a)).flatMap(([t,n])=>r.has(t.toLowerCase())?i(n)?[]:(e+=1,[[t,typeof n==`object`&&n?o(n):n]]):[[t,n]]);e!==0&&(t[n]=Object.fromEntries(s))}return{...e,info:o(e.info),paths:t}}function f(e){return e.startsWith(`/`)?e:`/${e}`}function p(e){let[t]=e.replace(/^[a-z][a-z\d+.-]*:\/\/[^/?#]*/i,``).split(/[?#]/,1);return f(t)}function m(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)--t;return e.slice(0,t)}function h(e,t){let r=p(t),i=m(r),a=i.toLowerCase(),o=/* @__PURE__ */ new Set([r,i]);for(let t of e.servers??[]){let e=m(p(n(t)));e!==`/`&&a.startsWith(`${e.toLowerCase()}/`)&&o.add(i.slice(e.length))}return[...o]}function g(e){return e.split(`/`).slice(1)}const _=/^\{[^}]+\}$/;function v(e){return e.startsWith(`:`)?e.length>1:_.test(e)}function y(e){let t=[],n=0;for(let r=e.indexOf(`{`);r!==-1;r=e.indexOf(`{`,n)){let i=e.indexOf(`}`,r);if(i===-1)break;t.push(e.slice(n,r)),n=i+1}return t.push(e.slice(n)),t}function b(e,t){let n=y(e);if(n.length===1)return t===n[0];let r=n[0],i=n[n.length-1];if(!t.startsWith(r))return!1;let a=r.length;for(let e of n.slice(1,-1)){let n=t.indexOf(e,a+1);if(n===-1)return!1;a=n+e.length}return t.length-i.length>a&&t.endsWith(i)}function x(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return v(r)?_.test(e):b(e,r)})}function S(e){return e.map(e=>g(e.toLowerCase()))}function C(e,t){let n=g(e.toLowerCase());return t.some(e=>x(n,e))}function w(e,t){let n=f(t);if(e.paths?.[n])return{path:n,isTemplateMatch:!1};let r=h(e,t),i=u(e),a=r.find(e=>i.includes(e));if(a)return{path:a,isTemplateMatch:!1};for(let e of r.map(e=>e.toLowerCase())){let t=i.find(t=>t.toLowerCase()===e);if(t)return{path:t,isTemplateMatch:!1}}for(let e of S(r)){let t=i.filter(t=>C(t,[e]));if(t.length===1)return{path:t[0],isTemplateMatch:!0};if(t.length>1)return}}function T(e,t){return w(e,t)?.path??p(t)}function E(e,t){let n=S(h(e,t)),r=new Set(n.flat());return u(e).map(e=>({path:e,isMatch:C(e,n),sharedSegments:g(e.toLowerCase()).filter(e=>r.has(e)).length})).sort((e,t)=>Number(t.isMatch)-Number(e.isMatch)||t.sharedSegments-e.sharedSegments).map(({path:e})=>e)}const D=15;function O(e){let t=e.slice(0,15),n=e.length-t.length;return n>0?`${t.join(`, `)} (+${n} more)`:t.join(`, `)}function k(e){let n=n=>e===`code`?`site.${t(n,e)}`:n;return{endpoints:n(`get-endpoints`),search:n(`search`),listApis:n(`list-apis`),listPages:n(`list-pages`)}}function A(e,t,n,r){let i=E(e,n);if(i.length===0)return`Endpoint not found`;let{endpoints:a,search:o}=k(r);return`No path "${n}" in "${t}". Documented paths: ${O(i)}. Call ${a} for the full list, or ${o} with a keyword from the request.`}function j(e,t,n,r){let i=l(e,n);return i.length===0?`Endpoint not found`:`"${n}" in "${t}" documents no ${r.toUpperCase()}. Available methods: ${O(i)}.`}export{D as MAX_LISTED_CANDIDATES,f as absolutePath,j as describeMethodMiss,A as describePathMiss,w as findDocumentedPath,O as formatCandidates,a as isDefinitionHidden,i as isEndpointHidden,T as matchDocumentedPath,k as recoveryToolNames,c as visibleEndpoints,l as visibleMethodsAt,s as visibleOperations,u as visiblePaths,d as withVisibleOperationsOnly,m as withoutTrailingSlashes,o as withoutXMcp};
@@ -1 +1 @@
1
- import{resolveParameters as e,resolveRef as t,resolveRequestBody as n,resolveResponses as r,unescapeJsonPointerToken as i}from"@redocly/api-docs/lib/utils/inline-openapi-refs.js";const a=/^#\/components\/([^/]+)\/([^/]+)(\/.*)?$/;function o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function s(e,n){let r={},s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Set,l=[e];for(;l.length>0;){let e=l.pop();if(typeof e==`object`&&e){if(o(e)&&typeof e.$ref==`string`&&!s.has(e.$ref)){s.add(e.$ref);let[,o,u]=a.exec(e.$ref)??[],d=u&&i(u);if(o&&d&&!c.has(`${o}/${d}`)){let e=t(`#/components/${o}/${u}`,n);e!==void 0&&(c.add(`${o}/${d}`),(r[o]??={})[d]=e,l.push(e))}}for(let t of Object.values(e))l.push(t)}}return Object.keys(r).length>0?r:void 0}function c(e,n){let r=o(e)&&typeof e.$ref==`string`?t(e.$ref,n)??e:e,{name:i,in:a}=o(r)?r:{};return typeof i==`string`&&typeof a==`string`?`${a}:${i}`:JSON.stringify(e)}function l(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of[...e,...t])i&&r.set(c(i,n),i);return[...r.values()]}function u({operation:e,pathParams:t,definition:n}){let r={...e,parameters:l(t,e.parameters??[],n)};return{operation:r,components:s(r,n)}}var d=class extends Error{};function f(e){let t=e,n=/* @__PURE__ */ new Map;return(e,r)=>{let i=r===void 0?void 0:n.get(r);if(i===void 0&&(i=JSON.stringify(e).length,r!==void 0&&n.set(r,i)),t-=i,t<0)throw new d}}function p({operation:t,pathParams:i,definition:a},o){let c=f(o);try{let o={...t,parameters:e({pathParams:i,opParams:t.parameters||[],definition:a,charge:c}),requestBody:n(t.requestBody,a,c),responses:t.responses&&r(t.responses,a,c)};return{operation:o,components:s(o,a)}}catch{return}}export{p as inlineOperation,u as resolveOperation};
1
+ import{resolveParameters as e,resolveRef as t,resolveRequestBody as n,resolveResponses as r,unescapeJsonPointerToken as i}from"@redocly/api-docs/server";const a=/^#\/components\/([^/]+)\/([^/]+)(\/.*)?$/;function o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function s(e,n){let r={},s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Set,l=[e];for(;l.length>0;){let e=l.pop();if(typeof e==`object`&&e){if(o(e)&&typeof e.$ref==`string`&&!s.has(e.$ref)){s.add(e.$ref);let[,o,u]=a.exec(e.$ref)??[],d=u&&i(u);if(o&&d&&!c.has(`${o}/${d}`)){let e=t(`#/components/${o}/${u}`,n);e!==void 0&&(c.add(`${o}/${d}`),(r[o]??={})[d]=e,l.push(e))}}for(let t of Object.values(e))l.push(t)}}return Object.keys(r).length>0?r:void 0}function c(e,n){let r=o(e)&&typeof e.$ref==`string`?t(e.$ref,n)??e:e,{name:i,in:a}=o(r)?r:{};return typeof i==`string`&&typeof a==`string`?`${a}:${i}`:JSON.stringify(e)}function l(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of[...e,...t])i&&r.set(c(i,n),i);return[...r.values()]}function u({operation:e,pathParams:t,definition:n}){let r={...e,parameters:l(t,e.parameters??[],n)};return{operation:r,components:s(r,n)}}var d=class extends Error{};function f(e){let t=e,n=/* @__PURE__ */ new Map;return(e,r)=>{let i=r===void 0?void 0:n.get(r);if(i===void 0&&(i=JSON.stringify(e).length,r!==void 0&&n.set(r,i)),t-=i,t<0)throw new d}}function p({operation:t,pathParams:i,definition:a},o){let c=f(o);try{let o={...t,parameters:e({pathParams:i,opParams:t.parameters||[],definition:a,charge:c}),requestBody:n(t.requestBody,a,c),responses:t.responses&&r(t.responses,a,c)};return{operation:o,components:s(o,a)}}catch{return}}export{p as inlineOperation,u as resolveOperation};
@@ -1 +1 @@
1
- import{describeMethodMiss as e,describePathMiss as t,matchDocumentedPath as n,visibleEndpoints as r,visibleOperations as i,withVisibleOperationsOnly as a,withoutXMcp as o}from"./openapi-document.js";import{GET_ENDPOINTS_SCHEMA as s,GET_ENDPOINT_INFO_SCHEMA as c,GET_FULL_API_DESCRIPTION_SCHEMA as l,GET_SECURITY_SCHEMES_SCHEMA as u,LIST_APIS_CALLABLE_SCHEMA as d,LIST_APIS_SCHEMA as f,getEndpointInfoToolSchema as p,getEndpointsToolSchema as m,getFullApiDescriptionToolSchema as h,getSecuritySchemesToolSchema as g}from"./schemas.js";import{apiTitleKey as _,countApiTitles as v,orderSharedTitles as y}from"./api-titles.js";import{filterApisByName as b,loadApiCatalog as x,resolveApi as S}from"./openapi-catalog.js";import{callableApis as C}from"../gateway/eligibility.js";import{inlineOperation as w,resolveOperation as T}from"./openapi-refs.js";import{replaceServerVariables as E}from"@redocly/api-docs/lib/services/code-samples/server-variables.js";const D=8388608,O={apiName:`name`,api:`name`};function k(e){return e.map(e=>({...e,url:E(e)}))}async function A(e){return new Set((await C(e)).map(e=>e.entityKey))}const j=[{schema:f,schemaFor:async e=>(await A(e)).size>0?d:f,async execute(e,t){let n=e??{},{filter:r}=n,i=n.page??1,a=n.limit??300,o=await A(t),s=y(await x(t)),c=v(s),l=r?b(s,r):s,u=(i-1)*a;return{items:l.slice(u,u+a).map(({entityKey:e,relativePath:t,name:n,description:r,version:i,servers:a})=>({filePath:t,name:n,description:r,version:i,servers:k(a),ambiguousTitle:(c.get(_(n))??0)>1||void 0,callable:o.size>0?o.has(e):void 0})),limit:a,total:l.length,page:i,totalPages:Math.ceil(l.length/a)}}},{schema:s,schemaFor:e=>m(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:i}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:i,servers:k(n.servers),endpoints:r(n.definition)}}},{schema:c,schemaFor:e=>p(e.mcpMode),inputAliases:O,async execute(r,a){let s=r??{},{path:c,method:l}=s;if(!c||!l)throw Error(`Both "path" and "method" are required (e.g. path: "/tickets", method: "GET").`);let{api:u,otherMatches:d}=await S(s,a),{definition:f}=u,p=d?` Other definitions share this title: ${d.map(e=>`"${e.filePath}"`).join(`, `)}. Pass "filePath" to check them.`:``,m=n(f,c),h=f.paths?.[m],g=i(h);if(!h||g.length===0)throw Error(t(f,u.name,m,a.mcpMode)+p);let _=g.find(([e])=>e.toLowerCase()===l.toLowerCase())?.[1];if(!_)throw Error(e(f,u.name,m,l)+p);let v={operation:o(_),pathParams:h.parameters??[],definition:f},{operation:y,components:b}=(a.mcpMode===`code`?w(v,1048576):void 0)??T(v),x={api:u.name,version:u.version,filePath:u.relativePath,otherMatches:d,servers:k(u.servers),endpoint:{path:m,method:l.toUpperCase(),...y},globalSecurity:f.security??[],securitySchemes:f.components?.securitySchemes??{},components:b},C=JSON.stringify(x,null,2).length;if(C>D)throw Error(`${l.toUpperCase()} ${m} is ${C} bytes, over the ${D} byte limit.`);return x}},{schema:u,schemaFor:e=>g(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:r}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:r,securitySchemes:n.definition.components?.securitySchemes??{},security:n.definition.security??[]}}},{schema:l,schemaFor:e=>h(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:r}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:r,definition:a(n.definition)}}}];export{j as openApiTools};
1
+ import{GET_ENDPOINTS_SCHEMA as e,GET_ENDPOINT_INFO_SCHEMA as t,GET_FULL_API_DESCRIPTION_SCHEMA as n,GET_SECURITY_SCHEMES_SCHEMA as r,LIST_APIS_CALLABLE_SCHEMA as i,LIST_APIS_SCHEMA as a,getEndpointInfoToolSchema as o,getEndpointsToolSchema as s,getFullApiDescriptionToolSchema as c,getSecuritySchemesToolSchema as l}from"./schemas.js";import{apiTitleKey as u,countApiTitles as d,orderSharedTitles as f}from"./api-titles.js";import{describeMethodMiss as p,describePathMiss as m,matchDocumentedPath as h,visibleEndpoints as g,visibleOperations as _,withVisibleOperationsOnly as v,withoutXMcp as y}from"./openapi-document.js";import{filterApisByName as b,loadApiCatalog as x,resolveApi as S}from"./openapi-catalog.js";import{callableApis as C}from"../gateway/eligibility.js";import{inlineOperation as w,resolveOperation as T}from"./openapi-refs.js";import{replaceServerVariables as E}from"@redocly/api-docs/server";const D=8388608,O={apiName:`name`,api:`name`};function k(e){return e.map(e=>({...e,url:E(e)}))}async function A(e){return new Set((await C(e)).map(e=>e.entityKey))}const j=[{schema:a,schemaFor:async e=>(await A(e)).size>0?i:a,async execute(e,t){let n=e??{},{filter:r}=n,i=n.page??1,a=n.limit??300,o=await A(t),s=f(await x(t)),c=d(s),l=r?b(s,r):s,p=(i-1)*a;return{items:l.slice(p,p+a).map(({entityKey:e,relativePath:t,name:n,description:r,version:i,servers:a})=>({filePath:t,name:n,description:r,version:i,servers:k(a),ambiguousTitle:(c.get(u(n))??0)>1||void 0,callable:o.size>0?o.has(e):void 0})),limit:a,total:l.length,page:i,totalPages:Math.ceil(l.length/a)}}},{schema:e,schemaFor:e=>s(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:r}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:r,servers:k(n.servers),endpoints:g(n.definition)}}},{schema:t,schemaFor:e=>o(e.mcpMode),inputAliases:O,async execute(e,t){let n=e??{},{path:r,method:i}=n;if(!r||!i)throw Error(`Both "path" and "method" are required (e.g. path: "/tickets", method: "GET").`);let{api:a,otherMatches:o}=await S(n,t),{definition:s}=a,c=o?` Other definitions share this title: ${o.map(e=>`"${e.filePath}"`).join(`, `)}. Pass "filePath" to check them.`:``,l=h(s,r),u=s.paths?.[l],d=_(u);if(!u||d.length===0)throw Error(m(s,a.name,l,t.mcpMode)+c);let f=d.find(([e])=>e.toLowerCase()===i.toLowerCase())?.[1];if(!f)throw Error(p(s,a.name,l,i)+c);let g={operation:y(f),pathParams:u.parameters??[],definition:s},{operation:v,components:b}=(t.mcpMode===`code`?w(g,1048576):void 0)??T(g),x={api:a.name,version:a.version,filePath:a.relativePath,otherMatches:o,servers:k(a.servers),endpoint:{path:l,method:i.toUpperCase(),...v},globalSecurity:s.security??[],securitySchemes:s.components?.securitySchemes??{},components:b},C=JSON.stringify(x,null,2).length;if(C>D)throw Error(`${i.toUpperCase()} ${l} is ${C} bytes, over the ${D} byte limit.`);return x}},{schema:r,schemaFor:e=>l(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:r}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:r,securitySchemes:n.definition.components?.securitySchemes??{},security:n.definition.security??[]}}},{schema:n,schemaFor:e=>c(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:r}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:r,definition:v(n.definition)}}}];export{j as openApiTools};
@@ -1 +1 @@
1
- import{normalizeRouteSlug as e}from"../../../../../../shared/utils/routes/normalize-route-slug.js";import{normalizeRoutePath as t}from"../../../../../../shared/utils/routes/normalize-route-path.js";import"../../../../../../shared/constants/app-data.js";import{filterRbacAnnotatedValue as n}from"../../../../../../server/rbac/filter.js";import{stripPathPrefix as r,withPathPrefix as i}from"../../../../../../shared/path-prefix.js";import{FOLDER_SIDEBAR_FILENAME_REGEX as a,SIDEBAR_AGGREGATOR_LOADER_ID as o,SIDEBAR_PLUGIN_ID as s,isTabbedSidebar as c}from"../../../sidebar/index.js";import{readIgnoredRouteSlugs as l}from"../../ignored-routes.js";import{toAppData as u}from"../../../../../../shared/utils/app-data.js";import{posix as d}from"node:path";const f=/* @__PURE__ */ new Set,p=/(?:\/index(?:\.html\.md|\.html|\.md)|\.md|\.html)$/;async function m(e){let[t,n]=await Promise.all([l(e.entities),e.pageMarkdown.listPages()]);return{pages:n.filter(e=>!t.has(e.slug)),isVisible:n=>!t.has(n)&&e.isSlugVisible(n)}}async function h(t){let[{pages:r,isVisible:i},a,o]=await Promise.all([m(t),w(t),T(t)]),s=o.filter(t=>typeof t.link==`string`&&t.external!==!0&&i(e(t.link))),c=new Map(r.map(e=>[e.slug,e.title])),l=/* @__PURE__ */ new Set,u=[],d=g(a.map(({path:e})=>e)),p=a.map(({path:e,value:t},n)=>({path:e,value:t,id:d[n],links:M(k(t))})),h=D(p.flatMap(({links:e})=>e.slice(0,1)));for(let{path:e,value:r,id:a,links:o}of p){for(let e of o)l.add(e);let d=N(k(n(r,t.request.teams)),e=>i(e)&&c.has(e));if(d.length===0)continue;let p=a===`/`,m=p?t.config.seo?.title||`Documentation`:a,g=O(e,d,s,c,p?f:h)||m;u.push({id:a,title:g,nodes:d})}u.sort((e,t)=>Number(t.id===`/`)-Number(e.id===`/`));let _=r.filter(e=>!l.has(e.slug)).map(e=>({type:`page`,label:e.title,link:e.slug,items:[]}));return _.length>0&&u.push({id:`other-pages`,title:`Other pages`,nodes:_}),{sections:u,pages:r}}function g(e){let t=e.map(e=>{let t=d.dirname(e);return t===`.`?`/`:t}),n=/* @__PURE__ */ new Map;for(let e of t)n.set(e,(n.get(e)??0)+1);return e.map((e,r)=>{let i=t[r],o=!a.test(e),s=(n.get(i)??0)>1;return o&&s?e:i})}function _(e){let t=(e,n)=>n.flatMap(n=>{if(n.type!==`section`)return[];let r=v(e,n.label);return[{id:r,title:n.label,link:n.link,nodes:n.items},...t(r,n.items)]});return e.flatMap(e=>[e,...t(e.id,e.nodes)])}function v(e,t){return`${e} > ${t}`}function y(e,t,n){let r=_(e),i=t.trim().toLowerCase(),a=r.find(e=>e.id.toLowerCase()===i);if(a)return a;let o=C(t,n),s=r.find(e=>e.link!==void 0&&e.link===o);if(s)return s;let c=r.filter(e=>e.title.toLowerCase()===i);return c.find(e=>c.every(t=>t===e||t.id.startsWith(`${e.id} > `)))}function b(e){return e.flatMap(e=>[...e.link?[e.link]:[],...b(e.items)])}function x(e){return e.reduce((e,t)=>e+(t.type===`page`?1:x(t.items)),0)}function S(e,t){return`${t}${i(e)}`}function C(e,n){let i;try{i=new URL(e.trim(),n).pathname}catch{return null}let a=r(i)??i;return t(a.replace(p,``))}async function w(e){let t=(await e.entities.list({pluginId:s})).flatMap(e=>{let t=e.metadata?.sourcePath;return e.loaderId===o&&typeof t==`string`?[{path:t,key:e.key}]:[]});return t.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path)),Promise.all(t.map(async({path:t,key:n})=>({path:t,value:await e.entities.load(n)})))}async function T(e){if(!await e.entities.get(`app-data`))return[];let t=u(await e.entities.load(`app-data`)).theme?.navbar?.items??[];return E(n(t,e.request.teams)??[])}function E(e){return e.flatMap(e=>[e,...E(e.items??[])])}function D(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return new Set([...t].filter(([,e])=>e>1).map(([e])=>e))}function O(e,t,n,r,i){let a=n.find(t=>Array.isArray(t.linkedSidebars)&&t.linkedSidebars.includes(e));if(typeof a?.label==`string`&&a.label!==``)return a.label;let o=t.find(e=>!e.link||!i.has(e.link));if(o)return o.link?r.get(o.link):o.label}function k(e){return e===null?[]:c(e)?e.tabs.map(A):e}function A(e){return{label:e.label,link:e.link,items:e.menu??e.items??[]}}function j(e){return e.link!==void 0&&e.external!==!0}function M(t){return t.flatMap(t=>[...j(t)&&t.link?[e(t.link)]:[],...M(t.items??[])])}function N(t,n){return t.flatMap(t=>{let r=j(t)&&t.link?e(t.link):void 0,i=r!==void 0&&n(r)?r:void 0;if(t.items){let e=N(t.items,n);return e.length===0&&!i?[]:[{type:`section`,label:t.label??``,...i?{link:i}:{},items:e}]}return i?[{type:`page`,label:t.label??i,link:i,items:[]}]:[]})}export{b as collectNodeLinks,x as countPages,y as findSection,_ as flattenSections,h as loadPageNavigation,m as loadVisiblePages,C as toPageSlug,S as toPublicUrl,v as toSectionId};
1
+ import{normalizeRouteSlug as e}from"../../../../../../shared/utils/routes/normalize-route-slug.js";import{normalizeRoutePath as t}from"../../../../../../shared/utils/routes/normalize-route-path.js";import"../../../../../../shared/constants/app-data.js";import{filterRbacAnnotatedValue as n}from"../../../../../../shared/rbac/filter.js";import{stripPathPrefix as r,withPathPrefix as i}from"../../../../../../shared/path-prefix.js";import{FOLDER_SIDEBAR_FILENAME_REGEX as a,SIDEBAR_AGGREGATOR_LOADER_ID as o,SIDEBAR_PLUGIN_ID as s,isTabbedSidebar as c}from"../../../sidebar/index.js";import{readIgnoredRouteSlugs as l}from"../../ignored-routes.js";import{toAppData as u}from"../../../../../../shared/utils/app-data.js";import{posix as d}from"node:path";const f=/* @__PURE__ */ new Set,p=/(?:\/index(?:\.html\.md|\.html|\.md)|\.md|\.html)$/;async function m(e){let[t,n]=await Promise.all([l(e.entities),e.pageMarkdown.listPages()]);return{pages:n.filter(e=>!t.has(e.slug)),isVisible:n=>!t.has(n)&&e.isSlugVisible(n)}}async function h(t){let[{pages:r,isVisible:i},a,o]=await Promise.all([m(t),w(t),T(t)]),s=o.filter(t=>typeof t.link==`string`&&t.external!==!0&&i(e(t.link))),c=new Map(r.map(e=>[e.slug,e.title])),l=/* @__PURE__ */ new Set,u=[],d=g(a.map(({path:e})=>e)),p=a.map(({path:e,value:t},n)=>({path:e,value:t,id:d[n],links:M(k(t))})),h=D(p.flatMap(({links:e})=>e.slice(0,1)));for(let{path:e,value:r,id:a,links:o}of p){for(let e of o)l.add(e);let d=N(k(n(r,t.request.teams)),e=>i(e)&&c.has(e));if(d.length===0)continue;let p=a===`/`,m=p?t.config.seo?.title||`Documentation`:a,g=O(e,d,s,c,p?f:h)||m;u.push({id:a,title:g,nodes:d})}u.sort((e,t)=>Number(t.id===`/`)-Number(e.id===`/`));let _=r.filter(e=>!l.has(e.slug)).map(e=>({type:`page`,label:e.title,link:e.slug,items:[]}));return _.length>0&&u.push({id:`other-pages`,title:`Other pages`,nodes:_}),{sections:u,pages:r}}function g(e){let t=e.map(e=>{let t=d.dirname(e);return t===`.`?`/`:t}),n=/* @__PURE__ */ new Map;for(let e of t)n.set(e,(n.get(e)??0)+1);return e.map((e,r)=>{let i=t[r],o=!a.test(e),s=(n.get(i)??0)>1;return o&&s?e:i})}function _(e){let t=(e,n)=>n.flatMap(n=>{if(n.type!==`section`)return[];let r=v(e,n.label);return[{id:r,title:n.label,link:n.link,nodes:n.items},...t(r,n.items)]});return e.flatMap(e=>[e,...t(e.id,e.nodes)])}function v(e,t){return`${e} > ${t}`}function y(e,t,n){let r=_(e),i=t.trim().toLowerCase(),a=r.find(e=>e.id.toLowerCase()===i);if(a)return a;let o=C(t,n),s=r.find(e=>e.link!==void 0&&e.link===o);if(s)return s;let c=r.filter(e=>e.title.toLowerCase()===i);return c.find(e=>c.every(t=>t===e||t.id.startsWith(`${e.id} > `)))}function b(e){return e.flatMap(e=>[...e.link?[e.link]:[],...b(e.items)])}function x(e){return e.reduce((e,t)=>e+(t.type===`page`?1:x(t.items)),0)}function S(e,t){return`${t}${i(e)}`}function C(e,n){let i;try{i=new URL(e.trim(),n).pathname}catch{return null}let a=r(i)??i;return t(a.replace(p,``))}async function w(e){let t=(await e.entities.list({pluginId:s})).flatMap(e=>{let t=e.metadata?.sourcePath;return e.loaderId===o&&typeof t==`string`?[{path:t,key:e.key}]:[]});return t.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path)),Promise.all(t.map(async({path:t,key:n})=>({path:t,value:await e.entities.load(n)})))}async function T(e){if(!await e.entities.get(`app-data`))return[];let t=u(await e.entities.load(`app-data`)).theme?.navbar?.items??[];return E(n(t,e.request.teams)??[])}function E(e){return e.flatMap(e=>[e,...E(e.items??[])])}function D(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return new Set([...t].filter(([,e])=>e>1).map(([e])=>e))}function O(e,t,n,r,i){let a=n.find(t=>Array.isArray(t.linkedSidebars)&&t.linkedSidebars.includes(e));if(typeof a?.label==`string`&&a.label!==``)return a.label;let o=t.find(e=>!e.link||!i.has(e.link));if(o)return o.link?r.get(o.link):o.label}function k(e){return e===null?[]:c(e)?e.tabs.map(A):e}function A(e){return{label:e.label,link:e.link,items:e.menu??e.items??[]}}function j(e){return e.link!==void 0&&e.external!==!0}function M(t){return t.flatMap(t=>[...j(t)&&t.link?[e(t.link)]:[],...M(t.items??[])])}function N(t,n){return t.flatMap(t=>{let r=j(t)&&t.link?e(t.link):void 0,i=r!==void 0&&n(r)?r:void 0;if(t.items){let e=N(t.items,n);return e.length===0&&!i?[]:[{type:`section`,label:t.label??``,...i?{link:i}:{},items:e}]}return i?[{type:`page`,label:t.label??i,link:i,items:[]}]:[]})}export{b as collectNodeLinks,x as countPages,y as findSection,_ as flattenSections,h as loadPageNavigation,m as loadVisiblePages,C as toPageSlug,S as toPublicUrl,v as toSectionId};
@@ -1,4 +1,4 @@
1
- import{readIgnoredRouteSlugs as e}from"../../ignored-routes.js";import{publicOrigin as t}from"../../../../utils/request-origin.js";import{recoveryToolNames as n}from"./openapi-document.js";import{MAX_PAGE_LINES as r}from"./pages-constants.js";import{GET_PAGE_SCHEMA as i,GREP_PAGES_SCHEMA as a,LIST_PAGES_SCHEMA as o,grepPagesToolSchema as s,listPagesToolSchema as c}from"./schemas.js";import{collectNodeLinks as l,countPages as u,findSection as d,flattenSections as f,loadPageNavigation as p,loadVisiblePages as m,toPageSlug as h,toPublicUrl as g,toSectionId as _}from"./pages-navigation.js";const v=/^(#{1,3}) +(\S.*)$/,y=/^\s*(```|~~~)/,b={schema:o,schemaFor:e=>c(e.mcpMode),async execute(e,n){let{section:r}=e??{},{sections:i}=await p(n),a=t(n.request);if(!r)return{sections:i.map(e=>({id:e.id,title:e.title,items:w(e.id,e.nodes,a)}))};let o=d(i,r,a);if(!o){let e=f(i).slice(0,50).map(({id:e})=>e);throw Error(`No section "${r}". Pass one of these section ids: ${e.join(`; `)}.`)}return{section:{id:o.id,title:o.title},items:w(o.id,o.nodes,a)}}},x={schema:i,async execute(e,i){let{url:a,startLine:o,lines:s}=e??{};if(typeof a!=`string`||a.trim()===``)throw Error(`The "url" parameter is required: a page URL or path.`);let c=t(i.request),l=h(a,c),u=l===null?null:await C(l,i);if(l===null||u===null)throw Error(`No page you can read is at "${a}": it does not exist, or your access does not include it. Do not describe it from other pages. Call ${n(i.mcpMode).listPages} to see the pages you can read.`);let d=D(u.text),f=Math.max(1,Math.floor(o??1));if(f>d.length)throw Error(`Line ${f} is past the end of "${u.title??l}", which has ${d.length} lines.`);let p=T(s,200,r),m=Math.min(d.length,f+p-1);return{url:g(l,c),title:u.title??l,totalLines:d.length,startLine:f,endLine:m,...m<d.length?{nextStartLine:m+1}:{},outline:O(d),content:d.slice(f-1,m).join(`
2
- `)}}},S={schema:a,schemaFor:e=>s(e.mcpMode),async execute(e,r){let{query:i,section:a,maxMatches:o}=e??{};if(typeof i!=`string`||i===``)throw Error(`The "query" parameter is required: a text to find.`);let s=t(r.request),c,u;if(a){let{sections:e,pages:t}=await p(r),i=d(e,a,s);if(!i)throw Error(`No section "${a}". Call ${n(r.mcpMode).listPages} to see the sections.`);let o=new Set(l(i.nodes));i.link&&o.add(i.link),c=t.filter(e=>o.has(e.slug)),u=i.title}else c=(await m(r)).pages;let f=T(o,20,100),h=i.toLowerCase(),_=c.length,v=[];for(let e of c){let t=(await r.pageMarkdown.readPage(e.slug))?.text??``;if(t.toLowerCase().includes(h))for(let[n,r]of D(t).entries()){let t=r.toLowerCase().indexOf(h);if(t!==-1){if(v.length===f)return{matches:v,searchedPages:_,truncated:!0};v.push({url:g(e.slug,s),title:e.title,line:n+1,text:E(r,t)})}}}return v.length>0?{matches:v,searchedPages:_,truncated:!1}:{matches:v,searchedPages:_,truncated:!1,note:`No page you can read ${u?`in "${u}" contains "${i}". All ${_} pages there were searched.`:`contains "${i}". All ${_} pages were searched. API references are not searched: use ${n(r.mcpMode).listApis} for them.`}`}}};async function C(t,n){return(await e(n.entities)).has(t)?null:n.pageMarkdown.readPage(t)}function w(e,t,n){return t.map(t=>t.type===`page`?{type:`page`,title:t.label,url:g(t.link??``,n)}:{type:`section`,id:_(e,t.label),title:t.label,...t.link?{url:g(t.link,n)}:{},pageCount:u(t.items)})}function T(e,t,n){return Math.min(Math.max(1,Math.floor(e??t)),n)}function E(e,t){let n=Math.max(0,Math.min(t-80,e.length-200));return e.slice(n,n+200).trim()}function D(e){return(e.endsWith(`
1
+ import{readIgnoredRouteSlugs as e}from"../../ignored-routes.js";import{publicOrigin as t}from"../../../../utils/request-origin.js";import{MAX_PAGE_LINES as n}from"./pages-constants.js";import{GET_PAGE_SCHEMA as r,GREP_PAGES_SCHEMA as i,LIST_PAGES_SCHEMA as a,grepPagesToolSchema as o,listPagesToolSchema as s}from"./schemas.js";import{recoveryToolNames as c}from"./openapi-document.js";import{collectNodeLinks as l,countPages as u,findSection as d,flattenSections as f,loadPageNavigation as p,loadVisiblePages as m,toPageSlug as h,toPublicUrl as g,toSectionId as _}from"./pages-navigation.js";const v=/^(#{1,3}) +(\S.*)$/,y=/^\s*(```|~~~)/,b={schema:a,schemaFor:e=>s(e.mcpMode),async execute(e,n){let{section:r}=e??{},{sections:i}=await p(n),a=t(n.request);if(!r)return{sections:i.map(e=>({id:e.id,title:e.title,items:w(e.id,e.nodes,a)}))};let o=d(i,r,a);if(!o){let e=f(i).slice(0,50).map(({id:e})=>e);throw Error(`No section "${r}". Pass one of these section ids: ${e.join(`; `)}.`)}return{section:{id:o.id,title:o.title},items:w(o.id,o.nodes,a)}}},x={schema:r,async execute(e,r){let{url:i,startLine:a,lines:o}=e??{};if(typeof i!=`string`||i.trim()===``)throw Error(`The "url" parameter is required: a page URL or path.`);let s=t(r.request),l=h(i,s),u=l===null?null:await C(l,r);if(l===null||u===null)throw Error(`No page you can read is at "${i}": it does not exist, or your access does not include it. Do not describe it from other pages. Call ${c(r.mcpMode).listPages} to see the pages you can read.`);let d=D(u.text),f=Math.max(1,Math.floor(a??1));if(f>d.length)throw Error(`Line ${f} is past the end of "${u.title??l}", which has ${d.length} lines.`);let p=T(o,200,n),m=Math.min(d.length,f+p-1);return{url:g(l,s),title:u.title??l,totalLines:d.length,startLine:f,endLine:m,...m<d.length?{nextStartLine:m+1}:{},outline:O(d),content:d.slice(f-1,m).join(`
2
+ `)}}},S={schema:i,schemaFor:e=>o(e.mcpMode),async execute(e,n){let{query:r,section:i,maxMatches:a}=e??{};if(typeof r!=`string`||r===``)throw Error(`The "query" parameter is required: a text to find.`);let o=t(n.request),s,u;if(i){let{sections:e,pages:t}=await p(n),r=d(e,i,o);if(!r)throw Error(`No section "${i}". Call ${c(n.mcpMode).listPages} to see the sections.`);let a=new Set(l(r.nodes));r.link&&a.add(r.link),s=t.filter(e=>a.has(e.slug)),u=r.title}else s=(await m(n)).pages;let f=T(a,20,100),h=r.toLowerCase(),_=s.length,v=[];for(let e=0;e<s.length;e+=100){let t=s.slice(e,e+100),r=await Promise.all(t.map(async e=>(await n.pageMarkdown.readPage(e.slug))?.text??``));for(let[e,n]of t.entries()){let t=r[e];if(t.toLowerCase().includes(h))for(let[e,r]of D(t).entries()){let t=r.toLowerCase().indexOf(h);if(t!==-1){if(v.length===f)return{matches:v,searchedPages:_,truncated:!0};v.push({url:g(n.slug,o),title:n.title,line:e+1,text:E(r,t)})}}}}return v.length>0?{matches:v,searchedPages:_,truncated:!1}:{matches:v,searchedPages:_,truncated:!1,note:`No page you can read ${u?`in "${u}" contains "${r}". All ${_} pages there were searched.`:`contains "${r}". All ${_} pages were searched. API references are not searched: use ${c(n.mcpMode).listApis} for them.`}`}}};async function C(t,n){return(await e(n.entities)).has(t)?null:n.pageMarkdown.readPage(t)}function w(e,t,n){return t.map(t=>t.type===`page`?{type:`page`,title:t.label,url:g(t.link??``,n)}:{type:`section`,id:_(e,t.label),title:t.label,...t.link?{url:g(t.link,n)}:{},pageCount:u(t.items)})}function T(e,t,n){return Math.min(Math.max(1,Math.floor(e??t)),n)}function E(e,t){let n=Math.max(0,Math.min(t-80,e.length-200));return e.slice(n,n+200).trim()}function D(e){return(e.endsWith(`
3
3
  `)?e.slice(0,-1):e).split(`
4
4
  `)}function O(e){let t=[],n=!1;return e.forEach((e,r)=>{if(y.test(e)){n=!n;return}let i=n?null:v.exec(e);i&&t.push({line:r+1,level:i[1].length,heading:i[2].trim()})}),t}const k=[b,x,S];export{k as pageTools};
@@ -1 +1 @@
1
- import{SUBMIT_FEEDBACK_TOOL_NAME as e}from"../../constants.js";import{toolNameForMode as t}from"../codemode/tool-declarations.js";import{GRAPHQL_LIST_SCOPES as n,GRAPHQL_TYPE_KINDS as r}from"./graphql-constants.js";import{OPERATION_METHODS as i}from"./openapi-document.js";import{MAX_PAGE_LINES as a}from"./pages-constants.js";const o={type:`string`,nullable:!0},s={limit:{type:`number`},total:{type:`number`},page:{type:`number`},totalPages:{type:`number`}},c={codemodeType:`OpenApiServer[]`},l={codemodeType:`OpenApiSecurityRequirement[]`},u={codemodeType:`Record<string, OpenApiSecurityScheme>`},d={codemodeType:`OpenApiDocument`},f={codemodeType:`OpenApiOperation & { path: string; method: string }`},p={codemodeType:`OpenApiComponents`,description:"Components the endpoint references. A `$ref` in `endpoint` resolves against the root of the result."},m={filePath:{type:`string`,description:`API definition file path`},otherMatches:{type:`array`,description:"Other API definitions the lookup also matched. Present only when several matched; pass `filePath` to pick another one",items:{type:`object`,required:[`filePath`],properties:{version:{type:`string`},filePath:{type:`string`}}}}},h="When several definitions match the name, the highest version or the shortest file path is used and the rest are listed in `otherMatches`; tell the user which version or file the answer is based on.",g={readOnlyHint:!0,destructiveHint:!1,openWorldHint:!1};function _(e,t){let n={query:{type:`string`,description:`What to find, as a few words or a short question.`,minLength:1}};return e.length>0&&(n.product={type:`string`,description:`Optional product name to filter search results by specific product.`,enum:[...e,null],nullable:!0}),t.length>0&&(n.locale={type:`string`,description:`Optional locale code to filter search results by documentation language (e.g. 'en', 'ja'). Use the locale matching the language of the user's request. Defaults to the site's default locale.`,enum:[...t,null],nullable:!0}),{name:`search`,title:`Search documentation`,description:`Search the documentation. Returns Markdown text: one section per matching page, with its title and URL as a link.`,summary:`Search the documentation.`,schema:{type:`object`,required:[`query`],additionalProperties:!1,properties:n},annotations:g,outputSchema:{type:`string`}}}const v=_([],[]),y={name:`whoami`,title:`Who am I`,description:`Get information about the currently authenticated user`,summary:`Get the signed-in user.`,schema:{type:`object`,required:[],additionalProperties:!1,properties:{}},annotations:g,outputSchema:{type:`object`,required:[`authenticated`],properties:{authenticated:{type:`boolean`},email:{type:`string`},name:{type:`string`},subject:{type:`string`},clientId:{type:`string`},scope:{type:`string`},issuedAt:{type:`string`},expiresAt:{type:`string`}}}},b={name:e,title:`Submit feedback`,description:`Report a documentation page that is wrong or incomplete. Use it when the user reports a problem with a page on this site, or agrees to report a problem that you found. Do not use it for product bugs or support questions.`,schema:{type:`object`,required:[`path`,`summary`],additionalProperties:!1,properties:{path:{type:`string`,description:`Path or URL of the documentation page the feedback is about (e.g. /guides/auth)`,minLength:1,maxLength:1e3},summary:{type:`string`,description:`One sentence that names what is wrong with the page`,minLength:1,maxLength:500},details:{type:`string`,description:`Expected versus actual behavior, missing steps, or the snippet that failed`,maxLength:4e3,nullable:!0},targetFeature:{type:`string`,description:`The API or feature the page documents`,maxLength:500,nullable:!0}}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},outputSchema:{type:`object`,required:[`status`,`page`,`message`],properties:{status:{type:`string`},page:{type:`string`},message:{type:`string`}}}},x={type:`object`,additionalProperties:!1,required:[],properties:{filter:{type:`string`,description:`Matches part of an API name, or of a description when no name matches`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of APIs per page. Default is 300`,minimum:1,default:300,nullable:!0}}};function S(e){return{type:`string`,description:`API definition file path, as returned by \`${t(`list-apis`,e)}\``,nullable:!0}}function C(e){return{type:`object`,required:[],additionalProperties:!1,properties:{name:{type:`string`,description:"API name, or a unique part of it. Required when the project documents more than one API, unless `filePath` is given.",minLength:1,nullable:!0},version:{type:`string`,description:`API version. When omitted and several versions exist, the highest one is used`,nullable:!0},filePath:S(e)}}}function w(e){let{name:t,version:n,filePath:r}=C(e).properties;return{type:`object`,required:[`path`,`method`],additionalProperties:!1,properties:{name:t,path:{type:`string`,description:`Endpoint path (e.g. /api/v1/users)`,minLength:1},method:{type:`string`,description:`HTTP method (GET, POST, PUT, DELETE, etc.)`,enum:[...i.map(e=>e.toUpperCase()),...i],minLength:1},version:n,filePath:r}}}function T(e){let t={name:{type:`string`},description:{type:`string`},version:{type:`string`},servers:c,filePath:{type:`string`,description:`API definition file path`},ambiguousTitle:{type:`boolean`,description:"true = another API shares this title; a lookup picks the highest version, or the shortest file path at the same version, and lists the rest in `otherMatches`. Pass `filePath` to pick another one"}};return e&&(t.callable={type:`boolean`,description:"true = the documented hosts of this API are reachable via `fetch`; false = documentation only"}),{name:`list-apis`,title:`List APIs`,description:`Lists the APIs documented on this site`,summary:`List the available APIs.`,schema:x,annotations:g,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`,`description`,`version`,`servers`,`filePath`],properties:t}},...s}}}}const E=T(!1),D=T(!0);function O(e){return{name:`get-endpoints`,title:`Get endpoints`,description:`Get all endpoints for a specific API. ${h}`,summary:`Get all endpoints for an API.`,schema:C(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoints`],properties:{api:{type:`string`},version:{type:`string`},...m,servers:c,endpoints:{type:`array`,items:{type:`object`,required:[`path`,`method`],properties:{path:{type:`string`},method:{type:`string`},summary:o,description:o,security:l}}}}}}}const k=O(`tools`);function A(e){return{name:`get-endpoint-info`,title:`Get endpoint info`,description:`Get comprehensive information about specific endpoint including parameters, security, and examples. A \`$ref\` in \`endpoint\` points into the \`components\` key at the root of the result: read \`#/components/<section>/<name>\` there. ${h}`,summary:`Get the details of an endpoint.`,schema:w(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoint`,`globalSecurity`,`securitySchemes`],properties:{api:{type:`string`},version:{type:`string`},...m,servers:c,endpoint:f,globalSecurity:l,securitySchemes:u,components:p}}}}const j=A(`tools`);function M(e){return{name:`get-security-schemes`,title:`Get security schemes`,description:`Get the security schemes for a specific API. ${h}`,summary:`Get the security schemes for an API.`,schema:C(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`securitySchemes`,`security`],properties:{api:{type:`string`},version:{type:`string`},...m,securitySchemes:u,security:l}}}}const N=M(`tools`);function P(e){return{name:`get-full-api-description`,title:`Get full API description`,description:`Get the complete OpenAPI description. ${h}`,summary:`Get the complete OpenAPI description.`,schema:C(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`definition`],properties:{api:{type:`string`},version:{type:`string`},...m,definition:d}}}}const F=P(`tools`),I={type:`object`,required:[],additionalProperties:!1,properties:{filter:{type:`string`,description:`GraphQL schema name (or part of it)`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of results per page. Default is 300`,minimum:1,default:300,nullable:!0}}},L={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1},kind:{type:`string`,description:`Optional: return only a single category of schema members. With scope "fields", restricts to the fields of that parent category ("objects", "interfaces", or "inputs" only).`,enum:[...r,null],nullable:!0},scope:{type:`string`,description:'Optional: what each list item is. "members" (default) lists top-level types and operations. "fields" flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions — combine with `filter` to search nested fields anywhere in the schema.',enum:[...n,null],nullable:!0},filter:{type:`string`,description:`Optional: only members whose name or description contains this substring, case-insensitive (e.g. "custom tags")`,minLength:1,nullable:!0},referencesType:{type:`string`,description:`Optional: only members that reference this type directly or transitively (via return, field, argument, union-member or input-field types). Finds cross-cutting members that never name it — e.g. referencesType "Book" surfaces a search query returning a union that includes Book.`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of results per page. Default is 300`,minimum:1,default:300,nullable:!0}}},R={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1},type:{type:`string`,description:`Name of the type, operation, or directive`,minLength:1,nullable:!0},includeReferencedTypes:{type:`boolean`,description:`Also include the SDL of every type referenced transitively. Gives the whole subgraph at once, but can be large for highly-connected types.`,default:!1,nullable:!0}}},z={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1}}},B={name:`list-graphql-apis`,title:`List GraphQL APIs`,description:`Lists available GraphQL schemas with their context and purpose`,summary:`List the available GraphQL schemas.`,schema:I,annotations:g,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`],properties:{name:{type:`string`},description:o}}},...s}}},V={name:`get-graphql-type-list`,title:`Get GraphQL type list`,description:'List all operations and types in a GraphQL schema as a flat, paginated list. Each item is tagged with its kind (query, object, enum, …) and carries a one-line description; operations also include their return type and argument signature — use it to decide which members to fetch in detail. Narrow the result with `kind` (one category), `filter` (case-insensitive substring of the member name or description, e.g. "book"), or `referencesType` (only members that use a given type, directly or transitively) to explore a domain cheaply instead of pulling the full schema. To search nested fields — not just type names — set scope "fields": it flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions, so `filter` finds things like an input field whose docstring mentions your keyword.',summary:`List the operations and types in a GraphQL schema.`,schema:L,annotations:g,outputSchema:{type:`object`,required:[`name`,`items`,`limit`,`total`,`page`,`totalPages`],properties:{name:{type:`string`},items:{type:`array`,items:{type:`object`,required:[`kind`,`name`],properties:{kind:{type:`string`,enum:[...r]},name:{type:`string`},description:o,type:{type:`string`},args:{type:`string`},directives:{type:`string`}}}},...s}}};function H(e){return{name:`get-graphql-type`,title:`Get GraphQL type`,description:`Get the SDL for a single GraphQL type, operation (query/mutation/subscription field), or directive. Without includeReferencedTypes, the SDL is followed by a one-level manifest of every directly referenced type's field names (e.g. "input ActionOperationInput { addTags, removeTags }"), so you can see what nested types contain before fetching them. Set includeReferencedTypes to instead pull in the full SDL of every type it references transitively — the whole structural subgraph in one call, ideal for complete exploration of an entity (e.g. Book and all the types it touches). That traversal only follows what the target depends on; to go the other direction and find the members that use a type, call ${t(`get-graphql-type-list`,e)} with \`referencesType\`.`,summary:`Get the SDL of one GraphQL type or operation.`,schema:R,annotations:g,outputSchema:{type:`string`}}}const U=H(`tools`);function W(e){return{name:`get-graphql-schema`,title:`Get GraphQL schema`,description:`Get the complete GraphQL schema as SDL — the whole type graph in one call. Returns everything, so it can be very large and token-expensive for big schemas; prefer ${t(`get-graphql-type-list`,e)} (filter/paginate) plus targeted ${t(`get-graphql-type`,e)} calls, and reach for this only for small schemas or when you truly need the full SDL.`,summary:`Get the complete GraphQL schema.`,schema:z,annotations:g,outputSchema:{type:`string`}}}const G=W(`tools`);function K(e){return`Section id from ${t(`list-pages`,e)} (for example "products/ledger > Integration"), a section title, or a section URL`}function q(e){return{type:`object`,required:[`type`,`title`],properties:{type:{type:`string`,enum:[`page`,`section`]},id:{type:`string`,description:`Section id to pass to ${t(`list-pages`,e)} or ${t(`grep-pages`,e)}`},title:{type:`string`},url:{type:`string`},pageCount:{type:`number`,description:`Pages inside the section`}}}}function J(e){let t=q(e);return{name:`list-pages`,title:`List pages`,description:`Lists the docs navigation, one level per call`,summary:`List the docs navigation, one level per call.`,schema:{type:`object`,additionalProperties:!1,required:[],properties:{section:{type:`string`,nullable:!0,description:`${K(e)}. Omit it to list the top level`}}},annotations:g,outputSchema:{type:`object`,properties:{sections:{type:`array`,description:`Top level, when no section is given`,items:{type:`object`,required:[`id`,`title`,`items`],properties:{id:{type:`string`},title:{type:`string`},items:{type:`array`,items:t}}}},section:{type:`object`,properties:{id:{type:`string`},title:{type:`string`}}},items:{type:`array`,items:t}}}}}const Y=J(`tools`),X={name:`get-page`,title:`Get page`,description:`Reads a docs page as Markdown, in line windows`,summary:`Read a docs page as Markdown, in line windows.`,schema:{type:`object`,additionalProperties:!1,required:[`url`],properties:{url:{type:`string`,minLength:1,description:`Page URL or path, for example "/guides/auth"`},startLine:{type:`integer`,nullable:!0,minimum:1,description:`First line to return (default 1)`},lines:{type:`integer`,nullable:!0,minimum:1,maximum:a,description:`Number of lines to return (default 200)`}}},annotations:g,outputSchema:{type:`object`,required:[`url`,`title`,`totalLines`,`startLine`,`endLine`,`outline`,`content`],properties:{url:{type:`string`},title:{type:`string`},totalLines:{type:`number`},startLine:{type:`number`},endLine:{type:`number`},nextStartLine:{type:`number`,description:`Pass as startLine to read on; absent at the end`},outline:{type:`array`,description:`Headings (levels 1-3) with their line numbers`,items:{type:`object`,required:[`line`,`level`,`heading`],properties:{line:{type:`number`},level:{type:`number`},heading:{type:`string`}}}},content:{type:`string`}}}};function Z(e){return{name:`grep-pages`,title:`Grep pages`,description:`Finds the docs lines that contain a text`,summary:`Find the docs lines that contain a text.`,schema:{type:`object`,additionalProperties:!1,required:[`query`],properties:{query:{type:`string`,minLength:1,description:`Text to find, case-insensitive. Not a regular expression`},section:{type:`string`,nullable:!0,description:`${K(e)}. Omit it to search every page`},maxMatches:{type:`integer`,nullable:!0,minimum:1,maximum:100,description:`Maximum matching lines to return (default 20)`}}},annotations:g,outputSchema:{type:`object`,required:[`matches`,`searchedPages`,`truncated`],properties:{matches:{type:`array`,items:{type:`object`,required:[`url`,`title`,`line`,`text`],properties:{url:{type:`string`},title:{type:`string`},line:{type:`number`},text:{type:`string`}}}},searchedPages:{type:`number`,description:`Pages searched: every page you can read, or every page in the section`},truncated:{type:`boolean`,description:`true = more matches exist; narrow the query or the section`},note:{type:`string`,description:`Present when nothing matches: the docs you can read do not contain the text`}}}}}const Q=Z(`tools`);export{k as GET_ENDPOINTS_SCHEMA,j as GET_ENDPOINT_INFO_SCHEMA,F as GET_FULL_API_DESCRIPTION_SCHEMA,G as GET_GRAPHQL_SCHEMA_SCHEMA,V as GET_GRAPHQL_TYPE_LIST_SCHEMA,U as GET_GRAPHQL_TYPE_SCHEMA,X as GET_PAGE_SCHEMA,N as GET_SECURITY_SCHEMES_SCHEMA,Q as GREP_PAGES_SCHEMA,D as LIST_APIS_CALLABLE_SCHEMA,E as LIST_APIS_SCHEMA,B as LIST_GRAPHQL_APIS_SCHEMA,Y as LIST_PAGES_SCHEMA,g as READ_ONLY_ANNOTATIONS,v as SEARCH_SCHEMA,b as SUBMIT_FEEDBACK_SCHEMA,y as WHOAMI_SCHEMA,A as getEndpointInfoToolSchema,O as getEndpointsToolSchema,P as getFullApiDescriptionToolSchema,W as getGraphqlSchemaToolSchema,H as getGraphqlTypeToolSchema,M as getSecuritySchemesToolSchema,Z as grepPagesToolSchema,J as listPagesToolSchema,_ as searchSchema};
1
+ import{READ_ONLY_ANNOTATIONS as e,SUBMIT_FEEDBACK_TOOL_NAME as t}from"../../constants.js";import{OPERATION_METHODS as n}from"../../../../../../shared/constants/openapi-operation-methods.js";import{toolNameForMode as r}from"../codemode/tool-declarations.js";import{GRAPHQL_LIST_SCOPES as i,GRAPHQL_TYPE_KINDS as a}from"./graphql-constants.js";import{MAX_PAGE_LINES as o}from"./pages-constants.js";const s={type:`string`,nullable:!0},c={limit:{type:`number`},total:{type:`number`},page:{type:`number`},totalPages:{type:`number`}},l={codemodeType:`OpenApiServer[]`},u={codemodeType:`OpenApiSecurityRequirement[]`},d={codemodeType:`Record<string, OpenApiSecurityScheme>`},f={codemodeType:`OpenApiDocument`},p={codemodeType:`OpenApiOperation & { path: string; method: string }`},m={codemodeType:`OpenApiComponents`,description:"Components the endpoint references. A `$ref` in `endpoint` resolves against the root of the result."},h={filePath:{type:`string`,description:`API definition file path`},otherMatches:{type:`array`,description:"Other API definitions the lookup also matched. Present only when several matched; pass `filePath` to pick another one",items:{type:`object`,required:[`filePath`],properties:{version:{type:`string`},filePath:{type:`string`}}}}},g="When several definitions match the name, the highest version or the shortest file path is used and the rest are listed in `otherMatches`; tell the user which version or file the answer is based on.";function _(t,n){let r={query:{type:`string`,description:`What to find, as a few words or a short question.`,minLength:1}};return t.length>0&&(r.product={type:`string`,description:`Optional product name to filter search results by specific product.`,enum:[...t,null],nullable:!0}),n.length>0&&(r.locale={type:`string`,description:`Optional locale code to filter search results by documentation language (e.g. 'en', 'ja'). Use the locale matching the language of the user's request. Defaults to the site's default locale.`,enum:[...n,null],nullable:!0}),{name:`search`,title:`Search documentation`,description:`Search the documentation. Returns Markdown text: one section per matching page, with its title and URL as a link.`,summary:`Search the documentation.`,schema:{type:`object`,required:[`query`],additionalProperties:!1,properties:r},annotations:e,outputSchema:{type:`string`}}}const v=_([],[]),y={name:`whoami`,title:`Who am I`,description:`Get information about the currently authenticated user`,summary:`Get the signed-in user.`,schema:{type:`object`,required:[],additionalProperties:!1,properties:{}},annotations:e,outputSchema:{type:`object`,required:[`authenticated`],properties:{authenticated:{type:`boolean`},email:{type:`string`},name:{type:`string`},subject:{type:`string`},clientId:{type:`string`},scope:{type:`string`},issuedAt:{type:`string`},expiresAt:{type:`string`}}}},b={name:t,title:`Submit feedback`,description:`Report a documentation page that is wrong or incomplete. Use it when the user reports a problem with a page on this site, or agrees to report a problem that you found. Do not use it for product bugs or support questions.`,schema:{type:`object`,required:[`path`,`summary`],additionalProperties:!1,properties:{path:{type:`string`,description:`Path or URL of the documentation page the feedback is about (e.g. /guides/auth)`,minLength:1,maxLength:1e3},summary:{type:`string`,description:`One sentence that names what is wrong with the page`,minLength:1,maxLength:500},details:{type:`string`,description:`Expected versus actual behavior, missing steps, or the snippet that failed`,maxLength:4e3,nullable:!0},targetFeature:{type:`string`,description:`The API or feature the page documents`,maxLength:500,nullable:!0}}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},outputSchema:{type:`object`,required:[`status`,`page`,`message`],properties:{status:{type:`string`},page:{type:`string`},message:{type:`string`}}}},x={type:`object`,additionalProperties:!1,required:[],properties:{filter:{type:`string`,description:`Matches part of an API name, or of a description when no name matches`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of APIs per page. Default is 300`,minimum:1,default:300,nullable:!0}}};function S(e){return{type:`string`,description:`API definition file path, as returned by \`${r(`list-apis`,e)}\``,nullable:!0}}function C(e){return{type:`object`,required:[],additionalProperties:!1,properties:{name:{type:`string`,description:"API name, or a unique part of it. Required when the project documents more than one API, unless `filePath` is given.",minLength:1,nullable:!0},version:{type:`string`,description:`API version. When omitted and several versions exist, the highest one is used`,nullable:!0},filePath:S(e)}}}function w(e){let{name:t,version:r,filePath:i}=C(e).properties;return{type:`object`,required:[`path`,`method`],additionalProperties:!1,properties:{name:t,path:{type:`string`,description:`Endpoint path (e.g. /api/v1/users)`,minLength:1},method:{type:`string`,description:`HTTP method (GET, POST, PUT, DELETE, etc.)`,enum:[...n.map(e=>e.toUpperCase()),...n],minLength:1},version:r,filePath:i}}}function T(t){let n={name:{type:`string`},description:{type:`string`},version:{type:`string`},servers:l,filePath:{type:`string`,description:`API definition file path`},ambiguousTitle:{type:`boolean`,description:"true = another API shares this title; a lookup picks the highest version, or the shortest file path at the same version, and lists the rest in `otherMatches`. Pass `filePath` to pick another one"}};return t&&(n.callable={type:`boolean`,description:"true = the documented hosts of this API are reachable via `fetch`; false = documentation only"}),{name:`list-apis`,title:`List APIs`,description:`Lists the APIs documented on this site`,summary:`List the available APIs.`,schema:x,annotations:e,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`,`description`,`version`,`servers`,`filePath`],properties:n}},...c}}}}const E=T(!1),D=T(!0);function O(t){return{name:`get-endpoints`,title:`Get endpoints`,description:`Get all endpoints for a specific API. ${g}`,summary:`Get all endpoints for an API.`,schema:C(t),annotations:e,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoints`],properties:{api:{type:`string`},version:{type:`string`},...h,servers:l,endpoints:{type:`array`,items:{type:`object`,required:[`path`,`method`],properties:{path:{type:`string`},method:{type:`string`},summary:s,description:s,security:u}}}}}}}const k=O(`tools`);function A(t){return{name:`get-endpoint-info`,title:`Get endpoint info`,description:`Get comprehensive information about specific endpoint including parameters, security, and examples. A \`$ref\` in \`endpoint\` points into the \`components\` key at the root of the result: read \`#/components/<section>/<name>\` there. ${g}`,summary:`Get the details of an endpoint.`,schema:w(t),annotations:e,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoint`,`globalSecurity`,`securitySchemes`],properties:{api:{type:`string`},version:{type:`string`},...h,servers:l,endpoint:p,globalSecurity:u,securitySchemes:d,components:m}}}}const j=A(`tools`);function M(t){return{name:`get-security-schemes`,title:`Get security schemes`,description:`Get the security schemes for a specific API. ${g}`,summary:`Get the security schemes for an API.`,schema:C(t),annotations:e,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`securitySchemes`,`security`],properties:{api:{type:`string`},version:{type:`string`},...h,securitySchemes:d,security:u}}}}const N=M(`tools`);function P(t){return{name:`get-full-api-description`,title:`Get full API description`,description:`Get the complete OpenAPI description. ${g}`,summary:`Get the complete OpenAPI description.`,schema:C(t),annotations:e,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`definition`],properties:{api:{type:`string`},version:{type:`string`},...h,definition:f}}}}const F=P(`tools`),I={type:`object`,required:[],additionalProperties:!1,properties:{filter:{type:`string`,description:`GraphQL schema name (or part of it)`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of results per page. Default is 300`,minimum:1,default:300,nullable:!0}}},L={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1},kind:{type:`string`,description:`Optional: return only a single category of schema members. With scope "fields", restricts to the fields of that parent category ("objects", "interfaces", or "inputs" only).`,enum:[...a,null],nullable:!0},scope:{type:`string`,description:'Optional: what each list item is. "members" (default) lists top-level types and operations. "fields" flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions — combine with `filter` to search nested fields anywhere in the schema.',enum:[...i,null],nullable:!0},filter:{type:`string`,description:`Optional: only members whose name or description contains this substring, case-insensitive (e.g. "custom tags")`,minLength:1,nullable:!0},referencesType:{type:`string`,description:`Optional: only members that reference this type directly or transitively (via return, field, argument, union-member or input-field types). Finds cross-cutting members that never name it — e.g. referencesType "Book" surfaces a search query returning a union that includes Book.`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of results per page. Default is 300`,minimum:1,default:300,nullable:!0}}},R={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1},type:{type:`string`,description:`Name of the type, operation, or directive`,minLength:1,nullable:!0},includeReferencedTypes:{type:`boolean`,description:`Also include the SDL of every type referenced transitively. Gives the whole subgraph at once, but can be large for highly-connected types.`,default:!1,nullable:!0}}},z={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1}}},B={name:`list-graphql-apis`,title:`List GraphQL APIs`,description:`Lists available GraphQL schemas with their context and purpose`,summary:`List the available GraphQL schemas.`,schema:I,annotations:e,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`],properties:{name:{type:`string`},description:s}}},...c}}},V={name:`get-graphql-type-list`,title:`Get GraphQL type list`,description:'List all operations and types in a GraphQL schema as a flat, paginated list. Each item is tagged with its kind (query, object, enum, …) and carries a one-line description; operations also include their return type and argument signature — use it to decide which members to fetch in detail. Narrow the result with `kind` (one category), `filter` (case-insensitive substring of the member name or description, e.g. "book"), or `referencesType` (only members that use a given type, directly or transitively) to explore a domain cheaply instead of pulling the full schema. To search nested fields — not just type names — set scope "fields": it flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions, so `filter` finds things like an input field whose docstring mentions your keyword.',summary:`List the operations and types in a GraphQL schema.`,schema:L,annotations:e,outputSchema:{type:`object`,required:[`name`,`items`,`limit`,`total`,`page`,`totalPages`],properties:{name:{type:`string`},items:{type:`array`,items:{type:`object`,required:[`kind`,`name`],properties:{kind:{type:`string`,enum:[...a]},name:{type:`string`},description:s,type:{type:`string`},args:{type:`string`},directives:{type:`string`}}}},...c}}};function H(t){return{name:`get-graphql-type`,title:`Get GraphQL type`,description:`Get the SDL for a single GraphQL type, operation (query/mutation/subscription field), or directive. Without includeReferencedTypes, the SDL is followed by a one-level manifest of every directly referenced type's field names (e.g. "input ActionOperationInput { addTags, removeTags }"), so you can see what nested types contain before fetching them. Set includeReferencedTypes to instead pull in the full SDL of every type it references transitively — the whole structural subgraph in one call, ideal for complete exploration of an entity (e.g. Book and all the types it touches). That traversal only follows what the target depends on; to go the other direction and find the members that use a type, call ${r(`get-graphql-type-list`,t)} with \`referencesType\`.`,summary:`Get the SDL of one GraphQL type or operation.`,schema:R,annotations:e,outputSchema:{type:`string`}}}const U=H(`tools`);function W(t){return{name:`get-graphql-schema`,title:`Get GraphQL schema`,description:`Get the complete GraphQL schema as SDL — the whole type graph in one call. Returns everything, so it can be very large and token-expensive for big schemas; prefer ${r(`get-graphql-type-list`,t)} (filter/paginate) plus targeted ${r(`get-graphql-type`,t)} calls, and reach for this only for small schemas or when you truly need the full SDL.`,summary:`Get the complete GraphQL schema.`,schema:z,annotations:e,outputSchema:{type:`string`}}}const G=W(`tools`);function K(e){return`Section id from ${r(`list-pages`,e)} (for example "products/ledger > Integration"), a section title, or a section URL`}function q(e){return{type:`object`,required:[`type`,`title`],properties:{type:{type:`string`,enum:[`page`,`section`]},id:{type:`string`,description:`Section id to pass to ${r(`list-pages`,e)} or ${r(`grep-pages`,e)}`},title:{type:`string`},url:{type:`string`},pageCount:{type:`number`,description:`Pages inside the section`}}}}function J(t){let n=q(t);return{name:`list-pages`,title:`List pages`,description:`Lists the docs navigation, one level per call`,summary:`List the docs navigation, one level per call.`,schema:{type:`object`,additionalProperties:!1,required:[],properties:{section:{type:`string`,nullable:!0,description:`${K(t)}. Omit it to list the top level`}}},annotations:e,outputSchema:{type:`object`,properties:{sections:{type:`array`,description:`Top level, when no section is given`,items:{type:`object`,required:[`id`,`title`,`items`],properties:{id:{type:`string`},title:{type:`string`},items:{type:`array`,items:n}}}},section:{type:`object`,properties:{id:{type:`string`},title:{type:`string`}}},items:{type:`array`,items:n}}}}}const Y=J(`tools`),X={name:`get-page`,title:`Get page`,description:`Reads a docs page as Markdown, in line windows`,summary:`Read a docs page as Markdown, in line windows.`,schema:{type:`object`,additionalProperties:!1,required:[`url`],properties:{url:{type:`string`,minLength:1,description:`Page URL or path, for example "/guides/auth"`},startLine:{type:`integer`,nullable:!0,minimum:1,description:`First line to return (default 1)`},lines:{type:`integer`,nullable:!0,minimum:1,maximum:o,description:`Number of lines to return (default 200)`}}},annotations:e,outputSchema:{type:`object`,required:[`url`,`title`,`totalLines`,`startLine`,`endLine`,`outline`,`content`],properties:{url:{type:`string`},title:{type:`string`},totalLines:{type:`number`},startLine:{type:`number`},endLine:{type:`number`},nextStartLine:{type:`number`,description:`Pass as startLine to read on; absent at the end`},outline:{type:`array`,description:`Headings (levels 1-3) with their line numbers`,items:{type:`object`,required:[`line`,`level`,`heading`],properties:{line:{type:`number`},level:{type:`number`},heading:{type:`string`}}}},content:{type:`string`}}}};function Z(t){return{name:`grep-pages`,title:`Grep pages`,description:`Finds the docs lines that contain a text`,summary:`Find the docs lines that contain a text.`,schema:{type:`object`,additionalProperties:!1,required:[`query`],properties:{query:{type:`string`,minLength:1,description:`Text to find, case-insensitive. Not a regular expression`},section:{type:`string`,nullable:!0,description:`${K(t)}. Omit it to search every page`},maxMatches:{type:`integer`,nullable:!0,minimum:1,maximum:100,description:`Maximum matching lines to return (default 20)`}}},annotations:e,outputSchema:{type:`object`,required:[`matches`,`searchedPages`,`truncated`],properties:{matches:{type:`array`,items:{type:`object`,required:[`url`,`title`,`line`,`text`],properties:{url:{type:`string`},title:{type:`string`},line:{type:`number`},text:{type:`string`}}}},searchedPages:{type:`number`,description:`Pages searched: every page you can read, or every page in the section`},truncated:{type:`boolean`,description:`true = more matches exist; narrow the query or the section`},note:{type:`string`,description:`Present when nothing matches: the docs you can read do not contain the text`}}}}}const Q=Z(`tools`);export{k as GET_ENDPOINTS_SCHEMA,j as GET_ENDPOINT_INFO_SCHEMA,F as GET_FULL_API_DESCRIPTION_SCHEMA,G as GET_GRAPHQL_SCHEMA_SCHEMA,V as GET_GRAPHQL_TYPE_LIST_SCHEMA,U as GET_GRAPHQL_TYPE_SCHEMA,X as GET_PAGE_SCHEMA,N as GET_SECURITY_SCHEMES_SCHEMA,Q as GREP_PAGES_SCHEMA,D as LIST_APIS_CALLABLE_SCHEMA,E as LIST_APIS_SCHEMA,B as LIST_GRAPHQL_APIS_SCHEMA,Y as LIST_PAGES_SCHEMA,v as SEARCH_SCHEMA,b as SUBMIT_FEEDBACK_SCHEMA,y as WHOAMI_SCHEMA,A as getEndpointInfoToolSchema,O as getEndpointsToolSchema,P as getFullApiDescriptionToolSchema,W as getGraphqlSchemaToolSchema,H as getGraphqlTypeToolSchema,M as getSecuritySchemesToolSchema,Z as grepPagesToolSchema,J as listPagesToolSchema,_ as searchSchema};
@@ -0,0 +1 @@
1
+ import{isPlanFeatureGranted as e}from"../../../../../../shared/plan-gates.js";import{compileContentGlob as t}from"../../../../utils/glob.js";import{SPEC_KIND_ARAZZO as n}from"../../../../../../shared/constants/api-spec-kinds.js";import{filterApiDocsByRbac as r}from"../../../../../../shared/rbac/api-docs.js";import{formatError as i}from"../tool-errors.js";import{isDefinitionHidden as a}from"../tools/openapi-document.js";import{callableApis as o,excludedOperations as s}from"../gateway/eligibility.js";import{getAllowedHttpMethods as c}from"../gateway/allowed-http-methods.js";import{apiCallOperationsOf as l}from"../gateway/api-call-operations.js";import{resolveArazzoFile as u,sourceDescriptionPath as d}from"./resolve-workflows.js";const f=/* @__PURE__ */ new WeakMap;function p(e){let t=f.get(e);if(t)return t;let n=h(e);return f.set(e,n),n}async function m(e){return(await p(e)).some(e=>e.runnable.size>0)}async function h(t){if(!e(t.config,`mcpWorkflows`))return[];let n=await o(t);if(n.length===0)return[];let r=(await Promise.all((await g(t)).map(e=>_(t,e)))).filter(e=>e!==null);if(r.length===0)return[];let i=new Set(r.flatMap(({relativePath:e,document:t})=>v(e,t))),a=n.filter(e=>i.has(e.relativePath)).map(e=>({relativePath:e.relativePath,definition:e.definition,servers:e.servers,operations:l(e.fullDefinition,e.definition,e.servers,s(t,e.relativePath))})),d=c(t.config.mcp);return r.map(({relativePath:e,document:t})=>u({filePath:e,document:t,apis:a,allowedHttpMethods:d}))}async function g(e){let n=t(e.config.mcp?.ignore??[]),r=t(e.config.mcp?.apiCalls?.excludeFiles??[]);return(await e.entities.list({type:`api`})).flatMap(({key:e,metadata:t})=>{let{specType:i,sourcePath:a}=t??{};return i!==`arazzo`||typeof a!=`string`||n(a)||r(a)?[]:[{entityKey:e,relativePath:a}]})}async function _(e,{entityKey:t,relativePath:o}){try{let i=r(await e.entities.load(t),n,e.request.teams,{warn:t=>e.logger?.warn(t)});return!i||a(i.info,`apiCalls`)?null:{relativePath:o,document:i}}catch(n){return e.logger?.warn(`MCP: skipping Arazzo entity "${t}": ${i(n)}`),null}}function v(e,t){return(t.sourceDescriptions??[]).flatMap(t=>d(e,t.url)??[])}export{m as hasRunnableWorkflows,p as loadWorkflowCatalog};
@@ -0,0 +1 @@
1
+ import{BaseResolver as e,ResolveError as t,Source as n}from"@redocly/openapi-core";var r=class extends e{documents=/* @__PURE__ */ new Map;constructor(e,t,n){super(),this.documents.set(e,t);for(let{name:r,url:i}of t.sourceDescriptions??[])n.has(r)&&this.documents.set(this.resolveExternalRef(e,i),n.get(r))}async resolveDocument(e,r){let i=this.resolveExternalRef(e,r);return this.documents.has(i)?{source:new n(i,``),parsed:structuredClone(this.documents.get(i))}:new t(/* @__PURE__ */ Error(`"${r}" is not a document of this project`))}};export{r as InMemoryDocumentResolver};
@@ -0,0 +1 @@
1
+ import{isObject as e}from"../../../../../../shared/utils/is-object.js";function t(t,o){let s={};for(let{operationKey:r,path:i}of o){let a=t.paths?.[i];if(!e(a))continue;let{parameters:o,servers:c}=a;s[i]={...s[i],...o!==void 0&&{parameters:o},...c!==void 0&&{servers:c},[r]:n(a[r])}}let c=t.components?.securitySchemes,l={...t,paths:s,components:c?{securitySchemes:c}:{}},u=[s,l.security,c],d=/* @__PURE__ */ new Set;for(;u.length>0;){let e=u.pop();for(let n of i(e)){let[e,i,o]=n;if(e!==`components`||!i||!o)continue;let s=`${i}/${o}`;if(d.has(s))continue;d.add(s);let c=a(t,i,o),f=i===`responses`?r(c):c;if(f===void 0)continue;let p=l.components;p[i]={...p[i],[o]:f},u.push(f)}}return l}function n(t){if(!e(t)||!e(t.responses))return t;let n=Object.entries(t.responses).map(([e,t])=>[e,r(t)]);return{...t,responses:Object.fromEntries(n)}}function r(t){if(!e(t)||!e(t.content))return t;let n=Object.entries(t.content).map(([t,n])=>{if(!e(n))return[t,n];let{schema:r,...i}=n;return[t,i]});return{...t,content:Object.fromEntries(n)}}function i(t){let n=[],r=[t],i=/* @__PURE__ */ new Set;for(;r.length>0;){let t=r.pop();if(typeof t==`object`&&t&&!i.has(t)){if(i.add(t),Array.isArray(t))r.push(...t);else if(e(t)){let e=t.$ref;typeof e==`string`&&e.startsWith(`#/`)&&n.push(e.slice(2).split(`/`).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`))),r.push(...Object.values(t))}}}return n}function a(t,n,r){let i=t.components,a=e(i)?i[n]:void 0;return e(a)?a[r]:void 0}export{t as definitionForOperations};
@@ -0,0 +1 @@
1
+ import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{OPERATION_METHODS as t}from"../../../../../../shared/constants/openapi-operation-methods.js";import{withoutTrailingSlashes as n}from"../tools/openapi-document.js";import{operationHttpMethod as r,pathTemplateKey as i}from"../gateway/route-pattern.js";import{findUnresolvedPlaceholders as a}from"../gateway/fetch/url-placeholders.js";import{SOURCE_REFERENCE as o,UnsupportedWorkflowError as s,failureActionsOf as c,localWorkflowId as l,referencedWorkflowIds as u,successActionsOf as d}from"./workflow-references.js";import{definitionForOperations as f}from"./operations-subset.js";import{stepKey as p}from"./types.js";import{posix as m}from"node:path";import{replaceServerVariables as h}from"@redocly/api-docs/lib/services/code-samples/server-variables.js";import{resolveRef as g}from"@redocly/api-docs/lib/utils/inline-openapi-refs.js";const _=/^\{\$sourceDescriptions\.([\w.-]+)\.url\}#(\/.+)$/,v=/^([\w-]+)\.(.+)$/,y=/^[a-z][a-z0-9+.-]*:/i,b=/^https?:\/\//i,x=/\$components\.(\w+)\.([\w.-]+)/g,S=/\b(?:match|search)\s*\(/,C=[`multipart/form-data`,`application/octet-stream`],w=new Set(t);function T(e){let{filePath:t,document:n}=e,r=E(e),i=new Map((n.workflows??[]).map(e=>[e.workflowId,e])),a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map;for(let t of i.values())try{if(R(t,n.components))throw new s(`it generates test data with $faker`);for(let n of t.steps??[]){let i=A(n,t,r,e);i&&a.set(p(t.workflowId,n.stepId),i)}for(let e of u(t,n.components))V(e,r)}catch(e){if(!(e instanceof s))throw e;o.set(t.workflowId,e.message)}H(i,o),G(i,n.components,o);let c=/* @__PURE__ */ new Map;for(let e of i.values())o.has(e.workflowId)||c.set(e.workflowId,{workflow:e,inputs:K(e,i),methods:q(e,i,n.components,a)});return{filePath:t,title:n.info?.title??m.basename(t),document:n,sources:D(n,r,[...a.values()]),operations:a,runnable:c,unsupported:o}}function E({filePath:e,document:t,apis:n}){let r=/* @__PURE__ */ new Map;for(let i of t.sourceDescriptions??[]){let t=k(e,i.url);if(t){if(i.type===`arazzo`&&t===e)r.set(i.name,{kind:`self`});else if(i.type===`openapi`&&!i[`x-serverUrl`]){let e=n.find(e=>e.relativePath===t);e&&r.set(i.name,{kind:`api`,api:e})}}}return r}function D(e,t,n){let r=/* @__PURE__ */ new Map;for(let{name:i,type:a}of e.sourceDescriptions??[]){let e=t.get(i);if(e?.kind!==`self`){if(e?.kind===`api`){let{definition:t,servers:a}=e.api,o=n.filter(e=>e.sourceName===i);r.set(i,{...f(t,o),servers:[...a]})}else r.set(i,O(a,i))}}return r}function O(e,t){let n={title:t,version:`0`};return e===`arazzo`?{arazzo:`1.0.1`,info:n,sourceDescriptions:[],workflows:[]}:{openapi:`3.1.0`,info:n,paths:{}}}function k(e,t){if(!(y.test(t)||t.startsWith(`/`)))return m.normalize(m.join(m.dirname(e),t))}function A(e,t,n,a){if(L(e,t,a.document.components),c(e,t,a.document.components).some(B))throw new s(`step "${e.stepId}" waits more than 5 seconds before a retry`);if(e.workflowId)return;let o=j(e,n);if(!o)throw new s(`step "${e.stepId}" calls no operation of a callable API`);let{sourceName:l,api:u,path:d,method:f,operation:p}=o,m=r(f),h=i(d),g=u.operations.find(e=>e.method===m&&i(e.path)===h);if(!g?.callable||!g.visible)throw new s(`step "${e.stepId}" calls ${m} ${d}, which agents cannot call`);if(!a.allowedHttpMethods.includes(m))throw new s(`step "${e.stepId}" sends ${m}, which this project does not allow`);let _=e.requestBody?.contentType??F(p,u.definition);if(e.requestBody&&_&&C.some(e=>_.includes(e)))throw new s(`step "${e.stepId}" sends ${_}, which workflows cannot send`);if(!I(u))throw new s(`step "${e.stepId}" calls an API without an absolute server URL`);return{sourceName:l,method:m,operationKey:f,path:d}}function j(e,t){if(e.operationPath)return M(e.operationPath,t);if(!e.operationId)return;let n=o.exec(e.operationId)??v.exec(e.operationId),r=n?[[n[1],t.get(n[1])]]:[...t],i=n?n[2]:e.operationId,a=r.flatMap(([e,t])=>t?.kind===`api`?N(e,t.api,i):[]);return a.length===1?a[0]:void 0}function M(e,t){let n=_.exec(e),r=n&&t.get(n[1]);if(!n||r?.kind!==`api`)return;let i=n[2].slice(1).split(`/`).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`));if(i.length!==3||i[0]!==`paths`)return;let[,a,o]=i,s=P(r.api,a,o);return s&&{sourceName:n[1],api:r.api,path:a,method:o,operation:s}}function N(t,n,r){return Object.entries(n.definition.paths??{}).flatMap(([i,a])=>Object.keys(e(a)?a:{}).flatMap(e=>{let a=P(n,i,e);return a?.operationId===r?[{sourceName:t,api:n,path:i,method:e,operation:a}]:[]}))}function P(t,n,r){if(!w.has(r.toLowerCase()))return;let i=t.definition.paths?.[n],a=e(i)?i[r]:void 0;return e(a)?a:void 0}function F(t,n){let r=t.requestBody,i=r&&`$ref`in r&&r.$ref?g(r.$ref,n):r,a=e(i)?i.content:void 0;return e(a)?Object.keys(a)[0]:void 0}function I(e){let[t]=e.servers;if(!t)return!1;let r=n(h(t));return b.test(r)&&a(r).length===0}function L(e,t,n){let r=[...d(e,t,n),...c(e,t,n)],i=[...e.successCriteria??[],...r.flatMap(e=>e.criteria??[])];for(let{type:t,condition:n}of i){let r=typeof t==`object`?t.type:t;if(r===`xpath`)throw new s(`step "${e.stepId}" checks an XPath criterion, which workflows cannot evaluate`);if(r===`regex`||r===`jsonpath`&&S.test(n))throw new s(`step "${e.stepId}" checks a regex, which workflows cannot evaluate safely`)}}function R(e,t){let n=JSON.stringify(e);return[n,...[...n.matchAll(x)].map(([,e=``,n=``])=>JSON.stringify(z(t,e,n))??``)].some(e=>e.includes(`$faker`))}function z(t,n,r){let i=t,a=e(i)?i[n]:void 0;return e(a)?a[r]:void 0}function B(e){return e.type===`retry`&&(e.retryAfter??0)>5}function V(e,t){let n=o.exec(e);if(n&&t.get(n[1])?.kind!==`self`)throw new s(`it uses workflow "${e}" of another file`)}function H(e,t){for(let n of e.values()){let r=U(n,e);r&&!t.has(n.workflowId)&&t.set(n.workflowId,`it calls itself through workflow "${r}"`)}}function U(e,t){for(let n of W(e)){let r=/* @__PURE__ */ new Set,i=[n];for(;i.length>0;){let a=i.pop();if(a===e.workflowId)return n;if(r.has(a))continue;r.add(a);let o=t.get(a);o&&i.push(...W(o))}}}function W(e){let t=(e.steps??[]).flatMap(e=>e.workflowId?[l(e.workflowId)]:[]);return[...(e.dependsOn??[]).map(l),...t]}function G(e,t,n){let r=!0;for(;r;){r=!1;for(let i of e.values()){if(n.has(i.workflowId))continue;let a=u(i,t).map(l).find(t=>!e.has(t)||n.has(t));a!==void 0&&(n.set(i.workflowId,`it uses workflow "${a}", which cannot run`),r=!0)}}}function K(e,t){let n={},r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=e=>{if(!i.has(e.workflowId)){i.add(e.workflowId);for(let[t,r]of Object.entries(e.inputs?.properties??{}))t in n||(n[t]=r);for(let t of e.inputs?.required??[])r.add(t);for(let n of e.dependsOn??[]){let e=t.get(l(n));e&&a(e)}}};return a(e),r.size>0?{type:`object`,properties:n,required:[...r]}:{type:`object`,properties:n}}function q(e,t,n,r){let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=[e];for(;o.length>0;){let e=o.pop();if(!a.has(e.workflowId)){a.add(e.workflowId);for(let t of e.steps??[]){let n=r.get(p(e.workflowId,t.stepId))?.method;n&&i.add(n)}for(let r of u(e,n)){let e=t.get(l(r));e&&o.push(e)}}}return[...i].sort()}export{T as resolveArazzoFile,k as sourceDescriptionPath};
@@ -0,0 +1 @@
1
+ import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{errorMessage as t}from"../../../../../../shared/utils/error-message.js";import{redactSecretsFromString as n}from"../gateway/fetch/redact.js";import{stepKey as r}from"./types.js";import{stripVTControlCharacters as i}from"node:util";const a=JSON.stringify({CONTENT_TYPE_CHECK:`warn`}),o=/* @__PURE__ */ new Set([101,103,204,205,304]),s=/* @__PURE__ */ new Set([`failed network request`,`unexpected error`]),c={info:()=>{},warn:()=>{},output:()=>{},error:()=>{},printNewLine:()=>{},printSeparator:()=>{},indent:e=>e},l={getFileBody:()=>Promise.reject(/* @__PURE__ */ Error(`workflows cannot send files`))};let u;async function d(n){let{file:r,workflowId:i}=n,o=b(n),s,d;try{let[{run:t},{createConfig:o},{InMemoryDocumentResolver:p}]=await Promise.all([import(`@redocly/respect-core`),import(`@redocly/openapi-core`),import(`./document-resolver.js`)]),[m]=await t({files:[`/${r.filePath}`],workflow:[i],input:JSON.stringify(n.inputs),fetch:f(n.fetch),externalRefResolver:new p(`/${r.filePath}`,r.document,r.sources),config:await(u??=o({})),logger:c,skipLint:!0,maxSteps:100,maxFetchTimeout:Math.max(n.deadline-Date.now(),1),severity:a,requestFileLoader:l,envVariables:{}});s=m?.executedWorkflows.find(e=>e.workflowId===i);let h=m?.ctx.$outputs?.[i];d=e(h)?h:{}}catch(e){return v(i,[],{workflowId:i,reason:t(e)},o)}if(!s)return v(i,[],{workflowId:i,reason:`the workflow did not run`},o);let m=p(s),y=m.map(({step:e,workflowId:t})=>h(r,e,t,i)),x=m.find(({step:e,isRetried:t})=>!t&&g(e));return x?v(i,y,_(x),o):{workflowId:i,status:`succeeded`,outputs:d,steps:y}}function f(e){return async(t,n)=>{let r=n?.body;if(r!=null&&typeof r!=`string`&&!(r instanceof URLSearchParams))throw Error(`workflows send only text request bodies`);let i=await e({url:t instanceof Request?t.url:String(t),method:n?.method??`GET`,headers:Object.fromEntries(new Headers(n?.headers)),...r!=null&&{body:String(r)}});return new Response(o.has(i.status)?null:i.bodyText,{status:i.status,statusText:i.statusText,headers:i.headers})}}function p(e,t=!1){let n=e.executedSteps,r=/* @__PURE__ */ new Map;return n.forEach((e,t)=>{m(e)&&r.set(e.stepId,t)}),n.flatMap((n,i)=>{if(!m(n))return[{step:n,workflowId:e.workflowId,isRetried:t||!!n.retriesLeft}];let a=r.get(n.stepId)!==i;return p(n,t||a)})}function m(e){return`type`in e&&e.type===`workflow`}function h(e,t,n,i){let a=e.operations.get(r(n,t.stepId)),o={stepId:t.stepId,ms:t.response?.time??0};n!==i&&(o.workflowId=n);let c=t.response?.requestUrl;if(a){let e=typeof c==`string`?new URL(c).pathname:a.path;o.request=`${a.method} ${e}`}t.response?.statusCode&&(o.status=t.response.statusCode);let l=t.checks.find(e=>!e.passed&&s.has(e.name));return l&&(o.error=y(l.message??l.name)),o}function g(e){return e.checks.find(e=>!e.passed&&e.severity===`error`)}function _({step:e,workflowId:t}){let n=g(e),r={workflowId:t,stepId:e.stepId,reason:n?.message?y(n.message):`${n?.name??`a check`} failed`};if(e.response?.statusCode){let{body:t}=e.response;r.response={status:e.response.statusCode,body:(typeof t==`string`?t:JSON.stringify(t)).slice(0,2048)}}return r}function v(e,t,n,r){return{workflowId:e,status:`failed`,steps:t,failure:x(n,r)}}function y(e){return i(e).trim()}function b({file:t,workflowId:n,inputs:r}){let i=t.runnable.get(n)?.inputs.properties??{};return Object.entries(i).flatMap(([t,n])=>{let i=r[t];return e(n)&&n.format===`password`&&typeof i==`string`?[i]:[]})}function x(e,t){if(t.length===0)return e;let r={...e,reason:n(e.reason,t)};return e.response&&(r.response={...e.response,body:n(e.response.body,t)}),r}export{d as runWorkflow};