@wix/mcp 1.0.94 → 1.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +2 -2
  2. package/build/bin-standalone.js +1457 -332
  3. package/build/cjs/index.cjs +3379 -1333
  4. package/build/cjs/toolkit.cjs +2158 -373
  5. package/build/dts/api-call/headless-release.d.ts +56 -0
  6. package/build/dts/api-call/headless-release.js +135 -0
  7. package/build/dts/api-call/index.d.ts +9 -1
  8. package/build/dts/api-call/index.js +36 -8
  9. package/build/dts/api-call/site-files.d.ts +14 -0
  10. package/build/dts/api-call/site-files.js +106 -10
  11. package/build/dts/api-call/upload-headless-website-files.d.ts +117 -5
  12. package/build/dts/api-call/upload-headless-website-files.js +565 -20
  13. package/build/dts/api-call/upload-image-tool.d.ts +2 -0
  14. package/build/dts/api-call/upload-image-tool.js +8 -4
  15. package/build/dts/bin.d.ts +1 -1
  16. package/build/dts/bin.js +3 -1
  17. package/build/dts/code-mode/attachments.d.ts +9 -6
  18. package/build/dts/code-mode/attachments.js +23 -16
  19. package/build/dts/code-mode/index.d.ts +6 -1
  20. package/build/dts/code-mode/index.js +32 -12
  21. package/build/dts/code-mode/truncate-response.js +5 -1
  22. package/build/dts/config/default-config.d.ts +35 -5
  23. package/build/dts/config/default-config.js +339 -182
  24. package/build/dts/config/file-params.d.ts +22 -0
  25. package/build/dts/config/file-params.js +24 -0
  26. package/build/dts/config/param-descriptions.d.ts +14 -2
  27. package/build/dts/config/param-descriptions.js +33 -14
  28. package/build/dts/constants.d.ts +1 -0
  29. package/build/dts/constants.js +1 -0
  30. package/build/dts/docs/docs.d.ts +12 -1
  31. package/build/dts/docs/docs.js +274 -43
  32. package/build/dts/docs/fetch-article.d.ts +21 -0
  33. package/build/dts/docs/fetch-article.js +66 -4
  34. package/build/dts/docs/get-to-know.d.ts +7 -2
  35. package/build/dts/docs/get-to-know.js +36 -14
  36. package/build/dts/docs/guessed-url.d.ts +41 -0
  37. package/build/dts/docs/guessed-url.js +185 -0
  38. package/build/dts/docs/mintlify-docs.d.ts +121 -0
  39. package/build/dts/docs/mintlify-docs.js +391 -0
  40. package/build/dts/docs/semanticSearch.d.ts +2 -1
  41. package/build/dts/docs/semanticSearch.js +14 -7
  42. package/build/dts/docs/start-deploy-website.d.ts +7 -6
  43. package/build/dts/docs/start-deploy-website.js +13 -8
  44. package/build/dts/docs/start-headless-build.d.ts +8 -10
  45. package/build/dts/docs/start-headless-build.js +14 -28
  46. package/build/dts/index.d.ts +2 -2
  47. package/build/dts/index.js +2 -2
  48. package/build/dts/infra/redact-personal-data.d.ts +4 -0
  49. package/build/dts/infra/redact-personal-data.js +148 -0
  50. package/build/dts/site-widget-tools/constants.d.ts +50 -2
  51. package/build/dts/site-widget-tools/constants.js +65 -8
  52. package/build/dts/site-widget-tools/index.d.ts +1 -0
  53. package/build/dts/site-widget-tools/index.js +1 -0
  54. package/build/dts/site-widget-tools/pick-images-tool/index.d.ts +14 -0
  55. package/build/dts/site-widget-tools/pick-images-tool/index.js +138 -0
  56. package/build/dts/site-widget-tools/pull-site-creation-job-tool/index.js +1 -1
  57. package/build/dts/site-widget-tools/search-site-templates-tool/index.js +25 -2
  58. package/build/dts/site-widget-tools/site-builder-tool/index.js +35 -3
  59. package/build/dts/site-widget-tools/site-creation-tool/index.d.ts +7 -1
  60. package/build/dts/site-widget-tools/site-creation-tool/index.js +22 -51
  61. package/build/dts/site-widget-tools/suggested-domain-tool/index.js +26 -12
  62. package/build/dts/support/index.d.ts +4 -0
  63. package/build/dts/support/index.js +13 -7
  64. package/build/dts/tool-utils.d.ts +8 -1
  65. package/build/dts/tool-utils.js +26 -2
  66. package/build/dts/toolkit-entry.d.cts +15 -10
  67. package/build/dts/toolkit-entry.d.ts +15 -10
  68. package/build/dts/toolkit.d.ts +2 -2
  69. package/build/dts/toolkit.js +21 -8
  70. package/build/dts/wix-mcp-server.d.ts +10 -1
  71. package/build/dts/wix-mcp-server.js +25 -7
  72. package/build/dts/wixel/constants.d.ts +8 -1
  73. package/build/dts/wixel/constants.js +8 -1
  74. package/build/dts/wixel/index.d.ts +1 -1
  75. package/build/dts/wixel/index.js +2 -2
  76. package/build/dts/wixel/wixel-a2a-client.d.ts +83 -0
  77. package/build/dts/wixel/wixel-a2a-client.js +166 -0
  78. package/build/dts/wixel/wixel-bi.d.ts +2 -1
  79. package/build/dts/wixel/wixel-bi.js +2 -1
  80. package/build/dts/wixel/{external-agent-api.d.ts → wixel-session-entries.d.ts} +11 -33
  81. package/build/dts/wixel/{external-agent-api.js → wixel-session-entries.js} +33 -54
  82. package/build/dts/wixel/wixel-session-tools.d.ts +21 -26
  83. package/build/dts/wixel/wixel-session-tools.js +494 -599
  84. package/build/esm/index.js +3422 -1388
  85. package/build/esm/toolkit.js +2158 -373
  86. package/package.json +4 -4
@@ -2,15 +2,17 @@ import { z } from 'zod';
2
2
  import { runSemanticSearchAndFormat } from './semanticSearch.js';
3
3
  import { logger } from '../infra/logger.js';
4
4
  import { captureException } from '@sentry/node';
5
- import { fetchArticleContent, isSkillsRegistryUrl } from './fetch-article.js';
5
+ import { fetchArticleContent, fetchSourceContent, isSkillsRegistryUrl, parseSourceContentUrl } from './fetch-article.js';
6
6
  import { normalizeMenuContent, summarizeLargeMenu, fetchMenuContent, MENU_CONTENT_THRESHOLD } from './normalize-menu-content.js';
7
7
  import { fetchPlatformizedMenu, MenuNotFoundError } from './browse-menu.js';
8
+ import { closestMenuLinks, closestSkillFile, parentMenuUrls, skillManifestUrl, subMenusToRead } from './guessed-url.js';
8
9
  import { isQueryOrSearchEndpoint, QUERY_CAPABILITY_MARKER } from './searchFormatting.js';
9
10
  import { addGetToKnowTools, addGetSiteContextTool } from './get-to-know.js';
10
11
  import { addStartHeadlessBuildTool } from './start-headless-build.js';
11
12
  import { addStartDeployWebsiteTool } from './start-deploy-website.js';
12
- import { defaultToolDescriptions } from '../config/default-config.js';
13
- import { desc } from '../config/param-descriptions.js';
13
+ import { defaultToolDescriptions, HELP_CENTER_IS_FOR_PEOPLE } from '../config/default-config.js';
14
+ import { desc as paramDescriptionsOf } from '../config/param-descriptions.js';
15
+ import { isMintlifyDocsSite, isMintlifyUrl, MINTLIFY_URL_PREFIXES, mintlifyDocumentTypes, readMintlifyMarkdown, rewriteDocsLinks, toDevWixUrl, toMintlifyHostText } from './mintlify-docs.js';
14
16
  import dedent from 'dedent';
15
17
  export const VALID_DOCS_TOOLS = [
16
18
  'WDS',
@@ -21,7 +23,8 @@ export const VALID_DOCS_TOOLS = [
21
23
  'VELO',
22
24
  'BUSINESS_SOLUTIONS',
23
25
  'CLI',
24
- 'OVERVIEW'
26
+ 'OVERVIEW',
27
+ 'HELP_CENTER'
25
28
  ];
26
29
  const REST_SEARCH_API_GROUNDING_REMINDER = dedent `
27
30
  # Before calling a Wix API
@@ -53,7 +56,17 @@ function shouldTryMenuFallbackForDocsRead(error, articleUrl) {
53
56
  if (!message.includes('404') || !isMenuFallbackUrl) {
54
57
  return false;
55
58
  }
56
- return !['This resource is deprecated', 'No schema found'].some((knownArticleError) => message.includes(knownArticleError));
59
+ return !isKnownArticleError(error);
60
+ }
61
+ // A 404 that says why (a deprecated page, a method with no schema) is the answer itself.
62
+ function isKnownArticleError(error) {
63
+ const message = getErrorMessage(error);
64
+ return [
65
+ 'This resource is deprecated',
66
+ 'This method is deprecated',
67
+ 'This article is deprecated',
68
+ 'No schema found'
69
+ ].some((knownArticleError) => message.includes(knownArticleError));
57
70
  }
58
71
  function formatDocsReadError(toolAction, error) {
59
72
  return `Could not fetch ${toolAction}: "${getErrorMessage(error)}".`;
@@ -66,18 +79,59 @@ export const addDocsTools = (server, allowedTools = [
66
79
  'WIX_HEADLESS',
67
80
  'BUSINESS_SOLUTIONS',
68
81
  'CLI',
69
- 'OVERVIEW'
82
+ 'OVERVIEW',
83
+ 'HELP_CENTER'
70
84
  ], options = {}) => {
71
- const { getToKnowWixEnabled = false, startDeployWebsiteEnabled = true, startHeadlessBuildEnabled = true, disableTools, toolDescriptions, readmeDocs, authStrategy, skillsPortalUrl, skillsRepo, repo, skillsPr, commitHash, skillsTags, dynamicContextEnabled, usePlatformizedSearch = true, usePlatformizedBrowse = true } = options;
85
+ const { getToKnowWixEnabled = false, startDeployWebsiteEnabled = true, startHeadlessBuildEnabled = true, disableTools, toolDescriptions, readmeDocs, authStrategy, skillsPortalUrl, skillsRepo, repo, skillsPr, commitHash, skillsTags, readmeRecipesIndexEnabled, dynamicContextEnabled, includeCompanionApp, usePlatformizedSearch = true, usePlatformizedBrowse = true, docsSite } = options;
72
86
  const effectiveRepo = repo ?? skillsRepo;
73
87
  const effectiveCommitHash = commitHash ?? skillsPr;
88
+ // Mintlify docs: search as today, then resolve the links in the results.
89
+ const mintlifyDocs = isMintlifyDocsSite(docsSite);
90
+ const runSearch = mintlifyDocs
91
+ ? async (params) => {
92
+ // Stage 2 (docsSite=mintlify): REST and SDK search the Mintlify KBs.
93
+ const documentTypes = mintlifyDocumentTypes(docsSite, params.toolName);
94
+ const result = await runSemanticSearchAndFormat(documentTypes ? { ...params, documentTypes } : params);
95
+ return (await rewriteDocsLinks(result, { label: `search ${params.toolName}` })).text;
96
+ }
97
+ : runSemanticSearchAndFormat;
98
+ const docsUrlPrefixes = mintlifyDocs
99
+ ? ['https://dev.wix.com/docs/', ...MINTLIFY_URL_PREFIXES]
100
+ : ['https://dev.wix.com/docs/'];
101
+ // The backends only know dev.wix.com; Mintlify paths map back one to one.
102
+ const toBackendUrl = (url) => mintlifyDocs && isMintlifyUrl(url) ? toDevWixUrl(url) : url;
103
+ // Mintlify docs: a separate text block naming where a read's content came from.
104
+ const sourceNote = (source) => mintlifyDocs
105
+ ? [{ type: 'text', text: `[docs source] ${source}` }]
106
+ : [];
107
+ // Mintlify docs: tool and parameter texts show docs URLs on the Mintlify host, or
108
+ // the model cites dev.wix.com (it copies the examples' host into answers).
109
+ const docsText = (text) => mintlifyDocs ? toMintlifyHostText(text) : text;
110
+ const desc = (toolName) => {
111
+ const descriptions = paramDescriptionsOf(toolName);
112
+ if (!mintlifyDocs)
113
+ return descriptions;
114
+ return Object.fromEntries(Object.entries(descriptions).map(([param, text]) => [
115
+ param,
116
+ docsText(text)
117
+ ]));
118
+ };
74
119
  // Helper to get description (custom or default)
75
- const getDescription = (toolName, defaultDesc) => toolDescriptions?.[toolName] ?? defaultDesc;
120
+ const getDescription = (toolName, defaultDesc) => docsText(toolDescriptions?.[toolName] ?? defaultDesc);
76
121
  // Menu text for a docs URL, shared by BrowseWixRESTDocsMenu and the
77
122
  // ReadFullDocs* category fallbacks. Platformized browse first — its 404 is a
78
123
  // real answer (null, no such menu); any other failure falls back to the
79
124
  // legacy get-menu-content scrape, which keeps its original thresholding.
80
125
  const fetchMenuTextForUrl = async (httpClient, url) => {
126
+ const text = await fetchMenuTextForBackendUrl(httpClient, toBackendUrl(url));
127
+ if (!text || !mintlifyDocs)
128
+ return text;
129
+ // Menu links are Portal Service nodes, the same tree the Mintlify
130
+ // navigation is built from, so they map by rule without a page check.
131
+ return (await rewriteDocsLinks(text, { verify: false, label: 'menu' }))
132
+ .text;
133
+ };
134
+ const fetchMenuTextForBackendUrl = async (httpClient, url) => {
81
135
  if (usePlatformizedBrowse) {
82
136
  try {
83
137
  return await fetchPlatformizedMenu(url);
@@ -96,16 +150,81 @@ export const addDocsTools = (server, allowedTools = [
96
150
  ? summarizeLargeMenu(menuContent, url)
97
151
  : normalizeMenuContent(menuContent);
98
152
  };
153
+ // A docs or skills page that 404'd, most often a URL rewritten or guessed from a real one:
154
+ // the closest file in the skill or its folder's files, or the nearest menu above a docs page
155
+ // with its closest entries (one level into its closest sub-menus when none of its own is
156
+ // close). Null when nothing near exists, so the 404 stands.
157
+ const nearestToMissingPage = async (httpClient, url, isSkillsPage) => {
158
+ try {
159
+ if (isSkillsPage) {
160
+ const manifestUrl = skillManifestUrl(url);
161
+ if (!manifestUrl)
162
+ return null;
163
+ const manifest = JSON.parse(await fetchArticleContent(httpClient, manifestUrl, 'article'));
164
+ const guess = closestSkillFile(url, manifest, manifestUrl);
165
+ if (!guess)
166
+ return null;
167
+ if (guess.kind === 'file') {
168
+ const text = await fetchArticleContent(httpClient, guess.url, 'article');
169
+ return `Note: "${url}" does not exist. Found a similar file in the skill, ${guess.url}, and read it:\n\n${text}`;
170
+ }
171
+ return `Note: "${url}" does not exist, and no file in ${guess.folder ? `its folder (${guess.folder}/)` : 'the skill'} has a name close to it. ${guess.folder ? 'The files in that folder' : "The skill's top-level folders and files"}, to read the one you need (every file: ${guess.manifestUrl}):\n\n${guess.files.map((f) => `- ${f}`).join('\n')}`;
172
+ }
173
+ for (const menuUrl of parentMenuUrls(url)) {
174
+ const text = await fetchMenuTextForUrl(httpClient, menuUrl);
175
+ if (!text)
176
+ continue;
177
+ const subMenus = (await Promise.all(subMenusToRead(text, menuUrl, url).map(async (sub) => ({
178
+ sub,
179
+ text: await fetchMenuTextForUrl(httpClient, sub).catch(() => null)
180
+ })))).filter((m) => !!m.text);
181
+ const closest = closestMenuLinks([text, ...subMenus.map((m) => m.text)].join('\n'), menuUrl, url);
182
+ return [
183
+ `Note: "${url}" does not exist. Showing the nearest documentation menu above it, ${menuUrl}; read the page you need from its links.`,
184
+ ...(closest.length
185
+ ? [
186
+ `Closest to what you asked for:\n${closest.map((l) => `- ${l}`).join('\n')}`
187
+ ]
188
+ : []),
189
+ text
190
+ ].join('\n\n');
191
+ }
192
+ }
193
+ catch (error) {
194
+ logger.error(`[docs] no nearest page for ${url}: ${error}`);
195
+ }
196
+ return null;
197
+ };
198
+ // The two site-creation guides register first, so they head the tool list: an agent that
199
+ // loads every definition at once and gets a cut-down copy keeps the start and the end.
200
+ // On by default: they are routing slots, not docs sources.
201
+ if (startDeployWebsiteEnabled) {
202
+ addStartDeployWebsiteTool(server, disableTools || [], toolDescriptions, {
203
+ skillsPortalUrl,
204
+ repo: effectiveRepo,
205
+ commitHash: effectiveCommitHash
206
+ });
207
+ }
208
+ // Same reach as StartDeployWebsite: the slot for a site that needs Wix business features.
209
+ if (startHeadlessBuildEnabled) {
210
+ addStartHeadlessBuildTool(server, disableTools || [], toolDescriptions, {
211
+ skillsPortalUrl,
212
+ repo: effectiveRepo,
213
+ commitHash: effectiveCommitHash
214
+ });
215
+ }
99
216
  if (dynamicContextEnabled &&
100
217
  authStrategy &&
101
218
  !disableTools?.includes('GetSiteContext')) {
102
219
  addGetSiteContextTool({
103
220
  server,
104
221
  authStrategy,
222
+ includeCompanionApp,
105
223
  toolDescriptions,
106
224
  disableTools: disableTools || []
107
225
  });
108
226
  }
227
+ // Named in SERVER_INSTRUCTIONS (config/default-config.ts): when this tool's name or what it is for changes, update them to match.
109
228
  if (getToKnowWixEnabled && !disableTools?.includes('WixREADME')) {
110
229
  addGetToKnowTools({
111
230
  server,
@@ -117,24 +236,9 @@ export const addDocsTools = (server, allowedTools = [
117
236
  dynamicContextEnabled,
118
237
  repo: effectiveRepo,
119
238
  commitHash: effectiveCommitHash,
120
- skillsTags
121
- });
122
- }
123
- // On by default: it is a routing slot, not a docs source — the agent with
124
- // ready-made site files must find it next to the site-creation tools.
125
- if (startDeployWebsiteEnabled) {
126
- addStartDeployWebsiteTool(server, disableTools || [], toolDescriptions, {
127
- skillsPortalUrl,
128
- repo: effectiveRepo,
129
- commitHash: effectiveCommitHash
130
- });
131
- }
132
- // Same reach as StartDeployWebsite: the slot for a site built in code with no code yet.
133
- if (startHeadlessBuildEnabled) {
134
- addStartHeadlessBuildTool(server, disableTools || [], toolDescriptions, {
135
- skillsPortalUrl,
136
- repo: effectiveRepo,
137
- commitHash: effectiveCommitHash
239
+ skillsTags,
240
+ readmeRecipesIndexEnabled,
241
+ docsSite
138
242
  });
139
243
  }
140
244
  // WDS Documentation
@@ -155,7 +259,7 @@ export const addDocsTools = (server, allowedTools = [
155
259
  })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ searchTerm, maxResults }, { panorama }) => {
156
260
  try {
157
261
  logger.log(`Searching for ${searchTerm} in Wix WDS`);
158
- const result = await runSemanticSearchAndFormat({
262
+ const result = await runSearch({
159
263
  toolName: 'WDS',
160
264
  toolParams: {
161
265
  searchTerm: searchTerm
@@ -207,7 +311,7 @@ export const addDocsTools = (server, allowedTools = [
207
311
  })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ searchTerm, maxResults, reason }, { panorama }) => {
208
312
  try {
209
313
  logger.log(`[SearchWixRESTDocumentation] searchTerm="${searchTerm}", reason="${reason}"`);
210
- const result = await runSemanticSearchAndFormat({
314
+ const result = await runSearch({
211
315
  toolName: 'REST',
212
316
  toolParams: {
213
317
  searchTerm: searchTerm
@@ -270,7 +374,7 @@ export const addDocsTools = (server, allowedTools = [
270
374
  })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ searchTerm, maxResults }, { panorama }) => {
271
375
  try {
272
376
  logger.log(`Searching for ${searchTerm} in Wix Sample Flows`);
273
- const result = await runSemanticSearchAndFormat({
377
+ const result = await runSearch({
274
378
  toolName: 'BUSINESS_SOLUTIONS',
275
379
  toolParams: {
276
380
  searchTerm: '**RECIPE**: Business Recipes - full setup flow for::: ' +
@@ -328,7 +432,7 @@ export const addDocsTools = (server, allowedTools = [
328
432
  panorama
329
433
  .transaction('SearchWixSDKDocumentation')
330
434
  .start({ maxResults });
331
- const result = await runSemanticSearchAndFormat({
435
+ const result = await runSearch({
332
436
  toolName: 'SDK',
333
437
  toolParams: {
334
438
  searchTerm: searchTerm
@@ -386,7 +490,7 @@ export const addDocsTools = (server, allowedTools = [
386
490
  })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ searchTerm, maxResults }, { panorama }) => {
387
491
  try {
388
492
  logger.log(`Searching for ${searchTerm} in Build Apps`);
389
- const result = await runSemanticSearchAndFormat({
493
+ const result = await runSearch({
390
494
  toolName: 'BUILD_APPS',
391
495
  toolParams: {
392
496
  searchTerm: `wix cli docs for ${searchTerm}`
@@ -436,7 +540,7 @@ export const addDocsTools = (server, allowedTools = [
436
540
  })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ searchTerm, maxResults }, { panorama }) => {
437
541
  try {
438
542
  logger.log(`Searching for ${searchTerm} in Wix Overview`);
439
- const result = await runSemanticSearchAndFormat({
543
+ const result = await runSearch({
440
544
  toolName: 'OVERVIEW',
441
545
  toolParams: {
442
546
  searchTerm: searchTerm
@@ -486,7 +590,7 @@ export const addDocsTools = (server, allowedTools = [
486
590
  })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ searchTerm, maxResults }, { panorama }) => {
487
591
  try {
488
592
  logger.log(`Searching for ${searchTerm} in Headless`);
489
- const result = await runSemanticSearchAndFormat({
593
+ const result = await runSearch({
490
594
  toolName: 'WIX_HEADLESS',
491
595
  toolParams: {
492
596
  searchTerm: searchTerm
@@ -542,7 +646,7 @@ export const addDocsTools = (server, allowedTools = [
542
646
  panorama
543
647
  .transaction('SearchWixVeloDocumentation')
544
648
  .start({ maxResults });
545
- const result = await runSemanticSearchAndFormat({
649
+ const result = await runSearch({
546
650
  toolName: 'VELO',
547
651
  toolParams: {
548
652
  searchTerm: searchTerm
@@ -583,6 +687,66 @@ export const addDocsTools = (server, allowedTools = [
583
687
  });
584
688
  }
585
689
  // CLI Documentation
690
+ // Help Center (support.wix.com): how site owners do things in the Wix
691
+ // dashboard and editors. Articles are long and prose-only, so fewer results
692
+ // with a larger line budget than the developer docs tools.
693
+ if (allowedTools.includes('HELP_CENTER') &&
694
+ !disableTools?.includes('SearchWixHelpCenter')) {
695
+ server.tool('SearchWixHelpCenter', getDescription('SearchWixHelpCenter', defaultToolDescriptions.SearchWixHelpCenter ?? ''), (() => {
696
+ const d = desc('SearchWixHelpCenter');
697
+ return {
698
+ searchTerm: z.string().describe(d.searchTerm),
699
+ maxResults: z
700
+ .number()
701
+ .describe(d.maxResults)
702
+ .min(1)
703
+ .max(15)
704
+ .optional()
705
+ .default(15),
706
+ reason: z.string().describe(d.reason)
707
+ };
708
+ })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ searchTerm, maxResults, reason }, { panorama }) => {
709
+ try {
710
+ logger.log(`[SearchWixHelpCenter] searchTerm="${searchTerm}", reason="${reason}"`);
711
+ const result = await runSemanticSearchAndFormat({
712
+ toolName: 'HELP_CENTER',
713
+ toolParams: {
714
+ searchTerm: searchTerm
715
+ },
716
+ maxResults: Math.max(1, Math.min(maxResults ?? 15, 15)),
717
+ linesInEachResult: 60,
718
+ usePlatformizedSearch
719
+ });
720
+ return {
721
+ content: [
722
+ {
723
+ type: 'text',
724
+ text: `${HELP_CENTER_IS_FOR_PEOPLE}\n\n${result}`
725
+ }
726
+ ]
727
+ };
728
+ }
729
+ catch (error) {
730
+ panorama.errorMonitor().reportError(error);
731
+ captureException(error, {
732
+ tags: {
733
+ componentId: 'SearchWixHelpCenter',
734
+ toolName: 'SearchWixHelpCenter'
735
+ }
736
+ });
737
+ logger.error(`Error searching for ${searchTerm} in the Wix Help Center: ${error}`);
738
+ return {
739
+ isError: true,
740
+ content: [
741
+ {
742
+ type: 'text',
743
+ text: `Error: ${error.message}\n\n${HELP_CENTER_IS_FOR_PEOPLE}`
744
+ }
745
+ ]
746
+ };
747
+ }
748
+ });
749
+ }
586
750
  if (allowedTools.includes('CLI') &&
587
751
  !disableTools?.includes('SearchWixCLIDocumentation')) {
588
752
  server.tool('SearchWixCLIDocumentation', getDescription('SearchWixCLIDocumentation', defaultToolDescriptions.SearchWixCLIDocumentation ?? ''), (() => {
@@ -601,7 +765,7 @@ export const addDocsTools = (server, allowedTools = [
601
765
  })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ searchTerm, maxResults, reason }, { panorama }) => {
602
766
  try {
603
767
  logger.log(`[SearchWixCLIDocumentation] searchTerm="${searchTerm}", reason="${reason}"`);
604
- const result = await runSemanticSearchAndFormat({
768
+ const result = await runSearch({
605
769
  toolName: 'CLI',
606
770
  toolParams: {
607
771
  searchTerm: searchTerm
@@ -642,9 +806,32 @@ export const addDocsTools = (server, allowedTools = [
642
806
  articleUrl: z.string().url().describe(d.articleUrl)
643
807
  };
644
808
  })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ articleUrl }, { httpClient }) => {
645
- // URL validation: known docs prefixes, or a Wix skills registry page
809
+ // A file with no docs page, such as a skill kept out of the public
810
+ // mirror, is linked as get-source-content and read from its repository.
811
+ const source = parseSourceContentUrl(articleUrl);
812
+ if (source) {
813
+ try {
814
+ const text = await fetchSourceContent(httpClient, source.repo, source.path, source.commitHash);
815
+ return { content: [{ type: 'text', text }] };
816
+ }
817
+ catch (error) {
818
+ logger.error(`Error fetching source content for ${articleUrl}: ${error}`);
819
+ return {
820
+ isError: true,
821
+ content: [
822
+ {
823
+ type: 'text',
824
+ text: formatDocsReadError('source content', error)
825
+ }
826
+ ]
827
+ };
828
+ }
829
+ }
830
+ // URL validation: known docs prefixes, a Help Center article
831
+ // (get-article-content reads support.wix.com/<locale>/article/<slug>),
832
+ // or a Wix skills registry page
646
833
  // (https://www.wix.com/skills/..., https://dev.wix.com/docs/skills/...).
647
- const validPrefixes = ['https://dev.wix.com/docs/'];
834
+ const validPrefixes = [...docsUrlPrefixes, 'https://support.wix.com/'];
648
835
  if (skillsPortalUrl)
649
836
  validPrefixes.push(skillsPortalUrl);
650
837
  const isSkillsPage = isSkillsRegistryUrl(articleUrl);
@@ -655,7 +842,7 @@ export const addDocsTools = (server, allowedTools = [
655
842
  content: [
656
843
  {
657
844
  type: 'text',
658
- text: `Invalid article URL: must start with https://dev.wix.com/docs/, or be a Wix skills page (https://www.wix.com/skills/..., https://www.wix.com/headless/...). Got: "${articleUrl}"`
845
+ text: `Invalid article URL: must start with https://dev.wix.com/docs/ or https://support.wix.com/, or be a Wix skills page (https://www.wix.com/skills/..., https://www.wix.com/headless/..., or that file's github.com/wix/skills source). Got: "${articleUrl}"`
659
846
  }
660
847
  ]
661
848
  };
@@ -668,6 +855,30 @@ export const addDocsTools = (server, allowedTools = [
668
855
  articleUrl.startsWith('https://dev.wix.com/docs/')) {
669
856
  articleUrl = articleUrl.replace(/\.md$/, '');
670
857
  }
858
+ // Mintlify docs: read the page from the Mintlify site when it has one,
859
+ // else fall through to today's backend with the dev.wix.com URL.
860
+ if (mintlifyDocs && !isSkillsPage) {
861
+ try {
862
+ const page = await readMintlifyMarkdown(articleUrl);
863
+ if (page) {
864
+ return {
865
+ content: [
866
+ {
867
+ type: 'text',
868
+ text: isQueryOrSearchEndpoint(page.url)
869
+ ? [page.markdown, ARTICLE_CAPABILITY_NOTE].join('\n\n')
870
+ : page.markdown
871
+ },
872
+ ...sourceNote(`Mintlify site: ${page.url}.md`)
873
+ ]
874
+ };
875
+ }
876
+ }
877
+ catch (error) {
878
+ logger.error(`[mintlify] reading ${articleUrl} from Mintlify failed, falling back: ${error}`);
879
+ }
880
+ articleUrl = toBackendUrl(articleUrl);
881
+ }
671
882
  try {
672
883
  const articleContent = await fetchArticleContent(httpClient, articleUrl, 'article', false, skillsPortalUrl, effectiveRepo, effectiveCommitHash);
673
884
  if (!articleContent) {
@@ -682,7 +893,10 @@ export const addDocsTools = (server, allowedTools = [
682
893
  text: isQueryOrSearchEndpoint(articleUrl)
683
894
  ? [articleContent, ARTICLE_CAPABILITY_NOTE].join('\n\n')
684
895
  : articleContent
685
- }
896
+ },
897
+ ...sourceNote(isSkillsPage
898
+ ? `skills registry: ${articleUrl}`
899
+ : `today's backend (dev.wix.com/rawdocs, ingvar), not on the Mintlify site: ${articleUrl}`)
686
900
  ]
687
901
  };
688
902
  }
@@ -707,6 +921,13 @@ export const addDocsTools = (server, allowedTools = [
707
921
  // menu fallback failed too — fall through to error below
708
922
  }
709
923
  }
924
+ if (getErrorMessage(error).includes('404') &&
925
+ !isKnownArticleError(error)) {
926
+ const nearest = await nearestToMissingPage(httpClient, articleUrl, isSkillsPage);
927
+ if (nearest) {
928
+ return { content: [{ type: 'text', text: nearest }] };
929
+ }
930
+ }
710
931
  return {
711
932
  isError: true,
712
933
  content: [
@@ -728,7 +949,7 @@ export const addDocsTools = (server, allowedTools = [
728
949
  };
729
950
  })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ articleUrl, reason }, { httpClient }) => {
730
951
  // URL validation: only allow known docs prefixes
731
- const validPrefixes = ['https://dev.wix.com/docs/'];
952
+ const validPrefixes = [...docsUrlPrefixes];
732
953
  if (skillsPortalUrl)
733
954
  validPrefixes.push(skillsPortalUrl);
734
955
  if (!validPrefixes.some((p) => articleUrl.startsWith(p))) {
@@ -746,18 +967,28 @@ export const addDocsTools = (server, allowedTools = [
746
967
  if (articleUrl.startsWith('https://dev.wix.com/docs/')) {
747
968
  articleUrl = articleUrl.replace(/\.md$/, '');
748
969
  }
970
+ // Mintlify docs: schemas stay on PAPI through ingvar, by dev.wix.com URL.
971
+ articleUrl = toBackendUrl(articleUrl);
749
972
  try {
750
973
  logger.log(`[ReadFullDocsMethodSchema] url="${articleUrl}", reason="${reason}"`);
751
974
  const articleContent = await fetchArticleContent(httpClient, articleUrl, 'methodSchema', false, skillsPortalUrl, effectiveRepo, effectiveCommitHash, true);
752
975
  if (!articleContent) {
753
976
  throw new Error('Method schema is empty');
754
977
  }
978
+ // Mintlify docs: the schema text links other methods on dev.wix.com;
979
+ // resolve those to their Mintlify pages, as in search results.
980
+ const schemaText = mintlifyDocs
981
+ ? (await rewriteDocsLinks(articleContent, {
982
+ label: 'schema ReadFullDocsMethodSchema'
983
+ })).text
984
+ : articleContent;
755
985
  return {
756
986
  content: [
757
987
  {
758
988
  type: 'text',
759
- text: articleContent
760
- }
989
+ text: schemaText
990
+ },
991
+ ...sourceNote(`PAPI, through today's backend (dev.wix.com/rawdocs, ingvar): ${articleUrl}`)
761
992
  ]
762
993
  };
763
994
  }
@@ -803,7 +1034,7 @@ export const addDocsTools = (server, allowedTools = [
803
1034
  };
804
1035
  })(), { readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ menuUrl, reason }, { httpClient }) => {
805
1036
  try {
806
- if (menuUrl && !menuUrl.startsWith('https://dev.wix.com/docs/')) {
1037
+ if (menuUrl && !docsUrlPrefixes.some((p) => menuUrl.startsWith(p))) {
807
1038
  return {
808
1039
  content: [
809
1040
  {
@@ -36,5 +36,26 @@ export declare function fetchRecipesIndex(): Promise<string>;
36
36
  */
37
37
  export declare function fetchArticle(articleUrl: string): Promise<string>;
38
38
  export declare function isSkillsRegistryUrl(url: string): boolean;
39
+ /**
40
+ * The forms of a skills URL agents hold that the registry serves under another
41
+ * name: wix.com without www (a 301 the fetch client does not follow), and the
42
+ * GitHub source of the same file. Both map to the www.wix.com/skills page.
43
+ */
44
+ export declare function normalizeSkillsUrl(url: string): string;
45
+ /**
46
+ * A file read from its source repository rather than the published docs, via
47
+ * the rawdocs get-source-content API (e.g. the management index as authored in
48
+ * wix-private/ax-skills). The API serves only the files it allows.
49
+ */
50
+ /**
51
+ * The repo and path a get-source-content URL names: what a file served from its
52
+ * source repository links a file that has no docs page to.
53
+ */
54
+ export declare function parseSourceContentUrl(url: string): {
55
+ repo: string;
56
+ path: string;
57
+ commitHash?: string;
58
+ } | undefined;
59
+ export declare function fetchSourceContent(httpClient: HttpClient, repo: string, path: string, commitHash?: string): Promise<string>;
39
60
  export declare function fetchArticleContent(httpClient: HttpClient, articleUrl: string, mode: 'article' | 'methodSchema' | 'raw', stripHeader?: boolean, skillsPortalUrl?: string, repo?: string, commitHash?: string, fetchMcpWhiteList?: boolean): Promise<string>;
40
61
  //# sourceMappingURL=fetch-article.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { HttpClient } from '@wix/http-client';
2
2
  import { logger } from '../infra/logger.js';
3
- import { GET_ARTICLE_CONTENT_URL } from '../constants.js';
3
+ import { GET_ARTICLE_CONTENT_URL, GET_SOURCE_CONTENT_URL } from '../constants.js';
4
4
  // ---------------------------------------------------------------------------
5
5
  // Public constants and utilities
6
6
  // ---------------------------------------------------------------------------
@@ -62,7 +62,22 @@ const SKILLS_REGISTRY_URL = new RegExp('^https://(?:dev\\.wix\\.com(?:/docs)?|ww
62
62
  // served as raw markdown like the registry, and read the same way.
63
63
  '|^https://www\\.wix\\.com/headless/');
64
64
  export function isSkillsRegistryUrl(url) {
65
- return SKILLS_REGISTRY_URL.test(url.trim());
65
+ return SKILLS_REGISTRY_URL.test(normalizeSkillsUrl(url));
66
+ }
67
+ // A GitHub view of the skills repository, as an installed plugin cross-references it:
68
+ // github.com/wix/skills/blob/<ref>/skills/<skill>/<path>, with or without a line anchor.
69
+ const GITHUB_SKILLS_URL = /^https:\/\/(?:www\.)?github\.com\/wix\/skills\/(?:blob|raw|tree)\/[^/]+\/skills\/([^#?]+)/;
70
+ /**
71
+ * The forms of a skills URL agents hold that the registry serves under another
72
+ * name: wix.com without www (a 301 the fetch client does not follow), and the
73
+ * GitHub source of the same file. Both map to the www.wix.com/skills page.
74
+ */
75
+ export function normalizeSkillsUrl(url) {
76
+ const apex = url
77
+ .trim()
78
+ .replace(/^https:\/\/wix\.com\//, 'https://www.wix.com/');
79
+ const gh = apex.match(GITHUB_SKILLS_URL);
80
+ return gh ? `https://www.wix.com/skills/${gh[1]}` : apex;
66
81
  }
67
82
  async function fetchSkillsRegistryPage(httpClient, url) {
68
83
  let data;
@@ -173,6 +188,53 @@ async function fetchArticleContentFromDigor(httpClient, articleUrl, mode, stripH
173
188
  }
174
189
  return articleContent;
175
190
  }
191
+ /**
192
+ * A file read from its source repository rather than the published docs, via
193
+ * the rawdocs get-source-content API (e.g. the management index as authored in
194
+ * wix-private/ax-skills). The API serves only the files it allows.
195
+ */
196
+ /**
197
+ * The repo and path a get-source-content URL names: what a file served from its
198
+ * source repository links a file that has no docs page to.
199
+ */
200
+ export function parseSourceContentUrl(url) {
201
+ let parsed;
202
+ try {
203
+ parsed = new URL(url);
204
+ }
205
+ catch {
206
+ return undefined;
207
+ }
208
+ if (`${parsed.origin}${parsed.pathname}` !== GET_SOURCE_CONTENT_URL) {
209
+ return undefined;
210
+ }
211
+ const repo = parsed.searchParams.get('repo');
212
+ const path = parsed.searchParams.get('path');
213
+ const commitHash = parsed.searchParams.get('commitHash');
214
+ if (!repo || !path)
215
+ return undefined;
216
+ return commitHash ? { repo, path, commitHash } : { repo, path };
217
+ }
218
+ export async function fetchSourceContent(httpClient, repo, path, commitHash) {
219
+ const url = new URL(GET_SOURCE_CONTENT_URL);
220
+ url.searchParams.set('repo', repo);
221
+ url.searchParams.set('path', path);
222
+ if (commitHash)
223
+ url.searchParams.set('commitHash', commitHash);
224
+ let data;
225
+ try {
226
+ ({ data } = await httpClient.get(url.toString()));
227
+ }
228
+ catch (error) {
229
+ const { message, status } = getHttpErrorDetails(error);
230
+ const statusSuffix = status ? ` (status ${status})` : '';
231
+ throw new Error(`${message}${statusSuffix}`);
232
+ }
233
+ if (!data?.content) {
234
+ throw new Error('Source content is empty');
235
+ }
236
+ return data.content;
237
+ }
176
238
  export async function fetchArticleContent(httpClient, articleUrl, mode, stripHeader = false, skillsPortalUrl, repo, commitHash, fetchMcpWhiteList) {
177
239
  // Apply portal URL override if configured
178
240
  const effectiveUrl = applyPortalUrlOverride(articleUrl, skillsPortalUrl);
@@ -190,12 +252,12 @@ export async function fetchArticleContent(httpClient, articleUrl, mode, stripHea
190
252
  // Fall through to the normal fetch for this URL: the registry for a
191
253
  // skills page (rawdocs cannot serve those), rawdocs otherwise.
192
254
  content = isSkillsRegistryUrl(articleUrl)
193
- ? await fetchSkillsRegistryPage(httpClient, articleUrl)
255
+ ? await fetchSkillsRegistryPage(httpClient, normalizeSkillsUrl(articleUrl))
194
256
  : await fetchArticleContentFromDigor(httpClient, articleUrl, mode, stripHeader);
195
257
  }
196
258
  }
197
259
  else if (isSkillsRegistryUrl(articleUrl)) {
198
- content = await fetchSkillsRegistryPage(httpClient, articleUrl);
260
+ content = await fetchSkillsRegistryPage(httpClient, normalizeSkillsUrl(articleUrl));
199
261
  }
200
262
  else if (mode === 'raw') {
201
263
  let parsedUrl;
@@ -28,14 +28,19 @@ export interface AddGetToKnowTools {
28
28
  repo?: string;
29
29
  commitHash?: string;
30
30
  skillsTags?: string[];
31
+ readmeRecipesIndexEnabled?: boolean;
32
+ /** The connection's docsSite (see ./mintlify-docs.ts): a Mintlify mode resolves the README's docs links. */
33
+ docsSite?: string;
31
34
  }
32
35
  interface AddGetSiteContextTool {
33
36
  server: WixMcpServer;
34
37
  authStrategy: McpAuthenticationStrategy;
35
38
  partnerContextEnabled?: boolean;
39
+ /** Render the site's companion app. Off by default: only Aria (via the toolkit) needs it. */
40
+ includeCompanionApp?: boolean;
36
41
  toolDescriptions?: Record<string, string>;
37
42
  disableTools?: string[];
38
43
  }
39
- export declare function addGetSiteContextTool({ server, authStrategy, toolDescriptions }: AddGetSiteContextTool): void;
40
- export declare function addGetToKnowTools({ server, disableTools, toolDescriptions, readmeDocs, authStrategy, skillsPortalUrl, dynamicContextEnabled, repo, commitHash, skillsTags }: AddGetToKnowTools): Promise<void>;
44
+ export declare function addGetSiteContextTool({ server, authStrategy, includeCompanionApp, toolDescriptions }: AddGetSiteContextTool): void;
45
+ export declare function addGetToKnowTools({ server, disableTools, toolDescriptions, readmeDocs, authStrategy, skillsPortalUrl, dynamicContextEnabled, repo, commitHash, skillsTags, readmeRecipesIndexEnabled, docsSite }: AddGetToKnowTools): Promise<void>;
41
46
  //# sourceMappingURL=get-to-know.d.ts.map