@redocly/framework 1.0.0-next.12 → 1.0.0-next.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/bundler/build/dependency-pack.js +1 -1
- package/dist/bundler/build/output-metadata.js +1 -1
- package/dist/bundler/build/run.js +1 -1
- package/dist/bundler/build/theme-global-stylesheets.js +1 -1
- package/dist/bundler/build/vite-config.js +2 -2
- package/dist/bundler/dev/dev-content-build.js +1 -1
- package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
- package/dist/bundler/dev/routes/source-sync-route.js +1 -1
- package/dist/bundler/dev/run.js +1 -1
- package/dist/bundler/dev/runtime-app.js +1 -1
- package/dist/bundler/dev/vite-chunk-url.js +1 -1
- package/dist/bundler/user-markdoc-schema.js +1 -1
- package/dist/bundler/vite-config.base.js +5 -5
- package/dist/cli/api-docs-build-event.js +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/commands/build.js +1 -1
- package/dist/cli/commands/dev.js +1 -1
- package/dist/cli/commands/ingest.js +1 -1
- package/dist/cli/commands/translate.js +1 -1
- package/dist/cli/problems-output.js +3 -3
- package/dist/cli/validate-react-pages.js +1 -1
- package/dist/client/UnversionedVersionButton.js +1 -1
- package/dist/client/VersionPicker.js +343 -0
- package/dist/client/ai-search/use-ai-search.js +1 -1
- package/dist/client/analytics-page-view.js +1 -1
- package/dist/client/app.js +2 -2
- package/dist/client/classic-webview-sync.js +1 -1
- package/dist/client/client-entry.js +1 -1
- package/dist/client/contexts.js +1 -1
- package/dist/client/feedback.js +1 -1
- package/dist/client/history-mount.js +6 -5
- package/dist/client/l10n/ssr-l10n.js +1 -1
- package/dist/client/l10n/use-l10n-config.js +1 -1
- package/dist/client/products.js +1 -1
- package/dist/client/review/ReviewBar.js +31 -31
- package/dist/client/review/login-url.js +1 -1
- package/dist/client/review/use-review.js +1 -1
- package/dist/client/revisions-history.js +1 -1
- package/dist/client/sidebar/SidebarDataProvider.js +1 -1
- package/dist/client/sidebar/drilldown.js +1 -1
- package/dist/client/ssr.js +1 -1
- package/dist/client/telemetry/config.js +1 -1
- package/dist/client/theme-logo.js +1 -1
- package/dist/client/use-entity-revisions.js +1 -1
- package/dist/client/use-page-versions.js +1 -1
- package/dist/client/use-search.js +1 -1
- package/dist/client/webmcp/tools/shared.js +1 -1
- package/dist/client/webmcp/tools/site-tools.js +1 -1
- package/dist/client/webmcp/use-webmcp-tools.js +1 -1
- package/dist/content-layer/config-schema.js +1 -1
- package/dist/content-layer/config.d.ts +8 -0
- package/dist/content-layer/config.js +1 -1
- package/dist/content-layer/context-state.js +1 -1
- package/dist/content-layer/context.d.ts +6 -0
- package/dist/content-layer/context.js +1 -1
- package/dist/content-layer/database/assets.js +1 -1
- package/dist/content-layer/database/blobs.js +1 -1
- package/dist/content-layer/database/entities.d.ts +2 -0
- package/dist/content-layer/database/entities.js +1 -1
- package/dist/content-layer/database/entity-store.js +1 -1
- package/dist/content-layer/database/files.js +1 -1
- package/dist/content-layer/database/finalize.js +1 -1
- package/dist/content-layer/database/invalidation.js +26 -26
- package/dist/content-layer/database/link-refs.js +1 -1
- package/dist/content-layer/database/origins.d.ts +2 -1
- package/dist/content-layer/database/origins.js +1 -1
- package/dist/content-layer/database/problems.js +1 -1
- package/dist/content-layer/database/reset.js +1 -1
- package/dist/content-layer/database/route-query-deps.d.ts +19 -3
- package/dist/content-layer/database/route-query-deps.js +1 -1
- package/dist/content-layer/database/search-vocab.js +2 -2
- package/dist/content-layer/database/static-files.js +1 -1
- package/dist/content-layer/ingest/extract-all-phase.js +1 -1
- package/dist/content-layer/ingest/finalize-phase.js +1 -1
- package/dist/content-layer/ingest/git-last-modified.d.ts +20 -0
- package/dist/content-layer/ingest/git-last-modified.js +5 -4
- package/dist/content-layer/ingest/hash.js +1 -1
- package/dist/content-layer/ingest/hook-inputs.js +1 -1
- package/dist/content-layer/ingest/l10n-warnings.js +1 -1
- package/dist/content-layer/ingest/markdoc-schema-problem.js +1 -1
- package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
- package/dist/content-layer/ingest/run.js +1 -1
- package/dist/content-layer/ingest/scan.js +1 -1
- package/dist/content-layer/ingest/search-sync.js +1 -1
- package/dist/content-layer/ingest/sync.js +1 -1
- package/dist/content-layer/link-checker/config-links.js +1 -1
- package/dist/content-layer/link-checker/delta.js +1 -1
- package/dist/content-layer/link-checker/fingerprint.js +1 -1
- package/dist/content-layer/link-checker/load-view.js +1 -1
- package/dist/content-layer/link-checker/node-ref.js +1 -1
- package/dist/content-layer/link-checker/run-build.js +1 -1
- package/dist/content-layer/link-checker/validate.js +1 -1
- package/dist/content-layer/loaders/context.js +1 -1
- package/dist/content-layer/markdown/client/JsonSchemaTag.js +1 -1
- package/dist/content-layer/markdown/client/markdown-text.js +1 -1
- package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
- package/dist/content-layer/markdown/nodes/fence.js +1 -1
- package/dist/content-layer/markdown/nodes/heading.js +1 -1
- package/dist/content-layer/markdown/nodes/table.js +1 -1
- package/dist/content-layer/markdown/resolve/ast.d.ts +2 -0
- package/dist/content-layer/markdown/resolve/ast.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/file-reference.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/partial.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/svg-content.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
- package/dist/content-layer/markdown/resolve/references.js +1 -1
- package/dist/content-layer/markdown/search/to-markdown.js +3 -3
- package/dist/content-layer/markdown/search/to-sections.js +1 -1
- package/dist/content-layer/markdown/search/to-text.js +5 -5
- package/dist/content-layer/markdown/server/render.js +1 -1
- package/dist/content-layer/markdown/service.js +1 -1
- package/dist/content-layer/markdown/tags/variant.js +1 -1
- package/dist/content-layer/markdown/utils/collect-anchors.js +1 -1
- package/dist/content-layer/markdown/utils/first-heading.js +1 -1
- package/dist/content-layer/markdown/utils/parse-cache.d.ts +5 -1
- package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
- package/dist/content-layer/materialization/asset-reconcile.js +1 -1
- package/dist/content-layer/materialization/entity.js +1 -1
- package/dist/content-layer/materialization/materializer.js +1 -1
- package/dist/content-layer/materialization/static-files.js +1 -1
- package/dist/content-layer/plugins/execute.js +1 -1
- package/dist/content-layer/plugins/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/template.js +2 -2
- package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/build-definition.d.ts +4 -1
- package/dist/content-layer/plugins/internal/api-docs/server/build-definition.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-copy.js +12 -10
- package/dist/content-layer/plugins/internal/api-docs/server/options.d.ts +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/search-documents.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/spec-download.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/logo.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/products.js +1 -1
- package/dist/content-layer/plugins/internal/assets/index.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/client/use-catalog-classic.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/resolve-items.js +1 -1
- package/dist/content-layer/plugins/internal/index.js +1 -1
- package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
- package/dist/content-layer/plugins/internal/l10n/translations-loader.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/app-data.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/constants.d.ts +4 -3
- package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/ignored-routes.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/constants.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/execute-schema.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/prompts.js +8 -8
- package/dist/content-layer/plugins/internal/mcp/server/config-gate.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/custom-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/call-api.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-handler.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +6 -6
- package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
- package/dist/content-layer/plugins/internal/mcp/server/gateway/subject.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/tool-list.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +4 -4
- package/dist/content-layer/plugins/internal/mcp/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/callback.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/client-metadata.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/register.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/token.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-info.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/workflows/resolve-workflows.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/workflows/schemas.js +2 -1
- package/dist/content-layer/plugins/internal/mcp/server/workflows/tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/setup-page.js +1 -1
- package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
- package/dist/content-layer/plugins/internal/skills/index.js +1 -1
- package/dist/content-layer/plugins/internal/skills/server/routes.js +1 -1
- package/dist/content-layer/plugins/io.js +1 -1
- package/dist/content-layer/plugins/project/load.js +2 -2
- package/dist/content-layer/plugins/source-file.js +1 -1
- package/dist/content-layer/plugins/utils/link-access.js +1 -1
- package/dist/content-layer/plugins/utils/route-index.js +1 -1
- package/dist/content-layer/revisions/delete.js +1 -1
- package/dist/content-layer/revisions/read.js +1 -1
- package/dist/content-layer/search/engine/core/search-engine.js +1 -1
- package/dist/content-layer/search/postings/postings-store.js +1 -1
- package/dist/content-layer/server/database.js +1 -1
- package/dist/content-layer/static/registry.js +1 -1
- package/dist/content-layer/templates/template-set.js +1 -1
- package/dist/content-layer/versions/redirect.js +1 -1
- package/dist/content-layer/versions/resolve.js +1 -1
- package/dist/server/app.js +3 -3
- package/dist/server/ask-ai/feature-gate.js +1 -1
- package/dist/server/ask-ai/route.js +1 -1
- package/dist/server/auth/middleware.js +1 -1
- package/dist/server/auth/request.js +1 -1
- package/dist/server/auth/routes.js +1 -1
- package/dist/server/content.js +12 -12
- package/dist/server/cors-proxy/handler.js +1 -1
- package/dist/server/feedback/route.js +1 -1
- package/dist/server/lambda-entry.js +1 -1
- package/dist/server/manifest-assets.js +4 -4
- package/dist/server/node-entry.js +1 -1
- package/dist/server/page-handlers.js +2 -2
- package/dist/server/plugin-context.js +1 -1
- package/dist/server/rbac/content-asset-access.js +1 -1
- package/dist/server/runtime-config.js +1 -1
- package/dist/server/search/route.js +1 -1
- package/dist/server/seo-tags.js +2 -2
- package/dist/server/sitemap.js +1 -1
- package/dist/server/static-files/serve.js +1 -1
- package/dist/server/subprocess/child-entry.js +1 -1
- package/dist/server/subprocess/host.js +1 -1
- package/dist/server/template-ids.js +1 -1
- package/dist/shared/constants/system-routes.js +1 -1
- package/dist/shared/rbac/engine.js +0 -0
- package/dist/shared/rbac/l10n-rules.js +1 -1
- package/dist/shared/rbac/route-scope.js +1 -1
- package/dist/shared/rbac/team-templates.js +1 -1
- package/dist/shared/types/config.d.ts +2 -1
- package/dist/shared/utils/l10n.js +1 -1
- package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
- package/package.json +4 -5
|
@@ -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{isPlanFeatureGranted as u}from"../../../../shared/plan-gates.js";import{isObject as d}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as f}from"../../../../shared/utils/routes/normalize-route-slug.js";import{MARKDOC_DOCUMENT_LOADER_KEY as p}from"../../../../shared/constants/route-deps.js";import{markdocNodeRange as m}from"../../../markdown/utils/node-source-range.js";import{replaceWithMarkdocError as h}from"../../../markdown/tags/markdoc-error.js";import{getPartialTwins as g}from"../../../markdown/tags/partial.js";import{CODE_WALKTHROUGH_TAG_NAMES as _,builtInMarkdocTags as v}from"../../../markdown/constants/builtin-tags.js";import{customMarkdocTagNames as y,isMarkdocValidationEnabled as b,resolveMarkdocTagSet as x,resolveMarkdownPageValidationSet as ee,userMarkdocSchemaFiles as te}from"../../../markdown/constants/tag-sets.js";import{splitUrlSuffix as S}from"../../../../shared/utils/routes/split-url-suffix.js";import{isSkillContentPath as C}from"../../utils/skill-paths.js";import{matchPathMap as ne}from"../../utils/glob.js";import{markdocFirstHeading as re}from"../../../markdown/search/to-text.js";import{markdocAstToSearchSections as ie}from"../../../markdown/search/to-sections.js";import{curationKeywordsOf as ae}from"../../../search/keywords.js";import{packMarkdocAst as oe,unpackMarkdocAst as w}from"../../../../shared/utils/packed-ast.js";import{resolveContentPath as se}from"../../../../shared/utils/resolve-content-path.js";import{isRouteSlugTarget as ce}from"../../../../shared/utils/routes/is-route-slug-target.js";import{safeDecodeURI as le}from"../../../../shared/utils/safe-decode-uri.js";import{classifyLinkTarget as ue}from"../../../link-checker/classify.js";import{frontmatterVariable as T}from"../../../markdown/utils/frontmatter-variable.js";import{SOURCE_TEMPLATE_PREFIX as de}from"../../../../shared/constants/template-ids.js";import{PAGE_BANNER_SCHEMA as E,sanitizeConfig as D}from"../../../config-schema.js";import{notInPlanProblem as O}from"../../../plan-gates.js";import{filePathToRouteSlug as k}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{loadSidebarSubtreeLabel as A}from"../../utils/sidebar-label.js";import{walkMarkdocAst as j}from"../../../markdown/utils/walk-markdoc-ast.js";import{shiftRange as M}from"../../../../shared/utils/shift-range.js";import{onDiskLinkRefs as N}from"../../../link-checker/node-ref.js";import{isPartialPath as P}from"../../../markdown/utils/partials.js";import{FRONTMATTER_BLOCK_RE as F,computeFrontmatterLineOffset as I}from"../../../markdown/utils/frontmatter-offset.js";import{inlineRawPartials as L}from"../../../markdown/resolve/raw-partials.js";import{resolveMarkdownAst as R}from"../../../markdown/resolve/ast.js";import{resolveBannerForAppData as z}from"../app-data/banner.js";import{pageLocale as B}from"../../utils/page-locale.js";import{captureSnippet as V,splitSourceLines as H}from"../../../../shared/utils/capture-snippet.js";import{collectAnchors as fe}from"../../../markdown/utils/collect-anchors.js";import{markdownFirstHeading as pe}from"../../../markdown/utils/first-heading.js";import{markdocAstToMarkdownDoc as me}from"../../../markdown/search/to-markdown.js";import{isInternalPagePath as he}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as ge}from"../../utils/explicit-slugs.js";import _e from"js-yaml";const U=`markdoc-page`,W=r(`internal.markdoc`,`document`),G=r(`internal.markdoc`,`sidebar-item`),ve=`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:d,linkRefs:f}=await R(n,e.file.path,{resolverContext:a,tags:(await x(void 0,e.config)).tags,variables:{get env(){return e.config.publicEnv??{}}},transform:t=>De(t,e.file.path,Ee(e.config)),validation:b()?await ee(e.config):void 0}),p=I(t);Me(o);let m=await Te(r.seo,e),h=u(e.config,`banner`)?await z(Ne(r,e.file.path,e.logger),a):void 0,g=await ke(r,e),_=await Ae(r.navigation,e),v={...g.frontmatter,navigation:_.value,seo:m.seo,banner:h?.banner},y=Pe(r,o);return{value:{ast:oe(o),frontmatter:v,tagList:l,title:y,editPage:we(e.config,r,e.file.path),lastModified:e.file.lastModifiedAt},entityDeps:[...s,...be(),...m.entityDeps,...h?.deps??[],...g.entityDeps,..._.entityDeps],assetUsages:[...c,...m.assetUsages,...h?.assetUsages??[],...g.assetUsages],problems:xe(t,e.file.path,p,d,i),linkRefs:[...N(f,p),..._.linkRefs],targetInventories:[Se(o,{frontmatter:T(v,y)})]}},{usesProjectMarkdocSchema:!0,async markdown(e,t){let{tags:n}=await x(void 0,t.config),{chunks:r,headings:i}=me(w(e.ast),{tags:n,locale:B(t),variables:{frontmatter:T(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=ae(e.frontmatter.keywords);return{docs:ie(w(e.ast),r,{frontmatter:T(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 L(t,e.file.path,J(e));return{value:{label:Z(n)??pe(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 ye=e({id:`internal.markdoc`,version:`3.52.0`,content:{filter:{match:e=>e.toLowerCase().endsWith(`.md`)&&!C(e)},extractFile(e,t){if(he(e.path)||P(e.path,t.config))return{routes:[]};if(!u(t.config,`markdown`))return{routes:[],problems:[O(`Markdown pages`)]};let{banner:n,...r}=e.manifest,i=Fe(e,t),a=ge(r.slug),o=K.withArgs({filePath:e.path}),s=q.withArgs({filePath:e.path});return{routes:a.length>0?a.map(e=>({deps:{[p]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:e,slugHint:null,template:i})):[{deps:{[p]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:null,slugHint:k(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(F);if(!t)return{content:e,frontmatter:{}};let n=t[1]??``;try{let r=_e.load(n);return{content:e.slice(t[0].length),frontmatter:d(r)?r:{}}}catch(n){let r=n instanceof Error?n.message:String(n);return{content:e.slice(t[0].length),frontmatter:{},frontmatterError:r}}}function be(){return(te()??[]).map(e=>({kind:`file`,path:e}))}function xe(e,t,n,r,i){if(r.length===0&&i===void 0)return[];let a=H(e),o=r.map(e=>Ce(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:V(a,e)}})}return o}function Se(e,t){let{ids:n,exhaustive:r}=fe(e,t);return{kind:`anchor`,exhaustive:r,targets:n}}function Ce(e,t,n,r){let i=e.location?.range;if(!i)return e;let a=M(i,n);return{...e,location:{filePath:r,range:a,snippet:V(t,a)}}}function we(e,t,n){let r=d(t.markdown)?t.markdown:{},i={...e.markdown?.editPage,...d(r.editPage)?r.editPage:{}};if(i.hide!==!0&&typeof i.baseUrl==`string`&&i.baseUrl!==``)return{to:`${i.baseUrl.replace(/(?<!\/)\/+$/,``)}/${n}`}}async function Te(e,t){if(!d(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 Ee(e){let t=/* @__PURE__ */ new Map;if(!u(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(!u(e,`codeWalkthrough`))for(let e of _)t.set(e,`\`${e}\` is not in this project's plan and is ignored.`);return t}function De(e,t,n){let r=[];if(n.size===0)return r;for(let i of j(e,{getExtraNodes:g})){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:m(i)??{start:{line:1},end:{line:1}}}}),h(i,e))}return r}const Oe=[`image`,`links`];async function ke(e,t){let n=t.config.markdown?.frontMatterKeysToResolve??Oe,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 Ae(e,t){let n=[],r=[];if(!d(e))return{value:e,entityDeps:n,linkRefs:r};let i={...e};for(let a of[`nextButton`,`previousButton`]){let o=e[a];if(!d(o)||typeof o.page!=`string`)continue;let{page:s,...c}=o,l=ue(le(s),t.file.path);l!==null&&r.push({kind:`link`,raw:s,...l});let u=await je(s,t);n.push(...u.entityDeps),i[a]={...c,label:typeof c.label==`string`?c.label:u.route&&await X(u.route,t),link:u.link}}return{value:i,entityDeps:n,linkRefs:r}}async function X(e,t){let n=await A(t.entities,e);if(n!==void 0)return n;let r=t.routes.get(e.slug)?.metadata.seo;return d(r)&&typeof r.title==`string`&&r.title.trim()!==``?r.title:e.slug}async function je(e,t){let n=e.trim(),{path:r,suffix:i}=S(n);if(ce(r)){let e=t.routes.bySlug(f(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(S(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 Me(e){let t=/* @__PURE__ */ new Map;for(let n of j(e)){if(n.type!==`tag`||n.tag===void 0||v[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 Ne(e,t,n){if(e.banner===void 0)return;let{value:r,problems:i}=D(E,{banner:e.banner});for(let e of i)n?.warn(`${t}: ${e.message}`);return r.banner}function Pe(e,t){return Z(e)??re(t)??void 0}function Z(e){let t=d(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 Fe(e,t){let n=e.manifest.template;if(typeof n==`string`&&n.trim()!==``)return $(n,e.path,t.logger);let r=ne(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=se(e,t);return r===null?(n.warn(`Template reference "${e}" in ${t} escapes the content root; falling back to ${U}.`),U):`${de}${r}`}export{W as MARKDOC_DOCUMENT_LOADER_ID,ve as MARKDOC_SEARCH_GROUP,G as MARKDOC_SIDEBAR_ITEM_LOADER_ID,U as MARKDOC_TEMPLATE_ID,ye 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{isPlanFeatureGranted as u}from"../../../../shared/plan-gates.js";import{SOURCE_TEMPLATE_PREFIX as d}from"../../../../shared/constants/template-ids.js";import{isObject as f}from"../../../../shared/utils/is-object.js";import{markdocNodeRange as p}from"../../../markdown/utils/node-source-range.js";import{replaceWithMarkdocError as m}from"../../../markdown/tags/markdoc-error.js";import{getPartialTwins as h}from"../../../markdown/tags/partial.js";import{CODE_WALKTHROUGH_TAG_NAMES as g,builtInMarkdocTags as _}from"../../../markdown/constants/builtin-tags.js";import{customMarkdocTagNames as v,isMarkdocValidationEnabled as ee,resolveMarkdocTagSet as y,resolveMarkdownPageValidationSet as te,userMarkdocSchemaFiles as b}from"../../../markdown/constants/tag-sets.js";import{normalizeRouteSlug as ne}from"../../../../shared/utils/routes/normalize-route-slug.js";import{resolveContentPath as x}from"../../../../shared/utils/resolve-content-path.js";import{PAGE_BANNER_SCHEMA as S,sanitizeConfig as C}from"../../../config-schema.js";import{notInPlanProblem as re}from"../../../plan-gates.js";import{matchPathMap as ie}from"../../utils/glob.js";import{filePathToRouteSlug as ae}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{splitUrlSuffix as w}from"../../../../shared/utils/routes/split-url-suffix.js";import{packMarkdocAst as oe,unpackMarkdocAst as T}from"../../../../shared/utils/packed-ast.js";import{isRouteSlugTarget as se}from"../../../../shared/utils/routes/is-route-slug-target.js";import{loadSidebarSubtreeLabel as ce}from"../../utils/sidebar-label.js";import{walkMarkdocAst as E}from"../../../markdown/utils/walk-markdoc-ast.js";import{markdocFirstHeading as le}from"../../../markdown/search/to-text.js";import{safeDecodeURI as ue}from"../../../../shared/utils/safe-decode-uri.js";import{shiftRange as de}from"../../../../shared/utils/shift-range.js";import{classifyLinkTarget as D}from"../../../link-checker/classify.js";import{onDiskLinkRefs as O}from"../../../link-checker/node-ref.js";import{isPartialPath as k}from"../../../markdown/utils/partials.js";import{FRONTMATTER_BLOCK_RE as A,computeFrontmatterLineOffset as j}from"../../../markdown/utils/frontmatter-offset.js";import{inlineRawPartials as M}from"../../../markdown/resolve/raw-partials.js";import{resolveMarkdownAst as N}from"../../../markdown/resolve/ast.js";import{resolveBannerForAppData as P}from"../app-data/banner.js";import{MARKDOC_DOCUMENT_LOADER_KEY as F}from"../../../../shared/constants/route-deps.js";import{pageLocale as I}from"../../utils/page-locale.js";import{captureSnippet as L,splitSourceLines as R}from"../../../../shared/utils/capture-snippet.js";import{collectAnchors as z}from"../../../markdown/utils/collect-anchors.js";import{frontmatterVariable as B}from"../../../markdown/utils/frontmatter-variable.js";import{markdownFirstHeading as V}from"../../../markdown/utils/first-heading.js";import{markdocAstToSearchSections as H}from"../../../markdown/search/to-sections.js";import{markdocAstToMarkdownDoc as fe}from"../../../markdown/search/to-markdown.js";import{isInternalPagePath as pe}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as me}from"../../utils/explicit-slugs.js";import{isSkillContentPath as he}from"../../utils/skill-paths.js";import{curationKeywordsOf as ge}from"../../../search/keywords.js";import _e from"js-yaml";const U=`markdoc-page`,W=r(`internal.markdoc`,`document`),G=r(`internal.markdoc`,`sidebar-item`),ve=`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:d,linkRefs:f}=await N(n,e.file.path,{resolverContext:a,tags:(await y(void 0,e.config)).tags,variables:{get env(){return e.config.publicEnv??{}}},transform:t=>De(t,e.file.path,Ee(e.config)),validation:ee()?await te(e.config):void 0}),p=j(t);Me(o);let m=await Te(r.seo,e),h=u(e.config,`banner`)?await P(Ne(r,e.file.path,e.logger),a):void 0,g=await ke(r,e),_=await Ae(r.navigation,e),v={...g.frontmatter,navigation:_.value,seo:m.seo,banner:h?.banner},b=Pe(r,o);return{value:{ast:oe(o),frontmatter:v,tagList:l,title:b,editPage:we(e.config,r,e.file.path),lastModified:e.file.lastModifiedAt},entityDeps:[...s,...be(),...m.entityDeps,...h?.deps??[],...g.entityDeps,..._.entityDeps],assetUsages:[...c,...m.assetUsages,...h?.assetUsages??[],...g.assetUsages],problems:xe(t,e.file.path,p,d,i),linkRefs:[...O(f,p),..._.linkRefs],targetInventories:[Se(o,{frontmatter:B(v,b)})]}},{usesProjectMarkdocSchema:!0,async markdown(e,t){let{tags:n}=await y(void 0,t.config),{chunks:r,headings:i}=fe(T(e.ast),{tags:n,locale:I(t),variables:{frontmatter:B(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=ge(e.frontmatter.keywords);return{docs:H(T(e.ast),r,{frontmatter:B(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 M(t,e.file.path,J(e));return{value:{label:Z(n)??V(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 ye=e({id:`internal.markdoc`,version:`3.52.0`,content:{filter:{match:e=>e.toLowerCase().endsWith(`.md`)&&!he(e)},extractFile(e,t){if(pe(e.path)||k(e.path,t.config))return{routes:[]};if(!u(t.config,`markdown`))return{routes:[],problems:[re(`Markdown pages`)]};let{banner:n,...r}=e.manifest,i=Fe(e,t),a=me(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:ae(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(A);if(!t)return{content:e,frontmatter:{}};let n=t[1]??``;try{let r=_e.load(n);return{content:e.slice(t[0].length),frontmatter:f(r)?r:{}}}catch(n){let r=n instanceof Error?n.message:String(n);return{content:e.slice(t[0].length),frontmatter:{},frontmatterError:r}}}function be(){return(b()??[]).map(e=>({kind:`file`,path:e}))}function xe(e,t,n,r,i){if(r.length===0&&i===void 0)return[];let a=R(e),o=r.map(e=>Ce(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:L(a,e)}})}return o}function Se(e,t){let{ids:n,exhaustive:r}=z(e,t);return{kind:`anchor`,exhaustive:r,targets:n}}function Ce(e,t,n,r){let i=e.location?.range;if(!i)return e;let a=de(i,n);return{...e,location:{filePath:r,range:a,snippet:L(t,a)}}}function we(e,t,n){let r=f(t.markdown)?t.markdown:{},i={...e.markdown?.editPage,...f(r.editPage)?r.editPage:{}};if(i.hide!==!0&&typeof i.baseUrl==`string`&&i.baseUrl!==``)return{to:`${i.baseUrl.replace(/(?<!\/)\/+$/,``)}/${n}`}}async function Te(e,t){if(!f(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 Ee(e){let t=/* @__PURE__ */ new Map;if(!u(e,`customMarkdocTags`))for(let e of v())t.set(e,`Custom Markdoc tags are not in this project's plan, so \`${e}\` is ignored.`);if(!u(e,`codeWalkthrough`))for(let e of g)t.set(e,`\`${e}\` is not in this project's plan and is ignored.`);return t}function De(e,t,n){let r=[];if(n.size===0)return r;for(let i of E(e,{getExtraNodes:h})){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 Oe=[`image`,`links`];async function ke(e,t){let n=t.config.markdown?.frontMatterKeysToResolve??Oe,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 Ae(e,t){let n=[],r=[];if(!f(e))return{value:e,entityDeps:n,linkRefs:r};let i={...e};for(let a of[`nextButton`,`previousButton`]){let o=e[a];if(!f(o)||typeof o.page!=`string`)continue;let{page:s,...c}=o,l=D(ue(s),t.file.path);l!==null&&r.push({kind:`link`,raw:s,...l});let u=await je(s,t);n.push(...u.entityDeps),i[a]={...c,label:typeof c.label==`string`?c.label:u.route&&await X(u.route,t),link:u.link}}return{value:i,entityDeps:n,linkRefs:r}}async function X(e,t){let n=await ce(t.entities,e);if(n!==void 0)return n;let r=t.routes.get(e.slug)?.metadata.seo;return f(r)&&typeof r.title==`string`&&r.title.trim()!==``?r.title:e.slug}async function je(e,t){let n=e.trim(),{path:r,suffix:i}=w(n);if(se(r)){let e=t.routes.bySlug(ne(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(w(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 Me(e){let t=/* @__PURE__ */ new Map;for(let n of E(e)){if(n.type!==`tag`||n.tag===void 0||_[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 Ne(e,t,n){if(e.banner===void 0)return;let{value:r,problems:i}=C(S,{banner:e.banner});for(let e of i)n?.warn(`${t}: ${e.message}`);return r.banner}function Pe(e,t){return Z(e)??le(t)??void 0}function Z(e){let t=f(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 Fe(e,t){let n=e.manifest.template;if(typeof n==`string`&&n.trim()!==``)return $(n,e.path,t.logger);let r=ie(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):`${d}${r}`}export{W as MARKDOC_DOCUMENT_LOADER_ID,ve as MARKDOC_SEARCH_GROUP,G as MARKDOC_SIDEBAR_ITEM_LOADER_ID,U as MARKDOC_TEMPLATE_ID,ye as markdocContentPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isMcpHidden as e,isPublicEndpointServedFromConfig as t}from"./server/config-gate.js";
|
|
1
|
+
import"./constants.js";import{isMcpHidden as e,isPublicEndpointServedFromConfig as t}from"./server/config-gate.js";function n(n){let r=!e(n);return{docs:{enabled:r,name:n.mcp?.name||`Docs MCP server`,publicEndpoint:r&&t(n)}}}export{n as buildMcpAppData};
|
|
@@ -12,14 +12,15 @@ export declare const MCP_TOKEN_ROUTE = "/_mcp/oauth2/token-portal";
|
|
|
12
12
|
export declare const MCP_CALLBACK_ROUTE = "/_mcp/oauth/callback";
|
|
13
13
|
export declare const EXECUTE_TOOL_NAME = "execute";
|
|
14
14
|
export declare const DISCOVER_TOOL_NAME = "discover";
|
|
15
|
-
export declare const CREATE_ANONYMOUS_SESSION_TOOL_NAME = "
|
|
16
|
-
export declare const MANAGE_API_CREDENTIALS_TOOL_NAME = "
|
|
17
|
-
export declare const REMOVE_API_CREDENTIALS_TOOL_NAME = "
|
|
15
|
+
export declare const CREATE_ANONYMOUS_SESSION_TOOL_NAME = "create-anonymous-session";
|
|
16
|
+
export declare const MANAGE_API_CREDENTIALS_TOOL_NAME = "manage-api-credentials";
|
|
17
|
+
export declare const REMOVE_API_CREDENTIALS_TOOL_NAME = "remove-api-credentials";
|
|
18
18
|
export declare const SUBMIT_FEEDBACK_TOOL_NAME = "submit-feedback";
|
|
19
19
|
export declare const CALL_API_WRITE_TOOL_NAME = "call-api_write";
|
|
20
20
|
export declare const LIST_WORKFLOWS_TOOL_NAME = "list-workflows";
|
|
21
21
|
export declare const GET_WORKFLOW_TOOL_NAME = "get-workflow";
|
|
22
22
|
export declare const RUN_WORKFLOW_TOOL_NAME = "run-workflow";
|
|
23
|
+
export declare const RUN_WORKFLOW_WRITE_TOOL_NAME = "run-workflow_write";
|
|
23
24
|
export declare const MCP_CREDENTIALS_ROUTE = "/mcp/credentials";
|
|
24
25
|
export declare const DEFAULT_MCP_SERVER_NAME = "Docs MCP server";
|
|
25
26
|
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=`
|
|
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=`create-anonymous-session`,h=`manage-api-credentials`,g=`remove-api-credentials`,_=`submit-feedback`,v=`call-api_write`,y=`list-workflows`,b=`get-workflow`,x=`run-workflow`,S=`run-workflow_write`,C=`/mcp/credentials`,w=`Docs MCP server`,T=[w,`MCP server`],E=`X-Redocly-AI-Metadata`,D=`mcp-tools`,O={readOnlyHint:!0,destructiveHint:!1,openWorldHint:!1},k={readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},A={"anthropic/requiresUserInteraction":!0};export{a as A2A_ROUTE,i as AGENT_CARD_ROUTE,E as AI_METADATA_HEADER,v as CALL_API_WRITE_TOOL_NAME,m as CREATE_ANONYMOUS_SESSION_TOOL_NAME,w as DEFAULT_MCP_SERVER_NAME,p as DISCOVER_TOOL_NAME,f as EXECUTE_TOOL_NAME,b as GET_WORKFLOW_TOOL_NAME,y as LIST_WORKFLOWS_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,C 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,D as MCP_TOOLS_ENTITY_TYPE,T as PLACEHOLDER_MCP_SERVER_NAMES,t as PUBLIC_MCP_ROUTE,O as READ_ONLY_ANNOTATIONS,g as REMOVE_API_CREDENTIALS_TOOL_NAME,A as REQUIRES_USER_INTERACTION_META,x as RUN_WORKFLOW_TOOL_NAME,S as RUN_WORKFLOW_WRITE_TOOL_NAME,_ as SUBMIT_FEEDBACK_TOOL_NAME,k as WRITE_TOOL_ANNOTATIONS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createInlineEntity as e}from"../../../loaders/define.js";import{isPlanFeatureGranted as t}from"../../../../shared/plan-gates.js";import{
|
|
1
|
+
import{createInlineEntity as e}from"../../../loaders/define.js";import{isPlanFeatureGranted as t}from"../../../../shared/plan-gates.js";import{CALL_API_WRITE_TOOL_NAME as n,CREATE_ANONYMOUS_SESSION_TOOL_NAME as r,DISCOVER_TOOL_NAME as i,EXECUTE_TOOL_NAME as a,GET_WORKFLOW_TOOL_NAME as o,LIST_WORKFLOWS_TOOL_NAME as s,MANAGE_API_CREDENTIALS_TOOL_NAME as c,MCP_TOOLS_ENTITY_TYPE as l,REMOVE_API_CREDENTIALS_TOOL_NAME as u,RUN_WORKFLOW_TOOL_NAME as d,RUN_WORKFLOW_WRITE_TOOL_NAME as f,SUBMIT_FEEDBACK_TOOL_NAME as p}from"./constants.js";import{notInPlanProblem as m}from"../../../plan-gates.js";import{MCP_TOOL_NAME_PATTERN as h}from"../../registry.js";import{isMcpHidden as g}from"./server/config-gate.js";import{buildMcpSetupPageRoutes as _}from"./setup-page.js";const v=`@mcp`,y=`mcp/invalid-tool`,b=/\.(ts|js)$/u,x=/\.d\.ts$/u,S=/* @__PURE__ */ new Set([n,`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`,p,a,i,`describe-tools`,r,c,u,s,o,d,f]);function C(e){return`mcp-tool-file:${e}`}function w(e){if(x.test(e)||!b.test(e))return!1;let t=e.split(`/`),n=t.indexOf(v);return n!==-1&&n<t.length-1}function T(e,t,n){if(!h.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(n!==void 0)return`Duplicate MCP tool name "${e}": defined by both "${n}" and "${t}". Tool names are file names, so each file name must be unique across @mcp folders.`;if(S.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 E(n){let r=[],i=[];if(g(n.config))return{entities:r,problems:i};if(!t(n.config,`customMcpTools`)){for(let{path:e}of n.files)i.push({...m(`Custom MCP tools`),location:{filePath:e}});return{entities:r,problems:i}}let a=/* @__PURE__ */ new Map;for(let{path:t}of n.files){let n=t.slice(t.lastIndexOf(`/`)+1).replace(b,``),o=T(n,t,a.get(n));if(o!==void 0){i.push({code:y,message:o,location:{filePath:t}});continue}a.set(n,t);let s={name:n,sourcePath:t};r.push(e(s,{stableKey:C(t),type:l,metadata:s}))}return{entities:r,problems:i}}const D={filter:{match:w},extractAll(e){return{routes:_(e.config),entities:[]}}};export{v as MCP_DIR_SEGMENT,y as MCP_TOOL_PROBLEM_CODE,S as RESERVED_MCP_TOOL_NAMES,w as isMcpToolFile,D as mcpContent,C as mcpToolFileEntityKey,E 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{
|
|
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 +1 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{createInlineEntity as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{runtimeTemplate as r}from"../../templates.js";import{
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{createInlineEntity as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{runtimeTemplate as r}from"../../templates.js";import{A2A_ROUTE as i,AGENT_CARD_ROUTE as a,MCP_AUTHORIZATION_SERVER_ROUTE as o,MCP_AUTHORIZE_ROUTE as s,MCP_CALLBACK_ROUTE as c,MCP_CREDENTIALS_ROUTE as l,MCP_PROTECTED_RESOURCE_ROUTE as u,MCP_REGISTER_ROUTE as d,MCP_ROUTE as f,MCP_SERVER_CARD_ROUTE as p,MCP_SETUP_TEMPLATE_ID as m,MCP_TOKEN_ROUTE as h,PUBLIC_MCP_ROUTE as g}from"./constants.js";import{collectVersionGroups as _,findVersionedDirectories as v}from"../../../versions/version-groups.js";import{MCP_CREDENTIALS_THEME_ENTITY_KEY as y,MCP_IGNORED_ROUTES_ENTITY_KEY as b}from"../../../../shared/constants/mcp.js";import{buildMcpAppData as x}from"./app-data.js";import{readCredentialsTheme as S}from"./credentials-theme.js";import{mcpContent as C,scanMcpToolFiles as w}from"./content-tools.js";import{collectIgnoredRouteSlugs as T}from"./ignored-routes.js";import{findMcpRedirectConflict as E}from"./redirects.js";function D(e,t,n,r){return{path:e,auth:`manual`,...r?{method:r}:{},handler:{filePath:t,importer:import.meta.url,exportName:n}}}const O=[D(f,`./server/handler.ts`,`mcp`),D(g,`./server/handler.ts`,`mcpPublic`),D(p,`./server/server-card.ts`,`mcpServerCard`,`GET`),D(u,`./server/oauth/discovery.ts`,`oauthProtectedResource`,`GET`),D(o,`./server/oauth/discovery.ts`,`oauthAuthorizationServer`,`GET`),D(d,`./server/oauth/register.ts`,`mcpRegister`,`POST`),D(s,`./server/oauth/authorize.ts`,`mcpAuthorize`,`GET`),D(h,`./server/oauth/token.ts`,`mcpToken`,`POST`),D(c,`./server/oauth/callback.ts`,`mcpCallback`,`GET`),D(`${c}/*`,`./server/oauth/callback.ts`,`mcpCallback`,`GET`),D(c,`./server/oauth/callback.ts`,`mcpConsent`,`POST`),D(`${c}/*`,`./server/oauth/callback.ts`,`mcpConsent`,`POST`),D(l,`./server/gateway/credentials-handler.ts`,`mcpCredentials`,`ALL`),D(a,`./server/agent-card.ts`,`agentCard`,`GET`),D(i,`./server/agent-card.ts`,`a2a`,`POST`)],k=e({id:`internal.mcp`,version:`1.11.0`,content:C,server:{routes:O},templates:{[m]:r(n(`./client/template.tsx`,import.meta.url))},async finalize(e){let n=E(e.config.redirects);if(n)throw Error(`Redirect "${n.from}" references the reserved MCP route "${n.route}". Remove it: the MCP endpoints are served by the internal.mcp plugin and a redirect would shadow them.`);let r={mcp:x(e.config)},{entities:i,problems:a}=w(e),o=await S(e.io,e.config.palette,t=>e.logger.debug(t));i.push(t(o,{stableKey:y}));let s=e.config.mcp?.ignore??[];if(s.length===0)return{appData:r,problems:a,entities:i};let c=await _({io:e.io,routes:e.routes,versionedDirectories:v(e.routes.all())}),l=T(e.routes.all(),s,c,e.localeContext);return l.length===0?{appData:r,problems:a,entities:i}:(e.logger.debug(`mcp.ignore: hiding ${l.length} routes from the MCP tools`),i.push(t(l,{stableKey:b})),{appData:r,problems:a,entities:i})}});export{k as mcpContentPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A2A_ROUTE as e,MCP_ROUTE as t,MCP_SERVER_CARD_ROUTE as n}from"../constants.js";import{withPathPrefix as r}from"../../../../../shared/path-prefix.js";import{SKILLS_INDEX_SLUG as i,skillMarkdownPath as a}from"../../../utils/skill-paths.js";import{isMcpContentProtected as o,isMcpHidden as s,resolveMcpAccess as c}from"./config-gate.js";import{SKILL_ENTITY_TYPE as l}from"../../../types/skill-entity.js";import{publicBaseUrl as u}from"../../../utils/request-origin.js";import{isEntityScopeVisible as d}from"../../../../../shared/rbac/entity-scope.js";import{notFoundResponse as f}from"../../../../../server/plugin-context.js";import{CORS_ANY_ORIGIN as p,MCP_AUTH_SCHEMES as m}from"./oauth/constants.js";import"./auth.js";const h=[`text/plain`],g=[`text/plain`],_={streaming:!1,pushNotifications:!1},v={"Cache-Control":`no-store`};async function y(e,t){let n=!!e.request.viewer?.isAuthenticated;return o(c(e.config))&&!n?[]:(await e.entities.list({type:l})).flatMap(n=>{let{slug:i,title:o,description:s}=n.metadata??{};return typeof i!=`string`||!d(n,e.request.teams,t=>e.logger?.warn(t))?[]:[{id:i,name:o??i,description:s??``,tags:[],url:`${t}${r(a(i))}`}]})}async function b(n,i){if(s(i.config)||i.config.skills?.hide===!0)return f();n.set(`realmCacheControlOwned`,!0);let a=u(i.config,i.request),l=o(c(i.config)),d=i.config.seo;return n.json({name:d?.title||d?.projectTitle||`Developer Documentation`,description:d?.description||`Documentation agent card announcing this site's agent skills and MCP server.`,url:`${a}${r(e)}`,documentationUrl:`${a}${r(`/`)}`,version:`0.0.1`,protocolVersion:`0.3.0`,preferredTransport:`HTTP+JSON`,capabilities:{..._,extensions:[{uri:`https://modelcontextprotocol.io`,description:`Model Context Protocol server exposing the documentation tools and skills.`,params:{url:`${a}${r(t)}`,...l?{authentication:{required:!0,schemes:[...m]}}:{}}}]},defaultInputModes:h,defaultOutputModes:g,skills:await y(i,a)},200,{...v,...p})}function x(e,t){if(s(t.config))return f();let a=[`<${r(n)}>; rel="mcp-server-card"`];return t.config.skills?.hide!==!0&&a.push(`<${r(i)}>; rel="agent-skills"`),e.json({error:{code:`405`,message:`Method not allowed`}},405,{Link:a.join(`, `),...p,"Access-Control-Expose-Headers":`Link`})}export{x as a2a,b as agentCard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as e}from"../../../../../shared/utils/is-object.js";import{
|
|
1
|
+
import"../constants.js";import{isObject as e}from"../../../../../shared/utils/is-object.js";import{thrownErrorClass as t}from"./tool-errors.js";import{waitUntil as n}from"../../../../../server/wait-until.js";import{redactSecretShapes as r}from"./secret-patterns.js";import{maskBodyCredentials as i,maskCodeCredentials as a}from"./code-credentials.js";import{redactSecretsFromString as o}from"./gateway/fetch/redact.js";import{createHash as s}from"node:crypto";function c(e){return{client:e.client,clientVersion:e.clientVersion,requestId:e.requestId,messageId:e.messageId,callerSubject:e.callerSubject,clientIp:e.request.ip??void 0}}const l=`[mcp-audit]`,u=4096;function d(e){return s(`sha256`).update(e,`utf8`).digest(`hex`)}function f(e){if(e.length<=4096)return e;let t=e.slice(0,u),n=t.search(/\s\S*$/),r=n>0?t.slice(0,n):t;return`${r}…[truncated: kept ${r.length} of ${e.length} chars]`}function p(e,t=[]){return r(o(f(e),t))}const m=/(?<=^|[\s('"])(?:file:\/\/\/?|\/)(?:[^\s()/:'"]+\/)+/gm;function h(e){return p(e.replace(m,``))}function g(e){return{sha256:d(e),bytes:Buffer.byteLength(e,`utf8`)}}function _(e){return Object.keys(e??{}).map(e=>e.toLowerCase()).sort().join(`,`)}const v=/* @__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 y(e,t=[],n=[]){let r;try{r=new URL(e)}catch{return p(e,t)}let i=new Set(n.map(e=>e.toLowerCase()));for(let e of[...r.searchParams.keys()]){let t=e.toLowerCase();(v.has(t)||i.has(t))&&r.searchParams.set(e,`redacted`)}return r.username=``,r.password=``,p(r.href,t)}function b(e,t,n){let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0&&e!==``));try{e?.info(`${l} ${t}`,r)}catch{}}const x=/(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,S=/(process\s*(?:\.\s*env\b|\[)|globalThis|require\s*\(|__proto__)/;function C(e){let t=[];return S.test(e)&&t.push(`env_probe`),x.test(e)&&t.push(`internal_target`),{sha256:d(e),length:e.length,flags:t.sort().join(`,`)}}function w(e){try{return JSON.stringify(e)??String(e)}catch{return`«[unserializable]»`}}function T(e,{tool:t,mode:n,args:r,result:a,errorClass:o,client:s,clientVersion:c,requestId:l,messageId:u,callerSubject:f,clientIp:m}){if(t===`execute`||t===`call-api_write`)return;let h=w(r),_=a===void 0?void 0:g(a),v=r?.sessionHandle,y=typeof v==`string`&&v!==``?v:void 0,x=f??y;b(e,`Record MCP tool call`,{tool:t,mode:n,server_type:`docs`,error_class:o,client:s,client_version:c,request_id:l,message_id:u,subject_sha256:x?d(x):void 0,client_ip:m,args_sha256:d(h),args:p(i(h),y?[y]:[]),result_sha256:_?.sha256,result_bytes:_?.bytes})}async function E(e,r,i,a){let o={tool:r,mode:e.mcpMode,args:i,...c(e)},s=Date.now(),l;try{l=await a()}catch(i){throw T(e.logger,{...o,errorClass:t(i)}),e.telemetry?.toolThrew(r,Date.now()-s,i),e.telemetry&&n(e.telemetry.flush()),i}let u=O(l)&&l.isError===!0;return T(e.logger,{...o,result:j(l),errorClass:u?`tool_error`:void 0}),e.telemetry?.toolReturned(r,Date.now()-s,l),e.telemetry&&n(e.telemetry.flush()),l}const D=/* @__PURE__ */ new Set([`text`,`image`,`audio`,`resource`,`resource_link`]);function O(t){return e(t)&&Array.isArray(t.content)&&t.content.every(t=>e(t)&&D.has(t.type))}function k(t){return e(t)&&t.resultType===`input_required`}function A(e,t=``){return e.content.map(e=>e.type===`text`?e.text:``).join(t)}function j(e){if(typeof e==`string`)return e;if(O(e))return A(e);if(k(e))return``;try{return JSON.stringify(e)??``}catch{return``}}function M(e,{audit:t,code:n,description:r,sessionHandle:i,toolNames:o,fetchBudget:s,fetchCapable:c,requestId:l,messageId:u,callerSubject:f,clientIp:m}){let h=f??i;b(e,`Record code execution input`,{code_sha256:t.sha256,code_length:t.length,request_id:l,message_id:u,flags:t.flags,subject_sha256:h?d(h):void 0,client_ip:m,description:p(r),tools:[...o].sort().join(`,`),fetch_capable:c,fetch_budget:s,code:p(a(n))})}function N(e,{rawUrl:t,method:n,host:r,outcome:a,durationMs:o,injectedSecretValues:s,credentialQueryParams:c,path:l,api:u,status:f,injectedScheme:m,requestHeaders:h,requestBody:v,responseHeaders:x,responseBody:S,caller:C={}}){let{requestId:w,callerSubject:T,clientIp:E}=C,D=S===void 0?void 0:g(S);b(e,`Record gateway fetch`,{url_sha256:d(t),host:r,method:n,path:l,api:u,outcome:a,status:f,injected_scheme:m,duration_ms:o,request_id:w,subject_sha256:T?d(T):void 0,client_ip:E,url:y(t,s,c),request_header_names:_(h),request_body:v===void 0?void 0:p(i(v),s),response_header_names:_(x),response_sha256:D?.sha256,response_bytes:D?.bytes})}export{u as AUDIT_FIELD_MAX_CHARS,l as AUDIT_LOG_PREFIX,C as auditCode,_ as auditHeaderNames,p as auditInput,d as auditSha256,h as auditStack,E as auditToolCall,y as auditUrl,c as callAttribution,O as isCallToolResult,b as logAuditRecord,M as logCodeExecutionAudit,N as logGatewayFetchAudit,T as logMcpToolCallAudit,j as toolOutputText,A as toolResultText,f as truncateAuditField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{MCP_AUTHORIZATION_SERVER_ROUTE as e,MCP_PROTECTED_RESOURCE_ROUTE as t,PUBLIC_MCP_ROUTE as n}from"../constants.js";import{withPathPrefix as r}from"../../../../../shared/path-prefix.js";import{ANONYMOUS_VIEWER as i}from"../../../../../shared/types/auth.js";import{canAccessMcpFeature as a,isMcpContentProtected as o,isPublicEndpointServed as s,resolveMcpAccess as c}from"./config-gate.js";import{publicOrigin as l}from"../../../utils/request-origin.js";import{getBearerVerifier as u,getSessionIssuer as d}from"../../../../../server/auth/middleware.js";import{isAssistantAnonymousToken as f}from"../../../../../server/ask-ai/assistant-anonymous-token.js";import{CORS_ANY_ORIGIN as p,CORS_EXPOSE_CHALLENGE as m,SUPPORTED_MCP_SCOPES as h}from"./oauth/constants.js";function g(e){let t=/^Bearer\s+(\S+)$/i.exec((e??``).trim());return t?t[1]:null}function _(n,i){let a=i?[`error="${i.code}"`,`error_description="${i.description}"`]:[];return a.push(`resource_metadata="${n}${r(t)}"`,`scope="${h.join(` `)}"`,`authorization_uri="${n}${r(e)}"`),`Bearer ${a.join(`, `)}`}function v(e,t){return t?`${e}. A public endpoint that serves anonymous-accessible content is available at ${t}.`:e}function y(e,t,n){return new Response(JSON.stringify(t),{status:e,headers:{"Content-Type":`application/json`,"Cache-Control":`no-store`,...n}})}function b(e,t){return y(401,{error:`unauthorized`,message:v(`Authentication required`,t)},{"WWW-Authenticate":_(e),...m})}function x(e,t){return y(401,{error:`invalid_token`,message:v(`Invalid or expired token`,t)},{"WWW-Authenticate":_(e,{code:`invalid_token`,description:`Invalid or expired token`}),...m})}function S(){return y(403,{error:`forbidden`,message:`You do not have access to this MCP server`},{...p})}async function C(e){let{c:t,ctx:p}=e,m=e=>p.logger?.warn(e),h=c(p.config),_=o(h);if(e.forceAnonymous){let e=await p.withViewer(i);return a(h,e.request.teams,!1,m)?{kind:`allow`,ctx:e,isProtected:_}:{kind:`deny`,response:S()}}let v=e=>{let t=l(p.request);return{kind:`deny`,response:e(t,s(p.config,h)?`${t}${r(n)}`:void 0)}},y=p.request.viewer??i,C,w,T=p,E=g(t.req.header(`authorization`)),D=d(t)?.artifactSecret,O=E!==null&&D!==void 0&&await f(E,D);if(!_)w=O||E===null?void 0:E;else if(O)y=i,T=await p.withViewer(i);else if(E!==null){let e=await u(t)?.(E);if(!e)return v(x);y=e.viewer,C=e.claims,w=E,T=await p.withViewer(y)}else if(!y.isAuthenticated)return v(b);return a(h,T.request.teams,y.isAuthenticated,m)?{kind:`allow`,ctx:T,isProtected:_,accessToken:w,claims:C}:{kind:`deny`,response:S()}}export{C as authorizeMcpRequest,o as isMcpContentProtected,s as isPublicEndpointServed,g as readBearerToken,c as resolveMcpAccess};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CALL_API_WRITE_TOOL_NAME as e,CREATE_ANONYMOUS_SESSION_TOOL_NAME as t,DISCOVER_TOOL_NAME as n,EXECUTE_TOOL_NAME as r,MANAGE_API_CREDENTIALS_TOOL_NAME as i,REMOVE_API_CREDENTIALS_TOOL_NAME as a,SUBMIT_FEEDBACK_TOOL_NAME as
|
|
1
|
+
import{CALL_API_WRITE_TOOL_NAME as e,CREATE_ANONYMOUS_SESSION_TOOL_NAME as t,DISCOVER_TOOL_NAME as n,EXECUTE_TOOL_NAME as r,MANAGE_API_CREDENTIALS_TOOL_NAME as i,REMOVE_API_CREDENTIALS_TOOL_NAME as a,RUN_WORKFLOW_WRITE_TOOL_NAME as o,SUBMIT_FEEDBACK_TOOL_NAME as s}from"../../constants.js";const c=`fetch`,l=/* @__PURE__ */ new Set([r,n,t,i,a,s,e,o]),u=`site`,d=`tools`,f=`__fetchBridge`,p=`fetch`,m=1e4,h=45e3,g=5e4,_=1e3,v=50,y=50,b={ratePerMin:600,quotaPerDay:1e5},x=8388608,S=1048576,C=1048576,w=262144,T=67108864,E=134217728,D=16777216,O=65536,k=2,A=4,j=5e3,M=`The sandbox failed to run this code. The cause was logged on the server.`,N=`HostFunctionError`,P=`HostOutputTooLargeError`,F={NoReturn:`no_return`,OutputTooLarge:`output_too_large`,Timeout:`timeout`,MemoryLimit:`memory_limit`,SyntaxError:`syntax_error`,HostError:`host_error`,RuntimeError:`runtime_error`};export{j as ACQUIRE_TIMEOUT_MS,l as CODE_MODE_TOOL_NAMES,h as DEFAULT_MAX_LIFETIME_MS,m as DEFAULT_TIMEOUT_MS,g as EXECUTE_DEADLINE_MS,p as FETCH_BRIDGE_FUNCTION_NAME,f as FETCH_BRIDGE_GLOBAL_NAME,c as FETCH_TOOL_NAME,y as GATEWAY_FETCH_BUDGET_PER_EXEC,b as GATEWAY_FETCH_LIMITS,N as HOST_FUNCTION_ERROR_NAME,P as HOST_OUTPUT_TOO_LARGE_ERROR_NAME,D as INITIAL_TOTAL_MEMORY_BYTES,M as INTERNAL_ERROR_MESSAGE,T as MAX_ALLOCATION_BYTES,k as MAX_CONCURRENT_RUNS,v as MAX_FETCH_CALLS,S as MAX_FETCH_OUTPUT_BYTES,A as MAX_QUEUED_RUNS,C as MAX_RESULT_BYTES,w as MAX_STACK_SIZE_BYTES,_ as MAX_TOOL_CALLS,x as MAX_TOOL_OUTPUT_BYTES,E as MAX_TOTAL_MEMORY_BYTES,F as SANDBOX_FAILURE,u as SITE_GLOBAL_NAME,d as TOOLS_GLOBAL_ALIAS,O as WASM_PAGE_BYTES};
|
|
@@ -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
|
|
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 `create-anonymous-session`. Required when an API needs credentials. This parameter is only offered when `create-anonymous-session` 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,8 +1,8 @@
|
|
|
1
|
-
import{CALL_API_WRITE_TOOL_NAME as e}from"../../constants.js";import{buildToolList as
|
|
2
|
-
`):e}function
|
|
3
|
-
`)}function
|
|
4
|
-
`)}function
|
|
5
|
-
`)}function
|
|
6
|
-
`);function
|
|
7
|
-
`):``}const
|
|
8
|
-
`);export{
|
|
1
|
+
import{CALL_API_WRITE_TOOL_NAME as e,RUN_WORKFLOW_WRITE_TOOL_NAME as t}from"../../constants.js";import{buildToolList as n}from"./tool-list.js";const r=2048,i="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).",a="Write plain JavaScript: no type annotations, interfaces or `as` casts.";function o(e,t){if(t.length===0)return e;let i=r-e.length-66-3,a=n(t,i);return a?[e,``,"Functions for `execute` scripts (signatures come from `discover`):",a].join(`
|
|
2
|
+
`):e}function s(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 c(e,t){let n=e&&t(e);return n&&n.length<=r?n:t()}function l(e,t=[],n){return o(c(n,t=>s(e,t)),t)}function u(e){return e?`Tools for the documentation at ${e}.`:`Tools for this documentation site.`}function d(e){return`${u(e)} Use them to answer questions about the content of these docs.`}function f(e){return c(e,d)}function p(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 m({hasFetch:n,hasCallApiWrite:r,hasWorkflows:i,hasRunWorkflowWrite:a,docsUrl:o}){let s=[d(o),"- `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 n&&s.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."),r&&s.push(`\`fetch\` sends only safe methods. Send one write request to a documented API with the \`${e}\` tool.`),i&&s.push("This project also ships ready-made multi-step API workflows. When a task needs several API calls, call `listWorkflows` first and run a matching workflow with `runWorkflow` instead of chaining `fetch` calls."),a&&s.push(`\`runWorkflow\` runs only read-only workflows. Run a workflow that writes with the \`${t}\` tool.`),s.join(`
|
|
5
|
+
`)}function h(e){return o(c(e.docsUrl,t=>m({...e,docsUrl:t})),e.toolList??[])}const g=[`listApis`,`getEndpoints`],_=[`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 v(e){if(g.every(t=>e.includes(t)))return _;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 y=["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{i as EXECUTE_ARGS_NOTE,a as PLAIN_JAVASCRIPT_RULE,y as USAGE_NOTES,h as buildCodeModeInstructions,p as buildDiscoverDescription,l as buildExecuteDescription,v as buildExecuteExample,f as buildToolsModeInstructions,u as docsSiteSentence};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{RBAC_TEAM_ANONYMOUS as e}from"../../../../../shared/rbac/types.js";import{canView as t,parseRbacScope as n,resolveRole as r}from"../../../../../shared/rbac/engine.js";import{resolveViewerTeams as i}from"../../../../../shared/rbac/teams.js";import{ANONYMOUS_VIEWER as a}from"../../../../../shared/types/auth.js";function o(e){return!!e.mcp?.hide}function s(e){return e!==void 0&&(Object.keys(e),!0)}function c(i){if(!i||typeof i!=`object`||Object.keys(i).length===0)return!1;let a=n(i,`rbac`,()=>{});return!t(r(a,[e]))}function l(e){let t=e.access?.rbac;return{requiresLogin:e.access?.requiresLogin===!0,rbacConfigured:s(t),rbacDeniesAnonymous:Object.values(t?.content??{}).some(c)||c(t?.features?.mcp),featureScope:t?.features?.mcp}}function u(e){return e.requiresLogin||e.rbacDeniesAnonymous}function d(e,t){return!!e.mcp?.publicEndpoint&&u(t)&&p(t,i(a),!1)}function f(e){return d(e,l(e))}function p(e,i,a,o=()=>{}){return e.rbacConfigured?e.featureScope===void 0||t(r(n(e.featureScope,`features.mcp`,o),i)):!e.requiresLogin||a}export{p as canAccessMcpFeature,u as isMcpContentProtected,o as isMcpHidden,d as isPublicEndpointServed,f as isPublicEndpointServedFromConfig,l as resolveMcpAccess};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{MCP_TOOLS_ENTITY_TYPE as e}from"../constants.js";import{publicOrigin as t}from"../../../utils/request-origin.js";import{isSubprocessError as n}from"../../../../../server/subprocess/runner.js";import{errorMessage as r}from"../../../../../shared/utils/error-message.js";import{ToolHandlerError as i}from"./tool-errors.js";import{fileURLToPath as a}from"node:url";import{parse as o}from"hono/utils/cookie";const s=a(import.meta.url);function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e){return`MCP tool "${e}" is not registered or its module does not export a handler for "${e}". Expected \`export default { '${e}': handler }\` or a single tool definition with \`description\` and \`execute\` as the default export.`}function u(e,t){if(c(e))return typeof e.execute==`function`&&typeof e.description==`string`?e:e[t]}const d=/* @__PURE__ */ new Set([`text`,`image`,`audio`,`resource`,`resource_link`]);function f(e){return c(e)&&Array.isArray(e.content)&&e.content.every(e=>c(e)&&d.has(e.type))}function p(e,t){if(f(t))return t;if(typeof t==`string`)return{content:[{type:`text`,text:t}]};let n;try{n=JSON.stringify(t)}catch(t){throw Error(`MCP tool "${e}" returned a value that cannot be serialized to JSON: ${S(t)}`)}if(n===void 0)throw Error(`MCP tool "${e}" returned an invalid result.`);return{content:[{type:`text`,text:n}]}}const m={readFile:async()=>{throw Error(`Project files are not available in this environment.`)}};async function h(e,t){let n=u((await t.loadModule(e.handlerModulePath)).default,e.toolName),i=typeof n==`function`?n:n?.execute;if(typeof i!=`function`)return{ok:!1,code:`no-handler-export`,message:l(e.toolName)};let a={...e.context,fs:m};try{if(e.mode===`isAvailable`){let e=typeof n==`function`?void 0:n?.isAvailable;return{ok:!0,output:!e||await e(a)}}let t=await i(e.args,a,e.extra);return{ok:!0,output:p(e.toolName,t)}}catch(e){return{ok:!1,code:`handler-error`,message:r(e),stack:e instanceof Error?e.stack:void 0}}}function g(e){let n=e.request.viewer;return{user:{teams:e.request.teams,claims:e.claims??{...n},email:n?.email,idpAccessToken:void 0,idpId:void 0,isAuthenticated:n?.isAuthenticated??!1},config:e.config,baseUrl:t(e.request),params:{},query:Object.fromEntries(new URL(e.request.url).searchParams),cookies:o(e.request.headers.cookie??``),products:Object.values(e.config.products??{}).map(e=>e.name),accessToken:e.accessToken,metadata:e.metadata}}function _(e,t,n){if(!c(e)||e.type!==`object`)return null;let r=`Invalid arguments for tool "${n}":`;if(!c(t))return`${r} expected an object.`;let i=Array.isArray(e.required)?e.required:[];for(let e of i)if(typeof e==`string`&&!(e in t))return`${r} missing required field "${e}".`;let a=c(e.properties)?e.properties:{};for(let[e,n]of Object.entries(t)){let t=a[e];if(c(t)){if(typeof t.type==`string`&&!v(n,t.type))return`${r} field "${e}" must be ${t.type}.`;if(Array.isArray(t.enum)&&!t.enum.includes(n))return`${r} field "${e}" must be one of ${JSON.stringify(t.enum)}.`}}return null}function v(e,t){switch(t){case`string`:return typeof e==`string`;case`number`:return typeof e==`number`&&Number.isFinite(e);case`integer`:return typeof e==`number`&&Number.isInteger(e);case`boolean`:return typeof e==`boolean`;case`object`:return c(e);case`array`:return Array.isArray(e);case`null`:return e===null;default:return!0}}function y(e,t,n,r,i){if(!t.subprocess)throw Error(`MCP tool "${e.toolName}" cannot run on this host: no subprocess.`);return t.subprocess.run({modulePath:s,exportName:`invokeCustomTool`,input:{handlerModulePath:t.subprocess.resolveContentModule(e.handlerFilePath),toolName:e.toolName,mode:n,args:r,context:g(t),extra:{sessionId:i?.sessionId,requestId:i?.mcpReq.id??t.requestId,_meta:i?.mcpReq._meta}},reuse:!import.meta.env.DEV,timeoutMs:3e4})}function b(e,t){return{schema:e,isAvailable:t.hasAvailabilityGate?async n=>{if(!n.subprocess)return!1;let r=n.isAvailableMemo?.get(e.name);if(r)return r;let i=(async()=>{try{let e=await y(t,n,`isAvailable`);return e.ok&&e.output===!0}catch(t){return n.logger?.warn(`MCP tool "${e.name}" isAvailable failed: ${S(t)}`),!1}})();return n.isAvailableMemo?.set(e.name,i),i}:void 0,async execute(n,r,a){let o=_(t.argsSchema,n,e.name);if(o)throw Error(o);let s=await y(t,r,`execute`,n,a?.serverContext);if(!s.ok){let e=new i(s.message);throw e.stack=s.stack??e.stack,e}return s.output}}}function x(e){let{declaration:t}=e;return b({name:t.name,title:t.title,description:t.description,schema:t.schema,outputSchema:t.outputSchema,annotations:t.annotations},{toolName:t.name,handlerFilePath:e.handler.filePath,argsSchema:t.schema,hasAvailabilityGate:!0})}function S(e){return n(e)?`${e.code}: ${e.message}`:r(e)}function C(e,t){if(!c(t))return{ok:!1,errors:["the default export must be an object with `description` and `execute` properties. Move shared helper code outside the `@mcp` folder."]};let{description:n,inputSchema:r,outputSchema:i,annotations:a,isAvailable:o,execute:s}=t,l=[];return(typeof n!=`string`||n.trim()===``)&&l.push("`description` must be a non-empty string."),typeof s!=`function`&&l.push("`execute` must be a function."),r!==void 0&&(c(r)?r.type!==void 0&&r.type!==`object`&&l.push('`inputSchema.type` must be "object" because MCP tool arguments are named.'):l.push("`inputSchema` must be a JSON Schema object.")),i!==void 0&&!c(i)&&l.push("`outputSchema` must be a JSON Schema object."),a!==void 0&&!c(a)&&l.push("`annotations` must be an object."),o!==void 0&&typeof o!=`function`&&l.push("`isAvailable` must be a function."),l.length>0||typeof n!=`string`?{ok:!1,errors:l}:{ok:!0,schema:{name:e,description:n,schema:Object.assign({type:`object`},r??{properties:{}}),outputSchema:i,annotations:a},hasAvailabilityGate:typeof o==`function`}}async function w(t){let n=[],r=[];for(let i of await t.entities.list({type:e})){let{name:e,sourcePath:a}=i.metadata,o=e=>r.push(`Invalid MCP tool file "${a}": ${e}`);if(t.reservedNames.has(e)){o(`the tool name "${e}" is already used by a built-in MCP tool. Rename the file.`);continue}let s;try{s=(await t.loadContentModule(a)).default}catch(e){o(`the file failed to load: ${S(e)}. Tool files must not have module-level side effects.`);continue}let c=C(e,s);if(!c.ok){o(c.errors.join(` `));continue}n.push({schema:c.schema,sourcePath:a,hasAvailabilityGate:c.hasAvailabilityGate})}return{tools:n,errors:r}}function T(e){return`MCP tool "${e.schema.name}" in ${e.sourcePath} declares no \`outputSchema\`. Add one that describes the returned value.`}const E=/* @__PURE__ */ new Set;function D(e,t){e&&!E.has(t)&&(E.add(t),e.warn(t))}async function O(e){let{loadContentModule:t,logger:n}=e;if(!t)return[];let{tools:r,errors:i}=await w({entities:e.entities,loadContentModule:t,reservedNames:e.reservedNames});for(let e of i)D(n,e);for(let e of r)e.schema.outputSchema===void 0&&D(n,T(e));return r.map(e=>b(e.schema,{toolName:e.schema.name,handlerFilePath:e.sourcePath,argsSchema:e.schema.schema,hasAvailabilityGate:e.hasAvailabilityGate}))}export{O as buildMcpFileTools,x as createCustomTool,h as invokeCustomTool,w as loadMcpFileTools,T as missingOutputSchemaWarning,C as validateToolDefinition};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`),annotations:
|
|
1
|
+
import{CALL_API_WRITE_TOOL_NAME as e,REQUIRES_USER_INTERACTION_META as t,WRITE_TOOL_ANNOTATIONS as n}from"../../constants.js";import{SsrfBlockedError as r}from"../../../../../../server/ssrf/ssrf-blocklist.js";import{callableApis as i}from"./eligibility.js";import{getOfferedWriteHttpMethods as a}from"./allowed-http-methods.js";import{GatewayFetchSystemError as o,GatewayFetchUserError as s}from"./fetch/fetch-errors.js";import{runExecuteWithGateway as c}from"./index.js";import{SESSION_HANDLE_PROPERTY as l}from"./tools.js";const u=[`content-type`,`location`],d=/[/+]json\b/i;function f(r){return{name:e,title:`Call a documented API`,description:[`Send one request with a write method to one documented operation of a callable API.`,"Read the operation with `execute` first: the server URL, the path parameters, and the body shape. Pass the same `url`, `method`, `headers` and `body` you would pass to `fetch` in a script.",`Send only the operation the user asked for. When its method or operation is not allowed, tell the user and stop. Do not substitute another operation.`].join(`
|
|
2
|
+
`),annotations:n,_meta:t,schema:{type:`object`,required:[`url`,`method`],additionalProperties:!1,properties:{url:{type:`string`,minLength:1,description:"The full URL: a documented server URL of the API plus the operation path, with every `{placeholder}` filled and the query parameters included."},method:r.length>0?{type:`string`,enum:r}:{type:`string`},headers:{type:`object`,additionalProperties:{type:`string`},description:`The request headers. The stored credential is added by the server.`},body:{description:"The request body: a JSON value, sent as `application/json`, or a string, sent as is with the `content-type` header you pass."},securityScheme:{type:`string`,minLength:1,description:`The security scheme whose stored credential to send. Omit it to let the server choose.`},sessionHandle:l}},outputSchema:{type:`object`,required:[`status`,`headers`],properties:{status:{type:`number`},headers:{type:`object`,additionalProperties:{type:`string`}},body:{description:`The response body: parsed JSON for a JSON response, else text.`}}}}}function p(e,t){return Object.keys(e).some(e=>e.toLowerCase()===t)}function m({url:e,method:t,headers:n={},body:r,securityScheme:i}){return r===void 0||typeof r==`string`?{url:e,method:t,headers:n,body:r,securityScheme:i}:{url:e,method:t,headers:p(n,`content-type`)?n:{...n,"content-type":`application/json`},body:JSON.stringify(r),securityScheme:i}}function h({headers:e,bodyText:t}){if(!d.test(e[`content-type`]??``))return t;try{return JSON.parse(t)}catch{return t}}async function g(e,t){try{let n=await t(m(e)),r=Object.fromEntries(u.flatMap(e=>n.headers[e]===void 0?[]:[[e,n.headers[e]]])),i={status:n.status,headers:r,body:h(n)};return{content:[{type:`text`,text:JSON.stringify(i)}],structuredContent:i}}catch(e){if(!(e instanceof s||e instanceof o||e instanceof r))throw e;return{content:[{type:`text`,text:e.message}],isError:!0}}}async function _(e){return(await i(e)).length>0}const v={schema:f([]),schemaFor:e=>f(a(e)),isAvailable:async e=>a(e).length>0&&await _(e),execute(t,n,r){let i=t,o=r?.serverContext;if(!o)throw Error(`\`${e}\` runs only as a top-level tool call.`);return c({ctx:n,sessionHandle:i.sessionHandle,serverContext:o,allowedHttpMethods:a(n),run:e=>g(i,e)})}};export{v as callApiWriteTool};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isMcpHidden as e}from"../config-gate.js";import{notFoundResponse as t}from"../../../../../../server/plugin-context.js";import{resolveMcpMode as n}from"../mode.js";import{isGatewayEnabled as r}from"./env.js";async function i(i,a){if(!r(a.config)||n()!==`code`||e(a.config))return t();let{serveCredentials:o}=await import(`./credentials.js`);return o(i,a)}export{i as mcpCredentials};
|
package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{MCP_CREDENTIALS_ROUTE as e}from"../../../constants.js";import{withPathPrefix as t}from"../../../../../../../shared/path-prefix.js";import{FORM_ACTIONS as n}from"./constants.js";import{secretTtlSeconds as r}from"../subject.js";import{ELICITATION_TTL_MS as i}from"../secret-store.js";import{credentialSchemesOf as a,schemeFieldName as o}from"./form-contract.js";import{ICONS as s,code as c,escapeHtml as l,siteHeader as u,targetTitle as d}from"./layout.js";const f=`form-error`,p=new Intl.DateTimeFormat(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`,timeZone:`UTC`}),m={bearer:{title:`API token`,noun:`API token`,placeholder:`Paste your API token`},apiKey:{title:`API key`,noun:`API key`,placeholder:`Paste your API key`},cookie:{title:`Cookie`,noun:`cookie value`,placeholder:`Paste the cookie value`},oauth2ClientCredentials:{title:`OAuth2`,noun:`access token`,placeholder:`Paste an access token`},raw:{title:`Authorization header`,noun:`header value`,placeholder:`Bearer <token>`}};function h(r){let{site:o,target:c,token:p,error:m}=r,h=t(e),y=a(c),b=y.length>1,x=g(r,y),S=x.some(e=>e.isStored),C=b&&S,w=x.map(e=>b?v(e):_(e)).join(``),O=C?`<button class="text-danger" type="submit" form="remove-all">Remove all credentials</button>`:``,k=m?`<div class="banner" role="alert" id="${f}">${s.alert}<p>${l(m.message)}</p></div>`:``,j=c.subject.startsWith(`anon:`)?`<div class="banner warning">${s.warning}<p>This link is not tied to an account. The person who sent it to you can use the credentials that you save here. Continue only if you asked your AI client for this link at ${A(c.expiresAt-i)} UTC.</p></div>`:``;return{title:`Credentials for ${d(c)}`,body:`<div class="page">
|
|
2
2
|
<main class="card">
|
|
3
3
|
${u(o)}
|
|
4
4
|
<h1>${S?`Update`:`Add`} credentials for ${l(d(c))}</h1>
|
package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{APP_DATA_ENTITY_KEY as e}from"../../../../../../../shared/constants/app-data.js";import{
|
|
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 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{SystemRoute as e}from"../../../../../../shared/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{SecretStore as a}from"./secret-store.js";import{buildAllowedOriginMatchers as o}from"./fetch/allowed-hosts.js";import{assertUrlAllowed as s}from"./fetch/ssrf-guard.js";import{getDefaultAgent as c,readCappedBody as l}from"./fetch/fetch-bridge.js";import{credentialSchemesOf as u,schemeFieldName as d}from"./credentials-page/form-contract.js";import{htmlDocument as f}from"./credentials-page/layout.js";import{formPage as p}from"./credentials-page/form-page.js";import{declinedPage as m,expiredPage as h,otherAccountPage as g,outcomePage as _,signInPage as v}from"./credentials-page/outcome-pages.js";import{loadPageSite as y}from"./credentials-page/site-branding.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,i=new a(t.gatewaySecretSeed);if(e.req.method===`GET`){let n=await y(t),a=e.req.query(`token`)??``,o=await i.peekElicitation(r,a);return o?R(o,t,n)??M({secretStore:i,kv:r,site:n,token:a,target:o},{},200):L(n)}if(e.req.method===`POST`){let a=await y(t),o=await e.req.formData(),s=F(o,`token`),c=await i.peekElicitation(r,s);if(!c)return L(a);let l=R(c,t,a);if(l)return l;let d={secretStore:i,kv:r,site:a,token:s,target:c,form:o,ctx:t};switch(F(o,`action`)){case n.remove:return O(d,k(c,F(o,`scheme`)));case n.removeAll:return O(d,u(c));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=u(t),a=i.map((e,t)=>F(n,d(`client_id`,t)).trim()),o=t=>M(e,{error:t,clientIds:a},400),s=T(i,n);if(`error`in s)return o(s.error);if(s.writes.length===0)return o(E(i));let c=[];for(let e of s.writes){if(e.kind!==`exchange`){c.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}`),o(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.`));c.push({kind:`set`,scheme:e.scheme,secret:n.secret})}return j(e,c)}function T(e,t){let n=[];for(let[r,a]of e.entries()){let o=F(t,d(`secret`,r)).trim();if(o){let t=i(a.auth,o);if(t)return{error:D(e,r,`secret`,t)};n.push({kind:`set`,scheme:a.name,secret:z(a.auth,o)});continue}if(a.auth.kind!==`oauth2ClientCredentials`)continue;let s=F(t,d(`client_id`,r)).trim(),c=F(t,d(`client_secret`,r)).trim();if(s&&c)n.push({kind:`exchange`,scheme:a.name,schemeIndex:r,auth:a.auth,clientId:s,clientSecret:c});else if(s||c)return{error:D(e,r,s?`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{secretStore:n,kv:r,target:i}=e,a=await n.getStoredSchemes(r,i.subject,i.api),o=t.filter(e=>a[e.name]).map(e=>({kind:`remove`,scheme:e.name}));return o.length===0?M(e,{error:{message:`No credential is stored there, so there is nothing to remove.`}},400):j(e,o)}function k(e,t){let n=S.test(t)?u(e)[Number(t)]:void 0;return n?[n]:[]}async function A({secretStore:e,kv:t,site:n,token:r}){return await e.consumeElicitation(t,r)?I(n,m(),200):L(n)}async function j({secretStore:e,kv:t,site:n,token:r},i){let a=await e.consumeElicitation(t,r);if(!a)return L(n);for(let n of i)n.kind===`remove`?await e.deleteSecret(t,a.subject,a.api,n.scheme):await e.setSecret(t,a.subject,a.api,n.scheme,n.secret);let o=await e.getStoredSchemes(t,a.subject,a.api),s={action:i.some(e=>e.kind===`set`)?`saved`:`removed`,schemes:i.map(e=>e.scheme),stored:Object.keys(o).sort()};return I(n,_(a,s),200)}async function M({secretStore:e,kv:t,site:n,token:r,target:i},a,o){let s=await e.getStoredSchemes(t,i.subject,i.api);return I(n,p({site:n,target:i,token:r,stored:s,...a}),o)}async function N(e,t,n){try{let r=o([{url:e.tokenUrl}]),a=s(e.tokenUrl,r),u=new AbortController,d=setTimeout(()=>u.abort(),3e4),f;try{f=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:u.signal,dispatcher:c()})}finally{clearTimeout(d)}if(!f.ok)return P(`token endpoint returned ${f.status}`);let p;try{p=await l(f,65536)}catch{return P(`token response exceeded the size cap`)}let m;try{m=JSON.parse(p)}catch{return P(`token response was not valid JSON`)}let h=typeof m==`object`&&m&&`access_token`in m?m.access_token:void 0,g=typeof h==`string`?h.trim():``;return g?i(e,g)?P(`token response had an access_token that cannot be sent in a header`):{ok:!0,secret:{header:`Authorization`,value:`Bearer ${g}`}}: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(f(t,e),{status:n,headers:b})}function L(e){return I(e,h(),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,g(o?.email),403);let c=`${t(e.AuthIdpLogin)}?${new URLSearchParams({redirectTo:`/`})}`;return I(a,v(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,7 +1,7 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}async function g(e,{secretStore:t,kv:n,subject:r,baseUrl:i,apis:a}){if(typeof e!=`string`)return;let o=await t.peekElicitation(n,e);if(o?.subject===r&&a.includes(o.api))return{apiName:o.name,url:N(i,e)}}function _(e,t){return Object.keys(e).length>1?t:void 0}async function v(e){let{token:t,url:n}=await C(e);return s({inputRequests:{[l]:s.elicitUrl({message:E(e),url:n})},requestState:t})}async function y(e){let{url:t}=await C(e);return P(e,t,T(e.subject))}function b(
|
|
3
|
-
`);if(
|
|
4
|
-
`);let a=
|
|
5
|
-
`);let o=n?`api: "${
|
|
6
|
-
`)}function x(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 S({status:e,detail:t}){return t?`HTTP ${e}: ${t}`:`HTTP ${e}`}async function C({secretStore:e,kv:t,subject:n,baseUrl:r,target:i,auth:a,apiAuth:o}){let s=o?w(o):[],c=await e.createElicitation(t,{subject:n,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:N(r,c)}}function w(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 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}.`:``,o=k(A(n)),s=o?j(n)?` The AI agent asked for this scheme, so the stored credentials (${o}) were not sent.`:` This operation does not take the stored credentials (${o}).`:``;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}${s} 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(e,t=`, `){return e.map(e=>`"${e}"`).join(t)}function A(e){return e.kind===`authFailure`?e.unsentStoredSchemes??[]:[]}function j(e){return e.kind===`authFailure`&&e.isSchemeRequested===!0}function M(e,t){let n=k(A(t));if(!n)return[];let r=k(e.acceptedSchemes??[e.scheme],` or `);return j(t)?[`The stored credentials of this API (${n}) were not sent: the call set securityScheme to ${r}.`,`Without securityScheme, the server sends a stored credential when the operation takes one.`]:[`The stored credentials of this API (${n}) were not sent: this operation takes only ${r}.`,`If the user has no credential for ${r}, tell them that this operation does not take the stored credentials, and do not retry it.`]}function N(
|
|
1
|
+
import{MANAGE_API_CREDENTIALS_TOOL_NAME as e,MCP_CREDENTIALS_ROUTE as t}from"../../constants.js";import{withPathPrefix as n}from"../../../../../../shared/path-prefix.js";import{ANONYMOUS_SUBJECT_PREFIX as r}from"./subject.js";import"./secret-store.js";import{operationsForScheme as i,orderedSchemesOf as a}from"./upstream-auth-scheme.js";import{CLIENT_CAPABILITIES_META_KEY as o,inputRequired as s,inputResponse as c}from"@modelcontextprotocol/server";const l=`credentials`,u=/* @__PURE__ */ new Map;function d(e,t){let n=u.get(e);if(n)return n;let r=t().finally(()=>{u.delete(e)});return u.set(e,r),r}function f(e){return!!(e.envelope?.[o])?.elicitation?.url}function p(e){return e.envelope!==void 0}function m(e){let t=c(e,l);if(t.kind===`elicit`)return t.action===`accept`?`accepted`:`declined`}function h(t,{url:n,canManageCredentials:r}){return[`The user accepted the prompt to add credentials for the "${t}" 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 \`${e}\` 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 g(e,{secretStore:t,kv:n,subject:r,baseUrl:i,apis:a}){if(typeof e!=`string`)return;let o=await t.peekElicitation(n,e);if(o?.subject===r&&a.includes(o.api))return{apiName:o.name,url:N(i,e)}}function _(e,t){return Object.keys(e).length>1?t:void 0}async function v(e){let{token:t,url:n}=await C(e);return s({inputRequests:{[l]:s.elicitUrl({message:E(e),url:n})},requestState:t})}async function y(e){let{url:t}=await C(e);return P(e,t,T(e.subject))}function b(t,{schemeLabel:n,canManageCredentials:r}){let i=S(t);if(!t.sentScheme&&(t.status===401||!t.schemes))return[`The "${t.name}" API returned ${i}. No stored credential was sent with this request, so this result says nothing about the stored credentials.`,``,t.unsupportedSchemes?`Do not replace them. This operation accepts only ${t.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(t.status===403&&t.sentScheme)return[`The "${t.name}" API refused this operation with the stored ${n?`"${n}" `:``}credential (${i}). 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.`,...r?[``,...x(t),`If the user has a different credential, or the API answer says this one is invalid or expired, call \`${e}\` with api: "${t.api}" to get a link where they can save it.`]:[`This client cannot replace the stored credentials.`]].join(`
|
|
4
|
+
`);let a=t.status===401?`The "${t.name}" API rejected the stored ${n?`"${n}" `:``}credential (${i}).`:`The "${t.name}" API rejected the request with ${i}.`;if(!r)return[a,``,t.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 o=n?`api: "${t.api}" and scheme: "${n}"`:`api: "${t.api}"`;return[a,``,...x(t),`Do not retry the same call. Call \`${e}\` 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(`
|
|
6
|
+
`)}function x(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 S({status:e,detail:t}){return t?`HTTP ${e}: ${t}`:`HTTP ${e}`}async function C({secretStore:e,kv:t,subject:n,baseUrl:r,target:i,auth:a,apiAuth:o}){let s=o?w(o):[],c=await e.createElicitation(t,{subject:n,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:N(r,c)}}function w(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 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}.`:``,o=k(A(n)),s=o?j(n)?` The AI agent asked for this scheme, so the stored credentials (${o}) were not sent.`:` This operation does not take the stored credentials (${o}).`:``;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}${s} 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(e,t=`, `){return e.map(e=>`"${e}"`).join(t)}function A(e){return e.kind===`authFailure`?e.unsentStoredSchemes??[]:[]}function j(e){return e.kind===`authFailure`&&e.isSchemeRequested===!0}function M(e,t){let n=k(A(t));if(!n)return[];let r=k(e.acceptedSchemes??[e.scheme],` or `);return j(t)?[`The stored credentials of this API (${n}) were not sent: the call set securityScheme to ${r}.`,`Without securityScheme, the server sends a stored credential when the operation takes one.`]:[`The stored credentials of this API (${n}) were not sent: this operation takes only ${r}.`,`If the user has no credential for ${r}, tell them that this operation does not take the stored credentials, and do not retry it.`]}function N(e,r){let i=new URL(n(t),e);return i.searchParams.set(`token`,r),i.toString()}function P({target:e,reason:t,hasExistingSecret:n},r,i){let a=n?`replace or remove the stored credentials for the "${e.name}" API`:`add credentials for the "${e.name}" API`,o=A(t).length>0?`Once the user confirms they saved a credential for ${k(e.acceptedSchemes??[e.scheme],` or `)}, retry the call that needed it`:`Once the user confirms they saved them, retry the call that needed them`,s=[`**Stop and show the user this link. They have to open it in a browser to ${a} - 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.`]:[],...M(e,t),i?`${o} with sessionHandle: "${i}" - the credentials are stored against that handle, applied server-side, and never appear in the conversation.`:`${o} - the credentials are applied server-side and never appear in the conversation.`],c=t.kind===`authFailure`?t.otherApiNames??[]:[];if(c.length>0){let e=c.map(e=>`"${e}"`).join(`, `);s.push(``,`The remaining APIs (${e}) will prompt for credentials on subsequent calls.`)}return s.join(`
|
|
7
7
|
`)}export{l as CREDENTIALS_INPUT_REQUEST_KEY,g as acceptedCredentialsLink,h as buildCredentialsAcceptedHint,b as buildCredentialsToolHint,y as buildUpstreamCredentialFallback,v as buildUpstreamCredentialInputRequired,m as credentialElicitationAnswer,d as dedupeElicitation,p as isStatelessRequest,_ as schemeLabelOf,f as supportsUrlElicitation};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{CALL_API_WRITE_TOOL_NAME as e,MANAGE_API_CREDENTIALS_TOOL_NAME as t}from"../../constants.js";import{isObject as n}from"../../../../../../shared/utils/is-object.js";import{publicOrigin as r}from"../../../../utils/request-origin.js";import{formatError as i}from"../tool-errors.js";import{callAttribution as a}from"../audit.js";import{isToolDisabledByCaller as o}from"../disabled-tools.js";import{GATEWAY_FETCH_LIMITS as s}from"../codemode/constants.js";import{resolveSecretSubject as c}from"./subject.js";import{ipRateLimitKey as l}from"../rate-limit.js";import{callableApis as u,excludedOperations as d}from"./eligibility.js";import{getOfferedWriteHttpMethods as f,getSafeHttpMethods as p,getWriteHttpMethods as m}from"./allowed-http-methods.js";import{apiCallOperationsOf as h}from"./api-call-operations.js";import{GatewayFetchUserError as g}from"./fetch/fetch-errors.js";import{SecretStore as _}from"./secret-store.js";import{credentialHeadersOf as v,orderedSchemesOf as y,resolveUpstreamApiAuth as b}from"./upstream-auth-scheme.js";import{acceptedCredentialsLink as x,buildCredentialsAcceptedHint as S,buildCredentialsToolHint as C,buildUpstreamCredentialFallback as w,buildUpstreamCredentialInputRequired as T,credentialElicitationAnswer as E,dedupeElicitation as D,isStatelessRequest as O,schemeLabelOf as k,supportsUrlElicitation as A}from"./elicitation.js";import{buildAllowedOriginMatchers as j}from"./fetch/allowed-hosts.js";import{buildFetchBridge as M}from"./fetch/fetch-bridge.js";import{applyFetchCount as N}from"./fetch/fetch-limit.js";import{dedupeAuthEvents as P,upstreamAuthKey as F}from"./upstream-auth.js";import{isInputRequiredResult as I}from"@modelcontextprotocol/server";function L(e){return new Map(e.map(e=>[e.relativePath,b(e)]))}function R(e,t,n,r,i,o,s,c){return M({apis:t.map(t=>{let i=n.get(t.relativePath);return{slug:t.relativePath,name:t.name,matchers:j(t.servers),secrets:r?.[t.relativePath],defaultScheme:i.defaultScheme,routes:i.routes,credentialHeaders:v(i.schemes),credentialQueryParams:i.credentialQueryParams,schemePriority:y(i.schemes),operations:h(t.fullDefinition,t.definition,t.servers,d(e,t.relativePath))}}),onAuthRequired:i,sent:o,runEnded:s,logger:e.logger,telemetry:e.telemetry,maxFetchesPerExec:50,deadline:e.executeDeadline,beforeSend:B(e),caller:a(e),refuseMethod:t=>z(e,c,t)})}function z(t,n,r){if(!n.includes(r))return f(t).includes(r)?`fetch sends safe methods only. Use the \`${e}\` tool for ${r} requests.`:`${r} is not allowed: ${m(t.config.mcp).includes(r)?`this client cannot send write requests`:`this call sends only ${n.join(`, `)} requests`}. Explain the call to the user instead of making it.`}function B(e){let{callerSubject:t,clientIp:n}=a(e),r={subject:t,ip:n&&l(n)};return async()=>{let t=await N(e.kv,r,s,Date.now(),e.logger);if(t)throw e.telemetry?.gatewayFetchRateLimited(t),new g(t.message)}}async function V(e,t){if(t)try{return await new _(e.gatewaySecretSeed).getSecretsForSubject(e.kv,t)}catch(t){e.logger?.warn(`gateway mcp secret store error, continuing unauthenticated: ${i(t)}`);return}}async function H(e){let t=[],n=await U(e,t);return I(n)?n:G(n,t)}async function U({ctx:e,sessionHandle:n,serverContext:r,allowedHttpMethods:i,run:a},s){let l=c(e,n);if(l.kind===`invalid`)return{content:[{type:`text`,text:l.message}],isError:!0};let d=l.kind===`resolved`?l.subject:void 0,[f,m]=await Promise.all([u(e),V(e,d)]),h=L(f),g=[],_=new AbortController,v=await a(R(e,f,h,m,e=>g.push(e),s,_.signal,i??p(e.config.mcp))).finally(()=>_.abort());if(g.length===0)return v;let y=P(g).map(e=>q(e,h));if(l.kind===`anonymous`)return y.some(e=>e.schemes)?K(v,[{type:`text`,text:l.message}]):K(v,[{type:`text`,text:Z(y,{plans:h,canManageCredentials:!1})},...v.content]);let b=O(r.mcpReq);e.logger?.info(`gateway mcp credentials prompt: era=${b?`2026-07-28`:`2025`} urlElicitation=${A(r.mcpReq)}`);let x={ctx:e,serverContext:r,subject:l.subject,stored:J(m),plans:h,canManageCredentials:!o(t,e.metadata)},S=b?await $(x,y,!s.some(W)):await ee(x,y);switch(S.kind){case`inputRequired`:return S.result;case`prependText`:return K(v,[{type:`text`,text:S.text},...v.content]);case`none`:return v}}function W(e){return e.status===void 0||e.status<400||e.status>=500}function G(e,t){if(!e.isError||t.length===0)return e;let r=t.map(e=>({...e})),i=`These requests reached the API before the failure, and running the code again sends them again:
|
|
2
2
|
`+r.map(e=>`${e.method} ${e.url} -> ${e.status??`no response`}`).join(`
|
|
3
|
-
`);return{...
|
|
3
|
+
`);return{...e,content:[...e.content.slice(0,-1),{type:`text`,text:i},...e.content.slice(-1)],structuredContent:{...n(e.structuredContent)?e.structuredContent:{},sentFetches:r}}}function K(e,t){let{structuredContent:n,...r}=e;return{...r,content:t,isError:!0}}function q(e,t){let n=t.get(e.api),r=e.scheme&&n.schemes[e.scheme]?e.scheme:n.defaultScheme;return{...e,scheme:r}}function J(e){let t=/* @__PURE__ */ new Set;for(let[n,r]of Object.entries(e??{}))for(let e of Object.keys(r))t.add(F({api:n,scheme:e}));return t}function Y(e,t){return e.status===401&&!!e.schemes&&!t.has(F(e))}function X(e,t){let n=t.get(e.api),r=e.sentScheme??e.scheme;return n&&r?k(n.schemes,r):void 0}function Z(e,{plans:t,canManageCredentials:n}){return e.map(e=>C(e,{schemeLabel:X(e,t),canManageCredentials:n})).join(`
|
|
4
4
|
|
|
5
|
-
`)}function Q({ctx:e,subject:
|
|
5
|
+
`)}function Q({ctx:e,subject:t,plans:n,stored:i},a){let[o,...s]=a,c=n.get(o.api),l=o.scheme??c.defaultScheme,u=o.schemes&&o.schemes.length>1?o.schemes:void 0;return{subject:t,baseUrl:r(e.request),target:{api:o.api,name:o.name,scheme:l,schemeLabel:u?void 0:X(o,n),acceptedSchemes:u},auth:c.schemes[l]??{kind:`raw`},apiAuth:c,secretStore:new _(e.gatewaySecretSeed),kv:e.kv,hasExistingSecret:!1,reason:{kind:`authFailure`,status:o.status,detail:o.detail,otherApiNames:s.map(e=>e.name),unsentStoredSchemes:Object.keys(c.schemes).filter(e=>i.has(F({api:o.api,scheme:e}))),isSchemeRequested:o.isSchemeRequested}}}async function $(e,t,n){let{ctx:i,serverContext:a,subject:o,stored:s,canManageCredentials:c}=e,l=E(a.mcpReq.inputResponses);if(l===`declined`)return{kind:`none`};let u=t.filter(e=>Y(e,s));if(u.length===0)return{kind:`prependText`,text:Z(t,e)};if(l===`accepted`){let e=await x(a.mcpReq.requestState(),{secretStore:new _(i.gatewaySecretSeed),kv:i.kv,subject:o,baseUrl:r(i.request),apis:u.map(e=>e.api)}),t=e?.apiName??u[0].name;return{kind:`prependText`,text:S(t,{url:e?.url,canManageCredentials:c})}}let d=Q(e,u);return!n||!A(a.mcpReq)?{kind:`prependText`,text:await w(d)}:{kind:`inputRequired`,result:await T(d)}}async function ee(e,t){let n=t.filter(t=>Y(t,e.stored));if(n.length===0)return{kind:`prependText`,text:Z(t,e)};let r=Q(e,n);return{kind:`prependText`,text:await D(`${e.subject}:${F(n[0])}`,()=>w(r))}}export{H as runExecuteWithGateway};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../../constants.js";import{isToolDisabledByCaller as e}from"../disabled-tools.js";import{randomBytes as t}from"node:crypto";const n=/^[A-Za-z0-9_-]{43}$/,r=`anon:`,i=`user:`,a
|
|
1
|
+
import"../../constants.js";import{isToolDisabledByCaller as e}from"../disabled-tools.js";import{randomBytes as t}from"node:crypto";const n=/^[A-Za-z0-9_-]{43}$/,r=`anon:`,i=`user:`,a="This API requires credentials and the caller is anonymous; call `create-anonymous-session` first, then retry with sessionHandle",o="The sessionHandle is not a valid handle; call `create-anonymous-session` to obtain one",s=`This API requires credentials, and this client cannot add them for an anonymous caller. Tell the user that the API needs credentials and that, if this site offers sign-in, they can sign in and ask again. Do not retry the call.`;function c(){return t(32).toString(`base64url`)}function l(e){return n.test(e)}function u(e){if(!e?.isAuthenticated)return;let t=e.sub||e.email;if(t)return`${i}${e.idpId||`local`}:${t}`}function d(t,n){let i=u(t.request.viewer);return i?{kind:`resolved`,subject:i}:e(`create-anonymous-session`,t.metadata)?{kind:`anonymous`,message:s}:typeof n==`string`?l(n)?{kind:`resolved`,subject:`${r}${n}`}:{kind:`invalid`,message:o}:{kind:`anonymous`,message:a}}function f(e){return e.startsWith(`anon:`)?86400:604800}export{s as ANONYMOUS_CREDENTIALS_UNAVAILABLE_MESSAGE,r as ANONYMOUS_SUBJECT_PREFIX,o as MALFORMED_SESSION_HANDLE_MESSAGE,a as MISSING_SESSION_HANDLE_MESSAGE,i as USER_SUBJECT_PREFIX,c as createSessionHandle,l as isValidSessionHandle,d as resolveSecretSubject,f as secretTtlSeconds,u as userSubject};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createAnonymousSessionTool as e,manageApiCredentialsTool as t,removeApiCredentialsTool as n}from"./tools.js";import{callApiWriteTool as r}from"./call-api.js";import{workflowTools as
|
|
1
|
+
import{createAnonymousSessionTool as e,manageApiCredentialsTool as t,removeApiCredentialsTool as n}from"./tools.js";import{callApiWriteTool as r}from"./call-api.js";import{runWorkflowWriteTool as i,workflowTools as a}from"../workflows/tools.js";function o(){return[e,t,n,r,i,...a()]}export{o as gatewayTools};
|