@redocly/realm 0.137.0-next.9 → 0.137.0
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/CHANGELOG.md +213 -1
- package/dist/cli/build/index.js +1 -1
- package/dist/client/app/Sidebar/useActions.js +1 -1
- package/dist/client/app/Sidebar/useSidebarItems.js +1 -1
- package/dist/client/app/hooks/catalog/useCatalogClassic.js +1 -1
- package/dist/client/app/hooks/catalog/useCatalogFilter.js +1 -1
- package/dist/client/app/search/useFacets.js +1 -1
- package/dist/client/app/seo/SeoTags.js +1 -1
- package/dist/client/app/utils/loadAndNavigate.js +1 -1
- package/dist/server/config/env-config.d.ts +2 -0
- package/dist/server/config/env-schema.d.ts +5 -0
- package/dist/server/config/env-schemas/feature-flags.d.ts +4 -0
- package/dist/server/config/env-schemas/feature-flags.js +1 -1
- package/dist/server/constants/plugins/search.js +1 -1
- package/dist/server/esbuild/esbuild-logger.d.ts +2 -2
- package/dist/server/esbuild/esbuild-logger.js +3 -3
- package/dist/server/plugins/api-docs/options.js +1 -1
- package/dist/server/plugins/api-docs/search/create-indexer.d.ts +5 -0
- package/dist/server/plugins/api-docs/search/create-indexer.js +1 -0
- package/dist/server/plugins/api-docs/search/get-ai-search-documents.d.ts +1 -1
- package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +41 -41
- package/dist/server/plugins/api-docs/search/search-resolver.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/common/revision-repository.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/common/version-repository.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/utils/normalize-revision-flags.js +1 -1
- package/dist/server/plugins/config-parser/loaders/content-slugs-loader.js +1 -1
- package/dist/server/plugins/config-parser/loaders/versions-config-loader.js +1 -1
- package/dist/server/plugins/dev-onboarding/template/components/EditAppDescriptionDialog.js +1 -1
- package/dist/server/plugins/dev-onboarding/template/components/EditAppDialog.js +1 -1
- package/dist/server/plugins/dev-onboarding/template/components/EditCallbackUrlDialog.js +1 -1
- package/dist/server/plugins/markdown/is-partial.js +1 -1
- package/dist/server/plugins/mcp/codemode/capabilities/fetch/index.js +5 -4
- package/dist/server/plugins/mcp/codemode/capabilities/types.d.ts +5 -2
- package/dist/server/plugins/mcp/codemode/capabilities/utils.js +4 -4
- package/dist/server/plugins/mcp/codemode/code-execution-audit.js +1 -1
- package/dist/server/plugins/mcp/codemode/prompts.d.ts +1 -1
- package/dist/server/plugins/mcp/codemode/prompts.js +7 -6
- package/dist/server/plugins/mcp/codemode/sandbox/create-sandbox-setup.d.ts +2 -2
- package/dist/server/plugins/mcp/codemode/sandbox/create-sandbox-setup.js +1 -11
- package/dist/server/plugins/mcp/codemode/sandbox/polyfills/console.d.ts +2 -0
- package/dist/server/plugins/mcp/codemode/sandbox/polyfills/console.js +7 -0
- package/dist/server/plugins/mcp/codemode/sandbox/polyfills/index.d.ts +1 -0
- package/dist/server/plugins/mcp/codemode/sandbox/polyfills/index.js +2 -2
- package/dist/server/plugins/mcp/codemode/sandbox/tool-input-validator.d.ts +5 -0
- package/dist/server/plugins/mcp/codemode/sandbox/tool-input-validator.js +1 -0
- package/dist/server/plugins/mcp/codemode/sandbox/unknown-tool-hint.d.ts +8 -0
- package/dist/server/plugins/mcp/codemode/sandbox/unknown-tool-hint.js +2 -0
- package/dist/server/plugins/mcp/codemode/tools/describe-tools.js +3 -1
- package/dist/server/plugins/mcp/codemode/tools/execute.js +1 -1
- package/dist/server/plugins/mcp/codemode/tools/manage-credentials.d.ts +2 -2
- package/dist/server/plugins/mcp/codemode/tools/manage-credentials.js +2 -2
- package/dist/server/plugins/mcp/docs-mcp/tool-schemas.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/core/create-anonymous-session.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/core/search.js +2 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/core/types.d.ts +2 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-type.js +5 -5
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/types.d.ts +2 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/list-apis.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/load-api-description.d.ts +4 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/load-api-description.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/types.d.ts +6 -2
- package/dist/server/plugins/mcp/docs-mcp/utils/api-titles.d.ts +6 -0
- package/dist/server/plugins/mcp/docs-mcp/utils/api-titles.js +1 -0
- package/dist/server/plugins/mcp/gateway-mcp/elicitation.d.ts +11 -0
- package/dist/server/plugins/mcp/gateway-mcp/elicitation.js +5 -5
- package/dist/server/plugins/mcp/gateway-mcp/fetch/ssrf-guard.js +1 -1
- package/dist/server/plugins/mcp/gateway-mcp/fetch/url-placeholders.d.ts +5 -0
- package/dist/server/plugins/mcp/gateway-mcp/fetch/url-placeholders.js +1 -0
- package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
- package/dist/server/plugins/mcp/servers/mcp-server.js +3 -3
- package/dist/server/plugins/mcp/types.d.ts +1 -0
- package/dist/server/plugins/mcp/utils/available-sandbox-tools.js +1 -1
- package/dist/server/plugins/mcp/workers/execute-mcp-tool.js +1 -1
- package/dist/server/plugins/search/ai-indexer/prepare-semantic-documents.js +1 -1
- package/dist/server/plugins/search/engines/flexsearch/index.js +1 -1
- package/dist/server/plugins/search/engines/flexsearch/search-index.d.ts +8 -4
- package/dist/server/plugins/search/engines/flexsearch/search-index.js +1 -1
- package/dist/server/plugins/search/llmstxt/create-llms-txt-generator.js +1 -1
- package/dist/server/plugins/search/llmstxt/index.d.ts +3 -1
- package/dist/server/plugins/search/llmstxt/index.js +9 -9
- package/dist/server/sandbox/sandbox.js +2 -2
- package/dist/server/sandbox/types.d.ts +9 -0
- package/dist/server/sandbox/utils/execution-budget.js +1 -1
- package/dist/server/sandbox/utils/return-last-expression.d.ts +6 -0
- package/dist/server/sandbox/utils/return-last-expression.js +1 -0
- package/dist/server/sandbox/utils/returns-from-top-level.d.ts +1 -2
- package/dist/server/sandbox/utils/returns-from-top-level.js +1 -1
- package/dist/server/sandbox/utils/setup-host-functions.d.ts +1 -0
- package/dist/server/sandbox/utils/setup-host-functions.js +2 -2
- package/dist/server/ssr/render.js +1 -1
- package/dist/server/store.js +1 -1
- package/dist/server/types/plugins/search.d.ts +7 -2
- package/dist/server/utils/globs.d.ts +4 -0
- package/dist/server/utils/globs.js +1 -1
- package/dist/server/utils/search/highlight-text-for-search.js +1 -1
- package/dist/server/web-server/middleware/ensureSearchData.js +1 -1
- package/dist/server/web-server/routes/dynamic-route.js +1 -1
- package/dist/server/web-server/routes/mcp-routes/mcp-oauth.js +1 -1
- package/dist/server/web-server/routes/mcp-routes/mcp-server-card.js +1 -1
- package/dist/{server/plugins/catalog-entities/utils/version-compare.d.ts → utils/version/compare-versions.d.ts} +1 -16
- package/dist/utils/version/compare-versions.js +1 -0
- package/package.json +11 -10
- package/dist/server/plugins/api-docs/search/search-indexer.d.ts +0 -9
- package/dist/server/plugins/api-docs/search/search-indexer.js +0 -1
- package/dist/server/plugins/catalog-entities/utils/version-compare.js +0 -1
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import P from"node:path";import{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";import{nodeTypes as h,contentType as
|
|
2
|
-
`+tn,on=q+F;
|
|
1
|
+
import P from"node:path";import{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";import{nodeTypes as h,contentType as y}from"@redocly/api-docs";import{normalizeApiVersion as sn}from"../utils/normalize-api-version.js";import{replaceFileExtension as U}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as cn,canDownloadApiDefinition as ln,extractTeamsFromScopeItems as fn}from"../../../utils/rbac.js";import{getLlmsTxtMdPathBySlug as J}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{PUBLIC_API_DEFINITIONS_FOLDER as Q}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as an}from"../../../../constants/common.js";import{ANONYMOUS_AUTH_DETAILS as pn}from"../../../constants/rbac.js";import{toMarkdown as v}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as un}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as dn}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as hn}from"../../../utils/l10n/get-build-translate-context.js";import{llmsTxtLink as N}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as mn}from"../../search/utils.js";import{extractDocumentSearchFacets as $n}from"./search-facets.js";import{createApiDocsSearchIndexer as yn}from"./create-indexer.js";function A(t,o){return o==="openapi"&&"openapi"in t}function H(t,o){return o==="asyncapi"&&"asyncapi"in t}function Qn({items:t,metadata:o,store:s,document:n,specType:r,excludeFromSearch:i,basePath:e,getSearchFacets:l,markdocTags:c}){return async(f,a,u,d)=>{if(i)return;const m={...d.markdocOptions?.tags,...c},{locale:X,translate:Z}=await hn(f.slug,d.getGlobalData?.().l10n),x=un(m,X,Z),C=d.getConfig(),L=dn(f.fsPath),j=yn(e,s?.schemaStore,n,s?.exampleStore),M=g=>{for(const p of g)j.addItem(p),p.items?.length&&M(p.items)};M(t);const nn=j.getResult(),V=new Map;for(const g of nn)V.set(g.url,g);const R=typeof o.title=="string"?o.title:void 0,_=sn(o.version),D=$n(f.metadata||{},R,_,l),S=[],I=[],q=gn(o,n,r),F=bn(r,o,f.fsPath,C),tn=In(t,C,x),en=q+F+`
|
|
2
|
+
`+tn,on=q+F;I.push({title:R||"API Overview",description:typeof o.description=="string"?o.description:void 0,content:en,slug:e,fsPath:f.fsPath,includeInLLMsTxt:!0}),S.push({title:R||"API Overview",content:on,url:e,fsPath:f.fsPath,locale:L,product:f.product?.name,facets:D});const rn=n&&A(n,r)?n.security:void 0,E=g=>{for(const p of g){if(!p.content||!p.link){p.items?.length&&E(p.items);continue}const k=V.get(p.link),G=p.content.contentType,z=p[O],W=z?fn(z):void 0,B=W?.length?W:void 0;if(G===y.ITEM){const $=Pn(p,n,r)??Y(p,k,r,_,rn,x);if($){const b=p.label||"";I.push({title:b,description:void 0,content:$,slug:p.link,fsPath:f.fsPath,includeInLLMsTxt:!1}),S.push({title:b,content:$,url:p.link,fsPath:f.fsPath,locale:L,product:f.product?.name,facets:D,rbacTeams:B})}}else if(G===y.GROUP){const $=On(p,C,r,x);if($){const b=p.label||"";I.push({title:b,description:k?Rn(k.text):void 0,content:$.llmstxt,slug:p.link,fsPath:f.fsPath,includeInLLMsTxt:!1}),S.push({title:b,content:$.aiSearch,url:p.link,fsPath:f.fsPath,locale:L,product:f.product?.name,facets:D,rbacTeams:B})}}p.items?.length&&E(p.items)}};return E(t),{async getLLMsTxts(){return I},async getSearchDocuments(){return S}}}}function gn(t,o,s){const n=typeof t.title=="string"?t.title:"",r=typeof t.description=="string"?t.description:"",i=typeof t.summary=="string"?t.summary:"",e=typeof t.version=="string"?t.version:"";let l=n?`# ${n}
|
|
3
3
|
|
|
4
|
-
`:"";if(l+=
|
|
4
|
+
`:"";if(l+=r?`${r}
|
|
5
5
|
|
|
6
6
|
`:"",l+=i?`${i}
|
|
7
7
|
|
|
8
8
|
`:"",l+=e?`Version: ${e}
|
|
9
|
-
`:"",
|
|
10
|
-
`);const f=
|
|
9
|
+
`:"",o){if(A(o,s)){const{info:c}=o;c?.license?.name&&(l+=`License: ${c.license.name}
|
|
10
|
+
`);const f=c["x-metadata"],a=mn(f);a&&(l+=`
|
|
11
11
|
Metadata:
|
|
12
12
|
${a}
|
|
13
|
-
`)}else if(H(
|
|
13
|
+
`)}else if(H(o,s)){const{info:c}=o;c?.license?.name&&(l+=`License: ${c.license.name}
|
|
14
14
|
`)}}return l+=`
|
|
15
|
-
`,l+=An(
|
|
15
|
+
`,l+=An(o,s),l+=Sn(o,s),l}function bn(t,o,s,n){if(!s)return"";let r,i,e;if(t==="openapi")r=P.posix.join(Q,U(s,".yaml")),i="## Download OpenAPI description",e="OpenAPI definition";else if(t==="asyncapi")r=P.posix.join(Q,U(s,".yaml")),i="## Download AsyncAPI description",e="AsyncAPI definition";else if(t==="graphql"){const f=P.posix.extname(s)||".graphql";r=P.posix.join(an,U(s,f)),i="## Download GraphQL schema",e="GraphQL schema"}else return"";if(!ln(r,n.access?.rbac??{},n.access?.requiresLogin??!1,pn))return"";const c=typeof o.title=="string"&&o.title||e;return`${i}
|
|
16
16
|
|
|
17
|
-
- ${
|
|
17
|
+
- ${N({title:c,description:void 0,slug:r,siteUrl:n.seo?.siteUrl})}`}function An(t,o){if(!t)return"";if(A(t,o)){const{servers:s}=t;if(!s?.length)return"";let n=`## Servers
|
|
18
18
|
|
|
19
|
-
`;for(const
|
|
19
|
+
`;for(const r of s)if(r.description&&(n+=`${r.description}
|
|
20
20
|
`),n+=`\`\`\`
|
|
21
|
-
${
|
|
21
|
+
${r.url}
|
|
22
22
|
\`\`\`
|
|
23
23
|
|
|
24
|
-
`,
|
|
25
|
-
`;for(const[i,e]of Object.entries(
|
|
24
|
+
`,r.variables){n+=`Variables:
|
|
25
|
+
`;for(const[i,e]of Object.entries(r.variables))n+=`- \`${i}\`${e.description?`: ${e.description}`:""}
|
|
26
26
|
`,e.default&&(n+=` Default: ${JSON.stringify(e.default)}
|
|
27
27
|
`),e.enum&&(n+=` Enum: ${e.enum.map(l=>JSON.stringify(l)).join(", ")}
|
|
28
28
|
`);n+=`
|
|
29
|
-
`}return n}if(H(t,
|
|
29
|
+
`}return n}if(H(t,o)){const{servers:s}=t;if(!s||!Object.keys(s).length)return"";let n=`## Servers
|
|
30
30
|
|
|
31
|
-
`;for(const[
|
|
31
|
+
`;for(const[r,i]of Object.entries(s))n+=`### ${r}
|
|
32
32
|
|
|
33
33
|
`,i.description&&(n+=`${i.description}
|
|
34
34
|
`),i.host&&(n+=`Host: ${i.host}
|
|
@@ -36,9 +36,9 @@ ${o.url}
|
|
|
36
36
|
`),i.protocolVersion&&(n+=`Protocol Version: ${i.protocolVersion}
|
|
37
37
|
`),i.pathname&&(n+=`Pathname: ${i.pathname}
|
|
38
38
|
`),n+=`
|
|
39
|
-
`;return n}return""}function
|
|
39
|
+
`;return n}return""}function Sn(t,o){if(!t||!A(t,o))return"";const s=t.components?.securitySchemes;if(!s)return"";let n=`## Security
|
|
40
40
|
|
|
41
|
-
`;for(const[
|
|
41
|
+
`;for(const[r,i]of Object.entries(s)){if(!i||"$ref"in i)continue;const e=i;n+=`### ${r}
|
|
42
42
|
|
|
43
43
|
`,e.description&&(n+=`${e.description}
|
|
44
44
|
|
|
@@ -48,58 +48,58 @@ ${o.url}
|
|
|
48
48
|
`),e.scheme&&(n+=`Scheme: ${e.scheme}
|
|
49
49
|
`),e.bearerFormat&&(n+=`Bearer Format: ${e.bearerFormat}
|
|
50
50
|
`),e.openIdConnectUrl&&(n+=`OpenID Connect URL: ${e.openIdConnectUrl}
|
|
51
|
-
`);const l=e.flows,
|
|
52
|
-
`),"tokenUrl"in
|
|
53
|
-
`),
|
|
54
|
-
`;for(const[f,a]of Object.entries(
|
|
51
|
+
`);const l=e.flows,c=l?.implicit||l?.password||l?.clientCredentials||l?.authorizationCode;if(c&&("authorizationUrl"in c&&c.authorizationUrl&&(n+=`Authorization URL: ${c.authorizationUrl}
|
|
52
|
+
`),"tokenUrl"in c&&c.tokenUrl&&(n+=`Token URL: ${c.tokenUrl}
|
|
53
|
+
`),c.scopes)){n+=`Scopes:
|
|
54
|
+
`;for(const[f,a]of Object.entries(c.scopes))n+=`- \`${f}\`: ${a}
|
|
55
55
|
`}n+=`
|
|
56
|
-
`}return n}function
|
|
56
|
+
`}return n}function In(t,o,s){let n="";const r=(i,e)=>{for(const l of i)if(l.link){if(l.content?.contentType===y.GROUP)n+=`${e} ${l.label||""}
|
|
57
57
|
|
|
58
|
-
`,l.items?.length&&
|
|
58
|
+
`,l.items?.length&&r(l.items,e+"#");else if(l.content?.contentType===y.ITEM){if(!w(l,o))continue;const c=l,f=c.httpVerb,a=c.httpPath,u=f&&a?`${f.toUpperCase()} ${a}`:l.label||"",d=l.content?T(l.content.children,s):void 0;n+=` - ${N({title:u,description:d?d.slice(0,200):void 0,slug:J(l.link),siteUrl:o.seo?.siteUrl})}`}}};return r(t,"##"),n}function Y(t,o,s,n,r,i){if(!t.content)return;const e=t,l=t.label||"",c=T(t.content.children,i),f=t.content.meta?.deprecated;let a=`# ${l}${f?" (deprecated)":""}
|
|
59
59
|
|
|
60
|
-
`;if(
|
|
60
|
+
`;if(c&&(a+=`${c}
|
|
61
61
|
|
|
62
|
-
`),
|
|
62
|
+
`),s==="openapi"||s==="asyncapi"){const u=e.httpVerb,d=e.httpPath;u&&d?a+=`Endpoint: ${u.toUpperCase()} ${d}
|
|
63
63
|
`:u&&(a+=`Method: ${u.toUpperCase()}
|
|
64
64
|
`),n&&(a+=`Version: ${n}
|
|
65
|
-
`);const m=Tn(t.content.children,
|
|
66
|
-
`)}return
|
|
67
|
-
`+
|
|
68
|
-
`),
|
|
65
|
+
`);const m=Tn(t.content.children,r);m&&(a+=`Security: ${m}
|
|
66
|
+
`)}return o?.parameters?.length&&s!=="graphql"&&(a+=`
|
|
67
|
+
`+xn(o.parameters)+`
|
|
68
|
+
`),s==="graphql"&&(a+=Cn(t.content.children)),a}function Pn(t,o,s){if(t.httpVerb!=="tool"||!o||!A(o,s))return;const n=t.content?.meta?.name,r=n?o["x-mcp"]?.tools?.find(e=>e.name===n):void 0;if(!r)return;let i=`# ${t.label||r.name}
|
|
69
69
|
|
|
70
|
-
`;return typeof
|
|
70
|
+
`;return typeof r.description=="string"&&r.description&&(i+=`${r.description}
|
|
71
71
|
|
|
72
72
|
`),i+=`## Input schema:
|
|
73
73
|
|
|
74
74
|
`,i+=`\`\`\`json
|
|
75
|
-
${JSON.stringify(
|
|
75
|
+
${JSON.stringify(r.inputSchema,null,2)}
|
|
76
76
|
\`\`\`
|
|
77
77
|
|
|
78
|
-
`,
|
|
78
|
+
`,r.outputSchema&&(i+=`## Output schema:
|
|
79
79
|
|
|
80
80
|
`,i+=`\`\`\`json
|
|
81
|
-
${JSON.stringify(
|
|
81
|
+
${JSON.stringify(r.outputSchema,null,2)}
|
|
82
82
|
\`\`\`
|
|
83
83
|
|
|
84
|
-
`),i}function On(t,
|
|
84
|
+
`),i}function On(t,o,s,n){if(!t.content)return;const r=t.label||"",i=T(t.content.children,n);let e=`# ${r}
|
|
85
85
|
|
|
86
86
|
`;if(i&&(e+=`${i}
|
|
87
87
|
|
|
88
|
-
`),
|
|
88
|
+
`),s==="graphql"){let c="";const f=a=>{for(const u of a??[])if(!(!u.content||!w(u,o)))if(u.content.contentType===y.ITEM){const d=Y(u,void 0,s,void 0,void 0,n);d&&(c+=`${d}
|
|
89
89
|
|
|
90
90
|
---
|
|
91
91
|
|
|
92
|
-
`)}else u.content.contentType===
|
|
93
|
-
`;return
|
|
92
|
+
`)}else u.content.contentType===y.GROUP&&f(u.items)};return f(t.items),{llmstxt:e+c,aiSearch:e}}let l="";if(t.items?.length)for(const c of t.items){if(!c.link||!c.content||c.content.contentType!==y.ITEM||!w(c,o))continue;const f=c,a=f.httpVerb,u=f.httpPath,d=a&&u?`${a.toUpperCase()} ${u}`:c.label||"",m=c.content?T(c.content.children,n):void 0;l+=` - ${N({title:d,description:m?m.slice(0,200):void 0,slug:J(c.link),siteUrl:o.seo?.siteUrl})}`}return{llmstxt:e+l,aiSearch:e}}function Tn(t,o){const s=[],n=r=>{for(const i of r)if(i.nodeType===h.SECURITY){const e=i;for(const l of e.requirements)for(const c of l.schemes)c[O]||c.name&&!s.includes(c.name)&&s.push(c.name)}else(i.nodeType===h.CONTAINER||i.nodeType===h.OVERVIEW_SECTION_WRAPPER)&&n(i.children)};if(n(t),s.length)return s.join(", ");if(o?.length){const r=o.flatMap(i=>Object.keys(i));if(r.length)return[...new Set(r)].join(", ")}}function xn(t){const o={};for(const n of t){const r=`${n.place}${n.mediaType?` (${n.mediaType})`:""}`;o[r]||(o[r]=[]),o[r].push(n)}return Object.entries(o).map(([n,r])=>{const i=r.map(e=>{const l=[...e.path||[],e.name],c=Array.isArray(e.description)?e.description.join(" "):e.description;let f=` - \`${l.join(".")}\` (${e.type}${e.required?", required":""})
|
|
93
|
+
`;return c&&(f+=` ${c.trim()}
|
|
94
94
|
`),e.enum?f+=` Enum: ${e.enum.map(a=>JSON.stringify(a)).join(", ")}
|
|
95
95
|
`:e.example&&(f+=` Example: ${e.example}
|
|
96
96
|
`),f});return`## ${K(n)}:
|
|
97
97
|
|
|
98
98
|
${i.join(`
|
|
99
99
|
`)}`}).join(`
|
|
100
|
-
`)}function
|
|
101
|
-
## ${K(
|
|
100
|
+
`)}function Cn(t){let o="";const s=n=>{for(const r of n)if(r.nodeType===h.ITEM){const i=r;i.graphqlSchema&&(o+=Ln(i.graphqlSchema,i.variant))}else(r.nodeType===h.CONTAINER||r.nodeType===h.OVERVIEW_SECTION_WRAPPER)&&s(r.children)};return s(t),o}function Ln(t,o){let n=`
|
|
101
|
+
## ${K(o==="return-type"?"Return type":o==="graphql-args"||o==="arguments"?"Arguments":o==="graphql-fields"?"Fields":o)}:
|
|
102
102
|
|
|
103
|
-
`;const
|
|
104
|
-
`};if(!Array.isArray(t)){const i=t.description?
|
|
105
|
-
`;for(const e of t.fields??[])n+=
|
|
103
|
+
`;const r=i=>{const e=i.description?v(Array.isArray(i.description)?i.description:[i.description]).trim():"";return` - \`${i.name}\` (${i.type})${e?`: ${e}`:""}
|
|
104
|
+
`};if(!Array.isArray(t)){const i=t.description?v(Array.isArray(t.description)?t.description:[t.description]).trim():"";n+=` Type: ${t.type}`,i&&(n+=` - ${i}`),n+=`
|
|
105
|
+
`;for(const e of t.fields??[])n+=r(e);return n}if(!t.length)return"";for(const i of t)n+=r(i);return n}function T(t,o){const s=[],n=i=>{for(const e of i)if(e.nodeType===h.MARKDOC){const l=e.content,c=Array.isArray(l)?l:[l],f=v(c,{renderTag:o}).trim();f&&s.push(f)}else(e.nodeType===h.CONTAINER||e.nodeType===h.OVERVIEW_SECTION_WRAPPER)&&n(e.children)};return n(t),s.join(" ").trim()||void 0}function Rn(t){return(Array.isArray(t)?t.join(" "):t)||void 0}function K(t){return t.charAt(0).toUpperCase()+t.slice(1)}function w(t,o){return o.access?.requiresLogin?!0:cn({slug:t.link||"",[O]:t[O]},o)}export{Qn as getAiDocumentsStore};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_ROUTE_RBAC as
|
|
1
|
+
import{REDOCLY_ROUTE_RBAC as h,REDOCLY_TEAMS_RBAC as o}from"@redocly/config";import{extractDocumentSearchFacets as x,setDocumentSearchFacets as A}from"./search-facets.js";import{ApiDocsSearchIndexer as D}from"@redocly/api-docs";import{normalizeApiVersion as d}from"../utils/normalize-api-version.js";function O(u,i,c,S,R,a,g){return async e=>{if(R)return[];const m=e.baseSlug||e.slug,l=new D(m,a?.schemaStore,g,{exampleStore:a?.exampleStore}),f=t=>{for(const r of t)l.addItem(r),r.items?.length&&f(r.items)};f(u);const s=typeof i.title=="string"?i.title:void 0,n=d(i.version),p=x(e.metadata||{},s,n,c);return A(p,c,S),l.getResult().map(t=>({...t,...t.url===m&&s&&{title:n?`${s} (${n})`:s},[o]:t[o]??e[o],[h]:e[h]??{slug:e.slug,fsPath:e.fsPath},facets:p}))}}export{O as searchResolver};
|
package/dist/server/plugins/catalog-entities/database/repositories/common/revision-repository.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{and as u,desc as v,eq as n,isNull as c,sql as d}from"drizzle-orm";import{VERSION_NOT_SPECIFIED as f}from"@redocly/theme/core/constants";import{entitiesTable as e}from"../../../../../providers/database/databases/sqlite-db/schemas/entities-table.js";import{compareVersions as h}from"
|
|
1
|
+
import{and as u,desc as v,eq as n,isNull as c,sql as d}from"drizzle-orm";import{VERSION_NOT_SPECIFIED as f}from"@redocly/theme/core/constants";import{entitiesTable as e}from"../../../../../providers/database/databases/sqlite-db/schemas/entities-table.js";import{compareVersions as h}from"../../../../../../utils/version/compare-versions.js";import{VersionRepository as m}from"./version-repository.js";import{buildSemanticVersionSortExpr as C}from"../utils/semantic-version-sort.js";import{normalizeRevisionFlags as y}from"../utils/normalize-revision-flags.js";class g{#i;#e;constructor(i){this.#e=i,this.#i=new m(i)}async getCurrentRevisionInfo({key:i,version:t,revision:r}){const o=await this.#t(i);if(!o)return{shouldSetNewCurrentRevision:!0,hasCurrentRevision:!1};if(t){const a=await this.#i.doesVersionExist(i,t),s=h(t,o.version)>0,l=o.version===f&&t!==f;if(!a&&(s||l))return{shouldSetNewCurrentRevision:!0,hasCurrentRevision:!0}}return t&&r&&t===o.version&&r>=o.revision?{shouldSetNewCurrentRevision:!0,hasCurrentRevision:!0}:{shouldSetNewCurrentRevision:!1,hasCurrentRevision:!0}}async markAllRevisionsAsNotCurrent(i){await this.#e.client.update(e).set({isCurrent:!1}).where(n(e.key,i)).run()}async ensureDefaultAndCurrentRevisionForKey(i){const t=await this.#i.getOrderedVersionListForKey(i),r=this.#i.getLatestVersion(t);r&&await this.#e.client.update(e).set({isDefaultVersion:!0,isCurrent:!0}).where(u(n(e.key,i),n(e.revision,r.revision),r.version?n(e.version,r.version):c(e.version))).run()}async shouldSkipRevisionCreation(i,t,r,o,a){if(o||a)return!1;const s=await this.#e.client.select({hash:e.hash,isDeleted:e.isDeleted}).from(e).where(u(n(e.key,i),t?n(e.version,t):c(e.version))).orderBy(v(e.revision)).limit(1).get();return!s||!!s.isDeleted?!1:s.hash===r}async#t(i){return await this.#e.client.select({version:e.version,revision:e.revision}).from(e).where(u(n(e.key,i),n(e.isCurrent,!0))).orderBy(v(e.revision)).limit(1).get()??null}async listEntityRevisions(i,t){const r=[n(e.key,i),n(e.isDeleted,!1),...t?[n(e.version,t)]:[]],a=(await this.#e.client.select({version:e.version,revision:e.revision,isCurrent:e.isCurrent,createdAt:e.createdAt,updatedAt:e.updatedAt,isDefaultVersion:e.isDefaultVersion}).from(e).where(u(...r)).orderBy(d`${C("version")} DESC`,d.raw("revision DESC")).all()).map(s=>({version:s.version,revision:s.revision??"",isCurrent:s.isCurrent!==null?s.isCurrent:!1,createdAt:s.createdAt,updatedAt:s.updatedAt,isDefaultVersion:s.isDefaultVersion!==null?s.isDefaultVersion:!1}));return y(a),a}}export{g as RevisionRepository};
|
package/dist/server/plugins/catalog-entities/database/repositories/common/version-repository.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{eq as a,and as u,desc as c}from"drizzle-orm";import{VERSION_NOT_SPECIFIED as f}from"@redocly/theme/core/constants";import{entitiesTable as e}from"../../../../../providers/database/databases/sqlite-db/schemas/entities-table.js";import{
|
|
1
|
+
import{eq as a,and as u,desc as c}from"drizzle-orm";import{VERSION_NOT_SPECIFIED as f}from"@redocly/theme/core/constants";import{entitiesTable as e}from"../../../../../providers/database/databases/sqlite-db/schemas/entities-table.js";import{compareVersions as m}from"../../../../../../utils/version/compare-versions.js";class A{db;constructor(t){this.db=t}async markAllVersionsAsNotDefault(t){await this.db.client.update(e).set({isDefaultVersion:!1}).where(u(a(e.key,t),a(e.isDefaultVersion,!0))).run()}async doesVersionExist(t,n){return await this.db.client.select().from(e).where(u(a(e.key,t),a(e.version,n))).get()!==void 0}async getOrderedVersionListForKey(t){return(await this.db.client.select({version:e.version,isDefaultVersion:e.isDefaultVersion,revision:e.revision,createdAt:e.createdAt}).from(e).where(u(a(e.key,t))).orderBy(c(e.createdAt)).all()).map(i=>({version:i.version,isDefaultVersion:!!i.isDefaultVersion,revision:i.revision,createdAt:new Date(i.createdAt)}))}getLatestVersion(t){const n=t.find(r=>r.isDefaultVersion);if(n)return n;const{versionedEntities:i,unversionedEntities:d}=t.reduce((r,s)=>(s.version!==null&&s.version!==f?r.versionedEntities.push(s):r.unversionedEntities.push(s),r),{versionedEntities:[],unversionedEntities:[]});if(i.length>0){i.sort((o,l)=>m(l.version,o.version));const r=i[0].version,s=i.filter(o=>o.version===r);return s.sort((o,l)=>l.createdAt.getTime()-o.createdAt.getTime()),s[0]}return d.length>0?(d.sort((r,s)=>s.createdAt.getTime()-r.createdAt.getTime()),d[0]):null}}export{A as VersionRepository};
|
package/dist/server/plugins/catalog-entities/database/repositories/utils/normalize-revision-flags.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{VERSION_NOT_SPECIFIED as t}from"@redocly/theme/core/constants";import{
|
|
1
|
+
import{VERSION_NOT_SPECIFIED as t}from"@redocly/theme/core/constants";import{compareVersions as f}from"../../../../../../utils/version/compare-versions.js";function s(r){return!r||r===t}function c(r,i){const e=s(r.version),o=s(i.version);if(e&&!o)return 1;if(!e&&o)return-1;const n=f(i.version??"",r.version??"");return n!==0?n:(i.revision??"").localeCompare(r.revision??"")}function a(r){const i=r.filter(e=>e.isCurrent||e.isDefaultVersion);if(!(i.length<=1)){i.sort(c);for(let e=1;e<i.length;e++)i[e].isCurrent=!1,i[e].isDefaultVersion=!1}}export{a as normalizeRevisionFlags};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import f from"path";import{combineUrls as S}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as b}from"../../../constants/common.js";import{removeTrailingSlash as v}from"../../../../utils/url/remove-trailing-slash.js";import{slash as E}from"../../../../utils/path/slash.js";import{logger as m}from"../../../tools/notifiers/logger.js";import{getDefaultVersionByPath as I}from"./versions-config-loader.js";import{GithubSlugger as N,slug as h}from"../../../utils/index.js";import{isPartial as z}from"../../markdown/is-partial.js";import{parseBaseName as T}from"../../utils.js";const j=new Set([".jpg",".jpeg",".png",".gif",".webp",".svg",".ico",".avif",".mp3",".wav",".ogg",".m4a",".mp4",".avi",".mov",".webm",".pdf",".doc",".docx",".zip",".rar",".gz",".ttf",".woff",".woff2"]),U=async(i,{fs:s,cache:r,getConfig:l})=>{const t=m.startTiming(),g=(await r.load("versions-config","versions-config")).data,{markdown:u}=await l(),o=u?.partialsFolders??[],e=new Map,n=new Map,c=new Set,d={pageVsPage:0,dirVsDir:0},D=new N;n.set(".","/"),n.set("/","/");const w=s.scan().sort((a,p)=>p.relativePath.localeCompare(a.relativePath));for(const{relativePath:a}of w){if(j.has(f.posix.extname(a)))continue;const{data:p}=await r.load(a,"is-ignored");if(p||f.posix.extname(a)===".md"&&z(a,o))continue;const F=E(a).replace(new RegExp("^(@i18n|@l10n)\\/"),""),V=I(a,g);y(F,{defaultVersion:V,fileSlugs:e,dirSlugs:n,allFileSlugsList:c,githubSlugger:D,collisions:d})}return m.verboseTime(t,"Calculated slugs. Number of file paths processed: "+w.length),{fileSlugs:e,dirSlugs:n,collisions:d}};function y(i,s){const r=s.fileSlugs.get(i);if(r)return r;let l=f.posix.dirname(i);const t=L(l,s)||"",{baseName:g,isIndexFile:u}=T(i),o=s.dirSlugs.has(f.posix.join(l,g));let e;if(!u&&o){const n=h(S(t,g));s.allFileSlugsList.has(n)||(e=n)}if(!e){const n=u?s.dirSlugs.get(l):void 0;if(n)e=n;else{const c=S(t,g),d=h(c);e=s.githubSlugger.slug(c),e!==d&&(s.collisions.pageVsPage++,m.verbose("File slug collision: %s wanted %s, assigned %s",i,d,e))}}e=v(e),s.fileSlugs.set(i,e),s.allFileSlugsList.add(e)}function L(i,s){if(s.dirSlugs.has(i))return s.dirSlugs.get(i);const r=v(f.posix.normalize(i)).split("/");let l="/",t="";for(const g of r){t=f.posix.join(t,g);const u=P(g,s.defaultVersion);let o=s.dirSlugs.get(t);if(!o){const e=S("/",l,u),n=h(e);o=s.githubSlugger.slug(e),o!==n&&(s.collisions.dirVsDir++,m.verbose("Directory slug collision: %s wanted %s, assigned %s",t,n,o))}o.endsWith("/")||(o=o+"/"),s.dirSlugs.set(t,o),l=o}return s.dirSlugs.get(i)}function P(i,s){if(!i.startsWith(b))return i;const r=i.substring(b.length);return r===s?"":r}export{j as IGNORED_EXTS,U as contentSlugsLoader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import v from"path";import{I18N_DIR_NAME as c,L10N_DIR_NAME as p,RESERVED_DIR_NAMES as m,VERSIONED_FOLDER_REGEXP_MATCH as
|
|
1
|
+
import v from"path";import{I18N_DIR_NAME as c,L10N_DIR_NAME as p,RESERVED_DIR_NAMES as m,VERSIONED_FOLDER_REGEXP_MATCH as V}from"../../../constants/common.js";import{parsePathVersions as l}from"../../../../utils/path/parse-path-versions.js";import{compareVersions as P}from"../../../../utils/version/compare-versions.js";import{reporter as h}from"../../../tools/notifiers/reporter.js";import{logger as g}from"../../../tools/notifiers/logger.js";const R=async(r,{cache:i,fs:s})=>{const e=new Map,a=await s.scan();await F(a);for(const{relativePath:n}of a){if(v.posix.basename(n)==="versions.yaml"){await y(n,e,i);continue}const o=l(n);if(o==null)continue;const t=e.get(o.versionFolderPath)||{versionedFiles:new Map,versions:[]},f=t.versionedFiles.get(o.filePathInVersion)||new Set,d={version:o.versionName};f.add(d.version),!t.hasVersionsConfig&&t.versions.findIndex(u=>u.version===o.versionName)===-1&&t.versions.push(d),t.versionedFiles.set(o.filePathInVersion,f),e.set(o.versionFolderPath,t)}return w(e)};async function y(r,i,s){let e=v.posix.dirname(r);e==="."?e="/":e=e.endsWith("/")?e:e+"/",e.startsWith(c+"/")&&(e=e.slice(c.length+1)),e.startsWith(p+"/")&&(e=e.slice(p.length+1));const n=(await s.load(r,"yaml")).data;n.versions&&!Array.isArray(n.versions)?(await h.panicOnBuild(`Property 'versions' must be an array at %rp. Got '${typeof n.versions}'.`,r),n.versions=[]):(!n.versions||n.versions.length===0)&&g.warn("Property 'versions' is empty at %rp. This is likely a mistake.",r);const o=i.get(e)||{versionedFiles:new Map,versions:[]};o.hasVersionsConfig=!0,o.versions=n.versions||[],n.default&&(o.defaultVersion=n.default),i.set(e,o)}async function F(r){const i=new Set;for(const{relativePath:s}of r){const e=l(s);if(!(e?.versionFolderPath&&m.includes(e?.versionFolderPath))){if(e?.versionFolderPath==null){(s.match(V)?.length||0)>1&&await h.panicOnBuild(`Nested versions are not supported. Detected nested versions in path: "${s}".`);continue}i.has(e.versionFolderPath)||i.add(e.versionFolderPath)}}}function w(r){for(let[i,s]of r){const e=s.hasVersionsConfig?s.versions:s.versions.sort((o,t)=>P(t.version,o.version)),a=s.hasVersionsConfig?e[e.length-1]:e[0],n=s.defaultVersion||a?.version;r.set(i,{...s,versions:e,defaultVersion:n})}return r}function A(r,i){const s=l(r);return s==null?null:i.get(s.versionFolderPath)?.defaultVersion}export{A as getDefaultVersionByPath,R as versionsConfigLoader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{useMutation as
|
|
1
|
+
import*as e from"react";import{useMutation as E,useQueryClient as C}from"@tanstack/react-query";import{useParams as f}from"react-router";import{Button as v}from"@redocly/theme/components/Button/Button";import{H2 as D}from"@redocly/theme/components/Typography/H2";import{Admonition as h}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{useTranslate as P}from"../../../../../client/app/hooks";import{Dialog as A}from"./Dialog";import{ButtonWithLoading as k}from"./ButtonWithLoading";import{ButtonsContainer as S}from"./RollAPIKey";import{DialogInputMultiline as T,DialogRow as w,DialogRowContent as K}from"./DialogStyledComponents";import{MAX_DESCRIPTION_LENGTH as d,CharacterCounter as O}from"./CharacterCounter";const Q=o=>{const{initialDescription:n,open:a,onOpen:i,onClose:t}=o;return e.createElement(A,{open:a,onClose:t,onOpen:i},e.createElement(R,{initialDescription:n,onClose:t}))},R=o=>{const{id:n}=f(),{initialDescription:a,onClose:i}=o,{translate:t}=P(),[r,p]=e.useState(a||""),c=async()=>{await y(),i()},u=s=>{s.key==="Enter"&&!l&&c()},g=C(),{mutateAsync:y,isPending:l,error:m}=E({mutationKey:["UPDATE_APP"+n],mutationFn:()=>fetch(`/api/api-keys/apps/${n}`,{method:"PUT",body:JSON.stringify({description:r})}),onSettled:()=>{g.invalidateQueries({queryKey:["APP:"+n]})}});return e.createElement(e.Fragment,null,e.createElement(D,{"data-translation-key":"dev.edit.description.dialog.title"},t("dev.edit.description.dialog.title","Change description")),e.createElement(w,null,e.createElement(K,null,e.createElement(T,{maxLength:d,value:r,onChange:s=>p(s.target.value),onKeyPress:u,rows:6,cols:60}))),e.createElement(O,null,r.length,"/",d),m&&e.createElement(h,{type:"danger"},m.message," "),e.createElement(S,null,e.createElement(v,{onClick:i,"data-translation-key":"dev.edit.description.dialog.cancel",variant:"text",size:"large"},t("dev.edit.description.dialog.cancel","Cancel")),e.createElement(k,{variant:"primary",loading:l,onClick:c,disabled:l,"data-translation-key":"dev.edit.description.dialog.save"},t("dev.edit.description.dialog.save","Save changes"))))};export{Q as EditAppDescriptionDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{useMutation as
|
|
1
|
+
import*as e from"react";import{useMutation as v,useQueryClient as E}from"@tanstack/react-query";import{useParams as C}from"react-router";import{Button as h}from"@redocly/theme/components/Button/Button";import{H2 as P}from"@redocly/theme/components/Typography/H2";import{Admonition as A}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{useTranslate as k}from"../../../../../client/app/hooks";import{Dialog as D}from"./Dialog";import{ButtonWithLoading as N}from"./ButtonWithLoading";import{ButtonsContainer as S}from"./RollAPIKey";import{DialogInput as w,DialogRow as K,DialogRowContent as O}from"./DialogStyledComponents";const U=e.forwardRef((l,a)=>{const{appName:s,appDisplayName:o}=l,[n,i]=e.useState(!1),r=()=>{i(!0)},t=()=>{i(!1)};return e.useImperativeHandle(a,()=>({open:r})),e.createElement(D,{open:n,onClose:t,onOpen:r},e.createElement(R,{initialName:o||s||"",onClose:t}))}),R=l=>{const{id:a}=C(),{initialName:s,onClose:o}=l,[n,i]=e.useState(s),r=p=>i(p.target.value),{translate:t}=k(),d=async()=>{await f(),o()},g=p=>{p.key==="Enter"&&!m&&u&&d()},y=E(),{mutateAsync:f,isPending:m,error:c}=v({mutationKey:["UPDATE_APP"+a],mutationFn:()=>fetch(`/api/api-keys/apps/${a}`,{method:"PUT",body:JSON.stringify({name:n})}),onSettled:()=>{y.invalidateQueries({queryKey:["APPS","APP:"+a]})}}),u=/^(?!\s*$).{1,100}$/gi.test(n);return e.createElement(e.Fragment,null,e.createElement(P,{"data-translation-key":"dev.edit.app.dialog.title"},t("dev.edit.app.dialog.title","Change display name")),e.createElement(K,null,e.createElement(O,null,e.createElement(w,{value:n,onChange:r,onKeyPress:g}))),c&&e.createElement(A,{type:"danger"},c.message," "),e.createElement(S,null,e.createElement(h,{onClick:o,"data-translation-key":"dev.edit.app.dialog.cancel",variant:"text",size:"large"},t("dev.edit.app.dialog.cancel","Cancel")),e.createElement(N,{variant:"primary",loading:m,onClick:d,disabled:m||!u,"data-translation-key":"dev.edit.app.dialog.save"},t("dev.edit.app.dialog.save","Save changes"))))};export{U as EditAppDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{useMutation as
|
|
1
|
+
import*as e from"react";import{useMutation as y,useQueryClient as b}from"@tanstack/react-query";import{useParams as C}from"react-router";import{Button as U}from"@redocly/theme/components/Button/Button";import{H2 as h}from"@redocly/theme/components/Typography/H2";import{Admonition as v}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{useTranslate as E}from"../../../../../client/app/hooks";import{Dialog as f}from"./Dialog";import{ButtonWithLoading as w}from"./ButtonWithLoading";import{ButtonsContainer as P}from"./RollAPIKey";import{DialogHelperText as D,DialogInputMultiline as R,DialogRow as S,DialogRowContent as A}from"./DialogStyledComponents";const Q=o=>{const{initialCallbackUrl:l,open:r,onOpen:n,onClose:a}=o;return e.createElement(f,{open:r,onClose:a,onOpen:n},e.createElement(T,{initialCallbackUrl:l,onClose:a}))},T=o=>{const{id:l}=C(),{initialCallbackUrl:r,onClose:n}=o,{translate:a}=E(),[c,m]=e.useState(r||""),s=async()=>{await g(),n()},p=t=>{t.key==="Enter"&&!i&&s()},u=b(),{mutateAsync:g,isPending:i,error:d}=y({mutationKey:["UPDATE_APP"+l],mutationFn:async()=>{const t=await fetch(`/api/api-keys/apps/${l}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:c})});if(!t.ok){const k=await t.json().catch(()=>null);throw new Error(k?.error||`Request failed with status ${t.status}`)}return t.json()},onSettled:()=>{u.invalidateQueries({queryKey:["APP:"+l]})}});return e.createElement(e.Fragment,null,e.createElement(h,{"data-translation-key":"dev.edit.callbackUrls.dialog.title"},a("dev.edit.callbackUrls.dialog.title","Change callback URLs")),e.createElement(S,null,e.createElement(A,null,e.createElement(R,{value:c,onChange:t=>m(t.target.value),onKeyPress:p,placeholder:a("dev.edit.callbackUrls.dialog.placeholder","https://example.com/callback"),rows:3}),e.createElement(D,{"data-translation-key":"dev.edit.callbackUrls.dialog.hint"},a("dev.edit.callbackUrls.dialog.hint","Separate multiple URLs with a comma")))),d&&e.createElement(v,{type:"danger"},d.message," "),e.createElement(P,null,e.createElement(U,{onClick:n,"data-translation-key":"dev.edit.callbackUrls.dialog.cancel",variant:"text",size:"large"},a("dev.edit.callbackUrls.dialog.cancel","Cancel")),e.createElement(w,{variant:"primary",loading:i,onClick:s,disabled:i,"data-translation-key":"dev.edit.callbackUrls.dialog.save"},a("dev.edit.callbackUrls.dialog.save","Save changes"))))};export{Q as EditCallbackUrlDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import c from"path";import{compileGlobMatcher as n}from"../../utils/globs.js";const m=new WeakMap,i=(o,e)=>{if(e.length===0)return!1;let t=m.get(e);return t||(t=n(e.map(r=>c.posix.normalize(r))),m.set(e,t)),t(o)};export{i as isPartial};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import{getCallableApis as n,isFetchCapable as o}from"../../../gateway-mcp/callable-apis.js";import{FETCH_TOOL_NAME as i}from"../../constants.js";const
|
|
2
|
-
`),
|
|
3
|
-
`)
|
|
4
|
-
`)}};
|
|
1
|
+
import{getCallableApis as n,isFetchCapable as o}from"../../../gateway-mcp/callable-apis.js";import{FETCH_TOOL_NAME as i}from"../../constants.js";const l=["```ts","/**"," * Call a documented API. Only the callable APIs' documented hosts are reachable."," * Responses cap at 1 MiB and redirects are not followed."," */","declare function fetch(url: string | URL, init?: {"," method?: string;"," /** `content-type` is set automatically for URLSearchParams/FormData unless you set one. */"," headers?: Record<string, string>;"," /** string \xB7 URLSearchParams (\u2192 application/x-www-form-urlencoded) \xB7 FormData (\u2192 multipart/form-data) */"," body?: string | URLSearchParams | FormData;"," /** Security scheme name (from the operation's `security` or `getSecuritySchemes`) whose credential to send. Omit to let the server choose. */"," securityScheme?: string;","}): Promise<{"," status: number;"," statusText: string;"," ok: boolean;"," headers: { get(name: string): string | null };"," json(): Promise<unknown>;"," text(): Promise<string>;","}>;","```"].join(`
|
|
2
|
+
`),c=["listApis","getEndpoints","getEndpointInfo"],h=["Example - list the paid invoices of a billing API:","","```ts","const { items } = await tools.listApis({ filter: 'billing' });","const [api] = items;",`if (!api) return { error: 'no API matches "billing"' };`,"const { endpoints } = await tools.getEndpoints({ name: api.name });","const ep = endpoints.find((e) => e.method === 'GET' && e.path.includes('invoices'));","const info = await tools.getEndpointInfo({ name: api.name, path: ep.path, method: ep.method });","// Replace every `{placeholder}` first.","const url = new URL((info.servers?.[0]?.url ?? '') + ep.path);","// Every name below comes from `info.endpoint.parameters` - read them first, never guess them.","url.searchParams.set('filter', 'status:paid');","url.searchParams.set('sort', '-createdTime');","url.searchParams.set('limit', '100');","try {"," const res = await fetch(url, { method: ep.method });"," return res.ok ? await res.json() : { status: res.status, error: await res.text() };","} catch (error) {"," return { error: error instanceof Error ? error.message : String(error), endpointId: info };","}","```"].join(`
|
|
3
|
+
`),p=["Example - call an endpoint you already read:","","```ts","// Call `getEndpointInfo` first for the server URL, the path, and the parameter names.","// Replace every `{placeholder}` first.","const url = new URL('https://api.example.com/invoices');","url.searchParams.set('filter', 'status:paid');","try {"," const res = await fetch(url, { method: 'GET' });"," return res.ok ? await res.json() : { status: res.status, error: await res.text() };","} catch (error) {"," return { error: error instanceof Error ? error.message : String(error) };","}","```"].join(`
|
|
4
|
+
`);function m(r){return c.every(t=>r.includes(t))?h:p}function d(r){const t=new Map;for(const{name:e,version:a}of r){if(!e)continue;const s=t.get(e)??[];a&&s.push(a),t.set(e,s)}return[...t.entries()].map(([e,a])=>a.length>1?`${e} (${a.map(s=>`v${s}`).join(", ")})`:e).join(", ")}const g={id:i,purpose:"Call the documented APIs over HTTP",isActive:o,annotations:{readOnlyHint:!1,destructiveHint:!0,openWorldHint:!0},renderSection(r,t){const e=d(n(r));return["## `fetch` \u2014 call the documented APIs","",l,"","Always call `getEndpointInfo` before `fetch` for the exact URL, required parameters, and body shape. Put filtering, sorting, and paging in the query parameters, and keep sandbox JS for what the endpoint cannot express. Never guess.","","A `servers[].url` or an endpoint path can hold `{placeholders}`. Replace every one before you call `fetch`. Use the server variable `default`. Ask the user when the `default` only repeats the variable name, such as `{organizationId}`.","","When an operation accepts more than one security scheme, pass `securityScheme` with the scheme name the user holds a credential for; without it the server picks one, and a mismatched credential fails upstream.","",`Callable APIs (their documented hosts are reachable via \`fetch\`): ${e}`,"",m(t)].join(`
|
|
5
|
+
`)}};export{l as FETCH_DECLARATION,g as fetchCapability};
|
|
@@ -8,7 +8,10 @@ export type SandboxCapability = {
|
|
|
8
8
|
isActive(context: McpToolContext): boolean;
|
|
9
9
|
/** How this capability changes `execute`'s MCP annotations when active. */
|
|
10
10
|
annotations: Partial<ToolAnnotations>;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The self-contained `describe-tools` section for this capability: heading, TS declaration,
|
|
13
|
+
* guidance, and an example built only from `describedToolNames`.
|
|
14
|
+
*/
|
|
15
|
+
renderSection(context: McpToolContext, describedToolNames: string[]): string;
|
|
13
16
|
};
|
|
14
17
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{buildToolTypeDeclarations as
|
|
1
|
+
import{buildToolTypeDeclarations as c,sanitizeToolName as p}from"../build-tool-type-declarations.js";import{EXECUTE_BASE_ANNOTATIONS as u}from"../tools/execute-schema.js";import{buildExecuteExample as m,EXECUTE_ARGS_NOTE as a,USAGE_NOTES as E}from"../prompts.js";import{FETCH_TOOL_NAME as f}from"../constants.js";import{ALL_CAPABILITIES as A}from"./registry.js";function S(n){return A.filter(e=>e.isActive(n))}function _(n){return n.reduce((e,i)=>({...e,...i.annotations}),{...u})}function x(n,e,i){const r=n.map(o=>p(o.name)),t=[];if(n.length>0){const o=c(n),s=o.includes("OpenApi")?`
|
|
2
2
|
|
|
3
|
-
${
|
|
3
|
+
${E}`:"";t.push(`## Sandbox tools
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${o}${s}`)}t.push(a),n.length>0&&!e.some(o=>o.id===f)&&t.push(m(r));for(const o of e)t.push(o.renderSection(i,r));return t.join(`
|
|
6
6
|
|
|
7
|
-
`)}export{
|
|
7
|
+
`)}export{_ as composeExecuteAnnotations,S as getActiveCapabilities,x as renderDescribeToolsOutput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{auditInput as
|
|
1
|
+
import{auditInput as t,auditSha256 as h,logAuditRecord as a}from"../audit/audit-log.js";function g({audit:e,code:c,description:d,sessionHandle:o,toolNames:i,fetchBudget:n,fetchCapable:u}){a("Record code execution input",{code_sha256:e.sha256,code_length:e.length,flags:e.flags,subject_sha256:o?h(o):void 0,description:t(d),tools:[...i].sort().join(","),fetch_capable:u,fetch_budget:n,code:t(c)})}export{g as logCodeExecutionAudit};
|
|
@@ -4,6 +4,6 @@ export declare const EXECUTE_ARGS_NOTE = "Both `execute` arguments are required:
|
|
|
4
4
|
export declare function buildExecuteDescription(hasFetch: boolean, toolList?: ToolListEntry[]): string;
|
|
5
5
|
export declare const DESCRIBE_TOOLS_DESCRIPTION: string;
|
|
6
6
|
export declare function buildCodeModeInstructions(hasFetch: boolean, toolList?: ToolListEntry[]): string;
|
|
7
|
-
export declare
|
|
7
|
+
export declare function buildExecuteExample(toolNames: string[]): string;
|
|
8
8
|
export declare const USAGE_NOTES: string;
|
|
9
9
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import{buildToolList as i}from"./build-tool-list.js";const
|
|
1
|
+
import{buildToolList as i}from"./build-tool-list.js";const r=2048,d="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).",n="Available tools (exact signatures come from `describe-tools`):";function a(e,t){if(t.length===0)return e;const o=r-e.length-n.length-3,s=i(t,o);return s?[e,"",n,s].join(`
|
|
2
2
|
`):e}function h(e,t=[]){const o=["Run JavaScript in a sandbox against the documentation tools on the global `tools` object.",e?"The extra globals are `tools`, `fetch`, `URL`, `URLSearchParams`, and `FormData` - there is no `console`, `setTimeout`, `require`, or Node.js API; all other I/O goes through `tools`.":"The only extra global is `tools` - there is no `fetch`, `console`, `setTimeout`, `require`, or Node.js API; all I/O goes through `tools`.","","Workflow - minimize round-trips; one `describe-tools` call plus one `execute` call covers most requests:","1. Analyze the request and decide which sandbox tools it needs.","2. Call `describe-tools` with those names to get their exact TypeScript signatures - inputs, result shapes, and a worked example. NEVER call `execute` with guessed method 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 tool calls, pass one call's output into the next, process results in plain JavaScript, and `return` only what the request needs."].join(`
|
|
3
|
-
`);return a(o,t)}const
|
|
4
|
-
`);function
|
|
5
|
-
`);return a(o,t)}const
|
|
6
|
-
`)
|
|
7
|
-
`)
|
|
3
|
+
`);return a(o,t)}const p=["Get the exact TypeScript signatures of the sandbox tools available to `execute`.","Analyze the user request first, then pass `tools` with only the tool names the request needs (every name is listed in this input schema / description); omit `tools` only when you cannot tell which tools apply.","Always call this before your first `execute` and never guess signatures. Request every tool the task may need in ONE call instead of calling this repeatedly."].join(`
|
|
4
|
+
`);function m(e,t=[]){const o=["This server exposes documentation tools (API discovery, endpoint details, security schemes, full-text search) through `describe-tools` and `execute`:","- `describe-tools` returns the exact TypeScript signatures of the sandbox tools.","- `execute` runs JavaScript that calls those tools on the global `tools` object.","Workflow: analyze the request, call `describe-tools` once with only the tool names it needs, then batch everything into a single `execute` script. Minimize round-trips and never guess tool signatures.",...e?["The sandbox also has a global `fetch` that can call the documented APIs (allow-listed hosts only). Include `fetch` in your `describe-tools` call to get its contract and the list of callable APIs."]:[]].join(`
|
|
5
|
+
`);return a(o,t)}const l=["listApis","getEndpoints"],c=["Example - list the write endpoints of an API:","","```ts","const { items } = await tools.listApis({ filter: 'billing' });","const [api] = items;",`if (!api) return { error: 'no API matches "billing"' };`,"const { endpoints } = await tools.getEndpoints({ name: api.name });","const writes = endpoints.filter((e) => e.method !== 'GET');","return { api: api.name, writes: writes.map((e) => `${e.method} ${e.path}`) };","```"].join(`
|
|
6
|
+
`);function g(e){if(l.every(o=>e.includes(o)))return c;const[t]=e;return t?[`Example - call \`${t}\` and return what the request needs:`,"","```ts",`const result = await tools.${t}({ /* the input its signature above declares */ });`,"return result;","```"].join(`
|
|
7
|
+
`):""}const b=["Types named `OpenApi\u2026` 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{p as DESCRIBE_TOOLS_DESCRIPTION,r as DESCRIPTION_CHAR_LIMIT,d as EXECUTE_ARGS_NOTE,b as USAGE_NOTES,m as buildCodeModeInstructions,h as buildExecuteDescription,g as buildExecuteExample};
|
|
@@ -3,8 +3,8 @@ import type { SandboxFetch, SandboxTool } from '../types.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Builds the `setupContext` that shapes the shared sandbox (`~/server/sandbox`) for code
|
|
5
5
|
* mode: the given tools — and, when provided, host fetch — become host-function rails, each
|
|
6
|
-
* capped and bound by the run's budget, and the prelude installs the
|
|
7
|
-
* over
|
|
6
|
+
* capped and bound by the run's budget, and the fetch prelude installs the guest `fetch`
|
|
7
|
+
* surface over its rail.
|
|
8
8
|
*/
|
|
9
9
|
export declare function createSandboxSetup(tools: Record<string, SandboxTool>, hostFetch?: SandboxFetch): SetupSandboxContext;
|
|
10
10
|
//# sourceMappingURL=create-sandbox-setup.d.ts.map
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import{setupHostFunctions as
|
|
2
|
-
const tools = ${e};
|
|
3
|
-
${e} = new Proxy(tools, {
|
|
4
|
-
get(target, prop) {
|
|
5
|
-
if (typeof prop !== 'string' || prop in target || prop === 'then' || prop === 'toJSON') {
|
|
6
|
-
return target[prop];
|
|
7
|
-
}
|
|
8
|
-
throw new TypeError('Unknown tool "' + prop + '". Available tools: ' + Object.keys(target).join(', '));
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
})();`}export{T as createSandboxSetup};
|
|
1
|
+
import{setupHostFunctions as l}from"../../../../sandbox/utils/setup-host-functions.js";import{evalGuestCode as r}from"../../../../sandbox/utils/eval-guest-code.js";import{CONSOLE_STUB as u,SANDBOX_FETCH_SETUP as _}from"./polyfills/index.js";import{FETCH_BRIDGE_FUNCTION_NAME as i,FETCH_BRIDGE_GLOBAL_NAME as E,TOOLS_BRIDGE_GLOBAL_NAME as L}from"../constants.js";const T=1e3,c=50,p=8*1024*1024;function A(m,t){return(o,s)=>{r(o,`(() => {${u}})();`);const a=[l(o,m,{globalName:L,budget:s,maxCalls:T,maxOutputBytes:p,messages:{outputTooLarge:e=>`Tool output is too large (${e} bytes); request narrower data instead`,callLimitExceeded:e=>`Exceeded the limit of ${e} tool calls`}})];return t&&(a.push(l(o,{[i]:e=>t(e)},{globalName:E,budget:s,maxCalls:c,messages:{outputTooLarge:e=>`Response is too large (${e} bytes); request less data`,callLimitExceeded:e=>`Exceeded the limit of ${e} fetch calls`}})),r(o,`(() => {${_}})();`)),()=>{for(const e of a)e()}}}export{A as createSandboxSetup};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const CONSOLE_STUB = "\nglobalThis.console = Object.freeze({\n assert() {}, clear() {}, count() {}, countReset() {}, debug() {}, dir() {}, dirxml() {},\n error() {}, group() {}, groupCollapsed() {}, groupEnd() {}, info() {}, log() {}, table() {},\n time() {}, timeEnd() {}, timeLog() {}, trace() {}, warn() {},\n});\n";
|
|
2
|
+
//# sourceMappingURL=console.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const e=`
|
|
2
|
+
globalThis.console = Object.freeze({
|
|
3
|
+
assert() {}, clear() {}, count() {}, countReset() {}, debug() {}, dir() {}, dirxml() {},
|
|
4
|
+
error() {}, group() {}, groupCollapsed() {}, groupEnd() {}, info() {}, log() {}, table() {},
|
|
5
|
+
time() {}, timeEnd() {}, timeLog() {}, trace() {}, warn() {},
|
|
6
|
+
});
|
|
7
|
+
`;export{e as CONSOLE_STUB};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{FETCH_SHIM as o}from"./fetch-shim.js";import{FORM_DATA_POLYFILL as L}from"./form-data.js";import{URL_POLYFILL as r}from"./url.js";import{URL_SEARCH_PARAMS_POLYFILL as _}from"./url-search-params.js";const
|
|
2
|
-
`);export{
|
|
1
|
+
import{FETCH_SHIM as o}from"./fetch-shim.js";import{FORM_DATA_POLYFILL as L}from"./form-data.js";import{URL_POLYFILL as r}from"./url.js";import{URL_SEARCH_PARAMS_POLYFILL as _}from"./url-search-params.js";const p=[_,r,L,o].join(`
|
|
2
|
+
`);import{CONSOLE_STUB as f}from"./console.js";export{f as CONSOLE_STUB,p as SANDBOX_FETCH_SETUP};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
type ToolInputValidator = (input: unknown) => string | undefined;
|
|
2
|
+
/** Validates a sandbox tool call against the tool's MCP input schema before the handler runs. */
|
|
3
|
+
export declare function createToolInputValidator(sandboxName: string, schema: Record<string, unknown>): ToolInputValidator;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=tool-input-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"@redocly/ajv";const c=new s({allErrors:!0}),n=new Map;function f(t,r){const e=d(r);if(!e)return()=>{};const o=Object.keys(r.properties??{});return i=>{if(e(i??{}))return;const a=p(e.errors??[]);return`Invalid input for tools.${t}: ${a.join("; ")}. Accepted properties: ${o.join(", ")}. Call describe-tools for the exact signature.`}}function d(t){const r=JSON.stringify(t);if(n.has(r))return n.get(r);let e;try{e=c.compile(t)}catch{e=void 0}return n.set(r,e),e}function p(t){const r=new Set;for(const e of t)switch(e.keyword){case"additionalProperties":r.add(`unknown property "${e.params.additionalProperty}"`);break;case"required":r.add(`missing required property "${e.params.missingProperty}"`);break;default:r.add(`${u(e.instancePath)} ${e.message}`)}return[...r]}function u(t){return t?`"${t.replace(/^\//,"").replace(/\//g,".")}"`:"input"}export{f as createToolInputValidator};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GuestPosition } from '../../../../sandbox/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Turns a guest error into the message the model reads. A call on a tool the sandbox does not
|
|
4
|
+
* hold names that tool and lists the available ones; every other error keeps its message and
|
|
5
|
+
* gains the line it was thrown on.
|
|
6
|
+
*/
|
|
7
|
+
export declare function describeGuestError(code: string, message: string, position: GuestPosition | undefined, availableTools: string[]): string;
|
|
8
|
+
//# sourceMappingURL=unknown-tool-hint.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{TOOLS_BRIDGE_GLOBAL_NAME as c}from"../constants.js";const i="not a function",d=new RegExp(`(?:^|[^\\w$.])${c}\\s*(?:(?:\\?\\.|\\.)\\s*([A-Za-z_$][\\w$]*)|(?:\\?\\.)?\\s*\\[\\s*(['"])([^'"]*)\\2\\s*\\])\\s*(?:\\?\\.)?\\s*$`);function $(o,t,n,e){const u=n&&E(o,n);if(!n||u===void 0)return t;const f=t===i?l(o.slice(0,u),e):void 0;return f===void 0?`${t} (line ${n.line})`:`Unknown tool "${f}". Available tools: ${e.join(", ")}`}function l(o,t){const n=d.exec(o),e=n?.[1]??n?.[3];return e!==void 0&&!t.includes(e)?e:void 0}function E(o,{line:t,column:n}){const e=o.split(`
|
|
2
|
+
`);if(t>e.length)return;const f=e.slice(0,t-1).reduce((r,s)=>r+s.length+1,0)+n-1;return f<=o.length?f:void 0}export{$ as describeGuestError};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{renderDescribeToolsOutput as
|
|
1
|
+
import{renderDescribeToolsOutput as O}from"../capabilities/index.js";import{McpServerType as M}from"../../constants.js";import{reportMcpToolCalled as _,reportMcpToolError as k}from"../../workers/mcp-tool-telemetry.js";import{DESCRIBE_TOOLS_TOOL_NAME as d}from"../constants.js";import{DESCRIBE_TOOLS_DESCRIPTION as D}from"../prompts.js";import{sanitizeToolName as n}from"../build-tool-type-declarations.js";import{UnknownToolError as v}from"./tool-errors.js";function x(i,c){const t=[...new Set([...i.map(s=>n(s.name)),...c.map(s=>n(s.id))])];return{name:d,title:"Describe tools",description:D,schema:{type:"object",required:[],additionalProperties:!1,properties:{tools:{type:"array",description:`Tool names to describe: ${t.join(", ")}. Omit to describe everything.`,items:t.length>0?{type:"string",enum:t}:{type:"string"},nullable:!0}}}}}function P(i,c,t,s){const l=new Map(i.map(r=>[n(r.name),r])),f=new Map(t.map(r=>[n(r.id),r]));return async r=>{const u=performance.now(),h=s.mcpMode??"code";try{const o=[...new Set((r.tools??[]).map(n))],a=o.length===0,T=o.filter(e=>!l.has(e)&&!f.has(e));if(T.length>0){const e=[...l.keys(),...f.keys()];throw new v(`Unknown tool(s): ${T.join(", ")}. Valid tools: ${e.join(", ")}.`)}const E=a?t:t.filter(e=>o.includes(n(e.id))),p=a?i:o.filter(e=>l.has(e)).map(e=>l.get(e)),y=await Promise.all(p.map(e=>c(e.name))),S=p.filter((e,m)=>y[m]),w=p.filter((e,m)=>!y[m]),g=[O(S,E,s)];w.length>0&&g.push(`Not available for this request: ${w.map(e=>n(e.name)).join(", ")}`);const b=g.join(`
|
|
2
|
+
|
|
3
|
+
`);return _({tool:d,mode:h,serverType:M.Docs,durationMs:Math.round(performance.now()-u),outputLength:b.length}),{content:[{type:"text",text:b}]}}catch(o){const a=o instanceof v;throw k({tool:d,mode:h,serverType:M.Docs,durationMs:Math.round(performance.now()-u),message:o instanceof Error?o.message:String(o),stack:!a&&o instanceof Error&&o.stack||"",errorClass:a?"tool_error":"server_error"}),o}}}export{P as describeTools,x as describeToolsSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{runInSandbox as
|
|
1
|
+
import{runInSandbox as b}from"../../../../sandbox/sandbox.js";import{returnLastExpression as w}from"../../../../sandbox/utils/return-last-expression.js";import{isMcpToolAvailable as C}from"../../workers/execute-mcp-tool.js";import{importMcpToolHandlers as O}from"../../workers/import-mcp-tool-handlers.js";import{isFetchCapable as T}from"../../gateway-mcp/callable-apis.js";import{buildExecuteHostFetch as y}from"../../gateway-mcp/fetch-capability.js";import{withAuthRequiredMeta as x}from"../../gateway-mcp/upstream-auth.js";import{CODE_MODE_TOOL_NAMES as M,EXECUTE_TOOL_NAME as S}from"../constants.js";import{sanitizeToolName as v}from"../build-tool-type-declarations.js";import{invokeTool as A}from"../invoke-tool.js";import{createSandboxSetup as _}from"../sandbox/create-sandbox-setup.js";import{createToolInputValidator as k}from"../sandbox/tool-input-validator.js";import{describeGuestError as F}from"../sandbox/unknown-tool-hint.js";import{auditCode as N}from"../code-audit.js";import{reportCodeExecuted as j}from"../code-execution-telemetry.js";import{logCodeExecutionAudit as D}from"../code-execution-audit.js";const H=async(o,r,u)=>{const i=new Set,n=await P(r,u,i),s=[],e=T(r)?await y(r,p=>s.push(p)):void 0;let m=0;const f=e?p=>(m+=1,e(p)):void 0,a=N(o.code);D({audit:a,code:o.code,description:o.description,sessionHandle:o.sessionHandle,toolNames:Object.keys(n),fetchBudget:r.gatewayFetchBudgetPerExec,fetchCapable:e!==void 0});const l=Date.now(),d=w(o.code),{result:c,error:t,errorPosition:h}=await b(d,{setupContext:_(n,f),authoredCode:o.code});j({audit:a,fetchCount:m,outcome:t===void 0?"ok":"error",durationMs:Date.now()-l,client:r.client,clientVersion:r.clientVersion});const E=t===void 0?void 0:F(d,t,h,Object.keys(n));return x({content:[{type:"text",text:JSON.stringify({result:c,error:E})}],isError:t!==void 0,...t!==void 0&&i.has(t)?{errorClass:"tool_error"}:{}},s)};async function P(o,r,u){const i=Object.keys(await O()).filter(e=>!M.has(e)),n=await Promise.all(i.map(e=>C({toolName:e,context:o}).catch(()=>!1))),s={};return i.forEach((e,m)=>{if(!n[m])return;const f=v(e),a=o.sandboxToolSchemas?.[e],l=a?k(f,a):void 0;s[f]=d=>{const c=l?.(d);return c?(u.add(c),Promise.reject(new Error(c))):A(e,d,o,r).catch(t=>{throw t instanceof Error&&u.add(t.message),t})}}),s}var Z={[S]:H};export{Z as default};
|