@redocly/framework 1.0.0-next.3 → 1.0.0-next.4

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 (176) 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/vite-config.js +2 -2
  4. package/dist/bundler/dev/materialization-sweeper.js +1 -1
  5. package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
  6. package/dist/bundler/dev/routes/source-sync-route.js +1 -1
  7. package/dist/bundler/dev/run.js +1 -1
  8. package/dist/bundler/dev/runtime-app.js +1 -1
  9. package/dist/bundler/dev/vite-chunk-url.js +1 -1
  10. package/dist/bundler/user-markdoc-schema.js +1 -1
  11. package/dist/bundler/vite-config.base.js +3 -3
  12. package/dist/cli/commands/build.js +1 -1
  13. package/dist/cli/commands/dev.js +1 -1
  14. package/dist/cli/commands/ingest.js +1 -1
  15. package/dist/cli/commands/translate.js +2 -2
  16. package/dist/cli/dev-console/index.js +1 -1
  17. package/dist/cli/log-output/index.js +1 -1
  18. package/dist/cli/validate-react-pages.js +1 -1
  19. package/dist/client/RuntimeLink.js +1 -1
  20. package/dist/client/ai-search/use-ai-search.js +1 -1
  21. package/dist/client/analytics-page-view.js +1 -1
  22. package/dist/client/app.js +3 -3
  23. package/dist/client/client-entry.js +1 -1
  24. package/dist/client/contexts.js +1 -1
  25. package/dist/client/dev-problems/ProblemsBar.js +1 -1
  26. package/dist/client/feedback.js +1 -1
  27. package/dist/client/l10n/use-l10n-config.js +1 -1
  28. package/dist/client/products.js +1 -1
  29. package/dist/client/review/ReviewBar.js +50 -50
  30. package/dist/client/review/use-review.js +1 -1
  31. package/dist/client/sidebar/SidebarDataProvider.js +1 -1
  32. package/dist/client/sidebar/drilldown.js +1 -1
  33. package/dist/client/ssr.js +1 -1
  34. package/dist/client/telemetry/config.js +1 -1
  35. package/dist/client/use-entity-revisions.js +1 -1
  36. package/dist/client/use-page-versions.js +1 -1
  37. package/dist/client/use-search.js +1 -1
  38. package/dist/client/webmcp/tools/shared.js +1 -1
  39. package/dist/client/webmcp/tools/site-tools.js +1 -1
  40. package/dist/client/webmcp/use-webmcp-tools.js +1 -1
  41. package/dist/content-layer/config.js +1 -1
  42. package/dist/content-layer/database/invalidation.js +26 -26
  43. package/dist/content-layer/ingest/finalize-phase.js +1 -1
  44. package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
  45. package/dist/content-layer/ingest/run.js +1 -1
  46. package/dist/content-layer/ingest/search-sync.js +1 -1
  47. package/dist/content-layer/ingest/sync.js +1 -1
  48. package/dist/content-layer/link-checker/load-view.js +1 -1
  49. package/dist/content-layer/link-checker/validate.js +1 -1
  50. package/dist/content-layer/loaders/context.js +1 -1
  51. package/dist/content-layer/markdown/client/markdown-text.js +1 -1
  52. package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
  53. package/dist/content-layer/markdown/constants/markdown-text-tag-set.js +1 -1
  54. package/dist/content-layer/markdown/constants/tag-sets.js +1 -1
  55. package/dist/content-layer/markdown/nodes/heading.js +1 -1
  56. package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.js +1 -1
  57. package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
  58. package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
  59. package/dist/content-layer/markdown/resolve/references.js +1 -1
  60. package/dist/content-layer/markdown/search/to-markdown.js +1 -1
  61. package/dist/content-layer/markdown/search/to-sections.js +1 -1
  62. package/dist/content-layer/markdown/server/render.js +1 -1
  63. package/dist/content-layer/markdown/tags/variant.js +1 -1
  64. package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
  65. package/dist/content-layer/plugins/index.js +1 -1
  66. package/dist/content-layer/plugins/internal/api-docs/client/rebase-item-links.js +1 -1
  67. package/dist/content-layer/plugins/internal/api-docs/client/template.js +2 -2
  68. package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
  69. package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.js +13 -13
  70. package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
  71. package/dist/content-layer/plugins/internal/app-data/banner.js +1 -1
  72. package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
  73. package/dist/content-layer/plugins/internal/catalog-classic/client/use-catalog-classic.js +1 -1
  74. package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
  75. package/dist/content-layer/plugins/internal/index.js +1 -1
  76. package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
  77. package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
  78. package/dist/content-layer/plugins/internal/mcp/constants.d.ts +0 -6
  79. package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
  80. package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
  81. package/dist/content-layer/plugins/internal/mcp/ignored-routes.js +1 -1
  82. package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
  83. package/dist/content-layer/plugins/internal/mcp/server/codemode/capabilities.js +3 -3
  84. package/dist/content-layer/plugins/internal/mcp/server/codemode/constants.js +1 -1
  85. package/dist/content-layer/plugins/internal/mcp/server/codemode/discover.js +1 -1
  86. package/dist/content-layer/plugins/internal/mcp/server/codemode/execute-schema.js +1 -1
  87. package/dist/content-layer/plugins/internal/mcp/server/codemode/index.js +1 -1
  88. package/dist/content-layer/plugins/internal/mcp/server/codemode/prompts.js +8 -8
  89. package/dist/content-layer/plugins/internal/mcp/server/codemode/sandbox.js +1 -1
  90. package/dist/content-layer/plugins/internal/mcp/server/codemode/tool-list.js +1 -1
  91. package/dist/content-layer/plugins/internal/mcp/server/gateway/api-call-operations.js +1 -1
  92. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
  93. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
  94. package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +6 -5
  95. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/allowed-hosts.js +1 -1
  96. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-bridge.js +1 -1
  97. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-errors.js +1 -1
  98. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/ssrf-guard.js +1 -1
  99. package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
  100. package/dist/content-layer/plugins/internal/mcp/server/gateway/subject.js +1 -1
  101. package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +4 -4
  102. package/dist/content-layer/plugins/internal/mcp/server/gateway/upstream-auth-scheme.js +2 -2
  103. package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
  104. package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.js +1 -1
  105. package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
  106. package/dist/content-layer/plugins/internal/mcp/server/server-info.js +1 -1
  107. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-document.js +1 -1
  108. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql.js +1 -1
  109. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-catalog.js +1 -1
  110. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-document.js +1 -1
  111. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi.js +1 -1
  112. package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
  113. package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +3 -3
  114. package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +1 -1
  115. package/dist/content-layer/plugins/internal/mcp/server/tools/submit-feedback.js +1 -1
  116. package/dist/content-layer/plugins/internal/mcp/server/tools/whoami.js +1 -1
  117. package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
  118. package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
  119. package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
  120. package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
  121. package/dist/content-layer/plugins/internal/skills/index.js +1 -1
  122. package/dist/content-layer/plugins/project/load.js +2 -2
  123. package/dist/content-layer/plugins/utils/link-access.js +1 -1
  124. package/dist/content-layer/plugins/utils/route-index.js +1 -1
  125. package/dist/content-layer/versions/redirect.js +1 -1
  126. package/dist/content-layer/versions/resolve.js +1 -1
  127. package/dist/server/__tests__/rbac-fixture.js +1 -1
  128. package/dist/server/app.js +3 -3
  129. package/dist/server/ask-ai/route.js +1 -1
  130. package/dist/server/auth/middleware.js +1 -1
  131. package/dist/server/auth/request.js +1 -1
  132. package/dist/server/auth/routes.js +1 -1
  133. package/dist/server/constants/system-routes.js +1 -1
  134. package/dist/server/content.js +13 -13
  135. package/dist/server/cors-proxy/handler.js +1 -1
  136. package/dist/server/feedback/route.js +1 -1
  137. package/dist/server/lambda-entry.js +1 -1
  138. package/dist/server/llms-txt.js +1 -1
  139. package/dist/server/manifest-assets.js +4 -4
  140. package/dist/server/node-entry.js +1 -1
  141. package/dist/server/plugin-context.js +1 -1
  142. package/dist/server/public-url.js +1 -0
  143. package/dist/server/rbac/l10n-rules.js +1 -1
  144. package/dist/server/rbac/team-templates.js +1 -1
  145. package/dist/server/search/cache.js +1 -0
  146. package/dist/server/search/route.js +1 -1
  147. package/dist/server/seo-tags.js +2 -2
  148. package/dist/server/static-files/serve.js +1 -1
  149. package/dist/shared/constants/l10n/langs/ar.js +1 -1
  150. package/dist/shared/constants/l10n/langs/de.js +1 -1
  151. package/dist/shared/constants/l10n/langs/en.js +1 -1
  152. package/dist/shared/constants/l10n/langs/es.js +1 -1
  153. package/dist/shared/constants/l10n/langs/fr.js +1 -1
  154. package/dist/shared/constants/l10n/langs/hi.js +1 -1
  155. package/dist/shared/constants/l10n/langs/it.js +1 -1
  156. package/dist/shared/constants/l10n/langs/ja.js +1 -1
  157. package/dist/shared/constants/l10n/langs/ko.js +1 -1
  158. package/dist/shared/constants/l10n/langs/pl.js +1 -1
  159. package/dist/shared/constants/l10n/langs/pt-br.js +1 -1
  160. package/dist/shared/constants/l10n/langs/pt.js +1 -1
  161. package/dist/shared/constants/l10n/langs/ru.js +1 -1
  162. package/dist/shared/constants/l10n/langs/uk.js +1 -1
  163. package/dist/shared/constants/l10n/langs/zh.js +1 -1
  164. package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
  165. package/dist/shared/utils/routes/markdown-copy-url.js +1 -0
  166. package/package.json +6 -4
  167. package/dist/content-layer/plugins/internal/mcp/server/codemode/execution-budget.js +0 -1
  168. package/dist/content-layer/plugins/internal/mcp/server/codemode/read-result.js +0 -1
  169. package/dist/content-layer/plugins/internal/mcp/server/codemode/return-last-expression.js +0 -6
  170. package/dist/content-layer/plugins/internal/mcp/server/codemode/returns-from-top-level.js +0 -1
  171. package/dist/content-layer/plugins/internal/mcp/server/codemode/tool-declarations.js +0 -4
  172. package/dist/content-layer/plugins/internal/mcp/server/codemode/unknown-tool-hint.js +0 -3
  173. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-constants.js +0 -1
  174. package/dist/content-layer/plugins/internal/mcp/server/tools/pages-constants.js +0 -1
  175. package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +0 -1
  176. package/dist/shared/utils/routes/markdown-path.js +0 -1
@@ -1 +1 @@
1
- import{defineContentPlugin as e}from"../../define.js";import{toJsonObject as t,toJsonValue as n}from"../../../database/utils/json.js";import{createEntityLoader as r}from"../../../loaders/define.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{buildSearchAppData as a}from"../../../../shared/search/facets.js";import{isObject as o}from"../../../../shared/utils/is-object.js";import{isAiHidden as s}from"../../../../shared/ask-ai/config-gate.js";import{parseNestedConfig as c}from"../../../config.js";import{APP_DATA_STATIC_DATA_SLUG as l}from"../../../../shared/constants/app-data.js";import{isAttributionRemoved as u,isPlanFeatureGranted as d}from"../../../../shared/plan-gates.js";import{splitUrlSuffix as f}from"../../../../shared/utils/routes/split-url-suffix.js";import{toNavItemRbacAnnotation as p}from"../../../../server/rbac/filter.js";import{resolvePageTarget as m}from"../../../../shared/utils/routes/resolve-page-target.js";import{listConfiguredProducts as h}from"../../../products.js";import{collectVersionGroups as g,findVersionedDirectories as ee}from"../../../versions/version-groups.js";import{publicLink as _}from"../../../versions/public-link.js";import{linkedPageAccess as v}from"../../utils/link-access.js";import{loadSidebarSubtreeLabel as y}from"../../utils/sidebar-label.js";import{resolveBannerForAppData as te}from"./banner.js";import{resolveLogoForAppData as ne}from"./logo.js";import{resolveNavbarIconsForAppData as b}from"./navbar-icons.js";import{resolveHtmlForAppData as x}from"./html.js";import{resolveSeoForAppData as S}from"./seo.js";import{productConfigPath as C,productLandingLink as w,resolveProductAssetsForAppData as T}from"./products.js";import{dirname as E,resolve as D}from"node:path";import{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";const k=`internal.app-data`,A=`1.32.0`,j=i(k,`app-data`);function M(e){return o(e)&&typeof e.owner==`string`&&`value`in e}const N=r(j,async e=>{let n=new Set(e.pluginRegistry.listFinalizePlugins().map(e=>e.id)),r={};for(let[t,i]of Object.entries(e.args.fragments??{}))M(i)&&n.has(i.owner)&&(r[t]=i.value);let i=await ne(e.config.logo,e.markdown,e.file.path);if(Object.keys(i.logo).length>0){let e=o(r.theme)?r.theme:{};r.theme=t({...e,logo:i.logo})}let a=await te(e.config.banner,e);if(a){let e=o(r.theme)?r.theme:{};r.theme=t({...e,banner:a.banner})}let s=await b(o(r.theme)?r.theme.navbar:void 0,e.markdown,e.file.path);if(s){let e=o(r.theme)?r.theme:{};r.theme=t({...e,navbar:s.navbar})}let c=await b(o(r.theme)?r.theme.footer:void 0,e.markdown,e.file.path);if(c){let e=o(r.theme)?r.theme:{};r.theme=t({...e,footer:c.navbar})}let l=await T(o(r.theme)?r.theme.products:void 0,e.markdown,e.file.path);if(l){let e=o(r.theme)?r.theme:{};r.theme=t({...e,products:l.products})}let u=await x(e.config,e.markdown,e.file.path,t=>e.io.readFile(D(E(e.file.absolutePath),t)),e.logger);u&&(r.html=t(u.html));let d=await S(r.seo,e.markdown,e.file.path);d&&(r.seo=d.seo);let f=[i,a,s,c,l,u,d];return{value:r,entityDeps:f.flatMap(e=>e?.deps??[]),assetUsages:f.flatMap(e=>e?.assetUsages??[])}});function P(e){return{isSystem:!0,key:l,kind:`loader`,type:null,metadata:null,loaderArgs:{pluginVersion:A},loaderId:j,pluginId:k,shouldInvalidateValue:!1,value:null,version:null,fragmentUpdates:e.fragmentUpdates}}const F=e({id:k,version:A,async finalize(e){let r=await g({io:e.io,routes:e.routes,versionedDirectories:ee(e.routes.all())}),i=e=>e&&_(e,r),a=t=>t&&{slug:_(t,r),loadLabel:()=>y(e.entities,t)},s=t=>a(e.routes.byFilePath(t)),c=t=>a(e.routes.bySlug(t)),l=t=>v(t,e.routes,r),u=await V(e.config,s,c,e.logger,l),d=await L(e,s,c,i,l);if(Object.keys(d).length>0){let e=o(u.theme)?u.theme:{};u.theme=t({...e,products:d}),u.pageProducts=n(Object.values(d).map(I))}return{appData:u}},loaders:[N]});function I(e){let{name:t,slug:n,configOverride:r}=e,i={name:t,slug:n},a=r?.analytics?.ga;return a&&(i.ga=a),i}async function L(e,n,r,i,o){let s={};for(let t of h(e.config)){let c=await w(t,e.routes,e.io,i);if(c===void 0){e.logger.warn(`Product "${t.id}" is left out of the product picker: "${t.folder}" has no page.`);continue}let l={name:t.name,folder:t.folder,slug:t.slug,link:c,[O]:o(c)??void 0};t.icon!==void 0&&(l.icon=t.icon);let u=C(t.folder),d=await e.io.exists(u)?await z(R(await e.io.readFile(u),u),{page:Q(n,r,u,e.logger),access:o},a(e.config),e.config):{};Object.keys(d).length>0&&(l.configOverride=d),s[t.id]=l}return t(s)}function R(e,t){try{return c(e,t).config}catch{return{}}}async function z(e,t,n,r){let i={},a=await K(e.navbar,t),o=await G(e.footer,t),s=W(e.breadcrumbs,t);return e.logo&&(i.logo=e.logo),a&&(i.navbar=a),o&&(i.footer=o),s&&d(r,`breadcrumbs`)&&(i.breadcrumbs=s),e.feedback&&(i.feedback=e.feedback),e.sidebar&&(i.sidebar=e.sidebar),e.codeSnippet&&(i.codeSnippet=e.codeSnippet),e.palette&&(i.palette=e.palette),e.search&&(i.search=await B(e.search,n,t)),e.analytics?.ga&&d(r,`analytics`)&&(i.analytics={ga:e.analytics.ga}),i}async function B(e,n,r){let i={...n},a=await q(e?.suggestedPages,r);return e?.hide!==void 0&&(i.hide=e.hide),e?.placement!==void 0&&(i.placement=e.placement),e?.shortcuts!==void 0&&(i.shortcuts=e.shortcuts),a.length>0&&(i.suggestedPages=a),t(i)}async function V(e,n,r,i,o=()=>void 0){let s={},c={page:Q(n,r,ae,i),access:o},l=await K(e.navbar,c),d=await G(e.footer,c),f=e.seo?.projectTitle,p=W(e.breadcrumbs,c),m={...l?{navbar:l}:{},...d?{footer:d}:{},...p?{breadcrumbs:p}:{},markdown:e.markdown,navigation:e.navigation,userMenu:await X(e.userMenu,c),feedback:e.feedback,consent:e.consent,...f?{seo:{projectTitle:f}}:{},aiAssistant:H(e),mcp:U(e),search:await B(e.search,a(e),c),sidebar:e.sidebar,versionPicker:e.versionPicker,codeSnippet:e.codeSnippet,palette:e.palette};if(e.colorMode&&(m.colorMode=e.colorMode),Object.keys(m).length>0&&(s.theme=m),e.analytics&&(s.analytics=e.analytics),e.planGates&&(s.removeAttribution=u(e)),e.removeAttribution===!0&&(s.removeConsoleAttribution=!0),e.seo){let{projectTitle:t,llmstxt:n,...r}=e.seo;Object.keys(r).length>0&&(s.seo=r)}return t(s)}function H(e){let t=s(e),n=e.aiAssistant?.trigger;return{...e.aiAssistant,hide:t,trigger:{...n,hide:n?.hide??t}}}function U(e){let t=e.mcp?.hide===!0;return{hide:t,docs:{hide:t}}}function W(e,n){if(!e)return null;let r={};e.hide!==void 0&&(r.hide=e.hide);let i=(e.prefixItems??[]).map(e=>{let t=e.page?n.page(e.page)?.link:void 0;return{icon:$(e.icon),label:$(e.label)??``,labelTranslationKey:$(e.labelTranslationKey),link:t,[O]:Y(n,t)}});return i.length>0&&(r.prefixItems=i),Object.keys(r).length>0?t(r):null}async function G(e,n){if(!e)return null;let r={hide:e.hide===!0},i=await q(e.items,n);return e.copyrightText!==void 0&&(r.copyrightText=e.copyrightText),e.logo&&(r.logo=e.logo),i.length>0&&(r.items=i),t(r)}async function K(e,n){if(!e)return null;let r={},i=await q(e.items,n);return e.hide!==void 0&&(r.hide=e.hide),i.length>0&&(r.items=i),Object.keys(r).length>0?t(r):null}async function q(e,t){return Array.isArray(e)?(await Promise.all(e.map(e=>J(e,t)))).filter(e=>e!==null):[]}async function J(e,n){if(typeof e==`string`)return J({page:e},n);if(!o(e))return null;if(typeof e.separator==`string`)return t({...Z(e),label:e.separator,type:`separator`});let r=await q(e.items,n),i=ie(e,n.page),a=i?.link,s=e.rbac===void 0?Y(n,a):void 0,c=$(e.label)??$(e.group)??(i?i.anchor??await i.loadLabel?.()??i.link:``);return typeof e.group==`string`||r.length>0?t({...Z(e),...a?{link:a}:{},...r.length>0?{items:r}:{},label:c,labelTranslationKey:$(e.groupTranslationKey)??$(e.labelTranslationKey),type:`group`,[O]:s}):a?t({...Z(e),...ce(e.external)??oe(a)?{external:!0}:{},label:c,link:a,type:`link`,[O]:s}):null}function Y(e,t){return t===void 0?void 0:e.access(t)??void 0}async function X(e,n){if(!e)return;let r=[];for(let t of e.items??[])r.push({...t,href:t.link});let i=await q(r,n);return t({...e,menu:i.length>0?i:void 0})}function Z(e){let t=se(e,[`additionalProps`,`expanded`,`labelTranslationKey`,`languageInsensitive`,`linePosition`,`linkedSidebars`,`menuStyle`,`selectFirstItemOnExpand`,`separatorLine`,`target`,`version`]),n=re(e.icon);return n.icon&&(t.icon=n.icon),n.srcSet&&(t.srcSet=n.srcSet),{...t,...p(e.rbac)}}function re(e){return typeof e==`string`?{icon:e}:o(e)&&typeof e.srcSet==`string`?{srcSet:e.srcSet}:{}}function ie(e,t){return typeof e.href==`string`&&e.href.trim()!==``?{link:e.href.trim()}:typeof e.page==`string`&&e.page.trim()!==``?t(e.page):null}const ae=`redocly.yaml`;function Q(e,t,n,r){let i={bySlug:e=>t?.(e),byFilePath:t=>e?.(t)};return e=>{let{path:t,suffix:a,anchor:o}=f(e.trim()),s=m(t,n,i);return s.kind===`escaped`?(r?.warn(`Config page reference escapes the content root`,{page:e}),null):s.kind===`missing`?(r?.warn(`Config page has no matching route`,{page:e}),{link:e.trim()}):{link:`${s.value.slug}${a}`,anchor:o,loadLabel:s.value.loadLabel}}}function oe(e){return/^(?:[a-z][a-z\d+.-]*:)?\/\//i.test(e)||/^(?:mailto|tel):/i.test(e)}function se(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function $(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function ce(e){return typeof e==`boolean`?e:void 0}export{k as APP_DATA_PLUGIN_ID,A as APP_DATA_PLUGIN_VERSION,j as APP_DATA_STATIC_DATA_LOADER_ID,l as APP_DATA_STATIC_DATA_SLUG,F as appDataContentPlugin,P as appDataSystemEntityDescriptor,V as buildConfigAppData,M as isAppDataFragment};
1
+ import{defineContentPlugin as e}from"../../define.js";import{toJsonObject as t,toJsonValue as n}from"../../../database/utils/json.js";import{createEntityLoader as r}from"../../../loaders/define.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{buildSearchAppData as a}from"../../../../shared/search/facets.js";import{APP_DATA_STATIC_DATA_SLUG as o}from"../../../../shared/constants/app-data.js";import{isObject as s}from"../../../../shared/utils/is-object.js";import{splitUrlSuffix as c}from"../../../../shared/utils/routes/split-url-suffix.js";import{isAiHidden as l}from"../../../../shared/ask-ai/config-gate.js";import{parseNestedConfig as u}from"../../../config.js";import{isAttributionRemoved as d,isPlanFeatureGranted as f}from"../../../../shared/plan-gates.js";import{toNavItemRbacAnnotation as p}from"../../../../server/rbac/filter.js";import{resolvePageTarget as m}from"../../../../shared/utils/routes/resolve-page-target.js";import{listConfiguredProducts as h}from"../../../products.js";import{collectVersionGroups as g,findVersionedDirectories as ee}from"../../../versions/version-groups.js";import{publicLink as _}from"../../../versions/public-link.js";import{linkedPageAccess as v}from"../../utils/link-access.js";import{loadSidebarSubtreeLabel as y}from"../../utils/sidebar-label.js";import{resolveBannerForAppData as te}from"./banner.js";import{resolveLogoForAppData as ne}from"./logo.js";import{resolveNavbarIconsForAppData as b}from"./navbar-icons.js";import{resolveHtmlForAppData as x}from"./html.js";import{resolveSeoForAppData as S}from"./seo.js";import{productConfigPath as C,productLandingLink as w,resolveProductAssetsForAppData as T}from"./products.js";import{dirname as E,resolve as D}from"node:path";import{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";const k=`internal.app-data`,A=`1.32.0`,j=i(k,`app-data`);function M(e){return s(e)&&typeof e.owner==`string`&&`value`in e}const N=r(j,async e=>{let n=new Set(e.pluginRegistry.listFinalizePlugins().map(e=>e.id)),r={};for(let[t,i]of Object.entries(e.args.fragments??{}))M(i)&&n.has(i.owner)&&(r[t]=i.value);let i=await ne(e.config.logo,e.markdown,e.file.path);if(Object.keys(i.logo).length>0){let e=s(r.theme)?r.theme:{};r.theme=t({...e,logo:i.logo})}let a=await te(e.config.banner,e);if(a){let e=s(r.theme)?r.theme:{};r.theme=t({...e,banner:a.banner})}let o=await b(s(r.theme)?r.theme.navbar:void 0,e.markdown,e.file.path);if(o){let e=s(r.theme)?r.theme:{};r.theme=t({...e,navbar:o.navbar})}let c=await b(s(r.theme)?r.theme.footer:void 0,e.markdown,e.file.path);if(c){let e=s(r.theme)?r.theme:{};r.theme=t({...e,footer:c.navbar})}let l=await T(s(r.theme)?r.theme.products:void 0,e.markdown,e.file.path);if(l){let e=s(r.theme)?r.theme:{};r.theme=t({...e,products:l.products})}let u=await x(e.config,e.markdown,e.file.path,t=>e.io.readFile(D(E(e.file.absolutePath),t)),e.logger);u&&(r.html=t(u.html));let d=await S(r.seo,e.markdown,e.file.path);d&&(r.seo=d.seo);let f=[i,a,o,c,l,u,d];return{value:r,entityDeps:f.flatMap(e=>e?.deps??[]),assetUsages:f.flatMap(e=>e?.assetUsages??[])}});function P(e){return{isSystem:!0,key:o,kind:`loader`,type:null,metadata:null,loaderArgs:{pluginVersion:A},loaderId:j,pluginId:k,shouldInvalidateValue:!1,value:null,version:null,fragmentUpdates:e.fragmentUpdates}}const F=e({id:k,version:A,async finalize(e){let r=await g({io:e.io,routes:e.routes,versionedDirectories:ee(e.routes.all())}),i=e=>e&&_(e,r),a=t=>t&&{slug:_(t,r),loadLabel:()=>y(e.entities,t)},o=t=>a(e.routes.byFilePath(t)),c=t=>a(e.routes.bySlug(t)),l=t=>v(t,e.routes,r),u=await V(e.config,o,c,e.logger,l),d=await L(e,o,c,i,l);if(Object.keys(d).length>0){let e=s(u.theme)?u.theme:{};u.theme=t({...e,products:d}),u.pageProducts=n(Object.values(d).map(I))}return{appData:u}},loaders:[N]});function I(e){let{name:t,slug:n,configOverride:r}=e,i={name:t,slug:n},a=r?.analytics?.ga;return a&&(i.ga=a),i}async function L(e,n,r,i,o){let s={};for(let t of h(e.config)){let c=await w(t,e.routes,e.io,i);if(c===void 0){e.logger.warn(`Product "${t.id}" is left out of the product picker: "${t.folder}" has no page.`);continue}let l={name:t.name,folder:t.folder,slug:t.slug,link:c,[O]:o(c)??void 0};t.icon!==void 0&&(l.icon=t.icon);let u=C(t.folder),d=await e.io.exists(u)?await z(R(await e.io.readFile(u),u),{page:Q(n,r,u,e.logger),access:o},a(e.config),e.config):{};Object.keys(d).length>0&&(l.configOverride=d),s[t.id]=l}return t(s)}function R(e,t){try{return u(e,t).config}catch{return{}}}async function z(e,t,n,r){let i={},a=await K(e.navbar,t),o=await G(e.footer,t),s=W(e.breadcrumbs,t);return e.logo&&(i.logo=e.logo),a&&(i.navbar=a),o&&(i.footer=o),s&&f(r,`breadcrumbs`)&&(i.breadcrumbs=s),e.feedback&&(i.feedback=e.feedback),e.sidebar&&(i.sidebar=e.sidebar),e.codeSnippet&&(i.codeSnippet=e.codeSnippet),e.palette&&(i.palette=e.palette),e.search&&(i.search=await B(e.search,n,t)),e.analytics?.ga&&f(r,`analytics`)&&(i.analytics={ga:e.analytics.ga}),i}async function B(e,n,r){let i={...n},a=await q(e?.suggestedPages,r);return e?.hide!==void 0&&(i.hide=e.hide),e?.placement!==void 0&&(i.placement=e.placement),e?.shortcuts!==void 0&&(i.shortcuts=e.shortcuts),a.length>0&&(i.suggestedPages=a),t(i)}async function V(e,n,r,i,o=()=>void 0){let s={},c={page:Q(n,r,ae,i),access:o},l=await K(e.navbar,c),u=await G(e.footer,c),f=e.seo?.projectTitle,p=W(e.breadcrumbs,c),m={...l?{navbar:l}:{},...u?{footer:u}:{},...p?{breadcrumbs:p}:{},markdown:e.markdown,navigation:e.navigation,userMenu:await X(e.userMenu,c),feedback:e.feedback,consent:e.consent,...f?{seo:{projectTitle:f}}:{},aiAssistant:H(e),mcp:U(e),search:await B(e.search,a(e),c),sidebar:e.sidebar,versionPicker:e.versionPicker,codeSnippet:e.codeSnippet,palette:e.palette};if(e.colorMode&&(m.colorMode=e.colorMode),Object.keys(m).length>0&&(s.theme=m),e.analytics&&(s.analytics=e.analytics),e.planGates&&(s.removeAttribution=d(e)),e.removeAttribution===!0&&(s.removeConsoleAttribution=!0),e.seo){let{projectTitle:t,llmstxt:n,...r}=e.seo;Object.keys(r).length>0&&(s.seo=r)}return t(s)}function H(e){let t=l(e),n=e.aiAssistant?.trigger;return{...e.aiAssistant,hide:t,trigger:{...n,hide:n?.hide??t}}}function U(e){let t=e.mcp?.hide===!0;return{hide:t,docs:{hide:t}}}function W(e,n){if(!e)return null;let r={};e.hide!==void 0&&(r.hide=e.hide);let i=(e.prefixItems??[]).map(e=>{let t=e.page?n.page(e.page)?.link:void 0;return{icon:$(e.icon),label:$(e.label)??``,labelTranslationKey:$(e.labelTranslationKey),link:t,[O]:Y(n,t)}});return i.length>0&&(r.prefixItems=i),Object.keys(r).length>0?t(r):null}async function G(e,n){if(!e)return null;let r={hide:e.hide===!0},i=await q(e.items,n);return e.copyrightText!==void 0&&(r.copyrightText=e.copyrightText),e.logo&&(r.logo=e.logo),i.length>0&&(r.items=i),t(r)}async function K(e,n){if(!e)return null;let r={},i=await q(e.items,n);return e.hide!==void 0&&(r.hide=e.hide),i.length>0&&(r.items=i),Object.keys(r).length>0?t(r):null}async function q(e,t){return Array.isArray(e)?(await Promise.all(e.map(e=>J(e,t)))).filter(e=>e!==null):[]}async function J(e,n){if(typeof e==`string`)return J({page:e},n);if(!s(e))return null;if(typeof e.separator==`string`)return t({...Z(e),label:e.separator,type:`separator`});let r=await q(e.items,n),i=ie(e,n.page),a=i?.link,o=e.rbac===void 0?Y(n,a):void 0,c=$(e.label)??$(e.group)??(i?i.anchor??await i.loadLabel?.()??i.link:``);return typeof e.group==`string`||r.length>0?t({...Z(e),...a?{link:a}:{},...r.length>0?{items:r}:{},label:c,labelTranslationKey:$(e.groupTranslationKey)??$(e.labelTranslationKey),type:`group`,[O]:o}):a?t({...Z(e),...ce(e.external)??oe(a)?{external:!0}:{},label:c,link:a,type:`link`,[O]:o}):null}function Y(e,t){return t===void 0?void 0:e.access(t)??void 0}async function X(e,n){if(!e)return;let r=[];for(let t of e.items??[])r.push({...t,href:t.link});let i=await q(r,n);return t({...e,menu:i.length>0?i:void 0})}function Z(e){let t=se(e,[`additionalProps`,`expanded`,`labelTranslationKey`,`languageInsensitive`,`linePosition`,`linkedSidebars`,`menuStyle`,`selectFirstItemOnExpand`,`separatorLine`,`target`,`version`]),n=re(e.icon);return n.icon&&(t.icon=n.icon),n.srcSet&&(t.srcSet=n.srcSet),{...t,...p(e.rbac)}}function re(e){return typeof e==`string`?{icon:e}:s(e)&&typeof e.srcSet==`string`?{srcSet:e.srcSet}:{}}function ie(e,t){return typeof e.href==`string`&&e.href.trim()!==``?{link:e.href.trim()}:typeof e.page==`string`&&e.page.trim()!==``?t(e.page):null}const ae=`redocly.yaml`;function Q(e,t,n,r){let i={bySlug:e=>t?.(e),byFilePath:t=>e?.(t)};return e=>{let{path:t,suffix:a,anchor:o}=c(e.trim()),s=m(t,n,i);return s.kind===`escaped`?(r?.warn(`Config page reference escapes the content root`,{page:e}),null):s.kind===`missing`?(r?.warn(`Config page has no matching route`,{page:e}),{link:e.trim()}):{link:`${s.value.slug}${a}`,anchor:o,loadLabel:s.value.loadLabel}}}function oe(e){return/^(?:[a-z][a-z\d+.-]*:)?\/\//i.test(e)||/^(?:mailto|tel):/i.test(e)}function se(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function $(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function ce(e){return typeof e==`boolean`?e:void 0}export{k as APP_DATA_PLUGIN_ID,A as APP_DATA_PLUGIN_VERSION,j as APP_DATA_STATIC_DATA_LOADER_ID,o as APP_DATA_STATIC_DATA_SLUG,F as appDataContentPlugin,P as appDataSystemEntityDescriptor,V as buildConfigAppData,M as isAppDataFragment};
@@ -1 +1 @@
1
- import{CATALOG_CLASSIC_DEP_KEY as e}from"./contract.js";import{LoaderDataContext as t}from"../../../../../client/contexts.js";import{telemetry as n}from"../../../../../client/telemetry/telemetry.js";import{readSelectionsFromSearch as r,readTermFromSearch as i,resolveCatalog as a,selectFilterOption as o,toCatalogItems as s,toggleFilterOption as c,writeSelectionsToSearch as l}from"./catalog-filtering.js";import*as u from"react";import{useLocation as d,useNavigate as f}from"react-router";import{getBaseDataAttributes as p}from"@redocly/theme/core/utils";const m=[];function h(e){n.sendCatalogFilterChangedMessage([{...p(`catalogFilter`,`field`),type:e}])}function g(n){let p=d(),g=f(),_=u.useContext(t)[e],v=n.filters??m,[y,b]=u.useState(()=>r(p.search,v)),[x,S]=u.useState(()=>i(p.search)),C=u.useCallback(e=>{S(e),h(`term`)},[]),w=u.useMemo(()=>s(_?.items??[]),[_]);u.useEffect(()=>{let e=l(p.search,v,y,x);e!==p.search.replace(/^\?/,``)&&g({search:e},{replace:!0})},[v,x,p.search,g,y]);let T=u.useMemo(()=>a({filters:v,groupByFirstFilter:n.groupByFirstFilter,items:w,selections:y,term:x}),[n.groupByFirstFilter,v,x,w,y]);return u.useMemo(()=>({groups:T.groups,filters:T.filters.map((e,t)=>({...e,toggleOption:e=>{b(n=>c(n,t,e)),h(`toggle`),window.scrollTo(0,0)},selectOption:e=>{b(n=>o(n,v,t,e)),h(`select`),window.scrollTo(0,0)}})),filterTerm:x,setFilterTerm:C}),[C,v,x,T])}export{g as useCatalogClassic};
1
+ import{LoaderDataContext as e}from"../../../../../client/contexts.js";import{telemetry as t}from"../../../../../client/telemetry/telemetry.js";import{CATALOG_CLASSIC_DEP_KEY as n}from"./contract.js";import{readSelectionsFromSearch as r,readTermFromSearch as i,resolveCatalog as a,selectFilterOption as o,toCatalogItems as s,toggleFilterOption as c,writeSelectionsToSearch as l}from"./catalog-filtering.js";import*as u from"react";import{useLocation as d,useNavigate as f}from"react-router";import{getBaseDataAttributes as p}from"@redocly/theme/core/utils";const m=[];function h(e){t.sendCatalogFilterChangedMessage([{...p(`catalogFilter`,`field`),type:e}])}function g(t){let p=d(),g=f(),_=u.useContext(e)[n],v=t.filters??m,[y,b]=u.useState(()=>r(p.search,v)),[x,S]=u.useState(()=>i(p.search)),C=u.useCallback(e=>{S(e),h(`term`)},[]),w=u.useMemo(()=>s(_?.items??[]),[_]);u.useEffect(()=>{let e=l(p.search,v,y,x);e!==p.search.replace(/^\?/,``)&&g({search:e},{replace:!0})},[v,x,p.search,g,y]);let T=u.useMemo(()=>a({filters:v,groupByFirstFilter:t.groupByFirstFilter,items:w,selections:y,term:x}),[t.groupByFirstFilter,v,x,w,y]);return u.useMemo(()=>({groups:T.groups,filters:T.filters.map((e,t)=>({...e,toggleOption:e=>{b(n=>c(n,t,e)),h(`toggle`),window.scrollTo(0,0)},selectOption:e=>{b(n=>o(n,v,t,e)),h(`select`),window.scrollTo(0,0)}})),filterTerm:x,setFilterTerm:C}),[C,v,x,T])}export{g as useCatalogClassic};
@@ -1 +1 @@
1
- import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{createServerFn as r}from"../../server-fn.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{runtimeTemplate as a}from"../../templates.js";import{normalizeRouteSlug as o}from"../../../../shared/utils/routes/normalize-route-slug.js";import{SIDEBAR_CONTRIBUTIONS_ENTITY_TYPE as s}from"../sidebar/contributions.js";import{CATALOG_CLASSIC_DEP_KEY as c}from"./client/contract.js";import{catalogEntityKey as l}from"./entity-key.js";import{buildCatalogCards as u,loadVersionGroups as d,pickDefaultVersions as f,resolveCatalogMembers as p}from"./resolve-items.js";import{catalogSidebarContributions as m}from"./sidebars.js";const h=`internal.catalog-classic`,g=`catalog-classic`,_=i(h,`catalog`),v=i(h,`sidebars`),y=i(h,`deliver`),b=t(_,async e=>{let t=p(e.args.items,e),{versionGroups:n,entityDeps:r}=await d(t,e),i=e.args.config.separateVersions?t:f(t,n),a=await u(i,n,e);return{value:{catalogId:e.args.catalogId,config:e.args.config,items:a},entityDeps:r}}),x=t(v,async e=>{let t=p(e.args.items,{routes:e.routes}),{versionGroups:n,entityDeps:r}=await d(t,e);return{value:await m(t,n,{label:e.args.title,link:e.args.slug},e),entityDeps:r}}),S=r(y,{filePath:`./server/deliver.ts`,importer:import.meta.url,exportName:`deliver`,cacheable:!0});function C(e){return Object.entries(e.catalogClassic??e.catalog??{})}const w=e({id:h,version:`1.7.0`,content:{extractAll(e){let t=[],n=[];for(let[r,i]of C(e.config)){let{items:e,...a}=i,u=o(String(i.slug)),d=typeof i.title==`string`?i.title:`API Catalog`;t.push(b.withArgs({catalogId:r,config:a,items:e},{stableKey:l(r),metadata:{sourcePath:u}}),x.withArgs({items:e,slug:u,title:d},{stableKey:`${l(r)}:sidebars`,type:s})),n.push({deps:{[c]:S.withArgs({catalogId:r})},metadata:{title:d},routeId:r,slug:u,template:g})}return{entities:t,routes:n}}},loaders:[b,x],server:{functions:[S]},templates:{[g]:a(n(`./client/template.tsx`,import.meta.url))}});export{_ as CATALOG_CLASSIC_LOADER_ID,h as CATALOG_CLASSIC_PLUGIN_ID,y as CATALOG_CLASSIC_SERVER_FN_ID,v as CATALOG_CLASSIC_SIDEBARS_LOADER_ID,g as CATALOG_CLASSIC_TEMPLATE_ID,w as catalogClassicContentPlugin};
1
+ import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{createServerFn as r}from"../../server-fn.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{runtimeTemplate as a}from"../../templates.js";import{normalizeRouteSlug as o}from"../../../../shared/utils/routes/normalize-route-slug.js";import{CATALOG_CLASSIC_DEP_KEY as s}from"./client/contract.js";import{SIDEBAR_CONTRIBUTIONS_ENTITY_TYPE as c}from"../sidebar/contributions.js";import{catalogEntityKey as l}from"./entity-key.js";import{buildCatalogCards as u,loadVersionGroups as d,pickDefaultVersions as f,resolveCatalogMembers as p}from"./resolve-items.js";import{catalogSidebarContributions as m}from"./sidebars.js";const h=`internal.catalog-classic`,g=`catalog-classic`,_=i(h,`catalog`),v=i(h,`sidebars`),y=i(h,`deliver`),b=t(_,async e=>{let t=p(e.args.items,e),{versionGroups:n,entityDeps:r}=await d(t,e),i=e.args.config.separateVersions?t:f(t,n),a=await u(i,n,e);return{value:{catalogId:e.args.catalogId,config:e.args.config,items:a},entityDeps:r}}),x=t(v,async e=>{let t=p(e.args.items,{routes:e.routes}),{versionGroups:n,entityDeps:r}=await d(t,e);return{value:await m(t,n,{label:e.args.title,link:e.args.slug},e),entityDeps:r}}),S=r(y,{filePath:`./server/deliver.ts`,importer:import.meta.url,exportName:`deliver`,cacheable:!0});function C(e){return Object.entries(e.catalogClassic??e.catalog??{})}const w=e({id:h,version:`1.7.0`,content:{extractAll(e){let t=[],n=[];for(let[r,i]of C(e.config)){let{items:e,...a}=i,u=o(String(i.slug)),d=typeof i.title==`string`?i.title:`API Catalog`;t.push(b.withArgs({catalogId:r,config:a,items:e},{stableKey:l(r),metadata:{sourcePath:u}}),x.withArgs({items:e,slug:u,title:d},{stableKey:`${l(r)}:sidebars`,type:c})),n.push({deps:{[s]:S.withArgs({catalogId:r})},metadata:{title:d},routeId:r,slug:u,template:g})}return{entities:t,routes:n}}},loaders:[b,x],server:{functions:[S]},templates:{[g]:a(n(`./client/template.tsx`,import.meta.url))}});export{_ as CATALOG_CLASSIC_LOADER_ID,h as CATALOG_CLASSIC_PLUGIN_ID,y as CATALOG_CLASSIC_SERVER_FN_ID,v as CATALOG_CLASSIC_SIDEBARS_LOADER_ID,g as CATALOG_CLASSIC_TEMPLATE_ID,w as catalogClassicContentPlugin};
@@ -1 +1 @@
1
- import{STATIC_FOLDER_PLUGIN_ID as e,STATIC_FOLDER_PREFIX as t,isStaticFolderPath as n,staticFolderContentPlugin as r}from"./static-folder/index.js";import{ASSETS_PLUGIN_ID as i,ASSET_ENTITY_KEY_PREFIX as a,assetsContentPlugin as o}from"./assets/index.js";import{APP_DATA_STATIC_DATA_SLUG as s}from"../../../shared/constants/app-data.js";import{SIDEBAR_ROUTE_DEP_KEY as c}from"../../../shared/constants/route-deps.js";import{FOLDER_SIDEBAR_FILENAME_REGEX as l,SIDEBAR_AGGREGATOR_LOADER_ID as u,SIDEBAR_FILENAME_REGEX as d,SIDEBAR_PLUGIN_ID as f,isTabbedSidebar as p,resolveAutoSidebar as m,sidebarContentPlugin as h}from"./sidebar/index.js";import{APP_DATA_PLUGIN_ID as g,APP_DATA_PLUGIN_VERSION as ee,APP_DATA_STATIC_DATA_LOADER_ID as _,appDataContentPlugin as v,appDataSystemEntityDescriptor as y,buildConfigAppData as b,isAppDataFragment as x}from"./app-data/index.js";import{apiDocsContentPlugin as S}from"./api-docs/index.js";import"./api-functions/constants.js";import{API_FUNCTIONS_PLUGIN_ID as C,apiFunctionsContentPlugin as w}from"./api-functions/index.js";import{CATALOG_CLASSIC_LOADER_ID as T,CATALOG_CLASSIC_PLUGIN_ID as E,CATALOG_CLASSIC_SERVER_FN_ID as D,CATALOG_CLASSIC_SIDEBARS_LOADER_ID as O,CATALOG_CLASSIC_TEMPLATE_ID as k,catalogClassicContentPlugin as A}from"./catalog-classic/index.js";import{L10N_PLUGIN_ID as j}from"./l10n/translations-loader.js";import{L10N_PLUGIN_VERSION as M,l10nContentPlugin as N}from"./l10n/index.js";import{MARKDOC_DOCUMENT_LOADER_ID as P,MARKDOC_SEARCH_GROUP as F,MARKDOC_SIDEBAR_ITEM_LOADER_ID as te,MARKDOC_TEMPLATE_ID as I,markdocContentPlugin as L}from"./markdoc/index.js";import{mcpContentPlugin as R}from"./mcp/index.js";import{MOCK_SERVER_PLUGIN_ID as z,MOCK_SERVER_ROUTE_PATH as B,mockServerContentPlugin as V}from"./mock/index.js";import{REACT_PAGE_SEARCH_LOADER_KEY as H,reactPageContentPlugin as U}from"./react-page/index.js";import{REVISIONS_PLUGIN_ID as W,revisionsContentPlugin as G}from"./revisions/index.js";import{SCORECARD_CLASSIC_PLUGIN_ID as K,SCORECARD_CLASSIC_TEMPLATE_ID as q,scorecardClassicContentPlugin as J}from"./scorecard-classic/index.js";import{SKILLS_PLUGIN_ID as Y,SKILL_MARKDOWN_ROUTE_PATH as X,skillsContentPlugin as Z}from"./skills/index.js";import{VERSIONS_PLUGIN_ID as Q,versionsContentPlugin as $}from"./versions/index.js";function ne(){return[v,N,r,o,L,h,$,G,A,S,J,w,V,R,U,Z]}export{C as API_FUNCTIONS_PLUGIN_ID,g as APP_DATA_PLUGIN_ID,ee as APP_DATA_PLUGIN_VERSION,_ as APP_DATA_STATIC_DATA_LOADER_ID,s as APP_DATA_STATIC_DATA_SLUG,i as ASSETS_PLUGIN_ID,a as ASSET_ENTITY_KEY_PREFIX,T as CATALOG_CLASSIC_LOADER_ID,E as CATALOG_CLASSIC_PLUGIN_ID,D as CATALOG_CLASSIC_SERVER_FN_ID,O as CATALOG_CLASSIC_SIDEBARS_LOADER_ID,k as CATALOG_CLASSIC_TEMPLATE_ID,l as FOLDER_SIDEBAR_FILENAME_REGEX,j as L10N_PLUGIN_ID,M as L10N_PLUGIN_VERSION,P as MARKDOC_DOCUMENT_LOADER_ID,F as MARKDOC_SEARCH_GROUP,te as MARKDOC_SIDEBAR_ITEM_LOADER_ID,I as MARKDOC_TEMPLATE_ID,z as MOCK_SERVER_PLUGIN_ID,B as MOCK_SERVER_ROUTE_PATH,H as REACT_PAGE_SEARCH_LOADER_KEY,W as REVISIONS_PLUGIN_ID,K as SCORECARD_CLASSIC_PLUGIN_ID,q as SCORECARD_CLASSIC_TEMPLATE_ID,u as SIDEBAR_AGGREGATOR_LOADER_ID,d as SIDEBAR_FILENAME_REGEX,f as SIDEBAR_PLUGIN_ID,c as SIDEBAR_ROUTE_DEP_KEY,Y as SKILLS_PLUGIN_ID,X as SKILL_MARKDOWN_ROUTE_PATH,e as STATIC_FOLDER_PLUGIN_ID,t as STATIC_FOLDER_PREFIX,Q as VERSIONS_PLUGIN_ID,S as apiDocsContentPlugin,w as apiFunctionsContentPlugin,v as appDataContentPlugin,y as appDataSystemEntityDescriptor,o as assetsContentPlugin,b as buildConfigAppData,A as catalogClassicContentPlugin,ne as createInternalContentPlugins,x as isAppDataFragment,n as isStaticFolderPath,p as isTabbedSidebar,N as l10nContentPlugin,L as markdocContentPlugin,R as mcpContentPlugin,V as mockServerContentPlugin,U as reactPageContentPlugin,m as resolveAutoSidebar,G as revisionsContentPlugin,J as scorecardClassicContentPlugin,h as sidebarContentPlugin,Z as skillsContentPlugin,r as staticFolderContentPlugin,$ as versionsContentPlugin};
1
+ import{APP_DATA_STATIC_DATA_SLUG as e}from"../../../shared/constants/app-data.js";import{SIDEBAR_ROUTE_DEP_KEY as t}from"../../../shared/constants/route-deps.js";import{STATIC_FOLDER_PLUGIN_ID as n,STATIC_FOLDER_PREFIX as r,isStaticFolderPath as i,staticFolderContentPlugin as a}from"./static-folder/index.js";import{ASSETS_PLUGIN_ID as o,ASSET_ENTITY_KEY_PREFIX as s,assetsContentPlugin as c}from"./assets/index.js";import{FOLDER_SIDEBAR_FILENAME_REGEX as l,SIDEBAR_AGGREGATOR_LOADER_ID as u,SIDEBAR_FILENAME_REGEX as d,SIDEBAR_PLUGIN_ID as f,isTabbedSidebar as p,resolveAutoSidebar as m,sidebarContentPlugin as h}from"./sidebar/index.js";import{APP_DATA_PLUGIN_ID as g,APP_DATA_PLUGIN_VERSION as ee,APP_DATA_STATIC_DATA_LOADER_ID as _,appDataContentPlugin as v,appDataSystemEntityDescriptor as y,buildConfigAppData as b,isAppDataFragment as x}from"./app-data/index.js";import{apiDocsContentPlugin as S}from"./api-docs/index.js";import"./api-functions/constants.js";import{API_FUNCTIONS_PLUGIN_ID as C,apiFunctionsContentPlugin as w}from"./api-functions/index.js";import{CATALOG_CLASSIC_LOADER_ID as T,CATALOG_CLASSIC_PLUGIN_ID as E,CATALOG_CLASSIC_SERVER_FN_ID as D,CATALOG_CLASSIC_SIDEBARS_LOADER_ID as O,CATALOG_CLASSIC_TEMPLATE_ID as k,catalogClassicContentPlugin as A}from"./catalog-classic/index.js";import{L10N_PLUGIN_ID as j}from"./l10n/translations-loader.js";import{L10N_PLUGIN_VERSION as M,l10nContentPlugin as N}from"./l10n/index.js";import{MARKDOC_DOCUMENT_LOADER_ID as P,MARKDOC_SEARCH_GROUP as F,MARKDOC_SIDEBAR_ITEM_LOADER_ID as te,MARKDOC_TEMPLATE_ID as I,markdocContentPlugin as L}from"./markdoc/index.js";import{mcpContentPlugin as R}from"./mcp/index.js";import{MOCK_SERVER_PLUGIN_ID as z,MOCK_SERVER_ROUTE_PATH as B,mockServerContentPlugin as V}from"./mock/index.js";import{REACT_PAGE_SEARCH_LOADER_KEY as H,reactPageContentPlugin as U}from"./react-page/index.js";import{REVISIONS_PLUGIN_ID as W,revisionsContentPlugin as G}from"./revisions/index.js";import{SCORECARD_CLASSIC_PLUGIN_ID as K,SCORECARD_CLASSIC_TEMPLATE_ID as q,scorecardClassicContentPlugin as J}from"./scorecard-classic/index.js";import{SKILLS_PLUGIN_ID as Y,SKILL_MARKDOWN_ROUTE_PATH as X,skillsContentPlugin as Z}from"./skills/index.js";import{VERSIONS_PLUGIN_ID as Q,versionsContentPlugin as $}from"./versions/index.js";function ne(){return[v,N,a,c,L,h,$,G,A,S,J,w,V,R,U,Z]}export{C as API_FUNCTIONS_PLUGIN_ID,g as APP_DATA_PLUGIN_ID,ee as APP_DATA_PLUGIN_VERSION,_ as APP_DATA_STATIC_DATA_LOADER_ID,e as APP_DATA_STATIC_DATA_SLUG,o as ASSETS_PLUGIN_ID,s as ASSET_ENTITY_KEY_PREFIX,T as CATALOG_CLASSIC_LOADER_ID,E as CATALOG_CLASSIC_PLUGIN_ID,D as CATALOG_CLASSIC_SERVER_FN_ID,O as CATALOG_CLASSIC_SIDEBARS_LOADER_ID,k as CATALOG_CLASSIC_TEMPLATE_ID,l as FOLDER_SIDEBAR_FILENAME_REGEX,j as L10N_PLUGIN_ID,M as L10N_PLUGIN_VERSION,P as MARKDOC_DOCUMENT_LOADER_ID,F as MARKDOC_SEARCH_GROUP,te as MARKDOC_SIDEBAR_ITEM_LOADER_ID,I as MARKDOC_TEMPLATE_ID,z as MOCK_SERVER_PLUGIN_ID,B as MOCK_SERVER_ROUTE_PATH,H as REACT_PAGE_SEARCH_LOADER_KEY,W as REVISIONS_PLUGIN_ID,K as SCORECARD_CLASSIC_PLUGIN_ID,q as SCORECARD_CLASSIC_TEMPLATE_ID,u as SIDEBAR_AGGREGATOR_LOADER_ID,d as SIDEBAR_FILENAME_REGEX,f as SIDEBAR_PLUGIN_ID,t as SIDEBAR_ROUTE_DEP_KEY,Y as SKILLS_PLUGIN_ID,X as SKILL_MARKDOWN_ROUTE_PATH,n as STATIC_FOLDER_PLUGIN_ID,r as STATIC_FOLDER_PREFIX,Q as VERSIONS_PLUGIN_ID,S as apiDocsContentPlugin,w as apiFunctionsContentPlugin,v as appDataContentPlugin,y as appDataSystemEntityDescriptor,c as assetsContentPlugin,b as buildConfigAppData,A as catalogClassicContentPlugin,ne as createInternalContentPlugins,x as isAppDataFragment,i as isStaticFolderPath,p as isTabbedSidebar,N as l10nContentPlugin,L as markdocContentPlugin,R as mcpContentPlugin,V as mockServerContentPlugin,U as reactPageContentPlugin,m as resolveAutoSidebar,G as revisionsContentPlugin,J as scorecardClassicContentPlugin,h as sidebarContentPlugin,Z as skillsContentPlugin,a as staticFolderContentPlugin,$ as versionsContentPlugin};
@@ -1 +1 @@
1
- import{MARKDOC_DOCUMENT_LOADER_KEY as e}from"../../../../../shared/constants/route-deps.js";import{collectHeadings as t}from"../../../../markdown/utils/collect-headings.js";import{MarkdocRenderer as n}from"../../../../markdown/client/markdoc-components.js";import{DEFAULT_FEEDBACK_TYPE as r}from"@redocly/theme/core/constants";import*as i from"react";import{jsx as a}from"react/jsx-runtime";import{extendDetailsBehaviour as o}from"@redocly/theme/core/utils";import{useThemeConfig as s,useThemeHooks as c}from"@redocly/theme/core/hooks";import{useLoaderData as l}from"virtual:realm-runtime";import{Feedback as u}from"@redocly/theme/components/Feedback/Feedback";import{TableOfContent as d}from"@redocly/theme/components/TableOfContent/TableOfContent";import{CodeWalkthroughLayout as f}from"@redocly/theme/layouts/CodeWalkthroughLayout";import{DocumentationLayout as p}from"@redocly/theme/layouts/DocumentationLayout";function m(m){let h=l(e),{useSidebarSiblingsData:g}=c(),{markdown:_,feedback:v}=s(),{nextPage:y,prevPage:b}=g()??{},[x,S]=i.useState(null),C=i.useMemo(()=>h?t(h.ast):[],[h]);if(i.useEffect(()=>o(),[h]),!h)return null;let w=/* @__PURE__ */ a(n,{ast:h.ast,withPageActions:!0});return h.tagList?.includes(`code-walkthrough`)?/* @__PURE__ */ a(f,{children:w}):/* @__PURE__ */ a(p,{config:_,editPage:h.editPage,lastModified:h.lastModified,feedback:/* @__PURE__ */ a(u,{...v,type:v?.type??r,settings:v?.settings??{},path:m.page.slug??m.page.path}),nextPage:y,prevPage:b,tableOfContent:/* @__PURE__ */ a(d,{contentWrapper:x,headings:C}),children:/* @__PURE__ */ a(`div`,{ref:S,children:w})})}export{m as default};
1
+ import{MARKDOC_DOCUMENT_LOADER_KEY as e}from"../../../../../shared/constants/route-deps.js";import{collectHeadings as t}from"../../../../markdown/utils/collect-headings.js";import{MarkdocRenderer as n}from"../../../../markdown/client/markdoc-components.js";import*as r from"react";import{jsx as i}from"react/jsx-runtime";import{extendDetailsBehaviour as a}from"@redocly/theme/core/utils";import{DEFAULT_FEEDBACK_TYPE as o}from"@redocly/theme/core/constants";import{useThemeConfig as s,useThemeHooks as c}from"@redocly/theme/core/hooks";import{useLoaderData as l}from"virtual:realm-runtime";import{Feedback as u}from"@redocly/theme/components/Feedback/Feedback";import{TableOfContent as d}from"@redocly/theme/components/TableOfContent/TableOfContent";import{CodeWalkthroughLayout as f}from"@redocly/theme/layouts/CodeWalkthroughLayout";import{DocumentationLayout as p}from"@redocly/theme/layouts/DocumentationLayout";function m(m){let h=l(e),{useSidebarSiblingsData:g}=c(),{markdown:_,feedback:v}=s(),{nextPage:y,prevPage:b}=g()??{},[x,S]=r.useState(null),C=r.useMemo(()=>h?t(h.ast):[],[h]);if(r.useEffect(()=>a(),[h]),!h)return null;let w=/* @__PURE__ */ i(n,{ast:h.ast,withPageActions:!0});return h.tagList?.includes(`code-walkthrough`)?/* @__PURE__ */ i(f,{children:w}):/* @__PURE__ */ i(p,{config:_,editPage:h.editPage,lastModified:h.lastModified,feedback:/* @__PURE__ */ i(u,{...v,type:v?.type??o,settings:v?.settings??{},path:m.page.slug??m.page.path}),nextPage:y,prevPage:b,tableOfContent:/* @__PURE__ */ i(d,{contentWrapper:x,headings:C}),children:/* @__PURE__ */ i(`div`,{ref:S,children:w})})}export{m as default};
@@ -1 +1 @@
1
- import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import{runtimeTemplate as i}from"../../templates.js";import{SEARCH_GROUP_FACET_FIELD as a}from"../../../../shared/search/facets.js";import{configuredFacetFields as o,extractFacetsFromFrontmatter as s,invalidFacetValueProblems as c,searchCategoryOf as l}from"../../../search/facet-values.js";import{isObject as u}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as d}from"../../../../shared/utils/routes/normalize-route-slug.js";import{resolveContentPath as f}from"../../../../shared/utils/resolve-content-path.js";import{PAGE_BANNER_SCHEMA as p,sanitizeConfig as m}from"../../../config-schema.js";import{notInPlanProblem as h}from"../../../plan-gates.js";import{matchPathMap as g}from"../../utils/glob.js";import{filePathToRouteSlug as _}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{isPlanFeatureGranted as v}from"../../../../shared/plan-gates.js";import{splitUrlSuffix as y}from"../../../../shared/utils/routes/split-url-suffix.js";import{packMarkdocAst as ee,unpackMarkdocAst as b}from"../../../markdown/utils/packed-ast.js";import{isRouteSlugTarget as x}from"../../../../shared/utils/routes/is-route-slug-target.js";import{loadSidebarSubtreeLabel as S}from"../../utils/sidebar-label.js";import{markdocNodeRange as C}from"../../../markdown/utils/node-source-range.js";import{replaceWithMarkdocError as te}from"../../../markdown/tags/markdoc-error.js";import{CODE_WALKTHROUGH_TAG_NAMES as ne,builtInMarkdocTags as re}from"../../../markdown/constants/builtin-tags.js";import{walkMarkdocAst as w}from"../../../markdown/utils/walk-markdoc-ast.js";import{markdocFirstHeading as ie}from"../../../markdown/search/to-text.js";import{safeDecodeURI as ae}from"../../../../shared/utils/safe-decode-uri.js";import{shiftRange as oe}from"../../../../shared/utils/shift-range.js";import{classifyLinkTarget as se}from"../../../link-checker/classify.js";import{onDiskLinkRefs as ce}from"../../../link-checker/node-ref.js";import{isPartialPath as le}from"../../../markdown/utils/partials.js";import{FRONTMATTER_BLOCK_RE as ue,computeFrontmatterLineOffset as de}from"../../../markdown/utils/frontmatter-offset.js";import{inlineRawPartials as fe}from"../../../markdown/resolve/raw-partials.js";import{resolveMarkdownAst as T}from"../../../markdown/resolve/ast.js";import{resolveBannerForAppData as E}from"../app-data/banner.js";import{MARKDOC_DOCUMENT_LOADER_KEY as D}from"../../../../shared/constants/route-deps.js";import{isMarkdocValidationEnabled as O,resolveMarkdocTagSet as k,resolveMarkdownPageValidationSet as A,userMarkdocSchemaFiles as j,userMarkdocTagNames as M}from"../../../markdown/constants/tag-sets.js";import{pageLocale as N}from"../../utils/page-locale.js";import{markdocAstToMarkdownDoc as P}from"../../../markdown/search/to-markdown.js";import{collectAnchors as F}from"../../../markdown/utils/collect-anchors.js";import{frontmatterVariable as I}from"../../../markdown/utils/frontmatter-variable.js";import{markdownFirstHeading as L}from"../../../markdown/utils/first-heading.js";import{markdocAstToSearchSections as R}from"../../../markdown/search/to-sections.js";import{isInternalPagePath as z}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as B}from"../../utils/explicit-slugs.js";import{isSkillContentPath as V}from"../../utils/skill-paths.js";import{SOURCE_TEMPLATE_PREFIX as pe}from"../../../../shared/constants/template-ids.js";import{captureSnippet as H,splitSourceLines as me}from"../../../../shared/utils/capture-snippet.js";import{curationKeywordsOf as he}from"../../../search/keywords.js";import ge from"js-yaml";const U=`markdoc-page`,W=r(`internal.markdoc`,`document`),G=r(`internal.markdoc`,`sidebar-item`),_e=`Documentation`,K=t(W,async e=>{let t=await e.io.readFile(e.file.absolutePath),{content:n,frontmatter:r,frontmatterError:i}=Y(t),a=J(e),{ast:o,entityDeps:s,assetUsages:c,tagList:l,problems:u,linkRefs:d}=await T(n,e.file.path,{resolverContext:a,tags:(await k()).tags,variables:{get env(){return e.config.publicEnv??{}}},transform:t=>Ee(t,e.file.path,Te(e.config)),validation:O()?await A():void 0}),f=de(t);je(o);let p=await we(r.seo,e),m=v(e.config,`banner`)?await E(Me(r,e.file.path,e.logger),a):void 0,h=await Oe(r,e),g=await ke(r.navigation,e),_={...h.frontmatter,navigation:g.value,seo:p.seo,banner:m?.banner},y=Ne(r,o);return{value:{ast:ee(o),frontmatter:_,tagList:l,title:y,editPage:Ce(e.config,r,e.file.path),lastModified:e.file.lastModifiedAt},entityDeps:[...s,...ye(),...p.entityDeps,...m?.deps??[],...h.entityDeps,...g.entityDeps],assetUsages:[...c,...p.assetUsages,...m?.assetUsages??[],...h.assetUsages],problems:be(t,e.file.path,f,u,i),linkRefs:[...ce(d,f),...g.linkRefs],targetInventories:[xe(o,{frontmatter:I(_,y)})]}},{usesProjectMarkdocSchema:!0,async markdown(e,t){let{tags:n}=await k(),{chunks:r,headings:i}=P(b(e.ast),{tags:n,locale:N(t),variables:{frontmatter:I(e.frontmatter,e.title),env:t.config.publicEnv??{}}});return[{chunks:r,headings:i,...e.title?{title:e.title}:{}}]},searchable(e,t){if(t.route===void 0||t.route.metadata.excludeFromSearch===!0)return{docs:[]};let n=t.route.slug,r=e.title??Q(t.route.originFilePath??n),{category:i,isInvalid:u}=l(t.route.metadata),{facets:d,invalidFields:f}=s(t.route.metadata,o(t.config)),p=he(e.frontmatter.keywords);return{docs:R(b(e.ast),r,{frontmatter:I(e.frontmatter,e.title)}).map((e,t)=>{let r={docKey:e.docKey,routeSlug:n,title:e.title,text:e.text,groupKey:i??`Documentation`,facets:d};e.anchor!==void 0&&(r.anchor=e.anchor),e.path!==void 0&&(r.path=e.path);let a=t===0?p:{excludes:p?.excludes};return(a?.includes||a?.excludes)&&(r.keywords=a),e.rbacTeams!==void 0&&(r.rbacScope=Object.fromEntries(e.rbacTeams.map(e=>[e,`read`]))),r}),problems:c([...f,...u?[a]:[]],t.route.originFilePath)}}}),q=t(G,async e=>{let{content:t,frontmatter:n}=Y(await e.io.readFile(e.file.absolutePath)),r=await fe(t,e.file.path,J(e));return{value:{label:Z(n)??L(r.source)??Q(e.args.filePath)},entityDeps:r.entityDeps}});function J(e){return{config:e.config,contentDir:e.contentDir,entities:e.entities,file:e.file,io:e.io,logger:e.logger,markdown:e.markdown,plugin:e.plugin}}const ve=e({id:`internal.markdoc`,version:`3.44.0`,content:{filter:{match:e=>e.toLowerCase().endsWith(`.md`)&&!V(e)},extractFile(e,t){if(z(e.path)||le(e.path,t.config))return{routes:[]};if(!v(t.config,`markdown`))return{routes:[],problems:[h(`Markdown pages`)]};let{banner:n,...r}=e.manifest,i=Pe(e,t),a=B(r.slug),o=K.withArgs({filePath:e.path}),s=q.withArgs({filePath:e.path});return{routes:a.length>0?a.map(e=>({deps:{[D]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:e,slugHint:null,template:i})):[{deps:{[D]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:null,slugHint:_(e.path),template:i}],entities:[o]}}},loaders:[K,q],templates:{[U]:i(n(`./client/template.tsx`,import.meta.url))}});function Y(e){let t=e.match(ue);if(!t)return{content:e,frontmatter:{}};let n=t[1]??``;try{let r=ge.load(n);return{content:e.slice(t[0].length),frontmatter:u(r)?r:{}}}catch(n){let r=n instanceof Error?n.message:String(n);return{content:e.slice(t[0].length),frontmatter:{},frontmatterError:r}}}function ye(){return(j()??[]).map(e=>({kind:`file`,path:e}))}function be(e,t,n,r,i){if(r.length===0&&i===void 0)return[];let a=me(e),o=r.map(e=>Se(e,a,n,t));if(i!==void 0){let e={start:{line:1},end:{line:n}};o.push({code:`markdown/frontmatter-parse`,message:i,location:{filePath:t,range:e,snippet:H(a,e)}})}return o}function xe(e,t){let{ids:n,exhaustive:r}=F(e,t);return{kind:`anchor`,exhaustive:r,targets:n}}function Se(e,t,n,r){let i=e.location?.range;if(!i)return e;let a=oe(i,n);return{...e,location:{filePath:r,range:a,snippet:H(t,a)}}}function Ce(e,t,n){let r=u(t.markdown)?t.markdown:{},i={...e.markdown?.editPage,...u(r.editPage)?r.editPage:{}};if(i.hide!==!0&&typeof i.baseUrl==`string`&&i.baseUrl!==``)return{to:`${i.baseUrl.replace(/(?<!\/)\/+$/,``)}/${n}`}}async function we(e,t){if(!u(e)||typeof e.image!=`string`)return{seo:e,entityDeps:[],assetUsages:[]};let n=await t.markdown.resolveImageReference(e.image,t.file.path);return n.result.kind===`assetRef`?{seo:{...e,image:n.result.url},entityDeps:n.entityDeps,assetUsages:n.assetUsages}:{seo:e,entityDeps:n.entityDeps,assetUsages:[]}}function Te(e){let t=/* @__PURE__ */ new Map;if(!v(e,`customMarkdocTags`))for(let e of M())t.set(e,`Custom Markdoc tags are not in this project's plan, so \`${e}\` is ignored.`);if(!v(e,`codeWalkthrough`))for(let e of ne)t.set(e,`\`${e}\` is not in this project's plan and is ignored.`);return t}function Ee(e,t,n){let r=[];if(n.size===0)return r;for(let i of w(e)){let e=i.type===`tag`&&i.tag!==void 0?n.get(i.tag):void 0;e!==void 0&&(r.push({code:`configuration/ignored`,message:e,location:{filePath:t,range:C(i)??{start:{line:1},end:{line:1}}}}),te(i,e))}return r}const De=[`image`,`links`];async function Oe(e,t){let n=t.config.markdown?.frontMatterKeysToResolve??De,r={...e},i=[],a=[];for(let o of n){let n=e[o];if(typeof n!=`string`)continue;let s=await t.markdown.resolveLocalReference(n,t.file.path);i.push(...s.entityDeps),a.push(...s.assetUsages),s.result.kind!==`passthrough`&&(r[o]=s.result.url)}return{frontmatter:r,entityDeps:i,assetUsages:a}}async function ke(e,t){let n=[],r=[];if(!u(e))return{value:e,entityDeps:n,linkRefs:r};let i={...e};for(let a of[`nextButton`,`previousButton`]){let o=e[a];if(!u(o)||typeof o.page!=`string`)continue;let{page:s,...c}=o,l=se(ae(s),t.file.path);l!==null&&r.push({kind:`link`,raw:s,...l});let d=await X(s,t);n.push(...d.entityDeps),i[a]={...c,label:typeof c.label==`string`?c.label:d.route&&await Ae(d.route,t),link:d.link}}return{value:i,entityDeps:n,linkRefs:r}}async function Ae(e,t){let n=await S(t.entities,e);if(n!==void 0)return n;let r=t.routes.get(e.slug)?.metadata.seo;return u(r)&&typeof r.title==`string`&&r.title.trim()!==``?r.title:e.slug}async function X(e,t){let n=e.trim(),{path:r,suffix:i}=y(n);if(x(r)){let e=t.routes.bySlug(d(r));return{link:e&&`${e.slug}${i}`,route:e,entityDeps:[]}}let a=await t.markdown.resolveLocalReference(n,t.file.path);if(a.result.kind!==`pageUrl`)return{entityDeps:a.entityDeps};let o=a.result.url;return{link:o,route:t.routes.bySlug(y(o).path)??a.entityDeps.map(e=>e.kind===`file`?t.routes.byFilePath(e.path):void 0).reverse().find(e=>e!==void 0),entityDeps:a.entityDeps}}function je(e){let t=/* @__PURE__ */ new Map;for(let n of w(e)){if(n.type!==`tag`||n.tag===void 0||re[n.tag]?.attributes?.__idx===void 0)continue;let e=(t.get(n.tag)??0)+1;t.set(n.tag,e),n.attributes.__idx=e}}function Me(e,t,n){if(e.banner===void 0)return;let{value:r,problems:i}=m(p,{banner:e.banner});for(let e of i)n?.warn(`${t}: ${e.message}`);return r.banner}function Ne(e,t){return Z(e)??ie(t)??void 0}function Z(e){let t=u(e.seo)?e.seo.title:void 0;return typeof t==`string`&&t.trim()!==``?t:void 0}function Q(e){let t=(e.split(`/`).pop()??e).replace(/\.[^.]+$/,``);return t===``?e:t}function Pe(e,t){let n=e.manifest.template;if(typeof n==`string`&&n.trim()!==``)return $(n,e.path,t.logger);let r=g(e.path,t.config.markdown?.template);return typeof r==`string`&&r.trim()!==``?$(r,`redocly.yaml`,t.logger):U}function $(e,t,n){if(!e.startsWith(`./`)&&!e.startsWith(`../`)&&!e.startsWith(`/`))return e;let r=f(e,t);return r===null?(n.warn(`Template reference "${e}" in ${t} escapes the content root; falling back to ${U}.`),U):`${pe}${r}`}export{W as MARKDOC_DOCUMENT_LOADER_ID,_e as MARKDOC_SEARCH_GROUP,G as MARKDOC_SIDEBAR_ITEM_LOADER_ID,U as MARKDOC_TEMPLATE_ID,ve as markdocContentPlugin};
1
+ import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import{runtimeTemplate as i}from"../../templates.js";import{SEARCH_GROUP_FACET_FIELD as a}from"../../../../shared/search/facets.js";import{configuredFacetFields as o,extractFacetsFromFrontmatter as s,invalidFacetValueProblems as c,searchCategoryOf as l}from"../../../search/facet-values.js";import{isObject as u}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as d}from"../../../../shared/utils/routes/normalize-route-slug.js";import{MARKDOC_DOCUMENT_LOADER_KEY as f}from"../../../../shared/constants/route-deps.js";import{markdocNodeRange as p}from"../../../markdown/utils/node-source-range.js";import{replaceWithMarkdocError as m}from"../../../markdown/tags/markdoc-error.js";import{CODE_WALKTHROUGH_TAG_NAMES as h,builtInMarkdocTags as g}from"../../../markdown/constants/builtin-tags.js";import{isMarkdocValidationEnabled as ee,resolveMarkdocTagSet as _,resolveMarkdownPageValidationSet as te,userMarkdocSchemaFiles as v,userMarkdocTagNames as y}from"../../../markdown/constants/tag-sets.js";import{splitUrlSuffix as b}from"../../../../shared/utils/routes/split-url-suffix.js";import{isSkillContentPath as ne}from"../../utils/skill-paths.js";import{resolveContentPath as x}from"../../../../shared/utils/resolve-content-path.js";import{PAGE_BANNER_SCHEMA as re,sanitizeConfig as ie}from"../../../config-schema.js";import{notInPlanProblem as ae}from"../../../plan-gates.js";import{matchPathMap as oe}from"../../utils/glob.js";import{filePathToRouteSlug as se}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{isPlanFeatureGranted as S}from"../../../../shared/plan-gates.js";import{packMarkdocAst as ce,unpackMarkdocAst as C}from"../../../markdown/utils/packed-ast.js";import{isRouteSlugTarget as le}from"../../../../shared/utils/routes/is-route-slug-target.js";import{loadSidebarSubtreeLabel as ue}from"../../utils/sidebar-label.js";import{walkMarkdocAst as w}from"../../../markdown/utils/walk-markdoc-ast.js";import{markdocFirstHeading as de}from"../../../markdown/search/to-text.js";import{safeDecodeURI as fe}from"../../../../shared/utils/safe-decode-uri.js";import{shiftRange as T}from"../../../../shared/utils/shift-range.js";import{classifyLinkTarget as E}from"../../../link-checker/classify.js";import{onDiskLinkRefs as D}from"../../../link-checker/node-ref.js";import{isPartialPath as O}from"../../../markdown/utils/partials.js";import{FRONTMATTER_BLOCK_RE as k,computeFrontmatterLineOffset as A}from"../../../markdown/utils/frontmatter-offset.js";import{inlineRawPartials as j}from"../../../markdown/resolve/raw-partials.js";import{resolveMarkdownAst as M}from"../../../markdown/resolve/ast.js";import{resolveBannerForAppData as N}from"../app-data/banner.js";import{pageLocale as P}from"../../utils/page-locale.js";import{markdocAstToMarkdownDoc as F}from"../../../markdown/search/to-markdown.js";import{collectAnchors as I}from"../../../markdown/utils/collect-anchors.js";import{frontmatterVariable as L}from"../../../markdown/utils/frontmatter-variable.js";import{markdownFirstHeading as R}from"../../../markdown/utils/first-heading.js";import{markdocAstToSearchSections as z}from"../../../markdown/search/to-sections.js";import{isInternalPagePath as B}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as V}from"../../utils/explicit-slugs.js";import{SOURCE_TEMPLATE_PREFIX as pe}from"../../../../shared/constants/template-ids.js";import{captureSnippet as H,splitSourceLines as me}from"../../../../shared/utils/capture-snippet.js";import{curationKeywordsOf as he}from"../../../search/keywords.js";import ge from"js-yaml";const U=`markdoc-page`,W=r(`internal.markdoc`,`document`),G=r(`internal.markdoc`,`sidebar-item`),_e=`Documentation`,K=t(W,async e=>{let t=await e.io.readFile(e.file.absolutePath),{content:n,frontmatter:r,frontmatterError:i}=Y(t),a=J(e),{ast:o,entityDeps:s,assetUsages:c,tagList:l,problems:u,linkRefs:d}=await M(n,e.file.path,{resolverContext:a,tags:(await _()).tags,variables:{get env(){return e.config.publicEnv??{}}},transform:t=>Ee(t,e.file.path,Te(e.config)),validation:ee()?await te():void 0}),f=A(t);je(o);let p=await we(r.seo,e),m=S(e.config,`banner`)?await N(Me(r,e.file.path,e.logger),a):void 0,h=await Oe(r,e),g=await ke(r.navigation,e),v={...h.frontmatter,navigation:g.value,seo:p.seo,banner:m?.banner},y=Ne(r,o);return{value:{ast:ce(o),frontmatter:v,tagList:l,title:y,editPage:Ce(e.config,r,e.file.path),lastModified:e.file.lastModifiedAt},entityDeps:[...s,...ye(),...p.entityDeps,...m?.deps??[],...h.entityDeps,...g.entityDeps],assetUsages:[...c,...p.assetUsages,...m?.assetUsages??[],...h.assetUsages],problems:be(t,e.file.path,f,u,i),linkRefs:[...D(d,f),...g.linkRefs],targetInventories:[xe(o,{frontmatter:L(v,y)})]}},{usesProjectMarkdocSchema:!0,async markdown(e,t){let{tags:n}=await _(),{chunks:r,headings:i}=F(C(e.ast),{tags:n,locale:P(t),variables:{frontmatter:L(e.frontmatter,e.title),env:t.config.publicEnv??{}}});return[{chunks:r,headings:i,...e.title?{title:e.title}:{}}]},searchable(e,t){if(t.route===void 0||t.route.metadata.excludeFromSearch===!0)return{docs:[]};let n=t.route.slug,r=e.title??Q(t.route.originFilePath??n),{category:i,isInvalid:u}=l(t.route.metadata),{facets:d,invalidFields:f}=s(t.route.metadata,o(t.config)),p=he(e.frontmatter.keywords);return{docs:z(C(e.ast),r,{frontmatter:L(e.frontmatter,e.title)}).map((e,t)=>{let r={docKey:e.docKey,routeSlug:n,title:e.title,text:e.text,groupKey:i??`Documentation`,facets:d};e.anchor!==void 0&&(r.anchor=e.anchor),e.path!==void 0&&(r.path=e.path);let a=t===0?p:{excludes:p?.excludes};return(a?.includes||a?.excludes)&&(r.keywords=a),e.rbacTeams!==void 0&&(r.rbacScope=Object.fromEntries(e.rbacTeams.map(e=>[e,`read`]))),r}),problems:c([...f,...u?[a]:[]],t.route.originFilePath)}}}),q=t(G,async e=>{let{content:t,frontmatter:n}=Y(await e.io.readFile(e.file.absolutePath)),r=await j(t,e.file.path,J(e));return{value:{label:Z(n)??R(r.source)??Q(e.args.filePath)},entityDeps:r.entityDeps}});function J(e){return{config:e.config,contentDir:e.contentDir,entities:e.entities,file:e.file,io:e.io,logger:e.logger,markdown:e.markdown,plugin:e.plugin}}const ve=e({id:`internal.markdoc`,version:`3.44.0`,content:{filter:{match:e=>e.toLowerCase().endsWith(`.md`)&&!ne(e)},extractFile(e,t){if(B(e.path)||O(e.path,t.config))return{routes:[]};if(!S(t.config,`markdown`))return{routes:[],problems:[ae(`Markdown pages`)]};let{banner:n,...r}=e.manifest,i=Pe(e,t),a=V(r.slug),o=K.withArgs({filePath:e.path}),s=q.withArgs({filePath:e.path});return{routes:a.length>0?a.map(e=>({deps:{[f]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:e,slugHint:null,template:i})):[{deps:{[f]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:null,slugHint:se(e.path),template:i}],entities:[o]}}},loaders:[K,q],templates:{[U]:i(n(`./client/template.tsx`,import.meta.url))}});function Y(e){let t=e.match(k);if(!t)return{content:e,frontmatter:{}};let n=t[1]??``;try{let r=ge.load(n);return{content:e.slice(t[0].length),frontmatter:u(r)?r:{}}}catch(n){let r=n instanceof Error?n.message:String(n);return{content:e.slice(t[0].length),frontmatter:{},frontmatterError:r}}}function ye(){return(v()??[]).map(e=>({kind:`file`,path:e}))}function be(e,t,n,r,i){if(r.length===0&&i===void 0)return[];let a=me(e),o=r.map(e=>Se(e,a,n,t));if(i!==void 0){let e={start:{line:1},end:{line:n}};o.push({code:`markdown/frontmatter-parse`,message:i,location:{filePath:t,range:e,snippet:H(a,e)}})}return o}function xe(e,t){let{ids:n,exhaustive:r}=I(e,t);return{kind:`anchor`,exhaustive:r,targets:n}}function Se(e,t,n,r){let i=e.location?.range;if(!i)return e;let a=T(i,n);return{...e,location:{filePath:r,range:a,snippet:H(t,a)}}}function Ce(e,t,n){let r=u(t.markdown)?t.markdown:{},i={...e.markdown?.editPage,...u(r.editPage)?r.editPage:{}};if(i.hide!==!0&&typeof i.baseUrl==`string`&&i.baseUrl!==``)return{to:`${i.baseUrl.replace(/(?<!\/)\/+$/,``)}/${n}`}}async function we(e,t){if(!u(e)||typeof e.image!=`string`)return{seo:e,entityDeps:[],assetUsages:[]};let n=await t.markdown.resolveImageReference(e.image,t.file.path);return n.result.kind===`assetRef`?{seo:{...e,image:n.result.url},entityDeps:n.entityDeps,assetUsages:n.assetUsages}:{seo:e,entityDeps:n.entityDeps,assetUsages:[]}}function Te(e){let t=/* @__PURE__ */ new Map;if(!S(e,`customMarkdocTags`))for(let e of y())t.set(e,`Custom Markdoc tags are not in this project's plan, so \`${e}\` is ignored.`);if(!S(e,`codeWalkthrough`))for(let e of h)t.set(e,`\`${e}\` is not in this project's plan and is ignored.`);return t}function Ee(e,t,n){let r=[];if(n.size===0)return r;for(let i of w(e)){let e=i.type===`tag`&&i.tag!==void 0?n.get(i.tag):void 0;e!==void 0&&(r.push({code:`configuration/ignored`,message:e,location:{filePath:t,range:p(i)??{start:{line:1},end:{line:1}}}}),m(i,e))}return r}const De=[`image`,`links`];async function Oe(e,t){let n=t.config.markdown?.frontMatterKeysToResolve??De,r={...e},i=[],a=[];for(let o of n){let n=e[o];if(typeof n!=`string`)continue;let s=await t.markdown.resolveLocalReference(n,t.file.path);i.push(...s.entityDeps),a.push(...s.assetUsages),s.result.kind!==`passthrough`&&(r[o]=s.result.url)}return{frontmatter:r,entityDeps:i,assetUsages:a}}async function ke(e,t){let n=[],r=[];if(!u(e))return{value:e,entityDeps:n,linkRefs:r};let i={...e};for(let a of[`nextButton`,`previousButton`]){let o=e[a];if(!u(o)||typeof o.page!=`string`)continue;let{page:s,...c}=o,l=E(fe(s),t.file.path);l!==null&&r.push({kind:`link`,raw:s,...l});let d=await X(s,t);n.push(...d.entityDeps),i[a]={...c,label:typeof c.label==`string`?c.label:d.route&&await Ae(d.route,t),link:d.link}}return{value:i,entityDeps:n,linkRefs:r}}async function Ae(e,t){let n=await ue(t.entities,e);if(n!==void 0)return n;let r=t.routes.get(e.slug)?.metadata.seo;return u(r)&&typeof r.title==`string`&&r.title.trim()!==``?r.title:e.slug}async function X(e,t){let n=e.trim(),{path:r,suffix:i}=b(n);if(le(r)){let e=t.routes.bySlug(d(r));return{link:e&&`${e.slug}${i}`,route:e,entityDeps:[]}}let a=await t.markdown.resolveLocalReference(n,t.file.path);if(a.result.kind!==`pageUrl`)return{entityDeps:a.entityDeps};let o=a.result.url;return{link:o,route:t.routes.bySlug(b(o).path)??a.entityDeps.map(e=>e.kind===`file`?t.routes.byFilePath(e.path):void 0).reverse().find(e=>e!==void 0),entityDeps:a.entityDeps}}function je(e){let t=/* @__PURE__ */ new Map;for(let n of w(e)){if(n.type!==`tag`||n.tag===void 0||g[n.tag]?.attributes?.__idx===void 0)continue;let e=(t.get(n.tag)??0)+1;t.set(n.tag,e),n.attributes.__idx=e}}function Me(e,t,n){if(e.banner===void 0)return;let{value:r,problems:i}=ie(re,{banner:e.banner});for(let e of i)n?.warn(`${t}: ${e.message}`);return r.banner}function Ne(e,t){return Z(e)??de(t)??void 0}function Z(e){let t=u(e.seo)?e.seo.title:void 0;return typeof t==`string`&&t.trim()!==``?t:void 0}function Q(e){let t=(e.split(`/`).pop()??e).replace(/\.[^.]+$/,``);return t===``?e:t}function Pe(e,t){let n=e.manifest.template;if(typeof n==`string`&&n.trim()!==``)return $(n,e.path,t.logger);let r=oe(e.path,t.config.markdown?.template);return typeof r==`string`&&r.trim()!==``?$(r,`redocly.yaml`,t.logger):U}function $(e,t,n){if(!e.startsWith(`./`)&&!e.startsWith(`../`)&&!e.startsWith(`/`))return e;let r=x(e,t);return r===null?(n.warn(`Template reference "${e}" in ${t} escapes the content root; falling back to ${U}.`),U):`${pe}${r}`}export{W as MARKDOC_DOCUMENT_LOADER_ID,_e as MARKDOC_SEARCH_GROUP,G as MARKDOC_SIDEBAR_ITEM_LOADER_ID,U as MARKDOC_TEMPLATE_ID,ve as markdocContentPlugin};
@@ -10,12 +10,6 @@ export declare const MCP_REGISTER_ROUTE = "/_mcp/register";
10
10
  export declare const MCP_AUTHORIZE_ROUTE = "/_mcp/oauth2/auth";
11
11
  export declare const MCP_TOKEN_ROUTE = "/_mcp/oauth2/token-portal";
12
12
  export declare const MCP_CALLBACK_ROUTE = "/_mcp/oauth/callback";
13
- export declare const EXECUTE_TOOL_NAME = "execute";
14
- export declare const DISCOVER_TOOL_NAME = "discover";
15
- export declare const CREATE_ANONYMOUS_SESSION_TOOL_NAME = "createAnonymousSession";
16
- export declare const MANAGE_API_CREDENTIALS_TOOL_NAME = "manageApiCredentials";
17
- export declare const REMOVE_API_CREDENTIALS_TOOL_NAME = "removeApiCredentials";
18
- export declare const SUBMIT_FEEDBACK_TOOL_NAME = "submit-feedback";
19
13
  export declare const MCP_CREDENTIALS_ROUTE = "/mcp/credentials";
20
14
  export declare const DEFAULT_MCP_SERVER_NAME = "Docs MCP server";
21
15
  export declare const PLACEHOLDER_MCP_SERVER_NAMES: readonly string[];
@@ -1 +1 @@
1
- const e=`/mcp`,t=`/mcp-public`,n=`mcp-setup`,r=`/.well-known/mcp/server-card.json`,i=`/.well-known/agent-card.json`,a=`/a2a`,o=`/.well-known/oauth-protected-resource${e}`,s=`/.well-known/oauth-authorization-server`,c=`/_mcp/register`,l=`/_mcp/oauth2/auth`,u=`/_mcp/oauth2/token-portal`,d=`/_mcp/oauth/callback`,f=`execute`,p=`discover`,m=`createAnonymousSession`,h=`manageApiCredentials`,g=`removeApiCredentials`,_=`submit-feedback`,v=`/mcp/credentials`,y=`Docs MCP server`,b=[y,`MCP server`],x=`X-Redocly-AI-Metadata`,S=`mcp-tools`;export{a as A2A_ROUTE,i as AGENT_CARD_ROUTE,x as AI_METADATA_HEADER,m as CREATE_ANONYMOUS_SESSION_TOOL_NAME,y as DEFAULT_MCP_SERVER_NAME,p as DISCOVER_TOOL_NAME,f as EXECUTE_TOOL_NAME,h as MANAGE_API_CREDENTIALS_TOOL_NAME,s as MCP_AUTHORIZATION_SERVER_ROUTE,l as MCP_AUTHORIZE_ROUTE,d as MCP_CALLBACK_ROUTE,v as MCP_CREDENTIALS_ROUTE,o as MCP_PROTECTED_RESOURCE_ROUTE,c as MCP_REGISTER_ROUTE,e as MCP_ROUTE,r as MCP_SERVER_CARD_ROUTE,n as MCP_SETUP_TEMPLATE_ID,u as MCP_TOKEN_ROUTE,S as MCP_TOOLS_ENTITY_TYPE,b as PLACEHOLDER_MCP_SERVER_NAMES,t as PUBLIC_MCP_ROUTE,g as REMOVE_API_CREDENTIALS_TOOL_NAME,_ as SUBMIT_FEEDBACK_TOOL_NAME};
1
+ const e=`/mcp`,t=`/mcp-public`,n=`mcp-setup`,r=`/.well-known/mcp/server-card.json`,i=`/.well-known/agent-card.json`,a=`/a2a`,o=`/.well-known/oauth-protected-resource${e}`,s=`/.well-known/oauth-authorization-server`,c=`/_mcp/register`,l=`/_mcp/oauth2/auth`,u=`/_mcp/oauth2/token-portal`,d=`/_mcp/oauth/callback`,f=`/mcp/credentials`,p=`Docs MCP server`,m=[p,`MCP server`],h=`X-Redocly-AI-Metadata`,g=`mcp-tools`;export{a as A2A_ROUTE,i as AGENT_CARD_ROUTE,h as AI_METADATA_HEADER,p as DEFAULT_MCP_SERVER_NAME,s as MCP_AUTHORIZATION_SERVER_ROUTE,l as MCP_AUTHORIZE_ROUTE,d as MCP_CALLBACK_ROUTE,f as MCP_CREDENTIALS_ROUTE,o as MCP_PROTECTED_RESOURCE_ROUTE,c as MCP_REGISTER_ROUTE,e as MCP_ROUTE,r as MCP_SERVER_CARD_ROUTE,n as MCP_SETUP_TEMPLATE_ID,u as MCP_TOKEN_ROUTE,g as MCP_TOOLS_ENTITY_TYPE,m as PLACEHOLDER_MCP_SERVER_NAMES,t as PUBLIC_MCP_ROUTE};
@@ -1 +1 @@
1
- import{createInlineEntity as e}from"../../../loaders/define.js";import{notInPlanProblem as t}from"../../../plan-gates.js";import{MCP_TOOL_NAME_PATTERN as n}from"../../registry.js";import{isPlanFeatureGranted as r}from"../../../../shared/plan-gates.js";import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as i,DISCOVER_TOOL_NAME as a,EXECUTE_TOOL_NAME as o,MANAGE_API_CREDENTIALS_TOOL_NAME as s,MCP_TOOLS_ENTITY_TYPE as c,REMOVE_API_CREDENTIALS_TOOL_NAME as l,SUBMIT_FEEDBACK_TOOL_NAME as u}from"./constants.js";import{isMcpHidden as d}from"./server/config-gate.js";import{buildMcpSetupPageRoutes as f}from"./setup-page.js";const p=`@mcp`,m=`mcp/invalid-tool`,h=/\.(ts|js)$/u,g=/\.d\.ts$/u,_=/* @__PURE__ */ new Set([`search`,`list-apis`,`get-endpoints`,`get-endpoint-info`,`get-security-schemes`,`get-full-api-description`,`list-graphql-apis`,`get-graphql-type-list`,`get-graphql-type`,`get-graphql-schema`,`list-pages`,`get-page`,`grep-pages`,`whoami`,u,o,a,`describe-tools`,i,s,l]);function v(e){return`mcp-tool-file:${e}`}function y(e){if(g.test(e)||!h.test(e))return!1;let t=e.split(`/`),n=t.indexOf(p);return n!==-1&&n<t.length-1}function b(e,t,r){if(!n.test(e))return`Invalid MCP tool file "${t}": the tool name "${e}" is derived from the file name and may only contain letters, numbers, hyphens, and underscores (max 64 characters). Rename the file.`;if(r!==void 0)return`Duplicate MCP tool name "${e}": defined by both "${r}" and "${t}". Tool names are file names, so each file name must be unique across @mcp folders.`;if(_.has(e))return`Invalid MCP tool file "${t}": the tool name "${e}" is already used by a built-in MCP tool. Rename the file.`}function x(n){let i=[],a=[];if(d(n.config))return{entities:i,problems:a};if(!r(n.config,`customMcpTools`)){for(let{path:e}of n.files)a.push({...t(`Custom MCP tools`),location:{filePath:e}});return{entities:i,problems:a}}let o=/* @__PURE__ */ new Map;for(let{path:t}of n.files){let n=t.slice(t.lastIndexOf(`/`)+1).replace(h,``),r=b(n,t,o.get(n));if(r!==void 0){a.push({code:m,message:r,location:{filePath:t}});continue}o.set(n,t);let s={name:n,sourcePath:t};i.push(e(s,{stableKey:v(t),type:c,metadata:s}))}return{entities:i,problems:a}}const S={filter:{match:y},extractAll(e){return{routes:f(e.config),entities:[]}}};export{p as MCP_DIR_SEGMENT,m as MCP_TOOL_PROBLEM_CODE,_ as RESERVED_MCP_TOOL_NAMES,y as isMcpToolFile,S as mcpContent,v as mcpToolFileEntityKey,x as scanMcpToolFiles};
1
+ import{createInlineEntity as e}from"../../../loaders/define.js";import{notInPlanProblem as t}from"../../../plan-gates.js";import{MCP_TOOL_NAME_PATTERN as n}from"../../registry.js";import{isPlanFeatureGranted as r}from"../../../../shared/plan-gates.js";import{MCP_TOOLS_ENTITY_TYPE as i}from"./constants.js";import{isMcpHidden as a}from"./server/config-gate.js";import{buildMcpSetupPageRoutes as o}from"./setup-page.js";import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as s,DISCOVER_TOOL_NAME as c,EXECUTE_TOOL_NAME as l,MANAGE_API_CREDENTIALS_TOOL_NAME as u,REMOVE_API_CREDENTIALS_TOOL_NAME as d,SUBMIT_FEEDBACK_TOOL_NAME as f}from"@redocly/mcp";const p=`@mcp`,m=`mcp/invalid-tool`,h=/\.(ts|js)$/u,g=/\.d\.ts$/u,_=/* @__PURE__ */ new Set([`search`,`list-apis`,`get-endpoints`,`get-endpoint-info`,`get-security-schemes`,`get-full-api-description`,`list-graphql-apis`,`get-graphql-type-list`,`get-graphql-type`,`get-graphql-schema`,`list-pages`,`get-page`,`grep-pages`,`whoami`,f,l,c,`describe-tools`,s,u,d]);function v(e){return`mcp-tool-file:${e}`}function y(e){if(g.test(e)||!h.test(e))return!1;let t=e.split(`/`),n=t.indexOf(p);return n!==-1&&n<t.length-1}function b(e,t,r){if(!n.test(e))return`Invalid MCP tool file "${t}": the tool name "${e}" is derived from the file name and may only contain letters, numbers, hyphens, and underscores (max 64 characters). Rename the file.`;if(r!==void 0)return`Duplicate MCP tool name "${e}": defined by both "${r}" and "${t}". Tool names are file names, so each file name must be unique across @mcp folders.`;if(_.has(e))return`Invalid MCP tool file "${t}": the tool name "${e}" is already used by a built-in MCP tool. Rename the file.`}function x(n){let o=[],s=[];if(a(n.config))return{entities:o,problems:s};if(!r(n.config,`customMcpTools`)){for(let{path:e}of n.files)s.push({...t(`Custom MCP tools`),location:{filePath:e}});return{entities:o,problems:s}}let c=/* @__PURE__ */ new Map;for(let{path:t}of n.files){let n=t.slice(t.lastIndexOf(`/`)+1).replace(h,``),r=b(n,t,c.get(n));if(r!==void 0){s.push({code:m,message:r,location:{filePath:t}});continue}c.set(n,t);let a={name:n,sourcePath:t};o.push(e(a,{stableKey:v(t),type:i,metadata:a}))}return{entities:o,problems:s}}const S={filter:{match:y},extractAll(e){return{routes:o(e.config),entities:[]}}};export{p as MCP_DIR_SEGMENT,m as MCP_TOOL_PROBLEM_CODE,_ as RESERVED_MCP_TOOL_NAMES,y as isMcpToolFile,S as mcpContent,v as mcpToolFileEntityKey,x as scanMcpToolFiles};
@@ -1 +1 @@
1
- import{compareStrings as e}from"../../../../shared/utils/compare-strings.js";import{delocalizeRouteSlug as t,l10nDirOf as n}from"../../../../shared/utils/l10n.js";import{compileContentGlob as r}from"../../utils/glob.js";import{toPublicVersionedSlug as i}from"../../../../shared/constants/versions.js";import{MCP_IGNORED_ROUTES_ENTITY_KEY as a}from"../../../../shared/constants/mcp.js";const o=/* @__PURE__ */ new Set;function s(e,r){let i=n(r);return(i===void 0?e:t(e,i)??e).replace(/^\/+/,``)}function c(t,n,i,a){if(n.length===0)return[];let o=r(n),c=/* @__PURE__ */ new Set,u=new Set(t.map(e=>e.slug)),d=e=>{let t=l(e,i),n=t!==void 0&&!u.has(t);for(let r of n?[e.slug,t]:[e.slug])if(c.add(r),e.locale===``&&a!==void 0)for(let e of a.locales)c.add(a.toL10nSlug(r,e))};for(let e of t){let t=s(e.slug,e.originFilePath??``);(e.originFilePath!==null&&o(e.originFilePath)||o(t))&&d(e)}return[...c].sort(e)}function l(e,t){if(e.versionGroup&&e.version&&t.get(e.versionGroup)?.defaultVersion===e.version)return i(e.slug,e.versionGroup,e.version,!0)}async function u(e){if(!await e.get(`mcp:ignored-routes`))return o;let t=await e.load(a);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):o}export{a as MCP_IGNORED_ROUTES_ENTITY_KEY,s as canonicalSlugPath,c as collectIgnoredRouteSlugs,u as readIgnoredRouteSlugs};
1
+ import{compareStrings as e}from"../../../../shared/utils/compare-strings.js";import{delocalizeRouteSlug as t,l10nDirOf as n}from"../../../../shared/utils/l10n.js";import{toPublicVersionedSlug as r}from"../../../../shared/constants/versions.js";import{compileContentGlob as i}from"../../utils/glob.js";import{MCP_IGNORED_ROUTES_ENTITY_KEY as a}from"../../../../shared/constants/mcp.js";const o=/* @__PURE__ */ new Set;function s(e,r){let i=n(r);return(i===void 0?e:t(e,i)??e).replace(/^\/+/,``)}function c(t,n,r,a){if(n.length===0)return[];let o=i(n),c=/* @__PURE__ */ new Set,u=new Set(t.map(e=>e.slug)),d=e=>{let t=l(e,r),n=t!==void 0&&!u.has(t);for(let r of n?[e.slug,t]:[e.slug])if(c.add(r),e.locale===``&&a!==void 0)for(let e of a.locales)c.add(a.toL10nSlug(r,e))};for(let e of t){let t=s(e.slug,e.originFilePath??``);(e.originFilePath!==null&&o(e.originFilePath)||o(t))&&d(e)}return[...c].sort(e)}function l(e,t){if(e.versionGroup&&e.version&&t.get(e.versionGroup)?.defaultVersion===e.version)return r(e.slug,e.versionGroup,e.version,!0)}async function u(e){if(!await e.get(`mcp:ignored-routes`))return o;let t=await e.load(a);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):o}export{a as MCP_IGNORED_ROUTES_ENTITY_KEY,s as canonicalSlugPath,c as collectIgnoredRouteSlugs,u as readIgnoredRouteSlugs};
@@ -1 +1 @@
1
- import{isObject as e}from"../../../../../shared/utils/is-object.js";import"../constants.js";import{thrownErrorClass as t}from"./tool-errors.js";import{maskCodeCredentials as n}from"./code-credentials.js";import{redactSecretsFromString as r}from"./gateway/fetch/redact.js";import{redactSecretShapes as i}from"./secret-patterns.js";import{createHash as a}from"node:crypto";function o(e){return{client:e.client,clientVersion:e.clientVersion,requestId:e.requestId,messageId:e.messageId,callerSubject:e.callerSubject,clientIp:e.request.ip??void 0}}const s=`[mcp-audit]`,c=4096;function l(e){return a(`sha256`).update(e,`utf8`).digest(`hex`)}function u(e){if(e.length<=4096)return e;let t=e.slice(0,c),n=t.search(/\s\S*$/),r=n>0?t.slice(0,n):t;return`${r}…[truncated: kept ${r.length} of ${e.length} chars]`}function d(e,t=[]){return i(r(u(e),t))}const f=/(?<=^|[\s('"])(?:file:\/\/\/?|\/)(?:[^\s()/:'"]+\/)+/gm;function p(e){return d(e.replace(f,``))}function m(e){return{sha256:l(e),bytes:Buffer.byteLength(e,`utf8`)}}function h(e){return Object.keys(e??{}).map(e=>e.toLowerCase()).sort().join(`,`)}const g=/* @__PURE__ */ new Set([`access_token`,`api-key`,`api_key`,`apikey`,`assertion`,`auth`,`client_secret`,`code`,`code_verifier`,`id_token`,`id_token_hint`,`key`,`password`,`refresh_token`,`samlresponse`,`secret`,`session`,`sig`,`signature`,`token`,`x-amz-credential`,`x-amz-security-token`,`x-amz-signature`]);function _(e,t=[],n=[]){let r;try{r=new URL(e)}catch{return d(e,t)}let i=new Set(n.map(e=>e.toLowerCase()));for(let e of[...r.searchParams.keys()]){let t=e.toLowerCase();(g.has(t)||i.has(t))&&r.searchParams.set(e,`redacted`)}return r.username=``,r.password=``,d(r.href,t)}function v(e,t,n){let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0&&e!==``));try{e?.info(`${s} ${t}`,r)}catch{}}const y=/(169\.254\.169\.254|metadata\.google\.internal|\.consul\b|\.internal\b|localhost|127\.0\.0\.1|\b10\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|\b192\.168\.\d{1,3}\.\d{1,3}\b|\b172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}\b)/i,b=/(process\s*(?:\.\s*env\b|\[)|globalThis|require\s*\(|__proto__)/;function x(e){let t=[];return b.test(e)&&t.push(`env_probe`),y.test(e)&&t.push(`internal_target`),{sha256:l(e),length:e.length,flags:t.sort().join(`,`)}}function S(e){try{return JSON.stringify(e)??String(e)}catch{return`«[unserializable]»`}}function C(e,{tool:t,mode:n,args:r,result:i,errorClass:a,client:o,clientVersion:s,requestId:c,messageId:u,callerSubject:f,clientIp:p}){if(t===`execute`)return;let h=S(r),g=i===void 0?void 0:m(i),_=r?.sessionHandle,y=typeof _==`string`&&_!==``?_:void 0,b=f??y;v(e,`Record MCP tool call`,{tool:t,mode:n,server_type:`docs`,error_class:a,client:o,client_version:s,request_id:c,message_id:u,subject_sha256:b?l(b):void 0,client_ip:p,args_sha256:l(h),args:d(h,y?[y]:[]),result_sha256:g?.sha256,result_bytes:g?.bytes})}async function w(e,n,r,i){let a={tool:n,mode:e.mcpMode,args:r,...o(e)},s=Date.now(),c;try{c=await i()}catch(r){throw C(e.logger,{...a,errorClass:t(r)}),e.telemetry?.toolThrew(n,Date.now()-s,r),await e.telemetry?.flush(),r}let l=E(c)&&c.isError===!0;return C(e.logger,{...a,result:k(c),errorClass:l?`tool_error`:void 0}),e.telemetry?.toolReturned(n,Date.now()-s,c),await e.telemetry?.flush(),c}const T=/* @__PURE__ */ new Set([`text`,`image`,`audio`,`resource`,`resource_link`]);function E(t){return e(t)&&Array.isArray(t.content)&&t.content.every(t=>e(t)&&T.has(t.type))}function D(t){return e(t)&&t.resultType===`input_required`}function O(e,t=``){return e.content.map(e=>e.type===`text`?e.text:``).join(t)}function k(e){if(typeof e==`string`)return e;if(E(e))return O(e);if(D(e))return``;try{return JSON.stringify(e)??``}catch{return``}}function A(e,{audit:t,code:r,description:i,sessionHandle:a,toolNames:o,fetchBudget:s,fetchCapable:c,requestId:u,messageId:f,callerSubject:p,clientIp:m}){let h=p??a;v(e,`Record code execution input`,{code_sha256:t.sha256,code_length:t.length,request_id:u,message_id:f,flags:t.flags,subject_sha256:h?l(h):void 0,client_ip:m,description:d(i),tools:[...o].sort().join(`,`),fetch_capable:c,fetch_budget:s,code:d(n(r))})}function j(e,{rawUrl:t,method:n,host:r,outcome:i,durationMs:a,injectedSecretValues:o,credentialQueryParams:s,path:c,api:u,status:f,injectedScheme:p,requestHeaders:g,requestBody:y,responseHeaders:b,responseBody:x,caller:S={}}){let{requestId:C,callerSubject:w,clientIp:T}=S,E=x===void 0?void 0:m(x);v(e,`Record gateway fetch`,{url_sha256:l(t),host:r,method:n,path:c,api:u,outcome:i,status:f,injected_scheme:p,duration_ms:a,request_id:C,subject_sha256:w?l(w):void 0,client_ip:T,url:_(t,o,s),request_header_names:h(g),request_body:y===void 0?void 0:d(y,o),response_header_names:h(b),response_sha256:E?.sha256,response_bytes:E?.bytes})}export{c as AUDIT_FIELD_MAX_CHARS,s as AUDIT_LOG_PREFIX,x as auditCode,h as auditHeaderNames,d as auditInput,l as auditSha256,p as auditStack,w as auditToolCall,_ as auditUrl,o as callAttribution,E as isCallToolResult,v as logAuditRecord,A as logCodeExecutionAudit,j as logGatewayFetchAudit,C as logMcpToolCallAudit,k as toolOutputText,O as toolResultText,u as truncateAuditField};
1
+ import{isObject as e}from"../../../../../shared/utils/is-object.js";import{thrownErrorClass as t}from"./tool-errors.js";import{maskCodeCredentials as n}from"./code-credentials.js";import{redactSecretsFromString as r}from"./gateway/fetch/redact.js";import{redactSecretShapes as i}from"./secret-patterns.js";import{createHash as a}from"node:crypto";import{EXECUTE_TOOL_NAME as o}from"@redocly/mcp";function s(e){return{client:e.client,clientVersion:e.clientVersion,requestId:e.requestId,messageId:e.messageId,callerSubject:e.callerSubject,clientIp:e.request.ip??void 0}}const c=`[mcp-audit]`,l=4096;function u(e){return a(`sha256`).update(e,`utf8`).digest(`hex`)}function d(e){if(e.length<=4096)return e;let t=e.slice(0,l),n=t.search(/\s\S*$/),r=n>0?t.slice(0,n):t;return`${r}…[truncated: kept ${r.length} of ${e.length} chars]`}function f(e,t=[]){return i(r(d(e),t))}const p=/(?<=^|[\s('"])(?:file:\/\/\/?|\/)(?:[^\s()/:'"]+\/)+/gm;function m(e){return f(e.replace(p,``))}function h(e){return{sha256:u(e),bytes:Buffer.byteLength(e,`utf8`)}}function g(e){return Object.keys(e??{}).map(e=>e.toLowerCase()).sort().join(`,`)}const _=/* @__PURE__ */ new Set([`access_token`,`api-key`,`api_key`,`apikey`,`assertion`,`auth`,`client_secret`,`code`,`code_verifier`,`id_token`,`id_token_hint`,`key`,`password`,`refresh_token`,`samlresponse`,`secret`,`session`,`sig`,`signature`,`token`,`x-amz-credential`,`x-amz-security-token`,`x-amz-signature`]);function v(e,t=[],n=[]){let r;try{r=new URL(e)}catch{return f(e,t)}let i=new Set(n.map(e=>e.toLowerCase()));for(let e of[...r.searchParams.keys()]){let t=e.toLowerCase();(_.has(t)||i.has(t))&&r.searchParams.set(e,`redacted`)}return r.username=``,r.password=``,f(r.href,t)}function y(e,t,n){let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0&&e!==``));try{e?.info(`${c} ${t}`,r)}catch{}}const b=/(169\.254\.169\.254|metadata\.google\.internal|\.consul\b|\.internal\b|localhost|127\.0\.0\.1|\b10\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|\b192\.168\.\d{1,3}\.\d{1,3}\b|\b172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}\b)/i,x=/(process\s*(?:\.\s*env\b|\[)|globalThis|require\s*\(|__proto__)/;function S(e){let t=[];return x.test(e)&&t.push(`env_probe`),b.test(e)&&t.push(`internal_target`),{sha256:u(e),length:e.length,flags:t.sort().join(`,`)}}function C(e){try{return JSON.stringify(e)??String(e)}catch{return`«[unserializable]»`}}function w(e,{tool:t,mode:n,args:r,result:i,errorClass:a,client:s,clientVersion:c,requestId:l,messageId:d,callerSubject:p,clientIp:m}){if(t===o)return;let g=C(r),_=i===void 0?void 0:h(i),v=r?.sessionHandle,b=typeof v==`string`&&v!==``?v:void 0,x=p??b;y(e,`Record MCP tool call`,{tool:t,mode:n,server_type:`docs`,error_class:a,client:s,client_version:c,request_id:l,message_id:d,subject_sha256:x?u(x):void 0,client_ip:m,args_sha256:u(g),args:f(g,b?[b]:[]),result_sha256:_?.sha256,result_bytes:_?.bytes})}async function T(e,n,r,i){let a={tool:n,mode:e.mcpMode,args:r,...s(e)},o=Date.now(),c;try{c=await i()}catch(r){throw w(e.logger,{...a,errorClass:t(r)}),e.telemetry?.toolThrew(n,Date.now()-o,r),await e.telemetry?.flush(),r}let l=D(c)&&c.isError===!0;return w(e.logger,{...a,result:A(c),errorClass:l?`tool_error`:void 0}),e.telemetry?.toolReturned(n,Date.now()-o,c),await e.telemetry?.flush(),c}const E=/* @__PURE__ */ new Set([`text`,`image`,`audio`,`resource`,`resource_link`]);function D(t){return e(t)&&Array.isArray(t.content)&&t.content.every(t=>e(t)&&E.has(t.type))}function O(t){return e(t)&&t.resultType===`input_required`}function k(e,t=``){return e.content.map(e=>e.type===`text`?e.text:``).join(t)}function A(e){if(typeof e==`string`)return e;if(D(e))return k(e);if(O(e))return``;try{return JSON.stringify(e)??``}catch{return``}}function j(e,{audit:t,code:r,description:i,sessionHandle:a,toolNames:o,fetchBudget:s,fetchCapable:c,requestId:l,messageId:d,callerSubject:p,clientIp:m}){let h=p??a;y(e,`Record code execution input`,{code_sha256:t.sha256,code_length:t.length,request_id:l,message_id:d,flags:t.flags,subject_sha256:h?u(h):void 0,client_ip:m,description:f(i),tools:[...o].sort().join(`,`),fetch_capable:c,fetch_budget:s,code:f(n(r))})}function M(e,{rawUrl:t,method:n,host:r,outcome:i,durationMs:a,injectedSecretValues:o,credentialQueryParams:s,path:c,api:l,status:d,injectedScheme:p,requestHeaders:m,requestBody:_,responseHeaders:b,responseBody:x,caller:S={}}){let{requestId:C,callerSubject:w,clientIp:T}=S,E=x===void 0?void 0:h(x);y(e,`Record gateway fetch`,{url_sha256:u(t),host:r,method:n,path:c,api:l,outcome:i,status:d,injected_scheme:p,duration_ms:a,request_id:C,subject_sha256:w?u(w):void 0,client_ip:T,url:v(t,o,s),request_header_names:g(m),request_body:_===void 0?void 0:f(_,o),response_header_names:g(b),response_sha256:E?.sha256,response_bytes:E?.bytes})}export{l as AUDIT_FIELD_MAX_CHARS,c as AUDIT_LOG_PREFIX,S as auditCode,g as auditHeaderNames,f as auditInput,u as auditSha256,m as auditStack,T as auditToolCall,v as auditUrl,s as callAttribution,D as isCallToolResult,y as logAuditRecord,j as logCodeExecutionAudit,M as logGatewayFetchAudit,w as logMcpToolCallAudit,A as toolOutputText,k as toolResultText,d as truncateAuditField};
@@ -1,7 +1,7 @@
1
- import{FETCH_TOOL_NAME as e}from"./constants.js";import{buildToolTypeDeclarations as t,sanitizeToolName as n}from"./tool-declarations.js";import{READ_ONLY_ANNOTATIONS as r}from"../tools/schemas.js";import{callableApis as i}from"../gateway/eligibility.js";import{allowsOnlySafeHttpMethods as a,getAllowedHttpMethods as o}from"../gateway/allowed-http-methods.js";import{EXECUTE_ARGS_NOTE as s,PLAIN_JAVASCRIPT_RULE as c,USAGE_NOTES as l,buildExecuteExample as u}from"./prompts.js";const d=["```ts",`/**`,` * Call a documented operation of a callable API. Undocumented paths and methods are refused.`,` * Responses cap at 1 MiB and redirects are not followed.`,` */`,`declare function fetch(url: string | URL, init?: {`,` method?: string;`," /** `content-type` is set automatically for URLSearchParams/FormData unless you set one. */",` headers?: Record<string, string>;`,` /** string · URLSearchParams (→ application/x-www-form-urlencoded) · FormData (→ multipart/form-data) */`,` body?: string | URLSearchParams | FormData;`," /** Security scheme name (from the operation's `security` or `getSecuritySchemes`) whose credential to send. Omit to let the server choose. */",` securityScheme?: string;`,`}): Promise<{`,` status: number;`,` statusText: string;`,` ok: boolean;`,` headers: { get(name: string): string | null };`,` json(): Promise<unknown>;`,` text(): Promise<string>;`,`}>;`,"```"].join(`
1
+ import{FETCH_TOOL_NAME as e}from"./constants.js";import{callableApis as t}from"../gateway/eligibility.js";import{allowsOnlySafeHttpMethods as n,getAllowedHttpMethods as r}from"../gateway/allowed-http-methods.js";import{EXECUTE_ARGS_NOTE as i,USAGE_NOTES as a,buildExecuteExample as o}from"./prompts.js";import{PLAIN_JAVASCRIPT_RULE as s,READ_ONLY_ANNOTATIONS as c,buildToolTypeDeclarations as l,sanitizeToolName as u}from"@redocly/mcp";const d=["```ts",`/**`,` * Call a documented operation of a callable API. Undocumented paths and methods are refused.`,` * Responses cap at 1 MiB and redirects are not followed.`,` */`,`declare function fetch(url: string | URL, init?: {`,` method?: string;`," /** `content-type` is set automatically for URLSearchParams/FormData unless you set one. */",` headers?: Record<string, string>;`,` /** string · URLSearchParams (→ application/x-www-form-urlencoded) · FormData (→ multipart/form-data) */`,` body?: string | URLSearchParams | FormData;`," /** Security scheme name (from the operation's `security` or `getSecuritySchemes`) whose credential to send. Omit to let the server choose. */",` securityScheme?: string;`,`}): Promise<{`,` status: number;`,` statusText: string;`,` ok: boolean;`,` headers: { get(name: string): string | null };`,` json(): Promise<unknown>;`,` text(): Promise<string>;`,`}>;`,"```"].join(`
2
2
  `),f=[`listApis`,`getEndpoints`,`getEndpointInfo`],p=[`Example - list the paid invoices of a billing API:`,``,"```js",`const { items } = await site.listApis({ filter: 'billing' });`,`const [api] = items;`,`if (!api) return { error: 'no API matches "billing"' };`,`const { endpoints } = await site.getEndpoints({ name: api.name });`,`const ep = endpoints.find((e) => e.method === 'GET' && e.path.includes('invoices'));`,`const info = await site.getEndpointInfo({ name: api.name, path: ep.path, method: ep.method });`,"// Replace every `{placeholder}` first.",`const url = new URL((info.servers?.[0]?.url ?? '') + ep.path);`,"// Every name below comes from `info.endpoint.parameters` - read them first, never guess them.",`url.searchParams.set('filter', 'status:paid');`,`url.searchParams.set('sort', '-createdTime');`,`url.searchParams.set('limit', '100');`,`try {`,` const res = await fetch(url, { method: ep.method });`,` return res.ok ? await res.json() : { status: res.status, error: await res.text() };`,`} catch (error) {`,` return { error: error instanceof Error ? error.message : String(error), endpointId: info };`,`}`,"```"].join(`
3
3
  `),m=[`Example - call an endpoint you already read:`,``,"```js","// Call `getEndpointInfo` first for the server URL, the path, and the parameter names.","// Replace every `{placeholder}` first.",`const url = new URL('https://api.example.com/invoices');`,`url.searchParams.set('filter', 'status:paid');`,`try {`,` const res = await fetch(url, { method: 'GET' });`,` return res.ok ? await res.json() : { status: res.status, error: await res.text() };`,`} catch (error) {`,` return { error: error instanceof Error ? error.message : String(error) };`,`}`,"```"].join(`
4
- `);function h(e){return f.every(t=>e.includes(t))?p:m}function g(e){let t=/* @__PURE__ */ new Map;for(let{name:n,version:r}of e){if(!n)continue;let e=t.get(n)??[];r&&e.push(r),t.set(n,e)}return[...t.entries()].map(([e,t])=>t.length>1?`${e} (${t.map(e=>`v${e}`).join(`, `)})`:e).join(`, `)}const _={id:e,purpose:`Call the documented APIs over HTTP`,isActive:async e=>(await i(e)).length>0,annotations:e=>a(e)?{readOnlyHint:!0,destructiveHint:!1,openWorldHint:!0}:{readOnlyHint:!1,destructiveHint:!0,openWorldHint:!0},async renderSection(e,t){let n=g(await i(e));return["## `fetch` — call the documented APIs",``,d,``,"Always call `getEndpointInfo` before `fetch` for the exact URL, required parameters, and body shape. Put filtering, sorting, and paging in the query parameters, and keep sandbox JS for what the endpoint cannot express. Never guess.",``,"An endpoint path can hold `{placeholders}`. Fill each one from `endpoint.parameters` before you call `fetch`. Server URLs come with their variable defaults filled in. A `{placeholder}` left in a server URL has no usable default, so ask the user for its value.",``,`\`fetch\` sends only the methods this project allows: ${o(e.config.mcp).join(`, `)}. Explain any other call to the user instead of making it.`,``,`Callable APIs (their documented hosts are reachable via \`fetch\`): ${n}`,``,h(t)].join(`
5
- `)}},v=[_];async function y(e){let t=await Promise.all(v.map(t=>t.isActive(e)));return v.filter((e,n)=>t[n])}function b(e,t,n){let i=[...e.map(e=>e.annotations??{}),...t.map(e=>e.annotations(n))],a=i.filter(e=>e.readOnlyHint!==!0),o=i.some(e=>e.openWorldHint!==!1);return a.length===0?{...r,openWorldHint:o}:{readOnlyHint:!1,destructiveHint:a.some(e=>e.destructiveHint!==!1),idempotentHint:a.every(e=>e.idempotentHint===!0),openWorldHint:o}}async function x(e,r,i){let a=e.map(e=>n(e.name)),o=[];if(e.length>0){let n=t(e),r=n.includes(`OpenApi`)?`\n\n${l}`:``;o.push(`## Sandbox functions\n\nThe signatures are TypeScript declarations. ${c}\n\n${n}${r}`)}o.push(s),e.length>0&&!r.some(e=>e.id===`fetch`)&&o.push(u(a));for(let e of r)o.push(await e.renderSection(i,a));return o.join(`
4
+ `);function h(e){return f.every(t=>e.includes(t))?p:m}function g(e){let t=/* @__PURE__ */ new Map;for(let{name:n,version:r}of e){if(!n)continue;let e=t.get(n)??[];r&&e.push(r),t.set(n,e)}return[...t.entries()].map(([e,t])=>t.length>1?`${e} (${t.map(e=>`v${e}`).join(`, `)})`:e).join(`, `)}const _={id:e,purpose:`Call the documented APIs over HTTP`,isActive:async e=>(await t(e)).length>0,annotations:e=>n(e)?{readOnlyHint:!0,destructiveHint:!1,openWorldHint:!0}:{readOnlyHint:!1,destructiveHint:!0,openWorldHint:!0},async renderSection(e,n){let i=g(await t(e));return["## `fetch` — call the documented APIs",``,d,``,"Always call `getEndpointInfo` before `fetch` for the exact URL, required parameters, and body shape. Put filtering, sorting, and paging in the query parameters, and keep sandbox JS for what the endpoint cannot express. Never guess.",``,"An endpoint path can hold `{placeholders}`. Fill each one from `endpoint.parameters` before you call `fetch`. Server URLs come with their variable defaults filled in. A `{placeholder}` left in a server URL has no usable default, so ask the user for its value.",``,`\`fetch\` sends only the methods this project allows: ${r(e.config.mcp).join(`, `)}. Explain any other call to the user instead of making it.`,``,`Callable APIs (their documented hosts are reachable via \`fetch\`): ${i}`,``,h(n)].join(`
5
+ `)}},v=[_];async function y(e){let t=await Promise.all(v.map(t=>t.isActive(e)));return v.filter((e,n)=>t[n])}function b(e,t,n){let r=[...e.map(e=>e.annotations??{}),...t.map(e=>e.annotations(n))],i=r.filter(e=>e.readOnlyHint!==!0),a=r.some(e=>e.openWorldHint!==!1);return i.length===0?{...c,openWorldHint:a}:{readOnlyHint:!1,destructiveHint:i.some(e=>e.destructiveHint!==!1),idempotentHint:i.every(e=>e.idempotentHint===!0),openWorldHint:a}}async function x(e,t,n){let r=e.map(e=>u(e.name)),c=[];if(e.length>0){let t=l(e),n=t.includes(`OpenApi`)?`\n\n${a}`:``;c.push(`## Sandbox functions\n\nThe signatures are TypeScript declarations. ${s}\n\n${t}${n}`)}c.push(i),e.length>0&&!t.some(e=>e.id===`fetch`)&&c.push(o(r));for(let e of t)c.push(await e.renderSection(n,r));return c.join(`
6
6
 
7
7
  `)}export{v as ALL_CAPABILITIES,d as FETCH_DECLARATION,b as composeExecuteAnnotations,_ as fetchCapability,y as getActiveCapabilities,x as renderDiscoverOutput};
@@ -1 +1 @@
1
- import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as e,DISCOVER_TOOL_NAME as t,EXECUTE_TOOL_NAME as n,MANAGE_API_CREDENTIALS_TOOL_NAME as r,REMOVE_API_CREDENTIALS_TOOL_NAME as i,SUBMIT_FEEDBACK_TOOL_NAME as a}from"../../constants.js";const o=`fetch`,s=/* @__PURE__ */ new Set([n,t,e,r,i,a]),c=`site`,l=`tools`,u=`__fetchBridge`,d=`fetch`,f=1e4,p=45e3,m=5e4,h=1e3,g=50,_=50,v={ratePerMin:600,quotaPerDay:1e5},y=8388608,b=1048576,x=1048576,S=262144,C=67108864,w=134217728,T=16777216,E=65536,D=2,O=4,k=5e3,A=`The sandbox failed to run this code. The cause was logged on the server.`,j=`HostFunctionError`,M=`HostOutputTooLargeError`,N={NoReturn:`no_return`,OutputTooLarge:`output_too_large`,Timeout:`timeout`,MemoryLimit:`memory_limit`,SyntaxError:`syntax_error`,HostError:`host_error`,RuntimeError:`runtime_error`};export{k as ACQUIRE_TIMEOUT_MS,s as CODE_MODE_TOOL_NAMES,p as DEFAULT_MAX_LIFETIME_MS,f as DEFAULT_TIMEOUT_MS,m as EXECUTE_DEADLINE_MS,d as FETCH_BRIDGE_FUNCTION_NAME,u as FETCH_BRIDGE_GLOBAL_NAME,o as FETCH_TOOL_NAME,_ as GATEWAY_FETCH_BUDGET_PER_EXEC,v as GATEWAY_FETCH_LIMITS,j as HOST_FUNCTION_ERROR_NAME,M as HOST_OUTPUT_TOO_LARGE_ERROR_NAME,T as INITIAL_TOTAL_MEMORY_BYTES,A as INTERNAL_ERROR_MESSAGE,C as MAX_ALLOCATION_BYTES,D as MAX_CONCURRENT_RUNS,g as MAX_FETCH_CALLS,b as MAX_FETCH_OUTPUT_BYTES,O as MAX_QUEUED_RUNS,x as MAX_RESULT_BYTES,S as MAX_STACK_SIZE_BYTES,h as MAX_TOOL_CALLS,y as MAX_TOOL_OUTPUT_BYTES,w as MAX_TOTAL_MEMORY_BYTES,N as SANDBOX_FAILURE,c as SITE_GLOBAL_NAME,l as TOOLS_GLOBAL_ALIAS,E as WASM_PAGE_BYTES};
1
+ import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as e,DISCOVER_TOOL_NAME as t,EXECUTE_TOOL_NAME as n,MANAGE_API_CREDENTIALS_TOOL_NAME as r,REMOVE_API_CREDENTIALS_TOOL_NAME as i,SUBMIT_FEEDBACK_TOOL_NAME as a}from"@redocly/mcp";const o=`fetch`,s=/* @__PURE__ */ new Set([n,t,e,r,i,a]),c=`site`,l=`tools`,u=`__fetchBridge`,d=`fetch`,f=1e4,p=45e3,m=5e4,h=1e3,g=50,_=50,v={ratePerMin:600,quotaPerDay:1e5},y=8388608,b=1048576,x=262144,S=67108864,C=134217728,w=16777216,T=65536,E=2,D=4,O=5e3,k=`The sandbox failed to run this code. The cause was logged on the server.`,A=`HostFunctionError`,j=`HostOutputTooLargeError`;export{O as ACQUIRE_TIMEOUT_MS,s as CODE_MODE_TOOL_NAMES,p as DEFAULT_MAX_LIFETIME_MS,f as DEFAULT_TIMEOUT_MS,m as EXECUTE_DEADLINE_MS,d as FETCH_BRIDGE_FUNCTION_NAME,u as FETCH_BRIDGE_GLOBAL_NAME,o as FETCH_TOOL_NAME,_ as GATEWAY_FETCH_BUDGET_PER_EXEC,v as GATEWAY_FETCH_LIMITS,A as HOST_FUNCTION_ERROR_NAME,j as HOST_OUTPUT_TOO_LARGE_ERROR_NAME,w as INITIAL_TOTAL_MEMORY_BYTES,k as INTERNAL_ERROR_MESSAGE,S as MAX_ALLOCATION_BYTES,E as MAX_CONCURRENT_RUNS,g as MAX_FETCH_CALLS,b as MAX_FETCH_OUTPUT_BYTES,D as MAX_QUEUED_RUNS,x as MAX_STACK_SIZE_BYTES,h as MAX_TOOL_CALLS,y as MAX_TOOL_OUTPUT_BYTES,C as MAX_TOTAL_MEMORY_BYTES,c as SITE_GLOBAL_NAME,l as TOOLS_GLOBAL_ALIAS,T as WASM_PAGE_BYTES};
@@ -1,3 +1,3 @@
1
- import{DISCOVER_TOOL_NAME as e}from"../../constants.js";import{UnknownToolError as t}from"../tool-errors.js";import{sanitizeToolName as n}from"./tool-declarations.js";import{READ_ONLY_ANNOTATIONS as r}from"../tools/schemas.js";import{buildDiscoverDescription as i}from"./prompts.js";import{renderDiscoverOutput as a}from"./capabilities.js";function o(t,a,o=!0){let s=[.../* @__PURE__ */ new Set([...t.map(e=>n(e.name)),...a.map(e=>n(e.id))])];return{name:e,title:`Get docs function signatures`,description:i(o),annotations:r,schema:{type:`object`,required:[],additionalProperties:!1,properties:{names:{type:`array`,description:o?`Names of the sandbox functions to discover: ${s.join(`, `)}. Omit to discover all of them.`:`Names of the sandbox functions to discover. Omit to discover all of them.`,items:s.length>0?{type:`string`,enum:s}:{type:`string`},nullable:!0}}}}}function s(e,r,i,o){let s=new Map(e.map(e=>[n(e.name),e])),c=new Set(i.map(e=>n(e.id)));return async l=>{let u=[...new Set((l.names??[]).map(n))],d=u.filter(e=>!s.has(e)&&!c.has(e));if(d.length>0){let e=[...s.keys(),...c];throw new t(`Unknown function name(s): ${d.join(`, `)}. Valid names: ${e.join(`, `)}.`)}let f=u.length===0?i:i.filter(e=>u.includes(n(e.id))),p=u.length===0?e:u.filter(e=>s.has(e)).map(e=>s.get(e)),m=await Promise.all(p.map(e=>r(e.name))),h=p.filter((e,t)=>m[t]),g=p.filter((e,t)=>!m[t]),_=[await a(h,f,o)];return g.length>0&&_.push(`Not available for this request: ${g.map(e=>n(e.name)).join(`, `)}`),{content:[{type:`text`,text:_.join(`
1
+ import{UnknownToolError as e}from"../tool-errors.js";import{buildDiscoverDescription as t}from"./prompts.js";import{renderDiscoverOutput as n}from"./capabilities.js";import{DISCOVER_TOOL_NAME as r,READ_ONLY_ANNOTATIONS as i,sanitizeToolName as a}from"@redocly/mcp";function o(e,n,o=!0){let s=[.../* @__PURE__ */ new Set([...e.map(e=>a(e.name)),...n.map(e=>a(e.id))])];return{name:r,title:`Get docs function signatures`,description:t(o),annotations:i,schema:{type:`object`,required:[],additionalProperties:!1,properties:{names:{type:`array`,description:o?`Names of the sandbox functions to discover: ${s.join(`, `)}. Omit to discover all of them.`:`Names of the sandbox functions to discover. Omit to discover all of them.`,items:s.length>0?{type:`string`,enum:s}:{type:`string`},nullable:!0}}}}}function s(t,r,i,o){let s=new Map(t.map(e=>[a(e.name),e])),c=new Set(i.map(e=>a(e.id)));return async l=>{let u=[...new Set((l.names??[]).map(a))],d=u.filter(e=>!s.has(e)&&!c.has(e));if(d.length>0){let t=[...s.keys(),...c];throw new e(`Unknown function name(s): ${d.join(`, `)}. Valid names: ${t.join(`, `)}.`)}let f=u.length===0?i:i.filter(e=>u.includes(a(e.id))),p=u.length===0?t:u.filter(e=>s.has(e)).map(e=>s.get(e)),m=await Promise.all(p.map(e=>r(e.name))),h=p.filter((e,t)=>m[t]),g=p.filter((e,t)=>!m[t]),_=[await n(h,f,o)];return g.length>0&&_.push(`Not available for this request: ${g.map(e=>a(e.name)).join(`, `)}`),{content:[{type:`text`,text:_.join(`
2
2
 
3
3
  `)}]}}}export{s as discover,o as discoverSchema};
@@ -1 +1 @@
1
- import{EXECUTE_TOOL_NAME as e}from"../../constants.js";import{buildExecuteDescription as t}from"./prompts.js";const n=`Execute code`;function r(e){return e.readOnlyHint?`Query the docs with code`:n}const i={name:e,title:n,description:t(!1),schema:{type:`object`,required:[`code`,`description`],additionalProperties:!1,properties:{code:{type:`string`,description:`JavaScript to run in the sandbox. Return a value to receive it as the result.`,minLength:1},description:{type:`string`,description:`A short, human-readable summary of what this code does.`,minLength:1},sessionHandle:{type:`string`,description:`Handle returned by createAnonymousSession. Required when an API needs credentials. This parameter is only offered when createAnonymousSession is available, so pass it whenever you have called that tool.`,minLength:1}}},outputSchema:{type:`object`,properties:{result:{description:`The value the code returned, as JSON`},error:{type:`string`,description:`Why the code failed. Set only on a failed call`},sentFetches:{type:`array`,description:"Every `fetch` request that reached an API before the failure, with its status; running the code again sends them again. Set only on a failed call",items:{type:`object`,properties:{method:{type:`string`},url:{type:`string`},status:{type:`number`,description:`Unset when no response arrived`}}}}}}};export{i as EXECUTE_TOOL_SCHEMA,r as executeToolTitle};
1
+ import{buildExecuteDescription as e}from"./prompts.js";import{EXECUTE_TOOL_NAME as t}from"@redocly/mcp";const n=`Execute code`;function r(e){return e.readOnlyHint?`Query the docs with code`:n}const i={name:t,title:n,description:e(!1),schema:{type:`object`,required:[`code`,`description`],additionalProperties:!1,properties:{code:{type:`string`,description:`JavaScript to run in the sandbox. Return a value to receive it as the result.`,minLength:1},description:{type:`string`,description:`A short, human-readable summary of what this code does.`,minLength:1},sessionHandle:{type:`string`,description:`Handle returned by createAnonymousSession. Required when an API needs credentials. This parameter is only offered when createAnonymousSession is available, so pass it whenever you have called that tool.`,minLength:1}}}},a={result:{description:`The value the code returned, as JSON`},error:{type:`string`,description:`Why the code failed. Set only on a failed call`}},o={type:`array`,description:"Every `fetch` request that reached an API before the failure, with its status; running the code again sends them again. Set only on a failed call",items:{type:`object`,properties:{method:{type:`string`},url:{type:`string`},status:{type:`number`,description:`Unset when no response arrived`}}}};function s(e){return{type:`object`,properties:e?{...a,sentFetches:o}:a}}export{i as EXECUTE_TOOL_SCHEMA,s as executeOutputSchema,r as executeToolTitle};
@@ -1 +1 @@
1
- import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{formatError as t,innerToolErrorClass as n}from"../tool-errors.js";import{auditCode as r,callAttribution as i,logCodeExecutionAudit as a,logMcpToolCallAudit as o,toolOutputText as s,toolResultText as c}from"../audit.js";import{CODE_MODE_TOOL_NAMES as l,INTERNAL_ERROR_MESSAGE as u,SANDBOX_FAILURE as d}from"./constants.js";import{availableTools as f}from"../tool-registry.js";import{sanitizeToolName as p}from"./tool-declarations.js";import{SandboxBusyError as m,sandboxAdmission as h}from"./admission.js";import{authoredPosition as g,returnLastExpression as _}from"./return-last-expression.js";import{createSandboxSetup as v}from"./sandbox-setup.js";import{createToolInputValidator as y}from"./tool-input-validator.js";import{describeGuestError as b}from"./unknown-tool-hint.js";import{isCallToolResult as x}from"@modelcontextprotocol/server";async function S(e){let{code:n,registry:o,ctx:s,timeoutMs:c}=e,y=await f(o,s),x=s.telemetry?.trackCodeExecution(n,e.hostFetch),S=x?.hostFetch??e.hostFetch,w=Object.create(null);for(let e of y){if(l.has(e.schema.name))continue;let t=p(e.schema.name);w[t]=C(e,t,s,x)}let T=Object.keys(w);a(s.logger,{audit:r(n),code:n,description:e.description??``,sessionHandle:e.sessionHandle,toolNames:T,fetchBudget:e.fetchBudget,fetchCapable:S!==void 0,...i(s)});let E=_(n),D;try{let{runInSandbox:e}=await import(`./sandbox.js`);D=await h.run(()=>e(E.code,{setupContext:v(w,S),authoredCode:n,timeoutMs:c,deadline:s.executeDeadline,logger:s.logger}))}catch(e){e instanceof m?D={error:e.message}:(s.logger?.error(`MCP code mode failed before a result: ${t(e)}`),D={error:u,failure:d.RuntimeError})}let O=D.error===void 0?void 0:b(n,D.error,D.errorPosition&&g(E,D.errorPosition),T,D.failure),k=O===void 0?{result:D.result}:{error:O.message},A={content:[{type:`text`,text:JSON.stringify(k)}],structuredContent:k,isError:O!==void 0};return x?.finish(D,A,O?.unknownTool),A}function C(e,r,a,l){let{name:u}=e.schema,d=y(r,e.schema.schema),f={tool:u,mode:`code`,...i(a)},p=async r=>{let i=w(r,e.inputAliases),l=d(i);if(l)throw Error(l);let p;try{p=await e.execute(i,a)}catch(e){throw a.logger?.warn(`MCP tool "${u}" failed in code mode: ${t(e)}`),o(a.logger,{...f,args:r,errorClass:n(e)}),e}let m=x(p)&&p.isError===!0?p:void 0;if(o(a.logger,{...f,args:r,result:s(p),errorClass:m?`tool_error`:void 0}),m)throw Error(c(m));return p};return async e=>T(await(l?l.innerToolCall(u,()=>p(e)):p(e)))}function w(t,n){if(!n||!e(t))return t;let r={...t};for(let[e,t]of Object.entries(n))e in r&&(r[t]??=r[e],delete r[e]);return r}function T(e){if(!x(e))return e;if(e.structuredContent!==void 0)return e.structuredContent;let t=c(e);try{return JSON.parse(t)}catch{return t}}export{S as runCodeMode};
1
+ import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{formatError as t,innerToolErrorClass as n}from"../tool-errors.js";import{auditCode as r,callAttribution as i,logCodeExecutionAudit as a,logMcpToolCallAudit as o,toolOutputText as s,toolResultText as c}from"../audit.js";import{CODE_MODE_TOOL_NAMES as l,INTERNAL_ERROR_MESSAGE as u}from"./constants.js";import{availableTools as d}from"../tool-registry.js";import{SandboxBusyError as f,sandboxAdmission as p}from"./admission.js";import{createSandboxSetup as m}from"./sandbox-setup.js";import{createToolInputValidator as h}from"./tool-input-validator.js";import{SANDBOX_FAILURE as g,authoredPosition as _,describeGuestError as v,returnLastExpression as y,sanitizeToolName as b}from"@redocly/mcp";import{isCallToolResult as x}from"@modelcontextprotocol/server";async function S(e){let{code:n,registry:o,ctx:s,timeoutMs:c}=e,h=await d(o,s),x=s.telemetry?.trackCodeExecution(n,e.hostFetch),S=x?.hostFetch??e.hostFetch,w=Object.create(null);for(let e of h){if(l.has(e.schema.name))continue;let t=b(e.schema.name);w[t]=C(e,t,s,x)}let T=Object.keys(w);a(s.logger,{audit:r(n),code:n,description:e.description??``,sessionHandle:e.sessionHandle,toolNames:T,fetchBudget:e.fetchBudget,fetchCapable:S!==void 0,...i(s)});let E=y(n),D;try{let{runInSandbox:e}=await import(`./sandbox.js`);D=await p.run(()=>e(E.code,{setupContext:m(w,S),authoredCode:n,timeoutMs:c,deadline:s.executeDeadline,logger:s.logger}))}catch(e){e instanceof f?D={error:e.message}:(s.logger?.error(`MCP code mode failed before a result: ${t(e)}`),D={error:u,failure:g.RuntimeError})}let O=D.error===void 0?void 0:v(n,D.error,D.errorPosition&&_(E,D.errorPosition),T,D.failure),k=O===void 0?{result:D.result}:{error:O.message},A={content:[{type:`text`,text:JSON.stringify(k)}],structuredContent:k,isError:O!==void 0};return x?.finish(D,A,O?.unknownTool),A}function C(e,r,a,l){let{name:u}=e.schema,d=h(r,e.schema.schema),f={tool:u,mode:`code`,...i(a)},p=async r=>{let i=w(r,e.inputAliases),l=d(i);if(l)throw Error(l);let p;try{p=await e.execute(i,a)}catch(e){throw a.logger?.warn(`MCP tool "${u}" failed in code mode: ${t(e)}`),o(a.logger,{...f,args:r,errorClass:n(e)}),e}let m=x(p)&&p.isError===!0?p:void 0;if(o(a.logger,{...f,args:r,result:s(p),errorClass:m?`tool_error`:void 0}),m)throw Error(c(m));return p};return async e=>T(await(l?l.innerToolCall(u,()=>p(e)):p(e)))}function w(t,n){if(!n||!e(t))return t;let r={...t};for(let[e,t]of Object.entries(n))e in r&&(r[t]??=r[e],delete r[e]);return r}function T(e){if(!x(e))return e;if(e.structuredContent!==void 0)return e.structuredContent;let t=c(e);try{return JSON.parse(t)}catch{return t}}export{S as runCodeMode};
@@ -1,8 +1,8 @@
1
- import{buildToolList as e}from"./tool-list.js";const t=2048,n="Both `execute` arguments are required: `code` (the JavaScript to run; return a value to receive it) and `description` (a short human-readable summary of what the code does).",r="Write plain JavaScript: no type annotations, interfaces or `as` casts.";function i(n,r){if(r.length===0)return n;let i=t-n.length-66-3,a=e(r,i);return a?[n,``,"Functions for `execute` scripts (signatures come from `discover`):",a].join(`
2
- `):n}function a(e,t){return[t?`Run plain JavaScript (no TypeScript syntax) in a sandbox against the documentation at ${t}. The script calls the sandbox functions on the global \`site\` object.`:"Run plain JavaScript (no TypeScript syntax) in a sandbox against this documentation site. The script calls the sandbox functions on the global `site` object.",e?"The extra globals are `site`, `fetch`, `URL`, `URLSearchParams`, and `FormData` - there is no `console`, `setTimeout`, `require`, or Node.js API; all other I/O goes through `site`.":"The only extra global is `site` - there is no `fetch`, `console`, `setTimeout`, `require`, or Node.js API; all I/O goes through `site`.",``,"Workflow - minimize round-trips; one `discover` call plus one `execute` call covers most requests:",`1. Analyze the request and decide which sandbox functions it needs.`,"2. Call `discover` with those names to get their exact TypeScript signatures - inputs, result shapes, and a worked example. NEVER call `execute` with guessed function names, parameter names, enum values, or result field names: read fields off the declared return types, not from assumptions.","3. Batch everything into a SINGLE script: chain function calls, pass one call's output into the next, process results in plain JavaScript, and `return` only what the request needs."].join(`
3
- `)}function o(e,n){let r=e&&n(e);return r&&r.length<=t?r:n()}function s(e,t=[],n){return i(o(n,t=>a(e,t)),t)}function c(e){return e?`Tools for the documentation at ${e}.`:`Tools for this documentation site.`}function l(e){return`${c(e)} Use them to answer questions about the content of these docs.`}function u(e){return o(e,l)}function d(e){return["Get the exact TypeScript signatures of the sandbox functions that `execute` scripts can call.",`Analyze the user request first, then pass \`names\` with only the functions the request needs (${e?`every name is listed in this input schema / description`:`every name is in the enum of this input schema`}); omit \`names\` only when you cannot tell which functions apply.`,"Always call this before your first `execute` and never guess signatures. Request every function the task may need in ONE call instead of calling this repeatedly."].join(`
4
- `)}function f(e,t){let n=[l(t),"- `discover` returns the exact TypeScript signatures of the sandbox functions.","- `execute` runs a JavaScript script that calls those functions on the global `site` object.","Workflow: analyze the request, call `discover` once with `names` set to only the functions it needs, then batch everything into a single `execute` script. Minimize round-trips and never guess function signatures."];return e&&n.push("The sandbox also has a global `fetch` that can call the documented APIs (allow-listed hosts only). Include `fetch` in your `discover` call to get its contract and the list of callable APIs."),n.join(`
5
- `)}function p(e,t=[],n){return i(o(n,t=>f(e,t)),t)}const m=[`listApis`,`getEndpoints`],h=[`Example - list the write endpoints of an API:`,``,"```js",`const { items } = await site.listApis({ filter: 'billing' });`,`const [api] = items;`,`if (!api) return { error: 'no API matches "billing"' };`,`const { endpoints } = await site.getEndpoints({ name: api.name });`,`const writes = endpoints.filter((e) => e.method !== 'GET');`,"return { api: api.name, writes: writes.map((e) => `${e.method} ${e.path}`) };","```"].join(`
6
- `);function g(e){if(m.every(t=>e.includes(t)))return h;let[t]=e;return t?[`Example - call \`${t}\` and return what the request needs:`,``,"```js",`const result = await site.${t}({ /* the input its signature above declares */ });`,`return result;`,"```"].join(`
7
- `):``}const _=["Types named `OpenApi…` are the standard OpenAPI Specification objects.","Payload samples live on a media type object (`requestBody.content[mediaType]`, `responses[code].content[mediaType]`): `.example` holds a single value, `.examples[name].value` a named map, and some descriptions only set `.schema.example`. Read each before concluding a sample is absent."].join(`
8
- `);export{n as EXECUTE_ARGS_NOTE,r as PLAIN_JAVASCRIPT_RULE,_ as USAGE_NOTES,p as buildCodeModeInstructions,d as buildDiscoverDescription,s as buildExecuteDescription,g as buildExecuteExample,u as buildToolsModeInstructions,c as docsSiteSentence};
1
+ import{buildToolList as e}from"./tool-list.js";const t=2048,n="Both `execute` arguments are required: `code` (the JavaScript to run; return a value to receive it) and `description` (a short human-readable summary of what the code does).";function r(n,r){if(r.length===0)return n;let i=t-n.length-66-3,a=e(r,i);return a?[n,``,"Functions for `execute` scripts (signatures come from `discover`):",a].join(`
2
+ `):n}function i(e,t){return[t?`Run plain JavaScript (no TypeScript syntax) in a sandbox against the documentation at ${t}. The script calls the sandbox functions on the global \`site\` object.`:"Run plain JavaScript (no TypeScript syntax) in a sandbox against this documentation site. The script calls the sandbox functions on the global `site` object.",e?"The extra globals are `site`, `fetch`, `URL`, `URLSearchParams`, and `FormData` - there is no `console`, `setTimeout`, `require`, or Node.js API; all other I/O goes through `site`.":"The only extra global is `site` - there is no `fetch`, `console`, `setTimeout`, `require`, or Node.js API; all I/O goes through `site`.",``,"Workflow - minimize round-trips; one `discover` call plus one `execute` call covers most requests:",`1. Analyze the request and decide which sandbox functions it needs.`,"2. Call `discover` with those names to get their exact TypeScript signatures - inputs, result shapes, and a worked example. NEVER call `execute` with guessed function names, parameter names, enum values, or result field names: read fields off the declared return types, not from assumptions.","3. Batch everything into a SINGLE script: chain function calls, pass one call's output into the next, process results in plain JavaScript, and `return` only what the request needs."].join(`
3
+ `)}function a(e,n){let r=e&&n(e);return r&&r.length<=t?r:n()}function o(e,t=[],n){return r(a(n,t=>i(e,t)),t)}function s(e){return e?`Tools for the documentation at ${e}.`:`Tools for this documentation site.`}function c(e){return`${s(e)} Use them to answer questions about the content of these docs.`}function l(e){return a(e,c)}function u(e){return["Get the exact TypeScript signatures of the sandbox functions that `execute` scripts can call.",`Analyze the user request first, then pass \`names\` with only the functions the request needs (${e?`every name is listed in this input schema / description`:`every name is in the enum of this input schema`}); omit \`names\` only when you cannot tell which functions apply.`,"Always call this before your first `execute` and never guess signatures. Request every function the task may need in ONE call instead of calling this repeatedly."].join(`
4
+ `)}function d(e,t){let n=[c(t),"- `discover` returns the exact TypeScript signatures of the sandbox functions.","- `execute` runs a JavaScript script that calls those functions on the global `site` object.","Workflow: analyze the request, call `discover` once with `names` set to only the functions it needs, then batch everything into a single `execute` script. Minimize round-trips and never guess function signatures."];return e&&n.push("The sandbox also has a global `fetch` that can call the documented APIs (allow-listed hosts only). Include `fetch` in your `discover` call to get its contract and the list of callable APIs."),n.join(`
5
+ `)}function f(e,t=[],n){return r(a(n,t=>d(e,t)),t)}const p=[`listApis`,`getEndpoints`],m=[`Example - list the write endpoints of an API:`,``,"```js",`const { items } = await site.listApis({ filter: 'billing' });`,`const [api] = items;`,`if (!api) return { error: 'no API matches "billing"' };`,`const { endpoints } = await site.getEndpoints({ name: api.name });`,`const writes = endpoints.filter((e) => e.method !== 'GET');`,"return { api: api.name, writes: writes.map((e) => `${e.method} ${e.path}`) };","```"].join(`
6
+ `);function h(e){if(p.every(t=>e.includes(t)))return m;let[t]=e;return t?[`Example - call \`${t}\` and return what the request needs:`,``,"```js",`const result = await site.${t}({ /* the input its signature above declares */ });`,`return result;`,"```"].join(`
7
+ `):``}const g=["Types named `OpenApi…` are the standard OpenAPI Specification objects.","Payload samples live on a media type object (`requestBody.content[mediaType]`, `responses[code].content[mediaType]`): `.example` holds a single value, `.examples[name].value` a named map, and some descriptions only set `.schema.example`. Read each before concluding a sample is absent."].join(`
8
+ `);export{n as EXECUTE_ARGS_NOTE,g as USAGE_NOTES,f as buildCodeModeInstructions,u as buildDiscoverDescription,o as buildExecuteDescription,h as buildExecuteExample,l as buildToolsModeInstructions,s as docsSiteSentence};
@@ -1 +1 @@
1
- import{errorMessage as e}from"../../../../../../shared/utils/error-message.js";import{formatError as t}from"../tool-errors.js";import{DEFAULT_MAX_LIFETIME_MS as n,DEFAULT_TIMEOUT_MS as r,INITIAL_TOTAL_MEMORY_BYTES as i,INTERNAL_ERROR_MESSAGE as a,MAX_ALLOCATION_BYTES as o,MAX_STACK_SIZE_BYTES as s,MAX_TOTAL_MEMORY_BYTES as c,SANDBOX_FAILURE as l,WASM_PAGE_BYTES as u}from"./constants.js";import{createExecutionBudget as d}from"./execution-budget.js";import{readResult as f}from"./read-result.js";import{returnsFromTopLevel as p}from"./returns-from-top-level.js";import m from"@jitl/quickjs-singlefile-mjs-release-sync";import{newQuickJSWASMModuleFromVariant as h,newVariant as g}from"quickjs-emscripten-core";var _=class extends Error{guestError;name=`ReportableError`;constructor(e,t){super(e),this.guestError=t}};function v(t){try{return t()}catch(t){throw new _(e(t),w(t))}}let y;function b(){return y??=h(g(m,{wasmMemory:new WebAssembly.Memory({initial:i/u,maximum:c/u})}))}async function x(e,i={}){let{timeoutMs:c=r,deadline:u=Date.now()+n,setupContext:m,authoredCode:h=e,logger:g}=i,x,C,w,D,O;try{let t=x=(await b()).newContext();t.runtime.setMemoryLimit(o),t.runtime.setMaxStackSize(s),C=d(t,c,u),O=t.unwrapResult(t.evalCode(`JSON.stringify`)),w=m?.(t,C)??void 0,D=v(()=>t.unwrapResult(t.evalCode(`(async () => {\n${e}\n})()`,S)));let n=t.resolvePromise(D);t.runtime.executePendingJobs();let r=await Promise.race([n,C.aborted]),i=v(()=>t.unwrapResult(r));if(t.typeof(i)===`undefined`)return i.dispose(),{error:p(t,h)?"The code returned undefined: the `return` ran but produced no value. Read fields off the declared return types — a field name that does not exist reads as undefined — and do not `return;` or `return undefined`.":"The code returned undefined because nothing was returned. Add a top-level `return` of the value to send back.",failure:l.NoReturn};let a=f(t,O,i);if(a.error===void 0)return a;let g=C.expiredMessage();return g===void 0?a:{error:g,failure:l.Timeout}}catch(e){let n=C?.expiredMessage();return n===void 0?e instanceof _?{error:e.message,failure:T(e.guestError,D!==void 0),errorPosition:E(e.guestError.stack)}:(g?.error(`MCP code mode sandbox failed: ${t(e)}`),{error:a,failure:l.RuntimeError}):{error:n,failure:l.Timeout}}finally{C?.dispose(),D?.dispose(),O?.dispose();try{w?.()}catch{}try{x?.dispose()}catch{y=void 0}}}const S=`sandbox-code.js`,C=/sandbox-code\.js:(\d+):(\d+)/;function w(e){let{cause:t}=e;return typeof t==`object`&&t?t:{}}function T({name:e,message:t},n){return e===`InternalError`&&t===`out of memory`?l.MemoryLimit:e===`SyntaxError`&&!n?l.SyntaxError:e===`HostOutputTooLargeError`?l.OutputTooLarge:e===`HostFunctionError`?l.HostError:l.RuntimeError}function E(e){let t=typeof e==`string`?C.exec(e):null;if(!t)return;let n=Number(t[1])-1;return n>=1?{line:n,column:Number(t[2])}:void 0}export{x as runInSandbox};
1
+ import{errorMessage as e}from"../../../../../../shared/utils/error-message.js";import{formatError as t}from"../tool-errors.js";import{DEFAULT_MAX_LIFETIME_MS as n,DEFAULT_TIMEOUT_MS as r,INITIAL_TOTAL_MEMORY_BYTES as i,INTERNAL_ERROR_MESSAGE as a,MAX_ALLOCATION_BYTES as o,MAX_STACK_SIZE_BYTES as s,MAX_TOTAL_MEMORY_BYTES as c,WASM_PAGE_BYTES as l}from"./constants.js";import{SANDBOX_FAILURE as u,createExecutionBudget as d,readResult as f,returnsFromTopLevel as p}from"@redocly/mcp";import m from"@jitl/quickjs-singlefile-mjs-release-sync";import{newQuickJSWASMModuleFromVariant as h,newVariant as g}from"quickjs-emscripten-core";var _=class extends Error{guestError;name=`ReportableError`;constructor(e,t){super(e),this.guestError=t}};function v(t){try{return t()}catch(t){throw new _(e(t),w(t))}}let y;function b(){return y??=h(g(m,{wasmMemory:new WebAssembly.Memory({initial:i/l,maximum:c/l})}))}async function x(e,i={}){let{timeoutMs:c=r,deadline:l=Date.now()+n,setupContext:m,authoredCode:h=e,logger:g}=i,x,C,w,D,O;try{let t=x=(await b()).newContext();t.runtime.setMemoryLimit(o),t.runtime.setMaxStackSize(s),C=d(t,c,l),O=t.unwrapResult(t.evalCode(`JSON.stringify`)),w=m?.(t,C)??void 0,D=v(()=>t.unwrapResult(t.evalCode(`(async () => {\n${e}\n})()`,S)));let n=t.resolvePromise(D);t.runtime.executePendingJobs();let r=await Promise.race([n,C.aborted]),i=v(()=>t.unwrapResult(r));if(t.typeof(i)===`undefined`)return i.dispose(),{error:p(t,h)?"The code returned undefined: the `return` ran but produced no value. Read fields off the declared return types — a field name that does not exist reads as undefined — and do not `return;` or `return undefined`.":"The code returned undefined because nothing was returned. Add a top-level `return` of the value to send back.",failure:u.NoReturn};let a=f(t,O,i);if(a.error===void 0)return a;let g=C.expiredMessage();return g===void 0?a:{error:g,failure:u.Timeout}}catch(e){let n=C?.expiredMessage();return n===void 0?e instanceof _?{error:e.message,failure:T(e.guestError,D!==void 0),errorPosition:E(e.guestError.stack)}:(g?.error(`MCP code mode sandbox failed: ${t(e)}`),{error:a,failure:u.RuntimeError}):{error:n,failure:u.Timeout}}finally{C?.dispose(),D?.dispose(),O?.dispose();try{w?.()}catch{}try{x?.dispose()}catch{y=void 0}}}const S=`sandbox-code.js`,C=/sandbox-code\.js:(\d+):(\d+)/;function w(e){let{cause:t}=e;return typeof t==`object`&&t?t:{}}function T({name:e,message:t},n){return e===`InternalError`&&t===`out of memory`?u.MemoryLimit:e===`SyntaxError`&&!n?u.SyntaxError:e===`HostOutputTooLargeError`?u.OutputTooLarge:e===`HostFunctionError`?u.HostError:u.RuntimeError}function E(e){let t=typeof e==`string`?C.exec(e):null;if(!t)return;let n=Number(t[1])-1;return n>=1?{line:n,column:Number(t[2])}:void 0}export{x as runInSandbox};
@@ -1,2 +1,2 @@
1
- import{sanitizeToolName as e}from"./tool-declarations.js";import{mcpToolRegistry as t}from"../registry-instance.js";function n(n,r){return[...n.map(n=>({name:e(n.name),purpose:n.summary??n.description,builtIn:t.get(n.name)!==void 0})),...r.map(t=>({name:e(t.id),purpose:t.purpose,builtIn:!0}))]}function r(e,t){if(e.length===0||t<=0)return``;let n=e.map(e=>({...e,purpose:(e.purpose??``).replace(/\s+/g,` `).trim()}));for(let e of i()){let r=a(n,e);if(r.length<=t)return r}let r=e.map(e=>e.name),o=r.join(`, `);return o.length<=t?o:s(r,t)}function*i(){for(let e=60;e>=40;e--)yield{builtIn:e,custom:60};for(let e=60;e>=20;e--)yield{builtIn:0,custom:e}}function a(e,t){return e.map(({name:e,purpose:n,builtIn:r})=>{let i=r?t.builtIn:t.custom;return n&&i>0?`- ${e} — ${o(n,i)}`:`- ${e}`}).join(`
1
+ import{mcpToolRegistry as e}from"../registry-instance.js";import{sanitizeToolName as t}from"@redocly/mcp";function n(n,r){return[...n.map(n=>({name:t(n.name),purpose:n.summary??n.description,builtIn:e.get(n.name)!==void 0})),...r.map(e=>({name:t(e.id),purpose:e.purpose,builtIn:!0}))]}function r(e,t){if(e.length===0||t<=0)return``;let n=e.map(e=>({...e,purpose:(e.purpose??``).replace(/\s+/g,` `).trim()}));for(let e of i()){let r=a(n,e);if(r.length<=t)return r}let r=e.map(e=>e.name),o=r.join(`, `);return o.length<=t?o:s(r,t)}function*i(){for(let e=60;e>=40;e--)yield{builtIn:e,custom:60};for(let e=60;e>=20;e--)yield{builtIn:0,custom:e}}function a(e,t){return e.map(({name:e,purpose:n,builtIn:r})=>{let i=r?t.builtIn:t.custom;return n&&i>0?`- ${e} — ${o(n,i)}`:`- ${e}`}).join(`
2
2
  `)}function o(e,t){return e.length<=t?e:`${e.slice(0,t-1).replace(/[\uD800-\uDBFF]$/,``).trimEnd()}…`}function s(e,t){let n=[];for(let r of e){if([...n,r].join(`, `).length+c(e.length-n.length-1).length>t)break;n.push(r)}return n.length>0?`${n.join(`, `)}${c(e.length-n.length)}`:``}function c(e){return e>0?` … (+${e} more)`:``}export{r as buildToolList,n as toToolListEntries};
@@ -1 +1 @@
1
- import{OPERATION_METHODS as e,isEndpointHidden as t}from"../tools/openapi-document.js";import{basePathPrefix as n,operationHttpMethod as r,pathPattern as i,pathTemplateKey as a,pathVariableCount as o}from"./route-pattern.js";const s=new Set(e);function c(e){return t(e,`apiCalls`)||t(e,`docs`)}function l(e,t,a,l=[]){let d=n(a),f=new Set(l.map(({method:e,path:t})=>u(e&&r(e),t))),p=[];for(let[n,a]of Object.entries(e.paths??{})){if(!a||typeof a!=`object`)continue;let e=i(d,n);if(!e)continue;let l=c(a)||f.has(u(void 0,n)),m=t.paths?.[n],h=o(n);for(let[t,i]of Object.entries(a)){if(!s.has(t.toLowerCase())||!i||typeof i!=`object`)continue;let a=r(t);p.push({pattern:e,method:a,callable:!l&&!c(i)&&!f.has(u(a,n)),visible:!!m?.[t],variables:h})}}return p}function u(e,t){return`${e??`*`} ${a(t)}`}function d(e,t,n){return e.filter(e=>e.method===n&&e.pattern.test(t))}export{l as apiCallOperationsOf,d as matchingApiCallOperations};
1
+ import{isEndpointHidden as e}from"../tools/openapi-document.js";import{basePathPrefix as t,operationHttpMethod as n,pathPattern as r,pathTemplateKey as i,pathVariableCount as a}from"./route-pattern.js";import{OPERATION_METHODS as o}from"@redocly/mcp";const s=new Set(o);function c(t){return e(t,`apiCalls`)||e(t,`docs`)}function l(e,i,o,l=[]){let d=t(o),f=new Set(l.map(({method:e,path:t})=>u(e&&n(e),t))),p=[];for(let[t,o]of Object.entries(e.paths??{})){if(!o||typeof o!=`object`)continue;let e=r(d,t);if(!e)continue;let l=c(o)||f.has(u(void 0,t)),m=i.paths?.[t],h=a(t);for(let[r,i]of Object.entries(o)){if(!s.has(r.toLowerCase())||!i||typeof i!=`object`)continue;let a=n(r);p.push({pattern:e,method:a,callable:!l&&!c(i)&&!f.has(u(a,t)),visible:!!m?.[r],variables:h})}}return p}function u(e,t){return`${e??`*`} ${i(t)}`}function d(e,t,n){return e.filter(e=>e.method===n&&e.pattern.test(t))}export{l as apiCallOperationsOf,d as matchingApiCallOperations};
@@ -1 +1 @@
1
- import{APP_DATA_ENTITY_KEY as e}from"../../../../../../../shared/constants/app-data.js";import{parseSrcSet as t}from"../../../../assets/srcset.js";import{MCP_CREDENTIALS_THEME_ENTITY_KEY as n}from"../../../../../../../shared/constants/mcp.js";import{toAppData as r}from"../../../../../../../shared/utils/app-data.js";import{publicOrigin as i}from"../../../../../utils/request-origin.js";async function a(t){let a=r(await t.entities.load(e)),s=o({seo:t.config.seo,logo:a.theme?.logo,colorMode:t.config.colorMode}),c=await t.entities.get(`mcp:credentials-theme`)?await t.entities.load(n):void 0;return{...s,...c?{theme:c}:{},host:new URL(i(t.request)).host}}function o({seo:e,logo:n,colorMode:r}){let i={},a=e?.title||e?.projectTitle||n?.altText;a&&(i.name=a);let o=new Map((n?.srcSet?t(n.srcSet)??[]:[]).map(({src:e,descriptor:t})=>[t.trim(),e])),l=c(o.get(`light`)??n?.image),u=c(o.get(`dark`));l&&(i.logo=u?{light:l,dark:u}:{light:l});let d=s(r);return d&&(i.colorScheme=d),i}function s(e){if(e?.hide)return`light`;if(e?.ignoreDetection)return e.modes?.[0]===`dark`?`dark`:`light`}function c(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:void 0}export{a as loadPageSite,o as resolveSiteBranding};
1
+ import{APP_DATA_ENTITY_KEY as e}from"../../../../../../../shared/constants/app-data.js";import{toAppData as t}from"../../../../../../../shared/utils/app-data.js";import{parseSrcSet as n}from"../../../../assets/srcset.js";import{MCP_CREDENTIALS_THEME_ENTITY_KEY as r}from"../../../../../../../shared/constants/mcp.js";import{publicOrigin as i}from"../../../../../utils/request-origin.js";async function a(n){let a=t(await n.entities.load(e)),s=o({seo:n.config.seo,logo:a.theme?.logo,colorMode:n.config.colorMode}),c=await n.entities.get(`mcp:credentials-theme`)?await n.entities.load(r):void 0;return{...s,...c?{theme:c}:{},host:new URL(i(n.request)).host}}function o({seo:e,logo:t,colorMode:r}){let i={},a=e?.title||e?.projectTitle||t?.altText;a&&(i.name=a);let o=new Map((t?.srcSet?n(t.srcSet)??[]:[]).map(({src:e,descriptor:t})=>[t.trim(),e])),l=c(o.get(`light`)??t?.image),u=c(o.get(`dark`));l&&(i.logo=u?{light:l,dark:u}:{light:l});let d=s(r);return d&&(i.colorScheme=d),i}function s(e){if(e?.hide)return`light`;if(e?.ignoreDetection)return e.modes?.[0]===`dark`?`dark`:`light`}function c(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:void 0}export{a as loadPageSite,o as resolveSiteBranding};
@@ -1 +1 @@
1
- import{SystemRoute as e}from"../../../../../../server/constants/system-routes.js";import{withPathPrefix as t}from"../../../../../../shared/path-prefix.js";import{FORM_ACTIONS as n}from"./credentials-page/constants.js";import{userSubject as r}from"./subject.js";import{rejectCredential as i}from"./credential-validation.js";import{credentialSchemesOf as a,schemeFieldName as o}from"./credentials-page/form-contract.js";import{secretStore as s}from"./secret-store.js";import{htmlDocument as c}from"./credentials-page/layout.js";import{formPage as l}from"./credentials-page/form-page.js";import{declinedPage as u,expiredPage as d,otherAccountPage as f,outcomePage as p,signInPage as m}from"./credentials-page/outcome-pages.js";import{loadPageSite as h}from"./credentials-page/site-branding.js";import{buildAllowedHostMatchers as g}from"./fetch/allowed-hosts.js";import{assertUrlAllowed as _}from"./fetch/ssrf-guard.js";import{getDefaultAgent as v,readCappedBody as y}from"./fetch/fetch-bridge.js";const b={"Content-Type":`text/html; charset=utf-8`,"Cache-Control":`no-store`,"X-Frame-Options":`DENY`,"Referrer-Policy":`no-referrer`,"Content-Security-Policy":`default-src 'none'; style-src 'unsafe-inline'; img-src 'self'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'`},x=/^bearer\s+/i,S=/^\d+$/;async function C(e,t){let{kv:r}=t;if(e.req.method===`GET`){let n=await h(t),i=e.req.query(`token`)??``,a=await s.peekElicitation(r,i);return a?R(a,t,n)??M({kv:r,site:n,token:i,target:a},{},200):L(n)}if(e.req.method===`POST`){let i=await h(t),o=await e.req.formData(),c=F(o,`token`),l=await s.peekElicitation(r,c);if(!l)return L(i);let u=R(l,t,i);if(u)return u;let d={kv:r,site:i,token:c,target:l,form:o,ctx:t};switch(F(o,`action`)){case n.remove:return O(d,k(l,F(o,`scheme`)));case n.removeAll:return O(d,a(l));case n.decline:return A(d);default:return w(d)}}return new Response(`Method Not Allowed`,{status:405,headers:{Allow:`GET, POST`}})}async function w(e){let{target:t,form:n,ctx:r}=e,i=a(t),s=i.map((e,t)=>F(n,o(`client_id`,t)).trim()),c=t=>M(e,{error:t,clientIds:s},400),l=T(i,n);if(`error`in l)return c(l.error);if(l.writes.length===0)return c(E(i));let u=[];for(let e of l.writes){if(e.kind!==`exchange`){u.push(e);continue}let n=await N(e.auth,e.clientId,e.clientSecret);if(!n.ok)return r.logger?.warn(`gateway oauth2 client_credentials exchange failed for ${t.api}: ${n.reason}`),c(D(i,e.schemeIndex,`client_id`,`We could not exchange those client credentials for a token. Check the client ID and secret, then try again.`));u.push({kind:`set`,scheme:e.scheme,secret:n.secret})}return j(e,u)}function T(e,t){let n=[];for(let[r,a]of e.entries()){let s=F(t,o(`secret`,r)).trim();if(s){let t=i(a.auth,s);if(t)return{error:D(e,r,`secret`,t)};n.push({kind:`set`,scheme:a.name,secret:z(a.auth,s)});continue}if(a.auth.kind!==`oauth2ClientCredentials`)continue;let c=F(t,o(`client_id`,r)).trim(),l=F(t,o(`client_secret`,r)).trim();if(c&&l)n.push({kind:`exchange`,scheme:a.name,schemeIndex:r,auth:a.auth,clientId:c,clientSecret:l});else if(c||l)return{error:D(e,r,c?`client_secret`:`client_id`,`Enter both the client ID and the client secret, or leave both blank.`)}}return{writes:n}}function E(e){return e.length>1?{message:`Fill in at least one credential before saving.`}:{message:e[0].auth.kind===`oauth2ClientCredentials`?`Enter an access token, or the client ID and the client secret, before saving.`:`Enter a value before saving.`,schemeIndex:0,field:`secret`}}function D(e,t,n,r){return{message:e.length>1?`${e[t].name}: ${r}`:r,schemeIndex:t,field:n}}async function O(e,t){let{kv:n,target:r}=e,i=await s.getStoredSchemes(n,r.subject,r.api),a=t.filter(e=>i[e.name]).map(e=>({kind:`remove`,scheme:e.name}));return a.length===0?M(e,{error:{message:`No credential is stored there, so there is nothing to remove.`}},400):j(e,a)}function k(e,t){let n=S.test(t)?a(e)[Number(t)]:void 0;return n?[n]:[]}async function A({kv:e,site:t,token:n}){return await s.consumeElicitation(e,n)?I(t,u(),200):L(t)}async function j({kv:e,site:t,token:n},r){let i=await s.consumeElicitation(e,n);if(!i)return L(t);for(let t of r)t.kind===`remove`?await s.deleteSecret(e,i.subject,i.api,t.scheme):await s.setSecret(e,i.subject,i.api,t.scheme,t.secret);let a=await s.getStoredSchemes(e,i.subject,i.api),o={action:r.some(e=>e.kind===`set`)?`saved`:`removed`,schemes:r.map(e=>e.scheme),stored:Object.keys(a).sort()};return I(t,p(i,o),200)}async function M({kv:e,site:t,token:n,target:r},i,a){let o=await s.getStoredSchemes(e,r.subject,r.api);return I(t,l({site:t,target:r,token:n,stored:o,...i}),a)}async function N(e,t,n){try{let r=g([{url:e.tokenUrl}]),a=_(e.tokenUrl,r),o=new AbortController,s=setTimeout(()=>o.abort(),3e4),c;try{c=await fetch(a,{method:`POST`,headers:{"content-type":`application/x-www-form-urlencoded`},body:new URLSearchParams({grant_type:`client_credentials`,client_id:t,client_secret:n}),redirect:`manual`,signal:o.signal,dispatcher:v()})}finally{clearTimeout(s)}if(!c.ok)return P(`token endpoint returned ${c.status}`);let l;try{l=await y(c,65536)}catch{return P(`token response exceeded the size cap`)}let u;try{u=JSON.parse(l)}catch{return P(`token response was not valid JSON`)}let d=typeof u==`object`&&u&&`access_token`in u?u.access_token:void 0,f=typeof d==`string`?d.trim():``;return f?i(e,f)?P(`token response had an access_token that cannot be sent in a header`):{ok:!0,secret:{header:`Authorization`,value:`Bearer ${f}`}}:P(`token response had no access_token`)}catch(e){return P(e instanceof Error?e.message:String(e))}}function P(e){return{ok:!1,reason:e}}function F(e,t){let n=e.get(t);return typeof n==`string`?n:``}function I(e,t,n){return new Response(c(t,e),{status:n,headers:b})}function L(e){return I(e,d(),404)}function R(n,i,a){if(!n.subject.startsWith(`user:`))return;let{viewer:o}=i.request,s=r(o);if(s===n.subject)return;if(s)return I(a,f(o?.email),403);let c=`${t(e.AuthIdpLogin)}?${new URLSearchParams({redirectTo:`/`})}`;return I(a,m(a.host,c),403)}function z(e,t){return e.kind===`apiKey`?{header:e.header,value:t}:e.kind===`cookie`?{header:`Cookie`,value:`${e.name}=${t}`}:e.kind===`bearer`||e.kind===`oauth2ClientCredentials`?{header:`Authorization`,value:B(t)}:{header:`Authorization`,value:t}}function B(e){return`Bearer ${e.replace(x,``)}`}export{C as serveCredentials};
1
+ import{withPathPrefix as e}from"../../../../../../shared/path-prefix.js";import{SystemRoute as t}from"../../../../../../server/constants/system-routes.js";import{FORM_ACTIONS as n}from"./credentials-page/constants.js";import{userSubject as r}from"./subject.js";import{rejectCredential as i}from"./credential-validation.js";import{credentialSchemesOf as a,schemeFieldName as o}from"./credentials-page/form-contract.js";import{secretStore as s}from"./secret-store.js";import{htmlDocument as c}from"./credentials-page/layout.js";import{formPage as l}from"./credentials-page/form-page.js";import{declinedPage as u,expiredPage as d,otherAccountPage as f,outcomePage as p,signInPage as m}from"./credentials-page/outcome-pages.js";import{loadPageSite as h}from"./credentials-page/site-branding.js";import{buildAllowedOriginMatchers as g}from"./fetch/allowed-hosts.js";import{assertUrlAllowed as _}from"./fetch/ssrf-guard.js";import{getDefaultAgent as v,readCappedBody as y}from"./fetch/fetch-bridge.js";const b={"Content-Type":`text/html; charset=utf-8`,"Cache-Control":`no-store`,"X-Frame-Options":`DENY`,"Referrer-Policy":`no-referrer`,"Content-Security-Policy":`default-src 'none'; style-src 'unsafe-inline'; img-src 'self'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'`},x=/^bearer\s+/i,S=/^\d+$/;async function C(e,t){let{kv:r}=t;if(e.req.method===`GET`){let n=await h(t),i=e.req.query(`token`)??``,a=await s.peekElicitation(r,i);return a?R(a,t,n)??M({kv:r,site:n,token:i,target:a},{},200):L(n)}if(e.req.method===`POST`){let i=await h(t),o=await e.req.formData(),c=F(o,`token`),l=await s.peekElicitation(r,c);if(!l)return L(i);let u=R(l,t,i);if(u)return u;let d={kv:r,site:i,token:c,target:l,form:o,ctx:t};switch(F(o,`action`)){case n.remove:return O(d,k(l,F(o,`scheme`)));case n.removeAll:return O(d,a(l));case n.decline:return A(d);default:return w(d)}}return new Response(`Method Not Allowed`,{status:405,headers:{Allow:`GET, POST`}})}async function w(e){let{target:t,form:n,ctx:r}=e,i=a(t),s=i.map((e,t)=>F(n,o(`client_id`,t)).trim()),c=t=>M(e,{error:t,clientIds:s},400),l=T(i,n);if(`error`in l)return c(l.error);if(l.writes.length===0)return c(E(i));let u=[];for(let e of l.writes){if(e.kind!==`exchange`){u.push(e);continue}let n=await N(e.auth,e.clientId,e.clientSecret);if(!n.ok)return r.logger?.warn(`gateway oauth2 client_credentials exchange failed for ${t.api}: ${n.reason}`),c(D(i,e.schemeIndex,`client_id`,`We could not exchange those client credentials for a token. Check the client ID and secret, then try again.`));u.push({kind:`set`,scheme:e.scheme,secret:n.secret})}return j(e,u)}function T(e,t){let n=[];for(let[r,a]of e.entries()){let s=F(t,o(`secret`,r)).trim();if(s){let t=i(a.auth,s);if(t)return{error:D(e,r,`secret`,t)};n.push({kind:`set`,scheme:a.name,secret:z(a.auth,s)});continue}if(a.auth.kind!==`oauth2ClientCredentials`)continue;let c=F(t,o(`client_id`,r)).trim(),l=F(t,o(`client_secret`,r)).trim();if(c&&l)n.push({kind:`exchange`,scheme:a.name,schemeIndex:r,auth:a.auth,clientId:c,clientSecret:l});else if(c||l)return{error:D(e,r,c?`client_secret`:`client_id`,`Enter both the client ID and the client secret, or leave both blank.`)}}return{writes:n}}function E(e){return e.length>1?{message:`Fill in at least one credential before saving.`}:{message:e[0].auth.kind===`oauth2ClientCredentials`?`Enter an access token, or the client ID and the client secret, before saving.`:`Enter a value before saving.`,schemeIndex:0,field:`secret`}}function D(e,t,n,r){return{message:e.length>1?`${e[t].name}: ${r}`:r,schemeIndex:t,field:n}}async function O(e,t){let{kv:n,target:r}=e,i=await s.getStoredSchemes(n,r.subject,r.api),a=t.filter(e=>i[e.name]).map(e=>({kind:`remove`,scheme:e.name}));return a.length===0?M(e,{error:{message:`No credential is stored there, so there is nothing to remove.`}},400):j(e,a)}function k(e,t){let n=S.test(t)?a(e)[Number(t)]:void 0;return n?[n]:[]}async function A({kv:e,site:t,token:n}){return await s.consumeElicitation(e,n)?I(t,u(),200):L(t)}async function j({kv:e,site:t,token:n},r){let i=await s.consumeElicitation(e,n);if(!i)return L(t);for(let t of r)t.kind===`remove`?await s.deleteSecret(e,i.subject,i.api,t.scheme):await s.setSecret(e,i.subject,i.api,t.scheme,t.secret);let a=await s.getStoredSchemes(e,i.subject,i.api),o={action:r.some(e=>e.kind===`set`)?`saved`:`removed`,schemes:r.map(e=>e.scheme),stored:Object.keys(a).sort()};return I(t,p(i,o),200)}async function M({kv:e,site:t,token:n,target:r},i,a){let o=await s.getStoredSchemes(e,r.subject,r.api);return I(t,l({site:t,target:r,token:n,stored:o,...i}),a)}async function N(e,t,n){try{let r=g([{url:e.tokenUrl}]),a=_(e.tokenUrl,r),o=new AbortController,s=setTimeout(()=>o.abort(),3e4),c;try{c=await fetch(a,{method:`POST`,headers:{"content-type":`application/x-www-form-urlencoded`},body:new URLSearchParams({grant_type:`client_credentials`,client_id:t,client_secret:n}),redirect:`manual`,signal:o.signal,dispatcher:v()})}finally{clearTimeout(s)}if(!c.ok)return P(`token endpoint returned ${c.status}`);let l;try{l=await y(c,65536)}catch{return P(`token response exceeded the size cap`)}let u;try{u=JSON.parse(l)}catch{return P(`token response was not valid JSON`)}let d=typeof u==`object`&&u&&`access_token`in u?u.access_token:void 0,f=typeof d==`string`?d.trim():``;return f?i(e,f)?P(`token response had an access_token that cannot be sent in a header`):{ok:!0,secret:{header:`Authorization`,value:`Bearer ${f}`}}:P(`token response had no access_token`)}catch(e){return P(e instanceof Error?e.message:String(e))}}function P(e){return{ok:!1,reason:e}}function F(e,t){let n=e.get(t);return typeof n==`string`?n:``}function I(e,t,n){return new Response(c(t,e),{status:n,headers:b})}function L(e){return I(e,d(),404)}function R(n,i,a){if(!n.subject.startsWith(`user:`))return;let{viewer:o}=i.request,s=r(o);if(s===n.subject)return;if(s)return I(a,f(o?.email),403);let c=`${e(t.AuthIdpLogin)}?${new URLSearchParams({redirectTo:`/`})}`;return I(a,m(a.host,c),403)}function z(e,t){return e.kind===`apiKey`?{header:e.header,value:t}:e.kind===`cookie`?{header:`Cookie`,value:`${e.name}=${t}`}:e.kind===`bearer`||e.kind===`oauth2ClientCredentials`?{header:`Authorization`,value:B(t)}:{header:`Authorization`,value:t}}function B(e){return`Bearer ${e.replace(x,``)}`}export{C as serveCredentials};
@@ -1,6 +1,7 @@
1
- import{withPathPrefix as e}from"../../../../../../shared/path-prefix.js";import{MANAGE_API_CREDENTIALS_TOOL_NAME as t,MCP_CREDENTIALS_ROUTE as n}from"../../constants.js";import{ANONYMOUS_SUBJECT_PREFIX as r}from"./subject.js";import{secretStore as i}from"./secret-store.js";import{operationsForScheme as a,orderedSchemesOf as o}from"./upstream-auth-scheme.js";import{CLIENT_CAPABILITIES_META_KEY as s,inputRequired as c,inputResponse as l}from"@modelcontextprotocol/server";const u=`credentials`,d=/* @__PURE__ */ new Map;function f(e,t){let n=d.get(e);if(n)return n;let r=t().finally(()=>{d.delete(e)});return d.set(e,r),r}function p(e){return!!(e.envelope?.[s])?.elicitation?.url}function m(e){return e.envelope!==void 0}function h(e){let t=l(e,u);if(t.kind===`elicit`)return t.action===`accept`?`accepted`:`declined`}function g(e,{url:n,canManageCredentials:r}){return[`The user accepted the prompt to add credentials for the "${e}" API.`,...n?[`The credentials page:`,n]:[],``,r?`Wait until the user says they saved the credentials, then retry the call that needed them. Do not call \`${t}\` again unless the user asks for a new link.`:`Wait until the user says they saved the credentials, then retry the call that needed them.`].join(`
2
- `)}async function _(e,{kv:t,subject:n,baseUrl:r,apis:a}){if(typeof e!=`string`)return;let o=await i.peekElicitation(t,e);if(o?.subject===n&&a.includes(o.api))return{apiName:o.name,url:k(r,e)}}function v(e,t){return Object.keys(e).length>1?t:void 0}async function y(e){let{token:t,url:n}=await C(e);return c({inputRequests:{[u]:c.elicitUrl({message:E(e),url:n})},requestState:t})}async function b(e){let{url:t}=await C(e);return A(e,t,T(e.subject))}function x(e,{schemeLabel:n,canManageCredentials:r}){let i=S(e);if(e.status===401&&!e.sentScheme)return[`The "${e.name}" API returned ${i}. No stored credential was sent with this request, so this result says nothing about the stored credentials.`,``,`Do not replace them. Check whether this operation needs a different kind of credential or a different route.`].join(`
3
- `);let a=e.status===401?`The "${e.name}" API rejected the stored ${n?`"${n}" `:``}credential (${i}).`:`The "${e.name}" API rejected the request with ${i}.`;if(!r)return[a,``,e.sentScheme?`Do not retry the same call. Tell the user what the API answered. This client cannot replace the stored credentials.`:`Do not retry the same call. Tell the user what the API answered.`].join(`
4
- `);let o=n?`api: "${e.api}" and scheme: "${n}"`:`api: "${e.api}"`,s=e.sentScheme?(e.schemes??[]).filter(t=>t!==e.sentScheme):[];return[a,``,...s.length>0?[`This API also defines ${s.map(e=>`"${e}"`).join(`, `)}. Ask the user which credential they hold: if it is one of those, they can save it through the same link.`,``]:[],`Do not retry the same call. Call \`${t}\` with ${o} to get a link the user has to open in a browser to replace or remove the stored credentials, then retry once they confirm they saved them.`].join(`
5
- `)}function S({status:e,detail:t}){return t?`HTTP ${e}: ${t}`:`HTTP ${e}`}async function C({kv:e,subject:t,baseUrl:n,target:r,auth:a,apiAuth:o}){let s=o?w(o):[],c=await i.createElicitation(e,{subject:t,api:r.api,name:r.name,scheme:r.scheme,schemeLabel:r.schemeLabel,auth:a,schemes:s.length>1?s:void 0,acceptedSchemes:s.length>1?r.acceptedSchemes:void 0});return{token:c,url:k(n,c)}}function w(e){return o(e.schemes).map(t=>{let n=a(e,t);return{name:t,label:e.descriptions?.[t],auth:e.schemes[t],operations:n.length>0?n:void 0}})}function T(e){return e.startsWith(`anon:`)?e.slice(r.length):void 0}function E({target:e,hasExistingSecret:t,reason:n}){let r=`The link works for 15 minutes.`,i=D(e),a=n.kind===`authFailure`&&n.detail?` The API answered: ${n.detail}.`:``;return t?`Open this page in a browser to replace or remove the stored credentials for ${i}. They stay out of the chat. ${r}`:`${O(i)} needs credentials.${a} Open this page in a browser to paste them - they stay out of the chat. ${r}`}function D({name:e,schemeLabel:t}){return t?`the "${t}" scheme of the "${e}" API`:`the "${e}" API`}function O(e){return e.charAt(0).toUpperCase()+e.slice(1)}function k(t,r){let i=new URL(e(n),t);return i.searchParams.set(`token`,r),i.toString()}function A({target:e,reason:t,hasExistingSecret:n},r,i){let a=[`**Stop and show the user this link. They have to open it in a browser to ${n?`replace or remove the stored credentials for the "${e.name}" API`:`add credentials for the "${e.name}" API`} - nothing continues until they do.**`,``,r,``,`The link is valid 15 minutes and opens a form on this site. The site stores the credentials and adds them to API calls: never ask for them in the conversation and never pass them as a tool argument.`,``,t.kind===`authFailure`?`The upstream API "${e.name}" returned ${t.status}${t.detail?` (${t.detail})`:``} and needs credentials.`:n?`Credentials are already stored for the "${e.name}" API; the link lets the user replace or remove them.`:`The "${e.name}" API needs credentials.`,...e.schemeLabel?[`The operation authenticates with its "${e.schemeLabel}" security scheme.`]:[],i?`Once the user confirms they saved them, retry the call that needed them with sessionHandle: "${i}" - the credentials are stored against that handle, applied server-side, and never appear in the conversation.`:`Once the user confirms they saved them, retry the call that needed them - the credentials are applied server-side and never appear in the conversation.`],o=t.kind===`authFailure`?t.otherApiNames??[]:[];if(o.length>0){let e=o.map(e=>`"${e}"`).join(`, `);a.push(``,`The remaining APIs (${e}) will prompt for credentials on subsequent calls.`)}return a.join(`
1
+ import{withPathPrefix as e}from"../../../../../../shared/path-prefix.js";import{MCP_CREDENTIALS_ROUTE as t}from"../../constants.js";import{ANONYMOUS_SUBJECT_PREFIX as n}from"./subject.js";import{secretStore as r}from"./secret-store.js";import{operationsForScheme as i,orderedSchemesOf as a}from"./upstream-auth-scheme.js";import{MANAGE_API_CREDENTIALS_TOOL_NAME as o}from"@redocly/mcp";import{CLIENT_CAPABILITIES_META_KEY as s,inputRequired as c,inputResponse as l}from"@modelcontextprotocol/server";const u=`credentials`,d=/* @__PURE__ */ new Map;function f(e,t){let n=d.get(e);if(n)return n;let r=t().finally(()=>{d.delete(e)});return d.set(e,r),r}function p(e){return!!(e.envelope?.[s])?.elicitation?.url}function m(e){return e.envelope!==void 0}function h(e){let t=l(e,u);if(t.kind===`elicit`)return t.action===`accept`?`accepted`:`declined`}function g(e,{url:t,canManageCredentials:n}){return[`The user accepted the prompt to add credentials for the "${e}" API.`,...t?[`The credentials page:`,t]:[],``,n?`Wait until the user says they saved the credentials, then retry the call that needed them. Do not call \`${o}\` again unless the user asks for a new link.`:`Wait until the user says they saved the credentials, then retry the call that needed them.`].join(`
2
+ `)}async function _(e,{kv:t,subject:n,baseUrl:i,apis:a}){if(typeof e!=`string`)return;let o=await r.peekElicitation(t,e);if(o?.subject===n&&a.includes(o.api))return{apiName:o.name,url:A(i,e)}}function v(e,t){return Object.keys(e).length>1?t:void 0}async function y(e){let{token:t,url:n}=await w(e);return c({inputRequests:{[u]:c.elicitUrl({message:D(e),url:n})},requestState:t})}async function b(e){let{url:t}=await w(e);return j(e,t,E(e.subject))}function x(e,{schemeLabel:t,canManageCredentials:n}){let r=C(e);if(!e.sentScheme&&(e.status===401||!e.schemes))return[`The "${e.name}" API returned ${r}. No stored credential was sent with this request, so this result says nothing about the stored credentials.`,``,e.unsupportedSchemes?`Do not replace them. This operation accepts only ${e.unsupportedSchemes.map(e=>`"${e}"`).join(`, `)}, which this site cannot send. Use a different route.`:`Do not replace them. Check whether this operation needs a different kind of credential or a different route.`].join(`
3
+ `);if(e.status===403&&e.sentScheme)return[`The "${e.name}" API refused this operation with the stored ${t?`"${t}" `:``}credential (${r}). Usually the credential lacks a permission or role for it.`,``,`Tell the user what the API answered and that they need a credential with access to this operation.`,...n?[``,...S(e),`If the user has a different credential, or the API answer says this one is invalid or expired, call \`${o}\` with api: "${e.api}" to get a link where they can save it.`]:[`This client cannot replace the stored credentials.`]].join(`
4
+ `);let i=e.status===401?`The "${e.name}" API rejected the stored ${t?`"${t}" `:``}credential (${r}).`:`The "${e.name}" API rejected the request with ${r}.`;if(!n)return[i,``,e.sentScheme?`Do not retry the same call. Tell the user what the API answered. This client cannot replace the stored credentials.`:`Do not retry the same call. Tell the user what the API answered.`].join(`
5
+ `);let a=t?`api: "${e.api}" and scheme: "${t}"`:`api: "${e.api}"`;return[i,``,...S(e),`Do not retry the same call. Call \`${o}\` with ${a} to get a link the user has to open in a browser to replace or remove the stored credentials, then retry once they confirm they saved them.`].join(`
6
+ `)}function S(e){let t=e.sentScheme?(e.schemes??[]).filter(t=>t!==e.sentScheme):[];return t.length>0?[`This API also defines ${t.map(e=>`"${e}"`).join(`, `)}. Ask the user which credential they hold: if it is one of those, they can save it through the same link.`,``]:[]}function C({status:e,detail:t}){return t?`HTTP ${e}: ${t}`:`HTTP ${e}`}async function w({kv:e,subject:t,baseUrl:n,target:i,auth:a,apiAuth:o}){let s=o?T(o):[],c=await r.createElicitation(e,{subject:t,api:i.api,name:i.name,scheme:i.scheme,schemeLabel:i.schemeLabel,auth:a,schemes:s.length>1?s:void 0,acceptedSchemes:s.length>1?i.acceptedSchemes:void 0});return{token:c,url:A(n,c)}}function T(e){return a(e.schemes).map(t=>{let n=i(e,t);return{name:t,label:e.descriptions?.[t],auth:e.schemes[t],operations:n.length>0?n:void 0}})}function E(e){return e.startsWith(`anon:`)?e.slice(n.length):void 0}function D({target:e,hasExistingSecret:t,reason:n}){let r=`The link works for 15 minutes.`,i=O(e),a=n.kind===`authFailure`&&n.detail?` The API answered: ${n.detail}.`:``;return t?`Open this page in a browser to replace or remove the stored credentials for ${i}. They stay out of the chat. ${r}`:`${k(i)} needs credentials.${a} Open this page in a browser to paste them - they stay out of the chat. ${r}`}function O({name:e,schemeLabel:t}){return t?`the "${t}" scheme of the "${e}" API`:`the "${e}" API`}function k(e){return e.charAt(0).toUpperCase()+e.slice(1)}function A(n,r){let i=new URL(e(t),n);return i.searchParams.set(`token`,r),i.toString()}function j({target:e,reason:t,hasExistingSecret:n},r,i){let a=[`**Stop and show the user this link. They have to open it in a browser to ${n?`replace or remove the stored credentials for the "${e.name}" API`:`add credentials for the "${e.name}" API`} - nothing continues until they do.**`,``,r,``,`The link is valid 15 minutes and opens a form on this site. The site stores the credentials and adds them to API calls: never ask for them in the conversation and never pass them as a tool argument.`,``,t.kind===`authFailure`?`The upstream API "${e.name}" returned ${t.status}${t.detail?` (${t.detail})`:``} and needs credentials.`:n?`Credentials are already stored for the "${e.name}" API; the link lets the user replace or remove them.`:`The "${e.name}" API needs credentials.`,...e.schemeLabel?[`The operation authenticates with its "${e.schemeLabel}" security scheme.`]:[],i?`Once the user confirms they saved them, retry the call that needed them with sessionHandle: "${i}" - the credentials are stored against that handle, applied server-side, and never appear in the conversation.`:`Once the user confirms they saved them, retry the call that needed them - the credentials are applied server-side and never appear in the conversation.`],o=t.kind===`authFailure`?t.otherApiNames??[]:[];if(o.length>0){let e=o.map(e=>`"${e}"`).join(`, `);a.push(``,`The remaining APIs (${e}) will prompt for credentials on subsequent calls.`)}return a.join(`
6
7
  `)}export{u as CREDENTIALS_INPUT_REQUEST_KEY,_ as acceptedCredentialsLink,g as buildCredentialsAcceptedHint,x as buildCredentialsToolHint,b as buildUpstreamCredentialFallback,y as buildUpstreamCredentialInputRequired,h as credentialElicitationAnswer,f as dedupeElicitation,m as isStatelessRequest,v as schemeLabelOf,p as supportsUrlElicitation};
@@ -1 +1 @@
1
- const e=/\{(?<!\{[^}]*?\{)([^}]+)\}/g;function t(e=[]){let t=[];for(let n of e){let e=r(n);e&&t.push(e)}return t}function n(e,t){return t.some(t=>t.test(e))}function r(t){let n=a(t.url);if(!n)return null;let r=``,s=0,c=!1;for(let a of n.matchAll(e)){let[e,l]=a,u=n.slice(s,a.index);u.includes(`.`)&&(c=!0),r+=o(u);let d=i(t.variables?.[l]);d.guaranteesDot&&(c=!0),r+=d.pattern,s=a.index+e.length}let l=n.slice(s);return l.includes(`.`)&&(c=!0),r+=o(l),c?RegExp(`^${r}$`,`i`):null}function i(e){let t=e?.enum?.filter(Boolean);if(t&&t.length>0)return{pattern:`(?:${t.map(o).join(`|`)})`,guaranteesDot:t.every(e=>e.includes(`.`))};let n=e?.default?.split(`.`).slice(1).join(`.`);return n?{pattern:`[^.]+\\.${o(n)}`,guaranteesDot:!0}:{pattern:`[^.]+`,guaranteesDot:!1}}function a(e){if(!e)return null;let t=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).split(/[/?#]/,1)[0];return t&&(t.includes(`@`)?t.slice(t.lastIndexOf(`@`)+1):t).replace(/:(?:\d+|\{[^}]+\})$/,``)||null}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}export{t as buildAllowedHostMatchers,n as isHostAllowed};
1
+ const e=/\{(?<!\{[^}]*?\{)([^}]+)\}/g,t=/^([a-z][a-z0-9+.-]*):\/\//i,n=/[/?#]/,r=/:(\d+|\{[^}]+\})$/,i=/^\{([^}]+)\}$/,a=/^\d+$/,o={"http:":80,"https:":443};function s(e=[]){let t=[];for(let n of e)t.push(...l(n));return t}function c(e,t){return e.protocol===t.protocol&&e.ports.includes(t.port)&&e.hostname.test(t.hostname)}function l(e){let t=h(e.url);if(!t)return[];let n=u(t.host,e.variables),r=f(t,e.variables);if(!n||r.length===0)return[];let i=[{protocol:t.protocol,hostname:n,ports:r}];return t.protocol===`http:`&&r.includes(``)&&i.push({protocol:`https:`,hostname:n,ports:[``]}),i}function u(t,n){let r=``,i=0,a=!1;for(let o of t.matchAll(e)){let[e,s]=o,c=t.slice(i,o.index);c.includes(`.`)&&(a=!0),r+=g(c);let l=d(n?.[s]);l.guaranteesDot&&(a=!0),r+=l.pattern,i=o.index+e.length}let o=t.slice(i);return o.includes(`.`)&&(a=!0),r+=g(o),a?RegExp(`^${r}$`,`i`):null}function d(e){let t=e?.enum?.filter(Boolean);if(t&&t.length>0)return{pattern:`(?:${t.map(g).join(`|`)})`,guaranteesDot:t.every(e=>e.includes(`.`))};let n=e?.default?.split(`.`).slice(1).join(`.`);return n?{pattern:`[^.]+\\.${g(n)}`,guaranteesDot:!0}:{pattern:`[^.]+`,guaranteesDot:!1}}function f({protocol:e,port:t},n){let r=i.exec(t)?.[1],a=r?p(n?.[r]):[t];return[...new Set(a.flatMap(t=>m(e,t)))]}function p(e){let t=e?.enum?.filter(Boolean).map(String);return t&&t.length>0?t:e?.default?[String(e.default)]:[]}function m(e,t){if(t===``)return[``];if(!a.test(t))return[];let n=Number(t);return[n===o[e]?``:String(n)]}function h(e){if(!e)return null;let i=(t.exec(e)?.[1]??`https`).toLowerCase();if(i!==`http`&&i!==`https`)return null;let a=e.replace(t,``).split(n,1)[0];if(!a)return null;let o=a.includes(`@`)?a.slice(a.lastIndexOf(`@`)+1):a,s=r.exec(o),c=s?o.slice(0,s.index):o;return c?{protocol:`${i}:`,host:c,port:s?.[1]??``}:null}function g(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}export{s as buildAllowedOriginMatchers,c as matchesOrigin};